From 3a238b776d914e73f1618bc7f021df26e48885df Mon Sep 17 00:00:00 2001 From: David Luecke Date: Sun, 12 Jul 2015 16:40:25 -0600 Subject: [PATCH 01/11] Some updates to the frontpage and adding a couple of learn pages. --- _includes/navbar.html | 6 ++-- _layouts/index.html | 60 ++++++++++++++++----------------------- _layouts/quick-start.html | 28 ++++++------------ _less/feathers.less | 8 ++++-- css/feathers.min.css | 2 +- learn/authentication.md | 8 ++++++ learn/authorization.md | 8 ++++++ learn/mongodb.md | 36 +++++++++++++++++++++++ learn/validation.md | 8 ++++++ quick-start.md | 33 --------------------- 10 files changed, 104 insertions(+), 93 deletions(-) create mode 100644 learn/authentication.md create mode 100644 learn/authorization.md create mode 100644 learn/mongodb.md create mode 100644 learn/validation.md diff --git a/_includes/navbar.html b/_includes/navbar.html index 9fddf98b06..61108bddc9 100644 --- a/_includes/navbar.html +++ b/_includes/navbar.html @@ -4,20 +4,22 @@ {% for weight in (1..5) %} {% for p in site.pages %} {% if p.weight == weight %} + {% unless p.hide %}
  • {% if p.url == '/' %} + {% else %} {{ p.title }} {% endif %}
  • + {% endunless %} {% endif %} {% endfor %} {% endfor %} - \ No newline at end of file + diff --git a/_layouts/index.html b/_layouts/index.html index 9b03fedc31..f920b690f4 100644 --- a/_layouts/index.html +++ b/_layouts/index.html @@ -47,7 +47,7 @@

    Feathers is built for developers that need to ship maintainable code, get prototypes out in a matter of minutes and production ready in days. Seriously.

    - How is that even possible? We believe that less is more. So we built a razor thin wrapper (a few hundred lines of code) over top of Express and Socket.io, the defacto technologies for building real-time web applications using NodeJS. + How is that even possible? We believe that less is more. So we created a razor thin wrapper (a few hundred lines of code) over top of Express and Socket.io, the defacto technologies for building real-time web applications using NodeJS.

    At its core Feathers is a real-time, micro-service web framework that gives you control over your data via RESTful resources, sockets and flexible plug-ins. @@ -109,47 +109,37 @@

    We have plug-ins or guides for the most popular clients.

    -

    Here are just a few reasons why Feathers is quickly becoming the toolbox of choice for modern web applications.

    +

    + Feathers is a real-time framework where you don't have to + throw away the things you already learned or built... +

    -
    -

    Battle Tested Core

    -

    Feathers is a very thin wrapper over top of Express and Socket.io, both of which have been used in production by thousands of companies.

    -
    -
    -

    Uber Flexible

    -

    Our plug-ins are extremely flexible. Giving you only what you need and then getting out of your way.

    +
    +

    Pure JavaScript

    +

    Because Feathers is 100% vanilla JavaScript on the backend, you get to use the same language all the way through your web stack. Less context switching.

    -
    -

    Scaffold Real-time API's

    -

    Instantly scaffold services from the command line, providing you with full CRUD via REST and websockets in just a few key strokes.

    +
    +

    Express

    +

    Feathers is a very thin wrapper over top of Express and Socket.io and works as a drop-in replacement for Express in any existing application.

    -
    -

    Zero Lock In

    -

    Feathers is totally open source, works with any Express middleware and node module out of the box, and can be easily removed if it's not for you.

    +
    +

    Middleware

    +

    Use any Express middleware and Hooks, which follow the same pattern, for service data-processing and authorization that works via REST and websockets.

    -
    -

    Minimal Configuration

    -

    Tired of massive JSON or YAML files? No need for that here! We value convention over configuration so you can spend more time writing code.

    -
    -
    +

    Multi-Database

    -

    We support MongoDB, Postgres, and MySQL out of the box. If that's not for you, you can easily write your own service adapters and submit a PR.

    +

    We support MongoDB, Postgres, NeDB and MySQL out of the box. If that's not for you, you can easily write your own service adapters.

    -
    +

    Front End Agnostic

    -

    Use whatever client you want; Angular, React, Swift/ObjC, Android, it doesn't matter. We only provide some helpful guides and plug-ins to make things easier.

    -
    -
    -

    Pure JavaScript

    -

    Because Feathers is 100% vanilla JavaScript on the backend, you get to use the same language all the way through your web stack. Less context switching.

    +

    Use whatever client you want; Angular, React, Swift/ObjC, Android, it doesn't matter. A few lines of code can make your frontend real-time.

    -
    -
    -
    - Tell Me More +
    +

    Existing APIs

    +

    No need to re-write your existing API to go real-time. Feathers can act as a real-time proxy between other APIs and your frontend.

    @@ -165,7 +155,7 @@

    See How Feathers Is Different

    Feathers vs Meteor

    "Once you go Meteor, you don't go back. And not in a good way."

    - Meteor has amassed a large community and a lot of venture backed funding. Our biggest complaint is that because of this funding, there is some serious lock in. Meteor has it's own package system, how you use npm modules can be inconsistent, and there really is a lot of code for what it is doing. There is also the risk that when investors start pushing for a return on their investment, it could negatively impact the community. + Meteor has amassed a large community and a lot of venture backed funding. Our biggest complaint is that because of this funding, there is some serious lock in. Meteor has it's own package system, how you use npm modules can be inconsistent and it is a large codebase. There is also the risk that when investors start pushing for a return on their investment, it could negatively impact the community.

    From a feature standpoint Feathers is pretty similar to Meteor. You get real-time API's from both. However, we let you use the defacto npm for managing dependencies, we let you choose whether you want to use Webpack, Gulp, Grunt, or any other tool for managing assets, and Feathers is completely client agnostic without any additional overhead. Everything is open, flexible and pluggable. You use only what you need. @@ -184,7 +174,7 @@

    "If you love JSON config files, Sails is for you."
    From a feature standpoint Feathers and Sails are probably the closest. Both provide real-time REST API's, multiple db support, and are client agnostic. Both frameworks also wrap Express, but Feathers supports Express 4, while Sails only supports Express 3.

    - Even though they have feature parity, Feathers achieves this with MUCH less code, which means less stuff to break and maintain. We also don't assume how you want to manage your assets by letting you use your build tool of choice. Feathers provides lightweight services and hooks instead of a bulky ORM, and we let you write code instead of long config files to define relationships and security policies. + Even though the features are very similar, Feathers achieves this with MUCH less code, which means less stuff to break and maintain. We also don't assume how you want to manage your assets by letting you use your build tool of choice. Feathers provides lightweight services and hooks instead of a full-blown ORM, and we let you write code instead of long config files to define relationships and security policies.

    @@ -197,10 +187,10 @@
    "If you love JSON config files, Sails is for you."

    Feathers vs Express

    "I like Express because I love flexibility and boilerplate!"

    - Express is awesome! It does much of the heavy lifting behind Feathers; routing, content-negotiation, middleware support, etc. However, you still need to implement a lot yourself. + Express is awesome! It does much of the heavy lifting behind Feathers; routing, content-negotiation, middleware support, etc. In fact, you can simply replace Express with Feathers in any existing application and start adding your own microservices.

    - Feathers eliminates a lot of the common boilerplate and gives you helpful plug-ins to make implementing common features easily, while also providing some convention. This includes stuff like managing permissions, CRUD for multiple databases, and real-time APIs using web sockets. We give you just enough to build your web app quickly but get out of your way when you need to customize something. + Feathers eliminates a lot of the common boilerplate and gives you helpful plug-ins to make implementing common features easier, while also providing some convention. This includes stuff like managing permissions, CRUD for multiple databases, and real-time APIs using web sockets. Just like Express, Feathers gives you just enough to build your web app quickly but gets out of your way when you need to customize something.

    diff --git a/_layouts/quick-start.html b/_layouts/quick-start.html index 84b2540ec4..2e45a2b408 100644 --- a/_layouts/quick-start.html +++ b/_layouts/quick-start.html @@ -16,29 +16,17 @@
    -
    -
    -
    -
      -
      -
      - -
      - -
      +
      +
        +
        +
        +
        -
        -
        -
        -
        - Server - Client -
        - -
        -
        + +
        +
        diff --git a/_less/feathers.less b/_less/feathers.less index cb9847d57e..c11f2f3737 100644 --- a/_less/feathers.less +++ b/_less/feathers.less @@ -82,7 +82,7 @@ section { a { display: inline-block; - + img { height: 100px; max-width: 160px; @@ -116,6 +116,10 @@ section { border-bottom: 1px dashed darken(@soft-white, 10%); } } + + p { + text-align: justify; + } } #comparison { @@ -163,4 +167,4 @@ section { .primary-button { width: 100%; } -} \ No newline at end of file +} diff --git a/css/feathers.min.css b/css/feathers.min.css index 3fbf646b55..bdc4ac7886 100644 --- a/css/feathers.min.css +++ b/css/feathers.min.css @@ -1,4 +1,4 @@ .hll{background-color:#ffc}.c{color:#998;font-style:italic}.err{color:#a61717;background-color:#e3d2d2}.k{color:#000;font-weight:bold}.o{color:#000;font-weight:bold}.cm{color:#998;font-style:italic}.cp{color:#999;font-weight:bold;font-style:italic}.c1{color:#998;font-style:italic}.cs{color:#999;font-weight:bold;font-style:italic}.gd{color:#000;background-color:#fdd}.ge{color:#000;font-style:italic}.gr{color:#a00}.gh{color:#999}.gi{color:#000;background-color:#dfd}.go{color:#888}.gp{color:#555}.gs{font-weight:bold}.gu{color:#aaa}.gt{color:#a00}.kc{color:#000;font-weight:bold}.kd{color:#000;font-weight:bold}.kn{color:#000;font-weight:bold}.kp{color:#000;font-weight:bold}.kr{color:#000;font-weight:bold}.kt{color:#458;font-weight:bold}.m{color:#099}.s{color:#d01040}.na{color:#008080}.nb{color:#0086b3}.nc{color:#458;font-weight:bold}.no{color:#008080}.nd{color:#3c5d5d;font-weight:bold}.ni{color:#800080}.ne{color:#900;font-weight:bold}.nf{color:#900;font-weight:bold}.nl{color:#900;font-weight:bold}.nn{color:#555}.nt{color:#000080}.nv{color:#008080}.ow{color:#000;font-weight:bold}.w{color:#bbb}.mf{color:#099}.mh{color:#099}.mi{color:#099}.mo{color:#099}.sb{color:#d01040}.sc{color:#d01040}.sd{color:#d01040}.s2{color:#d01040}.se{color:#d01040}.sh{color:#d01040}.si{color:#d01040}.sx{color:#d01040}.sr{color:#009926}.s1{color:#d01040}.ss{color:#990073}.bp{color:#999}.vc{color:#008080}.vg{color:#008080}.vi{color:#008080}.il{color:#099}/*! * Font Awesome 4.3.0 by @davegandy - http://fontawesome.io - @fontawesome * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) - */@font-face{font-family:'FontAwesome';src:url('/fonts/fontawesome-webfont.eot?v=4.3.0');src:url('/fonts/fontawesome-webfont.eot?#iefix&v=4.3.0') format('embedded-opentype'),url('/fonts/fontawesome-webfont.woff2?v=4.3.0') format('woff2'),url('/fonts/fontawesome-webfont.woff?v=4.3.0') format('woff'),url('/fonts/fontawesome-webfont.ttf?v=4.3.0') format('truetype'),url('/fonts/fontawesome-webfont.svg?v=4.3.0#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;transform:translate(0,0)}.fa-lg{font-size:1.3333333333333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.2857142857142858em;text-align:center}.fa-ul{padding-left:0;margin-left:2.142857142857143em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.142857142857143em;width:2.142857142857143em;top:.14285714285714285em;text-align:center}.fa-li.fa-lg{left:-1.8571428571428572em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2);-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=0,mirror=1);-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.fa-flip-vertical{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2,mirror=1);-webkit-transform:scale(1,-1);-ms-transform:scale(1,-1);transform:scale(1,-1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-remove:before,.fa-close:before,.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook-f:before,.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{content:"\f09c"}.fa-credit-card:before{content:"\f09d"}.fa-rss:before{content:"\f09e"}.fa-hdd-o:before{content:"\f0a0"}.fa-bullhorn:before{content:"\f0a1"}.fa-bell:before{content:"\f0f3"}.fa-certificate:before{content:"\f0a3"}.fa-hand-o-right:before{content:"\f0a4"}.fa-hand-o-left:before{content:"\f0a5"}.fa-hand-o-up:before{content:"\f0a6"}.fa-hand-o-down:before{content:"\f0a7"}.fa-arrow-circle-left:before{content:"\f0a8"}.fa-arrow-circle-right:before{content:"\f0a9"}.fa-arrow-circle-up:before{content:"\f0aa"}.fa-arrow-circle-down:before{content:"\f0ab"}.fa-globe:before{content:"\f0ac"}.fa-wrench:before{content:"\f0ad"}.fa-tasks:before{content:"\f0ae"}.fa-filter:before{content:"\f0b0"}.fa-briefcase:before{content:"\f0b1"}.fa-arrows-alt:before{content:"\f0b2"}.fa-group:before,.fa-users:before{content:"\f0c0"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-cloud:before{content:"\f0c2"}.fa-flask:before{content:"\f0c3"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-copy:before,.fa-files-o:before{content:"\f0c5"}.fa-paperclip:before{content:"\f0c6"}.fa-save:before,.fa-floppy-o:before{content:"\f0c7"}.fa-square:before{content:"\f0c8"}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:"\f0c9"}.fa-list-ul:before{content:"\f0ca"}.fa-list-ol:before{content:"\f0cb"}.fa-strikethrough:before{content:"\f0cc"}.fa-underline:before{content:"\f0cd"}.fa-table:before{content:"\f0ce"}.fa-magic:before{content:"\f0d0"}.fa-truck:before{content:"\f0d1"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-google-plus-square:before{content:"\f0d4"}.fa-google-plus:before{content:"\f0d5"}.fa-money:before{content:"\f0d6"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-columns:before{content:"\f0db"}.fa-unsorted:before,.fa-sort:before{content:"\f0dc"}.fa-sort-down:before,.fa-sort-desc:before{content:"\f0dd"}.fa-sort-up:before,.fa-sort-asc:before{content:"\f0de"}.fa-envelope:before{content:"\f0e0"}.fa-linkedin:before{content:"\f0e1"}.fa-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-legal:before,.fa-gavel:before{content:"\f0e3"}.fa-dashboard:before,.fa-tachometer:before{content:"\f0e4"}.fa-comment-o:before{content:"\f0e5"}.fa-comments-o:before{content:"\f0e6"}.fa-flash:before,.fa-bolt:before{content:"\f0e7"}.fa-sitemap:before{content:"\f0e8"}.fa-umbrella:before{content:"\f0e9"}.fa-paste:before,.fa-clipboard:before{content:"\f0ea"}.fa-lightbulb-o:before{content:"\f0eb"}.fa-exchange:before{content:"\f0ec"}.fa-cloud-download:before{content:"\f0ed"}.fa-cloud-upload:before{content:"\f0ee"}.fa-user-md:before{content:"\f0f0"}.fa-stethoscope:before{content:"\f0f1"}.fa-suitcase:before{content:"\f0f2"}.fa-bell-o:before{content:"\f0a2"}.fa-coffee:before{content:"\f0f4"}.fa-cutlery:before{content:"\f0f5"}.fa-file-text-o:before{content:"\f0f6"}.fa-building-o:before{content:"\f0f7"}.fa-hospital-o:before{content:"\f0f8"}.fa-ambulance:before{content:"\f0f9"}.fa-medkit:before{content:"\f0fa"}.fa-fighter-jet:before{content:"\f0fb"}.fa-beer:before{content:"\f0fc"}.fa-h-square:before{content:"\f0fd"}.fa-plus-square:before{content:"\f0fe"}.fa-angle-double-left:before{content:"\f100"}.fa-angle-double-right:before{content:"\f101"}.fa-angle-double-up:before{content:"\f102"}.fa-angle-double-down:before{content:"\f103"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}.fa-angle-up:before{content:"\f106"}.fa-angle-down:before{content:"\f107"}.fa-desktop:before{content:"\f108"}.fa-laptop:before{content:"\f109"}.fa-tablet:before{content:"\f10a"}.fa-mobile-phone:before,.fa-mobile:before{content:"\f10b"}.fa-circle-o:before{content:"\f10c"}.fa-quote-left:before{content:"\f10d"}.fa-quote-right:before{content:"\f10e"}.fa-spinner:before{content:"\f110"}.fa-circle:before{content:"\f111"}.fa-mail-reply:before,.fa-reply:before{content:"\f112"}.fa-github-alt:before{content:"\f113"}.fa-folder-o:before{content:"\f114"}.fa-folder-open-o:before{content:"\f115"}.fa-smile-o:before{content:"\f118"}.fa-frown-o:before{content:"\f119"}.fa-meh-o:before{content:"\f11a"}.fa-gamepad:before{content:"\f11b"}.fa-keyboard-o:before{content:"\f11c"}.fa-flag-o:before{content:"\f11d"}.fa-flag-checkered:before{content:"\f11e"}.fa-terminal:before{content:"\f120"}.fa-code:before{content:"\f121"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"\f122"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"\f123"}.fa-location-arrow:before{content:"\f124"}.fa-crop:before{content:"\f125"}.fa-code-fork:before{content:"\f126"}.fa-unlink:before,.fa-chain-broken:before{content:"\f127"}.fa-question:before{content:"\f128"}.fa-info:before{content:"\f129"}.fa-exclamation:before{content:"\f12a"}.fa-superscript:before{content:"\f12b"}.fa-subscript:before{content:"\f12c"}.fa-eraser:before{content:"\f12d"}.fa-puzzle-piece:before{content:"\f12e"}.fa-microphone:before{content:"\f130"}.fa-microphone-slash:before{content:"\f131"}.fa-shield:before{content:"\f132"}.fa-calendar-o:before{content:"\f133"}.fa-fire-extinguisher:before{content:"\f134"}.fa-rocket:before{content:"\f135"}.fa-maxcdn:before{content:"\f136"}.fa-chevron-circle-left:before{content:"\f137"}.fa-chevron-circle-right:before{content:"\f138"}.fa-chevron-circle-up:before{content:"\f139"}.fa-chevron-circle-down:before{content:"\f13a"}.fa-html5:before{content:"\f13b"}.fa-css3:before{content:"\f13c"}.fa-anchor:before{content:"\f13d"}.fa-unlock-alt:before{content:"\f13e"}.fa-bullseye:before{content:"\f140"}.fa-ellipsis-h:before{content:"\f141"}.fa-ellipsis-v:before{content:"\f142"}.fa-rss-square:before{content:"\f143"}.fa-play-circle:before{content:"\f144"}.fa-ticket:before{content:"\f145"}.fa-minus-square:before{content:"\f146"}.fa-minus-square-o:before{content:"\f147"}.fa-level-up:before{content:"\f148"}.fa-level-down:before{content:"\f149"}.fa-check-square:before{content:"\f14a"}.fa-pencil-square:before{content:"\f14b"}.fa-external-link-square:before{content:"\f14c"}.fa-share-square:before{content:"\f14d"}.fa-compass:before{content:"\f14e"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"\f150"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"\f151"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"\f152"}.fa-euro:before,.fa-eur:before{content:"\f153"}.fa-gbp:before{content:"\f154"}.fa-dollar:before,.fa-usd:before{content:"\f155"}.fa-rupee:before,.fa-inr:before{content:"\f156"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"\f157"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"\f158"}.fa-won:before,.fa-krw:before{content:"\f159"}.fa-bitcoin:before,.fa-btc:before{content:"\f15a"}.fa-file:before{content:"\f15b"}.fa-file-text:before{content:"\f15c"}.fa-sort-alpha-asc:before{content:"\f15d"}.fa-sort-alpha-desc:before{content:"\f15e"}.fa-sort-amount-asc:before{content:"\f160"}.fa-sort-amount-desc:before{content:"\f161"}.fa-sort-numeric-asc:before{content:"\f162"}.fa-sort-numeric-desc:before{content:"\f163"}.fa-thumbs-up:before{content:"\f164"}.fa-thumbs-down:before{content:"\f165"}.fa-youtube-square:before{content:"\f166"}.fa-youtube:before{content:"\f167"}.fa-xing:before{content:"\f168"}.fa-xing-square:before{content:"\f169"}.fa-youtube-play:before{content:"\f16a"}.fa-dropbox:before{content:"\f16b"}.fa-stack-overflow:before{content:"\f16c"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-adn:before{content:"\f170"}.fa-bitbucket:before{content:"\f171"}.fa-bitbucket-square:before{content:"\f172"}.fa-tumblr:before{content:"\f173"}.fa-tumblr-square:before{content:"\f174"}.fa-long-arrow-down:before{content:"\f175"}.fa-long-arrow-up:before{content:"\f176"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-apple:before{content:"\f179"}.fa-windows:before{content:"\f17a"}.fa-android:before{content:"\f17b"}.fa-linux:before{content:"\f17c"}.fa-dribbble:before{content:"\f17d"}.fa-skype:before{content:"\f17e"}.fa-foursquare:before{content:"\f180"}.fa-trello:before{content:"\f181"}.fa-female:before{content:"\f182"}.fa-male:before{content:"\f183"}.fa-gittip:before,.fa-gratipay:before{content:"\f184"}.fa-sun-o:before{content:"\f185"}.fa-moon-o:before{content:"\f186"}.fa-archive:before{content:"\f187"}.fa-bug:before{content:"\f188"}.fa-vk:before{content:"\f189"}.fa-weibo:before{content:"\f18a"}.fa-renren:before{content:"\f18b"}.fa-pagelines:before{content:"\f18c"}.fa-stack-exchange:before{content:"\f18d"}.fa-arrow-circle-o-right:before{content:"\f18e"}.fa-arrow-circle-o-left:before{content:"\f190"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:"\f191"}.fa-dot-circle-o:before{content:"\f192"}.fa-wheelchair:before{content:"\f193"}.fa-vimeo-square:before{content:"\f194"}.fa-turkish-lira:before,.fa-try:before{content:"\f195"}.fa-plus-square-o:before{content:"\f196"}.fa-space-shuttle:before{content:"\f197"}.fa-slack:before{content:"\f198"}.fa-envelope-square:before{content:"\f199"}.fa-wordpress:before{content:"\f19a"}.fa-openid:before{content:"\f19b"}.fa-institution:before,.fa-bank:before,.fa-university:before{content:"\f19c"}.fa-mortar-board:before,.fa-graduation-cap:before{content:"\f19d"}.fa-yahoo:before{content:"\f19e"}.fa-google:before{content:"\f1a0"}.fa-reddit:before{content:"\f1a1"}.fa-reddit-square:before{content:"\f1a2"}.fa-stumbleupon-circle:before{content:"\f1a3"}.fa-stumbleupon:before{content:"\f1a4"}.fa-delicious:before{content:"\f1a5"}.fa-digg:before{content:"\f1a6"}.fa-pied-piper:before{content:"\f1a7"}.fa-pied-piper-alt:before{content:"\f1a8"}.fa-drupal:before{content:"\f1a9"}.fa-joomla:before{content:"\f1aa"}.fa-language:before{content:"\f1ab"}.fa-fax:before{content:"\f1ac"}.fa-building:before{content:"\f1ad"}.fa-child:before{content:"\f1ae"}.fa-paw:before{content:"\f1b0"}.fa-spoon:before{content:"\f1b1"}.fa-cube:before{content:"\f1b2"}.fa-cubes:before{content:"\f1b3"}.fa-behance:before{content:"\f1b4"}.fa-behance-square:before{content:"\f1b5"}.fa-steam:before{content:"\f1b6"}.fa-steam-square:before{content:"\f1b7"}.fa-recycle:before{content:"\f1b8"}.fa-automobile:before,.fa-car:before{content:"\f1b9"}.fa-cab:before,.fa-taxi:before{content:"\f1ba"}.fa-tree:before{content:"\f1bb"}.fa-spotify:before{content:"\f1bc"}.fa-deviantart:before{content:"\f1bd"}.fa-soundcloud:before{content:"\f1be"}.fa-database:before{content:"\f1c0"}.fa-file-pdf-o:before{content:"\f1c1"}.fa-file-word-o:before{content:"\f1c2"}.fa-file-excel-o:before{content:"\f1c3"}.fa-file-powerpoint-o:before{content:"\f1c4"}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:"\f1c5"}.fa-file-zip-o:before,.fa-file-archive-o:before{content:"\f1c6"}.fa-file-sound-o:before,.fa-file-audio-o:before{content:"\f1c7"}.fa-file-movie-o:before,.fa-file-video-o:before{content:"\f1c8"}.fa-file-code-o:before{content:"\f1c9"}.fa-vine:before{content:"\f1ca"}.fa-codepen:before{content:"\f1cb"}.fa-jsfiddle:before{content:"\f1cc"}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:"\f1cd"}.fa-circle-o-notch:before{content:"\f1ce"}.fa-ra:before,.fa-rebel:before{content:"\f1d0"}.fa-ge:before,.fa-empire:before{content:"\f1d1"}.fa-git-square:before{content:"\f1d2"}.fa-git:before{content:"\f1d3"}.fa-hacker-news:before{content:"\f1d4"}.fa-tencent-weibo:before{content:"\f1d5"}.fa-qq:before{content:"\f1d6"}.fa-wechat:before,.fa-weixin:before{content:"\f1d7"}.fa-send:before,.fa-paper-plane:before{content:"\f1d8"}.fa-send-o:before,.fa-paper-plane-o:before{content:"\f1d9"}.fa-history:before{content:"\f1da"}.fa-genderless:before,.fa-circle-thin:before{content:"\f1db"}.fa-header:before{content:"\f1dc"}.fa-paragraph:before{content:"\f1dd"}.fa-sliders:before{content:"\f1de"}.fa-share-alt:before{content:"\f1e0"}.fa-share-alt-square:before{content:"\f1e1"}.fa-bomb:before{content:"\f1e2"}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:"\f1e3"}.fa-tty:before{content:"\f1e4"}.fa-binoculars:before{content:"\f1e5"}.fa-plug:before{content:"\f1e6"}.fa-slideshare:before{content:"\f1e7"}.fa-twitch:before{content:"\f1e8"}.fa-yelp:before{content:"\f1e9"}.fa-newspaper-o:before{content:"\f1ea"}.fa-wifi:before{content:"\f1eb"}.fa-calculator:before{content:"\f1ec"}.fa-paypal:before{content:"\f1ed"}.fa-google-wallet:before{content:"\f1ee"}.fa-cc-visa:before{content:"\f1f0"}.fa-cc-mastercard:before{content:"\f1f1"}.fa-cc-discover:before{content:"\f1f2"}.fa-cc-amex:before{content:"\f1f3"}.fa-cc-paypal:before{content:"\f1f4"}.fa-cc-stripe:before{content:"\f1f5"}.fa-bell-slash:before{content:"\f1f6"}.fa-bell-slash-o:before{content:"\f1f7"}.fa-trash:before{content:"\f1f8"}.fa-copyright:before{content:"\f1f9"}.fa-at:before{content:"\f1fa"}.fa-eyedropper:before{content:"\f1fb"}.fa-paint-brush:before{content:"\f1fc"}.fa-birthday-cake:before{content:"\f1fd"}.fa-area-chart:before{content:"\f1fe"}.fa-pie-chart:before{content:"\f200"}.fa-line-chart:before{content:"\f201"}.fa-lastfm:before{content:"\f202"}.fa-lastfm-square:before{content:"\f203"}.fa-toggle-off:before{content:"\f204"}.fa-toggle-on:before{content:"\f205"}.fa-bicycle:before{content:"\f206"}.fa-bus:before{content:"\f207"}.fa-ioxhost:before{content:"\f208"}.fa-angellist:before{content:"\f209"}.fa-cc:before{content:"\f20a"}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:"\f20b"}.fa-meanpath:before{content:"\f20c"}.fa-buysellads:before{content:"\f20d"}.fa-connectdevelop:before{content:"\f20e"}.fa-dashcube:before{content:"\f210"}.fa-forumbee:before{content:"\f211"}.fa-leanpub:before{content:"\f212"}.fa-sellsy:before{content:"\f213"}.fa-shirtsinbulk:before{content:"\f214"}.fa-simplybuilt:before{content:"\f215"}.fa-skyatlas:before{content:"\f216"}.fa-cart-plus:before{content:"\f217"}.fa-cart-arrow-down:before{content:"\f218"}.fa-diamond:before{content:"\f219"}.fa-ship:before{content:"\f21a"}.fa-user-secret:before{content:"\f21b"}.fa-motorcycle:before{content:"\f21c"}.fa-street-view:before{content:"\f21d"}.fa-heartbeat:before{content:"\f21e"}.fa-venus:before{content:"\f221"}.fa-mars:before{content:"\f222"}.fa-mercury:before{content:"\f223"}.fa-transgender:before{content:"\f224"}.fa-transgender-alt:before{content:"\f225"}.fa-venus-double:before{content:"\f226"}.fa-mars-double:before{content:"\f227"}.fa-venus-mars:before{content:"\f228"}.fa-mars-stroke:before{content:"\f229"}.fa-mars-stroke-v:before{content:"\f22a"}.fa-mars-stroke-h:before{content:"\f22b"}.fa-neuter:before{content:"\f22c"}.fa-facebook-official:before{content:"\f230"}.fa-pinterest-p:before{content:"\f231"}.fa-whatsapp:before{content:"\f232"}.fa-server:before{content:"\f233"}.fa-user-plus:before{content:"\f234"}.fa-user-times:before{content:"\f235"}.fa-hotel:before,.fa-bed:before{content:"\f236"}.fa-viacoin:before{content:"\f237"}.fa-train:before{content:"\f238"}.fa-subway:before{content:"\f239"}.fa-medium:before{content:"\f23a"}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}html,button,input,select,textarea{font-family:sans-serif}body,form,fieldset,legend,input,select,textarea,button{margin:0}html{font-size:100%}body{font-family:sans-serif;font-size:16px;font-size:1rem;line-height:21px;line-height:1.3125rem;color:#434343;background-color:#fff;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}b,strong{font-weight:700}i,em,.em{font-style:italic}a{color:#669fcf}a:hover{text-decoration:none}a:focus{outline:0}a:active,a:hover{outline:0}p{margin:0 0 1.6em 0}pre{margin:1em 0}ul+p,ul+pre,ol+p,ol+pre{margin-top:0}small{font-size:80%}abbr[title]{border-bottom:1px dotted}audio,canvas,video{display:inline-block;*zoom:1;*display:inline}audio:not([controls]){display:none;height:0}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}dfn{font-style:italic}img{border:0;-ms-interpolation-mode:bicubic}svg:not(:root){overflow:hidden}figure{margin:0}.image-left{margin-right:20px}.image-right{margin-left:20px}h1,h2,h3,h4,h5,h6{line-height:normal;font-weight:normal;margin:0 0 .33em 0}h1,.h1{font-size:40px;font-size:2.5rem}h2,.h2{font-size:32px;font-size:2rem}h3,.h3{font-size:26px;font-size:1.625rem}h4,.h4{font-size:20px;font-size:1.25rem}h5,.h5{font-size:18px;font-size:1.125rem}h6,.h6{font-size:16px;font-size:1rem}.no-style-heading{margin:0;font-size:100%}hr{border:0;background:0;outline:0;background-color:#ddd;margin:2em 0;*margin:1em 0;-moz-box-sizing:content-box;box-sizing:content-box;height:1px}blockquote{font-size:22px;font-size:1.375rem;line-height:32px;line-height:2rem;color:#434343;margin:1em 0;font-style:italic}blockquote p{margin:1em 0}cite{color:#434343;font-style:normal;font-weight:normal;font-size:16px;font-size:1rem;line-height:normal}q{font-style:italic;quotes:none}q:before,q:after{content:'';content:none}mark{background:#ff0;color:#111}code,kbd,pre,samp{word-wrap:break-word;font-family:'courier new',monospace,serif;font-size:13px;font-size:.8125rem;line-height:normal;font-weight:normal;background-color:#f1f1f1;padding:10px}code{color:#111}dl,menu,ol,ul{margin:1em 0}dd,ul ul,ol ol,ul ol,ol ul{margin:0}dt{font-weight:normal}dd{margin-bottom:1em}menu,ol,ul{padding:0 0 0 22px}nav ul,nav ol{list-style:none;list-style-image:none}.unstyled-list{list-style:none;padding:0;margin:0}.unstyled-list li{margin-top:0;margin-bottom:0}.inline-list{list-style:none;padding:0;margin:0;display:inline-block;*zoom:1;*display:inline}.inline-list li{margin-top:0;margin-bottom:0}.inline-list li{display:inline-block;*zoom:1;*display:inline}table{width:100%;margin:1em 0;table-layout:fixed;border-collapse:collapse;border-spacing:0;border-right:1px solid #f1f1f1;border-bottom:1px solid #f1f1f1;word-wrap:break-word;-ms-word-wrap:break-word;*white-space:normal}table th,table td{padding:8px;text-align:left;vertical-align:top;border-top:1px solid #eee;border-left:1px solid #eee}table thead th,table tfoot th{vertical-align:bottom;font-weight:normal;background-color:#f1f1f1;color:#333}table caption{padding:8px;font-style:normal;text-align:left;font-weight:normal;border-bottom:0}fieldset{border:0;padding:0}legend{border:0;padding:0;white-space:normal;*margin-left:-7px;font-weight:normal}label{margin:0;cursor:pointer}button,input,select,textarea{font-size:100%;vertical-align:baseline;*vertical-align:middle}input[type=text],input[type=password],input[type=email],input[type=search],input[type=tel],textarea{padding:5px;-webkit-appearance:none;-moz-appearance:none;font-weight:normal;line-height:normal;background-color:#fff;border:1px solid #ccc;color:#111}input[type=checkbox],input[type=radio]{cursor:pointer;box-sizing:border-box;line-height:normal;margin:0;padding:0;*height:13px;*width:13px}.checkbox{display:block;margin:.2em 0}.checkbox input[type=checkbox],.checkbox input[type=radio]{margin-top:.05em;float:left}.checkbox label{padding-left:5px;overflow:hidden;display:table;*zoom:1}button,input{line-height:normal}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer;*overflow:visible}button[disabled],html input[disabled]{cursor:default}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top;resize:none}.button{border:0;padding:1em 3em;background-color:#e74b3c;color:#fff;text-decoration:none;text-align:center;display:inline-block;*zoom:1;*display:inline;position:relative}.button:hover{background-color:#fc5547}.button:active{top:1px}.grey-button{background-color:#eee;color:#434343}.grey-button:hover{background-color:#f1f1f1}.button[disabled],.button.disabled{color:#999;background-color:#f1f1f1}.unstyled-button{font-size:16px;font-size:1rem;color:#27ae61;text-decoration:underline;border:0;background:transparent;height:auto;padding:0;cursor:pointer;outline:0}.unstyled-button:hover{text-decoration:none}.unstyled-button[disabled],.unstyled-button.disabled{text-decoration:none;color:#999;background-color:#ccc}.section{position:relative}.container{max-width:960px;margin-left:auto;margin-right:auto;padding-left:10px;padding-right:10px}.container-full{max-width:960px;margin-left:auto;margin-right:auto}.col{float:left;padding-left:10px;padding-right:10px}[class*="pull-"],[class*="push-"]{position:relative}.no-gutter{padding-left:0;padding-right:0}.col-1{width:8.33333%;width:calc(8.333333333333334%);width:-webkit-calc(8.333333333333334%);width:-moz-calc(8.333333333333334%)}.col-2{width:16.66667%;width:calc(16.666666666666668%);width:-webkit-calc(16.666666666666668%);width:-moz-calc(16.666666666666668%)}.col-3{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.col-4{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.col-5{width:41.66665%;width:calc(41.66666666666667%);width:-webkit-calc(41.66666666666667%);width:-moz-calc(41.66666666666667%)}.col-6{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.col-7{width:58.33333%;width:calc(58.333333333333336%);width:-webkit-calc(58.333333333333336%);width:-moz-calc(58.333333333333336%)}.col-8{width:66.66666%;width:calc(66.66666666666667%);width:-webkit-calc(66.66666666666667%);width:-moz-calc(66.66666666666667%)}.col-9{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.col-10{width:83.33333%;width:calc(83.33333333333334%);width:-webkit-calc(83.33333333333334%);width:-moz-calc(83.33333333333334%)}.col-11{width:91.66666%;width:calc(91.66666666666667%);width:-webkit-calc(91.66666666666667%);width:-moz-calc(91.66666666666667%)}.col-12{width:100%}.col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.push-1{left:8.33333%;left:calc(8.333333333333334%);left:-webkit-calc(8.333333333333334%);left:-moz-calc(8.333333333333334%)}.pull-1{left:-8.33333%;left:calc(-8.333333333333334%);left:-webkit-calc(-8.333333333333334%);left:-moz-calc(-8.333333333333334%)}.push-2{left:16.66667%;left:calc(16.666666666666668%);left:-webkit-calc(16.666666666666668%);left:-moz-calc(16.666666666666668%)}.pull-2{left:-16.66667%;left:calc(-16.666666666666668%);left:-webkit-calc(-16.666666666666668%);left:-moz-calc(-16.666666666666668%)}.push-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.pull-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.push-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.pull-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.push-5{left:41.66665%;left:calc(41.66666666666667%);left:-webkit-calc(41.66666666666667%);left:-moz-calc(41.66666666666667%)}.pull-5{left:-41.66665%;left:calc(-41.66666666666667%);left:-webkit-calc(-41.66666666666667%);left:-moz-calc(-41.66666666666667%)}.push-6{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.pull-6{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.push-7{left:58.33333%;left:calc(58.333333333333336%);left:-webkit-calc(58.333333333333336%);left:-moz-calc(58.333333333333336%)}.pull-7{left:-58.33333%;left:calc(-58.333333333333336%);left:-webkit-calc(-58.333333333333336%);left:-moz-calc(-58.333333333333336%)}.push-8{left:66.66666%;left:calc(66.66666666666667%);left:-webkit-calc(66.66666666666667%);left:-moz-calc(66.66666666666667%)}.pull-8{left:-66.66666%;left:calc(-66.66666666666667%);left:-webkit-calc(-66.66666666666667%);left:-moz-calc(-66.66666666666667%)}.push-9{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.pull-9{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.push-10{left:83.33333%;left:calc(83.33333333333334%);left:-webkit-calc(83.33333333333334%);left:-moz-calc(83.33333333333334%)}.pull-10{left:-83.33333%;left:calc(-83.33333333333334%);left:-webkit-calc(-83.33333333333334%);left:-moz-calc(-83.33333333333334%)}.push-11{left:91.66666%;left:calc(91.66666666666667%);left:-webkit-calc(91.66666666666667%);left:-moz-calc(91.66666666666667%)}.pull-11{left:-91.66666%;left:calc(-91.66666666666667%);left:-webkit-calc(-91.66666666666667%);left:-moz-calc(-91.66666666666667%)}.row{padding-top:1em;padding-bottom:1em}.clear:before,.clear:after{content:"";display:table}.clear:after{clear:both}.clear{zoom:1}.left{float:left}.right{float:right}.block{display:block}.inline{display:inline}.inline-block{display:inline-block;*zoom:1;*display:inline}.none,.hidden,[hidden],.no-desktop{display:none}.heavy{font-weight:900}.strong{font-weight:700}.normal{font-weight:normal}.thin{font-weight:300}.fine{font-weight:100}.italic{font-style:italic}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.left-text{text-align:left}.right-text{text-align:right}.center-text{text-align:center}.justify-text{text-align:justify}.visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;overflow:hidden;padding:0;position:absolute;width:1px;left:-9999em}.visuallyvisible{clip:auto;width:auto;height:auto;overflow:visible;left:0}.no-margin{margin:0}.no-padding{padding:0}@media only screen and (min-width:740px) and (max-width:960px){.container,.tablet-container{max-width:960px;padding-left:20px;padding-right:20px;margin-left:auto;margin-right:auto;float:none}.container:first-child,.tablet-container:first-child{margin-left:auto}.tablet-container-full{padding-left:0;padding-right:0;margin-left:auto;margin-right:auto;float:none}.tablet-container-full:first-child{margin-left:auto}.tablet-no-gutter{padding-left:0;padding-right:0}.tablet-col-1{width:8.33333%;width:calc(8.333333333333334%);width:-webkit-calc(8.333333333333334%);width:-moz-calc(8.333333333333334%)}.tablet-col-2{width:16.66667%;width:calc(16.666666666666668%);width:-webkit-calc(16.666666666666668%);width:-moz-calc(16.666666666666668%)}.tablet-col-3{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.tablet-col-4{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.tablet-col-5{width:41.66665%;width:calc(41.66666666666667%);width:-webkit-calc(41.66666666666667%);width:-moz-calc(41.66666666666667%)}.tablet-col-6{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.tablet-col-7{width:58.33333%;width:calc(58.333333333333336%);width:-webkit-calc(58.333333333333336%);width:-moz-calc(58.333333333333336%)}.tablet-col-8{width:66.66666%;width:calc(66.66666666666667%);width:-webkit-calc(66.66666666666667%);width:-moz-calc(66.66666666666667%)}.tablet-col-9{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.tablet-col-10{width:83.33333%;width:calc(83.33333333333334%);width:-webkit-calc(83.33333333333334%);width:-moz-calc(83.33333333333334%)}.tablet-col-11{width:91.66666%;width:calc(91.66666666666667%);width:-webkit-calc(91.66666666666667%);width:-moz-calc(91.66666666666667%)}.tablet-col-12{width:100%}.tablet-col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.tablet-col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.tablet-col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.tablet-col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.tablet-push-1{left:8.33333%;left:calc(8.333333333333334%);left:-webkit-calc(8.333333333333334%);left:-moz-calc(8.333333333333334%)}.tablet-pull-1{left:-8.33333%;left:calc(-8.333333333333334%);left:-webkit-calc(-8.333333333333334%);left:-moz-calc(-8.333333333333334%)}.tablet-push-2{left:16.66667%;left:calc(16.666666666666668%);left:-webkit-calc(16.666666666666668%);left:-moz-calc(16.666666666666668%)}.tablet-pull-2{left:-16.66667%;left:calc(-16.666666666666668%);left:-webkit-calc(-16.666666666666668%);left:-moz-calc(-16.666666666666668%)}.tablet-push-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.tablet-pull-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.tablet-push-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.tablet-pull-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.tablet-push-5{left:41.66665%;left:calc(41.66666666666667%);left:-webkit-calc(41.66666666666667%);left:-moz-calc(41.66666666666667%)}.tablet-pull-5{left:-41.66665%;left:calc(-41.66666666666667%);left:-webkit-calc(-41.66666666666667%);left:-moz-calc(-41.66666666666667%)}.tablet-push-6{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.tablet-pull-6{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.tablet-push-7{left:58.33333%;left:calc(58.333333333333336%);left:-webkit-calc(58.333333333333336%);left:-moz-calc(58.333333333333336%)}.tablet-pull-7{left:-58.33333%;left:calc(-58.333333333333336%);left:-webkit-calc(-58.333333333333336%);left:-moz-calc(-58.333333333333336%)}.tablet-push-8{left:66.66666%;left:calc(66.66666666666667%);left:-webkit-calc(66.66666666666667%);left:-moz-calc(66.66666666666667%)}.tablet-pull-8{left:-66.66666%;left:calc(-66.66666666666667%);left:-webkit-calc(-66.66666666666667%);left:-moz-calc(-66.66666666666667%)}.tablet-push-9{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.tablet-pull-9{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.tablet-push-10{left:83.33333%;left:calc(83.33333333333334%);left:-webkit-calc(83.33333333333334%);left:-moz-calc(83.33333333333334%)}.tablet-pull-10{left:-83.33333%;left:calc(-83.33333333333334%);left:-webkit-calc(-83.33333333333334%);left:-moz-calc(-83.33333333333334%)}.tablet-push-11{left:91.66666%;left:calc(91.66666666666667%);left:-webkit-calc(91.66666666666667%);left:-moz-calc(91.66666666666667%)}.tablet-pull-11{left:-91.66666%;left:calc(-91.66666666666667%);left:-webkit-calc(-91.66666666666667%);left:-moz-calc(-91.66666666666667%)}.tablet-no-push,.tablet-no-pull{left:auto}.tablet-row{padding-top:1em;padding-bottom:1em}.tablet-full{left:auto;clear:both;float:none;width:100%;margin:1em 0 0 0;display:block}.tablet-full:first-child{margin-top:0}.tablet-left-text{text-align:left}.tablet-right-text{text-align:right}.tablet-center-text{text-align:center}.tablet-left{float:left}.tablet-right{float:right}.tablet-no-float{float:none}.tablet-no-margin{margin:0}.tablet-no-padding{padding:0}.no-tablet{display:none}.show-tablet{display:block}}@media only screen and (max-width:739px){.container,.mobile-container{padding-left:20px;padding-right:20px;margin-left:auto;margin-right:auto;float:none}.container:first-child,.mobile-container:first-child{margin-left:auto}.mobile-container-full{padding-left:0;padding-right:0;margin-left:auto;margin-right:auto;float:none}.mobile-container-full:first-child{margin-left:auto}.mobile-no-gutter{padding-left:0;padding-right:0}.mobile-col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.mobile-col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.mobile-col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.mobile-col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.mobile-push-1-2{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.mobile-pull-1-2{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.mobile-push-1-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.mobile-pull-1-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.mobile-push-1-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.mobile-pull-1-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.mobile-push-3-4{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.mobile-pull-3-4{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.mobile-no-push,.mobile-no-pull{left:auto}.mobile-row{padding-top:1em;padding-bottom:1em}.mobile-full{left:auto;clear:both;float:none;width:100%;margin:.2em 0 0 0;display:block}.mobile-full:first-child{margin-top:0}.mobile-left-text{text-align:left}.mobile-right-text{text-align:right}.mobile-center-text{text-align:center}.mobile-left{float:left}.mobile-right{float:right}.mobile-no-float{float:none}.mobile-no-margin{margin:0}.mobile-no-padding{padding:0}table th,table td{padding:4px}.no-mobile{display:none}.show-mobile{display:block}}@media print{*{background:transparent}a,a:visited{text-decoration:underline}abbr[title]:after{content:" (" attr(title) ")"}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100%}@page{margin:.5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}}html,body{height:100%}.absolute{position:absolute}.relative{position:relative}.full{width:100%}.no-scroll{overflow:hidden}.table{display:table;margin:0 auto}.xlarge-top{margin-top:60px}.large-top{margin-top:40px}.medium-top{margin-top:20px}.small-top{margin-top:10px}.mini-top{margin-top:5px}.no-left-padding{padding-left:0}.no-right-padding{padding-right:0}@media only screen and (max-width:739px){.mobile-hide{display:none}.mobile-xlarge-top{margin-top:60px}.mobile-large-top{margin-top:40px}.mobile-medium-top{margin-top:20px}.mobile-small-top{margin-top:10px}.mobile-mini-top{margin-top:5px}}html,body{font-family:'Roboto','Helvetica Neue','Arial','Helvetica','Lucida Grande',sans-serif;font-weight:300;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}h1,h2,h3,h4,h5{font-weight:300}p{margin:0 0 1em 0}pre,code{padding:5px 10px;color:#6e6e6e;font-size:14px;line-height:20px;font-weight:100;background:#f8f8f8;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}a{color:#333;text-decoration:none;-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out}a.active{color:#000}a:hover{color:#000}a:hover .fa-trash-o{color:#e2717f}a.primary{color:#e2717f}a.primary:hover{color:#d94759}img{max-width:100%}hr{margin:.5em 0;width:100%}i.right-padding{padding-right:10px}i.left-padding{padding-left:10px}.button{outline:0;padding:1em 1.5em;background:#fafafa;color:#333;white-space:nowrap;background-clip:padding-box;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.button.disabled,.button[disabled]{-moz-opacity:.7;-khtml-opacity:.7;-webkit-opacity:.7;opacity:.7;-ms-filter:alpha(opacity=70);filter:alpha(opacity=70);cursor:default}.button:hover:not(.disabled),.button:hover:not([disabled]){background:#d9d9d9}.button.large{padding:1em 4em}.button.small{padding:.6em .8em}.button.x-small{padding:.4em .6em}.button.primary-button{color:#fff;background:#e2717f}.button.primary-button:hover,.button.primary-button:focus{color:#f2f2f2;background:#de5c6c}.button.primary-button:hover.disabled,.button.primary-button:focus.disabled,.button.primary-button:hover:disabled,.button.primary-button:focus:disabled{background:#e2717f}.button.secondary-button{background:0;border:1px solid #eee}.button.secondary-button:hover:not(.active),.button.secondary-button:hover:not(.disabled),.button.secondary-button:hover:not(:disabled),.button.secondary-button:focus:not(.active),.button.secondary-button:focus:not(.disabled),.button.secondary-button:focus:not(:disabled){color:#666;background:#f8f8f8}.button.secondary-button.active{color:#595959;background:#ebebeb;border:1px solid #eee}.button.secondary-button.active:hover{color:#595959;background:#ebebeb;border:1px solid #eee}.button.remove-button{background:#e2717f;color:#fff;padding:.9em 1.5em}.button.remove-button:hover,.button.remove-button:focus{background:#de5c6c}.button.remove-button:hover.disabled,.button.remove-button:focus.disabled,.button.remove-button:hover:disabled,.button.remove-button:focus:disabled{background:#e2717f}.button.transparent-button{background:0;color:#fff;border:1px solid #f2f2f2}.button.transparent-button:hover:not(.disabled),.button.transparent-button:hover:not(:disabled){background:rgba(255,255,255,0.1);color:#fff}.button-group>.button{padding:.8em 1em;text-align:center;background:#fff;border-top:1px solid #eee;border-bottom:1px solid #eee;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.button-group>.button i.fa{margin-right:5px}.button-group>.button:first-child{border-left:1px solid #eee;-webkit-border-top-right-radius:0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:5px;-webkit-border-top-left-radius:5px;-moz-border-radius-topright:0;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:5px;-moz-border-radius-topleft:5px;border-top-right-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:5px;border-top-left-radius:5px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.button-group>.button:last-child{border-right:1px solid #eee;-webkit-border-top-right-radius:5px;-webkit-border-bottom-right-radius:5px;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:0;-moz-border-radius-topright:5px;-moz-border-radius-bottomright:5px;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:0;border-top-right-radius:5px;border-bottom-right-radius:5px;border-bottom-left-radius:0;border-top-left-radius:0;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.button-group>.button:hover:not(.active),.button-group>.button:focus:not(.active){color:#666;background:#f8f8f8}.button-group>.button.active{color:#595959;background:#ebebeb;border:1px solid #eee}.button-group>.button.active:hover{color:#595959;background:#ebebeb;border:1px solid #eee}.button-group.small>.button{padding:.6em .8em}.button-group.x-small>.button{padding:.4em .6em}form .col,form .input-wrapper{position:relative}form input,form input[type="text"],form input[type="password"],form input[type="email"],form input[type="search"],form input[type="tel"],form input[type="number"],form input[type="date"],form textarea{width:100%;padding:.8em .6em .6em;outline:0;border:1px solid #d3d3d3;font-size:1.1em;line-height:1;background:#fff;color:#666;-webkit-appearance:none;-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out}form input:focus,form input[type="text"]:focus,form input[type="password"]:focus,form input[type="email"]:focus,form input[type="search"]:focus,form input[type="tel"]:focus,form input[type="number"]:focus,form input[type="date"]:focus,form textarea:focus{color:#333;border:1px solid #a0a0a0;-moz-box-shadow:0 0 2px #a0a0a0;-webkit-box-shadow:0 0 2px #a0a0a0;box-shadow:0 0 2px #a0a0a0;-webkit-box-shadow:0 0 2px #a0a0a0 0 0 #000;box-shadow:0 0 2px #a0a0a0 0 0 #000}form input:focus+label,form input[type="text"]:focus+label,form input[type="password"]:focus+label,form input[type="email"]:focus+label,form input[type="search"]:focus+label,form input[type="tel"]:focus+label,form input[type="number"]:focus+label,form input[type="date"]:focus+label,form textarea:focus+label{color:#666;font-weight:400}form input.success,form input[type="text"].success,form input[type="password"].success,form input[type="email"].success,form input[type="search"].success,form input[type="tel"].success,form input[type="number"].success,form input[type="date"].success,form textarea.success{border:1px solid #43cea2;-moz-box-shadow:0 0 2px #43cea2;-webkit-box-shadow:0 0 2px #43cea2;box-shadow:0 0 2px #43cea2;-webkit-box-shadow:0 0 2px #43cea2 0 0 #000;box-shadow:0 0 2px #43cea2 0 0 #000}form input.success+label,form input[type="text"].success+label,form input[type="password"].success+label,form input[type="email"].success+label,form input[type="search"].success+label,form input[type="tel"].success+label,form input[type="number"].success+label,form input[type="date"].success+label,form textarea.success+label{color:#43cea2;font-weight:400}form input.error,form input[type="text"].error,form input[type="password"].error,form input[type="email"].error,form input[type="search"].error,form input[type="tel"].error,form input[type="number"].error,form input[type="date"].error,form textarea.error{border:1px solid #e2717f;-moz-box-shadow:0 0 2px #e2717f;-webkit-box-shadow:0 0 2px #e2717f;box-shadow:0 0 2px #e2717f;-webkit-box-shadow:0 0 2px #e2717f 0 0 #000;box-shadow:0 0 2px #e2717f 0 0 #000}form input.error+label,form input[type="text"].error+label,form input[type="password"].error+label,form input[type="email"].error+label,form input[type="search"].error+label,form input[type="tel"].error+label,form input[type="number"].error+label,form input[type="date"].error+label,form textarea.error+label{color:#e2717f;font-weight:400}form input::-webkit-input-placeholder,form input[type="text"]::-webkit-input-placeholder,form input[type="password"]::-webkit-input-placeholder,form input[type="email"]::-webkit-input-placeholder,form input[type="search"]::-webkit-input-placeholder,form input[type="tel"]::-webkit-input-placeholder,form input[type="number"]::-webkit-input-placeholder,form input[type="date"]::-webkit-input-placeholder,form textarea::-webkit-input-placeholder{color:#d3d3d3;font-weight:300}form [placeholder]:focus::-webkit-input-placeholder{-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out;opacity:0}form input[type="number"]::-webkit-inner-spin-button,form input[type="number"]::-webkit-outer-spin-button,form input[type="date"]::-webkit-inner-spin-button,form input[type="date"]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}form .select-style{position:relative;display:block;width:100%;border:1px solid #a0a0a0;background:#fff}form .select-style .fa-caret-down{position:absolute;right:.6em;top:.8em;color:#a0a0a0;font-size:1.4em}form .select-style select{padding:.8em 0;margin-left:.6em;width:100%;border:0;box-shadow:none;background:transparent;background-image:none;-webkit-appearance:none;color:#a0a0a0;font-size:1.2em}form .select-style select:hover{cursor:pointer}form .select-style select:focus{outline:0}form fieldset.row{padding:.5em 0}form label{position:absolute;left:5px;top:-5px;padding:0 5px;background:white;color:#a0a0a0;font-size:12px;line-height:12px;text-transform:uppercase;pointer-events:none;z-index:2}.modal-wrapper{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.3);display:none;z-index:1001;will-change:transform}.modal-wrapper .modal{position:relative;color:#333;display:none}.modal-wrapper .modal a.close{position:absolute;padding:6px 12px 9px;border:1px solid;border-radius:20px;font-weight:300;font-size:27px}.modal-wrapper .modal section.modal-content{padding:20px}.modal-wrapper:not(.fullscreen) .modal{min-height:300px;max-width:434px;margin:60px auto 0;background-color:#fff;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.modal-wrapper:not(.fullscreen) .modal a.close{right:-45px;top:-30px;color:#fff}.modal-wrapper.fullscreen{background:#fff}.modal-wrapper.fullscreen .modal{height:100%;overflow:auto}.modal-wrapper.fullscreen .modal a.close{right:20px;top:20px}.notice{position:fixed;bottom:0;right:10px;height:100px;width:300px;padding:5px 10px 5px 10px;display:none;color:#fff;z-index:1005;-webkit-border-top-right-radius:5px;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:5px;-moz-border-radius-topright:5px;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:5px;border-top-right-radius:5px;border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-left-radius:5px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.notice.success{background-color:#43cea2}.notice.warning{background-color:#f4ed6b}.notice.error{background-color:#e2717f}.notice header.notice-header{position:relative;margin-bottom:.2em}.notice section.notice-content{height:70px;width:100%;overflow:auto;font-size:.8em}.notice a.close{position:absolute;top:3px;right:0;padding:0 4px 2px;border:1px solid;border-radius:100%;font-weight:300;font-size:12px;line-height:12px;color:#fff}.notice a.close:hover{color:#ccc}nav{font-size:18px;font-size:1.125rem}nav .navbar{margin:0 auto;display:table;padding:10px 0}nav li{margin:0 10px}nav a{display:inline-block;line-height:60px;vertical-align:middle}nav a.logo{height:60px;width:60px}@media(max-width:739px){nav{font-size:14px;font-size:.875rem}nav a{line-height:40px}nav a.logo{height:40px;width:40px}}#toc{position:fixed;top:80px;height:100%;width:263px;overflow:auto;padding-bottom:100px}#toc a{color:#333}#toc a:hover{color:#1a1a1a}#toc li>ul{display:none}#toc li>ul.unstyled-list{margin-left:10px}#toc li.active>a{font-weight:bold}#toc li.active>ul{display:block}#toc ul.nav>li.active>ul>li{list-style:none}footer{padding:60px 0;color:#d3d3d3;background:#333}footer i.fa-heart{color:#e2717f}footer i.fa-beer{color:#f4ed6b}html,body{background:#fff;color:#333}.kd{color:#a783b6}.k{color:#43cea2}h1.logo{font-size:64px;font-size:4rem}.gist pre,.gist .file-data{font-size:14px!important}section{padding:40px 0}#hero .badges,#hero .github-links{padding:.3em 0}#hero .badges p,#hero .github-links p{margin:0}#ship h3{margin-bottom:1em}#ship img.ship-it{display:table;height:300px;width:300px;margin:0 auto;background:#d3d3d3;-webkit-border-radius:100%;-moz-border-radius:100%;border-radius:100%}#plugins{color:#fff;background:#333}#plugins p{color:#d3d3d3}#plugins ul li{padding:10px 20px}#plugins ul li a{display:inline-block}#plugins ul li a img{height:100px;max-width:160px}@media(max-width:739px){#plugins ul li a img{height:60px;max-width:120px}}#features{color:#fff;background:#e2717f}#features h4{color:#982e3e}#features a.primary{color:#f8f8f8;border-bottom:1px dashed #f8f8f8}#features a.primary:hover{color:#dfdfdf;border-bottom:1px dashed #dfdfdf}#comparison img{margin:0 auto}.page a,.example a{color:#e2717f}.page a:hover,.example a:hover{color:#d94759}.page .file-data .line-numbers,.example .file-data .line-numbers{width:40px}#todo-example input[type="text"]{margin:10px 0}#todo-example ul.todos li{padding:5px 0}#todo-example ul.todos li input[type="checkbox"]{margin-top:.2em}#todo-example ul.todos li span{margin-left:5px}#todo-example .primary-button{width:100%} \ No newline at end of file + */@font-face{font-family:'FontAwesome';src:url('/fonts/fontawesome-webfont.eot?v=4.3.0');src:url('/fonts/fontawesome-webfont.eot?#iefix&v=4.3.0') format('embedded-opentype'),url('/fonts/fontawesome-webfont.woff2?v=4.3.0') format('woff2'),url('/fonts/fontawesome-webfont.woff?v=4.3.0') format('woff'),url('/fonts/fontawesome-webfont.ttf?v=4.3.0') format('truetype'),url('/fonts/fontawesome-webfont.svg?v=4.3.0#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;transform:translate(0,0)}.fa-lg{font-size:1.3333333333333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.2857142857142858em;text-align:center}.fa-ul{padding-left:0;margin-left:2.142857142857143em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.142857142857143em;width:2.142857142857143em;top:.14285714285714285em;text-align:center}.fa-li.fa-lg{left:-1.8571428571428572em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2);-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=0,mirror=1);-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.fa-flip-vertical{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2,mirror=1);-webkit-transform:scale(1,-1);-ms-transform:scale(1,-1);transform:scale(1,-1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-remove:before,.fa-close:before,.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook-f:before,.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{content:"\f09c"}.fa-credit-card:before{content:"\f09d"}.fa-rss:before{content:"\f09e"}.fa-hdd-o:before{content:"\f0a0"}.fa-bullhorn:before{content:"\f0a1"}.fa-bell:before{content:"\f0f3"}.fa-certificate:before{content:"\f0a3"}.fa-hand-o-right:before{content:"\f0a4"}.fa-hand-o-left:before{content:"\f0a5"}.fa-hand-o-up:before{content:"\f0a6"}.fa-hand-o-down:before{content:"\f0a7"}.fa-arrow-circle-left:before{content:"\f0a8"}.fa-arrow-circle-right:before{content:"\f0a9"}.fa-arrow-circle-up:before{content:"\f0aa"}.fa-arrow-circle-down:before{content:"\f0ab"}.fa-globe:before{content:"\f0ac"}.fa-wrench:before{content:"\f0ad"}.fa-tasks:before{content:"\f0ae"}.fa-filter:before{content:"\f0b0"}.fa-briefcase:before{content:"\f0b1"}.fa-arrows-alt:before{content:"\f0b2"}.fa-group:before,.fa-users:before{content:"\f0c0"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-cloud:before{content:"\f0c2"}.fa-flask:before{content:"\f0c3"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-copy:before,.fa-files-o:before{content:"\f0c5"}.fa-paperclip:before{content:"\f0c6"}.fa-save:before,.fa-floppy-o:before{content:"\f0c7"}.fa-square:before{content:"\f0c8"}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:"\f0c9"}.fa-list-ul:before{content:"\f0ca"}.fa-list-ol:before{content:"\f0cb"}.fa-strikethrough:before{content:"\f0cc"}.fa-underline:before{content:"\f0cd"}.fa-table:before{content:"\f0ce"}.fa-magic:before{content:"\f0d0"}.fa-truck:before{content:"\f0d1"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-google-plus-square:before{content:"\f0d4"}.fa-google-plus:before{content:"\f0d5"}.fa-money:before{content:"\f0d6"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-columns:before{content:"\f0db"}.fa-unsorted:before,.fa-sort:before{content:"\f0dc"}.fa-sort-down:before,.fa-sort-desc:before{content:"\f0dd"}.fa-sort-up:before,.fa-sort-asc:before{content:"\f0de"}.fa-envelope:before{content:"\f0e0"}.fa-linkedin:before{content:"\f0e1"}.fa-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-legal:before,.fa-gavel:before{content:"\f0e3"}.fa-dashboard:before,.fa-tachometer:before{content:"\f0e4"}.fa-comment-o:before{content:"\f0e5"}.fa-comments-o:before{content:"\f0e6"}.fa-flash:before,.fa-bolt:before{content:"\f0e7"}.fa-sitemap:before{content:"\f0e8"}.fa-umbrella:before{content:"\f0e9"}.fa-paste:before,.fa-clipboard:before{content:"\f0ea"}.fa-lightbulb-o:before{content:"\f0eb"}.fa-exchange:before{content:"\f0ec"}.fa-cloud-download:before{content:"\f0ed"}.fa-cloud-upload:before{content:"\f0ee"}.fa-user-md:before{content:"\f0f0"}.fa-stethoscope:before{content:"\f0f1"}.fa-suitcase:before{content:"\f0f2"}.fa-bell-o:before{content:"\f0a2"}.fa-coffee:before{content:"\f0f4"}.fa-cutlery:before{content:"\f0f5"}.fa-file-text-o:before{content:"\f0f6"}.fa-building-o:before{content:"\f0f7"}.fa-hospital-o:before{content:"\f0f8"}.fa-ambulance:before{content:"\f0f9"}.fa-medkit:before{content:"\f0fa"}.fa-fighter-jet:before{content:"\f0fb"}.fa-beer:before{content:"\f0fc"}.fa-h-square:before{content:"\f0fd"}.fa-plus-square:before{content:"\f0fe"}.fa-angle-double-left:before{content:"\f100"}.fa-angle-double-right:before{content:"\f101"}.fa-angle-double-up:before{content:"\f102"}.fa-angle-double-down:before{content:"\f103"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}.fa-angle-up:before{content:"\f106"}.fa-angle-down:before{content:"\f107"}.fa-desktop:before{content:"\f108"}.fa-laptop:before{content:"\f109"}.fa-tablet:before{content:"\f10a"}.fa-mobile-phone:before,.fa-mobile:before{content:"\f10b"}.fa-circle-o:before{content:"\f10c"}.fa-quote-left:before{content:"\f10d"}.fa-quote-right:before{content:"\f10e"}.fa-spinner:before{content:"\f110"}.fa-circle:before{content:"\f111"}.fa-mail-reply:before,.fa-reply:before{content:"\f112"}.fa-github-alt:before{content:"\f113"}.fa-folder-o:before{content:"\f114"}.fa-folder-open-o:before{content:"\f115"}.fa-smile-o:before{content:"\f118"}.fa-frown-o:before{content:"\f119"}.fa-meh-o:before{content:"\f11a"}.fa-gamepad:before{content:"\f11b"}.fa-keyboard-o:before{content:"\f11c"}.fa-flag-o:before{content:"\f11d"}.fa-flag-checkered:before{content:"\f11e"}.fa-terminal:before{content:"\f120"}.fa-code:before{content:"\f121"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"\f122"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"\f123"}.fa-location-arrow:before{content:"\f124"}.fa-crop:before{content:"\f125"}.fa-code-fork:before{content:"\f126"}.fa-unlink:before,.fa-chain-broken:before{content:"\f127"}.fa-question:before{content:"\f128"}.fa-info:before{content:"\f129"}.fa-exclamation:before{content:"\f12a"}.fa-superscript:before{content:"\f12b"}.fa-subscript:before{content:"\f12c"}.fa-eraser:before{content:"\f12d"}.fa-puzzle-piece:before{content:"\f12e"}.fa-microphone:before{content:"\f130"}.fa-microphone-slash:before{content:"\f131"}.fa-shield:before{content:"\f132"}.fa-calendar-o:before{content:"\f133"}.fa-fire-extinguisher:before{content:"\f134"}.fa-rocket:before{content:"\f135"}.fa-maxcdn:before{content:"\f136"}.fa-chevron-circle-left:before{content:"\f137"}.fa-chevron-circle-right:before{content:"\f138"}.fa-chevron-circle-up:before{content:"\f139"}.fa-chevron-circle-down:before{content:"\f13a"}.fa-html5:before{content:"\f13b"}.fa-css3:before{content:"\f13c"}.fa-anchor:before{content:"\f13d"}.fa-unlock-alt:before{content:"\f13e"}.fa-bullseye:before{content:"\f140"}.fa-ellipsis-h:before{content:"\f141"}.fa-ellipsis-v:before{content:"\f142"}.fa-rss-square:before{content:"\f143"}.fa-play-circle:before{content:"\f144"}.fa-ticket:before{content:"\f145"}.fa-minus-square:before{content:"\f146"}.fa-minus-square-o:before{content:"\f147"}.fa-level-up:before{content:"\f148"}.fa-level-down:before{content:"\f149"}.fa-check-square:before{content:"\f14a"}.fa-pencil-square:before{content:"\f14b"}.fa-external-link-square:before{content:"\f14c"}.fa-share-square:before{content:"\f14d"}.fa-compass:before{content:"\f14e"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"\f150"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"\f151"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"\f152"}.fa-euro:before,.fa-eur:before{content:"\f153"}.fa-gbp:before{content:"\f154"}.fa-dollar:before,.fa-usd:before{content:"\f155"}.fa-rupee:before,.fa-inr:before{content:"\f156"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"\f157"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"\f158"}.fa-won:before,.fa-krw:before{content:"\f159"}.fa-bitcoin:before,.fa-btc:before{content:"\f15a"}.fa-file:before{content:"\f15b"}.fa-file-text:before{content:"\f15c"}.fa-sort-alpha-asc:before{content:"\f15d"}.fa-sort-alpha-desc:before{content:"\f15e"}.fa-sort-amount-asc:before{content:"\f160"}.fa-sort-amount-desc:before{content:"\f161"}.fa-sort-numeric-asc:before{content:"\f162"}.fa-sort-numeric-desc:before{content:"\f163"}.fa-thumbs-up:before{content:"\f164"}.fa-thumbs-down:before{content:"\f165"}.fa-youtube-square:before{content:"\f166"}.fa-youtube:before{content:"\f167"}.fa-xing:before{content:"\f168"}.fa-xing-square:before{content:"\f169"}.fa-youtube-play:before{content:"\f16a"}.fa-dropbox:before{content:"\f16b"}.fa-stack-overflow:before{content:"\f16c"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-adn:before{content:"\f170"}.fa-bitbucket:before{content:"\f171"}.fa-bitbucket-square:before{content:"\f172"}.fa-tumblr:before{content:"\f173"}.fa-tumblr-square:before{content:"\f174"}.fa-long-arrow-down:before{content:"\f175"}.fa-long-arrow-up:before{content:"\f176"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-apple:before{content:"\f179"}.fa-windows:before{content:"\f17a"}.fa-android:before{content:"\f17b"}.fa-linux:before{content:"\f17c"}.fa-dribbble:before{content:"\f17d"}.fa-skype:before{content:"\f17e"}.fa-foursquare:before{content:"\f180"}.fa-trello:before{content:"\f181"}.fa-female:before{content:"\f182"}.fa-male:before{content:"\f183"}.fa-gittip:before,.fa-gratipay:before{content:"\f184"}.fa-sun-o:before{content:"\f185"}.fa-moon-o:before{content:"\f186"}.fa-archive:before{content:"\f187"}.fa-bug:before{content:"\f188"}.fa-vk:before{content:"\f189"}.fa-weibo:before{content:"\f18a"}.fa-renren:before{content:"\f18b"}.fa-pagelines:before{content:"\f18c"}.fa-stack-exchange:before{content:"\f18d"}.fa-arrow-circle-o-right:before{content:"\f18e"}.fa-arrow-circle-o-left:before{content:"\f190"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:"\f191"}.fa-dot-circle-o:before{content:"\f192"}.fa-wheelchair:before{content:"\f193"}.fa-vimeo-square:before{content:"\f194"}.fa-turkish-lira:before,.fa-try:before{content:"\f195"}.fa-plus-square-o:before{content:"\f196"}.fa-space-shuttle:before{content:"\f197"}.fa-slack:before{content:"\f198"}.fa-envelope-square:before{content:"\f199"}.fa-wordpress:before{content:"\f19a"}.fa-openid:before{content:"\f19b"}.fa-institution:before,.fa-bank:before,.fa-university:before{content:"\f19c"}.fa-mortar-board:before,.fa-graduation-cap:before{content:"\f19d"}.fa-yahoo:before{content:"\f19e"}.fa-google:before{content:"\f1a0"}.fa-reddit:before{content:"\f1a1"}.fa-reddit-square:before{content:"\f1a2"}.fa-stumbleupon-circle:before{content:"\f1a3"}.fa-stumbleupon:before{content:"\f1a4"}.fa-delicious:before{content:"\f1a5"}.fa-digg:before{content:"\f1a6"}.fa-pied-piper:before{content:"\f1a7"}.fa-pied-piper-alt:before{content:"\f1a8"}.fa-drupal:before{content:"\f1a9"}.fa-joomla:before{content:"\f1aa"}.fa-language:before{content:"\f1ab"}.fa-fax:before{content:"\f1ac"}.fa-building:before{content:"\f1ad"}.fa-child:before{content:"\f1ae"}.fa-paw:before{content:"\f1b0"}.fa-spoon:before{content:"\f1b1"}.fa-cube:before{content:"\f1b2"}.fa-cubes:before{content:"\f1b3"}.fa-behance:before{content:"\f1b4"}.fa-behance-square:before{content:"\f1b5"}.fa-steam:before{content:"\f1b6"}.fa-steam-square:before{content:"\f1b7"}.fa-recycle:before{content:"\f1b8"}.fa-automobile:before,.fa-car:before{content:"\f1b9"}.fa-cab:before,.fa-taxi:before{content:"\f1ba"}.fa-tree:before{content:"\f1bb"}.fa-spotify:before{content:"\f1bc"}.fa-deviantart:before{content:"\f1bd"}.fa-soundcloud:before{content:"\f1be"}.fa-database:before{content:"\f1c0"}.fa-file-pdf-o:before{content:"\f1c1"}.fa-file-word-o:before{content:"\f1c2"}.fa-file-excel-o:before{content:"\f1c3"}.fa-file-powerpoint-o:before{content:"\f1c4"}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:"\f1c5"}.fa-file-zip-o:before,.fa-file-archive-o:before{content:"\f1c6"}.fa-file-sound-o:before,.fa-file-audio-o:before{content:"\f1c7"}.fa-file-movie-o:before,.fa-file-video-o:before{content:"\f1c8"}.fa-file-code-o:before{content:"\f1c9"}.fa-vine:before{content:"\f1ca"}.fa-codepen:before{content:"\f1cb"}.fa-jsfiddle:before{content:"\f1cc"}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:"\f1cd"}.fa-circle-o-notch:before{content:"\f1ce"}.fa-ra:before,.fa-rebel:before{content:"\f1d0"}.fa-ge:before,.fa-empire:before{content:"\f1d1"}.fa-git-square:before{content:"\f1d2"}.fa-git:before{content:"\f1d3"}.fa-hacker-news:before{content:"\f1d4"}.fa-tencent-weibo:before{content:"\f1d5"}.fa-qq:before{content:"\f1d6"}.fa-wechat:before,.fa-weixin:before{content:"\f1d7"}.fa-send:before,.fa-paper-plane:before{content:"\f1d8"}.fa-send-o:before,.fa-paper-plane-o:before{content:"\f1d9"}.fa-history:before{content:"\f1da"}.fa-genderless:before,.fa-circle-thin:before{content:"\f1db"}.fa-header:before{content:"\f1dc"}.fa-paragraph:before{content:"\f1dd"}.fa-sliders:before{content:"\f1de"}.fa-share-alt:before{content:"\f1e0"}.fa-share-alt-square:before{content:"\f1e1"}.fa-bomb:before{content:"\f1e2"}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:"\f1e3"}.fa-tty:before{content:"\f1e4"}.fa-binoculars:before{content:"\f1e5"}.fa-plug:before{content:"\f1e6"}.fa-slideshare:before{content:"\f1e7"}.fa-twitch:before{content:"\f1e8"}.fa-yelp:before{content:"\f1e9"}.fa-newspaper-o:before{content:"\f1ea"}.fa-wifi:before{content:"\f1eb"}.fa-calculator:before{content:"\f1ec"}.fa-paypal:before{content:"\f1ed"}.fa-google-wallet:before{content:"\f1ee"}.fa-cc-visa:before{content:"\f1f0"}.fa-cc-mastercard:before{content:"\f1f1"}.fa-cc-discover:before{content:"\f1f2"}.fa-cc-amex:before{content:"\f1f3"}.fa-cc-paypal:before{content:"\f1f4"}.fa-cc-stripe:before{content:"\f1f5"}.fa-bell-slash:before{content:"\f1f6"}.fa-bell-slash-o:before{content:"\f1f7"}.fa-trash:before{content:"\f1f8"}.fa-copyright:before{content:"\f1f9"}.fa-at:before{content:"\f1fa"}.fa-eyedropper:before{content:"\f1fb"}.fa-paint-brush:before{content:"\f1fc"}.fa-birthday-cake:before{content:"\f1fd"}.fa-area-chart:before{content:"\f1fe"}.fa-pie-chart:before{content:"\f200"}.fa-line-chart:before{content:"\f201"}.fa-lastfm:before{content:"\f202"}.fa-lastfm-square:before{content:"\f203"}.fa-toggle-off:before{content:"\f204"}.fa-toggle-on:before{content:"\f205"}.fa-bicycle:before{content:"\f206"}.fa-bus:before{content:"\f207"}.fa-ioxhost:before{content:"\f208"}.fa-angellist:before{content:"\f209"}.fa-cc:before{content:"\f20a"}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:"\f20b"}.fa-meanpath:before{content:"\f20c"}.fa-buysellads:before{content:"\f20d"}.fa-connectdevelop:before{content:"\f20e"}.fa-dashcube:before{content:"\f210"}.fa-forumbee:before{content:"\f211"}.fa-leanpub:before{content:"\f212"}.fa-sellsy:before{content:"\f213"}.fa-shirtsinbulk:before{content:"\f214"}.fa-simplybuilt:before{content:"\f215"}.fa-skyatlas:before{content:"\f216"}.fa-cart-plus:before{content:"\f217"}.fa-cart-arrow-down:before{content:"\f218"}.fa-diamond:before{content:"\f219"}.fa-ship:before{content:"\f21a"}.fa-user-secret:before{content:"\f21b"}.fa-motorcycle:before{content:"\f21c"}.fa-street-view:before{content:"\f21d"}.fa-heartbeat:before{content:"\f21e"}.fa-venus:before{content:"\f221"}.fa-mars:before{content:"\f222"}.fa-mercury:before{content:"\f223"}.fa-transgender:before{content:"\f224"}.fa-transgender-alt:before{content:"\f225"}.fa-venus-double:before{content:"\f226"}.fa-mars-double:before{content:"\f227"}.fa-venus-mars:before{content:"\f228"}.fa-mars-stroke:before{content:"\f229"}.fa-mars-stroke-v:before{content:"\f22a"}.fa-mars-stroke-h:before{content:"\f22b"}.fa-neuter:before{content:"\f22c"}.fa-facebook-official:before{content:"\f230"}.fa-pinterest-p:before{content:"\f231"}.fa-whatsapp:before{content:"\f232"}.fa-server:before{content:"\f233"}.fa-user-plus:before{content:"\f234"}.fa-user-times:before{content:"\f235"}.fa-hotel:before,.fa-bed:before{content:"\f236"}.fa-viacoin:before{content:"\f237"}.fa-train:before{content:"\f238"}.fa-subway:before{content:"\f239"}.fa-medium:before{content:"\f23a"}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}html,button,input,select,textarea{font-family:sans-serif}body,form,fieldset,legend,input,select,textarea,button{margin:0}html{font-size:100%}body{font-family:sans-serif;font-size:16px;font-size:1rem;line-height:21px;line-height:1.3125rem;color:#434343;background-color:#fff;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}b,strong{font-weight:700}i,em,.em{font-style:italic}a{color:#669fcf}a:hover{text-decoration:none}a:focus{outline:0}a:active,a:hover{outline:0}p{margin:0 0 1.6em 0}pre{margin:1em 0}ul+p,ul+pre,ol+p,ol+pre{margin-top:0}small{font-size:80%}abbr[title]{border-bottom:1px dotted}audio,canvas,video{display:inline-block;*zoom:1;*display:inline}audio:not([controls]){display:none;height:0}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}dfn{font-style:italic}img{border:0;-ms-interpolation-mode:bicubic}svg:not(:root){overflow:hidden}figure{margin:0}.image-left{margin-right:20px}.image-right{margin-left:20px}h1,h2,h3,h4,h5,h6{line-height:normal;font-weight:normal;margin:0 0 .33em 0}h1,.h1{font-size:40px;font-size:2.5rem}h2,.h2{font-size:32px;font-size:2rem}h3,.h3{font-size:26px;font-size:1.625rem}h4,.h4{font-size:20px;font-size:1.25rem}h5,.h5{font-size:18px;font-size:1.125rem}h6,.h6{font-size:16px;font-size:1rem}.no-style-heading{margin:0;font-size:100%}hr{border:0;background:0;outline:0;background-color:#ddd;margin:2em 0;*margin:1em 0;-moz-box-sizing:content-box;box-sizing:content-box;height:1px}blockquote{font-size:22px;font-size:1.375rem;line-height:32px;line-height:2rem;color:#434343;margin:1em 0;font-style:italic}blockquote p{margin:1em 0}cite{color:#434343;font-style:normal;font-weight:normal;font-size:16px;font-size:1rem;line-height:normal}q{font-style:italic;quotes:none}q:before,q:after{content:'';content:none}mark{background:#ff0;color:#111}code,kbd,pre,samp{word-wrap:break-word;font-family:'courier new',monospace,serif;font-size:13px;font-size:.8125rem;line-height:normal;font-weight:normal;background-color:#f1f1f1;padding:10px}code{color:#111}dl,menu,ol,ul{margin:1em 0}dd,ul ul,ol ol,ul ol,ol ul{margin:0}dt{font-weight:normal}dd{margin-bottom:1em}menu,ol,ul{padding:0 0 0 22px}nav ul,nav ol{list-style:none;list-style-image:none}.unstyled-list{list-style:none;padding:0;margin:0}.unstyled-list li{margin-top:0;margin-bottom:0}.inline-list{list-style:none;padding:0;margin:0;display:inline-block;*zoom:1;*display:inline}.inline-list li{margin-top:0;margin-bottom:0}.inline-list li{display:inline-block;*zoom:1;*display:inline}table{width:100%;margin:1em 0;table-layout:fixed;border-collapse:collapse;border-spacing:0;border-right:1px solid #f1f1f1;border-bottom:1px solid #f1f1f1;word-wrap:break-word;-ms-word-wrap:break-word;*white-space:normal}table th,table td{padding:8px;text-align:left;vertical-align:top;border-top:1px solid #eee;border-left:1px solid #eee}table thead th,table tfoot th{vertical-align:bottom;font-weight:normal;background-color:#f1f1f1;color:#333}table caption{padding:8px;font-style:normal;text-align:left;font-weight:normal;border-bottom:0}fieldset{border:0;padding:0}legend{border:0;padding:0;white-space:normal;*margin-left:-7px;font-weight:normal}label{margin:0;cursor:pointer}button,input,select,textarea{font-size:100%;vertical-align:baseline;*vertical-align:middle}input[type=text],input[type=password],input[type=email],input[type=search],input[type=tel],textarea{padding:5px;-webkit-appearance:none;-moz-appearance:none;font-weight:normal;line-height:normal;background-color:#fff;border:1px solid #ccc;color:#111}input[type=checkbox],input[type=radio]{cursor:pointer;box-sizing:border-box;line-height:normal;margin:0;padding:0;*height:13px;*width:13px}.checkbox{display:block;margin:.2em 0}.checkbox input[type=checkbox],.checkbox input[type=radio]{margin-top:.05em;float:left}.checkbox label{padding-left:5px;overflow:hidden;display:table;*zoom:1}button,input{line-height:normal}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer;*overflow:visible}button[disabled],html input[disabled]{cursor:default}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top;resize:none}.button{border:0;padding:1em 3em;background-color:#e74b3c;color:#fff;text-decoration:none;text-align:center;display:inline-block;*zoom:1;*display:inline;position:relative}.button:hover{background-color:#fc5547}.button:active{top:1px}.grey-button{background-color:#eee;color:#434343}.grey-button:hover{background-color:#f1f1f1}.button[disabled],.button.disabled{color:#999;background-color:#f1f1f1}.unstyled-button{font-size:16px;font-size:1rem;color:#27ae61;text-decoration:underline;border:0;background:transparent;height:auto;padding:0;cursor:pointer;outline:0}.unstyled-button:hover{text-decoration:none}.unstyled-button[disabled],.unstyled-button.disabled{text-decoration:none;color:#999;background-color:#ccc}.section{position:relative}.container{max-width:960px;margin-left:auto;margin-right:auto;padding-left:10px;padding-right:10px}.container-full{max-width:960px;margin-left:auto;margin-right:auto}.col{float:left;padding-left:10px;padding-right:10px}[class*="pull-"],[class*="push-"]{position:relative}.no-gutter{padding-left:0;padding-right:0}.col-1{width:8.33333%;width:calc(8.333333333333334%);width:-webkit-calc(8.333333333333334%);width:-moz-calc(8.333333333333334%)}.col-2{width:16.66667%;width:calc(16.666666666666668%);width:-webkit-calc(16.666666666666668%);width:-moz-calc(16.666666666666668%)}.col-3{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.col-4{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.col-5{width:41.66665%;width:calc(41.66666666666667%);width:-webkit-calc(41.66666666666667%);width:-moz-calc(41.66666666666667%)}.col-6{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.col-7{width:58.33333%;width:calc(58.333333333333336%);width:-webkit-calc(58.333333333333336%);width:-moz-calc(58.333333333333336%)}.col-8{width:66.66666%;width:calc(66.66666666666667%);width:-webkit-calc(66.66666666666667%);width:-moz-calc(66.66666666666667%)}.col-9{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.col-10{width:83.33333%;width:calc(83.33333333333334%);width:-webkit-calc(83.33333333333334%);width:-moz-calc(83.33333333333334%)}.col-11{width:91.66666%;width:calc(91.66666666666667%);width:-webkit-calc(91.66666666666667%);width:-moz-calc(91.66666666666667%)}.col-12{width:100%}.col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.push-1{left:8.33333%;left:calc(8.333333333333334%);left:-webkit-calc(8.333333333333334%);left:-moz-calc(8.333333333333334%)}.pull-1{left:-8.33333%;left:calc(-8.333333333333334%);left:-webkit-calc(-8.333333333333334%);left:-moz-calc(-8.333333333333334%)}.push-2{left:16.66667%;left:calc(16.666666666666668%);left:-webkit-calc(16.666666666666668%);left:-moz-calc(16.666666666666668%)}.pull-2{left:-16.66667%;left:calc(-16.666666666666668%);left:-webkit-calc(-16.666666666666668%);left:-moz-calc(-16.666666666666668%)}.push-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.pull-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.push-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.pull-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.push-5{left:41.66665%;left:calc(41.66666666666667%);left:-webkit-calc(41.66666666666667%);left:-moz-calc(41.66666666666667%)}.pull-5{left:-41.66665%;left:calc(-41.66666666666667%);left:-webkit-calc(-41.66666666666667%);left:-moz-calc(-41.66666666666667%)}.push-6{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.pull-6{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.push-7{left:58.33333%;left:calc(58.333333333333336%);left:-webkit-calc(58.333333333333336%);left:-moz-calc(58.333333333333336%)}.pull-7{left:-58.33333%;left:calc(-58.333333333333336%);left:-webkit-calc(-58.333333333333336%);left:-moz-calc(-58.333333333333336%)}.push-8{left:66.66666%;left:calc(66.66666666666667%);left:-webkit-calc(66.66666666666667%);left:-moz-calc(66.66666666666667%)}.pull-8{left:-66.66666%;left:calc(-66.66666666666667%);left:-webkit-calc(-66.66666666666667%);left:-moz-calc(-66.66666666666667%)}.push-9{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.pull-9{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.push-10{left:83.33333%;left:calc(83.33333333333334%);left:-webkit-calc(83.33333333333334%);left:-moz-calc(83.33333333333334%)}.pull-10{left:-83.33333%;left:calc(-83.33333333333334%);left:-webkit-calc(-83.33333333333334%);left:-moz-calc(-83.33333333333334%)}.push-11{left:91.66666%;left:calc(91.66666666666667%);left:-webkit-calc(91.66666666666667%);left:-moz-calc(91.66666666666667%)}.pull-11{left:-91.66666%;left:calc(-91.66666666666667%);left:-webkit-calc(-91.66666666666667%);left:-moz-calc(-91.66666666666667%)}.row{padding-top:1em;padding-bottom:1em}.clear:before,.clear:after{content:"";display:table}.clear:after{clear:both}.clear{zoom:1}.left{float:left}.right{float:right}.block{display:block}.inline{display:inline}.inline-block{display:inline-block;*zoom:1;*display:inline}.none,.hidden,[hidden],.no-desktop{display:none}.heavy{font-weight:900}.strong{font-weight:700}.normal{font-weight:normal}.thin{font-weight:300}.fine{font-weight:100}.italic{font-style:italic}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.left-text{text-align:left}.right-text{text-align:right}.center-text{text-align:center}.justify-text{text-align:justify}.visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;overflow:hidden;padding:0;position:absolute;width:1px;left:-9999em}.visuallyvisible{clip:auto;width:auto;height:auto;overflow:visible;left:0}.no-margin{margin:0}.no-padding{padding:0}@media only screen and (min-width:740px) and (max-width:960px){.container,.tablet-container{max-width:960px;padding-left:20px;padding-right:20px;margin-left:auto;margin-right:auto;float:none}.container:first-child,.tablet-container:first-child{margin-left:auto}.tablet-container-full{padding-left:0;padding-right:0;margin-left:auto;margin-right:auto;float:none}.tablet-container-full:first-child{margin-left:auto}.tablet-no-gutter{padding-left:0;padding-right:0}.tablet-col-1{width:8.33333%;width:calc(8.333333333333334%);width:-webkit-calc(8.333333333333334%);width:-moz-calc(8.333333333333334%)}.tablet-col-2{width:16.66667%;width:calc(16.666666666666668%);width:-webkit-calc(16.666666666666668%);width:-moz-calc(16.666666666666668%)}.tablet-col-3{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.tablet-col-4{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.tablet-col-5{width:41.66665%;width:calc(41.66666666666667%);width:-webkit-calc(41.66666666666667%);width:-moz-calc(41.66666666666667%)}.tablet-col-6{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.tablet-col-7{width:58.33333%;width:calc(58.333333333333336%);width:-webkit-calc(58.333333333333336%);width:-moz-calc(58.333333333333336%)}.tablet-col-8{width:66.66666%;width:calc(66.66666666666667%);width:-webkit-calc(66.66666666666667%);width:-moz-calc(66.66666666666667%)}.tablet-col-9{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.tablet-col-10{width:83.33333%;width:calc(83.33333333333334%);width:-webkit-calc(83.33333333333334%);width:-moz-calc(83.33333333333334%)}.tablet-col-11{width:91.66666%;width:calc(91.66666666666667%);width:-webkit-calc(91.66666666666667%);width:-moz-calc(91.66666666666667%)}.tablet-col-12{width:100%}.tablet-col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.tablet-col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.tablet-col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.tablet-col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.tablet-push-1{left:8.33333%;left:calc(8.333333333333334%);left:-webkit-calc(8.333333333333334%);left:-moz-calc(8.333333333333334%)}.tablet-pull-1{left:-8.33333%;left:calc(-8.333333333333334%);left:-webkit-calc(-8.333333333333334%);left:-moz-calc(-8.333333333333334%)}.tablet-push-2{left:16.66667%;left:calc(16.666666666666668%);left:-webkit-calc(16.666666666666668%);left:-moz-calc(16.666666666666668%)}.tablet-pull-2{left:-16.66667%;left:calc(-16.666666666666668%);left:-webkit-calc(-16.666666666666668%);left:-moz-calc(-16.666666666666668%)}.tablet-push-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.tablet-pull-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.tablet-push-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.tablet-pull-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.tablet-push-5{left:41.66665%;left:calc(41.66666666666667%);left:-webkit-calc(41.66666666666667%);left:-moz-calc(41.66666666666667%)}.tablet-pull-5{left:-41.66665%;left:calc(-41.66666666666667%);left:-webkit-calc(-41.66666666666667%);left:-moz-calc(-41.66666666666667%)}.tablet-push-6{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.tablet-pull-6{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.tablet-push-7{left:58.33333%;left:calc(58.333333333333336%);left:-webkit-calc(58.333333333333336%);left:-moz-calc(58.333333333333336%)}.tablet-pull-7{left:-58.33333%;left:calc(-58.333333333333336%);left:-webkit-calc(-58.333333333333336%);left:-moz-calc(-58.333333333333336%)}.tablet-push-8{left:66.66666%;left:calc(66.66666666666667%);left:-webkit-calc(66.66666666666667%);left:-moz-calc(66.66666666666667%)}.tablet-pull-8{left:-66.66666%;left:calc(-66.66666666666667%);left:-webkit-calc(-66.66666666666667%);left:-moz-calc(-66.66666666666667%)}.tablet-push-9{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.tablet-pull-9{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.tablet-push-10{left:83.33333%;left:calc(83.33333333333334%);left:-webkit-calc(83.33333333333334%);left:-moz-calc(83.33333333333334%)}.tablet-pull-10{left:-83.33333%;left:calc(-83.33333333333334%);left:-webkit-calc(-83.33333333333334%);left:-moz-calc(-83.33333333333334%)}.tablet-push-11{left:91.66666%;left:calc(91.66666666666667%);left:-webkit-calc(91.66666666666667%);left:-moz-calc(91.66666666666667%)}.tablet-pull-11{left:-91.66666%;left:calc(-91.66666666666667%);left:-webkit-calc(-91.66666666666667%);left:-moz-calc(-91.66666666666667%)}.tablet-no-push,.tablet-no-pull{left:auto}.tablet-row{padding-top:1em;padding-bottom:1em}.tablet-full{left:auto;clear:both;float:none;width:100%;margin:1em 0 0 0;display:block}.tablet-full:first-child{margin-top:0}.tablet-left-text{text-align:left}.tablet-right-text{text-align:right}.tablet-center-text{text-align:center}.tablet-left{float:left}.tablet-right{float:right}.tablet-no-float{float:none}.tablet-no-margin{margin:0}.tablet-no-padding{padding:0}.no-tablet{display:none}.show-tablet{display:block}}@media only screen and (max-width:739px){.container,.mobile-container{padding-left:20px;padding-right:20px;margin-left:auto;margin-right:auto;float:none}.container:first-child,.mobile-container:first-child{margin-left:auto}.mobile-container-full{padding-left:0;padding-right:0;margin-left:auto;margin-right:auto;float:none}.mobile-container-full:first-child{margin-left:auto}.mobile-no-gutter{padding-left:0;padding-right:0}.mobile-col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.mobile-col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.mobile-col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.mobile-col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.mobile-push-1-2{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.mobile-pull-1-2{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.mobile-push-1-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.mobile-pull-1-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.mobile-push-1-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.mobile-pull-1-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.mobile-push-3-4{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.mobile-pull-3-4{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.mobile-no-push,.mobile-no-pull{left:auto}.mobile-row{padding-top:1em;padding-bottom:1em}.mobile-full{left:auto;clear:both;float:none;width:100%;margin:.2em 0 0 0;display:block}.mobile-full:first-child{margin-top:0}.mobile-left-text{text-align:left}.mobile-right-text{text-align:right}.mobile-center-text{text-align:center}.mobile-left{float:left}.mobile-right{float:right}.mobile-no-float{float:none}.mobile-no-margin{margin:0}.mobile-no-padding{padding:0}table th,table td{padding:4px}.no-mobile{display:none}.show-mobile{display:block}}@media print{*{background:transparent}a,a:visited{text-decoration:underline}abbr[title]:after{content:" (" attr(title) ")"}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100%}@page{margin:.5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}}html,body{height:100%}.absolute{position:absolute}.relative{position:relative}.full{width:100%}.no-scroll{overflow:hidden}.table{display:table;margin:0 auto}.xlarge-top{margin-top:60px}.large-top{margin-top:40px}.medium-top{margin-top:20px}.small-top{margin-top:10px}.mini-top{margin-top:5px}.no-left-padding{padding-left:0}.no-right-padding{padding-right:0}@media only screen and (max-width:739px){.mobile-hide{display:none}.mobile-xlarge-top{margin-top:60px}.mobile-large-top{margin-top:40px}.mobile-medium-top{margin-top:20px}.mobile-small-top{margin-top:10px}.mobile-mini-top{margin-top:5px}}html,body{font-family:'Roboto','Helvetica Neue','Arial','Helvetica','Lucida Grande',sans-serif;font-weight:300;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}h1,h2,h3,h4,h5{font-weight:300}p{margin:0 0 1em 0}pre,code{padding:5px 10px;color:#6e6e6e;font-size:14px;line-height:20px;font-weight:100;background:#f8f8f8;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}a{color:#333;text-decoration:none;-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out}a.active{color:#000}a:hover{color:#000}a:hover .fa-trash-o{color:#e2717f}a.primary{color:#e2717f}a.primary:hover{color:#d94759}img{max-width:100%}hr{margin:.5em 0;width:100%}i.right-padding{padding-right:10px}i.left-padding{padding-left:10px}.button{outline:0;padding:1em 1.5em;background:#fafafa;color:#333;white-space:nowrap;background-clip:padding-box;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.button.disabled,.button[disabled]{-moz-opacity:.7;-khtml-opacity:.7;-webkit-opacity:.7;opacity:.7;-ms-filter:alpha(opacity=70);filter:alpha(opacity=70);cursor:default}.button:hover:not(.disabled),.button:hover:not([disabled]){background:#d9d9d9}.button.large{padding:1em 4em}.button.small{padding:.6em .8em}.button.x-small{padding:.4em .6em}.button.primary-button{color:#fff;background:#e2717f}.button.primary-button:hover,.button.primary-button:focus{color:#f2f2f2;background:#de5c6c}.button.primary-button:hover.disabled,.button.primary-button:focus.disabled,.button.primary-button:hover:disabled,.button.primary-button:focus:disabled{background:#e2717f}.button.secondary-button{background:0;border:1px solid #eee}.button.secondary-button:hover:not(.active),.button.secondary-button:hover:not(.disabled),.button.secondary-button:hover:not(:disabled),.button.secondary-button:focus:not(.active),.button.secondary-button:focus:not(.disabled),.button.secondary-button:focus:not(:disabled){color:#666;background:#f8f8f8}.button.secondary-button.active{color:#595959;background:#ebebeb;border:1px solid #eee}.button.secondary-button.active:hover{color:#595959;background:#ebebeb;border:1px solid #eee}.button.remove-button{background:#e2717f;color:#fff;padding:.9em 1.5em}.button.remove-button:hover,.button.remove-button:focus{background:#de5c6c}.button.remove-button:hover.disabled,.button.remove-button:focus.disabled,.button.remove-button:hover:disabled,.button.remove-button:focus:disabled{background:#e2717f}.button.transparent-button{background:0;color:#fff;border:1px solid #f2f2f2}.button.transparent-button:hover:not(.disabled),.button.transparent-button:hover:not(:disabled){background:rgba(255,255,255,0.1);color:#fff}.button-group>.button{padding:.8em 1em;text-align:center;background:#fff;border-top:1px solid #eee;border-bottom:1px solid #eee;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.button-group>.button i.fa{margin-right:5px}.button-group>.button:first-child{border-left:1px solid #eee;-webkit-border-top-right-radius:0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:5px;-webkit-border-top-left-radius:5px;-moz-border-radius-topright:0;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:5px;-moz-border-radius-topleft:5px;border-top-right-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:5px;border-top-left-radius:5px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.button-group>.button:last-child{border-right:1px solid #eee;-webkit-border-top-right-radius:5px;-webkit-border-bottom-right-radius:5px;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:0;-moz-border-radius-topright:5px;-moz-border-radius-bottomright:5px;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:0;border-top-right-radius:5px;border-bottom-right-radius:5px;border-bottom-left-radius:0;border-top-left-radius:0;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.button-group>.button:hover:not(.active),.button-group>.button:focus:not(.active){color:#666;background:#f8f8f8}.button-group>.button.active{color:#595959;background:#ebebeb;border:1px solid #eee}.button-group>.button.active:hover{color:#595959;background:#ebebeb;border:1px solid #eee}.button-group.small>.button{padding:.6em .8em}.button-group.x-small>.button{padding:.4em .6em}form .col,form .input-wrapper{position:relative}form input,form input[type="text"],form input[type="password"],form input[type="email"],form input[type="search"],form input[type="tel"],form input[type="number"],form input[type="date"],form textarea{width:100%;padding:.8em .6em .6em;outline:0;border:1px solid #d3d3d3;font-size:1.1em;line-height:1;background:#fff;color:#666;-webkit-appearance:none;-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out}form input:focus,form input[type="text"]:focus,form input[type="password"]:focus,form input[type="email"]:focus,form input[type="search"]:focus,form input[type="tel"]:focus,form input[type="number"]:focus,form input[type="date"]:focus,form textarea:focus{color:#333;border:1px solid #a0a0a0;-moz-box-shadow:0 0 2px #a0a0a0;-webkit-box-shadow:0 0 2px #a0a0a0;box-shadow:0 0 2px #a0a0a0;-webkit-box-shadow:0 0 2px #a0a0a0 0 0 #000;box-shadow:0 0 2px #a0a0a0 0 0 #000}form input:focus+label,form input[type="text"]:focus+label,form input[type="password"]:focus+label,form input[type="email"]:focus+label,form input[type="search"]:focus+label,form input[type="tel"]:focus+label,form input[type="number"]:focus+label,form input[type="date"]:focus+label,form textarea:focus+label{color:#666;font-weight:400}form input.success,form input[type="text"].success,form input[type="password"].success,form input[type="email"].success,form input[type="search"].success,form input[type="tel"].success,form input[type="number"].success,form input[type="date"].success,form textarea.success{border:1px solid #43cea2;-moz-box-shadow:0 0 2px #43cea2;-webkit-box-shadow:0 0 2px #43cea2;box-shadow:0 0 2px #43cea2;-webkit-box-shadow:0 0 2px #43cea2 0 0 #000;box-shadow:0 0 2px #43cea2 0 0 #000}form input.success+label,form input[type="text"].success+label,form input[type="password"].success+label,form input[type="email"].success+label,form input[type="search"].success+label,form input[type="tel"].success+label,form input[type="number"].success+label,form input[type="date"].success+label,form textarea.success+label{color:#43cea2;font-weight:400}form input.error,form input[type="text"].error,form input[type="password"].error,form input[type="email"].error,form input[type="search"].error,form input[type="tel"].error,form input[type="number"].error,form input[type="date"].error,form textarea.error{border:1px solid #e2717f;-moz-box-shadow:0 0 2px #e2717f;-webkit-box-shadow:0 0 2px #e2717f;box-shadow:0 0 2px #e2717f;-webkit-box-shadow:0 0 2px #e2717f 0 0 #000;box-shadow:0 0 2px #e2717f 0 0 #000}form input.error+label,form input[type="text"].error+label,form input[type="password"].error+label,form input[type="email"].error+label,form input[type="search"].error+label,form input[type="tel"].error+label,form input[type="number"].error+label,form input[type="date"].error+label,form textarea.error+label{color:#e2717f;font-weight:400}form input::-webkit-input-placeholder,form input[type="text"]::-webkit-input-placeholder,form input[type="password"]::-webkit-input-placeholder,form input[type="email"]::-webkit-input-placeholder,form input[type="search"]::-webkit-input-placeholder,form input[type="tel"]::-webkit-input-placeholder,form input[type="number"]::-webkit-input-placeholder,form input[type="date"]::-webkit-input-placeholder,form textarea::-webkit-input-placeholder{color:#d3d3d3;font-weight:300}form [placeholder]:focus::-webkit-input-placeholder{-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out;opacity:0}form input[type="number"]::-webkit-inner-spin-button,form input[type="number"]::-webkit-outer-spin-button,form input[type="date"]::-webkit-inner-spin-button,form input[type="date"]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}form .select-style{position:relative;display:block;width:100%;border:1px solid #a0a0a0;background:#fff}form .select-style .fa-caret-down{position:absolute;right:.6em;top:.8em;color:#a0a0a0;font-size:1.4em}form .select-style select{padding:.8em 0;margin-left:.6em;width:100%;border:0;box-shadow:none;background:transparent;background-image:none;-webkit-appearance:none;color:#a0a0a0;font-size:1.2em}form .select-style select:hover{cursor:pointer}form .select-style select:focus{outline:0}form fieldset.row{padding:.5em 0}form label{position:absolute;left:5px;top:-5px;padding:0 5px;background:white;color:#a0a0a0;font-size:12px;line-height:12px;text-transform:uppercase;pointer-events:none;z-index:2}.modal-wrapper{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.3);display:none;z-index:1001;will-change:transform}.modal-wrapper .modal{position:relative;color:#333;display:none}.modal-wrapper .modal a.close{position:absolute;padding:6px 12px 9px;border:1px solid;border-radius:20px;font-weight:300;font-size:27px}.modal-wrapper .modal section.modal-content{padding:20px}.modal-wrapper:not(.fullscreen) .modal{min-height:300px;max-width:434px;margin:60px auto 0;background-color:#fff;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.modal-wrapper:not(.fullscreen) .modal a.close{right:-45px;top:-30px;color:#fff}.modal-wrapper.fullscreen{background:#fff}.modal-wrapper.fullscreen .modal{height:100%;overflow:auto}.modal-wrapper.fullscreen .modal a.close{right:20px;top:20px}.notice{position:fixed;bottom:0;right:10px;height:100px;width:300px;padding:5px 10px 5px 10px;display:none;color:#fff;z-index:1005;-webkit-border-top-right-radius:5px;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:5px;-moz-border-radius-topright:5px;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:5px;border-top-right-radius:5px;border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-left-radius:5px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.notice.success{background-color:#43cea2}.notice.warning{background-color:#f4ed6b}.notice.error{background-color:#e2717f}.notice header.notice-header{position:relative;margin-bottom:.2em}.notice section.notice-content{height:70px;width:100%;overflow:auto;font-size:.8em}.notice a.close{position:absolute;top:3px;right:0;padding:0 4px 2px;border:1px solid;border-radius:100%;font-weight:300;font-size:12px;line-height:12px;color:#fff}.notice a.close:hover{color:#ccc}nav{font-size:18px;font-size:1.125rem}nav .navbar{margin:0 auto;display:table;padding:10px 0}nav li{margin:0 10px}nav a{display:inline-block;line-height:60px;vertical-align:middle}nav a.logo{height:60px;width:60px}@media(max-width:739px){nav{font-size:14px;font-size:.875rem}nav a{line-height:40px}nav a.logo{height:40px;width:40px}}#toc{position:fixed;top:80px;height:100%;width:263px;overflow:auto;padding-bottom:100px}#toc a{color:#333}#toc a:hover{color:#1a1a1a}#toc li>ul{display:none}#toc li>ul.unstyled-list{margin-left:10px}#toc li.active>a{font-weight:bold}#toc li.active>ul{display:block}#toc ul.nav>li.active>ul>li{list-style:none}footer{padding:60px 0;color:#d3d3d3;background:#333}footer i.fa-heart{color:#e2717f}footer i.fa-beer{color:#f4ed6b}html,body{background:#fff;color:#333}.kd{color:#a783b6}.k{color:#43cea2}h1.logo{font-size:64px;font-size:4rem}.gist pre,.gist .file-data{font-size:14px!important}section{padding:40px 0}#hero .badges,#hero .github-links{padding:.3em 0}#hero .badges p,#hero .github-links p{margin:0}#ship h3{margin-bottom:1em}#ship img.ship-it{display:table;height:300px;width:300px;margin:0 auto;background:#d3d3d3;-webkit-border-radius:100%;-moz-border-radius:100%;border-radius:100%}#plugins{color:#fff;background:#333}#plugins p{color:#d3d3d3}#plugins ul li{padding:10px 20px}#plugins ul li a{display:inline-block}#plugins ul li a img{height:100px;max-width:160px}@media(max-width:739px){#plugins ul li a img{height:60px;max-width:120px}}#features{color:#fff;background:#e2717f}#features h4{color:#982e3e}#features a.primary{color:#f8f8f8;border-bottom:1px dashed #f8f8f8}#features a.primary:hover{color:#dfdfdf;border-bottom:1px dashed #dfdfdf}#features p{text-align:justify}#comparison img{margin:0 auto}.page a,.example a{color:#e2717f}.page a:hover,.example a:hover{color:#d94759}.page .file-data .line-numbers,.example .file-data .line-numbers{width:40px}#todo-example input[type="text"]{margin:10px 0}#todo-example ul.todos li{padding:5px 0}#todo-example ul.todos li input[type="checkbox"]{margin-top:.2em}#todo-example ul.todos li span{margin-left:5px}#todo-example .primary-button{width:100%} \ No newline at end of file diff --git a/learn/authentication.md b/learn/authentication.md new file mode 100644 index 0000000000..251ba3c346 --- /dev/null +++ b/learn/authentication.md @@ -0,0 +1,8 @@ +--- +layout: page +title: Authentication +description: Learn how to do user authentication and authorization +hide: true +--- + +# Authentication diff --git a/learn/authorization.md b/learn/authorization.md new file mode 100644 index 0000000000..ce1eb251be --- /dev/null +++ b/learn/authorization.md @@ -0,0 +1,8 @@ +--- +layout: page +title: Authorization +description: Learn how to authorize users +hide: true +--- + +# Authorization diff --git a/learn/mongodb.md b/learn/mongodb.md new file mode 100644 index 0000000000..483d251256 --- /dev/null +++ b/learn/mongodb.md @@ -0,0 +1,36 @@ +--- +layout: page +title: MongoDB +description: Learn how to connect to MongoDB +hide: true +--- + +## Persisting to MongoDB + +Our CRUD Todo functionality implemented in the service is very common and doesn't have to be re-done from scratch every time. In fact, this is almost exactly what is being provided already in the [feathers-memory](https://github.com/feathersjs/feathers-memory) module. Luckily we don't have to stop at storing everything in-memory. For the popular NoSQL database [MongoDB](http://mongodb.org) , for example, there already is the [feathers-mongodb](https://github.com/feathersjs/feathers-mongodb) module and if you need more ORM-like functionality through [Mongoose](http://mongoosejs.com/) you can also use [feathers-mongoose](https://github.com/feathersjs/feathers-mongoose). + +> `npm install feathers-mongodb` + +With a MongoDB instance running locally, we can replace our `todoService` in `app.js` with a MongoDB storage on the `feathers-demo` database and the `todos` collection like this: + +```js +// app.js +var feathers = require('feathers'); +var mongodb = require('feathers-mongodb'); +var bodyParser = require('body-parser'); + +var app = feathers(); +var todoService = mongodb({ + db: 'feathers-demo', + collection: 'todos' +}); + +app.configure(feathers.rest()) + .configure(feathers.socketio()) + .use(bodyParser.json()) + .use('/todos', todoService) + .use('/', feathers.static(__dirname)) + .listen(3000); +``` + +And just like this we have a full REST and real-time Todo API that stores its data into MongoDB in just 16 lines of code! We will continue using MongoDB so we don't need our example `todos.js` service anymore. diff --git a/learn/validation.md b/learn/validation.md new file mode 100644 index 0000000000..02371395fe --- /dev/null +++ b/learn/validation.md @@ -0,0 +1,8 @@ +--- +layout: page +title: Validation +description: Learn how to do Validation and data processing +hide: true +--- + +# Validation & Processing diff --git a/quick-start.md b/quick-start.md index e4f379f7c7..5ed89bd5ce 100644 --- a/quick-start.md +++ b/quick-start.md @@ -4,7 +4,6 @@ title: Quick Start description: Build your first Feathers app in minutes using our quick start guide. weight: 1 permalink: /quick-start/ -anchor: quick-start --- ## To get started @@ -278,36 +277,4 @@ After restarting, going directly to [localhost:3000](http://localhost:3000) with will also log `Someone created a new Todo`. This is how you can implement real-time functionality in any web page by using standardized websocket messages instead of having to make up your own. -## Persisting to MongoDB - -Our CRUD Todo functionality implemented in the service is very common and doesn't have to be re-done from scratch every time. In fact, this is almost exactly what is being provided already in the [feathers-memory](https://github.com/feathersjs/feathers-memory) module. Luckily we don't have to stop at storing everything in-memory. For the popular NoSQL database [MongoDB](http://mongodb.org) , for example, there already is the [feathers-mongodb](https://github.com/feathersjs/feathers-mongodb) module and if you need more ORM-like functionality through [Mongoose](http://mongoosejs.com/) you can also use [feathers-mongoose](https://github.com/feathersjs/feathers-mongoose). - -> `npm install feathers-mongodb` - -With a MongoDB instance running locally, we can replace our `todoService` in `app.js` with a MongoDB storage on the `feathers-demo` database and the `todos` collection like this: - -```js -// app.js -var feathers = require('feathers'); -var mongodb = require('feathers-mongodb'); -var bodyParser = require('body-parser'); - -var app = feathers(); -var todoService = mongodb({ - db: 'feathers-demo', - collection: 'todos' -}); - -app.configure(feathers.rest()) - .configure(feathers.socketio()) - .use(bodyParser.json()) - .use('/todos', todoService) - .use('/', feathers.static(__dirname)) - .listen(3000); -``` - -And just like this we have a full REST and real-time Todo API that stores its data into MongoDB in just 16 lines of code! We will continue using MongoDB so we don't need our example `todos.js` service anymore. - **[Learn more](/learn)** - - From d3fc487fec393b7df05f8b0b020019c5be7292f5 Mon Sep 17 00:00:00 2001 From: David Luecke Date: Mon, 13 Jul 2015 11:12:34 -0600 Subject: [PATCH 02/11] Splitting articles up and fixing Todo demo --- _layouts/index.html | 6 +- _less/common/sidebar.less | 2 +- _less/feathers.less | 16 ++ css/feathers.min.css | 2 +- js/todos.js | 6 +- learn.md | 310 -------------------------------------- learn/authentication.md | 179 +++++++++++++++++++++- learn/authorization.md | 54 ++++++- learn/validation.md | 81 +++++++++- 9 files changed, 334 insertions(+), 322 deletions(-) diff --git a/_layouts/index.html b/_layouts/index.html index f920b690f4..8321d496db 100644 --- a/_layouts/index.html +++ b/_layouts/index.html @@ -125,7 +125,7 @@

        Express

        Middleware

        -

        Use any Express middleware and Hooks, which follow the same pattern, for service data-processing and authorization that works via REST and websockets.

        +

        Use any Express middleware and Hooks, which follow the same pattern, for service data-processing and authorization that works both via REST and websockets.

        @@ -171,7 +171,7 @@
        "Once you go Meteor, you don't go back. And not in a good way

        Feathers vs Sails

        "If you love JSON config files, Sails is for you."

        - From a feature standpoint Feathers and Sails are probably the closest. Both provide real-time REST API's, multiple db support, and are client agnostic. Both frameworks also wrap Express, but Feathers supports Express 4, while Sails only supports Express 3. + From a feature standpoint Feathers and Sails are probably the closest. Both provide real-time REST API's, multiple db support, and are client agnostic. Both frameworks also use Express, but Feathers supports Express 4 (and the latest version in a branch), while Sails only supports Express 3.

        Even though the features are very similar, Feathers achieves this with MUCH less code, which means less stuff to break and maintain. We also don't assume how you want to manage your assets by letting you use your build tool of choice. Feathers provides lightweight services and hooks instead of a full-blown ORM, and we let you write code instead of long config files to define relationships and security policies. @@ -187,7 +187,7 @@

        "If you love JSON config files, Sails is for you."

        Feathers vs Express

        "I like Express because I love flexibility and boilerplate!"

        - Express is awesome! It does much of the heavy lifting behind Feathers; routing, content-negotiation, middleware support, etc. In fact, you can simply replace Express with Feathers in any existing application and start adding your own microservices. + Express is awesome! It does much of the heavy lifting behind Feathers; routing, content-negotiation, middleware support, etc. In fact, you can simply replace Express with Feathers in any existing application and start adding new microservices.

        Feathers eliminates a lot of the common boilerplate and gives you helpful plug-ins to make implementing common features easier, while also providing some convention. This includes stuff like managing permissions, CRUD for multiple databases, and real-time APIs using web sockets. Just like Express, Feathers gives you just enough to build your web app quickly but gets out of your way when you need to customize something. diff --git a/_less/common/sidebar.less b/_less/common/sidebar.less index 8885e68d2b..7cebe5f00a 100644 --- a/_less/common/sidebar.less +++ b/_less/common/sidebar.less @@ -2,7 +2,7 @@ position: fixed; top: 80px; height: 100%; - width: 263px; + width: 220px; // padding-top: 20px; overflow: auto; padding-bottom: 100px; diff --git a/_less/feathers.less b/_less/feathers.less index c11f2f3737..8cb286ef45 100644 --- a/_less/feathers.less +++ b/_less/feathers.less @@ -146,11 +146,14 @@ section { } #todo-example { + input[type="text"] { margin: 10px 0; } ul.todos { + height: 320px; + li { padding: 5px 0; @@ -161,9 +164,22 @@ section { span { margin-left: 5px; } + + &.done label { + text-decoration: line-through; + color: #998; + } + + .delete { + font-weight: bold; + } } } + label { + float: left; + } + .primary-button { width: 100%; } diff --git a/css/feathers.min.css b/css/feathers.min.css index bdc4ac7886..bb62fca957 100644 --- a/css/feathers.min.css +++ b/css/feathers.min.css @@ -1,4 +1,4 @@ .hll{background-color:#ffc}.c{color:#998;font-style:italic}.err{color:#a61717;background-color:#e3d2d2}.k{color:#000;font-weight:bold}.o{color:#000;font-weight:bold}.cm{color:#998;font-style:italic}.cp{color:#999;font-weight:bold;font-style:italic}.c1{color:#998;font-style:italic}.cs{color:#999;font-weight:bold;font-style:italic}.gd{color:#000;background-color:#fdd}.ge{color:#000;font-style:italic}.gr{color:#a00}.gh{color:#999}.gi{color:#000;background-color:#dfd}.go{color:#888}.gp{color:#555}.gs{font-weight:bold}.gu{color:#aaa}.gt{color:#a00}.kc{color:#000;font-weight:bold}.kd{color:#000;font-weight:bold}.kn{color:#000;font-weight:bold}.kp{color:#000;font-weight:bold}.kr{color:#000;font-weight:bold}.kt{color:#458;font-weight:bold}.m{color:#099}.s{color:#d01040}.na{color:#008080}.nb{color:#0086b3}.nc{color:#458;font-weight:bold}.no{color:#008080}.nd{color:#3c5d5d;font-weight:bold}.ni{color:#800080}.ne{color:#900;font-weight:bold}.nf{color:#900;font-weight:bold}.nl{color:#900;font-weight:bold}.nn{color:#555}.nt{color:#000080}.nv{color:#008080}.ow{color:#000;font-weight:bold}.w{color:#bbb}.mf{color:#099}.mh{color:#099}.mi{color:#099}.mo{color:#099}.sb{color:#d01040}.sc{color:#d01040}.sd{color:#d01040}.s2{color:#d01040}.se{color:#d01040}.sh{color:#d01040}.si{color:#d01040}.sx{color:#d01040}.sr{color:#009926}.s1{color:#d01040}.ss{color:#990073}.bp{color:#999}.vc{color:#008080}.vg{color:#008080}.vi{color:#008080}.il{color:#099}/*! * Font Awesome 4.3.0 by @davegandy - http://fontawesome.io - @fontawesome * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) - */@font-face{font-family:'FontAwesome';src:url('/fonts/fontawesome-webfont.eot?v=4.3.0');src:url('/fonts/fontawesome-webfont.eot?#iefix&v=4.3.0') format('embedded-opentype'),url('/fonts/fontawesome-webfont.woff2?v=4.3.0') format('woff2'),url('/fonts/fontawesome-webfont.woff?v=4.3.0') format('woff'),url('/fonts/fontawesome-webfont.ttf?v=4.3.0') format('truetype'),url('/fonts/fontawesome-webfont.svg?v=4.3.0#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;transform:translate(0,0)}.fa-lg{font-size:1.3333333333333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.2857142857142858em;text-align:center}.fa-ul{padding-left:0;margin-left:2.142857142857143em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.142857142857143em;width:2.142857142857143em;top:.14285714285714285em;text-align:center}.fa-li.fa-lg{left:-1.8571428571428572em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2);-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=0,mirror=1);-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.fa-flip-vertical{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2,mirror=1);-webkit-transform:scale(1,-1);-ms-transform:scale(1,-1);transform:scale(1,-1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-remove:before,.fa-close:before,.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook-f:before,.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{content:"\f09c"}.fa-credit-card:before{content:"\f09d"}.fa-rss:before{content:"\f09e"}.fa-hdd-o:before{content:"\f0a0"}.fa-bullhorn:before{content:"\f0a1"}.fa-bell:before{content:"\f0f3"}.fa-certificate:before{content:"\f0a3"}.fa-hand-o-right:before{content:"\f0a4"}.fa-hand-o-left:before{content:"\f0a5"}.fa-hand-o-up:before{content:"\f0a6"}.fa-hand-o-down:before{content:"\f0a7"}.fa-arrow-circle-left:before{content:"\f0a8"}.fa-arrow-circle-right:before{content:"\f0a9"}.fa-arrow-circle-up:before{content:"\f0aa"}.fa-arrow-circle-down:before{content:"\f0ab"}.fa-globe:before{content:"\f0ac"}.fa-wrench:before{content:"\f0ad"}.fa-tasks:before{content:"\f0ae"}.fa-filter:before{content:"\f0b0"}.fa-briefcase:before{content:"\f0b1"}.fa-arrows-alt:before{content:"\f0b2"}.fa-group:before,.fa-users:before{content:"\f0c0"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-cloud:before{content:"\f0c2"}.fa-flask:before{content:"\f0c3"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-copy:before,.fa-files-o:before{content:"\f0c5"}.fa-paperclip:before{content:"\f0c6"}.fa-save:before,.fa-floppy-o:before{content:"\f0c7"}.fa-square:before{content:"\f0c8"}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:"\f0c9"}.fa-list-ul:before{content:"\f0ca"}.fa-list-ol:before{content:"\f0cb"}.fa-strikethrough:before{content:"\f0cc"}.fa-underline:before{content:"\f0cd"}.fa-table:before{content:"\f0ce"}.fa-magic:before{content:"\f0d0"}.fa-truck:before{content:"\f0d1"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-google-plus-square:before{content:"\f0d4"}.fa-google-plus:before{content:"\f0d5"}.fa-money:before{content:"\f0d6"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-columns:before{content:"\f0db"}.fa-unsorted:before,.fa-sort:before{content:"\f0dc"}.fa-sort-down:before,.fa-sort-desc:before{content:"\f0dd"}.fa-sort-up:before,.fa-sort-asc:before{content:"\f0de"}.fa-envelope:before{content:"\f0e0"}.fa-linkedin:before{content:"\f0e1"}.fa-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-legal:before,.fa-gavel:before{content:"\f0e3"}.fa-dashboard:before,.fa-tachometer:before{content:"\f0e4"}.fa-comment-o:before{content:"\f0e5"}.fa-comments-o:before{content:"\f0e6"}.fa-flash:before,.fa-bolt:before{content:"\f0e7"}.fa-sitemap:before{content:"\f0e8"}.fa-umbrella:before{content:"\f0e9"}.fa-paste:before,.fa-clipboard:before{content:"\f0ea"}.fa-lightbulb-o:before{content:"\f0eb"}.fa-exchange:before{content:"\f0ec"}.fa-cloud-download:before{content:"\f0ed"}.fa-cloud-upload:before{content:"\f0ee"}.fa-user-md:before{content:"\f0f0"}.fa-stethoscope:before{content:"\f0f1"}.fa-suitcase:before{content:"\f0f2"}.fa-bell-o:before{content:"\f0a2"}.fa-coffee:before{content:"\f0f4"}.fa-cutlery:before{content:"\f0f5"}.fa-file-text-o:before{content:"\f0f6"}.fa-building-o:before{content:"\f0f7"}.fa-hospital-o:before{content:"\f0f8"}.fa-ambulance:before{content:"\f0f9"}.fa-medkit:before{content:"\f0fa"}.fa-fighter-jet:before{content:"\f0fb"}.fa-beer:before{content:"\f0fc"}.fa-h-square:before{content:"\f0fd"}.fa-plus-square:before{content:"\f0fe"}.fa-angle-double-left:before{content:"\f100"}.fa-angle-double-right:before{content:"\f101"}.fa-angle-double-up:before{content:"\f102"}.fa-angle-double-down:before{content:"\f103"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}.fa-angle-up:before{content:"\f106"}.fa-angle-down:before{content:"\f107"}.fa-desktop:before{content:"\f108"}.fa-laptop:before{content:"\f109"}.fa-tablet:before{content:"\f10a"}.fa-mobile-phone:before,.fa-mobile:before{content:"\f10b"}.fa-circle-o:before{content:"\f10c"}.fa-quote-left:before{content:"\f10d"}.fa-quote-right:before{content:"\f10e"}.fa-spinner:before{content:"\f110"}.fa-circle:before{content:"\f111"}.fa-mail-reply:before,.fa-reply:before{content:"\f112"}.fa-github-alt:before{content:"\f113"}.fa-folder-o:before{content:"\f114"}.fa-folder-open-o:before{content:"\f115"}.fa-smile-o:before{content:"\f118"}.fa-frown-o:before{content:"\f119"}.fa-meh-o:before{content:"\f11a"}.fa-gamepad:before{content:"\f11b"}.fa-keyboard-o:before{content:"\f11c"}.fa-flag-o:before{content:"\f11d"}.fa-flag-checkered:before{content:"\f11e"}.fa-terminal:before{content:"\f120"}.fa-code:before{content:"\f121"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"\f122"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"\f123"}.fa-location-arrow:before{content:"\f124"}.fa-crop:before{content:"\f125"}.fa-code-fork:before{content:"\f126"}.fa-unlink:before,.fa-chain-broken:before{content:"\f127"}.fa-question:before{content:"\f128"}.fa-info:before{content:"\f129"}.fa-exclamation:before{content:"\f12a"}.fa-superscript:before{content:"\f12b"}.fa-subscript:before{content:"\f12c"}.fa-eraser:before{content:"\f12d"}.fa-puzzle-piece:before{content:"\f12e"}.fa-microphone:before{content:"\f130"}.fa-microphone-slash:before{content:"\f131"}.fa-shield:before{content:"\f132"}.fa-calendar-o:before{content:"\f133"}.fa-fire-extinguisher:before{content:"\f134"}.fa-rocket:before{content:"\f135"}.fa-maxcdn:before{content:"\f136"}.fa-chevron-circle-left:before{content:"\f137"}.fa-chevron-circle-right:before{content:"\f138"}.fa-chevron-circle-up:before{content:"\f139"}.fa-chevron-circle-down:before{content:"\f13a"}.fa-html5:before{content:"\f13b"}.fa-css3:before{content:"\f13c"}.fa-anchor:before{content:"\f13d"}.fa-unlock-alt:before{content:"\f13e"}.fa-bullseye:before{content:"\f140"}.fa-ellipsis-h:before{content:"\f141"}.fa-ellipsis-v:before{content:"\f142"}.fa-rss-square:before{content:"\f143"}.fa-play-circle:before{content:"\f144"}.fa-ticket:before{content:"\f145"}.fa-minus-square:before{content:"\f146"}.fa-minus-square-o:before{content:"\f147"}.fa-level-up:before{content:"\f148"}.fa-level-down:before{content:"\f149"}.fa-check-square:before{content:"\f14a"}.fa-pencil-square:before{content:"\f14b"}.fa-external-link-square:before{content:"\f14c"}.fa-share-square:before{content:"\f14d"}.fa-compass:before{content:"\f14e"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"\f150"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"\f151"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"\f152"}.fa-euro:before,.fa-eur:before{content:"\f153"}.fa-gbp:before{content:"\f154"}.fa-dollar:before,.fa-usd:before{content:"\f155"}.fa-rupee:before,.fa-inr:before{content:"\f156"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"\f157"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"\f158"}.fa-won:before,.fa-krw:before{content:"\f159"}.fa-bitcoin:before,.fa-btc:before{content:"\f15a"}.fa-file:before{content:"\f15b"}.fa-file-text:before{content:"\f15c"}.fa-sort-alpha-asc:before{content:"\f15d"}.fa-sort-alpha-desc:before{content:"\f15e"}.fa-sort-amount-asc:before{content:"\f160"}.fa-sort-amount-desc:before{content:"\f161"}.fa-sort-numeric-asc:before{content:"\f162"}.fa-sort-numeric-desc:before{content:"\f163"}.fa-thumbs-up:before{content:"\f164"}.fa-thumbs-down:before{content:"\f165"}.fa-youtube-square:before{content:"\f166"}.fa-youtube:before{content:"\f167"}.fa-xing:before{content:"\f168"}.fa-xing-square:before{content:"\f169"}.fa-youtube-play:before{content:"\f16a"}.fa-dropbox:before{content:"\f16b"}.fa-stack-overflow:before{content:"\f16c"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-adn:before{content:"\f170"}.fa-bitbucket:before{content:"\f171"}.fa-bitbucket-square:before{content:"\f172"}.fa-tumblr:before{content:"\f173"}.fa-tumblr-square:before{content:"\f174"}.fa-long-arrow-down:before{content:"\f175"}.fa-long-arrow-up:before{content:"\f176"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-apple:before{content:"\f179"}.fa-windows:before{content:"\f17a"}.fa-android:before{content:"\f17b"}.fa-linux:before{content:"\f17c"}.fa-dribbble:before{content:"\f17d"}.fa-skype:before{content:"\f17e"}.fa-foursquare:before{content:"\f180"}.fa-trello:before{content:"\f181"}.fa-female:before{content:"\f182"}.fa-male:before{content:"\f183"}.fa-gittip:before,.fa-gratipay:before{content:"\f184"}.fa-sun-o:before{content:"\f185"}.fa-moon-o:before{content:"\f186"}.fa-archive:before{content:"\f187"}.fa-bug:before{content:"\f188"}.fa-vk:before{content:"\f189"}.fa-weibo:before{content:"\f18a"}.fa-renren:before{content:"\f18b"}.fa-pagelines:before{content:"\f18c"}.fa-stack-exchange:before{content:"\f18d"}.fa-arrow-circle-o-right:before{content:"\f18e"}.fa-arrow-circle-o-left:before{content:"\f190"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:"\f191"}.fa-dot-circle-o:before{content:"\f192"}.fa-wheelchair:before{content:"\f193"}.fa-vimeo-square:before{content:"\f194"}.fa-turkish-lira:before,.fa-try:before{content:"\f195"}.fa-plus-square-o:before{content:"\f196"}.fa-space-shuttle:before{content:"\f197"}.fa-slack:before{content:"\f198"}.fa-envelope-square:before{content:"\f199"}.fa-wordpress:before{content:"\f19a"}.fa-openid:before{content:"\f19b"}.fa-institution:before,.fa-bank:before,.fa-university:before{content:"\f19c"}.fa-mortar-board:before,.fa-graduation-cap:before{content:"\f19d"}.fa-yahoo:before{content:"\f19e"}.fa-google:before{content:"\f1a0"}.fa-reddit:before{content:"\f1a1"}.fa-reddit-square:before{content:"\f1a2"}.fa-stumbleupon-circle:before{content:"\f1a3"}.fa-stumbleupon:before{content:"\f1a4"}.fa-delicious:before{content:"\f1a5"}.fa-digg:before{content:"\f1a6"}.fa-pied-piper:before{content:"\f1a7"}.fa-pied-piper-alt:before{content:"\f1a8"}.fa-drupal:before{content:"\f1a9"}.fa-joomla:before{content:"\f1aa"}.fa-language:before{content:"\f1ab"}.fa-fax:before{content:"\f1ac"}.fa-building:before{content:"\f1ad"}.fa-child:before{content:"\f1ae"}.fa-paw:before{content:"\f1b0"}.fa-spoon:before{content:"\f1b1"}.fa-cube:before{content:"\f1b2"}.fa-cubes:before{content:"\f1b3"}.fa-behance:before{content:"\f1b4"}.fa-behance-square:before{content:"\f1b5"}.fa-steam:before{content:"\f1b6"}.fa-steam-square:before{content:"\f1b7"}.fa-recycle:before{content:"\f1b8"}.fa-automobile:before,.fa-car:before{content:"\f1b9"}.fa-cab:before,.fa-taxi:before{content:"\f1ba"}.fa-tree:before{content:"\f1bb"}.fa-spotify:before{content:"\f1bc"}.fa-deviantart:before{content:"\f1bd"}.fa-soundcloud:before{content:"\f1be"}.fa-database:before{content:"\f1c0"}.fa-file-pdf-o:before{content:"\f1c1"}.fa-file-word-o:before{content:"\f1c2"}.fa-file-excel-o:before{content:"\f1c3"}.fa-file-powerpoint-o:before{content:"\f1c4"}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:"\f1c5"}.fa-file-zip-o:before,.fa-file-archive-o:before{content:"\f1c6"}.fa-file-sound-o:before,.fa-file-audio-o:before{content:"\f1c7"}.fa-file-movie-o:before,.fa-file-video-o:before{content:"\f1c8"}.fa-file-code-o:before{content:"\f1c9"}.fa-vine:before{content:"\f1ca"}.fa-codepen:before{content:"\f1cb"}.fa-jsfiddle:before{content:"\f1cc"}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:"\f1cd"}.fa-circle-o-notch:before{content:"\f1ce"}.fa-ra:before,.fa-rebel:before{content:"\f1d0"}.fa-ge:before,.fa-empire:before{content:"\f1d1"}.fa-git-square:before{content:"\f1d2"}.fa-git:before{content:"\f1d3"}.fa-hacker-news:before{content:"\f1d4"}.fa-tencent-weibo:before{content:"\f1d5"}.fa-qq:before{content:"\f1d6"}.fa-wechat:before,.fa-weixin:before{content:"\f1d7"}.fa-send:before,.fa-paper-plane:before{content:"\f1d8"}.fa-send-o:before,.fa-paper-plane-o:before{content:"\f1d9"}.fa-history:before{content:"\f1da"}.fa-genderless:before,.fa-circle-thin:before{content:"\f1db"}.fa-header:before{content:"\f1dc"}.fa-paragraph:before{content:"\f1dd"}.fa-sliders:before{content:"\f1de"}.fa-share-alt:before{content:"\f1e0"}.fa-share-alt-square:before{content:"\f1e1"}.fa-bomb:before{content:"\f1e2"}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:"\f1e3"}.fa-tty:before{content:"\f1e4"}.fa-binoculars:before{content:"\f1e5"}.fa-plug:before{content:"\f1e6"}.fa-slideshare:before{content:"\f1e7"}.fa-twitch:before{content:"\f1e8"}.fa-yelp:before{content:"\f1e9"}.fa-newspaper-o:before{content:"\f1ea"}.fa-wifi:before{content:"\f1eb"}.fa-calculator:before{content:"\f1ec"}.fa-paypal:before{content:"\f1ed"}.fa-google-wallet:before{content:"\f1ee"}.fa-cc-visa:before{content:"\f1f0"}.fa-cc-mastercard:before{content:"\f1f1"}.fa-cc-discover:before{content:"\f1f2"}.fa-cc-amex:before{content:"\f1f3"}.fa-cc-paypal:before{content:"\f1f4"}.fa-cc-stripe:before{content:"\f1f5"}.fa-bell-slash:before{content:"\f1f6"}.fa-bell-slash-o:before{content:"\f1f7"}.fa-trash:before{content:"\f1f8"}.fa-copyright:before{content:"\f1f9"}.fa-at:before{content:"\f1fa"}.fa-eyedropper:before{content:"\f1fb"}.fa-paint-brush:before{content:"\f1fc"}.fa-birthday-cake:before{content:"\f1fd"}.fa-area-chart:before{content:"\f1fe"}.fa-pie-chart:before{content:"\f200"}.fa-line-chart:before{content:"\f201"}.fa-lastfm:before{content:"\f202"}.fa-lastfm-square:before{content:"\f203"}.fa-toggle-off:before{content:"\f204"}.fa-toggle-on:before{content:"\f205"}.fa-bicycle:before{content:"\f206"}.fa-bus:before{content:"\f207"}.fa-ioxhost:before{content:"\f208"}.fa-angellist:before{content:"\f209"}.fa-cc:before{content:"\f20a"}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:"\f20b"}.fa-meanpath:before{content:"\f20c"}.fa-buysellads:before{content:"\f20d"}.fa-connectdevelop:before{content:"\f20e"}.fa-dashcube:before{content:"\f210"}.fa-forumbee:before{content:"\f211"}.fa-leanpub:before{content:"\f212"}.fa-sellsy:before{content:"\f213"}.fa-shirtsinbulk:before{content:"\f214"}.fa-simplybuilt:before{content:"\f215"}.fa-skyatlas:before{content:"\f216"}.fa-cart-plus:before{content:"\f217"}.fa-cart-arrow-down:before{content:"\f218"}.fa-diamond:before{content:"\f219"}.fa-ship:before{content:"\f21a"}.fa-user-secret:before{content:"\f21b"}.fa-motorcycle:before{content:"\f21c"}.fa-street-view:before{content:"\f21d"}.fa-heartbeat:before{content:"\f21e"}.fa-venus:before{content:"\f221"}.fa-mars:before{content:"\f222"}.fa-mercury:before{content:"\f223"}.fa-transgender:before{content:"\f224"}.fa-transgender-alt:before{content:"\f225"}.fa-venus-double:before{content:"\f226"}.fa-mars-double:before{content:"\f227"}.fa-venus-mars:before{content:"\f228"}.fa-mars-stroke:before{content:"\f229"}.fa-mars-stroke-v:before{content:"\f22a"}.fa-mars-stroke-h:before{content:"\f22b"}.fa-neuter:before{content:"\f22c"}.fa-facebook-official:before{content:"\f230"}.fa-pinterest-p:before{content:"\f231"}.fa-whatsapp:before{content:"\f232"}.fa-server:before{content:"\f233"}.fa-user-plus:before{content:"\f234"}.fa-user-times:before{content:"\f235"}.fa-hotel:before,.fa-bed:before{content:"\f236"}.fa-viacoin:before{content:"\f237"}.fa-train:before{content:"\f238"}.fa-subway:before{content:"\f239"}.fa-medium:before{content:"\f23a"}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}html,button,input,select,textarea{font-family:sans-serif}body,form,fieldset,legend,input,select,textarea,button{margin:0}html{font-size:100%}body{font-family:sans-serif;font-size:16px;font-size:1rem;line-height:21px;line-height:1.3125rem;color:#434343;background-color:#fff;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}b,strong{font-weight:700}i,em,.em{font-style:italic}a{color:#669fcf}a:hover{text-decoration:none}a:focus{outline:0}a:active,a:hover{outline:0}p{margin:0 0 1.6em 0}pre{margin:1em 0}ul+p,ul+pre,ol+p,ol+pre{margin-top:0}small{font-size:80%}abbr[title]{border-bottom:1px dotted}audio,canvas,video{display:inline-block;*zoom:1;*display:inline}audio:not([controls]){display:none;height:0}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}dfn{font-style:italic}img{border:0;-ms-interpolation-mode:bicubic}svg:not(:root){overflow:hidden}figure{margin:0}.image-left{margin-right:20px}.image-right{margin-left:20px}h1,h2,h3,h4,h5,h6{line-height:normal;font-weight:normal;margin:0 0 .33em 0}h1,.h1{font-size:40px;font-size:2.5rem}h2,.h2{font-size:32px;font-size:2rem}h3,.h3{font-size:26px;font-size:1.625rem}h4,.h4{font-size:20px;font-size:1.25rem}h5,.h5{font-size:18px;font-size:1.125rem}h6,.h6{font-size:16px;font-size:1rem}.no-style-heading{margin:0;font-size:100%}hr{border:0;background:0;outline:0;background-color:#ddd;margin:2em 0;*margin:1em 0;-moz-box-sizing:content-box;box-sizing:content-box;height:1px}blockquote{font-size:22px;font-size:1.375rem;line-height:32px;line-height:2rem;color:#434343;margin:1em 0;font-style:italic}blockquote p{margin:1em 0}cite{color:#434343;font-style:normal;font-weight:normal;font-size:16px;font-size:1rem;line-height:normal}q{font-style:italic;quotes:none}q:before,q:after{content:'';content:none}mark{background:#ff0;color:#111}code,kbd,pre,samp{word-wrap:break-word;font-family:'courier new',monospace,serif;font-size:13px;font-size:.8125rem;line-height:normal;font-weight:normal;background-color:#f1f1f1;padding:10px}code{color:#111}dl,menu,ol,ul{margin:1em 0}dd,ul ul,ol ol,ul ol,ol ul{margin:0}dt{font-weight:normal}dd{margin-bottom:1em}menu,ol,ul{padding:0 0 0 22px}nav ul,nav ol{list-style:none;list-style-image:none}.unstyled-list{list-style:none;padding:0;margin:0}.unstyled-list li{margin-top:0;margin-bottom:0}.inline-list{list-style:none;padding:0;margin:0;display:inline-block;*zoom:1;*display:inline}.inline-list li{margin-top:0;margin-bottom:0}.inline-list li{display:inline-block;*zoom:1;*display:inline}table{width:100%;margin:1em 0;table-layout:fixed;border-collapse:collapse;border-spacing:0;border-right:1px solid #f1f1f1;border-bottom:1px solid #f1f1f1;word-wrap:break-word;-ms-word-wrap:break-word;*white-space:normal}table th,table td{padding:8px;text-align:left;vertical-align:top;border-top:1px solid #eee;border-left:1px solid #eee}table thead th,table tfoot th{vertical-align:bottom;font-weight:normal;background-color:#f1f1f1;color:#333}table caption{padding:8px;font-style:normal;text-align:left;font-weight:normal;border-bottom:0}fieldset{border:0;padding:0}legend{border:0;padding:0;white-space:normal;*margin-left:-7px;font-weight:normal}label{margin:0;cursor:pointer}button,input,select,textarea{font-size:100%;vertical-align:baseline;*vertical-align:middle}input[type=text],input[type=password],input[type=email],input[type=search],input[type=tel],textarea{padding:5px;-webkit-appearance:none;-moz-appearance:none;font-weight:normal;line-height:normal;background-color:#fff;border:1px solid #ccc;color:#111}input[type=checkbox],input[type=radio]{cursor:pointer;box-sizing:border-box;line-height:normal;margin:0;padding:0;*height:13px;*width:13px}.checkbox{display:block;margin:.2em 0}.checkbox input[type=checkbox],.checkbox input[type=radio]{margin-top:.05em;float:left}.checkbox label{padding-left:5px;overflow:hidden;display:table;*zoom:1}button,input{line-height:normal}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer;*overflow:visible}button[disabled],html input[disabled]{cursor:default}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top;resize:none}.button{border:0;padding:1em 3em;background-color:#e74b3c;color:#fff;text-decoration:none;text-align:center;display:inline-block;*zoom:1;*display:inline;position:relative}.button:hover{background-color:#fc5547}.button:active{top:1px}.grey-button{background-color:#eee;color:#434343}.grey-button:hover{background-color:#f1f1f1}.button[disabled],.button.disabled{color:#999;background-color:#f1f1f1}.unstyled-button{font-size:16px;font-size:1rem;color:#27ae61;text-decoration:underline;border:0;background:transparent;height:auto;padding:0;cursor:pointer;outline:0}.unstyled-button:hover{text-decoration:none}.unstyled-button[disabled],.unstyled-button.disabled{text-decoration:none;color:#999;background-color:#ccc}.section{position:relative}.container{max-width:960px;margin-left:auto;margin-right:auto;padding-left:10px;padding-right:10px}.container-full{max-width:960px;margin-left:auto;margin-right:auto}.col{float:left;padding-left:10px;padding-right:10px}[class*="pull-"],[class*="push-"]{position:relative}.no-gutter{padding-left:0;padding-right:0}.col-1{width:8.33333%;width:calc(8.333333333333334%);width:-webkit-calc(8.333333333333334%);width:-moz-calc(8.333333333333334%)}.col-2{width:16.66667%;width:calc(16.666666666666668%);width:-webkit-calc(16.666666666666668%);width:-moz-calc(16.666666666666668%)}.col-3{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.col-4{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.col-5{width:41.66665%;width:calc(41.66666666666667%);width:-webkit-calc(41.66666666666667%);width:-moz-calc(41.66666666666667%)}.col-6{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.col-7{width:58.33333%;width:calc(58.333333333333336%);width:-webkit-calc(58.333333333333336%);width:-moz-calc(58.333333333333336%)}.col-8{width:66.66666%;width:calc(66.66666666666667%);width:-webkit-calc(66.66666666666667%);width:-moz-calc(66.66666666666667%)}.col-9{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.col-10{width:83.33333%;width:calc(83.33333333333334%);width:-webkit-calc(83.33333333333334%);width:-moz-calc(83.33333333333334%)}.col-11{width:91.66666%;width:calc(91.66666666666667%);width:-webkit-calc(91.66666666666667%);width:-moz-calc(91.66666666666667%)}.col-12{width:100%}.col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.push-1{left:8.33333%;left:calc(8.333333333333334%);left:-webkit-calc(8.333333333333334%);left:-moz-calc(8.333333333333334%)}.pull-1{left:-8.33333%;left:calc(-8.333333333333334%);left:-webkit-calc(-8.333333333333334%);left:-moz-calc(-8.333333333333334%)}.push-2{left:16.66667%;left:calc(16.666666666666668%);left:-webkit-calc(16.666666666666668%);left:-moz-calc(16.666666666666668%)}.pull-2{left:-16.66667%;left:calc(-16.666666666666668%);left:-webkit-calc(-16.666666666666668%);left:-moz-calc(-16.666666666666668%)}.push-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.pull-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.push-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.pull-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.push-5{left:41.66665%;left:calc(41.66666666666667%);left:-webkit-calc(41.66666666666667%);left:-moz-calc(41.66666666666667%)}.pull-5{left:-41.66665%;left:calc(-41.66666666666667%);left:-webkit-calc(-41.66666666666667%);left:-moz-calc(-41.66666666666667%)}.push-6{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.pull-6{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.push-7{left:58.33333%;left:calc(58.333333333333336%);left:-webkit-calc(58.333333333333336%);left:-moz-calc(58.333333333333336%)}.pull-7{left:-58.33333%;left:calc(-58.333333333333336%);left:-webkit-calc(-58.333333333333336%);left:-moz-calc(-58.333333333333336%)}.push-8{left:66.66666%;left:calc(66.66666666666667%);left:-webkit-calc(66.66666666666667%);left:-moz-calc(66.66666666666667%)}.pull-8{left:-66.66666%;left:calc(-66.66666666666667%);left:-webkit-calc(-66.66666666666667%);left:-moz-calc(-66.66666666666667%)}.push-9{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.pull-9{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.push-10{left:83.33333%;left:calc(83.33333333333334%);left:-webkit-calc(83.33333333333334%);left:-moz-calc(83.33333333333334%)}.pull-10{left:-83.33333%;left:calc(-83.33333333333334%);left:-webkit-calc(-83.33333333333334%);left:-moz-calc(-83.33333333333334%)}.push-11{left:91.66666%;left:calc(91.66666666666667%);left:-webkit-calc(91.66666666666667%);left:-moz-calc(91.66666666666667%)}.pull-11{left:-91.66666%;left:calc(-91.66666666666667%);left:-webkit-calc(-91.66666666666667%);left:-moz-calc(-91.66666666666667%)}.row{padding-top:1em;padding-bottom:1em}.clear:before,.clear:after{content:"";display:table}.clear:after{clear:both}.clear{zoom:1}.left{float:left}.right{float:right}.block{display:block}.inline{display:inline}.inline-block{display:inline-block;*zoom:1;*display:inline}.none,.hidden,[hidden],.no-desktop{display:none}.heavy{font-weight:900}.strong{font-weight:700}.normal{font-weight:normal}.thin{font-weight:300}.fine{font-weight:100}.italic{font-style:italic}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.left-text{text-align:left}.right-text{text-align:right}.center-text{text-align:center}.justify-text{text-align:justify}.visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;overflow:hidden;padding:0;position:absolute;width:1px;left:-9999em}.visuallyvisible{clip:auto;width:auto;height:auto;overflow:visible;left:0}.no-margin{margin:0}.no-padding{padding:0}@media only screen and (min-width:740px) and (max-width:960px){.container,.tablet-container{max-width:960px;padding-left:20px;padding-right:20px;margin-left:auto;margin-right:auto;float:none}.container:first-child,.tablet-container:first-child{margin-left:auto}.tablet-container-full{padding-left:0;padding-right:0;margin-left:auto;margin-right:auto;float:none}.tablet-container-full:first-child{margin-left:auto}.tablet-no-gutter{padding-left:0;padding-right:0}.tablet-col-1{width:8.33333%;width:calc(8.333333333333334%);width:-webkit-calc(8.333333333333334%);width:-moz-calc(8.333333333333334%)}.tablet-col-2{width:16.66667%;width:calc(16.666666666666668%);width:-webkit-calc(16.666666666666668%);width:-moz-calc(16.666666666666668%)}.tablet-col-3{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.tablet-col-4{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.tablet-col-5{width:41.66665%;width:calc(41.66666666666667%);width:-webkit-calc(41.66666666666667%);width:-moz-calc(41.66666666666667%)}.tablet-col-6{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.tablet-col-7{width:58.33333%;width:calc(58.333333333333336%);width:-webkit-calc(58.333333333333336%);width:-moz-calc(58.333333333333336%)}.tablet-col-8{width:66.66666%;width:calc(66.66666666666667%);width:-webkit-calc(66.66666666666667%);width:-moz-calc(66.66666666666667%)}.tablet-col-9{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.tablet-col-10{width:83.33333%;width:calc(83.33333333333334%);width:-webkit-calc(83.33333333333334%);width:-moz-calc(83.33333333333334%)}.tablet-col-11{width:91.66666%;width:calc(91.66666666666667%);width:-webkit-calc(91.66666666666667%);width:-moz-calc(91.66666666666667%)}.tablet-col-12{width:100%}.tablet-col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.tablet-col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.tablet-col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.tablet-col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.tablet-push-1{left:8.33333%;left:calc(8.333333333333334%);left:-webkit-calc(8.333333333333334%);left:-moz-calc(8.333333333333334%)}.tablet-pull-1{left:-8.33333%;left:calc(-8.333333333333334%);left:-webkit-calc(-8.333333333333334%);left:-moz-calc(-8.333333333333334%)}.tablet-push-2{left:16.66667%;left:calc(16.666666666666668%);left:-webkit-calc(16.666666666666668%);left:-moz-calc(16.666666666666668%)}.tablet-pull-2{left:-16.66667%;left:calc(-16.666666666666668%);left:-webkit-calc(-16.666666666666668%);left:-moz-calc(-16.666666666666668%)}.tablet-push-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.tablet-pull-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.tablet-push-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.tablet-pull-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.tablet-push-5{left:41.66665%;left:calc(41.66666666666667%);left:-webkit-calc(41.66666666666667%);left:-moz-calc(41.66666666666667%)}.tablet-pull-5{left:-41.66665%;left:calc(-41.66666666666667%);left:-webkit-calc(-41.66666666666667%);left:-moz-calc(-41.66666666666667%)}.tablet-push-6{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.tablet-pull-6{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.tablet-push-7{left:58.33333%;left:calc(58.333333333333336%);left:-webkit-calc(58.333333333333336%);left:-moz-calc(58.333333333333336%)}.tablet-pull-7{left:-58.33333%;left:calc(-58.333333333333336%);left:-webkit-calc(-58.333333333333336%);left:-moz-calc(-58.333333333333336%)}.tablet-push-8{left:66.66666%;left:calc(66.66666666666667%);left:-webkit-calc(66.66666666666667%);left:-moz-calc(66.66666666666667%)}.tablet-pull-8{left:-66.66666%;left:calc(-66.66666666666667%);left:-webkit-calc(-66.66666666666667%);left:-moz-calc(-66.66666666666667%)}.tablet-push-9{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.tablet-pull-9{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.tablet-push-10{left:83.33333%;left:calc(83.33333333333334%);left:-webkit-calc(83.33333333333334%);left:-moz-calc(83.33333333333334%)}.tablet-pull-10{left:-83.33333%;left:calc(-83.33333333333334%);left:-webkit-calc(-83.33333333333334%);left:-moz-calc(-83.33333333333334%)}.tablet-push-11{left:91.66666%;left:calc(91.66666666666667%);left:-webkit-calc(91.66666666666667%);left:-moz-calc(91.66666666666667%)}.tablet-pull-11{left:-91.66666%;left:calc(-91.66666666666667%);left:-webkit-calc(-91.66666666666667%);left:-moz-calc(-91.66666666666667%)}.tablet-no-push,.tablet-no-pull{left:auto}.tablet-row{padding-top:1em;padding-bottom:1em}.tablet-full{left:auto;clear:both;float:none;width:100%;margin:1em 0 0 0;display:block}.tablet-full:first-child{margin-top:0}.tablet-left-text{text-align:left}.tablet-right-text{text-align:right}.tablet-center-text{text-align:center}.tablet-left{float:left}.tablet-right{float:right}.tablet-no-float{float:none}.tablet-no-margin{margin:0}.tablet-no-padding{padding:0}.no-tablet{display:none}.show-tablet{display:block}}@media only screen and (max-width:739px){.container,.mobile-container{padding-left:20px;padding-right:20px;margin-left:auto;margin-right:auto;float:none}.container:first-child,.mobile-container:first-child{margin-left:auto}.mobile-container-full{padding-left:0;padding-right:0;margin-left:auto;margin-right:auto;float:none}.mobile-container-full:first-child{margin-left:auto}.mobile-no-gutter{padding-left:0;padding-right:0}.mobile-col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.mobile-col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.mobile-col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.mobile-col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.mobile-push-1-2{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.mobile-pull-1-2{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.mobile-push-1-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.mobile-pull-1-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.mobile-push-1-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.mobile-pull-1-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.mobile-push-3-4{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.mobile-pull-3-4{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.mobile-no-push,.mobile-no-pull{left:auto}.mobile-row{padding-top:1em;padding-bottom:1em}.mobile-full{left:auto;clear:both;float:none;width:100%;margin:.2em 0 0 0;display:block}.mobile-full:first-child{margin-top:0}.mobile-left-text{text-align:left}.mobile-right-text{text-align:right}.mobile-center-text{text-align:center}.mobile-left{float:left}.mobile-right{float:right}.mobile-no-float{float:none}.mobile-no-margin{margin:0}.mobile-no-padding{padding:0}table th,table td{padding:4px}.no-mobile{display:none}.show-mobile{display:block}}@media print{*{background:transparent}a,a:visited{text-decoration:underline}abbr[title]:after{content:" (" attr(title) ")"}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100%}@page{margin:.5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}}html,body{height:100%}.absolute{position:absolute}.relative{position:relative}.full{width:100%}.no-scroll{overflow:hidden}.table{display:table;margin:0 auto}.xlarge-top{margin-top:60px}.large-top{margin-top:40px}.medium-top{margin-top:20px}.small-top{margin-top:10px}.mini-top{margin-top:5px}.no-left-padding{padding-left:0}.no-right-padding{padding-right:0}@media only screen and (max-width:739px){.mobile-hide{display:none}.mobile-xlarge-top{margin-top:60px}.mobile-large-top{margin-top:40px}.mobile-medium-top{margin-top:20px}.mobile-small-top{margin-top:10px}.mobile-mini-top{margin-top:5px}}html,body{font-family:'Roboto','Helvetica Neue','Arial','Helvetica','Lucida Grande',sans-serif;font-weight:300;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}h1,h2,h3,h4,h5{font-weight:300}p{margin:0 0 1em 0}pre,code{padding:5px 10px;color:#6e6e6e;font-size:14px;line-height:20px;font-weight:100;background:#f8f8f8;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}a{color:#333;text-decoration:none;-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out}a.active{color:#000}a:hover{color:#000}a:hover .fa-trash-o{color:#e2717f}a.primary{color:#e2717f}a.primary:hover{color:#d94759}img{max-width:100%}hr{margin:.5em 0;width:100%}i.right-padding{padding-right:10px}i.left-padding{padding-left:10px}.button{outline:0;padding:1em 1.5em;background:#fafafa;color:#333;white-space:nowrap;background-clip:padding-box;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.button.disabled,.button[disabled]{-moz-opacity:.7;-khtml-opacity:.7;-webkit-opacity:.7;opacity:.7;-ms-filter:alpha(opacity=70);filter:alpha(opacity=70);cursor:default}.button:hover:not(.disabled),.button:hover:not([disabled]){background:#d9d9d9}.button.large{padding:1em 4em}.button.small{padding:.6em .8em}.button.x-small{padding:.4em .6em}.button.primary-button{color:#fff;background:#e2717f}.button.primary-button:hover,.button.primary-button:focus{color:#f2f2f2;background:#de5c6c}.button.primary-button:hover.disabled,.button.primary-button:focus.disabled,.button.primary-button:hover:disabled,.button.primary-button:focus:disabled{background:#e2717f}.button.secondary-button{background:0;border:1px solid #eee}.button.secondary-button:hover:not(.active),.button.secondary-button:hover:not(.disabled),.button.secondary-button:hover:not(:disabled),.button.secondary-button:focus:not(.active),.button.secondary-button:focus:not(.disabled),.button.secondary-button:focus:not(:disabled){color:#666;background:#f8f8f8}.button.secondary-button.active{color:#595959;background:#ebebeb;border:1px solid #eee}.button.secondary-button.active:hover{color:#595959;background:#ebebeb;border:1px solid #eee}.button.remove-button{background:#e2717f;color:#fff;padding:.9em 1.5em}.button.remove-button:hover,.button.remove-button:focus{background:#de5c6c}.button.remove-button:hover.disabled,.button.remove-button:focus.disabled,.button.remove-button:hover:disabled,.button.remove-button:focus:disabled{background:#e2717f}.button.transparent-button{background:0;color:#fff;border:1px solid #f2f2f2}.button.transparent-button:hover:not(.disabled),.button.transparent-button:hover:not(:disabled){background:rgba(255,255,255,0.1);color:#fff}.button-group>.button{padding:.8em 1em;text-align:center;background:#fff;border-top:1px solid #eee;border-bottom:1px solid #eee;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.button-group>.button i.fa{margin-right:5px}.button-group>.button:first-child{border-left:1px solid #eee;-webkit-border-top-right-radius:0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:5px;-webkit-border-top-left-radius:5px;-moz-border-radius-topright:0;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:5px;-moz-border-radius-topleft:5px;border-top-right-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:5px;border-top-left-radius:5px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.button-group>.button:last-child{border-right:1px solid #eee;-webkit-border-top-right-radius:5px;-webkit-border-bottom-right-radius:5px;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:0;-moz-border-radius-topright:5px;-moz-border-radius-bottomright:5px;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:0;border-top-right-radius:5px;border-bottom-right-radius:5px;border-bottom-left-radius:0;border-top-left-radius:0;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.button-group>.button:hover:not(.active),.button-group>.button:focus:not(.active){color:#666;background:#f8f8f8}.button-group>.button.active{color:#595959;background:#ebebeb;border:1px solid #eee}.button-group>.button.active:hover{color:#595959;background:#ebebeb;border:1px solid #eee}.button-group.small>.button{padding:.6em .8em}.button-group.x-small>.button{padding:.4em .6em}form .col,form .input-wrapper{position:relative}form input,form input[type="text"],form input[type="password"],form input[type="email"],form input[type="search"],form input[type="tel"],form input[type="number"],form input[type="date"],form textarea{width:100%;padding:.8em .6em .6em;outline:0;border:1px solid #d3d3d3;font-size:1.1em;line-height:1;background:#fff;color:#666;-webkit-appearance:none;-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out}form input:focus,form input[type="text"]:focus,form input[type="password"]:focus,form input[type="email"]:focus,form input[type="search"]:focus,form input[type="tel"]:focus,form input[type="number"]:focus,form input[type="date"]:focus,form textarea:focus{color:#333;border:1px solid #a0a0a0;-moz-box-shadow:0 0 2px #a0a0a0;-webkit-box-shadow:0 0 2px #a0a0a0;box-shadow:0 0 2px #a0a0a0;-webkit-box-shadow:0 0 2px #a0a0a0 0 0 #000;box-shadow:0 0 2px #a0a0a0 0 0 #000}form input:focus+label,form input[type="text"]:focus+label,form input[type="password"]:focus+label,form input[type="email"]:focus+label,form input[type="search"]:focus+label,form input[type="tel"]:focus+label,form input[type="number"]:focus+label,form input[type="date"]:focus+label,form textarea:focus+label{color:#666;font-weight:400}form input.success,form input[type="text"].success,form input[type="password"].success,form input[type="email"].success,form input[type="search"].success,form input[type="tel"].success,form input[type="number"].success,form input[type="date"].success,form textarea.success{border:1px solid #43cea2;-moz-box-shadow:0 0 2px #43cea2;-webkit-box-shadow:0 0 2px #43cea2;box-shadow:0 0 2px #43cea2;-webkit-box-shadow:0 0 2px #43cea2 0 0 #000;box-shadow:0 0 2px #43cea2 0 0 #000}form input.success+label,form input[type="text"].success+label,form input[type="password"].success+label,form input[type="email"].success+label,form input[type="search"].success+label,form input[type="tel"].success+label,form input[type="number"].success+label,form input[type="date"].success+label,form textarea.success+label{color:#43cea2;font-weight:400}form input.error,form input[type="text"].error,form input[type="password"].error,form input[type="email"].error,form input[type="search"].error,form input[type="tel"].error,form input[type="number"].error,form input[type="date"].error,form textarea.error{border:1px solid #e2717f;-moz-box-shadow:0 0 2px #e2717f;-webkit-box-shadow:0 0 2px #e2717f;box-shadow:0 0 2px #e2717f;-webkit-box-shadow:0 0 2px #e2717f 0 0 #000;box-shadow:0 0 2px #e2717f 0 0 #000}form input.error+label,form input[type="text"].error+label,form input[type="password"].error+label,form input[type="email"].error+label,form input[type="search"].error+label,form input[type="tel"].error+label,form input[type="number"].error+label,form input[type="date"].error+label,form textarea.error+label{color:#e2717f;font-weight:400}form input::-webkit-input-placeholder,form input[type="text"]::-webkit-input-placeholder,form input[type="password"]::-webkit-input-placeholder,form input[type="email"]::-webkit-input-placeholder,form input[type="search"]::-webkit-input-placeholder,form input[type="tel"]::-webkit-input-placeholder,form input[type="number"]::-webkit-input-placeholder,form input[type="date"]::-webkit-input-placeholder,form textarea::-webkit-input-placeholder{color:#d3d3d3;font-weight:300}form [placeholder]:focus::-webkit-input-placeholder{-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out;opacity:0}form input[type="number"]::-webkit-inner-spin-button,form input[type="number"]::-webkit-outer-spin-button,form input[type="date"]::-webkit-inner-spin-button,form input[type="date"]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}form .select-style{position:relative;display:block;width:100%;border:1px solid #a0a0a0;background:#fff}form .select-style .fa-caret-down{position:absolute;right:.6em;top:.8em;color:#a0a0a0;font-size:1.4em}form .select-style select{padding:.8em 0;margin-left:.6em;width:100%;border:0;box-shadow:none;background:transparent;background-image:none;-webkit-appearance:none;color:#a0a0a0;font-size:1.2em}form .select-style select:hover{cursor:pointer}form .select-style select:focus{outline:0}form fieldset.row{padding:.5em 0}form label{position:absolute;left:5px;top:-5px;padding:0 5px;background:white;color:#a0a0a0;font-size:12px;line-height:12px;text-transform:uppercase;pointer-events:none;z-index:2}.modal-wrapper{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.3);display:none;z-index:1001;will-change:transform}.modal-wrapper .modal{position:relative;color:#333;display:none}.modal-wrapper .modal a.close{position:absolute;padding:6px 12px 9px;border:1px solid;border-radius:20px;font-weight:300;font-size:27px}.modal-wrapper .modal section.modal-content{padding:20px}.modal-wrapper:not(.fullscreen) .modal{min-height:300px;max-width:434px;margin:60px auto 0;background-color:#fff;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.modal-wrapper:not(.fullscreen) .modal a.close{right:-45px;top:-30px;color:#fff}.modal-wrapper.fullscreen{background:#fff}.modal-wrapper.fullscreen .modal{height:100%;overflow:auto}.modal-wrapper.fullscreen .modal a.close{right:20px;top:20px}.notice{position:fixed;bottom:0;right:10px;height:100px;width:300px;padding:5px 10px 5px 10px;display:none;color:#fff;z-index:1005;-webkit-border-top-right-radius:5px;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:5px;-moz-border-radius-topright:5px;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:5px;border-top-right-radius:5px;border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-left-radius:5px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.notice.success{background-color:#43cea2}.notice.warning{background-color:#f4ed6b}.notice.error{background-color:#e2717f}.notice header.notice-header{position:relative;margin-bottom:.2em}.notice section.notice-content{height:70px;width:100%;overflow:auto;font-size:.8em}.notice a.close{position:absolute;top:3px;right:0;padding:0 4px 2px;border:1px solid;border-radius:100%;font-weight:300;font-size:12px;line-height:12px;color:#fff}.notice a.close:hover{color:#ccc}nav{font-size:18px;font-size:1.125rem}nav .navbar{margin:0 auto;display:table;padding:10px 0}nav li{margin:0 10px}nav a{display:inline-block;line-height:60px;vertical-align:middle}nav a.logo{height:60px;width:60px}@media(max-width:739px){nav{font-size:14px;font-size:.875rem}nav a{line-height:40px}nav a.logo{height:40px;width:40px}}#toc{position:fixed;top:80px;height:100%;width:263px;overflow:auto;padding-bottom:100px}#toc a{color:#333}#toc a:hover{color:#1a1a1a}#toc li>ul{display:none}#toc li>ul.unstyled-list{margin-left:10px}#toc li.active>a{font-weight:bold}#toc li.active>ul{display:block}#toc ul.nav>li.active>ul>li{list-style:none}footer{padding:60px 0;color:#d3d3d3;background:#333}footer i.fa-heart{color:#e2717f}footer i.fa-beer{color:#f4ed6b}html,body{background:#fff;color:#333}.kd{color:#a783b6}.k{color:#43cea2}h1.logo{font-size:64px;font-size:4rem}.gist pre,.gist .file-data{font-size:14px!important}section{padding:40px 0}#hero .badges,#hero .github-links{padding:.3em 0}#hero .badges p,#hero .github-links p{margin:0}#ship h3{margin-bottom:1em}#ship img.ship-it{display:table;height:300px;width:300px;margin:0 auto;background:#d3d3d3;-webkit-border-radius:100%;-moz-border-radius:100%;border-radius:100%}#plugins{color:#fff;background:#333}#plugins p{color:#d3d3d3}#plugins ul li{padding:10px 20px}#plugins ul li a{display:inline-block}#plugins ul li a img{height:100px;max-width:160px}@media(max-width:739px){#plugins ul li a img{height:60px;max-width:120px}}#features{color:#fff;background:#e2717f}#features h4{color:#982e3e}#features a.primary{color:#f8f8f8;border-bottom:1px dashed #f8f8f8}#features a.primary:hover{color:#dfdfdf;border-bottom:1px dashed #dfdfdf}#features p{text-align:justify}#comparison img{margin:0 auto}.page a,.example a{color:#e2717f}.page a:hover,.example a:hover{color:#d94759}.page .file-data .line-numbers,.example .file-data .line-numbers{width:40px}#todo-example input[type="text"]{margin:10px 0}#todo-example ul.todos li{padding:5px 0}#todo-example ul.todos li input[type="checkbox"]{margin-top:.2em}#todo-example ul.todos li span{margin-left:5px}#todo-example .primary-button{width:100%} \ No newline at end of file + */@font-face{font-family:'FontAwesome';src:url('/fonts/fontawesome-webfont.eot?v=4.3.0');src:url('/fonts/fontawesome-webfont.eot?#iefix&v=4.3.0') format('embedded-opentype'),url('/fonts/fontawesome-webfont.woff2?v=4.3.0') format('woff2'),url('/fonts/fontawesome-webfont.woff?v=4.3.0') format('woff'),url('/fonts/fontawesome-webfont.ttf?v=4.3.0') format('truetype'),url('/fonts/fontawesome-webfont.svg?v=4.3.0#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;transform:translate(0,0)}.fa-lg{font-size:1.3333333333333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.2857142857142858em;text-align:center}.fa-ul{padding-left:0;margin-left:2.142857142857143em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.142857142857143em;width:2.142857142857143em;top:.14285714285714285em;text-align:center}.fa-li.fa-lg{left:-1.8571428571428572em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2);-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=0,mirror=1);-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.fa-flip-vertical{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2,mirror=1);-webkit-transform:scale(1,-1);-ms-transform:scale(1,-1);transform:scale(1,-1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-remove:before,.fa-close:before,.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook-f:before,.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{content:"\f09c"}.fa-credit-card:before{content:"\f09d"}.fa-rss:before{content:"\f09e"}.fa-hdd-o:before{content:"\f0a0"}.fa-bullhorn:before{content:"\f0a1"}.fa-bell:before{content:"\f0f3"}.fa-certificate:before{content:"\f0a3"}.fa-hand-o-right:before{content:"\f0a4"}.fa-hand-o-left:before{content:"\f0a5"}.fa-hand-o-up:before{content:"\f0a6"}.fa-hand-o-down:before{content:"\f0a7"}.fa-arrow-circle-left:before{content:"\f0a8"}.fa-arrow-circle-right:before{content:"\f0a9"}.fa-arrow-circle-up:before{content:"\f0aa"}.fa-arrow-circle-down:before{content:"\f0ab"}.fa-globe:before{content:"\f0ac"}.fa-wrench:before{content:"\f0ad"}.fa-tasks:before{content:"\f0ae"}.fa-filter:before{content:"\f0b0"}.fa-briefcase:before{content:"\f0b1"}.fa-arrows-alt:before{content:"\f0b2"}.fa-group:before,.fa-users:before{content:"\f0c0"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-cloud:before{content:"\f0c2"}.fa-flask:before{content:"\f0c3"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-copy:before,.fa-files-o:before{content:"\f0c5"}.fa-paperclip:before{content:"\f0c6"}.fa-save:before,.fa-floppy-o:before{content:"\f0c7"}.fa-square:before{content:"\f0c8"}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:"\f0c9"}.fa-list-ul:before{content:"\f0ca"}.fa-list-ol:before{content:"\f0cb"}.fa-strikethrough:before{content:"\f0cc"}.fa-underline:before{content:"\f0cd"}.fa-table:before{content:"\f0ce"}.fa-magic:before{content:"\f0d0"}.fa-truck:before{content:"\f0d1"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-google-plus-square:before{content:"\f0d4"}.fa-google-plus:before{content:"\f0d5"}.fa-money:before{content:"\f0d6"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-columns:before{content:"\f0db"}.fa-unsorted:before,.fa-sort:before{content:"\f0dc"}.fa-sort-down:before,.fa-sort-desc:before{content:"\f0dd"}.fa-sort-up:before,.fa-sort-asc:before{content:"\f0de"}.fa-envelope:before{content:"\f0e0"}.fa-linkedin:before{content:"\f0e1"}.fa-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-legal:before,.fa-gavel:before{content:"\f0e3"}.fa-dashboard:before,.fa-tachometer:before{content:"\f0e4"}.fa-comment-o:before{content:"\f0e5"}.fa-comments-o:before{content:"\f0e6"}.fa-flash:before,.fa-bolt:before{content:"\f0e7"}.fa-sitemap:before{content:"\f0e8"}.fa-umbrella:before{content:"\f0e9"}.fa-paste:before,.fa-clipboard:before{content:"\f0ea"}.fa-lightbulb-o:before{content:"\f0eb"}.fa-exchange:before{content:"\f0ec"}.fa-cloud-download:before{content:"\f0ed"}.fa-cloud-upload:before{content:"\f0ee"}.fa-user-md:before{content:"\f0f0"}.fa-stethoscope:before{content:"\f0f1"}.fa-suitcase:before{content:"\f0f2"}.fa-bell-o:before{content:"\f0a2"}.fa-coffee:before{content:"\f0f4"}.fa-cutlery:before{content:"\f0f5"}.fa-file-text-o:before{content:"\f0f6"}.fa-building-o:before{content:"\f0f7"}.fa-hospital-o:before{content:"\f0f8"}.fa-ambulance:before{content:"\f0f9"}.fa-medkit:before{content:"\f0fa"}.fa-fighter-jet:before{content:"\f0fb"}.fa-beer:before{content:"\f0fc"}.fa-h-square:before{content:"\f0fd"}.fa-plus-square:before{content:"\f0fe"}.fa-angle-double-left:before{content:"\f100"}.fa-angle-double-right:before{content:"\f101"}.fa-angle-double-up:before{content:"\f102"}.fa-angle-double-down:before{content:"\f103"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}.fa-angle-up:before{content:"\f106"}.fa-angle-down:before{content:"\f107"}.fa-desktop:before{content:"\f108"}.fa-laptop:before{content:"\f109"}.fa-tablet:before{content:"\f10a"}.fa-mobile-phone:before,.fa-mobile:before{content:"\f10b"}.fa-circle-o:before{content:"\f10c"}.fa-quote-left:before{content:"\f10d"}.fa-quote-right:before{content:"\f10e"}.fa-spinner:before{content:"\f110"}.fa-circle:before{content:"\f111"}.fa-mail-reply:before,.fa-reply:before{content:"\f112"}.fa-github-alt:before{content:"\f113"}.fa-folder-o:before{content:"\f114"}.fa-folder-open-o:before{content:"\f115"}.fa-smile-o:before{content:"\f118"}.fa-frown-o:before{content:"\f119"}.fa-meh-o:before{content:"\f11a"}.fa-gamepad:before{content:"\f11b"}.fa-keyboard-o:before{content:"\f11c"}.fa-flag-o:before{content:"\f11d"}.fa-flag-checkered:before{content:"\f11e"}.fa-terminal:before{content:"\f120"}.fa-code:before{content:"\f121"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"\f122"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"\f123"}.fa-location-arrow:before{content:"\f124"}.fa-crop:before{content:"\f125"}.fa-code-fork:before{content:"\f126"}.fa-unlink:before,.fa-chain-broken:before{content:"\f127"}.fa-question:before{content:"\f128"}.fa-info:before{content:"\f129"}.fa-exclamation:before{content:"\f12a"}.fa-superscript:before{content:"\f12b"}.fa-subscript:before{content:"\f12c"}.fa-eraser:before{content:"\f12d"}.fa-puzzle-piece:before{content:"\f12e"}.fa-microphone:before{content:"\f130"}.fa-microphone-slash:before{content:"\f131"}.fa-shield:before{content:"\f132"}.fa-calendar-o:before{content:"\f133"}.fa-fire-extinguisher:before{content:"\f134"}.fa-rocket:before{content:"\f135"}.fa-maxcdn:before{content:"\f136"}.fa-chevron-circle-left:before{content:"\f137"}.fa-chevron-circle-right:before{content:"\f138"}.fa-chevron-circle-up:before{content:"\f139"}.fa-chevron-circle-down:before{content:"\f13a"}.fa-html5:before{content:"\f13b"}.fa-css3:before{content:"\f13c"}.fa-anchor:before{content:"\f13d"}.fa-unlock-alt:before{content:"\f13e"}.fa-bullseye:before{content:"\f140"}.fa-ellipsis-h:before{content:"\f141"}.fa-ellipsis-v:before{content:"\f142"}.fa-rss-square:before{content:"\f143"}.fa-play-circle:before{content:"\f144"}.fa-ticket:before{content:"\f145"}.fa-minus-square:before{content:"\f146"}.fa-minus-square-o:before{content:"\f147"}.fa-level-up:before{content:"\f148"}.fa-level-down:before{content:"\f149"}.fa-check-square:before{content:"\f14a"}.fa-pencil-square:before{content:"\f14b"}.fa-external-link-square:before{content:"\f14c"}.fa-share-square:before{content:"\f14d"}.fa-compass:before{content:"\f14e"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"\f150"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"\f151"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"\f152"}.fa-euro:before,.fa-eur:before{content:"\f153"}.fa-gbp:before{content:"\f154"}.fa-dollar:before,.fa-usd:before{content:"\f155"}.fa-rupee:before,.fa-inr:before{content:"\f156"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"\f157"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"\f158"}.fa-won:before,.fa-krw:before{content:"\f159"}.fa-bitcoin:before,.fa-btc:before{content:"\f15a"}.fa-file:before{content:"\f15b"}.fa-file-text:before{content:"\f15c"}.fa-sort-alpha-asc:before{content:"\f15d"}.fa-sort-alpha-desc:before{content:"\f15e"}.fa-sort-amount-asc:before{content:"\f160"}.fa-sort-amount-desc:before{content:"\f161"}.fa-sort-numeric-asc:before{content:"\f162"}.fa-sort-numeric-desc:before{content:"\f163"}.fa-thumbs-up:before{content:"\f164"}.fa-thumbs-down:before{content:"\f165"}.fa-youtube-square:before{content:"\f166"}.fa-youtube:before{content:"\f167"}.fa-xing:before{content:"\f168"}.fa-xing-square:before{content:"\f169"}.fa-youtube-play:before{content:"\f16a"}.fa-dropbox:before{content:"\f16b"}.fa-stack-overflow:before{content:"\f16c"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-adn:before{content:"\f170"}.fa-bitbucket:before{content:"\f171"}.fa-bitbucket-square:before{content:"\f172"}.fa-tumblr:before{content:"\f173"}.fa-tumblr-square:before{content:"\f174"}.fa-long-arrow-down:before{content:"\f175"}.fa-long-arrow-up:before{content:"\f176"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-apple:before{content:"\f179"}.fa-windows:before{content:"\f17a"}.fa-android:before{content:"\f17b"}.fa-linux:before{content:"\f17c"}.fa-dribbble:before{content:"\f17d"}.fa-skype:before{content:"\f17e"}.fa-foursquare:before{content:"\f180"}.fa-trello:before{content:"\f181"}.fa-female:before{content:"\f182"}.fa-male:before{content:"\f183"}.fa-gittip:before,.fa-gratipay:before{content:"\f184"}.fa-sun-o:before{content:"\f185"}.fa-moon-o:before{content:"\f186"}.fa-archive:before{content:"\f187"}.fa-bug:before{content:"\f188"}.fa-vk:before{content:"\f189"}.fa-weibo:before{content:"\f18a"}.fa-renren:before{content:"\f18b"}.fa-pagelines:before{content:"\f18c"}.fa-stack-exchange:before{content:"\f18d"}.fa-arrow-circle-o-right:before{content:"\f18e"}.fa-arrow-circle-o-left:before{content:"\f190"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:"\f191"}.fa-dot-circle-o:before{content:"\f192"}.fa-wheelchair:before{content:"\f193"}.fa-vimeo-square:before{content:"\f194"}.fa-turkish-lira:before,.fa-try:before{content:"\f195"}.fa-plus-square-o:before{content:"\f196"}.fa-space-shuttle:before{content:"\f197"}.fa-slack:before{content:"\f198"}.fa-envelope-square:before{content:"\f199"}.fa-wordpress:before{content:"\f19a"}.fa-openid:before{content:"\f19b"}.fa-institution:before,.fa-bank:before,.fa-university:before{content:"\f19c"}.fa-mortar-board:before,.fa-graduation-cap:before{content:"\f19d"}.fa-yahoo:before{content:"\f19e"}.fa-google:before{content:"\f1a0"}.fa-reddit:before{content:"\f1a1"}.fa-reddit-square:before{content:"\f1a2"}.fa-stumbleupon-circle:before{content:"\f1a3"}.fa-stumbleupon:before{content:"\f1a4"}.fa-delicious:before{content:"\f1a5"}.fa-digg:before{content:"\f1a6"}.fa-pied-piper:before{content:"\f1a7"}.fa-pied-piper-alt:before{content:"\f1a8"}.fa-drupal:before{content:"\f1a9"}.fa-joomla:before{content:"\f1aa"}.fa-language:before{content:"\f1ab"}.fa-fax:before{content:"\f1ac"}.fa-building:before{content:"\f1ad"}.fa-child:before{content:"\f1ae"}.fa-paw:before{content:"\f1b0"}.fa-spoon:before{content:"\f1b1"}.fa-cube:before{content:"\f1b2"}.fa-cubes:before{content:"\f1b3"}.fa-behance:before{content:"\f1b4"}.fa-behance-square:before{content:"\f1b5"}.fa-steam:before{content:"\f1b6"}.fa-steam-square:before{content:"\f1b7"}.fa-recycle:before{content:"\f1b8"}.fa-automobile:before,.fa-car:before{content:"\f1b9"}.fa-cab:before,.fa-taxi:before{content:"\f1ba"}.fa-tree:before{content:"\f1bb"}.fa-spotify:before{content:"\f1bc"}.fa-deviantart:before{content:"\f1bd"}.fa-soundcloud:before{content:"\f1be"}.fa-database:before{content:"\f1c0"}.fa-file-pdf-o:before{content:"\f1c1"}.fa-file-word-o:before{content:"\f1c2"}.fa-file-excel-o:before{content:"\f1c3"}.fa-file-powerpoint-o:before{content:"\f1c4"}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:"\f1c5"}.fa-file-zip-o:before,.fa-file-archive-o:before{content:"\f1c6"}.fa-file-sound-o:before,.fa-file-audio-o:before{content:"\f1c7"}.fa-file-movie-o:before,.fa-file-video-o:before{content:"\f1c8"}.fa-file-code-o:before{content:"\f1c9"}.fa-vine:before{content:"\f1ca"}.fa-codepen:before{content:"\f1cb"}.fa-jsfiddle:before{content:"\f1cc"}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:"\f1cd"}.fa-circle-o-notch:before{content:"\f1ce"}.fa-ra:before,.fa-rebel:before{content:"\f1d0"}.fa-ge:before,.fa-empire:before{content:"\f1d1"}.fa-git-square:before{content:"\f1d2"}.fa-git:before{content:"\f1d3"}.fa-hacker-news:before{content:"\f1d4"}.fa-tencent-weibo:before{content:"\f1d5"}.fa-qq:before{content:"\f1d6"}.fa-wechat:before,.fa-weixin:before{content:"\f1d7"}.fa-send:before,.fa-paper-plane:before{content:"\f1d8"}.fa-send-o:before,.fa-paper-plane-o:before{content:"\f1d9"}.fa-history:before{content:"\f1da"}.fa-genderless:before,.fa-circle-thin:before{content:"\f1db"}.fa-header:before{content:"\f1dc"}.fa-paragraph:before{content:"\f1dd"}.fa-sliders:before{content:"\f1de"}.fa-share-alt:before{content:"\f1e0"}.fa-share-alt-square:before{content:"\f1e1"}.fa-bomb:before{content:"\f1e2"}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:"\f1e3"}.fa-tty:before{content:"\f1e4"}.fa-binoculars:before{content:"\f1e5"}.fa-plug:before{content:"\f1e6"}.fa-slideshare:before{content:"\f1e7"}.fa-twitch:before{content:"\f1e8"}.fa-yelp:before{content:"\f1e9"}.fa-newspaper-o:before{content:"\f1ea"}.fa-wifi:before{content:"\f1eb"}.fa-calculator:before{content:"\f1ec"}.fa-paypal:before{content:"\f1ed"}.fa-google-wallet:before{content:"\f1ee"}.fa-cc-visa:before{content:"\f1f0"}.fa-cc-mastercard:before{content:"\f1f1"}.fa-cc-discover:before{content:"\f1f2"}.fa-cc-amex:before{content:"\f1f3"}.fa-cc-paypal:before{content:"\f1f4"}.fa-cc-stripe:before{content:"\f1f5"}.fa-bell-slash:before{content:"\f1f6"}.fa-bell-slash-o:before{content:"\f1f7"}.fa-trash:before{content:"\f1f8"}.fa-copyright:before{content:"\f1f9"}.fa-at:before{content:"\f1fa"}.fa-eyedropper:before{content:"\f1fb"}.fa-paint-brush:before{content:"\f1fc"}.fa-birthday-cake:before{content:"\f1fd"}.fa-area-chart:before{content:"\f1fe"}.fa-pie-chart:before{content:"\f200"}.fa-line-chart:before{content:"\f201"}.fa-lastfm:before{content:"\f202"}.fa-lastfm-square:before{content:"\f203"}.fa-toggle-off:before{content:"\f204"}.fa-toggle-on:before{content:"\f205"}.fa-bicycle:before{content:"\f206"}.fa-bus:before{content:"\f207"}.fa-ioxhost:before{content:"\f208"}.fa-angellist:before{content:"\f209"}.fa-cc:before{content:"\f20a"}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:"\f20b"}.fa-meanpath:before{content:"\f20c"}.fa-buysellads:before{content:"\f20d"}.fa-connectdevelop:before{content:"\f20e"}.fa-dashcube:before{content:"\f210"}.fa-forumbee:before{content:"\f211"}.fa-leanpub:before{content:"\f212"}.fa-sellsy:before{content:"\f213"}.fa-shirtsinbulk:before{content:"\f214"}.fa-simplybuilt:before{content:"\f215"}.fa-skyatlas:before{content:"\f216"}.fa-cart-plus:before{content:"\f217"}.fa-cart-arrow-down:before{content:"\f218"}.fa-diamond:before{content:"\f219"}.fa-ship:before{content:"\f21a"}.fa-user-secret:before{content:"\f21b"}.fa-motorcycle:before{content:"\f21c"}.fa-street-view:before{content:"\f21d"}.fa-heartbeat:before{content:"\f21e"}.fa-venus:before{content:"\f221"}.fa-mars:before{content:"\f222"}.fa-mercury:before{content:"\f223"}.fa-transgender:before{content:"\f224"}.fa-transgender-alt:before{content:"\f225"}.fa-venus-double:before{content:"\f226"}.fa-mars-double:before{content:"\f227"}.fa-venus-mars:before{content:"\f228"}.fa-mars-stroke:before{content:"\f229"}.fa-mars-stroke-v:before{content:"\f22a"}.fa-mars-stroke-h:before{content:"\f22b"}.fa-neuter:before{content:"\f22c"}.fa-facebook-official:before{content:"\f230"}.fa-pinterest-p:before{content:"\f231"}.fa-whatsapp:before{content:"\f232"}.fa-server:before{content:"\f233"}.fa-user-plus:before{content:"\f234"}.fa-user-times:before{content:"\f235"}.fa-hotel:before,.fa-bed:before{content:"\f236"}.fa-viacoin:before{content:"\f237"}.fa-train:before{content:"\f238"}.fa-subway:before{content:"\f239"}.fa-medium:before{content:"\f23a"}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}html,button,input,select,textarea{font-family:sans-serif}body,form,fieldset,legend,input,select,textarea,button{margin:0}html{font-size:100%}body{font-family:sans-serif;font-size:16px;font-size:1rem;line-height:21px;line-height:1.3125rem;color:#434343;background-color:#fff;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}b,strong{font-weight:700}i,em,.em{font-style:italic}a{color:#669fcf}a:hover{text-decoration:none}a:focus{outline:0}a:active,a:hover{outline:0}p{margin:0 0 1.6em 0}pre{margin:1em 0}ul+p,ul+pre,ol+p,ol+pre{margin-top:0}small{font-size:80%}abbr[title]{border-bottom:1px dotted}audio,canvas,video{display:inline-block;*zoom:1;*display:inline}audio:not([controls]){display:none;height:0}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}dfn{font-style:italic}img{border:0;-ms-interpolation-mode:bicubic}svg:not(:root){overflow:hidden}figure{margin:0}.image-left{margin-right:20px}.image-right{margin-left:20px}h1,h2,h3,h4,h5,h6{line-height:normal;font-weight:normal;margin:0 0 .33em 0}h1,.h1{font-size:40px;font-size:2.5rem}h2,.h2{font-size:32px;font-size:2rem}h3,.h3{font-size:26px;font-size:1.625rem}h4,.h4{font-size:20px;font-size:1.25rem}h5,.h5{font-size:18px;font-size:1.125rem}h6,.h6{font-size:16px;font-size:1rem}.no-style-heading{margin:0;font-size:100%}hr{border:0;background:0;outline:0;background-color:#ddd;margin:2em 0;*margin:1em 0;-moz-box-sizing:content-box;box-sizing:content-box;height:1px}blockquote{font-size:22px;font-size:1.375rem;line-height:32px;line-height:2rem;color:#434343;margin:1em 0;font-style:italic}blockquote p{margin:1em 0}cite{color:#434343;font-style:normal;font-weight:normal;font-size:16px;font-size:1rem;line-height:normal}q{font-style:italic;quotes:none}q:before,q:after{content:'';content:none}mark{background:#ff0;color:#111}code,kbd,pre,samp{word-wrap:break-word;font-family:'courier new',monospace,serif;font-size:13px;font-size:.8125rem;line-height:normal;font-weight:normal;background-color:#f1f1f1;padding:10px}code{color:#111}dl,menu,ol,ul{margin:1em 0}dd,ul ul,ol ol,ul ol,ol ul{margin:0}dt{font-weight:normal}dd{margin-bottom:1em}menu,ol,ul{padding:0 0 0 22px}nav ul,nav ol{list-style:none;list-style-image:none}.unstyled-list{list-style:none;padding:0;margin:0}.unstyled-list li{margin-top:0;margin-bottom:0}.inline-list{list-style:none;padding:0;margin:0;display:inline-block;*zoom:1;*display:inline}.inline-list li{margin-top:0;margin-bottom:0}.inline-list li{display:inline-block;*zoom:1;*display:inline}table{width:100%;margin:1em 0;table-layout:fixed;border-collapse:collapse;border-spacing:0;border-right:1px solid #f1f1f1;border-bottom:1px solid #f1f1f1;word-wrap:break-word;-ms-word-wrap:break-word;*white-space:normal}table th,table td{padding:8px;text-align:left;vertical-align:top;border-top:1px solid #eee;border-left:1px solid #eee}table thead th,table tfoot th{vertical-align:bottom;font-weight:normal;background-color:#f1f1f1;color:#333}table caption{padding:8px;font-style:normal;text-align:left;font-weight:normal;border-bottom:0}fieldset{border:0;padding:0}legend{border:0;padding:0;white-space:normal;*margin-left:-7px;font-weight:normal}label{margin:0;cursor:pointer}button,input,select,textarea{font-size:100%;vertical-align:baseline;*vertical-align:middle}input[type=text],input[type=password],input[type=email],input[type=search],input[type=tel],textarea{padding:5px;-webkit-appearance:none;-moz-appearance:none;font-weight:normal;line-height:normal;background-color:#fff;border:1px solid #ccc;color:#111}input[type=checkbox],input[type=radio]{cursor:pointer;box-sizing:border-box;line-height:normal;margin:0;padding:0;*height:13px;*width:13px}.checkbox{display:block;margin:.2em 0}.checkbox input[type=checkbox],.checkbox input[type=radio]{margin-top:.05em;float:left}.checkbox label{padding-left:5px;overflow:hidden;display:table;*zoom:1}button,input{line-height:normal}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer;*overflow:visible}button[disabled],html input[disabled]{cursor:default}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top;resize:none}.button{border:0;padding:1em 3em;background-color:#e74b3c;color:#fff;text-decoration:none;text-align:center;display:inline-block;*zoom:1;*display:inline;position:relative}.button:hover{background-color:#fc5547}.button:active{top:1px}.grey-button{background-color:#eee;color:#434343}.grey-button:hover{background-color:#f1f1f1}.button[disabled],.button.disabled{color:#999;background-color:#f1f1f1}.unstyled-button{font-size:16px;font-size:1rem;color:#27ae61;text-decoration:underline;border:0;background:transparent;height:auto;padding:0;cursor:pointer;outline:0}.unstyled-button:hover{text-decoration:none}.unstyled-button[disabled],.unstyled-button.disabled{text-decoration:none;color:#999;background-color:#ccc}.section{position:relative}.container{max-width:960px;margin-left:auto;margin-right:auto;padding-left:10px;padding-right:10px}.container-full{max-width:960px;margin-left:auto;margin-right:auto}.col{float:left;padding-left:10px;padding-right:10px}[class*="pull-"],[class*="push-"]{position:relative}.no-gutter{padding-left:0;padding-right:0}.col-1{width:8.33333%;width:calc(8.333333333333334%);width:-webkit-calc(8.333333333333334%);width:-moz-calc(8.333333333333334%)}.col-2{width:16.66667%;width:calc(16.666666666666668%);width:-webkit-calc(16.666666666666668%);width:-moz-calc(16.666666666666668%)}.col-3{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.col-4{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.col-5{width:41.66665%;width:calc(41.66666666666667%);width:-webkit-calc(41.66666666666667%);width:-moz-calc(41.66666666666667%)}.col-6{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.col-7{width:58.33333%;width:calc(58.333333333333336%);width:-webkit-calc(58.333333333333336%);width:-moz-calc(58.333333333333336%)}.col-8{width:66.66666%;width:calc(66.66666666666667%);width:-webkit-calc(66.66666666666667%);width:-moz-calc(66.66666666666667%)}.col-9{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.col-10{width:83.33333%;width:calc(83.33333333333334%);width:-webkit-calc(83.33333333333334%);width:-moz-calc(83.33333333333334%)}.col-11{width:91.66666%;width:calc(91.66666666666667%);width:-webkit-calc(91.66666666666667%);width:-moz-calc(91.66666666666667%)}.col-12{width:100%}.col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.push-1{left:8.33333%;left:calc(8.333333333333334%);left:-webkit-calc(8.333333333333334%);left:-moz-calc(8.333333333333334%)}.pull-1{left:-8.33333%;left:calc(-8.333333333333334%);left:-webkit-calc(-8.333333333333334%);left:-moz-calc(-8.333333333333334%)}.push-2{left:16.66667%;left:calc(16.666666666666668%);left:-webkit-calc(16.666666666666668%);left:-moz-calc(16.666666666666668%)}.pull-2{left:-16.66667%;left:calc(-16.666666666666668%);left:-webkit-calc(-16.666666666666668%);left:-moz-calc(-16.666666666666668%)}.push-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.pull-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.push-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.pull-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.push-5{left:41.66665%;left:calc(41.66666666666667%);left:-webkit-calc(41.66666666666667%);left:-moz-calc(41.66666666666667%)}.pull-5{left:-41.66665%;left:calc(-41.66666666666667%);left:-webkit-calc(-41.66666666666667%);left:-moz-calc(-41.66666666666667%)}.push-6{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.pull-6{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.push-7{left:58.33333%;left:calc(58.333333333333336%);left:-webkit-calc(58.333333333333336%);left:-moz-calc(58.333333333333336%)}.pull-7{left:-58.33333%;left:calc(-58.333333333333336%);left:-webkit-calc(-58.333333333333336%);left:-moz-calc(-58.333333333333336%)}.push-8{left:66.66666%;left:calc(66.66666666666667%);left:-webkit-calc(66.66666666666667%);left:-moz-calc(66.66666666666667%)}.pull-8{left:-66.66666%;left:calc(-66.66666666666667%);left:-webkit-calc(-66.66666666666667%);left:-moz-calc(-66.66666666666667%)}.push-9{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.pull-9{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.push-10{left:83.33333%;left:calc(83.33333333333334%);left:-webkit-calc(83.33333333333334%);left:-moz-calc(83.33333333333334%)}.pull-10{left:-83.33333%;left:calc(-83.33333333333334%);left:-webkit-calc(-83.33333333333334%);left:-moz-calc(-83.33333333333334%)}.push-11{left:91.66666%;left:calc(91.66666666666667%);left:-webkit-calc(91.66666666666667%);left:-moz-calc(91.66666666666667%)}.pull-11{left:-91.66666%;left:calc(-91.66666666666667%);left:-webkit-calc(-91.66666666666667%);left:-moz-calc(-91.66666666666667%)}.row{padding-top:1em;padding-bottom:1em}.clear:before,.clear:after{content:"";display:table}.clear:after{clear:both}.clear{zoom:1}.left{float:left}.right{float:right}.block{display:block}.inline{display:inline}.inline-block{display:inline-block;*zoom:1;*display:inline}.none,.hidden,[hidden],.no-desktop{display:none}.heavy{font-weight:900}.strong{font-weight:700}.normal{font-weight:normal}.thin{font-weight:300}.fine{font-weight:100}.italic{font-style:italic}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.left-text{text-align:left}.right-text{text-align:right}.center-text{text-align:center}.justify-text{text-align:justify}.visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;overflow:hidden;padding:0;position:absolute;width:1px;left:-9999em}.visuallyvisible{clip:auto;width:auto;height:auto;overflow:visible;left:0}.no-margin{margin:0}.no-padding{padding:0}@media only screen and (min-width:740px) and (max-width:960px){.container,.tablet-container{max-width:960px;padding-left:20px;padding-right:20px;margin-left:auto;margin-right:auto;float:none}.container:first-child,.tablet-container:first-child{margin-left:auto}.tablet-container-full{padding-left:0;padding-right:0;margin-left:auto;margin-right:auto;float:none}.tablet-container-full:first-child{margin-left:auto}.tablet-no-gutter{padding-left:0;padding-right:0}.tablet-col-1{width:8.33333%;width:calc(8.333333333333334%);width:-webkit-calc(8.333333333333334%);width:-moz-calc(8.333333333333334%)}.tablet-col-2{width:16.66667%;width:calc(16.666666666666668%);width:-webkit-calc(16.666666666666668%);width:-moz-calc(16.666666666666668%)}.tablet-col-3{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.tablet-col-4{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.tablet-col-5{width:41.66665%;width:calc(41.66666666666667%);width:-webkit-calc(41.66666666666667%);width:-moz-calc(41.66666666666667%)}.tablet-col-6{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.tablet-col-7{width:58.33333%;width:calc(58.333333333333336%);width:-webkit-calc(58.333333333333336%);width:-moz-calc(58.333333333333336%)}.tablet-col-8{width:66.66666%;width:calc(66.66666666666667%);width:-webkit-calc(66.66666666666667%);width:-moz-calc(66.66666666666667%)}.tablet-col-9{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.tablet-col-10{width:83.33333%;width:calc(83.33333333333334%);width:-webkit-calc(83.33333333333334%);width:-moz-calc(83.33333333333334%)}.tablet-col-11{width:91.66666%;width:calc(91.66666666666667%);width:-webkit-calc(91.66666666666667%);width:-moz-calc(91.66666666666667%)}.tablet-col-12{width:100%}.tablet-col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.tablet-col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.tablet-col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.tablet-col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.tablet-push-1{left:8.33333%;left:calc(8.333333333333334%);left:-webkit-calc(8.333333333333334%);left:-moz-calc(8.333333333333334%)}.tablet-pull-1{left:-8.33333%;left:calc(-8.333333333333334%);left:-webkit-calc(-8.333333333333334%);left:-moz-calc(-8.333333333333334%)}.tablet-push-2{left:16.66667%;left:calc(16.666666666666668%);left:-webkit-calc(16.666666666666668%);left:-moz-calc(16.666666666666668%)}.tablet-pull-2{left:-16.66667%;left:calc(-16.666666666666668%);left:-webkit-calc(-16.666666666666668%);left:-moz-calc(-16.666666666666668%)}.tablet-push-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.tablet-pull-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.tablet-push-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.tablet-pull-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.tablet-push-5{left:41.66665%;left:calc(41.66666666666667%);left:-webkit-calc(41.66666666666667%);left:-moz-calc(41.66666666666667%)}.tablet-pull-5{left:-41.66665%;left:calc(-41.66666666666667%);left:-webkit-calc(-41.66666666666667%);left:-moz-calc(-41.66666666666667%)}.tablet-push-6{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.tablet-pull-6{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.tablet-push-7{left:58.33333%;left:calc(58.333333333333336%);left:-webkit-calc(58.333333333333336%);left:-moz-calc(58.333333333333336%)}.tablet-pull-7{left:-58.33333%;left:calc(-58.333333333333336%);left:-webkit-calc(-58.333333333333336%);left:-moz-calc(-58.333333333333336%)}.tablet-push-8{left:66.66666%;left:calc(66.66666666666667%);left:-webkit-calc(66.66666666666667%);left:-moz-calc(66.66666666666667%)}.tablet-pull-8{left:-66.66666%;left:calc(-66.66666666666667%);left:-webkit-calc(-66.66666666666667%);left:-moz-calc(-66.66666666666667%)}.tablet-push-9{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.tablet-pull-9{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.tablet-push-10{left:83.33333%;left:calc(83.33333333333334%);left:-webkit-calc(83.33333333333334%);left:-moz-calc(83.33333333333334%)}.tablet-pull-10{left:-83.33333%;left:calc(-83.33333333333334%);left:-webkit-calc(-83.33333333333334%);left:-moz-calc(-83.33333333333334%)}.tablet-push-11{left:91.66666%;left:calc(91.66666666666667%);left:-webkit-calc(91.66666666666667%);left:-moz-calc(91.66666666666667%)}.tablet-pull-11{left:-91.66666%;left:calc(-91.66666666666667%);left:-webkit-calc(-91.66666666666667%);left:-moz-calc(-91.66666666666667%)}.tablet-no-push,.tablet-no-pull{left:auto}.tablet-row{padding-top:1em;padding-bottom:1em}.tablet-full{left:auto;clear:both;float:none;width:100%;margin:1em 0 0 0;display:block}.tablet-full:first-child{margin-top:0}.tablet-left-text{text-align:left}.tablet-right-text{text-align:right}.tablet-center-text{text-align:center}.tablet-left{float:left}.tablet-right{float:right}.tablet-no-float{float:none}.tablet-no-margin{margin:0}.tablet-no-padding{padding:0}.no-tablet{display:none}.show-tablet{display:block}}@media only screen and (max-width:739px){.container,.mobile-container{padding-left:20px;padding-right:20px;margin-left:auto;margin-right:auto;float:none}.container:first-child,.mobile-container:first-child{margin-left:auto}.mobile-container-full{padding-left:0;padding-right:0;margin-left:auto;margin-right:auto;float:none}.mobile-container-full:first-child{margin-left:auto}.mobile-no-gutter{padding-left:0;padding-right:0}.mobile-col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.mobile-col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.mobile-col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.mobile-col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.mobile-push-1-2{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.mobile-pull-1-2{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.mobile-push-1-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.mobile-pull-1-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.mobile-push-1-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.mobile-pull-1-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.mobile-push-3-4{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.mobile-pull-3-4{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.mobile-no-push,.mobile-no-pull{left:auto}.mobile-row{padding-top:1em;padding-bottom:1em}.mobile-full{left:auto;clear:both;float:none;width:100%;margin:.2em 0 0 0;display:block}.mobile-full:first-child{margin-top:0}.mobile-left-text{text-align:left}.mobile-right-text{text-align:right}.mobile-center-text{text-align:center}.mobile-left{float:left}.mobile-right{float:right}.mobile-no-float{float:none}.mobile-no-margin{margin:0}.mobile-no-padding{padding:0}table th,table td{padding:4px}.no-mobile{display:none}.show-mobile{display:block}}@media print{*{background:transparent}a,a:visited{text-decoration:underline}abbr[title]:after{content:" (" attr(title) ")"}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100%}@page{margin:.5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}}html,body{height:100%}.absolute{position:absolute}.relative{position:relative}.full{width:100%}.no-scroll{overflow:hidden}.table{display:table;margin:0 auto}.xlarge-top{margin-top:60px}.large-top{margin-top:40px}.medium-top{margin-top:20px}.small-top{margin-top:10px}.mini-top{margin-top:5px}.no-left-padding{padding-left:0}.no-right-padding{padding-right:0}@media only screen and (max-width:739px){.mobile-hide{display:none}.mobile-xlarge-top{margin-top:60px}.mobile-large-top{margin-top:40px}.mobile-medium-top{margin-top:20px}.mobile-small-top{margin-top:10px}.mobile-mini-top{margin-top:5px}}html,body{font-family:'Roboto','Helvetica Neue','Arial','Helvetica','Lucida Grande',sans-serif;font-weight:300;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}h1,h2,h3,h4,h5{font-weight:300}p{margin:0 0 1em 0}pre,code{padding:5px 10px;color:#6e6e6e;font-size:14px;line-height:20px;font-weight:100;background:#f8f8f8;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}a{color:#333;text-decoration:none;-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out}a.active{color:#000}a:hover{color:#000}a:hover .fa-trash-o{color:#e2717f}a.primary{color:#e2717f}a.primary:hover{color:#d94759}img{max-width:100%}hr{margin:.5em 0;width:100%}i.right-padding{padding-right:10px}i.left-padding{padding-left:10px}.button{outline:0;padding:1em 1.5em;background:#fafafa;color:#333;white-space:nowrap;background-clip:padding-box;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.button.disabled,.button[disabled]{-moz-opacity:.7;-khtml-opacity:.7;-webkit-opacity:.7;opacity:.7;-ms-filter:alpha(opacity=70);filter:alpha(opacity=70);cursor:default}.button:hover:not(.disabled),.button:hover:not([disabled]){background:#d9d9d9}.button.large{padding:1em 4em}.button.small{padding:.6em .8em}.button.x-small{padding:.4em .6em}.button.primary-button{color:#fff;background:#e2717f}.button.primary-button:hover,.button.primary-button:focus{color:#f2f2f2;background:#de5c6c}.button.primary-button:hover.disabled,.button.primary-button:focus.disabled,.button.primary-button:hover:disabled,.button.primary-button:focus:disabled{background:#e2717f}.button.secondary-button{background:0;border:1px solid #eee}.button.secondary-button:hover:not(.active),.button.secondary-button:hover:not(.disabled),.button.secondary-button:hover:not(:disabled),.button.secondary-button:focus:not(.active),.button.secondary-button:focus:not(.disabled),.button.secondary-button:focus:not(:disabled){color:#666;background:#f8f8f8}.button.secondary-button.active{color:#595959;background:#ebebeb;border:1px solid #eee}.button.secondary-button.active:hover{color:#595959;background:#ebebeb;border:1px solid #eee}.button.remove-button{background:#e2717f;color:#fff;padding:.9em 1.5em}.button.remove-button:hover,.button.remove-button:focus{background:#de5c6c}.button.remove-button:hover.disabled,.button.remove-button:focus.disabled,.button.remove-button:hover:disabled,.button.remove-button:focus:disabled{background:#e2717f}.button.transparent-button{background:0;color:#fff;border:1px solid #f2f2f2}.button.transparent-button:hover:not(.disabled),.button.transparent-button:hover:not(:disabled){background:rgba(255,255,255,0.1);color:#fff}.button-group>.button{padding:.8em 1em;text-align:center;background:#fff;border-top:1px solid #eee;border-bottom:1px solid #eee;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.button-group>.button i.fa{margin-right:5px}.button-group>.button:first-child{border-left:1px solid #eee;-webkit-border-top-right-radius:0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:5px;-webkit-border-top-left-radius:5px;-moz-border-radius-topright:0;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:5px;-moz-border-radius-topleft:5px;border-top-right-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:5px;border-top-left-radius:5px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.button-group>.button:last-child{border-right:1px solid #eee;-webkit-border-top-right-radius:5px;-webkit-border-bottom-right-radius:5px;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:0;-moz-border-radius-topright:5px;-moz-border-radius-bottomright:5px;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:0;border-top-right-radius:5px;border-bottom-right-radius:5px;border-bottom-left-radius:0;border-top-left-radius:0;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.button-group>.button:hover:not(.active),.button-group>.button:focus:not(.active){color:#666;background:#f8f8f8}.button-group>.button.active{color:#595959;background:#ebebeb;border:1px solid #eee}.button-group>.button.active:hover{color:#595959;background:#ebebeb;border:1px solid #eee}.button-group.small>.button{padding:.6em .8em}.button-group.x-small>.button{padding:.4em .6em}form .col,form .input-wrapper{position:relative}form input,form input[type="text"],form input[type="password"],form input[type="email"],form input[type="search"],form input[type="tel"],form input[type="number"],form input[type="date"],form textarea{width:100%;padding:.8em .6em .6em;outline:0;border:1px solid #d3d3d3;font-size:1.1em;line-height:1;background:#fff;color:#666;-webkit-appearance:none;-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out}form input:focus,form input[type="text"]:focus,form input[type="password"]:focus,form input[type="email"]:focus,form input[type="search"]:focus,form input[type="tel"]:focus,form input[type="number"]:focus,form input[type="date"]:focus,form textarea:focus{color:#333;border:1px solid #a0a0a0;-moz-box-shadow:0 0 2px #a0a0a0;-webkit-box-shadow:0 0 2px #a0a0a0;box-shadow:0 0 2px #a0a0a0;-webkit-box-shadow:0 0 2px #a0a0a0 0 0 #000;box-shadow:0 0 2px #a0a0a0 0 0 #000}form input:focus+label,form input[type="text"]:focus+label,form input[type="password"]:focus+label,form input[type="email"]:focus+label,form input[type="search"]:focus+label,form input[type="tel"]:focus+label,form input[type="number"]:focus+label,form input[type="date"]:focus+label,form textarea:focus+label{color:#666;font-weight:400}form input.success,form input[type="text"].success,form input[type="password"].success,form input[type="email"].success,form input[type="search"].success,form input[type="tel"].success,form input[type="number"].success,form input[type="date"].success,form textarea.success{border:1px solid #43cea2;-moz-box-shadow:0 0 2px #43cea2;-webkit-box-shadow:0 0 2px #43cea2;box-shadow:0 0 2px #43cea2;-webkit-box-shadow:0 0 2px #43cea2 0 0 #000;box-shadow:0 0 2px #43cea2 0 0 #000}form input.success+label,form input[type="text"].success+label,form input[type="password"].success+label,form input[type="email"].success+label,form input[type="search"].success+label,form input[type="tel"].success+label,form input[type="number"].success+label,form input[type="date"].success+label,form textarea.success+label{color:#43cea2;font-weight:400}form input.error,form input[type="text"].error,form input[type="password"].error,form input[type="email"].error,form input[type="search"].error,form input[type="tel"].error,form input[type="number"].error,form input[type="date"].error,form textarea.error{border:1px solid #e2717f;-moz-box-shadow:0 0 2px #e2717f;-webkit-box-shadow:0 0 2px #e2717f;box-shadow:0 0 2px #e2717f;-webkit-box-shadow:0 0 2px #e2717f 0 0 #000;box-shadow:0 0 2px #e2717f 0 0 #000}form input.error+label,form input[type="text"].error+label,form input[type="password"].error+label,form input[type="email"].error+label,form input[type="search"].error+label,form input[type="tel"].error+label,form input[type="number"].error+label,form input[type="date"].error+label,form textarea.error+label{color:#e2717f;font-weight:400}form input::-webkit-input-placeholder,form input[type="text"]::-webkit-input-placeholder,form input[type="password"]::-webkit-input-placeholder,form input[type="email"]::-webkit-input-placeholder,form input[type="search"]::-webkit-input-placeholder,form input[type="tel"]::-webkit-input-placeholder,form input[type="number"]::-webkit-input-placeholder,form input[type="date"]::-webkit-input-placeholder,form textarea::-webkit-input-placeholder{color:#d3d3d3;font-weight:300}form [placeholder]:focus::-webkit-input-placeholder{-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out;opacity:0}form input[type="number"]::-webkit-inner-spin-button,form input[type="number"]::-webkit-outer-spin-button,form input[type="date"]::-webkit-inner-spin-button,form input[type="date"]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}form .select-style{position:relative;display:block;width:100%;border:1px solid #a0a0a0;background:#fff}form .select-style .fa-caret-down{position:absolute;right:.6em;top:.8em;color:#a0a0a0;font-size:1.4em}form .select-style select{padding:.8em 0;margin-left:.6em;width:100%;border:0;box-shadow:none;background:transparent;background-image:none;-webkit-appearance:none;color:#a0a0a0;font-size:1.2em}form .select-style select:hover{cursor:pointer}form .select-style select:focus{outline:0}form fieldset.row{padding:.5em 0}form label{position:absolute;left:5px;top:-5px;padding:0 5px;background:white;color:#a0a0a0;font-size:12px;line-height:12px;text-transform:uppercase;pointer-events:none;z-index:2}.modal-wrapper{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.3);display:none;z-index:1001;will-change:transform}.modal-wrapper .modal{position:relative;color:#333;display:none}.modal-wrapper .modal a.close{position:absolute;padding:6px 12px 9px;border:1px solid;border-radius:20px;font-weight:300;font-size:27px}.modal-wrapper .modal section.modal-content{padding:20px}.modal-wrapper:not(.fullscreen) .modal{min-height:300px;max-width:434px;margin:60px auto 0;background-color:#fff;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.modal-wrapper:not(.fullscreen) .modal a.close{right:-45px;top:-30px;color:#fff}.modal-wrapper.fullscreen{background:#fff}.modal-wrapper.fullscreen .modal{height:100%;overflow:auto}.modal-wrapper.fullscreen .modal a.close{right:20px;top:20px}.notice{position:fixed;bottom:0;right:10px;height:100px;width:300px;padding:5px 10px 5px 10px;display:none;color:#fff;z-index:1005;-webkit-border-top-right-radius:5px;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:5px;-moz-border-radius-topright:5px;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:5px;border-top-right-radius:5px;border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-left-radius:5px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.notice.success{background-color:#43cea2}.notice.warning{background-color:#f4ed6b}.notice.error{background-color:#e2717f}.notice header.notice-header{position:relative;margin-bottom:.2em}.notice section.notice-content{height:70px;width:100%;overflow:auto;font-size:.8em}.notice a.close{position:absolute;top:3px;right:0;padding:0 4px 2px;border:1px solid;border-radius:100%;font-weight:300;font-size:12px;line-height:12px;color:#fff}.notice a.close:hover{color:#ccc}nav{font-size:18px;font-size:1.125rem}nav .navbar{margin:0 auto;display:table;padding:10px 0}nav li{margin:0 10px}nav a{display:inline-block;line-height:60px;vertical-align:middle}nav a.logo{height:60px;width:60px}@media(max-width:739px){nav{font-size:14px;font-size:.875rem}nav a{line-height:40px}nav a.logo{height:40px;width:40px}}#toc{position:fixed;top:80px;height:100%;width:220px;overflow:auto;padding-bottom:100px}#toc a{color:#333}#toc a:hover{color:#1a1a1a}#toc li>ul{display:none}#toc li>ul.unstyled-list{margin-left:10px}#toc li.active>a{font-weight:bold}#toc li.active>ul{display:block}#toc ul.nav>li.active>ul>li{list-style:none}footer{padding:60px 0;color:#d3d3d3;background:#333}footer i.fa-heart{color:#e2717f}footer i.fa-beer{color:#f4ed6b}html,body{background:#fff;color:#333}.kd{color:#a783b6}.k{color:#43cea2}h1.logo{font-size:64px;font-size:4rem}.gist pre,.gist .file-data{font-size:14px!important}section{padding:40px 0}#hero .badges,#hero .github-links{padding:.3em 0}#hero .badges p,#hero .github-links p{margin:0}#ship h3{margin-bottom:1em}#ship img.ship-it{display:table;height:300px;width:300px;margin:0 auto;background:#d3d3d3;-webkit-border-radius:100%;-moz-border-radius:100%;border-radius:100%}#plugins{color:#fff;background:#333}#plugins p{color:#d3d3d3}#plugins ul li{padding:10px 20px}#plugins ul li a{display:inline-block}#plugins ul li a img{height:100px;max-width:160px}@media(max-width:739px){#plugins ul li a img{height:60px;max-width:120px}}#features{color:#fff;background:#e2717f}#features h4{color:#982e3e}#features a.primary{color:#f8f8f8;border-bottom:1px dashed #f8f8f8}#features a.primary:hover{color:#dfdfdf;border-bottom:1px dashed #dfdfdf}#features p{text-align:justify}#comparison img{margin:0 auto}.page a,.example a{color:#e2717f}.page a:hover,.example a:hover{color:#d94759}.page .file-data .line-numbers,.example .file-data .line-numbers{width:40px}#todo-example input[type="text"]{margin:10px 0}#todo-example ul.todos{height:320px}#todo-example ul.todos li{padding:5px 0}#todo-example ul.todos li input[type="checkbox"]{margin-top:.2em}#todo-example ul.todos li span{margin-left:5px}#todo-example ul.todos li.done label{text-decoration:line-through;color:#998}#todo-example ul.todos li .delete{font-weight:bold}#todo-example label{float:left}#todo-example .primary-button{width:100%} \ No newline at end of file diff --git a/js/todos.js b/js/todos.js index 6f4a58b356..3ec39c65b0 100644 --- a/js/todos.js +++ b/js/todos.js @@ -5,12 +5,10 @@ var app = { addTodo: function(todo) { - var html = '

        '; + 'X'; el.find('.todos').append(html); app.updateTodo(todo); diff --git a/learn.md b/learn.md index 217ea475e7..e1f687b8ad 100644 --- a/learn.md +++ b/learn.md @@ -6,319 +6,11 @@ permalink: /learn/ weight: 2 --- -## Validation and processing -The next step is validating and processing our data. With the MongoDB service already implemented we have two options to extend its functionality. -### Service Extension -*feathers-mongodb* uses the ES5 inheritance library [Uberproto](https://github.com/daffl/uberproto). This allows us to `extend` the original object returned by the call to `mongodb(options)` and overwrite the existing implementation of `create` to process the Todo data and then pass it to the original (`_super`) method. This way we can also easily add our own methods to the service. -```js -var todoService = mongodb({ - db: 'feathers-demo', - collection: 'todos' -}).extend({ - create: function(data, params, callback) { - // We want to make sure that `complete` is always set - // and also only use the `text` and `complete` properties - var newData = { - text: data.text, - complete: data.complete === 'true' || !!data.complete - }; - // Call the original method with the new data - this._super(newData, params, callback); - }, - // Add another method - addDefaultTodo: function(callback) { - this.create({ - text: 'The default todo', - complete: false - }, {}, callback); - } -}); -``` - -### Hooks - -Another option is the [feathers-hooks](https://github.com/feathersjs/feathers-hooks) plugin which allows us to add asynchronous hooks before or after a service method call. Hooks work similar to Express middleware. The following example adds a hook that converts our Todo data and makes sure that nobody submits anything that we don't want to put into MongoDB: - -> `npm install feathers-hooks` - -```js -// app.js -var feathers = require('feathers'); -var mongodb = require('feathers-mongodb'); -var hooks = require('feathers-hooks'); -var bodyParser = require('body-parser'); - -var app = feathers(); -var todoService = mongodb({ - db: 'feathers-demo', - collection: 'todos' -}); - -app.configure(feathers.rest()) - .configure(feathers.socketio()) - // Configure hooks - .configure(hooks()) - .use(bodyParser.json()) - .use('/todos', todoService) - .use('/', feathers.static(__dirname)) - .listen(3000); - -// Get the wrapped todos service object and -// add a `before` create hook modifying the data -app.service('todos').before({ - create: function(hook, next) { - var oldData = hook.data; - // Replace the old data by creating a new object - hook.data = { - text: oldData.text, - complete: oldData.complete === 'true' || !!oldData.complete - }; - next(); - } -}); -``` - -You might have noticed the call to [.service](/api/#toc9) in `app.service('todos')`. This will basically return the original service object (`todoService` in our case) *but* contain some functionality added by Feathers. Most notably, the returned service object will be an [EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter) that emits `created`, `updated` etc. events. - -The *feathers-hooks* plugin also adds a `.before` and `.after` method that allows to add hooks to that service. When you need to access services, *always* use `app.service(name)` and not the original service object otherwise things will not work as expected. - -## Authentication - -Since Feathers directly extends Express you can use any of its authentication mechanism. [Passport](http://passportjs.org/) is one that is used quite often and also really flexible. Manually setting up shared authentication between websockets and an HTTP REST API can be tricky. This is what the [feathers-passport](https://github.com/feathersjs/feathers-passport) module aims to make easier. The following examples show how to add local authentication that uses a Feathers service for storing and retrieving user information. - -### Configuring Passport - -The first step is to add the Passport, local strategy and feathers-passport modules to our application. Since we are using MongoDB already we will also use it as the session store through the [connect-mongo](https://github.com/kcbanner/connect-mongo) module: - -> `npm install passport passport-local connect-mongo feathers-passport` - -```js -// app.js -var feathers = require('feathers'); -var mongodb = require('feathers-mongodb'); -var bodyParser = require('body-parser'); -var hooks = require('feathers-hooks'); - -var passport = require('passport'); -var connectMongo = require('connect-mongo'); -var feathersPassport = require('feathers-passport'); - -var app = feathers(); -var todoService = mongodb({ - db: 'feathers-demo', - collection: 'todos' -}); - -app.configure(feathers.rest()) - .configure(feathers.socketio()) - .configure(hooks()) - .configure(feathersPassport(function(result) { - // MongoStore needs the session function - var MongoStore = connectMongo(result.createSession); - - result.secret = 'feathers-rocks'; - result.store = new MongoStore({ - db: 'feathers-demo' - }); - - return result; - })) - .use(bodyParser.json()) - // Now we also need to parse HTML form submissions - .use(bodyParser.urlencoded({ extended: true })) - .use('/todos', todoService) - .use('/', feathers.static(__dirname)); -``` - -### User storage - -Next, we create a MongoDB service for storing user information. It is always a good idea to not store plain text passwords in the database so we add a `.before` hook that salts and then hashes the password when creating a new user. This can be done in the service `.setup` which is called when the application is ready to start up. We also add an `.authenticate` method that we can use to look up a user by username and compare the hashed and salted passwords. - -```js -var crypto = require('crypto'); -// One-way hashes a string -var hash = function(string, salt) { - var shasum = crypto.createHash('sha256'); - shasum.update(string + salt); - return shasum.digest('hex'); -}; - -var userService = mongodb({ - db: 'feathers-demo', - collection: 'users' -}).extend({ - authenticate: function(username, password, callback) { - // This will be used as the MongoDB query - var query = { - username: username - }; - - this.find({ query: query }, function(error, users) { - if(error) { - return callback(error); - } - - var user = users[0]; - - if(!user) { - return callback(new Error('No user found')); - } - - // Compare the hashed and salted passwords - if(user.password !== hash(password, user.salt)) { - return callback(new Error('User password does not match')); - } - - // If we got to here, we call the callback with the user information - return callback(null, user); - }); - }, - - setup: function() { - // Adds the hook during service setup - this.before({ - // Hash the password before sending it to MongoDB - create: function(hook, next) { - // Create a random salt string - var salt = crypto.randomBytes(128).toString('base64'); - // Change the password to a hashed and salted password - hook.data.password = hash(hook.data.password, salt); - // Add the salt to the user data - hook.data.salt = salt; - next(); - } - }); - } -}); - -app.use('/users', userService); -``` - -Now we need to set up Passport to use that service and tell it how to deserialize and serialize our user information. For us, the serialized form is the `_id` generated by MongoDB. To deserialize by `_id` we can simply call the user services `.get` method. Then we add the local strategy which simply calls the `.authenticate` method that we implemented in the user service. - -```js -var LocalStrategy = require('passport-local').Strategy; - -passport.serializeUser(function(user, done) { - // Use the `_id` property to serialize the user - done(null, user._id); -}); - -passport.deserializeUser(function(id, done) { - // Get the user information from the service - app.service('users').get(id, {}, done); -}); - -passport.use(new LocalStrategy(function(username, password, done) { - app.service('users').authenticate(username, password, done); -})); -``` - -### Login - -The last step is to add the authentication route that we can POST the login to: - -```js -app.post('/login', passport.authenticate('local', { - successRedirect: '/', - failureRedirect: '/login.html', - failureFlash: false -})); - -app.listen(3000); -``` - -And to add a `login.html` page: - -```html - - - - - - - -
        -
        - - -
        -
        - - -
        -
        - -
        -
        - - -``` - -To test the login, we might want to add a new user as well: - -
        curl 'http://localhost:3000/users/' -H 'Content-Type: application/json' --data-binary '{ "username": "feathers", "password": "supersecret" }'
        - -Now it should be possible to log in with the `feathers` username and `supersecret` password and you will get the logged in user information in every service call in `params.user`. - -## Authorization - -Authorization is the process of determining after successful authentication if the user is allowed to perform the requested action. This is again where hooks come in handy. - -### User authorization - -Since *feathers-passport* adds the authenticated user information to the service call parameters we can just check those in the hook and return with an error if the user is not authorized: - -```js -app.service('todos').before({ - create: function(hook, next) { - // We only allow creating todos with an authenticated user - if(!hook.params.user) { - return next(new Error('You need to be authenticated')); - } - - // Check if the user belongs the `admin` group - var groups = hook.params.user.groups; - if(groups.indexOf('admin') === -1) { - // Return with an error if not - return next(new Error('User is not allowed to create a new Todo')); - } - - // Otherwise just continue on to the - // next hook or the service method - next(); - } -}); -``` - -### Event filtering - -This is also a good time to talk a little about [filtering events](/api/#event-filtering). It is very likely that you eventually only want to send certain events to specific users instead of everybody. Following up on the group authorization example from above, we might only want to dispatch a `todos created` event to users that are in the admin group. This can be done by adding a `created(data, params, callback)` method to the Todo MongoDB service: - -```js -var todoService = mongodb({ - db: 'feathers-demo', - collection: 'todos' -}).extend({ - created: function(data, params, callback) { - // Only dispatch if we have a user and user belongs to the admin group - if(params.user && params.user.groups.indexOf('admin') !== -1) { - // Call back with the data we want to dispatch - return callback(null, data); - } - - // Call back with falsy value to not dispatch the event - callback(null, false); - } -}); -``` - -The `created` method is being called for every connected user with the `params` set in the `request.feathers` object and the data from the event. You can either call back with the original or modified data (which will then be dispatched to that user) or a falsy value which will prevent the event from being dispatched to that connection. ## What's next? @@ -327,5 +19,3 @@ This guide hopefully gave you an overview of how Feathers works. We created a To The next step is definitely reading through the [API documentation](/api/) for a more detailed information on how to configure and use certain parts of Feathers. The [FAQ](/faq/) also has some answers to questions that come up regularly. For a growing list of official plugins, have a look at the [Feathersjs GitHub organization](https://github.com/feathersjs). If you have any other questions, feel free to submit them as a [GitHub issue](https://github.com/feathersjs/feathers/issues) or on [Stackoverflow](http://stackoverflow.com) using the `feathers` or `feathersjs` tag or join [#feathersjs](http://webchat.freenode.net/?channels=feathersjs) on Freenode IRC. - - diff --git a/learn/authentication.md b/learn/authentication.md index 251ba3c346..2ad421bcae 100644 --- a/learn/authentication.md +++ b/learn/authentication.md @@ -5,4 +5,181 @@ description: Learn how to do user authentication and authorization hide: true --- -# Authentication +## Authentication + +Since Feathers directly extends Express you can use any of its authentication mechanism. [Passport](http://passportjs.org/) is one that is used quite often and also really flexible. Manually setting up shared authentication between websockets and an HTTP REST API can be tricky. This is what the [feathers-passport](https://github.com/feathersjs/feathers-passport) module aims to make easier. The following examples show how to add local authentication that uses a Feathers service for storing and retrieving user information. + +### Configuring Passport + +The first step is to add the Passport, local strategy and feathers-passport modules to our application. Since we are using MongoDB already we will also use it as the session store through the [connect-mongo](https://github.com/kcbanner/connect-mongo) module: + +> `npm install passport passport-local connect-mongo feathers-passport` + +```js +// app.js +var feathers = require('feathers'); +var mongodb = require('feathers-mongodb'); +var bodyParser = require('body-parser'); +var hooks = require('feathers-hooks'); + +var passport = require('passport'); +var connectMongo = require('connect-mongo'); +var feathersPassport = require('feathers-passport'); + +var app = feathers(); +var todoService = mongodb({ + db: 'feathers-demo', + collection: 'todos' +}); + +app.configure(feathers.rest()) + .configure(feathers.socketio()) + .configure(hooks()) + .configure(feathersPassport(function(result) { + // MongoStore needs the session function + var MongoStore = connectMongo(result.createSession); + + result.secret = 'feathers-rocks'; + result.store = new MongoStore({ + db: 'feathers-demo' + }); + + return result; + })) + .use(bodyParser.json()) + // Now we also need to parse HTML form submissions + .use(bodyParser.urlencoded({ extended: true })) + .use('/todos', todoService) + .use('/', feathers.static(__dirname)); +``` + +### User storage + +Next, we create a MongoDB service for storing user information. It is always a good idea to not store plain text passwords in the database so we add a `.before` hook that salts and then hashes the password when creating a new user. This can be done in the service `.setup` which is called when the application is ready to start up. We also add an `.authenticate` method that we can use to look up a user by username and compare the hashed and salted passwords. + +```js +var crypto = require('crypto'); +// One-way hashes a string +var hash = function(string, salt) { + var shasum = crypto.createHash('sha256'); + shasum.update(string + salt); + return shasum.digest('hex'); +}; + +var userService = mongodb({ + db: 'feathers-demo', + collection: 'users' +}).extend({ + authenticate: function(username, password, callback) { + // This will be used as the MongoDB query + var query = { + username: username + }; + + this.find({ query: query }, function(error, users) { + if(error) { + return callback(error); + } + + var user = users[0]; + + if(!user) { + return callback(new Error('No user found')); + } + + // Compare the hashed and salted passwords + if(user.password !== hash(password, user.salt)) { + return callback(new Error('User password does not match')); + } + + // If we got to here, we call the callback with the user information + return callback(null, user); + }); + }, + + setup: function() { + // Adds the hook during service setup + this.before({ + // Hash the password before sending it to MongoDB + create: function(hook, next) { + // Create a random salt string + var salt = crypto.randomBytes(128).toString('base64'); + // Change the password to a hashed and salted password + hook.data.password = hash(hook.data.password, salt); + // Add the salt to the user data + hook.data.salt = salt; + next(); + } + }); + } +}); + +app.use('/users', userService); +``` + +Now we need to set up Passport to use that service and tell it how to deserialize and serialize our user information. For us, the serialized form is the `_id` generated by MongoDB. To deserialize by `_id` we can simply call the user services `.get` method. Then we add the local strategy which simply calls the `.authenticate` method that we implemented in the user service. + +```js +var LocalStrategy = require('passport-local').Strategy; + +passport.serializeUser(function(user, done) { + // Use the `_id` property to serialize the user + done(null, user._id); +}); + +passport.deserializeUser(function(id, done) { + // Get the user information from the service + app.service('users').get(id, {}, done); +}); + +passport.use(new LocalStrategy(function(username, password, done) { + app.service('users').authenticate(username, password, done); +})); +``` + +### Login + +The last step is to add the authentication route that we can POST the login to: + +```js +app.post('/login', passport.authenticate('local', { + successRedirect: '/', + failureRedirect: '/login.html', + failureFlash: false +})); + +app.listen(3000); +``` + +And to add a `login.html` page: + +```html + + + + + + + +
        +
        + + +
        +
        + + +
        +
        + +
        +
        + + +``` + +To test the login, we might want to add a new user as well: + +
        curl 'http://localhost:3000/users/' -H 'Content-Type: application/json' --data-binary '{ "username": "feathers", "password": "supersecret" }'
        + +Now it should be possible to log in with the `feathers` username and `supersecret` password and you will get the logged in user information in every service call in `params.user`. diff --git a/learn/authorization.md b/learn/authorization.md index ce1eb251be..336f4ed730 100644 --- a/learn/authorization.md +++ b/learn/authorization.md @@ -5,4 +5,56 @@ description: Learn how to authorize users hide: true --- -# Authorization +## Authorization + +Authorization is the process of determining after successful authentication if the user is allowed to perform the requested action. This is again where hooks come in handy. + +### User authorization + +Since *feathers-passport* adds the authenticated user information to the service call parameters we can just check those in the hook and return with an error if the user is not authorized: + +```js +app.service('todos').before({ + create: function(hook, next) { + // We only allow creating todos with an authenticated user + if(!hook.params.user) { + return next(new Error('You need to be authenticated')); + } + + // Check if the user belongs the `admin` group + var groups = hook.params.user.groups; + if(groups.indexOf('admin') === -1) { + // Return with an error if not + return next(new Error('User is not allowed to create a new Todo')); + } + + // Otherwise just continue on to the + // next hook or the service method + next(); + } +}); +``` + +### Event filtering + +This is also a good time to talk a little about [filtering events](/api/#event-filtering). It is very likely that you eventually only want to send certain events to specific users instead of everybody. Following up on the group authorization example from above, we might only want to dispatch a `todos created` event to users that are in the admin group. This can be done by adding a `created(data, params, callback)` method to the Todo MongoDB service: + +```js +var todoService = mongodb({ + db: 'feathers-demo', + collection: 'todos' +}).extend({ + created: function(data, params, callback) { + // Only dispatch if we have a user and user belongs to the admin group + if(params.user && params.user.groups.indexOf('admin') !== -1) { + // Call back with the data we want to dispatch + return callback(null, data); + } + + // Call back with falsy value to not dispatch the event + callback(null, false); + } +}); +``` + +The `created` method is being called for every connected user with the `params` set in the `request.feathers` object and the data from the event. You can either call back with the original or modified data (which will then be dispatched to that user) or a falsy value which will prevent the event from being dispatched to that connection. diff --git a/learn/validation.md b/learn/validation.md index 02371395fe..cff1f5c6ea 100644 --- a/learn/validation.md +++ b/learn/validation.md @@ -5,4 +5,83 @@ description: Learn how to do Validation and data processing hide: true --- -# Validation & Processing +## Validation and processing + +The next step is validating and processing our data. With the MongoDB service already implemented we have two options to extend its functionality. + +### Service Extension + +*feathers-mongodb* uses the ES5 inheritance library [Uberproto](https://github.com/daffl/uberproto). This allows us to `extend` the original object returned by the call to `mongodb(options)` and overwrite the existing implementation of `create` to process the Todo data and then pass it to the original (`_super`) method. This way we can also easily add our own methods to the service. + +```js +var todoService = mongodb({ + db: 'feathers-demo', + collection: 'todos' +}).extend({ + create: function(data, params, callback) { + // We want to make sure that `complete` is always set + // and also only use the `text` and `complete` properties + var newData = { + text: data.text, + complete: data.complete === 'true' || !!data.complete + }; + // Call the original method with the new data + this._super(newData, params, callback); + }, + + // Add another method + addDefaultTodo: function(callback) { + this.create({ + text: 'The default todo', + complete: false + }, {}, callback); + } +}); +``` + +### Hooks + +Another option is the [feathers-hooks](https://github.com/feathersjs/feathers-hooks) plugin which allows us to add asynchronous hooks before or after a service method call. Hooks work similar to Express middleware. The following example adds a hook that converts our Todo data and makes sure that nobody submits anything that we don't want to put into MongoDB: + +> `npm install feathers-hooks` + +```js +// app.js +var feathers = require('feathers'); +var mongodb = require('feathers-mongodb'); +var hooks = require('feathers-hooks'); +var bodyParser = require('body-parser'); + +var app = feathers(); +var todoService = mongodb({ + db: 'feathers-demo', + collection: 'todos' +}); + +app.configure(feathers.rest()) + .configure(feathers.socketio()) + // Configure hooks + .configure(hooks()) + .use(bodyParser.json()) + .use('/todos', todoService) + .use('/', feathers.static(__dirname)) + .listen(3000); + +// Get the wrapped todos service object and +// add a `before` create hook modifying the data +app.service('todos').before({ + create: function(hook, next) { + var oldData = hook.data; + // Replace the old data by creating a new object + hook.data = { + text: oldData.text, + complete: oldData.complete === 'true' || !!oldData.complete + }; + next(); + } +}); +``` + +You might have noticed the call to [.service](/api/#toc9) in `app.service('todos')`. This will basically return the original service object (`todoService` in our case) *but* contain some functionality added by Feathers. Most notably, the returned service object will be an [EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter) that emits `created`, `updated` etc. events. + +The *feathers-hooks* plugin also adds a `.before` and `.after` method that allows to add hooks to that service. When you need to access services, *always* use `app.service(name)` and not the original service object otherwise things will not work as expected. From 596a72ff2954d256ff68542ebbd85a900cb55e18 Mon Sep 17 00:00:00 2001 From: David Luecke Date: Mon, 13 Jul 2015 23:17:21 -0600 Subject: [PATCH 03/11] More documentation, better styles. --- _layouts/index.html | 31 +++++++++++++++---------------- _layouts/page.html | 1 + _layouts/quick-start.html | 16 +++++++++------- _less/feathers.less | 14 ++++++++++---- css/feathers.min.css | 2 +- learn.md | 34 ++++++++++++++++++++++++++++++---- quick-start.md | 36 +++++++++++++++++++++++++++++------- 7 files changed, 95 insertions(+), 39 deletions(-) diff --git a/_layouts/index.html b/_layouts/index.html index 8321d496db..365dc7942b 100644 --- a/_layouts/index.html +++ b/_layouts/index.html @@ -108,38 +108,37 @@

        We have plug-ins or guides for the most popular clients.

        -
        -

        - Feathers is a real-time framework where you don't have to - throw away the things you already learned or built... -

        -
        -

        Pure JavaScript

        -

        Because Feathers is 100% vanilla JavaScript on the backend, you get to use the same language all the way through your web stack. Less context switching.

        +

        Battle Tested Core

        +

        Feathers is a very thin wrapper over top of Express and Socket.io, both of which have been used in production by thousands of companies.

        -

        Express

        -

        Feathers is a very thin wrapper over top of Express and Socket.io and works as a drop-in replacement for Express in any existing application.

        +

        Uber Flexible

        +

        Our plug-ins are small, easy to learn and extremely flexible. Giving you only what you need and then getting out of your way.

        -

        Middleware

        -

        Use any Express middleware and Hooks, which follow the same pattern, for service data-processing and authorization that works both via REST and websockets.

        +

        Minimal Configuration

        +

        Tired of massive JSON or YAML files? Feathers reduces complexity while still being explicit, not by hiding it behind generators and configuration files.

        Multi-Database

        -

        We support MongoDB, Postgres, NeDB and MySQL out of the box. If that's not for you, you can easily write your own service adapters.

        +

        We support MongoDB, Postgres, MySQL and NeDB out of the box. If that's not for you, you can easily write your own service adapters.

        Front End Agnostic

        -

        Use whatever client you want; Angular, React, Swift/ObjC, Android, it doesn't matter. A few lines of code can make your frontend real-time.

        +

        Use whatever client you want; Angular, React, Swift/ObjC, Android, it doesn't matter. We provide some helpful guides and plug-ins to make things easier.

        -

        Existing APIs

        -

        No need to re-write your existing API to go real-time. Feathers can act as a real-time proxy between other APIs and your frontend.

        +

        Pure JavaScript

        +

        Because Feathers is 100% vanilla JavaScript on the backend, you get to use the same language all the way through your web stack. Less context switching.

        +
        +
        +
        diff --git a/_layouts/page.html b/_layouts/page.html index cff7f6e576..6c48bca5cf 100644 --- a/_layouts/page.html +++ b/_layouts/page.html @@ -9,6 +9,7 @@
        +

        {{page.title}}

        {{ content }}
        diff --git a/_layouts/quick-start.html b/_layouts/quick-start.html index 2e45a2b408..96bec0089e 100644 --- a/_layouts/quick-start.html +++ b/_layouts/quick-start.html @@ -6,13 +6,9 @@
        - +

        {{page.title}}

        -

        - In the tradition of TodoMVC the below example shows a real-time Todo application with Feathers and an in-memory Todo service on the server and a jQuery HTML page for the browser. To get up and running with this example download the Gist, unpack and in the new folder run -

        npm install feathers feathers-memory body-parser
        node app.js
        - Then go to http://localhost:8080. The REST API will be available at localhost:8080/todos (check out the example application endpoint here).
        Next, read up on the Feathers guide. -

        +

        In this guide we will go over the basic concepts of Feathers by building the following real-time Todo application (inspired by the great TodoMVC) using jQuery as the frontend:


        @@ -25,8 +21,14 @@
        + +

        + Eager to try it out yourself? Download this Gist, unpack and in the new folder run +

        npm install feathers feathers-memory body-parser
        node app.js
        + Then go to http://localhost:8080. The REST API will be available at localhost:8080/todos. +
        In this guide we will learn how it all works... +

        -
        diff --git a/_less/feathers.less b/_less/feathers.less index 8cb286ef45..19673591af 100644 --- a/_less/feathers.less +++ b/_less/feathers.less @@ -42,6 +42,10 @@ section { padding: 40px 0; } +code { + padding: 0; +} + #hero { .badges, .github-links { @@ -116,10 +120,6 @@ section { border-bottom: 1px dashed darken(@soft-white, 10%); } } - - p { - text-align: justify; - } } #comparison { @@ -128,8 +128,13 @@ section { } } +.example, .example .row { + padding-bottom: 0; +} .page, .example { + margin-bottom: 0; + a { color: @red; @@ -146,6 +151,7 @@ section { } #todo-example { + padding-bottom: 2em; input[type="text"] { margin: 10px 0; diff --git a/css/feathers.min.css b/css/feathers.min.css index bb62fca957..0bde08b66e 100644 --- a/css/feathers.min.css +++ b/css/feathers.min.css @@ -1,4 +1,4 @@ .hll{background-color:#ffc}.c{color:#998;font-style:italic}.err{color:#a61717;background-color:#e3d2d2}.k{color:#000;font-weight:bold}.o{color:#000;font-weight:bold}.cm{color:#998;font-style:italic}.cp{color:#999;font-weight:bold;font-style:italic}.c1{color:#998;font-style:italic}.cs{color:#999;font-weight:bold;font-style:italic}.gd{color:#000;background-color:#fdd}.ge{color:#000;font-style:italic}.gr{color:#a00}.gh{color:#999}.gi{color:#000;background-color:#dfd}.go{color:#888}.gp{color:#555}.gs{font-weight:bold}.gu{color:#aaa}.gt{color:#a00}.kc{color:#000;font-weight:bold}.kd{color:#000;font-weight:bold}.kn{color:#000;font-weight:bold}.kp{color:#000;font-weight:bold}.kr{color:#000;font-weight:bold}.kt{color:#458;font-weight:bold}.m{color:#099}.s{color:#d01040}.na{color:#008080}.nb{color:#0086b3}.nc{color:#458;font-weight:bold}.no{color:#008080}.nd{color:#3c5d5d;font-weight:bold}.ni{color:#800080}.ne{color:#900;font-weight:bold}.nf{color:#900;font-weight:bold}.nl{color:#900;font-weight:bold}.nn{color:#555}.nt{color:#000080}.nv{color:#008080}.ow{color:#000;font-weight:bold}.w{color:#bbb}.mf{color:#099}.mh{color:#099}.mi{color:#099}.mo{color:#099}.sb{color:#d01040}.sc{color:#d01040}.sd{color:#d01040}.s2{color:#d01040}.se{color:#d01040}.sh{color:#d01040}.si{color:#d01040}.sx{color:#d01040}.sr{color:#009926}.s1{color:#d01040}.ss{color:#990073}.bp{color:#999}.vc{color:#008080}.vg{color:#008080}.vi{color:#008080}.il{color:#099}/*! * Font Awesome 4.3.0 by @davegandy - http://fontawesome.io - @fontawesome * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) - */@font-face{font-family:'FontAwesome';src:url('/fonts/fontawesome-webfont.eot?v=4.3.0');src:url('/fonts/fontawesome-webfont.eot?#iefix&v=4.3.0') format('embedded-opentype'),url('/fonts/fontawesome-webfont.woff2?v=4.3.0') format('woff2'),url('/fonts/fontawesome-webfont.woff?v=4.3.0') format('woff'),url('/fonts/fontawesome-webfont.ttf?v=4.3.0') format('truetype'),url('/fonts/fontawesome-webfont.svg?v=4.3.0#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;transform:translate(0,0)}.fa-lg{font-size:1.3333333333333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.2857142857142858em;text-align:center}.fa-ul{padding-left:0;margin-left:2.142857142857143em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.142857142857143em;width:2.142857142857143em;top:.14285714285714285em;text-align:center}.fa-li.fa-lg{left:-1.8571428571428572em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2);-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=0,mirror=1);-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.fa-flip-vertical{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2,mirror=1);-webkit-transform:scale(1,-1);-ms-transform:scale(1,-1);transform:scale(1,-1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-remove:before,.fa-close:before,.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook-f:before,.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{content:"\f09c"}.fa-credit-card:before{content:"\f09d"}.fa-rss:before{content:"\f09e"}.fa-hdd-o:before{content:"\f0a0"}.fa-bullhorn:before{content:"\f0a1"}.fa-bell:before{content:"\f0f3"}.fa-certificate:before{content:"\f0a3"}.fa-hand-o-right:before{content:"\f0a4"}.fa-hand-o-left:before{content:"\f0a5"}.fa-hand-o-up:before{content:"\f0a6"}.fa-hand-o-down:before{content:"\f0a7"}.fa-arrow-circle-left:before{content:"\f0a8"}.fa-arrow-circle-right:before{content:"\f0a9"}.fa-arrow-circle-up:before{content:"\f0aa"}.fa-arrow-circle-down:before{content:"\f0ab"}.fa-globe:before{content:"\f0ac"}.fa-wrench:before{content:"\f0ad"}.fa-tasks:before{content:"\f0ae"}.fa-filter:before{content:"\f0b0"}.fa-briefcase:before{content:"\f0b1"}.fa-arrows-alt:before{content:"\f0b2"}.fa-group:before,.fa-users:before{content:"\f0c0"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-cloud:before{content:"\f0c2"}.fa-flask:before{content:"\f0c3"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-copy:before,.fa-files-o:before{content:"\f0c5"}.fa-paperclip:before{content:"\f0c6"}.fa-save:before,.fa-floppy-o:before{content:"\f0c7"}.fa-square:before{content:"\f0c8"}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:"\f0c9"}.fa-list-ul:before{content:"\f0ca"}.fa-list-ol:before{content:"\f0cb"}.fa-strikethrough:before{content:"\f0cc"}.fa-underline:before{content:"\f0cd"}.fa-table:before{content:"\f0ce"}.fa-magic:before{content:"\f0d0"}.fa-truck:before{content:"\f0d1"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-google-plus-square:before{content:"\f0d4"}.fa-google-plus:before{content:"\f0d5"}.fa-money:before{content:"\f0d6"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-columns:before{content:"\f0db"}.fa-unsorted:before,.fa-sort:before{content:"\f0dc"}.fa-sort-down:before,.fa-sort-desc:before{content:"\f0dd"}.fa-sort-up:before,.fa-sort-asc:before{content:"\f0de"}.fa-envelope:before{content:"\f0e0"}.fa-linkedin:before{content:"\f0e1"}.fa-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-legal:before,.fa-gavel:before{content:"\f0e3"}.fa-dashboard:before,.fa-tachometer:before{content:"\f0e4"}.fa-comment-o:before{content:"\f0e5"}.fa-comments-o:before{content:"\f0e6"}.fa-flash:before,.fa-bolt:before{content:"\f0e7"}.fa-sitemap:before{content:"\f0e8"}.fa-umbrella:before{content:"\f0e9"}.fa-paste:before,.fa-clipboard:before{content:"\f0ea"}.fa-lightbulb-o:before{content:"\f0eb"}.fa-exchange:before{content:"\f0ec"}.fa-cloud-download:before{content:"\f0ed"}.fa-cloud-upload:before{content:"\f0ee"}.fa-user-md:before{content:"\f0f0"}.fa-stethoscope:before{content:"\f0f1"}.fa-suitcase:before{content:"\f0f2"}.fa-bell-o:before{content:"\f0a2"}.fa-coffee:before{content:"\f0f4"}.fa-cutlery:before{content:"\f0f5"}.fa-file-text-o:before{content:"\f0f6"}.fa-building-o:before{content:"\f0f7"}.fa-hospital-o:before{content:"\f0f8"}.fa-ambulance:before{content:"\f0f9"}.fa-medkit:before{content:"\f0fa"}.fa-fighter-jet:before{content:"\f0fb"}.fa-beer:before{content:"\f0fc"}.fa-h-square:before{content:"\f0fd"}.fa-plus-square:before{content:"\f0fe"}.fa-angle-double-left:before{content:"\f100"}.fa-angle-double-right:before{content:"\f101"}.fa-angle-double-up:before{content:"\f102"}.fa-angle-double-down:before{content:"\f103"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}.fa-angle-up:before{content:"\f106"}.fa-angle-down:before{content:"\f107"}.fa-desktop:before{content:"\f108"}.fa-laptop:before{content:"\f109"}.fa-tablet:before{content:"\f10a"}.fa-mobile-phone:before,.fa-mobile:before{content:"\f10b"}.fa-circle-o:before{content:"\f10c"}.fa-quote-left:before{content:"\f10d"}.fa-quote-right:before{content:"\f10e"}.fa-spinner:before{content:"\f110"}.fa-circle:before{content:"\f111"}.fa-mail-reply:before,.fa-reply:before{content:"\f112"}.fa-github-alt:before{content:"\f113"}.fa-folder-o:before{content:"\f114"}.fa-folder-open-o:before{content:"\f115"}.fa-smile-o:before{content:"\f118"}.fa-frown-o:before{content:"\f119"}.fa-meh-o:before{content:"\f11a"}.fa-gamepad:before{content:"\f11b"}.fa-keyboard-o:before{content:"\f11c"}.fa-flag-o:before{content:"\f11d"}.fa-flag-checkered:before{content:"\f11e"}.fa-terminal:before{content:"\f120"}.fa-code:before{content:"\f121"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"\f122"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"\f123"}.fa-location-arrow:before{content:"\f124"}.fa-crop:before{content:"\f125"}.fa-code-fork:before{content:"\f126"}.fa-unlink:before,.fa-chain-broken:before{content:"\f127"}.fa-question:before{content:"\f128"}.fa-info:before{content:"\f129"}.fa-exclamation:before{content:"\f12a"}.fa-superscript:before{content:"\f12b"}.fa-subscript:before{content:"\f12c"}.fa-eraser:before{content:"\f12d"}.fa-puzzle-piece:before{content:"\f12e"}.fa-microphone:before{content:"\f130"}.fa-microphone-slash:before{content:"\f131"}.fa-shield:before{content:"\f132"}.fa-calendar-o:before{content:"\f133"}.fa-fire-extinguisher:before{content:"\f134"}.fa-rocket:before{content:"\f135"}.fa-maxcdn:before{content:"\f136"}.fa-chevron-circle-left:before{content:"\f137"}.fa-chevron-circle-right:before{content:"\f138"}.fa-chevron-circle-up:before{content:"\f139"}.fa-chevron-circle-down:before{content:"\f13a"}.fa-html5:before{content:"\f13b"}.fa-css3:before{content:"\f13c"}.fa-anchor:before{content:"\f13d"}.fa-unlock-alt:before{content:"\f13e"}.fa-bullseye:before{content:"\f140"}.fa-ellipsis-h:before{content:"\f141"}.fa-ellipsis-v:before{content:"\f142"}.fa-rss-square:before{content:"\f143"}.fa-play-circle:before{content:"\f144"}.fa-ticket:before{content:"\f145"}.fa-minus-square:before{content:"\f146"}.fa-minus-square-o:before{content:"\f147"}.fa-level-up:before{content:"\f148"}.fa-level-down:before{content:"\f149"}.fa-check-square:before{content:"\f14a"}.fa-pencil-square:before{content:"\f14b"}.fa-external-link-square:before{content:"\f14c"}.fa-share-square:before{content:"\f14d"}.fa-compass:before{content:"\f14e"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"\f150"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"\f151"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"\f152"}.fa-euro:before,.fa-eur:before{content:"\f153"}.fa-gbp:before{content:"\f154"}.fa-dollar:before,.fa-usd:before{content:"\f155"}.fa-rupee:before,.fa-inr:before{content:"\f156"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"\f157"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"\f158"}.fa-won:before,.fa-krw:before{content:"\f159"}.fa-bitcoin:before,.fa-btc:before{content:"\f15a"}.fa-file:before{content:"\f15b"}.fa-file-text:before{content:"\f15c"}.fa-sort-alpha-asc:before{content:"\f15d"}.fa-sort-alpha-desc:before{content:"\f15e"}.fa-sort-amount-asc:before{content:"\f160"}.fa-sort-amount-desc:before{content:"\f161"}.fa-sort-numeric-asc:before{content:"\f162"}.fa-sort-numeric-desc:before{content:"\f163"}.fa-thumbs-up:before{content:"\f164"}.fa-thumbs-down:before{content:"\f165"}.fa-youtube-square:before{content:"\f166"}.fa-youtube:before{content:"\f167"}.fa-xing:before{content:"\f168"}.fa-xing-square:before{content:"\f169"}.fa-youtube-play:before{content:"\f16a"}.fa-dropbox:before{content:"\f16b"}.fa-stack-overflow:before{content:"\f16c"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-adn:before{content:"\f170"}.fa-bitbucket:before{content:"\f171"}.fa-bitbucket-square:before{content:"\f172"}.fa-tumblr:before{content:"\f173"}.fa-tumblr-square:before{content:"\f174"}.fa-long-arrow-down:before{content:"\f175"}.fa-long-arrow-up:before{content:"\f176"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-apple:before{content:"\f179"}.fa-windows:before{content:"\f17a"}.fa-android:before{content:"\f17b"}.fa-linux:before{content:"\f17c"}.fa-dribbble:before{content:"\f17d"}.fa-skype:before{content:"\f17e"}.fa-foursquare:before{content:"\f180"}.fa-trello:before{content:"\f181"}.fa-female:before{content:"\f182"}.fa-male:before{content:"\f183"}.fa-gittip:before,.fa-gratipay:before{content:"\f184"}.fa-sun-o:before{content:"\f185"}.fa-moon-o:before{content:"\f186"}.fa-archive:before{content:"\f187"}.fa-bug:before{content:"\f188"}.fa-vk:before{content:"\f189"}.fa-weibo:before{content:"\f18a"}.fa-renren:before{content:"\f18b"}.fa-pagelines:before{content:"\f18c"}.fa-stack-exchange:before{content:"\f18d"}.fa-arrow-circle-o-right:before{content:"\f18e"}.fa-arrow-circle-o-left:before{content:"\f190"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:"\f191"}.fa-dot-circle-o:before{content:"\f192"}.fa-wheelchair:before{content:"\f193"}.fa-vimeo-square:before{content:"\f194"}.fa-turkish-lira:before,.fa-try:before{content:"\f195"}.fa-plus-square-o:before{content:"\f196"}.fa-space-shuttle:before{content:"\f197"}.fa-slack:before{content:"\f198"}.fa-envelope-square:before{content:"\f199"}.fa-wordpress:before{content:"\f19a"}.fa-openid:before{content:"\f19b"}.fa-institution:before,.fa-bank:before,.fa-university:before{content:"\f19c"}.fa-mortar-board:before,.fa-graduation-cap:before{content:"\f19d"}.fa-yahoo:before{content:"\f19e"}.fa-google:before{content:"\f1a0"}.fa-reddit:before{content:"\f1a1"}.fa-reddit-square:before{content:"\f1a2"}.fa-stumbleupon-circle:before{content:"\f1a3"}.fa-stumbleupon:before{content:"\f1a4"}.fa-delicious:before{content:"\f1a5"}.fa-digg:before{content:"\f1a6"}.fa-pied-piper:before{content:"\f1a7"}.fa-pied-piper-alt:before{content:"\f1a8"}.fa-drupal:before{content:"\f1a9"}.fa-joomla:before{content:"\f1aa"}.fa-language:before{content:"\f1ab"}.fa-fax:before{content:"\f1ac"}.fa-building:before{content:"\f1ad"}.fa-child:before{content:"\f1ae"}.fa-paw:before{content:"\f1b0"}.fa-spoon:before{content:"\f1b1"}.fa-cube:before{content:"\f1b2"}.fa-cubes:before{content:"\f1b3"}.fa-behance:before{content:"\f1b4"}.fa-behance-square:before{content:"\f1b5"}.fa-steam:before{content:"\f1b6"}.fa-steam-square:before{content:"\f1b7"}.fa-recycle:before{content:"\f1b8"}.fa-automobile:before,.fa-car:before{content:"\f1b9"}.fa-cab:before,.fa-taxi:before{content:"\f1ba"}.fa-tree:before{content:"\f1bb"}.fa-spotify:before{content:"\f1bc"}.fa-deviantart:before{content:"\f1bd"}.fa-soundcloud:before{content:"\f1be"}.fa-database:before{content:"\f1c0"}.fa-file-pdf-o:before{content:"\f1c1"}.fa-file-word-o:before{content:"\f1c2"}.fa-file-excel-o:before{content:"\f1c3"}.fa-file-powerpoint-o:before{content:"\f1c4"}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:"\f1c5"}.fa-file-zip-o:before,.fa-file-archive-o:before{content:"\f1c6"}.fa-file-sound-o:before,.fa-file-audio-o:before{content:"\f1c7"}.fa-file-movie-o:before,.fa-file-video-o:before{content:"\f1c8"}.fa-file-code-o:before{content:"\f1c9"}.fa-vine:before{content:"\f1ca"}.fa-codepen:before{content:"\f1cb"}.fa-jsfiddle:before{content:"\f1cc"}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:"\f1cd"}.fa-circle-o-notch:before{content:"\f1ce"}.fa-ra:before,.fa-rebel:before{content:"\f1d0"}.fa-ge:before,.fa-empire:before{content:"\f1d1"}.fa-git-square:before{content:"\f1d2"}.fa-git:before{content:"\f1d3"}.fa-hacker-news:before{content:"\f1d4"}.fa-tencent-weibo:before{content:"\f1d5"}.fa-qq:before{content:"\f1d6"}.fa-wechat:before,.fa-weixin:before{content:"\f1d7"}.fa-send:before,.fa-paper-plane:before{content:"\f1d8"}.fa-send-o:before,.fa-paper-plane-o:before{content:"\f1d9"}.fa-history:before{content:"\f1da"}.fa-genderless:before,.fa-circle-thin:before{content:"\f1db"}.fa-header:before{content:"\f1dc"}.fa-paragraph:before{content:"\f1dd"}.fa-sliders:before{content:"\f1de"}.fa-share-alt:before{content:"\f1e0"}.fa-share-alt-square:before{content:"\f1e1"}.fa-bomb:before{content:"\f1e2"}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:"\f1e3"}.fa-tty:before{content:"\f1e4"}.fa-binoculars:before{content:"\f1e5"}.fa-plug:before{content:"\f1e6"}.fa-slideshare:before{content:"\f1e7"}.fa-twitch:before{content:"\f1e8"}.fa-yelp:before{content:"\f1e9"}.fa-newspaper-o:before{content:"\f1ea"}.fa-wifi:before{content:"\f1eb"}.fa-calculator:before{content:"\f1ec"}.fa-paypal:before{content:"\f1ed"}.fa-google-wallet:before{content:"\f1ee"}.fa-cc-visa:before{content:"\f1f0"}.fa-cc-mastercard:before{content:"\f1f1"}.fa-cc-discover:before{content:"\f1f2"}.fa-cc-amex:before{content:"\f1f3"}.fa-cc-paypal:before{content:"\f1f4"}.fa-cc-stripe:before{content:"\f1f5"}.fa-bell-slash:before{content:"\f1f6"}.fa-bell-slash-o:before{content:"\f1f7"}.fa-trash:before{content:"\f1f8"}.fa-copyright:before{content:"\f1f9"}.fa-at:before{content:"\f1fa"}.fa-eyedropper:before{content:"\f1fb"}.fa-paint-brush:before{content:"\f1fc"}.fa-birthday-cake:before{content:"\f1fd"}.fa-area-chart:before{content:"\f1fe"}.fa-pie-chart:before{content:"\f200"}.fa-line-chart:before{content:"\f201"}.fa-lastfm:before{content:"\f202"}.fa-lastfm-square:before{content:"\f203"}.fa-toggle-off:before{content:"\f204"}.fa-toggle-on:before{content:"\f205"}.fa-bicycle:before{content:"\f206"}.fa-bus:before{content:"\f207"}.fa-ioxhost:before{content:"\f208"}.fa-angellist:before{content:"\f209"}.fa-cc:before{content:"\f20a"}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:"\f20b"}.fa-meanpath:before{content:"\f20c"}.fa-buysellads:before{content:"\f20d"}.fa-connectdevelop:before{content:"\f20e"}.fa-dashcube:before{content:"\f210"}.fa-forumbee:before{content:"\f211"}.fa-leanpub:before{content:"\f212"}.fa-sellsy:before{content:"\f213"}.fa-shirtsinbulk:before{content:"\f214"}.fa-simplybuilt:before{content:"\f215"}.fa-skyatlas:before{content:"\f216"}.fa-cart-plus:before{content:"\f217"}.fa-cart-arrow-down:before{content:"\f218"}.fa-diamond:before{content:"\f219"}.fa-ship:before{content:"\f21a"}.fa-user-secret:before{content:"\f21b"}.fa-motorcycle:before{content:"\f21c"}.fa-street-view:before{content:"\f21d"}.fa-heartbeat:before{content:"\f21e"}.fa-venus:before{content:"\f221"}.fa-mars:before{content:"\f222"}.fa-mercury:before{content:"\f223"}.fa-transgender:before{content:"\f224"}.fa-transgender-alt:before{content:"\f225"}.fa-venus-double:before{content:"\f226"}.fa-mars-double:before{content:"\f227"}.fa-venus-mars:before{content:"\f228"}.fa-mars-stroke:before{content:"\f229"}.fa-mars-stroke-v:before{content:"\f22a"}.fa-mars-stroke-h:before{content:"\f22b"}.fa-neuter:before{content:"\f22c"}.fa-facebook-official:before{content:"\f230"}.fa-pinterest-p:before{content:"\f231"}.fa-whatsapp:before{content:"\f232"}.fa-server:before{content:"\f233"}.fa-user-plus:before{content:"\f234"}.fa-user-times:before{content:"\f235"}.fa-hotel:before,.fa-bed:before{content:"\f236"}.fa-viacoin:before{content:"\f237"}.fa-train:before{content:"\f238"}.fa-subway:before{content:"\f239"}.fa-medium:before{content:"\f23a"}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}html,button,input,select,textarea{font-family:sans-serif}body,form,fieldset,legend,input,select,textarea,button{margin:0}html{font-size:100%}body{font-family:sans-serif;font-size:16px;font-size:1rem;line-height:21px;line-height:1.3125rem;color:#434343;background-color:#fff;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}b,strong{font-weight:700}i,em,.em{font-style:italic}a{color:#669fcf}a:hover{text-decoration:none}a:focus{outline:0}a:active,a:hover{outline:0}p{margin:0 0 1.6em 0}pre{margin:1em 0}ul+p,ul+pre,ol+p,ol+pre{margin-top:0}small{font-size:80%}abbr[title]{border-bottom:1px dotted}audio,canvas,video{display:inline-block;*zoom:1;*display:inline}audio:not([controls]){display:none;height:0}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}dfn{font-style:italic}img{border:0;-ms-interpolation-mode:bicubic}svg:not(:root){overflow:hidden}figure{margin:0}.image-left{margin-right:20px}.image-right{margin-left:20px}h1,h2,h3,h4,h5,h6{line-height:normal;font-weight:normal;margin:0 0 .33em 0}h1,.h1{font-size:40px;font-size:2.5rem}h2,.h2{font-size:32px;font-size:2rem}h3,.h3{font-size:26px;font-size:1.625rem}h4,.h4{font-size:20px;font-size:1.25rem}h5,.h5{font-size:18px;font-size:1.125rem}h6,.h6{font-size:16px;font-size:1rem}.no-style-heading{margin:0;font-size:100%}hr{border:0;background:0;outline:0;background-color:#ddd;margin:2em 0;*margin:1em 0;-moz-box-sizing:content-box;box-sizing:content-box;height:1px}blockquote{font-size:22px;font-size:1.375rem;line-height:32px;line-height:2rem;color:#434343;margin:1em 0;font-style:italic}blockquote p{margin:1em 0}cite{color:#434343;font-style:normal;font-weight:normal;font-size:16px;font-size:1rem;line-height:normal}q{font-style:italic;quotes:none}q:before,q:after{content:'';content:none}mark{background:#ff0;color:#111}code,kbd,pre,samp{word-wrap:break-word;font-family:'courier new',monospace,serif;font-size:13px;font-size:.8125rem;line-height:normal;font-weight:normal;background-color:#f1f1f1;padding:10px}code{color:#111}dl,menu,ol,ul{margin:1em 0}dd,ul ul,ol ol,ul ol,ol ul{margin:0}dt{font-weight:normal}dd{margin-bottom:1em}menu,ol,ul{padding:0 0 0 22px}nav ul,nav ol{list-style:none;list-style-image:none}.unstyled-list{list-style:none;padding:0;margin:0}.unstyled-list li{margin-top:0;margin-bottom:0}.inline-list{list-style:none;padding:0;margin:0;display:inline-block;*zoom:1;*display:inline}.inline-list li{margin-top:0;margin-bottom:0}.inline-list li{display:inline-block;*zoom:1;*display:inline}table{width:100%;margin:1em 0;table-layout:fixed;border-collapse:collapse;border-spacing:0;border-right:1px solid #f1f1f1;border-bottom:1px solid #f1f1f1;word-wrap:break-word;-ms-word-wrap:break-word;*white-space:normal}table th,table td{padding:8px;text-align:left;vertical-align:top;border-top:1px solid #eee;border-left:1px solid #eee}table thead th,table tfoot th{vertical-align:bottom;font-weight:normal;background-color:#f1f1f1;color:#333}table caption{padding:8px;font-style:normal;text-align:left;font-weight:normal;border-bottom:0}fieldset{border:0;padding:0}legend{border:0;padding:0;white-space:normal;*margin-left:-7px;font-weight:normal}label{margin:0;cursor:pointer}button,input,select,textarea{font-size:100%;vertical-align:baseline;*vertical-align:middle}input[type=text],input[type=password],input[type=email],input[type=search],input[type=tel],textarea{padding:5px;-webkit-appearance:none;-moz-appearance:none;font-weight:normal;line-height:normal;background-color:#fff;border:1px solid #ccc;color:#111}input[type=checkbox],input[type=radio]{cursor:pointer;box-sizing:border-box;line-height:normal;margin:0;padding:0;*height:13px;*width:13px}.checkbox{display:block;margin:.2em 0}.checkbox input[type=checkbox],.checkbox input[type=radio]{margin-top:.05em;float:left}.checkbox label{padding-left:5px;overflow:hidden;display:table;*zoom:1}button,input{line-height:normal}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer;*overflow:visible}button[disabled],html input[disabled]{cursor:default}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top;resize:none}.button{border:0;padding:1em 3em;background-color:#e74b3c;color:#fff;text-decoration:none;text-align:center;display:inline-block;*zoom:1;*display:inline;position:relative}.button:hover{background-color:#fc5547}.button:active{top:1px}.grey-button{background-color:#eee;color:#434343}.grey-button:hover{background-color:#f1f1f1}.button[disabled],.button.disabled{color:#999;background-color:#f1f1f1}.unstyled-button{font-size:16px;font-size:1rem;color:#27ae61;text-decoration:underline;border:0;background:transparent;height:auto;padding:0;cursor:pointer;outline:0}.unstyled-button:hover{text-decoration:none}.unstyled-button[disabled],.unstyled-button.disabled{text-decoration:none;color:#999;background-color:#ccc}.section{position:relative}.container{max-width:960px;margin-left:auto;margin-right:auto;padding-left:10px;padding-right:10px}.container-full{max-width:960px;margin-left:auto;margin-right:auto}.col{float:left;padding-left:10px;padding-right:10px}[class*="pull-"],[class*="push-"]{position:relative}.no-gutter{padding-left:0;padding-right:0}.col-1{width:8.33333%;width:calc(8.333333333333334%);width:-webkit-calc(8.333333333333334%);width:-moz-calc(8.333333333333334%)}.col-2{width:16.66667%;width:calc(16.666666666666668%);width:-webkit-calc(16.666666666666668%);width:-moz-calc(16.666666666666668%)}.col-3{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.col-4{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.col-5{width:41.66665%;width:calc(41.66666666666667%);width:-webkit-calc(41.66666666666667%);width:-moz-calc(41.66666666666667%)}.col-6{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.col-7{width:58.33333%;width:calc(58.333333333333336%);width:-webkit-calc(58.333333333333336%);width:-moz-calc(58.333333333333336%)}.col-8{width:66.66666%;width:calc(66.66666666666667%);width:-webkit-calc(66.66666666666667%);width:-moz-calc(66.66666666666667%)}.col-9{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.col-10{width:83.33333%;width:calc(83.33333333333334%);width:-webkit-calc(83.33333333333334%);width:-moz-calc(83.33333333333334%)}.col-11{width:91.66666%;width:calc(91.66666666666667%);width:-webkit-calc(91.66666666666667%);width:-moz-calc(91.66666666666667%)}.col-12{width:100%}.col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.push-1{left:8.33333%;left:calc(8.333333333333334%);left:-webkit-calc(8.333333333333334%);left:-moz-calc(8.333333333333334%)}.pull-1{left:-8.33333%;left:calc(-8.333333333333334%);left:-webkit-calc(-8.333333333333334%);left:-moz-calc(-8.333333333333334%)}.push-2{left:16.66667%;left:calc(16.666666666666668%);left:-webkit-calc(16.666666666666668%);left:-moz-calc(16.666666666666668%)}.pull-2{left:-16.66667%;left:calc(-16.666666666666668%);left:-webkit-calc(-16.666666666666668%);left:-moz-calc(-16.666666666666668%)}.push-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.pull-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.push-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.pull-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.push-5{left:41.66665%;left:calc(41.66666666666667%);left:-webkit-calc(41.66666666666667%);left:-moz-calc(41.66666666666667%)}.pull-5{left:-41.66665%;left:calc(-41.66666666666667%);left:-webkit-calc(-41.66666666666667%);left:-moz-calc(-41.66666666666667%)}.push-6{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.pull-6{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.push-7{left:58.33333%;left:calc(58.333333333333336%);left:-webkit-calc(58.333333333333336%);left:-moz-calc(58.333333333333336%)}.pull-7{left:-58.33333%;left:calc(-58.333333333333336%);left:-webkit-calc(-58.333333333333336%);left:-moz-calc(-58.333333333333336%)}.push-8{left:66.66666%;left:calc(66.66666666666667%);left:-webkit-calc(66.66666666666667%);left:-moz-calc(66.66666666666667%)}.pull-8{left:-66.66666%;left:calc(-66.66666666666667%);left:-webkit-calc(-66.66666666666667%);left:-moz-calc(-66.66666666666667%)}.push-9{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.pull-9{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.push-10{left:83.33333%;left:calc(83.33333333333334%);left:-webkit-calc(83.33333333333334%);left:-moz-calc(83.33333333333334%)}.pull-10{left:-83.33333%;left:calc(-83.33333333333334%);left:-webkit-calc(-83.33333333333334%);left:-moz-calc(-83.33333333333334%)}.push-11{left:91.66666%;left:calc(91.66666666666667%);left:-webkit-calc(91.66666666666667%);left:-moz-calc(91.66666666666667%)}.pull-11{left:-91.66666%;left:calc(-91.66666666666667%);left:-webkit-calc(-91.66666666666667%);left:-moz-calc(-91.66666666666667%)}.row{padding-top:1em;padding-bottom:1em}.clear:before,.clear:after{content:"";display:table}.clear:after{clear:both}.clear{zoom:1}.left{float:left}.right{float:right}.block{display:block}.inline{display:inline}.inline-block{display:inline-block;*zoom:1;*display:inline}.none,.hidden,[hidden],.no-desktop{display:none}.heavy{font-weight:900}.strong{font-weight:700}.normal{font-weight:normal}.thin{font-weight:300}.fine{font-weight:100}.italic{font-style:italic}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.left-text{text-align:left}.right-text{text-align:right}.center-text{text-align:center}.justify-text{text-align:justify}.visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;overflow:hidden;padding:0;position:absolute;width:1px;left:-9999em}.visuallyvisible{clip:auto;width:auto;height:auto;overflow:visible;left:0}.no-margin{margin:0}.no-padding{padding:0}@media only screen and (min-width:740px) and (max-width:960px){.container,.tablet-container{max-width:960px;padding-left:20px;padding-right:20px;margin-left:auto;margin-right:auto;float:none}.container:first-child,.tablet-container:first-child{margin-left:auto}.tablet-container-full{padding-left:0;padding-right:0;margin-left:auto;margin-right:auto;float:none}.tablet-container-full:first-child{margin-left:auto}.tablet-no-gutter{padding-left:0;padding-right:0}.tablet-col-1{width:8.33333%;width:calc(8.333333333333334%);width:-webkit-calc(8.333333333333334%);width:-moz-calc(8.333333333333334%)}.tablet-col-2{width:16.66667%;width:calc(16.666666666666668%);width:-webkit-calc(16.666666666666668%);width:-moz-calc(16.666666666666668%)}.tablet-col-3{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.tablet-col-4{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.tablet-col-5{width:41.66665%;width:calc(41.66666666666667%);width:-webkit-calc(41.66666666666667%);width:-moz-calc(41.66666666666667%)}.tablet-col-6{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.tablet-col-7{width:58.33333%;width:calc(58.333333333333336%);width:-webkit-calc(58.333333333333336%);width:-moz-calc(58.333333333333336%)}.tablet-col-8{width:66.66666%;width:calc(66.66666666666667%);width:-webkit-calc(66.66666666666667%);width:-moz-calc(66.66666666666667%)}.tablet-col-9{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.tablet-col-10{width:83.33333%;width:calc(83.33333333333334%);width:-webkit-calc(83.33333333333334%);width:-moz-calc(83.33333333333334%)}.tablet-col-11{width:91.66666%;width:calc(91.66666666666667%);width:-webkit-calc(91.66666666666667%);width:-moz-calc(91.66666666666667%)}.tablet-col-12{width:100%}.tablet-col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.tablet-col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.tablet-col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.tablet-col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.tablet-push-1{left:8.33333%;left:calc(8.333333333333334%);left:-webkit-calc(8.333333333333334%);left:-moz-calc(8.333333333333334%)}.tablet-pull-1{left:-8.33333%;left:calc(-8.333333333333334%);left:-webkit-calc(-8.333333333333334%);left:-moz-calc(-8.333333333333334%)}.tablet-push-2{left:16.66667%;left:calc(16.666666666666668%);left:-webkit-calc(16.666666666666668%);left:-moz-calc(16.666666666666668%)}.tablet-pull-2{left:-16.66667%;left:calc(-16.666666666666668%);left:-webkit-calc(-16.666666666666668%);left:-moz-calc(-16.666666666666668%)}.tablet-push-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.tablet-pull-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.tablet-push-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.tablet-pull-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.tablet-push-5{left:41.66665%;left:calc(41.66666666666667%);left:-webkit-calc(41.66666666666667%);left:-moz-calc(41.66666666666667%)}.tablet-pull-5{left:-41.66665%;left:calc(-41.66666666666667%);left:-webkit-calc(-41.66666666666667%);left:-moz-calc(-41.66666666666667%)}.tablet-push-6{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.tablet-pull-6{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.tablet-push-7{left:58.33333%;left:calc(58.333333333333336%);left:-webkit-calc(58.333333333333336%);left:-moz-calc(58.333333333333336%)}.tablet-pull-7{left:-58.33333%;left:calc(-58.333333333333336%);left:-webkit-calc(-58.333333333333336%);left:-moz-calc(-58.333333333333336%)}.tablet-push-8{left:66.66666%;left:calc(66.66666666666667%);left:-webkit-calc(66.66666666666667%);left:-moz-calc(66.66666666666667%)}.tablet-pull-8{left:-66.66666%;left:calc(-66.66666666666667%);left:-webkit-calc(-66.66666666666667%);left:-moz-calc(-66.66666666666667%)}.tablet-push-9{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.tablet-pull-9{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.tablet-push-10{left:83.33333%;left:calc(83.33333333333334%);left:-webkit-calc(83.33333333333334%);left:-moz-calc(83.33333333333334%)}.tablet-pull-10{left:-83.33333%;left:calc(-83.33333333333334%);left:-webkit-calc(-83.33333333333334%);left:-moz-calc(-83.33333333333334%)}.tablet-push-11{left:91.66666%;left:calc(91.66666666666667%);left:-webkit-calc(91.66666666666667%);left:-moz-calc(91.66666666666667%)}.tablet-pull-11{left:-91.66666%;left:calc(-91.66666666666667%);left:-webkit-calc(-91.66666666666667%);left:-moz-calc(-91.66666666666667%)}.tablet-no-push,.tablet-no-pull{left:auto}.tablet-row{padding-top:1em;padding-bottom:1em}.tablet-full{left:auto;clear:both;float:none;width:100%;margin:1em 0 0 0;display:block}.tablet-full:first-child{margin-top:0}.tablet-left-text{text-align:left}.tablet-right-text{text-align:right}.tablet-center-text{text-align:center}.tablet-left{float:left}.tablet-right{float:right}.tablet-no-float{float:none}.tablet-no-margin{margin:0}.tablet-no-padding{padding:0}.no-tablet{display:none}.show-tablet{display:block}}@media only screen and (max-width:739px){.container,.mobile-container{padding-left:20px;padding-right:20px;margin-left:auto;margin-right:auto;float:none}.container:first-child,.mobile-container:first-child{margin-left:auto}.mobile-container-full{padding-left:0;padding-right:0;margin-left:auto;margin-right:auto;float:none}.mobile-container-full:first-child{margin-left:auto}.mobile-no-gutter{padding-left:0;padding-right:0}.mobile-col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.mobile-col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.mobile-col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.mobile-col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.mobile-push-1-2{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.mobile-pull-1-2{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.mobile-push-1-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.mobile-pull-1-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.mobile-push-1-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.mobile-pull-1-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.mobile-push-3-4{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.mobile-pull-3-4{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.mobile-no-push,.mobile-no-pull{left:auto}.mobile-row{padding-top:1em;padding-bottom:1em}.mobile-full{left:auto;clear:both;float:none;width:100%;margin:.2em 0 0 0;display:block}.mobile-full:first-child{margin-top:0}.mobile-left-text{text-align:left}.mobile-right-text{text-align:right}.mobile-center-text{text-align:center}.mobile-left{float:left}.mobile-right{float:right}.mobile-no-float{float:none}.mobile-no-margin{margin:0}.mobile-no-padding{padding:0}table th,table td{padding:4px}.no-mobile{display:none}.show-mobile{display:block}}@media print{*{background:transparent}a,a:visited{text-decoration:underline}abbr[title]:after{content:" (" attr(title) ")"}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100%}@page{margin:.5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}}html,body{height:100%}.absolute{position:absolute}.relative{position:relative}.full{width:100%}.no-scroll{overflow:hidden}.table{display:table;margin:0 auto}.xlarge-top{margin-top:60px}.large-top{margin-top:40px}.medium-top{margin-top:20px}.small-top{margin-top:10px}.mini-top{margin-top:5px}.no-left-padding{padding-left:0}.no-right-padding{padding-right:0}@media only screen and (max-width:739px){.mobile-hide{display:none}.mobile-xlarge-top{margin-top:60px}.mobile-large-top{margin-top:40px}.mobile-medium-top{margin-top:20px}.mobile-small-top{margin-top:10px}.mobile-mini-top{margin-top:5px}}html,body{font-family:'Roboto','Helvetica Neue','Arial','Helvetica','Lucida Grande',sans-serif;font-weight:300;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}h1,h2,h3,h4,h5{font-weight:300}p{margin:0 0 1em 0}pre,code{padding:5px 10px;color:#6e6e6e;font-size:14px;line-height:20px;font-weight:100;background:#f8f8f8;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}a{color:#333;text-decoration:none;-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out}a.active{color:#000}a:hover{color:#000}a:hover .fa-trash-o{color:#e2717f}a.primary{color:#e2717f}a.primary:hover{color:#d94759}img{max-width:100%}hr{margin:.5em 0;width:100%}i.right-padding{padding-right:10px}i.left-padding{padding-left:10px}.button{outline:0;padding:1em 1.5em;background:#fafafa;color:#333;white-space:nowrap;background-clip:padding-box;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.button.disabled,.button[disabled]{-moz-opacity:.7;-khtml-opacity:.7;-webkit-opacity:.7;opacity:.7;-ms-filter:alpha(opacity=70);filter:alpha(opacity=70);cursor:default}.button:hover:not(.disabled),.button:hover:not([disabled]){background:#d9d9d9}.button.large{padding:1em 4em}.button.small{padding:.6em .8em}.button.x-small{padding:.4em .6em}.button.primary-button{color:#fff;background:#e2717f}.button.primary-button:hover,.button.primary-button:focus{color:#f2f2f2;background:#de5c6c}.button.primary-button:hover.disabled,.button.primary-button:focus.disabled,.button.primary-button:hover:disabled,.button.primary-button:focus:disabled{background:#e2717f}.button.secondary-button{background:0;border:1px solid #eee}.button.secondary-button:hover:not(.active),.button.secondary-button:hover:not(.disabled),.button.secondary-button:hover:not(:disabled),.button.secondary-button:focus:not(.active),.button.secondary-button:focus:not(.disabled),.button.secondary-button:focus:not(:disabled){color:#666;background:#f8f8f8}.button.secondary-button.active{color:#595959;background:#ebebeb;border:1px solid #eee}.button.secondary-button.active:hover{color:#595959;background:#ebebeb;border:1px solid #eee}.button.remove-button{background:#e2717f;color:#fff;padding:.9em 1.5em}.button.remove-button:hover,.button.remove-button:focus{background:#de5c6c}.button.remove-button:hover.disabled,.button.remove-button:focus.disabled,.button.remove-button:hover:disabled,.button.remove-button:focus:disabled{background:#e2717f}.button.transparent-button{background:0;color:#fff;border:1px solid #f2f2f2}.button.transparent-button:hover:not(.disabled),.button.transparent-button:hover:not(:disabled){background:rgba(255,255,255,0.1);color:#fff}.button-group>.button{padding:.8em 1em;text-align:center;background:#fff;border-top:1px solid #eee;border-bottom:1px solid #eee;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.button-group>.button i.fa{margin-right:5px}.button-group>.button:first-child{border-left:1px solid #eee;-webkit-border-top-right-radius:0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:5px;-webkit-border-top-left-radius:5px;-moz-border-radius-topright:0;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:5px;-moz-border-radius-topleft:5px;border-top-right-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:5px;border-top-left-radius:5px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.button-group>.button:last-child{border-right:1px solid #eee;-webkit-border-top-right-radius:5px;-webkit-border-bottom-right-radius:5px;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:0;-moz-border-radius-topright:5px;-moz-border-radius-bottomright:5px;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:0;border-top-right-radius:5px;border-bottom-right-radius:5px;border-bottom-left-radius:0;border-top-left-radius:0;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.button-group>.button:hover:not(.active),.button-group>.button:focus:not(.active){color:#666;background:#f8f8f8}.button-group>.button.active{color:#595959;background:#ebebeb;border:1px solid #eee}.button-group>.button.active:hover{color:#595959;background:#ebebeb;border:1px solid #eee}.button-group.small>.button{padding:.6em .8em}.button-group.x-small>.button{padding:.4em .6em}form .col,form .input-wrapper{position:relative}form input,form input[type="text"],form input[type="password"],form input[type="email"],form input[type="search"],form input[type="tel"],form input[type="number"],form input[type="date"],form textarea{width:100%;padding:.8em .6em .6em;outline:0;border:1px solid #d3d3d3;font-size:1.1em;line-height:1;background:#fff;color:#666;-webkit-appearance:none;-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out}form input:focus,form input[type="text"]:focus,form input[type="password"]:focus,form input[type="email"]:focus,form input[type="search"]:focus,form input[type="tel"]:focus,form input[type="number"]:focus,form input[type="date"]:focus,form textarea:focus{color:#333;border:1px solid #a0a0a0;-moz-box-shadow:0 0 2px #a0a0a0;-webkit-box-shadow:0 0 2px #a0a0a0;box-shadow:0 0 2px #a0a0a0;-webkit-box-shadow:0 0 2px #a0a0a0 0 0 #000;box-shadow:0 0 2px #a0a0a0 0 0 #000}form input:focus+label,form input[type="text"]:focus+label,form input[type="password"]:focus+label,form input[type="email"]:focus+label,form input[type="search"]:focus+label,form input[type="tel"]:focus+label,form input[type="number"]:focus+label,form input[type="date"]:focus+label,form textarea:focus+label{color:#666;font-weight:400}form input.success,form input[type="text"].success,form input[type="password"].success,form input[type="email"].success,form input[type="search"].success,form input[type="tel"].success,form input[type="number"].success,form input[type="date"].success,form textarea.success{border:1px solid #43cea2;-moz-box-shadow:0 0 2px #43cea2;-webkit-box-shadow:0 0 2px #43cea2;box-shadow:0 0 2px #43cea2;-webkit-box-shadow:0 0 2px #43cea2 0 0 #000;box-shadow:0 0 2px #43cea2 0 0 #000}form input.success+label,form input[type="text"].success+label,form input[type="password"].success+label,form input[type="email"].success+label,form input[type="search"].success+label,form input[type="tel"].success+label,form input[type="number"].success+label,form input[type="date"].success+label,form textarea.success+label{color:#43cea2;font-weight:400}form input.error,form input[type="text"].error,form input[type="password"].error,form input[type="email"].error,form input[type="search"].error,form input[type="tel"].error,form input[type="number"].error,form input[type="date"].error,form textarea.error{border:1px solid #e2717f;-moz-box-shadow:0 0 2px #e2717f;-webkit-box-shadow:0 0 2px #e2717f;box-shadow:0 0 2px #e2717f;-webkit-box-shadow:0 0 2px #e2717f 0 0 #000;box-shadow:0 0 2px #e2717f 0 0 #000}form input.error+label,form input[type="text"].error+label,form input[type="password"].error+label,form input[type="email"].error+label,form input[type="search"].error+label,form input[type="tel"].error+label,form input[type="number"].error+label,form input[type="date"].error+label,form textarea.error+label{color:#e2717f;font-weight:400}form input::-webkit-input-placeholder,form input[type="text"]::-webkit-input-placeholder,form input[type="password"]::-webkit-input-placeholder,form input[type="email"]::-webkit-input-placeholder,form input[type="search"]::-webkit-input-placeholder,form input[type="tel"]::-webkit-input-placeholder,form input[type="number"]::-webkit-input-placeholder,form input[type="date"]::-webkit-input-placeholder,form textarea::-webkit-input-placeholder{color:#d3d3d3;font-weight:300}form [placeholder]:focus::-webkit-input-placeholder{-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out;opacity:0}form input[type="number"]::-webkit-inner-spin-button,form input[type="number"]::-webkit-outer-spin-button,form input[type="date"]::-webkit-inner-spin-button,form input[type="date"]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}form .select-style{position:relative;display:block;width:100%;border:1px solid #a0a0a0;background:#fff}form .select-style .fa-caret-down{position:absolute;right:.6em;top:.8em;color:#a0a0a0;font-size:1.4em}form .select-style select{padding:.8em 0;margin-left:.6em;width:100%;border:0;box-shadow:none;background:transparent;background-image:none;-webkit-appearance:none;color:#a0a0a0;font-size:1.2em}form .select-style select:hover{cursor:pointer}form .select-style select:focus{outline:0}form fieldset.row{padding:.5em 0}form label{position:absolute;left:5px;top:-5px;padding:0 5px;background:white;color:#a0a0a0;font-size:12px;line-height:12px;text-transform:uppercase;pointer-events:none;z-index:2}.modal-wrapper{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.3);display:none;z-index:1001;will-change:transform}.modal-wrapper .modal{position:relative;color:#333;display:none}.modal-wrapper .modal a.close{position:absolute;padding:6px 12px 9px;border:1px solid;border-radius:20px;font-weight:300;font-size:27px}.modal-wrapper .modal section.modal-content{padding:20px}.modal-wrapper:not(.fullscreen) .modal{min-height:300px;max-width:434px;margin:60px auto 0;background-color:#fff;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.modal-wrapper:not(.fullscreen) .modal a.close{right:-45px;top:-30px;color:#fff}.modal-wrapper.fullscreen{background:#fff}.modal-wrapper.fullscreen .modal{height:100%;overflow:auto}.modal-wrapper.fullscreen .modal a.close{right:20px;top:20px}.notice{position:fixed;bottom:0;right:10px;height:100px;width:300px;padding:5px 10px 5px 10px;display:none;color:#fff;z-index:1005;-webkit-border-top-right-radius:5px;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:5px;-moz-border-radius-topright:5px;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:5px;border-top-right-radius:5px;border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-left-radius:5px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.notice.success{background-color:#43cea2}.notice.warning{background-color:#f4ed6b}.notice.error{background-color:#e2717f}.notice header.notice-header{position:relative;margin-bottom:.2em}.notice section.notice-content{height:70px;width:100%;overflow:auto;font-size:.8em}.notice a.close{position:absolute;top:3px;right:0;padding:0 4px 2px;border:1px solid;border-radius:100%;font-weight:300;font-size:12px;line-height:12px;color:#fff}.notice a.close:hover{color:#ccc}nav{font-size:18px;font-size:1.125rem}nav .navbar{margin:0 auto;display:table;padding:10px 0}nav li{margin:0 10px}nav a{display:inline-block;line-height:60px;vertical-align:middle}nav a.logo{height:60px;width:60px}@media(max-width:739px){nav{font-size:14px;font-size:.875rem}nav a{line-height:40px}nav a.logo{height:40px;width:40px}}#toc{position:fixed;top:80px;height:100%;width:220px;overflow:auto;padding-bottom:100px}#toc a{color:#333}#toc a:hover{color:#1a1a1a}#toc li>ul{display:none}#toc li>ul.unstyled-list{margin-left:10px}#toc li.active>a{font-weight:bold}#toc li.active>ul{display:block}#toc ul.nav>li.active>ul>li{list-style:none}footer{padding:60px 0;color:#d3d3d3;background:#333}footer i.fa-heart{color:#e2717f}footer i.fa-beer{color:#f4ed6b}html,body{background:#fff;color:#333}.kd{color:#a783b6}.k{color:#43cea2}h1.logo{font-size:64px;font-size:4rem}.gist pre,.gist .file-data{font-size:14px!important}section{padding:40px 0}#hero .badges,#hero .github-links{padding:.3em 0}#hero .badges p,#hero .github-links p{margin:0}#ship h3{margin-bottom:1em}#ship img.ship-it{display:table;height:300px;width:300px;margin:0 auto;background:#d3d3d3;-webkit-border-radius:100%;-moz-border-radius:100%;border-radius:100%}#plugins{color:#fff;background:#333}#plugins p{color:#d3d3d3}#plugins ul li{padding:10px 20px}#plugins ul li a{display:inline-block}#plugins ul li a img{height:100px;max-width:160px}@media(max-width:739px){#plugins ul li a img{height:60px;max-width:120px}}#features{color:#fff;background:#e2717f}#features h4{color:#982e3e}#features a.primary{color:#f8f8f8;border-bottom:1px dashed #f8f8f8}#features a.primary:hover{color:#dfdfdf;border-bottom:1px dashed #dfdfdf}#features p{text-align:justify}#comparison img{margin:0 auto}.page a,.example a{color:#e2717f}.page a:hover,.example a:hover{color:#d94759}.page .file-data .line-numbers,.example .file-data .line-numbers{width:40px}#todo-example input[type="text"]{margin:10px 0}#todo-example ul.todos{height:320px}#todo-example ul.todos li{padding:5px 0}#todo-example ul.todos li input[type="checkbox"]{margin-top:.2em}#todo-example ul.todos li span{margin-left:5px}#todo-example ul.todos li.done label{text-decoration:line-through;color:#998}#todo-example ul.todos li .delete{font-weight:bold}#todo-example label{float:left}#todo-example .primary-button{width:100%} \ No newline at end of file + */@font-face{font-family:'FontAwesome';src:url('/fonts/fontawesome-webfont.eot?v=4.3.0');src:url('/fonts/fontawesome-webfont.eot?#iefix&v=4.3.0') format('embedded-opentype'),url('/fonts/fontawesome-webfont.woff2?v=4.3.0') format('woff2'),url('/fonts/fontawesome-webfont.woff?v=4.3.0') format('woff'),url('/fonts/fontawesome-webfont.ttf?v=4.3.0') format('truetype'),url('/fonts/fontawesome-webfont.svg?v=4.3.0#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;transform:translate(0,0)}.fa-lg{font-size:1.3333333333333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.2857142857142858em;text-align:center}.fa-ul{padding-left:0;margin-left:2.142857142857143em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.142857142857143em;width:2.142857142857143em;top:.14285714285714285em;text-align:center}.fa-li.fa-lg{left:-1.8571428571428572em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2);-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=0,mirror=1);-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.fa-flip-vertical{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2,mirror=1);-webkit-transform:scale(1,-1);-ms-transform:scale(1,-1);transform:scale(1,-1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-remove:before,.fa-close:before,.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook-f:before,.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{content:"\f09c"}.fa-credit-card:before{content:"\f09d"}.fa-rss:before{content:"\f09e"}.fa-hdd-o:before{content:"\f0a0"}.fa-bullhorn:before{content:"\f0a1"}.fa-bell:before{content:"\f0f3"}.fa-certificate:before{content:"\f0a3"}.fa-hand-o-right:before{content:"\f0a4"}.fa-hand-o-left:before{content:"\f0a5"}.fa-hand-o-up:before{content:"\f0a6"}.fa-hand-o-down:before{content:"\f0a7"}.fa-arrow-circle-left:before{content:"\f0a8"}.fa-arrow-circle-right:before{content:"\f0a9"}.fa-arrow-circle-up:before{content:"\f0aa"}.fa-arrow-circle-down:before{content:"\f0ab"}.fa-globe:before{content:"\f0ac"}.fa-wrench:before{content:"\f0ad"}.fa-tasks:before{content:"\f0ae"}.fa-filter:before{content:"\f0b0"}.fa-briefcase:before{content:"\f0b1"}.fa-arrows-alt:before{content:"\f0b2"}.fa-group:before,.fa-users:before{content:"\f0c0"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-cloud:before{content:"\f0c2"}.fa-flask:before{content:"\f0c3"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-copy:before,.fa-files-o:before{content:"\f0c5"}.fa-paperclip:before{content:"\f0c6"}.fa-save:before,.fa-floppy-o:before{content:"\f0c7"}.fa-square:before{content:"\f0c8"}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:"\f0c9"}.fa-list-ul:before{content:"\f0ca"}.fa-list-ol:before{content:"\f0cb"}.fa-strikethrough:before{content:"\f0cc"}.fa-underline:before{content:"\f0cd"}.fa-table:before{content:"\f0ce"}.fa-magic:before{content:"\f0d0"}.fa-truck:before{content:"\f0d1"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-google-plus-square:before{content:"\f0d4"}.fa-google-plus:before{content:"\f0d5"}.fa-money:before{content:"\f0d6"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-columns:before{content:"\f0db"}.fa-unsorted:before,.fa-sort:before{content:"\f0dc"}.fa-sort-down:before,.fa-sort-desc:before{content:"\f0dd"}.fa-sort-up:before,.fa-sort-asc:before{content:"\f0de"}.fa-envelope:before{content:"\f0e0"}.fa-linkedin:before{content:"\f0e1"}.fa-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-legal:before,.fa-gavel:before{content:"\f0e3"}.fa-dashboard:before,.fa-tachometer:before{content:"\f0e4"}.fa-comment-o:before{content:"\f0e5"}.fa-comments-o:before{content:"\f0e6"}.fa-flash:before,.fa-bolt:before{content:"\f0e7"}.fa-sitemap:before{content:"\f0e8"}.fa-umbrella:before{content:"\f0e9"}.fa-paste:before,.fa-clipboard:before{content:"\f0ea"}.fa-lightbulb-o:before{content:"\f0eb"}.fa-exchange:before{content:"\f0ec"}.fa-cloud-download:before{content:"\f0ed"}.fa-cloud-upload:before{content:"\f0ee"}.fa-user-md:before{content:"\f0f0"}.fa-stethoscope:before{content:"\f0f1"}.fa-suitcase:before{content:"\f0f2"}.fa-bell-o:before{content:"\f0a2"}.fa-coffee:before{content:"\f0f4"}.fa-cutlery:before{content:"\f0f5"}.fa-file-text-o:before{content:"\f0f6"}.fa-building-o:before{content:"\f0f7"}.fa-hospital-o:before{content:"\f0f8"}.fa-ambulance:before{content:"\f0f9"}.fa-medkit:before{content:"\f0fa"}.fa-fighter-jet:before{content:"\f0fb"}.fa-beer:before{content:"\f0fc"}.fa-h-square:before{content:"\f0fd"}.fa-plus-square:before{content:"\f0fe"}.fa-angle-double-left:before{content:"\f100"}.fa-angle-double-right:before{content:"\f101"}.fa-angle-double-up:before{content:"\f102"}.fa-angle-double-down:before{content:"\f103"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}.fa-angle-up:before{content:"\f106"}.fa-angle-down:before{content:"\f107"}.fa-desktop:before{content:"\f108"}.fa-laptop:before{content:"\f109"}.fa-tablet:before{content:"\f10a"}.fa-mobile-phone:before,.fa-mobile:before{content:"\f10b"}.fa-circle-o:before{content:"\f10c"}.fa-quote-left:before{content:"\f10d"}.fa-quote-right:before{content:"\f10e"}.fa-spinner:before{content:"\f110"}.fa-circle:before{content:"\f111"}.fa-mail-reply:before,.fa-reply:before{content:"\f112"}.fa-github-alt:before{content:"\f113"}.fa-folder-o:before{content:"\f114"}.fa-folder-open-o:before{content:"\f115"}.fa-smile-o:before{content:"\f118"}.fa-frown-o:before{content:"\f119"}.fa-meh-o:before{content:"\f11a"}.fa-gamepad:before{content:"\f11b"}.fa-keyboard-o:before{content:"\f11c"}.fa-flag-o:before{content:"\f11d"}.fa-flag-checkered:before{content:"\f11e"}.fa-terminal:before{content:"\f120"}.fa-code:before{content:"\f121"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"\f122"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"\f123"}.fa-location-arrow:before{content:"\f124"}.fa-crop:before{content:"\f125"}.fa-code-fork:before{content:"\f126"}.fa-unlink:before,.fa-chain-broken:before{content:"\f127"}.fa-question:before{content:"\f128"}.fa-info:before{content:"\f129"}.fa-exclamation:before{content:"\f12a"}.fa-superscript:before{content:"\f12b"}.fa-subscript:before{content:"\f12c"}.fa-eraser:before{content:"\f12d"}.fa-puzzle-piece:before{content:"\f12e"}.fa-microphone:before{content:"\f130"}.fa-microphone-slash:before{content:"\f131"}.fa-shield:before{content:"\f132"}.fa-calendar-o:before{content:"\f133"}.fa-fire-extinguisher:before{content:"\f134"}.fa-rocket:before{content:"\f135"}.fa-maxcdn:before{content:"\f136"}.fa-chevron-circle-left:before{content:"\f137"}.fa-chevron-circle-right:before{content:"\f138"}.fa-chevron-circle-up:before{content:"\f139"}.fa-chevron-circle-down:before{content:"\f13a"}.fa-html5:before{content:"\f13b"}.fa-css3:before{content:"\f13c"}.fa-anchor:before{content:"\f13d"}.fa-unlock-alt:before{content:"\f13e"}.fa-bullseye:before{content:"\f140"}.fa-ellipsis-h:before{content:"\f141"}.fa-ellipsis-v:before{content:"\f142"}.fa-rss-square:before{content:"\f143"}.fa-play-circle:before{content:"\f144"}.fa-ticket:before{content:"\f145"}.fa-minus-square:before{content:"\f146"}.fa-minus-square-o:before{content:"\f147"}.fa-level-up:before{content:"\f148"}.fa-level-down:before{content:"\f149"}.fa-check-square:before{content:"\f14a"}.fa-pencil-square:before{content:"\f14b"}.fa-external-link-square:before{content:"\f14c"}.fa-share-square:before{content:"\f14d"}.fa-compass:before{content:"\f14e"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"\f150"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"\f151"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"\f152"}.fa-euro:before,.fa-eur:before{content:"\f153"}.fa-gbp:before{content:"\f154"}.fa-dollar:before,.fa-usd:before{content:"\f155"}.fa-rupee:before,.fa-inr:before{content:"\f156"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"\f157"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"\f158"}.fa-won:before,.fa-krw:before{content:"\f159"}.fa-bitcoin:before,.fa-btc:before{content:"\f15a"}.fa-file:before{content:"\f15b"}.fa-file-text:before{content:"\f15c"}.fa-sort-alpha-asc:before{content:"\f15d"}.fa-sort-alpha-desc:before{content:"\f15e"}.fa-sort-amount-asc:before{content:"\f160"}.fa-sort-amount-desc:before{content:"\f161"}.fa-sort-numeric-asc:before{content:"\f162"}.fa-sort-numeric-desc:before{content:"\f163"}.fa-thumbs-up:before{content:"\f164"}.fa-thumbs-down:before{content:"\f165"}.fa-youtube-square:before{content:"\f166"}.fa-youtube:before{content:"\f167"}.fa-xing:before{content:"\f168"}.fa-xing-square:before{content:"\f169"}.fa-youtube-play:before{content:"\f16a"}.fa-dropbox:before{content:"\f16b"}.fa-stack-overflow:before{content:"\f16c"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-adn:before{content:"\f170"}.fa-bitbucket:before{content:"\f171"}.fa-bitbucket-square:before{content:"\f172"}.fa-tumblr:before{content:"\f173"}.fa-tumblr-square:before{content:"\f174"}.fa-long-arrow-down:before{content:"\f175"}.fa-long-arrow-up:before{content:"\f176"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-apple:before{content:"\f179"}.fa-windows:before{content:"\f17a"}.fa-android:before{content:"\f17b"}.fa-linux:before{content:"\f17c"}.fa-dribbble:before{content:"\f17d"}.fa-skype:before{content:"\f17e"}.fa-foursquare:before{content:"\f180"}.fa-trello:before{content:"\f181"}.fa-female:before{content:"\f182"}.fa-male:before{content:"\f183"}.fa-gittip:before,.fa-gratipay:before{content:"\f184"}.fa-sun-o:before{content:"\f185"}.fa-moon-o:before{content:"\f186"}.fa-archive:before{content:"\f187"}.fa-bug:before{content:"\f188"}.fa-vk:before{content:"\f189"}.fa-weibo:before{content:"\f18a"}.fa-renren:before{content:"\f18b"}.fa-pagelines:before{content:"\f18c"}.fa-stack-exchange:before{content:"\f18d"}.fa-arrow-circle-o-right:before{content:"\f18e"}.fa-arrow-circle-o-left:before{content:"\f190"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:"\f191"}.fa-dot-circle-o:before{content:"\f192"}.fa-wheelchair:before{content:"\f193"}.fa-vimeo-square:before{content:"\f194"}.fa-turkish-lira:before,.fa-try:before{content:"\f195"}.fa-plus-square-o:before{content:"\f196"}.fa-space-shuttle:before{content:"\f197"}.fa-slack:before{content:"\f198"}.fa-envelope-square:before{content:"\f199"}.fa-wordpress:before{content:"\f19a"}.fa-openid:before{content:"\f19b"}.fa-institution:before,.fa-bank:before,.fa-university:before{content:"\f19c"}.fa-mortar-board:before,.fa-graduation-cap:before{content:"\f19d"}.fa-yahoo:before{content:"\f19e"}.fa-google:before{content:"\f1a0"}.fa-reddit:before{content:"\f1a1"}.fa-reddit-square:before{content:"\f1a2"}.fa-stumbleupon-circle:before{content:"\f1a3"}.fa-stumbleupon:before{content:"\f1a4"}.fa-delicious:before{content:"\f1a5"}.fa-digg:before{content:"\f1a6"}.fa-pied-piper:before{content:"\f1a7"}.fa-pied-piper-alt:before{content:"\f1a8"}.fa-drupal:before{content:"\f1a9"}.fa-joomla:before{content:"\f1aa"}.fa-language:before{content:"\f1ab"}.fa-fax:before{content:"\f1ac"}.fa-building:before{content:"\f1ad"}.fa-child:before{content:"\f1ae"}.fa-paw:before{content:"\f1b0"}.fa-spoon:before{content:"\f1b1"}.fa-cube:before{content:"\f1b2"}.fa-cubes:before{content:"\f1b3"}.fa-behance:before{content:"\f1b4"}.fa-behance-square:before{content:"\f1b5"}.fa-steam:before{content:"\f1b6"}.fa-steam-square:before{content:"\f1b7"}.fa-recycle:before{content:"\f1b8"}.fa-automobile:before,.fa-car:before{content:"\f1b9"}.fa-cab:before,.fa-taxi:before{content:"\f1ba"}.fa-tree:before{content:"\f1bb"}.fa-spotify:before{content:"\f1bc"}.fa-deviantart:before{content:"\f1bd"}.fa-soundcloud:before{content:"\f1be"}.fa-database:before{content:"\f1c0"}.fa-file-pdf-o:before{content:"\f1c1"}.fa-file-word-o:before{content:"\f1c2"}.fa-file-excel-o:before{content:"\f1c3"}.fa-file-powerpoint-o:before{content:"\f1c4"}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:"\f1c5"}.fa-file-zip-o:before,.fa-file-archive-o:before{content:"\f1c6"}.fa-file-sound-o:before,.fa-file-audio-o:before{content:"\f1c7"}.fa-file-movie-o:before,.fa-file-video-o:before{content:"\f1c8"}.fa-file-code-o:before{content:"\f1c9"}.fa-vine:before{content:"\f1ca"}.fa-codepen:before{content:"\f1cb"}.fa-jsfiddle:before{content:"\f1cc"}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:"\f1cd"}.fa-circle-o-notch:before{content:"\f1ce"}.fa-ra:before,.fa-rebel:before{content:"\f1d0"}.fa-ge:before,.fa-empire:before{content:"\f1d1"}.fa-git-square:before{content:"\f1d2"}.fa-git:before{content:"\f1d3"}.fa-hacker-news:before{content:"\f1d4"}.fa-tencent-weibo:before{content:"\f1d5"}.fa-qq:before{content:"\f1d6"}.fa-wechat:before,.fa-weixin:before{content:"\f1d7"}.fa-send:before,.fa-paper-plane:before{content:"\f1d8"}.fa-send-o:before,.fa-paper-plane-o:before{content:"\f1d9"}.fa-history:before{content:"\f1da"}.fa-genderless:before,.fa-circle-thin:before{content:"\f1db"}.fa-header:before{content:"\f1dc"}.fa-paragraph:before{content:"\f1dd"}.fa-sliders:before{content:"\f1de"}.fa-share-alt:before{content:"\f1e0"}.fa-share-alt-square:before{content:"\f1e1"}.fa-bomb:before{content:"\f1e2"}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:"\f1e3"}.fa-tty:before{content:"\f1e4"}.fa-binoculars:before{content:"\f1e5"}.fa-plug:before{content:"\f1e6"}.fa-slideshare:before{content:"\f1e7"}.fa-twitch:before{content:"\f1e8"}.fa-yelp:before{content:"\f1e9"}.fa-newspaper-o:before{content:"\f1ea"}.fa-wifi:before{content:"\f1eb"}.fa-calculator:before{content:"\f1ec"}.fa-paypal:before{content:"\f1ed"}.fa-google-wallet:before{content:"\f1ee"}.fa-cc-visa:before{content:"\f1f0"}.fa-cc-mastercard:before{content:"\f1f1"}.fa-cc-discover:before{content:"\f1f2"}.fa-cc-amex:before{content:"\f1f3"}.fa-cc-paypal:before{content:"\f1f4"}.fa-cc-stripe:before{content:"\f1f5"}.fa-bell-slash:before{content:"\f1f6"}.fa-bell-slash-o:before{content:"\f1f7"}.fa-trash:before{content:"\f1f8"}.fa-copyright:before{content:"\f1f9"}.fa-at:before{content:"\f1fa"}.fa-eyedropper:before{content:"\f1fb"}.fa-paint-brush:before{content:"\f1fc"}.fa-birthday-cake:before{content:"\f1fd"}.fa-area-chart:before{content:"\f1fe"}.fa-pie-chart:before{content:"\f200"}.fa-line-chart:before{content:"\f201"}.fa-lastfm:before{content:"\f202"}.fa-lastfm-square:before{content:"\f203"}.fa-toggle-off:before{content:"\f204"}.fa-toggle-on:before{content:"\f205"}.fa-bicycle:before{content:"\f206"}.fa-bus:before{content:"\f207"}.fa-ioxhost:before{content:"\f208"}.fa-angellist:before{content:"\f209"}.fa-cc:before{content:"\f20a"}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:"\f20b"}.fa-meanpath:before{content:"\f20c"}.fa-buysellads:before{content:"\f20d"}.fa-connectdevelop:before{content:"\f20e"}.fa-dashcube:before{content:"\f210"}.fa-forumbee:before{content:"\f211"}.fa-leanpub:before{content:"\f212"}.fa-sellsy:before{content:"\f213"}.fa-shirtsinbulk:before{content:"\f214"}.fa-simplybuilt:before{content:"\f215"}.fa-skyatlas:before{content:"\f216"}.fa-cart-plus:before{content:"\f217"}.fa-cart-arrow-down:before{content:"\f218"}.fa-diamond:before{content:"\f219"}.fa-ship:before{content:"\f21a"}.fa-user-secret:before{content:"\f21b"}.fa-motorcycle:before{content:"\f21c"}.fa-street-view:before{content:"\f21d"}.fa-heartbeat:before{content:"\f21e"}.fa-venus:before{content:"\f221"}.fa-mars:before{content:"\f222"}.fa-mercury:before{content:"\f223"}.fa-transgender:before{content:"\f224"}.fa-transgender-alt:before{content:"\f225"}.fa-venus-double:before{content:"\f226"}.fa-mars-double:before{content:"\f227"}.fa-venus-mars:before{content:"\f228"}.fa-mars-stroke:before{content:"\f229"}.fa-mars-stroke-v:before{content:"\f22a"}.fa-mars-stroke-h:before{content:"\f22b"}.fa-neuter:before{content:"\f22c"}.fa-facebook-official:before{content:"\f230"}.fa-pinterest-p:before{content:"\f231"}.fa-whatsapp:before{content:"\f232"}.fa-server:before{content:"\f233"}.fa-user-plus:before{content:"\f234"}.fa-user-times:before{content:"\f235"}.fa-hotel:before,.fa-bed:before{content:"\f236"}.fa-viacoin:before{content:"\f237"}.fa-train:before{content:"\f238"}.fa-subway:before{content:"\f239"}.fa-medium:before{content:"\f23a"}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}html,button,input,select,textarea{font-family:sans-serif}body,form,fieldset,legend,input,select,textarea,button{margin:0}html{font-size:100%}body{font-family:sans-serif;font-size:16px;font-size:1rem;line-height:21px;line-height:1.3125rem;color:#434343;background-color:#fff;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}b,strong{font-weight:700}i,em,.em{font-style:italic}a{color:#669fcf}a:hover{text-decoration:none}a:focus{outline:0}a:active,a:hover{outline:0}p{margin:0 0 1.6em 0}pre{margin:1em 0}ul+p,ul+pre,ol+p,ol+pre{margin-top:0}small{font-size:80%}abbr[title]{border-bottom:1px dotted}audio,canvas,video{display:inline-block;*zoom:1;*display:inline}audio:not([controls]){display:none;height:0}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}dfn{font-style:italic}img{border:0;-ms-interpolation-mode:bicubic}svg:not(:root){overflow:hidden}figure{margin:0}.image-left{margin-right:20px}.image-right{margin-left:20px}h1,h2,h3,h4,h5,h6{line-height:normal;font-weight:normal;margin:0 0 .33em 0}h1,.h1{font-size:40px;font-size:2.5rem}h2,.h2{font-size:32px;font-size:2rem}h3,.h3{font-size:26px;font-size:1.625rem}h4,.h4{font-size:20px;font-size:1.25rem}h5,.h5{font-size:18px;font-size:1.125rem}h6,.h6{font-size:16px;font-size:1rem}.no-style-heading{margin:0;font-size:100%}hr{border:0;background:0;outline:0;background-color:#ddd;margin:2em 0;*margin:1em 0;-moz-box-sizing:content-box;box-sizing:content-box;height:1px}blockquote{font-size:22px;font-size:1.375rem;line-height:32px;line-height:2rem;color:#434343;margin:1em 0;font-style:italic}blockquote p{margin:1em 0}cite{color:#434343;font-style:normal;font-weight:normal;font-size:16px;font-size:1rem;line-height:normal}q{font-style:italic;quotes:none}q:before,q:after{content:'';content:none}mark{background:#ff0;color:#111}code,kbd,pre,samp{word-wrap:break-word;font-family:'courier new',monospace,serif;font-size:13px;font-size:.8125rem;line-height:normal;font-weight:normal;background-color:#f1f1f1;padding:10px}code{color:#111}dl,menu,ol,ul{margin:1em 0}dd,ul ul,ol ol,ul ol,ol ul{margin:0}dt{font-weight:normal}dd{margin-bottom:1em}menu,ol,ul{padding:0 0 0 22px}nav ul,nav ol{list-style:none;list-style-image:none}.unstyled-list{list-style:none;padding:0;margin:0}.unstyled-list li{margin-top:0;margin-bottom:0}.inline-list{list-style:none;padding:0;margin:0;display:inline-block;*zoom:1;*display:inline}.inline-list li{margin-top:0;margin-bottom:0}.inline-list li{display:inline-block;*zoom:1;*display:inline}table{width:100%;margin:1em 0;table-layout:fixed;border-collapse:collapse;border-spacing:0;border-right:1px solid #f1f1f1;border-bottom:1px solid #f1f1f1;word-wrap:break-word;-ms-word-wrap:break-word;*white-space:normal}table th,table td{padding:8px;text-align:left;vertical-align:top;border-top:1px solid #eee;border-left:1px solid #eee}table thead th,table tfoot th{vertical-align:bottom;font-weight:normal;background-color:#f1f1f1;color:#333}table caption{padding:8px;font-style:normal;text-align:left;font-weight:normal;border-bottom:0}fieldset{border:0;padding:0}legend{border:0;padding:0;white-space:normal;*margin-left:-7px;font-weight:normal}label{margin:0;cursor:pointer}button,input,select,textarea{font-size:100%;vertical-align:baseline;*vertical-align:middle}input[type=text],input[type=password],input[type=email],input[type=search],input[type=tel],textarea{padding:5px;-webkit-appearance:none;-moz-appearance:none;font-weight:normal;line-height:normal;background-color:#fff;border:1px solid #ccc;color:#111}input[type=checkbox],input[type=radio]{cursor:pointer;box-sizing:border-box;line-height:normal;margin:0;padding:0;*height:13px;*width:13px}.checkbox{display:block;margin:.2em 0}.checkbox input[type=checkbox],.checkbox input[type=radio]{margin-top:.05em;float:left}.checkbox label{padding-left:5px;overflow:hidden;display:table;*zoom:1}button,input{line-height:normal}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer;*overflow:visible}button[disabled],html input[disabled]{cursor:default}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top;resize:none}.button{border:0;padding:1em 3em;background-color:#e74b3c;color:#fff;text-decoration:none;text-align:center;display:inline-block;*zoom:1;*display:inline;position:relative}.button:hover{background-color:#fc5547}.button:active{top:1px}.grey-button{background-color:#eee;color:#434343}.grey-button:hover{background-color:#f1f1f1}.button[disabled],.button.disabled{color:#999;background-color:#f1f1f1}.unstyled-button{font-size:16px;font-size:1rem;color:#27ae61;text-decoration:underline;border:0;background:transparent;height:auto;padding:0;cursor:pointer;outline:0}.unstyled-button:hover{text-decoration:none}.unstyled-button[disabled],.unstyled-button.disabled{text-decoration:none;color:#999;background-color:#ccc}.section{position:relative}.container{max-width:960px;margin-left:auto;margin-right:auto;padding-left:10px;padding-right:10px}.container-full{max-width:960px;margin-left:auto;margin-right:auto}.col{float:left;padding-left:10px;padding-right:10px}[class*="pull-"],[class*="push-"]{position:relative}.no-gutter{padding-left:0;padding-right:0}.col-1{width:8.33333%;width:calc(8.333333333333334%);width:-webkit-calc(8.333333333333334%);width:-moz-calc(8.333333333333334%)}.col-2{width:16.66667%;width:calc(16.666666666666668%);width:-webkit-calc(16.666666666666668%);width:-moz-calc(16.666666666666668%)}.col-3{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.col-4{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.col-5{width:41.66665%;width:calc(41.66666666666667%);width:-webkit-calc(41.66666666666667%);width:-moz-calc(41.66666666666667%)}.col-6{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.col-7{width:58.33333%;width:calc(58.333333333333336%);width:-webkit-calc(58.333333333333336%);width:-moz-calc(58.333333333333336%)}.col-8{width:66.66666%;width:calc(66.66666666666667%);width:-webkit-calc(66.66666666666667%);width:-moz-calc(66.66666666666667%)}.col-9{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.col-10{width:83.33333%;width:calc(83.33333333333334%);width:-webkit-calc(83.33333333333334%);width:-moz-calc(83.33333333333334%)}.col-11{width:91.66666%;width:calc(91.66666666666667%);width:-webkit-calc(91.66666666666667%);width:-moz-calc(91.66666666666667%)}.col-12{width:100%}.col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.push-1{left:8.33333%;left:calc(8.333333333333334%);left:-webkit-calc(8.333333333333334%);left:-moz-calc(8.333333333333334%)}.pull-1{left:-8.33333%;left:calc(-8.333333333333334%);left:-webkit-calc(-8.333333333333334%);left:-moz-calc(-8.333333333333334%)}.push-2{left:16.66667%;left:calc(16.666666666666668%);left:-webkit-calc(16.666666666666668%);left:-moz-calc(16.666666666666668%)}.pull-2{left:-16.66667%;left:calc(-16.666666666666668%);left:-webkit-calc(-16.666666666666668%);left:-moz-calc(-16.666666666666668%)}.push-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.pull-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.push-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.pull-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.push-5{left:41.66665%;left:calc(41.66666666666667%);left:-webkit-calc(41.66666666666667%);left:-moz-calc(41.66666666666667%)}.pull-5{left:-41.66665%;left:calc(-41.66666666666667%);left:-webkit-calc(-41.66666666666667%);left:-moz-calc(-41.66666666666667%)}.push-6{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.pull-6{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.push-7{left:58.33333%;left:calc(58.333333333333336%);left:-webkit-calc(58.333333333333336%);left:-moz-calc(58.333333333333336%)}.pull-7{left:-58.33333%;left:calc(-58.333333333333336%);left:-webkit-calc(-58.333333333333336%);left:-moz-calc(-58.333333333333336%)}.push-8{left:66.66666%;left:calc(66.66666666666667%);left:-webkit-calc(66.66666666666667%);left:-moz-calc(66.66666666666667%)}.pull-8{left:-66.66666%;left:calc(-66.66666666666667%);left:-webkit-calc(-66.66666666666667%);left:-moz-calc(-66.66666666666667%)}.push-9{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.pull-9{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.push-10{left:83.33333%;left:calc(83.33333333333334%);left:-webkit-calc(83.33333333333334%);left:-moz-calc(83.33333333333334%)}.pull-10{left:-83.33333%;left:calc(-83.33333333333334%);left:-webkit-calc(-83.33333333333334%);left:-moz-calc(-83.33333333333334%)}.push-11{left:91.66666%;left:calc(91.66666666666667%);left:-webkit-calc(91.66666666666667%);left:-moz-calc(91.66666666666667%)}.pull-11{left:-91.66666%;left:calc(-91.66666666666667%);left:-webkit-calc(-91.66666666666667%);left:-moz-calc(-91.66666666666667%)}.row{padding-top:1em;padding-bottom:1em}.clear:before,.clear:after{content:"";display:table}.clear:after{clear:both}.clear{zoom:1}.left{float:left}.right{float:right}.block{display:block}.inline{display:inline}.inline-block{display:inline-block;*zoom:1;*display:inline}.none,.hidden,[hidden],.no-desktop{display:none}.heavy{font-weight:900}.strong{font-weight:700}.normal{font-weight:normal}.thin{font-weight:300}.fine{font-weight:100}.italic{font-style:italic}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.left-text{text-align:left}.right-text{text-align:right}.center-text{text-align:center}.justify-text{text-align:justify}.visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;overflow:hidden;padding:0;position:absolute;width:1px;left:-9999em}.visuallyvisible{clip:auto;width:auto;height:auto;overflow:visible;left:0}.no-margin{margin:0}.no-padding{padding:0}@media only screen and (min-width:740px) and (max-width:960px){.container,.tablet-container{max-width:960px;padding-left:20px;padding-right:20px;margin-left:auto;margin-right:auto;float:none}.container:first-child,.tablet-container:first-child{margin-left:auto}.tablet-container-full{padding-left:0;padding-right:0;margin-left:auto;margin-right:auto;float:none}.tablet-container-full:first-child{margin-left:auto}.tablet-no-gutter{padding-left:0;padding-right:0}.tablet-col-1{width:8.33333%;width:calc(8.333333333333334%);width:-webkit-calc(8.333333333333334%);width:-moz-calc(8.333333333333334%)}.tablet-col-2{width:16.66667%;width:calc(16.666666666666668%);width:-webkit-calc(16.666666666666668%);width:-moz-calc(16.666666666666668%)}.tablet-col-3{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.tablet-col-4{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.tablet-col-5{width:41.66665%;width:calc(41.66666666666667%);width:-webkit-calc(41.66666666666667%);width:-moz-calc(41.66666666666667%)}.tablet-col-6{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.tablet-col-7{width:58.33333%;width:calc(58.333333333333336%);width:-webkit-calc(58.333333333333336%);width:-moz-calc(58.333333333333336%)}.tablet-col-8{width:66.66666%;width:calc(66.66666666666667%);width:-webkit-calc(66.66666666666667%);width:-moz-calc(66.66666666666667%)}.tablet-col-9{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.tablet-col-10{width:83.33333%;width:calc(83.33333333333334%);width:-webkit-calc(83.33333333333334%);width:-moz-calc(83.33333333333334%)}.tablet-col-11{width:91.66666%;width:calc(91.66666666666667%);width:-webkit-calc(91.66666666666667%);width:-moz-calc(91.66666666666667%)}.tablet-col-12{width:100%}.tablet-col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.tablet-col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.tablet-col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.tablet-col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.tablet-push-1{left:8.33333%;left:calc(8.333333333333334%);left:-webkit-calc(8.333333333333334%);left:-moz-calc(8.333333333333334%)}.tablet-pull-1{left:-8.33333%;left:calc(-8.333333333333334%);left:-webkit-calc(-8.333333333333334%);left:-moz-calc(-8.333333333333334%)}.tablet-push-2{left:16.66667%;left:calc(16.666666666666668%);left:-webkit-calc(16.666666666666668%);left:-moz-calc(16.666666666666668%)}.tablet-pull-2{left:-16.66667%;left:calc(-16.666666666666668%);left:-webkit-calc(-16.666666666666668%);left:-moz-calc(-16.666666666666668%)}.tablet-push-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.tablet-pull-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.tablet-push-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.tablet-pull-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.tablet-push-5{left:41.66665%;left:calc(41.66666666666667%);left:-webkit-calc(41.66666666666667%);left:-moz-calc(41.66666666666667%)}.tablet-pull-5{left:-41.66665%;left:calc(-41.66666666666667%);left:-webkit-calc(-41.66666666666667%);left:-moz-calc(-41.66666666666667%)}.tablet-push-6{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.tablet-pull-6{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.tablet-push-7{left:58.33333%;left:calc(58.333333333333336%);left:-webkit-calc(58.333333333333336%);left:-moz-calc(58.333333333333336%)}.tablet-pull-7{left:-58.33333%;left:calc(-58.333333333333336%);left:-webkit-calc(-58.333333333333336%);left:-moz-calc(-58.333333333333336%)}.tablet-push-8{left:66.66666%;left:calc(66.66666666666667%);left:-webkit-calc(66.66666666666667%);left:-moz-calc(66.66666666666667%)}.tablet-pull-8{left:-66.66666%;left:calc(-66.66666666666667%);left:-webkit-calc(-66.66666666666667%);left:-moz-calc(-66.66666666666667%)}.tablet-push-9{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.tablet-pull-9{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.tablet-push-10{left:83.33333%;left:calc(83.33333333333334%);left:-webkit-calc(83.33333333333334%);left:-moz-calc(83.33333333333334%)}.tablet-pull-10{left:-83.33333%;left:calc(-83.33333333333334%);left:-webkit-calc(-83.33333333333334%);left:-moz-calc(-83.33333333333334%)}.tablet-push-11{left:91.66666%;left:calc(91.66666666666667%);left:-webkit-calc(91.66666666666667%);left:-moz-calc(91.66666666666667%)}.tablet-pull-11{left:-91.66666%;left:calc(-91.66666666666667%);left:-webkit-calc(-91.66666666666667%);left:-moz-calc(-91.66666666666667%)}.tablet-no-push,.tablet-no-pull{left:auto}.tablet-row{padding-top:1em;padding-bottom:1em}.tablet-full{left:auto;clear:both;float:none;width:100%;margin:1em 0 0 0;display:block}.tablet-full:first-child{margin-top:0}.tablet-left-text{text-align:left}.tablet-right-text{text-align:right}.tablet-center-text{text-align:center}.tablet-left{float:left}.tablet-right{float:right}.tablet-no-float{float:none}.tablet-no-margin{margin:0}.tablet-no-padding{padding:0}.no-tablet{display:none}.show-tablet{display:block}}@media only screen and (max-width:739px){.container,.mobile-container{padding-left:20px;padding-right:20px;margin-left:auto;margin-right:auto;float:none}.container:first-child,.mobile-container:first-child{margin-left:auto}.mobile-container-full{padding-left:0;padding-right:0;margin-left:auto;margin-right:auto;float:none}.mobile-container-full:first-child{margin-left:auto}.mobile-no-gutter{padding-left:0;padding-right:0}.mobile-col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.mobile-col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.mobile-col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.mobile-col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.mobile-push-1-2{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.mobile-pull-1-2{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.mobile-push-1-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.mobile-pull-1-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.mobile-push-1-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.mobile-pull-1-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.mobile-push-3-4{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.mobile-pull-3-4{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.mobile-no-push,.mobile-no-pull{left:auto}.mobile-row{padding-top:1em;padding-bottom:1em}.mobile-full{left:auto;clear:both;float:none;width:100%;margin:.2em 0 0 0;display:block}.mobile-full:first-child{margin-top:0}.mobile-left-text{text-align:left}.mobile-right-text{text-align:right}.mobile-center-text{text-align:center}.mobile-left{float:left}.mobile-right{float:right}.mobile-no-float{float:none}.mobile-no-margin{margin:0}.mobile-no-padding{padding:0}table th,table td{padding:4px}.no-mobile{display:none}.show-mobile{display:block}}@media print{*{background:transparent}a,a:visited{text-decoration:underline}abbr[title]:after{content:" (" attr(title) ")"}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100%}@page{margin:.5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}}html,body{height:100%}.absolute{position:absolute}.relative{position:relative}.full{width:100%}.no-scroll{overflow:hidden}.table{display:table;margin:0 auto}.xlarge-top{margin-top:60px}.large-top{margin-top:40px}.medium-top{margin-top:20px}.small-top{margin-top:10px}.mini-top{margin-top:5px}.no-left-padding{padding-left:0}.no-right-padding{padding-right:0}@media only screen and (max-width:739px){.mobile-hide{display:none}.mobile-xlarge-top{margin-top:60px}.mobile-large-top{margin-top:40px}.mobile-medium-top{margin-top:20px}.mobile-small-top{margin-top:10px}.mobile-mini-top{margin-top:5px}}html,body{font-family:'Roboto','Helvetica Neue','Arial','Helvetica','Lucida Grande',sans-serif;font-weight:300;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}h1,h2,h3,h4,h5{font-weight:300}p{margin:0 0 1em 0}pre,code{padding:5px 10px;color:#6e6e6e;font-size:14px;line-height:20px;font-weight:100;background:#f8f8f8;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}a{color:#333;text-decoration:none;-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out}a.active{color:#000}a:hover{color:#000}a:hover .fa-trash-o{color:#e2717f}a.primary{color:#e2717f}a.primary:hover{color:#d94759}img{max-width:100%}hr{margin:.5em 0;width:100%}i.right-padding{padding-right:10px}i.left-padding{padding-left:10px}.button{outline:0;padding:1em 1.5em;background:#fafafa;color:#333;white-space:nowrap;background-clip:padding-box;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.button.disabled,.button[disabled]{-moz-opacity:.7;-khtml-opacity:.7;-webkit-opacity:.7;opacity:.7;-ms-filter:alpha(opacity=70);filter:alpha(opacity=70);cursor:default}.button:hover:not(.disabled),.button:hover:not([disabled]){background:#d9d9d9}.button.large{padding:1em 4em}.button.small{padding:.6em .8em}.button.x-small{padding:.4em .6em}.button.primary-button{color:#fff;background:#e2717f}.button.primary-button:hover,.button.primary-button:focus{color:#f2f2f2;background:#de5c6c}.button.primary-button:hover.disabled,.button.primary-button:focus.disabled,.button.primary-button:hover:disabled,.button.primary-button:focus:disabled{background:#e2717f}.button.secondary-button{background:0;border:1px solid #eee}.button.secondary-button:hover:not(.active),.button.secondary-button:hover:not(.disabled),.button.secondary-button:hover:not(:disabled),.button.secondary-button:focus:not(.active),.button.secondary-button:focus:not(.disabled),.button.secondary-button:focus:not(:disabled){color:#666;background:#f8f8f8}.button.secondary-button.active{color:#595959;background:#ebebeb;border:1px solid #eee}.button.secondary-button.active:hover{color:#595959;background:#ebebeb;border:1px solid #eee}.button.remove-button{background:#e2717f;color:#fff;padding:.9em 1.5em}.button.remove-button:hover,.button.remove-button:focus{background:#de5c6c}.button.remove-button:hover.disabled,.button.remove-button:focus.disabled,.button.remove-button:hover:disabled,.button.remove-button:focus:disabled{background:#e2717f}.button.transparent-button{background:0;color:#fff;border:1px solid #f2f2f2}.button.transparent-button:hover:not(.disabled),.button.transparent-button:hover:not(:disabled){background:rgba(255,255,255,0.1);color:#fff}.button-group>.button{padding:.8em 1em;text-align:center;background:#fff;border-top:1px solid #eee;border-bottom:1px solid #eee;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.button-group>.button i.fa{margin-right:5px}.button-group>.button:first-child{border-left:1px solid #eee;-webkit-border-top-right-radius:0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:5px;-webkit-border-top-left-radius:5px;-moz-border-radius-topright:0;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:5px;-moz-border-radius-topleft:5px;border-top-right-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:5px;border-top-left-radius:5px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.button-group>.button:last-child{border-right:1px solid #eee;-webkit-border-top-right-radius:5px;-webkit-border-bottom-right-radius:5px;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:0;-moz-border-radius-topright:5px;-moz-border-radius-bottomright:5px;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:0;border-top-right-radius:5px;border-bottom-right-radius:5px;border-bottom-left-radius:0;border-top-left-radius:0;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.button-group>.button:hover:not(.active),.button-group>.button:focus:not(.active){color:#666;background:#f8f8f8}.button-group>.button.active{color:#595959;background:#ebebeb;border:1px solid #eee}.button-group>.button.active:hover{color:#595959;background:#ebebeb;border:1px solid #eee}.button-group.small>.button{padding:.6em .8em}.button-group.x-small>.button{padding:.4em .6em}form .col,form .input-wrapper{position:relative}form input,form input[type="text"],form input[type="password"],form input[type="email"],form input[type="search"],form input[type="tel"],form input[type="number"],form input[type="date"],form textarea{width:100%;padding:.8em .6em .6em;outline:0;border:1px solid #d3d3d3;font-size:1.1em;line-height:1;background:#fff;color:#666;-webkit-appearance:none;-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out}form input:focus,form input[type="text"]:focus,form input[type="password"]:focus,form input[type="email"]:focus,form input[type="search"]:focus,form input[type="tel"]:focus,form input[type="number"]:focus,form input[type="date"]:focus,form textarea:focus{color:#333;border:1px solid #a0a0a0;-moz-box-shadow:0 0 2px #a0a0a0;-webkit-box-shadow:0 0 2px #a0a0a0;box-shadow:0 0 2px #a0a0a0;-webkit-box-shadow:0 0 2px #a0a0a0 0 0 #000;box-shadow:0 0 2px #a0a0a0 0 0 #000}form input:focus+label,form input[type="text"]:focus+label,form input[type="password"]:focus+label,form input[type="email"]:focus+label,form input[type="search"]:focus+label,form input[type="tel"]:focus+label,form input[type="number"]:focus+label,form input[type="date"]:focus+label,form textarea:focus+label{color:#666;font-weight:400}form input.success,form input[type="text"].success,form input[type="password"].success,form input[type="email"].success,form input[type="search"].success,form input[type="tel"].success,form input[type="number"].success,form input[type="date"].success,form textarea.success{border:1px solid #43cea2;-moz-box-shadow:0 0 2px #43cea2;-webkit-box-shadow:0 0 2px #43cea2;box-shadow:0 0 2px #43cea2;-webkit-box-shadow:0 0 2px #43cea2 0 0 #000;box-shadow:0 0 2px #43cea2 0 0 #000}form input.success+label,form input[type="text"].success+label,form input[type="password"].success+label,form input[type="email"].success+label,form input[type="search"].success+label,form input[type="tel"].success+label,form input[type="number"].success+label,form input[type="date"].success+label,form textarea.success+label{color:#43cea2;font-weight:400}form input.error,form input[type="text"].error,form input[type="password"].error,form input[type="email"].error,form input[type="search"].error,form input[type="tel"].error,form input[type="number"].error,form input[type="date"].error,form textarea.error{border:1px solid #e2717f;-moz-box-shadow:0 0 2px #e2717f;-webkit-box-shadow:0 0 2px #e2717f;box-shadow:0 0 2px #e2717f;-webkit-box-shadow:0 0 2px #e2717f 0 0 #000;box-shadow:0 0 2px #e2717f 0 0 #000}form input.error+label,form input[type="text"].error+label,form input[type="password"].error+label,form input[type="email"].error+label,form input[type="search"].error+label,form input[type="tel"].error+label,form input[type="number"].error+label,form input[type="date"].error+label,form textarea.error+label{color:#e2717f;font-weight:400}form input::-webkit-input-placeholder,form input[type="text"]::-webkit-input-placeholder,form input[type="password"]::-webkit-input-placeholder,form input[type="email"]::-webkit-input-placeholder,form input[type="search"]::-webkit-input-placeholder,form input[type="tel"]::-webkit-input-placeholder,form input[type="number"]::-webkit-input-placeholder,form input[type="date"]::-webkit-input-placeholder,form textarea::-webkit-input-placeholder{color:#d3d3d3;font-weight:300}form [placeholder]:focus::-webkit-input-placeholder{-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out;opacity:0}form input[type="number"]::-webkit-inner-spin-button,form input[type="number"]::-webkit-outer-spin-button,form input[type="date"]::-webkit-inner-spin-button,form input[type="date"]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}form .select-style{position:relative;display:block;width:100%;border:1px solid #a0a0a0;background:#fff}form .select-style .fa-caret-down{position:absolute;right:.6em;top:.8em;color:#a0a0a0;font-size:1.4em}form .select-style select{padding:.8em 0;margin-left:.6em;width:100%;border:0;box-shadow:none;background:transparent;background-image:none;-webkit-appearance:none;color:#a0a0a0;font-size:1.2em}form .select-style select:hover{cursor:pointer}form .select-style select:focus{outline:0}form fieldset.row{padding:.5em 0}form label{position:absolute;left:5px;top:-5px;padding:0 5px;background:white;color:#a0a0a0;font-size:12px;line-height:12px;text-transform:uppercase;pointer-events:none;z-index:2}.modal-wrapper{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.3);display:none;z-index:1001;will-change:transform}.modal-wrapper .modal{position:relative;color:#333;display:none}.modal-wrapper .modal a.close{position:absolute;padding:6px 12px 9px;border:1px solid;border-radius:20px;font-weight:300;font-size:27px}.modal-wrapper .modal section.modal-content{padding:20px}.modal-wrapper:not(.fullscreen) .modal{min-height:300px;max-width:434px;margin:60px auto 0;background-color:#fff;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.modal-wrapper:not(.fullscreen) .modal a.close{right:-45px;top:-30px;color:#fff}.modal-wrapper.fullscreen{background:#fff}.modal-wrapper.fullscreen .modal{height:100%;overflow:auto}.modal-wrapper.fullscreen .modal a.close{right:20px;top:20px}.notice{position:fixed;bottom:0;right:10px;height:100px;width:300px;padding:5px 10px 5px 10px;display:none;color:#fff;z-index:1005;-webkit-border-top-right-radius:5px;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:5px;-moz-border-radius-topright:5px;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:5px;border-top-right-radius:5px;border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-left-radius:5px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.notice.success{background-color:#43cea2}.notice.warning{background-color:#f4ed6b}.notice.error{background-color:#e2717f}.notice header.notice-header{position:relative;margin-bottom:.2em}.notice section.notice-content{height:70px;width:100%;overflow:auto;font-size:.8em}.notice a.close{position:absolute;top:3px;right:0;padding:0 4px 2px;border:1px solid;border-radius:100%;font-weight:300;font-size:12px;line-height:12px;color:#fff}.notice a.close:hover{color:#ccc}nav{font-size:18px;font-size:1.125rem}nav .navbar{margin:0 auto;display:table;padding:10px 0}nav li{margin:0 10px}nav a{display:inline-block;line-height:60px;vertical-align:middle}nav a.logo{height:60px;width:60px}@media(max-width:739px){nav{font-size:14px;font-size:.875rem}nav a{line-height:40px}nav a.logo{height:40px;width:40px}}#toc{position:fixed;top:80px;height:100%;width:220px;overflow:auto;padding-bottom:100px}#toc a{color:#333}#toc a:hover{color:#1a1a1a}#toc li>ul{display:none}#toc li>ul.unstyled-list{margin-left:10px}#toc li.active>a{font-weight:bold}#toc li.active>ul{display:block}#toc ul.nav>li.active>ul>li{list-style:none}footer{padding:60px 0;color:#d3d3d3;background:#333}footer i.fa-heart{color:#e2717f}footer i.fa-beer{color:#f4ed6b}html,body{background:#fff;color:#333}.kd{color:#a783b6}.k{color:#43cea2}h1.logo{font-size:64px;font-size:4rem}.gist pre,.gist .file-data{font-size:14px!important}section{padding:40px 0}code{padding:0}#hero .badges,#hero .github-links{padding:.3em 0}#hero .badges p,#hero .github-links p{margin:0}#ship h3{margin-bottom:1em}#ship img.ship-it{display:table;height:300px;width:300px;margin:0 auto;background:#d3d3d3;-webkit-border-radius:100%;-moz-border-radius:100%;border-radius:100%}#plugins{color:#fff;background:#333}#plugins p{color:#d3d3d3}#plugins ul li{padding:10px 20px}#plugins ul li a{display:inline-block}#plugins ul li a img{height:100px;max-width:160px}@media(max-width:739px){#plugins ul li a img{height:60px;max-width:120px}}#features{color:#fff;background:#e2717f}#features h4{color:#982e3e}#features a.primary{color:#f8f8f8;border-bottom:1px dashed #f8f8f8}#features a.primary:hover{color:#dfdfdf;border-bottom:1px dashed #dfdfdf}#comparison img{margin:0 auto}.example,.example .row{padding-bottom:0}.page,.example{margin-bottom:0}.page a,.example a{color:#e2717f}.page a:hover,.example a:hover{color:#d94759}.page .file-data .line-numbers,.example .file-data .line-numbers{width:40px}#todo-example{padding-bottom:2em}#todo-example input[type="text"]{margin:10px 0}#todo-example ul.todos{height:320px}#todo-example ul.todos li{padding:5px 0}#todo-example ul.todos li input[type="checkbox"]{margin-top:.2em}#todo-example ul.todos li span{margin-left:5px}#todo-example ul.todos li.done label{text-decoration:line-through;color:#998}#todo-example ul.todos li .delete{font-weight:bold}#todo-example label{float:left}#todo-example .primary-button{width:100%} \ No newline at end of file diff --git a/learn.md b/learn.md index e1f687b8ad..7384bbc087 100644 --- a/learn.md +++ b/learn.md @@ -6,16 +6,42 @@ permalink: /learn/ weight: 2 --- +On this page you will find additional resources and guides about Feathers. Make sure to first get familiar with the basics in the [Quick Start guide](/quick-start/). +## API docs +For the API documentation with detailed information about the Feathers specific API, configuration and to see the Changelog and License head over to the [Docs](/docs/) page. +## Frameworks +Feathers works great with any frontend that can connect through the REST API or websockets. Sometimes it is just a few lines of code to make a frontend turn real-time. Which is why implemented some TodoMVC examples and guides that all connect to the same Feathers real-time API. +Pick your poison: -## What's next? +- jQuery +- React +- Angular +- CanJS +- iOS +- Android -This guide hopefully gave you an overview of how Feathers works. We created a Todo service and made it available through a REST API and SocketIO. Then we moved to using MongoDB as the backend storage and learned how to process and validate our data. After that we added PassportJS authentication for both, the REST API and websockets and then briefly discussed how you might authorize that authenticated user and make sure that websocket events only get dispatched to where we want them to. +We don't know all the frameworks out there so if you don't see your favourite, submit an issue or - even better - a pull request and we'll try our best to help out. -The next step is definitely reading through the [API documentation](/api/) for a more detailed information on how to configure and use certain parts of Feathers. The [FAQ](/faq/) also has some answers to questions that come up regularly. For a growing list of official plugins, have a look at the [Feathersjs GitHub organization](https://github.com/feathersjs). +## Databases -If you have any other questions, feel free to submit them as a [GitHub issue](https://github.com/feathersjs/feathers/issues) or on [Stackoverflow](http://stackoverflow.com) using the `feathers` or `feathersjs` tag or join [#feathersjs](http://webchat.freenode.net/?channels=feathersjs) on Freenode IRC. +Feathers already has plugins for CRUD operations on many different databases: + +- In memory - A service that stores everything locally in memory. Probably not ideal in production environments but great for prototyping. +- MongoDB - A basic MongoDB implementation. Easy to use. +- Mongoose - Support for the MongoDB ODM which already gives you schemas and validation out of the box. +- NeDB - A file based database similar to MongoDB, great if you don't want or need a full blown database. +- MySQL +- PostgreSQL + +If you are wondering how to customize those existing adapters and make it easier to switch between different databases, read more about hooks in the next paragraph. + +## Hooks and validation + +## Authentication + +## Authorization diff --git a/quick-start.md b/quick-start.md index 5ed89bd5ce..39bb143520 100644 --- a/quick-start.md +++ b/quick-start.md @@ -6,15 +6,27 @@ weight: 1 permalink: /quick-start/ --- -## To get started +## About Feathers Feathers extends [Express 4](http://expressjs.com), one of the most popular web frameworks for [NodeJS](http://nodejs.org/). It makes it easy to create shared RESTful web services and real-time applications using SocketIO and several other NodeJS websocket libraries supported by [Primus](http://primus.io). -If you are not familiar with Express head over to the [Express Guides](http://expressjs.com/guide.html) to get an idea. Feathers works the exact same way and supports the same functionality except that `var app = require('express')();` is replaced with `var app = require('feathers')()`. This means that you can literally drop Feathers into your existing Express 4 application and start adding new services right away. +If you are not familiar with Express head over to the [Express Guides](http://expressjs.com/guide.html) to get an idea. Feathers works the exact same way and supports the same functionality except that -The following guide will walk through creating a basic Todo REST and websocket API with Feathers and MongoDB and also explain how to add authentication and authorization. For additional information also make sure to read through the [API documentation](/api/) and [FAQ](/faq/) later. +```js +var express = require('express'); +var app = express(); +``` + +is replaced with + +```js +var feathers = require('feathers'); +var app = feathers(); +``` + +This means that you can literally drop Feathers into your existing Express 4 application and start adding new services right away without having to change anything. -To get started with this guide, lets create a new folder and in it run +The following guide will walk through creating a basic Todo REST and websocket API with Feathers. To get started, lets create a new folder and in it run > `npm install feathers` @@ -74,7 +86,7 @@ You can go to [localhost:3000/todos/dishes](http://localhost:3000/todos/dishes) ### CRUD Todos -As you might have noticed, service methods mainly reflect basic [CRUD](http://en.wikipedia.org/wiki/Create,_read,_update_and_delete) functionality. Following up is a longer example with comments for implementing a complete Todo service that manages all Todos in memory: +You might have noticed that service methods mainly reflect basic [CRUD](http://en.wikipedia.org/wiki/Create,_read,_update_and_delete) functionality. Following up is a longer example with comments for implementing a complete Todo service that manages all Todos in memory: ```js // todos.js @@ -189,11 +201,13 @@ app.configure(feathers.rest()) .listen(3000); ``` -Running `app.js` will now provide a fully functional REST API at `http://localhost:3000/todos`. You can test it, for example, using the [Postman](https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en) REST client plugin for Google chrome or via CURL: +Running `app.js` will now provide a fully functional REST API at `http://localhost:3000/todos`. We can test it, for example, using the [Postman](https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en) REST client plugin for Google chrome or via CURL:
        curl 'http://localhost:3000/todos/' -H 'Content-Type: application/json' --data-binary '{ "text": "You have to do dishes!" }'
        +The functionality provided by our service is quite common which is why we implemented the same thing and published it as the [feathers-memory](https://github.com/feathersjs/feathers-memory) module. + ## Getting real-time As previously mentioned, a Feathers service can also be exposed through websockets. You can either use [SocketIO](http://socket.io) or [Primus](https://github.com/primus/primus) - an abstraction layer for differentNode websocket libraries. In the following examples we will use SocketIO. @@ -216,6 +230,14 @@ app.configure(feathers.rest()) .listen(3000); ``` +That's it. Our application is now real-time, all we have to do is provide a nice frontend. + +## Building a frontend + +### Feathers client + +### Testing the connection + To test the connection, we can create an `index.html` file in the same folder. The example page will connect to SocketIO, create a new Todo and also log when any Todo has been created, updated or patched: ```html @@ -271,7 +293,7 @@ To test the connection, we can create an `index.html` file in the same folder. T ``` -After restarting, going directly to [localhost:3000](http://localhost:3000) with the console open will show what is happening on the HTML page. You can also see the newly created Todo at the REST endpoint [localhost:3000/todos](http://localhost:3000/todos). With the page open, creating a new Todo via the REST API, for example +After restarting, going directly to [localhost:3000](http://localhost:3000) with the console open will show what is happening on the HTML page. You can also see the newly created Todo at the REST endpoint [localhost:3000/todos](http://localhost:3000/todos). With the page open, creating a new Todo via the REST API, for example
        curl 'http://localhost:3000/todos/' -H 'Content-Type: application/json' --data-binary '{ "text": "Do something" }'
        From 23c80f689a4e2454556b3d511bcf49f1502f84f4 Mon Sep 17 00:00:00 2001 From: David Luecke Date: Fri, 17 Jul 2015 10:31:53 -0600 Subject: [PATCH 04/11] More documentation and page improvements. --- _layouts/index.html | 6 +++--- _layouts/quick-start.html | 4 +++- _less/feathers.less | 1 + css/feathers.min.css | 2 +- js/feathers.js | 24 ++------------------- js/todos.js | 1 + learn.md | 44 +++++++++++++++++++++------------------ learn/authentication.md | 2 +- learn/authorization.md | 8 +++---- quick-start.md | 2 ++ support.md | 8 +++---- 11 files changed, 45 insertions(+), 57 deletions(-) diff --git a/_layouts/index.html b/_layouts/index.html index 365dc7942b..3f51e3e6ab 100644 --- a/_layouts/index.html +++ b/_layouts/index.html @@ -119,7 +119,7 @@

        Uber Flexible

        Minimal Configuration

        -

        Tired of massive JSON or YAML files? Feathers reduces complexity while still being explicit, not by hiding it behind generators and configuration files.

        +

        Tired of massive JSON or YAML files? Feathers reduces complexity while staying explicit, not by hiding it behind generators and configuration files.

        @@ -170,10 +170,10 @@
        "Once you go Meteor, you don't go back. And not in a good way

        Feathers vs Sails

        "If you love JSON config files, Sails is for you."

        - From a feature standpoint Feathers and Sails are probably the closest. Both provide real-time REST API's, multiple db support, and are client agnostic. Both frameworks also use Express, but Feathers supports Express 4 (and the latest version in a branch), while Sails only supports Express 3. + From a feature standpoint Feathers and Sails are probably the closest. Both provide real-time REST API's, multiple db support, and are client agnostic. Both frameworks also use Express, but Feathers supports Express 4, while Sails only supports Express 3.

        - Even though the features are very similar, Feathers achieves this with MUCH less code, which means less stuff to break and maintain. We also don't assume how you want to manage your assets by letting you use your build tool of choice. Feathers provides lightweight services and hooks instead of a full-blown ORM, and we let you write code instead of long config files to define relationships and security policies. + Even though the features are very similar, Feathers achieves this with MUCH less code, which means less stuff to break and maintain making it easy to continuously upgrade to the latest version of Express. We also don't assume how you want to manage your assets by letting you use your build tool of choice. Feathers provides lightweight services and hooks instead of a full-blown ORM, and we let you write code instead of long config files to define relationships and security policies.

        diff --git a/_layouts/quick-start.html b/_layouts/quick-start.html index 96bec0089e..28a499bc85 100644 --- a/_layouts/quick-start.html +++ b/_layouts/quick-start.html @@ -13,7 +13,9 @@

        {{page.title}}


        -
          +
            +
          • Loading...
          • +
          diff --git a/_less/feathers.less b/_less/feathers.less index 19673591af..50a38385aa 100644 --- a/_less/feathers.less +++ b/_less/feathers.less @@ -133,6 +133,7 @@ code { } .page, .example { + padding-top: 0; margin-bottom: 0; a { diff --git a/css/feathers.min.css b/css/feathers.min.css index 0bde08b66e..079e3e92cf 100644 --- a/css/feathers.min.css +++ b/css/feathers.min.css @@ -1,4 +1,4 @@ .hll{background-color:#ffc}.c{color:#998;font-style:italic}.err{color:#a61717;background-color:#e3d2d2}.k{color:#000;font-weight:bold}.o{color:#000;font-weight:bold}.cm{color:#998;font-style:italic}.cp{color:#999;font-weight:bold;font-style:italic}.c1{color:#998;font-style:italic}.cs{color:#999;font-weight:bold;font-style:italic}.gd{color:#000;background-color:#fdd}.ge{color:#000;font-style:italic}.gr{color:#a00}.gh{color:#999}.gi{color:#000;background-color:#dfd}.go{color:#888}.gp{color:#555}.gs{font-weight:bold}.gu{color:#aaa}.gt{color:#a00}.kc{color:#000;font-weight:bold}.kd{color:#000;font-weight:bold}.kn{color:#000;font-weight:bold}.kp{color:#000;font-weight:bold}.kr{color:#000;font-weight:bold}.kt{color:#458;font-weight:bold}.m{color:#099}.s{color:#d01040}.na{color:#008080}.nb{color:#0086b3}.nc{color:#458;font-weight:bold}.no{color:#008080}.nd{color:#3c5d5d;font-weight:bold}.ni{color:#800080}.ne{color:#900;font-weight:bold}.nf{color:#900;font-weight:bold}.nl{color:#900;font-weight:bold}.nn{color:#555}.nt{color:#000080}.nv{color:#008080}.ow{color:#000;font-weight:bold}.w{color:#bbb}.mf{color:#099}.mh{color:#099}.mi{color:#099}.mo{color:#099}.sb{color:#d01040}.sc{color:#d01040}.sd{color:#d01040}.s2{color:#d01040}.se{color:#d01040}.sh{color:#d01040}.si{color:#d01040}.sx{color:#d01040}.sr{color:#009926}.s1{color:#d01040}.ss{color:#990073}.bp{color:#999}.vc{color:#008080}.vg{color:#008080}.vi{color:#008080}.il{color:#099}/*! * Font Awesome 4.3.0 by @davegandy - http://fontawesome.io - @fontawesome * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) - */@font-face{font-family:'FontAwesome';src:url('/fonts/fontawesome-webfont.eot?v=4.3.0');src:url('/fonts/fontawesome-webfont.eot?#iefix&v=4.3.0') format('embedded-opentype'),url('/fonts/fontawesome-webfont.woff2?v=4.3.0') format('woff2'),url('/fonts/fontawesome-webfont.woff?v=4.3.0') format('woff'),url('/fonts/fontawesome-webfont.ttf?v=4.3.0') format('truetype'),url('/fonts/fontawesome-webfont.svg?v=4.3.0#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;transform:translate(0,0)}.fa-lg{font-size:1.3333333333333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.2857142857142858em;text-align:center}.fa-ul{padding-left:0;margin-left:2.142857142857143em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.142857142857143em;width:2.142857142857143em;top:.14285714285714285em;text-align:center}.fa-li.fa-lg{left:-1.8571428571428572em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2);-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=0,mirror=1);-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.fa-flip-vertical{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2,mirror=1);-webkit-transform:scale(1,-1);-ms-transform:scale(1,-1);transform:scale(1,-1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-remove:before,.fa-close:before,.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook-f:before,.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{content:"\f09c"}.fa-credit-card:before{content:"\f09d"}.fa-rss:before{content:"\f09e"}.fa-hdd-o:before{content:"\f0a0"}.fa-bullhorn:before{content:"\f0a1"}.fa-bell:before{content:"\f0f3"}.fa-certificate:before{content:"\f0a3"}.fa-hand-o-right:before{content:"\f0a4"}.fa-hand-o-left:before{content:"\f0a5"}.fa-hand-o-up:before{content:"\f0a6"}.fa-hand-o-down:before{content:"\f0a7"}.fa-arrow-circle-left:before{content:"\f0a8"}.fa-arrow-circle-right:before{content:"\f0a9"}.fa-arrow-circle-up:before{content:"\f0aa"}.fa-arrow-circle-down:before{content:"\f0ab"}.fa-globe:before{content:"\f0ac"}.fa-wrench:before{content:"\f0ad"}.fa-tasks:before{content:"\f0ae"}.fa-filter:before{content:"\f0b0"}.fa-briefcase:before{content:"\f0b1"}.fa-arrows-alt:before{content:"\f0b2"}.fa-group:before,.fa-users:before{content:"\f0c0"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-cloud:before{content:"\f0c2"}.fa-flask:before{content:"\f0c3"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-copy:before,.fa-files-o:before{content:"\f0c5"}.fa-paperclip:before{content:"\f0c6"}.fa-save:before,.fa-floppy-o:before{content:"\f0c7"}.fa-square:before{content:"\f0c8"}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:"\f0c9"}.fa-list-ul:before{content:"\f0ca"}.fa-list-ol:before{content:"\f0cb"}.fa-strikethrough:before{content:"\f0cc"}.fa-underline:before{content:"\f0cd"}.fa-table:before{content:"\f0ce"}.fa-magic:before{content:"\f0d0"}.fa-truck:before{content:"\f0d1"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-google-plus-square:before{content:"\f0d4"}.fa-google-plus:before{content:"\f0d5"}.fa-money:before{content:"\f0d6"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-columns:before{content:"\f0db"}.fa-unsorted:before,.fa-sort:before{content:"\f0dc"}.fa-sort-down:before,.fa-sort-desc:before{content:"\f0dd"}.fa-sort-up:before,.fa-sort-asc:before{content:"\f0de"}.fa-envelope:before{content:"\f0e0"}.fa-linkedin:before{content:"\f0e1"}.fa-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-legal:before,.fa-gavel:before{content:"\f0e3"}.fa-dashboard:before,.fa-tachometer:before{content:"\f0e4"}.fa-comment-o:before{content:"\f0e5"}.fa-comments-o:before{content:"\f0e6"}.fa-flash:before,.fa-bolt:before{content:"\f0e7"}.fa-sitemap:before{content:"\f0e8"}.fa-umbrella:before{content:"\f0e9"}.fa-paste:before,.fa-clipboard:before{content:"\f0ea"}.fa-lightbulb-o:before{content:"\f0eb"}.fa-exchange:before{content:"\f0ec"}.fa-cloud-download:before{content:"\f0ed"}.fa-cloud-upload:before{content:"\f0ee"}.fa-user-md:before{content:"\f0f0"}.fa-stethoscope:before{content:"\f0f1"}.fa-suitcase:before{content:"\f0f2"}.fa-bell-o:before{content:"\f0a2"}.fa-coffee:before{content:"\f0f4"}.fa-cutlery:before{content:"\f0f5"}.fa-file-text-o:before{content:"\f0f6"}.fa-building-o:before{content:"\f0f7"}.fa-hospital-o:before{content:"\f0f8"}.fa-ambulance:before{content:"\f0f9"}.fa-medkit:before{content:"\f0fa"}.fa-fighter-jet:before{content:"\f0fb"}.fa-beer:before{content:"\f0fc"}.fa-h-square:before{content:"\f0fd"}.fa-plus-square:before{content:"\f0fe"}.fa-angle-double-left:before{content:"\f100"}.fa-angle-double-right:before{content:"\f101"}.fa-angle-double-up:before{content:"\f102"}.fa-angle-double-down:before{content:"\f103"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}.fa-angle-up:before{content:"\f106"}.fa-angle-down:before{content:"\f107"}.fa-desktop:before{content:"\f108"}.fa-laptop:before{content:"\f109"}.fa-tablet:before{content:"\f10a"}.fa-mobile-phone:before,.fa-mobile:before{content:"\f10b"}.fa-circle-o:before{content:"\f10c"}.fa-quote-left:before{content:"\f10d"}.fa-quote-right:before{content:"\f10e"}.fa-spinner:before{content:"\f110"}.fa-circle:before{content:"\f111"}.fa-mail-reply:before,.fa-reply:before{content:"\f112"}.fa-github-alt:before{content:"\f113"}.fa-folder-o:before{content:"\f114"}.fa-folder-open-o:before{content:"\f115"}.fa-smile-o:before{content:"\f118"}.fa-frown-o:before{content:"\f119"}.fa-meh-o:before{content:"\f11a"}.fa-gamepad:before{content:"\f11b"}.fa-keyboard-o:before{content:"\f11c"}.fa-flag-o:before{content:"\f11d"}.fa-flag-checkered:before{content:"\f11e"}.fa-terminal:before{content:"\f120"}.fa-code:before{content:"\f121"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"\f122"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"\f123"}.fa-location-arrow:before{content:"\f124"}.fa-crop:before{content:"\f125"}.fa-code-fork:before{content:"\f126"}.fa-unlink:before,.fa-chain-broken:before{content:"\f127"}.fa-question:before{content:"\f128"}.fa-info:before{content:"\f129"}.fa-exclamation:before{content:"\f12a"}.fa-superscript:before{content:"\f12b"}.fa-subscript:before{content:"\f12c"}.fa-eraser:before{content:"\f12d"}.fa-puzzle-piece:before{content:"\f12e"}.fa-microphone:before{content:"\f130"}.fa-microphone-slash:before{content:"\f131"}.fa-shield:before{content:"\f132"}.fa-calendar-o:before{content:"\f133"}.fa-fire-extinguisher:before{content:"\f134"}.fa-rocket:before{content:"\f135"}.fa-maxcdn:before{content:"\f136"}.fa-chevron-circle-left:before{content:"\f137"}.fa-chevron-circle-right:before{content:"\f138"}.fa-chevron-circle-up:before{content:"\f139"}.fa-chevron-circle-down:before{content:"\f13a"}.fa-html5:before{content:"\f13b"}.fa-css3:before{content:"\f13c"}.fa-anchor:before{content:"\f13d"}.fa-unlock-alt:before{content:"\f13e"}.fa-bullseye:before{content:"\f140"}.fa-ellipsis-h:before{content:"\f141"}.fa-ellipsis-v:before{content:"\f142"}.fa-rss-square:before{content:"\f143"}.fa-play-circle:before{content:"\f144"}.fa-ticket:before{content:"\f145"}.fa-minus-square:before{content:"\f146"}.fa-minus-square-o:before{content:"\f147"}.fa-level-up:before{content:"\f148"}.fa-level-down:before{content:"\f149"}.fa-check-square:before{content:"\f14a"}.fa-pencil-square:before{content:"\f14b"}.fa-external-link-square:before{content:"\f14c"}.fa-share-square:before{content:"\f14d"}.fa-compass:before{content:"\f14e"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"\f150"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"\f151"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"\f152"}.fa-euro:before,.fa-eur:before{content:"\f153"}.fa-gbp:before{content:"\f154"}.fa-dollar:before,.fa-usd:before{content:"\f155"}.fa-rupee:before,.fa-inr:before{content:"\f156"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"\f157"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"\f158"}.fa-won:before,.fa-krw:before{content:"\f159"}.fa-bitcoin:before,.fa-btc:before{content:"\f15a"}.fa-file:before{content:"\f15b"}.fa-file-text:before{content:"\f15c"}.fa-sort-alpha-asc:before{content:"\f15d"}.fa-sort-alpha-desc:before{content:"\f15e"}.fa-sort-amount-asc:before{content:"\f160"}.fa-sort-amount-desc:before{content:"\f161"}.fa-sort-numeric-asc:before{content:"\f162"}.fa-sort-numeric-desc:before{content:"\f163"}.fa-thumbs-up:before{content:"\f164"}.fa-thumbs-down:before{content:"\f165"}.fa-youtube-square:before{content:"\f166"}.fa-youtube:before{content:"\f167"}.fa-xing:before{content:"\f168"}.fa-xing-square:before{content:"\f169"}.fa-youtube-play:before{content:"\f16a"}.fa-dropbox:before{content:"\f16b"}.fa-stack-overflow:before{content:"\f16c"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-adn:before{content:"\f170"}.fa-bitbucket:before{content:"\f171"}.fa-bitbucket-square:before{content:"\f172"}.fa-tumblr:before{content:"\f173"}.fa-tumblr-square:before{content:"\f174"}.fa-long-arrow-down:before{content:"\f175"}.fa-long-arrow-up:before{content:"\f176"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-apple:before{content:"\f179"}.fa-windows:before{content:"\f17a"}.fa-android:before{content:"\f17b"}.fa-linux:before{content:"\f17c"}.fa-dribbble:before{content:"\f17d"}.fa-skype:before{content:"\f17e"}.fa-foursquare:before{content:"\f180"}.fa-trello:before{content:"\f181"}.fa-female:before{content:"\f182"}.fa-male:before{content:"\f183"}.fa-gittip:before,.fa-gratipay:before{content:"\f184"}.fa-sun-o:before{content:"\f185"}.fa-moon-o:before{content:"\f186"}.fa-archive:before{content:"\f187"}.fa-bug:before{content:"\f188"}.fa-vk:before{content:"\f189"}.fa-weibo:before{content:"\f18a"}.fa-renren:before{content:"\f18b"}.fa-pagelines:before{content:"\f18c"}.fa-stack-exchange:before{content:"\f18d"}.fa-arrow-circle-o-right:before{content:"\f18e"}.fa-arrow-circle-o-left:before{content:"\f190"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:"\f191"}.fa-dot-circle-o:before{content:"\f192"}.fa-wheelchair:before{content:"\f193"}.fa-vimeo-square:before{content:"\f194"}.fa-turkish-lira:before,.fa-try:before{content:"\f195"}.fa-plus-square-o:before{content:"\f196"}.fa-space-shuttle:before{content:"\f197"}.fa-slack:before{content:"\f198"}.fa-envelope-square:before{content:"\f199"}.fa-wordpress:before{content:"\f19a"}.fa-openid:before{content:"\f19b"}.fa-institution:before,.fa-bank:before,.fa-university:before{content:"\f19c"}.fa-mortar-board:before,.fa-graduation-cap:before{content:"\f19d"}.fa-yahoo:before{content:"\f19e"}.fa-google:before{content:"\f1a0"}.fa-reddit:before{content:"\f1a1"}.fa-reddit-square:before{content:"\f1a2"}.fa-stumbleupon-circle:before{content:"\f1a3"}.fa-stumbleupon:before{content:"\f1a4"}.fa-delicious:before{content:"\f1a5"}.fa-digg:before{content:"\f1a6"}.fa-pied-piper:before{content:"\f1a7"}.fa-pied-piper-alt:before{content:"\f1a8"}.fa-drupal:before{content:"\f1a9"}.fa-joomla:before{content:"\f1aa"}.fa-language:before{content:"\f1ab"}.fa-fax:before{content:"\f1ac"}.fa-building:before{content:"\f1ad"}.fa-child:before{content:"\f1ae"}.fa-paw:before{content:"\f1b0"}.fa-spoon:before{content:"\f1b1"}.fa-cube:before{content:"\f1b2"}.fa-cubes:before{content:"\f1b3"}.fa-behance:before{content:"\f1b4"}.fa-behance-square:before{content:"\f1b5"}.fa-steam:before{content:"\f1b6"}.fa-steam-square:before{content:"\f1b7"}.fa-recycle:before{content:"\f1b8"}.fa-automobile:before,.fa-car:before{content:"\f1b9"}.fa-cab:before,.fa-taxi:before{content:"\f1ba"}.fa-tree:before{content:"\f1bb"}.fa-spotify:before{content:"\f1bc"}.fa-deviantart:before{content:"\f1bd"}.fa-soundcloud:before{content:"\f1be"}.fa-database:before{content:"\f1c0"}.fa-file-pdf-o:before{content:"\f1c1"}.fa-file-word-o:before{content:"\f1c2"}.fa-file-excel-o:before{content:"\f1c3"}.fa-file-powerpoint-o:before{content:"\f1c4"}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:"\f1c5"}.fa-file-zip-o:before,.fa-file-archive-o:before{content:"\f1c6"}.fa-file-sound-o:before,.fa-file-audio-o:before{content:"\f1c7"}.fa-file-movie-o:before,.fa-file-video-o:before{content:"\f1c8"}.fa-file-code-o:before{content:"\f1c9"}.fa-vine:before{content:"\f1ca"}.fa-codepen:before{content:"\f1cb"}.fa-jsfiddle:before{content:"\f1cc"}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:"\f1cd"}.fa-circle-o-notch:before{content:"\f1ce"}.fa-ra:before,.fa-rebel:before{content:"\f1d0"}.fa-ge:before,.fa-empire:before{content:"\f1d1"}.fa-git-square:before{content:"\f1d2"}.fa-git:before{content:"\f1d3"}.fa-hacker-news:before{content:"\f1d4"}.fa-tencent-weibo:before{content:"\f1d5"}.fa-qq:before{content:"\f1d6"}.fa-wechat:before,.fa-weixin:before{content:"\f1d7"}.fa-send:before,.fa-paper-plane:before{content:"\f1d8"}.fa-send-o:before,.fa-paper-plane-o:before{content:"\f1d9"}.fa-history:before{content:"\f1da"}.fa-genderless:before,.fa-circle-thin:before{content:"\f1db"}.fa-header:before{content:"\f1dc"}.fa-paragraph:before{content:"\f1dd"}.fa-sliders:before{content:"\f1de"}.fa-share-alt:before{content:"\f1e0"}.fa-share-alt-square:before{content:"\f1e1"}.fa-bomb:before{content:"\f1e2"}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:"\f1e3"}.fa-tty:before{content:"\f1e4"}.fa-binoculars:before{content:"\f1e5"}.fa-plug:before{content:"\f1e6"}.fa-slideshare:before{content:"\f1e7"}.fa-twitch:before{content:"\f1e8"}.fa-yelp:before{content:"\f1e9"}.fa-newspaper-o:before{content:"\f1ea"}.fa-wifi:before{content:"\f1eb"}.fa-calculator:before{content:"\f1ec"}.fa-paypal:before{content:"\f1ed"}.fa-google-wallet:before{content:"\f1ee"}.fa-cc-visa:before{content:"\f1f0"}.fa-cc-mastercard:before{content:"\f1f1"}.fa-cc-discover:before{content:"\f1f2"}.fa-cc-amex:before{content:"\f1f3"}.fa-cc-paypal:before{content:"\f1f4"}.fa-cc-stripe:before{content:"\f1f5"}.fa-bell-slash:before{content:"\f1f6"}.fa-bell-slash-o:before{content:"\f1f7"}.fa-trash:before{content:"\f1f8"}.fa-copyright:before{content:"\f1f9"}.fa-at:before{content:"\f1fa"}.fa-eyedropper:before{content:"\f1fb"}.fa-paint-brush:before{content:"\f1fc"}.fa-birthday-cake:before{content:"\f1fd"}.fa-area-chart:before{content:"\f1fe"}.fa-pie-chart:before{content:"\f200"}.fa-line-chart:before{content:"\f201"}.fa-lastfm:before{content:"\f202"}.fa-lastfm-square:before{content:"\f203"}.fa-toggle-off:before{content:"\f204"}.fa-toggle-on:before{content:"\f205"}.fa-bicycle:before{content:"\f206"}.fa-bus:before{content:"\f207"}.fa-ioxhost:before{content:"\f208"}.fa-angellist:before{content:"\f209"}.fa-cc:before{content:"\f20a"}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:"\f20b"}.fa-meanpath:before{content:"\f20c"}.fa-buysellads:before{content:"\f20d"}.fa-connectdevelop:before{content:"\f20e"}.fa-dashcube:before{content:"\f210"}.fa-forumbee:before{content:"\f211"}.fa-leanpub:before{content:"\f212"}.fa-sellsy:before{content:"\f213"}.fa-shirtsinbulk:before{content:"\f214"}.fa-simplybuilt:before{content:"\f215"}.fa-skyatlas:before{content:"\f216"}.fa-cart-plus:before{content:"\f217"}.fa-cart-arrow-down:before{content:"\f218"}.fa-diamond:before{content:"\f219"}.fa-ship:before{content:"\f21a"}.fa-user-secret:before{content:"\f21b"}.fa-motorcycle:before{content:"\f21c"}.fa-street-view:before{content:"\f21d"}.fa-heartbeat:before{content:"\f21e"}.fa-venus:before{content:"\f221"}.fa-mars:before{content:"\f222"}.fa-mercury:before{content:"\f223"}.fa-transgender:before{content:"\f224"}.fa-transgender-alt:before{content:"\f225"}.fa-venus-double:before{content:"\f226"}.fa-mars-double:before{content:"\f227"}.fa-venus-mars:before{content:"\f228"}.fa-mars-stroke:before{content:"\f229"}.fa-mars-stroke-v:before{content:"\f22a"}.fa-mars-stroke-h:before{content:"\f22b"}.fa-neuter:before{content:"\f22c"}.fa-facebook-official:before{content:"\f230"}.fa-pinterest-p:before{content:"\f231"}.fa-whatsapp:before{content:"\f232"}.fa-server:before{content:"\f233"}.fa-user-plus:before{content:"\f234"}.fa-user-times:before{content:"\f235"}.fa-hotel:before,.fa-bed:before{content:"\f236"}.fa-viacoin:before{content:"\f237"}.fa-train:before{content:"\f238"}.fa-subway:before{content:"\f239"}.fa-medium:before{content:"\f23a"}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}html,button,input,select,textarea{font-family:sans-serif}body,form,fieldset,legend,input,select,textarea,button{margin:0}html{font-size:100%}body{font-family:sans-serif;font-size:16px;font-size:1rem;line-height:21px;line-height:1.3125rem;color:#434343;background-color:#fff;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}b,strong{font-weight:700}i,em,.em{font-style:italic}a{color:#669fcf}a:hover{text-decoration:none}a:focus{outline:0}a:active,a:hover{outline:0}p{margin:0 0 1.6em 0}pre{margin:1em 0}ul+p,ul+pre,ol+p,ol+pre{margin-top:0}small{font-size:80%}abbr[title]{border-bottom:1px dotted}audio,canvas,video{display:inline-block;*zoom:1;*display:inline}audio:not([controls]){display:none;height:0}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}dfn{font-style:italic}img{border:0;-ms-interpolation-mode:bicubic}svg:not(:root){overflow:hidden}figure{margin:0}.image-left{margin-right:20px}.image-right{margin-left:20px}h1,h2,h3,h4,h5,h6{line-height:normal;font-weight:normal;margin:0 0 .33em 0}h1,.h1{font-size:40px;font-size:2.5rem}h2,.h2{font-size:32px;font-size:2rem}h3,.h3{font-size:26px;font-size:1.625rem}h4,.h4{font-size:20px;font-size:1.25rem}h5,.h5{font-size:18px;font-size:1.125rem}h6,.h6{font-size:16px;font-size:1rem}.no-style-heading{margin:0;font-size:100%}hr{border:0;background:0;outline:0;background-color:#ddd;margin:2em 0;*margin:1em 0;-moz-box-sizing:content-box;box-sizing:content-box;height:1px}blockquote{font-size:22px;font-size:1.375rem;line-height:32px;line-height:2rem;color:#434343;margin:1em 0;font-style:italic}blockquote p{margin:1em 0}cite{color:#434343;font-style:normal;font-weight:normal;font-size:16px;font-size:1rem;line-height:normal}q{font-style:italic;quotes:none}q:before,q:after{content:'';content:none}mark{background:#ff0;color:#111}code,kbd,pre,samp{word-wrap:break-word;font-family:'courier new',monospace,serif;font-size:13px;font-size:.8125rem;line-height:normal;font-weight:normal;background-color:#f1f1f1;padding:10px}code{color:#111}dl,menu,ol,ul{margin:1em 0}dd,ul ul,ol ol,ul ol,ol ul{margin:0}dt{font-weight:normal}dd{margin-bottom:1em}menu,ol,ul{padding:0 0 0 22px}nav ul,nav ol{list-style:none;list-style-image:none}.unstyled-list{list-style:none;padding:0;margin:0}.unstyled-list li{margin-top:0;margin-bottom:0}.inline-list{list-style:none;padding:0;margin:0;display:inline-block;*zoom:1;*display:inline}.inline-list li{margin-top:0;margin-bottom:0}.inline-list li{display:inline-block;*zoom:1;*display:inline}table{width:100%;margin:1em 0;table-layout:fixed;border-collapse:collapse;border-spacing:0;border-right:1px solid #f1f1f1;border-bottom:1px solid #f1f1f1;word-wrap:break-word;-ms-word-wrap:break-word;*white-space:normal}table th,table td{padding:8px;text-align:left;vertical-align:top;border-top:1px solid #eee;border-left:1px solid #eee}table thead th,table tfoot th{vertical-align:bottom;font-weight:normal;background-color:#f1f1f1;color:#333}table caption{padding:8px;font-style:normal;text-align:left;font-weight:normal;border-bottom:0}fieldset{border:0;padding:0}legend{border:0;padding:0;white-space:normal;*margin-left:-7px;font-weight:normal}label{margin:0;cursor:pointer}button,input,select,textarea{font-size:100%;vertical-align:baseline;*vertical-align:middle}input[type=text],input[type=password],input[type=email],input[type=search],input[type=tel],textarea{padding:5px;-webkit-appearance:none;-moz-appearance:none;font-weight:normal;line-height:normal;background-color:#fff;border:1px solid #ccc;color:#111}input[type=checkbox],input[type=radio]{cursor:pointer;box-sizing:border-box;line-height:normal;margin:0;padding:0;*height:13px;*width:13px}.checkbox{display:block;margin:.2em 0}.checkbox input[type=checkbox],.checkbox input[type=radio]{margin-top:.05em;float:left}.checkbox label{padding-left:5px;overflow:hidden;display:table;*zoom:1}button,input{line-height:normal}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer;*overflow:visible}button[disabled],html input[disabled]{cursor:default}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top;resize:none}.button{border:0;padding:1em 3em;background-color:#e74b3c;color:#fff;text-decoration:none;text-align:center;display:inline-block;*zoom:1;*display:inline;position:relative}.button:hover{background-color:#fc5547}.button:active{top:1px}.grey-button{background-color:#eee;color:#434343}.grey-button:hover{background-color:#f1f1f1}.button[disabled],.button.disabled{color:#999;background-color:#f1f1f1}.unstyled-button{font-size:16px;font-size:1rem;color:#27ae61;text-decoration:underline;border:0;background:transparent;height:auto;padding:0;cursor:pointer;outline:0}.unstyled-button:hover{text-decoration:none}.unstyled-button[disabled],.unstyled-button.disabled{text-decoration:none;color:#999;background-color:#ccc}.section{position:relative}.container{max-width:960px;margin-left:auto;margin-right:auto;padding-left:10px;padding-right:10px}.container-full{max-width:960px;margin-left:auto;margin-right:auto}.col{float:left;padding-left:10px;padding-right:10px}[class*="pull-"],[class*="push-"]{position:relative}.no-gutter{padding-left:0;padding-right:0}.col-1{width:8.33333%;width:calc(8.333333333333334%);width:-webkit-calc(8.333333333333334%);width:-moz-calc(8.333333333333334%)}.col-2{width:16.66667%;width:calc(16.666666666666668%);width:-webkit-calc(16.666666666666668%);width:-moz-calc(16.666666666666668%)}.col-3{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.col-4{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.col-5{width:41.66665%;width:calc(41.66666666666667%);width:-webkit-calc(41.66666666666667%);width:-moz-calc(41.66666666666667%)}.col-6{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.col-7{width:58.33333%;width:calc(58.333333333333336%);width:-webkit-calc(58.333333333333336%);width:-moz-calc(58.333333333333336%)}.col-8{width:66.66666%;width:calc(66.66666666666667%);width:-webkit-calc(66.66666666666667%);width:-moz-calc(66.66666666666667%)}.col-9{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.col-10{width:83.33333%;width:calc(83.33333333333334%);width:-webkit-calc(83.33333333333334%);width:-moz-calc(83.33333333333334%)}.col-11{width:91.66666%;width:calc(91.66666666666667%);width:-webkit-calc(91.66666666666667%);width:-moz-calc(91.66666666666667%)}.col-12{width:100%}.col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.push-1{left:8.33333%;left:calc(8.333333333333334%);left:-webkit-calc(8.333333333333334%);left:-moz-calc(8.333333333333334%)}.pull-1{left:-8.33333%;left:calc(-8.333333333333334%);left:-webkit-calc(-8.333333333333334%);left:-moz-calc(-8.333333333333334%)}.push-2{left:16.66667%;left:calc(16.666666666666668%);left:-webkit-calc(16.666666666666668%);left:-moz-calc(16.666666666666668%)}.pull-2{left:-16.66667%;left:calc(-16.666666666666668%);left:-webkit-calc(-16.666666666666668%);left:-moz-calc(-16.666666666666668%)}.push-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.pull-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.push-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.pull-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.push-5{left:41.66665%;left:calc(41.66666666666667%);left:-webkit-calc(41.66666666666667%);left:-moz-calc(41.66666666666667%)}.pull-5{left:-41.66665%;left:calc(-41.66666666666667%);left:-webkit-calc(-41.66666666666667%);left:-moz-calc(-41.66666666666667%)}.push-6{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.pull-6{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.push-7{left:58.33333%;left:calc(58.333333333333336%);left:-webkit-calc(58.333333333333336%);left:-moz-calc(58.333333333333336%)}.pull-7{left:-58.33333%;left:calc(-58.333333333333336%);left:-webkit-calc(-58.333333333333336%);left:-moz-calc(-58.333333333333336%)}.push-8{left:66.66666%;left:calc(66.66666666666667%);left:-webkit-calc(66.66666666666667%);left:-moz-calc(66.66666666666667%)}.pull-8{left:-66.66666%;left:calc(-66.66666666666667%);left:-webkit-calc(-66.66666666666667%);left:-moz-calc(-66.66666666666667%)}.push-9{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.pull-9{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.push-10{left:83.33333%;left:calc(83.33333333333334%);left:-webkit-calc(83.33333333333334%);left:-moz-calc(83.33333333333334%)}.pull-10{left:-83.33333%;left:calc(-83.33333333333334%);left:-webkit-calc(-83.33333333333334%);left:-moz-calc(-83.33333333333334%)}.push-11{left:91.66666%;left:calc(91.66666666666667%);left:-webkit-calc(91.66666666666667%);left:-moz-calc(91.66666666666667%)}.pull-11{left:-91.66666%;left:calc(-91.66666666666667%);left:-webkit-calc(-91.66666666666667%);left:-moz-calc(-91.66666666666667%)}.row{padding-top:1em;padding-bottom:1em}.clear:before,.clear:after{content:"";display:table}.clear:after{clear:both}.clear{zoom:1}.left{float:left}.right{float:right}.block{display:block}.inline{display:inline}.inline-block{display:inline-block;*zoom:1;*display:inline}.none,.hidden,[hidden],.no-desktop{display:none}.heavy{font-weight:900}.strong{font-weight:700}.normal{font-weight:normal}.thin{font-weight:300}.fine{font-weight:100}.italic{font-style:italic}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.left-text{text-align:left}.right-text{text-align:right}.center-text{text-align:center}.justify-text{text-align:justify}.visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;overflow:hidden;padding:0;position:absolute;width:1px;left:-9999em}.visuallyvisible{clip:auto;width:auto;height:auto;overflow:visible;left:0}.no-margin{margin:0}.no-padding{padding:0}@media only screen and (min-width:740px) and (max-width:960px){.container,.tablet-container{max-width:960px;padding-left:20px;padding-right:20px;margin-left:auto;margin-right:auto;float:none}.container:first-child,.tablet-container:first-child{margin-left:auto}.tablet-container-full{padding-left:0;padding-right:0;margin-left:auto;margin-right:auto;float:none}.tablet-container-full:first-child{margin-left:auto}.tablet-no-gutter{padding-left:0;padding-right:0}.tablet-col-1{width:8.33333%;width:calc(8.333333333333334%);width:-webkit-calc(8.333333333333334%);width:-moz-calc(8.333333333333334%)}.tablet-col-2{width:16.66667%;width:calc(16.666666666666668%);width:-webkit-calc(16.666666666666668%);width:-moz-calc(16.666666666666668%)}.tablet-col-3{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.tablet-col-4{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.tablet-col-5{width:41.66665%;width:calc(41.66666666666667%);width:-webkit-calc(41.66666666666667%);width:-moz-calc(41.66666666666667%)}.tablet-col-6{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.tablet-col-7{width:58.33333%;width:calc(58.333333333333336%);width:-webkit-calc(58.333333333333336%);width:-moz-calc(58.333333333333336%)}.tablet-col-8{width:66.66666%;width:calc(66.66666666666667%);width:-webkit-calc(66.66666666666667%);width:-moz-calc(66.66666666666667%)}.tablet-col-9{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.tablet-col-10{width:83.33333%;width:calc(83.33333333333334%);width:-webkit-calc(83.33333333333334%);width:-moz-calc(83.33333333333334%)}.tablet-col-11{width:91.66666%;width:calc(91.66666666666667%);width:-webkit-calc(91.66666666666667%);width:-moz-calc(91.66666666666667%)}.tablet-col-12{width:100%}.tablet-col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.tablet-col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.tablet-col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.tablet-col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.tablet-push-1{left:8.33333%;left:calc(8.333333333333334%);left:-webkit-calc(8.333333333333334%);left:-moz-calc(8.333333333333334%)}.tablet-pull-1{left:-8.33333%;left:calc(-8.333333333333334%);left:-webkit-calc(-8.333333333333334%);left:-moz-calc(-8.333333333333334%)}.tablet-push-2{left:16.66667%;left:calc(16.666666666666668%);left:-webkit-calc(16.666666666666668%);left:-moz-calc(16.666666666666668%)}.tablet-pull-2{left:-16.66667%;left:calc(-16.666666666666668%);left:-webkit-calc(-16.666666666666668%);left:-moz-calc(-16.666666666666668%)}.tablet-push-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.tablet-pull-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.tablet-push-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.tablet-pull-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.tablet-push-5{left:41.66665%;left:calc(41.66666666666667%);left:-webkit-calc(41.66666666666667%);left:-moz-calc(41.66666666666667%)}.tablet-pull-5{left:-41.66665%;left:calc(-41.66666666666667%);left:-webkit-calc(-41.66666666666667%);left:-moz-calc(-41.66666666666667%)}.tablet-push-6{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.tablet-pull-6{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.tablet-push-7{left:58.33333%;left:calc(58.333333333333336%);left:-webkit-calc(58.333333333333336%);left:-moz-calc(58.333333333333336%)}.tablet-pull-7{left:-58.33333%;left:calc(-58.333333333333336%);left:-webkit-calc(-58.333333333333336%);left:-moz-calc(-58.333333333333336%)}.tablet-push-8{left:66.66666%;left:calc(66.66666666666667%);left:-webkit-calc(66.66666666666667%);left:-moz-calc(66.66666666666667%)}.tablet-pull-8{left:-66.66666%;left:calc(-66.66666666666667%);left:-webkit-calc(-66.66666666666667%);left:-moz-calc(-66.66666666666667%)}.tablet-push-9{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.tablet-pull-9{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.tablet-push-10{left:83.33333%;left:calc(83.33333333333334%);left:-webkit-calc(83.33333333333334%);left:-moz-calc(83.33333333333334%)}.tablet-pull-10{left:-83.33333%;left:calc(-83.33333333333334%);left:-webkit-calc(-83.33333333333334%);left:-moz-calc(-83.33333333333334%)}.tablet-push-11{left:91.66666%;left:calc(91.66666666666667%);left:-webkit-calc(91.66666666666667%);left:-moz-calc(91.66666666666667%)}.tablet-pull-11{left:-91.66666%;left:calc(-91.66666666666667%);left:-webkit-calc(-91.66666666666667%);left:-moz-calc(-91.66666666666667%)}.tablet-no-push,.tablet-no-pull{left:auto}.tablet-row{padding-top:1em;padding-bottom:1em}.tablet-full{left:auto;clear:both;float:none;width:100%;margin:1em 0 0 0;display:block}.tablet-full:first-child{margin-top:0}.tablet-left-text{text-align:left}.tablet-right-text{text-align:right}.tablet-center-text{text-align:center}.tablet-left{float:left}.tablet-right{float:right}.tablet-no-float{float:none}.tablet-no-margin{margin:0}.tablet-no-padding{padding:0}.no-tablet{display:none}.show-tablet{display:block}}@media only screen and (max-width:739px){.container,.mobile-container{padding-left:20px;padding-right:20px;margin-left:auto;margin-right:auto;float:none}.container:first-child,.mobile-container:first-child{margin-left:auto}.mobile-container-full{padding-left:0;padding-right:0;margin-left:auto;margin-right:auto;float:none}.mobile-container-full:first-child{margin-left:auto}.mobile-no-gutter{padding-left:0;padding-right:0}.mobile-col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.mobile-col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.mobile-col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.mobile-col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.mobile-push-1-2{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.mobile-pull-1-2{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.mobile-push-1-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.mobile-pull-1-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.mobile-push-1-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.mobile-pull-1-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.mobile-push-3-4{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.mobile-pull-3-4{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.mobile-no-push,.mobile-no-pull{left:auto}.mobile-row{padding-top:1em;padding-bottom:1em}.mobile-full{left:auto;clear:both;float:none;width:100%;margin:.2em 0 0 0;display:block}.mobile-full:first-child{margin-top:0}.mobile-left-text{text-align:left}.mobile-right-text{text-align:right}.mobile-center-text{text-align:center}.mobile-left{float:left}.mobile-right{float:right}.mobile-no-float{float:none}.mobile-no-margin{margin:0}.mobile-no-padding{padding:0}table th,table td{padding:4px}.no-mobile{display:none}.show-mobile{display:block}}@media print{*{background:transparent}a,a:visited{text-decoration:underline}abbr[title]:after{content:" (" attr(title) ")"}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100%}@page{margin:.5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}}html,body{height:100%}.absolute{position:absolute}.relative{position:relative}.full{width:100%}.no-scroll{overflow:hidden}.table{display:table;margin:0 auto}.xlarge-top{margin-top:60px}.large-top{margin-top:40px}.medium-top{margin-top:20px}.small-top{margin-top:10px}.mini-top{margin-top:5px}.no-left-padding{padding-left:0}.no-right-padding{padding-right:0}@media only screen and (max-width:739px){.mobile-hide{display:none}.mobile-xlarge-top{margin-top:60px}.mobile-large-top{margin-top:40px}.mobile-medium-top{margin-top:20px}.mobile-small-top{margin-top:10px}.mobile-mini-top{margin-top:5px}}html,body{font-family:'Roboto','Helvetica Neue','Arial','Helvetica','Lucida Grande',sans-serif;font-weight:300;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}h1,h2,h3,h4,h5{font-weight:300}p{margin:0 0 1em 0}pre,code{padding:5px 10px;color:#6e6e6e;font-size:14px;line-height:20px;font-weight:100;background:#f8f8f8;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}a{color:#333;text-decoration:none;-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out}a.active{color:#000}a:hover{color:#000}a:hover .fa-trash-o{color:#e2717f}a.primary{color:#e2717f}a.primary:hover{color:#d94759}img{max-width:100%}hr{margin:.5em 0;width:100%}i.right-padding{padding-right:10px}i.left-padding{padding-left:10px}.button{outline:0;padding:1em 1.5em;background:#fafafa;color:#333;white-space:nowrap;background-clip:padding-box;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.button.disabled,.button[disabled]{-moz-opacity:.7;-khtml-opacity:.7;-webkit-opacity:.7;opacity:.7;-ms-filter:alpha(opacity=70);filter:alpha(opacity=70);cursor:default}.button:hover:not(.disabled),.button:hover:not([disabled]){background:#d9d9d9}.button.large{padding:1em 4em}.button.small{padding:.6em .8em}.button.x-small{padding:.4em .6em}.button.primary-button{color:#fff;background:#e2717f}.button.primary-button:hover,.button.primary-button:focus{color:#f2f2f2;background:#de5c6c}.button.primary-button:hover.disabled,.button.primary-button:focus.disabled,.button.primary-button:hover:disabled,.button.primary-button:focus:disabled{background:#e2717f}.button.secondary-button{background:0;border:1px solid #eee}.button.secondary-button:hover:not(.active),.button.secondary-button:hover:not(.disabled),.button.secondary-button:hover:not(:disabled),.button.secondary-button:focus:not(.active),.button.secondary-button:focus:not(.disabled),.button.secondary-button:focus:not(:disabled){color:#666;background:#f8f8f8}.button.secondary-button.active{color:#595959;background:#ebebeb;border:1px solid #eee}.button.secondary-button.active:hover{color:#595959;background:#ebebeb;border:1px solid #eee}.button.remove-button{background:#e2717f;color:#fff;padding:.9em 1.5em}.button.remove-button:hover,.button.remove-button:focus{background:#de5c6c}.button.remove-button:hover.disabled,.button.remove-button:focus.disabled,.button.remove-button:hover:disabled,.button.remove-button:focus:disabled{background:#e2717f}.button.transparent-button{background:0;color:#fff;border:1px solid #f2f2f2}.button.transparent-button:hover:not(.disabled),.button.transparent-button:hover:not(:disabled){background:rgba(255,255,255,0.1);color:#fff}.button-group>.button{padding:.8em 1em;text-align:center;background:#fff;border-top:1px solid #eee;border-bottom:1px solid #eee;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.button-group>.button i.fa{margin-right:5px}.button-group>.button:first-child{border-left:1px solid #eee;-webkit-border-top-right-radius:0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:5px;-webkit-border-top-left-radius:5px;-moz-border-radius-topright:0;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:5px;-moz-border-radius-topleft:5px;border-top-right-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:5px;border-top-left-radius:5px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.button-group>.button:last-child{border-right:1px solid #eee;-webkit-border-top-right-radius:5px;-webkit-border-bottom-right-radius:5px;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:0;-moz-border-radius-topright:5px;-moz-border-radius-bottomright:5px;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:0;border-top-right-radius:5px;border-bottom-right-radius:5px;border-bottom-left-radius:0;border-top-left-radius:0;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.button-group>.button:hover:not(.active),.button-group>.button:focus:not(.active){color:#666;background:#f8f8f8}.button-group>.button.active{color:#595959;background:#ebebeb;border:1px solid #eee}.button-group>.button.active:hover{color:#595959;background:#ebebeb;border:1px solid #eee}.button-group.small>.button{padding:.6em .8em}.button-group.x-small>.button{padding:.4em .6em}form .col,form .input-wrapper{position:relative}form input,form input[type="text"],form input[type="password"],form input[type="email"],form input[type="search"],form input[type="tel"],form input[type="number"],form input[type="date"],form textarea{width:100%;padding:.8em .6em .6em;outline:0;border:1px solid #d3d3d3;font-size:1.1em;line-height:1;background:#fff;color:#666;-webkit-appearance:none;-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out}form input:focus,form input[type="text"]:focus,form input[type="password"]:focus,form input[type="email"]:focus,form input[type="search"]:focus,form input[type="tel"]:focus,form input[type="number"]:focus,form input[type="date"]:focus,form textarea:focus{color:#333;border:1px solid #a0a0a0;-moz-box-shadow:0 0 2px #a0a0a0;-webkit-box-shadow:0 0 2px #a0a0a0;box-shadow:0 0 2px #a0a0a0;-webkit-box-shadow:0 0 2px #a0a0a0 0 0 #000;box-shadow:0 0 2px #a0a0a0 0 0 #000}form input:focus+label,form input[type="text"]:focus+label,form input[type="password"]:focus+label,form input[type="email"]:focus+label,form input[type="search"]:focus+label,form input[type="tel"]:focus+label,form input[type="number"]:focus+label,form input[type="date"]:focus+label,form textarea:focus+label{color:#666;font-weight:400}form input.success,form input[type="text"].success,form input[type="password"].success,form input[type="email"].success,form input[type="search"].success,form input[type="tel"].success,form input[type="number"].success,form input[type="date"].success,form textarea.success{border:1px solid #43cea2;-moz-box-shadow:0 0 2px #43cea2;-webkit-box-shadow:0 0 2px #43cea2;box-shadow:0 0 2px #43cea2;-webkit-box-shadow:0 0 2px #43cea2 0 0 #000;box-shadow:0 0 2px #43cea2 0 0 #000}form input.success+label,form input[type="text"].success+label,form input[type="password"].success+label,form input[type="email"].success+label,form input[type="search"].success+label,form input[type="tel"].success+label,form input[type="number"].success+label,form input[type="date"].success+label,form textarea.success+label{color:#43cea2;font-weight:400}form input.error,form input[type="text"].error,form input[type="password"].error,form input[type="email"].error,form input[type="search"].error,form input[type="tel"].error,form input[type="number"].error,form input[type="date"].error,form textarea.error{border:1px solid #e2717f;-moz-box-shadow:0 0 2px #e2717f;-webkit-box-shadow:0 0 2px #e2717f;box-shadow:0 0 2px #e2717f;-webkit-box-shadow:0 0 2px #e2717f 0 0 #000;box-shadow:0 0 2px #e2717f 0 0 #000}form input.error+label,form input[type="text"].error+label,form input[type="password"].error+label,form input[type="email"].error+label,form input[type="search"].error+label,form input[type="tel"].error+label,form input[type="number"].error+label,form input[type="date"].error+label,form textarea.error+label{color:#e2717f;font-weight:400}form input::-webkit-input-placeholder,form input[type="text"]::-webkit-input-placeholder,form input[type="password"]::-webkit-input-placeholder,form input[type="email"]::-webkit-input-placeholder,form input[type="search"]::-webkit-input-placeholder,form input[type="tel"]::-webkit-input-placeholder,form input[type="number"]::-webkit-input-placeholder,form input[type="date"]::-webkit-input-placeholder,form textarea::-webkit-input-placeholder{color:#d3d3d3;font-weight:300}form [placeholder]:focus::-webkit-input-placeholder{-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out;opacity:0}form input[type="number"]::-webkit-inner-spin-button,form input[type="number"]::-webkit-outer-spin-button,form input[type="date"]::-webkit-inner-spin-button,form input[type="date"]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}form .select-style{position:relative;display:block;width:100%;border:1px solid #a0a0a0;background:#fff}form .select-style .fa-caret-down{position:absolute;right:.6em;top:.8em;color:#a0a0a0;font-size:1.4em}form .select-style select{padding:.8em 0;margin-left:.6em;width:100%;border:0;box-shadow:none;background:transparent;background-image:none;-webkit-appearance:none;color:#a0a0a0;font-size:1.2em}form .select-style select:hover{cursor:pointer}form .select-style select:focus{outline:0}form fieldset.row{padding:.5em 0}form label{position:absolute;left:5px;top:-5px;padding:0 5px;background:white;color:#a0a0a0;font-size:12px;line-height:12px;text-transform:uppercase;pointer-events:none;z-index:2}.modal-wrapper{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.3);display:none;z-index:1001;will-change:transform}.modal-wrapper .modal{position:relative;color:#333;display:none}.modal-wrapper .modal a.close{position:absolute;padding:6px 12px 9px;border:1px solid;border-radius:20px;font-weight:300;font-size:27px}.modal-wrapper .modal section.modal-content{padding:20px}.modal-wrapper:not(.fullscreen) .modal{min-height:300px;max-width:434px;margin:60px auto 0;background-color:#fff;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.modal-wrapper:not(.fullscreen) .modal a.close{right:-45px;top:-30px;color:#fff}.modal-wrapper.fullscreen{background:#fff}.modal-wrapper.fullscreen .modal{height:100%;overflow:auto}.modal-wrapper.fullscreen .modal a.close{right:20px;top:20px}.notice{position:fixed;bottom:0;right:10px;height:100px;width:300px;padding:5px 10px 5px 10px;display:none;color:#fff;z-index:1005;-webkit-border-top-right-radius:5px;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:5px;-moz-border-radius-topright:5px;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:5px;border-top-right-radius:5px;border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-left-radius:5px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.notice.success{background-color:#43cea2}.notice.warning{background-color:#f4ed6b}.notice.error{background-color:#e2717f}.notice header.notice-header{position:relative;margin-bottom:.2em}.notice section.notice-content{height:70px;width:100%;overflow:auto;font-size:.8em}.notice a.close{position:absolute;top:3px;right:0;padding:0 4px 2px;border:1px solid;border-radius:100%;font-weight:300;font-size:12px;line-height:12px;color:#fff}.notice a.close:hover{color:#ccc}nav{font-size:18px;font-size:1.125rem}nav .navbar{margin:0 auto;display:table;padding:10px 0}nav li{margin:0 10px}nav a{display:inline-block;line-height:60px;vertical-align:middle}nav a.logo{height:60px;width:60px}@media(max-width:739px){nav{font-size:14px;font-size:.875rem}nav a{line-height:40px}nav a.logo{height:40px;width:40px}}#toc{position:fixed;top:80px;height:100%;width:220px;overflow:auto;padding-bottom:100px}#toc a{color:#333}#toc a:hover{color:#1a1a1a}#toc li>ul{display:none}#toc li>ul.unstyled-list{margin-left:10px}#toc li.active>a{font-weight:bold}#toc li.active>ul{display:block}#toc ul.nav>li.active>ul>li{list-style:none}footer{padding:60px 0;color:#d3d3d3;background:#333}footer i.fa-heart{color:#e2717f}footer i.fa-beer{color:#f4ed6b}html,body{background:#fff;color:#333}.kd{color:#a783b6}.k{color:#43cea2}h1.logo{font-size:64px;font-size:4rem}.gist pre,.gist .file-data{font-size:14px!important}section{padding:40px 0}code{padding:0}#hero .badges,#hero .github-links{padding:.3em 0}#hero .badges p,#hero .github-links p{margin:0}#ship h3{margin-bottom:1em}#ship img.ship-it{display:table;height:300px;width:300px;margin:0 auto;background:#d3d3d3;-webkit-border-radius:100%;-moz-border-radius:100%;border-radius:100%}#plugins{color:#fff;background:#333}#plugins p{color:#d3d3d3}#plugins ul li{padding:10px 20px}#plugins ul li a{display:inline-block}#plugins ul li a img{height:100px;max-width:160px}@media(max-width:739px){#plugins ul li a img{height:60px;max-width:120px}}#features{color:#fff;background:#e2717f}#features h4{color:#982e3e}#features a.primary{color:#f8f8f8;border-bottom:1px dashed #f8f8f8}#features a.primary:hover{color:#dfdfdf;border-bottom:1px dashed #dfdfdf}#comparison img{margin:0 auto}.example,.example .row{padding-bottom:0}.page,.example{margin-bottom:0}.page a,.example a{color:#e2717f}.page a:hover,.example a:hover{color:#d94759}.page .file-data .line-numbers,.example .file-data .line-numbers{width:40px}#todo-example{padding-bottom:2em}#todo-example input[type="text"]{margin:10px 0}#todo-example ul.todos{height:320px}#todo-example ul.todos li{padding:5px 0}#todo-example ul.todos li input[type="checkbox"]{margin-top:.2em}#todo-example ul.todos li span{margin-left:5px}#todo-example ul.todos li.done label{text-decoration:line-through;color:#998}#todo-example ul.todos li .delete{font-weight:bold}#todo-example label{float:left}#todo-example .primary-button{width:100%} \ No newline at end of file + */@font-face{font-family:'FontAwesome';src:url('/fonts/fontawesome-webfont.eot?v=4.3.0');src:url('/fonts/fontawesome-webfont.eot?#iefix&v=4.3.0') format('embedded-opentype'),url('/fonts/fontawesome-webfont.woff2?v=4.3.0') format('woff2'),url('/fonts/fontawesome-webfont.woff?v=4.3.0') format('woff'),url('/fonts/fontawesome-webfont.ttf?v=4.3.0') format('truetype'),url('/fonts/fontawesome-webfont.svg?v=4.3.0#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;transform:translate(0,0)}.fa-lg{font-size:1.3333333333333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.2857142857142858em;text-align:center}.fa-ul{padding-left:0;margin-left:2.142857142857143em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.142857142857143em;width:2.142857142857143em;top:.14285714285714285em;text-align:center}.fa-li.fa-lg{left:-1.8571428571428572em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2);-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=0,mirror=1);-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.fa-flip-vertical{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2,mirror=1);-webkit-transform:scale(1,-1);-ms-transform:scale(1,-1);transform:scale(1,-1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-remove:before,.fa-close:before,.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook-f:before,.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{content:"\f09c"}.fa-credit-card:before{content:"\f09d"}.fa-rss:before{content:"\f09e"}.fa-hdd-o:before{content:"\f0a0"}.fa-bullhorn:before{content:"\f0a1"}.fa-bell:before{content:"\f0f3"}.fa-certificate:before{content:"\f0a3"}.fa-hand-o-right:before{content:"\f0a4"}.fa-hand-o-left:before{content:"\f0a5"}.fa-hand-o-up:before{content:"\f0a6"}.fa-hand-o-down:before{content:"\f0a7"}.fa-arrow-circle-left:before{content:"\f0a8"}.fa-arrow-circle-right:before{content:"\f0a9"}.fa-arrow-circle-up:before{content:"\f0aa"}.fa-arrow-circle-down:before{content:"\f0ab"}.fa-globe:before{content:"\f0ac"}.fa-wrench:before{content:"\f0ad"}.fa-tasks:before{content:"\f0ae"}.fa-filter:before{content:"\f0b0"}.fa-briefcase:before{content:"\f0b1"}.fa-arrows-alt:before{content:"\f0b2"}.fa-group:before,.fa-users:before{content:"\f0c0"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-cloud:before{content:"\f0c2"}.fa-flask:before{content:"\f0c3"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-copy:before,.fa-files-o:before{content:"\f0c5"}.fa-paperclip:before{content:"\f0c6"}.fa-save:before,.fa-floppy-o:before{content:"\f0c7"}.fa-square:before{content:"\f0c8"}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:"\f0c9"}.fa-list-ul:before{content:"\f0ca"}.fa-list-ol:before{content:"\f0cb"}.fa-strikethrough:before{content:"\f0cc"}.fa-underline:before{content:"\f0cd"}.fa-table:before{content:"\f0ce"}.fa-magic:before{content:"\f0d0"}.fa-truck:before{content:"\f0d1"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-google-plus-square:before{content:"\f0d4"}.fa-google-plus:before{content:"\f0d5"}.fa-money:before{content:"\f0d6"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-columns:before{content:"\f0db"}.fa-unsorted:before,.fa-sort:before{content:"\f0dc"}.fa-sort-down:before,.fa-sort-desc:before{content:"\f0dd"}.fa-sort-up:before,.fa-sort-asc:before{content:"\f0de"}.fa-envelope:before{content:"\f0e0"}.fa-linkedin:before{content:"\f0e1"}.fa-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-legal:before,.fa-gavel:before{content:"\f0e3"}.fa-dashboard:before,.fa-tachometer:before{content:"\f0e4"}.fa-comment-o:before{content:"\f0e5"}.fa-comments-o:before{content:"\f0e6"}.fa-flash:before,.fa-bolt:before{content:"\f0e7"}.fa-sitemap:before{content:"\f0e8"}.fa-umbrella:before{content:"\f0e9"}.fa-paste:before,.fa-clipboard:before{content:"\f0ea"}.fa-lightbulb-o:before{content:"\f0eb"}.fa-exchange:before{content:"\f0ec"}.fa-cloud-download:before{content:"\f0ed"}.fa-cloud-upload:before{content:"\f0ee"}.fa-user-md:before{content:"\f0f0"}.fa-stethoscope:before{content:"\f0f1"}.fa-suitcase:before{content:"\f0f2"}.fa-bell-o:before{content:"\f0a2"}.fa-coffee:before{content:"\f0f4"}.fa-cutlery:before{content:"\f0f5"}.fa-file-text-o:before{content:"\f0f6"}.fa-building-o:before{content:"\f0f7"}.fa-hospital-o:before{content:"\f0f8"}.fa-ambulance:before{content:"\f0f9"}.fa-medkit:before{content:"\f0fa"}.fa-fighter-jet:before{content:"\f0fb"}.fa-beer:before{content:"\f0fc"}.fa-h-square:before{content:"\f0fd"}.fa-plus-square:before{content:"\f0fe"}.fa-angle-double-left:before{content:"\f100"}.fa-angle-double-right:before{content:"\f101"}.fa-angle-double-up:before{content:"\f102"}.fa-angle-double-down:before{content:"\f103"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}.fa-angle-up:before{content:"\f106"}.fa-angle-down:before{content:"\f107"}.fa-desktop:before{content:"\f108"}.fa-laptop:before{content:"\f109"}.fa-tablet:before{content:"\f10a"}.fa-mobile-phone:before,.fa-mobile:before{content:"\f10b"}.fa-circle-o:before{content:"\f10c"}.fa-quote-left:before{content:"\f10d"}.fa-quote-right:before{content:"\f10e"}.fa-spinner:before{content:"\f110"}.fa-circle:before{content:"\f111"}.fa-mail-reply:before,.fa-reply:before{content:"\f112"}.fa-github-alt:before{content:"\f113"}.fa-folder-o:before{content:"\f114"}.fa-folder-open-o:before{content:"\f115"}.fa-smile-o:before{content:"\f118"}.fa-frown-o:before{content:"\f119"}.fa-meh-o:before{content:"\f11a"}.fa-gamepad:before{content:"\f11b"}.fa-keyboard-o:before{content:"\f11c"}.fa-flag-o:before{content:"\f11d"}.fa-flag-checkered:before{content:"\f11e"}.fa-terminal:before{content:"\f120"}.fa-code:before{content:"\f121"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"\f122"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"\f123"}.fa-location-arrow:before{content:"\f124"}.fa-crop:before{content:"\f125"}.fa-code-fork:before{content:"\f126"}.fa-unlink:before,.fa-chain-broken:before{content:"\f127"}.fa-question:before{content:"\f128"}.fa-info:before{content:"\f129"}.fa-exclamation:before{content:"\f12a"}.fa-superscript:before{content:"\f12b"}.fa-subscript:before{content:"\f12c"}.fa-eraser:before{content:"\f12d"}.fa-puzzle-piece:before{content:"\f12e"}.fa-microphone:before{content:"\f130"}.fa-microphone-slash:before{content:"\f131"}.fa-shield:before{content:"\f132"}.fa-calendar-o:before{content:"\f133"}.fa-fire-extinguisher:before{content:"\f134"}.fa-rocket:before{content:"\f135"}.fa-maxcdn:before{content:"\f136"}.fa-chevron-circle-left:before{content:"\f137"}.fa-chevron-circle-right:before{content:"\f138"}.fa-chevron-circle-up:before{content:"\f139"}.fa-chevron-circle-down:before{content:"\f13a"}.fa-html5:before{content:"\f13b"}.fa-css3:before{content:"\f13c"}.fa-anchor:before{content:"\f13d"}.fa-unlock-alt:before{content:"\f13e"}.fa-bullseye:before{content:"\f140"}.fa-ellipsis-h:before{content:"\f141"}.fa-ellipsis-v:before{content:"\f142"}.fa-rss-square:before{content:"\f143"}.fa-play-circle:before{content:"\f144"}.fa-ticket:before{content:"\f145"}.fa-minus-square:before{content:"\f146"}.fa-minus-square-o:before{content:"\f147"}.fa-level-up:before{content:"\f148"}.fa-level-down:before{content:"\f149"}.fa-check-square:before{content:"\f14a"}.fa-pencil-square:before{content:"\f14b"}.fa-external-link-square:before{content:"\f14c"}.fa-share-square:before{content:"\f14d"}.fa-compass:before{content:"\f14e"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"\f150"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"\f151"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"\f152"}.fa-euro:before,.fa-eur:before{content:"\f153"}.fa-gbp:before{content:"\f154"}.fa-dollar:before,.fa-usd:before{content:"\f155"}.fa-rupee:before,.fa-inr:before{content:"\f156"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"\f157"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"\f158"}.fa-won:before,.fa-krw:before{content:"\f159"}.fa-bitcoin:before,.fa-btc:before{content:"\f15a"}.fa-file:before{content:"\f15b"}.fa-file-text:before{content:"\f15c"}.fa-sort-alpha-asc:before{content:"\f15d"}.fa-sort-alpha-desc:before{content:"\f15e"}.fa-sort-amount-asc:before{content:"\f160"}.fa-sort-amount-desc:before{content:"\f161"}.fa-sort-numeric-asc:before{content:"\f162"}.fa-sort-numeric-desc:before{content:"\f163"}.fa-thumbs-up:before{content:"\f164"}.fa-thumbs-down:before{content:"\f165"}.fa-youtube-square:before{content:"\f166"}.fa-youtube:before{content:"\f167"}.fa-xing:before{content:"\f168"}.fa-xing-square:before{content:"\f169"}.fa-youtube-play:before{content:"\f16a"}.fa-dropbox:before{content:"\f16b"}.fa-stack-overflow:before{content:"\f16c"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-adn:before{content:"\f170"}.fa-bitbucket:before{content:"\f171"}.fa-bitbucket-square:before{content:"\f172"}.fa-tumblr:before{content:"\f173"}.fa-tumblr-square:before{content:"\f174"}.fa-long-arrow-down:before{content:"\f175"}.fa-long-arrow-up:before{content:"\f176"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-apple:before{content:"\f179"}.fa-windows:before{content:"\f17a"}.fa-android:before{content:"\f17b"}.fa-linux:before{content:"\f17c"}.fa-dribbble:before{content:"\f17d"}.fa-skype:before{content:"\f17e"}.fa-foursquare:before{content:"\f180"}.fa-trello:before{content:"\f181"}.fa-female:before{content:"\f182"}.fa-male:before{content:"\f183"}.fa-gittip:before,.fa-gratipay:before{content:"\f184"}.fa-sun-o:before{content:"\f185"}.fa-moon-o:before{content:"\f186"}.fa-archive:before{content:"\f187"}.fa-bug:before{content:"\f188"}.fa-vk:before{content:"\f189"}.fa-weibo:before{content:"\f18a"}.fa-renren:before{content:"\f18b"}.fa-pagelines:before{content:"\f18c"}.fa-stack-exchange:before{content:"\f18d"}.fa-arrow-circle-o-right:before{content:"\f18e"}.fa-arrow-circle-o-left:before{content:"\f190"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:"\f191"}.fa-dot-circle-o:before{content:"\f192"}.fa-wheelchair:before{content:"\f193"}.fa-vimeo-square:before{content:"\f194"}.fa-turkish-lira:before,.fa-try:before{content:"\f195"}.fa-plus-square-o:before{content:"\f196"}.fa-space-shuttle:before{content:"\f197"}.fa-slack:before{content:"\f198"}.fa-envelope-square:before{content:"\f199"}.fa-wordpress:before{content:"\f19a"}.fa-openid:before{content:"\f19b"}.fa-institution:before,.fa-bank:before,.fa-university:before{content:"\f19c"}.fa-mortar-board:before,.fa-graduation-cap:before{content:"\f19d"}.fa-yahoo:before{content:"\f19e"}.fa-google:before{content:"\f1a0"}.fa-reddit:before{content:"\f1a1"}.fa-reddit-square:before{content:"\f1a2"}.fa-stumbleupon-circle:before{content:"\f1a3"}.fa-stumbleupon:before{content:"\f1a4"}.fa-delicious:before{content:"\f1a5"}.fa-digg:before{content:"\f1a6"}.fa-pied-piper:before{content:"\f1a7"}.fa-pied-piper-alt:before{content:"\f1a8"}.fa-drupal:before{content:"\f1a9"}.fa-joomla:before{content:"\f1aa"}.fa-language:before{content:"\f1ab"}.fa-fax:before{content:"\f1ac"}.fa-building:before{content:"\f1ad"}.fa-child:before{content:"\f1ae"}.fa-paw:before{content:"\f1b0"}.fa-spoon:before{content:"\f1b1"}.fa-cube:before{content:"\f1b2"}.fa-cubes:before{content:"\f1b3"}.fa-behance:before{content:"\f1b4"}.fa-behance-square:before{content:"\f1b5"}.fa-steam:before{content:"\f1b6"}.fa-steam-square:before{content:"\f1b7"}.fa-recycle:before{content:"\f1b8"}.fa-automobile:before,.fa-car:before{content:"\f1b9"}.fa-cab:before,.fa-taxi:before{content:"\f1ba"}.fa-tree:before{content:"\f1bb"}.fa-spotify:before{content:"\f1bc"}.fa-deviantart:before{content:"\f1bd"}.fa-soundcloud:before{content:"\f1be"}.fa-database:before{content:"\f1c0"}.fa-file-pdf-o:before{content:"\f1c1"}.fa-file-word-o:before{content:"\f1c2"}.fa-file-excel-o:before{content:"\f1c3"}.fa-file-powerpoint-o:before{content:"\f1c4"}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:"\f1c5"}.fa-file-zip-o:before,.fa-file-archive-o:before{content:"\f1c6"}.fa-file-sound-o:before,.fa-file-audio-o:before{content:"\f1c7"}.fa-file-movie-o:before,.fa-file-video-o:before{content:"\f1c8"}.fa-file-code-o:before{content:"\f1c9"}.fa-vine:before{content:"\f1ca"}.fa-codepen:before{content:"\f1cb"}.fa-jsfiddle:before{content:"\f1cc"}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:"\f1cd"}.fa-circle-o-notch:before{content:"\f1ce"}.fa-ra:before,.fa-rebel:before{content:"\f1d0"}.fa-ge:before,.fa-empire:before{content:"\f1d1"}.fa-git-square:before{content:"\f1d2"}.fa-git:before{content:"\f1d3"}.fa-hacker-news:before{content:"\f1d4"}.fa-tencent-weibo:before{content:"\f1d5"}.fa-qq:before{content:"\f1d6"}.fa-wechat:before,.fa-weixin:before{content:"\f1d7"}.fa-send:before,.fa-paper-plane:before{content:"\f1d8"}.fa-send-o:before,.fa-paper-plane-o:before{content:"\f1d9"}.fa-history:before{content:"\f1da"}.fa-genderless:before,.fa-circle-thin:before{content:"\f1db"}.fa-header:before{content:"\f1dc"}.fa-paragraph:before{content:"\f1dd"}.fa-sliders:before{content:"\f1de"}.fa-share-alt:before{content:"\f1e0"}.fa-share-alt-square:before{content:"\f1e1"}.fa-bomb:before{content:"\f1e2"}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:"\f1e3"}.fa-tty:before{content:"\f1e4"}.fa-binoculars:before{content:"\f1e5"}.fa-plug:before{content:"\f1e6"}.fa-slideshare:before{content:"\f1e7"}.fa-twitch:before{content:"\f1e8"}.fa-yelp:before{content:"\f1e9"}.fa-newspaper-o:before{content:"\f1ea"}.fa-wifi:before{content:"\f1eb"}.fa-calculator:before{content:"\f1ec"}.fa-paypal:before{content:"\f1ed"}.fa-google-wallet:before{content:"\f1ee"}.fa-cc-visa:before{content:"\f1f0"}.fa-cc-mastercard:before{content:"\f1f1"}.fa-cc-discover:before{content:"\f1f2"}.fa-cc-amex:before{content:"\f1f3"}.fa-cc-paypal:before{content:"\f1f4"}.fa-cc-stripe:before{content:"\f1f5"}.fa-bell-slash:before{content:"\f1f6"}.fa-bell-slash-o:before{content:"\f1f7"}.fa-trash:before{content:"\f1f8"}.fa-copyright:before{content:"\f1f9"}.fa-at:before{content:"\f1fa"}.fa-eyedropper:before{content:"\f1fb"}.fa-paint-brush:before{content:"\f1fc"}.fa-birthday-cake:before{content:"\f1fd"}.fa-area-chart:before{content:"\f1fe"}.fa-pie-chart:before{content:"\f200"}.fa-line-chart:before{content:"\f201"}.fa-lastfm:before{content:"\f202"}.fa-lastfm-square:before{content:"\f203"}.fa-toggle-off:before{content:"\f204"}.fa-toggle-on:before{content:"\f205"}.fa-bicycle:before{content:"\f206"}.fa-bus:before{content:"\f207"}.fa-ioxhost:before{content:"\f208"}.fa-angellist:before{content:"\f209"}.fa-cc:before{content:"\f20a"}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:"\f20b"}.fa-meanpath:before{content:"\f20c"}.fa-buysellads:before{content:"\f20d"}.fa-connectdevelop:before{content:"\f20e"}.fa-dashcube:before{content:"\f210"}.fa-forumbee:before{content:"\f211"}.fa-leanpub:before{content:"\f212"}.fa-sellsy:before{content:"\f213"}.fa-shirtsinbulk:before{content:"\f214"}.fa-simplybuilt:before{content:"\f215"}.fa-skyatlas:before{content:"\f216"}.fa-cart-plus:before{content:"\f217"}.fa-cart-arrow-down:before{content:"\f218"}.fa-diamond:before{content:"\f219"}.fa-ship:before{content:"\f21a"}.fa-user-secret:before{content:"\f21b"}.fa-motorcycle:before{content:"\f21c"}.fa-street-view:before{content:"\f21d"}.fa-heartbeat:before{content:"\f21e"}.fa-venus:before{content:"\f221"}.fa-mars:before{content:"\f222"}.fa-mercury:before{content:"\f223"}.fa-transgender:before{content:"\f224"}.fa-transgender-alt:before{content:"\f225"}.fa-venus-double:before{content:"\f226"}.fa-mars-double:before{content:"\f227"}.fa-venus-mars:before{content:"\f228"}.fa-mars-stroke:before{content:"\f229"}.fa-mars-stroke-v:before{content:"\f22a"}.fa-mars-stroke-h:before{content:"\f22b"}.fa-neuter:before{content:"\f22c"}.fa-facebook-official:before{content:"\f230"}.fa-pinterest-p:before{content:"\f231"}.fa-whatsapp:before{content:"\f232"}.fa-server:before{content:"\f233"}.fa-user-plus:before{content:"\f234"}.fa-user-times:before{content:"\f235"}.fa-hotel:before,.fa-bed:before{content:"\f236"}.fa-viacoin:before{content:"\f237"}.fa-train:before{content:"\f238"}.fa-subway:before{content:"\f239"}.fa-medium:before{content:"\f23a"}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}html,button,input,select,textarea{font-family:sans-serif}body,form,fieldset,legend,input,select,textarea,button{margin:0}html{font-size:100%}body{font-family:sans-serif;font-size:16px;font-size:1rem;line-height:21px;line-height:1.3125rem;color:#434343;background-color:#fff;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}b,strong{font-weight:700}i,em,.em{font-style:italic}a{color:#669fcf}a:hover{text-decoration:none}a:focus{outline:0}a:active,a:hover{outline:0}p{margin:0 0 1.6em 0}pre{margin:1em 0}ul+p,ul+pre,ol+p,ol+pre{margin-top:0}small{font-size:80%}abbr[title]{border-bottom:1px dotted}audio,canvas,video{display:inline-block;*zoom:1;*display:inline}audio:not([controls]){display:none;height:0}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}dfn{font-style:italic}img{border:0;-ms-interpolation-mode:bicubic}svg:not(:root){overflow:hidden}figure{margin:0}.image-left{margin-right:20px}.image-right{margin-left:20px}h1,h2,h3,h4,h5,h6{line-height:normal;font-weight:normal;margin:0 0 .33em 0}h1,.h1{font-size:40px;font-size:2.5rem}h2,.h2{font-size:32px;font-size:2rem}h3,.h3{font-size:26px;font-size:1.625rem}h4,.h4{font-size:20px;font-size:1.25rem}h5,.h5{font-size:18px;font-size:1.125rem}h6,.h6{font-size:16px;font-size:1rem}.no-style-heading{margin:0;font-size:100%}hr{border:0;background:0;outline:0;background-color:#ddd;margin:2em 0;*margin:1em 0;-moz-box-sizing:content-box;box-sizing:content-box;height:1px}blockquote{font-size:22px;font-size:1.375rem;line-height:32px;line-height:2rem;color:#434343;margin:1em 0;font-style:italic}blockquote p{margin:1em 0}cite{color:#434343;font-style:normal;font-weight:normal;font-size:16px;font-size:1rem;line-height:normal}q{font-style:italic;quotes:none}q:before,q:after{content:'';content:none}mark{background:#ff0;color:#111}code,kbd,pre,samp{word-wrap:break-word;font-family:'courier new',monospace,serif;font-size:13px;font-size:.8125rem;line-height:normal;font-weight:normal;background-color:#f1f1f1;padding:10px}code{color:#111}dl,menu,ol,ul{margin:1em 0}dd,ul ul,ol ol,ul ol,ol ul{margin:0}dt{font-weight:normal}dd{margin-bottom:1em}menu,ol,ul{padding:0 0 0 22px}nav ul,nav ol{list-style:none;list-style-image:none}.unstyled-list{list-style:none;padding:0;margin:0}.unstyled-list li{margin-top:0;margin-bottom:0}.inline-list{list-style:none;padding:0;margin:0;display:inline-block;*zoom:1;*display:inline}.inline-list li{margin-top:0;margin-bottom:0}.inline-list li{display:inline-block;*zoom:1;*display:inline}table{width:100%;margin:1em 0;table-layout:fixed;border-collapse:collapse;border-spacing:0;border-right:1px solid #f1f1f1;border-bottom:1px solid #f1f1f1;word-wrap:break-word;-ms-word-wrap:break-word;*white-space:normal}table th,table td{padding:8px;text-align:left;vertical-align:top;border-top:1px solid #eee;border-left:1px solid #eee}table thead th,table tfoot th{vertical-align:bottom;font-weight:normal;background-color:#f1f1f1;color:#333}table caption{padding:8px;font-style:normal;text-align:left;font-weight:normal;border-bottom:0}fieldset{border:0;padding:0}legend{border:0;padding:0;white-space:normal;*margin-left:-7px;font-weight:normal}label{margin:0;cursor:pointer}button,input,select,textarea{font-size:100%;vertical-align:baseline;*vertical-align:middle}input[type=text],input[type=password],input[type=email],input[type=search],input[type=tel],textarea{padding:5px;-webkit-appearance:none;-moz-appearance:none;font-weight:normal;line-height:normal;background-color:#fff;border:1px solid #ccc;color:#111}input[type=checkbox],input[type=radio]{cursor:pointer;box-sizing:border-box;line-height:normal;margin:0;padding:0;*height:13px;*width:13px}.checkbox{display:block;margin:.2em 0}.checkbox input[type=checkbox],.checkbox input[type=radio]{margin-top:.05em;float:left}.checkbox label{padding-left:5px;overflow:hidden;display:table;*zoom:1}button,input{line-height:normal}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer;*overflow:visible}button[disabled],html input[disabled]{cursor:default}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top;resize:none}.button{border:0;padding:1em 3em;background-color:#e74b3c;color:#fff;text-decoration:none;text-align:center;display:inline-block;*zoom:1;*display:inline;position:relative}.button:hover{background-color:#fc5547}.button:active{top:1px}.grey-button{background-color:#eee;color:#434343}.grey-button:hover{background-color:#f1f1f1}.button[disabled],.button.disabled{color:#999;background-color:#f1f1f1}.unstyled-button{font-size:16px;font-size:1rem;color:#27ae61;text-decoration:underline;border:0;background:transparent;height:auto;padding:0;cursor:pointer;outline:0}.unstyled-button:hover{text-decoration:none}.unstyled-button[disabled],.unstyled-button.disabled{text-decoration:none;color:#999;background-color:#ccc}.section{position:relative}.container{max-width:960px;margin-left:auto;margin-right:auto;padding-left:10px;padding-right:10px}.container-full{max-width:960px;margin-left:auto;margin-right:auto}.col{float:left;padding-left:10px;padding-right:10px}[class*="pull-"],[class*="push-"]{position:relative}.no-gutter{padding-left:0;padding-right:0}.col-1{width:8.33333%;width:calc(8.333333333333334%);width:-webkit-calc(8.333333333333334%);width:-moz-calc(8.333333333333334%)}.col-2{width:16.66667%;width:calc(16.666666666666668%);width:-webkit-calc(16.666666666666668%);width:-moz-calc(16.666666666666668%)}.col-3{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.col-4{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.col-5{width:41.66665%;width:calc(41.66666666666667%);width:-webkit-calc(41.66666666666667%);width:-moz-calc(41.66666666666667%)}.col-6{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.col-7{width:58.33333%;width:calc(58.333333333333336%);width:-webkit-calc(58.333333333333336%);width:-moz-calc(58.333333333333336%)}.col-8{width:66.66666%;width:calc(66.66666666666667%);width:-webkit-calc(66.66666666666667%);width:-moz-calc(66.66666666666667%)}.col-9{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.col-10{width:83.33333%;width:calc(83.33333333333334%);width:-webkit-calc(83.33333333333334%);width:-moz-calc(83.33333333333334%)}.col-11{width:91.66666%;width:calc(91.66666666666667%);width:-webkit-calc(91.66666666666667%);width:-moz-calc(91.66666666666667%)}.col-12{width:100%}.col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.push-1{left:8.33333%;left:calc(8.333333333333334%);left:-webkit-calc(8.333333333333334%);left:-moz-calc(8.333333333333334%)}.pull-1{left:-8.33333%;left:calc(-8.333333333333334%);left:-webkit-calc(-8.333333333333334%);left:-moz-calc(-8.333333333333334%)}.push-2{left:16.66667%;left:calc(16.666666666666668%);left:-webkit-calc(16.666666666666668%);left:-moz-calc(16.666666666666668%)}.pull-2{left:-16.66667%;left:calc(-16.666666666666668%);left:-webkit-calc(-16.666666666666668%);left:-moz-calc(-16.666666666666668%)}.push-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.pull-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.push-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.pull-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.push-5{left:41.66665%;left:calc(41.66666666666667%);left:-webkit-calc(41.66666666666667%);left:-moz-calc(41.66666666666667%)}.pull-5{left:-41.66665%;left:calc(-41.66666666666667%);left:-webkit-calc(-41.66666666666667%);left:-moz-calc(-41.66666666666667%)}.push-6{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.pull-6{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.push-7{left:58.33333%;left:calc(58.333333333333336%);left:-webkit-calc(58.333333333333336%);left:-moz-calc(58.333333333333336%)}.pull-7{left:-58.33333%;left:calc(-58.333333333333336%);left:-webkit-calc(-58.333333333333336%);left:-moz-calc(-58.333333333333336%)}.push-8{left:66.66666%;left:calc(66.66666666666667%);left:-webkit-calc(66.66666666666667%);left:-moz-calc(66.66666666666667%)}.pull-8{left:-66.66666%;left:calc(-66.66666666666667%);left:-webkit-calc(-66.66666666666667%);left:-moz-calc(-66.66666666666667%)}.push-9{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.pull-9{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.push-10{left:83.33333%;left:calc(83.33333333333334%);left:-webkit-calc(83.33333333333334%);left:-moz-calc(83.33333333333334%)}.pull-10{left:-83.33333%;left:calc(-83.33333333333334%);left:-webkit-calc(-83.33333333333334%);left:-moz-calc(-83.33333333333334%)}.push-11{left:91.66666%;left:calc(91.66666666666667%);left:-webkit-calc(91.66666666666667%);left:-moz-calc(91.66666666666667%)}.pull-11{left:-91.66666%;left:calc(-91.66666666666667%);left:-webkit-calc(-91.66666666666667%);left:-moz-calc(-91.66666666666667%)}.row{padding-top:1em;padding-bottom:1em}.clear:before,.clear:after{content:"";display:table}.clear:after{clear:both}.clear{zoom:1}.left{float:left}.right{float:right}.block{display:block}.inline{display:inline}.inline-block{display:inline-block;*zoom:1;*display:inline}.none,.hidden,[hidden],.no-desktop{display:none}.heavy{font-weight:900}.strong{font-weight:700}.normal{font-weight:normal}.thin{font-weight:300}.fine{font-weight:100}.italic{font-style:italic}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.left-text{text-align:left}.right-text{text-align:right}.center-text{text-align:center}.justify-text{text-align:justify}.visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;overflow:hidden;padding:0;position:absolute;width:1px;left:-9999em}.visuallyvisible{clip:auto;width:auto;height:auto;overflow:visible;left:0}.no-margin{margin:0}.no-padding{padding:0}@media only screen and (min-width:740px) and (max-width:960px){.container,.tablet-container{max-width:960px;padding-left:20px;padding-right:20px;margin-left:auto;margin-right:auto;float:none}.container:first-child,.tablet-container:first-child{margin-left:auto}.tablet-container-full{padding-left:0;padding-right:0;margin-left:auto;margin-right:auto;float:none}.tablet-container-full:first-child{margin-left:auto}.tablet-no-gutter{padding-left:0;padding-right:0}.tablet-col-1{width:8.33333%;width:calc(8.333333333333334%);width:-webkit-calc(8.333333333333334%);width:-moz-calc(8.333333333333334%)}.tablet-col-2{width:16.66667%;width:calc(16.666666666666668%);width:-webkit-calc(16.666666666666668%);width:-moz-calc(16.666666666666668%)}.tablet-col-3{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.tablet-col-4{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.tablet-col-5{width:41.66665%;width:calc(41.66666666666667%);width:-webkit-calc(41.66666666666667%);width:-moz-calc(41.66666666666667%)}.tablet-col-6{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.tablet-col-7{width:58.33333%;width:calc(58.333333333333336%);width:-webkit-calc(58.333333333333336%);width:-moz-calc(58.333333333333336%)}.tablet-col-8{width:66.66666%;width:calc(66.66666666666667%);width:-webkit-calc(66.66666666666667%);width:-moz-calc(66.66666666666667%)}.tablet-col-9{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.tablet-col-10{width:83.33333%;width:calc(83.33333333333334%);width:-webkit-calc(83.33333333333334%);width:-moz-calc(83.33333333333334%)}.tablet-col-11{width:91.66666%;width:calc(91.66666666666667%);width:-webkit-calc(91.66666666666667%);width:-moz-calc(91.66666666666667%)}.tablet-col-12{width:100%}.tablet-col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.tablet-col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.tablet-col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.tablet-col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.tablet-push-1{left:8.33333%;left:calc(8.333333333333334%);left:-webkit-calc(8.333333333333334%);left:-moz-calc(8.333333333333334%)}.tablet-pull-1{left:-8.33333%;left:calc(-8.333333333333334%);left:-webkit-calc(-8.333333333333334%);left:-moz-calc(-8.333333333333334%)}.tablet-push-2{left:16.66667%;left:calc(16.666666666666668%);left:-webkit-calc(16.666666666666668%);left:-moz-calc(16.666666666666668%)}.tablet-pull-2{left:-16.66667%;left:calc(-16.666666666666668%);left:-webkit-calc(-16.666666666666668%);left:-moz-calc(-16.666666666666668%)}.tablet-push-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.tablet-pull-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.tablet-push-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.tablet-pull-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.tablet-push-5{left:41.66665%;left:calc(41.66666666666667%);left:-webkit-calc(41.66666666666667%);left:-moz-calc(41.66666666666667%)}.tablet-pull-5{left:-41.66665%;left:calc(-41.66666666666667%);left:-webkit-calc(-41.66666666666667%);left:-moz-calc(-41.66666666666667%)}.tablet-push-6{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.tablet-pull-6{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.tablet-push-7{left:58.33333%;left:calc(58.333333333333336%);left:-webkit-calc(58.333333333333336%);left:-moz-calc(58.333333333333336%)}.tablet-pull-7{left:-58.33333%;left:calc(-58.333333333333336%);left:-webkit-calc(-58.333333333333336%);left:-moz-calc(-58.333333333333336%)}.tablet-push-8{left:66.66666%;left:calc(66.66666666666667%);left:-webkit-calc(66.66666666666667%);left:-moz-calc(66.66666666666667%)}.tablet-pull-8{left:-66.66666%;left:calc(-66.66666666666667%);left:-webkit-calc(-66.66666666666667%);left:-moz-calc(-66.66666666666667%)}.tablet-push-9{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.tablet-pull-9{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.tablet-push-10{left:83.33333%;left:calc(83.33333333333334%);left:-webkit-calc(83.33333333333334%);left:-moz-calc(83.33333333333334%)}.tablet-pull-10{left:-83.33333%;left:calc(-83.33333333333334%);left:-webkit-calc(-83.33333333333334%);left:-moz-calc(-83.33333333333334%)}.tablet-push-11{left:91.66666%;left:calc(91.66666666666667%);left:-webkit-calc(91.66666666666667%);left:-moz-calc(91.66666666666667%)}.tablet-pull-11{left:-91.66666%;left:calc(-91.66666666666667%);left:-webkit-calc(-91.66666666666667%);left:-moz-calc(-91.66666666666667%)}.tablet-no-push,.tablet-no-pull{left:auto}.tablet-row{padding-top:1em;padding-bottom:1em}.tablet-full{left:auto;clear:both;float:none;width:100%;margin:1em 0 0 0;display:block}.tablet-full:first-child{margin-top:0}.tablet-left-text{text-align:left}.tablet-right-text{text-align:right}.tablet-center-text{text-align:center}.tablet-left{float:left}.tablet-right{float:right}.tablet-no-float{float:none}.tablet-no-margin{margin:0}.tablet-no-padding{padding:0}.no-tablet{display:none}.show-tablet{display:block}}@media only screen and (max-width:739px){.container,.mobile-container{padding-left:20px;padding-right:20px;margin-left:auto;margin-right:auto;float:none}.container:first-child,.mobile-container:first-child{margin-left:auto}.mobile-container-full{padding-left:0;padding-right:0;margin-left:auto;margin-right:auto;float:none}.mobile-container-full:first-child{margin-left:auto}.mobile-no-gutter{padding-left:0;padding-right:0}.mobile-col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.mobile-col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.mobile-col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.mobile-col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.mobile-push-1-2{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.mobile-pull-1-2{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.mobile-push-1-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.mobile-pull-1-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.mobile-push-1-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.mobile-pull-1-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.mobile-push-3-4{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.mobile-pull-3-4{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.mobile-no-push,.mobile-no-pull{left:auto}.mobile-row{padding-top:1em;padding-bottom:1em}.mobile-full{left:auto;clear:both;float:none;width:100%;margin:.2em 0 0 0;display:block}.mobile-full:first-child{margin-top:0}.mobile-left-text{text-align:left}.mobile-right-text{text-align:right}.mobile-center-text{text-align:center}.mobile-left{float:left}.mobile-right{float:right}.mobile-no-float{float:none}.mobile-no-margin{margin:0}.mobile-no-padding{padding:0}table th,table td{padding:4px}.no-mobile{display:none}.show-mobile{display:block}}@media print{*{background:transparent}a,a:visited{text-decoration:underline}abbr[title]:after{content:" (" attr(title) ")"}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100%}@page{margin:.5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}}html,body{height:100%}.absolute{position:absolute}.relative{position:relative}.full{width:100%}.no-scroll{overflow:hidden}.table{display:table;margin:0 auto}.xlarge-top{margin-top:60px}.large-top{margin-top:40px}.medium-top{margin-top:20px}.small-top{margin-top:10px}.mini-top{margin-top:5px}.no-left-padding{padding-left:0}.no-right-padding{padding-right:0}@media only screen and (max-width:739px){.mobile-hide{display:none}.mobile-xlarge-top{margin-top:60px}.mobile-large-top{margin-top:40px}.mobile-medium-top{margin-top:20px}.mobile-small-top{margin-top:10px}.mobile-mini-top{margin-top:5px}}html,body{font-family:'Roboto','Helvetica Neue','Arial','Helvetica','Lucida Grande',sans-serif;font-weight:300;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}h1,h2,h3,h4,h5{font-weight:300}p{margin:0 0 1em 0}pre,code{padding:5px 10px;color:#6e6e6e;font-size:14px;line-height:20px;font-weight:100;background:#f8f8f8;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}a{color:#333;text-decoration:none;-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out}a.active{color:#000}a:hover{color:#000}a:hover .fa-trash-o{color:#e2717f}a.primary{color:#e2717f}a.primary:hover{color:#d94759}img{max-width:100%}hr{margin:.5em 0;width:100%}i.right-padding{padding-right:10px}i.left-padding{padding-left:10px}.button{outline:0;padding:1em 1.5em;background:#fafafa;color:#333;white-space:nowrap;background-clip:padding-box;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.button.disabled,.button[disabled]{-moz-opacity:.7;-khtml-opacity:.7;-webkit-opacity:.7;opacity:.7;-ms-filter:alpha(opacity=70);filter:alpha(opacity=70);cursor:default}.button:hover:not(.disabled),.button:hover:not([disabled]){background:#d9d9d9}.button.large{padding:1em 4em}.button.small{padding:.6em .8em}.button.x-small{padding:.4em .6em}.button.primary-button{color:#fff;background:#e2717f}.button.primary-button:hover,.button.primary-button:focus{color:#f2f2f2;background:#de5c6c}.button.primary-button:hover.disabled,.button.primary-button:focus.disabled,.button.primary-button:hover:disabled,.button.primary-button:focus:disabled{background:#e2717f}.button.secondary-button{background:0;border:1px solid #eee}.button.secondary-button:hover:not(.active),.button.secondary-button:hover:not(.disabled),.button.secondary-button:hover:not(:disabled),.button.secondary-button:focus:not(.active),.button.secondary-button:focus:not(.disabled),.button.secondary-button:focus:not(:disabled){color:#666;background:#f8f8f8}.button.secondary-button.active{color:#595959;background:#ebebeb;border:1px solid #eee}.button.secondary-button.active:hover{color:#595959;background:#ebebeb;border:1px solid #eee}.button.remove-button{background:#e2717f;color:#fff;padding:.9em 1.5em}.button.remove-button:hover,.button.remove-button:focus{background:#de5c6c}.button.remove-button:hover.disabled,.button.remove-button:focus.disabled,.button.remove-button:hover:disabled,.button.remove-button:focus:disabled{background:#e2717f}.button.transparent-button{background:0;color:#fff;border:1px solid #f2f2f2}.button.transparent-button:hover:not(.disabled),.button.transparent-button:hover:not(:disabled){background:rgba(255,255,255,0.1);color:#fff}.button-group>.button{padding:.8em 1em;text-align:center;background:#fff;border-top:1px solid #eee;border-bottom:1px solid #eee;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.button-group>.button i.fa{margin-right:5px}.button-group>.button:first-child{border-left:1px solid #eee;-webkit-border-top-right-radius:0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:5px;-webkit-border-top-left-radius:5px;-moz-border-radius-topright:0;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:5px;-moz-border-radius-topleft:5px;border-top-right-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:5px;border-top-left-radius:5px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.button-group>.button:last-child{border-right:1px solid #eee;-webkit-border-top-right-radius:5px;-webkit-border-bottom-right-radius:5px;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:0;-moz-border-radius-topright:5px;-moz-border-radius-bottomright:5px;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:0;border-top-right-radius:5px;border-bottom-right-radius:5px;border-bottom-left-radius:0;border-top-left-radius:0;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.button-group>.button:hover:not(.active),.button-group>.button:focus:not(.active){color:#666;background:#f8f8f8}.button-group>.button.active{color:#595959;background:#ebebeb;border:1px solid #eee}.button-group>.button.active:hover{color:#595959;background:#ebebeb;border:1px solid #eee}.button-group.small>.button{padding:.6em .8em}.button-group.x-small>.button{padding:.4em .6em}form .col,form .input-wrapper{position:relative}form input,form input[type="text"],form input[type="password"],form input[type="email"],form input[type="search"],form input[type="tel"],form input[type="number"],form input[type="date"],form textarea{width:100%;padding:.8em .6em .6em;outline:0;border:1px solid #d3d3d3;font-size:1.1em;line-height:1;background:#fff;color:#666;-webkit-appearance:none;-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out}form input:focus,form input[type="text"]:focus,form input[type="password"]:focus,form input[type="email"]:focus,form input[type="search"]:focus,form input[type="tel"]:focus,form input[type="number"]:focus,form input[type="date"]:focus,form textarea:focus{color:#333;border:1px solid #a0a0a0;-moz-box-shadow:0 0 2px #a0a0a0;-webkit-box-shadow:0 0 2px #a0a0a0;box-shadow:0 0 2px #a0a0a0;-webkit-box-shadow:0 0 2px #a0a0a0 0 0 #000;box-shadow:0 0 2px #a0a0a0 0 0 #000}form input:focus+label,form input[type="text"]:focus+label,form input[type="password"]:focus+label,form input[type="email"]:focus+label,form input[type="search"]:focus+label,form input[type="tel"]:focus+label,form input[type="number"]:focus+label,form input[type="date"]:focus+label,form textarea:focus+label{color:#666;font-weight:400}form input.success,form input[type="text"].success,form input[type="password"].success,form input[type="email"].success,form input[type="search"].success,form input[type="tel"].success,form input[type="number"].success,form input[type="date"].success,form textarea.success{border:1px solid #43cea2;-moz-box-shadow:0 0 2px #43cea2;-webkit-box-shadow:0 0 2px #43cea2;box-shadow:0 0 2px #43cea2;-webkit-box-shadow:0 0 2px #43cea2 0 0 #000;box-shadow:0 0 2px #43cea2 0 0 #000}form input.success+label,form input[type="text"].success+label,form input[type="password"].success+label,form input[type="email"].success+label,form input[type="search"].success+label,form input[type="tel"].success+label,form input[type="number"].success+label,form input[type="date"].success+label,form textarea.success+label{color:#43cea2;font-weight:400}form input.error,form input[type="text"].error,form input[type="password"].error,form input[type="email"].error,form input[type="search"].error,form input[type="tel"].error,form input[type="number"].error,form input[type="date"].error,form textarea.error{border:1px solid #e2717f;-moz-box-shadow:0 0 2px #e2717f;-webkit-box-shadow:0 0 2px #e2717f;box-shadow:0 0 2px #e2717f;-webkit-box-shadow:0 0 2px #e2717f 0 0 #000;box-shadow:0 0 2px #e2717f 0 0 #000}form input.error+label,form input[type="text"].error+label,form input[type="password"].error+label,form input[type="email"].error+label,form input[type="search"].error+label,form input[type="tel"].error+label,form input[type="number"].error+label,form input[type="date"].error+label,form textarea.error+label{color:#e2717f;font-weight:400}form input::-webkit-input-placeholder,form input[type="text"]::-webkit-input-placeholder,form input[type="password"]::-webkit-input-placeholder,form input[type="email"]::-webkit-input-placeholder,form input[type="search"]::-webkit-input-placeholder,form input[type="tel"]::-webkit-input-placeholder,form input[type="number"]::-webkit-input-placeholder,form input[type="date"]::-webkit-input-placeholder,form textarea::-webkit-input-placeholder{color:#d3d3d3;font-weight:300}form [placeholder]:focus::-webkit-input-placeholder{-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out;opacity:0}form input[type="number"]::-webkit-inner-spin-button,form input[type="number"]::-webkit-outer-spin-button,form input[type="date"]::-webkit-inner-spin-button,form input[type="date"]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}form .select-style{position:relative;display:block;width:100%;border:1px solid #a0a0a0;background:#fff}form .select-style .fa-caret-down{position:absolute;right:.6em;top:.8em;color:#a0a0a0;font-size:1.4em}form .select-style select{padding:.8em 0;margin-left:.6em;width:100%;border:0;box-shadow:none;background:transparent;background-image:none;-webkit-appearance:none;color:#a0a0a0;font-size:1.2em}form .select-style select:hover{cursor:pointer}form .select-style select:focus{outline:0}form fieldset.row{padding:.5em 0}form label{position:absolute;left:5px;top:-5px;padding:0 5px;background:white;color:#a0a0a0;font-size:12px;line-height:12px;text-transform:uppercase;pointer-events:none;z-index:2}.modal-wrapper{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.3);display:none;z-index:1001;will-change:transform}.modal-wrapper .modal{position:relative;color:#333;display:none}.modal-wrapper .modal a.close{position:absolute;padding:6px 12px 9px;border:1px solid;border-radius:20px;font-weight:300;font-size:27px}.modal-wrapper .modal section.modal-content{padding:20px}.modal-wrapper:not(.fullscreen) .modal{min-height:300px;max-width:434px;margin:60px auto 0;background-color:#fff;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.modal-wrapper:not(.fullscreen) .modal a.close{right:-45px;top:-30px;color:#fff}.modal-wrapper.fullscreen{background:#fff}.modal-wrapper.fullscreen .modal{height:100%;overflow:auto}.modal-wrapper.fullscreen .modal a.close{right:20px;top:20px}.notice{position:fixed;bottom:0;right:10px;height:100px;width:300px;padding:5px 10px 5px 10px;display:none;color:#fff;z-index:1005;-webkit-border-top-right-radius:5px;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:5px;-moz-border-radius-topright:5px;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:5px;border-top-right-radius:5px;border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-left-radius:5px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.notice.success{background-color:#43cea2}.notice.warning{background-color:#f4ed6b}.notice.error{background-color:#e2717f}.notice header.notice-header{position:relative;margin-bottom:.2em}.notice section.notice-content{height:70px;width:100%;overflow:auto;font-size:.8em}.notice a.close{position:absolute;top:3px;right:0;padding:0 4px 2px;border:1px solid;border-radius:100%;font-weight:300;font-size:12px;line-height:12px;color:#fff}.notice a.close:hover{color:#ccc}nav{font-size:18px;font-size:1.125rem}nav .navbar{margin:0 auto;display:table;padding:10px 0}nav li{margin:0 10px}nav a{display:inline-block;line-height:60px;vertical-align:middle}nav a.logo{height:60px;width:60px}@media(max-width:739px){nav{font-size:14px;font-size:.875rem}nav a{line-height:40px}nav a.logo{height:40px;width:40px}}#toc{position:fixed;top:80px;height:100%;width:220px;overflow:auto;padding-bottom:100px}#toc a{color:#333}#toc a:hover{color:#1a1a1a}#toc li>ul{display:none}#toc li>ul.unstyled-list{margin-left:10px}#toc li.active>a{font-weight:bold}#toc li.active>ul{display:block}#toc ul.nav>li.active>ul>li{list-style:none}footer{padding:60px 0;color:#d3d3d3;background:#333}footer i.fa-heart{color:#e2717f}footer i.fa-beer{color:#f4ed6b}html,body{background:#fff;color:#333}.kd{color:#a783b6}.k{color:#43cea2}h1.logo{font-size:64px;font-size:4rem}.gist pre,.gist .file-data{font-size:14px!important}section{padding:40px 0}code{padding:0}#hero .badges,#hero .github-links{padding:.3em 0}#hero .badges p,#hero .github-links p{margin:0}#ship h3{margin-bottom:1em}#ship img.ship-it{display:table;height:300px;width:300px;margin:0 auto;background:#d3d3d3;-webkit-border-radius:100%;-moz-border-radius:100%;border-radius:100%}#plugins{color:#fff;background:#333}#plugins p{color:#d3d3d3}#plugins ul li{padding:10px 20px}#plugins ul li a{display:inline-block}#plugins ul li a img{height:100px;max-width:160px}@media(max-width:739px){#plugins ul li a img{height:60px;max-width:120px}}#features{color:#fff;background:#e2717f}#features h4{color:#982e3e}#features a.primary{color:#f8f8f8;border-bottom:1px dashed #f8f8f8}#features a.primary:hover{color:#dfdfdf;border-bottom:1px dashed #dfdfdf}#comparison img{margin:0 auto}.example,.example .row{padding-bottom:0}.page,.example{padding-top:0;margin-bottom:0}.page a,.example a{color:#e2717f}.page a:hover,.example a:hover{color:#d94759}.page .file-data .line-numbers,.example .file-data .line-numbers{width:40px}#todo-example{padding-bottom:2em}#todo-example input[type="text"]{margin:10px 0}#todo-example ul.todos{height:320px}#todo-example ul.todos li{padding:5px 0}#todo-example ul.todos li input[type="checkbox"]{margin-top:.2em}#todo-example ul.todos li span{margin-left:5px}#todo-example ul.todos li.done label{text-decoration:line-through;color:#998}#todo-example ul.todos li .delete{font-weight:bold}#todo-example label{float:left}#todo-example .primary-button{width:100%} \ No newline at end of file diff --git a/js/feathers.js b/js/feathers.js index 943400ea2c..3bf5c7ee1f 100644 --- a/js/feathers.js +++ b/js/feathers.js @@ -1,21 +1,4 @@ (function($, undefined){ - $.fn.gistPills = function(gistId, index) { - var gistFiles = $('#gist' + gistId).find('.gist-file'); - var lis = this.find('a'); - - gistFiles.hide(); - - this.on('click', 'a', function(ev) { - var el = $(this); - lis.removeClass('active'); - el.addClass('active'); - $(gistFiles.hide().get(el.index())).show(); - ev.preventDefault(); - }); - - $(lis.get(index || 0)).click(); - }; - $.fn.toc = function(target) { var idCounter = 0; var existingIds = {}; @@ -63,10 +46,7 @@ }; $(document).ready(function() { - var offsetTop = $('.navbar').outerHeight(); - $('#toc').toc('.page-content'); - $('#realtime-todos').gistPills(6665992, 0); $(window).on('resize', function(){ $('[data-spy="scroll"]').each(function () { @@ -77,7 +57,7 @@ if($(window).width() > 992) { $('#toc').affix({ offset: { - top: $('#toc').offset().top - $('.navbar').outerHeight() + top: $('#toc').offset().top } }); } @@ -94,7 +74,7 @@ $('#todo-example').todos('http://todos.feathersjs.com:80'); $('body').scrollspy({ target: '#toc', - offset: offsetTop + offset: 0 }); }); })(jQuery); diff --git a/js/todos.js b/js/todos.js index 3ec39c65b0..567cd0a9ec 100644 --- a/js/todos.js +++ b/js/todos.js @@ -61,6 +61,7 @@ socket.on('todos removed', app.removeTodo); socket.on('todos created', app.addTodo); socket.emit('todos::find', {}, function (error, todos) { + el.find('ul').empty(); todos.forEach(app.addTodo); }); }; diff --git a/learn.md b/learn.md index 7384bbc087..e9e0e42029 100644 --- a/learn.md +++ b/learn.md @@ -6,42 +6,46 @@ permalink: /learn/ weight: 2 --- -On this page you will find additional resources and guides about Feathers. Make sure to first get familiar with the basics in the [Quick Start guide](/quick-start/). +On this page you can find additional resources and guides about Feathers. Make sure to first get familiar with the basics in the [Quick Start guide](/quick-start/). ## API docs -For the API documentation with detailed information about the Feathers specific API, configuration and to see the Changelog and License head over to the [Docs](/docs/) page. +For the API documentation with detailed information about the Feathers specific API, configuration and to see the changelog and license head over to the [Docs](/docs/) page. -## Frameworks +## Frontend Frameworks -Feathers works great with any frontend that can connect through the REST API or websockets. Sometimes it is just a few lines of code to make a frontend turn real-time. Which is why implemented some TodoMVC examples and guides that all connect to the same Feathers real-time API. +Feathers works great with any frontend that can connect through the REST API or websockets. Sometimes it is just a few lines of code to make a frontend turn real-time which is why implemented some TodoMVC examples and guides that all connect to the same Feathers real-time API: -Pick your poison: +- [jQuery]() +- [React]() +- [Angular]() +- [CanJS]() +- [iOS]() +- [Android]() -- jQuery -- React -- Angular -- CanJS -- iOS -- Android - -We don't know all the frameworks out there so if you don't see your favourite, submit an issue or - even better - a pull request and we'll try our best to help out. +We don't know all the frameworks out there so if you don't see your favourite, submit an issue or - even better - a pull request and we'll try our best to make it happen. ## Databases -Feathers already has plugins for CRUD operations on many different databases: +Feathers already has plugins for CRUD operations on many different databases. All plugins provide a common way to filter, sort and limit records to make switching between databases easier. Our [MongoDB guide]() goes a little more into detail how to use Feathers with MongoDB (spoiler: it's only 16 lines of code to build a complete REST and real-time API with a MongoDB backend). For more information about other databases visit their plugin pages: -- In memory - A service that stores everything locally in memory. Probably not ideal in production environments but great for prototyping. -- MongoDB - A basic MongoDB implementation. Easy to use. -- Mongoose - Support for the MongoDB ODM which already gives you schemas and validation out of the box. -- NeDB - A file based database similar to MongoDB, great if you don't want or need a full blown database. -- MySQL -- PostgreSQL +- [In memory]() - A service that stores everything locally in memory. Probably not ideal in production environments but great for prototyping. +- [MongoDB]() - A basic MongoDB implementation, easy to use. +- [Mongoose]() - Support for the MongoDB ODM which gives you schemas and validation out of the box. +- [NeDB]() - A file based database similar to MongoDB. Great if you want to ship your application and use it without having to set up a datbase server. +- [MySQL]() +- [PostgreSQL]() If you are wondering how to customize those existing adapters and make it easier to switch between different databases, read more about hooks in the next paragraph. ## Hooks and validation +While not part of the core, [feathers-hooks]() is a powerful plugin that allows to customize service method execution with small pluggable, reusable Lego-pieces very similar to Express middleware. We created a [guide how to use hooks for validation]() and you can read more about the theory and patterns behind it [in this blog post](). + ## Authentication +Since Feathers directly extends Express you can use any of its authentication mechanism. The [Authentication Guide](/learn/authentication) describes more specifically how to set up shared authentication between HTTP and websockets using PassportJS, sessions and a service for managing users. + ## Authorization + +Once set up with user authentication, our [Authorization Guide](/learn/authorization) talks about how to use hooks for user authorization and how to dispatch real-time events only to specific authenticated users. diff --git a/learn/authentication.md b/learn/authentication.md index 2ad421bcae..cb09bfd6d0 100644 --- a/learn/authentication.md +++ b/learn/authentication.md @@ -7,7 +7,7 @@ hide: true ## Authentication -Since Feathers directly extends Express you can use any of its authentication mechanism. [Passport](http://passportjs.org/) is one that is used quite often and also really flexible. Manually setting up shared authentication between websockets and an HTTP REST API can be tricky. This is what the [feathers-passport](https://github.com/feathersjs/feathers-passport) module aims to make easier. The following examples show how to add local authentication that uses a Feathers service for storing and retrieving user information. +[Passport](http://passportjs.org/) is one that is used quite often and also really flexible. Manually setting up shared authentication between websockets and an HTTP REST API can be tricky. This is what the [feathers-passport](https://github.com/feathersjs/feathers-passport) module aims to make easier. The following examples show how to add local authentication that uses a Feathers service for storing and retrieving user information. ### Configuring Passport diff --git a/learn/authorization.md b/learn/authorization.md index 336f4ed730..93501a3a31 100644 --- a/learn/authorization.md +++ b/learn/authorization.md @@ -5,11 +5,9 @@ description: Learn how to authorize users hide: true --- -## Authorization +Authorization is the process of determining after [successful authentication](/learn/authentication) if the user is allowed to perform the requested action. This is again where [hooks](learn/validation#hooks) come in handy. -Authorization is the process of determining after successful authentication if the user is allowed to perform the requested action. This is again where hooks come in handy. - -### User authorization +## User authorization Since *feathers-passport* adds the authenticated user information to the service call parameters we can just check those in the hook and return with an error if the user is not authorized: @@ -35,7 +33,7 @@ app.service('todos').before({ }); ``` -### Event filtering +## Event filtering This is also a good time to talk a little about [filtering events](/api/#event-filtering). It is very likely that you eventually only want to send certain events to specific users instead of everybody. Following up on the group authorization example from above, we might only want to dispatch a `todos created` event to users that are in the admin group. This can be done by adding a `created(data, params, callback)` method to the Todo MongoDB service: diff --git a/quick-start.md b/quick-start.md index 39bb143520..d5cc3bfd84 100644 --- a/quick-start.md +++ b/quick-start.md @@ -236,6 +236,8 @@ That's it. Our application is now real-time, all we have to do is provide a nice ### Feathers client +[feathers-client]() is a JavaScript client that can connect to Feathers services either via REST (using jQuery.ajax, node-request or Superagent) or websockets (Socket.io and Primus). That makes it possible to use + ### Testing the connection To test the connection, we can create an `index.html` file in the same folder. The example page will connect to SocketIO, create a new Todo and also log when any Todo has been created, updated or patched: diff --git a/support.md b/support.md index 48892cd6ec..1fa2356dc1 100644 --- a/support.md +++ b/support.md @@ -18,7 +18,7 @@ If you have any questions, feel free to submit them as a [GitHub issue](https:// We know! Oh God another NodeJS framework! We really didn't want to add another name to the long list of NodeJS web frameworks but also wanted to explore a different approach than any other library we have seen. We strongly believe that data is the core of the web and should be the focus of web applications. -Many web frameworks end up focussing so much on secondary concerns like how to render views or handle and process HTTP requests and responses that even when using the MVC pattern your actual application logic becomes a slave to those concerns. +Many web frameworks focus on things like rendering views, defining routes and handling HTTP requests and responses without providing a structure for implementing application logic separate from those secondary concerns. The result - even when using the MVC pattern - are big monolithic controllers where your actual application logic and how it is accessed - usually via HTTP - are all mixed up together. Feathers services bring two important concepts together that help to separate those concerns from how your application works: @@ -43,7 +43,7 @@ var myService = { } ``` -This interface also made it easier to hook into the execution of those methods and emit events when they return. +This interface also makes it easier to hook into the execution of those methods and emit events when they return which can naturally be used to provide real-time functionality. ## Do I get websocket events from REST calls? @@ -164,13 +164,13 @@ Custom Express middleware that only should be run before a specific service can app.use('/todos', ensureAuthenticated, logRequest, todoService); ``` -Keep in mind that shared authentication (between REST and websockets) should use a service based approach as described in the [authentication section of the guide](/#authentication). +Keep in mind that shared authentication (between REST and websockets) should use a service based approach as described in the [authentication section of the guide](/learn/authentication). ## What about Koa? Koa is a *"next generation web framework for Node.JS"* using ES6 generator functions instead of Express middleware. This approach does unfortunately not easily play well with Feathers services so there are no direct plans yet to use it as a future base for Feathers. -There are however definitely plans of using ES6 features for Feathers once they make it into `node --harmony`, specifically: +There are however definite plans of using ES6 features for Feathers once they make it into `node --harmony`, specifically: - [Promises](http://www.html5rocks.com/en/tutorials/es6/promises/) instead of callbacks for asynchronous processing - [ES6 classes](http://wiki.ecmascript.org/doku.php?id=strawman:maximally_minimal_classes) for defining services. From be1960fef11f331c1618e94cc01160228c1e1150 Mon Sep 17 00:00:00 2001 From: Eric Kryski Date: Fri, 17 Jul 2015 17:55:34 -0600 Subject: [PATCH 05/11] fixing up some grammar and spelling in the docs --- learn.md | 26 +++++++++++--------------- learn/authentication.md | 4 ++-- learn/authorization.md | 2 +- learn/validation.md | 2 +- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/learn.md b/learn.md index e9e0e42029..844b215bbe 100644 --- a/learn.md +++ b/learn.md @@ -6,15 +6,11 @@ permalink: /learn/ weight: 2 --- -On this page you can find additional resources and guides about Feathers. Make sure to first get familiar with the basics in the [Quick Start guide](/quick-start/). +So you're ready to learn more about Feathers, eh? If you haven't checked out the [Quick Start guide](/quick-start/) head over there first to get a brief intro to the basic concepts in a Feathers app. On this page you'll find additional resources and guides about Feathers. -## API docs +## Front-end Frameworks -For the API documentation with detailed information about the Feathers specific API, configuration and to see the changelog and license head over to the [Docs](/docs/) page. - -## Frontend Frameworks - -Feathers works great with any frontend that can connect through the REST API or websockets. Sometimes it is just a few lines of code to make a frontend turn real-time which is why implemented some TodoMVC examples and guides that all connect to the same Feathers real-time API: +Feathers works great with any front-end that connects through HTTP/HTTPS or websockets to your Feathers REST API. Sometimes it is just a few lines of code to make a front-end turn real-time. To help you out we've provided some simple TodoMVC style examples and guides that all connect to the same Feathers real-time API ([todos.feathersjs.com](http://todos.feathersjs.com)): - [jQuery]() - [React]() @@ -23,29 +19,29 @@ Feathers works great with any frontend that can connect through the REST API or - [iOS]() - [Android]() -We don't know all the frameworks out there so if you don't see your favourite, submit an issue or - even better - a pull request and we'll try our best to make it happen. +We can't possibly support or no about all the frameworks out there so if you don't see your favourite, submit an issue or - even better - a pull request and we'll try our best to make it happen. ## Databases -Feathers already has plugins for CRUD operations on many different databases. All plugins provide a common way to filter, sort and limit records to make switching between databases easier. Our [MongoDB guide]() goes a little more into detail how to use Feathers with MongoDB (spoiler: it's only 16 lines of code to build a complete REST and real-time API with a MongoDB backend). For more information about other databases visit their plugin pages: +Feathers already has plug-ins for CRUD (Create, Read, Update, Delete) operations on many different databases. All plug-ins provide a common way to filter, sort and limit records which makes switching between databases super easy. Our [MongoDB guide]() goes into a bit more detail on how to use Feathers with MongoDB (**spoiler:** it's only 16 lines of code to build a complete REST and real-time API with a MongoDB backend). For more information about other databases visit their very own plug-in page: - [In memory]() - A service that stores everything locally in memory. Probably not ideal in production environments but great for prototyping. - [MongoDB]() - A basic MongoDB implementation, easy to use. - [Mongoose]() - Support for the MongoDB ODM which gives you schemas and validation out of the box. - [NeDB]() - A file based database similar to MongoDB. Great if you want to ship your application and use it without having to set up a datbase server. -- [MySQL]() -- [PostgreSQL]() +- [MySQL]() - A basic MySQL/MariaDB implementation. +- [PostgreSQL]() - A basic PostgreSQL implementation. -If you are wondering how to customize those existing adapters and make it easier to switch between different databases, read more about hooks in the next paragraph. +If you need to customize those existing adapters they can be easily extended or you can use hooks. Read more about hooks in the next paragraph. ## Hooks and validation -While not part of the core, [feathers-hooks]() is a powerful plugin that allows to customize service method execution with small pluggable, reusable Lego-pieces very similar to Express middleware. We created a [guide how to use hooks for validation]() and you can read more about the theory and patterns behind it [in this blog post](). +While not part of the core, [feathers-hooks]() is a powerful plug-in that allows you to customize service method execution with small pluggable, reusable methods (concerns), very similar to Express middleware. We created a [guide on how to use hooks for validation]() and you can read more about the theory and patterns behind it [in this blog post](). ## Authentication -Since Feathers directly extends Express you can use any of its authentication mechanism. The [Authentication Guide](/learn/authentication) describes more specifically how to set up shared authentication between HTTP and websockets using PassportJS, sessions and a service for managing users. +Since Feathers directly extends Express you can use any of its authentication mechanisms. The [Authentication Guide](/learn/authentication) describes how to set up shared authentication between HTTP and websockets using PassportJS. We'll go through how to manage sessions, set up a service for managing users, and authenticate a user. ## Authorization -Once set up with user authentication, our [Authorization Guide](/learn/authorization) talks about how to use hooks for user authorization and how to dispatch real-time events only to specific authenticated users. +Once set up with user authentication, our [Authorization Guide](/learn/authorization) will walk you through how to use hooks for user authorization and how to dispatch real-time events to only specific authenticated users. diff --git a/learn/authentication.md b/learn/authentication.md index cb09bfd6d0..22b3196ac6 100644 --- a/learn/authentication.md +++ b/learn/authentication.md @@ -7,7 +7,7 @@ hide: true ## Authentication -[Passport](http://passportjs.org/) is one that is used quite often and also really flexible. Manually setting up shared authentication between websockets and an HTTP REST API can be tricky. This is what the [feathers-passport](https://github.com/feathersjs/feathers-passport) module aims to make easier. The following examples show how to add local authentication that uses a Feathers service for storing and retrieving user information. +[Passport](http://passportjs.org/) is the most popular authentication library for NodeJS is also really flexible. That's why we recommend with and without Feathers. Manually setting up shared authentication between websockets and an HTTP REST API can be tricky. Managing this shared session state is what the [feathers-passport](https://github.com/feathersjs/feathers-passport) module aims to make easier. The following example shows how you can use local authentication (email + password) and a simple Feathers service to authenticate users. ### Configuring Passport @@ -55,7 +55,7 @@ app.configure(feathers.rest()) ### User storage -Next, we create a MongoDB service for storing user information. It is always a good idea to not store plain text passwords in the database so we add a `.before` hook that salts and then hashes the password when creating a new user. This can be done in the service `.setup` which is called when the application is ready to start up. We also add an `.authenticate` method that we can use to look up a user by username and compare the hashed and salted passwords. +Next, we create a MongoDB service for storing user information. You should never store plain text passwords in the database so we add a `.before` hook that salts and then hashes the password when creating a new user. This can be done in the service `.setup` which is called when the application is ready to start up. We also add an `.authenticate` method that we can use to look up a user by username and compare the hashed and salted passwords. ```js var crypto = require('crypto'); diff --git a/learn/authorization.md b/learn/authorization.md index 93501a3a31..0d32ecbfb6 100644 --- a/learn/authorization.md +++ b/learn/authorization.md @@ -5,7 +5,7 @@ description: Learn how to authorize users hide: true --- -Authorization is the process of determining after [successful authentication](/learn/authentication) if the user is allowed to perform the requested action. This is again where [hooks](learn/validation#hooks) come in handy. +Authorization is the process of determining, after [successful authentication](/learn/authentication), if the user is allowed to perform the requested action. This is where [hooks](learn/validation#hooks) come in handy. ## User authorization diff --git a/learn/validation.md b/learn/validation.md index cff1f5c6ea..de659907e8 100644 --- a/learn/validation.md +++ b/learn/validation.md @@ -41,7 +41,7 @@ var todoService = mongodb({ ### Hooks -Another option is the [feathers-hooks](https://github.com/feathersjs/feathers-hooks) plugin which allows us to add asynchronous hooks before or after a service method call. Hooks work similar to Express middleware. The following example adds a hook that converts our Todo data and makes sure that nobody submits anything that we don't want to put into MongoDB: +Another option is the [feathers-hooks](https://github.com/feathersjs/feathers-hooks) plug-in which allows us to add asynchronous hooks before or after a service method call. Hooks work similar to Express middleware. The following example adds a hook that converts our Todo data and makes sure that nobody submits anything that we don't want to put into MongoDB: > `npm install feathers-hooks` From 7c8888eeb2e78c9a27c87b7fcffe20eec30925f8 Mon Sep 17 00:00:00 2001 From: Eric Kryski Date: Fri, 17 Jul 2015 17:56:42 -0600 Subject: [PATCH 06/11] nicer sentence structure --- learn.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/learn.md b/learn.md index 844b215bbe..862f1dd536 100644 --- a/learn.md +++ b/learn.md @@ -6,7 +6,7 @@ permalink: /learn/ weight: 2 --- -So you're ready to learn more about Feathers, eh? If you haven't checked out the [Quick Start guide](/quick-start/) head over there first to get a brief intro to the basic concepts in a Feathers app. On this page you'll find additional resources and guides about Feathers. +So you're ready to learn more about Feathers, eh? If you haven't checked out the [Quick Start guide](/quick-start/) head over there first to get a brief intro to the basic parts of a Feathers app. On this page you'll find additional resources and guides about to do more with Feathers. ## Front-end Frameworks From 8c4715f5340d6a3f463822fca28ee84a5c1fc3ca Mon Sep 17 00:00:00 2001 From: Eric Kryski Date: Fri, 17 Jul 2015 18:12:29 -0600 Subject: [PATCH 07/11] a little bit more wordsmithing --- learn.md | 26 ++++++++++++++------------ support.md | 6 +++--- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/learn.md b/learn.md index 862f1dd536..850cec0f4e 100644 --- a/learn.md +++ b/learn.md @@ -12,31 +12,33 @@ So you're ready to learn more about Feathers, eh? If you haven't checked out the Feathers works great with any front-end that connects through HTTP/HTTPS or websockets to your Feathers REST API. Sometimes it is just a few lines of code to make a front-end turn real-time. To help you out we've provided some simple TodoMVC style examples and guides that all connect to the same Feathers real-time API ([todos.feathersjs.com](http://todos.feathersjs.com)): -- [jQuery]() -- [React]() -- [Angular]() -- [CanJS]() -- [iOS]() -- [Android]() +- [jQuery]() (coming soon) +- [React]() (coming soon) +- [Angular]() (coming soon) +- [CanJS]() (coming soon) +- [iOS]() (coming soon) +- [Android]() (coming soon) -We can't possibly support or no about all the frameworks out there so if you don't see your favourite, submit an issue or - even better - a pull request and we'll try our best to make it happen. +We can't possibly support (or know about) all the frameworks out there so if you don't see your favourite one, please [submit an issue](https://github.com/feathersjs/feathers/issues/new), or **even better**, a pull request and we'll try our best to make it happen. ## Databases -Feathers already has plug-ins for CRUD (Create, Read, Update, Delete) operations on many different databases. All plug-ins provide a common way to filter, sort and limit records which makes switching between databases super easy. Our [MongoDB guide]() goes into a bit more detail on how to use Feathers with MongoDB (**spoiler:** it's only 16 lines of code to build a complete REST and real-time API with a MongoDB backend). For more information about other databases visit their very own plug-in page: +Feathers already has plug-ins for *Create, Read, Update and Delete* operations on many different databases. All plug-ins provide a common way to filter, sort and limit records, which makes switching between databases super easy. Our [MongoDB guide]() goes into a bit more detail on how to use Feathers with MongoDB (**spoiler:** it's only 16 lines of code to build a complete REST and real-time API with a MongoDB backend). For more information about other databases visit their very own plug-in page: - [In memory]() - A service that stores everything locally in memory. Probably not ideal in production environments but great for prototyping. - [MongoDB]() - A basic MongoDB implementation, easy to use. - [Mongoose]() - Support for the MongoDB ODM which gives you schemas and validation out of the box. - [NeDB]() - A file based database similar to MongoDB. Great if you want to ship your application and use it without having to set up a datbase server. -- [MySQL]() - A basic MySQL/MariaDB implementation. -- [PostgreSQL]() - A basic PostgreSQL implementation. +- [MySQL]() - A basic MySQL/MariaDB implementation. (coming soon) +- [PostgreSQL]() - A basic PostgreSQL implementation. (coming soon) +- [CouchDB]() - A basic CouchDB implementation. (coming soon) +- [Redis]() - A basic Redis implementation. (coming soon) -If you need to customize those existing adapters they can be easily extended or you can use hooks. Read more about hooks in the next paragraph. +If you need to customize any of the provided adapters they can be easily extended or you can use [feathers-hooks](https://github.com/feathersjs/feathers-hooks). Read more about hooks in the next paragraph. ## Hooks and validation -While not part of the core, [feathers-hooks]() is a powerful plug-in that allows you to customize service method execution with small pluggable, reusable methods (concerns), very similar to Express middleware. We created a [guide on how to use hooks for validation]() and you can read more about the theory and patterns behind it [in this blog post](). +While not part of the core, [feathers-hooks](https://github.com/feathersjs/feathers-hooks) is a powerful plug-in that allows you to customize service method execution with small pluggable, reusable methods (concerns), very similar to Express middleware. We created a [guide on how to use hooks for validation](/learn/validation) and you can read more about the theory and patterns behind it [in this Medium post](https://medium.com/all-about-feathersjs/api-service-composition-with-hooks-47af13aa6c01). ## Authentication diff --git a/support.md b/support.md index 1fa2356dc1..b0250b293d 100644 --- a/support.md +++ b/support.md @@ -8,7 +8,7 @@ weight: 5 ## The Feathers FAQ -On this page you can find a list of Feathers related questions that came up before. Make sure to also head over to the [Express FAQ](http://expressjs.com/faq.html). As already mentioned, since Feathers directly extends Express, everything there applies to Feathers as well. You are more than welcome to submit any questions as a [GitHub issue](https://github.com/feathersjs/feathers/issues) or on [Stackoverflow](http://stackoverflow.com) using the `feathers` or `feathersjs` tag. +On this page you can find a list of common questions that have come up before. Make sure to also check out to the [Express FAQ](http://expressjs.com/faq.html). Since Feathers directly extends Express, everything there applies to Feathers as well and your question may actually be about Express. ## Where can I get help? @@ -16,9 +16,9 @@ If you have any questions, feel free to submit them as a [GitHub issue](https:// ## Why another Node web framework? -We know! Oh God another NodeJS framework! We really didn't want to add another name to the long list of NodeJS web frameworks but also wanted to explore a different approach than any other library we have seen. We strongly believe that data is the core of the web and should be the focus of web applications. +We know! Oh God another NodeJS framework! We really didn't want to add another name to the long list of NodeJS web frameworks but also wanted to explore a different approach than any other library we have seen. We strongly believe that data is the core of the web and should be the focus of web applications, you shouldn't have to worry about the request or response objects. -Many web frameworks focus on things like rendering views, defining routes and handling HTTP requests and responses without providing a structure for implementing application logic separate from those secondary concerns. The result - even when using the MVC pattern - are big monolithic controllers where your actual application logic and how it is accessed - usually via HTTP - are all mixed up together. +Many web frameworks focus on things like rendering views, defining routes and handling HTTP requests and responses without providing a structure for implementing application logic separate from those secondary concerns. The result, even when using the MVC pattern, is usually big monolithic app with complex controllers and views or bloated models, where there isn't really a clean separation of concern between your application logic and how it is accessed (usually via HTTP). Feathers services bring two important concepts together that help to separate those concerns from how your application works: From 919da2447d235c4cb3c55237c51b0268b64caf08 Mon Sep 17 00:00:00 2001 From: David Luecke Date: Sat, 18 Jul 2015 12:15:59 -0600 Subject: [PATCH 08/11] Finalizing quick start quide --- 404.md | 15 +++ _layouts/not-found.html | 14 +++ _layouts/quick-start.html | 2 +- _less/feathers.less | 7 ++ css/feathers.min.css | 2 +- js/feathers.js | 4 +- quick-start.md | 186 +++++++++++++++++++++++++++++--------- 7 files changed, 184 insertions(+), 46 deletions(-) create mode 100644 404.md create mode 100644 _layouts/not-found.html diff --git a/404.md b/404.md new file mode 100644 index 0000000000..5c7e230916 --- /dev/null +++ b/404.md @@ -0,0 +1,15 @@ +--- +layout: not-found +title: Not Found +description: Oh no +permalink: /404.html +--- + +## Oh no, something went wrong + +Here are some links that can help you find what you were looking for: + +- [Feathers homepage](/) +- [Feathers GitHub](https://github.com/feathersjs/feathers) +- [Quick-start guide](/quick-start) +- [API documentation](/docs) diff --git a/_layouts/not-found.html b/_layouts/not-found.html new file mode 100644 index 0000000000..01787d45ed --- /dev/null +++ b/_layouts/not-found.html @@ -0,0 +1,14 @@ +--- +layout: default +--- + +
          +
          +
          +
          +

          {{page.title}}

          + {{ content }} +
          +
          +
          +
          diff --git a/_layouts/quick-start.html b/_layouts/quick-start.html index 28a499bc85..229824ae6e 100644 --- a/_layouts/quick-start.html +++ b/_layouts/quick-start.html @@ -25,7 +25,7 @@

          {{page.title}}

          - Eager to try it out yourself? Download this Gist, unpack and in the new folder run + Eager to try it out yourself? Download this Gist (view the code here), unpack and in the new folder run

          npm install feathers feathers-memory body-parser
          node app.js
          Then go to http://localhost:8080. The REST API will be available at localhost:8080/todos.
          In this guide we will learn how it all works... diff --git a/_less/feathers.less b/_less/feathers.less index 50a38385aa..9dcb2c47da 100644 --- a/_less/feathers.less +++ b/_less/feathers.less @@ -191,3 +191,10 @@ code { width: 100%; } } + +.not-found { + text-align: center; + ul { + list-style: none; + } +} diff --git a/css/feathers.min.css b/css/feathers.min.css index 079e3e92cf..a1be19bb36 100644 --- a/css/feathers.min.css +++ b/css/feathers.min.css @@ -1,4 +1,4 @@ .hll{background-color:#ffc}.c{color:#998;font-style:italic}.err{color:#a61717;background-color:#e3d2d2}.k{color:#000;font-weight:bold}.o{color:#000;font-weight:bold}.cm{color:#998;font-style:italic}.cp{color:#999;font-weight:bold;font-style:italic}.c1{color:#998;font-style:italic}.cs{color:#999;font-weight:bold;font-style:italic}.gd{color:#000;background-color:#fdd}.ge{color:#000;font-style:italic}.gr{color:#a00}.gh{color:#999}.gi{color:#000;background-color:#dfd}.go{color:#888}.gp{color:#555}.gs{font-weight:bold}.gu{color:#aaa}.gt{color:#a00}.kc{color:#000;font-weight:bold}.kd{color:#000;font-weight:bold}.kn{color:#000;font-weight:bold}.kp{color:#000;font-weight:bold}.kr{color:#000;font-weight:bold}.kt{color:#458;font-weight:bold}.m{color:#099}.s{color:#d01040}.na{color:#008080}.nb{color:#0086b3}.nc{color:#458;font-weight:bold}.no{color:#008080}.nd{color:#3c5d5d;font-weight:bold}.ni{color:#800080}.ne{color:#900;font-weight:bold}.nf{color:#900;font-weight:bold}.nl{color:#900;font-weight:bold}.nn{color:#555}.nt{color:#000080}.nv{color:#008080}.ow{color:#000;font-weight:bold}.w{color:#bbb}.mf{color:#099}.mh{color:#099}.mi{color:#099}.mo{color:#099}.sb{color:#d01040}.sc{color:#d01040}.sd{color:#d01040}.s2{color:#d01040}.se{color:#d01040}.sh{color:#d01040}.si{color:#d01040}.sx{color:#d01040}.sr{color:#009926}.s1{color:#d01040}.ss{color:#990073}.bp{color:#999}.vc{color:#008080}.vg{color:#008080}.vi{color:#008080}.il{color:#099}/*! * Font Awesome 4.3.0 by @davegandy - http://fontawesome.io - @fontawesome * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) - */@font-face{font-family:'FontAwesome';src:url('/fonts/fontawesome-webfont.eot?v=4.3.0');src:url('/fonts/fontawesome-webfont.eot?#iefix&v=4.3.0') format('embedded-opentype'),url('/fonts/fontawesome-webfont.woff2?v=4.3.0') format('woff2'),url('/fonts/fontawesome-webfont.woff?v=4.3.0') format('woff'),url('/fonts/fontawesome-webfont.ttf?v=4.3.0') format('truetype'),url('/fonts/fontawesome-webfont.svg?v=4.3.0#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;transform:translate(0,0)}.fa-lg{font-size:1.3333333333333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.2857142857142858em;text-align:center}.fa-ul{padding-left:0;margin-left:2.142857142857143em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.142857142857143em;width:2.142857142857143em;top:.14285714285714285em;text-align:center}.fa-li.fa-lg{left:-1.8571428571428572em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2);-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=0,mirror=1);-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.fa-flip-vertical{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2,mirror=1);-webkit-transform:scale(1,-1);-ms-transform:scale(1,-1);transform:scale(1,-1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-remove:before,.fa-close:before,.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook-f:before,.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{content:"\f09c"}.fa-credit-card:before{content:"\f09d"}.fa-rss:before{content:"\f09e"}.fa-hdd-o:before{content:"\f0a0"}.fa-bullhorn:before{content:"\f0a1"}.fa-bell:before{content:"\f0f3"}.fa-certificate:before{content:"\f0a3"}.fa-hand-o-right:before{content:"\f0a4"}.fa-hand-o-left:before{content:"\f0a5"}.fa-hand-o-up:before{content:"\f0a6"}.fa-hand-o-down:before{content:"\f0a7"}.fa-arrow-circle-left:before{content:"\f0a8"}.fa-arrow-circle-right:before{content:"\f0a9"}.fa-arrow-circle-up:before{content:"\f0aa"}.fa-arrow-circle-down:before{content:"\f0ab"}.fa-globe:before{content:"\f0ac"}.fa-wrench:before{content:"\f0ad"}.fa-tasks:before{content:"\f0ae"}.fa-filter:before{content:"\f0b0"}.fa-briefcase:before{content:"\f0b1"}.fa-arrows-alt:before{content:"\f0b2"}.fa-group:before,.fa-users:before{content:"\f0c0"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-cloud:before{content:"\f0c2"}.fa-flask:before{content:"\f0c3"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-copy:before,.fa-files-o:before{content:"\f0c5"}.fa-paperclip:before{content:"\f0c6"}.fa-save:before,.fa-floppy-o:before{content:"\f0c7"}.fa-square:before{content:"\f0c8"}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:"\f0c9"}.fa-list-ul:before{content:"\f0ca"}.fa-list-ol:before{content:"\f0cb"}.fa-strikethrough:before{content:"\f0cc"}.fa-underline:before{content:"\f0cd"}.fa-table:before{content:"\f0ce"}.fa-magic:before{content:"\f0d0"}.fa-truck:before{content:"\f0d1"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-google-plus-square:before{content:"\f0d4"}.fa-google-plus:before{content:"\f0d5"}.fa-money:before{content:"\f0d6"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-columns:before{content:"\f0db"}.fa-unsorted:before,.fa-sort:before{content:"\f0dc"}.fa-sort-down:before,.fa-sort-desc:before{content:"\f0dd"}.fa-sort-up:before,.fa-sort-asc:before{content:"\f0de"}.fa-envelope:before{content:"\f0e0"}.fa-linkedin:before{content:"\f0e1"}.fa-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-legal:before,.fa-gavel:before{content:"\f0e3"}.fa-dashboard:before,.fa-tachometer:before{content:"\f0e4"}.fa-comment-o:before{content:"\f0e5"}.fa-comments-o:before{content:"\f0e6"}.fa-flash:before,.fa-bolt:before{content:"\f0e7"}.fa-sitemap:before{content:"\f0e8"}.fa-umbrella:before{content:"\f0e9"}.fa-paste:before,.fa-clipboard:before{content:"\f0ea"}.fa-lightbulb-o:before{content:"\f0eb"}.fa-exchange:before{content:"\f0ec"}.fa-cloud-download:before{content:"\f0ed"}.fa-cloud-upload:before{content:"\f0ee"}.fa-user-md:before{content:"\f0f0"}.fa-stethoscope:before{content:"\f0f1"}.fa-suitcase:before{content:"\f0f2"}.fa-bell-o:before{content:"\f0a2"}.fa-coffee:before{content:"\f0f4"}.fa-cutlery:before{content:"\f0f5"}.fa-file-text-o:before{content:"\f0f6"}.fa-building-o:before{content:"\f0f7"}.fa-hospital-o:before{content:"\f0f8"}.fa-ambulance:before{content:"\f0f9"}.fa-medkit:before{content:"\f0fa"}.fa-fighter-jet:before{content:"\f0fb"}.fa-beer:before{content:"\f0fc"}.fa-h-square:before{content:"\f0fd"}.fa-plus-square:before{content:"\f0fe"}.fa-angle-double-left:before{content:"\f100"}.fa-angle-double-right:before{content:"\f101"}.fa-angle-double-up:before{content:"\f102"}.fa-angle-double-down:before{content:"\f103"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}.fa-angle-up:before{content:"\f106"}.fa-angle-down:before{content:"\f107"}.fa-desktop:before{content:"\f108"}.fa-laptop:before{content:"\f109"}.fa-tablet:before{content:"\f10a"}.fa-mobile-phone:before,.fa-mobile:before{content:"\f10b"}.fa-circle-o:before{content:"\f10c"}.fa-quote-left:before{content:"\f10d"}.fa-quote-right:before{content:"\f10e"}.fa-spinner:before{content:"\f110"}.fa-circle:before{content:"\f111"}.fa-mail-reply:before,.fa-reply:before{content:"\f112"}.fa-github-alt:before{content:"\f113"}.fa-folder-o:before{content:"\f114"}.fa-folder-open-o:before{content:"\f115"}.fa-smile-o:before{content:"\f118"}.fa-frown-o:before{content:"\f119"}.fa-meh-o:before{content:"\f11a"}.fa-gamepad:before{content:"\f11b"}.fa-keyboard-o:before{content:"\f11c"}.fa-flag-o:before{content:"\f11d"}.fa-flag-checkered:before{content:"\f11e"}.fa-terminal:before{content:"\f120"}.fa-code:before{content:"\f121"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"\f122"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"\f123"}.fa-location-arrow:before{content:"\f124"}.fa-crop:before{content:"\f125"}.fa-code-fork:before{content:"\f126"}.fa-unlink:before,.fa-chain-broken:before{content:"\f127"}.fa-question:before{content:"\f128"}.fa-info:before{content:"\f129"}.fa-exclamation:before{content:"\f12a"}.fa-superscript:before{content:"\f12b"}.fa-subscript:before{content:"\f12c"}.fa-eraser:before{content:"\f12d"}.fa-puzzle-piece:before{content:"\f12e"}.fa-microphone:before{content:"\f130"}.fa-microphone-slash:before{content:"\f131"}.fa-shield:before{content:"\f132"}.fa-calendar-o:before{content:"\f133"}.fa-fire-extinguisher:before{content:"\f134"}.fa-rocket:before{content:"\f135"}.fa-maxcdn:before{content:"\f136"}.fa-chevron-circle-left:before{content:"\f137"}.fa-chevron-circle-right:before{content:"\f138"}.fa-chevron-circle-up:before{content:"\f139"}.fa-chevron-circle-down:before{content:"\f13a"}.fa-html5:before{content:"\f13b"}.fa-css3:before{content:"\f13c"}.fa-anchor:before{content:"\f13d"}.fa-unlock-alt:before{content:"\f13e"}.fa-bullseye:before{content:"\f140"}.fa-ellipsis-h:before{content:"\f141"}.fa-ellipsis-v:before{content:"\f142"}.fa-rss-square:before{content:"\f143"}.fa-play-circle:before{content:"\f144"}.fa-ticket:before{content:"\f145"}.fa-minus-square:before{content:"\f146"}.fa-minus-square-o:before{content:"\f147"}.fa-level-up:before{content:"\f148"}.fa-level-down:before{content:"\f149"}.fa-check-square:before{content:"\f14a"}.fa-pencil-square:before{content:"\f14b"}.fa-external-link-square:before{content:"\f14c"}.fa-share-square:before{content:"\f14d"}.fa-compass:before{content:"\f14e"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"\f150"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"\f151"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"\f152"}.fa-euro:before,.fa-eur:before{content:"\f153"}.fa-gbp:before{content:"\f154"}.fa-dollar:before,.fa-usd:before{content:"\f155"}.fa-rupee:before,.fa-inr:before{content:"\f156"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"\f157"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"\f158"}.fa-won:before,.fa-krw:before{content:"\f159"}.fa-bitcoin:before,.fa-btc:before{content:"\f15a"}.fa-file:before{content:"\f15b"}.fa-file-text:before{content:"\f15c"}.fa-sort-alpha-asc:before{content:"\f15d"}.fa-sort-alpha-desc:before{content:"\f15e"}.fa-sort-amount-asc:before{content:"\f160"}.fa-sort-amount-desc:before{content:"\f161"}.fa-sort-numeric-asc:before{content:"\f162"}.fa-sort-numeric-desc:before{content:"\f163"}.fa-thumbs-up:before{content:"\f164"}.fa-thumbs-down:before{content:"\f165"}.fa-youtube-square:before{content:"\f166"}.fa-youtube:before{content:"\f167"}.fa-xing:before{content:"\f168"}.fa-xing-square:before{content:"\f169"}.fa-youtube-play:before{content:"\f16a"}.fa-dropbox:before{content:"\f16b"}.fa-stack-overflow:before{content:"\f16c"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-adn:before{content:"\f170"}.fa-bitbucket:before{content:"\f171"}.fa-bitbucket-square:before{content:"\f172"}.fa-tumblr:before{content:"\f173"}.fa-tumblr-square:before{content:"\f174"}.fa-long-arrow-down:before{content:"\f175"}.fa-long-arrow-up:before{content:"\f176"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-apple:before{content:"\f179"}.fa-windows:before{content:"\f17a"}.fa-android:before{content:"\f17b"}.fa-linux:before{content:"\f17c"}.fa-dribbble:before{content:"\f17d"}.fa-skype:before{content:"\f17e"}.fa-foursquare:before{content:"\f180"}.fa-trello:before{content:"\f181"}.fa-female:before{content:"\f182"}.fa-male:before{content:"\f183"}.fa-gittip:before,.fa-gratipay:before{content:"\f184"}.fa-sun-o:before{content:"\f185"}.fa-moon-o:before{content:"\f186"}.fa-archive:before{content:"\f187"}.fa-bug:before{content:"\f188"}.fa-vk:before{content:"\f189"}.fa-weibo:before{content:"\f18a"}.fa-renren:before{content:"\f18b"}.fa-pagelines:before{content:"\f18c"}.fa-stack-exchange:before{content:"\f18d"}.fa-arrow-circle-o-right:before{content:"\f18e"}.fa-arrow-circle-o-left:before{content:"\f190"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:"\f191"}.fa-dot-circle-o:before{content:"\f192"}.fa-wheelchair:before{content:"\f193"}.fa-vimeo-square:before{content:"\f194"}.fa-turkish-lira:before,.fa-try:before{content:"\f195"}.fa-plus-square-o:before{content:"\f196"}.fa-space-shuttle:before{content:"\f197"}.fa-slack:before{content:"\f198"}.fa-envelope-square:before{content:"\f199"}.fa-wordpress:before{content:"\f19a"}.fa-openid:before{content:"\f19b"}.fa-institution:before,.fa-bank:before,.fa-university:before{content:"\f19c"}.fa-mortar-board:before,.fa-graduation-cap:before{content:"\f19d"}.fa-yahoo:before{content:"\f19e"}.fa-google:before{content:"\f1a0"}.fa-reddit:before{content:"\f1a1"}.fa-reddit-square:before{content:"\f1a2"}.fa-stumbleupon-circle:before{content:"\f1a3"}.fa-stumbleupon:before{content:"\f1a4"}.fa-delicious:before{content:"\f1a5"}.fa-digg:before{content:"\f1a6"}.fa-pied-piper:before{content:"\f1a7"}.fa-pied-piper-alt:before{content:"\f1a8"}.fa-drupal:before{content:"\f1a9"}.fa-joomla:before{content:"\f1aa"}.fa-language:before{content:"\f1ab"}.fa-fax:before{content:"\f1ac"}.fa-building:before{content:"\f1ad"}.fa-child:before{content:"\f1ae"}.fa-paw:before{content:"\f1b0"}.fa-spoon:before{content:"\f1b1"}.fa-cube:before{content:"\f1b2"}.fa-cubes:before{content:"\f1b3"}.fa-behance:before{content:"\f1b4"}.fa-behance-square:before{content:"\f1b5"}.fa-steam:before{content:"\f1b6"}.fa-steam-square:before{content:"\f1b7"}.fa-recycle:before{content:"\f1b8"}.fa-automobile:before,.fa-car:before{content:"\f1b9"}.fa-cab:before,.fa-taxi:before{content:"\f1ba"}.fa-tree:before{content:"\f1bb"}.fa-spotify:before{content:"\f1bc"}.fa-deviantart:before{content:"\f1bd"}.fa-soundcloud:before{content:"\f1be"}.fa-database:before{content:"\f1c0"}.fa-file-pdf-o:before{content:"\f1c1"}.fa-file-word-o:before{content:"\f1c2"}.fa-file-excel-o:before{content:"\f1c3"}.fa-file-powerpoint-o:before{content:"\f1c4"}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:"\f1c5"}.fa-file-zip-o:before,.fa-file-archive-o:before{content:"\f1c6"}.fa-file-sound-o:before,.fa-file-audio-o:before{content:"\f1c7"}.fa-file-movie-o:before,.fa-file-video-o:before{content:"\f1c8"}.fa-file-code-o:before{content:"\f1c9"}.fa-vine:before{content:"\f1ca"}.fa-codepen:before{content:"\f1cb"}.fa-jsfiddle:before{content:"\f1cc"}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:"\f1cd"}.fa-circle-o-notch:before{content:"\f1ce"}.fa-ra:before,.fa-rebel:before{content:"\f1d0"}.fa-ge:before,.fa-empire:before{content:"\f1d1"}.fa-git-square:before{content:"\f1d2"}.fa-git:before{content:"\f1d3"}.fa-hacker-news:before{content:"\f1d4"}.fa-tencent-weibo:before{content:"\f1d5"}.fa-qq:before{content:"\f1d6"}.fa-wechat:before,.fa-weixin:before{content:"\f1d7"}.fa-send:before,.fa-paper-plane:before{content:"\f1d8"}.fa-send-o:before,.fa-paper-plane-o:before{content:"\f1d9"}.fa-history:before{content:"\f1da"}.fa-genderless:before,.fa-circle-thin:before{content:"\f1db"}.fa-header:before{content:"\f1dc"}.fa-paragraph:before{content:"\f1dd"}.fa-sliders:before{content:"\f1de"}.fa-share-alt:before{content:"\f1e0"}.fa-share-alt-square:before{content:"\f1e1"}.fa-bomb:before{content:"\f1e2"}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:"\f1e3"}.fa-tty:before{content:"\f1e4"}.fa-binoculars:before{content:"\f1e5"}.fa-plug:before{content:"\f1e6"}.fa-slideshare:before{content:"\f1e7"}.fa-twitch:before{content:"\f1e8"}.fa-yelp:before{content:"\f1e9"}.fa-newspaper-o:before{content:"\f1ea"}.fa-wifi:before{content:"\f1eb"}.fa-calculator:before{content:"\f1ec"}.fa-paypal:before{content:"\f1ed"}.fa-google-wallet:before{content:"\f1ee"}.fa-cc-visa:before{content:"\f1f0"}.fa-cc-mastercard:before{content:"\f1f1"}.fa-cc-discover:before{content:"\f1f2"}.fa-cc-amex:before{content:"\f1f3"}.fa-cc-paypal:before{content:"\f1f4"}.fa-cc-stripe:before{content:"\f1f5"}.fa-bell-slash:before{content:"\f1f6"}.fa-bell-slash-o:before{content:"\f1f7"}.fa-trash:before{content:"\f1f8"}.fa-copyright:before{content:"\f1f9"}.fa-at:before{content:"\f1fa"}.fa-eyedropper:before{content:"\f1fb"}.fa-paint-brush:before{content:"\f1fc"}.fa-birthday-cake:before{content:"\f1fd"}.fa-area-chart:before{content:"\f1fe"}.fa-pie-chart:before{content:"\f200"}.fa-line-chart:before{content:"\f201"}.fa-lastfm:before{content:"\f202"}.fa-lastfm-square:before{content:"\f203"}.fa-toggle-off:before{content:"\f204"}.fa-toggle-on:before{content:"\f205"}.fa-bicycle:before{content:"\f206"}.fa-bus:before{content:"\f207"}.fa-ioxhost:before{content:"\f208"}.fa-angellist:before{content:"\f209"}.fa-cc:before{content:"\f20a"}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:"\f20b"}.fa-meanpath:before{content:"\f20c"}.fa-buysellads:before{content:"\f20d"}.fa-connectdevelop:before{content:"\f20e"}.fa-dashcube:before{content:"\f210"}.fa-forumbee:before{content:"\f211"}.fa-leanpub:before{content:"\f212"}.fa-sellsy:before{content:"\f213"}.fa-shirtsinbulk:before{content:"\f214"}.fa-simplybuilt:before{content:"\f215"}.fa-skyatlas:before{content:"\f216"}.fa-cart-plus:before{content:"\f217"}.fa-cart-arrow-down:before{content:"\f218"}.fa-diamond:before{content:"\f219"}.fa-ship:before{content:"\f21a"}.fa-user-secret:before{content:"\f21b"}.fa-motorcycle:before{content:"\f21c"}.fa-street-view:before{content:"\f21d"}.fa-heartbeat:before{content:"\f21e"}.fa-venus:before{content:"\f221"}.fa-mars:before{content:"\f222"}.fa-mercury:before{content:"\f223"}.fa-transgender:before{content:"\f224"}.fa-transgender-alt:before{content:"\f225"}.fa-venus-double:before{content:"\f226"}.fa-mars-double:before{content:"\f227"}.fa-venus-mars:before{content:"\f228"}.fa-mars-stroke:before{content:"\f229"}.fa-mars-stroke-v:before{content:"\f22a"}.fa-mars-stroke-h:before{content:"\f22b"}.fa-neuter:before{content:"\f22c"}.fa-facebook-official:before{content:"\f230"}.fa-pinterest-p:before{content:"\f231"}.fa-whatsapp:before{content:"\f232"}.fa-server:before{content:"\f233"}.fa-user-plus:before{content:"\f234"}.fa-user-times:before{content:"\f235"}.fa-hotel:before,.fa-bed:before{content:"\f236"}.fa-viacoin:before{content:"\f237"}.fa-train:before{content:"\f238"}.fa-subway:before{content:"\f239"}.fa-medium:before{content:"\f23a"}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}html,button,input,select,textarea{font-family:sans-serif}body,form,fieldset,legend,input,select,textarea,button{margin:0}html{font-size:100%}body{font-family:sans-serif;font-size:16px;font-size:1rem;line-height:21px;line-height:1.3125rem;color:#434343;background-color:#fff;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}b,strong{font-weight:700}i,em,.em{font-style:italic}a{color:#669fcf}a:hover{text-decoration:none}a:focus{outline:0}a:active,a:hover{outline:0}p{margin:0 0 1.6em 0}pre{margin:1em 0}ul+p,ul+pre,ol+p,ol+pre{margin-top:0}small{font-size:80%}abbr[title]{border-bottom:1px dotted}audio,canvas,video{display:inline-block;*zoom:1;*display:inline}audio:not([controls]){display:none;height:0}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}dfn{font-style:italic}img{border:0;-ms-interpolation-mode:bicubic}svg:not(:root){overflow:hidden}figure{margin:0}.image-left{margin-right:20px}.image-right{margin-left:20px}h1,h2,h3,h4,h5,h6{line-height:normal;font-weight:normal;margin:0 0 .33em 0}h1,.h1{font-size:40px;font-size:2.5rem}h2,.h2{font-size:32px;font-size:2rem}h3,.h3{font-size:26px;font-size:1.625rem}h4,.h4{font-size:20px;font-size:1.25rem}h5,.h5{font-size:18px;font-size:1.125rem}h6,.h6{font-size:16px;font-size:1rem}.no-style-heading{margin:0;font-size:100%}hr{border:0;background:0;outline:0;background-color:#ddd;margin:2em 0;*margin:1em 0;-moz-box-sizing:content-box;box-sizing:content-box;height:1px}blockquote{font-size:22px;font-size:1.375rem;line-height:32px;line-height:2rem;color:#434343;margin:1em 0;font-style:italic}blockquote p{margin:1em 0}cite{color:#434343;font-style:normal;font-weight:normal;font-size:16px;font-size:1rem;line-height:normal}q{font-style:italic;quotes:none}q:before,q:after{content:'';content:none}mark{background:#ff0;color:#111}code,kbd,pre,samp{word-wrap:break-word;font-family:'courier new',monospace,serif;font-size:13px;font-size:.8125rem;line-height:normal;font-weight:normal;background-color:#f1f1f1;padding:10px}code{color:#111}dl,menu,ol,ul{margin:1em 0}dd,ul ul,ol ol,ul ol,ol ul{margin:0}dt{font-weight:normal}dd{margin-bottom:1em}menu,ol,ul{padding:0 0 0 22px}nav ul,nav ol{list-style:none;list-style-image:none}.unstyled-list{list-style:none;padding:0;margin:0}.unstyled-list li{margin-top:0;margin-bottom:0}.inline-list{list-style:none;padding:0;margin:0;display:inline-block;*zoom:1;*display:inline}.inline-list li{margin-top:0;margin-bottom:0}.inline-list li{display:inline-block;*zoom:1;*display:inline}table{width:100%;margin:1em 0;table-layout:fixed;border-collapse:collapse;border-spacing:0;border-right:1px solid #f1f1f1;border-bottom:1px solid #f1f1f1;word-wrap:break-word;-ms-word-wrap:break-word;*white-space:normal}table th,table td{padding:8px;text-align:left;vertical-align:top;border-top:1px solid #eee;border-left:1px solid #eee}table thead th,table tfoot th{vertical-align:bottom;font-weight:normal;background-color:#f1f1f1;color:#333}table caption{padding:8px;font-style:normal;text-align:left;font-weight:normal;border-bottom:0}fieldset{border:0;padding:0}legend{border:0;padding:0;white-space:normal;*margin-left:-7px;font-weight:normal}label{margin:0;cursor:pointer}button,input,select,textarea{font-size:100%;vertical-align:baseline;*vertical-align:middle}input[type=text],input[type=password],input[type=email],input[type=search],input[type=tel],textarea{padding:5px;-webkit-appearance:none;-moz-appearance:none;font-weight:normal;line-height:normal;background-color:#fff;border:1px solid #ccc;color:#111}input[type=checkbox],input[type=radio]{cursor:pointer;box-sizing:border-box;line-height:normal;margin:0;padding:0;*height:13px;*width:13px}.checkbox{display:block;margin:.2em 0}.checkbox input[type=checkbox],.checkbox input[type=radio]{margin-top:.05em;float:left}.checkbox label{padding-left:5px;overflow:hidden;display:table;*zoom:1}button,input{line-height:normal}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer;*overflow:visible}button[disabled],html input[disabled]{cursor:default}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top;resize:none}.button{border:0;padding:1em 3em;background-color:#e74b3c;color:#fff;text-decoration:none;text-align:center;display:inline-block;*zoom:1;*display:inline;position:relative}.button:hover{background-color:#fc5547}.button:active{top:1px}.grey-button{background-color:#eee;color:#434343}.grey-button:hover{background-color:#f1f1f1}.button[disabled],.button.disabled{color:#999;background-color:#f1f1f1}.unstyled-button{font-size:16px;font-size:1rem;color:#27ae61;text-decoration:underline;border:0;background:transparent;height:auto;padding:0;cursor:pointer;outline:0}.unstyled-button:hover{text-decoration:none}.unstyled-button[disabled],.unstyled-button.disabled{text-decoration:none;color:#999;background-color:#ccc}.section{position:relative}.container{max-width:960px;margin-left:auto;margin-right:auto;padding-left:10px;padding-right:10px}.container-full{max-width:960px;margin-left:auto;margin-right:auto}.col{float:left;padding-left:10px;padding-right:10px}[class*="pull-"],[class*="push-"]{position:relative}.no-gutter{padding-left:0;padding-right:0}.col-1{width:8.33333%;width:calc(8.333333333333334%);width:-webkit-calc(8.333333333333334%);width:-moz-calc(8.333333333333334%)}.col-2{width:16.66667%;width:calc(16.666666666666668%);width:-webkit-calc(16.666666666666668%);width:-moz-calc(16.666666666666668%)}.col-3{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.col-4{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.col-5{width:41.66665%;width:calc(41.66666666666667%);width:-webkit-calc(41.66666666666667%);width:-moz-calc(41.66666666666667%)}.col-6{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.col-7{width:58.33333%;width:calc(58.333333333333336%);width:-webkit-calc(58.333333333333336%);width:-moz-calc(58.333333333333336%)}.col-8{width:66.66666%;width:calc(66.66666666666667%);width:-webkit-calc(66.66666666666667%);width:-moz-calc(66.66666666666667%)}.col-9{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.col-10{width:83.33333%;width:calc(83.33333333333334%);width:-webkit-calc(83.33333333333334%);width:-moz-calc(83.33333333333334%)}.col-11{width:91.66666%;width:calc(91.66666666666667%);width:-webkit-calc(91.66666666666667%);width:-moz-calc(91.66666666666667%)}.col-12{width:100%}.col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.push-1{left:8.33333%;left:calc(8.333333333333334%);left:-webkit-calc(8.333333333333334%);left:-moz-calc(8.333333333333334%)}.pull-1{left:-8.33333%;left:calc(-8.333333333333334%);left:-webkit-calc(-8.333333333333334%);left:-moz-calc(-8.333333333333334%)}.push-2{left:16.66667%;left:calc(16.666666666666668%);left:-webkit-calc(16.666666666666668%);left:-moz-calc(16.666666666666668%)}.pull-2{left:-16.66667%;left:calc(-16.666666666666668%);left:-webkit-calc(-16.666666666666668%);left:-moz-calc(-16.666666666666668%)}.push-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.pull-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.push-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.pull-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.push-5{left:41.66665%;left:calc(41.66666666666667%);left:-webkit-calc(41.66666666666667%);left:-moz-calc(41.66666666666667%)}.pull-5{left:-41.66665%;left:calc(-41.66666666666667%);left:-webkit-calc(-41.66666666666667%);left:-moz-calc(-41.66666666666667%)}.push-6{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.pull-6{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.push-7{left:58.33333%;left:calc(58.333333333333336%);left:-webkit-calc(58.333333333333336%);left:-moz-calc(58.333333333333336%)}.pull-7{left:-58.33333%;left:calc(-58.333333333333336%);left:-webkit-calc(-58.333333333333336%);left:-moz-calc(-58.333333333333336%)}.push-8{left:66.66666%;left:calc(66.66666666666667%);left:-webkit-calc(66.66666666666667%);left:-moz-calc(66.66666666666667%)}.pull-8{left:-66.66666%;left:calc(-66.66666666666667%);left:-webkit-calc(-66.66666666666667%);left:-moz-calc(-66.66666666666667%)}.push-9{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.pull-9{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.push-10{left:83.33333%;left:calc(83.33333333333334%);left:-webkit-calc(83.33333333333334%);left:-moz-calc(83.33333333333334%)}.pull-10{left:-83.33333%;left:calc(-83.33333333333334%);left:-webkit-calc(-83.33333333333334%);left:-moz-calc(-83.33333333333334%)}.push-11{left:91.66666%;left:calc(91.66666666666667%);left:-webkit-calc(91.66666666666667%);left:-moz-calc(91.66666666666667%)}.pull-11{left:-91.66666%;left:calc(-91.66666666666667%);left:-webkit-calc(-91.66666666666667%);left:-moz-calc(-91.66666666666667%)}.row{padding-top:1em;padding-bottom:1em}.clear:before,.clear:after{content:"";display:table}.clear:after{clear:both}.clear{zoom:1}.left{float:left}.right{float:right}.block{display:block}.inline{display:inline}.inline-block{display:inline-block;*zoom:1;*display:inline}.none,.hidden,[hidden],.no-desktop{display:none}.heavy{font-weight:900}.strong{font-weight:700}.normal{font-weight:normal}.thin{font-weight:300}.fine{font-weight:100}.italic{font-style:italic}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.left-text{text-align:left}.right-text{text-align:right}.center-text{text-align:center}.justify-text{text-align:justify}.visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;overflow:hidden;padding:0;position:absolute;width:1px;left:-9999em}.visuallyvisible{clip:auto;width:auto;height:auto;overflow:visible;left:0}.no-margin{margin:0}.no-padding{padding:0}@media only screen and (min-width:740px) and (max-width:960px){.container,.tablet-container{max-width:960px;padding-left:20px;padding-right:20px;margin-left:auto;margin-right:auto;float:none}.container:first-child,.tablet-container:first-child{margin-left:auto}.tablet-container-full{padding-left:0;padding-right:0;margin-left:auto;margin-right:auto;float:none}.tablet-container-full:first-child{margin-left:auto}.tablet-no-gutter{padding-left:0;padding-right:0}.tablet-col-1{width:8.33333%;width:calc(8.333333333333334%);width:-webkit-calc(8.333333333333334%);width:-moz-calc(8.333333333333334%)}.tablet-col-2{width:16.66667%;width:calc(16.666666666666668%);width:-webkit-calc(16.666666666666668%);width:-moz-calc(16.666666666666668%)}.tablet-col-3{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.tablet-col-4{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.tablet-col-5{width:41.66665%;width:calc(41.66666666666667%);width:-webkit-calc(41.66666666666667%);width:-moz-calc(41.66666666666667%)}.tablet-col-6{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.tablet-col-7{width:58.33333%;width:calc(58.333333333333336%);width:-webkit-calc(58.333333333333336%);width:-moz-calc(58.333333333333336%)}.tablet-col-8{width:66.66666%;width:calc(66.66666666666667%);width:-webkit-calc(66.66666666666667%);width:-moz-calc(66.66666666666667%)}.tablet-col-9{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.tablet-col-10{width:83.33333%;width:calc(83.33333333333334%);width:-webkit-calc(83.33333333333334%);width:-moz-calc(83.33333333333334%)}.tablet-col-11{width:91.66666%;width:calc(91.66666666666667%);width:-webkit-calc(91.66666666666667%);width:-moz-calc(91.66666666666667%)}.tablet-col-12{width:100%}.tablet-col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.tablet-col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.tablet-col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.tablet-col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.tablet-push-1{left:8.33333%;left:calc(8.333333333333334%);left:-webkit-calc(8.333333333333334%);left:-moz-calc(8.333333333333334%)}.tablet-pull-1{left:-8.33333%;left:calc(-8.333333333333334%);left:-webkit-calc(-8.333333333333334%);left:-moz-calc(-8.333333333333334%)}.tablet-push-2{left:16.66667%;left:calc(16.666666666666668%);left:-webkit-calc(16.666666666666668%);left:-moz-calc(16.666666666666668%)}.tablet-pull-2{left:-16.66667%;left:calc(-16.666666666666668%);left:-webkit-calc(-16.666666666666668%);left:-moz-calc(-16.666666666666668%)}.tablet-push-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.tablet-pull-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.tablet-push-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.tablet-pull-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.tablet-push-5{left:41.66665%;left:calc(41.66666666666667%);left:-webkit-calc(41.66666666666667%);left:-moz-calc(41.66666666666667%)}.tablet-pull-5{left:-41.66665%;left:calc(-41.66666666666667%);left:-webkit-calc(-41.66666666666667%);left:-moz-calc(-41.66666666666667%)}.tablet-push-6{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.tablet-pull-6{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.tablet-push-7{left:58.33333%;left:calc(58.333333333333336%);left:-webkit-calc(58.333333333333336%);left:-moz-calc(58.333333333333336%)}.tablet-pull-7{left:-58.33333%;left:calc(-58.333333333333336%);left:-webkit-calc(-58.333333333333336%);left:-moz-calc(-58.333333333333336%)}.tablet-push-8{left:66.66666%;left:calc(66.66666666666667%);left:-webkit-calc(66.66666666666667%);left:-moz-calc(66.66666666666667%)}.tablet-pull-8{left:-66.66666%;left:calc(-66.66666666666667%);left:-webkit-calc(-66.66666666666667%);left:-moz-calc(-66.66666666666667%)}.tablet-push-9{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.tablet-pull-9{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.tablet-push-10{left:83.33333%;left:calc(83.33333333333334%);left:-webkit-calc(83.33333333333334%);left:-moz-calc(83.33333333333334%)}.tablet-pull-10{left:-83.33333%;left:calc(-83.33333333333334%);left:-webkit-calc(-83.33333333333334%);left:-moz-calc(-83.33333333333334%)}.tablet-push-11{left:91.66666%;left:calc(91.66666666666667%);left:-webkit-calc(91.66666666666667%);left:-moz-calc(91.66666666666667%)}.tablet-pull-11{left:-91.66666%;left:calc(-91.66666666666667%);left:-webkit-calc(-91.66666666666667%);left:-moz-calc(-91.66666666666667%)}.tablet-no-push,.tablet-no-pull{left:auto}.tablet-row{padding-top:1em;padding-bottom:1em}.tablet-full{left:auto;clear:both;float:none;width:100%;margin:1em 0 0 0;display:block}.tablet-full:first-child{margin-top:0}.tablet-left-text{text-align:left}.tablet-right-text{text-align:right}.tablet-center-text{text-align:center}.tablet-left{float:left}.tablet-right{float:right}.tablet-no-float{float:none}.tablet-no-margin{margin:0}.tablet-no-padding{padding:0}.no-tablet{display:none}.show-tablet{display:block}}@media only screen and (max-width:739px){.container,.mobile-container{padding-left:20px;padding-right:20px;margin-left:auto;margin-right:auto;float:none}.container:first-child,.mobile-container:first-child{margin-left:auto}.mobile-container-full{padding-left:0;padding-right:0;margin-left:auto;margin-right:auto;float:none}.mobile-container-full:first-child{margin-left:auto}.mobile-no-gutter{padding-left:0;padding-right:0}.mobile-col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.mobile-col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.mobile-col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.mobile-col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.mobile-push-1-2{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.mobile-pull-1-2{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.mobile-push-1-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.mobile-pull-1-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.mobile-push-1-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.mobile-pull-1-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.mobile-push-3-4{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.mobile-pull-3-4{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.mobile-no-push,.mobile-no-pull{left:auto}.mobile-row{padding-top:1em;padding-bottom:1em}.mobile-full{left:auto;clear:both;float:none;width:100%;margin:.2em 0 0 0;display:block}.mobile-full:first-child{margin-top:0}.mobile-left-text{text-align:left}.mobile-right-text{text-align:right}.mobile-center-text{text-align:center}.mobile-left{float:left}.mobile-right{float:right}.mobile-no-float{float:none}.mobile-no-margin{margin:0}.mobile-no-padding{padding:0}table th,table td{padding:4px}.no-mobile{display:none}.show-mobile{display:block}}@media print{*{background:transparent}a,a:visited{text-decoration:underline}abbr[title]:after{content:" (" attr(title) ")"}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100%}@page{margin:.5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}}html,body{height:100%}.absolute{position:absolute}.relative{position:relative}.full{width:100%}.no-scroll{overflow:hidden}.table{display:table;margin:0 auto}.xlarge-top{margin-top:60px}.large-top{margin-top:40px}.medium-top{margin-top:20px}.small-top{margin-top:10px}.mini-top{margin-top:5px}.no-left-padding{padding-left:0}.no-right-padding{padding-right:0}@media only screen and (max-width:739px){.mobile-hide{display:none}.mobile-xlarge-top{margin-top:60px}.mobile-large-top{margin-top:40px}.mobile-medium-top{margin-top:20px}.mobile-small-top{margin-top:10px}.mobile-mini-top{margin-top:5px}}html,body{font-family:'Roboto','Helvetica Neue','Arial','Helvetica','Lucida Grande',sans-serif;font-weight:300;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}h1,h2,h3,h4,h5{font-weight:300}p{margin:0 0 1em 0}pre,code{padding:5px 10px;color:#6e6e6e;font-size:14px;line-height:20px;font-weight:100;background:#f8f8f8;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}a{color:#333;text-decoration:none;-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out}a.active{color:#000}a:hover{color:#000}a:hover .fa-trash-o{color:#e2717f}a.primary{color:#e2717f}a.primary:hover{color:#d94759}img{max-width:100%}hr{margin:.5em 0;width:100%}i.right-padding{padding-right:10px}i.left-padding{padding-left:10px}.button{outline:0;padding:1em 1.5em;background:#fafafa;color:#333;white-space:nowrap;background-clip:padding-box;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.button.disabled,.button[disabled]{-moz-opacity:.7;-khtml-opacity:.7;-webkit-opacity:.7;opacity:.7;-ms-filter:alpha(opacity=70);filter:alpha(opacity=70);cursor:default}.button:hover:not(.disabled),.button:hover:not([disabled]){background:#d9d9d9}.button.large{padding:1em 4em}.button.small{padding:.6em .8em}.button.x-small{padding:.4em .6em}.button.primary-button{color:#fff;background:#e2717f}.button.primary-button:hover,.button.primary-button:focus{color:#f2f2f2;background:#de5c6c}.button.primary-button:hover.disabled,.button.primary-button:focus.disabled,.button.primary-button:hover:disabled,.button.primary-button:focus:disabled{background:#e2717f}.button.secondary-button{background:0;border:1px solid #eee}.button.secondary-button:hover:not(.active),.button.secondary-button:hover:not(.disabled),.button.secondary-button:hover:not(:disabled),.button.secondary-button:focus:not(.active),.button.secondary-button:focus:not(.disabled),.button.secondary-button:focus:not(:disabled){color:#666;background:#f8f8f8}.button.secondary-button.active{color:#595959;background:#ebebeb;border:1px solid #eee}.button.secondary-button.active:hover{color:#595959;background:#ebebeb;border:1px solid #eee}.button.remove-button{background:#e2717f;color:#fff;padding:.9em 1.5em}.button.remove-button:hover,.button.remove-button:focus{background:#de5c6c}.button.remove-button:hover.disabled,.button.remove-button:focus.disabled,.button.remove-button:hover:disabled,.button.remove-button:focus:disabled{background:#e2717f}.button.transparent-button{background:0;color:#fff;border:1px solid #f2f2f2}.button.transparent-button:hover:not(.disabled),.button.transparent-button:hover:not(:disabled){background:rgba(255,255,255,0.1);color:#fff}.button-group>.button{padding:.8em 1em;text-align:center;background:#fff;border-top:1px solid #eee;border-bottom:1px solid #eee;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.button-group>.button i.fa{margin-right:5px}.button-group>.button:first-child{border-left:1px solid #eee;-webkit-border-top-right-radius:0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:5px;-webkit-border-top-left-radius:5px;-moz-border-radius-topright:0;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:5px;-moz-border-radius-topleft:5px;border-top-right-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:5px;border-top-left-radius:5px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.button-group>.button:last-child{border-right:1px solid #eee;-webkit-border-top-right-radius:5px;-webkit-border-bottom-right-radius:5px;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:0;-moz-border-radius-topright:5px;-moz-border-radius-bottomright:5px;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:0;border-top-right-radius:5px;border-bottom-right-radius:5px;border-bottom-left-radius:0;border-top-left-radius:0;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.button-group>.button:hover:not(.active),.button-group>.button:focus:not(.active){color:#666;background:#f8f8f8}.button-group>.button.active{color:#595959;background:#ebebeb;border:1px solid #eee}.button-group>.button.active:hover{color:#595959;background:#ebebeb;border:1px solid #eee}.button-group.small>.button{padding:.6em .8em}.button-group.x-small>.button{padding:.4em .6em}form .col,form .input-wrapper{position:relative}form input,form input[type="text"],form input[type="password"],form input[type="email"],form input[type="search"],form input[type="tel"],form input[type="number"],form input[type="date"],form textarea{width:100%;padding:.8em .6em .6em;outline:0;border:1px solid #d3d3d3;font-size:1.1em;line-height:1;background:#fff;color:#666;-webkit-appearance:none;-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out}form input:focus,form input[type="text"]:focus,form input[type="password"]:focus,form input[type="email"]:focus,form input[type="search"]:focus,form input[type="tel"]:focus,form input[type="number"]:focus,form input[type="date"]:focus,form textarea:focus{color:#333;border:1px solid #a0a0a0;-moz-box-shadow:0 0 2px #a0a0a0;-webkit-box-shadow:0 0 2px #a0a0a0;box-shadow:0 0 2px #a0a0a0;-webkit-box-shadow:0 0 2px #a0a0a0 0 0 #000;box-shadow:0 0 2px #a0a0a0 0 0 #000}form input:focus+label,form input[type="text"]:focus+label,form input[type="password"]:focus+label,form input[type="email"]:focus+label,form input[type="search"]:focus+label,form input[type="tel"]:focus+label,form input[type="number"]:focus+label,form input[type="date"]:focus+label,form textarea:focus+label{color:#666;font-weight:400}form input.success,form input[type="text"].success,form input[type="password"].success,form input[type="email"].success,form input[type="search"].success,form input[type="tel"].success,form input[type="number"].success,form input[type="date"].success,form textarea.success{border:1px solid #43cea2;-moz-box-shadow:0 0 2px #43cea2;-webkit-box-shadow:0 0 2px #43cea2;box-shadow:0 0 2px #43cea2;-webkit-box-shadow:0 0 2px #43cea2 0 0 #000;box-shadow:0 0 2px #43cea2 0 0 #000}form input.success+label,form input[type="text"].success+label,form input[type="password"].success+label,form input[type="email"].success+label,form input[type="search"].success+label,form input[type="tel"].success+label,form input[type="number"].success+label,form input[type="date"].success+label,form textarea.success+label{color:#43cea2;font-weight:400}form input.error,form input[type="text"].error,form input[type="password"].error,form input[type="email"].error,form input[type="search"].error,form input[type="tel"].error,form input[type="number"].error,form input[type="date"].error,form textarea.error{border:1px solid #e2717f;-moz-box-shadow:0 0 2px #e2717f;-webkit-box-shadow:0 0 2px #e2717f;box-shadow:0 0 2px #e2717f;-webkit-box-shadow:0 0 2px #e2717f 0 0 #000;box-shadow:0 0 2px #e2717f 0 0 #000}form input.error+label,form input[type="text"].error+label,form input[type="password"].error+label,form input[type="email"].error+label,form input[type="search"].error+label,form input[type="tel"].error+label,form input[type="number"].error+label,form input[type="date"].error+label,form textarea.error+label{color:#e2717f;font-weight:400}form input::-webkit-input-placeholder,form input[type="text"]::-webkit-input-placeholder,form input[type="password"]::-webkit-input-placeholder,form input[type="email"]::-webkit-input-placeholder,form input[type="search"]::-webkit-input-placeholder,form input[type="tel"]::-webkit-input-placeholder,form input[type="number"]::-webkit-input-placeholder,form input[type="date"]::-webkit-input-placeholder,form textarea::-webkit-input-placeholder{color:#d3d3d3;font-weight:300}form [placeholder]:focus::-webkit-input-placeholder{-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out;opacity:0}form input[type="number"]::-webkit-inner-spin-button,form input[type="number"]::-webkit-outer-spin-button,form input[type="date"]::-webkit-inner-spin-button,form input[type="date"]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}form .select-style{position:relative;display:block;width:100%;border:1px solid #a0a0a0;background:#fff}form .select-style .fa-caret-down{position:absolute;right:.6em;top:.8em;color:#a0a0a0;font-size:1.4em}form .select-style select{padding:.8em 0;margin-left:.6em;width:100%;border:0;box-shadow:none;background:transparent;background-image:none;-webkit-appearance:none;color:#a0a0a0;font-size:1.2em}form .select-style select:hover{cursor:pointer}form .select-style select:focus{outline:0}form fieldset.row{padding:.5em 0}form label{position:absolute;left:5px;top:-5px;padding:0 5px;background:white;color:#a0a0a0;font-size:12px;line-height:12px;text-transform:uppercase;pointer-events:none;z-index:2}.modal-wrapper{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.3);display:none;z-index:1001;will-change:transform}.modal-wrapper .modal{position:relative;color:#333;display:none}.modal-wrapper .modal a.close{position:absolute;padding:6px 12px 9px;border:1px solid;border-radius:20px;font-weight:300;font-size:27px}.modal-wrapper .modal section.modal-content{padding:20px}.modal-wrapper:not(.fullscreen) .modal{min-height:300px;max-width:434px;margin:60px auto 0;background-color:#fff;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.modal-wrapper:not(.fullscreen) .modal a.close{right:-45px;top:-30px;color:#fff}.modal-wrapper.fullscreen{background:#fff}.modal-wrapper.fullscreen .modal{height:100%;overflow:auto}.modal-wrapper.fullscreen .modal a.close{right:20px;top:20px}.notice{position:fixed;bottom:0;right:10px;height:100px;width:300px;padding:5px 10px 5px 10px;display:none;color:#fff;z-index:1005;-webkit-border-top-right-radius:5px;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:5px;-moz-border-radius-topright:5px;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:5px;border-top-right-radius:5px;border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-left-radius:5px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.notice.success{background-color:#43cea2}.notice.warning{background-color:#f4ed6b}.notice.error{background-color:#e2717f}.notice header.notice-header{position:relative;margin-bottom:.2em}.notice section.notice-content{height:70px;width:100%;overflow:auto;font-size:.8em}.notice a.close{position:absolute;top:3px;right:0;padding:0 4px 2px;border:1px solid;border-radius:100%;font-weight:300;font-size:12px;line-height:12px;color:#fff}.notice a.close:hover{color:#ccc}nav{font-size:18px;font-size:1.125rem}nav .navbar{margin:0 auto;display:table;padding:10px 0}nav li{margin:0 10px}nav a{display:inline-block;line-height:60px;vertical-align:middle}nav a.logo{height:60px;width:60px}@media(max-width:739px){nav{font-size:14px;font-size:.875rem}nav a{line-height:40px}nav a.logo{height:40px;width:40px}}#toc{position:fixed;top:80px;height:100%;width:220px;overflow:auto;padding-bottom:100px}#toc a{color:#333}#toc a:hover{color:#1a1a1a}#toc li>ul{display:none}#toc li>ul.unstyled-list{margin-left:10px}#toc li.active>a{font-weight:bold}#toc li.active>ul{display:block}#toc ul.nav>li.active>ul>li{list-style:none}footer{padding:60px 0;color:#d3d3d3;background:#333}footer i.fa-heart{color:#e2717f}footer i.fa-beer{color:#f4ed6b}html,body{background:#fff;color:#333}.kd{color:#a783b6}.k{color:#43cea2}h1.logo{font-size:64px;font-size:4rem}.gist pre,.gist .file-data{font-size:14px!important}section{padding:40px 0}code{padding:0}#hero .badges,#hero .github-links{padding:.3em 0}#hero .badges p,#hero .github-links p{margin:0}#ship h3{margin-bottom:1em}#ship img.ship-it{display:table;height:300px;width:300px;margin:0 auto;background:#d3d3d3;-webkit-border-radius:100%;-moz-border-radius:100%;border-radius:100%}#plugins{color:#fff;background:#333}#plugins p{color:#d3d3d3}#plugins ul li{padding:10px 20px}#plugins ul li a{display:inline-block}#plugins ul li a img{height:100px;max-width:160px}@media(max-width:739px){#plugins ul li a img{height:60px;max-width:120px}}#features{color:#fff;background:#e2717f}#features h4{color:#982e3e}#features a.primary{color:#f8f8f8;border-bottom:1px dashed #f8f8f8}#features a.primary:hover{color:#dfdfdf;border-bottom:1px dashed #dfdfdf}#comparison img{margin:0 auto}.example,.example .row{padding-bottom:0}.page,.example{padding-top:0;margin-bottom:0}.page a,.example a{color:#e2717f}.page a:hover,.example a:hover{color:#d94759}.page .file-data .line-numbers,.example .file-data .line-numbers{width:40px}#todo-example{padding-bottom:2em}#todo-example input[type="text"]{margin:10px 0}#todo-example ul.todos{height:320px}#todo-example ul.todos li{padding:5px 0}#todo-example ul.todos li input[type="checkbox"]{margin-top:.2em}#todo-example ul.todos li span{margin-left:5px}#todo-example ul.todos li.done label{text-decoration:line-through;color:#998}#todo-example ul.todos li .delete{font-weight:bold}#todo-example label{float:left}#todo-example .primary-button{width:100%} \ No newline at end of file + */@font-face{font-family:'FontAwesome';src:url('/fonts/fontawesome-webfont.eot?v=4.3.0');src:url('/fonts/fontawesome-webfont.eot?#iefix&v=4.3.0') format('embedded-opentype'),url('/fonts/fontawesome-webfont.woff2?v=4.3.0') format('woff2'),url('/fonts/fontawesome-webfont.woff?v=4.3.0') format('woff'),url('/fonts/fontawesome-webfont.ttf?v=4.3.0') format('truetype'),url('/fonts/fontawesome-webfont.svg?v=4.3.0#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;transform:translate(0,0)}.fa-lg{font-size:1.3333333333333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.2857142857142858em;text-align:center}.fa-ul{padding-left:0;margin-left:2.142857142857143em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.142857142857143em;width:2.142857142857143em;top:.14285714285714285em;text-align:center}.fa-li.fa-lg{left:-1.8571428571428572em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2);-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=0,mirror=1);-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.fa-flip-vertical{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2,mirror=1);-webkit-transform:scale(1,-1);-ms-transform:scale(1,-1);transform:scale(1,-1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-remove:before,.fa-close:before,.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook-f:before,.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{content:"\f09c"}.fa-credit-card:before{content:"\f09d"}.fa-rss:before{content:"\f09e"}.fa-hdd-o:before{content:"\f0a0"}.fa-bullhorn:before{content:"\f0a1"}.fa-bell:before{content:"\f0f3"}.fa-certificate:before{content:"\f0a3"}.fa-hand-o-right:before{content:"\f0a4"}.fa-hand-o-left:before{content:"\f0a5"}.fa-hand-o-up:before{content:"\f0a6"}.fa-hand-o-down:before{content:"\f0a7"}.fa-arrow-circle-left:before{content:"\f0a8"}.fa-arrow-circle-right:before{content:"\f0a9"}.fa-arrow-circle-up:before{content:"\f0aa"}.fa-arrow-circle-down:before{content:"\f0ab"}.fa-globe:before{content:"\f0ac"}.fa-wrench:before{content:"\f0ad"}.fa-tasks:before{content:"\f0ae"}.fa-filter:before{content:"\f0b0"}.fa-briefcase:before{content:"\f0b1"}.fa-arrows-alt:before{content:"\f0b2"}.fa-group:before,.fa-users:before{content:"\f0c0"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-cloud:before{content:"\f0c2"}.fa-flask:before{content:"\f0c3"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-copy:before,.fa-files-o:before{content:"\f0c5"}.fa-paperclip:before{content:"\f0c6"}.fa-save:before,.fa-floppy-o:before{content:"\f0c7"}.fa-square:before{content:"\f0c8"}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:"\f0c9"}.fa-list-ul:before{content:"\f0ca"}.fa-list-ol:before{content:"\f0cb"}.fa-strikethrough:before{content:"\f0cc"}.fa-underline:before{content:"\f0cd"}.fa-table:before{content:"\f0ce"}.fa-magic:before{content:"\f0d0"}.fa-truck:before{content:"\f0d1"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-google-plus-square:before{content:"\f0d4"}.fa-google-plus:before{content:"\f0d5"}.fa-money:before{content:"\f0d6"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-columns:before{content:"\f0db"}.fa-unsorted:before,.fa-sort:before{content:"\f0dc"}.fa-sort-down:before,.fa-sort-desc:before{content:"\f0dd"}.fa-sort-up:before,.fa-sort-asc:before{content:"\f0de"}.fa-envelope:before{content:"\f0e0"}.fa-linkedin:before{content:"\f0e1"}.fa-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-legal:before,.fa-gavel:before{content:"\f0e3"}.fa-dashboard:before,.fa-tachometer:before{content:"\f0e4"}.fa-comment-o:before{content:"\f0e5"}.fa-comments-o:before{content:"\f0e6"}.fa-flash:before,.fa-bolt:before{content:"\f0e7"}.fa-sitemap:before{content:"\f0e8"}.fa-umbrella:before{content:"\f0e9"}.fa-paste:before,.fa-clipboard:before{content:"\f0ea"}.fa-lightbulb-o:before{content:"\f0eb"}.fa-exchange:before{content:"\f0ec"}.fa-cloud-download:before{content:"\f0ed"}.fa-cloud-upload:before{content:"\f0ee"}.fa-user-md:before{content:"\f0f0"}.fa-stethoscope:before{content:"\f0f1"}.fa-suitcase:before{content:"\f0f2"}.fa-bell-o:before{content:"\f0a2"}.fa-coffee:before{content:"\f0f4"}.fa-cutlery:before{content:"\f0f5"}.fa-file-text-o:before{content:"\f0f6"}.fa-building-o:before{content:"\f0f7"}.fa-hospital-o:before{content:"\f0f8"}.fa-ambulance:before{content:"\f0f9"}.fa-medkit:before{content:"\f0fa"}.fa-fighter-jet:before{content:"\f0fb"}.fa-beer:before{content:"\f0fc"}.fa-h-square:before{content:"\f0fd"}.fa-plus-square:before{content:"\f0fe"}.fa-angle-double-left:before{content:"\f100"}.fa-angle-double-right:before{content:"\f101"}.fa-angle-double-up:before{content:"\f102"}.fa-angle-double-down:before{content:"\f103"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}.fa-angle-up:before{content:"\f106"}.fa-angle-down:before{content:"\f107"}.fa-desktop:before{content:"\f108"}.fa-laptop:before{content:"\f109"}.fa-tablet:before{content:"\f10a"}.fa-mobile-phone:before,.fa-mobile:before{content:"\f10b"}.fa-circle-o:before{content:"\f10c"}.fa-quote-left:before{content:"\f10d"}.fa-quote-right:before{content:"\f10e"}.fa-spinner:before{content:"\f110"}.fa-circle:before{content:"\f111"}.fa-mail-reply:before,.fa-reply:before{content:"\f112"}.fa-github-alt:before{content:"\f113"}.fa-folder-o:before{content:"\f114"}.fa-folder-open-o:before{content:"\f115"}.fa-smile-o:before{content:"\f118"}.fa-frown-o:before{content:"\f119"}.fa-meh-o:before{content:"\f11a"}.fa-gamepad:before{content:"\f11b"}.fa-keyboard-o:before{content:"\f11c"}.fa-flag-o:before{content:"\f11d"}.fa-flag-checkered:before{content:"\f11e"}.fa-terminal:before{content:"\f120"}.fa-code:before{content:"\f121"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"\f122"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"\f123"}.fa-location-arrow:before{content:"\f124"}.fa-crop:before{content:"\f125"}.fa-code-fork:before{content:"\f126"}.fa-unlink:before,.fa-chain-broken:before{content:"\f127"}.fa-question:before{content:"\f128"}.fa-info:before{content:"\f129"}.fa-exclamation:before{content:"\f12a"}.fa-superscript:before{content:"\f12b"}.fa-subscript:before{content:"\f12c"}.fa-eraser:before{content:"\f12d"}.fa-puzzle-piece:before{content:"\f12e"}.fa-microphone:before{content:"\f130"}.fa-microphone-slash:before{content:"\f131"}.fa-shield:before{content:"\f132"}.fa-calendar-o:before{content:"\f133"}.fa-fire-extinguisher:before{content:"\f134"}.fa-rocket:before{content:"\f135"}.fa-maxcdn:before{content:"\f136"}.fa-chevron-circle-left:before{content:"\f137"}.fa-chevron-circle-right:before{content:"\f138"}.fa-chevron-circle-up:before{content:"\f139"}.fa-chevron-circle-down:before{content:"\f13a"}.fa-html5:before{content:"\f13b"}.fa-css3:before{content:"\f13c"}.fa-anchor:before{content:"\f13d"}.fa-unlock-alt:before{content:"\f13e"}.fa-bullseye:before{content:"\f140"}.fa-ellipsis-h:before{content:"\f141"}.fa-ellipsis-v:before{content:"\f142"}.fa-rss-square:before{content:"\f143"}.fa-play-circle:before{content:"\f144"}.fa-ticket:before{content:"\f145"}.fa-minus-square:before{content:"\f146"}.fa-minus-square-o:before{content:"\f147"}.fa-level-up:before{content:"\f148"}.fa-level-down:before{content:"\f149"}.fa-check-square:before{content:"\f14a"}.fa-pencil-square:before{content:"\f14b"}.fa-external-link-square:before{content:"\f14c"}.fa-share-square:before{content:"\f14d"}.fa-compass:before{content:"\f14e"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"\f150"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"\f151"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"\f152"}.fa-euro:before,.fa-eur:before{content:"\f153"}.fa-gbp:before{content:"\f154"}.fa-dollar:before,.fa-usd:before{content:"\f155"}.fa-rupee:before,.fa-inr:before{content:"\f156"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"\f157"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"\f158"}.fa-won:before,.fa-krw:before{content:"\f159"}.fa-bitcoin:before,.fa-btc:before{content:"\f15a"}.fa-file:before{content:"\f15b"}.fa-file-text:before{content:"\f15c"}.fa-sort-alpha-asc:before{content:"\f15d"}.fa-sort-alpha-desc:before{content:"\f15e"}.fa-sort-amount-asc:before{content:"\f160"}.fa-sort-amount-desc:before{content:"\f161"}.fa-sort-numeric-asc:before{content:"\f162"}.fa-sort-numeric-desc:before{content:"\f163"}.fa-thumbs-up:before{content:"\f164"}.fa-thumbs-down:before{content:"\f165"}.fa-youtube-square:before{content:"\f166"}.fa-youtube:before{content:"\f167"}.fa-xing:before{content:"\f168"}.fa-xing-square:before{content:"\f169"}.fa-youtube-play:before{content:"\f16a"}.fa-dropbox:before{content:"\f16b"}.fa-stack-overflow:before{content:"\f16c"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-adn:before{content:"\f170"}.fa-bitbucket:before{content:"\f171"}.fa-bitbucket-square:before{content:"\f172"}.fa-tumblr:before{content:"\f173"}.fa-tumblr-square:before{content:"\f174"}.fa-long-arrow-down:before{content:"\f175"}.fa-long-arrow-up:before{content:"\f176"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-apple:before{content:"\f179"}.fa-windows:before{content:"\f17a"}.fa-android:before{content:"\f17b"}.fa-linux:before{content:"\f17c"}.fa-dribbble:before{content:"\f17d"}.fa-skype:before{content:"\f17e"}.fa-foursquare:before{content:"\f180"}.fa-trello:before{content:"\f181"}.fa-female:before{content:"\f182"}.fa-male:before{content:"\f183"}.fa-gittip:before,.fa-gratipay:before{content:"\f184"}.fa-sun-o:before{content:"\f185"}.fa-moon-o:before{content:"\f186"}.fa-archive:before{content:"\f187"}.fa-bug:before{content:"\f188"}.fa-vk:before{content:"\f189"}.fa-weibo:before{content:"\f18a"}.fa-renren:before{content:"\f18b"}.fa-pagelines:before{content:"\f18c"}.fa-stack-exchange:before{content:"\f18d"}.fa-arrow-circle-o-right:before{content:"\f18e"}.fa-arrow-circle-o-left:before{content:"\f190"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:"\f191"}.fa-dot-circle-o:before{content:"\f192"}.fa-wheelchair:before{content:"\f193"}.fa-vimeo-square:before{content:"\f194"}.fa-turkish-lira:before,.fa-try:before{content:"\f195"}.fa-plus-square-o:before{content:"\f196"}.fa-space-shuttle:before{content:"\f197"}.fa-slack:before{content:"\f198"}.fa-envelope-square:before{content:"\f199"}.fa-wordpress:before{content:"\f19a"}.fa-openid:before{content:"\f19b"}.fa-institution:before,.fa-bank:before,.fa-university:before{content:"\f19c"}.fa-mortar-board:before,.fa-graduation-cap:before{content:"\f19d"}.fa-yahoo:before{content:"\f19e"}.fa-google:before{content:"\f1a0"}.fa-reddit:before{content:"\f1a1"}.fa-reddit-square:before{content:"\f1a2"}.fa-stumbleupon-circle:before{content:"\f1a3"}.fa-stumbleupon:before{content:"\f1a4"}.fa-delicious:before{content:"\f1a5"}.fa-digg:before{content:"\f1a6"}.fa-pied-piper:before{content:"\f1a7"}.fa-pied-piper-alt:before{content:"\f1a8"}.fa-drupal:before{content:"\f1a9"}.fa-joomla:before{content:"\f1aa"}.fa-language:before{content:"\f1ab"}.fa-fax:before{content:"\f1ac"}.fa-building:before{content:"\f1ad"}.fa-child:before{content:"\f1ae"}.fa-paw:before{content:"\f1b0"}.fa-spoon:before{content:"\f1b1"}.fa-cube:before{content:"\f1b2"}.fa-cubes:before{content:"\f1b3"}.fa-behance:before{content:"\f1b4"}.fa-behance-square:before{content:"\f1b5"}.fa-steam:before{content:"\f1b6"}.fa-steam-square:before{content:"\f1b7"}.fa-recycle:before{content:"\f1b8"}.fa-automobile:before,.fa-car:before{content:"\f1b9"}.fa-cab:before,.fa-taxi:before{content:"\f1ba"}.fa-tree:before{content:"\f1bb"}.fa-spotify:before{content:"\f1bc"}.fa-deviantart:before{content:"\f1bd"}.fa-soundcloud:before{content:"\f1be"}.fa-database:before{content:"\f1c0"}.fa-file-pdf-o:before{content:"\f1c1"}.fa-file-word-o:before{content:"\f1c2"}.fa-file-excel-o:before{content:"\f1c3"}.fa-file-powerpoint-o:before{content:"\f1c4"}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:"\f1c5"}.fa-file-zip-o:before,.fa-file-archive-o:before{content:"\f1c6"}.fa-file-sound-o:before,.fa-file-audio-o:before{content:"\f1c7"}.fa-file-movie-o:before,.fa-file-video-o:before{content:"\f1c8"}.fa-file-code-o:before{content:"\f1c9"}.fa-vine:before{content:"\f1ca"}.fa-codepen:before{content:"\f1cb"}.fa-jsfiddle:before{content:"\f1cc"}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:"\f1cd"}.fa-circle-o-notch:before{content:"\f1ce"}.fa-ra:before,.fa-rebel:before{content:"\f1d0"}.fa-ge:before,.fa-empire:before{content:"\f1d1"}.fa-git-square:before{content:"\f1d2"}.fa-git:before{content:"\f1d3"}.fa-hacker-news:before{content:"\f1d4"}.fa-tencent-weibo:before{content:"\f1d5"}.fa-qq:before{content:"\f1d6"}.fa-wechat:before,.fa-weixin:before{content:"\f1d7"}.fa-send:before,.fa-paper-plane:before{content:"\f1d8"}.fa-send-o:before,.fa-paper-plane-o:before{content:"\f1d9"}.fa-history:before{content:"\f1da"}.fa-genderless:before,.fa-circle-thin:before{content:"\f1db"}.fa-header:before{content:"\f1dc"}.fa-paragraph:before{content:"\f1dd"}.fa-sliders:before{content:"\f1de"}.fa-share-alt:before{content:"\f1e0"}.fa-share-alt-square:before{content:"\f1e1"}.fa-bomb:before{content:"\f1e2"}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:"\f1e3"}.fa-tty:before{content:"\f1e4"}.fa-binoculars:before{content:"\f1e5"}.fa-plug:before{content:"\f1e6"}.fa-slideshare:before{content:"\f1e7"}.fa-twitch:before{content:"\f1e8"}.fa-yelp:before{content:"\f1e9"}.fa-newspaper-o:before{content:"\f1ea"}.fa-wifi:before{content:"\f1eb"}.fa-calculator:before{content:"\f1ec"}.fa-paypal:before{content:"\f1ed"}.fa-google-wallet:before{content:"\f1ee"}.fa-cc-visa:before{content:"\f1f0"}.fa-cc-mastercard:before{content:"\f1f1"}.fa-cc-discover:before{content:"\f1f2"}.fa-cc-amex:before{content:"\f1f3"}.fa-cc-paypal:before{content:"\f1f4"}.fa-cc-stripe:before{content:"\f1f5"}.fa-bell-slash:before{content:"\f1f6"}.fa-bell-slash-o:before{content:"\f1f7"}.fa-trash:before{content:"\f1f8"}.fa-copyright:before{content:"\f1f9"}.fa-at:before{content:"\f1fa"}.fa-eyedropper:before{content:"\f1fb"}.fa-paint-brush:before{content:"\f1fc"}.fa-birthday-cake:before{content:"\f1fd"}.fa-area-chart:before{content:"\f1fe"}.fa-pie-chart:before{content:"\f200"}.fa-line-chart:before{content:"\f201"}.fa-lastfm:before{content:"\f202"}.fa-lastfm-square:before{content:"\f203"}.fa-toggle-off:before{content:"\f204"}.fa-toggle-on:before{content:"\f205"}.fa-bicycle:before{content:"\f206"}.fa-bus:before{content:"\f207"}.fa-ioxhost:before{content:"\f208"}.fa-angellist:before{content:"\f209"}.fa-cc:before{content:"\f20a"}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:"\f20b"}.fa-meanpath:before{content:"\f20c"}.fa-buysellads:before{content:"\f20d"}.fa-connectdevelop:before{content:"\f20e"}.fa-dashcube:before{content:"\f210"}.fa-forumbee:before{content:"\f211"}.fa-leanpub:before{content:"\f212"}.fa-sellsy:before{content:"\f213"}.fa-shirtsinbulk:before{content:"\f214"}.fa-simplybuilt:before{content:"\f215"}.fa-skyatlas:before{content:"\f216"}.fa-cart-plus:before{content:"\f217"}.fa-cart-arrow-down:before{content:"\f218"}.fa-diamond:before{content:"\f219"}.fa-ship:before{content:"\f21a"}.fa-user-secret:before{content:"\f21b"}.fa-motorcycle:before{content:"\f21c"}.fa-street-view:before{content:"\f21d"}.fa-heartbeat:before{content:"\f21e"}.fa-venus:before{content:"\f221"}.fa-mars:before{content:"\f222"}.fa-mercury:before{content:"\f223"}.fa-transgender:before{content:"\f224"}.fa-transgender-alt:before{content:"\f225"}.fa-venus-double:before{content:"\f226"}.fa-mars-double:before{content:"\f227"}.fa-venus-mars:before{content:"\f228"}.fa-mars-stroke:before{content:"\f229"}.fa-mars-stroke-v:before{content:"\f22a"}.fa-mars-stroke-h:before{content:"\f22b"}.fa-neuter:before{content:"\f22c"}.fa-facebook-official:before{content:"\f230"}.fa-pinterest-p:before{content:"\f231"}.fa-whatsapp:before{content:"\f232"}.fa-server:before{content:"\f233"}.fa-user-plus:before{content:"\f234"}.fa-user-times:before{content:"\f235"}.fa-hotel:before,.fa-bed:before{content:"\f236"}.fa-viacoin:before{content:"\f237"}.fa-train:before{content:"\f238"}.fa-subway:before{content:"\f239"}.fa-medium:before{content:"\f23a"}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}html,button,input,select,textarea{font-family:sans-serif}body,form,fieldset,legend,input,select,textarea,button{margin:0}html{font-size:100%}body{font-family:sans-serif;font-size:16px;font-size:1rem;line-height:21px;line-height:1.3125rem;color:#434343;background-color:#fff;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}b,strong{font-weight:700}i,em,.em{font-style:italic}a{color:#669fcf}a:hover{text-decoration:none}a:focus{outline:0}a:active,a:hover{outline:0}p{margin:0 0 1.6em 0}pre{margin:1em 0}ul+p,ul+pre,ol+p,ol+pre{margin-top:0}small{font-size:80%}abbr[title]{border-bottom:1px dotted}audio,canvas,video{display:inline-block;*zoom:1;*display:inline}audio:not([controls]){display:none;height:0}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}dfn{font-style:italic}img{border:0;-ms-interpolation-mode:bicubic}svg:not(:root){overflow:hidden}figure{margin:0}.image-left{margin-right:20px}.image-right{margin-left:20px}h1,h2,h3,h4,h5,h6{line-height:normal;font-weight:normal;margin:0 0 .33em 0}h1,.h1{font-size:40px;font-size:2.5rem}h2,.h2{font-size:32px;font-size:2rem}h3,.h3{font-size:26px;font-size:1.625rem}h4,.h4{font-size:20px;font-size:1.25rem}h5,.h5{font-size:18px;font-size:1.125rem}h6,.h6{font-size:16px;font-size:1rem}.no-style-heading{margin:0;font-size:100%}hr{border:0;background:0;outline:0;background-color:#ddd;margin:2em 0;*margin:1em 0;-moz-box-sizing:content-box;box-sizing:content-box;height:1px}blockquote{font-size:22px;font-size:1.375rem;line-height:32px;line-height:2rem;color:#434343;margin:1em 0;font-style:italic}blockquote p{margin:1em 0}cite{color:#434343;font-style:normal;font-weight:normal;font-size:16px;font-size:1rem;line-height:normal}q{font-style:italic;quotes:none}q:before,q:after{content:'';content:none}mark{background:#ff0;color:#111}code,kbd,pre,samp{word-wrap:break-word;font-family:'courier new',monospace,serif;font-size:13px;font-size:.8125rem;line-height:normal;font-weight:normal;background-color:#f1f1f1;padding:10px}code{color:#111}dl,menu,ol,ul{margin:1em 0}dd,ul ul,ol ol,ul ol,ol ul{margin:0}dt{font-weight:normal}dd{margin-bottom:1em}menu,ol,ul{padding:0 0 0 22px}nav ul,nav ol{list-style:none;list-style-image:none}.unstyled-list{list-style:none;padding:0;margin:0}.unstyled-list li{margin-top:0;margin-bottom:0}.inline-list{list-style:none;padding:0;margin:0;display:inline-block;*zoom:1;*display:inline}.inline-list li{margin-top:0;margin-bottom:0}.inline-list li{display:inline-block;*zoom:1;*display:inline}table{width:100%;margin:1em 0;table-layout:fixed;border-collapse:collapse;border-spacing:0;border-right:1px solid #f1f1f1;border-bottom:1px solid #f1f1f1;word-wrap:break-word;-ms-word-wrap:break-word;*white-space:normal}table th,table td{padding:8px;text-align:left;vertical-align:top;border-top:1px solid #eee;border-left:1px solid #eee}table thead th,table tfoot th{vertical-align:bottom;font-weight:normal;background-color:#f1f1f1;color:#333}table caption{padding:8px;font-style:normal;text-align:left;font-weight:normal;border-bottom:0}fieldset{border:0;padding:0}legend{border:0;padding:0;white-space:normal;*margin-left:-7px;font-weight:normal}label{margin:0;cursor:pointer}button,input,select,textarea{font-size:100%;vertical-align:baseline;*vertical-align:middle}input[type=text],input[type=password],input[type=email],input[type=search],input[type=tel],textarea{padding:5px;-webkit-appearance:none;-moz-appearance:none;font-weight:normal;line-height:normal;background-color:#fff;border:1px solid #ccc;color:#111}input[type=checkbox],input[type=radio]{cursor:pointer;box-sizing:border-box;line-height:normal;margin:0;padding:0;*height:13px;*width:13px}.checkbox{display:block;margin:.2em 0}.checkbox input[type=checkbox],.checkbox input[type=radio]{margin-top:.05em;float:left}.checkbox label{padding-left:5px;overflow:hidden;display:table;*zoom:1}button,input{line-height:normal}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer;*overflow:visible}button[disabled],html input[disabled]{cursor:default}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top;resize:none}.button{border:0;padding:1em 3em;background-color:#e74b3c;color:#fff;text-decoration:none;text-align:center;display:inline-block;*zoom:1;*display:inline;position:relative}.button:hover{background-color:#fc5547}.button:active{top:1px}.grey-button{background-color:#eee;color:#434343}.grey-button:hover{background-color:#f1f1f1}.button[disabled],.button.disabled{color:#999;background-color:#f1f1f1}.unstyled-button{font-size:16px;font-size:1rem;color:#27ae61;text-decoration:underline;border:0;background:transparent;height:auto;padding:0;cursor:pointer;outline:0}.unstyled-button:hover{text-decoration:none}.unstyled-button[disabled],.unstyled-button.disabled{text-decoration:none;color:#999;background-color:#ccc}.section{position:relative}.container{max-width:960px;margin-left:auto;margin-right:auto;padding-left:10px;padding-right:10px}.container-full{max-width:960px;margin-left:auto;margin-right:auto}.col{float:left;padding-left:10px;padding-right:10px}[class*="pull-"],[class*="push-"]{position:relative}.no-gutter{padding-left:0;padding-right:0}.col-1{width:8.33333%;width:calc(8.333333333333334%);width:-webkit-calc(8.333333333333334%);width:-moz-calc(8.333333333333334%)}.col-2{width:16.66667%;width:calc(16.666666666666668%);width:-webkit-calc(16.666666666666668%);width:-moz-calc(16.666666666666668%)}.col-3{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.col-4{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.col-5{width:41.66665%;width:calc(41.66666666666667%);width:-webkit-calc(41.66666666666667%);width:-moz-calc(41.66666666666667%)}.col-6{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.col-7{width:58.33333%;width:calc(58.333333333333336%);width:-webkit-calc(58.333333333333336%);width:-moz-calc(58.333333333333336%)}.col-8{width:66.66666%;width:calc(66.66666666666667%);width:-webkit-calc(66.66666666666667%);width:-moz-calc(66.66666666666667%)}.col-9{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.col-10{width:83.33333%;width:calc(83.33333333333334%);width:-webkit-calc(83.33333333333334%);width:-moz-calc(83.33333333333334%)}.col-11{width:91.66666%;width:calc(91.66666666666667%);width:-webkit-calc(91.66666666666667%);width:-moz-calc(91.66666666666667%)}.col-12{width:100%}.col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.push-1{left:8.33333%;left:calc(8.333333333333334%);left:-webkit-calc(8.333333333333334%);left:-moz-calc(8.333333333333334%)}.pull-1{left:-8.33333%;left:calc(-8.333333333333334%);left:-webkit-calc(-8.333333333333334%);left:-moz-calc(-8.333333333333334%)}.push-2{left:16.66667%;left:calc(16.666666666666668%);left:-webkit-calc(16.666666666666668%);left:-moz-calc(16.666666666666668%)}.pull-2{left:-16.66667%;left:calc(-16.666666666666668%);left:-webkit-calc(-16.666666666666668%);left:-moz-calc(-16.666666666666668%)}.push-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.pull-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.push-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.pull-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.push-5{left:41.66665%;left:calc(41.66666666666667%);left:-webkit-calc(41.66666666666667%);left:-moz-calc(41.66666666666667%)}.pull-5{left:-41.66665%;left:calc(-41.66666666666667%);left:-webkit-calc(-41.66666666666667%);left:-moz-calc(-41.66666666666667%)}.push-6{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.pull-6{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.push-7{left:58.33333%;left:calc(58.333333333333336%);left:-webkit-calc(58.333333333333336%);left:-moz-calc(58.333333333333336%)}.pull-7{left:-58.33333%;left:calc(-58.333333333333336%);left:-webkit-calc(-58.333333333333336%);left:-moz-calc(-58.333333333333336%)}.push-8{left:66.66666%;left:calc(66.66666666666667%);left:-webkit-calc(66.66666666666667%);left:-moz-calc(66.66666666666667%)}.pull-8{left:-66.66666%;left:calc(-66.66666666666667%);left:-webkit-calc(-66.66666666666667%);left:-moz-calc(-66.66666666666667%)}.push-9{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.pull-9{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.push-10{left:83.33333%;left:calc(83.33333333333334%);left:-webkit-calc(83.33333333333334%);left:-moz-calc(83.33333333333334%)}.pull-10{left:-83.33333%;left:calc(-83.33333333333334%);left:-webkit-calc(-83.33333333333334%);left:-moz-calc(-83.33333333333334%)}.push-11{left:91.66666%;left:calc(91.66666666666667%);left:-webkit-calc(91.66666666666667%);left:-moz-calc(91.66666666666667%)}.pull-11{left:-91.66666%;left:calc(-91.66666666666667%);left:-webkit-calc(-91.66666666666667%);left:-moz-calc(-91.66666666666667%)}.row{padding-top:1em;padding-bottom:1em}.clear:before,.clear:after{content:"";display:table}.clear:after{clear:both}.clear{zoom:1}.left{float:left}.right{float:right}.block{display:block}.inline{display:inline}.inline-block{display:inline-block;*zoom:1;*display:inline}.none,.hidden,[hidden],.no-desktop{display:none}.heavy{font-weight:900}.strong{font-weight:700}.normal{font-weight:normal}.thin{font-weight:300}.fine{font-weight:100}.italic{font-style:italic}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.left-text{text-align:left}.right-text{text-align:right}.center-text{text-align:center}.justify-text{text-align:justify}.visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;overflow:hidden;padding:0;position:absolute;width:1px;left:-9999em}.visuallyvisible{clip:auto;width:auto;height:auto;overflow:visible;left:0}.no-margin{margin:0}.no-padding{padding:0}@media only screen and (min-width:740px) and (max-width:960px){.container,.tablet-container{max-width:960px;padding-left:20px;padding-right:20px;margin-left:auto;margin-right:auto;float:none}.container:first-child,.tablet-container:first-child{margin-left:auto}.tablet-container-full{padding-left:0;padding-right:0;margin-left:auto;margin-right:auto;float:none}.tablet-container-full:first-child{margin-left:auto}.tablet-no-gutter{padding-left:0;padding-right:0}.tablet-col-1{width:8.33333%;width:calc(8.333333333333334%);width:-webkit-calc(8.333333333333334%);width:-moz-calc(8.333333333333334%)}.tablet-col-2{width:16.66667%;width:calc(16.666666666666668%);width:-webkit-calc(16.666666666666668%);width:-moz-calc(16.666666666666668%)}.tablet-col-3{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.tablet-col-4{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.tablet-col-5{width:41.66665%;width:calc(41.66666666666667%);width:-webkit-calc(41.66666666666667%);width:-moz-calc(41.66666666666667%)}.tablet-col-6{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.tablet-col-7{width:58.33333%;width:calc(58.333333333333336%);width:-webkit-calc(58.333333333333336%);width:-moz-calc(58.333333333333336%)}.tablet-col-8{width:66.66666%;width:calc(66.66666666666667%);width:-webkit-calc(66.66666666666667%);width:-moz-calc(66.66666666666667%)}.tablet-col-9{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.tablet-col-10{width:83.33333%;width:calc(83.33333333333334%);width:-webkit-calc(83.33333333333334%);width:-moz-calc(83.33333333333334%)}.tablet-col-11{width:91.66666%;width:calc(91.66666666666667%);width:-webkit-calc(91.66666666666667%);width:-moz-calc(91.66666666666667%)}.tablet-col-12{width:100%}.tablet-col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.tablet-col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.tablet-col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.tablet-col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.tablet-push-1{left:8.33333%;left:calc(8.333333333333334%);left:-webkit-calc(8.333333333333334%);left:-moz-calc(8.333333333333334%)}.tablet-pull-1{left:-8.33333%;left:calc(-8.333333333333334%);left:-webkit-calc(-8.333333333333334%);left:-moz-calc(-8.333333333333334%)}.tablet-push-2{left:16.66667%;left:calc(16.666666666666668%);left:-webkit-calc(16.666666666666668%);left:-moz-calc(16.666666666666668%)}.tablet-pull-2{left:-16.66667%;left:calc(-16.666666666666668%);left:-webkit-calc(-16.666666666666668%);left:-moz-calc(-16.666666666666668%)}.tablet-push-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.tablet-pull-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.tablet-push-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.tablet-pull-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.tablet-push-5{left:41.66665%;left:calc(41.66666666666667%);left:-webkit-calc(41.66666666666667%);left:-moz-calc(41.66666666666667%)}.tablet-pull-5{left:-41.66665%;left:calc(-41.66666666666667%);left:-webkit-calc(-41.66666666666667%);left:-moz-calc(-41.66666666666667%)}.tablet-push-6{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.tablet-pull-6{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.tablet-push-7{left:58.33333%;left:calc(58.333333333333336%);left:-webkit-calc(58.333333333333336%);left:-moz-calc(58.333333333333336%)}.tablet-pull-7{left:-58.33333%;left:calc(-58.333333333333336%);left:-webkit-calc(-58.333333333333336%);left:-moz-calc(-58.333333333333336%)}.tablet-push-8{left:66.66666%;left:calc(66.66666666666667%);left:-webkit-calc(66.66666666666667%);left:-moz-calc(66.66666666666667%)}.tablet-pull-8{left:-66.66666%;left:calc(-66.66666666666667%);left:-webkit-calc(-66.66666666666667%);left:-moz-calc(-66.66666666666667%)}.tablet-push-9{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.tablet-pull-9{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.tablet-push-10{left:83.33333%;left:calc(83.33333333333334%);left:-webkit-calc(83.33333333333334%);left:-moz-calc(83.33333333333334%)}.tablet-pull-10{left:-83.33333%;left:calc(-83.33333333333334%);left:-webkit-calc(-83.33333333333334%);left:-moz-calc(-83.33333333333334%)}.tablet-push-11{left:91.66666%;left:calc(91.66666666666667%);left:-webkit-calc(91.66666666666667%);left:-moz-calc(91.66666666666667%)}.tablet-pull-11{left:-91.66666%;left:calc(-91.66666666666667%);left:-webkit-calc(-91.66666666666667%);left:-moz-calc(-91.66666666666667%)}.tablet-no-push,.tablet-no-pull{left:auto}.tablet-row{padding-top:1em;padding-bottom:1em}.tablet-full{left:auto;clear:both;float:none;width:100%;margin:1em 0 0 0;display:block}.tablet-full:first-child{margin-top:0}.tablet-left-text{text-align:left}.tablet-right-text{text-align:right}.tablet-center-text{text-align:center}.tablet-left{float:left}.tablet-right{float:right}.tablet-no-float{float:none}.tablet-no-margin{margin:0}.tablet-no-padding{padding:0}.no-tablet{display:none}.show-tablet{display:block}}@media only screen and (max-width:739px){.container,.mobile-container{padding-left:20px;padding-right:20px;margin-left:auto;margin-right:auto;float:none}.container:first-child,.mobile-container:first-child{margin-left:auto}.mobile-container-full{padding-left:0;padding-right:0;margin-left:auto;margin-right:auto;float:none}.mobile-container-full:first-child{margin-left:auto}.mobile-no-gutter{padding-left:0;padding-right:0}.mobile-col-1-2{width:50%;width:calc(50%);width:-webkit-calc(50%);width:-moz-calc(50%)}.mobile-col-1-3{width:33.33333%;width:calc(33.333333333333336%);width:-webkit-calc(33.333333333333336%);width:-moz-calc(33.333333333333336%)}.mobile-col-1-4{width:25%;width:calc(25%);width:-webkit-calc(25%);width:-moz-calc(25%)}.mobile-col-3-4{width:75%;width:calc(75%);width:-webkit-calc(75%);width:-moz-calc(75%)}.mobile-push-1-2{left:50%;left:calc(50%);left:-webkit-calc(50%);left:-moz-calc(50%)}.mobile-pull-1-2{left:-50%;left:calc(-50%);left:-webkit-calc(-50%);left:-moz-calc(-50%)}.mobile-push-1-3{left:25%;left:calc(25%);left:-webkit-calc(25%);left:-moz-calc(25%)}.mobile-pull-1-3{left:-25%;left:calc(-25%);left:-webkit-calc(-25%);left:-moz-calc(-25%)}.mobile-push-1-4{left:33.33333%;left:calc(33.333333333333336%);left:-webkit-calc(33.333333333333336%);left:-moz-calc(33.333333333333336%)}.mobile-pull-1-4{left:-33.33333%;left:calc(-33.333333333333336%);left:-webkit-calc(-33.333333333333336%);left:-moz-calc(-33.333333333333336%)}.mobile-push-3-4{left:75%;left:calc(75%);left:-webkit-calc(75%);left:-moz-calc(75%)}.mobile-pull-3-4{left:-75%;left:calc(-75%);left:-webkit-calc(-75%);left:-moz-calc(-75%)}.mobile-no-push,.mobile-no-pull{left:auto}.mobile-row{padding-top:1em;padding-bottom:1em}.mobile-full{left:auto;clear:both;float:none;width:100%;margin:.2em 0 0 0;display:block}.mobile-full:first-child{margin-top:0}.mobile-left-text{text-align:left}.mobile-right-text{text-align:right}.mobile-center-text{text-align:center}.mobile-left{float:left}.mobile-right{float:right}.mobile-no-float{float:none}.mobile-no-margin{margin:0}.mobile-no-padding{padding:0}table th,table td{padding:4px}.no-mobile{display:none}.show-mobile{display:block}}@media print{*{background:transparent}a,a:visited{text-decoration:underline}abbr[title]:after{content:" (" attr(title) ")"}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100%}@page{margin:.5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}}html,body{height:100%}.absolute{position:absolute}.relative{position:relative}.full{width:100%}.no-scroll{overflow:hidden}.table{display:table;margin:0 auto}.xlarge-top{margin-top:60px}.large-top{margin-top:40px}.medium-top{margin-top:20px}.small-top{margin-top:10px}.mini-top{margin-top:5px}.no-left-padding{padding-left:0}.no-right-padding{padding-right:0}@media only screen and (max-width:739px){.mobile-hide{display:none}.mobile-xlarge-top{margin-top:60px}.mobile-large-top{margin-top:40px}.mobile-medium-top{margin-top:20px}.mobile-small-top{margin-top:10px}.mobile-mini-top{margin-top:5px}}html,body{font-family:'Roboto','Helvetica Neue','Arial','Helvetica','Lucida Grande',sans-serif;font-weight:300;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}h1,h2,h3,h4,h5{font-weight:300}p{margin:0 0 1em 0}pre,code{padding:5px 10px;color:#6e6e6e;font-size:14px;line-height:20px;font-weight:100;background:#f8f8f8;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}a{color:#333;text-decoration:none;-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out}a.active{color:#000}a:hover{color:#000}a:hover .fa-trash-o{color:#e2717f}a.primary{color:#e2717f}a.primary:hover{color:#d94759}img{max-width:100%}hr{margin:.5em 0;width:100%}i.right-padding{padding-right:10px}i.left-padding{padding-left:10px}.button{outline:0;padding:1em 1.5em;background:#fafafa;color:#333;white-space:nowrap;background-clip:padding-box;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.button.disabled,.button[disabled]{-moz-opacity:.7;-khtml-opacity:.7;-webkit-opacity:.7;opacity:.7;-ms-filter:alpha(opacity=70);filter:alpha(opacity=70);cursor:default}.button:hover:not(.disabled),.button:hover:not([disabled]){background:#d9d9d9}.button.large{padding:1em 4em}.button.small{padding:.6em .8em}.button.x-small{padding:.4em .6em}.button.primary-button{color:#fff;background:#e2717f}.button.primary-button:hover,.button.primary-button:focus{color:#f2f2f2;background:#de5c6c}.button.primary-button:hover.disabled,.button.primary-button:focus.disabled,.button.primary-button:hover:disabled,.button.primary-button:focus:disabled{background:#e2717f}.button.secondary-button{background:0;border:1px solid #eee}.button.secondary-button:hover:not(.active),.button.secondary-button:hover:not(.disabled),.button.secondary-button:hover:not(:disabled),.button.secondary-button:focus:not(.active),.button.secondary-button:focus:not(.disabled),.button.secondary-button:focus:not(:disabled){color:#666;background:#f8f8f8}.button.secondary-button.active{color:#595959;background:#ebebeb;border:1px solid #eee}.button.secondary-button.active:hover{color:#595959;background:#ebebeb;border:1px solid #eee}.button.remove-button{background:#e2717f;color:#fff;padding:.9em 1.5em}.button.remove-button:hover,.button.remove-button:focus{background:#de5c6c}.button.remove-button:hover.disabled,.button.remove-button:focus.disabled,.button.remove-button:hover:disabled,.button.remove-button:focus:disabled{background:#e2717f}.button.transparent-button{background:0;color:#fff;border:1px solid #f2f2f2}.button.transparent-button:hover:not(.disabled),.button.transparent-button:hover:not(:disabled){background:rgba(255,255,255,0.1);color:#fff}.button-group>.button{padding:.8em 1em;text-align:center;background:#fff;border-top:1px solid #eee;border-bottom:1px solid #eee;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.button-group>.button i.fa{margin-right:5px}.button-group>.button:first-child{border-left:1px solid #eee;-webkit-border-top-right-radius:0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:5px;-webkit-border-top-left-radius:5px;-moz-border-radius-topright:0;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:5px;-moz-border-radius-topleft:5px;border-top-right-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:5px;border-top-left-radius:5px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.button-group>.button:last-child{border-right:1px solid #eee;-webkit-border-top-right-radius:5px;-webkit-border-bottom-right-radius:5px;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:0;-moz-border-radius-topright:5px;-moz-border-radius-bottomright:5px;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:0;border-top-right-radius:5px;border-bottom-right-radius:5px;border-bottom-left-radius:0;border-top-left-radius:0;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.button-group>.button:hover:not(.active),.button-group>.button:focus:not(.active){color:#666;background:#f8f8f8}.button-group>.button.active{color:#595959;background:#ebebeb;border:1px solid #eee}.button-group>.button.active:hover{color:#595959;background:#ebebeb;border:1px solid #eee}.button-group.small>.button{padding:.6em .8em}.button-group.x-small>.button{padding:.4em .6em}form .col,form .input-wrapper{position:relative}form input,form input[type="text"],form input[type="password"],form input[type="email"],form input[type="search"],form input[type="tel"],form input[type="number"],form input[type="date"],form textarea{width:100%;padding:.8em .6em .6em;outline:0;border:1px solid #d3d3d3;font-size:1.1em;line-height:1;background:#fff;color:#666;-webkit-appearance:none;-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out}form input:focus,form input[type="text"]:focus,form input[type="password"]:focus,form input[type="email"]:focus,form input[type="search"]:focus,form input[type="tel"]:focus,form input[type="number"]:focus,form input[type="date"]:focus,form textarea:focus{color:#333;border:1px solid #a0a0a0;-moz-box-shadow:0 0 2px #a0a0a0;-webkit-box-shadow:0 0 2px #a0a0a0;box-shadow:0 0 2px #a0a0a0;-webkit-box-shadow:0 0 2px #a0a0a0 0 0 #000;box-shadow:0 0 2px #a0a0a0 0 0 #000}form input:focus+label,form input[type="text"]:focus+label,form input[type="password"]:focus+label,form input[type="email"]:focus+label,form input[type="search"]:focus+label,form input[type="tel"]:focus+label,form input[type="number"]:focus+label,form input[type="date"]:focus+label,form textarea:focus+label{color:#666;font-weight:400}form input.success,form input[type="text"].success,form input[type="password"].success,form input[type="email"].success,form input[type="search"].success,form input[type="tel"].success,form input[type="number"].success,form input[type="date"].success,form textarea.success{border:1px solid #43cea2;-moz-box-shadow:0 0 2px #43cea2;-webkit-box-shadow:0 0 2px #43cea2;box-shadow:0 0 2px #43cea2;-webkit-box-shadow:0 0 2px #43cea2 0 0 #000;box-shadow:0 0 2px #43cea2 0 0 #000}form input.success+label,form input[type="text"].success+label,form input[type="password"].success+label,form input[type="email"].success+label,form input[type="search"].success+label,form input[type="tel"].success+label,form input[type="number"].success+label,form input[type="date"].success+label,form textarea.success+label{color:#43cea2;font-weight:400}form input.error,form input[type="text"].error,form input[type="password"].error,form input[type="email"].error,form input[type="search"].error,form input[type="tel"].error,form input[type="number"].error,form input[type="date"].error,form textarea.error{border:1px solid #e2717f;-moz-box-shadow:0 0 2px #e2717f;-webkit-box-shadow:0 0 2px #e2717f;box-shadow:0 0 2px #e2717f;-webkit-box-shadow:0 0 2px #e2717f 0 0 #000;box-shadow:0 0 2px #e2717f 0 0 #000}form input.error+label,form input[type="text"].error+label,form input[type="password"].error+label,form input[type="email"].error+label,form input[type="search"].error+label,form input[type="tel"].error+label,form input[type="number"].error+label,form input[type="date"].error+label,form textarea.error+label{color:#e2717f;font-weight:400}form input::-webkit-input-placeholder,form input[type="text"]::-webkit-input-placeholder,form input[type="password"]::-webkit-input-placeholder,form input[type="email"]::-webkit-input-placeholder,form input[type="search"]::-webkit-input-placeholder,form input[type="tel"]::-webkit-input-placeholder,form input[type="number"]::-webkit-input-placeholder,form input[type="date"]::-webkit-input-placeholder,form textarea::-webkit-input-placeholder{color:#d3d3d3;font-weight:300}form [placeholder]:focus::-webkit-input-placeholder{-webkit-transition:-webkit-all .2s ease-out;-moz-transition:-moz-all .2s ease-out;-o-transition:-o-all .2s ease-out;transition:all .2s ease-out;opacity:0}form input[type="number"]::-webkit-inner-spin-button,form input[type="number"]::-webkit-outer-spin-button,form input[type="date"]::-webkit-inner-spin-button,form input[type="date"]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}form .select-style{position:relative;display:block;width:100%;border:1px solid #a0a0a0;background:#fff}form .select-style .fa-caret-down{position:absolute;right:.6em;top:.8em;color:#a0a0a0;font-size:1.4em}form .select-style select{padding:.8em 0;margin-left:.6em;width:100%;border:0;box-shadow:none;background:transparent;background-image:none;-webkit-appearance:none;color:#a0a0a0;font-size:1.2em}form .select-style select:hover{cursor:pointer}form .select-style select:focus{outline:0}form fieldset.row{padding:.5em 0}form label{position:absolute;left:5px;top:-5px;padding:0 5px;background:white;color:#a0a0a0;font-size:12px;line-height:12px;text-transform:uppercase;pointer-events:none;z-index:2}.modal-wrapper{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.3);display:none;z-index:1001;will-change:transform}.modal-wrapper .modal{position:relative;color:#333;display:none}.modal-wrapper .modal a.close{position:absolute;padding:6px 12px 9px;border:1px solid;border-radius:20px;font-weight:300;font-size:27px}.modal-wrapper .modal section.modal-content{padding:20px}.modal-wrapper:not(.fullscreen) .modal{min-height:300px;max-width:434px;margin:60px auto 0;background-color:#fff;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.modal-wrapper:not(.fullscreen) .modal a.close{right:-45px;top:-30px;color:#fff}.modal-wrapper.fullscreen{background:#fff}.modal-wrapper.fullscreen .modal{height:100%;overflow:auto}.modal-wrapper.fullscreen .modal a.close{right:20px;top:20px}.notice{position:fixed;bottom:0;right:10px;height:100px;width:300px;padding:5px 10px 5px 10px;display:none;color:#fff;z-index:1005;-webkit-border-top-right-radius:5px;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:5px;-moz-border-radius-topright:5px;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:5px;border-top-right-radius:5px;border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-left-radius:5px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.notice.success{background-color:#43cea2}.notice.warning{background-color:#f4ed6b}.notice.error{background-color:#e2717f}.notice header.notice-header{position:relative;margin-bottom:.2em}.notice section.notice-content{height:70px;width:100%;overflow:auto;font-size:.8em}.notice a.close{position:absolute;top:3px;right:0;padding:0 4px 2px;border:1px solid;border-radius:100%;font-weight:300;font-size:12px;line-height:12px;color:#fff}.notice a.close:hover{color:#ccc}nav{font-size:18px;font-size:1.125rem}nav .navbar{margin:0 auto;display:table;padding:10px 0}nav li{margin:0 10px}nav a{display:inline-block;line-height:60px;vertical-align:middle}nav a.logo{height:60px;width:60px}@media(max-width:739px){nav{font-size:14px;font-size:.875rem}nav a{line-height:40px}nav a.logo{height:40px;width:40px}}#toc{position:fixed;top:80px;height:100%;width:220px;overflow:auto;padding-bottom:100px}#toc a{color:#333}#toc a:hover{color:#1a1a1a}#toc li>ul{display:none}#toc li>ul.unstyled-list{margin-left:10px}#toc li.active>a{font-weight:bold}#toc li.active>ul{display:block}#toc ul.nav>li.active>ul>li{list-style:none}footer{padding:60px 0;color:#d3d3d3;background:#333}footer i.fa-heart{color:#e2717f}footer i.fa-beer{color:#f4ed6b}html,body{background:#fff;color:#333}.kd{color:#a783b6}.k{color:#43cea2}h1.logo{font-size:64px;font-size:4rem}.gist pre,.gist .file-data{font-size:14px!important}section{padding:40px 0}code{padding:0}#hero .badges,#hero .github-links{padding:.3em 0}#hero .badges p,#hero .github-links p{margin:0}#ship h3{margin-bottom:1em}#ship img.ship-it{display:table;height:300px;width:300px;margin:0 auto;background:#d3d3d3;-webkit-border-radius:100%;-moz-border-radius:100%;border-radius:100%}#plugins{color:#fff;background:#333}#plugins p{color:#d3d3d3}#plugins ul li{padding:10px 20px}#plugins ul li a{display:inline-block}#plugins ul li a img{height:100px;max-width:160px}@media(max-width:739px){#plugins ul li a img{height:60px;max-width:120px}}#features{color:#fff;background:#e2717f}#features h4{color:#982e3e}#features a.primary{color:#f8f8f8;border-bottom:1px dashed #f8f8f8}#features a.primary:hover{color:#dfdfdf;border-bottom:1px dashed #dfdfdf}#comparison img{margin:0 auto}.example,.example .row{padding-bottom:0}.page,.example{padding-top:0;margin-bottom:0}.page a,.example a{color:#e2717f}.page a:hover,.example a:hover{color:#d94759}.page .file-data .line-numbers,.example .file-data .line-numbers{width:40px}#todo-example{padding-bottom:2em}#todo-example input[type="text"]{margin:10px 0}#todo-example ul.todos{height:320px}#todo-example ul.todos li{padding:5px 0}#todo-example ul.todos li input[type="checkbox"]{margin-top:.2em}#todo-example ul.todos li span{margin-left:5px}#todo-example ul.todos li.done label{text-decoration:line-through;color:#998}#todo-example ul.todos li .delete{font-weight:bold}#todo-example label{float:left}#todo-example .primary-button{width:100%}.not-found{text-align:center}.not-found ul{list-style:none} \ No newline at end of file diff --git a/js/feathers.js b/js/feathers.js index 3bf5c7ee1f..7aa9d07ed8 100644 --- a/js/feathers.js +++ b/js/feathers.js @@ -57,7 +57,7 @@ if($(window).width() > 992) { $('#toc').affix({ offset: { - top: $('#toc').offset().top + top: $('#toc').offset().top + 5 } }); } @@ -74,7 +74,7 @@ $('#todo-example').todos('http://todos.feathersjs.com:80'); $('body').scrollspy({ target: '#toc', - offset: 0 + offset: 5 }); }); })(jQuery); diff --git a/quick-start.md b/quick-start.md index d5cc3bfd84..1aa09e2f95 100644 --- a/quick-start.md +++ b/quick-start.md @@ -210,7 +210,7 @@ The functionality provided by our service is quite common which is why we implem ## Getting real-time -As previously mentioned, a Feathers service can also be exposed through websockets. You can either use [SocketIO](http://socket.io) or [Primus](https://github.com/primus/primus) - an abstraction layer for differentNode websocket libraries. In the following examples we will use SocketIO. +As previously mentioned, a Feathers service can also be exposed through websockets for both real-time updates and to call service methods. You can either use [SocketIO](http://socket.io) or [Primus](https://github.com/primus/primus) - an abstraction layer for different Node websocket libraries. In the following examples we will use SocketIO. SocketIO can be enabled by calling `app.configure(feathers.socketio())`. Once set up, it is possible to call service methods by emitting events like `::` on the socket and also receive events by listening to ` ` (*eventname* can be `created`, `updated`, `patched` or `removed`). To make it easier to test in a web page, lets also statically host the files in the current folder. `app.js` then looks like this: @@ -234,13 +234,17 @@ That's it. Our application is now real-time, all we have to do is provide a nice ## Building a frontend +Feathers works great with any frontend framework, Android or iOS clients or anything else that can connect to a REST API or websockets (to get real-time). We have real-time [TodoMVC](http://todomvc.com/) examples for [jQuery](), [Angular](), [React]() and [CanJS]() but for this guide, we will create a more simplified jQuery client. + ### Feathers client -[feathers-client]() is a JavaScript client that can connect to Feathers services either via REST (using jQuery.ajax, node-request or Superagent) or websockets (Socket.io and Primus). That makes it possible to use +We could connect with any REST client or send our own websocket events but [feathers-client](https://github.com/feathersjs/feathers-client) makes it much easier. It is a JavaScript client that can connect to Feathers services either via REST (using jQuery.ajax, node-request or Superagent) or websockets (Socket.io and Primus) and lets you use services the same way you would on the server. You can install it via Bower, [download the release]() or install via NPM which is what we will use: -### Testing the connection +``` +npm install feathers-client +``` -To test the connection, we can create an `index.html` file in the same folder. The example page will connect to SocketIO, create a new Todo and also log when any Todo has been created, updated or patched: +Since we also set statically hosting the files in the current folder in the previous chapter, we can now create an `index.html` that loads the client, connects to our Todos service via Socket.io, creates a test todo and logs when a new todo has been created: ```html @@ -250,55 +254,153 @@ To test the connection, we can create an `index.html` file in the same folder. T

          A Feathers SocketIO example

          -
          
           
             
          -  
          +  
           
          -
           ```
           
           After restarting, going directly to [localhost:3000](http://localhost:3000) with the console open will show what is happening on the HTML page. You can also see the newly created Todo at the REST endpoint [localhost:3000/todos](http://localhost:3000/todos). With the page open, creating a new Todo via the REST API, for example
           
           
          curl 'http://localhost:3000/todos/' -H 'Content-Type: application/json' --data-binary '{ "text": "Do something" }'
          -will also log `Someone created a new Todo`. This is how you can implement real-time functionality in any web page by using standardized websocket messages instead of having to make up your own. +will also log `Someone created a new Todo` with. This is how you can implement real-time functionality in any web page. All that's left now is using jQuery to listen to those events to update the list and the ability to remove and create todos. + +### jQuery frontend + +Let's update `index.html` to load [Bootstrap](http://getbootstrap.com/) and [jQuery](https://jquery.com) and also create an HTML form and placeholder where the Todos will go: + +```html + + + + Feathers real-time Todos + + + + + +
          +

          Feathers real-time Todos

          + +
            + +
            + +
            + + +
            + + + + + + +``` + +In `todos.js` we now have to connect to the service again and add jQuery code that adds, removes and updates todos. To identify a Todo we'll store the `data-id=""` property on the todos `
          • ` and retrieve it with `getElement(todo)`: + +```js +var el = $('#todos'); +var socket = io(); +var app = feathers().configure(feathers.socketio(socket)); +var todos = app.service('todos'); + + +function getElement(todo) { + return el.find('[data-id="' + todo.id + '"]') +} + +function addTodo(todo) { + var html = '
          • '; + + el.find('.todos').append(html); + updateTodo(todo); +} + +function removeTodo(todo) { + getElement(todo).remove(); +} + +function updateTodo(todo) { + var element = getElement(todo); + var checkbox = element.find('[name="done"]').removeAttr('disabled'); + + element.toggleClass('done', todo.complete); + checkbox.prop('checked', todo.complete); +} +``` + +We can use the Todo service to listen to `created`, `updated` and `removed` events and call the appropriate functions that we just created. We will also initially load all existing Todos: + +```js +todos.on('updated', updateTodo); +todos.on('removed', removeTodo); +todos.on('created', addTodo); + +todos.find(function(error, todos) { + todos.forEach(addTodo); +}); +``` + +Now we can add the jQuery event handlers when submitting the form, removing a Todo or completing it by clicking the checkbox. We only need to call the service method since the updates will happen automatically already through the service event handlers that we set up previously: + +```js +el.on('submit', 'form', function (ev) { + var field = $(this).find('[name="description"]'); + + todos.create({ + text: field.val(), + complete: false + }); + + field.val(''); + ev.preventDefault(); + }); + + el.on('click', '.delete', function (ev) { + var id = $(this).parents('li').data('id'); + todos.remove(id); + ev.preventDefault(); + }); + + el.on('click', '[name="done"]', function(ev) { + var id = $(this).parents('li').data('id'); + + $(this).attr('disabled', 'disabled'); + + todos.update(id, { + complete: $(this).is(':checked') + }); + }); + ``` + +Now go to [http://localhost:3030](http://localhost:3030) and you will be able to create, complete and remove todos and it will update on all clients in real-time. + +## What's next? -**[Learn more](/learn)** +This are the basics of Feathers. We created a todos API that is accessible via REST and websockets and built a real-time jQuery frontend. Now, head over to the **[Learn section](/learn)** to learn more about things like Databases, how to integrate other frontend frameworks, Validation, Authentication or Authorization and get familiar with the **[API documentation](/api/)**. From b8a64759c71c73bc2af1484cebaf88818d2eff8c Mon Sep 17 00:00:00 2001 From: David Luecke Date: Sat, 18 Jul 2015 12:38:41 -0600 Subject: [PATCH 09/11] Adding jQuery and CanJS TodoMVC examples --- _layouts/todomvc.html | 15 + quick-start.md | 12 +- todomvc/canjs/.gitignore | 29 + todomvc/canjs/guide.md | 62 + todomvc/canjs/index.html | 66 + todomvc/canjs/js/app.js | 15 + todomvc/canjs/js/components/todo-app.js | 97 + todomvc/canjs/js/models/todo.js | 54 + .../node_modules/canjs-feathers/.jshintrc | 34 + .../node_modules/canjs-feathers/.npmignore | 6 + .../node_modules/canjs-feathers/.travis.yml | 6 + .../canjs/node_modules/canjs-feathers/LICENSE | 20 + .../node_modules/canjs-feathers/bower.json | 29 + .../bower_components/assert/.bower.json | 23 + .../bower_components/assert/HISTORY.md | 27 + .../bower_components/assert/README.md | 38 + .../bower_components/assert/assert.js | 370 + .../bower_components/assert/bower.json | 14 + .../bower_components/canjs/.bower.json | 26 + .../bower_components/canjs/amd-dev/can.js | 18 + .../canjs/amd-dev/can/bubble.js | 115 + .../canjs/amd-dev/can/component.js | 277 + .../canjs/amd-dev/can/compute.js | 70 + .../canjs/amd-dev/can/construct.js | 148 + .../canjs/amd-dev/can/construct/proxy.js | 54 + .../canjs/amd-dev/can/construct/super.js | 45 + .../canjs/amd-dev/can/control.js | 205 + .../canjs/amd-dev/can/control/plugin.js | 81 + .../canjs/amd-dev/can/control/route.js | 41 + .../canjs/amd-dev/can/deferred.js | 160 + .../canjs/amd-dev/can/elements.js | 83 + .../canjs/amd-dev/can/event.js | 152 + .../canjs/amd-dev/can/fragment.js | 65 + .../canjs/amd-dev/can/get_value_and_bind.js | 91 + .../canjs/amd-dev/can/hashchange.js | 25 + .../canjs/amd-dev/can/list.js | 264 + .../canjs/amd-dev/can/list/promise.js | 58 + .../canjs/amd-dev/can/list/sort.js | 198 + .../bower_components/canjs/amd-dev/can/map.js | 445 + .../canjs/amd-dev/can/map/attributes.js | 122 + .../canjs/amd-dev/can/map/backup.js | 49 + .../canjs/amd-dev/can/map/bubble.js | 28 + .../canjs/amd-dev/can/map/define.js | 258 + .../canjs/amd-dev/can/map/delegate.js | 133 + .../canjs/amd-dev/can/map/lazy.js | 225 + .../canjs/amd-dev/can/map/list.js | 77 + .../canjs/amd-dev/can/map/nested_reference.js | 80 + .../canjs/amd-dev/can/map/setter.js | 59 + .../canjs/amd-dev/can/map/sort.js | 12 + .../canjs/amd-dev/can/map/validations.js | 161 + .../canjs/amd-dev/can/model.js | 399 + .../canjs/amd-dev/can/model/queue.js | 109 + .../canjs/amd-dev/can/observe.js | 21 + .../canjs/amd-dev/can/proto_compute.js | 293 + .../canjs/amd-dev/can/read.js | 189 + .../canjs/amd-dev/can/render.js | 133 + .../canjs/amd-dev/can/route.js | 305 + .../canjs/amd-dev/can/route/pushstate.js | 125 + .../canjs/amd-dev/can/scanner.js | 384 + .../canjs/amd-dev/can/util/attr.js | 130 + .../canjs/amd-dev/can/util/batch.js | 89 + .../canjs/amd-dev/can/util/bind.js | 40 + .../canjs/amd-dev/can/util/can.js | 159 + .../canjs/amd-dev/can/util/dojo.js | 482 + .../canjs/amd-dev/can/util/domless.js | 106 + .../canjs/amd-dev/can/util/each.js | 56 + .../canjs/amd-dev/can/util/fixture.js | 498 + .../canjs/amd-dev/can/util/function.js | 43 + .../canjs/amd-dev/can/util/inserted.js | 55 + .../canjs/amd-dev/can/util/jquery.js | 229 + .../canjs/amd-dev/can/util/library.js | 12 + .../canjs/amd-dev/can/util/makeArray.js | 19 + .../canjs/amd-dev/can/util/mootools.js | 355 + .../canjs/amd-dev/can/util/object.js | 102 + .../canjs/amd-dev/can/util/object/isplain.js | 31 + .../canjs/amd-dev/can/util/string.js | 93 + .../canjs/amd-dev/can/util/string/deparam.js | 45 + .../canjs/amd-dev/can/util/tests.js | 15 + .../canjs/amd-dev/can/util/yui.js | 413 + .../canjs/amd-dev/can/util/zepto.js | 306 + .../canjs/amd-dev/can/view.js | 298 + .../canjs/amd-dev/can/view/autorender.js | 88 + .../canjs/amd-dev/can/view/bindings.js | 266 + .../canjs/amd-dev/can/view/callbacks.js | 89 + .../canjs/amd-dev/can/view/compute_data.js | 110 + .../canjs/amd-dev/can/view/ejs.js | 161 + .../canjs/amd-dev/can/view/html_section.js | 129 + .../can/view/intermediate_and_imports.js | 62 + .../canjs/amd-dev/can/view/live.js | 345 + .../canjs/amd-dev/can/view/modifiers.js | 100 + .../canjs/amd-dev/can/view/mustache.js | 510 + .../canjs/amd-dev/can/view/mustache_core.js | 330 + .../amd-dev/can/view/mustache_helpers.js | 144 + .../canjs/amd-dev/can/view/node_lists.js | 176 + .../canjs/amd-dev/can/view/parser.js | 189 + .../canjs/amd-dev/can/view/scope.js | 130 + .../canjs/amd-dev/can/view/stache.js | 274 + .../canjs/amd-dev/can/view/target.js | 167 + .../canjs/amd-dev/can/view/text_section.js | 98 + .../canjs/amd-dev/can/view/utils.js | 43 + .../bower_components/canjs/amd/can.js | 18 + .../bower_components/canjs/amd/can/bubble.js | 115 + .../canjs/amd/can/component.js | 274 + .../bower_components/canjs/amd/can/compute.js | 70 + .../canjs/amd/can/construct.js | 140 + .../canjs/amd/can/construct/proxy.js | 49 + .../canjs/amd/can/construct/super.js | 45 + .../bower_components/canjs/amd/can/control.js | 203 + .../canjs/amd/can/control/plugin.js | 81 + .../canjs/amd/can/control/route.js | 41 + .../canjs/amd/can/deferred.js | 160 + .../canjs/amd/can/elements.js | 83 + .../bower_components/canjs/amd/can/event.js | 152 + .../canjs/amd/can/fragment.js | 65 + .../canjs/amd/can/get_value_and_bind.js | 91 + .../canjs/amd/can/hashchange.js | 25 + .../bower_components/canjs/amd/can/list.js | 264 + .../canjs/amd/can/list/promise.js | 58 + .../canjs/amd/can/list/sort.js | 198 + .../bower_components/canjs/amd/can/map.js | 439 + .../canjs/amd/can/map/attributes.js | 121 + .../canjs/amd/can/map/backup.js | 49 + .../canjs/amd/can/map/bubble.js | 28 + .../canjs/amd/can/map/define.js | 249 + .../canjs/amd/can/map/delegate.js | 133 + .../canjs/amd/can/map/lazy.js | 225 + .../canjs/amd/can/map/list.js | 77 + .../canjs/amd/can/map/nested_reference.js | 80 + .../canjs/amd/can/map/setter.js | 52 + .../canjs/amd/can/map/sort.js | 12 + .../canjs/amd/can/map/validations.js | 161 + .../bower_components/canjs/amd/can/model.js | 394 + .../canjs/amd/can/model/queue.js | 109 + .../bower_components/canjs/amd/can/observe.js | 21 + .../canjs/amd/can/proto_compute.js | 293 + .../bower_components/canjs/amd/can/read.js | 189 + .../bower_components/canjs/amd/can/render.js | 133 + .../bower_components/canjs/amd/can/route.js | 305 + .../canjs/amd/can/route/pushstate.js | 125 + .../bower_components/canjs/amd/can/scanner.js | 384 + .../canjs/amd/can/util/attr.js | 130 + .../canjs/amd/can/util/batch.js | 89 + .../canjs/amd/can/util/bind.js | 40 + .../canjs/amd/can/util/can.js | 124 + .../canjs/amd/can/util/dojo.js | 482 + .../canjs/amd/can/util/domless.js | 106 + .../canjs/amd/can/util/each.js | 56 + .../canjs/amd/can/util/fixture.js | 495 + .../canjs/amd/can/util/function.js | 43 + .../canjs/amd/can/util/inserted.js | 55 + .../canjs/amd/can/util/jquery.js | 229 + .../canjs/amd/can/util/library.js | 12 + .../canjs/amd/can/util/makeArray.js | 19 + .../canjs/amd/can/util/mootools.js | 355 + .../canjs/amd/can/util/object.js | 102 + .../canjs/amd/can/util/object/isplain.js | 31 + .../canjs/amd/can/util/string.js | 93 + .../canjs/amd/can/util/string/deparam.js | 45 + .../canjs/amd/can/util/tests.js | 15 + .../canjs/amd/can/util/yui.js | 413 + .../canjs/amd/can/util/zepto.js | 306 + .../bower_components/canjs/amd/can/view.js | 282 + .../canjs/amd/can/view/autorender.js | 88 + .../canjs/amd/can/view/bindings.js | 259 + .../canjs/amd/can/view/callbacks.js | 83 + .../canjs/amd/can/view/compute_data.js | 110 + .../canjs/amd/can/view/ejs.js | 161 + .../canjs/amd/can/view/html_section.js | 129 + .../amd/can/view/intermediate_and_imports.js | 62 + .../canjs/amd/can/view/live.js | 345 + .../canjs/amd/can/view/modifiers.js | 100 + .../canjs/amd/can/view/mustache.js | 506 + .../canjs/amd/can/view/mustache_core.js | 323 + .../canjs/amd/can/view/mustache_helpers.js | 144 + .../canjs/amd/can/view/node_lists.js | 176 + .../canjs/amd/can/view/parser.js | 189 + .../canjs/amd/can/view/scope.js | 130 + .../canjs/amd/can/view/stache.js | 274 + .../canjs/amd/can/view/target.js | 167 + .../canjs/amd/can/view/text_section.js | 98 + .../canjs/amd/can/view/utils.js | 43 + .../bower_components/canjs/bower.json | 16 + .../bower_components/canjs/can.autorender.js | 154 + .../canjs/can.construct.proxy.js | 115 + .../canjs/can.construct.super.js | 111 + .../canjs/can.control.plugin.js | 147 + .../bower_components/canjs/can.dojo.dev.js | 7405 +++++++++++++ .../bower_components/canjs/can.dojo.js | 7306 +++++++++++++ .../bower_components/canjs/can.dojo.min.js | 98 + .../bower_components/canjs/can.ejs.js | 227 + .../bower_components/canjs/can.fixture.js | 655 ++ .../bower_components/canjs/can.jquery.dev.js | 6815 ++++++++++++ .../bower_components/canjs/can.jquery.js | 6825 ++++++++++++ .../bower_components/canjs/can.jquery.min.js | 94 + .../canjs/can.list.promise.js | 124 + .../bower_components/canjs/can.list.sort.js | 264 + .../canjs/can.map.attributes.js | 187 + .../bower_components/canjs/can.map.backup.js | 209 + .../bower_components/canjs/can.map.define.js | 315 + .../canjs/can.map.delegate.js | 199 + .../bower_components/canjs/can.map.lazy.js | 383 + .../bower_components/canjs/can.map.list.js | 143 + .../bower_components/canjs/can.map.setter.js | 118 + .../bower_components/canjs/can.map.sort.js | 268 + .../canjs/can.map.validations.js | 227 + .../bower_components/canjs/can.model.queue.js | 310 + .../canjs/can.mootools.dev.js | 7261 +++++++++++++ .../bower_components/canjs/can.mootools.js | 7162 +++++++++++++ .../canjs/can.mootools.min.js | 96 + .../bower_components/canjs/can.object.js | 168 + .../canjs/can.route.pushstate.js | 191 + .../bower_components/canjs/can.stache.js | 764 ++ .../canjs/can.util.domless.js | 183 + .../canjs/can.util.function.js | 109 + .../canjs/can.view.ejs.system.js | 238 + .../canjs/can.view.modifiers.js | 166 + .../canjs/can.view.mustache.system.js | 85 + .../canjs/can.view.stache.system.js | 777 ++ .../bower_components/canjs/can.yui.dev.js | 7336 +++++++++++++ .../bower_components/canjs/can.yui.js | 7237 +++++++++++++ .../bower_components/canjs/can.yui.min.js | 98 + .../bower_components/canjs/can.zepto.dev.js | 7212 +++++++++++++ .../bower_components/canjs/can.zepto.js | 7113 +++++++++++++ .../bower_components/canjs/can.zepto.min.js | 96 + .../bower_components/canjs/cjs/can.js | 15 + .../canjs/cjs/component/component.js | 271 + .../canjs/cjs/compute/compute.js | 67 + .../canjs/cjs/compute/get_value_and_bind.js | 90 + .../canjs/cjs/compute/proto_compute.js | 290 + .../canjs/cjs/compute/read.js | 188 + .../canjs/cjs/construct/construct.js | 139 + .../canjs/cjs/construct/proxy/proxy.js | 46 + .../canjs/cjs/construct/super/super.js | 42 + .../canjs/cjs/control/control.js | 200 + .../canjs/cjs/control/plugin/plugin.js | 78 + .../canjs/cjs/control/route/route.js | 38 + .../bower_components/canjs/cjs/event/event.js | 151 + .../bower_components/canjs/cjs/list/list.js | 261 + .../canjs/cjs/list/promise/promise.js | 57 + .../canjs/cjs/list/sort/sort.js | 195 + .../canjs/cjs/map/attributes/attributes.js | 118 + .../canjs/cjs/map/backup/backup.js | 46 + .../bower_components/canjs/cjs/map/bubble.js | 114 + .../canjs/cjs/map/define/define.js | 246 + .../canjs/cjs/map/delegate/delegate.js | 130 + .../canjs/cjs/map/lazy/bubble.js | 25 + .../canjs/cjs/map/lazy/lazy.js | 222 + .../canjs/cjs/map/lazy/nested_reference.js | 79 + .../canjs/cjs/map/list/list.js | 74 + .../bower_components/canjs/cjs/map/map.js | 436 + .../canjs/cjs/map/setter/setter.js | 49 + .../canjs/cjs/map/sort/sort.js | 11 + .../canjs/cjs/map/validations/validations.js | 158 + .../bower_components/canjs/cjs/model/model.js | 391 + .../canjs/cjs/model/queue/queue.js | 106 + .../canjs/cjs/observe/observe.js | 18 + .../canjs/cjs/route/pushstate/pushstate.js | 122 + .../bower_components/canjs/cjs/route/route.js | 302 + .../canjs/cjs/util/array/each.js | 55 + .../canjs/cjs/util/array/makeArray.js | 18 + .../canjs/cjs/util/attr/attr.js | 129 + .../canjs/cjs/util/batch/batch.js | 88 + .../canjs/cjs/util/bind/bind.js | 39 + .../bower_components/canjs/cjs/util/can.js | 122 + .../canjs/cjs/util/domless/domless.js | 103 + .../bower_components/canjs/cjs/util/event.js | 12 + .../canjs/cjs/util/fixture/fixture.js | 492 + .../canjs/cjs/util/function/function.js | 42 + .../canjs/cjs/util/inserted/inserted.js | 54 + .../canjs/cjs/util/jquery/jquery.js | 226 + .../canjs/cjs/util/object/object.js | 101 + .../canjs/cjs/util/string/deparam/deparam.js | 42 + .../canjs/cjs/util/string/string.js | 92 + .../canjs/cjs/util/tests/tests.js | 15 + .../bower_components/canjs/cjs/util/util.js | 11 + .../canjs/cjs/view/autorender/autorender.js | 86 + .../canjs/cjs/view/bindings/bindings.js | 256 + .../canjs/cjs/view/callbacks/callbacks.js | 80 + .../canjs/cjs/view/ejs/ejs.js | 158 + .../canjs/cjs/view/ejs/system.js | 17 + .../canjs/cjs/view/elements.js | 80 + .../canjs/cjs/view/live/live.js | 342 + .../canjs/cjs/view/modifiers/modifiers.js | 97 + .../canjs/cjs/view/mustache/mustache.js | 503 + .../canjs/cjs/view/mustache/system.js | 17 + .../canjs/cjs/view/node_lists/node_lists.js | 173 + .../canjs/cjs/view/parser/parser.js | 188 + .../bower_components/canjs/cjs/view/render.js | 130 + .../canjs/cjs/view/scanner.js | 381 + .../canjs/cjs/view/scope/compute_data.js | 107 + .../canjs/cjs/view/scope/scope.js | 127 + .../canjs/cjs/view/stache/html_section.js | 126 + .../view/stache/intermediate_and_imports.js | 59 + .../canjs/cjs/view/stache/mustache_core.js | 320 + .../canjs/cjs/view/stache/mustache_helpers.js | 141 + .../canjs/cjs/view/stache/stache.js | 271 + .../canjs/cjs/view/stache/system.js | 17 + .../canjs/cjs/view/stache/text_section.js | 95 + .../canjs/cjs/view/stache/utils.js | 42 + .../canjs/cjs/view/target/target.js | 164 + .../bower_components/canjs/cjs/view/view.js | 281 + .../bower_components/canjs/readme.md | 7 + .../bower_components/canjs/steal/can/can.js | 13 + .../canjs/steal/can/component/component.js | 539 + .../canjs/steal/can/compute/compute.js | 101 + .../steal/can/compute/get_value_and_bind.js | 162 + .../canjs/steal/can/compute/proto_compute.js | 434 + .../canjs/steal/can/compute/read.js | 239 + .../canjs/steal/can/construct/construct.js | 767 ++ .../canjs/steal/can/construct/proxy/proxy.js | 75 + .../canjs/steal/can/construct/super/super.js | 55 + .../canjs/steal/can/control/control.js | 343 + .../canjs/steal/can/control/plugin/plugin.js | 256 + .../canjs/steal/can/control/route/route.js | 48 + .../canjs/steal/can/event/event.js | 446 + .../canjs/steal/can/list/list.js | 1126 ++ .../canjs/steal/can/list/promise/promise.js | 77 + .../canjs/steal/can/list/sort/sort.js | 401 + .../steal/can/map/attributes/attributes.js | 167 + .../canjs/steal/can/map/backup/backup.js | 49 + .../canjs/steal/can/map/bubble.js | 153 + .../canjs/steal/can/map/define/define.js | 372 + .../canjs/steal/can/map/delegate/delegate.js | 198 + .../canjs/steal/can/map/lazy/bubble.js | 27 + .../canjs/steal/can/map/lazy/lazy.js | 341 + .../steal/can/map/lazy/nested_reference.js | 113 + .../canjs/steal/can/map/list/list.js | 120 + .../canjs/steal/can/map/map.js | 703 ++ .../canjs/steal/can/map/setter/setter.js | 92 + .../canjs/steal/can/map/sort/sort.js | 12 + .../steal/can/map/validations/validations.js | 192 + .../canjs/steal/can/model/model.js | 695 ++ .../canjs/steal/can/model/queue/queue.js | 151 + .../canjs/steal/can/observe/observe.js | 18 + .../steal/can/route/pushstate/pushstate.js | 238 + .../canjs/steal/can/route/route.js | 692 ++ .../canjs/steal/can/util/array/each.js | 70 + .../canjs/steal/can/util/array/makeArray.js | 19 + .../canjs/steal/can/util/attr/attr.js | 195 + .../canjs/steal/can/util/batch/batch.js | 263 + .../canjs/steal/can/util/bind/bind.js | 61 + .../canjs/steal/can/util/can.js | 203 + .../canjs/steal/can/util/deferred.js | 185 + .../canjs/steal/can/util/dojo/dojo.js | 694 ++ .../canjs/steal/can/util/domless/domless.js | 146 + .../canjs/steal/can/util/event.js | 15 + .../canjs/steal/can/util/fixture/fixture.js | 773 ++ .../canjs/steal/can/util/fragment.js | 89 + .../canjs/steal/can/util/function/function.js | 47 + .../canjs/steal/can/util/hashchange.js | 27 + .../canjs/steal/can/util/inserted/inserted.js | 77 + .../canjs/steal/can/util/jquery/jquery.js | 277 + .../canjs/steal/can/util/mootools/mootools.js | 414 + .../steal/can/util/object/isplain/isplain.js | 41 + .../canjs/steal/can/util/object/object.js | 196 + .../steal/can/util/string/deparam/deparam.js | 53 + .../canjs/steal/can/util/string/string.js | 143 + .../canjs/steal/can/util/tests/tests.js | 11 + .../canjs/steal/can/util/util.js | 14 + .../canjs/steal/can/util/yui/yui.js | 546 + .../canjs/steal/can/util/zepto/zepto.js | 380 + .../steal/can/view/autorender/autorender.js | 115 + .../canjs/steal/can/view/bindings/bindings.js | 477 + .../steal/can/view/callbacks/callbacks.js | 112 + .../canjs/steal/can/view/ejs/ejs.js | 217 + .../canjs/steal/can/view/ejs/system.js | 30 + .../canjs/steal/can/view/elements.js | 152 + .../canjs/steal/can/view/live/live.js | 687 ++ .../steal/can/view/modifiers/modifiers.js | 286 + .../canjs/steal/can/view/mustache/mustache.js | 2263 ++++ .../canjs/steal/can/view/mustache/system.js | 30 + .../steal/can/view/node_lists/node_lists.js | 373 + .../canjs/steal/can/view/parser/parser.js | 305 + .../canjs/steal/can/view/render.js | 267 + .../canjs/steal/can/view/scanner.js | 695 ++ .../steal/can/view/scope/compute_data.js | 163 + .../canjs/steal/can/view/scope/scope.js | 289 + .../steal/can/view/stache/html_section.js | 154 + .../view/stache/intermediate_and_imports.js | 67 + .../steal/can/view/stache/mustache_core.js | 659 ++ .../steal/can/view/stache/mustache_helpers.js | 179 + .../canjs/steal/can/view/stache/stache.js | 384 + .../canjs/steal/can/view/stache/system.js | 28 + .../steal/can/view/stache/text_section.js | 111 + .../canjs/steal/can/view/stache/utils.js | 49 + .../canjs/steal/can/view/target/target.js | 223 + .../canjs/steal/can/view/view.js | 766 ++ .../bower_components/jquery/.bower.json | 38 + .../bower_components/jquery/MIT-LICENSE.txt | 21 + .../bower_components/jquery/bower.json | 28 + .../bower_components/jquery/dist/jquery.js | 9210 +++++++++++++++++ .../jquery/dist/jquery.min.js | 5 + .../jquery/dist/jquery.min.map | 1 + .../bower_components/jquery/src/ajax.js | 786 ++ .../bower_components/jquery/src/ajax/jsonp.js | 89 + .../bower_components/jquery/src/ajax/load.js | 75 + .../jquery/src/ajax/parseJSON.js | 13 + .../jquery/src/ajax/parseXML.js | 28 + .../jquery/src/ajax/script.js | 64 + .../jquery/src/ajax/var/nonce.js | 5 + .../jquery/src/ajax/var/rquery.js | 3 + .../bower_components/jquery/src/ajax/xhr.js | 136 + .../bower_components/jquery/src/attributes.js | 11 + .../jquery/src/attributes/attr.js | 141 + .../jquery/src/attributes/classes.js | 158 + .../jquery/src/attributes/prop.js | 94 + .../jquery/src/attributes/support.js | 35 + .../jquery/src/attributes/val.js | 161 + .../bower_components/jquery/src/callbacks.js | 205 + .../bower_components/jquery/src/core.js | 502 + .../jquery/src/core/access.js | 60 + .../bower_components/jquery/src/core/init.js | 123 + .../jquery/src/core/parseHTML.js | 39 + .../bower_components/jquery/src/core/ready.js | 97 + .../jquery/src/core/var/rsingleTag.js | 4 + .../bower_components/jquery/src/css.js | 450 + .../jquery/src/css/addGetHookIf.js | 22 + .../bower_components/jquery/src/css/curCSS.js | 57 + .../jquery/src/css/defaultDisplay.js | 70 + .../jquery/src/css/hiddenVisibleSelectors.js | 15 + .../jquery/src/css/support.js | 96 + .../bower_components/jquery/src/css/swap.js | 28 + .../jquery/src/css/var/cssExpand.js | 3 + .../jquery/src/css/var/getStyles.js | 12 + .../jquery/src/css/var/isHidden.js | 13 + .../jquery/src/css/var/rmargin.js | 3 + .../jquery/src/css/var/rnumnonpx.js | 5 + .../bower_components/jquery/src/data.js | 178 + .../bower_components/jquery/src/data/Data.js | 181 + .../jquery/src/data/accepts.js | 20 + .../jquery/src/data/var/data_priv.js | 5 + .../jquery/src/data/var/data_user.js | 5 + .../bower_components/jquery/src/deferred.js | 149 + .../bower_components/jquery/src/deprecated.js | 13 + .../bower_components/jquery/src/dimensions.js | 50 + .../bower_components/jquery/src/effects.js | 648 ++ .../jquery/src/effects/Tween.js | 114 + .../jquery/src/effects/animatedSelector.js | 13 + .../bower_components/jquery/src/event.js | 868 ++ .../bower_components/jquery/src/event/ajax.js | 13 + .../jquery/src/event/alias.js | 39 + .../jquery/src/event/support.js | 9 + .../jquery/src/exports/amd.js | 24 + .../jquery/src/exports/global.js | 32 + .../bower_components/jquery/src/intro.js | 44 + .../bower_components/jquery/src/jquery.js | 37 + .../jquery/src/manipulation.js | 580 ++ .../jquery/src/manipulation/_evalUrl.js | 18 + .../jquery/src/manipulation/support.js | 32 + .../src/manipulation/var/rcheckableType.js | 3 + .../bower_components/jquery/src/offset.js | 207 + .../bower_components/jquery/src/outro.js | 1 + .../bower_components/jquery/src/queue.js | 142 + .../jquery/src/queue/delay.js | 22 + .../jquery/src/selector-native.js | 172 + .../jquery/src/selector-sizzle.js | 14 + .../bower_components/jquery/src/selector.js | 1 + .../bower_components/jquery/src/serialize.js | 111 + .../jquery/src/sizzle/dist/sizzle.js | 2067 ++++ .../jquery/src/sizzle/dist/sizzle.min.js | 3 + .../jquery/src/sizzle/dist/sizzle.min.map | 1 + .../bower_components/jquery/src/traversing.js | 199 + .../jquery/src/traversing/findFilter.js | 100 + .../src/traversing/var/rneedsContext.js | 6 + .../bower_components/jquery/src/var/arr.js | 3 + .../jquery/src/var/class2type.js | 4 + .../bower_components/jquery/src/var/concat.js | 5 + .../bower_components/jquery/src/var/hasOwn.js | 5 + .../jquery/src/var/indexOf.js | 5 + .../bower_components/jquery/src/var/pnum.js | 3 + .../bower_components/jquery/src/var/push.js | 5 + .../jquery/src/var/rnotwhite.js | 3 + .../bower_components/jquery/src/var/slice.js | 5 + .../jquery/src/var/strundefined.js | 3 + .../jquery/src/var/support.js | 4 + .../jquery/src/var/toString.js | 5 + .../bower_components/jquery/src/wrap.js | 79 + .../bower_components/mocha/.bower.json | 33 + .../bower_components/mocha/History.md | 749 ++ .../bower_components/mocha/LICENSE | 22 + .../bower_components/mocha/Readme.md | 203 + .../bower_components/mocha/bower.json | 23 + .../bower_components/mocha/media/logo.svg | 8 + .../bower_components/mocha/mocha.css | 270 + .../bower_components/mocha/mocha.js | 6095 +++++++++++ .../canjs-feathers/dist/canjs-feathers.js | 142 + .../canjs-feathers/lib/feathers.js | 138 + .../node_modules/canjs-feathers/package.json | 57 + .../node_modules/canjs-feathers/readme.md | 72 + .../node_modules/canjs-feathers/test.html | 37 + .../canjs-feathers/test/server/index.js | 49 + .../canjs-feathers/test/server/todos.js | 89 + .../node_modules/canjs-feathers/test/test.js | 143 + .../canjs-localstorage/can.localstorage.js | 76 + .../canjs/node_modules/canjs/can.jquery.js | 6955 +++++++++++++ .../node_modules/feathers-client/.jshintrc | 31 + .../node_modules/feathers-client/.npmignore | 6 + .../node_modules/feathers-client/.travis.yml | 5 + .../node_modules/feathers-client/LICENSE | 22 + .../node_modules/feathers-client/README.md | 161 + .../node_modules/feathers-client/bower.json | 16 + .../feathers-client/dist/feathers.js | 1036 ++ .../feathers-client/lib/arguments.js | 95 + .../feathers-client/lib/client.js | 30 + .../feathers-client/lib/normalizer.js | 12 + .../feathers-client/lib/rest/base.js | 77 + .../feathers-client/lib/rest/events.js | 25 + .../feathers-client/lib/rest/index.js | 5 + .../feathers-client/lib/rest/jquery.js | 41 + .../feathers-client/lib/rest/request.js | 29 + .../feathers-client/lib/rest/superagent.js | 29 + .../feathers-client/lib/sockets/base.js | 53 + .../feathers-client/lib/sockets/index.js | 16 + .../node_modules/feathers-client/lib/utils.js | 23 + .../node_modules/events/.npmignore | 1 + .../node_modules/events/.travis.yml | 7 + .../node_modules/events/.zuul.yml | 12 + .../node_modules/events/History.md | 34 + .../node_modules/events/LICENSE | 22 + .../node_modules/events/Readme.md | 19 + .../node_modules/events/events.js | 301 + .../node_modules/events/package.json | 64 + .../events/tests/add-listeners.js | 63 + .../events/tests/check-listener-leaks.js | 86 + .../node_modules/events/tests/common.js | 42 + .../node_modules/events/tests/index.js | 24 + .../events/tests/legacy-compat.js | 18 + .../events/tests/listeners-side-effects.js | 55 + .../node_modules/events/tests/listeners.js | 51 + .../events/tests/max-listeners.js | 50 + .../events/tests/modify-in-emit.js | 76 + .../node_modules/events/tests/num-args.js | 44 + .../node_modules/events/tests/once.js | 59 + .../events/tests/remove-all-listeners.js | 80 + .../events/tests/remove-listeners.js | 84 + .../tests/set-max-listeners-side-effects.js | 29 + .../node_modules/events/tests/subclass.js | 51 + .../node_modules/querystring/.History.md.un~ | Bin 0 -> 7960 bytes .../node_modules/querystring/.Readme.md.un~ | Bin 0 -> 3225 bytes .../querystring/.package.json.un~ | Bin 0 -> 5710 bytes .../node_modules/querystring/.travis.yml | 4 + .../node_modules/querystring/History.md | 20 + .../node_modules/querystring/License.md | 19 + .../node_modules/querystring/Readme.md | 15 + .../node_modules/querystring/decode.js | 80 + .../node_modules/querystring/encode.js | 64 + .../node_modules/querystring/index.js | 4 + .../node_modules/querystring/package.json | 96 + .../querystring/test/.index.js.un~ | Bin 0 -> 975 bytes .../querystring/test/common-index.js | 3 + .../node_modules/querystring/test/index.js | 210 + .../querystring/test/tap-index.js | 3 + .../node_modules/uberproto/.bowerrc | 3 + .../node_modules/uberproto/.jshintrc | 14 + .../node_modules/uberproto/.npmignore | 5 + .../node_modules/uberproto/.travis.yml | 4 + .../node_modules/uberproto/Gruntfile.js | 70 + .../node_modules/uberproto/bower.json | 21 + .../node_modules/uberproto/component.json | 21 + .../node_modules/uberproto/dist/proto.es5.js | 96 + .../uberproto/dist/proto.es5.min.js | 4 + .../node_modules/uberproto/dist/proto.js | 134 + .../node_modules/uberproto/dist/proto.min.js | 4 + .../node_modules/uberproto/lib/es5.js | 37 + .../node_modules/uberproto/lib/proto.js | 94 + .../node_modules/uberproto/package.json | 65 + .../node_modules/uberproto/proto.min.js | 4 + .../node_modules/uberproto/readme.md | 311 + .../node_modules/uberproto/test/index.html | 32 + .../node_modules/uberproto/test/test.js | 167 + .../node_modules/feathers-client/package.json | 70 + .../feathers-client/test/arguments.test.js | 184 + .../feathers-client/test/client.test.js | 32 + .../feathers-client/test/resources/base.js | 84 + .../feathers-client/test/resources/fixture.js | 52 + .../feathers-client/test/rest/jquery.test.js | 32 + .../feathers-client/test/rest/request.test.js | 21 + .../test/rest/superagent.test.js | 21 + .../test/sockets/primus.test.js | 26 + .../test/sockets/socketio.test.js | 25 + .../canjs/node_modules/jquery/dist/jquery.js | 9205 ++++++++++++++++ .../node_modules/todomvc-app-css/index.css | 378 + .../node_modules/todomvc-common/base.css | 141 + .../canjs/node_modules/todomvc-common/base.js | 244 + todomvc/canjs/package.json | 15 + todomvc/canjs/readme.md | 48 + todomvc/jquery/.gitignore | 15 + todomvc/jquery/css/app.css | 4 + todomvc/jquery/index.html | 64 + todomvc/jquery/js/app.js | 229 + todomvc/jquery/learn.json | 81 + .../node_modules/director/build/director.js | 725 ++ .../node_modules/feathers-client/.jshintrc | 31 + .../node_modules/feathers-client/.npmignore | 6 + .../node_modules/feathers-client/.travis.yml | 5 + .../node_modules/feathers-client/LICENSE | 22 + .../node_modules/feathers-client/README.md | 161 + .../node_modules/feathers-client/bower.json | 16 + .../feathers-client/dist/feathers.js | 1036 ++ .../feathers-client/lib/arguments.js | 95 + .../feathers-client/lib/client.js | 30 + .../feathers-client/lib/normalizer.js | 12 + .../feathers-client/lib/rest/base.js | 77 + .../feathers-client/lib/rest/events.js | 25 + .../feathers-client/lib/rest/index.js | 5 + .../feathers-client/lib/rest/jquery.js | 41 + .../feathers-client/lib/rest/request.js | 29 + .../feathers-client/lib/rest/superagent.js | 29 + .../feathers-client/lib/sockets/base.js | 53 + .../feathers-client/lib/sockets/index.js | 16 + .../node_modules/feathers-client/lib/utils.js | 23 + .../node_modules/events/.npmignore | 1 + .../node_modules/events/.travis.yml | 7 + .../node_modules/events/.zuul.yml | 12 + .../node_modules/events/History.md | 34 + .../node_modules/events/LICENSE | 22 + .../node_modules/events/Readme.md | 19 + .../node_modules/events/events.js | 301 + .../node_modules/events/package.json | 64 + .../events/tests/add-listeners.js | 63 + .../events/tests/check-listener-leaks.js | 86 + .../node_modules/events/tests/common.js | 42 + .../node_modules/events/tests/index.js | 24 + .../events/tests/legacy-compat.js | 18 + .../events/tests/listeners-side-effects.js | 55 + .../node_modules/events/tests/listeners.js | 51 + .../events/tests/max-listeners.js | 50 + .../events/tests/modify-in-emit.js | 76 + .../node_modules/events/tests/num-args.js | 44 + .../node_modules/events/tests/once.js | 59 + .../events/tests/remove-all-listeners.js | 80 + .../events/tests/remove-listeners.js | 84 + .../tests/set-max-listeners-side-effects.js | 29 + .../node_modules/events/tests/subclass.js | 51 + .../node_modules/querystring/.History.md.un~ | Bin 0 -> 7960 bytes .../node_modules/querystring/.Readme.md.un~ | Bin 0 -> 3225 bytes .../querystring/.package.json.un~ | Bin 0 -> 5710 bytes .../node_modules/querystring/.travis.yml | 4 + .../node_modules/querystring/History.md | 20 + .../node_modules/querystring/License.md | 19 + .../node_modules/querystring/Readme.md | 15 + .../node_modules/querystring/decode.js | 80 + .../node_modules/querystring/encode.js | 64 + .../node_modules/querystring/index.js | 4 + .../node_modules/querystring/package.json | 96 + .../querystring/test/.index.js.un~ | Bin 0 -> 975 bytes .../querystring/test/common-index.js | 3 + .../node_modules/querystring/test/index.js | 210 + .../querystring/test/tap-index.js | 3 + .../node_modules/uberproto/.bowerrc | 3 + .../node_modules/uberproto/.jshintrc | 14 + .../node_modules/uberproto/.npmignore | 5 + .../node_modules/uberproto/.travis.yml | 4 + .../node_modules/uberproto/Gruntfile.js | 70 + .../node_modules/uberproto/bower.json | 21 + .../node_modules/uberproto/component.json | 21 + .../node_modules/uberproto/dist/proto.es5.js | 96 + .../uberproto/dist/proto.es5.min.js | 4 + .../node_modules/uberproto/dist/proto.js | 134 + .../node_modules/uberproto/dist/proto.min.js | 4 + .../node_modules/uberproto/lib/es5.js | 37 + .../node_modules/uberproto/lib/proto.js | 94 + .../node_modules/uberproto/package.json | 65 + .../node_modules/uberproto/proto.min.js | 4 + .../node_modules/uberproto/readme.md | 311 + .../node_modules/uberproto/test/index.html | 32 + .../node_modules/uberproto/test/test.js | 167 + .../node_modules/feathers-client/package.json | 70 + .../feathers-client/test/arguments.test.js | 184 + .../feathers-client/test/client.test.js | 32 + .../feathers-client/test/resources/base.js | 84 + .../feathers-client/test/resources/fixture.js | 52 + .../feathers-client/test/rest/jquery.test.js | 32 + .../feathers-client/test/rest/request.test.js | 21 + .../test/rest/superagent.test.js | 21 + .../test/sockets/primus.test.js | 26 + .../test/sockets/socketio.test.js | 25 + .../handlebars/dist/handlebars.js | 3079 ++++++ .../jquery/node_modules/jquery/dist/jquery.js | 9205 ++++++++++++++++ .../node_modules/todomvc-app-css/index.css | 378 + .../node_modules/todomvc-common/base.css | 141 + .../node_modules/todomvc-common/base.js | 244 + todomvc/jquery/package.json | 11 + todomvc/jquery/readme.md | 33 + 684 files changed, 208251 insertions(+), 6 deletions(-) create mode 100644 _layouts/todomvc.html create mode 100644 todomvc/canjs/.gitignore create mode 100644 todomvc/canjs/guide.md create mode 100644 todomvc/canjs/index.html create mode 100644 todomvc/canjs/js/app.js create mode 100644 todomvc/canjs/js/components/todo-app.js create mode 100644 todomvc/canjs/js/models/todo.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/.jshintrc create mode 100644 todomvc/canjs/node_modules/canjs-feathers/.npmignore create mode 100644 todomvc/canjs/node_modules/canjs-feathers/.travis.yml create mode 100644 todomvc/canjs/node_modules/canjs-feathers/LICENSE create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower.json create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/assert/.bower.json create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/assert/HISTORY.md create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/assert/README.md create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/assert/assert.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/assert/bower.json create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/.bower.json create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/bubble.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/component.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/compute.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/construct.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/construct/proxy.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/construct/super.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/control.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/control/plugin.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/control/route.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/deferred.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/elements.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/event.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/fragment.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/get_value_and_bind.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/hashchange.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/list.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/list/promise.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/list/sort.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/attributes.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/backup.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/bubble.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/define.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/delegate.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/lazy.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/list.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/nested_reference.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/setter.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/sort.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/validations.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/model.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/model/queue.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/observe.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/proto_compute.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/read.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/render.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/route.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/route/pushstate.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/scanner.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/attr.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/batch.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/bind.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/can.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/dojo.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/domless.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/each.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/fixture.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/function.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/inserted.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/jquery.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/library.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/makeArray.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/mootools.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/object.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/object/isplain.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/string.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/string/deparam.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/tests.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/yui.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/zepto.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/autorender.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/bindings.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/callbacks.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/compute_data.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/ejs.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/html_section.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/intermediate_and_imports.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/live.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/modifiers.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/mustache.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/mustache_core.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/mustache_helpers.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/node_lists.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/parser.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/scope.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/stache.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/target.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/text_section.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/utils.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/bubble.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/component.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/compute.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/construct.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/construct/proxy.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/construct/super.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/control.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/control/plugin.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/control/route.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/deferred.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/elements.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/event.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/fragment.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/get_value_and_bind.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/hashchange.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/list.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/list/promise.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/list/sort.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/attributes.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/backup.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/bubble.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/define.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/delegate.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/lazy.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/list.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/nested_reference.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/setter.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/sort.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/validations.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/model.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/model/queue.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/observe.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/proto_compute.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/read.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/render.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/route.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/route/pushstate.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/scanner.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/attr.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/batch.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/bind.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/can.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/dojo.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/domless.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/each.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/fixture.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/function.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/inserted.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/jquery.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/library.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/makeArray.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/mootools.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/object.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/object/isplain.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/string.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/string/deparam.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/tests.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/yui.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/zepto.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/autorender.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/bindings.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/callbacks.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/compute_data.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/ejs.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/html_section.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/intermediate_and_imports.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/live.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/modifiers.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/mustache.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/mustache_core.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/mustache_helpers.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/node_lists.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/parser.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/scope.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/stache.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/target.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/text_section.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/utils.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/bower.json create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.autorender.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.construct.proxy.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.construct.super.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.control.plugin.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.dojo.dev.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.dojo.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.dojo.min.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.ejs.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.fixture.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.jquery.dev.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.jquery.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.jquery.min.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.list.promise.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.list.sort.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.attributes.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.backup.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.define.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.delegate.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.lazy.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.list.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.setter.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.sort.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.validations.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.model.queue.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.mootools.dev.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.mootools.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.mootools.min.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.object.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.route.pushstate.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.stache.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.util.domless.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.util.function.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.view.ejs.system.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.view.modifiers.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.view.mustache.system.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.view.stache.system.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.yui.dev.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.yui.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.yui.min.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.zepto.dev.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.zepto.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.zepto.min.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/can.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/component/component.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/compute/compute.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/compute/get_value_and_bind.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/compute/proto_compute.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/compute/read.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/construct/construct.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/construct/proxy/proxy.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/construct/super/super.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/control/control.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/control/plugin/plugin.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/control/route/route.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/event/event.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/list/list.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/list/promise/promise.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/list/sort/sort.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/attributes/attributes.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/backup/backup.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/bubble.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/define/define.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/delegate/delegate.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/lazy/bubble.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/lazy/lazy.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/lazy/nested_reference.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/list/list.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/map.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/setter/setter.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/sort/sort.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/validations/validations.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/model/model.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/model/queue/queue.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/observe/observe.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/route/pushstate/pushstate.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/route/route.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/array/each.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/array/makeArray.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/attr/attr.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/batch/batch.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/bind/bind.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/can.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/domless/domless.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/event.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/fixture/fixture.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/function/function.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/inserted/inserted.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/jquery/jquery.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/object/object.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/string/deparam/deparam.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/string/string.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/tests/tests.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/util.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/autorender/autorender.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/bindings/bindings.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/callbacks/callbacks.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/ejs/ejs.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/ejs/system.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/elements.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/live/live.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/modifiers/modifiers.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/mustache/mustache.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/mustache/system.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/node_lists/node_lists.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/parser/parser.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/render.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/scanner.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/scope/compute_data.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/scope/scope.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/html_section.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/intermediate_and_imports.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/mustache_core.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/mustache_helpers.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/stache.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/system.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/text_section.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/utils.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/target/target.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/view.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/readme.md create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/can.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/component/component.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/compute/compute.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/compute/get_value_and_bind.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/compute/proto_compute.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/compute/read.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/construct/construct.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/construct/proxy/proxy.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/construct/super/super.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/control/control.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/control/plugin/plugin.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/control/route/route.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/event/event.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/list/list.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/list/promise/promise.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/list/sort/sort.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/attributes/attributes.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/backup/backup.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/bubble.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/define/define.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/delegate/delegate.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/lazy/bubble.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/lazy/lazy.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/lazy/nested_reference.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/list/list.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/map.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/setter/setter.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/sort/sort.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/validations/validations.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/model/model.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/model/queue/queue.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/observe/observe.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/route/pushstate/pushstate.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/route/route.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/array/each.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/array/makeArray.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/attr/attr.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/batch/batch.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/bind/bind.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/can.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/deferred.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/dojo/dojo.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/domless/domless.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/event.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/fixture/fixture.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/fragment.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/function/function.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/hashchange.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/inserted/inserted.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/jquery/jquery.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/mootools/mootools.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/object/isplain/isplain.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/object/object.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/string/deparam/deparam.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/string/string.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/tests/tests.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/util.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/yui/yui.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/zepto/zepto.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/autorender/autorender.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/bindings/bindings.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/callbacks/callbacks.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/ejs/ejs.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/ejs/system.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/elements.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/live/live.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/modifiers/modifiers.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/mustache/mustache.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/mustache/system.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/node_lists/node_lists.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/parser/parser.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/render.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/scanner.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/scope/compute_data.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/scope/scope.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/stache/html_section.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/stache/intermediate_and_imports.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/stache/mustache_core.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/stache/mustache_helpers.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/stache/stache.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/stache/system.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/stache/text_section.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/stache/utils.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/target/target.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/view.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/.bower.json create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/MIT-LICENSE.txt create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/bower.json create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/dist/jquery.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/dist/jquery.min.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/dist/jquery.min.map create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/ajax.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/ajax/jsonp.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/ajax/load.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/ajax/parseJSON.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/ajax/parseXML.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/ajax/script.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/ajax/var/nonce.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/ajax/var/rquery.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/ajax/xhr.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/attributes.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/attributes/attr.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/attributes/classes.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/attributes/prop.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/attributes/support.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/attributes/val.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/callbacks.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/core.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/core/access.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/core/init.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/core/parseHTML.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/core/ready.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/core/var/rsingleTag.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/css.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/css/addGetHookIf.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/css/curCSS.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/css/defaultDisplay.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/css/hiddenVisibleSelectors.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/css/support.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/css/swap.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/css/var/cssExpand.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/css/var/getStyles.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/css/var/isHidden.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/css/var/rmargin.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/css/var/rnumnonpx.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/data.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/data/Data.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/data/accepts.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/data/var/data_priv.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/data/var/data_user.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/deferred.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/deprecated.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/dimensions.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/effects.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/effects/Tween.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/effects/animatedSelector.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/event.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/event/ajax.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/event/alias.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/event/support.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/exports/amd.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/exports/global.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/intro.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/jquery.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/manipulation.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/manipulation/_evalUrl.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/manipulation/support.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/manipulation/var/rcheckableType.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/offset.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/outro.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/queue.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/queue/delay.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/selector-native.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/selector-sizzle.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/selector.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/serialize.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/sizzle/dist/sizzle.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/sizzle/dist/sizzle.min.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/sizzle/dist/sizzle.min.map create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/traversing.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/traversing/findFilter.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/traversing/var/rneedsContext.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/var/arr.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/var/class2type.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/var/concat.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/var/hasOwn.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/var/indexOf.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/var/pnum.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/var/push.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/var/rnotwhite.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/var/slice.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/var/strundefined.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/var/support.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/var/toString.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/jquery/src/wrap.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/mocha/.bower.json create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/mocha/History.md create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/mocha/LICENSE create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/mocha/Readme.md create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/mocha/bower.json create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/mocha/media/logo.svg create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/mocha/mocha.css create mode 100644 todomvc/canjs/node_modules/canjs-feathers/bower_components/mocha/mocha.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/dist/canjs-feathers.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/lib/feathers.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/package.json create mode 100644 todomvc/canjs/node_modules/canjs-feathers/readme.md create mode 100644 todomvc/canjs/node_modules/canjs-feathers/test.html create mode 100644 todomvc/canjs/node_modules/canjs-feathers/test/server/index.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/test/server/todos.js create mode 100644 todomvc/canjs/node_modules/canjs-feathers/test/test.js create mode 100644 todomvc/canjs/node_modules/canjs-localstorage/can.localstorage.js create mode 100644 todomvc/canjs/node_modules/canjs/can.jquery.js create mode 100644 todomvc/canjs/node_modules/feathers-client/.jshintrc create mode 100644 todomvc/canjs/node_modules/feathers-client/.npmignore create mode 100644 todomvc/canjs/node_modules/feathers-client/.travis.yml create mode 100644 todomvc/canjs/node_modules/feathers-client/LICENSE create mode 100644 todomvc/canjs/node_modules/feathers-client/README.md create mode 100644 todomvc/canjs/node_modules/feathers-client/bower.json create mode 100644 todomvc/canjs/node_modules/feathers-client/dist/feathers.js create mode 100644 todomvc/canjs/node_modules/feathers-client/lib/arguments.js create mode 100644 todomvc/canjs/node_modules/feathers-client/lib/client.js create mode 100644 todomvc/canjs/node_modules/feathers-client/lib/normalizer.js create mode 100644 todomvc/canjs/node_modules/feathers-client/lib/rest/base.js create mode 100644 todomvc/canjs/node_modules/feathers-client/lib/rest/events.js create mode 100644 todomvc/canjs/node_modules/feathers-client/lib/rest/index.js create mode 100644 todomvc/canjs/node_modules/feathers-client/lib/rest/jquery.js create mode 100644 todomvc/canjs/node_modules/feathers-client/lib/rest/request.js create mode 100644 todomvc/canjs/node_modules/feathers-client/lib/rest/superagent.js create mode 100644 todomvc/canjs/node_modules/feathers-client/lib/sockets/base.js create mode 100644 todomvc/canjs/node_modules/feathers-client/lib/sockets/index.js create mode 100644 todomvc/canjs/node_modules/feathers-client/lib/utils.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/events/.npmignore create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/events/.travis.yml create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/events/.zuul.yml create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/events/History.md create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/events/LICENSE create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/events/Readme.md create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/events/events.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/events/package.json create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/events/tests/add-listeners.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/events/tests/check-listener-leaks.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/events/tests/common.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/events/tests/index.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/events/tests/legacy-compat.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/events/tests/listeners-side-effects.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/events/tests/listeners.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/events/tests/max-listeners.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/events/tests/modify-in-emit.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/events/tests/num-args.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/events/tests/once.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/events/tests/remove-all-listeners.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/events/tests/remove-listeners.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/events/tests/set-max-listeners-side-effects.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/events/tests/subclass.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/querystring/.History.md.un~ create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/querystring/.Readme.md.un~ create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/querystring/.package.json.un~ create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/querystring/.travis.yml create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/querystring/History.md create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/querystring/License.md create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/querystring/Readme.md create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/querystring/decode.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/querystring/encode.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/querystring/index.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/querystring/package.json create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/querystring/test/.index.js.un~ create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/querystring/test/common-index.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/querystring/test/index.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/querystring/test/tap-index.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/uberproto/.bowerrc create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/uberproto/.jshintrc create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/uberproto/.npmignore create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/uberproto/.travis.yml create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/uberproto/Gruntfile.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/uberproto/bower.json create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/uberproto/component.json create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/uberproto/dist/proto.es5.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/uberproto/dist/proto.es5.min.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/uberproto/dist/proto.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/uberproto/dist/proto.min.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/uberproto/lib/es5.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/uberproto/lib/proto.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/uberproto/package.json create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/uberproto/proto.min.js create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/uberproto/readme.md create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/uberproto/test/index.html create mode 100644 todomvc/canjs/node_modules/feathers-client/node_modules/uberproto/test/test.js create mode 100644 todomvc/canjs/node_modules/feathers-client/package.json create mode 100644 todomvc/canjs/node_modules/feathers-client/test/arguments.test.js create mode 100644 todomvc/canjs/node_modules/feathers-client/test/client.test.js create mode 100644 todomvc/canjs/node_modules/feathers-client/test/resources/base.js create mode 100644 todomvc/canjs/node_modules/feathers-client/test/resources/fixture.js create mode 100644 todomvc/canjs/node_modules/feathers-client/test/rest/jquery.test.js create mode 100644 todomvc/canjs/node_modules/feathers-client/test/rest/request.test.js create mode 100644 todomvc/canjs/node_modules/feathers-client/test/rest/superagent.test.js create mode 100644 todomvc/canjs/node_modules/feathers-client/test/sockets/primus.test.js create mode 100644 todomvc/canjs/node_modules/feathers-client/test/sockets/socketio.test.js create mode 100644 todomvc/canjs/node_modules/jquery/dist/jquery.js create mode 100644 todomvc/canjs/node_modules/todomvc-app-css/index.css create mode 100644 todomvc/canjs/node_modules/todomvc-common/base.css create mode 100644 todomvc/canjs/node_modules/todomvc-common/base.js create mode 100644 todomvc/canjs/package.json create mode 100644 todomvc/canjs/readme.md create mode 100644 todomvc/jquery/.gitignore create mode 100644 todomvc/jquery/css/app.css create mode 100644 todomvc/jquery/index.html create mode 100644 todomvc/jquery/js/app.js create mode 100644 todomvc/jquery/learn.json create mode 100644 todomvc/jquery/node_modules/director/build/director.js create mode 100644 todomvc/jquery/node_modules/feathers-client/.jshintrc create mode 100644 todomvc/jquery/node_modules/feathers-client/.npmignore create mode 100644 todomvc/jquery/node_modules/feathers-client/.travis.yml create mode 100644 todomvc/jquery/node_modules/feathers-client/LICENSE create mode 100644 todomvc/jquery/node_modules/feathers-client/README.md create mode 100644 todomvc/jquery/node_modules/feathers-client/bower.json create mode 100644 todomvc/jquery/node_modules/feathers-client/dist/feathers.js create mode 100644 todomvc/jquery/node_modules/feathers-client/lib/arguments.js create mode 100644 todomvc/jquery/node_modules/feathers-client/lib/client.js create mode 100644 todomvc/jquery/node_modules/feathers-client/lib/normalizer.js create mode 100644 todomvc/jquery/node_modules/feathers-client/lib/rest/base.js create mode 100644 todomvc/jquery/node_modules/feathers-client/lib/rest/events.js create mode 100644 todomvc/jquery/node_modules/feathers-client/lib/rest/index.js create mode 100644 todomvc/jquery/node_modules/feathers-client/lib/rest/jquery.js create mode 100644 todomvc/jquery/node_modules/feathers-client/lib/rest/request.js create mode 100644 todomvc/jquery/node_modules/feathers-client/lib/rest/superagent.js create mode 100644 todomvc/jquery/node_modules/feathers-client/lib/sockets/base.js create mode 100644 todomvc/jquery/node_modules/feathers-client/lib/sockets/index.js create mode 100644 todomvc/jquery/node_modules/feathers-client/lib/utils.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/events/.npmignore create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/events/.travis.yml create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/events/.zuul.yml create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/events/History.md create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/events/LICENSE create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/events/Readme.md create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/events/events.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/events/package.json create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/events/tests/add-listeners.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/events/tests/check-listener-leaks.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/events/tests/common.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/events/tests/index.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/events/tests/legacy-compat.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/events/tests/listeners-side-effects.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/events/tests/listeners.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/events/tests/max-listeners.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/events/tests/modify-in-emit.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/events/tests/num-args.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/events/tests/once.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/events/tests/remove-all-listeners.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/events/tests/remove-listeners.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/events/tests/set-max-listeners-side-effects.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/events/tests/subclass.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/querystring/.History.md.un~ create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/querystring/.Readme.md.un~ create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/querystring/.package.json.un~ create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/querystring/.travis.yml create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/querystring/History.md create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/querystring/License.md create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/querystring/Readme.md create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/querystring/decode.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/querystring/encode.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/querystring/index.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/querystring/package.json create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/querystring/test/.index.js.un~ create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/querystring/test/common-index.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/querystring/test/index.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/querystring/test/tap-index.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/uberproto/.bowerrc create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/uberproto/.jshintrc create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/uberproto/.npmignore create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/uberproto/.travis.yml create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/uberproto/Gruntfile.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/uberproto/bower.json create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/uberproto/component.json create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/uberproto/dist/proto.es5.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/uberproto/dist/proto.es5.min.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/uberproto/dist/proto.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/uberproto/dist/proto.min.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/uberproto/lib/es5.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/uberproto/lib/proto.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/uberproto/package.json create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/uberproto/proto.min.js create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/uberproto/readme.md create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/uberproto/test/index.html create mode 100644 todomvc/jquery/node_modules/feathers-client/node_modules/uberproto/test/test.js create mode 100644 todomvc/jquery/node_modules/feathers-client/package.json create mode 100644 todomvc/jquery/node_modules/feathers-client/test/arguments.test.js create mode 100644 todomvc/jquery/node_modules/feathers-client/test/client.test.js create mode 100644 todomvc/jquery/node_modules/feathers-client/test/resources/base.js create mode 100644 todomvc/jquery/node_modules/feathers-client/test/resources/fixture.js create mode 100644 todomvc/jquery/node_modules/feathers-client/test/rest/jquery.test.js create mode 100644 todomvc/jquery/node_modules/feathers-client/test/rest/request.test.js create mode 100644 todomvc/jquery/node_modules/feathers-client/test/rest/superagent.test.js create mode 100644 todomvc/jquery/node_modules/feathers-client/test/sockets/primus.test.js create mode 100644 todomvc/jquery/node_modules/feathers-client/test/sockets/socketio.test.js create mode 100644 todomvc/jquery/node_modules/handlebars/dist/handlebars.js create mode 100644 todomvc/jquery/node_modules/jquery/dist/jquery.js create mode 100644 todomvc/jquery/node_modules/todomvc-app-css/index.css create mode 100644 todomvc/jquery/node_modules/todomvc-common/base.css create mode 100644 todomvc/jquery/node_modules/todomvc-common/base.js create mode 100644 todomvc/jquery/package.json create mode 100644 todomvc/jquery/readme.md diff --git a/_layouts/todomvc.html b/_layouts/todomvc.html new file mode 100644 index 0000000000..ba37badb7c --- /dev/null +++ b/_layouts/todomvc.html @@ -0,0 +1,15 @@ +--- +layout: default +--- + + + +
            +
            +
            +

            {{page.title}}

            + {{ content }} +
            +
            +
            + diff --git a/quick-start.md b/quick-start.md index 1aa09e2f95..966870b8cf 100644 --- a/quick-start.md +++ b/quick-start.md @@ -234,7 +234,7 @@ That's it. Our application is now real-time, all we have to do is provide a nice ## Building a frontend -Feathers works great with any frontend framework, Android or iOS clients or anything else that can connect to a REST API or websockets (to get real-time). We have real-time [TodoMVC](http://todomvc.com/) examples for [jQuery](), [Angular](), [React]() and [CanJS]() but for this guide, we will create a more simplified jQuery client. +Feathers works great with [any frontend framework](/learn/), Android or iOS clients or anything else that can connect to a REST API or websockets (to get real-time). We have real-time [TodoMVC](http://todomvc.com/) examples for [jQuery](/todomvc/feathers/jquery/guide.html), [Angular](/todomvc/feathers/angularjs/guide.html), [React](/todomvc/feathers/react/guide.html) and [CanJS](/todomvc/feathers/canjs/guide.html) but for this guide, we will create a more simplified jQuery client. ### Feathers client @@ -267,7 +267,7 @@ Since we also set statically hosting the files in the current folder in the prev }); todos.create({ - text: 'Todo from client',. + text: 'Todo from client', complete: false }); @@ -311,13 +311,13 @@ Let's update `index.html` to load [Bootstrap](http://getbootstrap.com/) and [jQu - + - + ``` -In `todos.js` we now have to connect to the service again and add jQuery code that adds, removes and updates todos. To identify a Todo we'll store the `data-id=""` property on the todos `
          • ` and retrieve it with `getElement(todo)`: +In `todo-client.js` we now have to connect to the service again and add jQuery code that adds, removes and updates todos. To identify a Todo we'll store the `data-id=""` property on the todos `
          • ` and retrieve it with `getElement(todo)`: ```js var el = $('#todos'); @@ -399,7 +399,7 @@ el.on('submit', 'form', function (ev) { }); ``` -Now go to [http://localhost:3030](http://localhost:3030) and you will be able to create, complete and remove todos and it will update on all clients in real-time. +Now go to [http://localhost:3000](http://localhost:3000) and you will be able to create, complete and remove todos and it will update on all clients in real-time. ## What's next? diff --git a/todomvc/canjs/.gitignore b/todomvc/canjs/.gitignore new file mode 100644 index 0000000000..cc8b57f0f5 --- /dev/null +++ b/todomvc/canjs/.gitignore @@ -0,0 +1,29 @@ +node_modules/.bin/* + +node_modules/canjs-localstorage/* +!node_modules/canjs-localstorage/can.localstorage.js + +node_modules/napa/* + +node_modules/canjs/* +!node_modules/canjs/can.jquery.js + +node_modules/jquery/.bowerrc +node_modules/jquery/.npmignore +node_modules/jquery/AUTHORS.txt +node_modules/jquery/CONTRIBUTING.md +node_modules/jquery/MIT-LICENSE.txt +node_modules/jquery/README.md +node_modules/jquery/bower.json +node_modules/jquery/package.json +node_modules/jquery/.jscsrc +node_modules/jquery/src/* +node_modules/jquery/dist/* +!node_modules/jquery/dist/jquery.js + +node_modules/todomvc-common/* +!node_modules/todomvc-common/base.js +!node_modules/todomvc-common/base.css + +node_modules/todomvc-app-css/* +!node_modules/todomvc-app-css/index.css diff --git a/todomvc/canjs/guide.md b/todomvc/canjs/guide.md new file mode 100644 index 0000000000..7e6e4234a7 --- /dev/null +++ b/todomvc/canjs/guide.md @@ -0,0 +1,62 @@ +-- +layout: todomvc +title: CanJS TodoMVC +path: /todomvc/feathers/canjs +description: A real-time TodoMVC example using CanJS and Feathers +-- + +
            +
            +
            +

            Double-click to edit a todo

            +

            Written by Bitovi

            +

            Part of TodoMVC

            +
            + + + + + + + + + + diff --git a/todomvc/canjs/index.html b/todomvc/canjs/index.html new file mode 100644 index 0000000000..3eb02328a6 --- /dev/null +++ b/todomvc/canjs/index.html @@ -0,0 +1,66 @@ + + + + + CanJS • TodoMVC + + + + +
            +
            +
            +

            Double-click to edit a todo

            +

            Written by Bitovi

            +

            Part of TodoMVC

            +
            + + + + + + + + + + + + diff --git a/todomvc/canjs/js/app.js b/todomvc/canjs/js/app.js new file mode 100644 index 0000000000..3e5701332c --- /dev/null +++ b/todomvc/canjs/js/app.js @@ -0,0 +1,15 @@ +/* global $, can */ +(function () { + 'use strict'; + + $(function () { + // Set up a route that maps to the `filter` attribute + can.route(':filter'); + + // Render #app-template + $('#todoapp').html(can.view('app-template', {})); + + // Start the router + can.route.ready(); + }); +})(); diff --git a/todomvc/canjs/js/components/todo-app.js b/todomvc/canjs/js/components/todo-app.js new file mode 100644 index 0000000000..2b2f4d35dc --- /dev/null +++ b/todomvc/canjs/js/components/todo-app.js @@ -0,0 +1,97 @@ +/* global can */ +(function (namespace) { + 'use strict'; + + var ESCAPE_KEY = 27; + + can.Component.extend({ + // Create this component on a tag like ``. + tag: 'todo-app', + scope: { + // Store the Todo model in the scope + Todo: namespace.Models.Todo, + // A list of all Todos retrieved from LocalStorage + todos: new namespace.Models.Todo.List({}), + // Edit a Todo + edit: function (todo, el) { + todo.attr('editing', true); + el.parents('.todo').find('.edit').focus(); + }, + cancelEditing: function (todo, el, ev) { + if (ev.which === ESCAPE_KEY) { + el.val(todo.attr('text')); + todo.attr('editing', false); + } + }, + // Returns a list of Todos filtered based on the route + displayList: function () { + var filter = can.route.attr('filter'); + return this.todos.filter(function (todo) { + if (filter === 'completed') { + return todo.attr('complete'); + } + + if (filter === 'active') { + return !todo.attr('complete'); + } + + return true; + }); + }, + updateTodo: function (todo, el) { + var value = can.trim(el.val()); + + if (value === '') { + todo.destroy(); + } else { + todo.attr({ + editing: false, + text: value + }); + } + }, + createTodo: function (context, el) { + var value = can.trim(el.val()); + var TodoModel = this.Todo; + + if (value !== '') { + new TodoModel({ + text: value, + complete: false + }).save(); + + can.route.removeAttr('filter'); + el.val(''); + } + }, + toggleAll: function (scope, el) { + var toggle = el.prop('checked'); + this.attr('todos').each(function (todo) { + todo.attr('complete', toggle); + }); + }, + clearCompleted: function () { + this.attr('todos').completed().forEach(function (todo) { + todo.destroy(); + }); + } + }, + events: { + // When a new Todo has been created, add it to the todo list + '{Todo} created': function (Construct, ev, todo) { + this.scope.attr('todos').push(todo); + } + }, + helpers: { + link: function (name, filter) { + var data = filter ? { filter: filter } : {}; + return can.route.link(name, data, { + className: can.route.attr('filter') === filter ? 'selected' : '' + }); + }, + plural: function (singular, num) { + return num() === 1 ? singular : singular + 's'; + } + } + }); +})(this); diff --git a/todomvc/canjs/js/models/todo.js b/todomvc/canjs/js/models/todo.js new file mode 100644 index 0000000000..6d2a9703a9 --- /dev/null +++ b/todomvc/canjs/js/models/todo.js @@ -0,0 +1,54 @@ +/*global can */ +(function (namespace) { + 'use strict'; + + var socket = io('http://todos.feathersjs.com'); + var app = feathers().configure(feathers.socketio(socket)); + var FeathersModel = canFeathers(app); + + // Basic Todo entry model + var Todo = FeathersModel({ + resource: 'todos' + }, { + init: function () { + // Autosave when changing the text or completing the todo + this.on('change', function (ev, prop) { + if (prop === 'text' || prop === 'complete') { + ev.target.save(); + } + }); + } + }); + + // List for Todos + Todo.List = Todo.List.extend({ + filter: function (check) { + var list = []; + + this.each(function (todo) { + if (check(todo)) { + list.push(todo); + } + }); + + return list; + }, + + completed: function () { + return this.filter(function (todo) { + return todo.attr('complete'); + }); + }, + + remaining: function () { + return this.attr('length') - this.completed().length; + }, + + allComplete: function () { + return this.attr('length') === this.completed().length; + } + }); + + namespace.Models = namespace.Models || {}; + namespace.Models.Todo = Todo; +})(this); diff --git a/todomvc/canjs/node_modules/canjs-feathers/.jshintrc b/todomvc/canjs/node_modules/canjs-feathers/.jshintrc new file mode 100644 index 0000000000..0624fe1054 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/.jshintrc @@ -0,0 +1,34 @@ +{ + "node": true, + "browser": true, + "esnext": true, + "bitwise": true, + "camelcase": false, + "curly": true, + "eqeqeq": true, + "immed": true, + "indent": 2, + "latedef": "nofunc", + "newcap": false, + "noarg": true, + "quotmark": "single", + "regexp": true, + "undef": true, + "unused": true, + "strict": false, + "trailing": true, + "smarttabs": true, + "white": false, + "browser": true, + "globals": { + "it": true, + "describe": true, + "before": true, + "beforeEach": true, + "after": true, + "afterEach": true, + "exports": true, + "assert": true, + "can": true + } +} diff --git a/todomvc/canjs/node_modules/canjs-feathers/.npmignore b/todomvc/canjs/node_modules/canjs-feathers/.npmignore new file mode 100644 index 0000000000..3c0cf7db23 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/.npmignore @@ -0,0 +1,6 @@ +.git* +.DS_Store +*.markdown +*.md +.idea +!dist/ \ No newline at end of file diff --git a/todomvc/canjs/node_modules/canjs-feathers/.travis.yml b/todomvc/canjs/node_modules/canjs-feathers/.travis.yml new file mode 100644 index 0000000000..478bab6b94 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +before_script: bower install +before_install: + - "export DISPLAY=:99.0" + - "sh -e /etc/init.d/xvfb start" +node_js: "node" diff --git a/todomvc/canjs/node_modules/canjs-feathers/LICENSE b/todomvc/canjs/node_modules/canjs-feathers/LICENSE new file mode 100644 index 0000000000..14d0b10cfd --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2014 David Luecke + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower.json b/todomvc/canjs/node_modules/canjs-feathers/bower.json new file mode 100644 index 0000000000..ff7ccca573 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower.json @@ -0,0 +1,29 @@ +{ + "name": "canjs-feathers", + "version": "0.1.0", + "homepage": "https://github.com/feathersjs/canjs-feathers", + "authors": [ + "David Luecke " + ], + "description": "CanJS model real-time bindings to Feathers service", + "main": "lib/feathers.js", + "keywords": [ + "CanJS", + "Feathers", + "real-time" + ], + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "devDependencies": { + "canjs": "^2.1.4", + "jquery": "^2.1.0", + "mocha": "^1.18.2", + "assert": "^0.0.2" + } +} diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/assert/.bower.json b/todomvc/canjs/node_modules/canjs-feathers/bower_components/assert/.bower.json new file mode 100644 index 0000000000..30637b9aa3 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/assert/.bower.json @@ -0,0 +1,23 @@ +{ + "name": "assert", + "main": "assert.js", + "version": "0.0.2", + "homepage": "https://github.com/jgallen23/assert", + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "_release": "0.0.2", + "_resolution": { + "type": "version", + "tag": "0.0.2", + "commit": "a43546913b88907a64fd46ae96fc47634a969861" + }, + "_source": "git://github.com/jgallen23/assert.git", + "_target": "^0.0.2", + "_originalSource": "assert" +} \ No newline at end of file diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/assert/HISTORY.md b/todomvc/canjs/node_modules/canjs-feathers/bower_components/assert/HISTORY.md new file mode 100644 index 0000000000..53267029e4 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/assert/HISTORY.md @@ -0,0 +1,27 @@ +0.0.2 / 2014-01-17 +================== + + * Switching component.json to bower.json to avoid deprecation warnings + +0.0.1 / 2012-12-06 +================== + + * added component.json for bower + * add Object.create comatibile for issue #1 + * update assert to v0.8.1 + * fix README.md + * to make it perfect: s/the both-sides/both sides/ + * Assert to assert + * updates README + * add README.md + * add index.html for browser test + * fix replace for browser + * mod copyright + * add common object instead of require('common') + * semmicolon + * add test-assert.js + * remove case of buffer(browser dosen't has) + * define util.inherits instead of require('util') + * export assert to global or module + * modefy license + * initial commit diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/assert/README.md b/todomvc/canjs/node_modules/canjs-feathers/bower_components/assert/README.md new file mode 100644 index 0000000000..748c52593d --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/assert/README.md @@ -0,0 +1,38 @@ +# assert.js + +assert.js is a port of the Node.js standard assertion library for the browser. +The original code and tests are from Node.js, and have been modified to be browser compatible. + +For example, you can use it with [Mocha](http://visionmedia.github.com/mocha/) to perform tests +on the **both sides** (server-side and client-side). Mocha does not supply it's own assertion library. + +## run the same tests on both the client-side and server-side + +You can use the standard assert module when running mocha on Node.js. + +The same tests will run in the browser if you use this library. + +## how to use + +```html + + + +``` + +## running test of this library + +### browser +open ```test/index.html``` in your browser, +and see the console. + +### node.js + +```shell +> node test/test-assert.js +All OK +``` + +## license + +MIT (same as Node.js) \ No newline at end of file diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/assert/assert.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/assert/assert.js new file mode 100644 index 0000000000..ced0425877 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/assert/assert.js @@ -0,0 +1,370 @@ +// http://wiki.commonjs.org/wiki/Unit_Testing/1.0 +// +// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8! +// +// Copyright (c) 2011 Jxck +// +// Originally from node.js (http://nodejs.org) +// Copyright Joyent, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the 'Software'), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(function(global) { + +// Object.create compatible in IE +var create = Object.create || function(p) { + if (!p) throw Error('no type'); + function f() {}; + f.prototype = p; + return new f(); +}; + +// UTILITY +var util = { + inherits: function(ctor, superCtor) { + ctor.super_ = superCtor; + ctor.prototype = create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + } +}; + +var pSlice = Array.prototype.slice; + +// 1. The assert module provides functions that throw +// AssertionError's when particular conditions are not met. The +// assert module must conform to the following interface. + +var assert = ok; + +global['assert'] = assert; + +if (typeof module === 'object' && typeof module.exports === 'object') { + module.exports = assert; +}; + +// 2. The AssertionError is defined in assert. +// new assert.AssertionError({ message: message, +// actual: actual, +// expected: expected }) + +assert.AssertionError = function AssertionError(options) { + this.name = 'AssertionError'; + this.message = options.message; + this.actual = options.actual; + this.expected = options.expected; + this.operator = options.operator; + var stackStartFunction = options.stackStartFunction || fail; + + if (Error.captureStackTrace) { + Error.captureStackTrace(this, stackStartFunction); + } +}; +util.inherits(assert.AssertionError, Error); + +function replacer(key, value) { + if (value === undefined) { + return '' + value; + } + if (typeof value === 'number' && (isNaN(value) || !isFinite(value))) { + return value.toString(); + } + if (typeof value === 'function' || value instanceof RegExp) { + return value.toString(); + } + return value; +} + +function truncate(s, n) { + if (typeof s == 'string') { + return s.length < n ? s : s.slice(0, n); + } else { + return s; + } +} + +assert.AssertionError.prototype.toString = function() { + if (this.message) { + return [this.name + ':', this.message].join(' '); + } else { + return [ + this.name + ':', + truncate(JSON.stringify(this.actual, replacer), 128), + this.operator, + truncate(JSON.stringify(this.expected, replacer), 128) + ].join(' '); + } +}; + +// assert.AssertionError instanceof Error + +assert.AssertionError.__proto__ = Error.prototype; + +// At present only the three keys mentioned above are used and +// understood by the spec. Implementations or sub modules can pass +// other keys to the AssertionError's constructor - they will be +// ignored. + +// 3. All of the following functions must throw an AssertionError +// when a corresponding condition is not met, with a message that +// may be undefined if not provided. All assertion methods provide +// both the actual and expected values to the assertion error for +// display purposes. + +function fail(actual, expected, message, operator, stackStartFunction) { + throw new assert.AssertionError({ + message: message, + actual: actual, + expected: expected, + operator: operator, + stackStartFunction: stackStartFunction + }); +} + +// EXTENSION! allows for well behaved errors defined elsewhere. +assert.fail = fail; + +// 4. Pure assertion tests whether a value is truthy, as determined +// by !!guard. +// assert.ok(guard, message_opt); +// This statement is equivalent to assert.equal(true, !!guard, +// message_opt);. To test strictly for the value true, use +// assert.strictEqual(true, guard, message_opt);. + +function ok(value, message) { + if (!!!value) fail(value, true, message, '==', assert.ok); +} +assert.ok = ok; + +// 5. The equality assertion tests shallow, coercive equality with +// ==. +// assert.equal(actual, expected, message_opt); + +assert.equal = function equal(actual, expected, message) { + if (actual != expected) fail(actual, expected, message, '==', assert.equal); +}; + +// 6. The non-equality assertion tests for whether two objects are not equal +// with != assert.notEqual(actual, expected, message_opt); + +assert.notEqual = function notEqual(actual, expected, message) { + if (actual == expected) { + fail(actual, expected, message, '!=', assert.notEqual); + } +}; + +// 7. The equivalence assertion tests a deep equality relation. +// assert.deepEqual(actual, expected, message_opt); + +assert.deepEqual = function deepEqual(actual, expected, message) { + if (!_deepEqual(actual, expected)) { + fail(actual, expected, message, 'deepEqual', assert.deepEqual); + } +}; + +function _deepEqual(actual, expected) { + // 7.1. All identical values are equivalent, as determined by ===. + if (actual === expected) { + return true; + +// } else if (Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) { +// if (actual.length != expected.length) return false; +// +// for (var i = 0; i < actual.length; i++) { +// if (actual[i] !== expected[i]) return false; +// } +// +// return true; +// + // 7.2. If the expected value is a Date object, the actual value is + // equivalent if it is also a Date object that refers to the same time. + } else if (actual instanceof Date && expected instanceof Date) { + return actual.getTime() === expected.getTime(); + + // 7.3 If the expected value is a RegExp object, the actual value is + // equivalent if it is also a RegExp object with the same source and + // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`). + } else if (actual instanceof RegExp && expected instanceof RegExp) { + return actual.source === expected.source && + actual.global === expected.global && + actual.multiline === expected.multiline && + actual.lastIndex === expected.lastIndex && + actual.ignoreCase === expected.ignoreCase; + + // 7.4. Other pairs that do not both pass typeof value == 'object', + // equivalence is determined by ==. + } else if (typeof actual != 'object' && typeof expected != 'object') { + return actual == expected; + + // 7.5 For all other Object pairs, including Array objects, equivalence is + // determined by having the same number of owned properties (as verified + // with Object.prototype.hasOwnProperty.call), the same set of keys + // (although not necessarily the same order), equivalent values for every + // corresponding key, and an identical 'prototype' property. Note: this + // accounts for both named and indexed properties on Arrays. + } else { + return objEquiv(actual, expected); + } +} + +function isUndefinedOrNull(value) { + return value === null || value === undefined; +} + +function isArguments(object) { + return Object.prototype.toString.call(object) == '[object Arguments]'; +} + +function objEquiv(a, b) { + if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) + return false; + // an identical 'prototype' property. + if (a.prototype !== b.prototype) return false; + //~~~I've managed to break Object.keys through screwy arguments passing. + // Converting to array solves the problem. + if (isArguments(a)) { + if (!isArguments(b)) { + return false; + } + a = pSlice.call(a); + b = pSlice.call(b); + return _deepEqual(a, b); + } + try { + var ka = Object.keys(a), + kb = Object.keys(b), + key, i; + } catch (e) {//happens when one is a string literal and the other isn't + return false; + } + // having the same number of owned properties (keys incorporates + // hasOwnProperty) + if (ka.length != kb.length) + return false; + //the same set of keys (although not necessarily the same order), + ka.sort(); + kb.sort(); + //~~~cheap key test + for (i = ka.length - 1; i >= 0; i--) { + if (ka[i] != kb[i]) + return false; + } + //equivalent values for every corresponding key, and + //~~~possibly expensive deep test + for (i = ka.length - 1; i >= 0; i--) { + key = ka[i]; + if (!_deepEqual(a[key], b[key])) return false; + } + return true; +} + +// 8. The non-equivalence assertion tests for any deep inequality. +// assert.notDeepEqual(actual, expected, message_opt); + +assert.notDeepEqual = function notDeepEqual(actual, expected, message) { + if (_deepEqual(actual, expected)) { + fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual); + } +}; + +// 9. The strict equality assertion tests strict equality, as determined by ===. +// assert.strictEqual(actual, expected, message_opt); + +assert.strictEqual = function strictEqual(actual, expected, message) { + if (actual !== expected) { + fail(actual, expected, message, '===', assert.strictEqual); + } +}; + +// 10. The strict non-equality assertion tests for strict inequality, as +// determined by !==. assert.notStrictEqual(actual, expected, message_opt); + +assert.notStrictEqual = function notStrictEqual(actual, expected, message) { + if (actual === expected) { + fail(actual, expected, message, '!==', assert.notStrictEqual); + } +}; + +function expectedException(actual, expected) { + if (!actual || !expected) { + return false; + } + + if (expected instanceof RegExp) { + return expected.test(actual); + } else if (actual instanceof expected) { + return true; + } else if (expected.call({}, actual) === true) { + return true; + } + + return false; +} + +function _throws(shouldThrow, block, expected, message) { + var actual; + + if (typeof expected === 'string') { + message = expected; + expected = null; + } + + try { + block(); + } catch (e) { + actual = e; + } + + message = (expected && expected.name ? ' (' + expected.name + ').' : '.') + + (message ? ' ' + message : '.'); + + if (shouldThrow && !actual) { + fail('Missing expected exception' + message); + } + + if (!shouldThrow && expectedException(actual, expected)) { + fail('Got unwanted exception' + message); + } + + if ((shouldThrow && actual && expected && + !expectedException(actual, expected)) || (!shouldThrow && actual)) { + throw actual; + } +} + +// 11. Expected to throw an error: +// assert.throws(block, Error_opt, message_opt); + +assert.throws = function(block, /*optional*/error, /*optional*/message) { + _throws.apply(this, [true].concat(pSlice.call(arguments))); +}; + +// EXTENSION! This is annoying to write outside this module. +assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) { + _throws.apply(this, [false].concat(pSlice.call(arguments))); +}; + +assert.ifError = function(err) { if (err) {throw err;}}; + +})(this); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/assert/bower.json b/todomvc/canjs/node_modules/canjs-feathers/bower_components/assert/bower.json new file mode 100644 index 0000000000..0664ce2a01 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/assert/bower.json @@ -0,0 +1,14 @@ +{ + "name": "assert", + "main": "assert.js", + "version": "0.0.2", + "homepage": "https://github.com/jgallen23/assert", + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ] +} diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/.bower.json b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/.bower.json new file mode 100644 index 0000000000..1618212ed5 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/.bower.json @@ -0,0 +1,26 @@ +{ + "name": "CanJS", + "version": "2.2.6", + "repo": "bitovi/canjs", + "description": "Can do JavaScript MVC", + "main": "can.jquery.js", + "keywords": [ + "mvc", + "canjs", + "can", + "requirejs", + "component", + "amd" + ], + "license": "MIT", + "homepage": "https://github.com/bitovi/canjs.com", + "_release": "2.2.6", + "_resolution": { + "type": "version", + "tag": "v2.2.6", + "commit": "b1f5323bb5be24947d7c836d3cd91d23e1ba16b8" + }, + "_source": "git://github.com/bitovi/canjs.com.git", + "_target": "^2.1.4", + "_originalSource": "canjs" +} \ No newline at end of file diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can.js new file mode 100644 index 0000000000..4098f41c55 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can.js @@ -0,0 +1,18 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#can*/ +define([ + 'can/util/library', + 'can/control/route', + 'can/model', + 'can/view/mustache', + 'can/component' +], function (can) { + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/bubble.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/bubble.js new file mode 100644 index 0000000000..1d24552a4f --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/bubble.js @@ -0,0 +1,115 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/bubble*/ +define(['can/util/library'], function (can) { + var bubble = can.bubble = { + event: function (map, boundEventName) { + return map.constructor._bubbleRule(boundEventName, map); + }, + childrenOf: function (parentMap, eventName) { + parentMap._each(function (child, prop) { + if (child && child.bind) { + bubble.toParent(child, parentMap, prop, eventName); + } + }); + }, + teardownChildrenFrom: function (parentMap, eventName) { + parentMap._each(function (child) { + bubble.teardownFromParent(parentMap, child, eventName); + }); + }, + toParent: function (child, parent, prop, eventName) { + can.listenTo.call(parent, child, eventName, function () { + var args = can.makeArray(arguments), ev = args.shift(); + args[0] = (can.List && parent instanceof can.List ? parent.indexOf(child) : prop) + (args[0] ? '.' + args[0] : ''); + ev.triggeredNS = ev.triggeredNS || {}; + if (ev.triggeredNS[parent._cid]) { + return; + } + ev.triggeredNS[parent._cid] = true; + can.trigger(parent, ev, args); + }); + }, + teardownFromParent: function (parent, child, eventName) { + if (child && child.unbind) { + can.stopListening.call(parent, child, eventName); + } + }, + isBubbling: function (parent, eventName) { + return parent._bubbleBindings && parent._bubbleBindings[eventName]; + }, + bind: function (parent, eventName) { + if (!parent._init) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + if (!parent._bubbleBindings) { + parent._bubbleBindings = {}; + } + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (!parent._bubbleBindings[bubbleEvent]) { + parent._bubbleBindings[bubbleEvent] = 1; + bubble.childrenOf(parent, bubbleEvent); + } else { + parent._bubbleBindings[bubbleEvent]++; + } + } + } + }, + unbind: function (parent, eventName) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (parent._bubbleBindings) { + parent._bubbleBindings[bubbleEvent]--; + } + if (parent._bubbleBindings && !parent._bubbleBindings[bubbleEvent]) { + delete parent._bubbleBindings[bubbleEvent]; + bubble.teardownChildrenFrom(parent, bubbleEvent); + if (can.isEmptyObject(parent._bubbleBindings)) { + delete parent._bubbleBindings; + } + } + } + }, + add: function (parent, child, prop) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + bubble.toParent(child, parent, prop, eventName); + } + } + } + }, + removeMany: function (parent, children) { + for (var i = 0, len = children.length; i < len; i++) { + bubble.remove(parent, children[i]); + } + }, + remove: function (parent, child) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + } + } + } + }, + set: function (parent, prop, value, current) { + if (can.Map.helpers.isObservable(value)) { + bubble.add(parent, value, prop); + } + if (can.Map.helpers.isObservable(current)) { + bubble.remove(parent, current); + } + return value; + } + }; + return bubble; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/component.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/component.js new file mode 100644 index 0000000000..b992271e35 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/component.js @@ -0,0 +1,277 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#component/component*/ +define([ + 'can/util/library', + 'can/view/callbacks', + 'can/elements', + 'can/control', + 'can/observe', + 'can/view/mustache', + 'can/view/bindings' +], function (can, viewCallbacks, elements) { + var ignoreAttributesRegExp = /^(dataViewId|class|id)$/i, paramReplacer = /\{([^\}]+)\}/g; + var Component = can.Component = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Component) { + var self = this, scope = this.prototype.scope || this.prototype.viewModel; + this.Control = ComponentControl.extend(this.prototype.events); + if (!scope || typeof scope === 'object' && !(scope instanceof can.Map)) { + this.Map = can.Map.extend(scope || {}); + } else if (scope.prototype instanceof can.Map) { + this.Map = scope; + } + this.attributeScopeMappings = {}; + can.each(this.Map ? this.Map.defaults : {}, function (val, prop) { + if (val === '@') { + self.attributeScopeMappings[prop] = prop; + } + }); + if (this.prototype.template) { + if (typeof this.prototype.template === 'function') { + var temp = this.prototype.template; + this.renderer = function () { + return can.view.frag(temp.apply(null, arguments)); + }; + } else { + this.renderer = can.view.mustache(this.prototype.template); + } + } + can.view.tag(this.prototype.tag, function (el, options) { + new self(el, options); + }); + } + } + }, { + setup: function (el, hookupOptions) { + var initialScopeData = {}, component = this, lexicalContent = (typeof this.leakScope === 'undefined' ? false : !this.leakScope) && this.template, twoWayBindings = {}, scope = this.scope || this.viewModel, viewModelPropertyUpdates = {}, componentScope, frag, teardownFunctions = [], callTeardownFunctions = function () { + for (var i = 0, len = teardownFunctions.length; i < len; i++) { + teardownFunctions[i](); + } + }; + can.each(this.constructor.attributeScopeMappings, function (val, prop) { + initialScopeData[prop] = el.getAttribute(can.hyphenate(val)); + }); + can.each(can.makeArray(el.attributes), function (node, index) { + var name = can.camelize(node.nodeName.toLowerCase()), value = node.value; + if (ignoreAttributesRegExp.test(name) && value[0] === '{' && value[value.length - 1] === '}') { + can.dev.warn('can/component: looks like you\'re trying to pass ' + name + ' as an attribute into a component, ' + 'but it is not a supported attribute'); + } + if (component.constructor.attributeScopeMappings[name] || ignoreAttributesRegExp.test(name) || viewCallbacks.attr(node.nodeName)) { + return; + } + if (value[0] === '{' && value[value.length - 1] === '}') { + value = value.substr(1, value.length - 2); + } else { + if (hookupOptions.templateType !== 'legacy') { + initialScopeData[name] = value; + return; + } + } + var computeData = hookupOptions.scope.computeData(value, { args: [] }), compute = computeData.compute; + var handler = function (ev, newVal) { + viewModelPropertyUpdates[name] = (viewModelPropertyUpdates[name] || 0) + 1; + componentScope.attr(name, newVal); + can.batch.afterPreviousEvents(function () { + --viewModelPropertyUpdates[name]; + }); + }; + compute.bind('change', handler); + initialScopeData[name] = compute(); + if (!compute.computeInstance.hasDependencies) { + compute.unbind('change', handler); + } else { + teardownFunctions.push(function () { + compute.unbind('change', handler); + }); + twoWayBindings[name] = computeData; + } + }); + if (this.constructor.Map) { + componentScope = new this.constructor.Map(initialScopeData); + } else if (scope instanceof can.Map) { + componentScope = scope; + } else if (can.isFunction(scope)) { + var scopeResult = scope.call(this, initialScopeData, hookupOptions.scope, el); + if (scopeResult instanceof can.Map) { + componentScope = scopeResult; + } else if (scopeResult.prototype instanceof can.Map) { + componentScope = new scopeResult(initialScopeData); + } else { + componentScope = new (can.Map.extend(scopeResult))(initialScopeData); + } + } + var handlers = {}; + can.each(twoWayBindings, function (computeData, prop) { + handlers[prop] = function (ev, newVal) { + if (!viewModelPropertyUpdates[prop]) { + computeData.compute(newVal); + } + }; + componentScope.bind(prop, handlers[prop]); + }); + if (!can.isEmptyObject(this.constructor.attributeScopeMappings) || hookupOptions.templateType !== 'legacy') { + can.bind.call(el, 'attributes', function (ev) { + var camelized = can.camelize(ev.attributeName); + if (!twoWayBindings[camelized] && !ignoreAttributesRegExp.test(camelized)) { + componentScope.attr(camelized, el.getAttribute(ev.attributeName)); + } + }); + } + this.scope = this.viewModel = componentScope; + can.data(can.$(el), 'scope', this.scope); + can.data(can.$(el), 'viewModel', this.scope); + var renderedScope = lexicalContent ? this.scope : hookupOptions.scope.add(this.scope), options = { helpers: {} }; + can.each(this.helpers || {}, function (val, prop) { + if (can.isFunction(val)) { + options.helpers[prop] = function () { + return val.apply(componentScope, arguments); + }; + } + }); + teardownFunctions.push(function () { + can.each(handlers, function (handler, prop) { + componentScope.unbind(prop, handlers[prop]); + }); + }); + this._control = new this.constructor.Control(el, { + scope: this.scope, + viewModel: this.scope + }); + if (this._control && this._control.destroy) { + var oldDestroy = this._control.destroy; + this._control.destroy = function () { + oldDestroy.apply(this, arguments); + callTeardownFunctions(); + }; + this._control.on(); + } else { + can.bind.call(el, 'removed', function () { + callTeardownFunctions(); + }); + } + var nodeList = can.view.nodeLists.register([], undefined, true); + teardownFunctions.push(function () { + can.view.nodeLists.unregister(nodeList); + }); + if (this.constructor.renderer) { + if (!options.tags) { + options.tags = {}; + } + options.tags.content = function contentHookup(el, rendererOptions) { + var subtemplate = hookupOptions.subtemplate || rendererOptions.subtemplate; + if (subtemplate) { + delete options.tags.content; + var opts = !lexicalContent || subtemplate !== hookupOptions.subtemplate ? rendererOptions : hookupOptions; + if (rendererOptions.parentNodeList) { + var frag = subtemplate(opts.scope, opts.options, rendererOptions.parentNodeList); + elements.replace([el], frag); + } else { + can.view.live.replace([el], subtemplate(opts.scope, opts.options)); + } + options.tags.content = contentHookup; + } + }; + frag = this.constructor.renderer(renderedScope, hookupOptions.options.add(options), nodeList); + } else { + if (hookupOptions.templateType === 'legacy') { + frag = can.view.frag(hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options)) : ''); + } else { + frag = hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options), nodeList) : document.createDocumentFragment(); + } + } + can.appendChild(el, frag); + can.view.nodeLists.update(nodeList, el.childNodes); + } + }); + var ComponentControl = can.Control.extend({ + _lookup: function (options) { + return [ + options.scope, + options, + window + ]; + }, + _action: function (methodName, options, controlInstance) { + var hasObjectLookup, readyCompute; + paramReplacer.lastIndex = 0; + hasObjectLookup = paramReplacer.test(methodName); + if (!controlInstance && hasObjectLookup) { + return; + } else if (!hasObjectLookup) { + return can.Control._action.apply(this, arguments); + } else { + readyCompute = can.compute(function () { + var delegate; + var name = methodName.replace(paramReplacer, function (matched, key) { + var value; + if (key === 'scope' || key === 'viewModel') { + delegate = options.scope; + return ''; + } + key = key.replace(/^(scope|^viewModel)\./, ''); + value = can.compute.read(options.scope, key.split('.'), { isArgument: true }).value; + if (value === undefined) { + value = can.getObject(key); + } + if (typeof value === 'string') { + return value; + } else { + delegate = value; + return ''; + } + }); + var parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: this.processors[event] || this.processors.click, + parts: [ + name, + parts.join(' '), + event + ], + delegate: delegate || undefined + }; + }, this); + var handler = function (ev, ready) { + controlInstance._bindings.control[methodName](controlInstance.element); + controlInstance._bindings.control[methodName] = ready.processor(ready.delegate || controlInstance.element, ready.parts[2], ready.parts[1], methodName, controlInstance); + }; + readyCompute.bind('change', handler); + controlInstance._bindings.readyComputes[methodName] = { + compute: readyCompute, + handler: handler + }; + return readyCompute(); + } + } + }, { + setup: function (el, options) { + this.scope = options.scope; + this.viewModel = options.viewModel; + return can.Control.prototype.setup.call(this, el, options); + }, + off: function () { + if (this._bindings) { + can.each(this._bindings.readyComputes || {}, function (value) { + value.compute.unbind('change', value.handler); + }); + } + can.Control.prototype.off.apply(this, arguments); + this._bindings.readyComputes = {}; + } + }); + var $ = can.$; + if ($.fn) { + $.fn.scope = $.fn.viewModel = function () { + return can.viewModel.apply(can, [this].concat(can.makeArray(arguments))); + }; + } + return Component; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/compute.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/compute.js new file mode 100644 index 0000000000..c74c03d0b2 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/compute.js @@ -0,0 +1,70 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#compute/compute*/ +define([ + 'can/util/library', + 'can/util/bind', + 'can/util/batch', + 'can/proto_compute' +], function (can, bind) { + can.compute = function (getterSetter, context, eventName, bindOnce) { + var internalCompute = new can.Compute(getterSetter, context, eventName, bindOnce); + var compute = function (val) { + if (arguments.length) { + return internalCompute.set(val); + } + return internalCompute.get(); + }; + compute.bind = can.proxy(internalCompute.bind, internalCompute); + compute.unbind = can.proxy(internalCompute.unbind, internalCompute); + compute.isComputed = internalCompute.isComputed; + compute.clone = function (ctx) { + if (typeof getterSetter === 'function') { + context = ctx; + } + return can.compute(getterSetter, context, ctx, bindOnce); + }; + compute.computeInstance = internalCompute; + return compute; + }; + var k = function () { + }; + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.compute.truthy = function (compute) { + return can.compute(function () { + var res = compute(); + if (typeof res === 'function') { + res = res(); + } + return !!res; + }); + }; + can.compute.async = function (initialValue, asyncComputer, context) { + return can.compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.compute.read = can.Compute.read; + can.compute.set = can.Compute.set; + return can.compute; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/construct.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/construct.js new file mode 100644 index 0000000000..e659f16f89 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/construct.js @@ -0,0 +1,148 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#construct/construct*/ +define(['can/util/string'], function (can) { + var initializing = 0; + var canGetDescriptor; + try { + Object.getOwnPropertyDescriptor({}); + canGetDescriptor = true; + } catch (e) { + canGetDescriptor = false; + } + var getDescriptor = function (newProps, name) { + var descriptor = Object.getOwnPropertyDescriptor(newProps, name); + if (descriptor && (descriptor.get || descriptor.set)) { + return descriptor; + } + return null; + }, inheritGetterSetter = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + var descriptor; + for (var name in newProps) { + if (descriptor = getDescriptor(newProps, name)) { + this._defineProperty(addTo, oldProps, name, descriptor); + } else { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + } + }, simpleInherit = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + for (var name in newProps) { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + }; + can.Construct = function () { + if (arguments.length) { + return can.Construct.extend.apply(can.Construct, arguments); + } + }; + can.extend(can.Construct, { + constructorExtends: true, + newInstance: function () { + var inst = this.instance(), args; + if (inst.setup) { + args = inst.setup.apply(inst, arguments); + } + if (inst.init) { + inst.init.apply(inst, args || arguments); + } + return inst; + }, + _inherit: canGetDescriptor ? inheritGetterSetter : simpleInherit, + _defineProperty: function (what, oldProps, propName, descriptor) { + Object.defineProperty(what, propName, descriptor); + }, + _overwrite: function (what, oldProps, propName, val) { + what[propName] = val; + }, + setup: function (base, fullName) { + this.defaults = can.extend(true, {}, base.defaults, this.defaults); + }, + instance: function () { + initializing = 1; + var inst = new this(); + initializing = 0; + return inst; + }, + extend: function (name, staticProperties, instanceProperties) { + var fullName = name, klass = staticProperties, proto = instanceProperties; + if (typeof fullName !== 'string') { + proto = klass; + klass = fullName; + fullName = null; + } + if (!proto) { + proto = klass; + klass = null; + } + proto = proto || {}; + var _super_class = this, _super = this.prototype, Constructor, parts, current, _fullName, _shortName, propName, shortName, namespace, prototype; + prototype = this.instance(); + can.Construct._inherit(proto, _super, prototype); + if (fullName) { + parts = fullName.split('.'); + shortName = parts.pop(); + } + var constructorName = shortName ? shortName.replace(/;/g, '') : 'Constructor'; + eval('Constructor = function ' + constructorName + '() { return init.apply(this, arguments); }'); + if (typeof constructorName === 'undefined') { + Constructor = function () { + return init.apply(this, arguments); + }; + } + function init() { + if (!initializing) { + if (this.constructor !== Constructor && arguments.length && Constructor.constructorExtends) { + can.dev.warn('can/construct/construct.js: extending a can.Construct without calling extend'); + } + return this.constructor !== Constructor && arguments.length && Constructor.constructorExtends ? Constructor.extend.apply(Constructor, arguments) : Constructor.newInstance.apply(Constructor, arguments); + } + } + for (propName in _super_class) { + if (_super_class.hasOwnProperty(propName)) { + Constructor[propName] = _super_class[propName]; + } + } + can.Construct._inherit(klass, _super_class, Constructor); + if (fullName) { + current = can.getObject(parts.join('.'), window, true); + namespace = current; + _fullName = can.underscore(fullName.replace(/\./g, '_')); + _shortName = can.underscore(shortName); + if (current[shortName]) { + can.dev.warn('can/construct/construct.js: There\'s already something called ' + fullName); + } + current[shortName] = Constructor; + } + can.extend(Constructor, { + constructor: Constructor, + prototype: prototype, + namespace: namespace, + _shortName: _shortName, + fullName: fullName, + _fullName: _fullName + }); + if (shortName !== undefined) { + Constructor.shortName = shortName; + } + Constructor.prototype.constructor = Constructor; + var t = [_super_class].concat(can.makeArray(arguments)), args = Constructor.setup.apply(Constructor, t); + if (Constructor.init) { + Constructor.init.apply(Constructor, args || t); + } + return Constructor; + } + }); + can.Construct.prototype.setup = function () { + }; + can.Construct.prototype.init = function () { + }; + return can.Construct; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/construct/proxy.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/construct/proxy.js new file mode 100644 index 0000000000..976e0f45d3 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/construct/proxy.js @@ -0,0 +1,54 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#construct/proxy/proxy*/ +define([ + 'can/util/library', + 'can/construct' +], function (can, Construct) { + var isFunction = can.isFunction, isArray = can.isArray, makeArray = can.makeArray, proxy = function (funcs) { + var args = makeArray(arguments), self; + funcs = args.shift(); + if (!isArray(funcs)) { + funcs = [funcs]; + } + self = this; + for (var i = 0; i < funcs.length; i++) { + if (typeof funcs[i] === 'string' && !isFunction(this[funcs[i]])) { + throw 'class.js ' + (this.fullName || this.Class.fullName) + ' does not have a ' + funcs[i] + 'method!'; + } + } + return function class_cb() { + var cur = args.concat(makeArray(arguments)), isString, length = funcs.length, f = 0, func; + for (; f < length; f++) { + func = funcs[f]; + if (!func) { + continue; + } + isString = typeof func === 'string'; + cur = (isString ? self[func] : func).apply(self, cur || []); + if (f < length - 1) { + cur = !isArray(cur) || cur._use_call ? [cur] : cur; + } + } + return cur; + }; + }; + can.Construct.proxy = can.Construct.prototype.proxy = proxy; + var correctedClasses = [ + can.Map, + can.Control, + can.Model + ], i = 0; + for (; i < correctedClasses.length; i++) { + if (correctedClasses[i]) { + correctedClasses[i].proxy = proxy; + } + } + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/construct/super.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/construct/super.js new file mode 100644 index 0000000000..378bd884cc --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/construct/super.js @@ -0,0 +1,45 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#construct/super/super*/ +define([ + 'can/util/library', + 'can/construct' +], function (can, Construct) { + var isFunction = can.isFunction, fnTest = /xyz/.test(function () { + return this.xyz; + }) ? /\b_super\b/ : /.*/, getset = [ + 'get', + 'set' + ], getSuper = function (base, name, fn) { + return function () { + var tmp = this._super, ret; + this._super = base[name]; + ret = fn.apply(this, arguments); + this._super = tmp; + return ret; + }; + }; + can.Construct._defineProperty = function (addTo, base, name, descriptor) { + var _super = Object.getOwnPropertyDescriptor(base, name); + if (_super) { + can.each(getset, function (method) { + if (isFunction(_super[method]) && isFunction(descriptor[method])) { + descriptor[method] = getSuper(_super, method, descriptor[method]); + } else if (!isFunction(descriptor[method])) { + descriptor[method] = _super[method]; + } + }); + } + Object.defineProperty(addTo, name, descriptor); + }; + can.Construct._overwrite = function (addTo, base, name, val) { + addTo[name] = isFunction(val) && isFunction(base[name]) && fnTest.test(val) ? getSuper(base, name, val) : val; + }; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/control.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/control.js new file mode 100644 index 0000000000..8a6eb05cb8 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/control.js @@ -0,0 +1,205 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#control/control*/ +define([ + 'can/util/library', + 'can/construct' +], function (can) { + var bind = function (el, ev, callback) { + can.bind.call(el, ev, callback); + return function () { + can.unbind.call(el, ev, callback); + }; + }, isFunction = can.isFunction, extend = can.extend, each = can.each, slice = [].slice, paramReplacer = /\{([^\}]+)\}/g, special = can.getObject('$.event.special', [can]) || {}, delegate = function (el, selector, ev, callback) { + can.delegate.call(el, selector, ev, callback); + return function () { + can.undelegate.call(el, selector, ev, callback); + }; + }, binder = function (el, ev, callback, selector) { + return selector ? delegate(el, can.trim(selector), ev, callback) : bind(el, ev, callback); + }, basicProcessor; + var Control = can.Control = can.Construct({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Control) { + var control = this, funcName; + control.actions = {}; + for (funcName in control.prototype) { + if (control._isAction(funcName)) { + control.actions[funcName] = control._action(funcName); + } + } + } + }, + _shifter: function (context, name) { + var method = typeof name === 'string' ? context[name] : name; + if (!isFunction(method)) { + method = context[method]; + } + return function () { + context.called = name; + return method.apply(context, [this.nodeName ? can.$(this) : this].concat(slice.call(arguments, 0))); + }; + }, + _isAction: function (methodName) { + var val = this.prototype[methodName], type = typeof val; + return methodName !== 'constructor' && (type === 'function' || type === 'string' && isFunction(this.prototype[val])) && !!(special[methodName] || processors[methodName] || /[^\w]/.test(methodName)); + }, + _action: function (methodName, options) { + paramReplacer.lastIndex = 0; + if (options || !paramReplacer.test(methodName)) { + var convertedName = options ? can.sub(methodName, this._lookup(options)) : methodName; + if (!convertedName) { + can.dev.log('can/control/control.js: No property found for handling ' + methodName); + return null; + } + var arr = can.isArray(convertedName), name = arr ? convertedName[1] : convertedName, parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: processors[event] || basicProcessor, + parts: [ + name, + parts.join(' '), + event + ], + delegate: arr ? convertedName[0] : undefined + }; + } + }, + _lookup: function (options) { + return [ + options, + window + ]; + }, + processors: {}, + defaults: {} + }, { + setup: function (element, options) { + var cls = this.constructor, pluginname = cls.pluginName || cls._fullName, arr; + this.element = can.$(element); + if (pluginname && pluginname !== 'can_control') { + this.element.addClass(pluginname); + } + arr = can.data(this.element, 'controls'); + if (!arr) { + arr = []; + can.data(this.element, 'controls', arr); + } + arr.push(this); + this.options = extend({}, cls.defaults, options); + this.on(); + return [ + this.element, + this.options + ]; + }, + on: function (el, selector, eventName, func) { + if (!el) { + this.off(); + var cls = this.constructor, bindings = this._bindings, actions = cls.actions, element = this.element, destroyCB = can.Control._shifter(this, 'destroy'), funcName, ready; + for (funcName in actions) { + if (actions.hasOwnProperty(funcName)) { + ready = actions[funcName] || cls._action(funcName, this.options, this); + if (ready) { + bindings.control[funcName] = ready.processor(ready.delegate || element, ready.parts[2], ready.parts[1], funcName, this); + } + } + } + can.bind.call(element, 'removed', destroyCB); + bindings.user.push(function (el) { + can.unbind.call(el, 'removed', destroyCB); + }); + return bindings.user.length; + } + if (typeof el === 'string') { + func = eventName; + eventName = selector; + selector = el; + el = this.element; + } + if (func === undefined) { + func = eventName; + eventName = selector; + selector = null; + } + if (typeof func === 'string') { + func = can.Control._shifter(this, func); + } + this._bindings.user.push(binder(el, eventName, func, selector)); + return this._bindings.user.length; + }, + off: function () { + var el = this.element[0], bindings = this._bindings; + if (bindings) { + each(bindings.user || [], function (value) { + value(el); + }); + each(bindings.control || {}, function (value) { + value(el); + }); + } + this._bindings = { + user: [], + control: {} + }; + }, + destroy: function () { + if (this.element === null) { + can.dev.warn('can/control/control.js: Control already destroyed'); + return; + } + var Class = this.constructor, pluginName = Class.pluginName || Class._fullName, controls; + this.off(); + if (pluginName && pluginName !== 'can_control') { + this.element.removeClass(pluginName); + } + controls = can.data(this.element, 'controls'); + controls.splice(can.inArray(this, controls), 1); + can.trigger(this, 'destroyed'); + this.element = null; + } + }); + var processors = can.Control.processors; + basicProcessor = function (el, event, selector, methodName, control) { + return binder(el, event, can.Control._shifter(control, methodName), selector); + }; + each([ + 'change', + 'click', + 'contextmenu', + 'dblclick', + 'keydown', + 'keyup', + 'keypress', + 'mousedown', + 'mousemove', + 'mouseout', + 'mouseover', + 'mouseup', + 'reset', + 'resize', + 'scroll', + 'select', + 'submit', + 'focusin', + 'focusout', + 'mouseenter', + 'mouseleave', + 'touchstart', + 'touchmove', + 'touchcancel', + 'touchend', + 'touchleave', + 'inserted', + 'removed' + ], function (v) { + processors[v] = basicProcessor; + }); + return Control; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/control/plugin.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/control/plugin.js new file mode 100644 index 0000000000..e0a24c7d23 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/control/plugin.js @@ -0,0 +1,81 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#control/plugin/plugin*/ +define([ + 'jquery', + 'can/util/library', + 'can/control' +], function ($, can) { + $ = $ || window.$; + var i, isAControllerOf = function (instance, controllers) { + var name = instance.constructor.pluginName || instance.constructor._shortName; + for (i = 0; i < controllers.length; i++) { + if (typeof controllers[i] === 'string' ? name === controllers[i] : instance instanceof controllers[i]) { + return true; + } + } + return false; + }, makeArray = can.makeArray, old = can.Control.setup; + can.Control.setup = function () { + if (this !== can.Control) { + var pluginName = this.pluginName || this._fullName; + if (pluginName !== 'can_control') { + this.plugin(pluginName); + } + old.apply(this, arguments); + } + }; + $.fn.extend({ + controls: function () { + var controllerNames = makeArray(arguments), instances = [], controls, c; + this.each(function () { + controls = can.$(this).data('controls'); + if (!controls) { + return; + } + for (var i = 0; i < controls.length; i++) { + c = controls[i]; + if (!controllerNames.length || isAControllerOf(c, controllerNames)) { + instances.push(c); + } + } + }); + return instances; + }, + control: function (control) { + return this.controls.apply(this, arguments)[0]; + } + }); + can.Control.plugin = function (pluginname) { + var control = this; + if (!$.fn[pluginname]) { + $.fn[pluginname] = function (options) { + var args = makeArray(arguments), isMethod = typeof options === 'string' && $.isFunction(control.prototype[options]), meth = args[0], returns; + this.each(function () { + var plugin = can.$(this).control(control); + if (plugin) { + if (isMethod) { + returns = plugin[meth].apply(plugin, args.slice(1)); + } else { + plugin.update.apply(plugin, args); + } + } else { + control.newInstance.apply(control, [this].concat(args)); + } + }); + return returns !== undefined ? returns : this; + }; + } + }; + can.Control.prototype.update = function (options) { + can.extend(this.options, options); + this.on(); + }; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/control/route.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/control/route.js new file mode 100644 index 0000000000..bd792cbabb --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/control/route.js @@ -0,0 +1,41 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#control/route/route*/ +define([ + 'can/util/library', + 'can/route', + 'can/control' +], function (can) { + can.Control.processors.route = function (el, event, selector, funcName, controller) { + selector = selector || ''; + if (!can.route.routes[selector]) { + if (selector[0] === '/') { + selector = selector.substring(1); + } + can.route(selector); + } + var batchNum, check = function (ev, attr, how) { + if (can.route.attr('route') === selector && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + batchNum = ev.batchNum; + var d = can.route.attr(); + delete d.route; + if (can.isFunction(controller[funcName])) { + controller[funcName](d); + } else { + controller[controller[funcName]](d); + } + } + }; + can.route.bind('change', check); + return function () { + can.route.unbind('change', check); + }; + }; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/deferred.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/deferred.js new file mode 100644 index 0000000000..e072db2f4a --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/deferred.js @@ -0,0 +1,160 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/deferred*/ +define(['can/util/can'], function (can) { + var extend = function (target, src) { + for (var key in src) { + if (src.hasOwnProperty(key)) { + target[key] = src[key]; + } + } + }, Deferred = function (func) { + if (!(this instanceof Deferred)) { + return new Deferred(); + } + this._doneFuncs = []; + this._failFuncs = []; + this._resultArgs = null; + this._status = ''; + if (func) { + func.call(this, this); + } + }; + can.Deferred = Deferred; + can.when = Deferred.when = function () { + var args = can.makeArray(arguments); + if (args.length < 2) { + var obj = args[0]; + if (obj && (can.isFunction(obj.isResolved) && can.isFunction(obj.isRejected))) { + return obj; + } else { + return Deferred().resolve(obj); + } + } else { + var df = Deferred(), done = 0, rp = []; + can.each(args, function (arg, j) { + arg.done(function () { + rp[j] = arguments.length < 2 ? arguments[0] : arguments; + if (++done === args.length) { + df.resolve.apply(df, rp); + } + }).fail(function () { + df.reject(arguments.length === 1 ? arguments[0] : arguments); + }); + }); + return df; + } + }; + var resolveFunc = function (type, _status) { + return function (context) { + var args = this._resultArgs = arguments.length > 1 ? arguments[1] : []; + return this.exec(context, this[type], args, _status); + }; + }, doneFunc = function doneFunc(type, _status) { + return function () { + var self = this; + can.each(Array.prototype.slice.call(arguments), function (v, i, args) { + if (!v) { + return; + } + if (v.constructor === Array) { + doneFunc.apply(self, v); + } else { + if (self._status === _status) { + v.apply(self, self._resultArgs || []); + } + self[type].push(v); + } + }); + return this; + }; + }; + var isDeferred = function (obj) { + return obj && obj.then && obj.fail && obj.done; + }; + var wire = function (parentDeferred, result, setter, value) { + if (isDeferred(result)) { + result.done(can.proxy(parentDeferred.resolve, parentDeferred)).fail(can.proxy(parentDeferred.reject, parentDeferred)); + } else { + setter.call(parentDeferred, result !== undefined ? result : value); + } + }; + extend(Deferred.prototype, { + then: function (done, fail) { + var d = can.Deferred(), resolve = d.resolve, reject = d.reject; + this.done(function (value) { + if (typeof done === 'function') { + wire(d, done.apply(this, arguments), resolve, value); + } else { + resolve.apply(d, arguments); + } + }); + this.fail(function (value) { + if (typeof fail === 'function') { + wire(d, fail.apply(this, arguments), reject, value); + } else { + reject.apply(d, arguments); + } + }); + return d; + }, + resolveWith: resolveFunc('_doneFuncs', 'rs'), + rejectWith: resolveFunc('_failFuncs', 'rj'), + done: doneFunc('_doneFuncs', 'rs'), + fail: doneFunc('_failFuncs', 'rj'), + always: function () { + var args = can.makeArray(arguments); + if (args.length && args[0]) { + this.done(args[0]).fail(args[0]); + } + return this; + }, + state: function () { + switch (this._status) { + case 'rs': + return 'resolved'; + case 'rj': + return 'rejected'; + default: + return 'pending'; + } + }, + isResolved: function () { + return this._status === 'rs'; + }, + isRejected: function () { + return this._status === 'rj'; + }, + reject: function () { + return this.rejectWith(this, arguments); + }, + resolve: function () { + return this.resolveWith(this, arguments); + }, + exec: function (context, dst, args, st) { + if (this._status !== '') { + return this; + } + this._status = st; + can.each(dst, function (d) { + if (typeof d.apply === 'function') { + d.apply(context, args); + } + }); + return this; + }, + promise: function () { + var promise = this.then(); + promise.reject = promise.resolve = undefined; + return promise; + } + }); + Deferred.prototype.pipe = Deferred.prototype.then; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/elements.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/elements.js new file mode 100644 index 0000000000..22e8f61a22 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/elements.js @@ -0,0 +1,83 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/elements*/ +define([ + 'can/util/library', + 'can/view' +], function (can) { + var doc = typeof document !== 'undefined' ? document : null; + var selectsCommentNodes = doc && function () { + return can.$(document.createComment('~')).length === 1; + }(); + var elements = { + tagToContentPropMap: { + option: doc && 'textContent' in document.createElement('option') ? 'textContent' : 'innerText', + textarea: 'value' + }, + attrMap: can.attr.map, + attrReg: /([^\s=]+)[\s]*=[\s]*/, + defaultValue: can.attr.defaultValue, + tagMap: { + '': 'span', + colgroup: 'col', + table: 'tbody', + tr: 'td', + ol: 'li', + ul: 'li', + tbody: 'tr', + thead: 'tr', + tfoot: 'tr', + select: 'option', + optgroup: 'option' + }, + reverseTagMap: { + col: 'colgroup', + tr: 'tbody', + option: 'select', + td: 'tr', + th: 'tr', + li: 'ul' + }, + getParentNode: function (el, defaultParentNode) { + return defaultParentNode && el.parentNode.nodeType === 11 ? defaultParentNode : el.parentNode; + }, + setAttr: can.attr.set, + getAttr: can.attr.get, + removeAttr: can.attr.remove, + contentText: function (text) { + if (typeof text === 'string') { + return text; + } + if (!text && text !== 0) { + return ''; + } + return '' + text; + }, + after: function (oldElements, newFrag) { + var last = oldElements[oldElements.length - 1]; + if (last.nextSibling) { + can.insertBefore(last.parentNode, newFrag, last.nextSibling); + } else { + can.appendChild(last.parentNode, newFrag); + } + }, + replace: function (oldElements, newFrag) { + elements.after(oldElements, newFrag); + if (can.remove(can.$(oldElements)).length < oldElements.length && !selectsCommentNodes) { + can.each(oldElements, function (el) { + if (el.nodeType === 8) { + el.parentNode.removeChild(el); + } + }); + } + } + }; + can.view.elements = elements; + return elements; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/event.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/event.js new file mode 100644 index 0000000000..4bce9e59f6 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/event.js @@ -0,0 +1,152 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#event/event*/ +define(['can/util/can'], function (can) { + can.addEvent = function (event, handler) { + var allEvents = this.__bindEvents || (this.__bindEvents = {}), eventList = allEvents[event] || (allEvents[event] = []); + eventList.push({ + handler: handler, + name: event + }); + return this; + }; + can.listenTo = function (other, event, handler) { + var idedEvents = this.__listenToEvents; + if (!idedEvents) { + idedEvents = this.__listenToEvents = {}; + } + var otherId = can.cid(other); + var othersEvents = idedEvents[otherId]; + if (!othersEvents) { + othersEvents = idedEvents[otherId] = { + obj: other, + events: {} + }; + } + var eventsEvents = othersEvents.events[event]; + if (!eventsEvents) { + eventsEvents = othersEvents.events[event] = []; + } + eventsEvents.push(handler); + can.bind.call(other, event, handler); + }; + can.stopListening = function (other, event, handler) { + var idedEvents = this.__listenToEvents, iterIdedEvents = idedEvents, i = 0; + if (!idedEvents) { + return this; + } + if (other) { + var othercid = can.cid(other); + (iterIdedEvents = {})[othercid] = idedEvents[othercid]; + if (!idedEvents[othercid]) { + return this; + } + } + for (var cid in iterIdedEvents) { + var othersEvents = iterIdedEvents[cid], eventsEvents; + other = idedEvents[cid].obj; + if (!event) { + eventsEvents = othersEvents.events; + } else { + (eventsEvents = {})[event] = othersEvents.events[event]; + } + for (var eventName in eventsEvents) { + var handlers = eventsEvents[eventName] || []; + i = 0; + while (i < handlers.length) { + if (handler && handler === handlers[i] || !handler) { + can.unbind.call(other, eventName, handlers[i]); + handlers.splice(i, 1); + } else { + i++; + } + } + if (!handlers.length) { + delete othersEvents.events[eventName]; + } + } + if (can.isEmptyObject(othersEvents.events)) { + delete idedEvents[cid]; + } + } + return this; + }; + can.removeEvent = function (event, fn, __validate) { + if (!this.__bindEvents) { + return this; + } + var events = this.__bindEvents[event] || [], i = 0, ev, isFunction = typeof fn === 'function'; + while (i < events.length) { + ev = events[i]; + if (__validate ? __validate(ev, event, fn) : isFunction && ev.handler === fn || !isFunction && (ev.cid === fn || !fn)) { + events.splice(i, 1); + } else { + i++; + } + } + return this; + }; + can.dispatch = function (event, args) { + var events = this.__bindEvents; + if (!events) { + return; + } + if (typeof event === 'string') { + event = { type: event }; + } + var eventName = event.type, handlers = (events[eventName] || []).slice(0), passed = [event]; + if (args) { + passed.push.apply(passed, args); + } + for (var i = 0, len = handlers.length; i < len; i++) { + handlers[i].handler.apply(this, passed); + } + return event; + }; + can.one = function (event, handler) { + var one = function () { + can.unbind.call(this, event, one); + return handler.apply(this, arguments); + }; + can.bind.call(this, event, one); + return this; + }; + can.event = { + on: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.on.call(this); + } else { + return can.addEvent.apply(this, arguments); + } + }, + off: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.off.call(this); + } else { + return can.removeEvent.apply(this, arguments); + } + }, + bind: can.addEvent, + unbind: can.removeEvent, + delegate: function (selector, event, handler) { + return can.addEvent.call(this, event, handler); + }, + undelegate: function (selector, event, handler) { + return can.removeEvent.call(this, event, handler); + }, + trigger: can.dispatch, + one: can.one, + addEvent: can.addEvent, + removeEvent: can.removeEvent, + listenTo: can.listenTo, + stopListening: can.stopListening, + dispatch: can.dispatch + }; + return can.event; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/fragment.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/fragment.js new file mode 100644 index 0000000000..ec9b83198d --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/fragment.js @@ -0,0 +1,65 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/fragment*/ +define(['can/util/can'], function (can) { + var fragmentRE = /^\s*<(\w+)[^>]*>/, toString = {}.toString, fragment = function (html, name) { + if (name === undefined) { + name = fragmentRE.test(html) && RegExp.$1; + } + if (html && toString.call(html.replace) === '[object Function]') { + html = html.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, '<$1>'); + } + var container = document.createElement('div'), temp = document.createElement('div'); + if (name === 'tbody' || name === 'tfoot' || name === 'thead') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; + } else if (name === 'tr') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild; + } else if (name === 'td' || name === 'th') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild.firstChild; + } else if (name === 'option') { + temp.innerHTML = ''; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; + } else { + container.innerHTML = '' + html; + } + var tmp = {}, children = container.childNodes; + tmp.length = children.length; + for (var i = 0; i < children.length; i++) { + tmp[i] = children[i]; + } + return [].slice.call(tmp); + }; + can.buildFragment = function (html, nodes) { + if (html && html.nodeType === 11) { + return html; + } + var parts = fragment(html), frag = document.createDocumentFragment(); + for (var i = 0, length = parts.length; i < length; i++) { + frag.appendChild(parts[i]); + } + return frag; + }; + (function () { + var text = '<-\n>', frag = can.buildFragment(text, document); + if (text !== frag.childNodes[0].nodeValue) { + var oldBuildFragment = can.buildFragment; + can.buildFragment = function (html, nodes) { + var res = oldBuildFragment(html, nodes); + if (res.childNodes.length === 1 && res.childNodes[0].nodeType === 3) { + res.childNodes[0].nodeValue = html; + } + return res; + }; + } + }()); + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/get_value_and_bind.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/get_value_and_bind.js new file mode 100644 index 0000000000..b6359e7441 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/get_value_and_bind.js @@ -0,0 +1,91 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#compute/get_value_and_bind*/ +define(['can/util/library'], function () { + function observe(func, context, oldInfo, onchanged) { + var info = getValueAndObserved(func, context), newObserveSet = info.observed, oldObserved = oldInfo.observed; + if (info.names !== oldInfo.names) { + bindNewSet(oldObserved, newObserveSet, onchanged); + unbindOldSet(oldObserved, onchanged); + } + can.batch.afterPreviousEvents(function () { + info.ready = true; + }); + return info; + } + var observedStack = []; + can.__isRecordingObserves = function () { + return observedStack.length; + }; + can.__observe = can.__reading = function (obj, event) { + if (observedStack.length) { + var name = obj._cid + '|' + event, top = observedStack[observedStack.length - 1]; + top.names += name; + top.observed[name] = { + obj: obj, + event: event + '' + }; + } + }; + can.__notObserve = function (fn) { + return function () { + var previousReads = can.__clearObserved(); + var res = fn.apply(this, arguments); + can.__setObserved(previousReads); + return res; + }; + }; + can.__clearObserved = can.__clearReading = function () { + if (observedStack.length) { + var ret = observedStack[observedStack.length - 1]; + observedStack[observedStack.length - 1] = { observed: {} }; + return ret; + } + }; + can.__setObserved = can.__setReading = function (o) { + if (observedStack.length) { + observedStack[observedStack.length - 1] = o; + } + }; + can.__addObserved = can.__addReading = function (o) { + if (observedStack.length) { + can.simpleExtend(observedStack[observedStack.length - 1], o); + } + }; + var getValueAndObserved = function (func, self) { + observedStack.push({ + names: '', + observed: {} + }); + var value = func.call(self); + var stackItem = observedStack.pop(); + stackItem.value = value; + return stackItem; + }; + var bindNewSet = function (oldObserved, newObserveSet, onchanged) { + for (var name in newObserveSet) { + bindOrPreventUnbinding(oldObserved, newObserveSet, name, onchanged); + } + }; + var bindOrPreventUnbinding = function (oldObserved, newObserveSet, name, onchanged) { + if (oldObserved[name]) { + delete oldObserved[name]; + } else { + var obEv = newObserveSet[name]; + obEv.obj.bind(obEv.event, onchanged); + } + }; + var unbindOldSet = function (oldObserved, onchanged) { + for (var name in oldObserved) { + var obEv = oldObserved[name]; + obEv.obj.unbind(obEv.event, onchanged); + } + }; + return observe; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/hashchange.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/hashchange.js new file mode 100644 index 0000000000..13c7c846b8 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/hashchange.js @@ -0,0 +1,25 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/hashchange*/ +define(['can/util/can'], function (can) { + (function () { + var addEvent = function (el, ev, fn) { + if (el.addEventListener) { + el.addEventListener(ev, fn, false); + } else if (el.attachEvent) { + el.attachEvent('on' + ev, fn); + } else { + el['on' + ev] = fn; + } + }, onHashchange = function () { + can.trigger(window, 'hashchange'); + }; + addEvent(window, 'hashchange', onHashchange); + }()); +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/list.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/list.js new file mode 100644 index 0000000000..00dc1298b3 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/list.js @@ -0,0 +1,264 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#list/list*/ +define([ + 'can/util/library', + 'can/map', + 'can/bubble' +], function (can, Map, bubble) { + var splice = [].splice, spliceRemovesProps = function () { + var obj = { + 0: 'a', + length: 1 + }; + splice.call(obj, 0, 1); + return !obj[0]; + }(); + var list = Map.extend({ Map: Map }, { + setup: function (instances, options) { + this.length = 0; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + this._setupComputes(); + instances = instances || []; + var teardownMapping; + if (can.isDeferred(instances)) { + this.replace(instances); + } else { + teardownMapping = instances.length && can.Map.helpers.addToMap(instances, this); + this.push.apply(this, can.makeArray(instances || [])); + } + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + can.simpleExtend(this, options); + delete this._init; + }, + _triggerChange: function (attr, how, newVal, oldVal) { + Map.prototype._triggerChange.apply(this, arguments); + var index = +attr; + if (!~('' + attr).indexOf('.') && !isNaN(index)) { + if (how === 'add') { + can.batch.trigger(this, how, [ + newVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else if (how === 'remove') { + can.batch.trigger(this, how, [ + oldVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else { + can.batch.trigger(this, how, [ + newVal, + index + ]); + } + } + }, + __get: function (attr) { + if (attr) { + if (this[attr] && this[attr].isComputed && can.isFunction(this.constructor.prototype[attr])) { + return this[attr](); + } else { + return this[attr]; + } + } else { + return this; + } + }, + __set: function (prop, value, current) { + prop = isNaN(+prop) || prop % 1 ? prop : +prop; + if (typeof prop === 'number' && prop > this.length - 1) { + var newArr = new Array(prop + 1 - this.length); + newArr[newArr.length - 1] = value; + this.push.apply(this, newArr); + return newArr; + } + return can.Map.prototype.__set.call(this, '' + prop, value, current); + }, + ___set: function (attr, val) { + this[attr] = val; + if (+attr >= this.length) { + this.length = +attr + 1; + } + }, + _remove: function (prop, current) { + if (isNaN(+prop)) { + delete this[prop]; + this._triggerChange(prop, 'remove', undefined, current); + } else { + this.splice(prop, 1); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var i = 0; i < data.length; i++) { + callback(data[i], i); + } + }, + serialize: function () { + return Map.helpers.serialize(this, 'serialize', []); + }, + splice: function (index, howMany) { + var args = can.makeArray(arguments), added = [], i, len, listIndex, allSame = args.length > 2; + index = index || 0; + for (i = 0, len = args.length - 2; i < len; i++) { + listIndex = i + 2; + args[listIndex] = this.__type(args[listIndex], listIndex); + added.push(args[listIndex]); + if (this[i + index] !== args[listIndex]) { + allSame = false; + } + } + if (allSame && this.length <= added.length) { + return added; + } + if (howMany === undefined) { + howMany = args[1] = this.length - index; + } + var removed = splice.apply(this, args); + if (!spliceRemovesProps) { + for (i = this.length; i < removed.length + this.length; i++) { + delete this[i]; + } + } + can.batch.start(); + if (howMany > 0) { + bubble.removeMany(this, removed); + this._triggerChange('' + index, 'remove', undefined, removed); + } + if (args.length > 2) { + for (i = 0, len = added.length; i < len; i++) { + bubble.set(this, i, added[i]); + } + this._triggerChange('' + index, 'add', added, removed); + } + can.batch.stop(); + return removed; + }, + _attrs: function (items, remove) { + if (items === undefined) { + return Map.helpers.serialize(this, 'attr', []); + } + items = can.makeArray(items); + can.batch.start(); + this._updateAttrs(items, remove); + can.batch.stop(); + }, + _updateAttrs: function (items, remove) { + var len = Math.min(items.length, this.length); + for (var prop = 0; prop < len; prop++) { + var curVal = this[prop], newVal = items[prop]; + if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + this._set(prop, newVal); + } else { + } + } + if (items.length > this.length) { + this.push.apply(this, items.slice(this.length)); + } else if (items.length < this.length && remove) { + this.splice(items.length); + } + } + }), getArgs = function (args) { + return args[0] && can.isArray(args[0]) ? args[0] : can.makeArray(args); + }; + can.each({ + push: 'length', + unshift: 0 + }, function (where, name) { + var orig = [][name]; + list.prototype[name] = function () { + var args = [], len = where ? this.length : 0, i = arguments.length, res, val; + while (i--) { + val = arguments[i]; + args[i] = bubble.set(this, i, this.__type(val, i)); + } + res = orig.apply(this, args); + if (!this.comparator || args.length) { + this._triggerChange('' + len, 'add', args, undefined); + } + return res; + }; + }); + can.each({ + pop: 'length', + shift: 0 + }, function (where, name) { + list.prototype[name] = function () { + if (!this.length) { + return undefined; + } + var args = getArgs(arguments), len = where && this.length ? this.length - 1 : 0; + var res = [][name].apply(this, args); + this._triggerChange('' + len, 'remove', undefined, [res]); + if (res && res.unbind) { + bubble.remove(this, res); + } + return res; + }; + }); + can.extend(list.prototype, { + indexOf: function (item, fromIndex) { + this.attr('length'); + return can.inArray(item, this, fromIndex); + }, + join: function () { + return [].join.apply(this.attr(), arguments); + }, + reverse: function () { + var list = [].reverse.call(can.makeArray(this)); + this.replace(list); + }, + slice: function () { + var temp = Array.prototype.slice.apply(this, arguments); + return new this.constructor(temp); + }, + concat: function () { + var args = []; + can.each(can.makeArray(arguments), function (arg, i) { + args[i] = arg instanceof can.List ? arg.serialize() : arg; + }); + return new this.constructor(Array.prototype.concat.apply(this.serialize(), args)); + }, + forEach: function (cb, thisarg) { + return can.each(this, cb, thisarg || this); + }, + replace: function (newList) { + if (can.isDeferred(newList)) { + newList.then(can.proxy(this.replace, this)); + } else { + this.splice.apply(this, [ + 0, + this.length + ].concat(can.makeArray(newList || []))); + } + return this; + }, + filter: function (callback, thisArg) { + var filteredList = new can.List(), self = this, filtered; + this.each(function (item, index, list) { + filtered = callback.call(thisArg | self, item, index, self); + if (filtered) { + filteredList.push(item); + } + }); + return filteredList; + } + }); + can.List = Map.List = list; + return can.List; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/list/promise.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/list/promise.js new file mode 100644 index 0000000000..25e5fa76a0 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/list/promise.js @@ -0,0 +1,58 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#list/promise/promise*/ +define(['can/list'], function (list) { + var oldReplace = can.List.prototype.replace; + can.List.prototype.replace = function (data) { + var result = oldReplace.apply(this, arguments); + if (can.isDeferred(data)) { + can.batch.start(); + this.attr('state', data.state()); + this.removeAttr('reason'); + can.batch.stop(); + var self = this; + var deferred = this._deferred = new can.Deferred(); + data.then(function () { + self.attr('state', data.state()); + deferred.resolve(self); + }, function (reason) { + can.batch.start(); + self.attr('state', data.state()); + self.attr('reason', reason); + can.batch.stop(); + deferred.reject(reason); + }); + } + return result; + }; + can.each({ + isResolved: 'resolved', + isPending: 'pending', + isRejected: 'rejected' + }, function (value, method) { + can.List.prototype[method] = function () { + return this.attr('state') === value; + }; + }); + can.each([ + 'then', + 'done', + 'fail', + 'always', + 'promise' + ], function (name) { + can.List.prototype[name] = function () { + if (!this._deferred) { + this._deferred = new can.Deferred(); + this._deferred.resolve(this); + } + return this._deferred[name].apply(this._deferred, arguments); + }; + }); +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/list/sort.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/list/sort.js new file mode 100644 index 0000000000..44f13dccf5 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/list/sort.js @@ -0,0 +1,198 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#list/sort/sort*/ +define([ + 'can/util/library', + 'can/list' +], function () { + var oldBubbleRule = can.List._bubbleRule; + can.List._bubbleRule = function (eventName, list) { + var oldBubble = oldBubbleRule.apply(this, arguments); + if (list.comparator && can.inArray('change', oldBubble) === -1) { + oldBubble.push('change'); + } + return oldBubble; + }; + var proto = can.List.prototype, _changes = proto._changes, setup = proto.setup, unbind = proto.unbind; + can.extend(proto, { + setup: function (instances, options) { + setup.apply(this, arguments); + this._comparatorBound = false; + this._init = 1; + this.bind('comparator', can.proxy(this._comparatorUpdated, this)); + delete this._init; + if (this.comparator) { + this.sort(); + } + }, + _comparatorUpdated: function (ev, newValue) { + if (newValue || newValue === 0) { + this.sort(); + if (this._bindings > 0 && !this._comparatorBound) { + this.bind('change', this._comparatorBound = function () { + }); + } + } else if (this._comparatorBound) { + unbind.call(this, 'change', this._comparatorBound); + this._comparatorBound = false; + } + }, + unbind: function (ev, handler) { + var res = unbind.apply(this, arguments); + if (this._comparatorBound && this._bindings === 1) { + unbind.call(this, 'change', this._comparatorBound); + this._comparatorBound = false; + } + return res; + }, + _comparator: function (a, b) { + var comparator = this.comparator; + if (comparator && typeof comparator === 'function') { + return comparator(a, b); + } + return a === b ? 0 : a < b ? -1 : 1; + }, + _changes: function (ev, attr, how, newVal, oldVal) { + if (this.comparator && /^\d+/.test(attr)) { + if (ev.batchNum && ev.batchNum !== this._lastBatchNum) { + this.sort(); + this._lastBatchNum = ev.batchNum; + return; + } + var currentIndex = +/^\d+/.exec(attr)[0], item = this[currentIndex]; + if (typeof item !== 'undefined') { + var newIndex = this._getInsertIndex(item, currentIndex); + if (newIndex !== currentIndex) { + this._swapItems(currentIndex, newIndex); + can.trigger(this, 'length', [this.length]); + } + } + } + _changes.apply(this, arguments); + }, + _getInsertIndex: function (item, currentIndex) { + var a = this._getComparatorValue(item), b, offset = 0; + for (var i = 0; i < this.length; i++) { + b = this._getComparatorValue(this[i]); + if (typeof currentIndex !== 'undefined' && i === currentIndex) { + offset = -1; + continue; + } + if (this._comparator(a, b) < 0) { + return i + offset; + } + } + return i + offset; + }, + _getComparatorValue: function (item, overwrittenComparator) { + var comparator = typeof overwrittenComparator === 'string' ? overwrittenComparator : this.comparator; + if (item && comparator && typeof comparator === 'string') { + item = typeof item[comparator] === 'function' ? item[comparator]() : item.attr(comparator); + } + return item; + }, + _getComparatorValues: function () { + var self = this; + var a = []; + this.each(function (item, index) { + a.push(self._getComparatorValue(item)); + }); + return a; + }, + sort: function (comparator, silent) { + var a, b, c, isSorted; + var comparatorFn = can.isFunction(comparator) ? comparator : this._comparator; + for (var i, iMin, j = 0, n = this.length; j < n - 1; j++) { + iMin = j; + isSorted = true; + c = undefined; + for (i = j + 1; i < n; i++) { + a = this._getComparatorValue(this.attr(i), comparator); + b = this._getComparatorValue(this.attr(iMin), comparator); + if (comparatorFn.call(this, a, b) < 0) { + isSorted = false; + iMin = i; + } + if (c && comparatorFn.call(this, a, c) < 0) { + isSorted = false; + } + c = a; + } + if (isSorted) { + break; + } + if (iMin !== j) { + this._swapItems(iMin, j, silent); + } + } + if (!silent) { + can.trigger(this, 'length', [this.length]); + } + return this; + }, + _swapItems: function (oldIndex, newIndex, silent) { + var temporaryItemReference = this[oldIndex]; + [].splice.call(this, oldIndex, 1); + [].splice.call(this, newIndex, 0, temporaryItemReference); + if (!silent) { + can.trigger(this, 'move', [ + temporaryItemReference, + newIndex, + oldIndex + ]); + } + } + }); + var getArgs = function (args) { + return args[0] && can.isArray(args[0]) ? args[0] : can.makeArray(args); + }; + can.each({ + push: 'length', + unshift: 0 + }, function (where, name) { + var proto = can.List.prototype, old = proto[name]; + proto[name] = function () { + if (this.comparator && arguments.length) { + var args = getArgs(arguments); + var i = args.length; + while (i--) { + var val = can.bubble.set(this, i, this.__type(args[i], i)); + var newIndex = this._getInsertIndex(val); + Array.prototype.splice.apply(this, [ + newIndex, + 0, + val + ]); + this._triggerChange('' + newIndex, 'add', [val], undefined); + } + can.batch.trigger(this, 'reset', [args]); + return this; + } else { + return old.apply(this, arguments); + } + }; + }); + (function () { + var proto = can.List.prototype; + var oldSplice = proto.splice; + proto.splice = function (index, howMany) { + var args = can.makeArray(arguments), newElements = [], i, len; + if (!this.comparator) { + return oldSplice.apply(this, args); + } + for (i = 2, len = args.length; i < len; i++) { + args[i] = this.__type(args[i], i); + newElements.push(args[i]); + } + oldSplice.call(this, index, howMany); + proto.push.apply(this, newElements); + }; + }()); + return can.Map; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map.js new file mode 100644 index 0000000000..9356bae417 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map.js @@ -0,0 +1,445 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/map*/ +define([ + 'can/util/library', + 'can/util/bind', + 'can/bubble', + 'can/construct', + 'can/util/batch' +], function (can, bind, bubble) { + var madeMap = null; + var teardownMap = function () { + for (var cid in madeMap) { + if (madeMap[cid].added) { + delete madeMap[cid].obj._cid; + } + } + madeMap = null; + }; + var getMapFromObject = function (obj) { + return madeMap && madeMap[obj._cid] && madeMap[obj._cid].instance; + }; + var serializeMap = null; + var Map = can.Map = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Map) { + if (!this.defaults) { + this.defaults = {}; + } + this._computes = []; + if (this.prototype.define && !this.helpers.define) { + can.dev.warn('can/map/define is not included, yet there is a define property ' + 'used. You may want to add this plugin.'); + } + if (this.define && !this.helpers.define) { + can.dev.warn('The define property should be on the map\'s prototype properties, ' + 'not the static properies. Also, can/map/define is not included.'); + } + for (var prop in this.prototype) { + if (prop !== 'define' && prop !== 'constructor' && (typeof this.prototype[prop] !== 'function' || this.prototype[prop].prototype instanceof can.Construct)) { + this.defaults[prop] = this.prototype[prop]; + } else if (this.prototype[prop].isComputed) { + this._computes.push(prop); + } + } + if (this.helpers.define) { + this.helpers.define(this); + } + } + if (can.List && !(this.prototype instanceof can.List)) { + this.List = Map.List.extend({ Map: this }, {}); + } + }, + _bubble: bubble, + _bubbleRule: function (eventName) { + return eventName === 'change' || eventName.indexOf('.') >= 0 ? ['change'] : []; + }, + _computes: [], + bind: can.bindAndSetup, + on: can.bindAndSetup, + unbind: can.unbindAndTeardown, + off: can.unbindAndTeardown, + id: 'id', + helpers: { + define: null, + attrParts: function (attr, keepKey) { + if (keepKey) { + return [attr]; + } + return typeof attr === 'object' ? attr : ('' + attr).split('.'); + }, + addToMap: function (obj, instance) { + var teardown; + if (!madeMap) { + teardown = teardownMap; + madeMap = {}; + } + var hasCid = obj._cid; + var cid = can.cid(obj); + if (!madeMap[cid]) { + madeMap[cid] = { + obj: obj, + instance: instance, + added: !hasCid + }; + } + return teardown; + }, + isObservable: function (obj) { + return obj instanceof can.Map || obj && obj === can.route; + }, + canMakeObserve: function (obj) { + return obj && !can.isDeferred(obj) && (can.isArray(obj) || can.isPlainObject(obj)); + }, + serialize: function (map, how, where) { + var cid = can.cid(map), firstSerialize = false; + if (!serializeMap) { + firstSerialize = true; + serializeMap = { + attr: {}, + serialize: {} + }; + } + serializeMap[how][cid] = where; + map.each(function (val, name) { + var result, isObservable = Map.helpers.isObservable(val), serialized = isObservable && serializeMap[how][can.cid(val)]; + if (serialized) { + result = serialized; + } else { + if (how === 'serialize') { + result = Map.helpers._serialize(map, name, val); + } else { + result = Map.helpers._getValue(map, name, val, how); + } + } + if (result !== undefined) { + where[name] = result; + } + }); + can.__observe(map, '__keys'); + if (firstSerialize) { + serializeMap = null; + } + return where; + }, + _serialize: function (map, name, val) { + return Map.helpers._getValue(map, name, val, 'serialize'); + }, + _getValue: function (map, name, val, how) { + if (Map.helpers.isObservable(val)) { + return val[how](); + } else { + return val; + } + } + }, + keys: function (map) { + var keys = []; + can.__observe(map, '__keys'); + for (var keyName in map._data) { + keys.push(keyName); + } + return keys; + } + }, { + setup: function (obj) { + if (obj instanceof can.Map) { + obj = obj.serialize(); + } + this._data = {}; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + var defaultValues = this._setupDefaults(obj); + this._setupComputes(defaultValues); + var teardownMapping = obj && can.Map.helpers.addToMap(obj, this); + var data = can.extend(can.extend(true, {}, defaultValues), obj); + this.attr(data); + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + delete this._init; + }, + _setupComputes: function () { + var computes = this.constructor._computes; + for (var i = 0, len = computes.length, prop; i < len; i++) { + prop = computes[i]; + this[prop] = this[prop].clone(this); + this._computedBindings[prop] = { count: 0 }; + } + }, + _setupDefaults: function () { + return this.constructor.defaults || {}; + }, + _bindsetup: function () { + }, + _bindteardown: function () { + }, + _changes: function (ev, attr, how, newVal, oldVal) { + can.batch.trigger(this, { + type: attr, + batchNum: ev.batchNum, + target: ev.target + }, [ + newVal, + oldVal + ]); + }, + _triggerChange: function (attr, how, newVal, oldVal) { + if (bubble.isBubbling(this, 'change')) { + can.batch.trigger(this, { + type: 'change', + target: this + }, [ + attr, + how, + newVal, + oldVal + ]); + } else { + can.batch.trigger(this, attr, [ + newVal, + oldVal + ]); + } + if (how === 'remove' || how === 'add') { + can.batch.trigger(this, { + type: '__keys', + target: this + }); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var prop in data) { + if (data.hasOwnProperty(prop)) { + callback(data[prop], prop); + } + } + }, + attr: function (attr, val) { + var type = typeof attr; + if (type !== 'string' && type !== 'number') { + return this._attrs(attr, val); + } else if (arguments.length === 1) { + return this._get(attr); + } else { + this._set(attr, val); + return this; + } + }, + each: function () { + return can.each.apply(undefined, [this].concat(can.makeArray(arguments))); + }, + removeAttr: function (attr) { + var isList = can.List && this instanceof can.List, parts = can.Map.helpers.attrParts(attr), prop = parts.shift(), current = isList ? this[prop] : this._data[prop]; + if (parts.length && current) { + return current.removeAttr(parts); + } else { + if (typeof attr === 'string' && !!~attr.indexOf('.')) { + prop = attr; + } + this._remove(prop, current); + return current; + } + }, + _remove: function (prop, current) { + if (prop in this._data) { + delete this._data[prop]; + if (!(prop in this.constructor.prototype)) { + delete this[prop]; + } + this._triggerChange(prop, 'remove', undefined, current); + } + }, + _get: function (attr) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'); + if (dotIndex >= 0) { + var value = this.__get(attr); + if (value !== undefined) { + return value; + } + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + can.__observe(this, first); + var current = this.__get(first); + return current && current._get ? current._get(second) : undefined; + } else { + can.__observe(this, attr); + return this.__get(attr); + } + }, + __get: function (attr) { + if (attr) { + if (this._computedBindings[attr]) { + return this[attr](); + } else { + return this._data[attr]; + } + } else { + return this._data; + } + }, + __type: function (value, prop) { + if (!(value instanceof can.Map) && can.Map.helpers.canMakeObserve(value)) { + var cached = getMapFromObject(value); + if (cached) { + return cached; + } + if (can.isArray(value)) { + var List = can.List; + return new List(value); + } else { + var Map = this.constructor.Map || can.Map; + return new Map(value); + } + } + return value; + }, + _set: function (attr, value, keepKey) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'), current; + if (!keepKey && dotIndex >= 0) { + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + current = this._init ? undefined : this.__get(first); + if (Map.helpers.isObservable(current)) { + current._set(second, value); + } else { + throw 'can.Map: Object does not exist'; + } + } else { + if (this.__convert) { + value = this.__convert(attr, value); + } + current = this._init ? undefined : this.__get(attr); + this.__set(attr, this.__type(value, attr), current); + } + }, + __set: function (prop, value, current) { + if (value !== current) { + var changeType = current !== undefined || this.__get().hasOwnProperty(prop) ? 'set' : 'add'; + this.___set(prop, this.constructor._bubble.set(this, prop, value, current)); + if (!this._computedBindings[prop]) { + this._triggerChange(prop, changeType, value, current); + } + if (current) { + this.constructor._bubble.teardownFromParent(this, current); + } + } + }, + ___set: function (prop, val) { + if (this._computedBindings[prop]) { + this[prop](val); + } else { + this._data[prop] = val; + } + if (typeof this.constructor.prototype[prop] !== 'function' && !this._computedBindings[prop]) { + this[prop] = val; + } + }, + bind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (!computedBinding.count) { + computedBinding.count = 1; + var self = this; + computedBinding.handler = function (ev, newVal, oldVal) { + can.batch.trigger(self, { + type: eventName, + batchNum: ev.batchNum, + target: self + }, [ + newVal, + oldVal + ]); + }; + this[eventName].bind('change', computedBinding.handler); + } else { + computedBinding.count++; + } + } + this.constructor._bubble.bind(this, eventName); + return can.bindAndSetup.apply(this, arguments); + }, + unbind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (computedBinding.count === 1) { + computedBinding.count = 0; + this[eventName].unbind('change', computedBinding.handler); + delete computedBinding.handler; + } else { + computedBinding.count--; + } + } + this.constructor._bubble.unbind(this, eventName); + return can.unbindAndTeardown.apply(this, arguments); + }, + serialize: function () { + return can.Map.helpers.serialize(this, 'serialize', {}); + }, + _attrs: function (props, remove) { + if (props === undefined) { + return Map.helpers.serialize(this, 'attr', {}); + } + props = can.simpleExtend({}, props); + var prop, self = this, newVal; + can.batch.start(); + this.each(function (curVal, prop) { + if (prop === '_cid') { + return; + } + newVal = props[prop]; + if (newVal === undefined) { + if (remove) { + self.removeAttr(prop); + } + return; + } + if (self.__convert) { + newVal = self.__convert(prop, newVal); + } + if (Map.helpers.isObservable(newVal)) { + self.__set(prop, self.__type(newVal, prop), curVal); + } else if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + self.__set(prop, self.__type(newVal, prop), curVal); + } + delete props[prop]; + }); + for (prop in props) { + if (prop !== '_cid') { + newVal = props[prop]; + this._set(prop, newVal, true); + } + } + can.batch.stop(); + return this; + }, + compute: function (prop) { + if (can.isFunction(this.constructor.prototype[prop])) { + return can.compute(this[prop], this); + } else { + var reads = prop.split('.'), last = reads.length - 1, options = { args: [] }; + return can.compute(function (newVal) { + if (arguments.length) { + can.compute.read(this, reads.slice(0, last)).value.attr(reads[last], newVal); + } else { + return can.compute.read(this, reads, options).value; + } + }, this); + } + } + }); + Map.prototype.on = Map.prototype.bind; + Map.prototype.off = Map.prototype.unbind; + return Map; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/attributes.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/attributes.js new file mode 100644 index 0000000000..dce62160c5 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/attributes.js @@ -0,0 +1,122 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/attributes/attributes*/ +define([ + 'can/util/library', + 'can/map', + 'can/list' +], function (can, Map) { + can.dev.warn('can/map/attributes is a deprecated plugin and will be removed in a future release. ' + 'can/map/define provides the same functionality in a more complete API.'); + can.each([ + can.Map, + can.Model + ], function (clss) { + if (clss === undefined) { + return; + } + var isObject = function (obj) { + return typeof obj === 'object' && obj !== null && obj; + }; + can.extend(clss, { + attributes: {}, + convert: { + 'date': function (str) { + var type = typeof str; + if (type === 'string') { + str = Date.parse(str); + return isNaN(str) ? null : new Date(str); + } else if (type === 'number') { + return new Date(str); + } else { + return str; + } + }, + 'number': function (val) { + return parseFloat(val); + }, + 'boolean': function (val) { + if (val === 'false' || val === '0' || !val) { + return false; + } + return true; + }, + 'default': function (val, oldVal, error, type) { + if (can.Map.prototype.isPrototypeOf(type.prototype) && typeof type.model === 'function' && typeof type.models === 'function') { + return type[can.isArray(val) ? 'models' : 'model'](val); + } + if (can.Map.prototype.isPrototypeOf(type.prototype)) { + if (can.isArray(val) && typeof type.List === 'function') { + return new type.List(val); + } + return new type(val); + } + if (typeof type === 'function') { + return type(val, oldVal); + } + var construct = can.getObject(type), context = window, realType; + if (type.indexOf('.') >= 0) { + realType = type.substring(0, type.lastIndexOf('.')); + context = can.getObject(realType); + } + return typeof construct === 'function' ? construct.call(context, val, oldVal) : val; + } + }, + serialize: { + 'default': function (val, type) { + return isObject(val) && val.serialize ? val.serialize() : val; + }, + 'date': function (val) { + return val && val.getTime(); + } + } + }); + var oldSetup = clss.setup; + clss.setup = function (superClass, stat, proto) { + var self = this; + oldSetup.call(self, superClass, stat, proto); + can.each(['attributes'], function (name) { + if (!self[name] || superClass[name] === self[name]) { + self[name] = {}; + } + }); + can.each([ + 'convert', + 'serialize' + ], function (name) { + if (superClass[name] !== self[name]) { + self[name] = can.extend({}, superClass[name], self[name]); + } + }); + }; + }); + can.Map.prototype.__convert = function (prop, value) { + var Class = this.constructor, oldVal = this.__get(prop), type, converter; + if (Class.attributes) { + type = Class.attributes[prop]; + converter = Class.convert[type] || Class.convert['default']; + } + return value === null || !type ? value : converter.call(Class, value, oldVal, function () { + }, type); + }; + var oldSerialize = can.Map.helpers._serialize; + can.Map.helpers._serialize = function (map, name, val) { + var constructor = map.constructor, type = constructor.attributes ? constructor.attributes[name] : 0, converter = constructor.serialize ? constructor.serialize[type] : 0; + return val && typeof val.serialize === 'function' ? oldSerialize.apply(this, arguments) : converter ? converter(val, type) : oldSerialize.apply(this, arguments); + }; + var mapSerialize = can.Map.prototype.serialize; + can.Map.prototype.serialize = function (attrName) { + var baseResult = mapSerialize.apply(this, arguments); + if (attrName) { + return baseResult[attrName]; + } else { + return baseResult; + } + }; + return can.Map; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/backup.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/backup.js new file mode 100644 index 0000000000..2b246bbb8d --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/backup.js @@ -0,0 +1,49 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/backup/backup*/ +define([ + 'can/util/library', + 'can/compute', + 'can/map', + 'can/util/object' +], function (can) { + var flatProps = function (a, cur) { + var obj = {}; + for (var prop in a) { + if (typeof a[prop] !== 'object' || a[prop] === null || a[prop] instanceof Date) { + obj[prop] = a[prop]; + } else { + obj[prop] = cur.attr(prop); + } + } + return obj; + }; + var oldSetup = can.Map.prototype.setup; + can.extend(can.Map.prototype, { + setup: function () { + this._backupStore = can.compute(); + return oldSetup.apply(this, arguments); + }, + backup: function () { + this._backupStore(this.attr()); + return this; + }, + isDirty: function (checkAssociations) { + return this._backupStore() && !can.Object.same(this.attr(), this._backupStore(), undefined, undefined, undefined, !!checkAssociations); + }, + restore: function (restoreAssociations) { + var props = restoreAssociations ? this._backupStore() : flatProps(this._backupStore(), this); + if (this.isDirty(restoreAssociations)) { + this.attr(props, true); + } + return this; + } + }); + return can.Map; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/bubble.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/bubble.js new file mode 100644 index 0000000000..53090ccc00 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/bubble.js @@ -0,0 +1,28 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/lazy/bubble*/ +define([ + 'can/util/library', + 'can/bubble' +], function (can) { + var bubble = can.bubble; + return can.extend({}, bubble, { + childrenOf: function (parentMap, eventName) { + if (parentMap._nestedReference) { + parentMap._nestedReference.each(function (child, ref) { + if (child && child.bind) { + bubble.toParent(child, parentMap, ref(), eventName); + } + }); + } else { + bubble._each.apply(this, arguments); + } + } + }); +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/define.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/define.js new file mode 100644 index 0000000000..129b2e4c9b --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/define.js @@ -0,0 +1,258 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/define/define*/ +define([ + 'can/util/library', + 'can/observe' +], function (can) { + var define = can.define = {}; + var getPropDefineBehavior = function (behavior, attr, define) { + var prop, defaultProp; + if (define) { + prop = define[attr]; + defaultProp = define['*']; + if (prop && prop[behavior] !== undefined) { + return prop[behavior]; + } else if (defaultProp && defaultProp[behavior] !== undefined) { + return defaultProp[behavior]; + } + } + }; + can.Map.helpers.define = function (Map) { + var definitions = Map.prototype.define; + if (Map.define) { + can.dev.warn('The define property should be on the map\'s prototype properties, ' + 'not the static properies.'); + } + Map.defaultGenerators = {}; + for (var prop in definitions) { + var type = definitions[prop].type; + if (typeof type === 'string') { + if (typeof define.types[type] === 'object') { + delete definitions[prop].type; + can.extend(definitions[prop], define.types[type]); + } + } + if ('value' in definitions[prop]) { + if (typeof definitions[prop].value === 'function') { + Map.defaultGenerators[prop] = definitions[prop].value; + } else { + Map.defaults[prop] = definitions[prop].value; + } + } + if (typeof definitions[prop].Value === 'function') { + (function (Constructor) { + Map.defaultGenerators[prop] = function () { + return new Constructor(); + }; + }(definitions[prop].Value)); + } + } + }; + var oldSetupDefaults = can.Map.prototype._setupDefaults; + can.Map.prototype._setupDefaults = function (obj) { + var defaults = oldSetupDefaults.call(this), propsCommittedToAttr = {}, Map = this.constructor, originalGet = this._get; + this._get = function (originalProp) { + prop = originalProp.indexOf('.') !== -1 ? originalProp.substr(0, originalProp.indexOf('.')) : prop; + if (prop in defaults && !(prop in propsCommittedToAttr)) { + this.attr(prop, defaults[prop]); + propsCommittedToAttr[prop] = true; + } + return originalGet.apply(this, arguments); + }; + for (var prop in Map.defaultGenerators) { + if (!obj || !(prop in obj)) { + defaults[prop] = Map.defaultGenerators[prop].call(this); + } + } + this._get = originalGet; + return defaults; + }; + var proto = can.Map.prototype, oldSet = proto.__set; + proto.__set = function (prop, value, current, success, error) { + var asyncTimer; + var errorCallback = function (errors) { + clearTimeout(asyncTimer); + var stub = error && error.call(self, errors); + if (stub !== false) { + can.trigger(self, 'error', [ + prop, + errors + ], true); + } + return false; + }, self = this, setter = getPropDefineBehavior('set', prop, this.define), getter = getPropDefineBehavior('get', prop, this.define); + if (setter) { + can.batch.start(); + var setterCalled = false, setValue = setter.call(this, value, function (value) { + if (getter) { + self[prop](value); + } else { + oldSet.call(self, prop, value, current, success, errorCallback); + } + setterCalled = true; + clearTimeout(asyncTimer); + }, errorCallback, getter ? this[prop].computeInstance.lastSetValue.get() : current); + if (getter) { + if (setValue !== undefined && !setterCalled && setter.length >= 1) { + this[prop](setValue); + } + can.batch.stop(); + return; + } else if (setValue === undefined && !setterCalled && setter.length >= 1) { + asyncTimer = setTimeout(function () { + can.dev.warn('can/map/setter.js: Setter "' + prop + '" did not return a value or call the setter callback.'); + }, can.dev.warnTimeout); + can.batch.stop(); + return; + } else { + if (!setterCalled) { + oldSet.call(self, prop, setter.length === 0 && setValue === undefined ? value : setValue, current, success, errorCallback); + } + can.batch.stop(); + return this; + } + } else { + oldSet.call(self, prop, value, current, success, errorCallback); + } + return this; + }; + define.types = { + 'date': function (str) { + var type = typeof str; + if (type === 'string') { + str = Date.parse(str); + return isNaN(str) ? null : new Date(str); + } else if (type === 'number') { + return new Date(str); + } else { + return str; + } + }, + 'number': function (val) { + if (val == null) { + return val; + } + return +val; + }, + 'boolean': function (val) { + if (val === 'false' || val === '0' || !val) { + return false; + } + return true; + }, + 'htmlbool': function (val) { + return typeof val === 'string' || !!val; + }, + '*': function (val) { + return val; + }, + 'string': function (val) { + if (val == null) { + return val; + } + return '' + val; + }, + 'compute': { + set: function (newValue, setVal, setErr, oldValue) { + if (newValue.isComputed) { + return newValue; + } + if (oldValue && oldValue.isComputed) { + oldValue(newValue); + return oldValue; + } + return newValue; + }, + get: function (value) { + return value && value.isComputed ? value() : value; + } + } + }; + var oldType = proto.__type; + proto.__type = function (value, prop) { + var type = getPropDefineBehavior('type', prop, this.define), Type = getPropDefineBehavior('Type', prop, this.define), newValue = value; + if (typeof type === 'string') { + type = define.types[type]; + } + if (type || Type) { + if (type) { + newValue = type.call(this, newValue, prop); + } + if (Type && !(newValue instanceof Type)) { + newValue = new Type(newValue); + } + return newValue; + } else if (can.isPlainObject(newValue) && newValue.define) { + newValue = can.Map.extend(newValue); + newValue = new newValue(); + } + return oldType.call(this, newValue, prop); + }; + var oldRemove = proto._remove; + proto._remove = function (prop, current) { + var remove = getPropDefineBehavior('remove', prop, this.define), res; + if (remove) { + can.batch.start(); + res = remove.call(this, current); + if (res === false) { + can.batch.stop(); + return; + } else { + res = oldRemove.call(this, prop, current); + can.batch.stop(); + return res; + } + } + return oldRemove.call(this, prop, current); + }; + var oldSetupComputes = proto._setupComputes; + proto._setupComputes = function (defaultsValues) { + oldSetupComputes.apply(this, arguments); + for (var attr in this.define) { + var def = this.define[attr], get = def.get; + if (get) { + this[attr] = can.compute.async(defaultsValues[attr], get, this); + this._computedBindings[attr] = { count: 0 }; + } + } + }; + var oldSingleSerialize = can.Map.helpers._serialize; + can.Map.helpers._serialize = function (map, name, val) { + return serializeProp(map, name, val); + }; + var serializeProp = function (map, attr, val) { + var serializer = attr === '*' ? false : getPropDefineBehavior('serialize', attr, map.define); + if (serializer === undefined) { + return oldSingleSerialize.apply(this, arguments); + } else if (serializer !== false) { + return typeof serializer === 'function' ? serializer.call(map, val, attr) : oldSingleSerialize.apply(this, arguments); + } + }; + var oldSerialize = proto.serialize; + proto.serialize = function (property) { + var serialized = oldSerialize.apply(this, arguments); + if (property) { + return serialized; + } + var serializer, val; + for (var attr in this.define) { + if (!(attr in serialized)) { + serializer = this.define && this.define[attr] && this.define[attr].serialize; + if (serializer) { + val = serializeProp(this, attr, this.attr(attr)); + if (val !== undefined) { + serialized[attr] = val; + } + } + } + } + return serialized; + }; + return can.define; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/delegate.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/delegate.js new file mode 100644 index 0000000000..8d55ae3588 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/delegate.js @@ -0,0 +1,133 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/delegate/delegate*/ +define([ + 'can/util/library', + 'can/map' +], function (can) { + var delegateMatches = function (parts, props) { + var len = parts.length, i = 0, matchedProps = [], prop; + for (i; i < len; i++) { + prop = props[i]; + if (typeof prop !== 'string') { + return null; + } else if (parts[i] === '**') { + return props.join('.'); + } else if (parts[i] === '*') { + matchedProps.push(prop); + } else if (prop === parts[i]) { + matchedProps.push(prop); + } else { + return null; + } + } + return matchedProps.join('.'); + }, delegateHandler = function (event, prop, how, newVal, oldVal) { + var props = prop.split('.'), delegates = (this._observe_delegates || []).slice(0), delegate, attr, matchedAttr, hasMatch, valuesEqual; + event.attr = prop; + event.lastAttr = props[props.length - 1]; + for (var i = 0; delegate = delegates[i++];) { + if (event.batchNum && delegate.batchNum === event.batchNum || delegate.undelegated) { + continue; + } + hasMatch = undefined; + valuesEqual = true; + for (var a = 0; a < delegate.attrs.length; a++) { + attr = delegate.attrs[a]; + matchedAttr = delegateMatches(attr.parts, props); + if (matchedAttr) { + hasMatch = matchedAttr; + } + if (attr.value && valuesEqual) { + valuesEqual = attr.value === '' + this.attr(attr.attr); + } else if (valuesEqual && delegate.attrs.length > 1) { + valuesEqual = this.attr(attr.attr) !== undefined; + } + } + if (hasMatch && valuesEqual) { + var from = prop.replace(hasMatch + '.', ''); + if (event.batchNum) { + delegate.batchNum = event.batchNum; + } + if (delegate.event === 'change') { + prop = from; + event.curAttr = hasMatch; + delegate.callback.apply(this.attr(hasMatch), can.makeArray(arguments)); + } else if (delegate.event === how) { + delegate.callback.apply(this.attr(hasMatch), [ + event, + newVal, + oldVal, + from + ]); + } else if (delegate.event === 'set' && how === 'add') { + delegate.callback.apply(this.attr(hasMatch), [ + event, + newVal, + oldVal, + from + ]); + } + } + } + }; + can.extend(can.Map.prototype, { + delegate: function (selector, event, handler) { + selector = can.trim(selector); + var delegates = this._observe_delegates || (this._observe_delegates = []), attrs = [], selectorRegex = /([^\s=,]+)(?:=("[^",]*"|'[^',]*'|[^\s"',]*))?(,?)\s*/g, matches; + while ((matches = selectorRegex.exec(selector)) !== null) { + if (matches[2] && can.inArray(matches[2].substr(0, 1), [ + '"', + '\'' + ]) >= 0) { + matches[2] = matches[2].substr(1, -1); + } + attrs.push({ + attr: matches[1], + parts: matches[1].split('.'), + value: matches[2], + or: matches[3] === ',' + }); + } + delegates.push({ + selector: selector, + attrs: attrs, + callback: handler, + event: event + }); + if (delegates.length === 1) { + this.bind('change', delegateHandler); + } + return this; + }, + undelegate: function (selector, event, handler) { + selector = selector && can.trim(selector); + var i = 0, delegates = this._observe_delegates || [], delegateOb; + if (selector) { + while (i < delegates.length) { + delegateOb = delegates[i]; + if (delegateOb.callback === handler || !handler && delegateOb.selector === selector) { + delegateOb.undelegated = true; + delegates.splice(i, 1); + } else { + i++; + } + } + } else { + delegates = []; + } + if (!delegates.length) { + this.unbind('change', delegateHandler); + } + return this; + } + }); + can.Map.prototype.delegate.matches = delegateMatches; + return can.Map; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/lazy.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/lazy.js new file mode 100644 index 0000000000..bf374d8f59 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/lazy.js @@ -0,0 +1,225 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/lazy/lazy*/ +define([ + 'can/util/library', + 'can/map/bubble', + 'can/map', + 'can/list', + 'can/map/nested_reference' +], function (can, bubble) { + can.LazyMap = can.Map.extend({ _bubble: bubble }, { + setup: function (obj) { + this.constructor.Map = this.constructor; + this.constructor.List = can.LazyList; + this._data = can.extend(can.extend(true, {}, this._setupDefaults() || {}), obj); + can.cid(this, '.lazyMap'); + this._init = 1; + this._computedBindings = {}; + this._setupComputes(); + var teardownMapping = obj && can.Map.helpers.addToMap(obj, this); + this._nestedReference = new can.NestedReference(this._data); + if (teardownMapping) { + teardownMapping(); + } + can.each(this._data, can.proxy(function (value, prop) { + this.___set(prop, value); + }, this)); + this.bind('change', can.proxy(this._changes, this)); + delete this._init; + }, + _addChild: function (path, newChild, setNewChild) { + var self = this; + this._nestedReference.removeChildren(path, function (oldChild, oldChildPath) { + bubble.remove(self, oldChild); + if (newChild) { + var newChildPath = oldChildPath.replace(path + '.', ''); + if (path === newChildPath) { + oldChild._nestedReference.each(function (obj, path) { + newChild._nestedReference.make(path()); + if (self._bindings) { + bubble.add(this, newChild, path()); + } + }); + } else { + var reference = newChild._nestedReference.make(newChildPath); + if (self._bindings) { + bubble.add(oldChild, newChild, reference()); + } + } + } + }); + if (setNewChild) { + setNewChild(); + } + if (newChild) { + var reference = this._nestedReference.make(path); + if (this._bindings) { + bubble.add(this, newChild, reference()); + } + } + return newChild; + }, + removeAttr: function (attr) { + var data = this._goto(attr); + if (data.parts.length) { + return data.value.removeAttr(data.parts.join('.')); + } else { + if (can.isArray(data.parent)) { + data.parent.splice(data.prop, 1); + this._triggerChange(attr, 'remove', undefined, [this.__type(data.value, data.prop)]); + } else { + if (data.parent[data.prop]) { + delete data.parent[data.prop]; + can.batch.trigger(this, data.path.length ? data.path.join('.') + '.__keys' : '__keys'); + this._triggerChange(attr, 'remove', undefined, this.__type(data.value, data.prop)); + } + } + this._nestedReference.removeChildren(); + return data.value; + } + }, + __type: function (value, prop) { + if (!(value instanceof can.LazyMap) && can.Map.helpers.canMakeObserve(value)) { + if (can.isArray(value)) { + var List = can.LazyList; + return new List(value); + } else { + var Map = this.constructor.Map || can.LazyMap; + return new Map(value); + } + } + return value; + }, + _goto: function (attr, keepKey) { + var parts = can.Map.helpers.attrParts(attr, keepKey).slice(0), prev, path = [], part; + var cur = this instanceof can.List ? this[parts.shift()] : this.__get(); + while (cur && !can.Map.helpers.isObservable(cur) && parts.length) { + if (part !== undefined) { + path.push(part); + } + prev = cur; + cur = cur[part = parts.shift()]; + } + return { + parts: parts, + prop: part, + value: cur, + parent: prev, + path: path + }; + }, + _get: function (attr) { + can.__observe(this, attr); + var data = this._goto(attr); + if (can.Map.helpers.isObservable(data.value)) { + if (data.parts.length) { + return data.value._get(data.parts); + } else { + return data.value; + } + } else if (data.value && can.Map.helpers.canMakeObserve(data.value)) { + var converted = this.__type(data.value, data.prop); + this._addChild(attr, converted, function () { + data.parent[data.prop] = converted; + }); + return converted; + } else if (data.value !== undefined) { + return data.value; + } else { + return this.__get(attr); + } + }, + _set: function (attr, value, keepKey) { + var data = this._goto(attr, keepKey); + if (can.Map.helpers.isObservable(data.value) && data.parts.length) { + return data.value._set(data.parts, value); + } else if (!data.parts.length) { + this.__set(attr, value, data.value, data); + } else { + throw 'can.LazyMap: object does not exist'; + } + }, + __set: function (prop, value, current, data, convert) { + convert = convert || true; + if (value !== current) { + var changeType = data.parent.hasOwnProperty(data.prop) ? 'set' : 'add'; + if (convert && can.Map.helpers.canMakeObserve(value)) { + value = this.__type(value, prop); + var self = this; + this._addChild(prop, value, function () { + self.___set(prop, value, data); + }); + } else { + this.___set(prop, value, data); + } + if (changeType === 'add') { + can.batch.trigger(this, data.path.length ? data.path.join('.') + '.__keys' : '__keys', undefined); + } + this._triggerChange(prop, changeType, value, current); + } + }, + ___set: function (prop, val, data) { + if (this[prop] && this[prop].isComputed && can.isFunction(this.constructor.prototype[prop])) { + this[prop](val); + } else if (data) { + data.parent[data.prop] = val; + } else { + this._data[prop] = val; + } + if (!can.isFunction(this.constructor.prototype[prop])) { + this[prop] = val; + } + }, + _attrs: function (props, remove) { + if (props === undefined) { + return can.Map.helpers.serialize(this, 'attr', {}); + } + props = can.extend({}, props); + var self = this, prop, data, newVal; + can.batch.start(); + this.each(function (curVal, prop) { + newVal = props[prop]; + data = self._goto(prop, true); + if (newVal === undefined) { + if (remove) { + self.removeAttr(prop); + } + return; + } else if (!can.Map.helpers.isObservable(curVal) && can.Map.helpers.canMakeObserve(curVal)) { + curVal = self.attr(prop); + } + if (self.__convert) { + newVal = self.__convert(prop, newVal); + } + if (newVal instanceof can.Map) { + self.__set(prop, newVal, curVal, data); + } else if (can.Map.helpers.isObservable(curVal) && can.Map.helpers.canMakeObserve(newVal) && curVal.attr) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + self.__set(prop, newVal, curVal, data); + } + delete props[prop]; + }); + for (prop in props) { + newVal = props[prop]; + this._set(prop, newVal, true); + } + can.batch.stop(); + return this; + } + }); + can.LazyList = can.List.extend({ Map: can.LazyMap }, { + setup: function () { + can.List.prototype.setup.apply(this, arguments); + this._nestedReference = new can.NestedReference(this); + } + }); + return can.LazyMap; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/list.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/list.js new file mode 100644 index 0000000000..9bc256e31d --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/list.js @@ -0,0 +1,77 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/list/list*/ +define([ + 'can/util/library', + 'can/map', + 'can/list', + 'can/compute' +], function (can) { + can.extend(can.List.prototype, { + filter: function (callback) { + var filtered = new this.constructor(); + var self = this; + var generator = function (element, index) { + var binder = function (ev, val) { + var index = filtered.indexOf(element); + if (!val && index !== -1) { + filtered.splice(index, 1); + } + if (val && index === -1) { + filtered.push(element); + } + }; + var compute = can.compute(function () { + return callback(element, self.indexOf(element), self); + }); + compute.bind('change', binder); + binder(null, compute()); + }; + this.bind('add', function (ev, data, index) { + can.each(data, function (element, i) { + generator(element, index + i); + }); + }); + this.bind('remove', function (ev, data, index) { + can.each(data, function (element, i) { + var index = filtered.indexOf(element); + if (index !== -1) { + filtered.splice(index, 1); + } + }); + }); + this.forEach(generator); + return filtered; + }, + map: function (callback) { + var mapped = new can.List(); + var self = this; + var generator = function (element, index) { + var compute = can.compute(function () { + return callback(element, index, self); + }); + compute.bind('change', function (ev, val) { + mapped.splice(index, 1, val); + }); + mapped.splice(index, 0, compute()); + }; + this.forEach(generator); + this.bind('add', function (ev, data, index) { + can.each(data, function (element, i) { + generator(element, index + i); + }); + }); + this.bind('remove', function (ev, data, index) { + mapped.splice(index, data.length); + }); + return mapped; + } + }); + return can.List; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/nested_reference.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/nested_reference.js new file mode 100644 index 0000000000..3f92f90ff9 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/nested_reference.js @@ -0,0 +1,80 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/lazy/nested_reference*/ +define(['can/util/library'], function (can) { + var pathIterator = function (root, propPath, callback) { + var props = propPath.split('.'), cur = root, part; + while (part = props.shift()) { + cur = cur[part]; + if (callback) { + callback(cur, part); + } + } + return cur; + }; + var ArrIndex = function (array) { + this.array = array; + }; + ArrIndex.prototype.toString = function () { + return '' + can.inArray(this.item, this.array); + }; + var NestedReference = function (root) { + this.root = root; + this.references = []; + }; + NestedReference.ArrIndex = ArrIndex; + can.extend(NestedReference.prototype, { + make: function (propPath) { + var path = [], arrIndex; + if (can.isArray(this.root) || this.root instanceof can.LazyList) { + arrIndex = new ArrIndex(this.root); + } + pathIterator(this.root, propPath, function (item, prop) { + if (arrIndex) { + arrIndex.item = item; + path.push(arrIndex); + arrIndex = undefined; + } else { + path.push(prop); + if (can.isArray(item)) { + arrIndex = new ArrIndex(item); + } + } + }); + var pathFunc = function () { + return path.join('.'); + }; + this.references.push(pathFunc); + return pathFunc; + }, + removeChildren: function (path, callback) { + var i = 0; + while (i < this.references.length) { + var reference = this.references[i](); + if (reference.indexOf(path) === 0) { + callback(this.get(reference), reference); + this.references.splice(i, 1); + } else { + i++; + } + } + }, + get: function (path) { + return pathIterator(this.root, path); + }, + each: function (callback) { + var self = this; + can.each(this.references, function (ref) { + var path = ref(); + callback(self.get(path), ref, path); + }); + } + }); + can.NestedReference = NestedReference; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/setter.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/setter.js new file mode 100644 index 0000000000..ace4d1ca33 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/setter.js @@ -0,0 +1,59 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/setter/setter*/ +define([ + 'can/util/library', + 'can/map' +], function (can) { + can.classize = function (s, join) { + var parts = s.split(can.undHash), i = 0; + for (; i < parts.length; i++) { + parts[i] = can.capitalize(parts[i]); + } + return parts.join(join || ''); + }; + var classize = can.classize, proto = can.Map.prototype, old = proto.__set; + proto.__set = function (prop, value, current, success, error) { + var asyncTimer; + can.dev.warn('can/map/setter is a deprecated plugin and will be removed in a future release. ' + 'can/map/define provides the same functionality in a more complete API.'); + var cap = classize(prop), setName = 'set' + cap, errorCallback = function (errors) { + clearTimeout(asyncTimer); + var stub = error && error.call(self, errors); + if (stub !== false) { + can.trigger(self, 'error', [ + prop, + errors + ], true); + } + return false; + }, self = this; + if (this[setName]) { + can.batch.start(); + value = this[setName](value, function (value) { + old.call(self, prop, value, current, success, errorCallback); + clearTimeout(asyncTimer); + }, errorCallback); + if (value === undefined) { + asyncTimer = setTimeout(function () { + can.dev.warn('can/map/setter.js: Setter ' + setName + ' did not return a value or call the setter callback.'); + }, can.dev.warnTimeout); + can.batch.stop(); + return; + } else { + old.call(self, prop, value, current, success, errorCallback); + can.batch.stop(); + return this; + } + } else { + old.call(self, prop, value, current, success, errorCallback); + } + return this; + }; + return can.Map; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/sort.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/sort.js new file mode 100644 index 0000000000..a19b58c623 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/sort.js @@ -0,0 +1,12 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/sort/sort*/ +define(['can/list/sort'], function (sortPlugin) { + return sortPlugin; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/validations.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/validations.js new file mode 100644 index 0000000000..d90790afdd --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/map/validations.js @@ -0,0 +1,161 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/validations/validations*/ +define([ + 'can/util/library', + 'can/map' +], function (can) { + var validate = function (attrNames, options, proc) { + if (!proc) { + proc = options; + options = {}; + } + options = options || {}; + attrNames = typeof attrNames === 'string' ? [attrNames] : can.makeArray(attrNames); + if (options.testIf && !options.testIf.call(this)) { + return; + } + var self = this; + can.each(attrNames, function (attrName) { + if (!self.validations[attrName]) { + self.validations[attrName] = []; + } + self.validations[attrName].push(function (newVal) { + var res = proc.call(this, newVal, attrName); + return res === undefined ? undefined : options.message || res; + }); + }); + }; + var old = can.Map.prototype.__set; + can.Map.prototype.__set = function (prop, value, current, success, error) { + var self = this, validations = self.constructor.validations, errorCallback = function (errors) { + var stub = error && error.call(self, errors); + if (stub !== false) { + can.trigger(self, 'error', [ + prop, + errors + ], true); + } + return false; + }; + old.call(self, prop, value, current, success, errorCallback); + if (validations && validations[prop]) { + var errors = self.errors(prop); + if (errors) { + errorCallback(errors); + } + } + return this; + }; + can.each([ + can.Map, + can.Model + ], function (clss) { + if (clss === undefined) { + return; + } + var oldSetup = clss.setup; + can.extend(clss, { + setup: function (superClass) { + oldSetup.apply(this, arguments); + if (!this.validations || superClass.validations === this.validations) { + this.validations = {}; + } + }, + validate: validate, + validationMessages: { + format: 'is invalid', + inclusion: 'is not a valid option (perhaps out of range)', + lengthShort: 'is too short', + lengthLong: 'is too long', + presence: 'can\'t be empty', + range: 'is out of range', + numericality: 'must be a number' + }, + validateFormatOf: function (attrNames, regexp, options) { + validate.call(this, attrNames, options, function (value) { + if (typeof value !== 'undefined' && value !== null && value !== '' && String(value).match(regexp) === null) { + return this.constructor.validationMessages.format; + } + }); + }, + validateInclusionOf: function (attrNames, inArray, options) { + validate.call(this, attrNames, options, function (value) { + if (typeof value === 'undefined') { + return; + } + for (var i = 0; i < inArray.length; i++) { + if (inArray[i] === value) { + return; + } + } + return this.constructor.validationMessages.inclusion; + }); + }, + validateLengthOf: function (attrNames, min, max, options) { + validate.call(this, attrNames, options, function (value) { + if ((typeof value === 'undefined' || value === null) && min > 0 || typeof value !== 'undefined' && value !== null && value.length < min) { + return this.constructor.validationMessages.lengthShort + ' (min=' + min + ')'; + } else if (typeof value !== 'undefined' && value !== null && value.length > max) { + return this.constructor.validationMessages.lengthLong + ' (max=' + max + ')'; + } + }); + }, + validatePresenceOf: function (attrNames, options) { + validate.call(this, attrNames, options, function (value) { + if (typeof value === 'undefined' || value === '' || value === null) { + return this.constructor.validationMessages.presence; + } + }); + }, + validateRangeOf: function (attrNames, low, hi, options) { + validate.call(this, attrNames, options, function (value) { + if ((typeof value === 'undefined' || value === null) && low > 0 || typeof value !== 'undefined' && value !== null && (value < low || value > hi)) { + return this.constructor.validationMessages.range + ' [' + low + ',' + hi + ']'; + } + }); + }, + validatesNumericalityOf: function (attrNames) { + validate.call(this, attrNames, function (value) { + var res = !isNaN(parseFloat(value)) && isFinite(value); + if (!res) { + return this.constructor.validationMessages.numericality; + } + }); + } + }); + }); + can.extend(can.Map.prototype, { + errors: function (attrs, newVal) { + if (attrs) { + attrs = can.isArray(attrs) ? attrs : [attrs]; + } + var errors = {}, self = this, addErrors = function (attr, funcs) { + can.each(funcs, function (func) { + var res = func.call(self, isTest ? self.__convert ? self.__convert(attr, newVal) : newVal : self.attr(attr)); + if (res) { + if (!errors[attr]) { + errors[attr] = []; + } + errors[attr].push(res); + } + }); + }, validations = this.constructor.validations || {}, isTest = attrs && attrs.length === 1 && arguments.length === 2; + can.each(attrs || validations, function (funcs, attr) { + if (typeof attr === 'number') { + attr = funcs; + funcs = validations[attr]; + } + addErrors(attr, funcs || []); + }); + return can.isEmptyObject(errors) ? null : isTest ? errors[attrs[0]] : errors; + } + }); + return can.Map; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/model.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/model.js new file mode 100644 index 0000000000..da6142289b --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/model.js @@ -0,0 +1,399 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#model/model*/ +define([ + 'can/util/library', + 'can/map', + 'can/list' +], function (can) { + var pipe = function (def, thisArg, func) { + var d = new can.Deferred(); + def.then(function () { + var args = can.makeArray(arguments), success = true; + try { + args[0] = func.apply(thisArg, args); + } catch (e) { + success = false; + d.rejectWith(d, [e].concat(args)); + } + if (success) { + d.resolveWith(d, args); + } + }, function () { + d.rejectWith(this, arguments); + }); + if (typeof def.abort === 'function') { + d.abort = function () { + return def.abort(); + }; + } + return d; + }, modelNum = 0, getId = function (inst) { + can.__observe(inst, inst.constructor.id); + return inst.__get(inst.constructor.id); + }, ajax = function (ajaxOb, data, type, dataType, success, error) { + var params = {}; + if (typeof ajaxOb === 'string') { + var parts = ajaxOb.split(/\s+/); + params.url = parts.pop(); + if (parts.length) { + params.type = parts.pop(); + } + } else { + can.extend(params, ajaxOb); + } + params.data = typeof data === 'object' && !can.isArray(data) ? can.extend(params.data || {}, data) : data; + params.url = can.sub(params.url, params.data, true); + return can.ajax(can.extend({ + type: type || 'post', + dataType: dataType || 'json', + success: success, + error: error + }, params)); + }, makeRequest = function (modelObj, type, success, error, method) { + var args; + if (can.isArray(modelObj)) { + args = modelObj[1]; + modelObj = modelObj[0]; + } else { + args = modelObj.serialize(); + } + args = [args]; + var deferred, model = modelObj.constructor, jqXHR; + if (type === 'update' || type === 'destroy') { + args.unshift(getId(modelObj)); + } + jqXHR = model[type].apply(model, args); + deferred = pipe(jqXHR, modelObj, function (data) { + modelObj[method || type + 'd'](data, jqXHR); + return modelObj; + }); + if (jqXHR.abort) { + deferred.abort = function () { + jqXHR.abort(); + }; + } + deferred.then(success, error); + return deferred; + }, converters = { + models: function (instancesRawData, oldList, xhr) { + can.Model._reqs++; + if (!instancesRawData) { + return; + } + if (instancesRawData instanceof this.List) { + return instancesRawData; + } + var self = this, tmp = [], ListClass = self.List || ML, modelList = oldList instanceof can.List ? oldList : new ListClass(), rawDataIsList = instancesRawData instanceof ML, raw = rawDataIsList ? instancesRawData.serialize() : instancesRawData; + raw = self.parseModels(raw, xhr); + if (raw.data) { + instancesRawData = raw; + raw = raw.data; + } + if (typeof raw === 'undefined' || !can.isArray(raw)) { + throw new Error('Could not get any raw data while converting using .models'); + } + if (!raw.length) { + can.dev.warn('model.js models has no data.'); + } + if (modelList.length) { + modelList.splice(0); + } + can.each(raw, function (rawPart) { + tmp.push(self.model(rawPart, xhr)); + }); + modelList.push.apply(modelList, tmp); + if (!can.isArray(instancesRawData)) { + can.each(instancesRawData, function (val, prop) { + if (prop !== 'data') { + modelList.attr(prop, val); + } + }); + } + setTimeout(can.proxy(this._clean, this), 1); + return modelList; + }, + model: function (attributes, oldModel, xhr) { + if (!attributes) { + return; + } + if (typeof attributes.serialize === 'function') { + attributes = attributes.serialize(); + } else { + attributes = this.parseModel(attributes, xhr); + } + var id = attributes[this.id]; + if ((id || id === 0) && this.store[id]) { + oldModel = this.store[id]; + } + var model = oldModel && can.isFunction(oldModel.attr) ? oldModel.attr(attributes, this.removeAttr || false) : new this(attributes); + return model; + } + }, makeParser = { + parseModel: function (prop) { + return function (attributes) { + return prop ? can.getObject(prop, attributes) : attributes; + }; + }, + parseModels: function (prop) { + return function (attributes) { + if (can.isArray(attributes)) { + return attributes; + } + prop = prop || 'data'; + var result = can.getObject(prop, attributes); + if (!can.isArray(result)) { + throw new Error('Could not get any raw data while converting using .models'); + } + return result; + }; + } + }, ajaxMethods = { + create: { + url: '_shortName', + type: 'post' + }, + update: { + data: function (id, attrs) { + attrs = attrs || {}; + var identity = this.id; + if (attrs[identity] && attrs[identity] !== id) { + attrs['new' + can.capitalize(id)] = attrs[identity]; + delete attrs[identity]; + } + attrs[identity] = id; + return attrs; + }, + type: 'put' + }, + destroy: { + type: 'delete', + data: function (id, attrs) { + attrs = attrs || {}; + attrs.id = attrs[this.id] = id; + return attrs; + } + }, + findAll: { url: '_shortName' }, + findOne: {} + }, ajaxMaker = function (ajaxMethod, str) { + return function (data) { + data = ajaxMethod.data ? ajaxMethod.data.apply(this, arguments) : data; + return ajax(str || this[ajaxMethod.url || '_url'], data, ajaxMethod.type || 'get'); + }; + }, createURLFromResource = function (model, name) { + if (!model.resource) { + return; + } + var resource = model.resource.replace(/\/+$/, ''); + if (name === 'findAll' || name === 'create') { + return resource; + } else { + return resource + '/{' + model.id + '}'; + } + }; + can.Model = can.Map.extend({ + fullName: 'can.Model', + _reqs: 0, + setup: function (base, fullName, staticProps, protoProps) { + if (typeof fullName !== 'string') { + protoProps = staticProps; + staticProps = fullName; + } + if (!protoProps) { + can.dev.warn('can/model/model.js: can.Model extended without static properties.'); + protoProps = staticProps; + } + this.store = {}; + can.Map.setup.apply(this, arguments); + if (!can.Model) { + return; + } + if (staticProps && staticProps.List) { + this.List = staticProps.List; + this.List.Map = this; + } else { + this.List = base.List.extend({ Map: this }, {}); + } + var self = this, clean = can.proxy(this._clean, self); + can.each(ajaxMethods, function (method, name) { + if (staticProps && staticProps[name] && (typeof staticProps[name] === 'string' || typeof staticProps[name] === 'object')) { + self[name] = ajaxMaker(method, staticProps[name]); + } else if (staticProps && staticProps.resource && !can.isFunction(staticProps[name])) { + self[name] = ajaxMaker(method, createURLFromResource(self, name)); + } + if (self['make' + can.capitalize(name)]) { + var newMethod = self['make' + can.capitalize(name)](self[name]); + can.Construct._overwrite(self, base, name, function () { + can.Model._reqs++; + var def = newMethod.apply(this, arguments); + var then = def.then(clean, clean); + then.abort = def.abort; + return then; + }); + } + }); + var hasCustomConverter = {}; + can.each(converters, function (converter, name) { + var parseName = 'parse' + can.capitalize(name), dataProperty = staticProps && staticProps[name] || self[name]; + if (typeof dataProperty === 'string') { + self[parseName] = dataProperty; + can.Construct._overwrite(self, base, name, converter); + } else if (staticProps && staticProps[name]) { + hasCustomConverter[parseName] = true; + } + }); + can.each(makeParser, function (maker, parseName) { + var prop = staticProps && staticProps[parseName] || self[parseName]; + if (typeof prop === 'string') { + can.Construct._overwrite(self, base, parseName, maker(prop)); + } else if ((!staticProps || !can.isFunction(staticProps[parseName])) && !self[parseName]) { + var madeParser = maker(); + madeParser.useModelConverter = hasCustomConverter[parseName]; + can.Construct._overwrite(self, base, parseName, madeParser); + } + }); + if (self.fullName === 'can.Model' || !self.fullName) { + self.fullName = 'Model' + ++modelNum; + } + can.Model._reqs = 0; + this._url = this._shortName + '/{' + this.id + '}'; + }, + _ajax: ajaxMaker, + _makeRequest: makeRequest, + _clean: function () { + can.Model._reqs--; + if (!can.Model._reqs) { + for (var id in this.store) { + if (!this.store[id]._bindings) { + delete this.store[id]; + } + } + } + return arguments[0]; + }, + models: converters.models, + model: converters.model + }, { + setup: function (attrs) { + var id = attrs && attrs[this.constructor.id]; + if (can.Model._reqs && id != null) { + this.constructor.store[id] = this; + } + can.Map.prototype.setup.apply(this, arguments); + }, + isNew: function () { + var id = getId(this); + return !(id || id === 0); + }, + save: function (success, error) { + return makeRequest(this, this.isNew() ? 'create' : 'update', success, error); + }, + destroy: function (success, error) { + if (this.isNew()) { + var self = this; + var def = can.Deferred(); + def.then(success, error); + return def.done(function (data) { + self.destroyed(data); + }).resolve(self); + } + return makeRequest(this, 'destroy', success, error, 'destroyed'); + }, + _bindsetup: function () { + var modelInstance = this.__get(this.constructor.id); + if (modelInstance != null) { + this.constructor.store[modelInstance] = this; + } + return can.Map.prototype._bindsetup.apply(this, arguments); + }, + _bindteardown: function () { + delete this.constructor.store[getId(this)]; + return can.Map.prototype._bindteardown.apply(this, arguments); + }, + ___set: function (prop, val) { + can.Map.prototype.___set.call(this, prop, val); + if (prop === this.constructor.id && this._bindings) { + this.constructor.store[getId(this)] = this; + } + } + }); + var makeGetterHandler = function (name) { + return function (data, readyState, xhr) { + return this[name](data, null, xhr); + }; + }, createUpdateDestroyHandler = function (data) { + if (this.parseModel.useModelConverter) { + return this.model(data); + } + return this.parseModel(data); + }; + var responseHandlers = { + makeFindAll: makeGetterHandler('models'), + makeFindOne: makeGetterHandler('model'), + makeCreate: createUpdateDestroyHandler, + makeUpdate: createUpdateDestroyHandler, + makeDestroy: createUpdateDestroyHandler + }; + can.each(responseHandlers, function (method, name) { + can.Model[name] = function (oldMethod) { + return function () { + var args = can.makeArray(arguments), oldArgs = can.isFunction(args[1]) ? args.splice(0, 1) : args.splice(0, 2), def = pipe(oldMethod.apply(this, oldArgs), this, method); + def.then(args[0], args[1]); + return def; + }; + }; + }); + can.each([ + 'created', + 'updated', + 'destroyed' + ], function (funcName) { + can.Model.prototype[funcName] = function (attrs) { + var self = this, constructor = self.constructor; + if (attrs && typeof attrs === 'object') { + this.attr(can.isFunction(attrs.attr) ? attrs.attr() : attrs); + } + can.dispatch.call(this, { + type: 'change', + target: this + }, [funcName]); + can.dev.log('Model.js - ' + constructor.shortName + ' ' + funcName); + can.dispatch.call(constructor, funcName, [this]); + }; + }); + var ML = can.Model.List = can.List.extend({ + _bubbleRule: function (eventName, list) { + var bubbleRules = can.List._bubbleRule(eventName, list); + bubbleRules.push('destroyed'); + return bubbleRules; + } + }, { + setup: function (params) { + if (can.isPlainObject(params) && !can.isArray(params)) { + can.List.prototype.setup.apply(this); + this.replace(can.isDeferred(params) ? params : this.constructor.Map.findAll(params)); + } else { + can.List.prototype.setup.apply(this, arguments); + } + this._init = 1; + this.bind('destroyed', can.proxy(this._destroyed, this)); + delete this._init; + }, + _destroyed: function (ev, attr) { + if (/\w+/.test(attr)) { + var index; + while ((index = this.indexOf(ev.target)) > -1) { + this.splice(index, 1); + } + } + } + }); + return can.Model; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/model/queue.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/model/queue.js new file mode 100644 index 0000000000..386ed60c10 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/model/queue.js @@ -0,0 +1,109 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#model/queue/queue*/ +define([ + 'can/util/library', + 'can/model', + 'can/map/backup' +], function (can) { + var cleanAttrs = function (changedAttrs, attrs) { + var newAttrs = can.extend(true, {}, attrs), current, path; + if (changedAttrs) { + for (var i = 0; i < changedAttrs.length; i++) { + current = newAttrs; + path = changedAttrs[i].split('.'); + while (path.length > 1) { + current = current && current[path.shift()]; + } + if (current) { + delete current[path.shift()]; + } + } + } + return newAttrs; + }, queueRequests = function (success, error, method, callback) { + this._changedAttrs = this._changedAttrs || []; + var def = new can.Deferred(), self = this, attrs = this.serialize(), queue = this._requestQueue, changedAttrs = this._changedAttrs, reqFn, index; + reqFn = function (self, type, success, error) { + return function () { + return self.constructor._makeRequest([ + self, + attrs + ], type || (self.isNew() ? 'create' : 'update'), success, error, callback); + }; + }(this, method, function () { + def.resolveWith(self, arguments); + queue.splice(0, 1); + if (queue.length > 0) { + queue[0] = queue[0](); + } else { + changedAttrs.splice(0); + } + }, function () { + def.rejectWith(self, arguments); + queue.splice(0); + changedAttrs.splice(0); + }); + index = queue.push(reqFn) - 1; + if (queue.length === 1) { + queue[0] = queue[0](); + } + def.abort = function () { + var abort; + abort = queue[index].abort && queue[index].abort(); + queue.splice(index); + if (queue.length === 0) { + changedAttrs.splice(0); + } + return abort; + }; + def.then(success, error); + return def; + }, _triggerChange = can.Model.prototype._triggerChange, destroyFn = can.Model.prototype.destroy, setupFn = can.Model.prototype.setup; + can.each([ + 'created', + 'updated', + 'destroyed' + ], function (fn) { + var prototypeFn = can.Model.prototype[fn]; + can.Model.prototype[fn] = function (attrs) { + if (attrs && typeof attrs === 'object') { + attrs = attrs.attr ? attrs.attr() : attrs; + this._backupStore(attrs); + attrs = cleanAttrs(this._changedAttrs || [], attrs); + } + prototypeFn.call(this, attrs); + }; + }); + can.extend(can.Model.prototype, { + setup: function () { + setupFn.apply(this, arguments); + this._requestQueue = new can.List(); + }, + _triggerChange: function (attr, how, newVal, oldVal) { + if (this._changedAttrs) { + this._changedAttrs.push(attr); + } + _triggerChange.apply(this, arguments); + }, + hasQueuedRequests: function () { + return this._requestQueue.attr('length') > 1; + }, + save: function () { + return queueRequests.apply(this, arguments); + }, + destroy: function (success, error) { + if (this.isNew()) { + return destroyFn.call(this, success, error); + } + return queueRequests.call(this, success, error, 'destroy', 'destroyed'); + } + }); + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/observe.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/observe.js new file mode 100644 index 0000000000..2cd1e575da --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/observe.js @@ -0,0 +1,21 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#observe/observe*/ +define([ + 'can/util/library', + 'can/map', + 'can/list', + 'can/compute' +], function (can) { + can.Observe = can.Map; + can.Observe.startBatch = can.batch.start; + can.Observe.stopBatch = can.batch.stop; + can.Observe.triggerBatch = can.batch.trigger; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/proto_compute.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/proto_compute.js new file mode 100644 index 0000000000..01a6f90463 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/proto_compute.js @@ -0,0 +1,293 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#compute/proto_compute*/ +define([ + 'can/util/library', + 'can/util/bind', + 'can/read', + 'can/get_value_and_bind', + 'can/util/batch' +], function (can, bind, read, getValueAndBind) { + var updateOnChange = function (compute, newValue, oldValue, batchNum) { + if (newValue !== oldValue) { + can.batch.trigger(compute, batchNum ? { + type: 'change', + batchNum: batchNum + } : 'change', [ + newValue, + oldValue + ]); + } + }; + var setupComputeHandlers = function (compute, func, context, singleBind) { + var readInfo, onchanged, batchNum; + singleBind = false; + return { + on: function (updater) { + var self = this; + if (!onchanged) { + onchanged = function (ev) { + if (readInfo.ready && compute.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + if (singleBind) { + newValue = func.call(context); + readInfo.value = newValue; + } else { + readInfo = getValueAndBind(func, context, readInfo, onchanged); + newValue = readInfo.value; + } + self.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }; + } + readInfo = getValueAndBind(func, context, { observed: {} }, onchanged); + if (singleBind) { + func = can.__notObserve(func); + } + compute.value = readInfo.value; + compute.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function (updater) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, onchanged); + } + } + }; + }; + var k = function () { + }; + var updater = function (newVal, oldVal, batchNum) { + this.value = newVal; + updateOnChange(this, newVal, oldVal, batchNum); + }, asyncGet = function (fn, context, lastSetValue) { + return function () { + return fn.call(context, lastSetValue.get()); + }; + }, asyncUpdater = function (context, oldUpdater) { + return function (newVal) { + if (newVal !== undefined) { + oldUpdater(newVal, context.value); + } + }; + }; + can.Compute = function (getterSetter, context, eventName, bindOnce) { + var args = []; + for (var i = 0, arglen = arguments.length; i < arglen; i++) { + args[i] = arguments[i]; + } + var contextType = typeof args[1]; + if (typeof args[0] === 'function') { + this._setupGetterSetterFn(args[0], args[1], args[2], args[3]); + } else if (args[1]) { + if (contextType === 'string') { + this._setupContextString(args[0], args[1], args[2]); + } else if (contextType === 'function') { + this._setupContextFunction(args[0], args[1], args[2]); + } else { + if (args[1] && args[1].fn) { + this._setupAsyncCompute(args[0], args[1]); + } else { + this._setupContextSettings(args[0], args[1]); + } + } + } else { + this._setupInitialValue(args[0]); + } + this._args = args; + this.isComputed = true; + can.cid(this, 'compute'); + }; + can.simpleExtend(can.Compute.prototype, { + _bindsetup: can.__notObserve(function () { + this.bound = true; + this._on(this.updater); + }), + _bindteardown: function () { + this._off(this.updater); + this.bound = false; + }, + bind: can.bindAndSetup, + unbind: can.unbindAndTeardown, + clone: function (context) { + if (context && typeof this._args[0] === 'function') { + this._args[1] = context; + } else if (context) { + this._args[2] = context; + } + return new can.Compute(this._args[0], this._args[1], this._args[2], this._args[3]); + }, + _on: k, + _off: k, + get: function () { + if (can.__isRecordingObserves() && this._canObserve !== false) { + can.__observe(this, 'change'); + if (!this.bound) { + can.Compute.temporarilyBind(this); + } + } + if (this.bound) { + return this.value; + } else { + return this._get(); + } + }, + _get: function () { + return this.value; + }, + set: function (newVal) { + var old = this.value; + var setVal = this._set(newVal, old); + if (this.hasDependencies) { + if (this._setUpdates) { + return this.value; + } + return this._get(); + } + if (setVal === undefined) { + this.value = this._get(); + } else { + this.value = setVal; + } + updateOnChange(this, this.value, old); + return this.value; + }, + _set: function (newVal) { + return this.value = newVal; + }, + updater: updater, + _computeFn: function (newVal) { + if (arguments.length) { + return this.set(newVal); + } + return this.get(); + }, + toFunction: function () { + return can.proxy(this._computeFn, this); + }, + _setupGetterSetterFn: function (getterSetter, context, eventName, bindOnce) { + this._set = can.proxy(getterSetter, context); + this._get = can.proxy(getterSetter, context); + this._canObserve = eventName === false ? false : true; + var handlers = setupComputeHandlers(this, getterSetter, context || this, bindOnce); + this._on = handlers.on; + this._off = handlers.off; + }, + _setupContextString: function (target, propertyName, eventName) { + var isObserve = can.isMapLike(target), self = this, handler = function (ev, newVal, oldVal) { + self.updater(newVal, oldVal, ev.batchNum); + }; + if (isObserve) { + this.hasDependencies = true; + this._get = function () { + return target.attr(propertyName); + }; + this._set = function (val) { + target.attr(propertyName, val); + }; + this._on = function (update) { + target.bind(eventName || propertyName, handler); + this.value = this._get(); + }; + this._off = function () { + return target.unbind(eventName || propertyName, handler); + }; + } else { + this._get = can.proxy(this._get, target); + this._set = can.proxy(this._set, target); + } + }, + _setupContextFunction: function (initialValue, setter, eventName) { + this.value = initialValue; + this._set = setter; + can.simpleExtend(this, eventName); + }, + _setupContextSettings: function (initialValue, settings) { + this.value = initialValue; + this._set = settings.set ? can.proxy(settings.set, settings) : this._set; + this._get = settings.get ? can.proxy(settings.get, settings) : this._get; + if (!settings.__selfUpdater) { + var self = this, oldUpdater = this.updater; + this.updater = function () { + oldUpdater.call(self, self._get(), self.value); + }; + } + this._on = settings.on ? settings.on : this._on; + this._off = settings.off ? settings.off : this._off; + }, + _setupAsyncCompute: function (initialValue, settings) { + this.value = initialValue; + var oldUpdater = can.proxy(this.updater, this), self = this, fn = settings.fn, data; + this.updater = oldUpdater; + var lastSetValue = new can.Compute(initialValue); + this.lastSetValue = lastSetValue; + this._setUpdates = true; + this._set = function (newVal) { + if (newVal === lastSetValue.get()) { + return this.value; + } + return lastSetValue.set(newVal); + }; + this._get = asyncGet(fn, settings.context, lastSetValue); + if (fn.length === 0) { + data = setupComputeHandlers(this, fn, settings.context); + } else if (fn.length === 1) { + data = setupComputeHandlers(this, function () { + return fn.call(settings.context, lastSetValue.get()); + }, settings); + } else { + this.updater = asyncUpdater(this, oldUpdater); + data = setupComputeHandlers(this, function () { + var res = fn.call(settings.context, lastSetValue.get(), function (newVal) { + oldUpdater(newVal, self.value); + }); + return res !== undefined ? res : this.value; + }, settings); + } + this._on = data.on; + this._off = data.off; + }, + _setupInitialValue: function (initialValue) { + this.value = initialValue; + } + }); + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.Compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.Compute.async = function (initialValue, asyncComputer, context) { + return new can.Compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.Compute.read = read; + can.Compute.set = read.write; + can.Compute.truthy = function (compute) { + return new can.Compute(function () { + var res = compute.get(); + if (typeof res === 'function') { + res = res.get(); + } + return !!res; + }); + }; + return can.Compute; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/read.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/read.js new file mode 100644 index 0000000000..59f445cfb2 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/read.js @@ -0,0 +1,189 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#compute/read*/ +define(['can/util/library'], function (can) { + var read = function (parent, reads, options) { + options = options || {}; + var state = { foundObservable: false }; + var cur = readValue(parent, 0, reads, options, state), type, prev, readLength = reads.length, i = 0; + while (i < readLength) { + prev = cur; + for (var r = 0, readersLength = read.propertyReaders.length; r < readersLength; r++) { + var reader = read.propertyReaders[r]; + if (reader.test(cur)) { + cur = reader.read(cur, reads[i], i, options, state); + break; + } + } + i = i + 1; + cur = readValue(cur, i, reads, options, state, prev); + type = typeof cur; + if (i < reads.length && (cur === null || type !== 'function' && type !== 'object')) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1, cur); + } + return { + value: undefined, + parent: prev + }; + } + } + if (cur === undefined) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1); + } + } + return { + value: cur, + parent: prev + }; + }; + var readValue = function (value, index, reads, options, state, prev) { + var usedValueReader; + do { + usedValueReader = false; + for (var i = 0, len = read.valueReaders.length; i < len; i++) { + if (read.valueReaders[i].test(value, index, reads, options)) { + value = read.valueReaders[i].read(value, index, reads, options, state, prev); + } + } + } while (usedValueReader); + return value; + }; + read.valueReaders = [ + { + name: 'compute', + test: function (value, i, reads, options) { + return value && value.isComputed; + }, + read: function (value, i, reads, options, state) { + if (options.isArgument && i === reads.length) { + return value; + } + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, i); + state.foundObservable = true; + } + return value instanceof can.Compute ? value.get() : value(); + } + }, + { + name: 'function', + test: function (value, i, reads, options) { + var type = typeof value; + return type === 'function' && !value.isComputed && (options.executeAnonymousFunctions || options.isArgument && i === reads.length) && !(can.Construct && value.prototype instanceof can.Construct) && !(can.route && value === can.route); + }, + read: function (value, i, reads, options, state, prev) { + if (options.isArgument && i === reads.length) { + return options.proxyMethods !== false ? can.proxy(value, prev) : value; + } + return value.call(prev); + } + } + ]; + read.propertyReaders = [ + { + name: 'map', + test: can.isMapLike, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + if (typeof value[prop] === 'function' && value.constructor.prototype[prop] === value[prop]) { + if (options.returnObserveMethods) { + return value[prop]; + } else if (prop === 'constructor' && value instanceof can.Construct || value[prop].prototype instanceof can.Construct) { + return value[prop]; + } else { + return value[prop].apply(value, options.args || []); + } + } else { + return value.attr(prop); + } + } + }, + { + name: 'promise', + test: function (value) { + return can.isPromise(value); + }, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + var observeData = value.__observeData; + if (!value.__observeData) { + observeData = value.__observeData = { + isPending: true, + state: 'pending', + isResolved: false, + isRejected: false, + value: undefined, + reason: undefined + }; + can.cid(observeData); + can.simpleExtend(observeData, can.event); + value.then(function (value) { + observeData.isPending = false; + observeData.isResolved = true; + observeData.value = value; + observeData.state = 'resolved'; + observeData.dispatch('state', [ + 'resolved', + 'pending' + ]); + }, function (reason) { + observeData.isPending = false; + observeData.isRejected = true; + observeData.reason = reason; + observeData.state = 'rejected'; + observeData.dispatch('state', [ + 'rejected', + 'pending' + ]); + }); + } + can.__observe(observeData, 'state'); + return prop in observeData ? observeData[prop] : value[prop]; + } + }, + { + name: 'object', + test: function () { + return true; + }, + read: function (value, prop) { + if (value == null) { + return undefined; + } else { + return value[prop]; + } + } + } + ]; + read.write = function (parent, key, value, options) { + options = options || {}; + if (can.isMapLike(parent)) { + if (!options.isArgument && parent._data && parent._data[key] && parent._data[key].isComputed) { + return parent._data[key](value); + } else { + return parent.attr(key, value); + } + } + if (parent[key] && parent[key].isComputed) { + return parent[key](value); + } + if (typeof parent === 'object') { + parent[key] = value; + } + }; + return read; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/render.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/render.js new file mode 100644 index 0000000000..8e7e33a510 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/render.js @@ -0,0 +1,133 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/render*/ +define([ + 'can/view', + 'can/elements', + 'can/view/live', + 'can/util/string' +], function (can, elements, live) { + var pendingHookups = [], tagChildren = function (tagName) { + var newTag = elements.tagMap[tagName] || 'span'; + if (newTag === 'span') { + return '@@!!@@'; + } + return '<' + newTag + '>' + tagChildren(newTag) + ''; + }, contentText = function (input, tag) { + if (typeof input === 'string') { + return input; + } + if (!input && input !== 0) { + return ''; + } + var hook = input.hookup && function (el, id) { + input.hookup.call(input, el, id); + } || typeof input === 'function' && input; + if (hook) { + if (tag) { + return '<' + tag + ' ' + can.view.hook(hook) + '>'; + } else { + pendingHookups.push(hook); + } + return ''; + } + return '' + input; + }, contentEscape = function (txt, tag) { + return typeof txt === 'string' || typeof txt === 'number' ? can.esc(txt) : contentText(txt, tag); + }, withinTemplatedSectionWithinAnElement = false, emptyHandler = function () { + }; + var lastHookups; + can.extend(can.view, { + live: live, + setupLists: function () { + var old = can.view.lists, data; + can.view.lists = function (list, renderer) { + data = { + list: list, + renderer: renderer + }; + return Math.random(); + }; + return function () { + can.view.lists = old; + return data; + }; + }, + getHooks: function () { + var hooks = pendingHookups.slice(0); + lastHookups = hooks; + pendingHookups = []; + return hooks; + }, + onlytxt: function (self, func) { + return contentEscape(func.call(self)); + }, + txt: function (escape, tagName, status, self, func) { + var tag = elements.tagMap[tagName] || 'span', setupLiveBinding = false, value, listData, compute, unbind = emptyHandler, attributeName; + if (withinTemplatedSectionWithinAnElement) { + value = func.call(self); + } else { + if (typeof status === 'string' || status === 1) { + withinTemplatedSectionWithinAnElement = true; + } + var listTeardown = can.view.setupLists(); + unbind = function () { + compute.unbind('change', emptyHandler); + }; + compute = can.compute(func, self, false); + compute.bind('change', emptyHandler); + listData = listTeardown(); + value = compute(); + withinTemplatedSectionWithinAnElement = false; + setupLiveBinding = compute.computeInstance.hasDependencies; + } + if (listData) { + unbind(); + return '<' + tag + can.view.hook(function (el, parentNode) { + live.list(el, listData.list, listData.renderer, self, parentNode); + }) + '>'; + } + if (!setupLiveBinding || typeof value === 'function') { + unbind(); + return (withinTemplatedSectionWithinAnElement || escape === 2 || !escape ? contentText : contentEscape)(value, status === 0 && tag); + } + var contentProp = elements.tagToContentPropMap[tagName]; + if (status === 0 && !contentProp) { + return '<' + tag + can.view.hook(escape && typeof value !== 'object' ? function (el, parentNode) { + live.text(el, compute, parentNode); + unbind(); + } : function (el, parentNode) { + live.html(el, compute, parentNode); + unbind(); + }) + '>' + tagChildren(tag) + ''; + } else if (status === 1) { + pendingHookups.push(function (el) { + live.attributes(el, compute, compute()); + unbind(); + }); + return compute(); + } else if (escape === 2) { + attributeName = status; + pendingHookups.push(function (el) { + live.specialAttribute(el, attributeName, compute); + unbind(); + }); + return compute(); + } else { + attributeName = status === 0 ? contentProp : status; + (status === 0 ? lastHookups : pendingHookups).push(function (el) { + live.attribute(el, attributeName, compute); + unbind(); + }); + return live.attributePlaceholder; + } + } + }); + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/route.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/route.js new file mode 100644 index 0000000000..400355650a --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/route.js @@ -0,0 +1,305 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#route/route*/ +define([ + 'can/util/library', + 'can/map', + 'can/list', + 'can/util/string/deparam' +], function (can) { + var matcher = /\:([\w\.]+)/g, paramsMatcher = /^(?:&[^=]+=[^&]*)+/, makeProps = function (props) { + var tags = []; + can.each(props, function (val, name) { + tags.push((name === 'className' ? 'class' : name) + '="' + (name === 'href' ? val : can.esc(val)) + '"'); + }); + return tags.join(' '); + }, matchesData = function (route, data) { + var count = 0, i = 0, defaults = {}; + for (var name in route.defaults) { + if (route.defaults[name] === data[name]) { + defaults[name] = 1; + count++; + } + } + for (; i < route.names.length; i++) { + if (!data.hasOwnProperty(route.names[i])) { + return -1; + } + if (!defaults[route.names[i]]) { + count++; + } + } + return count; + }, location = window.location, wrapQuote = function (str) { + return (str + '').replace(/([.?*+\^$\[\]\\(){}|\-])/g, '\\$1'); + }, each = can.each, extend = can.extend, stringify = function (obj) { + if (obj && typeof obj === 'object') { + if (obj instanceof can.Map) { + obj = obj.attr(); + } else { + obj = can.isFunction(obj.slice) ? obj.slice() : can.extend({}, obj); + } + can.each(obj, function (val, prop) { + obj[prop] = stringify(val); + }); + } else if (obj !== undefined && obj !== null && can.isFunction(obj.toString)) { + obj = obj.toString(); + } + return obj; + }, removeBackslash = function (str) { + return str.replace(/\\/g, ''); + }, timer, curParams, lastHash, changingData, changedAttrs = [], onRouteDataChange = function (ev, attr, how, newval) { + changingData = 1; + changedAttrs.push(attr); + clearTimeout(timer); + timer = setTimeout(function () { + changingData = 0; + var serialized = can.route.data.serialize(), path = can.route.param(serialized, true); + can.route._call('setURL', path, changedAttrs); + can.batch.trigger(eventsObject, '__url', [ + path, + lastHash + ]); + lastHash = path; + changedAttrs = []; + }, 10); + }, eventsObject = can.extend({}, can.event); + can.route = function (url, defaults) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + defaults = defaults || {}; + var names = [], res, test = '', lastIndex = matcher.lastIndex = 0, next, querySeparator = can.route._call('querySeparator'), matchSlashes = can.route._call('matchSlashes'); + while (res = matcher.exec(url)) { + names.push(res[1]); + test += removeBackslash(url.substring(lastIndex, matcher.lastIndex - res[0].length)); + next = '\\' + (removeBackslash(url.substr(matcher.lastIndex, 1)) || querySeparator + (matchSlashes ? '' : '|/')); + test += '([^' + next + ']' + (defaults[res[1]] ? '*' : '+') + ')'; + lastIndex = matcher.lastIndex; + } + test += url.substr(lastIndex).replace('\\', ''); + can.route.routes[url] = { + test: new RegExp('^' + test + '($|' + wrapQuote(querySeparator) + ')'), + route: url, + names: names, + defaults: defaults, + length: url.split('/').length + }; + return can.route; + }; + extend(can.route, { + param: function (data, _setRoute) { + var route, matches = 0, matchCount, routeName = data.route, propCount = 0; + delete data.route; + each(data, function () { + propCount++; + }); + each(can.route.routes, function (temp, name) { + matchCount = matchesData(temp, data); + if (matchCount > matches) { + route = temp; + matches = matchCount; + } + if (matchCount >= propCount) { + return false; + } + }); + if (can.route.routes[routeName] && matchesData(can.route.routes[routeName], data) === matches) { + route = can.route.routes[routeName]; + } + if (route) { + var cpy = extend({}, data), res = route.route.replace(matcher, function (whole, name) { + delete cpy[name]; + return data[name] === route.defaults[name] ? '' : encodeURIComponent(data[name]); + }).replace('\\', ''), after; + each(route.defaults, function (val, name) { + if (cpy[name] === val) { + delete cpy[name]; + } + }); + after = can.param(cpy); + if (_setRoute) { + can.route.attr('route', route.route); + } + return res + (after ? can.route._call('querySeparator') + after : ''); + } + return can.isEmptyObject(data) ? '' : can.route._call('querySeparator') + can.param(data); + }, + deparam: function (url) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + var route = { length: -1 }, querySeparator = can.route._call('querySeparator'), paramsMatcher = can.route._call('paramsMatcher'); + each(can.route.routes, function (temp, name) { + if (temp.test.test(url) && temp.length > route.length) { + route = temp; + } + }); + if (route.length > -1) { + var parts = url.match(route.test), start = parts.shift(), remainder = url.substr(start.length - (parts[parts.length - 1] === querySeparator ? 1 : 0)), obj = remainder && paramsMatcher.test(remainder) ? can.deparam(remainder.slice(1)) : {}; + obj = extend(true, {}, route.defaults, obj); + each(parts, function (part, i) { + if (part && part !== querySeparator) { + obj[route.names[i]] = decodeURIComponent(part); + } + }); + obj.route = route.route; + return obj; + } + if (url.charAt(0) !== querySeparator) { + url = querySeparator + url; + } + return paramsMatcher.test(url) ? can.deparam(url.slice(1)) : {}; + }, + data: new can.Map({}), + map: function (data) { + var appState; + if (data.prototype instanceof can.Map) { + appState = new data(); + } else { + appState = data; + } + can.route.data = appState; + }, + routes: {}, + ready: function (val) { + if (val !== true) { + can.route._setup(); + can.route.setState(); + } + return can.route; + }, + url: function (options, merge) { + if (merge) { + options = can.extend({}, can.route.deparam(can.route._call('matchingPartOfURL')), options); + } + return can.route._call('root') + can.route.param(options); + }, + link: function (name, options, props, merge) { + return '' + name + ''; + }, + current: function (options) { + can.__observe(eventsObject, '__url'); + return this._call('matchingPartOfURL') === can.route.param(options); + }, + bindings: { + hashchange: { + paramsMatcher: paramsMatcher, + querySeparator: '&', + matchSlashes: false, + bind: function () { + can.bind.call(window, 'hashchange', setState); + }, + unbind: function () { + can.unbind.call(window, 'hashchange', setState); + }, + matchingPartOfURL: function () { + return location.href.split(/#!?/)[1] || ''; + }, + setURL: function (path) { + if (location.hash !== '#' + path) { + location.hash = '!' + path; + } + return path; + }, + root: '#!' + } + }, + defaultBinding: 'hashchange', + currentBinding: null, + _setup: function () { + if (!can.route.currentBinding) { + can.route._call('bind'); + can.route.bind('change', onRouteDataChange); + can.route.currentBinding = can.route.defaultBinding; + } + }, + _teardown: function () { + if (can.route.currentBinding) { + can.route._call('unbind'); + can.route.unbind('change', onRouteDataChange); + can.route.currentBinding = null; + } + clearTimeout(timer); + changingData = 0; + }, + _call: function () { + var args = can.makeArray(arguments), prop = args.shift(), binding = can.route.bindings[can.route.currentBinding || can.route.defaultBinding], method = binding[prop]; + if (method.apply) { + return method.apply(binding, args); + } else { + return method; + } + } + }); + each([ + 'bind', + 'unbind', + 'on', + 'off', + 'delegate', + 'undelegate', + 'removeAttr', + 'compute', + '_get', + '__get', + 'each' + ], function (name) { + can.route[name] = function () { + if (!can.route.data[name]) { + return; + } + return can.route.data[name].apply(can.route.data, arguments); + }; + }); + can.route.attr = function (attr, val) { + var type = typeof attr, newArguments; + if (val === undefined) { + newArguments = arguments; + } else if (type !== 'string' && type !== 'number') { + newArguments = [ + stringify(attr), + val + ]; + } else { + newArguments = [ + attr, + stringify(val) + ]; + } + return can.route.data.attr.apply(can.route.data, newArguments); + }; + var setState = can.route.setState = function () { + var hash = can.route._call('matchingPartOfURL'); + var oldParams = curParams; + curParams = can.route.deparam(hash); + if (!changingData || hash !== lastHash) { + can.batch.start(); + recursiveClean(oldParams, curParams, can.route.data); + can.route.attr(curParams); + can.batch.trigger(eventsObject, '__url', [ + hash, + lastHash + ]); + can.batch.stop(); + } + }; + var recursiveClean = function (old, cur, data) { + for (var attr in old) { + if (cur[attr] === undefined) { + data.removeAttr(attr); + } else if (Object.prototype.toString.call(old[attr]) === '[object Object]') { + recursiveClean(old[attr], cur[attr], data.attr(attr)); + } + } + }; + return can.route; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/route/pushstate.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/route/pushstate.js new file mode 100644 index 0000000000..3f31ef0792 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/route/pushstate.js @@ -0,0 +1,125 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#route/pushstate/pushstate*/ +define([ + 'can/util/library', + 'can/route' +], function (can) { + 'use strict'; + if (window.history && history.pushState) { + can.route.bindings.pushstate = { + root: '/', + matchSlashes: false, + paramsMatcher: /^\?(?:[^=]+=[^&]*&)*[^=]+=[^&]*/, + querySeparator: '?', + bind: function () { + can.delegate.call(can.$(document.documentElement), 'a', 'click', anchorClickHandler); + can.each(methodsToOverwrite, function (method) { + originalMethods[method] = window.history[method]; + window.history[method] = function (state, title, url) { + var absolute = url.indexOf('http') === 0; + var searchHash = window.location.search + window.location.hash; + if (!absolute && url !== window.location.pathname + searchHash || absolute && url !== window.location.href + searchHash) { + originalMethods[method].apply(window.history, arguments); + can.route.setState(); + } + }; + }); + can.bind.call(window, 'popstate', can.route.setState); + }, + unbind: function () { + can.undelegate.call(can.$(document.documentElement), 'click', 'a', anchorClickHandler); + can.each(methodsToOverwrite, function (method) { + window.history[method] = originalMethods[method]; + }); + can.unbind.call(window, 'popstate', can.route.setState); + }, + matchingPartOfURL: function () { + var root = cleanRoot(), loc = location.pathname + location.search, index = loc.indexOf(root); + return loc.substr(index + root.length); + }, + setURL: function (path, changed) { + var method = 'pushState'; + if (includeHash && path.indexOf('#') === -1 && window.location.hash) { + path += window.location.hash; + } + if (replaceStateAttrs.length > 0) { + var toRemove = []; + for (var i = 0, l = changed.length; i < l; i++) { + if (can.inArray(changed[i], replaceStateAttrs) !== -1) { + method = 'replaceState'; + } + if (can.inArray(changed[i], replaceStateAttrs.once) !== -1) { + toRemove.push(changed[i]); + } + } + if (toRemove.length > 0) { + removeAttrs(replaceStateAttrs, toRemove); + removeAttrs(replaceStateAttrs.once, toRemove); + } + } + window.history[method](null, null, can.route._call('root') + path); + } + }; + var anchorClickHandler = function (e) { + if (!(e.isDefaultPrevented ? e.isDefaultPrevented() : e.defaultPrevented === true)) { + var node = this._node || this; + var linksHost = node.host || window.location.host; + if (window.location.host === linksHost) { + var root = cleanRoot(); + if (node.pathname.indexOf(root) === 0) { + var url = (node.pathname + node.search).substr(root.length); + var curParams = can.route.deparam(url); + if (curParams.hasOwnProperty('route')) { + includeHash = true; + window.history.pushState(null, null, node.href); + if (e.preventDefault) { + e.preventDefault(); + } + } + } + } + } + }, cleanRoot = function () { + var domain = location.protocol + '//' + location.host, root = can.route._call('root'), index = root.indexOf(domain); + if (index === 0) { + return root.substr(domain.length); + } + return root; + }, removeAttrs = function (arr, attrs) { + var index; + for (var i = attrs.length - 1; i >= 0; i--) { + if ((index = can.inArray(attrs[i], arr)) !== -1) { + arr.splice(index, 1); + } + } + }, methodsToOverwrite = [ + 'pushState', + 'replaceState' + ], originalMethods = {}, includeHash = false, replaceStateAttrs = []; + can.route.defaultBinding = 'pushstate'; + can.extend(can.route, { + replaceStateOn: function () { + var attrs = can.makeArray(arguments); + Array.prototype.push.apply(replaceStateAttrs, attrs); + }, + replaceStateOnce: function () { + var attrs = can.makeArray(arguments); + replaceStateAttrs.once = can.makeArray(replaceStateAttrs.once); + Array.prototype.push.apply(replaceStateAttrs.once, attrs); + can.route.replaceStateOn.apply(this, arguments); + }, + replaceStateOff: function () { + var attrs = can.makeArray(arguments); + removeAttrs(replaceStateAttrs, attrs); + } + }); + } + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/scanner.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/scanner.js new file mode 100644 index 0000000000..90661fe99e --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/scanner.js @@ -0,0 +1,384 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/scanner*/ +define([ + 'can/view', + 'can/elements', + 'can/view/callbacks' +], function (can, elements, viewCallbacks) { + var newLine = /(\r|\n)+/g, notEndTag = /\//, clean = function (content) { + return content.split('\\').join('\\\\').split('\n').join('\\n').split('"').join('\\"').split('\t').join('\\t'); + }, getTag = function (tagName, tokens, i) { + if (tagName) { + return tagName; + } else { + while (i < tokens.length) { + if (tokens[i] === '<' && !notEndTag.test(tokens[i + 1])) { + return elements.reverseTagMap[tokens[i + 1]] || 'span'; + } + i++; + } + } + return ''; + }, bracketNum = function (content) { + return --content.split('{').length - --content.split('}').length; + }, myEval = function (script) { + eval(script); + }, attrReg = /([^\s]+)[\s]*=[\s]*$/, startTxt = 'var ___v1ew = [];', finishTxt = 'return ___v1ew.join(\'\')', put_cmd = '___v1ew.push(\n', insert_cmd = put_cmd, htmlTag = null, quote = null, beforeQuote = null, rescan = null, getAttrName = function () { + var matches = beforeQuote.match(attrReg); + return matches && matches[1]; + }, status = function () { + return quote ? '\'' + getAttrName() + '\'' : htmlTag ? 1 : 0; + }, top = function (stack) { + return stack[stack.length - 1]; + }, Scanner; + can.view.Scanner = Scanner = function (options) { + can.extend(this, { + text: {}, + tokens: [] + }, options); + this.text.options = this.text.options || ''; + this.tokenReg = []; + this.tokenSimple = { + '<': '<', + '>': '>', + '"': '"', + '\'': '\'' + }; + this.tokenComplex = []; + this.tokenMap = {}; + for (var i = 0, token; token = this.tokens[i]; i++) { + if (token[2]) { + this.tokenReg.push(token[2]); + this.tokenComplex.push({ + abbr: token[1], + re: new RegExp(token[2]), + rescan: token[3] + }); + } else { + this.tokenReg.push(token[1]); + this.tokenSimple[token[1]] = token[0]; + } + this.tokenMap[token[0]] = token[1]; + } + this.tokenReg = new RegExp('(' + this.tokenReg.slice(0).concat([ + '<', + '>', + '"', + '\'' + ]).join('|') + ')', 'g'); + }; + Scanner.prototype = { + helpers: [], + scan: function (source, name) { + var tokens = [], last = 0, simple = this.tokenSimple, complex = this.tokenComplex; + source = source.replace(newLine, '\n'); + if (this.transform) { + source = this.transform(source); + } + source.replace(this.tokenReg, function (whole, part) { + var offset = arguments[arguments.length - 2]; + if (offset > last) { + tokens.push(source.substring(last, offset)); + } + if (simple[whole]) { + tokens.push(whole); + } else { + for (var i = 0, token; token = complex[i]; i++) { + if (token.re.test(whole)) { + tokens.push(token.abbr); + if (token.rescan) { + tokens.push(token.rescan(part)); + } + break; + } + } + } + last = offset + part.length; + }); + if (last < source.length) { + tokens.push(source.substr(last)); + } + var content = '', buff = [startTxt + (this.text.start || '')], put = function (content, bonus) { + buff.push(put_cmd, '"', clean(content), '"' + (bonus || '') + ');'); + }, endStack = [], lastToken, startTag = null, magicInTag = false, specialStates = { + attributeHookups: [], + tagHookups: [], + lastTagHookup: '' + }, popTagHookup = function () { + specialStates.lastTagHookup = specialStates.tagHookups.pop() + specialStates.tagHookups.length; + }, tagName = '', tagNames = [], popTagName = false, bracketCount, specialAttribute = false, i = 0, token, tmap = this.tokenMap, attrName; + htmlTag = quote = beforeQuote = null; + for (; (token = tokens[i++]) !== undefined;) { + if (startTag === null) { + switch (token) { + case tmap.left: + case tmap.escapeLeft: + case tmap.returnLeft: + magicInTag = htmlTag && 1; + case tmap.commentLeft: + startTag = token; + if (content.length) { + put(content); + } + content = ''; + break; + case tmap.escapeFull: + magicInTag = htmlTag && 1; + rescan = 1; + startTag = tmap.escapeLeft; + if (content.length) { + put(content); + } + rescan = tokens[i++]; + content = rescan.content || rescan; + if (rescan.before) { + put(rescan.before); + } + tokens.splice(i, 0, tmap.right); + break; + case tmap.commentFull: + break; + case tmap.templateLeft: + content += tmap.left; + break; + case '<': + if (tokens[i].indexOf('!--') !== 0) { + htmlTag = 1; + magicInTag = 0; + } + content += token; + break; + case '>': + htmlTag = 0; + var emptyElement = content.substr(content.length - 1) === '/' || content.substr(content.length - 2) === '--', attrs = ''; + if (specialStates.attributeHookups.length) { + attrs = 'attrs: [\'' + specialStates.attributeHookups.join('\',\'') + '\'], '; + specialStates.attributeHookups = []; + } + if (tagName + specialStates.tagHookups.length !== specialStates.lastTagHookup && tagName === top(specialStates.tagHookups)) { + if (emptyElement) { + content = content.substr(0, content.length - 1); + } + buff.push(put_cmd, '"', clean(content), '"', ',can.view.pending({tagName:\'' + tagName + '\',' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options); + if (emptyElement) { + buff.push('}));'); + content = '/>'; + popTagHookup(); + } else if (tokens[i] === '<' && tokens[i + 1] === '/' + tagName) { + buff.push('}));'); + content = token; + popTagHookup(); + } else { + buff.push(',subtemplate: function(' + this.text.argNames + '){\n' + startTxt + (this.text.start || '')); + content = ''; + } + } else if (magicInTag || !popTagName && elements.tagToContentPropMap[tagNames[tagNames.length - 1]] || attrs) { + var pendingPart = ',can.view.pending({' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options + '}),"'; + if (emptyElement) { + put(content.substr(0, content.length - 1), pendingPart + '/>"'); + } else { + put(content, pendingPart + '>"'); + } + content = ''; + magicInTag = 0; + } else { + content += token; + } + if (emptyElement || popTagName) { + tagNames.pop(); + tagName = tagNames[tagNames.length - 1]; + popTagName = false; + } + specialStates.attributeHookups = []; + break; + case '\'': + case '"': + if (htmlTag) { + if (quote && quote === token) { + quote = null; + var attr = getAttrName(); + if (viewCallbacks.attr(attr)) { + specialStates.attributeHookups.push(attr); + } + if (specialAttribute) { + content += token; + put(content); + buff.push(finishTxt, '}));\n'); + content = ''; + specialAttribute = false; + break; + } + } else if (quote === null) { + quote = token; + beforeQuote = lastToken; + attrName = getAttrName(); + if (tagName === 'img' && attrName === 'src' || attrName === 'style') { + put(content.replace(attrReg, '')); + content = ''; + specialAttribute = true; + buff.push(insert_cmd, 'can.view.txt(2,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt); + put(attrName + '=' + token); + break; + } + } + } + default: + if (lastToken === '<') { + tagName = token.substr(0, 3) === '!--' ? '!--' : token.split(/\s/)[0]; + var isClosingTag = false, cleanedTagName; + if (tagName.indexOf('/') === 0) { + isClosingTag = true; + cleanedTagName = tagName.substr(1); + } + if (isClosingTag) { + if (top(tagNames) === cleanedTagName) { + tagName = cleanedTagName; + popTagName = true; + } + if (top(specialStates.tagHookups) === cleanedTagName) { + put(content.substr(0, content.length - 1)); + buff.push(finishTxt + '}}) );'); + content = '><'; + popTagHookup(); + } + } else { + if (tagName.lastIndexOf('/') === tagName.length - 1) { + tagName = tagName.substr(0, tagName.length - 1); + } + if (tagName !== '!--' && viewCallbacks.tag(tagName)) { + if (tagName === 'content' && elements.tagMap[top(tagNames)]) { + token = token.replace('content', elements.tagMap[top(tagNames)]); + } + specialStates.tagHookups.push(tagName); + } + tagNames.push(tagName); + } + } + content += token; + break; + } + } else { + switch (token) { + case tmap.right: + case tmap.returnRight: + switch (startTag) { + case tmap.left: + bracketCount = bracketNum(content); + if (bracketCount === 1) { + buff.push(insert_cmd, 'can.view.txt(0,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt, content); + endStack.push({ + before: '', + after: finishTxt + '}));\n' + }); + } else { + last = endStack.length && bracketCount === -1 ? endStack.pop() : { after: ';' }; + if (last.before) { + buff.push(last.before); + } + buff.push(content, ';', last.after); + } + break; + case tmap.escapeLeft: + case tmap.returnLeft: + bracketCount = bracketNum(content); + if (bracketCount) { + endStack.push({ + before: finishTxt, + after: '}));\n' + }); + } + var escaped = startTag === tmap.escapeLeft ? 1 : 0, commands = { + insert: insert_cmd, + tagName: getTag(tagName, tokens, i), + status: status(), + specialAttribute: specialAttribute + }; + for (var ii = 0; ii < this.helpers.length; ii++) { + var helper = this.helpers[ii]; + if (helper.name.test(content)) { + content = helper.fn(content, commands); + if (helper.name.source === /^>[\s]*\w*/.source) { + escaped = 0; + } + break; + } + } + if (typeof content === 'object') { + if (content.startTxt && content.end && specialAttribute) { + buff.push(insert_cmd, 'can.view.toStr( ', content.content, '() ) );'); + } else { + if (content.startTxt) { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || (content.escaped != null ? content.escaped : escaped)) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\n'); + } else if (content.startOnlyTxt) { + buff.push(insert_cmd, 'can.view.onlytxt(this,\n'); + } + buff.push(content.content); + if (content.end) { + buff.push('));'); + } + } + } else if (specialAttribute) { + buff.push(insert_cmd, content, ');'); + } else { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || escaped) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\nfunction(){ ' + (this.text.escape || '') + 'return ', content, bracketCount ? startTxt : '}));\n'); + } + if (rescan && rescan.after && rescan.after.length) { + put(rescan.after.length); + rescan = null; + } + break; + } + startTag = null; + content = ''; + break; + case tmap.templateLeft: + content += tmap.left; + break; + default: + content += token; + break; + } + } + lastToken = token; + } + if (content.length) { + put(content); + } + buff.push(';'); + var template = buff.join(''), out = { out: (this.text.outStart || '') + template + ' ' + finishTxt + (this.text.outEnd || '') }; + myEval.call(out, 'this.fn = (function(' + this.text.argNames + '){' + out.out + '});\r\n//# sourceURL=' + name + '.js'); + return out; + } + }; + can.view.pending = function (viewData) { + var hooks = can.view.getHooks(); + return can.view.hook(function (el) { + can.each(hooks, function (fn) { + fn(el); + }); + viewData.templateType = 'legacy'; + if (viewData.tagName) { + viewCallbacks.tagHandler(el, viewData.tagName, viewData); + } + can.each(viewData && viewData.attrs || [], function (attributeName) { + viewData.attributeName = attributeName; + var callback = viewCallbacks.attr(attributeName); + if (callback) { + callback(el, viewData); + } + }); + }); + }; + can.view.tag('content', function (el, tagData) { + return tagData.scope; + }); + can.view.Scanner = Scanner; + return Scanner; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/attr.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/attr.js new file mode 100644 index 0000000000..48345d3627 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/attr.js @@ -0,0 +1,130 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/attr/attr*/ +define(['can/util/can'], function (can) { + var setImmediate = can.global.setImmediate || function (cb) { + return setTimeout(cb, 0); + }, attr = { + MutationObserver: can.global.MutationObserver || can.global.WebKitMutationObserver || can.global.MozMutationObserver, + map: { + 'class': 'className', + 'value': 'value', + 'innertext': 'innerText', + 'textcontent': 'textContent', + 'checked': true, + 'disabled': true, + 'readonly': true, + 'required': true, + src: function (el, val) { + if (val == null || val === '') { + el.removeAttribute('src'); + return null; + } else { + el.setAttribute('src', val); + return val; + } + }, + style: function (el, val) { + return el.style.cssText = val || ''; + } + }, + defaultValue: [ + 'input', + 'textarea' + ], + set: function (el, attrName, val) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var tagName = el.nodeName.toString().toLowerCase(), prop = attr.map[attrName], newValue; + if (typeof prop === 'function') { + newValue = prop(el, val); + } else if (prop === true) { + newValue = el[attrName] = true; + if (attrName === 'checked' && el.type === 'radio') { + if (can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultChecked = true; + } + } + } else if (prop) { + newValue = val; + if (el[prop] !== val) { + el[prop] = val; + } + if (prop === 'value' && can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultValue = val; + } + } else { + el.setAttribute(attrName, val); + newValue = val; + } + if (!attr.MutationObserver && newValue !== oldValue) { + attr.trigger(el, attrName, oldValue); + } + }, + trigger: function (el, attrName, oldValue) { + if (can.data(can.$(el), 'canHasAttributesBindings')) { + attrName = attrName.toLowerCase(); + return setImmediate(function () { + can.trigger(el, { + type: 'attributes', + attributeName: attrName, + target: el, + oldValue: oldValue, + bubbles: false + }, []); + }); + } + }, + get: function (el, attrName) { + attrName = attrName.toLowerCase(); + var prop = attr.map[attrName]; + if (typeof prop === 'string' && el[prop]) { + return el[prop]; + } + return el.getAttribute(attrName); + }, + remove: function (el, attrName) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var setter = attr.map[attrName]; + if (typeof setter === 'function') { + setter(el, undefined); + } + if (setter === true) { + el[attrName] = false; + } else if (typeof setter === 'string') { + el[setter] = ''; + } else { + el.removeAttribute(attrName); + } + if (!attr.MutationObserver && oldValue != null) { + attr.trigger(el, attrName, oldValue); + } + }, + has: function () { + var el = can.global.document && document.createElement('div'); + if (el && el.hasAttribute) { + return function (el, name) { + return el.hasAttribute(name); + }; + } else { + return function (el, name) { + return el.getAttribute(name) !== null; + }; + } + }() + }; + return attr; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/batch.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/batch.js new file mode 100644 index 0000000000..989aedaea5 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/batch.js @@ -0,0 +1,89 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/batch/batch*/ +define(['can/util/can'], function (can) { + var batchNum = 1, transactions = 0, batchEvents = [], stopCallbacks = [], currentBatchEvents = null; + can.batch = { + start: function (batchStopHandler) { + transactions++; + if (batchStopHandler) { + stopCallbacks.push(batchStopHandler); + } + }, + stop: function (force, callStart) { + if (force) { + transactions = 0; + } else { + transactions--; + } + if (transactions === 0) { + if (currentBatchEvents !== null) { + return; + } + currentBatchEvents = batchEvents.slice(0); + var callbacks = stopCallbacks.slice(0), i, len; + batchEvents = []; + stopCallbacks = []; + can.batch.batchNum = batchNum; + batchNum++; + if (callStart) { + can.batch.start(); + } + for (i = 0; i < currentBatchEvents.length; i++) { + can.dispatch.apply(currentBatchEvents[i][0], currentBatchEvents[i][1]); + } + currentBatchEvents = null; + for (i = 0, len = callbacks.length; i < callbacks.length; i++) { + callbacks[i](); + } + can.batch.batchNum = undefined; + } + }, + trigger: function (item, event, args) { + if (!item._init) { + event = typeof event === 'string' ? { type: event } : event; + if (currentBatchEvents) { + currentBatchEvents.push([ + item, + [ + event, + args + ] + ]); + } else if (transactions === 0) { + return can.dispatch.call(item, event, args); + } else { + event.batchNum = batchNum; + batchEvents.push([ + item, + [ + event, + args + ] + ]); + } + } + }, + afterPreviousEvents: function (handler) { + if (currentBatchEvents) { + var obj = {}; + can.bind.call(obj, 'ready', handler); + currentBatchEvents.push([ + obj, + [ + { type: 'ready' }, + [] + ] + ]); + } else { + handler(); + } + } + }; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/bind.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/bind.js new file mode 100644 index 0000000000..4b5faffb8a --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/bind.js @@ -0,0 +1,40 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/bind/bind*/ +define(['can/util/library'], function (can) { + can.bindAndSetup = function () { + can.addEvent.apply(this, arguments); + if (!this._init) { + if (!this._bindings) { + this._bindings = 1; + if (this._bindsetup) { + this._bindsetup(); + } + } else { + this._bindings++; + } + } + return this; + }; + can.unbindAndTeardown = function (event, handler) { + var handlers = this.__bindEvents[event] || []; + var handlerCount = handlers.length; + can.removeEvent.apply(this, arguments); + if (this._bindings === null) { + this._bindings = 0; + } else { + this._bindings = this._bindings - (handlerCount - handlers.length); + } + if (!this._bindings && this._bindteardown) { + this._bindteardown(); + } + return this; + }; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/can.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/can.js new file mode 100644 index 0000000000..28615b0394 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/can.js @@ -0,0 +1,159 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/can*/ +define([], function () { + var glbl = typeof window !== 'undefined' ? window : global; + var can = {}; + if (typeof GLOBALCAN === 'undefined' || GLOBALCAN !== false) { + glbl.can = can; + } + can.global = glbl; + can.k = function () { + }; + can.isDeferred = can.isPromise = function (obj) { + return obj && typeof obj.then === 'function' && typeof obj.pipe === 'function'; + }; + can.isMapLike = function (obj) { + return can.Map && (obj instanceof can.Map || obj && obj.__get); + }; + var cid = 0; + can.cid = function (object, name) { + if (!object._cid) { + cid++; + object._cid = (name || '') + cid; + } + return object._cid; + }; + can.VERSION = '2.2.6'; + can.simpleExtend = function (d, s) { + for (var prop in s) { + d[prop] = s[prop]; + } + return d; + }; + can.last = function (arr) { + return arr && arr[arr.length - 1]; + }; + var protoBind = Function.prototype.bind; + if (protoBind) { + can.proxy = function (fn, context) { + return protoBind.call(fn, context); + }; + } else { + can.proxy = function (fn, context) { + return function () { + return fn.apply(context, arguments); + }; + }; + } + can.frag = function (item) { + var frag; + if (!item || typeof item === 'string') { + frag = can.buildFragment(item == null ? '' : '' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } else if (item.nodeType === 11) { + return item; + } else if (typeof item.nodeType === 'number') { + frag = document.createDocumentFragment(); + frag.appendChild(item); + return frag; + } else if (typeof item.length === 'number') { + frag = document.createDocumentFragment(); + can.each(item, function (item) { + frag.appendChild(can.frag(item)); + }); + return frag; + } else { + frag = can.buildFragment('' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } + }; + can.scope = can.viewModel = function (el, attr, val) { + el = can.$(el); + var scope = can.data(el, 'scope') || can.data(el, 'viewModel'); + if (!scope) { + scope = new can.Map(); + can.data(el, 'scope', scope); + can.data(el, 'viewModel', scope); + } + switch (arguments.length) { + case 0: + case 1: + return scope; + case 2: + return scope.attr(attr); + default: + scope.attr(attr, val); + return el; + } + }; + can['import'] = function (moduleName) { + var deferred = new can.Deferred(); + if (typeof window.System === 'object' && can.isFunction(window.System['import'])) { + window.System['import'](moduleName).then(can.proxy(deferred.resolve, deferred), can.proxy(deferred.reject, deferred)); + } else if (window.define && window.define.amd) { + window.require([moduleName], function (value) { + deferred.resolve(value); + }); + } else if (window.steal) { + steal.steal(moduleName, function (value) { + deferred.resolve(value); + }); + } else if (window.require) { + deferred.resolve(window.require(moduleName)); + } else { + deferred.resolve(); + } + return deferred.promise(); + }; + can.__observe = function () { + }; + can.dev = { + warnTimeout: 5000, + logLevel: 0, + warn: function (out) { + var ll = this.logLevel; + if (ll < 2) { + Array.prototype.unshift.call(arguments, 'WARN:'); + if (typeof window !== undefined && window.console && console.warn) { + this._logger('warn', Array.prototype.slice.call(arguments)); + } else if (window.console && console.log) { + this._logger('log', Array.prototype.slice.call(arguments)); + } else if (window.opera && window.opera.postError) { + window.opera.postError('steal.js WARNING: ' + out); + } + } + }, + log: function (out) { + var ll = this.logLevel; + if (ll < 1) { + if (window.console && console.log) { + Array.prototype.unshift.call(arguments, 'Info:'); + this._logger('log', Array.prototype.slice.call(arguments)); + } else if (window.opera && window.opera.postError) { + window.opera.postError('steal.js INFO: ' + out); + } + } + }, + _logger: function (type, arr) { + if (console.log.apply) { + console[type].apply(console, arr); + } else { + console[type](arr); + } + } + }; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/dojo.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/dojo.js new file mode 100644 index 0000000000..54f715c11a --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/dojo.js @@ -0,0 +1,482 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/dojo/dojo*/ +'format steal'; +define([ + 'can/util/can', + 'can/util/attr', + 'dojo/main', + 'can/event', + 'can/fragment', + 'can/util/each', + 'can/util/object/isplain', + 'can/deferred', + 'can/hashchange', + 'can/util/inserted' +], function (can, attr, djo) { + var dojo = djo || window.dojo; + define('plugd/trigger', ['dojo/main'], function () { + var d = dojo; + var isfn = d.isFunction; + var leaveRe = /mouse(enter|leave)/; + var _fix = function (_, p) { + return 'mouse' + (p === 'enter' ? 'over' : 'out'); + }; + var mix = d._mixin; + var realTrigger; + if (d.doc.createEvent) { + realTrigger = function (n, e, a) { + var ev = d.doc.createEvent('HTMLEvents'); + e = e.replace(leaveRe, _fix); + ev.initEvent(e, e === 'removed' || e === 'inserted' ? false : true, true); + if (a) { + mix(ev, a); + } + n.dispatchEvent(ev); + }; + } else { + realTrigger = function (n, e, a) { + var ev = 'on' + e, stop = false; + try { + var evObj = document.createEventObject(); + if (e === 'inserted' || e === 'removed') { + evObj.cancelBubble = true; + } + mix(evObj, a); + n.fireEvent(ev, evObj); + } catch (er) { + var evdata = mix({ + type: e, + target: n, + faux: true, + _stopper: function () { + stop = this.cancelBubble; + } + }, a); + if (isfn(n[ev])) { + n[ev](evdata); + } + if (e === 'inserted' || e === 'removed') { + return; + } + while (!stop && n !== d.doc && n.parentNode) { + n = n.parentNode; + if (isfn(n[ev])) { + n[ev](evdata); + } + } + } + }; + } + d._trigger = function (node, event, extraArgs) { + if (typeof event !== 'string') { + extraArgs = event; + event = extraArgs.type; + delete extraArgs.type; + } + var n = d.byId(node), ev = event && event.slice(0, 2) === 'on' ? event.slice(2) : event; + realTrigger(n, ev, extraArgs); + }; + d.trigger = function (obj, event, extraArgs) { + return isfn(obj) || isfn(event) || isfn(obj[event]) ? d.hitch.apply(d, arguments)() : d._trigger.apply(d, arguments); + }; + d.NodeList.prototype.trigger = d.NodeList._adaptAsForEach(d._trigger); + if (d._Node && !d._Node.prototype.trigger) { + d.extend(d._Node, { + trigger: function (ev, data) { + d._trigger(this, ev, data); + return this; + } + }); + } + return d.trigger; + }); + require([ + 'dojo/main', + 'dojo/query', + 'plugd/trigger', + 'dojo/NodeList-dom' + ]); + can.trim = function (s) { + return s && dojo.trim(s); + }; + can.makeArray = function (arr) { + var array = []; + dojo.forEach(arr, function (item) { + array.push(item); + }); + return array; + }; + can.isArray = dojo.isArray; + can.inArray = function (item, arr, from) { + return dojo.indexOf(arr, item, from); + }; + can.map = function (arr, fn) { + return dojo.map(can.makeArray(arr || []), fn); + }; + can.extend = function (first) { + if (first === true) { + var args = can.makeArray(arguments); + args.shift(); + return dojo.mixin.apply(dojo, args); + } + return dojo.mixin.apply(dojo, arguments); + }; + can.isEmptyObject = function (object) { + var prop; + for (prop in object) { + break; + } + return prop === undefined; + }; + can.param = function (object) { + var pairs = [], add = function (key, value) { + pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(value)); + }; + for (var name in object) { + can.buildParam(name, object[name], add); + } + return pairs.join('&').replace(/%20/g, '+'); + }; + can.buildParam = function (prefix, obj, add) { + if (can.isArray(obj)) { + for (var i = 0, l = obj.length; i < l; ++i) { + add(prefix + '[]', obj[i]); + } + } else if (dojo.isObject(obj)) { + for (var name in obj) { + can.buildParam(prefix + '[' + name + ']', obj[name], add); + } + } else { + add(prefix, obj); + } + }; + can.proxy = function (func, context) { + return dojo.hitch(context, func); + }; + can.isFunction = function (f) { + return dojo.isFunction(f); + }; + var dojoId = 0, dojoAddBinding = function (nodelist, ev, cb) { + nodelist.forEach(function (node) { + node = new dojo.NodeList(node.nodeName === 'SELECT' ? [node] : node); + var events = can.data(node, 'events'); + if (!events) { + can.data(node, 'events', events = {}); + } + if (!events[ev]) { + events[ev] = {}; + } + if (cb.__bindingsIds === undefined) { + cb.__bindingsIds = dojoId++; + } + events[ev][cb.__bindingsIds] = node.on(ev, cb)[0]; + }); + }, dojoRemoveBinding = function (nodelist, ev, cb) { + nodelist.forEach(function (node) { + var currentNode = new dojo.NodeList(node), events = can.data(currentNode, 'events'); + if (!events) { + return; + } + var handlers = events[ev]; + if (!handlers) { + return; + } + var handler = handlers[cb.__bindingsIds]; + dojo.disconnect(handler); + delete handlers[cb.__bindingsIds]; + if (can.isEmptyObject(handlers)) { + delete events[ev]; + } + }); + }; + can.bind = function (ev, cb) { + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (this.on || this.nodeType) { + dojoAddBinding(new dojo.NodeList(this.nodeName === 'SELECT' ? [this] : this), ev, cb); + } else if (this.addEvent) { + this.addEvent(ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + return this; + }; + can.unbind = function (ev, cb) { + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (this.on || this.nodeType) { + dojoRemoveBinding(new dojo.NodeList(this), ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + return this; + }; + can.on = can.bind; + can.off = can.unbind; + can.trigger = function (item, event, args, bubble) { + if (!(item instanceof dojo.NodeList) && (item.nodeName || item === window)) { + item = can.$(item); + } + if (item.trigger) { + if (bubble === false) { + if (!item[0] || item[0].nodeType === 3) { + return; + } + var connect = item.on(event, function (ev) { + if (ev.stopPropagation) { + ev.stopPropagation(); + } + ev.cancelBubble = true; + if (ev._stopper) { + ev._stopper(); + } + dojo.disconnect(connect); + }); + item.trigger(event, args); + } else { + item.trigger(event, args); + } + } else { + if (typeof event === 'string') { + event = { type: event }; + } + event.target = event.target || item; + can.dispatch.call(item, event, can.makeArray(args)); + } + }; + can.delegate = function (selector, ev, cb) { + if (!selector) { + can.bind.call(this, ev, cb); + } else if (this.on || this.nodeType) { + dojoAddBinding(new dojo.NodeList(this), selector + ':' + ev, cb); + } else if (this.delegate) { + this.delegate(selector, ev, cb); + } else { + can.bind.call(this, ev, cb); + } + return this; + }; + can.undelegate = function (selector, ev, cb) { + if (!selector) { + can.unbind.call(this, ev, cb); + } else if (this.on || this.nodeType) { + dojoRemoveBinding(new dojo.NodeList(this), selector + ':' + ev, cb); + } else if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else { + can.unbind.call(this, ev, cb); + } + return this; + }; + var updateDeferred = function (xhr, d) { + for (var prop in xhr) { + if (typeof d[prop] === 'function') { + d[prop] = function () { + xhr[prop].apply(xhr, arguments); + }; + } else { + d[prop] = prop[xhr]; + } + } + }; + can.ajax = function (options) { + var type = can.capitalize((options.type || 'get').toLowerCase()), method = dojo['xhr' + type]; + var success = options.success, error = options.error, d = new can.Deferred(); + var def = method({ + url: options.url, + handleAs: options.dataType, + sync: !options.async, + headers: options.headers, + content: options.data + }); + def.then(function (data, ioargs) { + updateDeferred(xhr, d); + d.resolve(data, 'success', xhr); + if (success) { + success(data, 'success', xhr); + } + }, function (data, ioargs) { + updateDeferred(xhr, d); + d.reject(xhr, 'error'); + error(xhr, 'error'); + }); + var xhr = def.ioArgs.xhr; + updateDeferred(xhr, d); + return d; + }; + can.$ = function (selector) { + if (selector === window) { + return window; + } + if (typeof selector === 'string') { + return dojo.query(selector); + } else { + return new dojo.NodeList(selector && selector.nodeName ? [selector] : selector); + } + }; + can.append = function (wrapped, html) { + return wrapped.forEach(function (node) { + dojo.place(html, node); + }); + }; + var data = {}, uuid = can.uuid = +new Date(), exp = can.expando = 'can' + uuid; + function getData(node, name) { + var id = node[exp], store = id && data[id]; + return name === undefined ? store || setData(node) : store && store[name]; + } + function setData(node, name, value) { + var id = node[exp] || (node[exp] = ++uuid), store = data[id] || (data[id] = {}); + if (name !== undefined) { + store[name] = value; + } + return store; + } + var cleanData = function (elems) { + var nodes = []; + for (var i = 0, len = elems.length; i < len; i++) { + if (elems[i].nodeType === 1) { + nodes.push(elems[i]); + } + } + can.trigger(new dojo.NodeList(nodes), 'removed', [], false); + i = 0; + for (var elem; (elem = elems[i]) !== undefined; i++) { + var id = elem[exp]; + delete data[id]; + } + }; + can.data = function (wrapped, name, value) { + return value === undefined ? wrapped.length === 0 ? undefined : getData(wrapped[0], name) : wrapped.forEach(function (node) { + setData(node, name, value); + }); + }; + can.cleanData = function (elem, prop) { + var id = elem[exp]; + delete data[id][prop]; + }; + dojo.empty = function (node) { + for (var c; c = node.lastChild;) { + dojo.destroy(c); + } + }; + var destroy = dojo.destroy; + dojo.destroy = function (node) { + node = dojo.byId(node); + var nodes = [node]; + if (node.getElementsByTagName) { + nodes.concat(can.makeArray(node.getElementsByTagName('*'))); + } + cleanData(nodes); + return destroy.apply(dojo, arguments); + }; + var place = dojo.place; + dojo.place = function (node, refNode, position) { + if (typeof node === 'string' && /^\s* 0 ? Array.prototype.concat.apply([], array) : array; + } + can.isArray = function (arr) { + return arr instanceof Array; + }; + can.isFunction = function () { + if (typeof document !== 'undefined' && typeof document.getElementsByTagName('body') === 'function') { + return function (value) { + return Object.prototype.toString.call(value) === '[object Function]'; + }; + } else { + return function (value) { + return typeof value === 'function'; + }; + } + }(); + can.trim = core_trim && !core_trim.call('\uFEFF\xA0') ? function (text) { + return text == null ? '' : core_trim.call(text); + } : function (text) { + return text == null ? '' : (text + '').replace(rtrim, ''); + }; + can.extend = function () { + var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, length = arguments.length, deep = false; + if (typeof target === 'boolean') { + deep = target; + target = arguments[1] || {}; + i = 2; + } + if (typeof target !== 'object' && !can.isFunction(target)) { + target = {}; + } + if (length === i) { + target = this; + --i; + } + for (; i < length; i++) { + if ((options = arguments[i]) != null) { + for (name in options) { + src = target[name]; + copy = options[name]; + if (target === copy) { + continue; + } + if (deep && copy && (can.isPlainObject(copy) || (copyIsArray = can.isArray(copy)))) { + if (copyIsArray) { + copyIsArray = false; + clone = src && can.isArray(src) ? src : []; + } else { + clone = src && can.isPlainObject(src) ? src : {}; + } + target[name] = can.extend(deep, clone, copy); + } else if (copy !== undefined) { + target[name] = copy; + } + } + } + } + return target; + }; + can.map = function (elements, callback) { + var values = [], putValue = function (val, index) { + var value = callback(val, index); + if (value != null) { + values.push(value); + } + }; + if (likeArray(elements)) { + for (var i = 0, l = elements.length; i < l; i++) { + putValue(elements[i], i); + } + } else { + for (var key in elements) { + putValue(elements[key], key); + } + } + return flatten(values); + }; + can.proxy = function (cb, that) { + return function () { + return cb.apply(that, arguments); + }; + }; + can.attr = attr; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/each.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/each.js new file mode 100644 index 0000000000..b3c645fa45 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/each.js @@ -0,0 +1,56 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/array/each*/ +define(['can/util/can'], function (can) { + var isArrayLike = function (obj) { + var length = 'length' in obj && obj.length; + return typeof arr !== 'function' && (length === 0 || typeof length === 'number' && length > 0 && length - 1 in obj); + }; + can.each = function (elements, callback, context) { + var i = 0, key, len, item; + if (elements) { + if (isArrayLike(elements)) { + if (can.List && elements instanceof can.List) { + for (len = elements.attr('length'); i < len; i++) { + item = elements.attr(i); + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } else { + for (len = elements.length; i < len; i++) { + item = elements[i]; + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } + } else if (typeof elements === 'object') { + if (can.Map && elements instanceof can.Map || elements === can.route) { + var keys = can.Map.keys(elements); + for (i = 0, len = keys.length; i < len; i++) { + key = keys[i]; + item = elements.attr(key); + if (callback.call(context || item, item, key, elements) === false) { + break; + } + } + } else { + for (key in elements) { + if (elements.hasOwnProperty(key) && callback.call(context || elements[key], elements[key], key, elements) === false) { + break; + } + } + } + } + } + return elements; + }; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/fixture.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/fixture.js new file mode 100644 index 0000000000..cd57e30fcf --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/fixture.js @@ -0,0 +1,498 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/fixture/fixture*/ +define([ + 'can/util/library', + 'can/util/string', + 'can/util/object' +], function (can) { + if (!can.Object) { + throw new Error('can.fixture depends on can.Object. Please include it before can.fixture.'); + } + var getUrl = function (url) { + if (typeof steal !== 'undefined') { + if (steal.joinURIs) { + var base = steal.config('baseUrl'); + var joined = steal.joinURIs(base, url); + return joined; + } + if (can.isFunction(steal.config)) { + if (steal.System) { + return steal.joinURIs(steal.config('baseURL'), url); + } else { + return steal.config().root.mapJoin(url).toString(); + } + } + return steal.root.join(url).toString(); + } + return (can.fixture.rootUrl || '') + url; + }; + var updateSettings = function (settings, originalOptions) { + if (!can.fixture.on || settings.fixture === false) { + return; + } + var log = function () { + can.dev.log('can/fixture/fixture.js: ' + Array.prototype.slice.call(arguments).join(' ')); + }; + settings.type = settings.type || settings.method || 'GET'; + var data = overwrite(settings); + if (!settings.fixture) { + if (window.location.protocol === 'file:') { + log('ajax request to ' + settings.url + ', no fixture found'); + } + return; + } + if (typeof settings.fixture === 'string' && can.fixture[settings.fixture]) { + settings.fixture = can.fixture[settings.fixture]; + } + if (typeof settings.fixture === 'string') { + var url = settings.fixture; + if (/^\/\//.test(url)) { + url = getUrl(settings.fixture.substr(2)); + } + if (data) { + url = can.sub(url, data); + } + delete settings.fixture; + log('looking for fixture in ' + url); + settings.url = url; + settings.data = null; + settings.type = 'GET'; + if (!settings.error) { + settings.error = function (xhr, error, message) { + throw 'fixtures.js Error ' + error + ' ' + message; + }; + } + } else { + log('using a dynamic fixture for ' + settings.type + ' ' + settings.url); + if (settings.dataTypes) { + settings.dataTypes.splice(0, 0, 'fixture'); + } + if (data && originalOptions) { + originalOptions.data = originalOptions.data || {}; + can.extend(originalOptions.data, data); + } + } + }, extractResponse = function (status, statusText, responses, headers) { + if (typeof status !== 'number') { + headers = statusText; + responses = status; + statusText = 'success'; + status = 200; + } + if (typeof statusText !== 'string') { + headers = responses; + responses = statusText; + statusText = 'success'; + } + if (status >= 400 && status <= 599) { + this.dataType = 'text'; + } + return [ + status, + statusText, + extractResponses(this, responses), + headers + ]; + }, extractResponses = function (settings, responses) { + var next = settings.dataTypes ? settings.dataTypes[0] : settings.dataType || 'json'; + if (!responses || !responses[next]) { + var tmp = {}; + tmp[next] = responses; + responses = tmp; + } + return responses; + }; + if (can.ajaxPrefilter && can.ajaxTransport) { + can.ajaxPrefilter(updateSettings); + can.ajaxTransport('fixture', function (s, original) { + s.dataTypes.shift(); + var timeout, stopped = false; + return { + send: function (headers, callback) { + timeout = setTimeout(function () { + var success = function () { + if (stopped === false) { + callback.apply(null, extractResponse.apply(s, arguments)); + } + }, result = s.fixture(original, success, headers, s); + if (result !== undefined) { + callback(200, 'success', extractResponses(s, result), {}); + } + }, can.fixture.delay); + }, + abort: function () { + stopped = true; + clearTimeout(timeout); + } + }; + }); + } else { + var AJAX = can.ajax; + can.ajax = function (settings) { + updateSettings(settings, settings); + if (settings.fixture) { + var timeout, deferred = new can.Deferred(), stopped = false; + deferred.getResponseHeader = function () { + }; + deferred.then(settings.success, settings.fail); + deferred.abort = function () { + clearTimeout(timeout); + stopped = true; + deferred.reject(deferred); + }; + timeout = setTimeout(function () { + var success = function () { + var response = extractResponse.apply(settings, arguments), status = response[0]; + if ((status >= 200 && status < 300 || status === 304) && stopped === false) { + deferred.resolve(response[2][settings.dataType]); + } else { + deferred.reject(deferred, 'error', response[1]); + } + }, result = settings.fixture(settings, success, settings.headers, settings); + if (result !== undefined) { + deferred.resolve(result); + } + }, can.fixture.delay); + return deferred; + } else { + return AJAX(settings); + } + }; + } + var overwrites = [], find = function (settings, exact) { + for (var i = 0; i < overwrites.length; i++) { + if ($fixture._similar(settings, overwrites[i], exact)) { + return i; + } + } + return -1; + }, overwrite = function (settings) { + var index = find(settings); + if (index > -1) { + settings.fixture = overwrites[index].fixture; + return $fixture._getData(overwrites[index].url, settings.url); + } + }, getId = function (settings) { + var id = settings.data.id; + if (id === undefined && typeof settings.data === 'number') { + id = settings.data; + } + if (id === undefined) { + settings.url.replace(/\/(\d+)(\/|$|\.)/g, function (all, num) { + id = num; + }); + } + if (id === undefined) { + id = settings.url.replace(/\/(\w+)(\/|$|\.)/g, function (all, num) { + if (num !== 'update') { + id = num; + } + }); + } + if (id === undefined) { + id = Math.round(Math.random() * 1000); + } + return id; + }; + var $fixture = can.fixture = function (settings, fixture) { + if (fixture !== undefined) { + if (typeof settings === 'string') { + var matches = settings.match(/(GET|POST|PUT|DELETE) (.+)/i); + if (!matches) { + settings = { url: settings }; + } else { + settings = { + url: matches[2], + type: matches[1] + }; + } + } + var index = find(settings, !!fixture); + if (index > -1) { + overwrites.splice(index, 1); + } + if (fixture == null) { + return; + } + settings.fixture = fixture; + overwrites.push(settings); + } else { + can.each(settings, function (fixture, url) { + $fixture(url, fixture); + }); + } + }; + var replacer = can.replacer; + can.extend(can.fixture, { + _similar: function (settings, overwrite, exact) { + if (exact) { + return can.Object.same(settings, overwrite, { fixture: null }); + } else { + return can.Object.subset(settings, overwrite, can.fixture._compare); + } + }, + _compare: { + url: function (a, b) { + return !!$fixture._getData(b, a); + }, + fixture: null, + type: 'i' + }, + _getData: function (fixtureUrl, url) { + var order = [], fixtureUrlAdjusted = fixtureUrl.replace('.', '\\.').replace('?', '\\?'), res = new RegExp(fixtureUrlAdjusted.replace(replacer, function (whole, part) { + order.push(part); + return '([^/]+)'; + }) + '$').exec(url), data = {}; + if (!res) { + return null; + } + res.shift(); + can.each(order, function (name) { + data[name] = res.shift(); + }); + return data; + }, + store: function (count, make, filter) { + var currentId = 0, findOne = function (id) { + for (var i = 0; i < items.length; i++) { + if (id == items[i].id) { + return items[i]; + } + } + }, methods = {}, types, items, reset; + if (can.isArray(count) && typeof count[0] === 'string') { + types = count; + count = make; + make = filter; + filter = arguments[3]; + } else if (typeof count === 'string') { + types = [ + count + 's', + count + ]; + count = make; + make = filter; + filter = arguments[3]; + } + if (typeof count === 'number') { + items = []; + reset = function () { + items = []; + for (var i = 0; i < count; i++) { + var item = make(i, items); + if (!item.id) { + item.id = i; + } + currentId = Math.max(item.id + 1, currentId + 1) || items.length; + items.push(item); + } + if (can.isArray(types)) { + can.fixture['~' + types[0]] = items; + can.fixture['-' + types[0]] = methods.findAll; + can.fixture['-' + types[1]] = methods.findOne; + can.fixture['-' + types[1] + 'Update'] = methods.update; + can.fixture['-' + types[1] + 'Destroy'] = methods.destroy; + can.fixture['-' + types[1] + 'Create'] = methods.create; + } + }; + } else { + filter = make; + var initialItems = count; + reset = function () { + items = initialItems.slice(0); + }; + } + can.extend(methods, { + findAll: function (request) { + request = request || {}; + var retArr = items.slice(0); + request.data = request.data || {}; + can.each((request.data.order || []).slice(0).reverse(), function (name) { + var split = name.split(' '); + retArr = retArr.sort(function (a, b) { + if (split[1].toUpperCase() !== 'ASC') { + if (a[split[0]] < b[split[0]]) { + return 1; + } else if (a[split[0]] === b[split[0]]) { + return 0; + } else { + return -1; + } + } else { + if (a[split[0]] < b[split[0]]) { + return -1; + } else if (a[split[0]] === b[split[0]]) { + return 0; + } else { + return 1; + } + } + }); + }); + can.each((request.data.group || []).slice(0).reverse(), function (name) { + var split = name.split(' '); + retArr = retArr.sort(function (a, b) { + return a[split[0]] > b[split[0]]; + }); + }); + var offset = parseInt(request.data.offset, 10) || 0, limit = parseInt(request.data.limit, 10) || items.length - offset, i = 0; + for (var param in request.data) { + i = 0; + if (request.data[param] !== undefined && (param.indexOf('Id') !== -1 || param.indexOf('_id') !== -1)) { + while (i < retArr.length) { + if (request.data[param] != retArr[i][param]) { + retArr.splice(i, 1); + } else { + i++; + } + } + } + } + if (typeof filter === 'function') { + i = 0; + while (i < retArr.length) { + if (!filter(retArr[i], request)) { + retArr.splice(i, 1); + } else { + i++; + } + } + } else if (typeof filter === 'object') { + i = 0; + while (i < retArr.length) { + if (!can.Object.subset(retArr[i], request.data, filter)) { + retArr.splice(i, 1); + } else { + i++; + } + } + } + return { + 'count': retArr.length, + 'limit': request.data.limit, + 'offset': request.data.offset, + 'data': retArr.slice(offset, offset + limit) + }; + }, + findOne: function (request, response) { + var item = findOne(getId(request)); + if (typeof item === 'undefined') { + return response(404, 'Requested resource not found'); + } + response(item); + }, + update: function (request, response) { + var id = getId(request), item = findOne(id); + if (typeof item === 'undefined') { + return response(404, 'Requested resource not found'); + } + can.extend(item, request.data); + response({ id: id }, { location: request.url || '/' + getId(request) }); + }, + destroy: function (request, response) { + var id = getId(request), item = findOne(id); + if (typeof item === 'undefined') { + return response(404, 'Requested resource not found'); + } + for (var i = 0; i < items.length; i++) { + if (items[i].id == id) { + items.splice(i, 1); + break; + } + } + return {}; + }, + create: function (settings, response) { + var item = typeof make === 'function' ? make(items.length, items) : {}; + can.extend(item, settings.data); + if (!item.id) { + item.id = currentId++; + } + items.push(item); + response({ id: item.id }, { location: settings.url + '/' + item.id }); + } + }); + reset(); + return can.extend({ + getId: getId, + find: function (settings) { + return findOne(getId(settings)); + }, + reset: reset + }, methods); + }, + rand: function randomize(arr, min, max) { + if (typeof arr === 'number') { + if (typeof min === 'number') { + return arr + Math.floor(Math.random() * (min - arr)); + } else { + return Math.floor(Math.random() * arr); + } + } + var rand = randomize; + if (min === undefined) { + return rand(arr, rand(arr.length + 1)); + } + var res = []; + arr = arr.slice(0); + if (!max) { + max = min; + } + max = min + Math.round(rand(max - min)); + for (var i = 0; i < max; i++) { + res.push(arr.splice(rand(arr.length), 1)[0]); + } + return res; + }, + xhr: function (xhr) { + return can.extend({}, { + abort: can.noop, + getAllResponseHeaders: function () { + return ''; + }, + getResponseHeader: function () { + return ''; + }, + open: can.noop, + overrideMimeType: can.noop, + readyState: 4, + responseText: '', + responseXML: null, + send: can.noop, + setRequestHeader: can.noop, + status: 200, + statusText: 'OK' + }, xhr); + }, + on: true + }); + can.fixture.delay = 200; + can.fixture.rootUrl = getUrl(''); + can.fixture['-handleFunction'] = function (settings) { + if (typeof settings.fixture === 'string' && can.fixture[settings.fixture]) { + settings.fixture = can.fixture[settings.fixture]; + } + if (typeof settings.fixture === 'function') { + setTimeout(function () { + if (settings.success) { + settings.success.apply(null, settings.fixture(settings, 'success')); + } + if (settings.complete) { + settings.complete.apply(null, settings.fixture(settings, 'complete')); + } + }, can.fixture.delay); + return true; + } + return false; + }; + can.fixture.overwrites = overwrites; + can.fixture.make = can.fixture.store; + return can.fixture; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/function.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/function.js new file mode 100644 index 0000000000..169af2b06c --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/function.js @@ -0,0 +1,43 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/function/function*/ +define(['can/util/library'], function (can) { + can.debounce = function (fn, time, context) { + var timeout; + return function () { + var args = arguments; + clearTimeout(timeout); + timeout = setTimeout(can.proxy(function () { + fn.apply(this, args); + }, context || this), time); + }; + }; + can.throttle = function (fn, time, context) { + var run; + return function () { + var args = arguments; + var ctx = context || this; + if (!run) { + run = true; + setTimeout(function () { + fn.apply(ctx, args); + run = false; + }, time); + } + }; + }; + can.defer = function (fn, context) { + var args = arguments; + var ctx = context || this; + setTimeout(function () { + fn.apply(ctx, args); + }, 0); + }; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/inserted.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/inserted.js new file mode 100644 index 0000000000..da1171ab33 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/inserted.js @@ -0,0 +1,55 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/inserted/inserted*/ +define(['can/util/can'], function (can) { + can.inserted = function (elems) { + elems = can.makeArray(elems); + var inDocument = false, doc = can.$(document.contains ? document : document.body), children; + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + if (!inDocument) { + if (elem.getElementsByTagName) { + if (can.has(doc, elem).length) { + inDocument = true; + } else { + return; + } + } else { + continue; + } + } + if (inDocument && elem.getElementsByTagName) { + children = can.makeArray(elem.getElementsByTagName('*')); + can.trigger(elem, 'inserted', [], false); + for (var j = 0, child; (child = children[j]) !== undefined; j++) { + can.trigger(child, 'inserted', [], false); + } + } + } + }; + can.appendChild = function (el, child) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.appendChild(child); + can.inserted(children); + }; + can.insertBefore = function (el, child, ref) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.insertBefore(child, ref); + can.inserted(children); + }; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/jquery.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/jquery.js new file mode 100644 index 0000000000..bccefbfa1a --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/jquery.js @@ -0,0 +1,229 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/jquery/jquery*/ +define([ + 'jquery', + 'can/util/can', + 'can/util/attr', + 'can/event', + 'can/util/each', + 'can/util/inserted' +], function ($, can, attr, event) { + var isBindableElement = function (node) { + return node.nodeName && (node.nodeType === 1 || node.nodeType === 9) || node == window; + }; + $ = $ || window.jQuery; + $.extend(can, $, { + trigger: function (obj, event, args, bubbles) { + if (isBindableElement(obj)) { + $.event.trigger(event, args, obj, !bubbles); + } else if (obj.trigger) { + obj.trigger(event, args); + } else { + if (typeof event === 'string') { + event = { type: event }; + } + event.target = event.target || obj; + if (args) { + if (args.length && typeof args === 'string') { + args = [args]; + } else if (!args.length) { + args = [args]; + } + } + if (!args) { + args = []; + } + can.dispatch.call(obj, event, args); + } + }, + event: can.event, + addEvent: can.addEvent, + removeEvent: can.removeEvent, + buildFragment: function (elems, context) { + var ret; + elems = [elems]; + context = context || document; + context = !context.nodeType && context[0] || context; + context = context.ownerDocument || context; + ret = $.buildFragment(elems, context); + return ret.cacheable ? $.clone(ret.fragment) : ret.fragment || ret; + }, + $: $, + each: can.each, + bind: function (ev, cb) { + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (isBindableElement(this)) { + $.event.add(this, ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + return this; + }, + unbind: function (ev, cb) { + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (isBindableElement(this)) { + $.event.remove(this, ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + return this; + }, + delegate: function (selector, ev, cb) { + if (this.delegate) { + this.delegate(selector, ev, cb); + } else if (isBindableElement(this)) { + $(this).delegate(selector, ev, cb); + } else { + can.bind.call(this, ev, cb); + } + return this; + }, + undelegate: function (selector, ev, cb) { + if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else if (isBindableElement(this)) { + $(this).undelegate(selector, ev, cb); + } else { + can.unbind.call(this, ev, cb); + } + return this; + }, + proxy: can.proxy, + attr: attr + }); + can.on = can.bind; + can.off = can.unbind; + $.each([ + 'append', + 'filter', + 'addClass', + 'remove', + 'data', + 'get', + 'has' + ], function (i, name) { + can[name] = function (wrapped) { + return wrapped[name].apply(wrapped, can.makeArray(arguments).slice(1)); + }; + }); + var oldClean = $.cleanData; + $.cleanData = function (elems) { + $.each(elems, function (i, elem) { + if (elem) { + can.trigger(elem, 'removed', [], false); + } + }); + oldClean(elems); + }; + var oldDomManip = $.fn.domManip, cbIndex; + $.fn.domManip = function (args, cb1, cb2) { + for (var i = 1; i < arguments.length; i++) { + if (typeof arguments[i] === 'function') { + cbIndex = i; + break; + } + } + return oldDomManip.apply(this, arguments); + }; + $(document.createElement('div')).append(document.createElement('div')); + $.fn.domManip = cbIndex === 2 ? function (args, table, callback) { + return oldDomManip.call(this, args, table, function (elem) { + var elems; + if (elem.nodeType === 11) { + elems = can.makeArray(elem.childNodes); + } + var ret = callback.apply(this, arguments); + can.inserted(elems ? elems : [elem]); + return ret; + }); + } : function (args, callback) { + return oldDomManip.call(this, args, function (elem) { + var elems; + if (elem.nodeType === 11) { + elems = can.makeArray(elem.childNodes); + } + var ret = callback.apply(this, arguments); + can.inserted(elems ? elems : [elem]); + return ret; + }); + }; + if (!can.attr.MutationObserver) { + var oldAttr = $.attr; + $.attr = function (el, attrName) { + var oldValue, newValue; + if (arguments.length >= 3) { + oldValue = oldAttr.call(this, el, attrName); + } + var res = oldAttr.apply(this, arguments); + if (arguments.length >= 3) { + newValue = oldAttr.call(this, el, attrName); + } + if (newValue !== oldValue) { + can.attr.trigger(el, attrName, oldValue); + } + return res; + }; + var oldRemove = $.removeAttr; + $.removeAttr = function (el, attrName) { + var oldValue = oldAttr.call(this, el, attrName), res = oldRemove.apply(this, arguments); + if (oldValue != null) { + can.attr.trigger(el, attrName, oldValue); + } + return res; + }; + $.event.special.attributes = { + setup: function () { + can.data(can.$(this), 'canHasAttributesBindings', true); + }, + teardown: function () { + $.removeData(this, 'canHasAttributesBindings'); + } + }; + } else { + $.event.special.attributes = { + setup: function () { + var self = this; + var observer = new can.attr.MutationObserver(function (mutations) { + mutations.forEach(function (mutation) { + var copy = can.simpleExtend({}, mutation); + can.trigger(self, copy, []); + }); + }); + observer.observe(this, { + attributes: true, + attributeOldValue: true + }); + can.data(can.$(this), 'canAttributesObserver', observer); + }, + teardown: function () { + can.data(can.$(this), 'canAttributesObserver').disconnect(); + $.removeData(this, 'canAttributesObserver'); + } + }; + } + (function () { + var text = '<-\n>', frag = can.buildFragment(text, document); + if (text !== frag.childNodes[0].nodeValue) { + var oldBuildFragment = can.buildFragment; + can.buildFragment = function (content, context) { + var res = oldBuildFragment(content, context); + if (res.childNodes.length === 1 && res.childNodes[0].nodeType === 3) { + res.childNodes[0].nodeValue = content; + } + return res; + }; + } + }()); + $.event.special.inserted = {}; + $.event.special.removed = {}; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/library.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/library.js new file mode 100644 index 0000000000..53e885cd91 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/library.js @@ -0,0 +1,12 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/library*/ +define(['can/util/jquery'], function (can) { + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/makeArray.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/makeArray.js new file mode 100644 index 0000000000..f3b4ccfe94 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/makeArray.js @@ -0,0 +1,19 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/array/makeArray*/ +define(['can/util/each'], function (can) { + can.makeArray = function (arr) { + var ret = []; + can.each(arr, function (a, i) { + ret[i] = a; + }); + return ret; + }; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/mootools.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/mootools.js new file mode 100644 index 0000000000..be95c1be11 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/mootools.js @@ -0,0 +1,355 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/mootools/mootools*/ +define([ + 'can/util/can', + 'can/util/attr', + 'mootools', + 'can/event', + 'can/fragment', + 'can/deferred', + 'can/util/each', + 'can/util/object/isplain', + 'can/util/inserted' +], function (can, attr) { + can.trim = function (s) { + return s ? s.trim() : s; + }; + var extend = function () { + var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, length = arguments.length, deep = false; + if (typeof target === 'boolean') { + deep = target; + target = arguments[1] || {}; + i = 2; + } + if (typeof target !== 'object' && !can.isFunction(target)) { + target = {}; + } + if (length === i) { + target = this; + --i; + } + for (; i < length; i++) { + if ((options = arguments[i]) !== null) { + for (name in options) { + src = target[name]; + copy = options[name]; + if (target === copy) { + continue; + } + if (deep && copy && (can.isPlainObject(copy) || (copyIsArray = can.isArray(copy)))) { + if (copyIsArray) { + copyIsArray = false; + clone = src && can.isArray(src) ? src : []; + } else { + clone = src && can.isPlainObject(src) ? src : {}; + } + target[name] = can.extend(deep, clone, copy); + } else if (copy !== undefined) { + target[name] = copy; + } + } + } + } + return target; + }; + can.extend = extend; + can.makeArray = function (item) { + if (item === null) { + return []; + } + try { + return Type.isEnumerable(item) && typeof item !== 'string' ? Array.prototype.slice.call(item) : [item]; + } catch (ex) { + var arr = [], i; + for (i = 0; i < item.length; ++i) { + arr.push(item[i]); + } + return arr; + } + }; + can.isArray = function (arr) { + return typeOf(arr) === 'array'; + }; + can.inArray = function (item, arr, fromIndex) { + if (!arr) { + return -1; + } + return Array.prototype.indexOf.call(arr, item, fromIndex); + }; + can.map = function (arr, fn) { + return Array.from(arr || []).map(fn); + }; + can.param = function (object) { + return Object.toQueryString(object); + }; + can.isEmptyObject = function (object) { + return Object.keys(object).length === 0; + }; + can.isFunction = function (f) { + return typeOf(f) === 'function'; + }; + can.bind = function (ev, cb) { + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (this.nodeName && (this.nodeType && this.nodeType !== 11)) { + can.$(this).addEvent(ev, cb); + } else if (this.addEvent) { + this.addEvent(ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + return this; + }; + can.unbind = function (ev, cb) { + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (this.nodeName && (this.nodeType && this.nodeType !== 11)) { + can.$(this).removeEvent(ev, cb); + } else if (this.removeEvent) { + this.removeEvent(ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + return this; + }; + can.on = can.bind; + can.off = can.unbind; + can.trigger = function (item, event, args, bubble) { + bubble = bubble === undefined ? true : bubble; + args = args || []; + var propagating = true; + if (item.fireEvent) { + item = item[0] || item; + while (item && propagating) { + if (!event.type) { + event = { + type: event, + target: item, + stopPropagation: function () { + propagating = false; + } + }; + } + var events = item !== window ? can.$(item).retrieve('events')[0] : item.retrieve('events'); + if (events && events[event.type]) { + events[event.type].keys.each(function (fn) { + fn.apply(item, [event].concat(args)); + }, this); + } + if (bubble && item.parentNode && item.parentNode.nodeType !== 11) { + item = item.parentNode; + } else { + item = null; + } + } + } else { + if (typeof event === 'string') { + event = { type: event }; + } + event.target = event.target || item; + can.dispatch.call(item, event, can.makeArray(args)); + } + }; + can.delegate = function (selector, ev, cb) { + if (this.delegate) { + this.delegate(selector, ev, cb); + } else if (this.addEvent) { + this.addEvent(ev + ':relay(' + selector + ')', cb); + } else { + can.bind.call(this, ev, cb); + } + return this; + }; + can.undelegate = function (selector, ev, cb) { + if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else if (this.removeEvent) { + this.removeEvent(ev + ':relay(' + selector + ')', cb); + } else { + can.unbind.call(this, ev, cb); + } + return this; + }; + var optionsMap = { + type: 'method', + success: undefined, + error: undefined + }; + var updateDeferred = function (xhr, d) { + for (var prop in xhr) { + if (typeof d[prop] === 'function') { + d[prop] = function () { + xhr[prop].apply(xhr, arguments); + }; + } else { + d[prop] = prop[xhr]; + } + } + }; + can.ajax = function (options) { + var d = can.Deferred(), requestOptions = can.extend({}, options), request; + for (var option in optionsMap) { + if (requestOptions[option] !== undefined) { + requestOptions[optionsMap[option]] = requestOptions[option]; + delete requestOptions[option]; + } + } + requestOptions.method = requestOptions.method || 'get'; + requestOptions.url = requestOptions.url.toString(); + var success = options.onSuccess || options.success, error = options.onFailure || options.error; + requestOptions.onSuccess = function (response, xml) { + var data = response; + updateDeferred(request.xhr, d); + d.resolve(data, 'success', request.xhr); + if (success) { + success(data, 'success', request.xhr); + } + }; + requestOptions.onFailure = function () { + updateDeferred(request.xhr, d); + d.reject(request.xhr, 'error'); + if (error) { + error(request.xhr, 'error'); + } + }; + if (options.dataType === 'json') { + request = new Request.JSON(requestOptions); + } else { + request = new Request(requestOptions); + } + request.send(); + updateDeferred(request.xhr, d); + return d; + }; + can.$ = function (selector) { + if (selector === window) { + return window; + } + return $$(selector && selector.nodeName ? [selector] : selector); + }; + var old = document.id; + document.id = function (el) { + if (el && el.nodeType === 11) { + return el; + } else { + return old.apply(document, arguments); + } + }; + can.append = function (wrapped, html) { + if (typeof html === 'string') { + html = can.buildFragment(html); + } + return wrapped.grab(html); + }; + can.filter = function (wrapped, filter) { + return wrapped.filter(filter); + }; + can.data = function (wrapped, key, value) { + if (value === undefined) { + return wrapped[0].retrieve(key); + } else { + return wrapped.store(key, value); + } + }; + can.addClass = function (wrapped, className) { + return wrapped.addClass(className); + }; + can.remove = function (wrapped) { + var filtered = wrapped.filter(function (node) { + if (node.nodeType !== 1) { + node.parentNode.removeChild(node); + } else { + return true; + } + }); + filtered.destroy(); + return filtered; + }; + can.has = function (wrapped, element) { + if (Slick.contains(wrapped[0], element)) { + return wrapped; + } else { + return []; + } + }; + var destroy = Element.prototype.destroy, grab = Element.prototype.grab, oldSet = Element.prototype.set; + Element.implement({ + destroy: function () { + can.trigger(this, 'removed', [], false); + var elems = this.getElementsByTagName('*'); + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + can.trigger(elem, 'removed', [], false); + } + destroy.apply(this, arguments); + }, + grab: function (el) { + var elems; + if (el && el.nodeType === 11) { + elems = can.makeArray(el.childNodes); + } else { + elems = [el]; + } + var ret = grab.apply(this, arguments); + can.inserted(elems); + return ret; + }, + set: function (attrName, value) { + var isAttributeOrProp = can.inArray(attrName, [ + 'events', + 'html', + 'load', + 'morph', + 'send', + 'tag', + 'tween' + ]) === -1, newValue, oldValue; + if (isAttributeOrProp) { + oldValue = this.get(attrName); + } + var res = oldSet.apply(this, arguments); + if (isAttributeOrProp) { + newValue = this.get(attrName); + } + if (newValue !== oldValue) { + can.attr.trigger(this, attrName, oldValue); + } + return res; + }.overloadSetter() + }); + can.get = function (wrapped, index) { + return wrapped[index]; + }; + var idOf = Slick.uidOf; + Slick.uidOf = function (node) { + if (node.nodeType === 1 || node === window || node.document === document) { + return idOf(node); + } else { + return Math.random(); + } + }; + Element.NativeEvents.hashchange = 2; + can.attr = attr; + delete attr.MutationObserver; + Element.Events.attributes = { + onAdd: function () { + var el = can.$(this); + can.data(el, 'canHasAttributesBindings', (can.data(el, 'canHasAttributesBindings') || 0) + 1); + }, + onRemove: function () { + var el = can.$(this), cur = can.data(el, 'canHasAttributesBindings') || 0; + if (cur <= 0) { + can.cleanData(el, 'canHasAttributesBindings'); + } else { + can.data(el, 'canHasAttributesBindings', cur - 1); + } + } + }; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/object.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/object.js new file mode 100644 index 0000000000..2f5aa9d0e7 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/object.js @@ -0,0 +1,102 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/object/object*/ +define(['can/util/library'], function (can) { + var isArray = can.isArray; + can.Object = {}; + var same = can.Object.same = function (a, b, compares, aParent, bParent, deep) { + var aType = typeof a, aArray = isArray(a), comparesType = typeof compares, compare; + if (comparesType === 'string' || compares === null) { + compares = compareMethods[compares]; + comparesType = 'function'; + } + if (comparesType === 'function') { + return compares(a, b, aParent, bParent); + } + compares = compares || {}; + if (a === null || b === null) { + return a === b; + } + if (a instanceof Date || b instanceof Date) { + return a === b; + } + if (deep === -1) { + return aType === 'object' || a === b; + } + if (aType !== typeof b || aArray !== isArray(b)) { + return false; + } + if (a === b) { + return true; + } + if (aArray) { + if (a.length !== b.length) { + return false; + } + for (var i = 0; i < a.length; i++) { + compare = compares[i] === undefined ? compares['*'] : compares[i]; + if (!same(a[i], b[i], a, b, compare)) { + return false; + } + } + return true; + } else if (aType === 'object' || aType === 'function') { + var bCopy = can.extend({}, b); + for (var prop in a) { + compare = compares[prop] === undefined ? compares['*'] : compares[prop]; + if (!same(a[prop], b[prop], compare, a, b, deep === false ? -1 : undefined)) { + return false; + } + delete bCopy[prop]; + } + for (prop in bCopy) { + if (compares[prop] === undefined || !same(undefined, b[prop], compares[prop], a, b, deep === false ? -1 : undefined)) { + return false; + } + } + return true; + } + return false; + }; + can.Object.subsets = function (checkSet, sets, compares) { + var len = sets.length, subsets = []; + for (var i = 0; i < len; i++) { + var set = sets[i]; + if (can.Object.subset(checkSet, set, compares)) { + subsets.push(set); + } + } + return subsets; + }; + can.Object.subset = function (subset, set, compares) { + compares = compares || {}; + for (var prop in set) { + if (!same(subset[prop], set[prop], compares[prop], subset, set)) { + return false; + } + } + return true; + }; + var compareMethods = { + 'null': function () { + return true; + }, + i: function (a, b) { + return ('' + a).toLowerCase() === ('' + b).toLowerCase(); + }, + eq: function (a, b) { + return a === b; + }, + similar: function (a, b) { + return a == b; + } + }; + compareMethods.eqeq = compareMethods.similar; + return can.Object; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/object/isplain.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/object/isplain.js new file mode 100644 index 0000000000..f949a00ee8 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/object/isplain.js @@ -0,0 +1,31 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/object/isplain/isplain*/ +define(['can/util/can'], function () { + var core_hasOwn = Object.prototype.hasOwnProperty, isWindow = function (obj) { + return obj !== null && obj == obj.window; + }, isPlainObject = function (obj) { + if (!obj || typeof obj !== 'object' || obj.nodeType || isWindow(obj)) { + return false; + } + try { + if (obj.constructor && !core_hasOwn.call(obj, 'constructor') && !core_hasOwn.call(obj.constructor.prototype, 'isPrototypeOf')) { + return false; + } + } catch (e) { + return false; + } + var key; + for (key in obj) { + } + return key === undefined || core_hasOwn.call(obj, key); + }; + can.isPlainObject = isPlainObject; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/string.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/string.js new file mode 100644 index 0000000000..d9fd21bb17 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/string.js @@ -0,0 +1,93 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/string/string*/ +define(['can/util/library'], function (can) { + var strUndHash = /_|-/, strColons = /\=\=/, strWords = /([A-Z]+)([A-Z][a-z])/g, strLowUp = /([a-z\d])([A-Z])/g, strDash = /([a-z\d])([A-Z])/g, strReplacer = /\{([^\}]+)\}/g, strQuote = /"/g, strSingleQuote = /'/g, strHyphenMatch = /-+(.)?/g, strCamelMatch = /[a-z][A-Z]/g, getNext = function (obj, prop, add) { + var result = obj[prop]; + if (result === undefined && add === true) { + result = obj[prop] = {}; + } + return result; + }, isContainer = function (current) { + return /^f|^o/.test(typeof current); + }, convertBadValues = function (content) { + var isInvalid = content === null || content === undefined || isNaN(content) && '' + content === 'NaN'; + return '' + (isInvalid ? '' : content); + }; + can.extend(can, { + esc: function (content) { + return convertBadValues(content).replace(/&/g, '&').replace(//g, '>').replace(strQuote, '"').replace(strSingleQuote, '''); + }, + getObject: function (name, roots, add) { + var parts = name ? name.split('.') : [], length = parts.length, current, r = 0, i, container, rootsLength; + roots = can.isArray(roots) ? roots : [roots || window]; + rootsLength = roots.length; + if (!length) { + return roots[0]; + } + for (r; r < rootsLength; r++) { + current = roots[r]; + container = undefined; + for (i = 0; i < length && isContainer(current); i++) { + container = current; + current = getNext(container, parts[i]); + } + if (container !== undefined && current !== undefined) { + break; + } + } + if (add === false && current !== undefined) { + delete container[parts[i - 1]]; + } + if (add === true && current === undefined) { + current = roots[0]; + for (i = 0; i < length && isContainer(current); i++) { + current = getNext(current, parts[i], true); + } + } + return current; + }, + capitalize: function (s, cache) { + return s.charAt(0).toUpperCase() + s.slice(1); + }, + camelize: function (str) { + return convertBadValues(str).replace(strHyphenMatch, function (match, chr) { + return chr ? chr.toUpperCase() : ''; + }); + }, + hyphenate: function (str) { + return convertBadValues(str).replace(strCamelMatch, function (str, offset) { + return str.charAt(0) + '-' + str.charAt(1).toLowerCase(); + }); + }, + underscore: function (s) { + return s.replace(strColons, '/').replace(strWords, '$1_$2').replace(strLowUp, '$1_$2').replace(strDash, '_').toLowerCase(); + }, + sub: function (str, data, remove) { + var obs = []; + str = str || ''; + obs.push(str.replace(strReplacer, function (whole, inside) { + var ob = can.getObject(inside, data, remove === true ? false : undefined); + if (ob === undefined || ob === null) { + obs = null; + return ''; + } + if (isContainer(ob) && obs) { + obs.push(ob); + return ''; + } + return '' + ob; + })); + return obs === null ? obs : obs.length <= 1 ? obs[0] : obs; + }, + replacer: strReplacer, + undHash: strUndHash + }); + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/string/deparam.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/string/deparam.js new file mode 100644 index 0000000000..b38284a65a --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/string/deparam.js @@ -0,0 +1,45 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/string/deparam/deparam*/ +define([ + 'can/util/library', + 'can/util/string' +], function (can) { + var digitTest = /^\d+$/, keyBreaker = /([^\[\]]+)|(\[\])/g, paramTest = /([^?#]*)(#.*)?$/, prep = function (str) { + return decodeURIComponent(str.replace(/\+/g, ' ')); + }; + can.extend(can, { + deparam: function (params) { + var data = {}, pairs, lastPart; + if (params && paramTest.test(params)) { + pairs = params.split('&'); + can.each(pairs, function (pair) { + var parts = pair.split('='), key = prep(parts.shift()), value = prep(parts.join('=')), current = data; + if (key) { + parts = key.match(keyBreaker); + for (var j = 0, l = parts.length - 1; j < l; j++) { + if (!current[parts[j]]) { + current[parts[j]] = digitTest.test(parts[j + 1]) || parts[j + 1] === '[]' ? [] : {}; + } + current = current[parts[j]]; + } + lastPart = parts.pop(); + if (lastPart === '[]') { + current.push(value); + } else { + current[lastPart] = value; + } + } + }); + } + return data; + } + }); + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/tests.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/tests.js new file mode 100644 index 0000000000..9574e66fb3 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/tests.js @@ -0,0 +1,15 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/tests/tests*/ +define([ + 'can/util/string', + 'can/util/inserted', + 'can/util/attr', + 'can/util/each' +]); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/yui.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/yui.js new file mode 100644 index 0000000000..e3afd253e6 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/yui.js @@ -0,0 +1,413 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/yui/yui*/ +define([ + 'can/util/can', + 'can/util/attr', + 'yui', + 'can/event', + 'can/fragment', + 'can/util/each', + 'can/util/object/isplain', + 'can/deferred', + 'can/hashchange', + 'can/util/inserted' +], function (can, attr, YUI) { + YUI = YUI || window.YUI; + YUI.add('can-modifications', function (Y, NAME) { + var addHTML = Y.DOM.addHTML; + Y.DOM.addHTML = function (node, content, where) { + if (typeof content === 'string' || typeof content === 'number') { + content = can.buildFragment(content); + } + var elems; + if (content.nodeType === 11) { + elems = can.makeArray(content.childNodes); + } else { + elems = [content]; + } + var ret = addHTML.call(this, node, content, where); + can.inserted(elems); + return ret; + }; + var oldOn = Y.Node.prototype.on; + Y.Node.prototype.on = function (type, fn) { + if (type === 'attributes') { + var el = can.$(this); + can.data(el, 'canHasAttributesBindings', (can.data(el, 'canHasAttributesBindings') || 0) + 1); + var handle = oldOn.apply(this, arguments), oldDetach = handle.detach; + handle.detach = function () { + var cur = can.data(el, 'canHasAttributesBindings') || 0; + if (cur <= 0) { + can.cleanData(el, 'canHasAttributesBindings'); + } else { + can.data(el, 'canHasAttributesBindings', cur - 1); + } + return oldDetach.apply(this, arguments); + }; + return handle; + } else { + return oldOn.apply(this, arguments); + } + }; + }, '3.7.3', { 'requires': ['node-base'] }); + var Y = can.Y = can.Y || YUI().use('*'); + can.trim = function (s) { + return Y.Lang.trim(s); + }; + can.makeArray = function (arr) { + if (!arr) { + return []; + } + return Y.Array(arr); + }; + can.isArray = Y.Lang.isArray; + can.inArray = function (item, arr, fromIndex) { + if (!arr) { + return -1; + } + return Y.Array.indexOf(arr, item, fromIndex); + }; + can.map = function (arr, fn) { + return Y.Array.map(can.makeArray(arr || []), fn); + }; + can.extend = function (first) { + var deep = first === true ? 1 : 0, target = arguments[deep], i = deep + 1, arg; + for (; arg = arguments[i]; i++) { + Y.mix(target, arg, true, null, null, !!deep); + } + return target; + }; + can.param = function (object) { + return Y.QueryString.stringify(object, { arrayKey: true }); + }; + can.isEmptyObject = function (object) { + return Y.Object.isEmpty(object); + }; + can.proxy = function (func, context) { + return Y.bind.apply(Y, arguments); + }; + can.isFunction = function (f) { + return Y.Lang.isFunction(f); + }; + var prepareNodeList = function (nodelist) { + nodelist.each(function (node, i) { + nodelist[i] = node.getDOMNode(); + }); + nodelist.length = nodelist.size(); + return nodelist; + }; + can.$ = function (selector) { + if (selector === window) { + return window; + } else if (selector instanceof Y.NodeList) { + return prepareNodeList(selector); + } else if (typeof selector === 'object' && !can.isArray(selector) && typeof selector.nodeType === 'undefined' && !selector.getDOMNode) { + return new Y.NodeList(selector); + } else { + return prepareNodeList(Y.all(selector)); + } + }; + can.get = function (wrapped, index) { + return wrapped._nodes[index]; + }; + can.append = function (wrapped, html) { + wrapped.each(function (node) { + if (typeof html === 'string') { + html = can.buildFragment(html, node); + } + node.append(html); + }); + }; + can.addClass = function (wrapped, className) { + return wrapped.addClass(className); + }; + can.data = function (wrapped, key, value) { + if (!wrapped.item(0)) { + return; + } + if (value === undefined) { + return wrapped.item(0).getData(key); + } else { + return wrapped.item(0).setData(key, value); + } + }; + can.remove = function (wrapped) { + return wrapped.remove() && wrapped.destroy(); + }; + can.has = function (wrapped, node) { + if (Y.DOM.contains(wrapped[0], node)) { + return wrapped; + } else { + return []; + } + }; + can._yNodeRemove = can._yNodeRemove || Y.Node.prototype.remove; + Y.Node.prototype.remove = function () { + var node = this.getDOMNode(); + if (node.nodeType === 1) { + can.trigger(this, 'removed', [], false); + var elems = node.getElementsByTagName('*'); + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + can.trigger(elem, 'removed', [], false); + } + } + can._yNodeRemove.apply(this, arguments); + }; + Y.NodeList.addMethod('remove', Y.Node.prototype.remove); + var optionsMap = { + type: 'method', + success: undefined, + error: undefined + }; + var updateDeferred = function (request, d) { + if (request && request.io) { + var xhr = request.io; + for (var prop in xhr) { + if (typeof d[prop] === 'function') { + d[prop] = function () { + xhr[prop].apply(xhr, arguments); + }; + } else { + d[prop] = prop[xhr]; + } + } + } + }; + can.ajax = function (options) { + var d = can.Deferred(), requestOptions = can.extend({}, options); + for (var option in optionsMap) { + if (requestOptions[option] !== undefined) { + requestOptions[optionsMap[option]] = requestOptions[option]; + delete requestOptions[option]; + } + } + requestOptions.sync = !options.async; + var success = options.success, error = options.error; + requestOptions.on = { + success: function (transactionid, response) { + var data = response.responseText; + if (options.dataType === 'json') { + data = eval('(' + data + ')'); + } + updateDeferred(request, d); + d.resolve(data); + if (success) { + success(data, 'success', request); + } + }, + failure: function (transactionid, response) { + updateDeferred(request, d); + d.reject(request, 'error'); + if (error) { + error(request, 'error'); + } + } + }; + var request = Y.io(requestOptions.url, requestOptions); + updateDeferred(request, d); + return d; + }; + var yuiEventId = 0, addBinding = function (nodelist, selector, ev, cb) { + if (nodelist instanceof Y.NodeList || !nodelist.on || nodelist.getDOMNode) { + nodelist.each(function (node) { + node = can.$(node); + var events = can.data(node, 'events'), eventName = ev + ':' + selector; + if (!events) { + can.data(node, 'events', events = {}); + } + if (!events[eventName]) { + events[eventName] = {}; + } + if (cb.__bindingsIds === undefined) { + cb.__bindingsIds = yuiEventId++; + } + events[eventName][cb.__bindingsIds] = selector ? node.item(0).delegate(ev, cb, selector) : node.item(0).on(ev, cb); + }); + } else { + var obj = nodelist, events = obj.__canEvents = obj.__canEvents || {}; + if (!events[ev]) { + events[ev] = {}; + } + if (cb.__bindingsIds === undefined) { + cb.__bindingsIds = yuiEventId++; + } + events[ev][cb.__bindingsIds] = obj.on(ev, cb); + } + }, removeBinding = function (nodelist, selector, ev, cb) { + if (nodelist instanceof Y.NodeList || !nodelist.on || nodelist.getDOMNode) { + nodelist.each(function (node) { + node = can.$(node); + var events = can.data(node, 'events'); + if (events) { + var eventName = ev + ':' + selector, handlers = events[eventName], handler = handlers[cb.__bindingsIds]; + handler.detach(); + delete handlers[cb.__bindingsIds]; + if (can.isEmptyObject(handlers)) { + delete events[ev]; + } + if (can.isEmptyObject(events)) { + } + } + }); + } else { + var obj = nodelist, events = obj.__canEvents || {}, handlers = events[ev], handler = handlers[cb.__bindingsIds]; + handler.detach(); + delete handlers[cb.__bindingsIds]; + if (can.isEmptyObject(handlers)) { + delete events[ev]; + } + if (can.isEmptyObject(events)) { + } + } + }; + can.bind = function (ev, cb) { + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (this.on || this.nodeType) { + addBinding(can.$(this), undefined, ev, cb); + } else if (this.addEvent) { + this.addEvent(ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + return this; + }; + can.unbind = function (ev, cb) { + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (this.on || this.nodeType) { + removeBinding(can.$(this), undefined, ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + return this; + }; + can.on = can.bind; + can.off = can.unbind; + can.trigger = function (item, event, args, bubble) { + if (item instanceof Y.NodeList) { + item = item.item(0); + } + if (item.getDOMNode) { + item = item.getDOMNode(); + } + if (item.nodeName) { + item = Y.Node(item); + if (bubble === false) { + item.once(event, function (ev) { + if (ev.stopPropagation) { + ev.stopPropagation(); + } + ev.cancelBubble = true; + if (ev._stopper) { + ev._stopper(); + } + }); + } + if (typeof event !== 'string') { + args = event; + event = args.type; + delete args.type; + } + realTrigger(item.getDOMNode(), event, args || {}); + } else { + if (typeof event === 'string') { + event = { type: event }; + } + event.target = event.target || item; + can.dispatch.call(item, event, can.makeArray(args)); + } + }; + Y.mix(Y.Node.DOM_EVENTS, { + removed: true, + inserted: true, + attributes: true, + foo: true + }); + Y.Env.evt.plugins.attributes = { + on: function () { + var args = can.makeArray(arguments); + return Y.Event._attach(args, { facade: false }); + } + }; + can.delegate = function (selector, ev, cb) { + if (this.on || this.nodeType) { + addBinding(can.$(this), selector, ev, cb); + } else if (this.delegate) { + this.delegate(selector, ev, cb); + } else { + can.bind.call(this, ev, cb); + } + return this; + }; + can.undelegate = function (selector, ev, cb) { + if (this.on || this.nodeType) { + removeBinding(can.$(this), selector, ev, cb); + } else if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else { + can.unbind.call(this, ev, cb); + } + return this; + }; + var realTrigger, realTriggerHandler = function (n, e, evdata) { + var node = Y.Node(n), handlers = can.Y.Event.getListeners(node._yuid, e), i; + if (handlers) { + for (i = 0; i < handlers.length; i++) { + if (handlers[i].fire) { + handlers[i].fire(evdata); + } else if (handlers[i].handles) { + can.each(handlers[i].handles, function (handle) { + handle.evt.fire(evdata); + }); + } else { + throw 'can not fire event'; + } + } + } + }, fakeTrigger = function (n, e, a) { + var stop = false; + var evdata = can.extend({ + type: e, + target: n, + faux: true, + _stopper: function () { + stop = this.cancelBubble; + }, + stopPropagation: function () { + stop = this.cancelBubble; + }, + preventDefault: function () { + } + }, a); + realTriggerHandler(n, e, evdata); + if (e === 'inserted' || e === 'removed') { + return; + } + while (!stop && n !== document && n.parentNode) { + n = n.parentNode; + realTriggerHandler(n, e, evdata); + } + }; + if (document.createEvent) { + realTrigger = function (n, e, a) { + fakeTrigger(n, e, a); + return; + }; + } else { + realTrigger = function (n, e, a) { + fakeTrigger(n, e, a); + return; + }; + } + can.attr = attr; + delete attr.MutationObserver; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/zepto.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/zepto.js new file mode 100644 index 0000000000..c4257fcf05 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/util/zepto.js @@ -0,0 +1,306 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/zepto/zepto*/ +define([ + 'can/util/can', + 'can/util/attr', + 'can/event', + 'zepto', + 'can/util/object/isplain', + 'can/fragment', + 'can/deferred', + 'can/util/each', + 'can/util/inserted' +], function (can, attr, event) { + var $ = Zepto; + var data = {}, dataAttr = $.fn.data, uuid = $.uuid = +new Date(), exp = $.expando = 'Zepto' + uuid; + function getData(node, name) { + var id = node[exp], store = id && data[id]; + return name === undefined ? store || setData(node) : store && store[name] || dataAttr.call($(node), name); + } + function setData(node, name, value) { + var id = node[exp] || (node[exp] = ++uuid), store = data[id] || (data[id] = {}); + if (name !== undefined) { + store[name] = value; + } + return store; + } + $.fn.data = function (name, value) { + return value === undefined ? this.length === 0 ? undefined : getData(this[0], name) : this.each(function (idx) { + setData(this, name, $.isFunction(value) ? value.call(this, idx, getData(this, name)) : value); + }); + }; + $.cleanData = function (elems) { + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + can.trigger(elem, 'removed', [], false); + } + for (i = 0; (elem = elems[i]) !== undefined; i++) { + var id = elem[exp]; + delete data[id]; + } + }; + var oldEach = can.each; + var oldPlain = can.isPlainObject; + $.extend(can, Zepto); + can.inArray = function (el, arr) { + return !arr ? -1 : $.inArray.apply($, arguments); + }; + can.isPlainObject = oldPlain; + can.each = oldEach; + can.attr = attr; + can.event = event; + var arrHas = function (obj, name) { + return obj[0] && obj[0][name] || obj[name]; + }; + can.trigger = function (obj, event, args, bubble) { + if (obj.trigger) { + obj.trigger(event, args); + } else if (arrHas(obj, 'dispatchEvent')) { + if (bubble === false) { + $([obj]).triggerHandler(event, args); + } else { + $([obj]).trigger(event, args); + } + } else { + if (typeof event === 'string') { + event = { type: event }; + } + event.target = event.target || obj; + can.dispatch.call(obj, event, can.makeArray(args)); + } + }; + can.$ = Zepto; + can.bind = function (ev, cb) { + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (arrHas(this, 'addEventListener')) { + $([this]).bind(ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + return this; + }; + can.unbind = function (ev, cb) { + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (arrHas(this, 'addEventListener')) { + $([this]).unbind(ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + return this; + }; + can.on = can.bind; + can.off = can.unbind; + can.delegate = function (selector, ev, cb) { + if (!selector) { + can.bind.call(this, ev, cb); + } else if (this.delegate) { + this.delegate(selector, ev, cb); + } else if (arrHas(this, 'addEventListener')) { + $([this]).delegate(selector, ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + }; + can.undelegate = function (selector, ev, cb) { + if (!selector) { + can.unbind.call(this, ev, cb); + } else if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else if (arrHas(this, 'addEventListener')) { + $([this]).undelegate(selector, ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + }; + $.each([ + 'append', + 'filter', + 'addClass', + 'remove', + 'data', + 'has' + ], function (i, name) { + can[name] = function (wrapped) { + return wrapped[name].apply(wrapped, can.makeArray(arguments).slice(1)); + }; + }); + can.makeArray = function (arr) { + var ret = []; + if (arr == null) { + return []; + } + if (arr.length === undefined || typeof arr === 'string') { + return [arr]; + } + can.each(arr, function (a, i) { + ret[i] = a; + }); + return ret; + }; + var XHR = $.ajaxSettings.xhr; + $.ajaxSettings.xhr = function () { + var xhr = XHR(); + var open = xhr.open; + xhr.open = function (type, url, async) { + open.call(this, type, url, ASYNC === undefined ? true : ASYNC); + }; + return xhr; + }; + var ASYNC; + var AJAX = $.ajax; + var updateDeferred = function (xhr, d) { + for (var prop in xhr) { + if (typeof d[prop] === 'function') { + d[prop] = function () { + xhr[prop].apply(xhr, arguments); + }; + } else { + d[prop] = prop[xhr]; + } + } + }; + can.ajax = function (options) { + var success = options.success, error = options.error; + var d = can.Deferred(); + options.success = function (data) { + updateDeferred(xhr, d); + d.resolve.call(d, data); + if (success) { + success.apply(this, arguments); + } + }; + options.error = function () { + updateDeferred(xhr, d); + d.reject.apply(d, arguments); + if (error) { + error.apply(this, arguments); + } + }; + if (options.async === false) { + ASYNC = false; + } + var xhr = AJAX(options); + ASYNC = undefined; + updateDeferred(xhr, d); + return d; + }; + var $_empty = $.fn.empty; + $.fn.empty = function () { + this.each(function () { + $.cleanData(this.getElementsByTagName('*')); + this.innerHTML = ''; + }); + return $_empty.call(this); + }; + var $_remove = $.fn.remove; + $.fn.remove = function () { + this.each(function () { + if (this.getElementsByTagName) { + $.cleanData([this].concat(can.makeArray(this.getElementsByTagName('*')))); + } + }); + return $_remove.call(this); + }; + can.trim = function (str) { + return str.trim(); + }; + can.isEmptyObject = function (object) { + var name; + for (name in object) { + } + return name === undefined; + }; + can.extend = function (first) { + if (first === true) { + var args = can.makeArray(arguments); + args.shift(); + return $.extend.apply($, args); + } + return $.extend.apply($, arguments); + }; + can.get = function (wrapped, index) { + return wrapped[index]; + }; + can.each([ + 'after', + 'prepend', + 'before', + 'append' + ], function (name) { + var original = Zepto.fn[name]; + Zepto.fn[name] = function () { + var elems, args = can.makeArray(arguments); + if (args[0] != null) { + if (typeof args[0] === 'string') { + args[0] = $.zepto.fragment(args[0]); + } + if (args[0].nodeType === 11) { + elems = can.makeArray(args[0].childNodes); + } else if (args[0] instanceof Zepto.fn.constructor) { + elems = can.makeArray(args[0]); + } else { + elems = [args[0]]; + } + } + var ret = original.apply(this, args); + can.inserted(elems); + return ret; + }; + }); + delete attr.MutationObserver; + var oldAttr = $.fn.attr; + $.fn.attr = function (attrName, value) { + var isString = typeof attrName === 'string', oldValue, newValue; + if (value !== undefined && isString) { + oldValue = oldAttr.call(this, attrName); + } + var res = oldAttr.apply(this, arguments); + if (value !== undefined && isString) { + newValue = oldAttr.call(this, attrName); + } + if (newValue !== oldValue) { + can.attr.trigger(this[0], attrName, oldValue); + } + return res; + }; + var oldRemove = $.fn.removeAttr; + $.fn.removeAttr = function (attrName) { + var oldValue = oldAttr.call(this, attrName), res = oldRemove.apply(this, arguments); + if (oldValue != null) { + can.attr.trigger(this[0], attrName, oldValue); + } + return res; + }; + var oldBind = $.fn.bind, oldUnbind = $.fn.unbind; + $.fn.bind = function (event) { + if (event === 'attributes') { + this.each(function () { + var el = can.$(this); + can.data(el, 'canHasAttributesBindings', (can.data(el, 'canHasAttributesBindings') || 0) + 1); + }); + } + return oldBind.apply(this, arguments); + }; + $.fn.unbind = function (event) { + if (event === 'attributes') { + this.each(function () { + var el = can.$(this), cur = can.data(el, 'canHasAttributesBindings') || 0; + if (cur <= 0) { + can.data(el, 'canHasAttributesBindings', 0); + } else { + can.data(el, 'canHasAttributesBindings', cur - 1); + } + }); + } + return oldUnbind.apply(this, arguments); + }; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view.js new file mode 100644 index 0000000000..66c7bddc97 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view.js @@ -0,0 +1,298 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/view*/ +define(['can/util/library'], function (can) { + var isFunction = can.isFunction, makeArray = can.makeArray, hookupId = 1; + var makeRenderer = function (textRenderer) { + var renderer = function () { + return $view.frag(textRenderer.apply(this, arguments)); + }; + renderer.render = function () { + return textRenderer.apply(textRenderer, arguments); + }; + return renderer; + }; + var checkText = function (text, url) { + if (!text.length) { + can.dev.log('can/view/view.js: There is no template or an empty template at ' + url); + throw 'can.view: No template or empty template:' + url; + } + }; + var getRenderer = function (obj, async) { + if (isFunction(obj)) { + var def = can.Deferred(); + return def.resolve(obj); + } + var url = typeof obj === 'string' ? obj : obj.url, suffix = obj.engine && '.' + obj.engine || url.match(/\.[\w\d]+$/), type, el, id; + if (url.match(/^#/)) { + url = url.substr(1); + } + if (el = document.getElementById(url)) { + suffix = '.' + el.type.match(/\/(x\-)?(.+)/)[2]; + } + if (!suffix && !$view.cached[url]) { + url += suffix = $view.ext; + } + if (can.isArray(suffix)) { + suffix = suffix[0]; + } + id = $view.toId(url); + if (url.match(/^\/\//)) { + url = url.substr(2); + url = !window.steal ? url : steal.config().root.mapJoin('' + steal.id(url)); + } + if (window.require) { + if (require.toUrl) { + url = require.toUrl(url); + } + } + type = $view.types[suffix]; + if ($view.cached[id]) { + return $view.cached[id]; + } else if (el) { + return $view.registerView(id, el.innerHTML, type); + } else { + var d = new can.Deferred(); + can.ajax({ + async: async, + url: url, + dataType: 'text', + error: function (jqXHR) { + checkText('', url); + d.reject(jqXHR); + }, + success: function (text) { + checkText(text, url); + $view.registerView(id, text, type, d); + } + }); + return d; + } + }; + var getDeferreds = function (data) { + var deferreds = []; + if (can.isDeferred(data)) { + return [data]; + } else { + for (var prop in data) { + if (can.isDeferred(data[prop])) { + deferreds.push(data[prop]); + } + } + } + return deferreds; + }; + var usefulPart = function (resolved) { + return can.isArray(resolved) && resolved[1] === 'success' ? resolved[0] : resolved; + }; + var $view = can.view = can.template = function (view, data, helpers, callback) { + if (isFunction(helpers)) { + callback = helpers; + helpers = undefined; + } + return $view.renderAs('fragment', view, data, helpers, callback); + }; + can.extend($view, { + frag: function (result, parentNode) { + return $view.hookup($view.fragment(result), parentNode); + }, + fragment: function (result) { + if (typeof result !== 'string' && result.nodeType === 11) { + return result; + } + var frag = can.buildFragment(result, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + }, + toId: function (src) { + return can.map(src.toString().split(/\/|\./g), function (part) { + if (part) { + return part; + } + }).join('_'); + }, + toStr: function (txt) { + return txt == null ? '' : '' + txt; + }, + hookup: function (fragment, parentNode) { + var hookupEls = [], id, func; + can.each(fragment.childNodes ? can.makeArray(fragment.childNodes) : fragment, function (node) { + if (node.nodeType === 1) { + hookupEls.push(node); + hookupEls.push.apply(hookupEls, can.makeArray(node.getElementsByTagName('*'))); + } + }); + can.each(hookupEls, function (el) { + if (el.getAttribute && (id = el.getAttribute('data-view-id')) && (func = $view.hookups[id])) { + func(el, parentNode, id); + delete $view.hookups[id]; + el.removeAttribute('data-view-id'); + } + }); + return fragment; + }, + hookups: {}, + hook: function (cb) { + $view.hookups[++hookupId] = cb; + return ' data-view-id=\'' + hookupId + '\''; + }, + cached: {}, + cachedRenderers: {}, + cache: true, + register: function (info) { + this.types['.' + info.suffix] = info; + if (typeof window !== 'undefined' && window.steal && steal.type) { + steal.type(info.suffix + ' view js', function (options, success, error) { + var type = $view.types['.' + options.type], id = $view.toId(options.id + ''); + options.text = type.script(id, options.text); + success(); + }); + } + can[info.suffix] = $view[info.suffix] = function (id, text) { + var renderer, renderFunc; + if (!text) { + renderFunc = function () { + if (!renderer) { + if (info.fragRenderer) { + renderer = info.fragRenderer(null, id); + } else { + renderer = makeRenderer(info.renderer(null, id)); + } + } + return renderer.apply(this, arguments); + }; + renderFunc.render = function () { + var textRenderer = info.renderer(null, id); + return textRenderer.apply(textRenderer, arguments); + }; + return renderFunc; + } + var registeredRenderer = function () { + if (!renderer) { + if (info.fragRenderer) { + renderer = info.fragRenderer(id, text); + } else { + renderer = info.renderer(id, text); + } + } + return renderer.apply(this, arguments); + }; + if (info.fragRenderer) { + return $view.preload(id, registeredRenderer); + } else { + return $view.preloadStringRenderer(id, registeredRenderer); + } + }; + }, + types: {}, + ext: '.ejs', + registerScript: function (type, id, src) { + return 'can.view.preloadStringRenderer(\'' + id + '\',' + $view.types['.' + type].script(id, src) + ');'; + }, + preload: function (id, renderer) { + var def = $view.cached[id] = new can.Deferred().resolve(function (data, helpers) { + return renderer.call(data, data, helpers); + }); + def.__view_id = id; + $view.cachedRenderers[id] = renderer; + return renderer; + }, + preloadStringRenderer: function (id, stringRenderer) { + return this.preload(id, makeRenderer(stringRenderer)); + }, + render: function (view, data, helpers, callback) { + return can.view.renderAs('string', view, data, helpers, callback); + }, + renderTo: function (format, renderer, data, helpers) { + return (format === 'string' && renderer.render ? renderer.render : renderer)(data, helpers); + }, + renderAs: function (format, view, data, helpers, callback) { + if (isFunction(helpers)) { + callback = helpers; + helpers = undefined; + } + var deferreds = getDeferreds(data); + var reading, deferred, dataCopy, async, response; + if (deferreds.length) { + deferred = new can.Deferred(); + dataCopy = can.extend({}, data); + deferreds.push(getRenderer(view, true)); + can.when.apply(can, deferreds).then(function (resolved) { + var objs = makeArray(arguments), renderer = objs.pop(), result; + if (can.isDeferred(data)) { + dataCopy = usefulPart(resolved); + } else { + for (var prop in data) { + if (can.isDeferred(data[prop])) { + dataCopy[prop] = usefulPart(objs.shift()); + } + } + } + result = can.view.renderTo(format, renderer, dataCopy, helpers); + deferred.resolve(result, dataCopy); + if (callback) { + callback(result, dataCopy); + } + }, function () { + deferred.reject.apply(deferred, arguments); + }); + return deferred; + } else { + reading = can.__clearReading(); + async = isFunction(callback); + deferred = getRenderer(view, async); + if (reading) { + can.__setReading(reading); + } + if (async) { + response = deferred; + deferred.then(function (renderer) { + callback(data ? can.view.renderTo(format, renderer, data, helpers) : renderer); + }); + } else { + if (deferred.state() === 'resolved' && deferred.__view_id) { + var currentRenderer = $view.cachedRenderers[deferred.__view_id]; + return data ? can.view.renderTo(format, currentRenderer, data, helpers) : currentRenderer; + } else { + deferred.then(function (renderer) { + response = data ? can.view.renderTo(format, renderer, data, helpers) : renderer; + }); + } + } + return response; + } + }, + registerView: function (id, text, type, def) { + var info = typeof type === 'object' ? type : $view.types[type || $view.ext], renderer; + if (info.fragRenderer) { + renderer = info.fragRenderer(id, text); + } else { + renderer = makeRenderer(info.renderer(id, text)); + } + def = def || new can.Deferred(); + if ($view.cache) { + $view.cached[id] = def; + def.__view_id = id; + $view.cachedRenderers[id] = renderer; + } + return def.resolve(renderer); + } + }); + if (typeof window !== 'undefined' && window.steal && steal.type) { + steal.type('view js', function (options, success, error) { + var type = $view.types['.' + options.type], id = $view.toId(options.id); + var dependency = type.plugin || 'can/view/' + options.type, preload = type.fragRenderer ? 'preload' : 'preloadStringRenderer'; + options.text = 'steal(\'can/view\',\'' + dependency + '\',function(can){return ' + 'can.view.' + preload + '(\'' + id + '\',' + options.text + ');\n})'; + success(); + }); + } + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/autorender.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/autorender.js new file mode 100644 index 0000000000..a1e7a9b21d --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/autorender.js @@ -0,0 +1,88 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/autorender/autorender*/ +'format steal'; +define(['can/util/library'], function (can) { + var deferred = new can.Deferred(), ignoreAttributesRegExp = /^(dataViewId|class|id|type|src)$/i; + var typeMatch = /\s*text\/(mustache|stache|ejs)\s*/; + function isIn(element, type) { + while (element.parentNode) { + element = element.parentNode; + if (element.nodeName.toLowerCase() === type.toLowerCase()) { + return true; + } + } + } + function setAttr(el, attr, scope) { + var camelized = can.camelize(attr); + if (!ignoreAttributesRegExp.test(camelized)) { + scope.attr(camelized, el.getAttribute(attr)); + } + } + function insertAfter(ref, element) { + if (ref.nextSibling) { + can.insertBefore(ref.parentNode, element, ref.nextSibling); + } else { + can.appendChild(ref.parentNode, element); + } + } + function render(renderer, scope, el) { + var frag = renderer(scope); + if (isIn(el, 'head')) { + can.appendChild(document.body, frag); + } else if (el.nodeName.toLowerCase() === 'script') { + insertAfter(el, frag); + } else { + insertAfter(el, frag); + el.parentNode.removeChild(el); + } + } + function setupScope(el) { + var scope = can.viewModel(el); + can.each(el.attributes || [], function (attr) { + setAttr(el, attr.name, scope); + }); + can.bind.call(el, 'attributes', function (ev) { + setAttr(el, ev.attributeName, scope); + }); + return scope; + } + function autoload() { + var promises = []; + can.each(can.$('[can-autorender]'), function (el, i) { + el.style.display = 'none'; + var text = el.innerHTML || el.text, typeAttr = el.getAttribute('type'), typeInfo = typeAttr.match(typeMatch), type = typeInfo && typeInfo[1], typeModule = 'can/view/' + type; + if (window.System || !(window.define && window.define.amd)) { + typeModule += '/' + type; + } + promises.push(can['import'](typeModule).then(function (engine) { + engine = can[type] || engine; + if (engine.async) { + return engine.async(text).then(function (renderer) { + render(renderer, setupScope(el), el); + }); + } else { + var renderer = engine(text); + render(renderer, setupScope(el), el); + } + })); + }); + can.when.apply(can, promises).then(can.proxy(deferred.resolve, deferred), can.proxy(deferred.reject, deferred)); + } + if (document.readyState === 'complete') { + autoload(); + } else { + can.bind.call(window, 'load', autoload); + } + var promise = deferred.promise(); + can.autorender = function (success, error) { + return promise.then(success, error); + }; + return can.autorender; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/bindings.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/bindings.js new file mode 100644 index 0000000000..73b8a529bc --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/bindings.js @@ -0,0 +1,266 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/bindings/bindings*/ +define([ + 'can/util/library', + 'can/view/mustache_core', + 'can/view/callbacks', + 'can/control', + 'can/view/scope' +], function (can, mustacheCore) { + var isContentEditable = function () { + var values = { + '': true, + 'true': true, + 'false': false + }; + var editable = function (el) { + if (!el || !el.getAttribute) { + return; + } + var attr = el.getAttribute('contenteditable'); + return values[attr]; + }; + return function (el) { + var val = editable(el); + if (typeof val === 'boolean') { + return val; + } else { + return !!editable(el.parentNode); + } + }; + }(), removeCurly = function (value) { + if (value[0] === '{' && value[value.length - 1] === '}') { + return value.substr(1, value.length - 2); + } + return value; + }; + can.view.attr('can-value', function (el, data) { + var attr = can.trim(removeCurly(el.getAttribute('can-value'))), value = data.scope.computeData(attr, { args: [] }).compute, trueValue, falseValue; + if (el.nodeName.toLowerCase() === 'input') { + if (el.type === 'checkbox') { + if (can.attr.has(el, 'can-true-value')) { + trueValue = el.getAttribute('can-true-value'); + } else { + trueValue = true; + } + if (can.attr.has(el, 'can-false-value')) { + falseValue = el.getAttribute('can-false-value'); + } else { + falseValue = false; + } + } + if (el.type === 'checkbox' || el.type === 'radio') { + new Checked(el, { + value: value, + trueValue: trueValue, + falseValue: falseValue + }); + return; + } + } + if (el.nodeName.toLowerCase() === 'select' && el.multiple) { + new Multiselect(el, { value: value }); + return; + } + if (isContentEditable(el)) { + new Content(el, { value: value }); + return; + } + new Value(el, { value: value }); + }); + var special = { + enter: function (data, el, original) { + return { + event: 'keyup', + handler: function (ev) { + if (ev.keyCode === 13) { + return original.call(this, ev); + } + } + }; + } + }; + can.view.attr(/can-[\w\.]+/, function (el, data) { + var attributeName = data.attributeName, event = attributeName.substr('can-'.length), handler = function (ev) { + var attrVal = el.getAttribute(attributeName); + if (!attrVal) { + return; + } + var attrInfo = mustacheCore.expressionData(removeCurly(attrVal)); + var scopeData = data.scope.read(attrInfo.name.get, { + returnObserveMethods: true, + isArgument: true, + executeAnonymousFunctions: true + }); + if (!scopeData.value) { + can.dev.warn('can/view/bindings: ' + attributeName + ' couldn\'t find method named ' + attrInfo.name.get, { + element: el, + scope: data.scope + }); + return null; + } + var args = []; + var $el = can.$(this); + var viewModel = can.viewModel($el[0]); + var localScope = data.scope.add({ + '@element': $el, + '@event': ev, + '@viewModel': viewModel, + '@scope': data.scope, + '@context': data.scope._context + }); + if (!can.isEmptyObject(attrInfo.hash)) { + var hash = {}; + can.each(attrInfo.hash, function (val, key) { + if (val && val.hasOwnProperty('get')) { + var s = !val.get.indexOf('@') ? localScope : data.scope; + hash[key] = s.read(val.get, {}).value; + } else { + hash[key] = val; + } + }); + args.unshift(hash); + } + if (attrInfo.args.length) { + var arg; + for (var i = attrInfo.args.length - 1; i >= 0; i--) { + arg = attrInfo.args[i]; + if (arg && arg.hasOwnProperty('get')) { + var s = !arg.get.indexOf('@') ? localScope : data.scope; + args.unshift(s.read(arg.get, {}).value); + } else { + args.unshift(arg); + } + } + } + if (!args.length) { + args = [ + data.scope._context, + $el + ].concat(can.makeArray(arguments)); + } + return scopeData.value.apply(scopeData.parent, args); + }; + if (special[event]) { + var specialData = special[event](data, el, handler); + handler = specialData.handler; + event = specialData.event; + } + can.bind.call(el, event, handler); + }); + var Value = can.Control.extend({ + init: function () { + if (this.element[0].nodeName.toUpperCase() === 'SELECT') { + setTimeout(can.proxy(this.set, this), 1); + } else { + this.set(); + } + }, + '{value} change': 'set', + set: function () { + if (!this.element) { + return; + } + var val = this.options.value(); + this.element[0].value = val == null ? '' : val; + }, + 'change': function () { + if (!this.element) { + return; + } + var el = this.element[0]; + this.options.value(el.value); + var newVal = this.options.value(); + if (el.value !== newVal) { + el.value = newVal; + } + } + }), Checked = can.Control.extend({ + init: function () { + this.isCheckbox = this.element[0].type.toLowerCase() === 'checkbox'; + this.check(); + }, + '{value} change': 'check', + check: function () { + if (this.isCheckbox) { + var value = this.options.value(), trueValue = this.options.trueValue || true; + this.element[0].checked = value == trueValue; + } else { + var setOrRemove = this.options.value() == this.element[0].value ? 'set' : 'remove'; + can.attr[setOrRemove](this.element[0], 'checked', true); + } + }, + 'change': function () { + if (this.isCheckbox) { + this.options.value(this.element[0].checked ? this.options.trueValue : this.options.falseValue); + } else { + if (this.element[0].checked) { + this.options.value(this.element[0].value); + } + } + } + }), Multiselect = Value.extend({ + init: function () { + this.delimiter = ';'; + setTimeout(can.proxy(this.set, this), 1); + }, + set: function () { + var newVal = this.options.value(); + if (typeof newVal === 'string') { + newVal = newVal.split(this.delimiter); + this.isString = true; + } else if (newVal) { + newVal = can.makeArray(newVal); + } + var isSelected = {}; + can.each(newVal, function (val) { + isSelected[val] = true; + }); + can.each(this.element[0].childNodes, function (option) { + if (option.value) { + option.selected = !!isSelected[option.value]; + } + }); + }, + get: function () { + var values = [], children = this.element[0].childNodes; + can.each(children, function (child) { + if (child.selected && child.value) { + values.push(child.value); + } + }); + return values; + }, + 'change': function () { + var value = this.get(), currentValue = this.options.value(); + if (this.isString || typeof currentValue === 'string') { + this.isString = true; + this.options.value(value.join(this.delimiter)); + } else if (currentValue instanceof can.List) { + currentValue.attr(value, true); + } else { + this.options.value(value); + } + } + }), Content = can.Control.extend({ + init: function () { + this.set(); + this.on('blur', 'setValue'); + }, + '{value} change': 'set', + set: function () { + var val = this.options.value(); + this.element[0].innerHTML = typeof val === 'undefined' ? '' : val; + }, + setValue: function () { + this.options.value(this.element[0].innerHTML); + } + }); +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/callbacks.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/callbacks.js new file mode 100644 index 0000000000..7c4207b70a --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/callbacks.js @@ -0,0 +1,89 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/callbacks/callbacks*/ +define([ + 'can/util/library', + 'can/view' +], function (can) { + var attr = can.view.attr = function (attributeName, attrHandler) { + if (attrHandler) { + if (typeof attributeName === 'string') { + attributes[attributeName] = attrHandler; + } else { + regExpAttributes.push({ + match: attributeName, + handler: attrHandler + }); + } + } else { + var cb = attributes[attributeName]; + if (!cb) { + for (var i = 0, len = regExpAttributes.length; i < len; i++) { + var attrMatcher = regExpAttributes[i]; + if (attrMatcher.match.test(attributeName)) { + cb = attrMatcher.handler; + break; + } + } + } + return cb; + } + }; + var attributes = {}, regExpAttributes = [], automaticCustomElementCharacters = /[-\:]/; + var tag = can.view.tag = function (tagName, tagHandler) { + if (tagHandler) { + if (typeof tags[tagName.toLowerCase()] !== 'undefined') { + can.dev.warn('Custom tag: ' + tagName.toLowerCase() + ' is already defined'); + } + if (can.global.html5) { + can.global.html5.elements += ' ' + tagName; + can.global.html5.shivDocument(); + } + tags[tagName.toLowerCase()] = tagHandler; + } else { + var cb = tags[tagName.toLowerCase()]; + if (!cb && automaticCustomElementCharacters.test(tagName)) { + cb = function () { + }; + } + return cb; + } + }; + var tags = {}; + can.view.callbacks = { + _tags: tags, + _attributes: attributes, + _regExpAttributes: regExpAttributes, + tag: tag, + attr: attr, + tagHandler: function (el, tagName, tagData) { + var helperTagCallback = tagData.options.attr('tags.' + tagName), tagCallback = helperTagCallback || tags[tagName]; + var scope = tagData.scope, res; + if (tagCallback) { + var reads = can.__clearReading(); + res = tagCallback(el, tagData); + can.__setReading(reads); + } else { + res = scope; + } + if (!tagCallback) { + can.dev.warn('can/view/scanner.js: No custom element found for ' + tagName); + } + if (res && tagData.subtemplate) { + if (scope !== res) { + scope = scope.add(res); + } + var result = tagData.subtemplate(scope, tagData.options); + var frag = typeof result === 'string' ? can.view.frag(result) : result; + can.appendChild(el, frag); + } + } + }; + return can.view.callbacks; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/compute_data.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/compute_data.js new file mode 100644 index 0000000000..dccdc87c90 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/compute_data.js @@ -0,0 +1,110 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/scope/compute_data*/ +define([ + 'can/util/library', + 'can/compute', + 'can/get_value_and_bind' +], function (can, compute, getValueAndBind) { + var isFastPath = function (computeData) { + return computeData.reads && computeData.reads.length === 1 && computeData.root instanceof can.Map && !can.isFunction(computeData.root[computeData.reads[0]]); + }; + var getValueAndBindScopeRead = function (scopeRead, scopeReadChanged) { + return getValueAndBind(scopeRead, null, { observed: {} }, scopeReadChanged); + }; + var unbindScopeRead = function (readInfo, scopeReadChanged) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, scopeReadChanged); + } + }; + var getValueAndBindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + var target = computeData.root, prop = computeData.reads[0]; + target.bind(prop, singlePropertyReadChanged); + return { + value: computeData.initialValue, + observed: { something: true } + }; + }; + var unbindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + computeData.root.unbind(computeData.reads[0], singlePropertyReadChanged); + }; + var scopeReader = function (scope, key, options, computeData, newVal) { + if (arguments.length > 4) { + if (computeData.root.isComputed) { + computeData.root(newVal); + } else if (computeData.reads.length) { + var last = computeData.reads.length - 1; + var obj = computeData.reads.length ? can.compute.read(computeData.root, computeData.reads.slice(0, last)).value : computeData.root; + can.compute.set(obj, computeData.reads[last], newVal, options); + } + } else { + if (computeData.root) { + return can.compute.read(computeData.root, computeData.reads, options).value; + } + var data = scope.read(key, options); + computeData.scope = data.scope; + computeData.initialValue = data.value; + computeData.reads = data.reads; + computeData.root = data.rootObserve; + return data.value; + } + }; + return function (scope, key, options) { + options = options || { args: [] }; + var computeData = {}, scopeRead = function (newVal) { + if (arguments.length) { + return scopeReader(scope, key, options, computeData, newVal); + } else { + return scopeReader(scope, key, options, computeData); + } + }, batchNum, readInfo, scopeReadChanged = function (ev) { + if (readInfo.ready && compute.computeInstance.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + readInfo = getValueAndBind(scopeRead, null, readInfo, scopeReadChanged); + newValue = readInfo.value; + compute.computeInstance.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }, singlePropertyReadChanged = function (ev, newVal, oldVal) { + if (typeof newVal !== 'function') { + compute.computeInstance.updater(newVal, oldVal, ev.batchNum); + } else { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + isFastPathBound = false; + compute.computeInstance.updater(readInfo.value, oldVal, ev.batchNum); + } + }, isFastPathBound = false, compute = can.compute(undefined, { + on: function () { + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + if (isFastPath(computeData)) { + var oldReadInfo = readInfo; + readInfo = getValueAndBindSinglePropertyRead(computeData, singlePropertyReadChanged); + unbindScopeRead(oldReadInfo, scopeReadChanged); + isFastPathBound = true; + } + compute.computeInstance.value = readInfo.value; + compute.computeInstance.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function () { + if (isFastPathBound) { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + } else { + unbindScopeRead(readInfo, scopeReadChanged); + } + }, + set: scopeRead, + get: scopeRead, + __selfUpdater: true + }); + computeData.compute = compute; + return computeData; + }; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/ejs.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/ejs.js new file mode 100644 index 0000000000..2f4162324f --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/ejs.js @@ -0,0 +1,161 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/ejs/ejs*/ +define([ + 'can/util/library', + 'can/view', + 'can/util/string', + 'can/compute', + 'can/scanner', + 'can/render' +], function (can) { + var extend = can.extend, EJS = function (options) { + if (this.constructor !== EJS) { + var ejs = new EJS(options); + return function (data, helpers) { + return ejs.render(data, helpers); + }; + } + if (typeof options === 'function') { + this.template = { fn: options }; + return; + } + extend(this, options); + this.template = this.scanner.scan(this.text, this.name); + }; + can.EJS = EJS; + EJS.prototype.render = function (object, extraHelpers) { + object = object || {}; + return this.template.fn.call(object, object, new EJS.Helpers(object, extraHelpers || {})); + }; + extend(EJS.prototype, { + scanner: new can.view.Scanner({ + text: { + outStart: 'with(_VIEW) { with (_CONTEXT) {', + outEnd: '}}', + argNames: '_CONTEXT,_VIEW', + context: 'this' + }, + tokens: [ + [ + 'templateLeft', + '<%%' + ], + [ + 'templateRight', + '%>' + ], + [ + 'returnLeft', + '<%==' + ], + [ + 'escapeLeft', + '<%=' + ], + [ + 'commentLeft', + '<%#' + ], + [ + 'left', + '<%' + ], + [ + 'right', + '%>' + ], + [ + 'returnRight', + '%>' + ] + ], + helpers: [{ + name: /\s*\(([\$\w]+)\)\s*->([^\n]*)/, + fn: function (content) { + var quickFunc = /\s*\(([\$\w]+)\)\s*->([^\n]*)/, parts = content.match(quickFunc); + return 'can.proxy(function(__){var ' + parts[1] + '=can.$(__);' + parts[2] + '}, this);'; + } + }], + transform: function (source) { + return source.replace(/<%([\s\S]+?)%>/gm, function (whole, part) { + var brackets = [], foundBracketPair, i; + part.replace(/[{}]/gm, function (bracket, offset) { + brackets.push([ + bracket, + offset + ]); + }); + do { + foundBracketPair = false; + for (i = brackets.length - 2; i >= 0; i--) { + if (brackets[i][0] === '{' && brackets[i + 1][0] === '}') { + brackets.splice(i, 2); + foundBracketPair = true; + break; + } + } + } while (foundBracketPair); + if (brackets.length >= 2) { + var result = ['<%'], bracket, last = 0; + for (i = 0; bracket = brackets[i]; i++) { + result.push(part.substring(last, last = bracket[1])); + if (bracket[0] === '{' && i < brackets.length - 1 || bracket[0] === '}' && i > 0) { + result.push(bracket[0] === '{' ? '{ %><% ' : ' %><% }'); + } else { + result.push(bracket[0]); + } + ++last; + } + result.push(part.substring(last), '%>'); + return result.join(''); + } else { + return '<%' + part + '%>'; + } + }); + } + }) + }); + EJS.Helpers = function (data, extras) { + this._data = data; + this._extras = extras; + extend(this, extras); + }; + EJS.Helpers.prototype = { + list: function (list, cb) { + can.each(list, function (item, i) { + cb(item, i, list); + }); + }, + each: function (list, cb) { + if (can.isArray(list)) { + this.list(list, cb); + } else { + can.view.lists(list, cb); + } + } + }; + can.view.register({ + suffix: 'ejs', + script: function (id, src) { + return 'can.EJS(function(_CONTEXT,_VIEW) { ' + new EJS({ + text: src, + name: id + }).template.out + ' })'; + }, + renderer: function (id, text) { + return EJS({ + text: text, + name: id + }); + } + }); + can.ejs.Helpers = EJS.Helpers; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/html_section.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/html_section.js new file mode 100644 index 0000000000..323faead06 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/html_section.js @@ -0,0 +1,129 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/stache/html_section*/ +define([ + 'can/util/library', + 'can/view/target', + 'can/view/utils', + 'can/view/mustache_core' +], function (can, target, utils, mustacheCore) { + var decodeHTML = typeof document !== 'undefined' && function () { + var el = document.createElement('div'); + return function (html) { + if (html.indexOf('&') === -1) { + return html.replace(/\r\n/g, '\n'); + } + el.innerHTML = html; + return el.childNodes.length === 0 ? '' : el.childNodes[0].nodeValue; + }; + }(); + var HTMLSectionBuilder = function () { + this.stack = [new HTMLSection()]; + }; + can.extend(HTMLSectionBuilder.prototype, utils.mixins); + can.extend(HTMLSectionBuilder.prototype, { + startSubSection: function (process) { + var newSection = new HTMLSection(process); + this.stack.push(newSection); + return newSection; + }, + endSubSectionAndReturnRenderer: function () { + if (this.last().isEmpty()) { + this.stack.pop(); + return null; + } else { + var htmlSection = this.endSection(); + return can.proxy(htmlSection.compiled.hydrate, htmlSection.compiled); + } + }, + startSection: function (process) { + var newSection = new HTMLSection(process); + this.last().add(newSection.targetCallback); + this.stack.push(newSection); + }, + endSection: function () { + this.last().compile(); + return this.stack.pop(); + }, + inverse: function () { + this.last().inverse(); + }, + compile: function () { + var compiled = this.stack.pop().compile(); + return function (scope, options, nodeList) { + if (!(scope instanceof can.view.Scope)) { + scope = new can.view.Scope(scope || {}); + } + if (!(options instanceof mustacheCore.Options)) { + options = new mustacheCore.Options(options || {}); + } + return compiled.hydrate(scope, options, nodeList); + }; + }, + push: function (chars) { + this.last().push(chars); + }, + pop: function () { + return this.last().pop(); + } + }); + var HTMLSection = function (process) { + this.data = 'targetData'; + this.targetData = []; + this.targetStack = []; + var self = this; + this.targetCallback = function (scope, options, sectionNode) { + process.call(this, scope, options, sectionNode, can.proxy(self.compiled.hydrate, self.compiled), self.inverseCompiled && can.proxy(self.inverseCompiled.hydrate, self.inverseCompiled)); + }; + }; + can.extend(HTMLSection.prototype, { + inverse: function () { + this.inverseData = []; + this.data = 'inverseData'; + }, + push: function (data) { + this.add(data); + this.targetStack.push(data); + }, + pop: function () { + return this.targetStack.pop(); + }, + add: function (data) { + if (typeof data === 'string') { + data = decodeHTML(data); + } + if (this.targetStack.length) { + this.targetStack[this.targetStack.length - 1].children.push(data); + } else { + this[this.data].push(data); + } + }, + compile: function () { + this.compiled = target(this.targetData); + if (this.inverseData) { + this.inverseCompiled = target(this.inverseData); + delete this.inverseData; + } + delete this.targetData; + delete this.targetStack; + return this.compiled; + }, + children: function () { + if (this.targetStack.length) { + return this.targetStack[this.targetStack.length - 1].children; + } else { + return this[this.data]; + } + }, + isEmpty: function () { + return !this.targetData.length; + } + }); + return HTMLSectionBuilder; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/intermediate_and_imports.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/intermediate_and_imports.js new file mode 100644 index 0000000000..0e99310807 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/intermediate_and_imports.js @@ -0,0 +1,62 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/stache/intermediate_and_imports*/ +define([ + 'can/view/mustache_core', + 'can/view/parser' +], function (mustacheCore, parser) { + return function (source) { + var template = mustacheCore.cleanLineEndings(source); + var imports = [], inImport = false, inFrom = false; + var keepToken = function () { + return inImport ? false : true; + }; + var intermediate = parser(template, { + start: function (tagName, unary) { + if (tagName === 'can-import') { + inImport = true; + } + return keepToken(); + }, + end: function (tagName, unary) { + if (tagName === 'can-import') { + inImport = false; + return false; + } + return keepToken(); + }, + attrStart: function (attrName) { + if (attrName === 'from') { + inFrom = true; + } + return keepToken(); + }, + attrEnd: function (attrName) { + if (attrName === 'from') { + inFrom = false; + } + return keepToken(); + }, + attrValue: function (value) { + if (inFrom && inImport) { + imports.push(value); + } + return keepToken(); + }, + chars: keepToken, + comment: keepToken, + special: keepToken, + done: keepToken + }, true); + return { + intermediate: intermediate, + imports: imports + }; + }; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/live.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/live.js new file mode 100644 index 0000000000..ce7847fe3a --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/live.js @@ -0,0 +1,345 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/live/live*/ +define([ + 'can/util/library', + 'can/elements', + 'can/view', + 'can/view/node_lists', + 'can/view/parser' +], function (can, elements, view, nodeLists, parser) { + elements = elements || can.view.elements; + nodeLists = nodeLists || can.view.NodeLists; + parser = parser || can.view.parser; + var setup = function (el, bind, unbind) { + var tornDown = false, teardown = function () { + if (!tornDown) { + tornDown = true; + unbind(data); + can.unbind.call(el, 'removed', teardown); + } + return true; + }, data = { + teardownCheck: function (parent) { + return parent ? false : teardown(); + } + }; + can.bind.call(el, 'removed', teardown); + bind(data); + return data; + }, listen = function (el, compute, change) { + return setup(el, function () { + compute.bind('change', change); + }, function (data) { + compute.unbind('change', change); + if (data.nodeList) { + nodeLists.unregister(data.nodeList); + } + }); + }, getAttributeParts = function (newVal) { + var attrs = {}, attr; + parser.parseAttrs(newVal, { + attrStart: function (name) { + attrs[name] = ''; + attr = name; + }, + attrValue: function (value) { + attrs[attr] += value; + }, + attrEnd: function () { + } + }); + return attrs; + }, splice = [].splice, isNode = function (obj) { + return obj && obj.nodeType; + }, addTextNodeIfNoChildren = function (frag) { + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + }; + var live = { + list: function (el, compute, render, context, parentNode, nodeList) { + var masterNodeList = nodeList || [el], indexMap = [], afterPreviousEvents = false, isTornDown = false, add = function (ev, items, index) { + if (!afterPreviousEvents) { + return; + } + var frag = document.createDocumentFragment(), newNodeLists = [], newIndicies = []; + can.each(items, function (item, key) { + var itemNodeList = []; + if (nodeList) { + nodeLists.register(itemNodeList, null, true); + } + var itemIndex = can.compute(key + index), itemHTML = render.call(context, item, itemIndex, itemNodeList), gotText = typeof itemHTML === 'string', itemFrag = can.frag(itemHTML); + itemFrag = gotText ? can.view.hookup(itemFrag) : itemFrag; + var childNodes = can.makeArray(itemFrag.childNodes); + if (nodeList) { + nodeLists.update(itemNodeList, childNodes); + newNodeLists.push(itemNodeList); + } else { + newNodeLists.push(nodeLists.register(childNodes)); + } + frag.appendChild(itemFrag); + newIndicies.push(itemIndex); + }); + var masterListIndex = index + 1; + if (!masterNodeList[masterListIndex]) { + elements.after(masterListIndex === 1 ? [text] : [nodeLists.last(masterNodeList[masterListIndex - 1])], frag); + } else { + var el = nodeLists.first(masterNodeList[masterListIndex]); + can.insertBefore(el.parentNode, frag, el); + } + splice.apply(masterNodeList, [ + masterListIndex, + 0 + ].concat(newNodeLists)); + splice.apply(indexMap, [ + index, + 0 + ].concat(newIndicies)); + for (var i = index + newIndicies.length, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + }, remove = function (ev, items, index, duringTeardown, fullTeardown) { + if (!afterPreviousEvents) { + return; + } + if (!duringTeardown && data.teardownCheck(text.parentNode)) { + return; + } + if (index < 0) { + index = indexMap.length + index; + } + var removedMappings = masterNodeList.splice(index + 1, items.length), itemsToRemove = []; + can.each(removedMappings, function (nodeList) { + var nodesToRemove = nodeLists.unregister(nodeList); + [].push.apply(itemsToRemove, nodesToRemove); + }); + indexMap.splice(index, items.length); + for (var i = index, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + if (!fullTeardown) { + can.remove(can.$(itemsToRemove)); + } else { + nodeLists.unregister(masterNodeList); + } + }, move = function (ev, item, newIndex, currentIndex) { + if (!afterPreviousEvents) { + return; + } + newIndex = newIndex + 1; + currentIndex = currentIndex + 1; + var referenceNodeList = masterNodeList[newIndex]; + var movedElements = can.frag(nodeLists.flatten(masterNodeList[currentIndex])); + var referenceElement; + if (currentIndex < newIndex) { + referenceElement = nodeLists.last(referenceNodeList).nextSibling; + } else { + referenceElement = nodeLists.first(referenceNodeList); + } + var parentNode = masterNodeList[0].parentNode; + parentNode.insertBefore(movedElements, referenceElement); + var temp = masterNodeList[currentIndex]; + [].splice.apply(masterNodeList, [ + currentIndex, + 1 + ]); + [].splice.apply(masterNodeList, [ + newIndex, + 0, + temp + ]); + }, text = document.createTextNode(''), list, teardownList = function (fullTeardown) { + if (list && list.unbind) { + list.unbind('add', add).unbind('remove', remove).unbind('move', move); + } + remove({}, { length: masterNodeList.length - 1 }, 0, true, fullTeardown); + }, updateList = function (ev, newList, oldList) { + if (isTornDown) { + return; + } + teardownList(); + list = newList || []; + if (list.bind) { + list.bind('add', add).bind('remove', remove).bind('move', move); + } + afterPreviousEvents = true; + add({}, list, 0); + afterPreviousEvents = false; + can.batch.afterPreviousEvents(function () { + afterPreviousEvents = true; + }); + }; + parentNode = elements.getParentNode(el, parentNode); + var data = setup(parentNode, function () { + if (can.isFunction(compute)) { + compute.bind('change', updateList); + } + }, function () { + if (can.isFunction(compute)) { + compute.unbind('change', updateList); + } + teardownList(true); + }); + if (!nodeList) { + live.replace(masterNodeList, text, data.teardownCheck); + } else { + elements.replace(masterNodeList, text); + nodeLists.update(masterNodeList, [text]); + nodeList.unregistered = function () { + data.teardownCheck(); + isTornDown = true; + }; + } + updateList({}, can.isFunction(compute) ? compute() : compute); + }, + html: function (el, compute, parentNode, nodeList) { + var data; + parentNode = elements.getParentNode(el, parentNode); + data = listen(parentNode, compute, function (ev, newVal, oldVal) { + var attached = nodeLists.first(nodes).parentNode; + if (attached) { + makeAndPut(newVal); + } + data.teardownCheck(nodeLists.first(nodes).parentNode); + }); + var nodes = nodeList || [el], makeAndPut = function (val) { + var isFunction = typeof val === 'function', aNode = isNode(val), frag = can.frag(isFunction ? '' : val), oldNodes = can.makeArray(nodes); + addTextNodeIfNoChildren(frag); + if (!aNode && !isFunction) { + frag = can.view.hookup(frag, parentNode); + } + oldNodes = nodeLists.update(nodes, frag.childNodes); + if (isFunction) { + val(frag.childNodes[0]); + } + elements.replace(oldNodes, frag); + }; + data.nodeList = nodes; + if (!nodeList) { + nodeLists.register(nodes, data.teardownCheck); + } else { + nodeList.unregistered = data.teardownCheck; + } + makeAndPut(compute()); + }, + replace: function (nodes, val, teardown) { + var oldNodes = nodes.slice(0), frag = can.frag(val); + nodeLists.register(nodes, teardown); + if (typeof val === 'string') { + frag = can.view.hookup(frag, nodes[0].parentNode); + } + nodeLists.update(nodes, frag.childNodes); + elements.replace(oldNodes, frag); + return nodes; + }, + text: function (el, compute, parentNode, nodeList) { + var parent = elements.getParentNode(el, parentNode); + var data = listen(parent, compute, function (ev, newVal, oldVal) { + if (typeof node.nodeValue !== 'unknown') { + node.nodeValue = can.view.toStr(newVal); + } + data.teardownCheck(node.parentNode); + }); + var node = document.createTextNode(can.view.toStr(compute())); + if (nodeList) { + nodeList.unregistered = data.teardownCheck; + data.nodeList = nodeList; + nodeLists.update(nodeList, [node]); + elements.replace([el], node); + } else { + data.nodeList = live.replace([el], node, data.teardownCheck); + } + }, + setAttributes: function (el, newVal) { + var attrs = getAttributeParts(newVal); + for (var name in attrs) { + can.attr.set(el, name, attrs[name]); + } + }, + attributes: function (el, compute, currentValue) { + var oldAttrs = {}; + var setAttrs = function (newVal) { + var newAttrs = getAttributeParts(newVal), name; + for (name in newAttrs) { + var newValue = newAttrs[name], oldValue = oldAttrs[name]; + if (newValue !== oldValue) { + can.attr.set(el, name, newValue); + } + delete oldAttrs[name]; + } + for (name in oldAttrs) { + elements.removeAttr(el, name); + } + oldAttrs = newAttrs; + }; + listen(el, compute, function (ev, newVal) { + setAttrs(newVal); + }); + if (arguments.length >= 3) { + oldAttrs = getAttributeParts(currentValue); + } else { + setAttrs(compute()); + } + }, + attributePlaceholder: '__!!__', + attributeReplace: /__!!__/g, + attribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, hook.render()); + }); + var wrapped = can.$(el), hooks; + hooks = can.data(wrapped, 'hooks'); + if (!hooks) { + can.data(wrapped, 'hooks', hooks = {}); + } + var attr = elements.getAttr(el, attributeName), parts = attr.split(live.attributePlaceholder), goodParts = [], hook; + goodParts.push(parts.shift(), parts.join(live.attributePlaceholder)); + if (hooks[attributeName]) { + hooks[attributeName].computes.push(compute); + } else { + hooks[attributeName] = { + render: function () { + var i = 0, newAttr = attr ? attr.replace(live.attributeReplace, function () { + return elements.contentText(hook.computes[i++]()); + }) : elements.contentText(hook.computes[i++]()); + return newAttr; + }, + computes: [compute], + batchNum: undefined + }; + } + hook = hooks[attributeName]; + goodParts.splice(1, 0, compute()); + elements.setAttr(el, attributeName, goodParts.join('')); + }, + specialAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, getValue(newVal)); + }); + elements.setAttr(el, attributeName, getValue(compute())); + }, + simpleAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, newVal); + }); + elements.setAttr(el, attributeName, compute()); + } + }; + live.attr = live.simpleAttribute; + live.attrs = live.attributes; + var newLine = /(\r|\n)+/g; + var getValue = function (val) { + var regexp = /^["'].*["']$/; + val = val.replace(elements.attrReg, '').replace(newLine, ''); + return regexp.test(val) ? val.substr(1, val.length - 2) : val; + }; + can.view.live = live; + return live; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/modifiers.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/modifiers.js new file mode 100644 index 0000000000..7fa96c0e41 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/modifiers.js @@ -0,0 +1,100 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/modifiers/modifiers*/ +define([ + 'jquery', + 'can/util/library', + 'can/view' +], function ($, can) { + $ = $ || window.$; + var convert, modify, isTemplate, isHTML, isDOM, getCallback, noHookup = { + 'val': true, + 'text': true + }; + convert = function (func_name) { + var old = $.fn[func_name]; + $.fn[func_name] = function () { + var args = can.makeArray(arguments), callbackNum, callback, self = this, result; + if (can.isDeferred(args[0])) { + args[0].done(function (res) { + modify.call(self, [res], old); + }); + return this; + } else if (isTemplate(args)) { + if (callbackNum = getCallback(args)) { + callback = args[callbackNum]; + args[callbackNum] = function (result) { + modify.call(self, [result], old); + callback.call(self, result); + }; + can.view.apply(can.view, args); + return this; + } + result = can.view.apply(can.view, args); + if (!can.isDeferred(result)) { + args = [result]; + } else { + result.done(function (res) { + modify.call(self, [res], old); + }); + return this; + } + } + return noHookup[func_name] ? old.apply(this, args) : modify.call(this, args, old); + }; + }; + modify = function (args, old) { + var res; + for (var hasHookups in can.view.hookups) { + break; + } + if (hasHookups && args[0] && isHTML(args[0])) { + args[0] = can.view.frag(args[0]).childNodes; + } + res = old.apply(this, args); + return res; + }; + isTemplate = function (args) { + var secArgType = typeof args[1]; + return typeof args[0] === 'string' && (secArgType === 'object' || secArgType === 'function') && !isDOM(args[1]); + }; + isDOM = function (arg) { + return arg.nodeType || arg[0] && arg[0].nodeType; + }; + isHTML = function (arg) { + if (isDOM(arg)) { + return true; + } else if (typeof arg === 'string') { + arg = can.trim(arg); + return arg.substr(0, 1) === '<' && arg.substr(arg.length - 1, 1) === '>' && arg.length >= 3; + } else { + return false; + } + }; + getCallback = function (args) { + return typeof args[3] === 'function' ? 3 : typeof args[2] === 'function' && 2; + }; + $.fn.hookup = function () { + can.view.frag(this); + return this; + }; + can.each([ + 'prepend', + 'append', + 'after', + 'before', + 'text', + 'html', + 'replaceWith', + 'val' + ], function (func) { + convert(func); + }); + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/mustache.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/mustache.js new file mode 100644 index 0000000000..17c72169f2 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/mustache.js @@ -0,0 +1,510 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/mustache/mustache*/ +define([ + 'can/util/library', + 'can/view/scope', + 'can/view', + 'can/scanner', + 'can/compute', + 'can/render', + 'can/view/bindings' +], function (can) { + can.view.ext = '.mustache'; + var SCOPE = 'scope', HASH = '___h4sh', CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options}', SPECIAL_CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options, special: true}', ARG_NAMES = SCOPE + ',options', argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false|null|undefined)|((.+?)=(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false)|(.+))))$/, makeLookupLiteral = function (type) { + return '{get:"' + type.replace(/"/g, '\\"') + '"}'; + }, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, isObserveLike = function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, isArrayLike = function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, makeConvertToScopes = function (original, scope, options) { + var originalWithScope = function (ctx, opts) { + return original(ctx || scope, opts); + }; + return function (updatedScope, updatedOptions) { + if (updatedScope !== undefined && !(updatedScope instanceof can.view.Scope)) { + updatedScope = scope.add(updatedScope); + } + if (updatedOptions !== undefined && !(updatedOptions instanceof can.view.Options)) { + updatedOptions = options.add(updatedOptions); + } + return originalWithScope(updatedScope, updatedOptions || options); + }; + }; + var Mustache = function (options, helpers) { + if (this.constructor !== Mustache) { + var mustache = new Mustache(options); + return function (data, options) { + return mustache.render(data, options); + }; + } + if (typeof options === 'function') { + this.template = { fn: options }; + return; + } + can.extend(this, options); + this.template = this.scanner.scan(this.text, this.name); + }; + can.Mustache = can.global.Mustache = Mustache; + Mustache.prototype.render = function (data, options) { + if (!(data instanceof can.view.Scope)) { + data = new can.view.Scope(data || {}); + } + if (!(options instanceof can.view.Options)) { + options = new can.view.Options(options || {}); + } + options = options || {}; + return this.template.fn.call(data, data, options); + }; + can.extend(Mustache.prototype, { + scanner: new can.view.Scanner({ + text: { + start: '', + scope: SCOPE, + options: ',options: options', + argNames: ARG_NAMES + }, + tokens: [ + [ + 'returnLeft', + '{{{', + '{{[{&]' + ], + [ + 'commentFull', + '{{!}}', + '^[\\s\\t]*{{!.+?}}\\n' + ], + [ + 'commentLeft', + '{{!', + '(\\n[\\s\\t]*{{!|{{!)' + ], + [ + 'escapeFull', + '{{}}', + '(^[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}$)', + function (content) { + return { + before: /^\n.+?\n$/.test(content) ? '\n' : '', + content: content.match(/\{\{(.+?)\}\}/)[1] || '' + }; + } + ], + [ + 'escapeLeft', + '{{' + ], + [ + 'returnRight', + '}}}' + ], + [ + 'right', + '}}' + ] + ], + helpers: [ + { + name: /^>[\s]*\w*/, + fn: function (content, cmd) { + var templateName = can.trim(content.replace(/^>\s?/, '')).replace(/["|']/g, ''); + return 'can.Mustache.renderPartial(\'' + templateName + '\',' + ARG_NAMES + ')'; + } + }, + { + name: /^\s*data\s/, + fn: function (content, cmd) { + var attr = content.match(/["|'](.*)["|']/)[1]; + return 'can.proxy(function(__){' + 'can.data(can.$(__),\'' + attr + '\', this.attr(\'.\')); }, ' + SCOPE + ')'; + } + }, + { + name: /\s*\(([\$\w]+)\)\s*->([^\n]*)/, + fn: function (content) { + var quickFunc = /\s*\(([\$\w]+)\)\s*->([^\n]*)/, parts = content.match(quickFunc); + return 'can.proxy(function(__){var ' + parts[1] + '=can.$(__);with(' + SCOPE + '.attr(\'.\')){' + parts[2] + '}}, this);'; + } + }, + { + name: /^.*$/, + fn: function (content, cmd) { + var mode = false, result = { + content: '', + startTxt: false, + startOnlyTxt: false, + end: false + }; + content = can.trim(content); + if (content.length && (mode = content.match(/^([#^\/]|else$)/))) { + mode = mode[0]; + switch (mode) { + case '#': + case '^': + if (cmd.specialAttribute) { + result.startOnlyTxt = true; + } else { + result.startTxt = true; + result.escaped = 0; + } + break; + case '/': + result.end = true; + result.content += 'return ___v1ew.join("");}}])'; + return result; + } + content = content.substring(1); + } + if (mode !== 'else') { + var args = [], hashes = [], i = 0, m; + result.content += 'can.Mustache.txt(\n' + (cmd.specialAttribute ? SPECIAL_CONTEXT_OBJ : CONTEXT_OBJ) + ',\n' + (mode ? '"' + mode + '"' : 'null') + ','; + (can.trim(content) + ' ').replace(argumentsRegExp, function (whole, arg) { + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[2]) { + args.push(m[0]); + } else { + hashes.push(m[4] + ':' + (m[6] ? m[6] : makeLookupLiteral(m[5]))); + } + } else { + args.push(makeLookupLiteral(arg)); + } + i++; + }); + result.content += args.join(','); + if (hashes.length) { + result.content += ',{' + HASH + ':{' + hashes.join(',') + '}}'; + } + } + if (mode && mode !== 'else') { + result.content += ',[\n\n'; + } + switch (mode) { + case '^': + case '#': + result.content += '{fn:function(' + ARG_NAMES + '){var ___v1ew = [];'; + break; + case 'else': + result.content += 'return ___v1ew.join("");}},\n{inverse:function(' + ARG_NAMES + '){\nvar ___v1ew = [];'; + break; + default: + result.content += ')'; + break; + } + if (!mode) { + result.startTxt = true; + result.end = true; + } + return result; + } + } + ] + }) + }); + var helpers = can.view.Scanner.prototype.helpers; + for (var i = 0; i < helpers.length; i++) { + Mustache.prototype.scanner.helpers.unshift(helpers[i]); + } + Mustache.txt = function (scopeAndOptions, mode, name) { + var scope = scopeAndOptions.scope, options = scopeAndOptions.options, args = [], helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, hash, context = scope.attr('.'), getHelper = true, helper; + for (var i = 3; i < arguments.length; i++) { + var arg = arguments[i]; + if (mode && can.isArray(arg)) { + helperOptions = can.extend.apply(can, [helperOptions].concat(arg)); + } else if (arg && arg[HASH]) { + hash = arg[HASH]; + for (var prop in hash) { + if (isLookup(hash[prop])) { + hash[prop] = Mustache.get(hash[prop].get, scopeAndOptions, false, true); + } + } + } else if (arg && isLookup(arg)) { + args.push(Mustache.get(arg.get, scopeAndOptions, false, true, true)); + } else { + args.push(arg); + } + } + if (isLookup(name)) { + var get = name.get; + name = Mustache.get(name.get, scopeAndOptions, args.length, false); + getHelper = get === name; + } + helperOptions.fn = makeConvertToScopes(helperOptions.fn, scope, options); + helperOptions.inverse = makeConvertToScopes(helperOptions.inverse, scope, options); + if (mode === '^') { + var tmp = helperOptions.fn; + helperOptions.fn = helperOptions.inverse; + helperOptions.inverse = tmp; + } + if (helper = getHelper && (typeof name === 'string' && Mustache.getHelper(name, options)) || can.isFunction(name) && !name.isComputed && { fn: name }) { + can.extend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash + }); + args.push(helperOptions); + return function () { + return helper.fn.apply(context, args) || ''; + }; + } + return function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + var validArgs = args.length ? args : [value], valid = true, result = [], i, argIsObserve, arg; + if (mode) { + for (i = 0; i < validArgs.length; i++) { + arg = validArgs[i]; + argIsObserve = typeof arg !== 'undefined' && isObserveLike(arg); + if (isArrayLike(arg)) { + if (mode === '#') { + valid = valid && !!(argIsObserve ? arg.attr('length') : arg.length); + } else if (mode === '^') { + valid = valid && !(argIsObserve ? arg.attr('length') : arg.length); + } + } else { + valid = mode === '#' ? valid && !!arg : mode === '^' ? valid && !arg : valid; + } + } + } + if (valid) { + if (mode === '#') { + if (isArrayLike(value)) { + var isObserveList = isObserveLike(value); + for (i = 0; i < value.length; i++) { + result.push(helperOptions.fn(isObserveList ? value.attr('' + i) : value[i])); + } + return result.join(''); + } else { + return helperOptions.fn(value || {}) || ''; + } + } else if (mode === '^') { + return helperOptions.inverse(value || {}) || ''; + } else { + return '' + (value != null ? value : ''); + } + } + return ''; + }; + }; + Mustache.get = function (key, scopeAndOptions, isHelper, isArgument, isLookup) { + var context = scopeAndOptions.scope.attr('.'), options = scopeAndOptions.options || {}; + if (isHelper) { + if (Mustache.getHelper(key, options)) { + return key; + } + if (scopeAndOptions.scope && can.isFunction(context[key])) { + return context[key]; + } + can.dev.warn('can/view/mustache/mustache.js: Unable to find helper "' + key + '".'); + } + var computeData = scopeAndOptions.scope.computeData(key, { + isArgument: isArgument, + args: [ + context, + scopeAndOptions.scope + ] + }), compute = computeData.compute; + can.compute.temporarilyBind(compute); + var initialValue = computeData.initialValue, helperObj = Mustache.getHelper(key, options); + if (initialValue === undefined && !isHelper && !helperObj) { + can.dev.warn('can/view/mustache/mustache.js: Unable to find key "' + key + '".'); + } + if (!isLookup && (initialValue === undefined || computeData.scope !== scopeAndOptions.scope) && Mustache.getHelper(key, options)) { + return key; + } + if (!compute.computeInstance.hasDependencies) { + return initialValue; + } else { + return compute; + } + }; + Mustache.resolve = function (value) { + if (isObserveLike(value) && isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + can.view.Options = can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }); + Mustache._helpers = {}; + Mustache.registerHelper = function (name, fn) { + this._helpers[name] = { + name: name, + fn: fn + }; + }; + Mustache.getHelper = function (name, options) { + var helper; + if (options) { + helper = options.attr('helpers.' + name); + } + return helper ? { fn: helper } : this._helpers[name]; + }; + Mustache.render = function (partial, scope, options) { + if (!can.view.cached[partial]) { + var reads = can.__clearReading(); + var scopePartialName = scope.attr(partial); + if (scopePartialName) { + partial = scopePartialName; + } + can.__setReading(reads); + } + return can.view.render(partial, scope, options); + }; + Mustache.safeString = function (str) { + return { + toString: function () { + return str; + } + }; + }; + Mustache.renderPartial = function (partialName, scope, options) { + var partial = options.attr('partials.' + partialName); + if (partial) { + return partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + return can.Mustache.render(partialName, scope, options); + } + }; + can.each({ + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!Mustache.resolve(expr); + } + if (value) { + return options.fn(options.contexts || this); + } else { + return options.inverse(options.contexts || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = Mustache.resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return Mustache._helpers.is.fn.apply(this, arguments); + }, + 'unless': function (expr, options) { + return Mustache._helpers['if'].fn.apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'each': function (expr, options) { + var resolved = Mustache.resolve(expr), result = [], keys, key, i; + if (can.view.lists && (resolved instanceof can.List || expr && expr.isComputed && resolved === undefined)) { + return can.view.lists(expr, function (item, index) { + return options.fn(options.scope.add({ '@index': index }).add(item)); + }); + } + expr = resolved; + if (!!expr && isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + return result.join(''); + } else if (isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } + }, + 'with': function (expr, options) { + var ctx = expr; + expr = Mustache.resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + } + }, function (fn, name) { + Mustache.registerHelper(name, fn); + }); + can.view.register({ + suffix: 'mustache', + contentType: 'x-mustache-template', + script: function (id, src) { + return 'can.Mustache(function(' + ARG_NAMES + ') { ' + new Mustache({ + text: src, + name: id + }).template.out + ' })'; + }, + renderer: function (id, text) { + return Mustache({ + text: text, + name: id + }); + } + }); + can.mustache.registerHelper = can.proxy(can.Mustache.registerHelper, can.Mustache); + can.mustache.safeString = can.Mustache.safeString; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/mustache_core.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/mustache_core.js new file mode 100644 index 0000000000..d59fc1c109 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/mustache_core.js @@ -0,0 +1,330 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/stache/mustache_core*/ +define([ + 'can/util/library', + 'can/view/utils', + 'can/view/mustache_helpers', + 'can/view/live', + 'can/elements', + 'can/view/scope', + 'can/view/node_lists' +], function (can, utils, mustacheHelpers, live, elements, Scope, nodeLists) { + live = live || can.view.live; + elements = elements || can.view.elements; + Scope = Scope || can.view.Scope; + nodeLists = nodeLists || can.view.nodeLists; + var argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(?:(.+?)=(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(.+))))$/, mustacheLineBreakRegExp = /(?:(?:^|(\r?)\n)(\s*)(\{\{([^\}]*)\}\}\}?)([^\S\n\r]*)($|\r?\n))|(\{\{([^\}]*)\}\}\}?)/g, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, getItemsFragContent = function (items, isObserveList, helperOptions, options) { + var frag = document.createDocumentFragment(); + for (var i = 0, len = items.length; i < len; i++) { + append(frag, helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options)); + } + return frag; + }, append = function (frag, content) { + if (content) { + frag.appendChild(typeof content === 'string' ? document.createTextNode(content) : content); + } + }, getItemsStringContent = function (items, isObserveList, helperOptions, options) { + var txt = ''; + for (var i = 0, len = items.length; i < len; i++) { + txt += helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options); + } + return txt; + }, getKeyComputeData = function (key, scope, isArgument) { + var data = scope.computeData(key, { + isArgument: isArgument, + args: [ + scope.attr('.'), + scope + ] + }); + can.compute.temporarilyBind(data.compute); + return data; + }, getKeyArgValue = function (key, scope) { + var data = getKeyComputeData(key, scope, true); + if (!data.compute.computeInstance.hasDependencies) { + return data.initialValue; + } else { + return data.compute; + } + }, convertToScopes = function (helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer) { + if (truthyRenderer) { + helperOptions.fn = makeRendererConvertScopes(truthyRenderer, scope, options, nodeList); + } + if (falseyRenderer) { + helperOptions.inverse = makeRendererConvertScopes(falseyRenderer, scope, options, nodeList); + } + }, makeRendererConvertScopes = function (renderer, parentScope, parentOptions, nodeList) { + var rendererWithScope = function (ctx, opts, parentNodeList) { + return renderer(ctx || parentScope, opts, parentNodeList); + }; + return can.__notObserve(function (newScope, newOptions, parentNodeList) { + if (newScope !== undefined && !(newScope instanceof can.view.Scope)) { + newScope = parentScope.add(newScope); + } + if (newOptions !== undefined && !(newOptions instanceof core.Options)) { + newOptions = parentOptions.add(newOptions); + } + var result = rendererWithScope(newScope, newOptions || parentOptions, parentNodeList || nodeList); + return result; + }); + }; + var core = { + expressionData: function (expression) { + var args = [], hashes = {}, i = 0; + (can.trim(expression) + ' ').replace(argumentsRegExp, function (whole, arg) { + var m; + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[1] || m[2]) { + args.push(utils.jsonParse(m[1] || m[2])); + } else { + hashes[m[3]] = m[6] ? { get: m[6] } : utils.jsonParse(m[4] || m[5]); + } + } else { + args.push({ get: arg }); + } + i++; + }); + return { + name: args.shift(), + args: args, + hash: hashes + }; + }, + makeEvaluator: function (scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, stringOnly) { + var args = [], hash = {}, helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, context = scope.attr('.'), name = exprData.name, helper, looksLikeAHelper = exprData.args.length || !can.isEmptyObject(exprData.hash), initialValue, helperEvaluator; + for (var i = 0, len = exprData.args.length; i < len; i++) { + var arg = exprData.args[i]; + if (arg && isLookup(arg)) { + args.push(getKeyArgValue(arg.get, scope, true)); + } else { + args.push(arg); + } + } + for (var prop in exprData.hash) { + if (isLookup(exprData.hash[prop])) { + hash[prop] = getKeyArgValue(exprData.hash[prop].get, scope); + } else { + hash[prop] = exprData.hash[prop]; + } + } + if (isLookup(name)) { + if (looksLikeAHelper) { + helper = mustacheHelpers.getHelper(name.get, options); + if (!helper && typeof context[name.get] === 'function') { + helper = { fn: context[name.get] }; + } + } + if (!helper) { + var get = name.get; + var computeData = getKeyComputeData(name.get, scope, false), compute = computeData.compute; + initialValue = computeData.initialValue; + if (computeData.compute.computeInstance.hasDependencies) { + name = compute; + } else { + name = initialValue; + } + if (!looksLikeAHelper && initialValue === undefined) { + helper = mustacheHelpers.getHelper(get, options); + } else if (typeof initialValue === 'function') { + helper = { fn: initialValue }; + } + } + if (!helper && initialValue === undefined) { + if (looksLikeAHelper) { + can.dev.warn('can/view/stache/mustache_core.js: Unable to find helper "' + exprData.name.get + '".'); + } else { + can.dev.warn('can/view/stache/mustache_core.js: Unable to find key or helper "' + exprData.name.get + '".'); + } + } + } + if (mode === '^') { + var temp = truthyRenderer; + truthyRenderer = falseyRenderer; + falseyRenderer = temp; + } + if (helper) { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + can.simpleExtend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash, + nodeList: nodeList, + exprData: exprData + }); + args.push(helperOptions); + helperEvaluator = function () { + return helper.fn.apply(context, args) || ''; + }; + helperEvaluator.bindOnce = false; + return helperEvaluator; + } + if (!mode) { + if (name && name.isComputed) { + return name; + } else { + return function () { + return '' + (name != null ? name : ''); + }; + } + } else if (mode === '#' || mode === '^') { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + var evaluator = function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + if (utils.isArrayLike(value)) { + var isObserveList = utils.isObserveLike(value); + if (isObserveList ? value.attr('length') : value.length) { + return (stringOnly ? getItemsStringContent : getItemsFragContent)(value, isObserveList, helperOptions, options); + } else { + return helperOptions.inverse(scope, options); + } + } else { + return value ? helperOptions.fn(value || scope, options) : helperOptions.inverse(scope, options); + } + }; + evaluator.bindOnce = false; + return evaluator; + } else { + } + }, + makeLiveBindingPartialRenderer: function (partialName, state) { + partialName = can.trim(partialName); + return function (scope, options, parentSectionNodeList) { + var nodeList = [this]; + nodeList.expression = '>' + partialName; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var partialFrag = can.compute(function () { + var localPartialName = partialName; + var partial = options.attr('partials.' + localPartialName), res; + if (partial) { + res = partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + var scopePartialName = scope.read(localPartialName, { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }).value; + if (scopePartialName) { + localPartialName = scopePartialName; + } + res = can.view.render(localPartialName, scope, options); + } + return can.frag(res); + }); + live.html(this, partialFrag, this.parentNode, nodeList); + }; + }, + makeStringBranchRenderer: function (mode, expression) { + var exprData = expressionData(expression), fullExpression = mode + expression; + return function branchRenderer(scope, options, truthyRenderer, falseyRenderer) { + var evaluator = scope.__cache[fullExpression]; + if (mode || !evaluator) { + evaluator = makeEvaluator(scope, options, null, mode, exprData, truthyRenderer, falseyRenderer, true); + if (!mode) { + scope.__cache[fullExpression] = evaluator; + } + } + var res = evaluator(); + return res == null ? '' : '' + res; + }; + }, + makeLiveBindingBranchRenderer: function (mode, expression, state) { + var exprData = expressionData(expression); + return function branchRenderer(scope, options, parentSectionNodeList, truthyRenderer, falseyRenderer) { + var nodeList = [this]; + nodeList.expression = expression; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var evaluator = makeEvaluator(scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, state.tag); + var compute = can.compute(evaluator, null, false, evaluator.bindOnce === false ? false : true); + compute.bind('change', can.k); + var value = compute(); + if (typeof value === 'function') { + var old = can.__clearReading(); + value(this); + can.__setReading(old); + } else if (compute.computeInstance.hasDependencies) { + if (state.attr) { + live.simpleAttribute(this, state.attr, compute); + } else if (state.tag) { + live.attributes(this, compute); + } else if (state.text && typeof value !== 'object') { + live.text(this, compute, this.parentNode, nodeList); + } else { + live.html(this, compute, this.parentNode, nodeList); + } + } else { + if (state.attr) { + can.attr.set(this, state.attr, value); + } else if (state.tag) { + live.setAttributes(this, value); + } else if (state.text && typeof value === 'string') { + this.nodeValue = value; + } else if (value) { + elements.replace([this], can.frag(value)); + } + } + compute.unbind('change', can.k); + }; + }, + splitModeFromExpression: function (expression, state) { + expression = can.trim(expression); + var mode = expression.charAt(0); + if ('#/{&^>!'.indexOf(mode) >= 0) { + expression = can.trim(expression.substr(1)); + } else { + mode = null; + } + if (mode === '{' && state.node) { + mode = null; + } + return { + mode: mode, + expression: expression + }; + }, + cleanLineEndings: function (template) { + return template.replace(mustacheLineBreakRegExp, function (whole, returnBefore, spaceBefore, special, expression, spaceAfter, returnAfter, spaceLessSpecial, spaceLessExpression, matchIndex) { + spaceAfter = spaceAfter || ''; + returnBefore = returnBefore || ''; + spaceBefore = spaceBefore || ''; + var modeAndExpression = splitModeFromExpression(expression || spaceLessExpression, {}); + if (spaceLessSpecial || '>{'.indexOf(modeAndExpression.mode) >= 0) { + return whole; + } else if ('^#!/'.indexOf(modeAndExpression.mode) >= 0) { + return special + (matchIndex !== 0 && returnAfter.length ? returnBefore + '\n' : ''); + } else { + return spaceBefore + special + spaceAfter + (spaceBefore.length || matchIndex !== 0 ? returnBefore + '\n' : ''); + } + }); + }, + Options: can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }) + }; + var makeEvaluator = core.makeEvaluator, expressionData = core.expressionData, splitModeFromExpression = core.splitModeFromExpression; + return core; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/mustache_helpers.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/mustache_helpers.js new file mode 100644 index 0000000000..f79b8f4281 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/mustache_helpers.js @@ -0,0 +1,144 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/stache/mustache_helpers*/ +define([ + 'can/util/library', + 'can/view/utils', + 'can/view/live' +], function (can, utils, live) { + live = live || can.view.live; + var resolve = function (value) { + if (utils.isObserveLike(value) && utils.isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + var helpers = { + 'each': function (items, options) { + var resolved = resolve(items), result = [], keys, key, i; + if (resolved instanceof can.List) { + return function (el) { + var nodeList = [el]; + nodeList.expression = 'live.list'; + can.view.nodeLists.register(nodeList, null, options.nodeList); + can.view.nodeLists.update(options.nodeList, [el]); + var cb = function (item, index, parentNodeList) { + return options.fn(options.scope.add({ '@index': index }).add(item), options.options, parentNodeList); + }; + live.list(el, items, cb, options.context, el.parentNode, nodeList); + }; + } + var expr = resolved; + if (!!expr && utils.isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + } else if (utils.isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } + return result; + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + }, + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!resolve(expr); + } + if (value) { + return options.fn(options.scope || this); + } else { + return options.inverse(options.scope || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return helpers.is.apply(this, arguments); + }, + 'unless': function (expr, options) { + return helpers['if'].apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'with': function (expr, options) { + var ctx = expr; + expr = resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + 'data': function (attr) { + var data = arguments.length === 2 ? this : arguments[1]; + return function (el) { + can.data(can.$(el), attr, data || this.context); + }; + } + }; + return { + registerHelper: function (name, callback) { + helpers[name] = callback; + }, + getHelper: function (name, options) { + var helper = options.attr('helpers.' + name); + if (!helper) { + helper = helpers[name]; + } + if (helper) { + return { fn: helper }; + } + } + }; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/node_lists.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/node_lists.js new file mode 100644 index 0000000000..0f78dd87c6 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/node_lists.js @@ -0,0 +1,176 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/node_lists/node_lists*/ +define([ + 'can/util/library', + 'can/elements' +], function (can) { + var canExpando = true; + try { + document.createTextNode('')._ = 0; + } catch (ex) { + canExpando = false; + } + var nodeMap = {}, textNodeMap = {}, expando = 'ejs_' + Math.random(), _id = 0, id = function (node, localMap) { + var _textNodeMap = localMap || textNodeMap; + var id = readId(node, _textNodeMap); + if (id) { + return id; + } else { + if (canExpando || node.nodeType !== 3) { + ++_id; + return node[expando] = (node.nodeName ? 'element_' : 'obj_') + _id; + } else { + ++_id; + _textNodeMap['text_' + _id] = node; + return 'text_' + _id; + } + } + }, readId = function (node, textNodeMap) { + if (canExpando || node.nodeType !== 3) { + return node[expando]; + } else { + for (var textNodeID in textNodeMap) { + if (textNodeMap[textNodeID] === node) { + return textNodeID; + } + } + } + }, splice = [].splice, push = [].push, itemsInChildListTree = function (list) { + var count = 0; + for (var i = 0, len = list.length; i < len; i++) { + var item = list[i]; + if (item.nodeType) { + count++; + } else { + count += itemsInChildListTree(item); + } + } + return count; + }, replacementMap = function (replacements, idMap) { + var map = {}; + for (var i = 0, len = replacements.length; i < len; i++) { + var node = nodeLists.first(replacements[i]); + map[id(node, idMap)] = replacements[i]; + } + return map; + }; + var nodeLists = { + id: id, + update: function (nodeList, newNodes) { + var oldNodes = nodeLists.unregisterChildren(nodeList); + newNodes = can.makeArray(newNodes); + var oldListLength = nodeList.length; + splice.apply(nodeList, [ + 0, + oldListLength + ].concat(newNodes)); + if (nodeList.replacements) { + nodeLists.nestReplacements(nodeList); + } else { + nodeLists.nestList(nodeList); + } + return oldNodes; + }, + nestReplacements: function (list) { + var index = 0, idMap = {}, rMap = replacementMap(list.replacements, idMap), rCount = list.replacements.length; + while (index < list.length && rCount) { + var node = list[index], replacement = rMap[readId(node, idMap)]; + if (replacement) { + list.splice(index, itemsInChildListTree(replacement), replacement); + rCount--; + } + index++; + } + list.replacements = []; + }, + nestList: function (list) { + var index = 0; + while (index < list.length) { + var node = list[index], childNodeList = nodeMap[id(node)]; + if (childNodeList) { + if (childNodeList !== list) { + list.splice(index, itemsInChildListTree(childNodeList), childNodeList); + } + } else { + nodeMap[id(node)] = list; + } + index++; + } + }, + last: function (nodeList) { + var last = nodeList[nodeList.length - 1]; + if (last.nodeType) { + return last; + } else { + return nodeLists.last(last); + } + }, + first: function (nodeList) { + var first = nodeList[0]; + if (first.nodeType) { + return first; + } else { + return nodeLists.first(first); + } + }, + flatten: function (nodeList) { + var items = []; + for (var i = 0; i < nodeList.length; i++) { + var item = nodeList[i]; + if (item.nodeType) { + items.push(item); + } else { + items.push.apply(items, nodeLists.flatten(item)); + } + } + return items; + }, + register: function (nodeList, unregistered, parent) { + nodeList.unregistered = unregistered; + nodeList.parentList = parent; + if (parent === true) { + nodeList.replacements = []; + } else if (parent) { + parent.replacements.push(nodeList); + nodeList.replacements = []; + } else { + nodeLists.nestList(nodeList); + } + return nodeList; + }, + unregisterChildren: function (nodeList) { + var nodes = []; + can.each(nodeList, function (node) { + if (node.nodeType) { + if (!nodeList.replacements) { + delete nodeMap[id(node)]; + } + nodes.push(node); + } else { + push.apply(nodes, nodeLists.unregister(node)); + } + }); + return nodes; + }, + unregister: function (nodeList) { + var nodes = nodeLists.unregisterChildren(nodeList); + if (nodeList.unregistered) { + var unregisteredCallback = nodeList.unregistered; + delete nodeList.unregistered; + delete nodeList.replacements; + unregisteredCallback(); + } + return nodes; + }, + nodeMap: nodeMap + }; + can.view.nodeLists = nodeLists; + return nodeLists; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/parser.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/parser.js new file mode 100644 index 0000000000..6faed24175 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/parser.js @@ -0,0 +1,189 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/parser/parser*/ +define(['can/view'], function (can) { + function makeMap(str) { + var obj = {}, items = str.split(','); + for (var i = 0; i < items.length; i++) { + obj[items[i]] = true; + } + return obj; + } + function handleIntermediate(intermediate, handler) { + for (var i = 0, len = intermediate.length; i < len; i++) { + var item = intermediate[i]; + handler[item.tokenType].apply(handler, item.args); + } + return intermediate; + } + var alphaNumericHU = '-:A-Za-z0-9_', attributeNames = '[a-zA-Z_:][' + alphaNumericHU + ':.]*', spaceEQspace = '\\s*=\\s*', dblQuote2dblQuote = '"((?:\\\\.|[^"])*)"', quote2quote = '\'((?:\\\\.|[^\'])*)\'', attributeEqAndValue = '(?:' + spaceEQspace + '(?:' + '(?:"[^"]*")|(?:\'[^\']*\')|[^>\\s]+))?', matchStash = '\\{\\{[^\\}]*\\}\\}\\}?', stash = '\\{\\{([^\\}]*)\\}\\}\\}?', startTag = new RegExp('^<([' + alphaNumericHU + ']+)' + '(' + '(?:\\s*' + '(?:(?:' + '(?:' + attributeNames + ')?' + attributeEqAndValue + ')|' + '(?:' + matchStash + ')+)' + ')*' + ')\\s*(\\/?)>'), endTag = new RegExp('^<\\/([' + alphaNumericHU + ']+)[^>]*>'), attr = new RegExp('(?:' + '(?:(' + attributeNames + ')|' + stash + ')' + '(?:' + spaceEQspace + '(?:' + '(?:' + dblQuote2dblQuote + ')|(?:' + quote2quote + ')|([^>\\s]+)' + ')' + ')?)', 'g'), mustache = new RegExp(stash, 'g'), txtBreak = /<|\{\{/; + var empty = makeMap('area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed'); + var block = makeMap('a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video'); + var inline = makeMap('abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var'); + var closeSelf = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr'); + var fillAttrs = makeMap('checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected'); + var special = makeMap('script,style'); + var tokenTypes = 'start,end,close,attrStart,attrEnd,attrValue,chars,comment,special,done'.split(','); + var fn = function () { + }; + var HTMLParser = function (html, handler, returnIntermediate) { + if (typeof html === 'object') { + return handleIntermediate(html, handler); + } + var intermediate = []; + handler = handler || {}; + if (returnIntermediate) { + can.each(tokenTypes, function (name) { + var callback = handler[name] || fn; + handler[name] = function () { + if (callback.apply(this, arguments) !== false) { + intermediate.push({ + tokenType: name, + args: can.makeArray(arguments) + }); + } + }; + }); + } + function parseStartTag(tag, tagName, rest, unary) { + tagName = tagName.toLowerCase(); + if (block[tagName]) { + while (stack.last() && inline[stack.last()]) { + parseEndTag('', stack.last()); + } + } + if (closeSelf[tagName] && stack.last() === tagName) { + parseEndTag('', tagName); + } + unary = empty[tagName] || !!unary; + handler.start(tagName, unary); + if (!unary) { + stack.push(tagName); + } + HTMLParser.parseAttrs(rest, handler); + handler.end(tagName, unary); + } + function parseEndTag(tag, tagName) { + var pos; + if (!tagName) { + pos = 0; + } else { + for (pos = stack.length - 1; pos >= 0; pos--) { + if (stack[pos] === tagName) { + break; + } + } + } + if (pos >= 0) { + for (var i = stack.length - 1; i >= pos; i--) { + if (handler.close) { + handler.close(stack[i]); + } + } + stack.length = pos; + } + } + function parseMustache(mustache, inside) { + if (handler.special) { + handler.special(inside); + } + } + var index, chars, match, stack = [], last = html; + stack.last = function () { + return this[this.length - 1]; + }; + while (html) { + chars = true; + if (!stack.last() || !special[stack.last()]) { + if (html.indexOf(''); + if (index >= 0) { + if (handler.comment) { + handler.comment(html.substring(4, index)); + } + html = html.substring(index + 3); + chars = false; + } + } else if (html.indexOf(']*>'), function (all, text) { + text = text.replace(/|/g, '$1$2'); + if (handler.chars) { + handler.chars(text); + } + return ''; + }); + parseEndTag('', stack.last()); + } + if (html === last) { + throw 'Parse Error: ' + html; + } + last = html; + } + parseEndTag(); + handler.done(); + return intermediate; + }; + HTMLParser.parseAttrs = function (rest, handler) { + (rest != null ? rest : '').replace(attr, function (text, name, special, dblQuote, singleQuote, val) { + if (special) { + handler.special(special); + } + if (name || dblQuote || singleQuote || val) { + var value = arguments[3] ? arguments[3] : arguments[4] ? arguments[4] : arguments[5] ? arguments[5] : fillAttrs[name.toLowerCase()] ? name : ''; + handler.attrStart(name || ''); + var last = mustache.lastIndex = 0, res = mustache.exec(value), chars; + while (res) { + chars = value.substring(last, mustache.lastIndex - res[0].length); + if (chars.length) { + handler.attrValue(chars); + } + handler.special(res[1]); + last = mustache.lastIndex; + res = mustache.exec(value); + } + chars = value.substr(last, value.length); + if (chars) { + handler.attrValue(chars); + } + handler.attrEnd(name || ''); + } + }); + }; + can.view.parser = HTMLParser; + return HTMLParser; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/scope.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/scope.js new file mode 100644 index 0000000000..e1e29664e1 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/scope.js @@ -0,0 +1,130 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/scope/scope*/ +define([ + 'can/util/library', + 'can/view/compute_data', + 'can/construct', + 'can/map', + 'can/list', + 'can/view', + 'can/compute' +], function (can, makeComputeData) { + var escapeReg = /(\\)?\./g, escapeDotReg = /\\\./g, getNames = function (attr) { + var names = [], last = 0; + attr.replace(escapeReg, function (first, second, index) { + if (!second) { + names.push(attr.slice(last, index).replace(escapeDotReg, '.')); + last = index + first.length; + } + }); + names.push(attr.slice(last).replace(escapeDotReg, '.')); + return names; + }; + var Scope = can.Construct.extend({ read: can.compute.read }, { + init: function (context, parent) { + this._context = context; + this._parent = parent; + this.__cache = {}; + }, + attr: can.__notObserve(function (key, value) { + var options = { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }, res = this.read(key, options); + if (arguments.length === 2) { + var lastIndex = key.lastIndexOf('.'), readKey = lastIndex !== -1 ? key.substring(0, lastIndex) : '.', obj = this.read(readKey, options).value; + if (lastIndex !== -1) { + key = key.substring(lastIndex + 1, key.length); + } + can.compute.set(obj, key, value, options); + } + return res.value; + }), + add: function (context) { + if (context !== this._context) { + return new this.constructor(context, this); + } else { + return this; + } + }, + computeData: function (key, options) { + return makeComputeData(this, key, options); + }, + compute: function (key, options) { + return this.computeData(key, options).compute; + }, + read: function (attr, options) { + var stopLookup; + if (attr.substr(0, 2) === './') { + stopLookup = true; + attr = attr.substr(2); + } else if (attr.substr(0, 3) === '../') { + return this._parent.read(attr.substr(3), options); + } else if (attr === '..') { + return { value: this._parent._context }; + } else if (attr === '.' || attr === 'this') { + return { value: this._context }; + } + var names = attr.indexOf('\\.') === -1 ? attr.split('.') : getNames(attr), context, scope = this, defaultObserve, defaultReads = [], defaultPropertyDepth = -1, defaultComputeReadings, defaultScope, currentObserve, currentReads; + while (scope) { + context = scope._context; + if (context !== null && (typeof context === 'object' || typeof context === 'function')) { + var data = can.compute.read(context, names, can.simpleExtend({ + foundObservable: function (observe, nameIndex) { + currentObserve = observe; + currentReads = names.slice(nameIndex); + }, + earlyExit: function (parentValue, nameIndex) { + if (nameIndex > defaultPropertyDepth) { + defaultObserve = currentObserve; + defaultReads = currentReads; + defaultPropertyDepth = nameIndex; + defaultScope = scope; + defaultComputeReadings = can.__clearReading(); + } + }, + executeAnonymousFunctions: true + }, options)); + if (data.value !== undefined) { + return { + scope: scope, + rootObserve: currentObserve, + value: data.value, + reads: currentReads + }; + } + } + can.__clearReading(); + if (!stopLookup) { + scope = scope._parent; + } else { + scope = null; + } + } + if (defaultObserve) { + can.__setReading(defaultComputeReadings); + return { + scope: defaultScope, + rootObserve: defaultObserve, + reads: defaultReads, + value: undefined + }; + } else { + return { + names: names, + value: undefined + }; + } + } + }); + can.view.Scope = Scope; + return Scope; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/stache.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/stache.js new file mode 100644 index 0000000000..cf881681b8 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/stache.js @@ -0,0 +1,274 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/stache/stache*/ +define([ + 'can/util/library', + 'can/view/parser', + 'can/view/target', + 'can/view/html_section', + 'can/view/text_section', + 'can/view/mustache_core', + 'can/view/mustache_helpers', + 'can/view/intermediate_and_imports', + 'can/view/callbacks', + 'can/view/bindings' +], function (can, parser, target, HTMLSectionBuilder, TextSectionBuilder, mustacheCore, mustacheHelpers, getIntermediateAndImports, viewCallbacks) { + parser = parser || can.view.parser; + viewCallbacks = viewCallbacks || can.view.callbacks; + var svgNamespace = 'http://www.w3.org/2000/svg'; + var namespaces = { + 'svg': svgNamespace, + 'g': svgNamespace + }; + function stache(template) { + if (typeof template === 'string') { + template = mustacheCore.cleanLineEndings(template); + } + var section = new HTMLSectionBuilder(), state = { + node: null, + attr: null, + sectionElementStack: [], + text: false, + namespaceStack: [] + }, makeRendererAndUpdateSection = function (section, mode, stache) { + if (mode === '>') { + section.add(mustacheCore.makeLiveBindingPartialRenderer(stache, state)); + } else if (mode === '/') { + section.endSection(); + if (section instanceof HTMLSectionBuilder) { + state.sectionElementStack.pop(); + } + } else if (mode === 'else') { + section.inverse(); + } else { + var makeRenderer = section instanceof HTMLSectionBuilder ? mustacheCore.makeLiveBindingBranchRenderer : mustacheCore.makeStringBranchRenderer; + if (mode === '{' || mode === '&') { + section.add(makeRenderer(null, stache, copyState())); + } else if (mode === '#' || mode === '^') { + section.startSection(makeRenderer(mode, stache, copyState())); + if (section instanceof HTMLSectionBuilder) { + state.sectionElementStack.push('section'); + } + } else { + section.add(makeRenderer(null, stache, copyState({ text: true }))); + } + } + }, copyState = function (overwrites) { + var lastElement = state.sectionElementStack[state.sectionElementStack.length - 1]; + var cur = { + tag: state.node && state.node.tag, + attr: state.attr && state.attr.name, + directlyNested: state.sectionElementStack.length ? lastElement === 'section' || lastElement === 'custom' : true + }; + return overwrites ? can.simpleExtend(cur, overwrites) : cur; + }, addAttributesCallback = function (node, callback) { + if (!node.attributes) { + node.attributes = []; + } + node.attributes.push(callback); + }; + parser(template, { + start: function (tagName, unary) { + var matchedNamespace = namespaces[tagName]; + if (matchedNamespace && !unary) { + state.namespaceStack.push(matchedNamespace); + } + state.node = { + tag: tagName, + children: [], + namespace: matchedNamespace || can.last(state.namespaceStack) + }; + }, + end: function (tagName, unary) { + var isCustomTag = viewCallbacks.tag(tagName); + if (unary) { + section.add(state.node); + if (isCustomTag) { + addAttributesCallback(state.node, function (scope, options, parentNodeList) { + viewCallbacks.tagHandler(this, tagName, { + scope: scope, + options: options, + subtemplate: null, + templateType: 'stache', + parentNodeList: parentNodeList + }); + }); + } + } else { + section.push(state.node); + state.sectionElementStack.push(isCustomTag ? 'custom' : 'element'); + if (isCustomTag) { + section.startSubSection(); + } + } + state.node = null; + }, + close: function (tagName) { + var matchedNamespace = namespaces[tagName]; + if (matchedNamespace) { + state.namespaceStack.pop(); + } + var isCustomTag = viewCallbacks.tag(tagName), renderer; + if (isCustomTag) { + renderer = section.endSubSectionAndReturnRenderer(); + } + var oldNode = section.pop(); + if (isCustomTag) { + addAttributesCallback(oldNode, function (scope, options, parentNodeList) { + viewCallbacks.tagHandler(this, tagName, { + scope: scope, + options: options, + subtemplate: renderer, + templateType: 'stache', + parentNodeList: parentNodeList + }); + }); + } + state.sectionElementStack.pop(); + }, + attrStart: function (attrName) { + if (state.node.section) { + state.node.section.add(attrName + '="'); + } else { + state.attr = { + name: attrName, + value: '' + }; + } + }, + attrEnd: function (attrName) { + if (state.node.section) { + state.node.section.add('" '); + } else { + if (!state.node.attrs) { + state.node.attrs = {}; + } + state.node.attrs[state.attr.name] = state.attr.section ? state.attr.section.compile(copyState()) : state.attr.value; + var attrCallback = viewCallbacks.attr(attrName); + if (attrCallback) { + if (!state.node.attributes) { + state.node.attributes = []; + } + state.node.attributes.push(function (scope, options) { + attrCallback(this, { + attributeName: attrName, + scope: scope, + options: options + }); + }); + } + state.attr = null; + } + }, + attrValue: function (value) { + var section = state.node.section || state.attr.section; + if (section) { + section.add(value); + } else { + state.attr.value += value; + } + }, + chars: function (text) { + section.add(text); + }, + special: function (text) { + var firstAndText = mustacheCore.splitModeFromExpression(text, state), mode = firstAndText.mode, expression = firstAndText.expression; + if (expression === 'else') { + (state.attr && state.attr.section ? state.attr.section : section).inverse(); + return; + } + if (mode === '!') { + return; + } + if (state.node && state.node.section) { + makeRendererAndUpdateSection(state.node.section, mode, expression); + if (state.node.section.subSectionDepth() === 0) { + state.node.attributes.push(state.node.section.compile(copyState())); + delete state.node.section; + } + } else if (state.attr) { + if (!state.attr.section) { + state.attr.section = new TextSectionBuilder(); + if (state.attr.value) { + state.attr.section.add(state.attr.value); + } + } + makeRendererAndUpdateSection(state.attr.section, mode, expression); + } else if (state.node) { + if (!state.node.attributes) { + state.node.attributes = []; + } + if (!mode) { + state.node.attributes.push(mustacheCore.makeLiveBindingBranchRenderer(null, expression, copyState())); + } else if (mode === '#' || mode === '^') { + if (!state.node.section) { + state.node.section = new TextSectionBuilder(); + } + makeRendererAndUpdateSection(state.node.section, mode, expression); + } else { + throw mode + ' is currently not supported within a tag.'; + } + } else { + makeRendererAndUpdateSection(section, mode, expression); + } + }, + comment: function (text) { + section.add({ comment: text }); + }, + done: function () { + } + }); + return section.compile(); + } + var escMap = { + '\n': '\\n', + '\r': '\\r', + '\u2028': '\\u2028', + '\u2029': '\\u2029' + }; + var esc = function (string) { + return ('' + string).replace(/["'\\\n\r\u2028\u2029]/g, function (character) { + if ('\'"\\'.indexOf(character) >= 0) { + return '\\' + character; + } else { + return escMap[character]; + } + }); + }; + can.view.register({ + suffix: 'stache', + contentType: 'x-stache-template', + fragRenderer: function (id, text) { + return stache(text); + }, + script: function (id, src) { + return 'can.stache("' + esc(src) + '")'; + } + }); + can.view.ext = '.stache'; + can.extend(can.stache, mustacheHelpers); + can.extend(stache, mustacheHelpers); + can.stache.safeString = stache.safeString = function (text) { + return { + toString: function () { + return text; + } + }; + }; + can.stache.async = function (source) { + var iAi = getIntermediateAndImports(source); + var importPromises = can.map(iAi.imports, function (moduleName) { + return can['import'](moduleName); + }); + return can.when.apply(can, importPromises).then(function () { + return stache(iAi.intermediate); + }); + }; + return stache; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/target.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/target.js new file mode 100644 index 0000000000..7036046ad7 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/target.js @@ -0,0 +1,167 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/target/target*/ +define([ + 'can/util/library', + 'can/elements' +], function (can, elements) { + var processNodes = function (nodes, paths, location) { + var frag = document.createDocumentFragment(); + for (var i = 0, len = nodes.length; i < len; i++) { + var node = nodes[i]; + frag.appendChild(processNode(node, paths, location.concat(i))); + } + return frag; + }, keepsTextNodes = typeof document !== 'undefined' && function () { + var testFrag = document.createDocumentFragment(); + var div = document.createElement('div'); + div.appendChild(document.createTextNode('')); + div.appendChild(document.createTextNode('')); + testFrag.appendChild(div); + var cloned = testFrag.cloneNode(true); + return cloned.childNodes[0].childNodes.length === 2; + }(), clonesWork = typeof document !== 'undefined' && function () { + var a = document.createElement('a'); + a.innerHTML = ''; + var clone = a.cloneNode(true); + return clone.innerHTML === ''; + }(), namespacesWork = typeof document !== 'undefined' && !!document.createElementNS; + var cloneNode = clonesWork ? function (el) { + return el.cloneNode(true); + } : function (node) { + var copy; + if (node.nodeType === 1) { + copy = document.createElement(node.nodeName); + } else if (node.nodeType === 3) { + copy = document.createTextNode(node.nodeValue); + } else if (node.nodeType === 8) { + copy = document.createComment(node.nodeValue); + } else if (node.nodeType === 11) { + copy = document.createDocumentFragment(); + } + if (node.attributes) { + var attributes = can.makeArray(node.attributes); + can.each(attributes, function (node) { + if (node && node.specified) { + copy.setAttribute(node.nodeName, node.nodeValue); + } + }); + } + if (node.childNodes) { + can.each(node.childNodes, function (child) { + copy.appendChild(cloneNode(child)); + }); + } + return copy; + }; + function processNode(node, paths, location) { + var callback, loc = location, nodeType = typeof node, el, p, i, len; + var getCallback = function () { + if (!callback) { + callback = { + path: location, + callbacks: [] + }; + paths.push(callback); + loc = []; + } + return callback; + }; + if (nodeType === 'object') { + if (node.tag) { + if (namespacesWork && node.namespace) { + el = document.createElementNS(node.namespace, node.tag); + } else { + el = document.createElement(node.tag); + } + if (node.attrs) { + for (var attrName in node.attrs) { + var value = node.attrs[attrName]; + if (typeof value === 'function') { + getCallback().callbacks.push({ callback: value }); + } else { + el.setAttribute(attrName, value); + } + } + } + if (node.attributes) { + for (i = 0, len = node.attributes.length; i < len; i++) { + getCallback().callbacks.push({ callback: node.attributes[i] }); + } + } + if (node.children && node.children.length) { + if (callback) { + p = callback.paths = []; + } else { + p = paths; + } + el.appendChild(processNodes(node.children, p, loc)); + } + } else if (node.comment) { + el = document.createComment(node.comment); + if (node.callbacks) { + for (i = 0, len = node.attributes.length; i < len; i++) { + getCallback().callbacks.push({ callback: node.callbacks[i] }); + } + } + } + } else if (nodeType === 'string') { + el = document.createTextNode(node); + } else if (nodeType === 'function') { + if (keepsTextNodes) { + el = document.createTextNode(''); + getCallback().callbacks.push({ callback: node }); + } else { + el = document.createComment('~'); + getCallback().callbacks.push({ + callback: function () { + var el = document.createTextNode(''); + elements.replace([this], el); + return node.apply(el, arguments); + } + }); + } + } + return el; + } + function hydratePath(el, pathData, args) { + var path = pathData.path, callbacks = pathData.callbacks, paths = pathData.paths, callbackData, child = el; + for (var i = 0, len = path.length; i < len; i++) { + child = child.childNodes[path[i]]; + } + for (i = 0, len = callbacks.length; i < len; i++) { + callbackData = callbacks[i]; + callbackData.callback.apply(child, args); + } + if (paths && paths.length) { + for (i = paths.length - 1; i >= 0; i--) { + hydratePath(child, paths[i], args); + } + } + } + function makeTarget(nodes) { + var paths = []; + var frag = processNodes(nodes, paths, []); + return { + paths: paths, + clone: frag, + hydrate: function () { + var cloned = cloneNode(this.clone); + var args = can.makeArray(arguments); + for (var i = paths.length - 1; i >= 0; i--) { + hydratePath(cloned, paths[i], args); + } + return cloned; + } + }; + } + makeTarget.keepsTextNodes = keepsTextNodes; + can.view.target = makeTarget; + return makeTarget; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/text_section.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/text_section.js new file mode 100644 index 0000000000..571ae3c9e6 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/text_section.js @@ -0,0 +1,98 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/stache/text_section*/ +define([ + 'can/util/library', + 'can/view/live', + 'can/view/utils' +], function (can, live, utils) { + live = live || can.view.live; + var TextSectionBuilder = function () { + this.stack = [new TextSection()]; + }, emptyHandler = function () { + }; + can.extend(TextSectionBuilder.prototype, utils.mixins); + can.extend(TextSectionBuilder.prototype, { + startSection: function (process) { + var subSection = new TextSection(); + this.last().add({ + process: process, + truthy: subSection + }); + this.stack.push(subSection); + }, + endSection: function () { + this.stack.pop(); + }, + inverse: function () { + this.stack.pop(); + var falseySection = new TextSection(); + this.last().last().falsey = falseySection; + this.stack.push(falseySection); + }, + compile: function (state) { + var renderer = this.stack[0].compile(); + return function (scope, options) { + var compute = can.compute(function () { + return renderer(scope, options); + }, this, false, true); + compute.bind('change', emptyHandler); + var value = compute(); + if (compute.computeInstance.hasDependencies) { + if (state.attr) { + live.simpleAttribute(this, state.attr, compute); + } else { + live.attributes(this, compute); + } + compute.unbind('change', emptyHandler); + } else { + if (state.attr) { + can.attr.set(this, state.attr, value); + } else { + live.setAttributes(this, value); + } + } + }; + } + }); + var passTruthyFalsey = function (process, truthy, falsey) { + return function (scope, options) { + return process.call(this, scope, options, truthy, falsey); + }; + }; + var TextSection = function () { + this.values = []; + }; + can.extend(TextSection.prototype, { + add: function (data) { + this.values.push(data); + }, + last: function () { + return this.values[this.values.length - 1]; + }, + compile: function () { + var values = this.values, len = values.length; + for (var i = 0; i < len; i++) { + var value = this.values[i]; + if (typeof value === 'object') { + values[i] = passTruthyFalsey(value.process, value.truthy && value.truthy.compile(), value.falsey && value.falsey.compile()); + } + } + return function (scope, options) { + var txt = '', value; + for (var i = 0; i < len; i++) { + value = values[i]; + txt += typeof value === 'string' ? value : value.call(this, scope, options); + } + return txt; + }; + } + }); + return TextSectionBuilder; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/utils.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/utils.js new file mode 100644 index 0000000000..21512a9c55 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd-dev/can/view/utils.js @@ -0,0 +1,43 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/stache/utils*/ +define(['can/util/library'], function () { + return { + isArrayLike: function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, + isObserveLike: function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, + emptyHandler: function () { + }, + jsonParse: function (str) { + if (str[0] === '\'') { + return str.substr(1, str.length - 2); + } else if (str === 'undefined') { + return undefined; + } else if (can.global.JSON) { + return JSON.parse(str); + } else { + return eval('(' + str + ')'); + } + }, + mixins: { + last: function () { + return this.stack[this.stack.length - 1]; + }, + add: function (chars) { + this.last().add(chars); + }, + subSectionDepth: function () { + return this.stack.length - 1; + } + } + }; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can.js new file mode 100644 index 0000000000..4098f41c55 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can.js @@ -0,0 +1,18 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#can*/ +define([ + 'can/util/library', + 'can/control/route', + 'can/model', + 'can/view/mustache', + 'can/component' +], function (can) { + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/bubble.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/bubble.js new file mode 100644 index 0000000000..1d24552a4f --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/bubble.js @@ -0,0 +1,115 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/bubble*/ +define(['can/util/library'], function (can) { + var bubble = can.bubble = { + event: function (map, boundEventName) { + return map.constructor._bubbleRule(boundEventName, map); + }, + childrenOf: function (parentMap, eventName) { + parentMap._each(function (child, prop) { + if (child && child.bind) { + bubble.toParent(child, parentMap, prop, eventName); + } + }); + }, + teardownChildrenFrom: function (parentMap, eventName) { + parentMap._each(function (child) { + bubble.teardownFromParent(parentMap, child, eventName); + }); + }, + toParent: function (child, parent, prop, eventName) { + can.listenTo.call(parent, child, eventName, function () { + var args = can.makeArray(arguments), ev = args.shift(); + args[0] = (can.List && parent instanceof can.List ? parent.indexOf(child) : prop) + (args[0] ? '.' + args[0] : ''); + ev.triggeredNS = ev.triggeredNS || {}; + if (ev.triggeredNS[parent._cid]) { + return; + } + ev.triggeredNS[parent._cid] = true; + can.trigger(parent, ev, args); + }); + }, + teardownFromParent: function (parent, child, eventName) { + if (child && child.unbind) { + can.stopListening.call(parent, child, eventName); + } + }, + isBubbling: function (parent, eventName) { + return parent._bubbleBindings && parent._bubbleBindings[eventName]; + }, + bind: function (parent, eventName) { + if (!parent._init) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + if (!parent._bubbleBindings) { + parent._bubbleBindings = {}; + } + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (!parent._bubbleBindings[bubbleEvent]) { + parent._bubbleBindings[bubbleEvent] = 1; + bubble.childrenOf(parent, bubbleEvent); + } else { + parent._bubbleBindings[bubbleEvent]++; + } + } + } + }, + unbind: function (parent, eventName) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (parent._bubbleBindings) { + parent._bubbleBindings[bubbleEvent]--; + } + if (parent._bubbleBindings && !parent._bubbleBindings[bubbleEvent]) { + delete parent._bubbleBindings[bubbleEvent]; + bubble.teardownChildrenFrom(parent, bubbleEvent); + if (can.isEmptyObject(parent._bubbleBindings)) { + delete parent._bubbleBindings; + } + } + } + }, + add: function (parent, child, prop) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + bubble.toParent(child, parent, prop, eventName); + } + } + } + }, + removeMany: function (parent, children) { + for (var i = 0, len = children.length; i < len; i++) { + bubble.remove(parent, children[i]); + } + }, + remove: function (parent, child) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + } + } + } + }, + set: function (parent, prop, value, current) { + if (can.Map.helpers.isObservable(value)) { + bubble.add(parent, value, prop); + } + if (can.Map.helpers.isObservable(current)) { + bubble.remove(parent, current); + } + return value; + } + }; + return bubble; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/component.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/component.js new file mode 100644 index 0000000000..abb3f3df61 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/component.js @@ -0,0 +1,274 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#component/component*/ +define([ + 'can/util/library', + 'can/view/callbacks', + 'can/elements', + 'can/control', + 'can/observe', + 'can/view/mustache', + 'can/view/bindings' +], function (can, viewCallbacks, elements) { + var ignoreAttributesRegExp = /^(dataViewId|class|id)$/i, paramReplacer = /\{([^\}]+)\}/g; + var Component = can.Component = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Component) { + var self = this, scope = this.prototype.scope || this.prototype.viewModel; + this.Control = ComponentControl.extend(this.prototype.events); + if (!scope || typeof scope === 'object' && !(scope instanceof can.Map)) { + this.Map = can.Map.extend(scope || {}); + } else if (scope.prototype instanceof can.Map) { + this.Map = scope; + } + this.attributeScopeMappings = {}; + can.each(this.Map ? this.Map.defaults : {}, function (val, prop) { + if (val === '@') { + self.attributeScopeMappings[prop] = prop; + } + }); + if (this.prototype.template) { + if (typeof this.prototype.template === 'function') { + var temp = this.prototype.template; + this.renderer = function () { + return can.view.frag(temp.apply(null, arguments)); + }; + } else { + this.renderer = can.view.mustache(this.prototype.template); + } + } + can.view.tag(this.prototype.tag, function (el, options) { + new self(el, options); + }); + } + } + }, { + setup: function (el, hookupOptions) { + var initialScopeData = {}, component = this, lexicalContent = (typeof this.leakScope === 'undefined' ? false : !this.leakScope) && this.template, twoWayBindings = {}, scope = this.scope || this.viewModel, viewModelPropertyUpdates = {}, componentScope, frag, teardownFunctions = [], callTeardownFunctions = function () { + for (var i = 0, len = teardownFunctions.length; i < len; i++) { + teardownFunctions[i](); + } + }; + can.each(this.constructor.attributeScopeMappings, function (val, prop) { + initialScopeData[prop] = el.getAttribute(can.hyphenate(val)); + }); + can.each(can.makeArray(el.attributes), function (node, index) { + var name = can.camelize(node.nodeName.toLowerCase()), value = node.value; + if (component.constructor.attributeScopeMappings[name] || ignoreAttributesRegExp.test(name) || viewCallbacks.attr(node.nodeName)) { + return; + } + if (value[0] === '{' && value[value.length - 1] === '}') { + value = value.substr(1, value.length - 2); + } else { + if (hookupOptions.templateType !== 'legacy') { + initialScopeData[name] = value; + return; + } + } + var computeData = hookupOptions.scope.computeData(value, { args: [] }), compute = computeData.compute; + var handler = function (ev, newVal) { + viewModelPropertyUpdates[name] = (viewModelPropertyUpdates[name] || 0) + 1; + componentScope.attr(name, newVal); + can.batch.afterPreviousEvents(function () { + --viewModelPropertyUpdates[name]; + }); + }; + compute.bind('change', handler); + initialScopeData[name] = compute(); + if (!compute.computeInstance.hasDependencies) { + compute.unbind('change', handler); + } else { + teardownFunctions.push(function () { + compute.unbind('change', handler); + }); + twoWayBindings[name] = computeData; + } + }); + if (this.constructor.Map) { + componentScope = new this.constructor.Map(initialScopeData); + } else if (scope instanceof can.Map) { + componentScope = scope; + } else if (can.isFunction(scope)) { + var scopeResult = scope.call(this, initialScopeData, hookupOptions.scope, el); + if (scopeResult instanceof can.Map) { + componentScope = scopeResult; + } else if (scopeResult.prototype instanceof can.Map) { + componentScope = new scopeResult(initialScopeData); + } else { + componentScope = new (can.Map.extend(scopeResult))(initialScopeData); + } + } + var handlers = {}; + can.each(twoWayBindings, function (computeData, prop) { + handlers[prop] = function (ev, newVal) { + if (!viewModelPropertyUpdates[prop]) { + computeData.compute(newVal); + } + }; + componentScope.bind(prop, handlers[prop]); + }); + if (!can.isEmptyObject(this.constructor.attributeScopeMappings) || hookupOptions.templateType !== 'legacy') { + can.bind.call(el, 'attributes', function (ev) { + var camelized = can.camelize(ev.attributeName); + if (!twoWayBindings[camelized] && !ignoreAttributesRegExp.test(camelized)) { + componentScope.attr(camelized, el.getAttribute(ev.attributeName)); + } + }); + } + this.scope = this.viewModel = componentScope; + can.data(can.$(el), 'scope', this.scope); + can.data(can.$(el), 'viewModel', this.scope); + var renderedScope = lexicalContent ? this.scope : hookupOptions.scope.add(this.scope), options = { helpers: {} }; + can.each(this.helpers || {}, function (val, prop) { + if (can.isFunction(val)) { + options.helpers[prop] = function () { + return val.apply(componentScope, arguments); + }; + } + }); + teardownFunctions.push(function () { + can.each(handlers, function (handler, prop) { + componentScope.unbind(prop, handlers[prop]); + }); + }); + this._control = new this.constructor.Control(el, { + scope: this.scope, + viewModel: this.scope + }); + if (this._control && this._control.destroy) { + var oldDestroy = this._control.destroy; + this._control.destroy = function () { + oldDestroy.apply(this, arguments); + callTeardownFunctions(); + }; + this._control.on(); + } else { + can.bind.call(el, 'removed', function () { + callTeardownFunctions(); + }); + } + var nodeList = can.view.nodeLists.register([], undefined, true); + teardownFunctions.push(function () { + can.view.nodeLists.unregister(nodeList); + }); + if (this.constructor.renderer) { + if (!options.tags) { + options.tags = {}; + } + options.tags.content = function contentHookup(el, rendererOptions) { + var subtemplate = hookupOptions.subtemplate || rendererOptions.subtemplate; + if (subtemplate) { + delete options.tags.content; + var opts = !lexicalContent || subtemplate !== hookupOptions.subtemplate ? rendererOptions : hookupOptions; + if (rendererOptions.parentNodeList) { + var frag = subtemplate(opts.scope, opts.options, rendererOptions.parentNodeList); + elements.replace([el], frag); + } else { + can.view.live.replace([el], subtemplate(opts.scope, opts.options)); + } + options.tags.content = contentHookup; + } + }; + frag = this.constructor.renderer(renderedScope, hookupOptions.options.add(options), nodeList); + } else { + if (hookupOptions.templateType === 'legacy') { + frag = can.view.frag(hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options)) : ''); + } else { + frag = hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options), nodeList) : document.createDocumentFragment(); + } + } + can.appendChild(el, frag); + can.view.nodeLists.update(nodeList, el.childNodes); + } + }); + var ComponentControl = can.Control.extend({ + _lookup: function (options) { + return [ + options.scope, + options, + window + ]; + }, + _action: function (methodName, options, controlInstance) { + var hasObjectLookup, readyCompute; + paramReplacer.lastIndex = 0; + hasObjectLookup = paramReplacer.test(methodName); + if (!controlInstance && hasObjectLookup) { + return; + } else if (!hasObjectLookup) { + return can.Control._action.apply(this, arguments); + } else { + readyCompute = can.compute(function () { + var delegate; + var name = methodName.replace(paramReplacer, function (matched, key) { + var value; + if (key === 'scope' || key === 'viewModel') { + delegate = options.scope; + return ''; + } + key = key.replace(/^(scope|^viewModel)\./, ''); + value = can.compute.read(options.scope, key.split('.'), { isArgument: true }).value; + if (value === undefined) { + value = can.getObject(key); + } + if (typeof value === 'string') { + return value; + } else { + delegate = value; + return ''; + } + }); + var parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: this.processors[event] || this.processors.click, + parts: [ + name, + parts.join(' '), + event + ], + delegate: delegate || undefined + }; + }, this); + var handler = function (ev, ready) { + controlInstance._bindings.control[methodName](controlInstance.element); + controlInstance._bindings.control[methodName] = ready.processor(ready.delegate || controlInstance.element, ready.parts[2], ready.parts[1], methodName, controlInstance); + }; + readyCompute.bind('change', handler); + controlInstance._bindings.readyComputes[methodName] = { + compute: readyCompute, + handler: handler + }; + return readyCompute(); + } + } + }, { + setup: function (el, options) { + this.scope = options.scope; + this.viewModel = options.viewModel; + return can.Control.prototype.setup.call(this, el, options); + }, + off: function () { + if (this._bindings) { + can.each(this._bindings.readyComputes || {}, function (value) { + value.compute.unbind('change', value.handler); + }); + } + can.Control.prototype.off.apply(this, arguments); + this._bindings.readyComputes = {}; + } + }); + var $ = can.$; + if ($.fn) { + $.fn.scope = $.fn.viewModel = function () { + return can.viewModel.apply(can, [this].concat(can.makeArray(arguments))); + }; + } + return Component; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/compute.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/compute.js new file mode 100644 index 0000000000..c74c03d0b2 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/compute.js @@ -0,0 +1,70 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#compute/compute*/ +define([ + 'can/util/library', + 'can/util/bind', + 'can/util/batch', + 'can/proto_compute' +], function (can, bind) { + can.compute = function (getterSetter, context, eventName, bindOnce) { + var internalCompute = new can.Compute(getterSetter, context, eventName, bindOnce); + var compute = function (val) { + if (arguments.length) { + return internalCompute.set(val); + } + return internalCompute.get(); + }; + compute.bind = can.proxy(internalCompute.bind, internalCompute); + compute.unbind = can.proxy(internalCompute.unbind, internalCompute); + compute.isComputed = internalCompute.isComputed; + compute.clone = function (ctx) { + if (typeof getterSetter === 'function') { + context = ctx; + } + return can.compute(getterSetter, context, ctx, bindOnce); + }; + compute.computeInstance = internalCompute; + return compute; + }; + var k = function () { + }; + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.compute.truthy = function (compute) { + return can.compute(function () { + var res = compute(); + if (typeof res === 'function') { + res = res(); + } + return !!res; + }); + }; + can.compute.async = function (initialValue, asyncComputer, context) { + return can.compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.compute.read = can.Compute.read; + can.compute.set = can.Compute.set; + return can.compute; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/construct.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/construct.js new file mode 100644 index 0000000000..8c53ab3c00 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/construct.js @@ -0,0 +1,140 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#construct/construct*/ +define(['can/util/string'], function (can) { + var initializing = 0; + var canGetDescriptor; + try { + Object.getOwnPropertyDescriptor({}); + canGetDescriptor = true; + } catch (e) { + canGetDescriptor = false; + } + var getDescriptor = function (newProps, name) { + var descriptor = Object.getOwnPropertyDescriptor(newProps, name); + if (descriptor && (descriptor.get || descriptor.set)) { + return descriptor; + } + return null; + }, inheritGetterSetter = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + var descriptor; + for (var name in newProps) { + if (descriptor = getDescriptor(newProps, name)) { + this._defineProperty(addTo, oldProps, name, descriptor); + } else { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + } + }, simpleInherit = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + for (var name in newProps) { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + }; + can.Construct = function () { + if (arguments.length) { + return can.Construct.extend.apply(can.Construct, arguments); + } + }; + can.extend(can.Construct, { + constructorExtends: true, + newInstance: function () { + var inst = this.instance(), args; + if (inst.setup) { + args = inst.setup.apply(inst, arguments); + } + if (inst.init) { + inst.init.apply(inst, args || arguments); + } + return inst; + }, + _inherit: canGetDescriptor ? inheritGetterSetter : simpleInherit, + _defineProperty: function (what, oldProps, propName, descriptor) { + Object.defineProperty(what, propName, descriptor); + }, + _overwrite: function (what, oldProps, propName, val) { + what[propName] = val; + }, + setup: function (base, fullName) { + this.defaults = can.extend(true, {}, base.defaults, this.defaults); + }, + instance: function () { + initializing = 1; + var inst = new this(); + initializing = 0; + return inst; + }, + extend: function (name, staticProperties, instanceProperties) { + var fullName = name, klass = staticProperties, proto = instanceProperties; + if (typeof fullName !== 'string') { + proto = klass; + klass = fullName; + fullName = null; + } + if (!proto) { + proto = klass; + klass = null; + } + proto = proto || {}; + var _super_class = this, _super = this.prototype, Constructor, parts, current, _fullName, _shortName, propName, shortName, namespace, prototype; + prototype = this.instance(); + can.Construct._inherit(proto, _super, prototype); + if (fullName) { + parts = fullName.split('.'); + shortName = parts.pop(); + } + if (typeof constructorName === 'undefined') { + Constructor = function () { + return init.apply(this, arguments); + }; + } + function init() { + if (!initializing) { + return this.constructor !== Constructor && arguments.length && Constructor.constructorExtends ? Constructor.extend.apply(Constructor, arguments) : Constructor.newInstance.apply(Constructor, arguments); + } + } + for (propName in _super_class) { + if (_super_class.hasOwnProperty(propName)) { + Constructor[propName] = _super_class[propName]; + } + } + can.Construct._inherit(klass, _super_class, Constructor); + if (fullName) { + current = can.getObject(parts.join('.'), window, true); + namespace = current; + _fullName = can.underscore(fullName.replace(/\./g, '_')); + _shortName = can.underscore(shortName); + current[shortName] = Constructor; + } + can.extend(Constructor, { + constructor: Constructor, + prototype: prototype, + namespace: namespace, + _shortName: _shortName, + fullName: fullName, + _fullName: _fullName + }); + if (shortName !== undefined) { + Constructor.shortName = shortName; + } + Constructor.prototype.constructor = Constructor; + var t = [_super_class].concat(can.makeArray(arguments)), args = Constructor.setup.apply(Constructor, t); + if (Constructor.init) { + Constructor.init.apply(Constructor, args || t); + } + return Constructor; + } + }); + can.Construct.prototype.setup = function () { + }; + can.Construct.prototype.init = function () { + }; + return can.Construct; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/construct/proxy.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/construct/proxy.js new file mode 100644 index 0000000000..28ece95bfb --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/construct/proxy.js @@ -0,0 +1,49 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#construct/proxy/proxy*/ +define([ + 'can/util/library', + 'can/construct' +], function (can, Construct) { + var isFunction = can.isFunction, isArray = can.isArray, makeArray = can.makeArray, proxy = function (funcs) { + var args = makeArray(arguments), self; + funcs = args.shift(); + if (!isArray(funcs)) { + funcs = [funcs]; + } + self = this; + return function class_cb() { + var cur = args.concat(makeArray(arguments)), isString, length = funcs.length, f = 0, func; + for (; f < length; f++) { + func = funcs[f]; + if (!func) { + continue; + } + isString = typeof func === 'string'; + cur = (isString ? self[func] : func).apply(self, cur || []); + if (f < length - 1) { + cur = !isArray(cur) || cur._use_call ? [cur] : cur; + } + } + return cur; + }; + }; + can.Construct.proxy = can.Construct.prototype.proxy = proxy; + var correctedClasses = [ + can.Map, + can.Control, + can.Model + ], i = 0; + for (; i < correctedClasses.length; i++) { + if (correctedClasses[i]) { + correctedClasses[i].proxy = proxy; + } + } + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/construct/super.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/construct/super.js new file mode 100644 index 0000000000..378bd884cc --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/construct/super.js @@ -0,0 +1,45 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#construct/super/super*/ +define([ + 'can/util/library', + 'can/construct' +], function (can, Construct) { + var isFunction = can.isFunction, fnTest = /xyz/.test(function () { + return this.xyz; + }) ? /\b_super\b/ : /.*/, getset = [ + 'get', + 'set' + ], getSuper = function (base, name, fn) { + return function () { + var tmp = this._super, ret; + this._super = base[name]; + ret = fn.apply(this, arguments); + this._super = tmp; + return ret; + }; + }; + can.Construct._defineProperty = function (addTo, base, name, descriptor) { + var _super = Object.getOwnPropertyDescriptor(base, name); + if (_super) { + can.each(getset, function (method) { + if (isFunction(_super[method]) && isFunction(descriptor[method])) { + descriptor[method] = getSuper(_super, method, descriptor[method]); + } else if (!isFunction(descriptor[method])) { + descriptor[method] = _super[method]; + } + }); + } + Object.defineProperty(addTo, name, descriptor); + }; + can.Construct._overwrite = function (addTo, base, name, val) { + addTo[name] = isFunction(val) && isFunction(base[name]) && fnTest.test(val) ? getSuper(base, name, val) : val; + }; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/control.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/control.js new file mode 100644 index 0000000000..21cf8125ad --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/control.js @@ -0,0 +1,203 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#control/control*/ +define([ + 'can/util/library', + 'can/construct' +], function (can) { + var bind = function (el, ev, callback) { + can.bind.call(el, ev, callback); + return function () { + can.unbind.call(el, ev, callback); + }; + }, isFunction = can.isFunction, extend = can.extend, each = can.each, slice = [].slice, paramReplacer = /\{([^\}]+)\}/g, special = can.getObject('$.event.special', [can]) || {}, delegate = function (el, selector, ev, callback) { + can.delegate.call(el, selector, ev, callback); + return function () { + can.undelegate.call(el, selector, ev, callback); + }; + }, binder = function (el, ev, callback, selector) { + return selector ? delegate(el, can.trim(selector), ev, callback) : bind(el, ev, callback); + }, basicProcessor; + var Control = can.Control = can.Construct({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Control) { + var control = this, funcName; + control.actions = {}; + for (funcName in control.prototype) { + if (control._isAction(funcName)) { + control.actions[funcName] = control._action(funcName); + } + } + } + }, + _shifter: function (context, name) { + var method = typeof name === 'string' ? context[name] : name; + if (!isFunction(method)) { + method = context[method]; + } + return function () { + context.called = name; + return method.apply(context, [this.nodeName ? can.$(this) : this].concat(slice.call(arguments, 0))); + }; + }, + _isAction: function (methodName) { + var val = this.prototype[methodName], type = typeof val; + return methodName !== 'constructor' && (type === 'function' || type === 'string' && isFunction(this.prototype[val])) && !!(special[methodName] || processors[methodName] || /[^\w]/.test(methodName)); + }, + _action: function (methodName, options) { + paramReplacer.lastIndex = 0; + if (options || !paramReplacer.test(methodName)) { + var convertedName = options ? can.sub(methodName, this._lookup(options)) : methodName; + if (!convertedName) { + return null; + } + var arr = can.isArray(convertedName), name = arr ? convertedName[1] : convertedName, parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: processors[event] || basicProcessor, + parts: [ + name, + parts.join(' '), + event + ], + delegate: arr ? convertedName[0] : undefined + }; + } + }, + _lookup: function (options) { + return [ + options, + window + ]; + }, + processors: {}, + defaults: {} + }, { + setup: function (element, options) { + var cls = this.constructor, pluginname = cls.pluginName || cls._fullName, arr; + this.element = can.$(element); + if (pluginname && pluginname !== 'can_control') { + this.element.addClass(pluginname); + } + arr = can.data(this.element, 'controls'); + if (!arr) { + arr = []; + can.data(this.element, 'controls', arr); + } + arr.push(this); + this.options = extend({}, cls.defaults, options); + this.on(); + return [ + this.element, + this.options + ]; + }, + on: function (el, selector, eventName, func) { + if (!el) { + this.off(); + var cls = this.constructor, bindings = this._bindings, actions = cls.actions, element = this.element, destroyCB = can.Control._shifter(this, 'destroy'), funcName, ready; + for (funcName in actions) { + if (actions.hasOwnProperty(funcName)) { + ready = actions[funcName] || cls._action(funcName, this.options, this); + if (ready) { + bindings.control[funcName] = ready.processor(ready.delegate || element, ready.parts[2], ready.parts[1], funcName, this); + } + } + } + can.bind.call(element, 'removed', destroyCB); + bindings.user.push(function (el) { + can.unbind.call(el, 'removed', destroyCB); + }); + return bindings.user.length; + } + if (typeof el === 'string') { + func = eventName; + eventName = selector; + selector = el; + el = this.element; + } + if (func === undefined) { + func = eventName; + eventName = selector; + selector = null; + } + if (typeof func === 'string') { + func = can.Control._shifter(this, func); + } + this._bindings.user.push(binder(el, eventName, func, selector)); + return this._bindings.user.length; + }, + off: function () { + var el = this.element[0], bindings = this._bindings; + if (bindings) { + each(bindings.user || [], function (value) { + value(el); + }); + each(bindings.control || {}, function (value) { + value(el); + }); + } + this._bindings = { + user: [], + control: {} + }; + }, + destroy: function () { + if (this.element === null) { + return; + } + var Class = this.constructor, pluginName = Class.pluginName || Class._fullName, controls; + this.off(); + if (pluginName && pluginName !== 'can_control') { + this.element.removeClass(pluginName); + } + controls = can.data(this.element, 'controls'); + controls.splice(can.inArray(this, controls), 1); + can.trigger(this, 'destroyed'); + this.element = null; + } + }); + var processors = can.Control.processors; + basicProcessor = function (el, event, selector, methodName, control) { + return binder(el, event, can.Control._shifter(control, methodName), selector); + }; + each([ + 'change', + 'click', + 'contextmenu', + 'dblclick', + 'keydown', + 'keyup', + 'keypress', + 'mousedown', + 'mousemove', + 'mouseout', + 'mouseover', + 'mouseup', + 'reset', + 'resize', + 'scroll', + 'select', + 'submit', + 'focusin', + 'focusout', + 'mouseenter', + 'mouseleave', + 'touchstart', + 'touchmove', + 'touchcancel', + 'touchend', + 'touchleave', + 'inserted', + 'removed' + ], function (v) { + processors[v] = basicProcessor; + }); + return Control; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/control/plugin.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/control/plugin.js new file mode 100644 index 0000000000..e0a24c7d23 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/control/plugin.js @@ -0,0 +1,81 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#control/plugin/plugin*/ +define([ + 'jquery', + 'can/util/library', + 'can/control' +], function ($, can) { + $ = $ || window.$; + var i, isAControllerOf = function (instance, controllers) { + var name = instance.constructor.pluginName || instance.constructor._shortName; + for (i = 0; i < controllers.length; i++) { + if (typeof controllers[i] === 'string' ? name === controllers[i] : instance instanceof controllers[i]) { + return true; + } + } + return false; + }, makeArray = can.makeArray, old = can.Control.setup; + can.Control.setup = function () { + if (this !== can.Control) { + var pluginName = this.pluginName || this._fullName; + if (pluginName !== 'can_control') { + this.plugin(pluginName); + } + old.apply(this, arguments); + } + }; + $.fn.extend({ + controls: function () { + var controllerNames = makeArray(arguments), instances = [], controls, c; + this.each(function () { + controls = can.$(this).data('controls'); + if (!controls) { + return; + } + for (var i = 0; i < controls.length; i++) { + c = controls[i]; + if (!controllerNames.length || isAControllerOf(c, controllerNames)) { + instances.push(c); + } + } + }); + return instances; + }, + control: function (control) { + return this.controls.apply(this, arguments)[0]; + } + }); + can.Control.plugin = function (pluginname) { + var control = this; + if (!$.fn[pluginname]) { + $.fn[pluginname] = function (options) { + var args = makeArray(arguments), isMethod = typeof options === 'string' && $.isFunction(control.prototype[options]), meth = args[0], returns; + this.each(function () { + var plugin = can.$(this).control(control); + if (plugin) { + if (isMethod) { + returns = plugin[meth].apply(plugin, args.slice(1)); + } else { + plugin.update.apply(plugin, args); + } + } else { + control.newInstance.apply(control, [this].concat(args)); + } + }); + return returns !== undefined ? returns : this; + }; + } + }; + can.Control.prototype.update = function (options) { + can.extend(this.options, options); + this.on(); + }; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/control/route.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/control/route.js new file mode 100644 index 0000000000..bd792cbabb --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/control/route.js @@ -0,0 +1,41 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#control/route/route*/ +define([ + 'can/util/library', + 'can/route', + 'can/control' +], function (can) { + can.Control.processors.route = function (el, event, selector, funcName, controller) { + selector = selector || ''; + if (!can.route.routes[selector]) { + if (selector[0] === '/') { + selector = selector.substring(1); + } + can.route(selector); + } + var batchNum, check = function (ev, attr, how) { + if (can.route.attr('route') === selector && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + batchNum = ev.batchNum; + var d = can.route.attr(); + delete d.route; + if (can.isFunction(controller[funcName])) { + controller[funcName](d); + } else { + controller[controller[funcName]](d); + } + } + }; + can.route.bind('change', check); + return function () { + can.route.unbind('change', check); + }; + }; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/deferred.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/deferred.js new file mode 100644 index 0000000000..e072db2f4a --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/deferred.js @@ -0,0 +1,160 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/deferred*/ +define(['can/util/can'], function (can) { + var extend = function (target, src) { + for (var key in src) { + if (src.hasOwnProperty(key)) { + target[key] = src[key]; + } + } + }, Deferred = function (func) { + if (!(this instanceof Deferred)) { + return new Deferred(); + } + this._doneFuncs = []; + this._failFuncs = []; + this._resultArgs = null; + this._status = ''; + if (func) { + func.call(this, this); + } + }; + can.Deferred = Deferred; + can.when = Deferred.when = function () { + var args = can.makeArray(arguments); + if (args.length < 2) { + var obj = args[0]; + if (obj && (can.isFunction(obj.isResolved) && can.isFunction(obj.isRejected))) { + return obj; + } else { + return Deferred().resolve(obj); + } + } else { + var df = Deferred(), done = 0, rp = []; + can.each(args, function (arg, j) { + arg.done(function () { + rp[j] = arguments.length < 2 ? arguments[0] : arguments; + if (++done === args.length) { + df.resolve.apply(df, rp); + } + }).fail(function () { + df.reject(arguments.length === 1 ? arguments[0] : arguments); + }); + }); + return df; + } + }; + var resolveFunc = function (type, _status) { + return function (context) { + var args = this._resultArgs = arguments.length > 1 ? arguments[1] : []; + return this.exec(context, this[type], args, _status); + }; + }, doneFunc = function doneFunc(type, _status) { + return function () { + var self = this; + can.each(Array.prototype.slice.call(arguments), function (v, i, args) { + if (!v) { + return; + } + if (v.constructor === Array) { + doneFunc.apply(self, v); + } else { + if (self._status === _status) { + v.apply(self, self._resultArgs || []); + } + self[type].push(v); + } + }); + return this; + }; + }; + var isDeferred = function (obj) { + return obj && obj.then && obj.fail && obj.done; + }; + var wire = function (parentDeferred, result, setter, value) { + if (isDeferred(result)) { + result.done(can.proxy(parentDeferred.resolve, parentDeferred)).fail(can.proxy(parentDeferred.reject, parentDeferred)); + } else { + setter.call(parentDeferred, result !== undefined ? result : value); + } + }; + extend(Deferred.prototype, { + then: function (done, fail) { + var d = can.Deferred(), resolve = d.resolve, reject = d.reject; + this.done(function (value) { + if (typeof done === 'function') { + wire(d, done.apply(this, arguments), resolve, value); + } else { + resolve.apply(d, arguments); + } + }); + this.fail(function (value) { + if (typeof fail === 'function') { + wire(d, fail.apply(this, arguments), reject, value); + } else { + reject.apply(d, arguments); + } + }); + return d; + }, + resolveWith: resolveFunc('_doneFuncs', 'rs'), + rejectWith: resolveFunc('_failFuncs', 'rj'), + done: doneFunc('_doneFuncs', 'rs'), + fail: doneFunc('_failFuncs', 'rj'), + always: function () { + var args = can.makeArray(arguments); + if (args.length && args[0]) { + this.done(args[0]).fail(args[0]); + } + return this; + }, + state: function () { + switch (this._status) { + case 'rs': + return 'resolved'; + case 'rj': + return 'rejected'; + default: + return 'pending'; + } + }, + isResolved: function () { + return this._status === 'rs'; + }, + isRejected: function () { + return this._status === 'rj'; + }, + reject: function () { + return this.rejectWith(this, arguments); + }, + resolve: function () { + return this.resolveWith(this, arguments); + }, + exec: function (context, dst, args, st) { + if (this._status !== '') { + return this; + } + this._status = st; + can.each(dst, function (d) { + if (typeof d.apply === 'function') { + d.apply(context, args); + } + }); + return this; + }, + promise: function () { + var promise = this.then(); + promise.reject = promise.resolve = undefined; + return promise; + } + }); + Deferred.prototype.pipe = Deferred.prototype.then; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/elements.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/elements.js new file mode 100644 index 0000000000..22e8f61a22 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/elements.js @@ -0,0 +1,83 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/elements*/ +define([ + 'can/util/library', + 'can/view' +], function (can) { + var doc = typeof document !== 'undefined' ? document : null; + var selectsCommentNodes = doc && function () { + return can.$(document.createComment('~')).length === 1; + }(); + var elements = { + tagToContentPropMap: { + option: doc && 'textContent' in document.createElement('option') ? 'textContent' : 'innerText', + textarea: 'value' + }, + attrMap: can.attr.map, + attrReg: /([^\s=]+)[\s]*=[\s]*/, + defaultValue: can.attr.defaultValue, + tagMap: { + '': 'span', + colgroup: 'col', + table: 'tbody', + tr: 'td', + ol: 'li', + ul: 'li', + tbody: 'tr', + thead: 'tr', + tfoot: 'tr', + select: 'option', + optgroup: 'option' + }, + reverseTagMap: { + col: 'colgroup', + tr: 'tbody', + option: 'select', + td: 'tr', + th: 'tr', + li: 'ul' + }, + getParentNode: function (el, defaultParentNode) { + return defaultParentNode && el.parentNode.nodeType === 11 ? defaultParentNode : el.parentNode; + }, + setAttr: can.attr.set, + getAttr: can.attr.get, + removeAttr: can.attr.remove, + contentText: function (text) { + if (typeof text === 'string') { + return text; + } + if (!text && text !== 0) { + return ''; + } + return '' + text; + }, + after: function (oldElements, newFrag) { + var last = oldElements[oldElements.length - 1]; + if (last.nextSibling) { + can.insertBefore(last.parentNode, newFrag, last.nextSibling); + } else { + can.appendChild(last.parentNode, newFrag); + } + }, + replace: function (oldElements, newFrag) { + elements.after(oldElements, newFrag); + if (can.remove(can.$(oldElements)).length < oldElements.length && !selectsCommentNodes) { + can.each(oldElements, function (el) { + if (el.nodeType === 8) { + el.parentNode.removeChild(el); + } + }); + } + } + }; + can.view.elements = elements; + return elements; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/event.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/event.js new file mode 100644 index 0000000000..4bce9e59f6 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/event.js @@ -0,0 +1,152 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#event/event*/ +define(['can/util/can'], function (can) { + can.addEvent = function (event, handler) { + var allEvents = this.__bindEvents || (this.__bindEvents = {}), eventList = allEvents[event] || (allEvents[event] = []); + eventList.push({ + handler: handler, + name: event + }); + return this; + }; + can.listenTo = function (other, event, handler) { + var idedEvents = this.__listenToEvents; + if (!idedEvents) { + idedEvents = this.__listenToEvents = {}; + } + var otherId = can.cid(other); + var othersEvents = idedEvents[otherId]; + if (!othersEvents) { + othersEvents = idedEvents[otherId] = { + obj: other, + events: {} + }; + } + var eventsEvents = othersEvents.events[event]; + if (!eventsEvents) { + eventsEvents = othersEvents.events[event] = []; + } + eventsEvents.push(handler); + can.bind.call(other, event, handler); + }; + can.stopListening = function (other, event, handler) { + var idedEvents = this.__listenToEvents, iterIdedEvents = idedEvents, i = 0; + if (!idedEvents) { + return this; + } + if (other) { + var othercid = can.cid(other); + (iterIdedEvents = {})[othercid] = idedEvents[othercid]; + if (!idedEvents[othercid]) { + return this; + } + } + for (var cid in iterIdedEvents) { + var othersEvents = iterIdedEvents[cid], eventsEvents; + other = idedEvents[cid].obj; + if (!event) { + eventsEvents = othersEvents.events; + } else { + (eventsEvents = {})[event] = othersEvents.events[event]; + } + for (var eventName in eventsEvents) { + var handlers = eventsEvents[eventName] || []; + i = 0; + while (i < handlers.length) { + if (handler && handler === handlers[i] || !handler) { + can.unbind.call(other, eventName, handlers[i]); + handlers.splice(i, 1); + } else { + i++; + } + } + if (!handlers.length) { + delete othersEvents.events[eventName]; + } + } + if (can.isEmptyObject(othersEvents.events)) { + delete idedEvents[cid]; + } + } + return this; + }; + can.removeEvent = function (event, fn, __validate) { + if (!this.__bindEvents) { + return this; + } + var events = this.__bindEvents[event] || [], i = 0, ev, isFunction = typeof fn === 'function'; + while (i < events.length) { + ev = events[i]; + if (__validate ? __validate(ev, event, fn) : isFunction && ev.handler === fn || !isFunction && (ev.cid === fn || !fn)) { + events.splice(i, 1); + } else { + i++; + } + } + return this; + }; + can.dispatch = function (event, args) { + var events = this.__bindEvents; + if (!events) { + return; + } + if (typeof event === 'string') { + event = { type: event }; + } + var eventName = event.type, handlers = (events[eventName] || []).slice(0), passed = [event]; + if (args) { + passed.push.apply(passed, args); + } + for (var i = 0, len = handlers.length; i < len; i++) { + handlers[i].handler.apply(this, passed); + } + return event; + }; + can.one = function (event, handler) { + var one = function () { + can.unbind.call(this, event, one); + return handler.apply(this, arguments); + }; + can.bind.call(this, event, one); + return this; + }; + can.event = { + on: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.on.call(this); + } else { + return can.addEvent.apply(this, arguments); + } + }, + off: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.off.call(this); + } else { + return can.removeEvent.apply(this, arguments); + } + }, + bind: can.addEvent, + unbind: can.removeEvent, + delegate: function (selector, event, handler) { + return can.addEvent.call(this, event, handler); + }, + undelegate: function (selector, event, handler) { + return can.removeEvent.call(this, event, handler); + }, + trigger: can.dispatch, + one: can.one, + addEvent: can.addEvent, + removeEvent: can.removeEvent, + listenTo: can.listenTo, + stopListening: can.stopListening, + dispatch: can.dispatch + }; + return can.event; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/fragment.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/fragment.js new file mode 100644 index 0000000000..ec9b83198d --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/fragment.js @@ -0,0 +1,65 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/fragment*/ +define(['can/util/can'], function (can) { + var fragmentRE = /^\s*<(\w+)[^>]*>/, toString = {}.toString, fragment = function (html, name) { + if (name === undefined) { + name = fragmentRE.test(html) && RegExp.$1; + } + if (html && toString.call(html.replace) === '[object Function]') { + html = html.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, '<$1>'); + } + var container = document.createElement('div'), temp = document.createElement('div'); + if (name === 'tbody' || name === 'tfoot' || name === 'thead') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; + } else if (name === 'tr') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild; + } else if (name === 'td' || name === 'th') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild.firstChild; + } else if (name === 'option') { + temp.innerHTML = ''; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; + } else { + container.innerHTML = '' + html; + } + var tmp = {}, children = container.childNodes; + tmp.length = children.length; + for (var i = 0; i < children.length; i++) { + tmp[i] = children[i]; + } + return [].slice.call(tmp); + }; + can.buildFragment = function (html, nodes) { + if (html && html.nodeType === 11) { + return html; + } + var parts = fragment(html), frag = document.createDocumentFragment(); + for (var i = 0, length = parts.length; i < length; i++) { + frag.appendChild(parts[i]); + } + return frag; + }; + (function () { + var text = '<-\n>', frag = can.buildFragment(text, document); + if (text !== frag.childNodes[0].nodeValue) { + var oldBuildFragment = can.buildFragment; + can.buildFragment = function (html, nodes) { + var res = oldBuildFragment(html, nodes); + if (res.childNodes.length === 1 && res.childNodes[0].nodeType === 3) { + res.childNodes[0].nodeValue = html; + } + return res; + }; + } + }()); + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/get_value_and_bind.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/get_value_and_bind.js new file mode 100644 index 0000000000..b6359e7441 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/get_value_and_bind.js @@ -0,0 +1,91 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#compute/get_value_and_bind*/ +define(['can/util/library'], function () { + function observe(func, context, oldInfo, onchanged) { + var info = getValueAndObserved(func, context), newObserveSet = info.observed, oldObserved = oldInfo.observed; + if (info.names !== oldInfo.names) { + bindNewSet(oldObserved, newObserveSet, onchanged); + unbindOldSet(oldObserved, onchanged); + } + can.batch.afterPreviousEvents(function () { + info.ready = true; + }); + return info; + } + var observedStack = []; + can.__isRecordingObserves = function () { + return observedStack.length; + }; + can.__observe = can.__reading = function (obj, event) { + if (observedStack.length) { + var name = obj._cid + '|' + event, top = observedStack[observedStack.length - 1]; + top.names += name; + top.observed[name] = { + obj: obj, + event: event + '' + }; + } + }; + can.__notObserve = function (fn) { + return function () { + var previousReads = can.__clearObserved(); + var res = fn.apply(this, arguments); + can.__setObserved(previousReads); + return res; + }; + }; + can.__clearObserved = can.__clearReading = function () { + if (observedStack.length) { + var ret = observedStack[observedStack.length - 1]; + observedStack[observedStack.length - 1] = { observed: {} }; + return ret; + } + }; + can.__setObserved = can.__setReading = function (o) { + if (observedStack.length) { + observedStack[observedStack.length - 1] = o; + } + }; + can.__addObserved = can.__addReading = function (o) { + if (observedStack.length) { + can.simpleExtend(observedStack[observedStack.length - 1], o); + } + }; + var getValueAndObserved = function (func, self) { + observedStack.push({ + names: '', + observed: {} + }); + var value = func.call(self); + var stackItem = observedStack.pop(); + stackItem.value = value; + return stackItem; + }; + var bindNewSet = function (oldObserved, newObserveSet, onchanged) { + for (var name in newObserveSet) { + bindOrPreventUnbinding(oldObserved, newObserveSet, name, onchanged); + } + }; + var bindOrPreventUnbinding = function (oldObserved, newObserveSet, name, onchanged) { + if (oldObserved[name]) { + delete oldObserved[name]; + } else { + var obEv = newObserveSet[name]; + obEv.obj.bind(obEv.event, onchanged); + } + }; + var unbindOldSet = function (oldObserved, onchanged) { + for (var name in oldObserved) { + var obEv = oldObserved[name]; + obEv.obj.unbind(obEv.event, onchanged); + } + }; + return observe; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/hashchange.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/hashchange.js new file mode 100644 index 0000000000..13c7c846b8 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/hashchange.js @@ -0,0 +1,25 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/hashchange*/ +define(['can/util/can'], function (can) { + (function () { + var addEvent = function (el, ev, fn) { + if (el.addEventListener) { + el.addEventListener(ev, fn, false); + } else if (el.attachEvent) { + el.attachEvent('on' + ev, fn); + } else { + el['on' + ev] = fn; + } + }, onHashchange = function () { + can.trigger(window, 'hashchange'); + }; + addEvent(window, 'hashchange', onHashchange); + }()); +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/list.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/list.js new file mode 100644 index 0000000000..00dc1298b3 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/list.js @@ -0,0 +1,264 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#list/list*/ +define([ + 'can/util/library', + 'can/map', + 'can/bubble' +], function (can, Map, bubble) { + var splice = [].splice, spliceRemovesProps = function () { + var obj = { + 0: 'a', + length: 1 + }; + splice.call(obj, 0, 1); + return !obj[0]; + }(); + var list = Map.extend({ Map: Map }, { + setup: function (instances, options) { + this.length = 0; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + this._setupComputes(); + instances = instances || []; + var teardownMapping; + if (can.isDeferred(instances)) { + this.replace(instances); + } else { + teardownMapping = instances.length && can.Map.helpers.addToMap(instances, this); + this.push.apply(this, can.makeArray(instances || [])); + } + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + can.simpleExtend(this, options); + delete this._init; + }, + _triggerChange: function (attr, how, newVal, oldVal) { + Map.prototype._triggerChange.apply(this, arguments); + var index = +attr; + if (!~('' + attr).indexOf('.') && !isNaN(index)) { + if (how === 'add') { + can.batch.trigger(this, how, [ + newVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else if (how === 'remove') { + can.batch.trigger(this, how, [ + oldVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else { + can.batch.trigger(this, how, [ + newVal, + index + ]); + } + } + }, + __get: function (attr) { + if (attr) { + if (this[attr] && this[attr].isComputed && can.isFunction(this.constructor.prototype[attr])) { + return this[attr](); + } else { + return this[attr]; + } + } else { + return this; + } + }, + __set: function (prop, value, current) { + prop = isNaN(+prop) || prop % 1 ? prop : +prop; + if (typeof prop === 'number' && prop > this.length - 1) { + var newArr = new Array(prop + 1 - this.length); + newArr[newArr.length - 1] = value; + this.push.apply(this, newArr); + return newArr; + } + return can.Map.prototype.__set.call(this, '' + prop, value, current); + }, + ___set: function (attr, val) { + this[attr] = val; + if (+attr >= this.length) { + this.length = +attr + 1; + } + }, + _remove: function (prop, current) { + if (isNaN(+prop)) { + delete this[prop]; + this._triggerChange(prop, 'remove', undefined, current); + } else { + this.splice(prop, 1); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var i = 0; i < data.length; i++) { + callback(data[i], i); + } + }, + serialize: function () { + return Map.helpers.serialize(this, 'serialize', []); + }, + splice: function (index, howMany) { + var args = can.makeArray(arguments), added = [], i, len, listIndex, allSame = args.length > 2; + index = index || 0; + for (i = 0, len = args.length - 2; i < len; i++) { + listIndex = i + 2; + args[listIndex] = this.__type(args[listIndex], listIndex); + added.push(args[listIndex]); + if (this[i + index] !== args[listIndex]) { + allSame = false; + } + } + if (allSame && this.length <= added.length) { + return added; + } + if (howMany === undefined) { + howMany = args[1] = this.length - index; + } + var removed = splice.apply(this, args); + if (!spliceRemovesProps) { + for (i = this.length; i < removed.length + this.length; i++) { + delete this[i]; + } + } + can.batch.start(); + if (howMany > 0) { + bubble.removeMany(this, removed); + this._triggerChange('' + index, 'remove', undefined, removed); + } + if (args.length > 2) { + for (i = 0, len = added.length; i < len; i++) { + bubble.set(this, i, added[i]); + } + this._triggerChange('' + index, 'add', added, removed); + } + can.batch.stop(); + return removed; + }, + _attrs: function (items, remove) { + if (items === undefined) { + return Map.helpers.serialize(this, 'attr', []); + } + items = can.makeArray(items); + can.batch.start(); + this._updateAttrs(items, remove); + can.batch.stop(); + }, + _updateAttrs: function (items, remove) { + var len = Math.min(items.length, this.length); + for (var prop = 0; prop < len; prop++) { + var curVal = this[prop], newVal = items[prop]; + if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + this._set(prop, newVal); + } else { + } + } + if (items.length > this.length) { + this.push.apply(this, items.slice(this.length)); + } else if (items.length < this.length && remove) { + this.splice(items.length); + } + } + }), getArgs = function (args) { + return args[0] && can.isArray(args[0]) ? args[0] : can.makeArray(args); + }; + can.each({ + push: 'length', + unshift: 0 + }, function (where, name) { + var orig = [][name]; + list.prototype[name] = function () { + var args = [], len = where ? this.length : 0, i = arguments.length, res, val; + while (i--) { + val = arguments[i]; + args[i] = bubble.set(this, i, this.__type(val, i)); + } + res = orig.apply(this, args); + if (!this.comparator || args.length) { + this._triggerChange('' + len, 'add', args, undefined); + } + return res; + }; + }); + can.each({ + pop: 'length', + shift: 0 + }, function (where, name) { + list.prototype[name] = function () { + if (!this.length) { + return undefined; + } + var args = getArgs(arguments), len = where && this.length ? this.length - 1 : 0; + var res = [][name].apply(this, args); + this._triggerChange('' + len, 'remove', undefined, [res]); + if (res && res.unbind) { + bubble.remove(this, res); + } + return res; + }; + }); + can.extend(list.prototype, { + indexOf: function (item, fromIndex) { + this.attr('length'); + return can.inArray(item, this, fromIndex); + }, + join: function () { + return [].join.apply(this.attr(), arguments); + }, + reverse: function () { + var list = [].reverse.call(can.makeArray(this)); + this.replace(list); + }, + slice: function () { + var temp = Array.prototype.slice.apply(this, arguments); + return new this.constructor(temp); + }, + concat: function () { + var args = []; + can.each(can.makeArray(arguments), function (arg, i) { + args[i] = arg instanceof can.List ? arg.serialize() : arg; + }); + return new this.constructor(Array.prototype.concat.apply(this.serialize(), args)); + }, + forEach: function (cb, thisarg) { + return can.each(this, cb, thisarg || this); + }, + replace: function (newList) { + if (can.isDeferred(newList)) { + newList.then(can.proxy(this.replace, this)); + } else { + this.splice.apply(this, [ + 0, + this.length + ].concat(can.makeArray(newList || []))); + } + return this; + }, + filter: function (callback, thisArg) { + var filteredList = new can.List(), self = this, filtered; + this.each(function (item, index, list) { + filtered = callback.call(thisArg | self, item, index, self); + if (filtered) { + filteredList.push(item); + } + }); + return filteredList; + } + }); + can.List = Map.List = list; + return can.List; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/list/promise.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/list/promise.js new file mode 100644 index 0000000000..25e5fa76a0 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/list/promise.js @@ -0,0 +1,58 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#list/promise/promise*/ +define(['can/list'], function (list) { + var oldReplace = can.List.prototype.replace; + can.List.prototype.replace = function (data) { + var result = oldReplace.apply(this, arguments); + if (can.isDeferred(data)) { + can.batch.start(); + this.attr('state', data.state()); + this.removeAttr('reason'); + can.batch.stop(); + var self = this; + var deferred = this._deferred = new can.Deferred(); + data.then(function () { + self.attr('state', data.state()); + deferred.resolve(self); + }, function (reason) { + can.batch.start(); + self.attr('state', data.state()); + self.attr('reason', reason); + can.batch.stop(); + deferred.reject(reason); + }); + } + return result; + }; + can.each({ + isResolved: 'resolved', + isPending: 'pending', + isRejected: 'rejected' + }, function (value, method) { + can.List.prototype[method] = function () { + return this.attr('state') === value; + }; + }); + can.each([ + 'then', + 'done', + 'fail', + 'always', + 'promise' + ], function (name) { + can.List.prototype[name] = function () { + if (!this._deferred) { + this._deferred = new can.Deferred(); + this._deferred.resolve(this); + } + return this._deferred[name].apply(this._deferred, arguments); + }; + }); +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/list/sort.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/list/sort.js new file mode 100644 index 0000000000..44f13dccf5 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/list/sort.js @@ -0,0 +1,198 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#list/sort/sort*/ +define([ + 'can/util/library', + 'can/list' +], function () { + var oldBubbleRule = can.List._bubbleRule; + can.List._bubbleRule = function (eventName, list) { + var oldBubble = oldBubbleRule.apply(this, arguments); + if (list.comparator && can.inArray('change', oldBubble) === -1) { + oldBubble.push('change'); + } + return oldBubble; + }; + var proto = can.List.prototype, _changes = proto._changes, setup = proto.setup, unbind = proto.unbind; + can.extend(proto, { + setup: function (instances, options) { + setup.apply(this, arguments); + this._comparatorBound = false; + this._init = 1; + this.bind('comparator', can.proxy(this._comparatorUpdated, this)); + delete this._init; + if (this.comparator) { + this.sort(); + } + }, + _comparatorUpdated: function (ev, newValue) { + if (newValue || newValue === 0) { + this.sort(); + if (this._bindings > 0 && !this._comparatorBound) { + this.bind('change', this._comparatorBound = function () { + }); + } + } else if (this._comparatorBound) { + unbind.call(this, 'change', this._comparatorBound); + this._comparatorBound = false; + } + }, + unbind: function (ev, handler) { + var res = unbind.apply(this, arguments); + if (this._comparatorBound && this._bindings === 1) { + unbind.call(this, 'change', this._comparatorBound); + this._comparatorBound = false; + } + return res; + }, + _comparator: function (a, b) { + var comparator = this.comparator; + if (comparator && typeof comparator === 'function') { + return comparator(a, b); + } + return a === b ? 0 : a < b ? -1 : 1; + }, + _changes: function (ev, attr, how, newVal, oldVal) { + if (this.comparator && /^\d+/.test(attr)) { + if (ev.batchNum && ev.batchNum !== this._lastBatchNum) { + this.sort(); + this._lastBatchNum = ev.batchNum; + return; + } + var currentIndex = +/^\d+/.exec(attr)[0], item = this[currentIndex]; + if (typeof item !== 'undefined') { + var newIndex = this._getInsertIndex(item, currentIndex); + if (newIndex !== currentIndex) { + this._swapItems(currentIndex, newIndex); + can.trigger(this, 'length', [this.length]); + } + } + } + _changes.apply(this, arguments); + }, + _getInsertIndex: function (item, currentIndex) { + var a = this._getComparatorValue(item), b, offset = 0; + for (var i = 0; i < this.length; i++) { + b = this._getComparatorValue(this[i]); + if (typeof currentIndex !== 'undefined' && i === currentIndex) { + offset = -1; + continue; + } + if (this._comparator(a, b) < 0) { + return i + offset; + } + } + return i + offset; + }, + _getComparatorValue: function (item, overwrittenComparator) { + var comparator = typeof overwrittenComparator === 'string' ? overwrittenComparator : this.comparator; + if (item && comparator && typeof comparator === 'string') { + item = typeof item[comparator] === 'function' ? item[comparator]() : item.attr(comparator); + } + return item; + }, + _getComparatorValues: function () { + var self = this; + var a = []; + this.each(function (item, index) { + a.push(self._getComparatorValue(item)); + }); + return a; + }, + sort: function (comparator, silent) { + var a, b, c, isSorted; + var comparatorFn = can.isFunction(comparator) ? comparator : this._comparator; + for (var i, iMin, j = 0, n = this.length; j < n - 1; j++) { + iMin = j; + isSorted = true; + c = undefined; + for (i = j + 1; i < n; i++) { + a = this._getComparatorValue(this.attr(i), comparator); + b = this._getComparatorValue(this.attr(iMin), comparator); + if (comparatorFn.call(this, a, b) < 0) { + isSorted = false; + iMin = i; + } + if (c && comparatorFn.call(this, a, c) < 0) { + isSorted = false; + } + c = a; + } + if (isSorted) { + break; + } + if (iMin !== j) { + this._swapItems(iMin, j, silent); + } + } + if (!silent) { + can.trigger(this, 'length', [this.length]); + } + return this; + }, + _swapItems: function (oldIndex, newIndex, silent) { + var temporaryItemReference = this[oldIndex]; + [].splice.call(this, oldIndex, 1); + [].splice.call(this, newIndex, 0, temporaryItemReference); + if (!silent) { + can.trigger(this, 'move', [ + temporaryItemReference, + newIndex, + oldIndex + ]); + } + } + }); + var getArgs = function (args) { + return args[0] && can.isArray(args[0]) ? args[0] : can.makeArray(args); + }; + can.each({ + push: 'length', + unshift: 0 + }, function (where, name) { + var proto = can.List.prototype, old = proto[name]; + proto[name] = function () { + if (this.comparator && arguments.length) { + var args = getArgs(arguments); + var i = args.length; + while (i--) { + var val = can.bubble.set(this, i, this.__type(args[i], i)); + var newIndex = this._getInsertIndex(val); + Array.prototype.splice.apply(this, [ + newIndex, + 0, + val + ]); + this._triggerChange('' + newIndex, 'add', [val], undefined); + } + can.batch.trigger(this, 'reset', [args]); + return this; + } else { + return old.apply(this, arguments); + } + }; + }); + (function () { + var proto = can.List.prototype; + var oldSplice = proto.splice; + proto.splice = function (index, howMany) { + var args = can.makeArray(arguments), newElements = [], i, len; + if (!this.comparator) { + return oldSplice.apply(this, args); + } + for (i = 2, len = args.length; i < len; i++) { + args[i] = this.__type(args[i], i); + newElements.push(args[i]); + } + oldSplice.call(this, index, howMany); + proto.push.apply(this, newElements); + }; + }()); + return can.Map; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map.js new file mode 100644 index 0000000000..e084ddfdeb --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map.js @@ -0,0 +1,439 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/map*/ +define([ + 'can/util/library', + 'can/util/bind', + 'can/bubble', + 'can/construct', + 'can/util/batch' +], function (can, bind, bubble) { + var madeMap = null; + var teardownMap = function () { + for (var cid in madeMap) { + if (madeMap[cid].added) { + delete madeMap[cid].obj._cid; + } + } + madeMap = null; + }; + var getMapFromObject = function (obj) { + return madeMap && madeMap[obj._cid] && madeMap[obj._cid].instance; + }; + var serializeMap = null; + var Map = can.Map = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Map) { + if (!this.defaults) { + this.defaults = {}; + } + this._computes = []; + for (var prop in this.prototype) { + if (prop !== 'define' && prop !== 'constructor' && (typeof this.prototype[prop] !== 'function' || this.prototype[prop].prototype instanceof can.Construct)) { + this.defaults[prop] = this.prototype[prop]; + } else if (this.prototype[prop].isComputed) { + this._computes.push(prop); + } + } + if (this.helpers.define) { + this.helpers.define(this); + } + } + if (can.List && !(this.prototype instanceof can.List)) { + this.List = Map.List.extend({ Map: this }, {}); + } + }, + _bubble: bubble, + _bubbleRule: function (eventName) { + return eventName === 'change' || eventName.indexOf('.') >= 0 ? ['change'] : []; + }, + _computes: [], + bind: can.bindAndSetup, + on: can.bindAndSetup, + unbind: can.unbindAndTeardown, + off: can.unbindAndTeardown, + id: 'id', + helpers: { + define: null, + attrParts: function (attr, keepKey) { + if (keepKey) { + return [attr]; + } + return typeof attr === 'object' ? attr : ('' + attr).split('.'); + }, + addToMap: function (obj, instance) { + var teardown; + if (!madeMap) { + teardown = teardownMap; + madeMap = {}; + } + var hasCid = obj._cid; + var cid = can.cid(obj); + if (!madeMap[cid]) { + madeMap[cid] = { + obj: obj, + instance: instance, + added: !hasCid + }; + } + return teardown; + }, + isObservable: function (obj) { + return obj instanceof can.Map || obj && obj === can.route; + }, + canMakeObserve: function (obj) { + return obj && !can.isDeferred(obj) && (can.isArray(obj) || can.isPlainObject(obj)); + }, + serialize: function (map, how, where) { + var cid = can.cid(map), firstSerialize = false; + if (!serializeMap) { + firstSerialize = true; + serializeMap = { + attr: {}, + serialize: {} + }; + } + serializeMap[how][cid] = where; + map.each(function (val, name) { + var result, isObservable = Map.helpers.isObservable(val), serialized = isObservable && serializeMap[how][can.cid(val)]; + if (serialized) { + result = serialized; + } else { + if (how === 'serialize') { + result = Map.helpers._serialize(map, name, val); + } else { + result = Map.helpers._getValue(map, name, val, how); + } + } + if (result !== undefined) { + where[name] = result; + } + }); + can.__observe(map, '__keys'); + if (firstSerialize) { + serializeMap = null; + } + return where; + }, + _serialize: function (map, name, val) { + return Map.helpers._getValue(map, name, val, 'serialize'); + }, + _getValue: function (map, name, val, how) { + if (Map.helpers.isObservable(val)) { + return val[how](); + } else { + return val; + } + } + }, + keys: function (map) { + var keys = []; + can.__observe(map, '__keys'); + for (var keyName in map._data) { + keys.push(keyName); + } + return keys; + } + }, { + setup: function (obj) { + if (obj instanceof can.Map) { + obj = obj.serialize(); + } + this._data = {}; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + var defaultValues = this._setupDefaults(obj); + this._setupComputes(defaultValues); + var teardownMapping = obj && can.Map.helpers.addToMap(obj, this); + var data = can.extend(can.extend(true, {}, defaultValues), obj); + this.attr(data); + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + delete this._init; + }, + _setupComputes: function () { + var computes = this.constructor._computes; + for (var i = 0, len = computes.length, prop; i < len; i++) { + prop = computes[i]; + this[prop] = this[prop].clone(this); + this._computedBindings[prop] = { count: 0 }; + } + }, + _setupDefaults: function () { + return this.constructor.defaults || {}; + }, + _bindsetup: function () { + }, + _bindteardown: function () { + }, + _changes: function (ev, attr, how, newVal, oldVal) { + can.batch.trigger(this, { + type: attr, + batchNum: ev.batchNum, + target: ev.target + }, [ + newVal, + oldVal + ]); + }, + _triggerChange: function (attr, how, newVal, oldVal) { + if (bubble.isBubbling(this, 'change')) { + can.batch.trigger(this, { + type: 'change', + target: this + }, [ + attr, + how, + newVal, + oldVal + ]); + } else { + can.batch.trigger(this, attr, [ + newVal, + oldVal + ]); + } + if (how === 'remove' || how === 'add') { + can.batch.trigger(this, { + type: '__keys', + target: this + }); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var prop in data) { + if (data.hasOwnProperty(prop)) { + callback(data[prop], prop); + } + } + }, + attr: function (attr, val) { + var type = typeof attr; + if (type !== 'string' && type !== 'number') { + return this._attrs(attr, val); + } else if (arguments.length === 1) { + return this._get(attr); + } else { + this._set(attr, val); + return this; + } + }, + each: function () { + return can.each.apply(undefined, [this].concat(can.makeArray(arguments))); + }, + removeAttr: function (attr) { + var isList = can.List && this instanceof can.List, parts = can.Map.helpers.attrParts(attr), prop = parts.shift(), current = isList ? this[prop] : this._data[prop]; + if (parts.length && current) { + return current.removeAttr(parts); + } else { + if (typeof attr === 'string' && !!~attr.indexOf('.')) { + prop = attr; + } + this._remove(prop, current); + return current; + } + }, + _remove: function (prop, current) { + if (prop in this._data) { + delete this._data[prop]; + if (!(prop in this.constructor.prototype)) { + delete this[prop]; + } + this._triggerChange(prop, 'remove', undefined, current); + } + }, + _get: function (attr) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'); + if (dotIndex >= 0) { + var value = this.__get(attr); + if (value !== undefined) { + return value; + } + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + can.__observe(this, first); + var current = this.__get(first); + return current && current._get ? current._get(second) : undefined; + } else { + can.__observe(this, attr); + return this.__get(attr); + } + }, + __get: function (attr) { + if (attr) { + if (this._computedBindings[attr]) { + return this[attr](); + } else { + return this._data[attr]; + } + } else { + return this._data; + } + }, + __type: function (value, prop) { + if (!(value instanceof can.Map) && can.Map.helpers.canMakeObserve(value)) { + var cached = getMapFromObject(value); + if (cached) { + return cached; + } + if (can.isArray(value)) { + var List = can.List; + return new List(value); + } else { + var Map = this.constructor.Map || can.Map; + return new Map(value); + } + } + return value; + }, + _set: function (attr, value, keepKey) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'), current; + if (!keepKey && dotIndex >= 0) { + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + current = this._init ? undefined : this.__get(first); + if (Map.helpers.isObservable(current)) { + current._set(second, value); + } else { + throw 'can.Map: Object does not exist'; + } + } else { + if (this.__convert) { + value = this.__convert(attr, value); + } + current = this._init ? undefined : this.__get(attr); + this.__set(attr, this.__type(value, attr), current); + } + }, + __set: function (prop, value, current) { + if (value !== current) { + var changeType = current !== undefined || this.__get().hasOwnProperty(prop) ? 'set' : 'add'; + this.___set(prop, this.constructor._bubble.set(this, prop, value, current)); + if (!this._computedBindings[prop]) { + this._triggerChange(prop, changeType, value, current); + } + if (current) { + this.constructor._bubble.teardownFromParent(this, current); + } + } + }, + ___set: function (prop, val) { + if (this._computedBindings[prop]) { + this[prop](val); + } else { + this._data[prop] = val; + } + if (typeof this.constructor.prototype[prop] !== 'function' && !this._computedBindings[prop]) { + this[prop] = val; + } + }, + bind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (!computedBinding.count) { + computedBinding.count = 1; + var self = this; + computedBinding.handler = function (ev, newVal, oldVal) { + can.batch.trigger(self, { + type: eventName, + batchNum: ev.batchNum, + target: self + }, [ + newVal, + oldVal + ]); + }; + this[eventName].bind('change', computedBinding.handler); + } else { + computedBinding.count++; + } + } + this.constructor._bubble.bind(this, eventName); + return can.bindAndSetup.apply(this, arguments); + }, + unbind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (computedBinding.count === 1) { + computedBinding.count = 0; + this[eventName].unbind('change', computedBinding.handler); + delete computedBinding.handler; + } else { + computedBinding.count--; + } + } + this.constructor._bubble.unbind(this, eventName); + return can.unbindAndTeardown.apply(this, arguments); + }, + serialize: function () { + return can.Map.helpers.serialize(this, 'serialize', {}); + }, + _attrs: function (props, remove) { + if (props === undefined) { + return Map.helpers.serialize(this, 'attr', {}); + } + props = can.simpleExtend({}, props); + var prop, self = this, newVal; + can.batch.start(); + this.each(function (curVal, prop) { + if (prop === '_cid') { + return; + } + newVal = props[prop]; + if (newVal === undefined) { + if (remove) { + self.removeAttr(prop); + } + return; + } + if (self.__convert) { + newVal = self.__convert(prop, newVal); + } + if (Map.helpers.isObservable(newVal)) { + self.__set(prop, self.__type(newVal, prop), curVal); + } else if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + self.__set(prop, self.__type(newVal, prop), curVal); + } + delete props[prop]; + }); + for (prop in props) { + if (prop !== '_cid') { + newVal = props[prop]; + this._set(prop, newVal, true); + } + } + can.batch.stop(); + return this; + }, + compute: function (prop) { + if (can.isFunction(this.constructor.prototype[prop])) { + return can.compute(this[prop], this); + } else { + var reads = prop.split('.'), last = reads.length - 1, options = { args: [] }; + return can.compute(function (newVal) { + if (arguments.length) { + can.compute.read(this, reads.slice(0, last)).value.attr(reads[last], newVal); + } else { + return can.compute.read(this, reads, options).value; + } + }, this); + } + } + }); + Map.prototype.on = Map.prototype.bind; + Map.prototype.off = Map.prototype.unbind; + return Map; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/attributes.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/attributes.js new file mode 100644 index 0000000000..67abfe7d52 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/attributes.js @@ -0,0 +1,121 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/attributes/attributes*/ +define([ + 'can/util/library', + 'can/map', + 'can/list' +], function (can, Map) { + can.each([ + can.Map, + can.Model + ], function (clss) { + if (clss === undefined) { + return; + } + var isObject = function (obj) { + return typeof obj === 'object' && obj !== null && obj; + }; + can.extend(clss, { + attributes: {}, + convert: { + 'date': function (str) { + var type = typeof str; + if (type === 'string') { + str = Date.parse(str); + return isNaN(str) ? null : new Date(str); + } else if (type === 'number') { + return new Date(str); + } else { + return str; + } + }, + 'number': function (val) { + return parseFloat(val); + }, + 'boolean': function (val) { + if (val === 'false' || val === '0' || !val) { + return false; + } + return true; + }, + 'default': function (val, oldVal, error, type) { + if (can.Map.prototype.isPrototypeOf(type.prototype) && typeof type.model === 'function' && typeof type.models === 'function') { + return type[can.isArray(val) ? 'models' : 'model'](val); + } + if (can.Map.prototype.isPrototypeOf(type.prototype)) { + if (can.isArray(val) && typeof type.List === 'function') { + return new type.List(val); + } + return new type(val); + } + if (typeof type === 'function') { + return type(val, oldVal); + } + var construct = can.getObject(type), context = window, realType; + if (type.indexOf('.') >= 0) { + realType = type.substring(0, type.lastIndexOf('.')); + context = can.getObject(realType); + } + return typeof construct === 'function' ? construct.call(context, val, oldVal) : val; + } + }, + serialize: { + 'default': function (val, type) { + return isObject(val) && val.serialize ? val.serialize() : val; + }, + 'date': function (val) { + return val && val.getTime(); + } + } + }); + var oldSetup = clss.setup; + clss.setup = function (superClass, stat, proto) { + var self = this; + oldSetup.call(self, superClass, stat, proto); + can.each(['attributes'], function (name) { + if (!self[name] || superClass[name] === self[name]) { + self[name] = {}; + } + }); + can.each([ + 'convert', + 'serialize' + ], function (name) { + if (superClass[name] !== self[name]) { + self[name] = can.extend({}, superClass[name], self[name]); + } + }); + }; + }); + can.Map.prototype.__convert = function (prop, value) { + var Class = this.constructor, oldVal = this.__get(prop), type, converter; + if (Class.attributes) { + type = Class.attributes[prop]; + converter = Class.convert[type] || Class.convert['default']; + } + return value === null || !type ? value : converter.call(Class, value, oldVal, function () { + }, type); + }; + var oldSerialize = can.Map.helpers._serialize; + can.Map.helpers._serialize = function (map, name, val) { + var constructor = map.constructor, type = constructor.attributes ? constructor.attributes[name] : 0, converter = constructor.serialize ? constructor.serialize[type] : 0; + return val && typeof val.serialize === 'function' ? oldSerialize.apply(this, arguments) : converter ? converter(val, type) : oldSerialize.apply(this, arguments); + }; + var mapSerialize = can.Map.prototype.serialize; + can.Map.prototype.serialize = function (attrName) { + var baseResult = mapSerialize.apply(this, arguments); + if (attrName) { + return baseResult[attrName]; + } else { + return baseResult; + } + }; + return can.Map; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/backup.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/backup.js new file mode 100644 index 0000000000..2b246bbb8d --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/backup.js @@ -0,0 +1,49 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/backup/backup*/ +define([ + 'can/util/library', + 'can/compute', + 'can/map', + 'can/util/object' +], function (can) { + var flatProps = function (a, cur) { + var obj = {}; + for (var prop in a) { + if (typeof a[prop] !== 'object' || a[prop] === null || a[prop] instanceof Date) { + obj[prop] = a[prop]; + } else { + obj[prop] = cur.attr(prop); + } + } + return obj; + }; + var oldSetup = can.Map.prototype.setup; + can.extend(can.Map.prototype, { + setup: function () { + this._backupStore = can.compute(); + return oldSetup.apply(this, arguments); + }, + backup: function () { + this._backupStore(this.attr()); + return this; + }, + isDirty: function (checkAssociations) { + return this._backupStore() && !can.Object.same(this.attr(), this._backupStore(), undefined, undefined, undefined, !!checkAssociations); + }, + restore: function (restoreAssociations) { + var props = restoreAssociations ? this._backupStore() : flatProps(this._backupStore(), this); + if (this.isDirty(restoreAssociations)) { + this.attr(props, true); + } + return this; + } + }); + return can.Map; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/bubble.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/bubble.js new file mode 100644 index 0000000000..53090ccc00 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/bubble.js @@ -0,0 +1,28 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/lazy/bubble*/ +define([ + 'can/util/library', + 'can/bubble' +], function (can) { + var bubble = can.bubble; + return can.extend({}, bubble, { + childrenOf: function (parentMap, eventName) { + if (parentMap._nestedReference) { + parentMap._nestedReference.each(function (child, ref) { + if (child && child.bind) { + bubble.toParent(child, parentMap, ref(), eventName); + } + }); + } else { + bubble._each.apply(this, arguments); + } + } + }); +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/define.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/define.js new file mode 100644 index 0000000000..fafe4e00ca --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/define.js @@ -0,0 +1,249 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/define/define*/ +define([ + 'can/util/library', + 'can/observe' +], function (can) { + var define = can.define = {}; + var getPropDefineBehavior = function (behavior, attr, define) { + var prop, defaultProp; + if (define) { + prop = define[attr]; + defaultProp = define['*']; + if (prop && prop[behavior] !== undefined) { + return prop[behavior]; + } else if (defaultProp && defaultProp[behavior] !== undefined) { + return defaultProp[behavior]; + } + } + }; + can.Map.helpers.define = function (Map) { + var definitions = Map.prototype.define; + Map.defaultGenerators = {}; + for (var prop in definitions) { + var type = definitions[prop].type; + if (typeof type === 'string') { + if (typeof define.types[type] === 'object') { + delete definitions[prop].type; + can.extend(definitions[prop], define.types[type]); + } + } + if ('value' in definitions[prop]) { + if (typeof definitions[prop].value === 'function') { + Map.defaultGenerators[prop] = definitions[prop].value; + } else { + Map.defaults[prop] = definitions[prop].value; + } + } + if (typeof definitions[prop].Value === 'function') { + (function (Constructor) { + Map.defaultGenerators[prop] = function () { + return new Constructor(); + }; + }(definitions[prop].Value)); + } + } + }; + var oldSetupDefaults = can.Map.prototype._setupDefaults; + can.Map.prototype._setupDefaults = function (obj) { + var defaults = oldSetupDefaults.call(this), propsCommittedToAttr = {}, Map = this.constructor, originalGet = this._get; + this._get = function (originalProp) { + prop = originalProp.indexOf('.') !== -1 ? originalProp.substr(0, originalProp.indexOf('.')) : prop; + if (prop in defaults && !(prop in propsCommittedToAttr)) { + this.attr(prop, defaults[prop]); + propsCommittedToAttr[prop] = true; + } + return originalGet.apply(this, arguments); + }; + for (var prop in Map.defaultGenerators) { + if (!obj || !(prop in obj)) { + defaults[prop] = Map.defaultGenerators[prop].call(this); + } + } + this._get = originalGet; + return defaults; + }; + var proto = can.Map.prototype, oldSet = proto.__set; + proto.__set = function (prop, value, current, success, error) { + var errorCallback = function (errors) { + var stub = error && error.call(self, errors); + if (stub !== false) { + can.trigger(self, 'error', [ + prop, + errors + ], true); + } + return false; + }, self = this, setter = getPropDefineBehavior('set', prop, this.define), getter = getPropDefineBehavior('get', prop, this.define); + if (setter) { + can.batch.start(); + var setterCalled = false, setValue = setter.call(this, value, function (value) { + if (getter) { + self[prop](value); + } else { + oldSet.call(self, prop, value, current, success, errorCallback); + } + setterCalled = true; + }, errorCallback, getter ? this[prop].computeInstance.lastSetValue.get() : current); + if (getter) { + if (setValue !== undefined && !setterCalled && setter.length >= 1) { + this[prop](setValue); + } + can.batch.stop(); + return; + } else if (setValue === undefined && !setterCalled && setter.length >= 1) { + can.batch.stop(); + return; + } else { + if (!setterCalled) { + oldSet.call(self, prop, setter.length === 0 && setValue === undefined ? value : setValue, current, success, errorCallback); + } + can.batch.stop(); + return this; + } + } else { + oldSet.call(self, prop, value, current, success, errorCallback); + } + return this; + }; + define.types = { + 'date': function (str) { + var type = typeof str; + if (type === 'string') { + str = Date.parse(str); + return isNaN(str) ? null : new Date(str); + } else if (type === 'number') { + return new Date(str); + } else { + return str; + } + }, + 'number': function (val) { + if (val == null) { + return val; + } + return +val; + }, + 'boolean': function (val) { + if (val === 'false' || val === '0' || !val) { + return false; + } + return true; + }, + 'htmlbool': function (val) { + return typeof val === 'string' || !!val; + }, + '*': function (val) { + return val; + }, + 'string': function (val) { + if (val == null) { + return val; + } + return '' + val; + }, + 'compute': { + set: function (newValue, setVal, setErr, oldValue) { + if (newValue.isComputed) { + return newValue; + } + if (oldValue && oldValue.isComputed) { + oldValue(newValue); + return oldValue; + } + return newValue; + }, + get: function (value) { + return value && value.isComputed ? value() : value; + } + } + }; + var oldType = proto.__type; + proto.__type = function (value, prop) { + var type = getPropDefineBehavior('type', prop, this.define), Type = getPropDefineBehavior('Type', prop, this.define), newValue = value; + if (typeof type === 'string') { + type = define.types[type]; + } + if (type || Type) { + if (type) { + newValue = type.call(this, newValue, prop); + } + if (Type && !(newValue instanceof Type)) { + newValue = new Type(newValue); + } + return newValue; + } else if (can.isPlainObject(newValue) && newValue.define) { + newValue = can.Map.extend(newValue); + newValue = new newValue(); + } + return oldType.call(this, newValue, prop); + }; + var oldRemove = proto._remove; + proto._remove = function (prop, current) { + var remove = getPropDefineBehavior('remove', prop, this.define), res; + if (remove) { + can.batch.start(); + res = remove.call(this, current); + if (res === false) { + can.batch.stop(); + return; + } else { + res = oldRemove.call(this, prop, current); + can.batch.stop(); + return res; + } + } + return oldRemove.call(this, prop, current); + }; + var oldSetupComputes = proto._setupComputes; + proto._setupComputes = function (defaultsValues) { + oldSetupComputes.apply(this, arguments); + for (var attr in this.define) { + var def = this.define[attr], get = def.get; + if (get) { + this[attr] = can.compute.async(defaultsValues[attr], get, this); + this._computedBindings[attr] = { count: 0 }; + } + } + }; + var oldSingleSerialize = can.Map.helpers._serialize; + can.Map.helpers._serialize = function (map, name, val) { + return serializeProp(map, name, val); + }; + var serializeProp = function (map, attr, val) { + var serializer = attr === '*' ? false : getPropDefineBehavior('serialize', attr, map.define); + if (serializer === undefined) { + return oldSingleSerialize.apply(this, arguments); + } else if (serializer !== false) { + return typeof serializer === 'function' ? serializer.call(map, val, attr) : oldSingleSerialize.apply(this, arguments); + } + }; + var oldSerialize = proto.serialize; + proto.serialize = function (property) { + var serialized = oldSerialize.apply(this, arguments); + if (property) { + return serialized; + } + var serializer, val; + for (var attr in this.define) { + if (!(attr in serialized)) { + serializer = this.define && this.define[attr] && this.define[attr].serialize; + if (serializer) { + val = serializeProp(this, attr, this.attr(attr)); + if (val !== undefined) { + serialized[attr] = val; + } + } + } + } + return serialized; + }; + return can.define; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/delegate.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/delegate.js new file mode 100644 index 0000000000..8d55ae3588 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/delegate.js @@ -0,0 +1,133 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/delegate/delegate*/ +define([ + 'can/util/library', + 'can/map' +], function (can) { + var delegateMatches = function (parts, props) { + var len = parts.length, i = 0, matchedProps = [], prop; + for (i; i < len; i++) { + prop = props[i]; + if (typeof prop !== 'string') { + return null; + } else if (parts[i] === '**') { + return props.join('.'); + } else if (parts[i] === '*') { + matchedProps.push(prop); + } else if (prop === parts[i]) { + matchedProps.push(prop); + } else { + return null; + } + } + return matchedProps.join('.'); + }, delegateHandler = function (event, prop, how, newVal, oldVal) { + var props = prop.split('.'), delegates = (this._observe_delegates || []).slice(0), delegate, attr, matchedAttr, hasMatch, valuesEqual; + event.attr = prop; + event.lastAttr = props[props.length - 1]; + for (var i = 0; delegate = delegates[i++];) { + if (event.batchNum && delegate.batchNum === event.batchNum || delegate.undelegated) { + continue; + } + hasMatch = undefined; + valuesEqual = true; + for (var a = 0; a < delegate.attrs.length; a++) { + attr = delegate.attrs[a]; + matchedAttr = delegateMatches(attr.parts, props); + if (matchedAttr) { + hasMatch = matchedAttr; + } + if (attr.value && valuesEqual) { + valuesEqual = attr.value === '' + this.attr(attr.attr); + } else if (valuesEqual && delegate.attrs.length > 1) { + valuesEqual = this.attr(attr.attr) !== undefined; + } + } + if (hasMatch && valuesEqual) { + var from = prop.replace(hasMatch + '.', ''); + if (event.batchNum) { + delegate.batchNum = event.batchNum; + } + if (delegate.event === 'change') { + prop = from; + event.curAttr = hasMatch; + delegate.callback.apply(this.attr(hasMatch), can.makeArray(arguments)); + } else if (delegate.event === how) { + delegate.callback.apply(this.attr(hasMatch), [ + event, + newVal, + oldVal, + from + ]); + } else if (delegate.event === 'set' && how === 'add') { + delegate.callback.apply(this.attr(hasMatch), [ + event, + newVal, + oldVal, + from + ]); + } + } + } + }; + can.extend(can.Map.prototype, { + delegate: function (selector, event, handler) { + selector = can.trim(selector); + var delegates = this._observe_delegates || (this._observe_delegates = []), attrs = [], selectorRegex = /([^\s=,]+)(?:=("[^",]*"|'[^',]*'|[^\s"',]*))?(,?)\s*/g, matches; + while ((matches = selectorRegex.exec(selector)) !== null) { + if (matches[2] && can.inArray(matches[2].substr(0, 1), [ + '"', + '\'' + ]) >= 0) { + matches[2] = matches[2].substr(1, -1); + } + attrs.push({ + attr: matches[1], + parts: matches[1].split('.'), + value: matches[2], + or: matches[3] === ',' + }); + } + delegates.push({ + selector: selector, + attrs: attrs, + callback: handler, + event: event + }); + if (delegates.length === 1) { + this.bind('change', delegateHandler); + } + return this; + }, + undelegate: function (selector, event, handler) { + selector = selector && can.trim(selector); + var i = 0, delegates = this._observe_delegates || [], delegateOb; + if (selector) { + while (i < delegates.length) { + delegateOb = delegates[i]; + if (delegateOb.callback === handler || !handler && delegateOb.selector === selector) { + delegateOb.undelegated = true; + delegates.splice(i, 1); + } else { + i++; + } + } + } else { + delegates = []; + } + if (!delegates.length) { + this.unbind('change', delegateHandler); + } + return this; + } + }); + can.Map.prototype.delegate.matches = delegateMatches; + return can.Map; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/lazy.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/lazy.js new file mode 100644 index 0000000000..bf374d8f59 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/lazy.js @@ -0,0 +1,225 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/lazy/lazy*/ +define([ + 'can/util/library', + 'can/map/bubble', + 'can/map', + 'can/list', + 'can/map/nested_reference' +], function (can, bubble) { + can.LazyMap = can.Map.extend({ _bubble: bubble }, { + setup: function (obj) { + this.constructor.Map = this.constructor; + this.constructor.List = can.LazyList; + this._data = can.extend(can.extend(true, {}, this._setupDefaults() || {}), obj); + can.cid(this, '.lazyMap'); + this._init = 1; + this._computedBindings = {}; + this._setupComputes(); + var teardownMapping = obj && can.Map.helpers.addToMap(obj, this); + this._nestedReference = new can.NestedReference(this._data); + if (teardownMapping) { + teardownMapping(); + } + can.each(this._data, can.proxy(function (value, prop) { + this.___set(prop, value); + }, this)); + this.bind('change', can.proxy(this._changes, this)); + delete this._init; + }, + _addChild: function (path, newChild, setNewChild) { + var self = this; + this._nestedReference.removeChildren(path, function (oldChild, oldChildPath) { + bubble.remove(self, oldChild); + if (newChild) { + var newChildPath = oldChildPath.replace(path + '.', ''); + if (path === newChildPath) { + oldChild._nestedReference.each(function (obj, path) { + newChild._nestedReference.make(path()); + if (self._bindings) { + bubble.add(this, newChild, path()); + } + }); + } else { + var reference = newChild._nestedReference.make(newChildPath); + if (self._bindings) { + bubble.add(oldChild, newChild, reference()); + } + } + } + }); + if (setNewChild) { + setNewChild(); + } + if (newChild) { + var reference = this._nestedReference.make(path); + if (this._bindings) { + bubble.add(this, newChild, reference()); + } + } + return newChild; + }, + removeAttr: function (attr) { + var data = this._goto(attr); + if (data.parts.length) { + return data.value.removeAttr(data.parts.join('.')); + } else { + if (can.isArray(data.parent)) { + data.parent.splice(data.prop, 1); + this._triggerChange(attr, 'remove', undefined, [this.__type(data.value, data.prop)]); + } else { + if (data.parent[data.prop]) { + delete data.parent[data.prop]; + can.batch.trigger(this, data.path.length ? data.path.join('.') + '.__keys' : '__keys'); + this._triggerChange(attr, 'remove', undefined, this.__type(data.value, data.prop)); + } + } + this._nestedReference.removeChildren(); + return data.value; + } + }, + __type: function (value, prop) { + if (!(value instanceof can.LazyMap) && can.Map.helpers.canMakeObserve(value)) { + if (can.isArray(value)) { + var List = can.LazyList; + return new List(value); + } else { + var Map = this.constructor.Map || can.LazyMap; + return new Map(value); + } + } + return value; + }, + _goto: function (attr, keepKey) { + var parts = can.Map.helpers.attrParts(attr, keepKey).slice(0), prev, path = [], part; + var cur = this instanceof can.List ? this[parts.shift()] : this.__get(); + while (cur && !can.Map.helpers.isObservable(cur) && parts.length) { + if (part !== undefined) { + path.push(part); + } + prev = cur; + cur = cur[part = parts.shift()]; + } + return { + parts: parts, + prop: part, + value: cur, + parent: prev, + path: path + }; + }, + _get: function (attr) { + can.__observe(this, attr); + var data = this._goto(attr); + if (can.Map.helpers.isObservable(data.value)) { + if (data.parts.length) { + return data.value._get(data.parts); + } else { + return data.value; + } + } else if (data.value && can.Map.helpers.canMakeObserve(data.value)) { + var converted = this.__type(data.value, data.prop); + this._addChild(attr, converted, function () { + data.parent[data.prop] = converted; + }); + return converted; + } else if (data.value !== undefined) { + return data.value; + } else { + return this.__get(attr); + } + }, + _set: function (attr, value, keepKey) { + var data = this._goto(attr, keepKey); + if (can.Map.helpers.isObservable(data.value) && data.parts.length) { + return data.value._set(data.parts, value); + } else if (!data.parts.length) { + this.__set(attr, value, data.value, data); + } else { + throw 'can.LazyMap: object does not exist'; + } + }, + __set: function (prop, value, current, data, convert) { + convert = convert || true; + if (value !== current) { + var changeType = data.parent.hasOwnProperty(data.prop) ? 'set' : 'add'; + if (convert && can.Map.helpers.canMakeObserve(value)) { + value = this.__type(value, prop); + var self = this; + this._addChild(prop, value, function () { + self.___set(prop, value, data); + }); + } else { + this.___set(prop, value, data); + } + if (changeType === 'add') { + can.batch.trigger(this, data.path.length ? data.path.join('.') + '.__keys' : '__keys', undefined); + } + this._triggerChange(prop, changeType, value, current); + } + }, + ___set: function (prop, val, data) { + if (this[prop] && this[prop].isComputed && can.isFunction(this.constructor.prototype[prop])) { + this[prop](val); + } else if (data) { + data.parent[data.prop] = val; + } else { + this._data[prop] = val; + } + if (!can.isFunction(this.constructor.prototype[prop])) { + this[prop] = val; + } + }, + _attrs: function (props, remove) { + if (props === undefined) { + return can.Map.helpers.serialize(this, 'attr', {}); + } + props = can.extend({}, props); + var self = this, prop, data, newVal; + can.batch.start(); + this.each(function (curVal, prop) { + newVal = props[prop]; + data = self._goto(prop, true); + if (newVal === undefined) { + if (remove) { + self.removeAttr(prop); + } + return; + } else if (!can.Map.helpers.isObservable(curVal) && can.Map.helpers.canMakeObserve(curVal)) { + curVal = self.attr(prop); + } + if (self.__convert) { + newVal = self.__convert(prop, newVal); + } + if (newVal instanceof can.Map) { + self.__set(prop, newVal, curVal, data); + } else if (can.Map.helpers.isObservable(curVal) && can.Map.helpers.canMakeObserve(newVal) && curVal.attr) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + self.__set(prop, newVal, curVal, data); + } + delete props[prop]; + }); + for (prop in props) { + newVal = props[prop]; + this._set(prop, newVal, true); + } + can.batch.stop(); + return this; + } + }); + can.LazyList = can.List.extend({ Map: can.LazyMap }, { + setup: function () { + can.List.prototype.setup.apply(this, arguments); + this._nestedReference = new can.NestedReference(this); + } + }); + return can.LazyMap; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/list.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/list.js new file mode 100644 index 0000000000..9bc256e31d --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/list.js @@ -0,0 +1,77 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/list/list*/ +define([ + 'can/util/library', + 'can/map', + 'can/list', + 'can/compute' +], function (can) { + can.extend(can.List.prototype, { + filter: function (callback) { + var filtered = new this.constructor(); + var self = this; + var generator = function (element, index) { + var binder = function (ev, val) { + var index = filtered.indexOf(element); + if (!val && index !== -1) { + filtered.splice(index, 1); + } + if (val && index === -1) { + filtered.push(element); + } + }; + var compute = can.compute(function () { + return callback(element, self.indexOf(element), self); + }); + compute.bind('change', binder); + binder(null, compute()); + }; + this.bind('add', function (ev, data, index) { + can.each(data, function (element, i) { + generator(element, index + i); + }); + }); + this.bind('remove', function (ev, data, index) { + can.each(data, function (element, i) { + var index = filtered.indexOf(element); + if (index !== -1) { + filtered.splice(index, 1); + } + }); + }); + this.forEach(generator); + return filtered; + }, + map: function (callback) { + var mapped = new can.List(); + var self = this; + var generator = function (element, index) { + var compute = can.compute(function () { + return callback(element, index, self); + }); + compute.bind('change', function (ev, val) { + mapped.splice(index, 1, val); + }); + mapped.splice(index, 0, compute()); + }; + this.forEach(generator); + this.bind('add', function (ev, data, index) { + can.each(data, function (element, i) { + generator(element, index + i); + }); + }); + this.bind('remove', function (ev, data, index) { + mapped.splice(index, data.length); + }); + return mapped; + } + }); + return can.List; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/nested_reference.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/nested_reference.js new file mode 100644 index 0000000000..3f92f90ff9 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/nested_reference.js @@ -0,0 +1,80 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/lazy/nested_reference*/ +define(['can/util/library'], function (can) { + var pathIterator = function (root, propPath, callback) { + var props = propPath.split('.'), cur = root, part; + while (part = props.shift()) { + cur = cur[part]; + if (callback) { + callback(cur, part); + } + } + return cur; + }; + var ArrIndex = function (array) { + this.array = array; + }; + ArrIndex.prototype.toString = function () { + return '' + can.inArray(this.item, this.array); + }; + var NestedReference = function (root) { + this.root = root; + this.references = []; + }; + NestedReference.ArrIndex = ArrIndex; + can.extend(NestedReference.prototype, { + make: function (propPath) { + var path = [], arrIndex; + if (can.isArray(this.root) || this.root instanceof can.LazyList) { + arrIndex = new ArrIndex(this.root); + } + pathIterator(this.root, propPath, function (item, prop) { + if (arrIndex) { + arrIndex.item = item; + path.push(arrIndex); + arrIndex = undefined; + } else { + path.push(prop); + if (can.isArray(item)) { + arrIndex = new ArrIndex(item); + } + } + }); + var pathFunc = function () { + return path.join('.'); + }; + this.references.push(pathFunc); + return pathFunc; + }, + removeChildren: function (path, callback) { + var i = 0; + while (i < this.references.length) { + var reference = this.references[i](); + if (reference.indexOf(path) === 0) { + callback(this.get(reference), reference); + this.references.splice(i, 1); + } else { + i++; + } + } + }, + get: function (path) { + return pathIterator(this.root, path); + }, + each: function (callback) { + var self = this; + can.each(this.references, function (ref) { + var path = ref(); + callback(self.get(path), ref, path); + }); + } + }); + can.NestedReference = NestedReference; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/setter.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/setter.js new file mode 100644 index 0000000000..6db3db96d7 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/setter.js @@ -0,0 +1,52 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/setter/setter*/ +define([ + 'can/util/library', + 'can/map' +], function (can) { + can.classize = function (s, join) { + var parts = s.split(can.undHash), i = 0; + for (; i < parts.length; i++) { + parts[i] = can.capitalize(parts[i]); + } + return parts.join(join || ''); + }; + var classize = can.classize, proto = can.Map.prototype, old = proto.__set; + proto.__set = function (prop, value, current, success, error) { + var cap = classize(prop), setName = 'set' + cap, errorCallback = function (errors) { + var stub = error && error.call(self, errors); + if (stub !== false) { + can.trigger(self, 'error', [ + prop, + errors + ], true); + } + return false; + }, self = this; + if (this[setName]) { + can.batch.start(); + value = this[setName](value, function (value) { + old.call(self, prop, value, current, success, errorCallback); + }, errorCallback); + if (value === undefined) { + can.batch.stop(); + return; + } else { + old.call(self, prop, value, current, success, errorCallback); + can.batch.stop(); + return this; + } + } else { + old.call(self, prop, value, current, success, errorCallback); + } + return this; + }; + return can.Map; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/sort.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/sort.js new file mode 100644 index 0000000000..a19b58c623 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/sort.js @@ -0,0 +1,12 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/sort/sort*/ +define(['can/list/sort'], function (sortPlugin) { + return sortPlugin; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/validations.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/validations.js new file mode 100644 index 0000000000..d90790afdd --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/map/validations.js @@ -0,0 +1,161 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/validations/validations*/ +define([ + 'can/util/library', + 'can/map' +], function (can) { + var validate = function (attrNames, options, proc) { + if (!proc) { + proc = options; + options = {}; + } + options = options || {}; + attrNames = typeof attrNames === 'string' ? [attrNames] : can.makeArray(attrNames); + if (options.testIf && !options.testIf.call(this)) { + return; + } + var self = this; + can.each(attrNames, function (attrName) { + if (!self.validations[attrName]) { + self.validations[attrName] = []; + } + self.validations[attrName].push(function (newVal) { + var res = proc.call(this, newVal, attrName); + return res === undefined ? undefined : options.message || res; + }); + }); + }; + var old = can.Map.prototype.__set; + can.Map.prototype.__set = function (prop, value, current, success, error) { + var self = this, validations = self.constructor.validations, errorCallback = function (errors) { + var stub = error && error.call(self, errors); + if (stub !== false) { + can.trigger(self, 'error', [ + prop, + errors + ], true); + } + return false; + }; + old.call(self, prop, value, current, success, errorCallback); + if (validations && validations[prop]) { + var errors = self.errors(prop); + if (errors) { + errorCallback(errors); + } + } + return this; + }; + can.each([ + can.Map, + can.Model + ], function (clss) { + if (clss === undefined) { + return; + } + var oldSetup = clss.setup; + can.extend(clss, { + setup: function (superClass) { + oldSetup.apply(this, arguments); + if (!this.validations || superClass.validations === this.validations) { + this.validations = {}; + } + }, + validate: validate, + validationMessages: { + format: 'is invalid', + inclusion: 'is not a valid option (perhaps out of range)', + lengthShort: 'is too short', + lengthLong: 'is too long', + presence: 'can\'t be empty', + range: 'is out of range', + numericality: 'must be a number' + }, + validateFormatOf: function (attrNames, regexp, options) { + validate.call(this, attrNames, options, function (value) { + if (typeof value !== 'undefined' && value !== null && value !== '' && String(value).match(regexp) === null) { + return this.constructor.validationMessages.format; + } + }); + }, + validateInclusionOf: function (attrNames, inArray, options) { + validate.call(this, attrNames, options, function (value) { + if (typeof value === 'undefined') { + return; + } + for (var i = 0; i < inArray.length; i++) { + if (inArray[i] === value) { + return; + } + } + return this.constructor.validationMessages.inclusion; + }); + }, + validateLengthOf: function (attrNames, min, max, options) { + validate.call(this, attrNames, options, function (value) { + if ((typeof value === 'undefined' || value === null) && min > 0 || typeof value !== 'undefined' && value !== null && value.length < min) { + return this.constructor.validationMessages.lengthShort + ' (min=' + min + ')'; + } else if (typeof value !== 'undefined' && value !== null && value.length > max) { + return this.constructor.validationMessages.lengthLong + ' (max=' + max + ')'; + } + }); + }, + validatePresenceOf: function (attrNames, options) { + validate.call(this, attrNames, options, function (value) { + if (typeof value === 'undefined' || value === '' || value === null) { + return this.constructor.validationMessages.presence; + } + }); + }, + validateRangeOf: function (attrNames, low, hi, options) { + validate.call(this, attrNames, options, function (value) { + if ((typeof value === 'undefined' || value === null) && low > 0 || typeof value !== 'undefined' && value !== null && (value < low || value > hi)) { + return this.constructor.validationMessages.range + ' [' + low + ',' + hi + ']'; + } + }); + }, + validatesNumericalityOf: function (attrNames) { + validate.call(this, attrNames, function (value) { + var res = !isNaN(parseFloat(value)) && isFinite(value); + if (!res) { + return this.constructor.validationMessages.numericality; + } + }); + } + }); + }); + can.extend(can.Map.prototype, { + errors: function (attrs, newVal) { + if (attrs) { + attrs = can.isArray(attrs) ? attrs : [attrs]; + } + var errors = {}, self = this, addErrors = function (attr, funcs) { + can.each(funcs, function (func) { + var res = func.call(self, isTest ? self.__convert ? self.__convert(attr, newVal) : newVal : self.attr(attr)); + if (res) { + if (!errors[attr]) { + errors[attr] = []; + } + errors[attr].push(res); + } + }); + }, validations = this.constructor.validations || {}, isTest = attrs && attrs.length === 1 && arguments.length === 2; + can.each(attrs || validations, function (funcs, attr) { + if (typeof attr === 'number') { + attr = funcs; + funcs = validations[attr]; + } + addErrors(attr, funcs || []); + }); + return can.isEmptyObject(errors) ? null : isTest ? errors[attrs[0]] : errors; + } + }); + return can.Map; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/model.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/model.js new file mode 100644 index 0000000000..5719e93235 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/model.js @@ -0,0 +1,394 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#model/model*/ +define([ + 'can/util/library', + 'can/map', + 'can/list' +], function (can) { + var pipe = function (def, thisArg, func) { + var d = new can.Deferred(); + def.then(function () { + var args = can.makeArray(arguments), success = true; + try { + args[0] = func.apply(thisArg, args); + } catch (e) { + success = false; + d.rejectWith(d, [e].concat(args)); + } + if (success) { + d.resolveWith(d, args); + } + }, function () { + d.rejectWith(this, arguments); + }); + if (typeof def.abort === 'function') { + d.abort = function () { + return def.abort(); + }; + } + return d; + }, modelNum = 0, getId = function (inst) { + can.__observe(inst, inst.constructor.id); + return inst.__get(inst.constructor.id); + }, ajax = function (ajaxOb, data, type, dataType, success, error) { + var params = {}; + if (typeof ajaxOb === 'string') { + var parts = ajaxOb.split(/\s+/); + params.url = parts.pop(); + if (parts.length) { + params.type = parts.pop(); + } + } else { + can.extend(params, ajaxOb); + } + params.data = typeof data === 'object' && !can.isArray(data) ? can.extend(params.data || {}, data) : data; + params.url = can.sub(params.url, params.data, true); + return can.ajax(can.extend({ + type: type || 'post', + dataType: dataType || 'json', + success: success, + error: error + }, params)); + }, makeRequest = function (modelObj, type, success, error, method) { + var args; + if (can.isArray(modelObj)) { + args = modelObj[1]; + modelObj = modelObj[0]; + } else { + args = modelObj.serialize(); + } + args = [args]; + var deferred, model = modelObj.constructor, jqXHR; + if (type === 'update' || type === 'destroy') { + args.unshift(getId(modelObj)); + } + jqXHR = model[type].apply(model, args); + deferred = pipe(jqXHR, modelObj, function (data) { + modelObj[method || type + 'd'](data, jqXHR); + return modelObj; + }); + if (jqXHR.abort) { + deferred.abort = function () { + jqXHR.abort(); + }; + } + deferred.then(success, error); + return deferred; + }, converters = { + models: function (instancesRawData, oldList, xhr) { + can.Model._reqs++; + if (!instancesRawData) { + return; + } + if (instancesRawData instanceof this.List) { + return instancesRawData; + } + var self = this, tmp = [], ListClass = self.List || ML, modelList = oldList instanceof can.List ? oldList : new ListClass(), rawDataIsList = instancesRawData instanceof ML, raw = rawDataIsList ? instancesRawData.serialize() : instancesRawData; + raw = self.parseModels(raw, xhr); + if (raw.data) { + instancesRawData = raw; + raw = raw.data; + } + if (typeof raw === 'undefined' || !can.isArray(raw)) { + throw new Error('Could not get any raw data while converting using .models'); + } + if (modelList.length) { + modelList.splice(0); + } + can.each(raw, function (rawPart) { + tmp.push(self.model(rawPart, xhr)); + }); + modelList.push.apply(modelList, tmp); + if (!can.isArray(instancesRawData)) { + can.each(instancesRawData, function (val, prop) { + if (prop !== 'data') { + modelList.attr(prop, val); + } + }); + } + setTimeout(can.proxy(this._clean, this), 1); + return modelList; + }, + model: function (attributes, oldModel, xhr) { + if (!attributes) { + return; + } + if (typeof attributes.serialize === 'function') { + attributes = attributes.serialize(); + } else { + attributes = this.parseModel(attributes, xhr); + } + var id = attributes[this.id]; + if ((id || id === 0) && this.store[id]) { + oldModel = this.store[id]; + } + var model = oldModel && can.isFunction(oldModel.attr) ? oldModel.attr(attributes, this.removeAttr || false) : new this(attributes); + return model; + } + }, makeParser = { + parseModel: function (prop) { + return function (attributes) { + return prop ? can.getObject(prop, attributes) : attributes; + }; + }, + parseModels: function (prop) { + return function (attributes) { + if (can.isArray(attributes)) { + return attributes; + } + prop = prop || 'data'; + var result = can.getObject(prop, attributes); + if (!can.isArray(result)) { + throw new Error('Could not get any raw data while converting using .models'); + } + return result; + }; + } + }, ajaxMethods = { + create: { + url: '_shortName', + type: 'post' + }, + update: { + data: function (id, attrs) { + attrs = attrs || {}; + var identity = this.id; + if (attrs[identity] && attrs[identity] !== id) { + attrs['new' + can.capitalize(id)] = attrs[identity]; + delete attrs[identity]; + } + attrs[identity] = id; + return attrs; + }, + type: 'put' + }, + destroy: { + type: 'delete', + data: function (id, attrs) { + attrs = attrs || {}; + attrs.id = attrs[this.id] = id; + return attrs; + } + }, + findAll: { url: '_shortName' }, + findOne: {} + }, ajaxMaker = function (ajaxMethod, str) { + return function (data) { + data = ajaxMethod.data ? ajaxMethod.data.apply(this, arguments) : data; + return ajax(str || this[ajaxMethod.url || '_url'], data, ajaxMethod.type || 'get'); + }; + }, createURLFromResource = function (model, name) { + if (!model.resource) { + return; + } + var resource = model.resource.replace(/\/+$/, ''); + if (name === 'findAll' || name === 'create') { + return resource; + } else { + return resource + '/{' + model.id + '}'; + } + }; + can.Model = can.Map.extend({ + fullName: 'can.Model', + _reqs: 0, + setup: function (base, fullName, staticProps, protoProps) { + if (typeof fullName !== 'string') { + protoProps = staticProps; + staticProps = fullName; + } + if (!protoProps) { + protoProps = staticProps; + } + this.store = {}; + can.Map.setup.apply(this, arguments); + if (!can.Model) { + return; + } + if (staticProps && staticProps.List) { + this.List = staticProps.List; + this.List.Map = this; + } else { + this.List = base.List.extend({ Map: this }, {}); + } + var self = this, clean = can.proxy(this._clean, self); + can.each(ajaxMethods, function (method, name) { + if (staticProps && staticProps[name] && (typeof staticProps[name] === 'string' || typeof staticProps[name] === 'object')) { + self[name] = ajaxMaker(method, staticProps[name]); + } else if (staticProps && staticProps.resource && !can.isFunction(staticProps[name])) { + self[name] = ajaxMaker(method, createURLFromResource(self, name)); + } + if (self['make' + can.capitalize(name)]) { + var newMethod = self['make' + can.capitalize(name)](self[name]); + can.Construct._overwrite(self, base, name, function () { + can.Model._reqs++; + var def = newMethod.apply(this, arguments); + var then = def.then(clean, clean); + then.abort = def.abort; + return then; + }); + } + }); + var hasCustomConverter = {}; + can.each(converters, function (converter, name) { + var parseName = 'parse' + can.capitalize(name), dataProperty = staticProps && staticProps[name] || self[name]; + if (typeof dataProperty === 'string') { + self[parseName] = dataProperty; + can.Construct._overwrite(self, base, name, converter); + } else if (staticProps && staticProps[name]) { + hasCustomConverter[parseName] = true; + } + }); + can.each(makeParser, function (maker, parseName) { + var prop = staticProps && staticProps[parseName] || self[parseName]; + if (typeof prop === 'string') { + can.Construct._overwrite(self, base, parseName, maker(prop)); + } else if ((!staticProps || !can.isFunction(staticProps[parseName])) && !self[parseName]) { + var madeParser = maker(); + madeParser.useModelConverter = hasCustomConverter[parseName]; + can.Construct._overwrite(self, base, parseName, madeParser); + } + }); + if (self.fullName === 'can.Model' || !self.fullName) { + self.fullName = 'Model' + ++modelNum; + } + can.Model._reqs = 0; + this._url = this._shortName + '/{' + this.id + '}'; + }, + _ajax: ajaxMaker, + _makeRequest: makeRequest, + _clean: function () { + can.Model._reqs--; + if (!can.Model._reqs) { + for (var id in this.store) { + if (!this.store[id]._bindings) { + delete this.store[id]; + } + } + } + return arguments[0]; + }, + models: converters.models, + model: converters.model + }, { + setup: function (attrs) { + var id = attrs && attrs[this.constructor.id]; + if (can.Model._reqs && id != null) { + this.constructor.store[id] = this; + } + can.Map.prototype.setup.apply(this, arguments); + }, + isNew: function () { + var id = getId(this); + return !(id || id === 0); + }, + save: function (success, error) { + return makeRequest(this, this.isNew() ? 'create' : 'update', success, error); + }, + destroy: function (success, error) { + if (this.isNew()) { + var self = this; + var def = can.Deferred(); + def.then(success, error); + return def.done(function (data) { + self.destroyed(data); + }).resolve(self); + } + return makeRequest(this, 'destroy', success, error, 'destroyed'); + }, + _bindsetup: function () { + var modelInstance = this.__get(this.constructor.id); + if (modelInstance != null) { + this.constructor.store[modelInstance] = this; + } + return can.Map.prototype._bindsetup.apply(this, arguments); + }, + _bindteardown: function () { + delete this.constructor.store[getId(this)]; + return can.Map.prototype._bindteardown.apply(this, arguments); + }, + ___set: function (prop, val) { + can.Map.prototype.___set.call(this, prop, val); + if (prop === this.constructor.id && this._bindings) { + this.constructor.store[getId(this)] = this; + } + } + }); + var makeGetterHandler = function (name) { + return function (data, readyState, xhr) { + return this[name](data, null, xhr); + }; + }, createUpdateDestroyHandler = function (data) { + if (this.parseModel.useModelConverter) { + return this.model(data); + } + return this.parseModel(data); + }; + var responseHandlers = { + makeFindAll: makeGetterHandler('models'), + makeFindOne: makeGetterHandler('model'), + makeCreate: createUpdateDestroyHandler, + makeUpdate: createUpdateDestroyHandler, + makeDestroy: createUpdateDestroyHandler + }; + can.each(responseHandlers, function (method, name) { + can.Model[name] = function (oldMethod) { + return function () { + var args = can.makeArray(arguments), oldArgs = can.isFunction(args[1]) ? args.splice(0, 1) : args.splice(0, 2), def = pipe(oldMethod.apply(this, oldArgs), this, method); + def.then(args[0], args[1]); + return def; + }; + }; + }); + can.each([ + 'created', + 'updated', + 'destroyed' + ], function (funcName) { + can.Model.prototype[funcName] = function (attrs) { + var self = this, constructor = self.constructor; + if (attrs && typeof attrs === 'object') { + this.attr(can.isFunction(attrs.attr) ? attrs.attr() : attrs); + } + can.dispatch.call(this, { + type: 'change', + target: this + }, [funcName]); + can.dispatch.call(constructor, funcName, [this]); + }; + }); + var ML = can.Model.List = can.List.extend({ + _bubbleRule: function (eventName, list) { + var bubbleRules = can.List._bubbleRule(eventName, list); + bubbleRules.push('destroyed'); + return bubbleRules; + } + }, { + setup: function (params) { + if (can.isPlainObject(params) && !can.isArray(params)) { + can.List.prototype.setup.apply(this); + this.replace(can.isDeferred(params) ? params : this.constructor.Map.findAll(params)); + } else { + can.List.prototype.setup.apply(this, arguments); + } + this._init = 1; + this.bind('destroyed', can.proxy(this._destroyed, this)); + delete this._init; + }, + _destroyed: function (ev, attr) { + if (/\w+/.test(attr)) { + var index; + while ((index = this.indexOf(ev.target)) > -1) { + this.splice(index, 1); + } + } + } + }); + return can.Model; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/model/queue.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/model/queue.js new file mode 100644 index 0000000000..386ed60c10 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/model/queue.js @@ -0,0 +1,109 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#model/queue/queue*/ +define([ + 'can/util/library', + 'can/model', + 'can/map/backup' +], function (can) { + var cleanAttrs = function (changedAttrs, attrs) { + var newAttrs = can.extend(true, {}, attrs), current, path; + if (changedAttrs) { + for (var i = 0; i < changedAttrs.length; i++) { + current = newAttrs; + path = changedAttrs[i].split('.'); + while (path.length > 1) { + current = current && current[path.shift()]; + } + if (current) { + delete current[path.shift()]; + } + } + } + return newAttrs; + }, queueRequests = function (success, error, method, callback) { + this._changedAttrs = this._changedAttrs || []; + var def = new can.Deferred(), self = this, attrs = this.serialize(), queue = this._requestQueue, changedAttrs = this._changedAttrs, reqFn, index; + reqFn = function (self, type, success, error) { + return function () { + return self.constructor._makeRequest([ + self, + attrs + ], type || (self.isNew() ? 'create' : 'update'), success, error, callback); + }; + }(this, method, function () { + def.resolveWith(self, arguments); + queue.splice(0, 1); + if (queue.length > 0) { + queue[0] = queue[0](); + } else { + changedAttrs.splice(0); + } + }, function () { + def.rejectWith(self, arguments); + queue.splice(0); + changedAttrs.splice(0); + }); + index = queue.push(reqFn) - 1; + if (queue.length === 1) { + queue[0] = queue[0](); + } + def.abort = function () { + var abort; + abort = queue[index].abort && queue[index].abort(); + queue.splice(index); + if (queue.length === 0) { + changedAttrs.splice(0); + } + return abort; + }; + def.then(success, error); + return def; + }, _triggerChange = can.Model.prototype._triggerChange, destroyFn = can.Model.prototype.destroy, setupFn = can.Model.prototype.setup; + can.each([ + 'created', + 'updated', + 'destroyed' + ], function (fn) { + var prototypeFn = can.Model.prototype[fn]; + can.Model.prototype[fn] = function (attrs) { + if (attrs && typeof attrs === 'object') { + attrs = attrs.attr ? attrs.attr() : attrs; + this._backupStore(attrs); + attrs = cleanAttrs(this._changedAttrs || [], attrs); + } + prototypeFn.call(this, attrs); + }; + }); + can.extend(can.Model.prototype, { + setup: function () { + setupFn.apply(this, arguments); + this._requestQueue = new can.List(); + }, + _triggerChange: function (attr, how, newVal, oldVal) { + if (this._changedAttrs) { + this._changedAttrs.push(attr); + } + _triggerChange.apply(this, arguments); + }, + hasQueuedRequests: function () { + return this._requestQueue.attr('length') > 1; + }, + save: function () { + return queueRequests.apply(this, arguments); + }, + destroy: function (success, error) { + if (this.isNew()) { + return destroyFn.call(this, success, error); + } + return queueRequests.call(this, success, error, 'destroy', 'destroyed'); + } + }); + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/observe.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/observe.js new file mode 100644 index 0000000000..2cd1e575da --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/observe.js @@ -0,0 +1,21 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#observe/observe*/ +define([ + 'can/util/library', + 'can/map', + 'can/list', + 'can/compute' +], function (can) { + can.Observe = can.Map; + can.Observe.startBatch = can.batch.start; + can.Observe.stopBatch = can.batch.stop; + can.Observe.triggerBatch = can.batch.trigger; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/proto_compute.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/proto_compute.js new file mode 100644 index 0000000000..01a6f90463 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/proto_compute.js @@ -0,0 +1,293 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#compute/proto_compute*/ +define([ + 'can/util/library', + 'can/util/bind', + 'can/read', + 'can/get_value_and_bind', + 'can/util/batch' +], function (can, bind, read, getValueAndBind) { + var updateOnChange = function (compute, newValue, oldValue, batchNum) { + if (newValue !== oldValue) { + can.batch.trigger(compute, batchNum ? { + type: 'change', + batchNum: batchNum + } : 'change', [ + newValue, + oldValue + ]); + } + }; + var setupComputeHandlers = function (compute, func, context, singleBind) { + var readInfo, onchanged, batchNum; + singleBind = false; + return { + on: function (updater) { + var self = this; + if (!onchanged) { + onchanged = function (ev) { + if (readInfo.ready && compute.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + if (singleBind) { + newValue = func.call(context); + readInfo.value = newValue; + } else { + readInfo = getValueAndBind(func, context, readInfo, onchanged); + newValue = readInfo.value; + } + self.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }; + } + readInfo = getValueAndBind(func, context, { observed: {} }, onchanged); + if (singleBind) { + func = can.__notObserve(func); + } + compute.value = readInfo.value; + compute.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function (updater) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, onchanged); + } + } + }; + }; + var k = function () { + }; + var updater = function (newVal, oldVal, batchNum) { + this.value = newVal; + updateOnChange(this, newVal, oldVal, batchNum); + }, asyncGet = function (fn, context, lastSetValue) { + return function () { + return fn.call(context, lastSetValue.get()); + }; + }, asyncUpdater = function (context, oldUpdater) { + return function (newVal) { + if (newVal !== undefined) { + oldUpdater(newVal, context.value); + } + }; + }; + can.Compute = function (getterSetter, context, eventName, bindOnce) { + var args = []; + for (var i = 0, arglen = arguments.length; i < arglen; i++) { + args[i] = arguments[i]; + } + var contextType = typeof args[1]; + if (typeof args[0] === 'function') { + this._setupGetterSetterFn(args[0], args[1], args[2], args[3]); + } else if (args[1]) { + if (contextType === 'string') { + this._setupContextString(args[0], args[1], args[2]); + } else if (contextType === 'function') { + this._setupContextFunction(args[0], args[1], args[2]); + } else { + if (args[1] && args[1].fn) { + this._setupAsyncCompute(args[0], args[1]); + } else { + this._setupContextSettings(args[0], args[1]); + } + } + } else { + this._setupInitialValue(args[0]); + } + this._args = args; + this.isComputed = true; + can.cid(this, 'compute'); + }; + can.simpleExtend(can.Compute.prototype, { + _bindsetup: can.__notObserve(function () { + this.bound = true; + this._on(this.updater); + }), + _bindteardown: function () { + this._off(this.updater); + this.bound = false; + }, + bind: can.bindAndSetup, + unbind: can.unbindAndTeardown, + clone: function (context) { + if (context && typeof this._args[0] === 'function') { + this._args[1] = context; + } else if (context) { + this._args[2] = context; + } + return new can.Compute(this._args[0], this._args[1], this._args[2], this._args[3]); + }, + _on: k, + _off: k, + get: function () { + if (can.__isRecordingObserves() && this._canObserve !== false) { + can.__observe(this, 'change'); + if (!this.bound) { + can.Compute.temporarilyBind(this); + } + } + if (this.bound) { + return this.value; + } else { + return this._get(); + } + }, + _get: function () { + return this.value; + }, + set: function (newVal) { + var old = this.value; + var setVal = this._set(newVal, old); + if (this.hasDependencies) { + if (this._setUpdates) { + return this.value; + } + return this._get(); + } + if (setVal === undefined) { + this.value = this._get(); + } else { + this.value = setVal; + } + updateOnChange(this, this.value, old); + return this.value; + }, + _set: function (newVal) { + return this.value = newVal; + }, + updater: updater, + _computeFn: function (newVal) { + if (arguments.length) { + return this.set(newVal); + } + return this.get(); + }, + toFunction: function () { + return can.proxy(this._computeFn, this); + }, + _setupGetterSetterFn: function (getterSetter, context, eventName, bindOnce) { + this._set = can.proxy(getterSetter, context); + this._get = can.proxy(getterSetter, context); + this._canObserve = eventName === false ? false : true; + var handlers = setupComputeHandlers(this, getterSetter, context || this, bindOnce); + this._on = handlers.on; + this._off = handlers.off; + }, + _setupContextString: function (target, propertyName, eventName) { + var isObserve = can.isMapLike(target), self = this, handler = function (ev, newVal, oldVal) { + self.updater(newVal, oldVal, ev.batchNum); + }; + if (isObserve) { + this.hasDependencies = true; + this._get = function () { + return target.attr(propertyName); + }; + this._set = function (val) { + target.attr(propertyName, val); + }; + this._on = function (update) { + target.bind(eventName || propertyName, handler); + this.value = this._get(); + }; + this._off = function () { + return target.unbind(eventName || propertyName, handler); + }; + } else { + this._get = can.proxy(this._get, target); + this._set = can.proxy(this._set, target); + } + }, + _setupContextFunction: function (initialValue, setter, eventName) { + this.value = initialValue; + this._set = setter; + can.simpleExtend(this, eventName); + }, + _setupContextSettings: function (initialValue, settings) { + this.value = initialValue; + this._set = settings.set ? can.proxy(settings.set, settings) : this._set; + this._get = settings.get ? can.proxy(settings.get, settings) : this._get; + if (!settings.__selfUpdater) { + var self = this, oldUpdater = this.updater; + this.updater = function () { + oldUpdater.call(self, self._get(), self.value); + }; + } + this._on = settings.on ? settings.on : this._on; + this._off = settings.off ? settings.off : this._off; + }, + _setupAsyncCompute: function (initialValue, settings) { + this.value = initialValue; + var oldUpdater = can.proxy(this.updater, this), self = this, fn = settings.fn, data; + this.updater = oldUpdater; + var lastSetValue = new can.Compute(initialValue); + this.lastSetValue = lastSetValue; + this._setUpdates = true; + this._set = function (newVal) { + if (newVal === lastSetValue.get()) { + return this.value; + } + return lastSetValue.set(newVal); + }; + this._get = asyncGet(fn, settings.context, lastSetValue); + if (fn.length === 0) { + data = setupComputeHandlers(this, fn, settings.context); + } else if (fn.length === 1) { + data = setupComputeHandlers(this, function () { + return fn.call(settings.context, lastSetValue.get()); + }, settings); + } else { + this.updater = asyncUpdater(this, oldUpdater); + data = setupComputeHandlers(this, function () { + var res = fn.call(settings.context, lastSetValue.get(), function (newVal) { + oldUpdater(newVal, self.value); + }); + return res !== undefined ? res : this.value; + }, settings); + } + this._on = data.on; + this._off = data.off; + }, + _setupInitialValue: function (initialValue) { + this.value = initialValue; + } + }); + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.Compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.Compute.async = function (initialValue, asyncComputer, context) { + return new can.Compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.Compute.read = read; + can.Compute.set = read.write; + can.Compute.truthy = function (compute) { + return new can.Compute(function () { + var res = compute.get(); + if (typeof res === 'function') { + res = res.get(); + } + return !!res; + }); + }; + return can.Compute; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/read.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/read.js new file mode 100644 index 0000000000..59f445cfb2 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/read.js @@ -0,0 +1,189 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#compute/read*/ +define(['can/util/library'], function (can) { + var read = function (parent, reads, options) { + options = options || {}; + var state = { foundObservable: false }; + var cur = readValue(parent, 0, reads, options, state), type, prev, readLength = reads.length, i = 0; + while (i < readLength) { + prev = cur; + for (var r = 0, readersLength = read.propertyReaders.length; r < readersLength; r++) { + var reader = read.propertyReaders[r]; + if (reader.test(cur)) { + cur = reader.read(cur, reads[i], i, options, state); + break; + } + } + i = i + 1; + cur = readValue(cur, i, reads, options, state, prev); + type = typeof cur; + if (i < reads.length && (cur === null || type !== 'function' && type !== 'object')) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1, cur); + } + return { + value: undefined, + parent: prev + }; + } + } + if (cur === undefined) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1); + } + } + return { + value: cur, + parent: prev + }; + }; + var readValue = function (value, index, reads, options, state, prev) { + var usedValueReader; + do { + usedValueReader = false; + for (var i = 0, len = read.valueReaders.length; i < len; i++) { + if (read.valueReaders[i].test(value, index, reads, options)) { + value = read.valueReaders[i].read(value, index, reads, options, state, prev); + } + } + } while (usedValueReader); + return value; + }; + read.valueReaders = [ + { + name: 'compute', + test: function (value, i, reads, options) { + return value && value.isComputed; + }, + read: function (value, i, reads, options, state) { + if (options.isArgument && i === reads.length) { + return value; + } + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, i); + state.foundObservable = true; + } + return value instanceof can.Compute ? value.get() : value(); + } + }, + { + name: 'function', + test: function (value, i, reads, options) { + var type = typeof value; + return type === 'function' && !value.isComputed && (options.executeAnonymousFunctions || options.isArgument && i === reads.length) && !(can.Construct && value.prototype instanceof can.Construct) && !(can.route && value === can.route); + }, + read: function (value, i, reads, options, state, prev) { + if (options.isArgument && i === reads.length) { + return options.proxyMethods !== false ? can.proxy(value, prev) : value; + } + return value.call(prev); + } + } + ]; + read.propertyReaders = [ + { + name: 'map', + test: can.isMapLike, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + if (typeof value[prop] === 'function' && value.constructor.prototype[prop] === value[prop]) { + if (options.returnObserveMethods) { + return value[prop]; + } else if (prop === 'constructor' && value instanceof can.Construct || value[prop].prototype instanceof can.Construct) { + return value[prop]; + } else { + return value[prop].apply(value, options.args || []); + } + } else { + return value.attr(prop); + } + } + }, + { + name: 'promise', + test: function (value) { + return can.isPromise(value); + }, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + var observeData = value.__observeData; + if (!value.__observeData) { + observeData = value.__observeData = { + isPending: true, + state: 'pending', + isResolved: false, + isRejected: false, + value: undefined, + reason: undefined + }; + can.cid(observeData); + can.simpleExtend(observeData, can.event); + value.then(function (value) { + observeData.isPending = false; + observeData.isResolved = true; + observeData.value = value; + observeData.state = 'resolved'; + observeData.dispatch('state', [ + 'resolved', + 'pending' + ]); + }, function (reason) { + observeData.isPending = false; + observeData.isRejected = true; + observeData.reason = reason; + observeData.state = 'rejected'; + observeData.dispatch('state', [ + 'rejected', + 'pending' + ]); + }); + } + can.__observe(observeData, 'state'); + return prop in observeData ? observeData[prop] : value[prop]; + } + }, + { + name: 'object', + test: function () { + return true; + }, + read: function (value, prop) { + if (value == null) { + return undefined; + } else { + return value[prop]; + } + } + } + ]; + read.write = function (parent, key, value, options) { + options = options || {}; + if (can.isMapLike(parent)) { + if (!options.isArgument && parent._data && parent._data[key] && parent._data[key].isComputed) { + return parent._data[key](value); + } else { + return parent.attr(key, value); + } + } + if (parent[key] && parent[key].isComputed) { + return parent[key](value); + } + if (typeof parent === 'object') { + parent[key] = value; + } + }; + return read; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/render.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/render.js new file mode 100644 index 0000000000..8e7e33a510 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/render.js @@ -0,0 +1,133 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/render*/ +define([ + 'can/view', + 'can/elements', + 'can/view/live', + 'can/util/string' +], function (can, elements, live) { + var pendingHookups = [], tagChildren = function (tagName) { + var newTag = elements.tagMap[tagName] || 'span'; + if (newTag === 'span') { + return '@@!!@@'; + } + return '<' + newTag + '>' + tagChildren(newTag) + ''; + }, contentText = function (input, tag) { + if (typeof input === 'string') { + return input; + } + if (!input && input !== 0) { + return ''; + } + var hook = input.hookup && function (el, id) { + input.hookup.call(input, el, id); + } || typeof input === 'function' && input; + if (hook) { + if (tag) { + return '<' + tag + ' ' + can.view.hook(hook) + '>'; + } else { + pendingHookups.push(hook); + } + return ''; + } + return '' + input; + }, contentEscape = function (txt, tag) { + return typeof txt === 'string' || typeof txt === 'number' ? can.esc(txt) : contentText(txt, tag); + }, withinTemplatedSectionWithinAnElement = false, emptyHandler = function () { + }; + var lastHookups; + can.extend(can.view, { + live: live, + setupLists: function () { + var old = can.view.lists, data; + can.view.lists = function (list, renderer) { + data = { + list: list, + renderer: renderer + }; + return Math.random(); + }; + return function () { + can.view.lists = old; + return data; + }; + }, + getHooks: function () { + var hooks = pendingHookups.slice(0); + lastHookups = hooks; + pendingHookups = []; + return hooks; + }, + onlytxt: function (self, func) { + return contentEscape(func.call(self)); + }, + txt: function (escape, tagName, status, self, func) { + var tag = elements.tagMap[tagName] || 'span', setupLiveBinding = false, value, listData, compute, unbind = emptyHandler, attributeName; + if (withinTemplatedSectionWithinAnElement) { + value = func.call(self); + } else { + if (typeof status === 'string' || status === 1) { + withinTemplatedSectionWithinAnElement = true; + } + var listTeardown = can.view.setupLists(); + unbind = function () { + compute.unbind('change', emptyHandler); + }; + compute = can.compute(func, self, false); + compute.bind('change', emptyHandler); + listData = listTeardown(); + value = compute(); + withinTemplatedSectionWithinAnElement = false; + setupLiveBinding = compute.computeInstance.hasDependencies; + } + if (listData) { + unbind(); + return '<' + tag + can.view.hook(function (el, parentNode) { + live.list(el, listData.list, listData.renderer, self, parentNode); + }) + '>'; + } + if (!setupLiveBinding || typeof value === 'function') { + unbind(); + return (withinTemplatedSectionWithinAnElement || escape === 2 || !escape ? contentText : contentEscape)(value, status === 0 && tag); + } + var contentProp = elements.tagToContentPropMap[tagName]; + if (status === 0 && !contentProp) { + return '<' + tag + can.view.hook(escape && typeof value !== 'object' ? function (el, parentNode) { + live.text(el, compute, parentNode); + unbind(); + } : function (el, parentNode) { + live.html(el, compute, parentNode); + unbind(); + }) + '>' + tagChildren(tag) + ''; + } else if (status === 1) { + pendingHookups.push(function (el) { + live.attributes(el, compute, compute()); + unbind(); + }); + return compute(); + } else if (escape === 2) { + attributeName = status; + pendingHookups.push(function (el) { + live.specialAttribute(el, attributeName, compute); + unbind(); + }); + return compute(); + } else { + attributeName = status === 0 ? contentProp : status; + (status === 0 ? lastHookups : pendingHookups).push(function (el) { + live.attribute(el, attributeName, compute); + unbind(); + }); + return live.attributePlaceholder; + } + } + }); + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/route.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/route.js new file mode 100644 index 0000000000..400355650a --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/route.js @@ -0,0 +1,305 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#route/route*/ +define([ + 'can/util/library', + 'can/map', + 'can/list', + 'can/util/string/deparam' +], function (can) { + var matcher = /\:([\w\.]+)/g, paramsMatcher = /^(?:&[^=]+=[^&]*)+/, makeProps = function (props) { + var tags = []; + can.each(props, function (val, name) { + tags.push((name === 'className' ? 'class' : name) + '="' + (name === 'href' ? val : can.esc(val)) + '"'); + }); + return tags.join(' '); + }, matchesData = function (route, data) { + var count = 0, i = 0, defaults = {}; + for (var name in route.defaults) { + if (route.defaults[name] === data[name]) { + defaults[name] = 1; + count++; + } + } + for (; i < route.names.length; i++) { + if (!data.hasOwnProperty(route.names[i])) { + return -1; + } + if (!defaults[route.names[i]]) { + count++; + } + } + return count; + }, location = window.location, wrapQuote = function (str) { + return (str + '').replace(/([.?*+\^$\[\]\\(){}|\-])/g, '\\$1'); + }, each = can.each, extend = can.extend, stringify = function (obj) { + if (obj && typeof obj === 'object') { + if (obj instanceof can.Map) { + obj = obj.attr(); + } else { + obj = can.isFunction(obj.slice) ? obj.slice() : can.extend({}, obj); + } + can.each(obj, function (val, prop) { + obj[prop] = stringify(val); + }); + } else if (obj !== undefined && obj !== null && can.isFunction(obj.toString)) { + obj = obj.toString(); + } + return obj; + }, removeBackslash = function (str) { + return str.replace(/\\/g, ''); + }, timer, curParams, lastHash, changingData, changedAttrs = [], onRouteDataChange = function (ev, attr, how, newval) { + changingData = 1; + changedAttrs.push(attr); + clearTimeout(timer); + timer = setTimeout(function () { + changingData = 0; + var serialized = can.route.data.serialize(), path = can.route.param(serialized, true); + can.route._call('setURL', path, changedAttrs); + can.batch.trigger(eventsObject, '__url', [ + path, + lastHash + ]); + lastHash = path; + changedAttrs = []; + }, 10); + }, eventsObject = can.extend({}, can.event); + can.route = function (url, defaults) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + defaults = defaults || {}; + var names = [], res, test = '', lastIndex = matcher.lastIndex = 0, next, querySeparator = can.route._call('querySeparator'), matchSlashes = can.route._call('matchSlashes'); + while (res = matcher.exec(url)) { + names.push(res[1]); + test += removeBackslash(url.substring(lastIndex, matcher.lastIndex - res[0].length)); + next = '\\' + (removeBackslash(url.substr(matcher.lastIndex, 1)) || querySeparator + (matchSlashes ? '' : '|/')); + test += '([^' + next + ']' + (defaults[res[1]] ? '*' : '+') + ')'; + lastIndex = matcher.lastIndex; + } + test += url.substr(lastIndex).replace('\\', ''); + can.route.routes[url] = { + test: new RegExp('^' + test + '($|' + wrapQuote(querySeparator) + ')'), + route: url, + names: names, + defaults: defaults, + length: url.split('/').length + }; + return can.route; + }; + extend(can.route, { + param: function (data, _setRoute) { + var route, matches = 0, matchCount, routeName = data.route, propCount = 0; + delete data.route; + each(data, function () { + propCount++; + }); + each(can.route.routes, function (temp, name) { + matchCount = matchesData(temp, data); + if (matchCount > matches) { + route = temp; + matches = matchCount; + } + if (matchCount >= propCount) { + return false; + } + }); + if (can.route.routes[routeName] && matchesData(can.route.routes[routeName], data) === matches) { + route = can.route.routes[routeName]; + } + if (route) { + var cpy = extend({}, data), res = route.route.replace(matcher, function (whole, name) { + delete cpy[name]; + return data[name] === route.defaults[name] ? '' : encodeURIComponent(data[name]); + }).replace('\\', ''), after; + each(route.defaults, function (val, name) { + if (cpy[name] === val) { + delete cpy[name]; + } + }); + after = can.param(cpy); + if (_setRoute) { + can.route.attr('route', route.route); + } + return res + (after ? can.route._call('querySeparator') + after : ''); + } + return can.isEmptyObject(data) ? '' : can.route._call('querySeparator') + can.param(data); + }, + deparam: function (url) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + var route = { length: -1 }, querySeparator = can.route._call('querySeparator'), paramsMatcher = can.route._call('paramsMatcher'); + each(can.route.routes, function (temp, name) { + if (temp.test.test(url) && temp.length > route.length) { + route = temp; + } + }); + if (route.length > -1) { + var parts = url.match(route.test), start = parts.shift(), remainder = url.substr(start.length - (parts[parts.length - 1] === querySeparator ? 1 : 0)), obj = remainder && paramsMatcher.test(remainder) ? can.deparam(remainder.slice(1)) : {}; + obj = extend(true, {}, route.defaults, obj); + each(parts, function (part, i) { + if (part && part !== querySeparator) { + obj[route.names[i]] = decodeURIComponent(part); + } + }); + obj.route = route.route; + return obj; + } + if (url.charAt(0) !== querySeparator) { + url = querySeparator + url; + } + return paramsMatcher.test(url) ? can.deparam(url.slice(1)) : {}; + }, + data: new can.Map({}), + map: function (data) { + var appState; + if (data.prototype instanceof can.Map) { + appState = new data(); + } else { + appState = data; + } + can.route.data = appState; + }, + routes: {}, + ready: function (val) { + if (val !== true) { + can.route._setup(); + can.route.setState(); + } + return can.route; + }, + url: function (options, merge) { + if (merge) { + options = can.extend({}, can.route.deparam(can.route._call('matchingPartOfURL')), options); + } + return can.route._call('root') + can.route.param(options); + }, + link: function (name, options, props, merge) { + return '' + name + ''; + }, + current: function (options) { + can.__observe(eventsObject, '__url'); + return this._call('matchingPartOfURL') === can.route.param(options); + }, + bindings: { + hashchange: { + paramsMatcher: paramsMatcher, + querySeparator: '&', + matchSlashes: false, + bind: function () { + can.bind.call(window, 'hashchange', setState); + }, + unbind: function () { + can.unbind.call(window, 'hashchange', setState); + }, + matchingPartOfURL: function () { + return location.href.split(/#!?/)[1] || ''; + }, + setURL: function (path) { + if (location.hash !== '#' + path) { + location.hash = '!' + path; + } + return path; + }, + root: '#!' + } + }, + defaultBinding: 'hashchange', + currentBinding: null, + _setup: function () { + if (!can.route.currentBinding) { + can.route._call('bind'); + can.route.bind('change', onRouteDataChange); + can.route.currentBinding = can.route.defaultBinding; + } + }, + _teardown: function () { + if (can.route.currentBinding) { + can.route._call('unbind'); + can.route.unbind('change', onRouteDataChange); + can.route.currentBinding = null; + } + clearTimeout(timer); + changingData = 0; + }, + _call: function () { + var args = can.makeArray(arguments), prop = args.shift(), binding = can.route.bindings[can.route.currentBinding || can.route.defaultBinding], method = binding[prop]; + if (method.apply) { + return method.apply(binding, args); + } else { + return method; + } + } + }); + each([ + 'bind', + 'unbind', + 'on', + 'off', + 'delegate', + 'undelegate', + 'removeAttr', + 'compute', + '_get', + '__get', + 'each' + ], function (name) { + can.route[name] = function () { + if (!can.route.data[name]) { + return; + } + return can.route.data[name].apply(can.route.data, arguments); + }; + }); + can.route.attr = function (attr, val) { + var type = typeof attr, newArguments; + if (val === undefined) { + newArguments = arguments; + } else if (type !== 'string' && type !== 'number') { + newArguments = [ + stringify(attr), + val + ]; + } else { + newArguments = [ + attr, + stringify(val) + ]; + } + return can.route.data.attr.apply(can.route.data, newArguments); + }; + var setState = can.route.setState = function () { + var hash = can.route._call('matchingPartOfURL'); + var oldParams = curParams; + curParams = can.route.deparam(hash); + if (!changingData || hash !== lastHash) { + can.batch.start(); + recursiveClean(oldParams, curParams, can.route.data); + can.route.attr(curParams); + can.batch.trigger(eventsObject, '__url', [ + hash, + lastHash + ]); + can.batch.stop(); + } + }; + var recursiveClean = function (old, cur, data) { + for (var attr in old) { + if (cur[attr] === undefined) { + data.removeAttr(attr); + } else if (Object.prototype.toString.call(old[attr]) === '[object Object]') { + recursiveClean(old[attr], cur[attr], data.attr(attr)); + } + } + }; + return can.route; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/route/pushstate.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/route/pushstate.js new file mode 100644 index 0000000000..3f31ef0792 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/route/pushstate.js @@ -0,0 +1,125 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#route/pushstate/pushstate*/ +define([ + 'can/util/library', + 'can/route' +], function (can) { + 'use strict'; + if (window.history && history.pushState) { + can.route.bindings.pushstate = { + root: '/', + matchSlashes: false, + paramsMatcher: /^\?(?:[^=]+=[^&]*&)*[^=]+=[^&]*/, + querySeparator: '?', + bind: function () { + can.delegate.call(can.$(document.documentElement), 'a', 'click', anchorClickHandler); + can.each(methodsToOverwrite, function (method) { + originalMethods[method] = window.history[method]; + window.history[method] = function (state, title, url) { + var absolute = url.indexOf('http') === 0; + var searchHash = window.location.search + window.location.hash; + if (!absolute && url !== window.location.pathname + searchHash || absolute && url !== window.location.href + searchHash) { + originalMethods[method].apply(window.history, arguments); + can.route.setState(); + } + }; + }); + can.bind.call(window, 'popstate', can.route.setState); + }, + unbind: function () { + can.undelegate.call(can.$(document.documentElement), 'click', 'a', anchorClickHandler); + can.each(methodsToOverwrite, function (method) { + window.history[method] = originalMethods[method]; + }); + can.unbind.call(window, 'popstate', can.route.setState); + }, + matchingPartOfURL: function () { + var root = cleanRoot(), loc = location.pathname + location.search, index = loc.indexOf(root); + return loc.substr(index + root.length); + }, + setURL: function (path, changed) { + var method = 'pushState'; + if (includeHash && path.indexOf('#') === -1 && window.location.hash) { + path += window.location.hash; + } + if (replaceStateAttrs.length > 0) { + var toRemove = []; + for (var i = 0, l = changed.length; i < l; i++) { + if (can.inArray(changed[i], replaceStateAttrs) !== -1) { + method = 'replaceState'; + } + if (can.inArray(changed[i], replaceStateAttrs.once) !== -1) { + toRemove.push(changed[i]); + } + } + if (toRemove.length > 0) { + removeAttrs(replaceStateAttrs, toRemove); + removeAttrs(replaceStateAttrs.once, toRemove); + } + } + window.history[method](null, null, can.route._call('root') + path); + } + }; + var anchorClickHandler = function (e) { + if (!(e.isDefaultPrevented ? e.isDefaultPrevented() : e.defaultPrevented === true)) { + var node = this._node || this; + var linksHost = node.host || window.location.host; + if (window.location.host === linksHost) { + var root = cleanRoot(); + if (node.pathname.indexOf(root) === 0) { + var url = (node.pathname + node.search).substr(root.length); + var curParams = can.route.deparam(url); + if (curParams.hasOwnProperty('route')) { + includeHash = true; + window.history.pushState(null, null, node.href); + if (e.preventDefault) { + e.preventDefault(); + } + } + } + } + } + }, cleanRoot = function () { + var domain = location.protocol + '//' + location.host, root = can.route._call('root'), index = root.indexOf(domain); + if (index === 0) { + return root.substr(domain.length); + } + return root; + }, removeAttrs = function (arr, attrs) { + var index; + for (var i = attrs.length - 1; i >= 0; i--) { + if ((index = can.inArray(attrs[i], arr)) !== -1) { + arr.splice(index, 1); + } + } + }, methodsToOverwrite = [ + 'pushState', + 'replaceState' + ], originalMethods = {}, includeHash = false, replaceStateAttrs = []; + can.route.defaultBinding = 'pushstate'; + can.extend(can.route, { + replaceStateOn: function () { + var attrs = can.makeArray(arguments); + Array.prototype.push.apply(replaceStateAttrs, attrs); + }, + replaceStateOnce: function () { + var attrs = can.makeArray(arguments); + replaceStateAttrs.once = can.makeArray(replaceStateAttrs.once); + Array.prototype.push.apply(replaceStateAttrs.once, attrs); + can.route.replaceStateOn.apply(this, arguments); + }, + replaceStateOff: function () { + var attrs = can.makeArray(arguments); + removeAttrs(replaceStateAttrs, attrs); + } + }); + } + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/scanner.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/scanner.js new file mode 100644 index 0000000000..90661fe99e --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/scanner.js @@ -0,0 +1,384 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/scanner*/ +define([ + 'can/view', + 'can/elements', + 'can/view/callbacks' +], function (can, elements, viewCallbacks) { + var newLine = /(\r|\n)+/g, notEndTag = /\//, clean = function (content) { + return content.split('\\').join('\\\\').split('\n').join('\\n').split('"').join('\\"').split('\t').join('\\t'); + }, getTag = function (tagName, tokens, i) { + if (tagName) { + return tagName; + } else { + while (i < tokens.length) { + if (tokens[i] === '<' && !notEndTag.test(tokens[i + 1])) { + return elements.reverseTagMap[tokens[i + 1]] || 'span'; + } + i++; + } + } + return ''; + }, bracketNum = function (content) { + return --content.split('{').length - --content.split('}').length; + }, myEval = function (script) { + eval(script); + }, attrReg = /([^\s]+)[\s]*=[\s]*$/, startTxt = 'var ___v1ew = [];', finishTxt = 'return ___v1ew.join(\'\')', put_cmd = '___v1ew.push(\n', insert_cmd = put_cmd, htmlTag = null, quote = null, beforeQuote = null, rescan = null, getAttrName = function () { + var matches = beforeQuote.match(attrReg); + return matches && matches[1]; + }, status = function () { + return quote ? '\'' + getAttrName() + '\'' : htmlTag ? 1 : 0; + }, top = function (stack) { + return stack[stack.length - 1]; + }, Scanner; + can.view.Scanner = Scanner = function (options) { + can.extend(this, { + text: {}, + tokens: [] + }, options); + this.text.options = this.text.options || ''; + this.tokenReg = []; + this.tokenSimple = { + '<': '<', + '>': '>', + '"': '"', + '\'': '\'' + }; + this.tokenComplex = []; + this.tokenMap = {}; + for (var i = 0, token; token = this.tokens[i]; i++) { + if (token[2]) { + this.tokenReg.push(token[2]); + this.tokenComplex.push({ + abbr: token[1], + re: new RegExp(token[2]), + rescan: token[3] + }); + } else { + this.tokenReg.push(token[1]); + this.tokenSimple[token[1]] = token[0]; + } + this.tokenMap[token[0]] = token[1]; + } + this.tokenReg = new RegExp('(' + this.tokenReg.slice(0).concat([ + '<', + '>', + '"', + '\'' + ]).join('|') + ')', 'g'); + }; + Scanner.prototype = { + helpers: [], + scan: function (source, name) { + var tokens = [], last = 0, simple = this.tokenSimple, complex = this.tokenComplex; + source = source.replace(newLine, '\n'); + if (this.transform) { + source = this.transform(source); + } + source.replace(this.tokenReg, function (whole, part) { + var offset = arguments[arguments.length - 2]; + if (offset > last) { + tokens.push(source.substring(last, offset)); + } + if (simple[whole]) { + tokens.push(whole); + } else { + for (var i = 0, token; token = complex[i]; i++) { + if (token.re.test(whole)) { + tokens.push(token.abbr); + if (token.rescan) { + tokens.push(token.rescan(part)); + } + break; + } + } + } + last = offset + part.length; + }); + if (last < source.length) { + tokens.push(source.substr(last)); + } + var content = '', buff = [startTxt + (this.text.start || '')], put = function (content, bonus) { + buff.push(put_cmd, '"', clean(content), '"' + (bonus || '') + ');'); + }, endStack = [], lastToken, startTag = null, magicInTag = false, specialStates = { + attributeHookups: [], + tagHookups: [], + lastTagHookup: '' + }, popTagHookup = function () { + specialStates.lastTagHookup = specialStates.tagHookups.pop() + specialStates.tagHookups.length; + }, tagName = '', tagNames = [], popTagName = false, bracketCount, specialAttribute = false, i = 0, token, tmap = this.tokenMap, attrName; + htmlTag = quote = beforeQuote = null; + for (; (token = tokens[i++]) !== undefined;) { + if (startTag === null) { + switch (token) { + case tmap.left: + case tmap.escapeLeft: + case tmap.returnLeft: + magicInTag = htmlTag && 1; + case tmap.commentLeft: + startTag = token; + if (content.length) { + put(content); + } + content = ''; + break; + case tmap.escapeFull: + magicInTag = htmlTag && 1; + rescan = 1; + startTag = tmap.escapeLeft; + if (content.length) { + put(content); + } + rescan = tokens[i++]; + content = rescan.content || rescan; + if (rescan.before) { + put(rescan.before); + } + tokens.splice(i, 0, tmap.right); + break; + case tmap.commentFull: + break; + case tmap.templateLeft: + content += tmap.left; + break; + case '<': + if (tokens[i].indexOf('!--') !== 0) { + htmlTag = 1; + magicInTag = 0; + } + content += token; + break; + case '>': + htmlTag = 0; + var emptyElement = content.substr(content.length - 1) === '/' || content.substr(content.length - 2) === '--', attrs = ''; + if (specialStates.attributeHookups.length) { + attrs = 'attrs: [\'' + specialStates.attributeHookups.join('\',\'') + '\'], '; + specialStates.attributeHookups = []; + } + if (tagName + specialStates.tagHookups.length !== specialStates.lastTagHookup && tagName === top(specialStates.tagHookups)) { + if (emptyElement) { + content = content.substr(0, content.length - 1); + } + buff.push(put_cmd, '"', clean(content), '"', ',can.view.pending({tagName:\'' + tagName + '\',' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options); + if (emptyElement) { + buff.push('}));'); + content = '/>'; + popTagHookup(); + } else if (tokens[i] === '<' && tokens[i + 1] === '/' + tagName) { + buff.push('}));'); + content = token; + popTagHookup(); + } else { + buff.push(',subtemplate: function(' + this.text.argNames + '){\n' + startTxt + (this.text.start || '')); + content = ''; + } + } else if (magicInTag || !popTagName && elements.tagToContentPropMap[tagNames[tagNames.length - 1]] || attrs) { + var pendingPart = ',can.view.pending({' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options + '}),"'; + if (emptyElement) { + put(content.substr(0, content.length - 1), pendingPart + '/>"'); + } else { + put(content, pendingPart + '>"'); + } + content = ''; + magicInTag = 0; + } else { + content += token; + } + if (emptyElement || popTagName) { + tagNames.pop(); + tagName = tagNames[tagNames.length - 1]; + popTagName = false; + } + specialStates.attributeHookups = []; + break; + case '\'': + case '"': + if (htmlTag) { + if (quote && quote === token) { + quote = null; + var attr = getAttrName(); + if (viewCallbacks.attr(attr)) { + specialStates.attributeHookups.push(attr); + } + if (specialAttribute) { + content += token; + put(content); + buff.push(finishTxt, '}));\n'); + content = ''; + specialAttribute = false; + break; + } + } else if (quote === null) { + quote = token; + beforeQuote = lastToken; + attrName = getAttrName(); + if (tagName === 'img' && attrName === 'src' || attrName === 'style') { + put(content.replace(attrReg, '')); + content = ''; + specialAttribute = true; + buff.push(insert_cmd, 'can.view.txt(2,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt); + put(attrName + '=' + token); + break; + } + } + } + default: + if (lastToken === '<') { + tagName = token.substr(0, 3) === '!--' ? '!--' : token.split(/\s/)[0]; + var isClosingTag = false, cleanedTagName; + if (tagName.indexOf('/') === 0) { + isClosingTag = true; + cleanedTagName = tagName.substr(1); + } + if (isClosingTag) { + if (top(tagNames) === cleanedTagName) { + tagName = cleanedTagName; + popTagName = true; + } + if (top(specialStates.tagHookups) === cleanedTagName) { + put(content.substr(0, content.length - 1)); + buff.push(finishTxt + '}}) );'); + content = '><'; + popTagHookup(); + } + } else { + if (tagName.lastIndexOf('/') === tagName.length - 1) { + tagName = tagName.substr(0, tagName.length - 1); + } + if (tagName !== '!--' && viewCallbacks.tag(tagName)) { + if (tagName === 'content' && elements.tagMap[top(tagNames)]) { + token = token.replace('content', elements.tagMap[top(tagNames)]); + } + specialStates.tagHookups.push(tagName); + } + tagNames.push(tagName); + } + } + content += token; + break; + } + } else { + switch (token) { + case tmap.right: + case tmap.returnRight: + switch (startTag) { + case tmap.left: + bracketCount = bracketNum(content); + if (bracketCount === 1) { + buff.push(insert_cmd, 'can.view.txt(0,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt, content); + endStack.push({ + before: '', + after: finishTxt + '}));\n' + }); + } else { + last = endStack.length && bracketCount === -1 ? endStack.pop() : { after: ';' }; + if (last.before) { + buff.push(last.before); + } + buff.push(content, ';', last.after); + } + break; + case tmap.escapeLeft: + case tmap.returnLeft: + bracketCount = bracketNum(content); + if (bracketCount) { + endStack.push({ + before: finishTxt, + after: '}));\n' + }); + } + var escaped = startTag === tmap.escapeLeft ? 1 : 0, commands = { + insert: insert_cmd, + tagName: getTag(tagName, tokens, i), + status: status(), + specialAttribute: specialAttribute + }; + for (var ii = 0; ii < this.helpers.length; ii++) { + var helper = this.helpers[ii]; + if (helper.name.test(content)) { + content = helper.fn(content, commands); + if (helper.name.source === /^>[\s]*\w*/.source) { + escaped = 0; + } + break; + } + } + if (typeof content === 'object') { + if (content.startTxt && content.end && specialAttribute) { + buff.push(insert_cmd, 'can.view.toStr( ', content.content, '() ) );'); + } else { + if (content.startTxt) { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || (content.escaped != null ? content.escaped : escaped)) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\n'); + } else if (content.startOnlyTxt) { + buff.push(insert_cmd, 'can.view.onlytxt(this,\n'); + } + buff.push(content.content); + if (content.end) { + buff.push('));'); + } + } + } else if (specialAttribute) { + buff.push(insert_cmd, content, ');'); + } else { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || escaped) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\nfunction(){ ' + (this.text.escape || '') + 'return ', content, bracketCount ? startTxt : '}));\n'); + } + if (rescan && rescan.after && rescan.after.length) { + put(rescan.after.length); + rescan = null; + } + break; + } + startTag = null; + content = ''; + break; + case tmap.templateLeft: + content += tmap.left; + break; + default: + content += token; + break; + } + } + lastToken = token; + } + if (content.length) { + put(content); + } + buff.push(';'); + var template = buff.join(''), out = { out: (this.text.outStart || '') + template + ' ' + finishTxt + (this.text.outEnd || '') }; + myEval.call(out, 'this.fn = (function(' + this.text.argNames + '){' + out.out + '});\r\n//# sourceURL=' + name + '.js'); + return out; + } + }; + can.view.pending = function (viewData) { + var hooks = can.view.getHooks(); + return can.view.hook(function (el) { + can.each(hooks, function (fn) { + fn(el); + }); + viewData.templateType = 'legacy'; + if (viewData.tagName) { + viewCallbacks.tagHandler(el, viewData.tagName, viewData); + } + can.each(viewData && viewData.attrs || [], function (attributeName) { + viewData.attributeName = attributeName; + var callback = viewCallbacks.attr(attributeName); + if (callback) { + callback(el, viewData); + } + }); + }); + }; + can.view.tag('content', function (el, tagData) { + return tagData.scope; + }); + can.view.Scanner = Scanner; + return Scanner; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/attr.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/attr.js new file mode 100644 index 0000000000..48345d3627 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/attr.js @@ -0,0 +1,130 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/attr/attr*/ +define(['can/util/can'], function (can) { + var setImmediate = can.global.setImmediate || function (cb) { + return setTimeout(cb, 0); + }, attr = { + MutationObserver: can.global.MutationObserver || can.global.WebKitMutationObserver || can.global.MozMutationObserver, + map: { + 'class': 'className', + 'value': 'value', + 'innertext': 'innerText', + 'textcontent': 'textContent', + 'checked': true, + 'disabled': true, + 'readonly': true, + 'required': true, + src: function (el, val) { + if (val == null || val === '') { + el.removeAttribute('src'); + return null; + } else { + el.setAttribute('src', val); + return val; + } + }, + style: function (el, val) { + return el.style.cssText = val || ''; + } + }, + defaultValue: [ + 'input', + 'textarea' + ], + set: function (el, attrName, val) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var tagName = el.nodeName.toString().toLowerCase(), prop = attr.map[attrName], newValue; + if (typeof prop === 'function') { + newValue = prop(el, val); + } else if (prop === true) { + newValue = el[attrName] = true; + if (attrName === 'checked' && el.type === 'radio') { + if (can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultChecked = true; + } + } + } else if (prop) { + newValue = val; + if (el[prop] !== val) { + el[prop] = val; + } + if (prop === 'value' && can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultValue = val; + } + } else { + el.setAttribute(attrName, val); + newValue = val; + } + if (!attr.MutationObserver && newValue !== oldValue) { + attr.trigger(el, attrName, oldValue); + } + }, + trigger: function (el, attrName, oldValue) { + if (can.data(can.$(el), 'canHasAttributesBindings')) { + attrName = attrName.toLowerCase(); + return setImmediate(function () { + can.trigger(el, { + type: 'attributes', + attributeName: attrName, + target: el, + oldValue: oldValue, + bubbles: false + }, []); + }); + } + }, + get: function (el, attrName) { + attrName = attrName.toLowerCase(); + var prop = attr.map[attrName]; + if (typeof prop === 'string' && el[prop]) { + return el[prop]; + } + return el.getAttribute(attrName); + }, + remove: function (el, attrName) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var setter = attr.map[attrName]; + if (typeof setter === 'function') { + setter(el, undefined); + } + if (setter === true) { + el[attrName] = false; + } else if (typeof setter === 'string') { + el[setter] = ''; + } else { + el.removeAttribute(attrName); + } + if (!attr.MutationObserver && oldValue != null) { + attr.trigger(el, attrName, oldValue); + } + }, + has: function () { + var el = can.global.document && document.createElement('div'); + if (el && el.hasAttribute) { + return function (el, name) { + return el.hasAttribute(name); + }; + } else { + return function (el, name) { + return el.getAttribute(name) !== null; + }; + } + }() + }; + return attr; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/batch.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/batch.js new file mode 100644 index 0000000000..989aedaea5 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/batch.js @@ -0,0 +1,89 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/batch/batch*/ +define(['can/util/can'], function (can) { + var batchNum = 1, transactions = 0, batchEvents = [], stopCallbacks = [], currentBatchEvents = null; + can.batch = { + start: function (batchStopHandler) { + transactions++; + if (batchStopHandler) { + stopCallbacks.push(batchStopHandler); + } + }, + stop: function (force, callStart) { + if (force) { + transactions = 0; + } else { + transactions--; + } + if (transactions === 0) { + if (currentBatchEvents !== null) { + return; + } + currentBatchEvents = batchEvents.slice(0); + var callbacks = stopCallbacks.slice(0), i, len; + batchEvents = []; + stopCallbacks = []; + can.batch.batchNum = batchNum; + batchNum++; + if (callStart) { + can.batch.start(); + } + for (i = 0; i < currentBatchEvents.length; i++) { + can.dispatch.apply(currentBatchEvents[i][0], currentBatchEvents[i][1]); + } + currentBatchEvents = null; + for (i = 0, len = callbacks.length; i < callbacks.length; i++) { + callbacks[i](); + } + can.batch.batchNum = undefined; + } + }, + trigger: function (item, event, args) { + if (!item._init) { + event = typeof event === 'string' ? { type: event } : event; + if (currentBatchEvents) { + currentBatchEvents.push([ + item, + [ + event, + args + ] + ]); + } else if (transactions === 0) { + return can.dispatch.call(item, event, args); + } else { + event.batchNum = batchNum; + batchEvents.push([ + item, + [ + event, + args + ] + ]); + } + } + }, + afterPreviousEvents: function (handler) { + if (currentBatchEvents) { + var obj = {}; + can.bind.call(obj, 'ready', handler); + currentBatchEvents.push([ + obj, + [ + { type: 'ready' }, + [] + ] + ]); + } else { + handler(); + } + } + }; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/bind.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/bind.js new file mode 100644 index 0000000000..4b5faffb8a --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/bind.js @@ -0,0 +1,40 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/bind/bind*/ +define(['can/util/library'], function (can) { + can.bindAndSetup = function () { + can.addEvent.apply(this, arguments); + if (!this._init) { + if (!this._bindings) { + this._bindings = 1; + if (this._bindsetup) { + this._bindsetup(); + } + } else { + this._bindings++; + } + } + return this; + }; + can.unbindAndTeardown = function (event, handler) { + var handlers = this.__bindEvents[event] || []; + var handlerCount = handlers.length; + can.removeEvent.apply(this, arguments); + if (this._bindings === null) { + this._bindings = 0; + } else { + this._bindings = this._bindings - (handlerCount - handlers.length); + } + if (!this._bindings && this._bindteardown) { + this._bindteardown(); + } + return this; + }; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/can.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/can.js new file mode 100644 index 0000000000..c910afe03a --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/can.js @@ -0,0 +1,124 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/can*/ +define([], function () { + var glbl = typeof window !== 'undefined' ? window : global; + var can = {}; + if (typeof GLOBALCAN === 'undefined' || GLOBALCAN !== false) { + glbl.can = can; + } + can.global = glbl; + can.k = function () { + }; + can.isDeferred = can.isPromise = function (obj) { + return obj && typeof obj.then === 'function' && typeof obj.pipe === 'function'; + }; + can.isMapLike = function (obj) { + return can.Map && (obj instanceof can.Map || obj && obj.__get); + }; + var cid = 0; + can.cid = function (object, name) { + if (!object._cid) { + cid++; + object._cid = (name || '') + cid; + } + return object._cid; + }; + can.VERSION = '2.2.6'; + can.simpleExtend = function (d, s) { + for (var prop in s) { + d[prop] = s[prop]; + } + return d; + }; + can.last = function (arr) { + return arr && arr[arr.length - 1]; + }; + var protoBind = Function.prototype.bind; + if (protoBind) { + can.proxy = function (fn, context) { + return protoBind.call(fn, context); + }; + } else { + can.proxy = function (fn, context) { + return function () { + return fn.apply(context, arguments); + }; + }; + } + can.frag = function (item) { + var frag; + if (!item || typeof item === 'string') { + frag = can.buildFragment(item == null ? '' : '' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } else if (item.nodeType === 11) { + return item; + } else if (typeof item.nodeType === 'number') { + frag = document.createDocumentFragment(); + frag.appendChild(item); + return frag; + } else if (typeof item.length === 'number') { + frag = document.createDocumentFragment(); + can.each(item, function (item) { + frag.appendChild(can.frag(item)); + }); + return frag; + } else { + frag = can.buildFragment('' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } + }; + can.scope = can.viewModel = function (el, attr, val) { + el = can.$(el); + var scope = can.data(el, 'scope') || can.data(el, 'viewModel'); + if (!scope) { + scope = new can.Map(); + can.data(el, 'scope', scope); + can.data(el, 'viewModel', scope); + } + switch (arguments.length) { + case 0: + case 1: + return scope; + case 2: + return scope.attr(attr); + default: + scope.attr(attr, val); + return el; + } + }; + can['import'] = function (moduleName) { + var deferred = new can.Deferred(); + if (typeof window.System === 'object' && can.isFunction(window.System['import'])) { + window.System['import'](moduleName).then(can.proxy(deferred.resolve, deferred), can.proxy(deferred.reject, deferred)); + } else if (window.define && window.define.amd) { + window.require([moduleName], function (value) { + deferred.resolve(value); + }); + } else if (window.steal) { + steal.steal(moduleName, function (value) { + deferred.resolve(value); + }); + } else if (window.require) { + deferred.resolve(window.require(moduleName)); + } else { + deferred.resolve(); + } + return deferred.promise(); + }; + can.__observe = function () { + }; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/dojo.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/dojo.js new file mode 100644 index 0000000000..54f715c11a --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/dojo.js @@ -0,0 +1,482 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/dojo/dojo*/ +'format steal'; +define([ + 'can/util/can', + 'can/util/attr', + 'dojo/main', + 'can/event', + 'can/fragment', + 'can/util/each', + 'can/util/object/isplain', + 'can/deferred', + 'can/hashchange', + 'can/util/inserted' +], function (can, attr, djo) { + var dojo = djo || window.dojo; + define('plugd/trigger', ['dojo/main'], function () { + var d = dojo; + var isfn = d.isFunction; + var leaveRe = /mouse(enter|leave)/; + var _fix = function (_, p) { + return 'mouse' + (p === 'enter' ? 'over' : 'out'); + }; + var mix = d._mixin; + var realTrigger; + if (d.doc.createEvent) { + realTrigger = function (n, e, a) { + var ev = d.doc.createEvent('HTMLEvents'); + e = e.replace(leaveRe, _fix); + ev.initEvent(e, e === 'removed' || e === 'inserted' ? false : true, true); + if (a) { + mix(ev, a); + } + n.dispatchEvent(ev); + }; + } else { + realTrigger = function (n, e, a) { + var ev = 'on' + e, stop = false; + try { + var evObj = document.createEventObject(); + if (e === 'inserted' || e === 'removed') { + evObj.cancelBubble = true; + } + mix(evObj, a); + n.fireEvent(ev, evObj); + } catch (er) { + var evdata = mix({ + type: e, + target: n, + faux: true, + _stopper: function () { + stop = this.cancelBubble; + } + }, a); + if (isfn(n[ev])) { + n[ev](evdata); + } + if (e === 'inserted' || e === 'removed') { + return; + } + while (!stop && n !== d.doc && n.parentNode) { + n = n.parentNode; + if (isfn(n[ev])) { + n[ev](evdata); + } + } + } + }; + } + d._trigger = function (node, event, extraArgs) { + if (typeof event !== 'string') { + extraArgs = event; + event = extraArgs.type; + delete extraArgs.type; + } + var n = d.byId(node), ev = event && event.slice(0, 2) === 'on' ? event.slice(2) : event; + realTrigger(n, ev, extraArgs); + }; + d.trigger = function (obj, event, extraArgs) { + return isfn(obj) || isfn(event) || isfn(obj[event]) ? d.hitch.apply(d, arguments)() : d._trigger.apply(d, arguments); + }; + d.NodeList.prototype.trigger = d.NodeList._adaptAsForEach(d._trigger); + if (d._Node && !d._Node.prototype.trigger) { + d.extend(d._Node, { + trigger: function (ev, data) { + d._trigger(this, ev, data); + return this; + } + }); + } + return d.trigger; + }); + require([ + 'dojo/main', + 'dojo/query', + 'plugd/trigger', + 'dojo/NodeList-dom' + ]); + can.trim = function (s) { + return s && dojo.trim(s); + }; + can.makeArray = function (arr) { + var array = []; + dojo.forEach(arr, function (item) { + array.push(item); + }); + return array; + }; + can.isArray = dojo.isArray; + can.inArray = function (item, arr, from) { + return dojo.indexOf(arr, item, from); + }; + can.map = function (arr, fn) { + return dojo.map(can.makeArray(arr || []), fn); + }; + can.extend = function (first) { + if (first === true) { + var args = can.makeArray(arguments); + args.shift(); + return dojo.mixin.apply(dojo, args); + } + return dojo.mixin.apply(dojo, arguments); + }; + can.isEmptyObject = function (object) { + var prop; + for (prop in object) { + break; + } + return prop === undefined; + }; + can.param = function (object) { + var pairs = [], add = function (key, value) { + pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(value)); + }; + for (var name in object) { + can.buildParam(name, object[name], add); + } + return pairs.join('&').replace(/%20/g, '+'); + }; + can.buildParam = function (prefix, obj, add) { + if (can.isArray(obj)) { + for (var i = 0, l = obj.length; i < l; ++i) { + add(prefix + '[]', obj[i]); + } + } else if (dojo.isObject(obj)) { + for (var name in obj) { + can.buildParam(prefix + '[' + name + ']', obj[name], add); + } + } else { + add(prefix, obj); + } + }; + can.proxy = function (func, context) { + return dojo.hitch(context, func); + }; + can.isFunction = function (f) { + return dojo.isFunction(f); + }; + var dojoId = 0, dojoAddBinding = function (nodelist, ev, cb) { + nodelist.forEach(function (node) { + node = new dojo.NodeList(node.nodeName === 'SELECT' ? [node] : node); + var events = can.data(node, 'events'); + if (!events) { + can.data(node, 'events', events = {}); + } + if (!events[ev]) { + events[ev] = {}; + } + if (cb.__bindingsIds === undefined) { + cb.__bindingsIds = dojoId++; + } + events[ev][cb.__bindingsIds] = node.on(ev, cb)[0]; + }); + }, dojoRemoveBinding = function (nodelist, ev, cb) { + nodelist.forEach(function (node) { + var currentNode = new dojo.NodeList(node), events = can.data(currentNode, 'events'); + if (!events) { + return; + } + var handlers = events[ev]; + if (!handlers) { + return; + } + var handler = handlers[cb.__bindingsIds]; + dojo.disconnect(handler); + delete handlers[cb.__bindingsIds]; + if (can.isEmptyObject(handlers)) { + delete events[ev]; + } + }); + }; + can.bind = function (ev, cb) { + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (this.on || this.nodeType) { + dojoAddBinding(new dojo.NodeList(this.nodeName === 'SELECT' ? [this] : this), ev, cb); + } else if (this.addEvent) { + this.addEvent(ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + return this; + }; + can.unbind = function (ev, cb) { + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (this.on || this.nodeType) { + dojoRemoveBinding(new dojo.NodeList(this), ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + return this; + }; + can.on = can.bind; + can.off = can.unbind; + can.trigger = function (item, event, args, bubble) { + if (!(item instanceof dojo.NodeList) && (item.nodeName || item === window)) { + item = can.$(item); + } + if (item.trigger) { + if (bubble === false) { + if (!item[0] || item[0].nodeType === 3) { + return; + } + var connect = item.on(event, function (ev) { + if (ev.stopPropagation) { + ev.stopPropagation(); + } + ev.cancelBubble = true; + if (ev._stopper) { + ev._stopper(); + } + dojo.disconnect(connect); + }); + item.trigger(event, args); + } else { + item.trigger(event, args); + } + } else { + if (typeof event === 'string') { + event = { type: event }; + } + event.target = event.target || item; + can.dispatch.call(item, event, can.makeArray(args)); + } + }; + can.delegate = function (selector, ev, cb) { + if (!selector) { + can.bind.call(this, ev, cb); + } else if (this.on || this.nodeType) { + dojoAddBinding(new dojo.NodeList(this), selector + ':' + ev, cb); + } else if (this.delegate) { + this.delegate(selector, ev, cb); + } else { + can.bind.call(this, ev, cb); + } + return this; + }; + can.undelegate = function (selector, ev, cb) { + if (!selector) { + can.unbind.call(this, ev, cb); + } else if (this.on || this.nodeType) { + dojoRemoveBinding(new dojo.NodeList(this), selector + ':' + ev, cb); + } else if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else { + can.unbind.call(this, ev, cb); + } + return this; + }; + var updateDeferred = function (xhr, d) { + for (var prop in xhr) { + if (typeof d[prop] === 'function') { + d[prop] = function () { + xhr[prop].apply(xhr, arguments); + }; + } else { + d[prop] = prop[xhr]; + } + } + }; + can.ajax = function (options) { + var type = can.capitalize((options.type || 'get').toLowerCase()), method = dojo['xhr' + type]; + var success = options.success, error = options.error, d = new can.Deferred(); + var def = method({ + url: options.url, + handleAs: options.dataType, + sync: !options.async, + headers: options.headers, + content: options.data + }); + def.then(function (data, ioargs) { + updateDeferred(xhr, d); + d.resolve(data, 'success', xhr); + if (success) { + success(data, 'success', xhr); + } + }, function (data, ioargs) { + updateDeferred(xhr, d); + d.reject(xhr, 'error'); + error(xhr, 'error'); + }); + var xhr = def.ioArgs.xhr; + updateDeferred(xhr, d); + return d; + }; + can.$ = function (selector) { + if (selector === window) { + return window; + } + if (typeof selector === 'string') { + return dojo.query(selector); + } else { + return new dojo.NodeList(selector && selector.nodeName ? [selector] : selector); + } + }; + can.append = function (wrapped, html) { + return wrapped.forEach(function (node) { + dojo.place(html, node); + }); + }; + var data = {}, uuid = can.uuid = +new Date(), exp = can.expando = 'can' + uuid; + function getData(node, name) { + var id = node[exp], store = id && data[id]; + return name === undefined ? store || setData(node) : store && store[name]; + } + function setData(node, name, value) { + var id = node[exp] || (node[exp] = ++uuid), store = data[id] || (data[id] = {}); + if (name !== undefined) { + store[name] = value; + } + return store; + } + var cleanData = function (elems) { + var nodes = []; + for (var i = 0, len = elems.length; i < len; i++) { + if (elems[i].nodeType === 1) { + nodes.push(elems[i]); + } + } + can.trigger(new dojo.NodeList(nodes), 'removed', [], false); + i = 0; + for (var elem; (elem = elems[i]) !== undefined; i++) { + var id = elem[exp]; + delete data[id]; + } + }; + can.data = function (wrapped, name, value) { + return value === undefined ? wrapped.length === 0 ? undefined : getData(wrapped[0], name) : wrapped.forEach(function (node) { + setData(node, name, value); + }); + }; + can.cleanData = function (elem, prop) { + var id = elem[exp]; + delete data[id][prop]; + }; + dojo.empty = function (node) { + for (var c; c = node.lastChild;) { + dojo.destroy(c); + } + }; + var destroy = dojo.destroy; + dojo.destroy = function (node) { + node = dojo.byId(node); + var nodes = [node]; + if (node.getElementsByTagName) { + nodes.concat(can.makeArray(node.getElementsByTagName('*'))); + } + cleanData(nodes); + return destroy.apply(dojo, arguments); + }; + var place = dojo.place; + dojo.place = function (node, refNode, position) { + if (typeof node === 'string' && /^\s* 0 ? Array.prototype.concat.apply([], array) : array; + } + can.isArray = function (arr) { + return arr instanceof Array; + }; + can.isFunction = function () { + if (typeof document !== 'undefined' && typeof document.getElementsByTagName('body') === 'function') { + return function (value) { + return Object.prototype.toString.call(value) === '[object Function]'; + }; + } else { + return function (value) { + return typeof value === 'function'; + }; + } + }(); + can.trim = core_trim && !core_trim.call('\uFEFF\xA0') ? function (text) { + return text == null ? '' : core_trim.call(text); + } : function (text) { + return text == null ? '' : (text + '').replace(rtrim, ''); + }; + can.extend = function () { + var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, length = arguments.length, deep = false; + if (typeof target === 'boolean') { + deep = target; + target = arguments[1] || {}; + i = 2; + } + if (typeof target !== 'object' && !can.isFunction(target)) { + target = {}; + } + if (length === i) { + target = this; + --i; + } + for (; i < length; i++) { + if ((options = arguments[i]) != null) { + for (name in options) { + src = target[name]; + copy = options[name]; + if (target === copy) { + continue; + } + if (deep && copy && (can.isPlainObject(copy) || (copyIsArray = can.isArray(copy)))) { + if (copyIsArray) { + copyIsArray = false; + clone = src && can.isArray(src) ? src : []; + } else { + clone = src && can.isPlainObject(src) ? src : {}; + } + target[name] = can.extend(deep, clone, copy); + } else if (copy !== undefined) { + target[name] = copy; + } + } + } + } + return target; + }; + can.map = function (elements, callback) { + var values = [], putValue = function (val, index) { + var value = callback(val, index); + if (value != null) { + values.push(value); + } + }; + if (likeArray(elements)) { + for (var i = 0, l = elements.length; i < l; i++) { + putValue(elements[i], i); + } + } else { + for (var key in elements) { + putValue(elements[key], key); + } + } + return flatten(values); + }; + can.proxy = function (cb, that) { + return function () { + return cb.apply(that, arguments); + }; + }; + can.attr = attr; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/each.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/each.js new file mode 100644 index 0000000000..b3c645fa45 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/each.js @@ -0,0 +1,56 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/array/each*/ +define(['can/util/can'], function (can) { + var isArrayLike = function (obj) { + var length = 'length' in obj && obj.length; + return typeof arr !== 'function' && (length === 0 || typeof length === 'number' && length > 0 && length - 1 in obj); + }; + can.each = function (elements, callback, context) { + var i = 0, key, len, item; + if (elements) { + if (isArrayLike(elements)) { + if (can.List && elements instanceof can.List) { + for (len = elements.attr('length'); i < len; i++) { + item = elements.attr(i); + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } else { + for (len = elements.length; i < len; i++) { + item = elements[i]; + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } + } else if (typeof elements === 'object') { + if (can.Map && elements instanceof can.Map || elements === can.route) { + var keys = can.Map.keys(elements); + for (i = 0, len = keys.length; i < len; i++) { + key = keys[i]; + item = elements.attr(key); + if (callback.call(context || item, item, key, elements) === false) { + break; + } + } + } else { + for (key in elements) { + if (elements.hasOwnProperty(key) && callback.call(context || elements[key], elements[key], key, elements) === false) { + break; + } + } + } + } + } + return elements; + }; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/fixture.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/fixture.js new file mode 100644 index 0000000000..285da6a004 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/fixture.js @@ -0,0 +1,495 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/fixture/fixture*/ +define([ + 'can/util/library', + 'can/util/string', + 'can/util/object' +], function (can) { + if (!can.Object) { + throw new Error('can.fixture depends on can.Object. Please include it before can.fixture.'); + } + var getUrl = function (url) { + if (typeof steal !== 'undefined') { + if (steal.joinURIs) { + var base = steal.config('baseUrl'); + var joined = steal.joinURIs(base, url); + return joined; + } + if (can.isFunction(steal.config)) { + if (steal.System) { + return steal.joinURIs(steal.config('baseURL'), url); + } else { + return steal.config().root.mapJoin(url).toString(); + } + } + return steal.root.join(url).toString(); + } + return (can.fixture.rootUrl || '') + url; + }; + var updateSettings = function (settings, originalOptions) { + if (!can.fixture.on || settings.fixture === false) { + return; + } + var log = function () { + }; + settings.type = settings.type || settings.method || 'GET'; + var data = overwrite(settings); + if (!settings.fixture) { + if (window.location.protocol === 'file:') { + log('ajax request to ' + settings.url + ', no fixture found'); + } + return; + } + if (typeof settings.fixture === 'string' && can.fixture[settings.fixture]) { + settings.fixture = can.fixture[settings.fixture]; + } + if (typeof settings.fixture === 'string') { + var url = settings.fixture; + if (/^\/\//.test(url)) { + url = getUrl(settings.fixture.substr(2)); + } + if (data) { + url = can.sub(url, data); + } + delete settings.fixture; + settings.url = url; + settings.data = null; + settings.type = 'GET'; + if (!settings.error) { + settings.error = function (xhr, error, message) { + throw 'fixtures.js Error ' + error + ' ' + message; + }; + } + } else { + if (settings.dataTypes) { + settings.dataTypes.splice(0, 0, 'fixture'); + } + if (data && originalOptions) { + originalOptions.data = originalOptions.data || {}; + can.extend(originalOptions.data, data); + } + } + }, extractResponse = function (status, statusText, responses, headers) { + if (typeof status !== 'number') { + headers = statusText; + responses = status; + statusText = 'success'; + status = 200; + } + if (typeof statusText !== 'string') { + headers = responses; + responses = statusText; + statusText = 'success'; + } + if (status >= 400 && status <= 599) { + this.dataType = 'text'; + } + return [ + status, + statusText, + extractResponses(this, responses), + headers + ]; + }, extractResponses = function (settings, responses) { + var next = settings.dataTypes ? settings.dataTypes[0] : settings.dataType || 'json'; + if (!responses || !responses[next]) { + var tmp = {}; + tmp[next] = responses; + responses = tmp; + } + return responses; + }; + if (can.ajaxPrefilter && can.ajaxTransport) { + can.ajaxPrefilter(updateSettings); + can.ajaxTransport('fixture', function (s, original) { + s.dataTypes.shift(); + var timeout, stopped = false; + return { + send: function (headers, callback) { + timeout = setTimeout(function () { + var success = function () { + if (stopped === false) { + callback.apply(null, extractResponse.apply(s, arguments)); + } + }, result = s.fixture(original, success, headers, s); + if (result !== undefined) { + callback(200, 'success', extractResponses(s, result), {}); + } + }, can.fixture.delay); + }, + abort: function () { + stopped = true; + clearTimeout(timeout); + } + }; + }); + } else { + var AJAX = can.ajax; + can.ajax = function (settings) { + updateSettings(settings, settings); + if (settings.fixture) { + var timeout, deferred = new can.Deferred(), stopped = false; + deferred.getResponseHeader = function () { + }; + deferred.then(settings.success, settings.fail); + deferred.abort = function () { + clearTimeout(timeout); + stopped = true; + deferred.reject(deferred); + }; + timeout = setTimeout(function () { + var success = function () { + var response = extractResponse.apply(settings, arguments), status = response[0]; + if ((status >= 200 && status < 300 || status === 304) && stopped === false) { + deferred.resolve(response[2][settings.dataType]); + } else { + deferred.reject(deferred, 'error', response[1]); + } + }, result = settings.fixture(settings, success, settings.headers, settings); + if (result !== undefined) { + deferred.resolve(result); + } + }, can.fixture.delay); + return deferred; + } else { + return AJAX(settings); + } + }; + } + var overwrites = [], find = function (settings, exact) { + for (var i = 0; i < overwrites.length; i++) { + if ($fixture._similar(settings, overwrites[i], exact)) { + return i; + } + } + return -1; + }, overwrite = function (settings) { + var index = find(settings); + if (index > -1) { + settings.fixture = overwrites[index].fixture; + return $fixture._getData(overwrites[index].url, settings.url); + } + }, getId = function (settings) { + var id = settings.data.id; + if (id === undefined && typeof settings.data === 'number') { + id = settings.data; + } + if (id === undefined) { + settings.url.replace(/\/(\d+)(\/|$|\.)/g, function (all, num) { + id = num; + }); + } + if (id === undefined) { + id = settings.url.replace(/\/(\w+)(\/|$|\.)/g, function (all, num) { + if (num !== 'update') { + id = num; + } + }); + } + if (id === undefined) { + id = Math.round(Math.random() * 1000); + } + return id; + }; + var $fixture = can.fixture = function (settings, fixture) { + if (fixture !== undefined) { + if (typeof settings === 'string') { + var matches = settings.match(/(GET|POST|PUT|DELETE) (.+)/i); + if (!matches) { + settings = { url: settings }; + } else { + settings = { + url: matches[2], + type: matches[1] + }; + } + } + var index = find(settings, !!fixture); + if (index > -1) { + overwrites.splice(index, 1); + } + if (fixture == null) { + return; + } + settings.fixture = fixture; + overwrites.push(settings); + } else { + can.each(settings, function (fixture, url) { + $fixture(url, fixture); + }); + } + }; + var replacer = can.replacer; + can.extend(can.fixture, { + _similar: function (settings, overwrite, exact) { + if (exact) { + return can.Object.same(settings, overwrite, { fixture: null }); + } else { + return can.Object.subset(settings, overwrite, can.fixture._compare); + } + }, + _compare: { + url: function (a, b) { + return !!$fixture._getData(b, a); + }, + fixture: null, + type: 'i' + }, + _getData: function (fixtureUrl, url) { + var order = [], fixtureUrlAdjusted = fixtureUrl.replace('.', '\\.').replace('?', '\\?'), res = new RegExp(fixtureUrlAdjusted.replace(replacer, function (whole, part) { + order.push(part); + return '([^/]+)'; + }) + '$').exec(url), data = {}; + if (!res) { + return null; + } + res.shift(); + can.each(order, function (name) { + data[name] = res.shift(); + }); + return data; + }, + store: function (count, make, filter) { + var currentId = 0, findOne = function (id) { + for (var i = 0; i < items.length; i++) { + if (id == items[i].id) { + return items[i]; + } + } + }, methods = {}, types, items, reset; + if (can.isArray(count) && typeof count[0] === 'string') { + types = count; + count = make; + make = filter; + filter = arguments[3]; + } else if (typeof count === 'string') { + types = [ + count + 's', + count + ]; + count = make; + make = filter; + filter = arguments[3]; + } + if (typeof count === 'number') { + items = []; + reset = function () { + items = []; + for (var i = 0; i < count; i++) { + var item = make(i, items); + if (!item.id) { + item.id = i; + } + currentId = Math.max(item.id + 1, currentId + 1) || items.length; + items.push(item); + } + if (can.isArray(types)) { + can.fixture['~' + types[0]] = items; + can.fixture['-' + types[0]] = methods.findAll; + can.fixture['-' + types[1]] = methods.findOne; + can.fixture['-' + types[1] + 'Update'] = methods.update; + can.fixture['-' + types[1] + 'Destroy'] = methods.destroy; + can.fixture['-' + types[1] + 'Create'] = methods.create; + } + }; + } else { + filter = make; + var initialItems = count; + reset = function () { + items = initialItems.slice(0); + }; + } + can.extend(methods, { + findAll: function (request) { + request = request || {}; + var retArr = items.slice(0); + request.data = request.data || {}; + can.each((request.data.order || []).slice(0).reverse(), function (name) { + var split = name.split(' '); + retArr = retArr.sort(function (a, b) { + if (split[1].toUpperCase() !== 'ASC') { + if (a[split[0]] < b[split[0]]) { + return 1; + } else if (a[split[0]] === b[split[0]]) { + return 0; + } else { + return -1; + } + } else { + if (a[split[0]] < b[split[0]]) { + return -1; + } else if (a[split[0]] === b[split[0]]) { + return 0; + } else { + return 1; + } + } + }); + }); + can.each((request.data.group || []).slice(0).reverse(), function (name) { + var split = name.split(' '); + retArr = retArr.sort(function (a, b) { + return a[split[0]] > b[split[0]]; + }); + }); + var offset = parseInt(request.data.offset, 10) || 0, limit = parseInt(request.data.limit, 10) || items.length - offset, i = 0; + for (var param in request.data) { + i = 0; + if (request.data[param] !== undefined && (param.indexOf('Id') !== -1 || param.indexOf('_id') !== -1)) { + while (i < retArr.length) { + if (request.data[param] != retArr[i][param]) { + retArr.splice(i, 1); + } else { + i++; + } + } + } + } + if (typeof filter === 'function') { + i = 0; + while (i < retArr.length) { + if (!filter(retArr[i], request)) { + retArr.splice(i, 1); + } else { + i++; + } + } + } else if (typeof filter === 'object') { + i = 0; + while (i < retArr.length) { + if (!can.Object.subset(retArr[i], request.data, filter)) { + retArr.splice(i, 1); + } else { + i++; + } + } + } + return { + 'count': retArr.length, + 'limit': request.data.limit, + 'offset': request.data.offset, + 'data': retArr.slice(offset, offset + limit) + }; + }, + findOne: function (request, response) { + var item = findOne(getId(request)); + if (typeof item === 'undefined') { + return response(404, 'Requested resource not found'); + } + response(item); + }, + update: function (request, response) { + var id = getId(request), item = findOne(id); + if (typeof item === 'undefined') { + return response(404, 'Requested resource not found'); + } + can.extend(item, request.data); + response({ id: id }, { location: request.url || '/' + getId(request) }); + }, + destroy: function (request, response) { + var id = getId(request), item = findOne(id); + if (typeof item === 'undefined') { + return response(404, 'Requested resource not found'); + } + for (var i = 0; i < items.length; i++) { + if (items[i].id == id) { + items.splice(i, 1); + break; + } + } + return {}; + }, + create: function (settings, response) { + var item = typeof make === 'function' ? make(items.length, items) : {}; + can.extend(item, settings.data); + if (!item.id) { + item.id = currentId++; + } + items.push(item); + response({ id: item.id }, { location: settings.url + '/' + item.id }); + } + }); + reset(); + return can.extend({ + getId: getId, + find: function (settings) { + return findOne(getId(settings)); + }, + reset: reset + }, methods); + }, + rand: function randomize(arr, min, max) { + if (typeof arr === 'number') { + if (typeof min === 'number') { + return arr + Math.floor(Math.random() * (min - arr)); + } else { + return Math.floor(Math.random() * arr); + } + } + var rand = randomize; + if (min === undefined) { + return rand(arr, rand(arr.length + 1)); + } + var res = []; + arr = arr.slice(0); + if (!max) { + max = min; + } + max = min + Math.round(rand(max - min)); + for (var i = 0; i < max; i++) { + res.push(arr.splice(rand(arr.length), 1)[0]); + } + return res; + }, + xhr: function (xhr) { + return can.extend({}, { + abort: can.noop, + getAllResponseHeaders: function () { + return ''; + }, + getResponseHeader: function () { + return ''; + }, + open: can.noop, + overrideMimeType: can.noop, + readyState: 4, + responseText: '', + responseXML: null, + send: can.noop, + setRequestHeader: can.noop, + status: 200, + statusText: 'OK' + }, xhr); + }, + on: true + }); + can.fixture.delay = 200; + can.fixture.rootUrl = getUrl(''); + can.fixture['-handleFunction'] = function (settings) { + if (typeof settings.fixture === 'string' && can.fixture[settings.fixture]) { + settings.fixture = can.fixture[settings.fixture]; + } + if (typeof settings.fixture === 'function') { + setTimeout(function () { + if (settings.success) { + settings.success.apply(null, settings.fixture(settings, 'success')); + } + if (settings.complete) { + settings.complete.apply(null, settings.fixture(settings, 'complete')); + } + }, can.fixture.delay); + return true; + } + return false; + }; + can.fixture.overwrites = overwrites; + can.fixture.make = can.fixture.store; + return can.fixture; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/function.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/function.js new file mode 100644 index 0000000000..169af2b06c --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/function.js @@ -0,0 +1,43 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/function/function*/ +define(['can/util/library'], function (can) { + can.debounce = function (fn, time, context) { + var timeout; + return function () { + var args = arguments; + clearTimeout(timeout); + timeout = setTimeout(can.proxy(function () { + fn.apply(this, args); + }, context || this), time); + }; + }; + can.throttle = function (fn, time, context) { + var run; + return function () { + var args = arguments; + var ctx = context || this; + if (!run) { + run = true; + setTimeout(function () { + fn.apply(ctx, args); + run = false; + }, time); + } + }; + }; + can.defer = function (fn, context) { + var args = arguments; + var ctx = context || this; + setTimeout(function () { + fn.apply(ctx, args); + }, 0); + }; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/inserted.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/inserted.js new file mode 100644 index 0000000000..da1171ab33 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/inserted.js @@ -0,0 +1,55 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/inserted/inserted*/ +define(['can/util/can'], function (can) { + can.inserted = function (elems) { + elems = can.makeArray(elems); + var inDocument = false, doc = can.$(document.contains ? document : document.body), children; + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + if (!inDocument) { + if (elem.getElementsByTagName) { + if (can.has(doc, elem).length) { + inDocument = true; + } else { + return; + } + } else { + continue; + } + } + if (inDocument && elem.getElementsByTagName) { + children = can.makeArray(elem.getElementsByTagName('*')); + can.trigger(elem, 'inserted', [], false); + for (var j = 0, child; (child = children[j]) !== undefined; j++) { + can.trigger(child, 'inserted', [], false); + } + } + } + }; + can.appendChild = function (el, child) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.appendChild(child); + can.inserted(children); + }; + can.insertBefore = function (el, child, ref) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.insertBefore(child, ref); + can.inserted(children); + }; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/jquery.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/jquery.js new file mode 100644 index 0000000000..bccefbfa1a --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/jquery.js @@ -0,0 +1,229 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/jquery/jquery*/ +define([ + 'jquery', + 'can/util/can', + 'can/util/attr', + 'can/event', + 'can/util/each', + 'can/util/inserted' +], function ($, can, attr, event) { + var isBindableElement = function (node) { + return node.nodeName && (node.nodeType === 1 || node.nodeType === 9) || node == window; + }; + $ = $ || window.jQuery; + $.extend(can, $, { + trigger: function (obj, event, args, bubbles) { + if (isBindableElement(obj)) { + $.event.trigger(event, args, obj, !bubbles); + } else if (obj.trigger) { + obj.trigger(event, args); + } else { + if (typeof event === 'string') { + event = { type: event }; + } + event.target = event.target || obj; + if (args) { + if (args.length && typeof args === 'string') { + args = [args]; + } else if (!args.length) { + args = [args]; + } + } + if (!args) { + args = []; + } + can.dispatch.call(obj, event, args); + } + }, + event: can.event, + addEvent: can.addEvent, + removeEvent: can.removeEvent, + buildFragment: function (elems, context) { + var ret; + elems = [elems]; + context = context || document; + context = !context.nodeType && context[0] || context; + context = context.ownerDocument || context; + ret = $.buildFragment(elems, context); + return ret.cacheable ? $.clone(ret.fragment) : ret.fragment || ret; + }, + $: $, + each: can.each, + bind: function (ev, cb) { + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (isBindableElement(this)) { + $.event.add(this, ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + return this; + }, + unbind: function (ev, cb) { + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (isBindableElement(this)) { + $.event.remove(this, ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + return this; + }, + delegate: function (selector, ev, cb) { + if (this.delegate) { + this.delegate(selector, ev, cb); + } else if (isBindableElement(this)) { + $(this).delegate(selector, ev, cb); + } else { + can.bind.call(this, ev, cb); + } + return this; + }, + undelegate: function (selector, ev, cb) { + if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else if (isBindableElement(this)) { + $(this).undelegate(selector, ev, cb); + } else { + can.unbind.call(this, ev, cb); + } + return this; + }, + proxy: can.proxy, + attr: attr + }); + can.on = can.bind; + can.off = can.unbind; + $.each([ + 'append', + 'filter', + 'addClass', + 'remove', + 'data', + 'get', + 'has' + ], function (i, name) { + can[name] = function (wrapped) { + return wrapped[name].apply(wrapped, can.makeArray(arguments).slice(1)); + }; + }); + var oldClean = $.cleanData; + $.cleanData = function (elems) { + $.each(elems, function (i, elem) { + if (elem) { + can.trigger(elem, 'removed', [], false); + } + }); + oldClean(elems); + }; + var oldDomManip = $.fn.domManip, cbIndex; + $.fn.domManip = function (args, cb1, cb2) { + for (var i = 1; i < arguments.length; i++) { + if (typeof arguments[i] === 'function') { + cbIndex = i; + break; + } + } + return oldDomManip.apply(this, arguments); + }; + $(document.createElement('div')).append(document.createElement('div')); + $.fn.domManip = cbIndex === 2 ? function (args, table, callback) { + return oldDomManip.call(this, args, table, function (elem) { + var elems; + if (elem.nodeType === 11) { + elems = can.makeArray(elem.childNodes); + } + var ret = callback.apply(this, arguments); + can.inserted(elems ? elems : [elem]); + return ret; + }); + } : function (args, callback) { + return oldDomManip.call(this, args, function (elem) { + var elems; + if (elem.nodeType === 11) { + elems = can.makeArray(elem.childNodes); + } + var ret = callback.apply(this, arguments); + can.inserted(elems ? elems : [elem]); + return ret; + }); + }; + if (!can.attr.MutationObserver) { + var oldAttr = $.attr; + $.attr = function (el, attrName) { + var oldValue, newValue; + if (arguments.length >= 3) { + oldValue = oldAttr.call(this, el, attrName); + } + var res = oldAttr.apply(this, arguments); + if (arguments.length >= 3) { + newValue = oldAttr.call(this, el, attrName); + } + if (newValue !== oldValue) { + can.attr.trigger(el, attrName, oldValue); + } + return res; + }; + var oldRemove = $.removeAttr; + $.removeAttr = function (el, attrName) { + var oldValue = oldAttr.call(this, el, attrName), res = oldRemove.apply(this, arguments); + if (oldValue != null) { + can.attr.trigger(el, attrName, oldValue); + } + return res; + }; + $.event.special.attributes = { + setup: function () { + can.data(can.$(this), 'canHasAttributesBindings', true); + }, + teardown: function () { + $.removeData(this, 'canHasAttributesBindings'); + } + }; + } else { + $.event.special.attributes = { + setup: function () { + var self = this; + var observer = new can.attr.MutationObserver(function (mutations) { + mutations.forEach(function (mutation) { + var copy = can.simpleExtend({}, mutation); + can.trigger(self, copy, []); + }); + }); + observer.observe(this, { + attributes: true, + attributeOldValue: true + }); + can.data(can.$(this), 'canAttributesObserver', observer); + }, + teardown: function () { + can.data(can.$(this), 'canAttributesObserver').disconnect(); + $.removeData(this, 'canAttributesObserver'); + } + }; + } + (function () { + var text = '<-\n>', frag = can.buildFragment(text, document); + if (text !== frag.childNodes[0].nodeValue) { + var oldBuildFragment = can.buildFragment; + can.buildFragment = function (content, context) { + var res = oldBuildFragment(content, context); + if (res.childNodes.length === 1 && res.childNodes[0].nodeType === 3) { + res.childNodes[0].nodeValue = content; + } + return res; + }; + } + }()); + $.event.special.inserted = {}; + $.event.special.removed = {}; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/library.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/library.js new file mode 100644 index 0000000000..53e885cd91 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/library.js @@ -0,0 +1,12 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/library*/ +define(['can/util/jquery'], function (can) { + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/makeArray.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/makeArray.js new file mode 100644 index 0000000000..f3b4ccfe94 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/makeArray.js @@ -0,0 +1,19 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/array/makeArray*/ +define(['can/util/each'], function (can) { + can.makeArray = function (arr) { + var ret = []; + can.each(arr, function (a, i) { + ret[i] = a; + }); + return ret; + }; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/mootools.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/mootools.js new file mode 100644 index 0000000000..be95c1be11 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/mootools.js @@ -0,0 +1,355 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/mootools/mootools*/ +define([ + 'can/util/can', + 'can/util/attr', + 'mootools', + 'can/event', + 'can/fragment', + 'can/deferred', + 'can/util/each', + 'can/util/object/isplain', + 'can/util/inserted' +], function (can, attr) { + can.trim = function (s) { + return s ? s.trim() : s; + }; + var extend = function () { + var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, length = arguments.length, deep = false; + if (typeof target === 'boolean') { + deep = target; + target = arguments[1] || {}; + i = 2; + } + if (typeof target !== 'object' && !can.isFunction(target)) { + target = {}; + } + if (length === i) { + target = this; + --i; + } + for (; i < length; i++) { + if ((options = arguments[i]) !== null) { + for (name in options) { + src = target[name]; + copy = options[name]; + if (target === copy) { + continue; + } + if (deep && copy && (can.isPlainObject(copy) || (copyIsArray = can.isArray(copy)))) { + if (copyIsArray) { + copyIsArray = false; + clone = src && can.isArray(src) ? src : []; + } else { + clone = src && can.isPlainObject(src) ? src : {}; + } + target[name] = can.extend(deep, clone, copy); + } else if (copy !== undefined) { + target[name] = copy; + } + } + } + } + return target; + }; + can.extend = extend; + can.makeArray = function (item) { + if (item === null) { + return []; + } + try { + return Type.isEnumerable(item) && typeof item !== 'string' ? Array.prototype.slice.call(item) : [item]; + } catch (ex) { + var arr = [], i; + for (i = 0; i < item.length; ++i) { + arr.push(item[i]); + } + return arr; + } + }; + can.isArray = function (arr) { + return typeOf(arr) === 'array'; + }; + can.inArray = function (item, arr, fromIndex) { + if (!arr) { + return -1; + } + return Array.prototype.indexOf.call(arr, item, fromIndex); + }; + can.map = function (arr, fn) { + return Array.from(arr || []).map(fn); + }; + can.param = function (object) { + return Object.toQueryString(object); + }; + can.isEmptyObject = function (object) { + return Object.keys(object).length === 0; + }; + can.isFunction = function (f) { + return typeOf(f) === 'function'; + }; + can.bind = function (ev, cb) { + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (this.nodeName && (this.nodeType && this.nodeType !== 11)) { + can.$(this).addEvent(ev, cb); + } else if (this.addEvent) { + this.addEvent(ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + return this; + }; + can.unbind = function (ev, cb) { + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (this.nodeName && (this.nodeType && this.nodeType !== 11)) { + can.$(this).removeEvent(ev, cb); + } else if (this.removeEvent) { + this.removeEvent(ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + return this; + }; + can.on = can.bind; + can.off = can.unbind; + can.trigger = function (item, event, args, bubble) { + bubble = bubble === undefined ? true : bubble; + args = args || []; + var propagating = true; + if (item.fireEvent) { + item = item[0] || item; + while (item && propagating) { + if (!event.type) { + event = { + type: event, + target: item, + stopPropagation: function () { + propagating = false; + } + }; + } + var events = item !== window ? can.$(item).retrieve('events')[0] : item.retrieve('events'); + if (events && events[event.type]) { + events[event.type].keys.each(function (fn) { + fn.apply(item, [event].concat(args)); + }, this); + } + if (bubble && item.parentNode && item.parentNode.nodeType !== 11) { + item = item.parentNode; + } else { + item = null; + } + } + } else { + if (typeof event === 'string') { + event = { type: event }; + } + event.target = event.target || item; + can.dispatch.call(item, event, can.makeArray(args)); + } + }; + can.delegate = function (selector, ev, cb) { + if (this.delegate) { + this.delegate(selector, ev, cb); + } else if (this.addEvent) { + this.addEvent(ev + ':relay(' + selector + ')', cb); + } else { + can.bind.call(this, ev, cb); + } + return this; + }; + can.undelegate = function (selector, ev, cb) { + if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else if (this.removeEvent) { + this.removeEvent(ev + ':relay(' + selector + ')', cb); + } else { + can.unbind.call(this, ev, cb); + } + return this; + }; + var optionsMap = { + type: 'method', + success: undefined, + error: undefined + }; + var updateDeferred = function (xhr, d) { + for (var prop in xhr) { + if (typeof d[prop] === 'function') { + d[prop] = function () { + xhr[prop].apply(xhr, arguments); + }; + } else { + d[prop] = prop[xhr]; + } + } + }; + can.ajax = function (options) { + var d = can.Deferred(), requestOptions = can.extend({}, options), request; + for (var option in optionsMap) { + if (requestOptions[option] !== undefined) { + requestOptions[optionsMap[option]] = requestOptions[option]; + delete requestOptions[option]; + } + } + requestOptions.method = requestOptions.method || 'get'; + requestOptions.url = requestOptions.url.toString(); + var success = options.onSuccess || options.success, error = options.onFailure || options.error; + requestOptions.onSuccess = function (response, xml) { + var data = response; + updateDeferred(request.xhr, d); + d.resolve(data, 'success', request.xhr); + if (success) { + success(data, 'success', request.xhr); + } + }; + requestOptions.onFailure = function () { + updateDeferred(request.xhr, d); + d.reject(request.xhr, 'error'); + if (error) { + error(request.xhr, 'error'); + } + }; + if (options.dataType === 'json') { + request = new Request.JSON(requestOptions); + } else { + request = new Request(requestOptions); + } + request.send(); + updateDeferred(request.xhr, d); + return d; + }; + can.$ = function (selector) { + if (selector === window) { + return window; + } + return $$(selector && selector.nodeName ? [selector] : selector); + }; + var old = document.id; + document.id = function (el) { + if (el && el.nodeType === 11) { + return el; + } else { + return old.apply(document, arguments); + } + }; + can.append = function (wrapped, html) { + if (typeof html === 'string') { + html = can.buildFragment(html); + } + return wrapped.grab(html); + }; + can.filter = function (wrapped, filter) { + return wrapped.filter(filter); + }; + can.data = function (wrapped, key, value) { + if (value === undefined) { + return wrapped[0].retrieve(key); + } else { + return wrapped.store(key, value); + } + }; + can.addClass = function (wrapped, className) { + return wrapped.addClass(className); + }; + can.remove = function (wrapped) { + var filtered = wrapped.filter(function (node) { + if (node.nodeType !== 1) { + node.parentNode.removeChild(node); + } else { + return true; + } + }); + filtered.destroy(); + return filtered; + }; + can.has = function (wrapped, element) { + if (Slick.contains(wrapped[0], element)) { + return wrapped; + } else { + return []; + } + }; + var destroy = Element.prototype.destroy, grab = Element.prototype.grab, oldSet = Element.prototype.set; + Element.implement({ + destroy: function () { + can.trigger(this, 'removed', [], false); + var elems = this.getElementsByTagName('*'); + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + can.trigger(elem, 'removed', [], false); + } + destroy.apply(this, arguments); + }, + grab: function (el) { + var elems; + if (el && el.nodeType === 11) { + elems = can.makeArray(el.childNodes); + } else { + elems = [el]; + } + var ret = grab.apply(this, arguments); + can.inserted(elems); + return ret; + }, + set: function (attrName, value) { + var isAttributeOrProp = can.inArray(attrName, [ + 'events', + 'html', + 'load', + 'morph', + 'send', + 'tag', + 'tween' + ]) === -1, newValue, oldValue; + if (isAttributeOrProp) { + oldValue = this.get(attrName); + } + var res = oldSet.apply(this, arguments); + if (isAttributeOrProp) { + newValue = this.get(attrName); + } + if (newValue !== oldValue) { + can.attr.trigger(this, attrName, oldValue); + } + return res; + }.overloadSetter() + }); + can.get = function (wrapped, index) { + return wrapped[index]; + }; + var idOf = Slick.uidOf; + Slick.uidOf = function (node) { + if (node.nodeType === 1 || node === window || node.document === document) { + return idOf(node); + } else { + return Math.random(); + } + }; + Element.NativeEvents.hashchange = 2; + can.attr = attr; + delete attr.MutationObserver; + Element.Events.attributes = { + onAdd: function () { + var el = can.$(this); + can.data(el, 'canHasAttributesBindings', (can.data(el, 'canHasAttributesBindings') || 0) + 1); + }, + onRemove: function () { + var el = can.$(this), cur = can.data(el, 'canHasAttributesBindings') || 0; + if (cur <= 0) { + can.cleanData(el, 'canHasAttributesBindings'); + } else { + can.data(el, 'canHasAttributesBindings', cur - 1); + } + } + }; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/object.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/object.js new file mode 100644 index 0000000000..2f5aa9d0e7 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/object.js @@ -0,0 +1,102 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/object/object*/ +define(['can/util/library'], function (can) { + var isArray = can.isArray; + can.Object = {}; + var same = can.Object.same = function (a, b, compares, aParent, bParent, deep) { + var aType = typeof a, aArray = isArray(a), comparesType = typeof compares, compare; + if (comparesType === 'string' || compares === null) { + compares = compareMethods[compares]; + comparesType = 'function'; + } + if (comparesType === 'function') { + return compares(a, b, aParent, bParent); + } + compares = compares || {}; + if (a === null || b === null) { + return a === b; + } + if (a instanceof Date || b instanceof Date) { + return a === b; + } + if (deep === -1) { + return aType === 'object' || a === b; + } + if (aType !== typeof b || aArray !== isArray(b)) { + return false; + } + if (a === b) { + return true; + } + if (aArray) { + if (a.length !== b.length) { + return false; + } + for (var i = 0; i < a.length; i++) { + compare = compares[i] === undefined ? compares['*'] : compares[i]; + if (!same(a[i], b[i], a, b, compare)) { + return false; + } + } + return true; + } else if (aType === 'object' || aType === 'function') { + var bCopy = can.extend({}, b); + for (var prop in a) { + compare = compares[prop] === undefined ? compares['*'] : compares[prop]; + if (!same(a[prop], b[prop], compare, a, b, deep === false ? -1 : undefined)) { + return false; + } + delete bCopy[prop]; + } + for (prop in bCopy) { + if (compares[prop] === undefined || !same(undefined, b[prop], compares[prop], a, b, deep === false ? -1 : undefined)) { + return false; + } + } + return true; + } + return false; + }; + can.Object.subsets = function (checkSet, sets, compares) { + var len = sets.length, subsets = []; + for (var i = 0; i < len; i++) { + var set = sets[i]; + if (can.Object.subset(checkSet, set, compares)) { + subsets.push(set); + } + } + return subsets; + }; + can.Object.subset = function (subset, set, compares) { + compares = compares || {}; + for (var prop in set) { + if (!same(subset[prop], set[prop], compares[prop], subset, set)) { + return false; + } + } + return true; + }; + var compareMethods = { + 'null': function () { + return true; + }, + i: function (a, b) { + return ('' + a).toLowerCase() === ('' + b).toLowerCase(); + }, + eq: function (a, b) { + return a === b; + }, + similar: function (a, b) { + return a == b; + } + }; + compareMethods.eqeq = compareMethods.similar; + return can.Object; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/object/isplain.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/object/isplain.js new file mode 100644 index 0000000000..f949a00ee8 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/object/isplain.js @@ -0,0 +1,31 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/object/isplain/isplain*/ +define(['can/util/can'], function () { + var core_hasOwn = Object.prototype.hasOwnProperty, isWindow = function (obj) { + return obj !== null && obj == obj.window; + }, isPlainObject = function (obj) { + if (!obj || typeof obj !== 'object' || obj.nodeType || isWindow(obj)) { + return false; + } + try { + if (obj.constructor && !core_hasOwn.call(obj, 'constructor') && !core_hasOwn.call(obj.constructor.prototype, 'isPrototypeOf')) { + return false; + } + } catch (e) { + return false; + } + var key; + for (key in obj) { + } + return key === undefined || core_hasOwn.call(obj, key); + }; + can.isPlainObject = isPlainObject; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/string.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/string.js new file mode 100644 index 0000000000..d9fd21bb17 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/string.js @@ -0,0 +1,93 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/string/string*/ +define(['can/util/library'], function (can) { + var strUndHash = /_|-/, strColons = /\=\=/, strWords = /([A-Z]+)([A-Z][a-z])/g, strLowUp = /([a-z\d])([A-Z])/g, strDash = /([a-z\d])([A-Z])/g, strReplacer = /\{([^\}]+)\}/g, strQuote = /"/g, strSingleQuote = /'/g, strHyphenMatch = /-+(.)?/g, strCamelMatch = /[a-z][A-Z]/g, getNext = function (obj, prop, add) { + var result = obj[prop]; + if (result === undefined && add === true) { + result = obj[prop] = {}; + } + return result; + }, isContainer = function (current) { + return /^f|^o/.test(typeof current); + }, convertBadValues = function (content) { + var isInvalid = content === null || content === undefined || isNaN(content) && '' + content === 'NaN'; + return '' + (isInvalid ? '' : content); + }; + can.extend(can, { + esc: function (content) { + return convertBadValues(content).replace(/&/g, '&').replace(//g, '>').replace(strQuote, '"').replace(strSingleQuote, '''); + }, + getObject: function (name, roots, add) { + var parts = name ? name.split('.') : [], length = parts.length, current, r = 0, i, container, rootsLength; + roots = can.isArray(roots) ? roots : [roots || window]; + rootsLength = roots.length; + if (!length) { + return roots[0]; + } + for (r; r < rootsLength; r++) { + current = roots[r]; + container = undefined; + for (i = 0; i < length && isContainer(current); i++) { + container = current; + current = getNext(container, parts[i]); + } + if (container !== undefined && current !== undefined) { + break; + } + } + if (add === false && current !== undefined) { + delete container[parts[i - 1]]; + } + if (add === true && current === undefined) { + current = roots[0]; + for (i = 0; i < length && isContainer(current); i++) { + current = getNext(current, parts[i], true); + } + } + return current; + }, + capitalize: function (s, cache) { + return s.charAt(0).toUpperCase() + s.slice(1); + }, + camelize: function (str) { + return convertBadValues(str).replace(strHyphenMatch, function (match, chr) { + return chr ? chr.toUpperCase() : ''; + }); + }, + hyphenate: function (str) { + return convertBadValues(str).replace(strCamelMatch, function (str, offset) { + return str.charAt(0) + '-' + str.charAt(1).toLowerCase(); + }); + }, + underscore: function (s) { + return s.replace(strColons, '/').replace(strWords, '$1_$2').replace(strLowUp, '$1_$2').replace(strDash, '_').toLowerCase(); + }, + sub: function (str, data, remove) { + var obs = []; + str = str || ''; + obs.push(str.replace(strReplacer, function (whole, inside) { + var ob = can.getObject(inside, data, remove === true ? false : undefined); + if (ob === undefined || ob === null) { + obs = null; + return ''; + } + if (isContainer(ob) && obs) { + obs.push(ob); + return ''; + } + return '' + ob; + })); + return obs === null ? obs : obs.length <= 1 ? obs[0] : obs; + }, + replacer: strReplacer, + undHash: strUndHash + }); + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/string/deparam.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/string/deparam.js new file mode 100644 index 0000000000..b38284a65a --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/string/deparam.js @@ -0,0 +1,45 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/string/deparam/deparam*/ +define([ + 'can/util/library', + 'can/util/string' +], function (can) { + var digitTest = /^\d+$/, keyBreaker = /([^\[\]]+)|(\[\])/g, paramTest = /([^?#]*)(#.*)?$/, prep = function (str) { + return decodeURIComponent(str.replace(/\+/g, ' ')); + }; + can.extend(can, { + deparam: function (params) { + var data = {}, pairs, lastPart; + if (params && paramTest.test(params)) { + pairs = params.split('&'); + can.each(pairs, function (pair) { + var parts = pair.split('='), key = prep(parts.shift()), value = prep(parts.join('=')), current = data; + if (key) { + parts = key.match(keyBreaker); + for (var j = 0, l = parts.length - 1; j < l; j++) { + if (!current[parts[j]]) { + current[parts[j]] = digitTest.test(parts[j + 1]) || parts[j + 1] === '[]' ? [] : {}; + } + current = current[parts[j]]; + } + lastPart = parts.pop(); + if (lastPart === '[]') { + current.push(value); + } else { + current[lastPart] = value; + } + } + }); + } + return data; + } + }); + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/tests.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/tests.js new file mode 100644 index 0000000000..9574e66fb3 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/tests.js @@ -0,0 +1,15 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/tests/tests*/ +define([ + 'can/util/string', + 'can/util/inserted', + 'can/util/attr', + 'can/util/each' +]); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/yui.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/yui.js new file mode 100644 index 0000000000..e3afd253e6 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/yui.js @@ -0,0 +1,413 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/yui/yui*/ +define([ + 'can/util/can', + 'can/util/attr', + 'yui', + 'can/event', + 'can/fragment', + 'can/util/each', + 'can/util/object/isplain', + 'can/deferred', + 'can/hashchange', + 'can/util/inserted' +], function (can, attr, YUI) { + YUI = YUI || window.YUI; + YUI.add('can-modifications', function (Y, NAME) { + var addHTML = Y.DOM.addHTML; + Y.DOM.addHTML = function (node, content, where) { + if (typeof content === 'string' || typeof content === 'number') { + content = can.buildFragment(content); + } + var elems; + if (content.nodeType === 11) { + elems = can.makeArray(content.childNodes); + } else { + elems = [content]; + } + var ret = addHTML.call(this, node, content, where); + can.inserted(elems); + return ret; + }; + var oldOn = Y.Node.prototype.on; + Y.Node.prototype.on = function (type, fn) { + if (type === 'attributes') { + var el = can.$(this); + can.data(el, 'canHasAttributesBindings', (can.data(el, 'canHasAttributesBindings') || 0) + 1); + var handle = oldOn.apply(this, arguments), oldDetach = handle.detach; + handle.detach = function () { + var cur = can.data(el, 'canHasAttributesBindings') || 0; + if (cur <= 0) { + can.cleanData(el, 'canHasAttributesBindings'); + } else { + can.data(el, 'canHasAttributesBindings', cur - 1); + } + return oldDetach.apply(this, arguments); + }; + return handle; + } else { + return oldOn.apply(this, arguments); + } + }; + }, '3.7.3', { 'requires': ['node-base'] }); + var Y = can.Y = can.Y || YUI().use('*'); + can.trim = function (s) { + return Y.Lang.trim(s); + }; + can.makeArray = function (arr) { + if (!arr) { + return []; + } + return Y.Array(arr); + }; + can.isArray = Y.Lang.isArray; + can.inArray = function (item, arr, fromIndex) { + if (!arr) { + return -1; + } + return Y.Array.indexOf(arr, item, fromIndex); + }; + can.map = function (arr, fn) { + return Y.Array.map(can.makeArray(arr || []), fn); + }; + can.extend = function (first) { + var deep = first === true ? 1 : 0, target = arguments[deep], i = deep + 1, arg; + for (; arg = arguments[i]; i++) { + Y.mix(target, arg, true, null, null, !!deep); + } + return target; + }; + can.param = function (object) { + return Y.QueryString.stringify(object, { arrayKey: true }); + }; + can.isEmptyObject = function (object) { + return Y.Object.isEmpty(object); + }; + can.proxy = function (func, context) { + return Y.bind.apply(Y, arguments); + }; + can.isFunction = function (f) { + return Y.Lang.isFunction(f); + }; + var prepareNodeList = function (nodelist) { + nodelist.each(function (node, i) { + nodelist[i] = node.getDOMNode(); + }); + nodelist.length = nodelist.size(); + return nodelist; + }; + can.$ = function (selector) { + if (selector === window) { + return window; + } else if (selector instanceof Y.NodeList) { + return prepareNodeList(selector); + } else if (typeof selector === 'object' && !can.isArray(selector) && typeof selector.nodeType === 'undefined' && !selector.getDOMNode) { + return new Y.NodeList(selector); + } else { + return prepareNodeList(Y.all(selector)); + } + }; + can.get = function (wrapped, index) { + return wrapped._nodes[index]; + }; + can.append = function (wrapped, html) { + wrapped.each(function (node) { + if (typeof html === 'string') { + html = can.buildFragment(html, node); + } + node.append(html); + }); + }; + can.addClass = function (wrapped, className) { + return wrapped.addClass(className); + }; + can.data = function (wrapped, key, value) { + if (!wrapped.item(0)) { + return; + } + if (value === undefined) { + return wrapped.item(0).getData(key); + } else { + return wrapped.item(0).setData(key, value); + } + }; + can.remove = function (wrapped) { + return wrapped.remove() && wrapped.destroy(); + }; + can.has = function (wrapped, node) { + if (Y.DOM.contains(wrapped[0], node)) { + return wrapped; + } else { + return []; + } + }; + can._yNodeRemove = can._yNodeRemove || Y.Node.prototype.remove; + Y.Node.prototype.remove = function () { + var node = this.getDOMNode(); + if (node.nodeType === 1) { + can.trigger(this, 'removed', [], false); + var elems = node.getElementsByTagName('*'); + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + can.trigger(elem, 'removed', [], false); + } + } + can._yNodeRemove.apply(this, arguments); + }; + Y.NodeList.addMethod('remove', Y.Node.prototype.remove); + var optionsMap = { + type: 'method', + success: undefined, + error: undefined + }; + var updateDeferred = function (request, d) { + if (request && request.io) { + var xhr = request.io; + for (var prop in xhr) { + if (typeof d[prop] === 'function') { + d[prop] = function () { + xhr[prop].apply(xhr, arguments); + }; + } else { + d[prop] = prop[xhr]; + } + } + } + }; + can.ajax = function (options) { + var d = can.Deferred(), requestOptions = can.extend({}, options); + for (var option in optionsMap) { + if (requestOptions[option] !== undefined) { + requestOptions[optionsMap[option]] = requestOptions[option]; + delete requestOptions[option]; + } + } + requestOptions.sync = !options.async; + var success = options.success, error = options.error; + requestOptions.on = { + success: function (transactionid, response) { + var data = response.responseText; + if (options.dataType === 'json') { + data = eval('(' + data + ')'); + } + updateDeferred(request, d); + d.resolve(data); + if (success) { + success(data, 'success', request); + } + }, + failure: function (transactionid, response) { + updateDeferred(request, d); + d.reject(request, 'error'); + if (error) { + error(request, 'error'); + } + } + }; + var request = Y.io(requestOptions.url, requestOptions); + updateDeferred(request, d); + return d; + }; + var yuiEventId = 0, addBinding = function (nodelist, selector, ev, cb) { + if (nodelist instanceof Y.NodeList || !nodelist.on || nodelist.getDOMNode) { + nodelist.each(function (node) { + node = can.$(node); + var events = can.data(node, 'events'), eventName = ev + ':' + selector; + if (!events) { + can.data(node, 'events', events = {}); + } + if (!events[eventName]) { + events[eventName] = {}; + } + if (cb.__bindingsIds === undefined) { + cb.__bindingsIds = yuiEventId++; + } + events[eventName][cb.__bindingsIds] = selector ? node.item(0).delegate(ev, cb, selector) : node.item(0).on(ev, cb); + }); + } else { + var obj = nodelist, events = obj.__canEvents = obj.__canEvents || {}; + if (!events[ev]) { + events[ev] = {}; + } + if (cb.__bindingsIds === undefined) { + cb.__bindingsIds = yuiEventId++; + } + events[ev][cb.__bindingsIds] = obj.on(ev, cb); + } + }, removeBinding = function (nodelist, selector, ev, cb) { + if (nodelist instanceof Y.NodeList || !nodelist.on || nodelist.getDOMNode) { + nodelist.each(function (node) { + node = can.$(node); + var events = can.data(node, 'events'); + if (events) { + var eventName = ev + ':' + selector, handlers = events[eventName], handler = handlers[cb.__bindingsIds]; + handler.detach(); + delete handlers[cb.__bindingsIds]; + if (can.isEmptyObject(handlers)) { + delete events[ev]; + } + if (can.isEmptyObject(events)) { + } + } + }); + } else { + var obj = nodelist, events = obj.__canEvents || {}, handlers = events[ev], handler = handlers[cb.__bindingsIds]; + handler.detach(); + delete handlers[cb.__bindingsIds]; + if (can.isEmptyObject(handlers)) { + delete events[ev]; + } + if (can.isEmptyObject(events)) { + } + } + }; + can.bind = function (ev, cb) { + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (this.on || this.nodeType) { + addBinding(can.$(this), undefined, ev, cb); + } else if (this.addEvent) { + this.addEvent(ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + return this; + }; + can.unbind = function (ev, cb) { + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (this.on || this.nodeType) { + removeBinding(can.$(this), undefined, ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + return this; + }; + can.on = can.bind; + can.off = can.unbind; + can.trigger = function (item, event, args, bubble) { + if (item instanceof Y.NodeList) { + item = item.item(0); + } + if (item.getDOMNode) { + item = item.getDOMNode(); + } + if (item.nodeName) { + item = Y.Node(item); + if (bubble === false) { + item.once(event, function (ev) { + if (ev.stopPropagation) { + ev.stopPropagation(); + } + ev.cancelBubble = true; + if (ev._stopper) { + ev._stopper(); + } + }); + } + if (typeof event !== 'string') { + args = event; + event = args.type; + delete args.type; + } + realTrigger(item.getDOMNode(), event, args || {}); + } else { + if (typeof event === 'string') { + event = { type: event }; + } + event.target = event.target || item; + can.dispatch.call(item, event, can.makeArray(args)); + } + }; + Y.mix(Y.Node.DOM_EVENTS, { + removed: true, + inserted: true, + attributes: true, + foo: true + }); + Y.Env.evt.plugins.attributes = { + on: function () { + var args = can.makeArray(arguments); + return Y.Event._attach(args, { facade: false }); + } + }; + can.delegate = function (selector, ev, cb) { + if (this.on || this.nodeType) { + addBinding(can.$(this), selector, ev, cb); + } else if (this.delegate) { + this.delegate(selector, ev, cb); + } else { + can.bind.call(this, ev, cb); + } + return this; + }; + can.undelegate = function (selector, ev, cb) { + if (this.on || this.nodeType) { + removeBinding(can.$(this), selector, ev, cb); + } else if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else { + can.unbind.call(this, ev, cb); + } + return this; + }; + var realTrigger, realTriggerHandler = function (n, e, evdata) { + var node = Y.Node(n), handlers = can.Y.Event.getListeners(node._yuid, e), i; + if (handlers) { + for (i = 0; i < handlers.length; i++) { + if (handlers[i].fire) { + handlers[i].fire(evdata); + } else if (handlers[i].handles) { + can.each(handlers[i].handles, function (handle) { + handle.evt.fire(evdata); + }); + } else { + throw 'can not fire event'; + } + } + } + }, fakeTrigger = function (n, e, a) { + var stop = false; + var evdata = can.extend({ + type: e, + target: n, + faux: true, + _stopper: function () { + stop = this.cancelBubble; + }, + stopPropagation: function () { + stop = this.cancelBubble; + }, + preventDefault: function () { + } + }, a); + realTriggerHandler(n, e, evdata); + if (e === 'inserted' || e === 'removed') { + return; + } + while (!stop && n !== document && n.parentNode) { + n = n.parentNode; + realTriggerHandler(n, e, evdata); + } + }; + if (document.createEvent) { + realTrigger = function (n, e, a) { + fakeTrigger(n, e, a); + return; + }; + } else { + realTrigger = function (n, e, a) { + fakeTrigger(n, e, a); + return; + }; + } + can.attr = attr; + delete attr.MutationObserver; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/zepto.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/zepto.js new file mode 100644 index 0000000000..c4257fcf05 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/util/zepto.js @@ -0,0 +1,306 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/zepto/zepto*/ +define([ + 'can/util/can', + 'can/util/attr', + 'can/event', + 'zepto', + 'can/util/object/isplain', + 'can/fragment', + 'can/deferred', + 'can/util/each', + 'can/util/inserted' +], function (can, attr, event) { + var $ = Zepto; + var data = {}, dataAttr = $.fn.data, uuid = $.uuid = +new Date(), exp = $.expando = 'Zepto' + uuid; + function getData(node, name) { + var id = node[exp], store = id && data[id]; + return name === undefined ? store || setData(node) : store && store[name] || dataAttr.call($(node), name); + } + function setData(node, name, value) { + var id = node[exp] || (node[exp] = ++uuid), store = data[id] || (data[id] = {}); + if (name !== undefined) { + store[name] = value; + } + return store; + } + $.fn.data = function (name, value) { + return value === undefined ? this.length === 0 ? undefined : getData(this[0], name) : this.each(function (idx) { + setData(this, name, $.isFunction(value) ? value.call(this, idx, getData(this, name)) : value); + }); + }; + $.cleanData = function (elems) { + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + can.trigger(elem, 'removed', [], false); + } + for (i = 0; (elem = elems[i]) !== undefined; i++) { + var id = elem[exp]; + delete data[id]; + } + }; + var oldEach = can.each; + var oldPlain = can.isPlainObject; + $.extend(can, Zepto); + can.inArray = function (el, arr) { + return !arr ? -1 : $.inArray.apply($, arguments); + }; + can.isPlainObject = oldPlain; + can.each = oldEach; + can.attr = attr; + can.event = event; + var arrHas = function (obj, name) { + return obj[0] && obj[0][name] || obj[name]; + }; + can.trigger = function (obj, event, args, bubble) { + if (obj.trigger) { + obj.trigger(event, args); + } else if (arrHas(obj, 'dispatchEvent')) { + if (bubble === false) { + $([obj]).triggerHandler(event, args); + } else { + $([obj]).trigger(event, args); + } + } else { + if (typeof event === 'string') { + event = { type: event }; + } + event.target = event.target || obj; + can.dispatch.call(obj, event, can.makeArray(args)); + } + }; + can.$ = Zepto; + can.bind = function (ev, cb) { + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (arrHas(this, 'addEventListener')) { + $([this]).bind(ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + return this; + }; + can.unbind = function (ev, cb) { + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (arrHas(this, 'addEventListener')) { + $([this]).unbind(ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + return this; + }; + can.on = can.bind; + can.off = can.unbind; + can.delegate = function (selector, ev, cb) { + if (!selector) { + can.bind.call(this, ev, cb); + } else if (this.delegate) { + this.delegate(selector, ev, cb); + } else if (arrHas(this, 'addEventListener')) { + $([this]).delegate(selector, ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + }; + can.undelegate = function (selector, ev, cb) { + if (!selector) { + can.unbind.call(this, ev, cb); + } else if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else if (arrHas(this, 'addEventListener')) { + $([this]).undelegate(selector, ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + }; + $.each([ + 'append', + 'filter', + 'addClass', + 'remove', + 'data', + 'has' + ], function (i, name) { + can[name] = function (wrapped) { + return wrapped[name].apply(wrapped, can.makeArray(arguments).slice(1)); + }; + }); + can.makeArray = function (arr) { + var ret = []; + if (arr == null) { + return []; + } + if (arr.length === undefined || typeof arr === 'string') { + return [arr]; + } + can.each(arr, function (a, i) { + ret[i] = a; + }); + return ret; + }; + var XHR = $.ajaxSettings.xhr; + $.ajaxSettings.xhr = function () { + var xhr = XHR(); + var open = xhr.open; + xhr.open = function (type, url, async) { + open.call(this, type, url, ASYNC === undefined ? true : ASYNC); + }; + return xhr; + }; + var ASYNC; + var AJAX = $.ajax; + var updateDeferred = function (xhr, d) { + for (var prop in xhr) { + if (typeof d[prop] === 'function') { + d[prop] = function () { + xhr[prop].apply(xhr, arguments); + }; + } else { + d[prop] = prop[xhr]; + } + } + }; + can.ajax = function (options) { + var success = options.success, error = options.error; + var d = can.Deferred(); + options.success = function (data) { + updateDeferred(xhr, d); + d.resolve.call(d, data); + if (success) { + success.apply(this, arguments); + } + }; + options.error = function () { + updateDeferred(xhr, d); + d.reject.apply(d, arguments); + if (error) { + error.apply(this, arguments); + } + }; + if (options.async === false) { + ASYNC = false; + } + var xhr = AJAX(options); + ASYNC = undefined; + updateDeferred(xhr, d); + return d; + }; + var $_empty = $.fn.empty; + $.fn.empty = function () { + this.each(function () { + $.cleanData(this.getElementsByTagName('*')); + this.innerHTML = ''; + }); + return $_empty.call(this); + }; + var $_remove = $.fn.remove; + $.fn.remove = function () { + this.each(function () { + if (this.getElementsByTagName) { + $.cleanData([this].concat(can.makeArray(this.getElementsByTagName('*')))); + } + }); + return $_remove.call(this); + }; + can.trim = function (str) { + return str.trim(); + }; + can.isEmptyObject = function (object) { + var name; + for (name in object) { + } + return name === undefined; + }; + can.extend = function (first) { + if (first === true) { + var args = can.makeArray(arguments); + args.shift(); + return $.extend.apply($, args); + } + return $.extend.apply($, arguments); + }; + can.get = function (wrapped, index) { + return wrapped[index]; + }; + can.each([ + 'after', + 'prepend', + 'before', + 'append' + ], function (name) { + var original = Zepto.fn[name]; + Zepto.fn[name] = function () { + var elems, args = can.makeArray(arguments); + if (args[0] != null) { + if (typeof args[0] === 'string') { + args[0] = $.zepto.fragment(args[0]); + } + if (args[0].nodeType === 11) { + elems = can.makeArray(args[0].childNodes); + } else if (args[0] instanceof Zepto.fn.constructor) { + elems = can.makeArray(args[0]); + } else { + elems = [args[0]]; + } + } + var ret = original.apply(this, args); + can.inserted(elems); + return ret; + }; + }); + delete attr.MutationObserver; + var oldAttr = $.fn.attr; + $.fn.attr = function (attrName, value) { + var isString = typeof attrName === 'string', oldValue, newValue; + if (value !== undefined && isString) { + oldValue = oldAttr.call(this, attrName); + } + var res = oldAttr.apply(this, arguments); + if (value !== undefined && isString) { + newValue = oldAttr.call(this, attrName); + } + if (newValue !== oldValue) { + can.attr.trigger(this[0], attrName, oldValue); + } + return res; + }; + var oldRemove = $.fn.removeAttr; + $.fn.removeAttr = function (attrName) { + var oldValue = oldAttr.call(this, attrName), res = oldRemove.apply(this, arguments); + if (oldValue != null) { + can.attr.trigger(this[0], attrName, oldValue); + } + return res; + }; + var oldBind = $.fn.bind, oldUnbind = $.fn.unbind; + $.fn.bind = function (event) { + if (event === 'attributes') { + this.each(function () { + var el = can.$(this); + can.data(el, 'canHasAttributesBindings', (can.data(el, 'canHasAttributesBindings') || 0) + 1); + }); + } + return oldBind.apply(this, arguments); + }; + $.fn.unbind = function (event) { + if (event === 'attributes') { + this.each(function () { + var el = can.$(this), cur = can.data(el, 'canHasAttributesBindings') || 0; + if (cur <= 0) { + can.data(el, 'canHasAttributesBindings', 0); + } else { + can.data(el, 'canHasAttributesBindings', cur - 1); + } + }); + } + return oldUnbind.apply(this, arguments); + }; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view.js new file mode 100644 index 0000000000..e8725ef868 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view.js @@ -0,0 +1,282 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/view*/ +define(['can/util/library'], function (can) { + var isFunction = can.isFunction, makeArray = can.makeArray, hookupId = 1; + var makeRenderer = function (textRenderer) { + var renderer = function () { + return $view.frag(textRenderer.apply(this, arguments)); + }; + renderer.render = function () { + return textRenderer.apply(textRenderer, arguments); + }; + return renderer; + }; + var checkText = function (text, url) { + if (!text.length) { + throw 'can.view: No template or empty template:' + url; + } + }; + var getRenderer = function (obj, async) { + if (isFunction(obj)) { + var def = can.Deferred(); + return def.resolve(obj); + } + var url = typeof obj === 'string' ? obj : obj.url, suffix = obj.engine && '.' + obj.engine || url.match(/\.[\w\d]+$/), type, el, id; + if (url.match(/^#/)) { + url = url.substr(1); + } + if (el = document.getElementById(url)) { + suffix = '.' + el.type.match(/\/(x\-)?(.+)/)[2]; + } + if (!suffix && !$view.cached[url]) { + url += suffix = $view.ext; + } + if (can.isArray(suffix)) { + suffix = suffix[0]; + } + id = $view.toId(url); + if (url.match(/^\/\//)) { + url = url.substr(2); + url = !window.steal ? url : steal.config().root.mapJoin('' + steal.id(url)); + } + if (window.require) { + if (require.toUrl) { + url = require.toUrl(url); + } + } + type = $view.types[suffix]; + if ($view.cached[id]) { + return $view.cached[id]; + } else if (el) { + return $view.registerView(id, el.innerHTML, type); + } else { + var d = new can.Deferred(); + can.ajax({ + async: async, + url: url, + dataType: 'text', + error: function (jqXHR) { + checkText('', url); + d.reject(jqXHR); + }, + success: function (text) { + checkText(text, url); + $view.registerView(id, text, type, d); + } + }); + return d; + } + }; + var getDeferreds = function (data) { + var deferreds = []; + if (can.isDeferred(data)) { + return [data]; + } else { + for (var prop in data) { + if (can.isDeferred(data[prop])) { + deferreds.push(data[prop]); + } + } + } + return deferreds; + }; + var usefulPart = function (resolved) { + return can.isArray(resolved) && resolved[1] === 'success' ? resolved[0] : resolved; + }; + var $view = can.view = can.template = function (view, data, helpers, callback) { + if (isFunction(helpers)) { + callback = helpers; + helpers = undefined; + } + return $view.renderAs('fragment', view, data, helpers, callback); + }; + can.extend($view, { + frag: function (result, parentNode) { + return $view.hookup($view.fragment(result), parentNode); + }, + fragment: function (result) { + if (typeof result !== 'string' && result.nodeType === 11) { + return result; + } + var frag = can.buildFragment(result, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + }, + toId: function (src) { + return can.map(src.toString().split(/\/|\./g), function (part) { + if (part) { + return part; + } + }).join('_'); + }, + toStr: function (txt) { + return txt == null ? '' : '' + txt; + }, + hookup: function (fragment, parentNode) { + var hookupEls = [], id, func; + can.each(fragment.childNodes ? can.makeArray(fragment.childNodes) : fragment, function (node) { + if (node.nodeType === 1) { + hookupEls.push(node); + hookupEls.push.apply(hookupEls, can.makeArray(node.getElementsByTagName('*'))); + } + }); + can.each(hookupEls, function (el) { + if (el.getAttribute && (id = el.getAttribute('data-view-id')) && (func = $view.hookups[id])) { + func(el, parentNode, id); + delete $view.hookups[id]; + el.removeAttribute('data-view-id'); + } + }); + return fragment; + }, + hookups: {}, + hook: function (cb) { + $view.hookups[++hookupId] = cb; + return ' data-view-id=\'' + hookupId + '\''; + }, + cached: {}, + cachedRenderers: {}, + cache: true, + register: function (info) { + this.types['.' + info.suffix] = info; + can[info.suffix] = $view[info.suffix] = function (id, text) { + var renderer, renderFunc; + if (!text) { + renderFunc = function () { + if (!renderer) { + if (info.fragRenderer) { + renderer = info.fragRenderer(null, id); + } else { + renderer = makeRenderer(info.renderer(null, id)); + } + } + return renderer.apply(this, arguments); + }; + renderFunc.render = function () { + var textRenderer = info.renderer(null, id); + return textRenderer.apply(textRenderer, arguments); + }; + return renderFunc; + } + var registeredRenderer = function () { + if (!renderer) { + if (info.fragRenderer) { + renderer = info.fragRenderer(id, text); + } else { + renderer = info.renderer(id, text); + } + } + return renderer.apply(this, arguments); + }; + if (info.fragRenderer) { + return $view.preload(id, registeredRenderer); + } else { + return $view.preloadStringRenderer(id, registeredRenderer); + } + }; + }, + types: {}, + ext: '.ejs', + registerScript: function (type, id, src) { + return 'can.view.preloadStringRenderer(\'' + id + '\',' + $view.types['.' + type].script(id, src) + ');'; + }, + preload: function (id, renderer) { + var def = $view.cached[id] = new can.Deferred().resolve(function (data, helpers) { + return renderer.call(data, data, helpers); + }); + def.__view_id = id; + $view.cachedRenderers[id] = renderer; + return renderer; + }, + preloadStringRenderer: function (id, stringRenderer) { + return this.preload(id, makeRenderer(stringRenderer)); + }, + render: function (view, data, helpers, callback) { + return can.view.renderAs('string', view, data, helpers, callback); + }, + renderTo: function (format, renderer, data, helpers) { + return (format === 'string' && renderer.render ? renderer.render : renderer)(data, helpers); + }, + renderAs: function (format, view, data, helpers, callback) { + if (isFunction(helpers)) { + callback = helpers; + helpers = undefined; + } + var deferreds = getDeferreds(data); + var reading, deferred, dataCopy, async, response; + if (deferreds.length) { + deferred = new can.Deferred(); + dataCopy = can.extend({}, data); + deferreds.push(getRenderer(view, true)); + can.when.apply(can, deferreds).then(function (resolved) { + var objs = makeArray(arguments), renderer = objs.pop(), result; + if (can.isDeferred(data)) { + dataCopy = usefulPart(resolved); + } else { + for (var prop in data) { + if (can.isDeferred(data[prop])) { + dataCopy[prop] = usefulPart(objs.shift()); + } + } + } + result = can.view.renderTo(format, renderer, dataCopy, helpers); + deferred.resolve(result, dataCopy); + if (callback) { + callback(result, dataCopy); + } + }, function () { + deferred.reject.apply(deferred, arguments); + }); + return deferred; + } else { + reading = can.__clearReading(); + async = isFunction(callback); + deferred = getRenderer(view, async); + if (reading) { + can.__setReading(reading); + } + if (async) { + response = deferred; + deferred.then(function (renderer) { + callback(data ? can.view.renderTo(format, renderer, data, helpers) : renderer); + }); + } else { + if (deferred.state() === 'resolved' && deferred.__view_id) { + var currentRenderer = $view.cachedRenderers[deferred.__view_id]; + return data ? can.view.renderTo(format, currentRenderer, data, helpers) : currentRenderer; + } else { + deferred.then(function (renderer) { + response = data ? can.view.renderTo(format, renderer, data, helpers) : renderer; + }); + } + } + return response; + } + }, + registerView: function (id, text, type, def) { + var info = typeof type === 'object' ? type : $view.types[type || $view.ext], renderer; + if (info.fragRenderer) { + renderer = info.fragRenderer(id, text); + } else { + renderer = makeRenderer(info.renderer(id, text)); + } + def = def || new can.Deferred(); + if ($view.cache) { + $view.cached[id] = def; + def.__view_id = id; + $view.cachedRenderers[id] = renderer; + } + return def.resolve(renderer); + } + }); + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/autorender.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/autorender.js new file mode 100644 index 0000000000..a1e7a9b21d --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/autorender.js @@ -0,0 +1,88 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/autorender/autorender*/ +'format steal'; +define(['can/util/library'], function (can) { + var deferred = new can.Deferred(), ignoreAttributesRegExp = /^(dataViewId|class|id|type|src)$/i; + var typeMatch = /\s*text\/(mustache|stache|ejs)\s*/; + function isIn(element, type) { + while (element.parentNode) { + element = element.parentNode; + if (element.nodeName.toLowerCase() === type.toLowerCase()) { + return true; + } + } + } + function setAttr(el, attr, scope) { + var camelized = can.camelize(attr); + if (!ignoreAttributesRegExp.test(camelized)) { + scope.attr(camelized, el.getAttribute(attr)); + } + } + function insertAfter(ref, element) { + if (ref.nextSibling) { + can.insertBefore(ref.parentNode, element, ref.nextSibling); + } else { + can.appendChild(ref.parentNode, element); + } + } + function render(renderer, scope, el) { + var frag = renderer(scope); + if (isIn(el, 'head')) { + can.appendChild(document.body, frag); + } else if (el.nodeName.toLowerCase() === 'script') { + insertAfter(el, frag); + } else { + insertAfter(el, frag); + el.parentNode.removeChild(el); + } + } + function setupScope(el) { + var scope = can.viewModel(el); + can.each(el.attributes || [], function (attr) { + setAttr(el, attr.name, scope); + }); + can.bind.call(el, 'attributes', function (ev) { + setAttr(el, ev.attributeName, scope); + }); + return scope; + } + function autoload() { + var promises = []; + can.each(can.$('[can-autorender]'), function (el, i) { + el.style.display = 'none'; + var text = el.innerHTML || el.text, typeAttr = el.getAttribute('type'), typeInfo = typeAttr.match(typeMatch), type = typeInfo && typeInfo[1], typeModule = 'can/view/' + type; + if (window.System || !(window.define && window.define.amd)) { + typeModule += '/' + type; + } + promises.push(can['import'](typeModule).then(function (engine) { + engine = can[type] || engine; + if (engine.async) { + return engine.async(text).then(function (renderer) { + render(renderer, setupScope(el), el); + }); + } else { + var renderer = engine(text); + render(renderer, setupScope(el), el); + } + })); + }); + can.when.apply(can, promises).then(can.proxy(deferred.resolve, deferred), can.proxy(deferred.reject, deferred)); + } + if (document.readyState === 'complete') { + autoload(); + } else { + can.bind.call(window, 'load', autoload); + } + var promise = deferred.promise(); + can.autorender = function (success, error) { + return promise.then(success, error); + }; + return can.autorender; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/bindings.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/bindings.js new file mode 100644 index 0000000000..726f324fbe --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/bindings.js @@ -0,0 +1,259 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/bindings/bindings*/ +define([ + 'can/util/library', + 'can/view/mustache_core', + 'can/view/callbacks', + 'can/control', + 'can/view/scope' +], function (can, mustacheCore) { + var isContentEditable = function () { + var values = { + '': true, + 'true': true, + 'false': false + }; + var editable = function (el) { + if (!el || !el.getAttribute) { + return; + } + var attr = el.getAttribute('contenteditable'); + return values[attr]; + }; + return function (el) { + var val = editable(el); + if (typeof val === 'boolean') { + return val; + } else { + return !!editable(el.parentNode); + } + }; + }(), removeCurly = function (value) { + if (value[0] === '{' && value[value.length - 1] === '}') { + return value.substr(1, value.length - 2); + } + return value; + }; + can.view.attr('can-value', function (el, data) { + var attr = can.trim(removeCurly(el.getAttribute('can-value'))), value = data.scope.computeData(attr, { args: [] }).compute, trueValue, falseValue; + if (el.nodeName.toLowerCase() === 'input') { + if (el.type === 'checkbox') { + if (can.attr.has(el, 'can-true-value')) { + trueValue = el.getAttribute('can-true-value'); + } else { + trueValue = true; + } + if (can.attr.has(el, 'can-false-value')) { + falseValue = el.getAttribute('can-false-value'); + } else { + falseValue = false; + } + } + if (el.type === 'checkbox' || el.type === 'radio') { + new Checked(el, { + value: value, + trueValue: trueValue, + falseValue: falseValue + }); + return; + } + } + if (el.nodeName.toLowerCase() === 'select' && el.multiple) { + new Multiselect(el, { value: value }); + return; + } + if (isContentEditable(el)) { + new Content(el, { value: value }); + return; + } + new Value(el, { value: value }); + }); + var special = { + enter: function (data, el, original) { + return { + event: 'keyup', + handler: function (ev) { + if (ev.keyCode === 13) { + return original.call(this, ev); + } + } + }; + } + }; + can.view.attr(/can-[\w\.]+/, function (el, data) { + var attributeName = data.attributeName, event = attributeName.substr('can-'.length), handler = function (ev) { + var attrVal = el.getAttribute(attributeName); + if (!attrVal) { + return; + } + var attrInfo = mustacheCore.expressionData(removeCurly(attrVal)); + var scopeData = data.scope.read(attrInfo.name.get, { + returnObserveMethods: true, + isArgument: true, + executeAnonymousFunctions: true + }); + var args = []; + var $el = can.$(this); + var viewModel = can.viewModel($el[0]); + var localScope = data.scope.add({ + '@element': $el, + '@event': ev, + '@viewModel': viewModel, + '@scope': data.scope, + '@context': data.scope._context + }); + if (!can.isEmptyObject(attrInfo.hash)) { + var hash = {}; + can.each(attrInfo.hash, function (val, key) { + if (val && val.hasOwnProperty('get')) { + var s = !val.get.indexOf('@') ? localScope : data.scope; + hash[key] = s.read(val.get, {}).value; + } else { + hash[key] = val; + } + }); + args.unshift(hash); + } + if (attrInfo.args.length) { + var arg; + for (var i = attrInfo.args.length - 1; i >= 0; i--) { + arg = attrInfo.args[i]; + if (arg && arg.hasOwnProperty('get')) { + var s = !arg.get.indexOf('@') ? localScope : data.scope; + args.unshift(s.read(arg.get, {}).value); + } else { + args.unshift(arg); + } + } + } + if (!args.length) { + args = [ + data.scope._context, + $el + ].concat(can.makeArray(arguments)); + } + return scopeData.value.apply(scopeData.parent, args); + }; + if (special[event]) { + var specialData = special[event](data, el, handler); + handler = specialData.handler; + event = specialData.event; + } + can.bind.call(el, event, handler); + }); + var Value = can.Control.extend({ + init: function () { + if (this.element[0].nodeName.toUpperCase() === 'SELECT') { + setTimeout(can.proxy(this.set, this), 1); + } else { + this.set(); + } + }, + '{value} change': 'set', + set: function () { + if (!this.element) { + return; + } + var val = this.options.value(); + this.element[0].value = val == null ? '' : val; + }, + 'change': function () { + if (!this.element) { + return; + } + var el = this.element[0]; + this.options.value(el.value); + var newVal = this.options.value(); + if (el.value !== newVal) { + el.value = newVal; + } + } + }), Checked = can.Control.extend({ + init: function () { + this.isCheckbox = this.element[0].type.toLowerCase() === 'checkbox'; + this.check(); + }, + '{value} change': 'check', + check: function () { + if (this.isCheckbox) { + var value = this.options.value(), trueValue = this.options.trueValue || true; + this.element[0].checked = value == trueValue; + } else { + var setOrRemove = this.options.value() == this.element[0].value ? 'set' : 'remove'; + can.attr[setOrRemove](this.element[0], 'checked', true); + } + }, + 'change': function () { + if (this.isCheckbox) { + this.options.value(this.element[0].checked ? this.options.trueValue : this.options.falseValue); + } else { + if (this.element[0].checked) { + this.options.value(this.element[0].value); + } + } + } + }), Multiselect = Value.extend({ + init: function () { + this.delimiter = ';'; + setTimeout(can.proxy(this.set, this), 1); + }, + set: function () { + var newVal = this.options.value(); + if (typeof newVal === 'string') { + newVal = newVal.split(this.delimiter); + this.isString = true; + } else if (newVal) { + newVal = can.makeArray(newVal); + } + var isSelected = {}; + can.each(newVal, function (val) { + isSelected[val] = true; + }); + can.each(this.element[0].childNodes, function (option) { + if (option.value) { + option.selected = !!isSelected[option.value]; + } + }); + }, + get: function () { + var values = [], children = this.element[0].childNodes; + can.each(children, function (child) { + if (child.selected && child.value) { + values.push(child.value); + } + }); + return values; + }, + 'change': function () { + var value = this.get(), currentValue = this.options.value(); + if (this.isString || typeof currentValue === 'string') { + this.isString = true; + this.options.value(value.join(this.delimiter)); + } else if (currentValue instanceof can.List) { + currentValue.attr(value, true); + } else { + this.options.value(value); + } + } + }), Content = can.Control.extend({ + init: function () { + this.set(); + this.on('blur', 'setValue'); + }, + '{value} change': 'set', + set: function () { + var val = this.options.value(); + this.element[0].innerHTML = typeof val === 'undefined' ? '' : val; + }, + setValue: function () { + this.options.value(this.element[0].innerHTML); + } + }); +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/callbacks.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/callbacks.js new file mode 100644 index 0000000000..e14b445ec6 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/callbacks.js @@ -0,0 +1,83 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/callbacks/callbacks*/ +define([ + 'can/util/library', + 'can/view' +], function (can) { + var attr = can.view.attr = function (attributeName, attrHandler) { + if (attrHandler) { + if (typeof attributeName === 'string') { + attributes[attributeName] = attrHandler; + } else { + regExpAttributes.push({ + match: attributeName, + handler: attrHandler + }); + } + } else { + var cb = attributes[attributeName]; + if (!cb) { + for (var i = 0, len = regExpAttributes.length; i < len; i++) { + var attrMatcher = regExpAttributes[i]; + if (attrMatcher.match.test(attributeName)) { + cb = attrMatcher.handler; + break; + } + } + } + return cb; + } + }; + var attributes = {}, regExpAttributes = [], automaticCustomElementCharacters = /[-\:]/; + var tag = can.view.tag = function (tagName, tagHandler) { + if (tagHandler) { + if (can.global.html5) { + can.global.html5.elements += ' ' + tagName; + can.global.html5.shivDocument(); + } + tags[tagName.toLowerCase()] = tagHandler; + } else { + var cb = tags[tagName.toLowerCase()]; + if (!cb && automaticCustomElementCharacters.test(tagName)) { + cb = function () { + }; + } + return cb; + } + }; + var tags = {}; + can.view.callbacks = { + _tags: tags, + _attributes: attributes, + _regExpAttributes: regExpAttributes, + tag: tag, + attr: attr, + tagHandler: function (el, tagName, tagData) { + var helperTagCallback = tagData.options.attr('tags.' + tagName), tagCallback = helperTagCallback || tags[tagName]; + var scope = tagData.scope, res; + if (tagCallback) { + var reads = can.__clearReading(); + res = tagCallback(el, tagData); + can.__setReading(reads); + } else { + res = scope; + } + if (res && tagData.subtemplate) { + if (scope !== res) { + scope = scope.add(res); + } + var result = tagData.subtemplate(scope, tagData.options); + var frag = typeof result === 'string' ? can.view.frag(result) : result; + can.appendChild(el, frag); + } + } + }; + return can.view.callbacks; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/compute_data.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/compute_data.js new file mode 100644 index 0000000000..dccdc87c90 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/compute_data.js @@ -0,0 +1,110 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/scope/compute_data*/ +define([ + 'can/util/library', + 'can/compute', + 'can/get_value_and_bind' +], function (can, compute, getValueAndBind) { + var isFastPath = function (computeData) { + return computeData.reads && computeData.reads.length === 1 && computeData.root instanceof can.Map && !can.isFunction(computeData.root[computeData.reads[0]]); + }; + var getValueAndBindScopeRead = function (scopeRead, scopeReadChanged) { + return getValueAndBind(scopeRead, null, { observed: {} }, scopeReadChanged); + }; + var unbindScopeRead = function (readInfo, scopeReadChanged) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, scopeReadChanged); + } + }; + var getValueAndBindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + var target = computeData.root, prop = computeData.reads[0]; + target.bind(prop, singlePropertyReadChanged); + return { + value: computeData.initialValue, + observed: { something: true } + }; + }; + var unbindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + computeData.root.unbind(computeData.reads[0], singlePropertyReadChanged); + }; + var scopeReader = function (scope, key, options, computeData, newVal) { + if (arguments.length > 4) { + if (computeData.root.isComputed) { + computeData.root(newVal); + } else if (computeData.reads.length) { + var last = computeData.reads.length - 1; + var obj = computeData.reads.length ? can.compute.read(computeData.root, computeData.reads.slice(0, last)).value : computeData.root; + can.compute.set(obj, computeData.reads[last], newVal, options); + } + } else { + if (computeData.root) { + return can.compute.read(computeData.root, computeData.reads, options).value; + } + var data = scope.read(key, options); + computeData.scope = data.scope; + computeData.initialValue = data.value; + computeData.reads = data.reads; + computeData.root = data.rootObserve; + return data.value; + } + }; + return function (scope, key, options) { + options = options || { args: [] }; + var computeData = {}, scopeRead = function (newVal) { + if (arguments.length) { + return scopeReader(scope, key, options, computeData, newVal); + } else { + return scopeReader(scope, key, options, computeData); + } + }, batchNum, readInfo, scopeReadChanged = function (ev) { + if (readInfo.ready && compute.computeInstance.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + readInfo = getValueAndBind(scopeRead, null, readInfo, scopeReadChanged); + newValue = readInfo.value; + compute.computeInstance.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }, singlePropertyReadChanged = function (ev, newVal, oldVal) { + if (typeof newVal !== 'function') { + compute.computeInstance.updater(newVal, oldVal, ev.batchNum); + } else { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + isFastPathBound = false; + compute.computeInstance.updater(readInfo.value, oldVal, ev.batchNum); + } + }, isFastPathBound = false, compute = can.compute(undefined, { + on: function () { + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + if (isFastPath(computeData)) { + var oldReadInfo = readInfo; + readInfo = getValueAndBindSinglePropertyRead(computeData, singlePropertyReadChanged); + unbindScopeRead(oldReadInfo, scopeReadChanged); + isFastPathBound = true; + } + compute.computeInstance.value = readInfo.value; + compute.computeInstance.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function () { + if (isFastPathBound) { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + } else { + unbindScopeRead(readInfo, scopeReadChanged); + } + }, + set: scopeRead, + get: scopeRead, + __selfUpdater: true + }); + computeData.compute = compute; + return computeData; + }; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/ejs.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/ejs.js new file mode 100644 index 0000000000..2f4162324f --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/ejs.js @@ -0,0 +1,161 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/ejs/ejs*/ +define([ + 'can/util/library', + 'can/view', + 'can/util/string', + 'can/compute', + 'can/scanner', + 'can/render' +], function (can) { + var extend = can.extend, EJS = function (options) { + if (this.constructor !== EJS) { + var ejs = new EJS(options); + return function (data, helpers) { + return ejs.render(data, helpers); + }; + } + if (typeof options === 'function') { + this.template = { fn: options }; + return; + } + extend(this, options); + this.template = this.scanner.scan(this.text, this.name); + }; + can.EJS = EJS; + EJS.prototype.render = function (object, extraHelpers) { + object = object || {}; + return this.template.fn.call(object, object, new EJS.Helpers(object, extraHelpers || {})); + }; + extend(EJS.prototype, { + scanner: new can.view.Scanner({ + text: { + outStart: 'with(_VIEW) { with (_CONTEXT) {', + outEnd: '}}', + argNames: '_CONTEXT,_VIEW', + context: 'this' + }, + tokens: [ + [ + 'templateLeft', + '<%%' + ], + [ + 'templateRight', + '%>' + ], + [ + 'returnLeft', + '<%==' + ], + [ + 'escapeLeft', + '<%=' + ], + [ + 'commentLeft', + '<%#' + ], + [ + 'left', + '<%' + ], + [ + 'right', + '%>' + ], + [ + 'returnRight', + '%>' + ] + ], + helpers: [{ + name: /\s*\(([\$\w]+)\)\s*->([^\n]*)/, + fn: function (content) { + var quickFunc = /\s*\(([\$\w]+)\)\s*->([^\n]*)/, parts = content.match(quickFunc); + return 'can.proxy(function(__){var ' + parts[1] + '=can.$(__);' + parts[2] + '}, this);'; + } + }], + transform: function (source) { + return source.replace(/<%([\s\S]+?)%>/gm, function (whole, part) { + var brackets = [], foundBracketPair, i; + part.replace(/[{}]/gm, function (bracket, offset) { + brackets.push([ + bracket, + offset + ]); + }); + do { + foundBracketPair = false; + for (i = brackets.length - 2; i >= 0; i--) { + if (brackets[i][0] === '{' && brackets[i + 1][0] === '}') { + brackets.splice(i, 2); + foundBracketPair = true; + break; + } + } + } while (foundBracketPair); + if (brackets.length >= 2) { + var result = ['<%'], bracket, last = 0; + for (i = 0; bracket = brackets[i]; i++) { + result.push(part.substring(last, last = bracket[1])); + if (bracket[0] === '{' && i < brackets.length - 1 || bracket[0] === '}' && i > 0) { + result.push(bracket[0] === '{' ? '{ %><% ' : ' %><% }'); + } else { + result.push(bracket[0]); + } + ++last; + } + result.push(part.substring(last), '%>'); + return result.join(''); + } else { + return '<%' + part + '%>'; + } + }); + } + }) + }); + EJS.Helpers = function (data, extras) { + this._data = data; + this._extras = extras; + extend(this, extras); + }; + EJS.Helpers.prototype = { + list: function (list, cb) { + can.each(list, function (item, i) { + cb(item, i, list); + }); + }, + each: function (list, cb) { + if (can.isArray(list)) { + this.list(list, cb); + } else { + can.view.lists(list, cb); + } + } + }; + can.view.register({ + suffix: 'ejs', + script: function (id, src) { + return 'can.EJS(function(_CONTEXT,_VIEW) { ' + new EJS({ + text: src, + name: id + }).template.out + ' })'; + }, + renderer: function (id, text) { + return EJS({ + text: text, + name: id + }); + } + }); + can.ejs.Helpers = EJS.Helpers; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/html_section.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/html_section.js new file mode 100644 index 0000000000..323faead06 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/html_section.js @@ -0,0 +1,129 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/stache/html_section*/ +define([ + 'can/util/library', + 'can/view/target', + 'can/view/utils', + 'can/view/mustache_core' +], function (can, target, utils, mustacheCore) { + var decodeHTML = typeof document !== 'undefined' && function () { + var el = document.createElement('div'); + return function (html) { + if (html.indexOf('&') === -1) { + return html.replace(/\r\n/g, '\n'); + } + el.innerHTML = html; + return el.childNodes.length === 0 ? '' : el.childNodes[0].nodeValue; + }; + }(); + var HTMLSectionBuilder = function () { + this.stack = [new HTMLSection()]; + }; + can.extend(HTMLSectionBuilder.prototype, utils.mixins); + can.extend(HTMLSectionBuilder.prototype, { + startSubSection: function (process) { + var newSection = new HTMLSection(process); + this.stack.push(newSection); + return newSection; + }, + endSubSectionAndReturnRenderer: function () { + if (this.last().isEmpty()) { + this.stack.pop(); + return null; + } else { + var htmlSection = this.endSection(); + return can.proxy(htmlSection.compiled.hydrate, htmlSection.compiled); + } + }, + startSection: function (process) { + var newSection = new HTMLSection(process); + this.last().add(newSection.targetCallback); + this.stack.push(newSection); + }, + endSection: function () { + this.last().compile(); + return this.stack.pop(); + }, + inverse: function () { + this.last().inverse(); + }, + compile: function () { + var compiled = this.stack.pop().compile(); + return function (scope, options, nodeList) { + if (!(scope instanceof can.view.Scope)) { + scope = new can.view.Scope(scope || {}); + } + if (!(options instanceof mustacheCore.Options)) { + options = new mustacheCore.Options(options || {}); + } + return compiled.hydrate(scope, options, nodeList); + }; + }, + push: function (chars) { + this.last().push(chars); + }, + pop: function () { + return this.last().pop(); + } + }); + var HTMLSection = function (process) { + this.data = 'targetData'; + this.targetData = []; + this.targetStack = []; + var self = this; + this.targetCallback = function (scope, options, sectionNode) { + process.call(this, scope, options, sectionNode, can.proxy(self.compiled.hydrate, self.compiled), self.inverseCompiled && can.proxy(self.inverseCompiled.hydrate, self.inverseCompiled)); + }; + }; + can.extend(HTMLSection.prototype, { + inverse: function () { + this.inverseData = []; + this.data = 'inverseData'; + }, + push: function (data) { + this.add(data); + this.targetStack.push(data); + }, + pop: function () { + return this.targetStack.pop(); + }, + add: function (data) { + if (typeof data === 'string') { + data = decodeHTML(data); + } + if (this.targetStack.length) { + this.targetStack[this.targetStack.length - 1].children.push(data); + } else { + this[this.data].push(data); + } + }, + compile: function () { + this.compiled = target(this.targetData); + if (this.inverseData) { + this.inverseCompiled = target(this.inverseData); + delete this.inverseData; + } + delete this.targetData; + delete this.targetStack; + return this.compiled; + }, + children: function () { + if (this.targetStack.length) { + return this.targetStack[this.targetStack.length - 1].children; + } else { + return this[this.data]; + } + }, + isEmpty: function () { + return !this.targetData.length; + } + }); + return HTMLSectionBuilder; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/intermediate_and_imports.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/intermediate_and_imports.js new file mode 100644 index 0000000000..0e99310807 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/intermediate_and_imports.js @@ -0,0 +1,62 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/stache/intermediate_and_imports*/ +define([ + 'can/view/mustache_core', + 'can/view/parser' +], function (mustacheCore, parser) { + return function (source) { + var template = mustacheCore.cleanLineEndings(source); + var imports = [], inImport = false, inFrom = false; + var keepToken = function () { + return inImport ? false : true; + }; + var intermediate = parser(template, { + start: function (tagName, unary) { + if (tagName === 'can-import') { + inImport = true; + } + return keepToken(); + }, + end: function (tagName, unary) { + if (tagName === 'can-import') { + inImport = false; + return false; + } + return keepToken(); + }, + attrStart: function (attrName) { + if (attrName === 'from') { + inFrom = true; + } + return keepToken(); + }, + attrEnd: function (attrName) { + if (attrName === 'from') { + inFrom = false; + } + return keepToken(); + }, + attrValue: function (value) { + if (inFrom && inImport) { + imports.push(value); + } + return keepToken(); + }, + chars: keepToken, + comment: keepToken, + special: keepToken, + done: keepToken + }, true); + return { + intermediate: intermediate, + imports: imports + }; + }; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/live.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/live.js new file mode 100644 index 0000000000..ce7847fe3a --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/live.js @@ -0,0 +1,345 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/live/live*/ +define([ + 'can/util/library', + 'can/elements', + 'can/view', + 'can/view/node_lists', + 'can/view/parser' +], function (can, elements, view, nodeLists, parser) { + elements = elements || can.view.elements; + nodeLists = nodeLists || can.view.NodeLists; + parser = parser || can.view.parser; + var setup = function (el, bind, unbind) { + var tornDown = false, teardown = function () { + if (!tornDown) { + tornDown = true; + unbind(data); + can.unbind.call(el, 'removed', teardown); + } + return true; + }, data = { + teardownCheck: function (parent) { + return parent ? false : teardown(); + } + }; + can.bind.call(el, 'removed', teardown); + bind(data); + return data; + }, listen = function (el, compute, change) { + return setup(el, function () { + compute.bind('change', change); + }, function (data) { + compute.unbind('change', change); + if (data.nodeList) { + nodeLists.unregister(data.nodeList); + } + }); + }, getAttributeParts = function (newVal) { + var attrs = {}, attr; + parser.parseAttrs(newVal, { + attrStart: function (name) { + attrs[name] = ''; + attr = name; + }, + attrValue: function (value) { + attrs[attr] += value; + }, + attrEnd: function () { + } + }); + return attrs; + }, splice = [].splice, isNode = function (obj) { + return obj && obj.nodeType; + }, addTextNodeIfNoChildren = function (frag) { + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + }; + var live = { + list: function (el, compute, render, context, parentNode, nodeList) { + var masterNodeList = nodeList || [el], indexMap = [], afterPreviousEvents = false, isTornDown = false, add = function (ev, items, index) { + if (!afterPreviousEvents) { + return; + } + var frag = document.createDocumentFragment(), newNodeLists = [], newIndicies = []; + can.each(items, function (item, key) { + var itemNodeList = []; + if (nodeList) { + nodeLists.register(itemNodeList, null, true); + } + var itemIndex = can.compute(key + index), itemHTML = render.call(context, item, itemIndex, itemNodeList), gotText = typeof itemHTML === 'string', itemFrag = can.frag(itemHTML); + itemFrag = gotText ? can.view.hookup(itemFrag) : itemFrag; + var childNodes = can.makeArray(itemFrag.childNodes); + if (nodeList) { + nodeLists.update(itemNodeList, childNodes); + newNodeLists.push(itemNodeList); + } else { + newNodeLists.push(nodeLists.register(childNodes)); + } + frag.appendChild(itemFrag); + newIndicies.push(itemIndex); + }); + var masterListIndex = index + 1; + if (!masterNodeList[masterListIndex]) { + elements.after(masterListIndex === 1 ? [text] : [nodeLists.last(masterNodeList[masterListIndex - 1])], frag); + } else { + var el = nodeLists.first(masterNodeList[masterListIndex]); + can.insertBefore(el.parentNode, frag, el); + } + splice.apply(masterNodeList, [ + masterListIndex, + 0 + ].concat(newNodeLists)); + splice.apply(indexMap, [ + index, + 0 + ].concat(newIndicies)); + for (var i = index + newIndicies.length, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + }, remove = function (ev, items, index, duringTeardown, fullTeardown) { + if (!afterPreviousEvents) { + return; + } + if (!duringTeardown && data.teardownCheck(text.parentNode)) { + return; + } + if (index < 0) { + index = indexMap.length + index; + } + var removedMappings = masterNodeList.splice(index + 1, items.length), itemsToRemove = []; + can.each(removedMappings, function (nodeList) { + var nodesToRemove = nodeLists.unregister(nodeList); + [].push.apply(itemsToRemove, nodesToRemove); + }); + indexMap.splice(index, items.length); + for (var i = index, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + if (!fullTeardown) { + can.remove(can.$(itemsToRemove)); + } else { + nodeLists.unregister(masterNodeList); + } + }, move = function (ev, item, newIndex, currentIndex) { + if (!afterPreviousEvents) { + return; + } + newIndex = newIndex + 1; + currentIndex = currentIndex + 1; + var referenceNodeList = masterNodeList[newIndex]; + var movedElements = can.frag(nodeLists.flatten(masterNodeList[currentIndex])); + var referenceElement; + if (currentIndex < newIndex) { + referenceElement = nodeLists.last(referenceNodeList).nextSibling; + } else { + referenceElement = nodeLists.first(referenceNodeList); + } + var parentNode = masterNodeList[0].parentNode; + parentNode.insertBefore(movedElements, referenceElement); + var temp = masterNodeList[currentIndex]; + [].splice.apply(masterNodeList, [ + currentIndex, + 1 + ]); + [].splice.apply(masterNodeList, [ + newIndex, + 0, + temp + ]); + }, text = document.createTextNode(''), list, teardownList = function (fullTeardown) { + if (list && list.unbind) { + list.unbind('add', add).unbind('remove', remove).unbind('move', move); + } + remove({}, { length: masterNodeList.length - 1 }, 0, true, fullTeardown); + }, updateList = function (ev, newList, oldList) { + if (isTornDown) { + return; + } + teardownList(); + list = newList || []; + if (list.bind) { + list.bind('add', add).bind('remove', remove).bind('move', move); + } + afterPreviousEvents = true; + add({}, list, 0); + afterPreviousEvents = false; + can.batch.afterPreviousEvents(function () { + afterPreviousEvents = true; + }); + }; + parentNode = elements.getParentNode(el, parentNode); + var data = setup(parentNode, function () { + if (can.isFunction(compute)) { + compute.bind('change', updateList); + } + }, function () { + if (can.isFunction(compute)) { + compute.unbind('change', updateList); + } + teardownList(true); + }); + if (!nodeList) { + live.replace(masterNodeList, text, data.teardownCheck); + } else { + elements.replace(masterNodeList, text); + nodeLists.update(masterNodeList, [text]); + nodeList.unregistered = function () { + data.teardownCheck(); + isTornDown = true; + }; + } + updateList({}, can.isFunction(compute) ? compute() : compute); + }, + html: function (el, compute, parentNode, nodeList) { + var data; + parentNode = elements.getParentNode(el, parentNode); + data = listen(parentNode, compute, function (ev, newVal, oldVal) { + var attached = nodeLists.first(nodes).parentNode; + if (attached) { + makeAndPut(newVal); + } + data.teardownCheck(nodeLists.first(nodes).parentNode); + }); + var nodes = nodeList || [el], makeAndPut = function (val) { + var isFunction = typeof val === 'function', aNode = isNode(val), frag = can.frag(isFunction ? '' : val), oldNodes = can.makeArray(nodes); + addTextNodeIfNoChildren(frag); + if (!aNode && !isFunction) { + frag = can.view.hookup(frag, parentNode); + } + oldNodes = nodeLists.update(nodes, frag.childNodes); + if (isFunction) { + val(frag.childNodes[0]); + } + elements.replace(oldNodes, frag); + }; + data.nodeList = nodes; + if (!nodeList) { + nodeLists.register(nodes, data.teardownCheck); + } else { + nodeList.unregistered = data.teardownCheck; + } + makeAndPut(compute()); + }, + replace: function (nodes, val, teardown) { + var oldNodes = nodes.slice(0), frag = can.frag(val); + nodeLists.register(nodes, teardown); + if (typeof val === 'string') { + frag = can.view.hookup(frag, nodes[0].parentNode); + } + nodeLists.update(nodes, frag.childNodes); + elements.replace(oldNodes, frag); + return nodes; + }, + text: function (el, compute, parentNode, nodeList) { + var parent = elements.getParentNode(el, parentNode); + var data = listen(parent, compute, function (ev, newVal, oldVal) { + if (typeof node.nodeValue !== 'unknown') { + node.nodeValue = can.view.toStr(newVal); + } + data.teardownCheck(node.parentNode); + }); + var node = document.createTextNode(can.view.toStr(compute())); + if (nodeList) { + nodeList.unregistered = data.teardownCheck; + data.nodeList = nodeList; + nodeLists.update(nodeList, [node]); + elements.replace([el], node); + } else { + data.nodeList = live.replace([el], node, data.teardownCheck); + } + }, + setAttributes: function (el, newVal) { + var attrs = getAttributeParts(newVal); + for (var name in attrs) { + can.attr.set(el, name, attrs[name]); + } + }, + attributes: function (el, compute, currentValue) { + var oldAttrs = {}; + var setAttrs = function (newVal) { + var newAttrs = getAttributeParts(newVal), name; + for (name in newAttrs) { + var newValue = newAttrs[name], oldValue = oldAttrs[name]; + if (newValue !== oldValue) { + can.attr.set(el, name, newValue); + } + delete oldAttrs[name]; + } + for (name in oldAttrs) { + elements.removeAttr(el, name); + } + oldAttrs = newAttrs; + }; + listen(el, compute, function (ev, newVal) { + setAttrs(newVal); + }); + if (arguments.length >= 3) { + oldAttrs = getAttributeParts(currentValue); + } else { + setAttrs(compute()); + } + }, + attributePlaceholder: '__!!__', + attributeReplace: /__!!__/g, + attribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, hook.render()); + }); + var wrapped = can.$(el), hooks; + hooks = can.data(wrapped, 'hooks'); + if (!hooks) { + can.data(wrapped, 'hooks', hooks = {}); + } + var attr = elements.getAttr(el, attributeName), parts = attr.split(live.attributePlaceholder), goodParts = [], hook; + goodParts.push(parts.shift(), parts.join(live.attributePlaceholder)); + if (hooks[attributeName]) { + hooks[attributeName].computes.push(compute); + } else { + hooks[attributeName] = { + render: function () { + var i = 0, newAttr = attr ? attr.replace(live.attributeReplace, function () { + return elements.contentText(hook.computes[i++]()); + }) : elements.contentText(hook.computes[i++]()); + return newAttr; + }, + computes: [compute], + batchNum: undefined + }; + } + hook = hooks[attributeName]; + goodParts.splice(1, 0, compute()); + elements.setAttr(el, attributeName, goodParts.join('')); + }, + specialAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, getValue(newVal)); + }); + elements.setAttr(el, attributeName, getValue(compute())); + }, + simpleAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, newVal); + }); + elements.setAttr(el, attributeName, compute()); + } + }; + live.attr = live.simpleAttribute; + live.attrs = live.attributes; + var newLine = /(\r|\n)+/g; + var getValue = function (val) { + var regexp = /^["'].*["']$/; + val = val.replace(elements.attrReg, '').replace(newLine, ''); + return regexp.test(val) ? val.substr(1, val.length - 2) : val; + }; + can.view.live = live; + return live; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/modifiers.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/modifiers.js new file mode 100644 index 0000000000..7fa96c0e41 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/modifiers.js @@ -0,0 +1,100 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/modifiers/modifiers*/ +define([ + 'jquery', + 'can/util/library', + 'can/view' +], function ($, can) { + $ = $ || window.$; + var convert, modify, isTemplate, isHTML, isDOM, getCallback, noHookup = { + 'val': true, + 'text': true + }; + convert = function (func_name) { + var old = $.fn[func_name]; + $.fn[func_name] = function () { + var args = can.makeArray(arguments), callbackNum, callback, self = this, result; + if (can.isDeferred(args[0])) { + args[0].done(function (res) { + modify.call(self, [res], old); + }); + return this; + } else if (isTemplate(args)) { + if (callbackNum = getCallback(args)) { + callback = args[callbackNum]; + args[callbackNum] = function (result) { + modify.call(self, [result], old); + callback.call(self, result); + }; + can.view.apply(can.view, args); + return this; + } + result = can.view.apply(can.view, args); + if (!can.isDeferred(result)) { + args = [result]; + } else { + result.done(function (res) { + modify.call(self, [res], old); + }); + return this; + } + } + return noHookup[func_name] ? old.apply(this, args) : modify.call(this, args, old); + }; + }; + modify = function (args, old) { + var res; + for (var hasHookups in can.view.hookups) { + break; + } + if (hasHookups && args[0] && isHTML(args[0])) { + args[0] = can.view.frag(args[0]).childNodes; + } + res = old.apply(this, args); + return res; + }; + isTemplate = function (args) { + var secArgType = typeof args[1]; + return typeof args[0] === 'string' && (secArgType === 'object' || secArgType === 'function') && !isDOM(args[1]); + }; + isDOM = function (arg) { + return arg.nodeType || arg[0] && arg[0].nodeType; + }; + isHTML = function (arg) { + if (isDOM(arg)) { + return true; + } else if (typeof arg === 'string') { + arg = can.trim(arg); + return arg.substr(0, 1) === '<' && arg.substr(arg.length - 1, 1) === '>' && arg.length >= 3; + } else { + return false; + } + }; + getCallback = function (args) { + return typeof args[3] === 'function' ? 3 : typeof args[2] === 'function' && 2; + }; + $.fn.hookup = function () { + can.view.frag(this); + return this; + }; + can.each([ + 'prepend', + 'append', + 'after', + 'before', + 'text', + 'html', + 'replaceWith', + 'val' + ], function (func) { + convert(func); + }); + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/mustache.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/mustache.js new file mode 100644 index 0000000000..f158c6c3ba --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/mustache.js @@ -0,0 +1,506 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/mustache/mustache*/ +define([ + 'can/util/library', + 'can/view/scope', + 'can/view', + 'can/scanner', + 'can/compute', + 'can/render', + 'can/view/bindings' +], function (can) { + can.view.ext = '.mustache'; + var SCOPE = 'scope', HASH = '___h4sh', CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options}', SPECIAL_CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options, special: true}', ARG_NAMES = SCOPE + ',options', argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false|null|undefined)|((.+?)=(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false)|(.+))))$/, makeLookupLiteral = function (type) { + return '{get:"' + type.replace(/"/g, '\\"') + '"}'; + }, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, isObserveLike = function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, isArrayLike = function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, makeConvertToScopes = function (original, scope, options) { + var originalWithScope = function (ctx, opts) { + return original(ctx || scope, opts); + }; + return function (updatedScope, updatedOptions) { + if (updatedScope !== undefined && !(updatedScope instanceof can.view.Scope)) { + updatedScope = scope.add(updatedScope); + } + if (updatedOptions !== undefined && !(updatedOptions instanceof can.view.Options)) { + updatedOptions = options.add(updatedOptions); + } + return originalWithScope(updatedScope, updatedOptions || options); + }; + }; + var Mustache = function (options, helpers) { + if (this.constructor !== Mustache) { + var mustache = new Mustache(options); + return function (data, options) { + return mustache.render(data, options); + }; + } + if (typeof options === 'function') { + this.template = { fn: options }; + return; + } + can.extend(this, options); + this.template = this.scanner.scan(this.text, this.name); + }; + can.Mustache = can.global.Mustache = Mustache; + Mustache.prototype.render = function (data, options) { + if (!(data instanceof can.view.Scope)) { + data = new can.view.Scope(data || {}); + } + if (!(options instanceof can.view.Options)) { + options = new can.view.Options(options || {}); + } + options = options || {}; + return this.template.fn.call(data, data, options); + }; + can.extend(Mustache.prototype, { + scanner: new can.view.Scanner({ + text: { + start: '', + scope: SCOPE, + options: ',options: options', + argNames: ARG_NAMES + }, + tokens: [ + [ + 'returnLeft', + '{{{', + '{{[{&]' + ], + [ + 'commentFull', + '{{!}}', + '^[\\s\\t]*{{!.+?}}\\n' + ], + [ + 'commentLeft', + '{{!', + '(\\n[\\s\\t]*{{!|{{!)' + ], + [ + 'escapeFull', + '{{}}', + '(^[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}$)', + function (content) { + return { + before: /^\n.+?\n$/.test(content) ? '\n' : '', + content: content.match(/\{\{(.+?)\}\}/)[1] || '' + }; + } + ], + [ + 'escapeLeft', + '{{' + ], + [ + 'returnRight', + '}}}' + ], + [ + 'right', + '}}' + ] + ], + helpers: [ + { + name: /^>[\s]*\w*/, + fn: function (content, cmd) { + var templateName = can.trim(content.replace(/^>\s?/, '')).replace(/["|']/g, ''); + return 'can.Mustache.renderPartial(\'' + templateName + '\',' + ARG_NAMES + ')'; + } + }, + { + name: /^\s*data\s/, + fn: function (content, cmd) { + var attr = content.match(/["|'](.*)["|']/)[1]; + return 'can.proxy(function(__){' + 'can.data(can.$(__),\'' + attr + '\', this.attr(\'.\')); }, ' + SCOPE + ')'; + } + }, + { + name: /\s*\(([\$\w]+)\)\s*->([^\n]*)/, + fn: function (content) { + var quickFunc = /\s*\(([\$\w]+)\)\s*->([^\n]*)/, parts = content.match(quickFunc); + return 'can.proxy(function(__){var ' + parts[1] + '=can.$(__);with(' + SCOPE + '.attr(\'.\')){' + parts[2] + '}}, this);'; + } + }, + { + name: /^.*$/, + fn: function (content, cmd) { + var mode = false, result = { + content: '', + startTxt: false, + startOnlyTxt: false, + end: false + }; + content = can.trim(content); + if (content.length && (mode = content.match(/^([#^\/]|else$)/))) { + mode = mode[0]; + switch (mode) { + case '#': + case '^': + if (cmd.specialAttribute) { + result.startOnlyTxt = true; + } else { + result.startTxt = true; + result.escaped = 0; + } + break; + case '/': + result.end = true; + result.content += 'return ___v1ew.join("");}}])'; + return result; + } + content = content.substring(1); + } + if (mode !== 'else') { + var args = [], hashes = [], i = 0, m; + result.content += 'can.Mustache.txt(\n' + (cmd.specialAttribute ? SPECIAL_CONTEXT_OBJ : CONTEXT_OBJ) + ',\n' + (mode ? '"' + mode + '"' : 'null') + ','; + (can.trim(content) + ' ').replace(argumentsRegExp, function (whole, arg) { + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[2]) { + args.push(m[0]); + } else { + hashes.push(m[4] + ':' + (m[6] ? m[6] : makeLookupLiteral(m[5]))); + } + } else { + args.push(makeLookupLiteral(arg)); + } + i++; + }); + result.content += args.join(','); + if (hashes.length) { + result.content += ',{' + HASH + ':{' + hashes.join(',') + '}}'; + } + } + if (mode && mode !== 'else') { + result.content += ',[\n\n'; + } + switch (mode) { + case '^': + case '#': + result.content += '{fn:function(' + ARG_NAMES + '){var ___v1ew = [];'; + break; + case 'else': + result.content += 'return ___v1ew.join("");}},\n{inverse:function(' + ARG_NAMES + '){\nvar ___v1ew = [];'; + break; + default: + result.content += ')'; + break; + } + if (!mode) { + result.startTxt = true; + result.end = true; + } + return result; + } + } + ] + }) + }); + var helpers = can.view.Scanner.prototype.helpers; + for (var i = 0; i < helpers.length; i++) { + Mustache.prototype.scanner.helpers.unshift(helpers[i]); + } + Mustache.txt = function (scopeAndOptions, mode, name) { + var scope = scopeAndOptions.scope, options = scopeAndOptions.options, args = [], helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, hash, context = scope.attr('.'), getHelper = true, helper; + for (var i = 3; i < arguments.length; i++) { + var arg = arguments[i]; + if (mode && can.isArray(arg)) { + helperOptions = can.extend.apply(can, [helperOptions].concat(arg)); + } else if (arg && arg[HASH]) { + hash = arg[HASH]; + for (var prop in hash) { + if (isLookup(hash[prop])) { + hash[prop] = Mustache.get(hash[prop].get, scopeAndOptions, false, true); + } + } + } else if (arg && isLookup(arg)) { + args.push(Mustache.get(arg.get, scopeAndOptions, false, true, true)); + } else { + args.push(arg); + } + } + if (isLookup(name)) { + var get = name.get; + name = Mustache.get(name.get, scopeAndOptions, args.length, false); + getHelper = get === name; + } + helperOptions.fn = makeConvertToScopes(helperOptions.fn, scope, options); + helperOptions.inverse = makeConvertToScopes(helperOptions.inverse, scope, options); + if (mode === '^') { + var tmp = helperOptions.fn; + helperOptions.fn = helperOptions.inverse; + helperOptions.inverse = tmp; + } + if (helper = getHelper && (typeof name === 'string' && Mustache.getHelper(name, options)) || can.isFunction(name) && !name.isComputed && { fn: name }) { + can.extend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash + }); + args.push(helperOptions); + return function () { + return helper.fn.apply(context, args) || ''; + }; + } + return function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + var validArgs = args.length ? args : [value], valid = true, result = [], i, argIsObserve, arg; + if (mode) { + for (i = 0; i < validArgs.length; i++) { + arg = validArgs[i]; + argIsObserve = typeof arg !== 'undefined' && isObserveLike(arg); + if (isArrayLike(arg)) { + if (mode === '#') { + valid = valid && !!(argIsObserve ? arg.attr('length') : arg.length); + } else if (mode === '^') { + valid = valid && !(argIsObserve ? arg.attr('length') : arg.length); + } + } else { + valid = mode === '#' ? valid && !!arg : mode === '^' ? valid && !arg : valid; + } + } + } + if (valid) { + if (mode === '#') { + if (isArrayLike(value)) { + var isObserveList = isObserveLike(value); + for (i = 0; i < value.length; i++) { + result.push(helperOptions.fn(isObserveList ? value.attr('' + i) : value[i])); + } + return result.join(''); + } else { + return helperOptions.fn(value || {}) || ''; + } + } else if (mode === '^') { + return helperOptions.inverse(value || {}) || ''; + } else { + return '' + (value != null ? value : ''); + } + } + return ''; + }; + }; + Mustache.get = function (key, scopeAndOptions, isHelper, isArgument, isLookup) { + var context = scopeAndOptions.scope.attr('.'), options = scopeAndOptions.options || {}; + if (isHelper) { + if (Mustache.getHelper(key, options)) { + return key; + } + if (scopeAndOptions.scope && can.isFunction(context[key])) { + return context[key]; + } + } + var computeData = scopeAndOptions.scope.computeData(key, { + isArgument: isArgument, + args: [ + context, + scopeAndOptions.scope + ] + }), compute = computeData.compute; + can.compute.temporarilyBind(compute); + var initialValue = computeData.initialValue, helperObj = Mustache.getHelper(key, options); + if (!isLookup && (initialValue === undefined || computeData.scope !== scopeAndOptions.scope) && Mustache.getHelper(key, options)) { + return key; + } + if (!compute.computeInstance.hasDependencies) { + return initialValue; + } else { + return compute; + } + }; + Mustache.resolve = function (value) { + if (isObserveLike(value) && isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + can.view.Options = can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }); + Mustache._helpers = {}; + Mustache.registerHelper = function (name, fn) { + this._helpers[name] = { + name: name, + fn: fn + }; + }; + Mustache.getHelper = function (name, options) { + var helper; + if (options) { + helper = options.attr('helpers.' + name); + } + return helper ? { fn: helper } : this._helpers[name]; + }; + Mustache.render = function (partial, scope, options) { + if (!can.view.cached[partial]) { + var reads = can.__clearReading(); + var scopePartialName = scope.attr(partial); + if (scopePartialName) { + partial = scopePartialName; + } + can.__setReading(reads); + } + return can.view.render(partial, scope, options); + }; + Mustache.safeString = function (str) { + return { + toString: function () { + return str; + } + }; + }; + Mustache.renderPartial = function (partialName, scope, options) { + var partial = options.attr('partials.' + partialName); + if (partial) { + return partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + return can.Mustache.render(partialName, scope, options); + } + }; + can.each({ + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!Mustache.resolve(expr); + } + if (value) { + return options.fn(options.contexts || this); + } else { + return options.inverse(options.contexts || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = Mustache.resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return Mustache._helpers.is.fn.apply(this, arguments); + }, + 'unless': function (expr, options) { + return Mustache._helpers['if'].fn.apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'each': function (expr, options) { + var resolved = Mustache.resolve(expr), result = [], keys, key, i; + if (can.view.lists && (resolved instanceof can.List || expr && expr.isComputed && resolved === undefined)) { + return can.view.lists(expr, function (item, index) { + return options.fn(options.scope.add({ '@index': index }).add(item)); + }); + } + expr = resolved; + if (!!expr && isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + return result.join(''); + } else if (isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } + }, + 'with': function (expr, options) { + var ctx = expr; + expr = Mustache.resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + } + }, function (fn, name) { + Mustache.registerHelper(name, fn); + }); + can.view.register({ + suffix: 'mustache', + contentType: 'x-mustache-template', + script: function (id, src) { + return 'can.Mustache(function(' + ARG_NAMES + ') { ' + new Mustache({ + text: src, + name: id + }).template.out + ' })'; + }, + renderer: function (id, text) { + return Mustache({ + text: text, + name: id + }); + } + }); + can.mustache.registerHelper = can.proxy(can.Mustache.registerHelper, can.Mustache); + can.mustache.safeString = can.Mustache.safeString; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/mustache_core.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/mustache_core.js new file mode 100644 index 0000000000..bd876549dd --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/mustache_core.js @@ -0,0 +1,323 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/stache/mustache_core*/ +define([ + 'can/util/library', + 'can/view/utils', + 'can/view/mustache_helpers', + 'can/view/live', + 'can/elements', + 'can/view/scope', + 'can/view/node_lists' +], function (can, utils, mustacheHelpers, live, elements, Scope, nodeLists) { + live = live || can.view.live; + elements = elements || can.view.elements; + Scope = Scope || can.view.Scope; + nodeLists = nodeLists || can.view.nodeLists; + var argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(?:(.+?)=(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(.+))))$/, mustacheLineBreakRegExp = /(?:(?:^|(\r?)\n)(\s*)(\{\{([^\}]*)\}\}\}?)([^\S\n\r]*)($|\r?\n))|(\{\{([^\}]*)\}\}\}?)/g, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, getItemsFragContent = function (items, isObserveList, helperOptions, options) { + var frag = document.createDocumentFragment(); + for (var i = 0, len = items.length; i < len; i++) { + append(frag, helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options)); + } + return frag; + }, append = function (frag, content) { + if (content) { + frag.appendChild(typeof content === 'string' ? document.createTextNode(content) : content); + } + }, getItemsStringContent = function (items, isObserveList, helperOptions, options) { + var txt = ''; + for (var i = 0, len = items.length; i < len; i++) { + txt += helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options); + } + return txt; + }, getKeyComputeData = function (key, scope, isArgument) { + var data = scope.computeData(key, { + isArgument: isArgument, + args: [ + scope.attr('.'), + scope + ] + }); + can.compute.temporarilyBind(data.compute); + return data; + }, getKeyArgValue = function (key, scope) { + var data = getKeyComputeData(key, scope, true); + if (!data.compute.computeInstance.hasDependencies) { + return data.initialValue; + } else { + return data.compute; + } + }, convertToScopes = function (helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer) { + if (truthyRenderer) { + helperOptions.fn = makeRendererConvertScopes(truthyRenderer, scope, options, nodeList); + } + if (falseyRenderer) { + helperOptions.inverse = makeRendererConvertScopes(falseyRenderer, scope, options, nodeList); + } + }, makeRendererConvertScopes = function (renderer, parentScope, parentOptions, nodeList) { + var rendererWithScope = function (ctx, opts, parentNodeList) { + return renderer(ctx || parentScope, opts, parentNodeList); + }; + return can.__notObserve(function (newScope, newOptions, parentNodeList) { + if (newScope !== undefined && !(newScope instanceof can.view.Scope)) { + newScope = parentScope.add(newScope); + } + if (newOptions !== undefined && !(newOptions instanceof core.Options)) { + newOptions = parentOptions.add(newOptions); + } + var result = rendererWithScope(newScope, newOptions || parentOptions, parentNodeList || nodeList); + return result; + }); + }; + var core = { + expressionData: function (expression) { + var args = [], hashes = {}, i = 0; + (can.trim(expression) + ' ').replace(argumentsRegExp, function (whole, arg) { + var m; + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[1] || m[2]) { + args.push(utils.jsonParse(m[1] || m[2])); + } else { + hashes[m[3]] = m[6] ? { get: m[6] } : utils.jsonParse(m[4] || m[5]); + } + } else { + args.push({ get: arg }); + } + i++; + }); + return { + name: args.shift(), + args: args, + hash: hashes + }; + }, + makeEvaluator: function (scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, stringOnly) { + var args = [], hash = {}, helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, context = scope.attr('.'), name = exprData.name, helper, looksLikeAHelper = exprData.args.length || !can.isEmptyObject(exprData.hash), initialValue, helperEvaluator; + for (var i = 0, len = exprData.args.length; i < len; i++) { + var arg = exprData.args[i]; + if (arg && isLookup(arg)) { + args.push(getKeyArgValue(arg.get, scope, true)); + } else { + args.push(arg); + } + } + for (var prop in exprData.hash) { + if (isLookup(exprData.hash[prop])) { + hash[prop] = getKeyArgValue(exprData.hash[prop].get, scope); + } else { + hash[prop] = exprData.hash[prop]; + } + } + if (isLookup(name)) { + if (looksLikeAHelper) { + helper = mustacheHelpers.getHelper(name.get, options); + if (!helper && typeof context[name.get] === 'function') { + helper = { fn: context[name.get] }; + } + } + if (!helper) { + var get = name.get; + var computeData = getKeyComputeData(name.get, scope, false), compute = computeData.compute; + initialValue = computeData.initialValue; + if (computeData.compute.computeInstance.hasDependencies) { + name = compute; + } else { + name = initialValue; + } + if (!looksLikeAHelper && initialValue === undefined) { + helper = mustacheHelpers.getHelper(get, options); + } else if (typeof initialValue === 'function') { + helper = { fn: initialValue }; + } + } + } + if (mode === '^') { + var temp = truthyRenderer; + truthyRenderer = falseyRenderer; + falseyRenderer = temp; + } + if (helper) { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + can.simpleExtend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash, + nodeList: nodeList, + exprData: exprData + }); + args.push(helperOptions); + helperEvaluator = function () { + return helper.fn.apply(context, args) || ''; + }; + helperEvaluator.bindOnce = false; + return helperEvaluator; + } + if (!mode) { + if (name && name.isComputed) { + return name; + } else { + return function () { + return '' + (name != null ? name : ''); + }; + } + } else if (mode === '#' || mode === '^') { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + var evaluator = function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + if (utils.isArrayLike(value)) { + var isObserveList = utils.isObserveLike(value); + if (isObserveList ? value.attr('length') : value.length) { + return (stringOnly ? getItemsStringContent : getItemsFragContent)(value, isObserveList, helperOptions, options); + } else { + return helperOptions.inverse(scope, options); + } + } else { + return value ? helperOptions.fn(value || scope, options) : helperOptions.inverse(scope, options); + } + }; + evaluator.bindOnce = false; + return evaluator; + } else { + } + }, + makeLiveBindingPartialRenderer: function (partialName, state) { + partialName = can.trim(partialName); + return function (scope, options, parentSectionNodeList) { + var nodeList = [this]; + nodeList.expression = '>' + partialName; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var partialFrag = can.compute(function () { + var localPartialName = partialName; + var partial = options.attr('partials.' + localPartialName), res; + if (partial) { + res = partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + var scopePartialName = scope.read(localPartialName, { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }).value; + if (scopePartialName) { + localPartialName = scopePartialName; + } + res = can.view.render(localPartialName, scope, options); + } + return can.frag(res); + }); + live.html(this, partialFrag, this.parentNode, nodeList); + }; + }, + makeStringBranchRenderer: function (mode, expression) { + var exprData = expressionData(expression), fullExpression = mode + expression; + return function branchRenderer(scope, options, truthyRenderer, falseyRenderer) { + var evaluator = scope.__cache[fullExpression]; + if (mode || !evaluator) { + evaluator = makeEvaluator(scope, options, null, mode, exprData, truthyRenderer, falseyRenderer, true); + if (!mode) { + scope.__cache[fullExpression] = evaluator; + } + } + var res = evaluator(); + return res == null ? '' : '' + res; + }; + }, + makeLiveBindingBranchRenderer: function (mode, expression, state) { + var exprData = expressionData(expression); + return function branchRenderer(scope, options, parentSectionNodeList, truthyRenderer, falseyRenderer) { + var nodeList = [this]; + nodeList.expression = expression; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var evaluator = makeEvaluator(scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, state.tag); + var compute = can.compute(evaluator, null, false, evaluator.bindOnce === false ? false : true); + compute.bind('change', can.k); + var value = compute(); + if (typeof value === 'function') { + var old = can.__clearReading(); + value(this); + can.__setReading(old); + } else if (compute.computeInstance.hasDependencies) { + if (state.attr) { + live.simpleAttribute(this, state.attr, compute); + } else if (state.tag) { + live.attributes(this, compute); + } else if (state.text && typeof value !== 'object') { + live.text(this, compute, this.parentNode, nodeList); + } else { + live.html(this, compute, this.parentNode, nodeList); + } + } else { + if (state.attr) { + can.attr.set(this, state.attr, value); + } else if (state.tag) { + live.setAttributes(this, value); + } else if (state.text && typeof value === 'string') { + this.nodeValue = value; + } else if (value) { + elements.replace([this], can.frag(value)); + } + } + compute.unbind('change', can.k); + }; + }, + splitModeFromExpression: function (expression, state) { + expression = can.trim(expression); + var mode = expression.charAt(0); + if ('#/{&^>!'.indexOf(mode) >= 0) { + expression = can.trim(expression.substr(1)); + } else { + mode = null; + } + if (mode === '{' && state.node) { + mode = null; + } + return { + mode: mode, + expression: expression + }; + }, + cleanLineEndings: function (template) { + return template.replace(mustacheLineBreakRegExp, function (whole, returnBefore, spaceBefore, special, expression, spaceAfter, returnAfter, spaceLessSpecial, spaceLessExpression, matchIndex) { + spaceAfter = spaceAfter || ''; + returnBefore = returnBefore || ''; + spaceBefore = spaceBefore || ''; + var modeAndExpression = splitModeFromExpression(expression || spaceLessExpression, {}); + if (spaceLessSpecial || '>{'.indexOf(modeAndExpression.mode) >= 0) { + return whole; + } else if ('^#!/'.indexOf(modeAndExpression.mode) >= 0) { + return special + (matchIndex !== 0 && returnAfter.length ? returnBefore + '\n' : ''); + } else { + return spaceBefore + special + spaceAfter + (spaceBefore.length || matchIndex !== 0 ? returnBefore + '\n' : ''); + } + }); + }, + Options: can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }) + }; + var makeEvaluator = core.makeEvaluator, expressionData = core.expressionData, splitModeFromExpression = core.splitModeFromExpression; + return core; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/mustache_helpers.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/mustache_helpers.js new file mode 100644 index 0000000000..f79b8f4281 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/mustache_helpers.js @@ -0,0 +1,144 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/stache/mustache_helpers*/ +define([ + 'can/util/library', + 'can/view/utils', + 'can/view/live' +], function (can, utils, live) { + live = live || can.view.live; + var resolve = function (value) { + if (utils.isObserveLike(value) && utils.isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + var helpers = { + 'each': function (items, options) { + var resolved = resolve(items), result = [], keys, key, i; + if (resolved instanceof can.List) { + return function (el) { + var nodeList = [el]; + nodeList.expression = 'live.list'; + can.view.nodeLists.register(nodeList, null, options.nodeList); + can.view.nodeLists.update(options.nodeList, [el]); + var cb = function (item, index, parentNodeList) { + return options.fn(options.scope.add({ '@index': index }).add(item), options.options, parentNodeList); + }; + live.list(el, items, cb, options.context, el.parentNode, nodeList); + }; + } + var expr = resolved; + if (!!expr && utils.isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + } else if (utils.isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } + return result; + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + }, + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!resolve(expr); + } + if (value) { + return options.fn(options.scope || this); + } else { + return options.inverse(options.scope || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return helpers.is.apply(this, arguments); + }, + 'unless': function (expr, options) { + return helpers['if'].apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'with': function (expr, options) { + var ctx = expr; + expr = resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + 'data': function (attr) { + var data = arguments.length === 2 ? this : arguments[1]; + return function (el) { + can.data(can.$(el), attr, data || this.context); + }; + } + }; + return { + registerHelper: function (name, callback) { + helpers[name] = callback; + }, + getHelper: function (name, options) { + var helper = options.attr('helpers.' + name); + if (!helper) { + helper = helpers[name]; + } + if (helper) { + return { fn: helper }; + } + } + }; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/node_lists.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/node_lists.js new file mode 100644 index 0000000000..0f78dd87c6 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/node_lists.js @@ -0,0 +1,176 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/node_lists/node_lists*/ +define([ + 'can/util/library', + 'can/elements' +], function (can) { + var canExpando = true; + try { + document.createTextNode('')._ = 0; + } catch (ex) { + canExpando = false; + } + var nodeMap = {}, textNodeMap = {}, expando = 'ejs_' + Math.random(), _id = 0, id = function (node, localMap) { + var _textNodeMap = localMap || textNodeMap; + var id = readId(node, _textNodeMap); + if (id) { + return id; + } else { + if (canExpando || node.nodeType !== 3) { + ++_id; + return node[expando] = (node.nodeName ? 'element_' : 'obj_') + _id; + } else { + ++_id; + _textNodeMap['text_' + _id] = node; + return 'text_' + _id; + } + } + }, readId = function (node, textNodeMap) { + if (canExpando || node.nodeType !== 3) { + return node[expando]; + } else { + for (var textNodeID in textNodeMap) { + if (textNodeMap[textNodeID] === node) { + return textNodeID; + } + } + } + }, splice = [].splice, push = [].push, itemsInChildListTree = function (list) { + var count = 0; + for (var i = 0, len = list.length; i < len; i++) { + var item = list[i]; + if (item.nodeType) { + count++; + } else { + count += itemsInChildListTree(item); + } + } + return count; + }, replacementMap = function (replacements, idMap) { + var map = {}; + for (var i = 0, len = replacements.length; i < len; i++) { + var node = nodeLists.first(replacements[i]); + map[id(node, idMap)] = replacements[i]; + } + return map; + }; + var nodeLists = { + id: id, + update: function (nodeList, newNodes) { + var oldNodes = nodeLists.unregisterChildren(nodeList); + newNodes = can.makeArray(newNodes); + var oldListLength = nodeList.length; + splice.apply(nodeList, [ + 0, + oldListLength + ].concat(newNodes)); + if (nodeList.replacements) { + nodeLists.nestReplacements(nodeList); + } else { + nodeLists.nestList(nodeList); + } + return oldNodes; + }, + nestReplacements: function (list) { + var index = 0, idMap = {}, rMap = replacementMap(list.replacements, idMap), rCount = list.replacements.length; + while (index < list.length && rCount) { + var node = list[index], replacement = rMap[readId(node, idMap)]; + if (replacement) { + list.splice(index, itemsInChildListTree(replacement), replacement); + rCount--; + } + index++; + } + list.replacements = []; + }, + nestList: function (list) { + var index = 0; + while (index < list.length) { + var node = list[index], childNodeList = nodeMap[id(node)]; + if (childNodeList) { + if (childNodeList !== list) { + list.splice(index, itemsInChildListTree(childNodeList), childNodeList); + } + } else { + nodeMap[id(node)] = list; + } + index++; + } + }, + last: function (nodeList) { + var last = nodeList[nodeList.length - 1]; + if (last.nodeType) { + return last; + } else { + return nodeLists.last(last); + } + }, + first: function (nodeList) { + var first = nodeList[0]; + if (first.nodeType) { + return first; + } else { + return nodeLists.first(first); + } + }, + flatten: function (nodeList) { + var items = []; + for (var i = 0; i < nodeList.length; i++) { + var item = nodeList[i]; + if (item.nodeType) { + items.push(item); + } else { + items.push.apply(items, nodeLists.flatten(item)); + } + } + return items; + }, + register: function (nodeList, unregistered, parent) { + nodeList.unregistered = unregistered; + nodeList.parentList = parent; + if (parent === true) { + nodeList.replacements = []; + } else if (parent) { + parent.replacements.push(nodeList); + nodeList.replacements = []; + } else { + nodeLists.nestList(nodeList); + } + return nodeList; + }, + unregisterChildren: function (nodeList) { + var nodes = []; + can.each(nodeList, function (node) { + if (node.nodeType) { + if (!nodeList.replacements) { + delete nodeMap[id(node)]; + } + nodes.push(node); + } else { + push.apply(nodes, nodeLists.unregister(node)); + } + }); + return nodes; + }, + unregister: function (nodeList) { + var nodes = nodeLists.unregisterChildren(nodeList); + if (nodeList.unregistered) { + var unregisteredCallback = nodeList.unregistered; + delete nodeList.unregistered; + delete nodeList.replacements; + unregisteredCallback(); + } + return nodes; + }, + nodeMap: nodeMap + }; + can.view.nodeLists = nodeLists; + return nodeLists; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/parser.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/parser.js new file mode 100644 index 0000000000..6faed24175 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/parser.js @@ -0,0 +1,189 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/parser/parser*/ +define(['can/view'], function (can) { + function makeMap(str) { + var obj = {}, items = str.split(','); + for (var i = 0; i < items.length; i++) { + obj[items[i]] = true; + } + return obj; + } + function handleIntermediate(intermediate, handler) { + for (var i = 0, len = intermediate.length; i < len; i++) { + var item = intermediate[i]; + handler[item.tokenType].apply(handler, item.args); + } + return intermediate; + } + var alphaNumericHU = '-:A-Za-z0-9_', attributeNames = '[a-zA-Z_:][' + alphaNumericHU + ':.]*', spaceEQspace = '\\s*=\\s*', dblQuote2dblQuote = '"((?:\\\\.|[^"])*)"', quote2quote = '\'((?:\\\\.|[^\'])*)\'', attributeEqAndValue = '(?:' + spaceEQspace + '(?:' + '(?:"[^"]*")|(?:\'[^\']*\')|[^>\\s]+))?', matchStash = '\\{\\{[^\\}]*\\}\\}\\}?', stash = '\\{\\{([^\\}]*)\\}\\}\\}?', startTag = new RegExp('^<([' + alphaNumericHU + ']+)' + '(' + '(?:\\s*' + '(?:(?:' + '(?:' + attributeNames + ')?' + attributeEqAndValue + ')|' + '(?:' + matchStash + ')+)' + ')*' + ')\\s*(\\/?)>'), endTag = new RegExp('^<\\/([' + alphaNumericHU + ']+)[^>]*>'), attr = new RegExp('(?:' + '(?:(' + attributeNames + ')|' + stash + ')' + '(?:' + spaceEQspace + '(?:' + '(?:' + dblQuote2dblQuote + ')|(?:' + quote2quote + ')|([^>\\s]+)' + ')' + ')?)', 'g'), mustache = new RegExp(stash, 'g'), txtBreak = /<|\{\{/; + var empty = makeMap('area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed'); + var block = makeMap('a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video'); + var inline = makeMap('abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var'); + var closeSelf = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr'); + var fillAttrs = makeMap('checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected'); + var special = makeMap('script,style'); + var tokenTypes = 'start,end,close,attrStart,attrEnd,attrValue,chars,comment,special,done'.split(','); + var fn = function () { + }; + var HTMLParser = function (html, handler, returnIntermediate) { + if (typeof html === 'object') { + return handleIntermediate(html, handler); + } + var intermediate = []; + handler = handler || {}; + if (returnIntermediate) { + can.each(tokenTypes, function (name) { + var callback = handler[name] || fn; + handler[name] = function () { + if (callback.apply(this, arguments) !== false) { + intermediate.push({ + tokenType: name, + args: can.makeArray(arguments) + }); + } + }; + }); + } + function parseStartTag(tag, tagName, rest, unary) { + tagName = tagName.toLowerCase(); + if (block[tagName]) { + while (stack.last() && inline[stack.last()]) { + parseEndTag('', stack.last()); + } + } + if (closeSelf[tagName] && stack.last() === tagName) { + parseEndTag('', tagName); + } + unary = empty[tagName] || !!unary; + handler.start(tagName, unary); + if (!unary) { + stack.push(tagName); + } + HTMLParser.parseAttrs(rest, handler); + handler.end(tagName, unary); + } + function parseEndTag(tag, tagName) { + var pos; + if (!tagName) { + pos = 0; + } else { + for (pos = stack.length - 1; pos >= 0; pos--) { + if (stack[pos] === tagName) { + break; + } + } + } + if (pos >= 0) { + for (var i = stack.length - 1; i >= pos; i--) { + if (handler.close) { + handler.close(stack[i]); + } + } + stack.length = pos; + } + } + function parseMustache(mustache, inside) { + if (handler.special) { + handler.special(inside); + } + } + var index, chars, match, stack = [], last = html; + stack.last = function () { + return this[this.length - 1]; + }; + while (html) { + chars = true; + if (!stack.last() || !special[stack.last()]) { + if (html.indexOf(''); + if (index >= 0) { + if (handler.comment) { + handler.comment(html.substring(4, index)); + } + html = html.substring(index + 3); + chars = false; + } + } else if (html.indexOf(']*>'), function (all, text) { + text = text.replace(/|/g, '$1$2'); + if (handler.chars) { + handler.chars(text); + } + return ''; + }); + parseEndTag('', stack.last()); + } + if (html === last) { + throw 'Parse Error: ' + html; + } + last = html; + } + parseEndTag(); + handler.done(); + return intermediate; + }; + HTMLParser.parseAttrs = function (rest, handler) { + (rest != null ? rest : '').replace(attr, function (text, name, special, dblQuote, singleQuote, val) { + if (special) { + handler.special(special); + } + if (name || dblQuote || singleQuote || val) { + var value = arguments[3] ? arguments[3] : arguments[4] ? arguments[4] : arguments[5] ? arguments[5] : fillAttrs[name.toLowerCase()] ? name : ''; + handler.attrStart(name || ''); + var last = mustache.lastIndex = 0, res = mustache.exec(value), chars; + while (res) { + chars = value.substring(last, mustache.lastIndex - res[0].length); + if (chars.length) { + handler.attrValue(chars); + } + handler.special(res[1]); + last = mustache.lastIndex; + res = mustache.exec(value); + } + chars = value.substr(last, value.length); + if (chars) { + handler.attrValue(chars); + } + handler.attrEnd(name || ''); + } + }); + }; + can.view.parser = HTMLParser; + return HTMLParser; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/scope.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/scope.js new file mode 100644 index 0000000000..e1e29664e1 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/scope.js @@ -0,0 +1,130 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/scope/scope*/ +define([ + 'can/util/library', + 'can/view/compute_data', + 'can/construct', + 'can/map', + 'can/list', + 'can/view', + 'can/compute' +], function (can, makeComputeData) { + var escapeReg = /(\\)?\./g, escapeDotReg = /\\\./g, getNames = function (attr) { + var names = [], last = 0; + attr.replace(escapeReg, function (first, second, index) { + if (!second) { + names.push(attr.slice(last, index).replace(escapeDotReg, '.')); + last = index + first.length; + } + }); + names.push(attr.slice(last).replace(escapeDotReg, '.')); + return names; + }; + var Scope = can.Construct.extend({ read: can.compute.read }, { + init: function (context, parent) { + this._context = context; + this._parent = parent; + this.__cache = {}; + }, + attr: can.__notObserve(function (key, value) { + var options = { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }, res = this.read(key, options); + if (arguments.length === 2) { + var lastIndex = key.lastIndexOf('.'), readKey = lastIndex !== -1 ? key.substring(0, lastIndex) : '.', obj = this.read(readKey, options).value; + if (lastIndex !== -1) { + key = key.substring(lastIndex + 1, key.length); + } + can.compute.set(obj, key, value, options); + } + return res.value; + }), + add: function (context) { + if (context !== this._context) { + return new this.constructor(context, this); + } else { + return this; + } + }, + computeData: function (key, options) { + return makeComputeData(this, key, options); + }, + compute: function (key, options) { + return this.computeData(key, options).compute; + }, + read: function (attr, options) { + var stopLookup; + if (attr.substr(0, 2) === './') { + stopLookup = true; + attr = attr.substr(2); + } else if (attr.substr(0, 3) === '../') { + return this._parent.read(attr.substr(3), options); + } else if (attr === '..') { + return { value: this._parent._context }; + } else if (attr === '.' || attr === 'this') { + return { value: this._context }; + } + var names = attr.indexOf('\\.') === -1 ? attr.split('.') : getNames(attr), context, scope = this, defaultObserve, defaultReads = [], defaultPropertyDepth = -1, defaultComputeReadings, defaultScope, currentObserve, currentReads; + while (scope) { + context = scope._context; + if (context !== null && (typeof context === 'object' || typeof context === 'function')) { + var data = can.compute.read(context, names, can.simpleExtend({ + foundObservable: function (observe, nameIndex) { + currentObserve = observe; + currentReads = names.slice(nameIndex); + }, + earlyExit: function (parentValue, nameIndex) { + if (nameIndex > defaultPropertyDepth) { + defaultObserve = currentObserve; + defaultReads = currentReads; + defaultPropertyDepth = nameIndex; + defaultScope = scope; + defaultComputeReadings = can.__clearReading(); + } + }, + executeAnonymousFunctions: true + }, options)); + if (data.value !== undefined) { + return { + scope: scope, + rootObserve: currentObserve, + value: data.value, + reads: currentReads + }; + } + } + can.__clearReading(); + if (!stopLookup) { + scope = scope._parent; + } else { + scope = null; + } + } + if (defaultObserve) { + can.__setReading(defaultComputeReadings); + return { + scope: defaultScope, + rootObserve: defaultObserve, + reads: defaultReads, + value: undefined + }; + } else { + return { + names: names, + value: undefined + }; + } + } + }); + can.view.Scope = Scope; + return Scope; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/stache.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/stache.js new file mode 100644 index 0000000000..cf881681b8 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/stache.js @@ -0,0 +1,274 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/stache/stache*/ +define([ + 'can/util/library', + 'can/view/parser', + 'can/view/target', + 'can/view/html_section', + 'can/view/text_section', + 'can/view/mustache_core', + 'can/view/mustache_helpers', + 'can/view/intermediate_and_imports', + 'can/view/callbacks', + 'can/view/bindings' +], function (can, parser, target, HTMLSectionBuilder, TextSectionBuilder, mustacheCore, mustacheHelpers, getIntermediateAndImports, viewCallbacks) { + parser = parser || can.view.parser; + viewCallbacks = viewCallbacks || can.view.callbacks; + var svgNamespace = 'http://www.w3.org/2000/svg'; + var namespaces = { + 'svg': svgNamespace, + 'g': svgNamespace + }; + function stache(template) { + if (typeof template === 'string') { + template = mustacheCore.cleanLineEndings(template); + } + var section = new HTMLSectionBuilder(), state = { + node: null, + attr: null, + sectionElementStack: [], + text: false, + namespaceStack: [] + }, makeRendererAndUpdateSection = function (section, mode, stache) { + if (mode === '>') { + section.add(mustacheCore.makeLiveBindingPartialRenderer(stache, state)); + } else if (mode === '/') { + section.endSection(); + if (section instanceof HTMLSectionBuilder) { + state.sectionElementStack.pop(); + } + } else if (mode === 'else') { + section.inverse(); + } else { + var makeRenderer = section instanceof HTMLSectionBuilder ? mustacheCore.makeLiveBindingBranchRenderer : mustacheCore.makeStringBranchRenderer; + if (mode === '{' || mode === '&') { + section.add(makeRenderer(null, stache, copyState())); + } else if (mode === '#' || mode === '^') { + section.startSection(makeRenderer(mode, stache, copyState())); + if (section instanceof HTMLSectionBuilder) { + state.sectionElementStack.push('section'); + } + } else { + section.add(makeRenderer(null, stache, copyState({ text: true }))); + } + } + }, copyState = function (overwrites) { + var lastElement = state.sectionElementStack[state.sectionElementStack.length - 1]; + var cur = { + tag: state.node && state.node.tag, + attr: state.attr && state.attr.name, + directlyNested: state.sectionElementStack.length ? lastElement === 'section' || lastElement === 'custom' : true + }; + return overwrites ? can.simpleExtend(cur, overwrites) : cur; + }, addAttributesCallback = function (node, callback) { + if (!node.attributes) { + node.attributes = []; + } + node.attributes.push(callback); + }; + parser(template, { + start: function (tagName, unary) { + var matchedNamespace = namespaces[tagName]; + if (matchedNamespace && !unary) { + state.namespaceStack.push(matchedNamespace); + } + state.node = { + tag: tagName, + children: [], + namespace: matchedNamespace || can.last(state.namespaceStack) + }; + }, + end: function (tagName, unary) { + var isCustomTag = viewCallbacks.tag(tagName); + if (unary) { + section.add(state.node); + if (isCustomTag) { + addAttributesCallback(state.node, function (scope, options, parentNodeList) { + viewCallbacks.tagHandler(this, tagName, { + scope: scope, + options: options, + subtemplate: null, + templateType: 'stache', + parentNodeList: parentNodeList + }); + }); + } + } else { + section.push(state.node); + state.sectionElementStack.push(isCustomTag ? 'custom' : 'element'); + if (isCustomTag) { + section.startSubSection(); + } + } + state.node = null; + }, + close: function (tagName) { + var matchedNamespace = namespaces[tagName]; + if (matchedNamespace) { + state.namespaceStack.pop(); + } + var isCustomTag = viewCallbacks.tag(tagName), renderer; + if (isCustomTag) { + renderer = section.endSubSectionAndReturnRenderer(); + } + var oldNode = section.pop(); + if (isCustomTag) { + addAttributesCallback(oldNode, function (scope, options, parentNodeList) { + viewCallbacks.tagHandler(this, tagName, { + scope: scope, + options: options, + subtemplate: renderer, + templateType: 'stache', + parentNodeList: parentNodeList + }); + }); + } + state.sectionElementStack.pop(); + }, + attrStart: function (attrName) { + if (state.node.section) { + state.node.section.add(attrName + '="'); + } else { + state.attr = { + name: attrName, + value: '' + }; + } + }, + attrEnd: function (attrName) { + if (state.node.section) { + state.node.section.add('" '); + } else { + if (!state.node.attrs) { + state.node.attrs = {}; + } + state.node.attrs[state.attr.name] = state.attr.section ? state.attr.section.compile(copyState()) : state.attr.value; + var attrCallback = viewCallbacks.attr(attrName); + if (attrCallback) { + if (!state.node.attributes) { + state.node.attributes = []; + } + state.node.attributes.push(function (scope, options) { + attrCallback(this, { + attributeName: attrName, + scope: scope, + options: options + }); + }); + } + state.attr = null; + } + }, + attrValue: function (value) { + var section = state.node.section || state.attr.section; + if (section) { + section.add(value); + } else { + state.attr.value += value; + } + }, + chars: function (text) { + section.add(text); + }, + special: function (text) { + var firstAndText = mustacheCore.splitModeFromExpression(text, state), mode = firstAndText.mode, expression = firstAndText.expression; + if (expression === 'else') { + (state.attr && state.attr.section ? state.attr.section : section).inverse(); + return; + } + if (mode === '!') { + return; + } + if (state.node && state.node.section) { + makeRendererAndUpdateSection(state.node.section, mode, expression); + if (state.node.section.subSectionDepth() === 0) { + state.node.attributes.push(state.node.section.compile(copyState())); + delete state.node.section; + } + } else if (state.attr) { + if (!state.attr.section) { + state.attr.section = new TextSectionBuilder(); + if (state.attr.value) { + state.attr.section.add(state.attr.value); + } + } + makeRendererAndUpdateSection(state.attr.section, mode, expression); + } else if (state.node) { + if (!state.node.attributes) { + state.node.attributes = []; + } + if (!mode) { + state.node.attributes.push(mustacheCore.makeLiveBindingBranchRenderer(null, expression, copyState())); + } else if (mode === '#' || mode === '^') { + if (!state.node.section) { + state.node.section = new TextSectionBuilder(); + } + makeRendererAndUpdateSection(state.node.section, mode, expression); + } else { + throw mode + ' is currently not supported within a tag.'; + } + } else { + makeRendererAndUpdateSection(section, mode, expression); + } + }, + comment: function (text) { + section.add({ comment: text }); + }, + done: function () { + } + }); + return section.compile(); + } + var escMap = { + '\n': '\\n', + '\r': '\\r', + '\u2028': '\\u2028', + '\u2029': '\\u2029' + }; + var esc = function (string) { + return ('' + string).replace(/["'\\\n\r\u2028\u2029]/g, function (character) { + if ('\'"\\'.indexOf(character) >= 0) { + return '\\' + character; + } else { + return escMap[character]; + } + }); + }; + can.view.register({ + suffix: 'stache', + contentType: 'x-stache-template', + fragRenderer: function (id, text) { + return stache(text); + }, + script: function (id, src) { + return 'can.stache("' + esc(src) + '")'; + } + }); + can.view.ext = '.stache'; + can.extend(can.stache, mustacheHelpers); + can.extend(stache, mustacheHelpers); + can.stache.safeString = stache.safeString = function (text) { + return { + toString: function () { + return text; + } + }; + }; + can.stache.async = function (source) { + var iAi = getIntermediateAndImports(source); + var importPromises = can.map(iAi.imports, function (moduleName) { + return can['import'](moduleName); + }); + return can.when.apply(can, importPromises).then(function () { + return stache(iAi.intermediate); + }); + }; + return stache; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/target.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/target.js new file mode 100644 index 0000000000..7036046ad7 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/target.js @@ -0,0 +1,167 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/target/target*/ +define([ + 'can/util/library', + 'can/elements' +], function (can, elements) { + var processNodes = function (nodes, paths, location) { + var frag = document.createDocumentFragment(); + for (var i = 0, len = nodes.length; i < len; i++) { + var node = nodes[i]; + frag.appendChild(processNode(node, paths, location.concat(i))); + } + return frag; + }, keepsTextNodes = typeof document !== 'undefined' && function () { + var testFrag = document.createDocumentFragment(); + var div = document.createElement('div'); + div.appendChild(document.createTextNode('')); + div.appendChild(document.createTextNode('')); + testFrag.appendChild(div); + var cloned = testFrag.cloneNode(true); + return cloned.childNodes[0].childNodes.length === 2; + }(), clonesWork = typeof document !== 'undefined' && function () { + var a = document.createElement('a'); + a.innerHTML = ''; + var clone = a.cloneNode(true); + return clone.innerHTML === ''; + }(), namespacesWork = typeof document !== 'undefined' && !!document.createElementNS; + var cloneNode = clonesWork ? function (el) { + return el.cloneNode(true); + } : function (node) { + var copy; + if (node.nodeType === 1) { + copy = document.createElement(node.nodeName); + } else if (node.nodeType === 3) { + copy = document.createTextNode(node.nodeValue); + } else if (node.nodeType === 8) { + copy = document.createComment(node.nodeValue); + } else if (node.nodeType === 11) { + copy = document.createDocumentFragment(); + } + if (node.attributes) { + var attributes = can.makeArray(node.attributes); + can.each(attributes, function (node) { + if (node && node.specified) { + copy.setAttribute(node.nodeName, node.nodeValue); + } + }); + } + if (node.childNodes) { + can.each(node.childNodes, function (child) { + copy.appendChild(cloneNode(child)); + }); + } + return copy; + }; + function processNode(node, paths, location) { + var callback, loc = location, nodeType = typeof node, el, p, i, len; + var getCallback = function () { + if (!callback) { + callback = { + path: location, + callbacks: [] + }; + paths.push(callback); + loc = []; + } + return callback; + }; + if (nodeType === 'object') { + if (node.tag) { + if (namespacesWork && node.namespace) { + el = document.createElementNS(node.namespace, node.tag); + } else { + el = document.createElement(node.tag); + } + if (node.attrs) { + for (var attrName in node.attrs) { + var value = node.attrs[attrName]; + if (typeof value === 'function') { + getCallback().callbacks.push({ callback: value }); + } else { + el.setAttribute(attrName, value); + } + } + } + if (node.attributes) { + for (i = 0, len = node.attributes.length; i < len; i++) { + getCallback().callbacks.push({ callback: node.attributes[i] }); + } + } + if (node.children && node.children.length) { + if (callback) { + p = callback.paths = []; + } else { + p = paths; + } + el.appendChild(processNodes(node.children, p, loc)); + } + } else if (node.comment) { + el = document.createComment(node.comment); + if (node.callbacks) { + for (i = 0, len = node.attributes.length; i < len; i++) { + getCallback().callbacks.push({ callback: node.callbacks[i] }); + } + } + } + } else if (nodeType === 'string') { + el = document.createTextNode(node); + } else if (nodeType === 'function') { + if (keepsTextNodes) { + el = document.createTextNode(''); + getCallback().callbacks.push({ callback: node }); + } else { + el = document.createComment('~'); + getCallback().callbacks.push({ + callback: function () { + var el = document.createTextNode(''); + elements.replace([this], el); + return node.apply(el, arguments); + } + }); + } + } + return el; + } + function hydratePath(el, pathData, args) { + var path = pathData.path, callbacks = pathData.callbacks, paths = pathData.paths, callbackData, child = el; + for (var i = 0, len = path.length; i < len; i++) { + child = child.childNodes[path[i]]; + } + for (i = 0, len = callbacks.length; i < len; i++) { + callbackData = callbacks[i]; + callbackData.callback.apply(child, args); + } + if (paths && paths.length) { + for (i = paths.length - 1; i >= 0; i--) { + hydratePath(child, paths[i], args); + } + } + } + function makeTarget(nodes) { + var paths = []; + var frag = processNodes(nodes, paths, []); + return { + paths: paths, + clone: frag, + hydrate: function () { + var cloned = cloneNode(this.clone); + var args = can.makeArray(arguments); + for (var i = paths.length - 1; i >= 0; i--) { + hydratePath(cloned, paths[i], args); + } + return cloned; + } + }; + } + makeTarget.keepsTextNodes = keepsTextNodes; + can.view.target = makeTarget; + return makeTarget; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/text_section.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/text_section.js new file mode 100644 index 0000000000..571ae3c9e6 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/text_section.js @@ -0,0 +1,98 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/stache/text_section*/ +define([ + 'can/util/library', + 'can/view/live', + 'can/view/utils' +], function (can, live, utils) { + live = live || can.view.live; + var TextSectionBuilder = function () { + this.stack = [new TextSection()]; + }, emptyHandler = function () { + }; + can.extend(TextSectionBuilder.prototype, utils.mixins); + can.extend(TextSectionBuilder.prototype, { + startSection: function (process) { + var subSection = new TextSection(); + this.last().add({ + process: process, + truthy: subSection + }); + this.stack.push(subSection); + }, + endSection: function () { + this.stack.pop(); + }, + inverse: function () { + this.stack.pop(); + var falseySection = new TextSection(); + this.last().last().falsey = falseySection; + this.stack.push(falseySection); + }, + compile: function (state) { + var renderer = this.stack[0].compile(); + return function (scope, options) { + var compute = can.compute(function () { + return renderer(scope, options); + }, this, false, true); + compute.bind('change', emptyHandler); + var value = compute(); + if (compute.computeInstance.hasDependencies) { + if (state.attr) { + live.simpleAttribute(this, state.attr, compute); + } else { + live.attributes(this, compute); + } + compute.unbind('change', emptyHandler); + } else { + if (state.attr) { + can.attr.set(this, state.attr, value); + } else { + live.setAttributes(this, value); + } + } + }; + } + }); + var passTruthyFalsey = function (process, truthy, falsey) { + return function (scope, options) { + return process.call(this, scope, options, truthy, falsey); + }; + }; + var TextSection = function () { + this.values = []; + }; + can.extend(TextSection.prototype, { + add: function (data) { + this.values.push(data); + }, + last: function () { + return this.values[this.values.length - 1]; + }, + compile: function () { + var values = this.values, len = values.length; + for (var i = 0; i < len; i++) { + var value = this.values[i]; + if (typeof value === 'object') { + values[i] = passTruthyFalsey(value.process, value.truthy && value.truthy.compile(), value.falsey && value.falsey.compile()); + } + } + return function (scope, options) { + var txt = '', value; + for (var i = 0; i < len; i++) { + value = values[i]; + txt += typeof value === 'string' ? value : value.call(this, scope, options); + } + return txt; + }; + } + }); + return TextSectionBuilder; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/utils.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/utils.js new file mode 100644 index 0000000000..21512a9c55 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/amd/can/view/utils.js @@ -0,0 +1,43 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/stache/utils*/ +define(['can/util/library'], function () { + return { + isArrayLike: function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, + isObserveLike: function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, + emptyHandler: function () { + }, + jsonParse: function (str) { + if (str[0] === '\'') { + return str.substr(1, str.length - 2); + } else if (str === 'undefined') { + return undefined; + } else if (can.global.JSON) { + return JSON.parse(str); + } else { + return eval('(' + str + ')'); + } + }, + mixins: { + last: function () { + return this.stack[this.stack.length - 1]; + }, + add: function (chars) { + this.last().add(chars); + }, + subSectionDepth: function () { + return this.stack.length - 1; + } + } + }; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/bower.json b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/bower.json new file mode 100644 index 0000000000..ddeed592c0 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/bower.json @@ -0,0 +1,16 @@ +{ + "name": "CanJS", + "version": "2.2.6", + "repo": "bitovi/canjs", + "description": "Can do JavaScript MVC", + "main": "can.jquery.js", + "keywords": [ + "mvc", + "canjs", + "can", + "requirejs", + "component", + "amd" + ], + "license": "MIT" +} diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.autorender.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.autorender.js new file mode 100644 index 0000000000..efe80abd57 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.autorender.js @@ -0,0 +1,154 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#view/autorender/autorender*/ +'format steal'; +define('can/view/autorender/autorender', ['can/util/util'], function (can) { + var deferred = new can.Deferred(), ignoreAttributesRegExp = /^(dataViewId|class|id|type|src)$/i; + var typeMatch = /\s*text\/(mustache|stache|ejs)\s*/; + function isIn(element, type) { + while (element.parentNode) { + element = element.parentNode; + if (element.nodeName.toLowerCase() === type.toLowerCase()) { + return true; + } + } + } + function setAttr(el, attr, scope) { + var camelized = can.camelize(attr); + if (!ignoreAttributesRegExp.test(camelized)) { + scope.attr(camelized, el.getAttribute(attr)); + } + } + function insertAfter(ref, element) { + if (ref.nextSibling) { + can.insertBefore(ref.parentNode, element, ref.nextSibling); + } else { + can.appendChild(ref.parentNode, element); + } + } + function render(renderer, scope, el) { + var frag = renderer(scope); + if (isIn(el, 'head')) { + can.appendChild(document.body, frag); + } else if (el.nodeName.toLowerCase() === 'script') { + insertAfter(el, frag); + } else { + insertAfter(el, frag); + el.parentNode.removeChild(el); + } + } + function setupScope(el) { + var scope = can.viewModel(el); + can.each(el.attributes || [], function (attr) { + setAttr(el, attr.name, scope); + }); + can.bind.call(el, 'attributes', function (ev) { + setAttr(el, ev.attributeName, scope); + }); + return scope; + } + function autoload() { + var promises = []; + can.each(can.$('[can-autorender]'), function (el, i) { + el.style.display = 'none'; + var text = el.innerHTML || el.text, typeAttr = el.getAttribute('type'), typeInfo = typeAttr.match(typeMatch), type = typeInfo && typeInfo[1], typeModule = 'can/view/' + type; + if (window.System || !(window.define && window.define.amd)) { + typeModule += '/' + type; + } + promises.push(can['import'](typeModule).then(function (engine) { + engine = can[type] || engine; + if (engine.async) { + return engine.async(text).then(function (renderer) { + render(renderer, setupScope(el), el); + }); + } else { + var renderer = engine(text); + render(renderer, setupScope(el), el); + } + })); + }); + can.when.apply(can, promises).then(can.proxy(deferred.resolve, deferred), can.proxy(deferred.reject, deferred)); + } + if (document.readyState === 'complete') { + autoload(); + } else { + can.bind.call(window, 'load', autoload); + } + var promise = deferred.promise(); + can.autorender = function (success, error) { + return promise.then(success, error); + }; + return can.autorender; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.construct.proxy.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.construct.proxy.js new file mode 100644 index 0000000000..f710bd34e4 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.construct.proxy.js @@ -0,0 +1,115 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#construct/proxy/proxy*/ +define('can/construct/proxy/proxy', [ + 'can/util/util', + 'can/construct/construct' +], function (can, Construct) { + var isFunction = can.isFunction, isArray = can.isArray, makeArray = can.makeArray, proxy = function (funcs) { + var args = makeArray(arguments), self; + funcs = args.shift(); + if (!isArray(funcs)) { + funcs = [funcs]; + } + self = this; + return function class_cb() { + var cur = args.concat(makeArray(arguments)), isString, length = funcs.length, f = 0, func; + for (; f < length; f++) { + func = funcs[f]; + if (!func) { + continue; + } + isString = typeof func === 'string'; + cur = (isString ? self[func] : func).apply(self, cur || []); + if (f < length - 1) { + cur = !isArray(cur) || cur._use_call ? [cur] : cur; + } + } + return cur; + }; + }; + can.Construct.proxy = can.Construct.prototype.proxy = proxy; + var correctedClasses = [ + can.Map, + can.Control, + can.Model + ], i = 0; + for (; i < correctedClasses.length; i++) { + if (correctedClasses[i]) { + correctedClasses[i].proxy = proxy; + } + } + return can; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.construct.super.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.construct.super.js new file mode 100644 index 0000000000..0f8fc65a10 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.construct.super.js @@ -0,0 +1,111 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#construct/super/super*/ +define('can/construct/super/super', [ + 'can/util/util', + 'can/construct/construct' +], function (can, Construct) { + var isFunction = can.isFunction, fnTest = /xyz/.test(function () { + return this.xyz; + }) ? /\b_super\b/ : /.*/, getset = [ + 'get', + 'set' + ], getSuper = function (base, name, fn) { + return function () { + var tmp = this._super, ret; + this._super = base[name]; + ret = fn.apply(this, arguments); + this._super = tmp; + return ret; + }; + }; + can.Construct._defineProperty = function (addTo, base, name, descriptor) { + var _super = Object.getOwnPropertyDescriptor(base, name); + if (_super) { + can.each(getset, function (method) { + if (isFunction(_super[method]) && isFunction(descriptor[method])) { + descriptor[method] = getSuper(_super, method, descriptor[method]); + } else if (!isFunction(descriptor[method])) { + descriptor[method] = _super[method]; + } + }); + } + Object.defineProperty(addTo, name, descriptor); + }; + can.Construct._overwrite = function (addTo, base, name, val) { + addTo[name] = isFunction(val) && isFunction(base[name]) && fnTest.test(val) ? getSuper(base, name, val) : val; + }; + return can; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.control.plugin.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.control.plugin.js new file mode 100644 index 0000000000..461b346e47 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.control.plugin.js @@ -0,0 +1,147 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#control/plugin/plugin*/ +define('can/control/plugin/plugin', [ + 'dist/jquery', + 'can/util/util', + 'can/control/control' +], function ($, can) { + $ = $ || window.$; + var i, isAControllerOf = function (instance, controllers) { + var name = instance.constructor.pluginName || instance.constructor._shortName; + for (i = 0; i < controllers.length; i++) { + if (typeof controllers[i] === 'string' ? name === controllers[i] : instance instanceof controllers[i]) { + return true; + } + } + return false; + }, makeArray = can.makeArray, old = can.Control.setup; + can.Control.setup = function () { + if (this !== can.Control) { + var pluginName = this.pluginName || this._fullName; + if (pluginName !== 'can_control') { + this.plugin(pluginName); + } + old.apply(this, arguments); + } + }; + $.fn.extend({ + controls: function () { + var controllerNames = makeArray(arguments), instances = [], controls, c; + this.each(function () { + controls = can.$(this).data('controls'); + if (!controls) { + return; + } + for (var i = 0; i < controls.length; i++) { + c = controls[i]; + if (!controllerNames.length || isAControllerOf(c, controllerNames)) { + instances.push(c); + } + } + }); + return instances; + }, + control: function (control) { + return this.controls.apply(this, arguments)[0]; + } + }); + can.Control.plugin = function (pluginname) { + var control = this; + if (!$.fn[pluginname]) { + $.fn[pluginname] = function (options) { + var args = makeArray(arguments), isMethod = typeof options === 'string' && $.isFunction(control.prototype[options]), meth = args[0], returns; + this.each(function () { + var plugin = can.$(this).control(control); + if (plugin) { + if (isMethod) { + returns = plugin[meth].apply(plugin, args.slice(1)); + } else { + plugin.update.apply(plugin, args); + } + } else { + control.newInstance.apply(control, [this].concat(args)); + } + }); + return returns !== undefined ? returns : this; + }; + } + }; + can.Control.prototype.update = function (options) { + can.extend(this.options, options); + this.on(); + }; + return can; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.dojo.dev.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.dojo.dev.js new file mode 100644 index 0000000000..11a57e440f --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.dojo.dev.js @@ -0,0 +1,7405 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#util/can*/ +define('can/util/can', [], function () { + var glbl = typeof window !== 'undefined' ? window : global; + var can = {}; + if (typeof GLOBALCAN === 'undefined' || GLOBALCAN !== false) { + glbl.can = can; + } + can.global = glbl; + can.k = function () { + }; + can.isDeferred = can.isPromise = function (obj) { + return obj && typeof obj.then === 'function' && typeof obj.pipe === 'function'; + }; + can.isMapLike = function (obj) { + return can.Map && (obj instanceof can.Map || obj && obj.__get); + }; + var cid = 0; + can.cid = function (object, name) { + if (!object._cid) { + cid++; + object._cid = (name || '') + cid; + } + return object._cid; + }; + can.VERSION = '2.2.6'; + can.simpleExtend = function (d, s) { + for (var prop in s) { + d[prop] = s[prop]; + } + return d; + }; + can.last = function (arr) { + return arr && arr[arr.length - 1]; + }; + var protoBind = Function.prototype.bind; + if (protoBind) { + can.proxy = function (fn, context) { + return protoBind.call(fn, context); + }; + } else { + can.proxy = function (fn, context) { + return function () { + return fn.apply(context, arguments); + }; + }; + } + can.frag = function (item) { + var frag; + if (!item || typeof item === 'string') { + frag = can.buildFragment(item == null ? '' : '' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } else if (item.nodeType === 11) { + return item; + } else if (typeof item.nodeType === 'number') { + frag = document.createDocumentFragment(); + frag.appendChild(item); + return frag; + } else if (typeof item.length === 'number') { + frag = document.createDocumentFragment(); + can.each(item, function (item) { + frag.appendChild(can.frag(item)); + }); + return frag; + } else { + frag = can.buildFragment('' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } + }; + can.scope = can.viewModel = function (el, attr, val) { + el = can.$(el); + var scope = can.data(el, 'scope') || can.data(el, 'viewModel'); + if (!scope) { + scope = new can.Map(); + can.data(el, 'scope', scope); + can.data(el, 'viewModel', scope); + } + switch (arguments.length) { + case 0: + case 1: + return scope; + case 2: + return scope.attr(attr); + default: + scope.attr(attr, val); + return el; + } + }; + can['import'] = function (moduleName) { + var deferred = new can.Deferred(); + if (typeof window.System === 'object' && can.isFunction(window.System['import'])) { + window.System['import'](moduleName).then(can.proxy(deferred.resolve, deferred), can.proxy(deferred.reject, deferred)); + } else if (window.define && window.define.amd) { + window.require([moduleName], function (value) { + deferred.resolve(value); + }); + } else if (window.steal) { + steal.steal(moduleName, function (value) { + deferred.resolve(value); + }); + } else if (window.require) { + deferred.resolve(window.require(moduleName)); + } else { + deferred.resolve(); + } + return deferred.promise(); + }; + can.__observe = function () { + }; + can.dev = { + warnTimeout: 5000, + logLevel: 0, + warn: function (out) { + var ll = this.logLevel; + if (ll < 2) { + Array.prototype.unshift.call(arguments, 'WARN:'); + if (typeof window !== undefined && window.console && console.warn) { + this._logger('warn', Array.prototype.slice.call(arguments)); + } else if (window.console && console.log) { + this._logger('log', Array.prototype.slice.call(arguments)); + } else if (window.opera && window.opera.postError) { + window.opera.postError('steal.js WARNING: ' + out); + } + } + }, + log: function (out) { + var ll = this.logLevel; + if (ll < 1) { + if (window.console && console.log) { + Array.prototype.unshift.call(arguments, 'Info:'); + this._logger('log', Array.prototype.slice.call(arguments)); + } else if (window.opera && window.opera.postError) { + window.opera.postError('steal.js INFO: ' + out); + } + } + }, + _logger: function (type, arr) { + if (console.log.apply) { + console[type].apply(console, arr); + } else { + console[type](arr); + } + } + }; + return can; +}); +/*can@2.2.6#util/attr/attr*/ +define('can/util/attr/attr', ['can/util/can'], function (can) { + var setImmediate = can.global.setImmediate || function (cb) { + return setTimeout(cb, 0); + }, attr = { + MutationObserver: can.global.MutationObserver || can.global.WebKitMutationObserver || can.global.MozMutationObserver, + map: { + 'class': 'className', + 'value': 'value', + 'innertext': 'innerText', + 'textcontent': 'textContent', + 'checked': true, + 'disabled': true, + 'readonly': true, + 'required': true, + src: function (el, val) { + if (val == null || val === '') { + el.removeAttribute('src'); + return null; + } else { + el.setAttribute('src', val); + return val; + } + }, + style: function (el, val) { + return el.style.cssText = val || ''; + } + }, + defaultValue: [ + 'input', + 'textarea' + ], + set: function (el, attrName, val) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var tagName = el.nodeName.toString().toLowerCase(), prop = attr.map[attrName], newValue; + if (typeof prop === 'function') { + newValue = prop(el, val); + } else if (prop === true) { + newValue = el[attrName] = true; + if (attrName === 'checked' && el.type === 'radio') { + if (can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultChecked = true; + } + } + } else if (prop) { + newValue = val; + if (el[prop] !== val) { + el[prop] = val; + } + if (prop === 'value' && can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultValue = val; + } + } else { + el.setAttribute(attrName, val); + newValue = val; + } + if (!attr.MutationObserver && newValue !== oldValue) { + attr.trigger(el, attrName, oldValue); + } + }, + trigger: function (el, attrName, oldValue) { + if (can.data(can.$(el), 'canHasAttributesBindings')) { + attrName = attrName.toLowerCase(); + return setImmediate(function () { + can.trigger(el, { + type: 'attributes', + attributeName: attrName, + target: el, + oldValue: oldValue, + bubbles: false + }, []); + }); + } + }, + get: function (el, attrName) { + attrName = attrName.toLowerCase(); + var prop = attr.map[attrName]; + if (typeof prop === 'string' && el[prop]) { + return el[prop]; + } + return el.getAttribute(attrName); + }, + remove: function (el, attrName) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var setter = attr.map[attrName]; + if (typeof setter === 'function') { + setter(el, undefined); + } + if (setter === true) { + el[attrName] = false; + } else if (typeof setter === 'string') { + el[setter] = ''; + } else { + el.removeAttribute(attrName); + } + if (!attr.MutationObserver && oldValue != null) { + attr.trigger(el, attrName, oldValue); + } + }, + has: function () { + var el = can.global.document && document.createElement('div'); + if (el && el.hasAttribute) { + return function (el, name) { + return el.hasAttribute(name); + }; + } else { + return function (el, name) { + return el.getAttribute(name) !== null; + }; + } + }() + }; + return attr; +}); +/*can@2.2.6#event/event*/ +define('can/event/event', ['can/util/can'], function (can) { + can.addEvent = function (event, handler) { + var allEvents = this.__bindEvents || (this.__bindEvents = {}), eventList = allEvents[event] || (allEvents[event] = []); + eventList.push({ + handler: handler, + name: event + }); + return this; + }; + can.listenTo = function (other, event, handler) { + var idedEvents = this.__listenToEvents; + if (!idedEvents) { + idedEvents = this.__listenToEvents = {}; + } + var otherId = can.cid(other); + var othersEvents = idedEvents[otherId]; + if (!othersEvents) { + othersEvents = idedEvents[otherId] = { + obj: other, + events: {} + }; + } + var eventsEvents = othersEvents.events[event]; + if (!eventsEvents) { + eventsEvents = othersEvents.events[event] = []; + } + eventsEvents.push(handler); + can.bind.call(other, event, handler); + }; + can.stopListening = function (other, event, handler) { + var idedEvents = this.__listenToEvents, iterIdedEvents = idedEvents, i = 0; + if (!idedEvents) { + return this; + } + if (other) { + var othercid = can.cid(other); + (iterIdedEvents = {})[othercid] = idedEvents[othercid]; + if (!idedEvents[othercid]) { + return this; + } + } + for (var cid in iterIdedEvents) { + var othersEvents = iterIdedEvents[cid], eventsEvents; + other = idedEvents[cid].obj; + if (!event) { + eventsEvents = othersEvents.events; + } else { + (eventsEvents = {})[event] = othersEvents.events[event]; + } + for (var eventName in eventsEvents) { + var handlers = eventsEvents[eventName] || []; + i = 0; + while (i < handlers.length) { + if (handler && handler === handlers[i] || !handler) { + can.unbind.call(other, eventName, handlers[i]); + handlers.splice(i, 1); + } else { + i++; + } + } + if (!handlers.length) { + delete othersEvents.events[eventName]; + } + } + if (can.isEmptyObject(othersEvents.events)) { + delete idedEvents[cid]; + } + } + return this; + }; + can.removeEvent = function (event, fn, __validate) { + if (!this.__bindEvents) { + return this; + } + var events = this.__bindEvents[event] || [], i = 0, ev, isFunction = typeof fn === 'function'; + while (i < events.length) { + ev = events[i]; + if (__validate ? __validate(ev, event, fn) : isFunction && ev.handler === fn || !isFunction && (ev.cid === fn || !fn)) { + events.splice(i, 1); + } else { + i++; + } + } + return this; + }; + can.dispatch = function (event, args) { + var events = this.__bindEvents; + if (!events) { + return; + } + if (typeof event === 'string') { + event = { type: event }; + } + var eventName = event.type, handlers = (events[eventName] || []).slice(0), passed = [event]; + if (args) { + passed.push.apply(passed, args); + } + for (var i = 0, len = handlers.length; i < len; i++) { + handlers[i].handler.apply(this, passed); + } + return event; + }; + can.one = function (event, handler) { + var one = function () { + can.unbind.call(this, event, one); + return handler.apply(this, arguments); + }; + can.bind.call(this, event, one); + return this; + }; + can.event = { + on: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.on.call(this); + } else { + return can.addEvent.apply(this, arguments); + } + }, + off: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.off.call(this); + } else { + return can.removeEvent.apply(this, arguments); + } + }, + bind: can.addEvent, + unbind: can.removeEvent, + delegate: function (selector, event, handler) { + return can.addEvent.call(this, event, handler); + }, + undelegate: function (selector, event, handler) { + return can.removeEvent.call(this, event, handler); + }, + trigger: can.dispatch, + one: can.one, + addEvent: can.addEvent, + removeEvent: can.removeEvent, + listenTo: can.listenTo, + stopListening: can.stopListening, + dispatch: can.dispatch + }; + return can.event; +}); +/*can@2.2.6#util/fragment*/ +define('can/util/fragment', ['can/util/can'], function (can) { + var fragmentRE = /^\s*<(\w+)[^>]*>/, toString = {}.toString, fragment = function (html, name) { + if (name === undefined) { + name = fragmentRE.test(html) && RegExp.$1; + } + if (html && toString.call(html.replace) === '[object Function]') { + html = html.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, '<$1>'); + } + var container = document.createElement('div'), temp = document.createElement('div'); + if (name === 'tbody' || name === 'tfoot' || name === 'thead') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; + } else if (name === 'tr') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild; + } else if (name === 'td' || name === 'th') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild.firstChild; + } else if (name === 'option') { + temp.innerHTML = ''; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; + } else { + container.innerHTML = '' + html; + } + var tmp = {}, children = container.childNodes; + tmp.length = children.length; + for (var i = 0; i < children.length; i++) { + tmp[i] = children[i]; + } + return [].slice.call(tmp); + }; + can.buildFragment = function (html, nodes) { + if (html && html.nodeType === 11) { + return html; + } + var parts = fragment(html), frag = document.createDocumentFragment(); + for (var i = 0, length = parts.length; i < length; i++) { + frag.appendChild(parts[i]); + } + return frag; + }; + (function () { + var text = '<-\n>', frag = can.buildFragment(text, document); + if (text !== frag.childNodes[0].nodeValue) { + var oldBuildFragment = can.buildFragment; + can.buildFragment = function (html, nodes) { + var res = oldBuildFragment(html, nodes); + if (res.childNodes.length === 1 && res.childNodes[0].nodeType === 3) { + res.childNodes[0].nodeValue = html; + } + return res; + }; + } + }()); + return can; +}); +/*can@2.2.6#util/array/each*/ +define('can/util/array/each', ['can/util/can'], function (can) { + var isArrayLike = function (obj) { + var length = 'length' in obj && obj.length; + return typeof arr !== 'function' && (length === 0 || typeof length === 'number' && length > 0 && length - 1 in obj); + }; + can.each = function (elements, callback, context) { + var i = 0, key, len, item; + if (elements) { + if (isArrayLike(elements)) { + if (can.List && elements instanceof can.List) { + for (len = elements.attr('length'); i < len; i++) { + item = elements.attr(i); + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } else { + for (len = elements.length; i < len; i++) { + item = elements[i]; + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } + } else if (typeof elements === 'object') { + if (can.Map && elements instanceof can.Map || elements === can.route) { + var keys = can.Map.keys(elements); + for (i = 0, len = keys.length; i < len; i++) { + key = keys[i]; + item = elements.attr(key); + if (callback.call(context || item, item, key, elements) === false) { + break; + } + } + } else { + for (key in elements) { + if (elements.hasOwnProperty(key) && callback.call(context || elements[key], elements[key], key, elements) === false) { + break; + } + } + } + } + } + return elements; + }; + return can; +}); +/*can@2.2.6#util/object/isplain/isplain*/ +define('can/util/object/isplain/isplain', ['can/util/can'], function () { + var core_hasOwn = Object.prototype.hasOwnProperty, isWindow = function (obj) { + return obj !== null && obj == obj.window; + }, isPlainObject = function (obj) { + if (!obj || typeof obj !== 'object' || obj.nodeType || isWindow(obj)) { + return false; + } + try { + if (obj.constructor && !core_hasOwn.call(obj, 'constructor') && !core_hasOwn.call(obj.constructor.prototype, 'isPrototypeOf')) { + return false; + } + } catch (e) { + return false; + } + var key; + for (key in obj) { + } + return key === undefined || core_hasOwn.call(obj, key); + }; + can.isPlainObject = isPlainObject; + return can; +}); +/*can@2.2.6#util/deferred*/ +define('can/util/deferred', ['can/util/can'], function (can) { + var extend = function (target, src) { + for (var key in src) { + if (src.hasOwnProperty(key)) { + target[key] = src[key]; + } + } + }, Deferred = function (func) { + if (!(this instanceof Deferred)) { + return new Deferred(); + } + this._doneFuncs = []; + this._failFuncs = []; + this._resultArgs = null; + this._status = ''; + if (func) { + func.call(this, this); + } + }; + can.Deferred = Deferred; + can.when = Deferred.when = function () { + var args = can.makeArray(arguments); + if (args.length < 2) { + var obj = args[0]; + if (obj && (can.isFunction(obj.isResolved) && can.isFunction(obj.isRejected))) { + return obj; + } else { + return Deferred().resolve(obj); + } + } else { + var df = Deferred(), done = 0, rp = []; + can.each(args, function (arg, j) { + arg.done(function () { + rp[j] = arguments.length < 2 ? arguments[0] : arguments; + if (++done === args.length) { + df.resolve.apply(df, rp); + } + }).fail(function () { + df.reject(arguments.length === 1 ? arguments[0] : arguments); + }); + }); + return df; + } + }; + var resolveFunc = function (type, _status) { + return function (context) { + var args = this._resultArgs = arguments.length > 1 ? arguments[1] : []; + return this.exec(context, this[type], args, _status); + }; + }, doneFunc = function doneFunc(type, _status) { + return function () { + var self = this; + can.each(Array.prototype.slice.call(arguments), function (v, i, args) { + if (!v) { + return; + } + if (v.constructor === Array) { + doneFunc.apply(self, v); + } else { + if (self._status === _status) { + v.apply(self, self._resultArgs || []); + } + self[type].push(v); + } + }); + return this; + }; + }; + var isDeferred = function (obj) { + return obj && obj.then && obj.fail && obj.done; + }; + var wire = function (parentDeferred, result, setter, value) { + if (isDeferred(result)) { + result.done(can.proxy(parentDeferred.resolve, parentDeferred)).fail(can.proxy(parentDeferred.reject, parentDeferred)); + } else { + setter.call(parentDeferred, result !== undefined ? result : value); + } + }; + extend(Deferred.prototype, { + then: function (done, fail) { + var d = can.Deferred(), resolve = d.resolve, reject = d.reject; + this.done(function (value) { + if (typeof done === 'function') { + wire(d, done.apply(this, arguments), resolve, value); + } else { + resolve.apply(d, arguments); + } + }); + this.fail(function (value) { + if (typeof fail === 'function') { + wire(d, fail.apply(this, arguments), reject, value); + } else { + reject.apply(d, arguments); + } + }); + return d; + }, + resolveWith: resolveFunc('_doneFuncs', 'rs'), + rejectWith: resolveFunc('_failFuncs', 'rj'), + done: doneFunc('_doneFuncs', 'rs'), + fail: doneFunc('_failFuncs', 'rj'), + always: function () { + var args = can.makeArray(arguments); + if (args.length && args[0]) { + this.done(args[0]).fail(args[0]); + } + return this; + }, + state: function () { + switch (this._status) { + case 'rs': + return 'resolved'; + case 'rj': + return 'rejected'; + default: + return 'pending'; + } + }, + isResolved: function () { + return this._status === 'rs'; + }, + isRejected: function () { + return this._status === 'rj'; + }, + reject: function () { + return this.rejectWith(this, arguments); + }, + resolve: function () { + return this.resolveWith(this, arguments); + }, + exec: function (context, dst, args, st) { + if (this._status !== '') { + return this; + } + this._status = st; + can.each(dst, function (d) { + if (typeof d.apply === 'function') { + d.apply(context, args); + } + }); + return this; + }, + promise: function () { + var promise = this.then(); + promise.reject = promise.resolve = undefined; + return promise; + } + }); + Deferred.prototype.pipe = Deferred.prototype.then; + return can; +}); +/*can@2.2.6#util/hashchange*/ +define('can/util/hashchange', ['can/util/can'], function (can) { + (function () { + var addEvent = function (el, ev, fn) { + if (el.addEventListener) { + el.addEventListener(ev, fn, false); + } else if (el.attachEvent) { + el.attachEvent('on' + ev, fn); + } else { + el['on' + ev] = fn; + } + }, onHashchange = function () { + can.trigger(window, 'hashchange'); + }; + addEvent(window, 'hashchange', onHashchange); + }()); +}); +/*can@2.2.6#util/inserted/inserted*/ +define('can/util/inserted/inserted', ['can/util/can'], function (can) { + can.inserted = function (elems) { + elems = can.makeArray(elems); + var inDocument = false, doc = can.$(document.contains ? document : document.body), children; + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + if (!inDocument) { + if (elem.getElementsByTagName) { + if (can.has(doc, elem).length) { + inDocument = true; + } else { + return; + } + } else { + continue; + } + } + if (inDocument && elem.getElementsByTagName) { + children = can.makeArray(elem.getElementsByTagName('*')); + can.trigger(elem, 'inserted', [], false); + for (var j = 0, child; (child = children[j]) !== undefined; j++) { + can.trigger(child, 'inserted', [], false); + } + } + } + }; + can.appendChild = function (el, child) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.appendChild(child); + can.inserted(children); + }; + can.insertBefore = function (el, child, ref) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.insertBefore(child, ref); + can.inserted(children); + }; +}); +/*can@2.2.6#util/util*/ +'format steal'; +define('can/util/util', [ + 'can/util/can', + 'can/util/attr/attr', + 'can/dojo/dojo', + 'can/event/event', + 'can/util/fragment', + 'can/util/array/each', + 'can/util/object/isplain/isplain', + 'can/util/deferred', + 'can/util/hashchange', + 'can/util/inserted/inserted' +], function (can, attr, djo) { + var dojo = djo || window.dojo; + define('plugd/trigger', ['dojo/main'], function () { + var d = dojo; + var isfn = d.isFunction; + var leaveRe = /mouse(enter|leave)/; + var _fix = function (_, p) { + return 'mouse' + (p === 'enter' ? 'over' : 'out'); + }; + var mix = d._mixin; + var realTrigger; + if (d.doc.createEvent) { + realTrigger = function (n, e, a) { + var ev = d.doc.createEvent('HTMLEvents'); + e = e.replace(leaveRe, _fix); + ev.initEvent(e, e === 'removed' || e === 'inserted' ? false : true, true); + if (a) { + mix(ev, a); + } + n.dispatchEvent(ev); + }; + } else { + realTrigger = function (n, e, a) { + var ev = 'on' + e, stop = false; + try { + var evObj = document.createEventObject(); + if (e === 'inserted' || e === 'removed') { + evObj.cancelBubble = true; + } + mix(evObj, a); + n.fireEvent(ev, evObj); + } catch (er) { + var evdata = mix({ + type: e, + target: n, + faux: true, + _stopper: function () { + stop = this.cancelBubble; + } + }, a); + if (isfn(n[ev])) { + n[ev](evdata); + } + if (e === 'inserted' || e === 'removed') { + return; + } + while (!stop && n !== d.doc && n.parentNode) { + n = n.parentNode; + if (isfn(n[ev])) { + n[ev](evdata); + } + } + } + }; + } + d._trigger = function (node, event, extraArgs) { + if (typeof event !== 'string') { + extraArgs = event; + event = extraArgs.type; + delete extraArgs.type; + } + var n = d.byId(node), ev = event && event.slice(0, 2) === 'on' ? event.slice(2) : event; + realTrigger(n, ev, extraArgs); + }; + d.trigger = function (obj, event, extraArgs) { + return isfn(obj) || isfn(event) || isfn(obj[event]) ? d.hitch.apply(d, arguments)() : d._trigger.apply(d, arguments); + }; + d.NodeList.prototype.trigger = d.NodeList._adaptAsForEach(d._trigger); + if (d._Node && !d._Node.prototype.trigger) { + d.extend(d._Node, { + trigger: function (ev, data) { + d._trigger(this, ev, data); + return this; + } + }); + } + return d.trigger; + }); + require([ + 'dojo/main', + 'dojo/query', + 'plugd/trigger', + 'dojo/NodeList-dom' + ]); + can.trim = function (s) { + return s && dojo.trim(s); + }; + can.makeArray = function (arr) { + var array = []; + dojo.forEach(arr, function (item) { + array.push(item); + }); + return array; + }; + can.isArray = dojo.isArray; + can.inArray = function (item, arr, from) { + return dojo.indexOf(arr, item, from); + }; + can.map = function (arr, fn) { + return dojo.map(can.makeArray(arr || []), fn); + }; + can.extend = function (first) { + if (first === true) { + var args = can.makeArray(arguments); + args.shift(); + return dojo.mixin.apply(dojo, args); + } + return dojo.mixin.apply(dojo, arguments); + }; + can.isEmptyObject = function (object) { + var prop; + for (prop in object) { + break; + } + return prop === undefined; + }; + can.param = function (object) { + var pairs = [], add = function (key, value) { + pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(value)); + }; + for (var name in object) { + can.buildParam(name, object[name], add); + } + return pairs.join('&').replace(/%20/g, '+'); + }; + can.buildParam = function (prefix, obj, add) { + if (can.isArray(obj)) { + for (var i = 0, l = obj.length; i < l; ++i) { + add(prefix + '[]', obj[i]); + } + } else if (dojo.isObject(obj)) { + for (var name in obj) { + can.buildParam(prefix + '[' + name + ']', obj[name], add); + } + } else { + add(prefix, obj); + } + }; + can.proxy = function (func, context) { + return dojo.hitch(context, func); + }; + can.isFunction = function (f) { + return dojo.isFunction(f); + }; + var dojoId = 0, dojoAddBinding = function (nodelist, ev, cb) { + nodelist.forEach(function (node) { + node = new dojo.NodeList(node.nodeName === 'SELECT' ? [node] : node); + var events = can.data(node, 'events'); + if (!events) { + can.data(node, 'events', events = {}); + } + if (!events[ev]) { + events[ev] = {}; + } + if (cb.__bindingsIds === undefined) { + cb.__bindingsIds = dojoId++; + } + events[ev][cb.__bindingsIds] = node.on(ev, cb)[0]; + }); + }, dojoRemoveBinding = function (nodelist, ev, cb) { + nodelist.forEach(function (node) { + var currentNode = new dojo.NodeList(node), events = can.data(currentNode, 'events'); + if (!events) { + return; + } + var handlers = events[ev]; + if (!handlers) { + return; + } + var handler = handlers[cb.__bindingsIds]; + dojo.disconnect(handler); + delete handlers[cb.__bindingsIds]; + if (can.isEmptyObject(handlers)) { + delete events[ev]; + } + }); + }; + can.bind = function (ev, cb) { + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (this.on || this.nodeType) { + dojoAddBinding(new dojo.NodeList(this.nodeName === 'SELECT' ? [this] : this), ev, cb); + } else if (this.addEvent) { + this.addEvent(ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + return this; + }; + can.unbind = function (ev, cb) { + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (this.on || this.nodeType) { + dojoRemoveBinding(new dojo.NodeList(this), ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + return this; + }; + can.on = can.bind; + can.off = can.unbind; + can.trigger = function (item, event, args, bubble) { + if (!(item instanceof dojo.NodeList) && (item.nodeName || item === window)) { + item = can.$(item); + } + if (item.trigger) { + if (bubble === false) { + if (!item[0] || item[0].nodeType === 3) { + return; + } + var connect = item.on(event, function (ev) { + if (ev.stopPropagation) { + ev.stopPropagation(); + } + ev.cancelBubble = true; + if (ev._stopper) { + ev._stopper(); + } + dojo.disconnect(connect); + }); + item.trigger(event, args); + } else { + item.trigger(event, args); + } + } else { + if (typeof event === 'string') { + event = { type: event }; + } + event.target = event.target || item; + can.dispatch.call(item, event, can.makeArray(args)); + } + }; + can.delegate = function (selector, ev, cb) { + if (!selector) { + can.bind.call(this, ev, cb); + } else if (this.on || this.nodeType) { + dojoAddBinding(new dojo.NodeList(this), selector + ':' + ev, cb); + } else if (this.delegate) { + this.delegate(selector, ev, cb); + } else { + can.bind.call(this, ev, cb); + } + return this; + }; + can.undelegate = function (selector, ev, cb) { + if (!selector) { + can.unbind.call(this, ev, cb); + } else if (this.on || this.nodeType) { + dojoRemoveBinding(new dojo.NodeList(this), selector + ':' + ev, cb); + } else if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else { + can.unbind.call(this, ev, cb); + } + return this; + }; + var updateDeferred = function (xhr, d) { + for (var prop in xhr) { + if (typeof d[prop] === 'function') { + d[prop] = function () { + xhr[prop].apply(xhr, arguments); + }; + } else { + d[prop] = prop[xhr]; + } + } + }; + can.ajax = function (options) { + var type = can.capitalize((options.type || 'get').toLowerCase()), method = dojo['xhr' + type]; + var success = options.success, error = options.error, d = new can.Deferred(); + var def = method({ + url: options.url, + handleAs: options.dataType, + sync: !options.async, + headers: options.headers, + content: options.data + }); + def.then(function (data, ioargs) { + updateDeferred(xhr, d); + d.resolve(data, 'success', xhr); + if (success) { + success(data, 'success', xhr); + } + }, function (data, ioargs) { + updateDeferred(xhr, d); + d.reject(xhr, 'error'); + error(xhr, 'error'); + }); + var xhr = def.ioArgs.xhr; + updateDeferred(xhr, d); + return d; + }; + can.$ = function (selector) { + if (selector === window) { + return window; + } + if (typeof selector === 'string') { + return dojo.query(selector); + } else { + return new dojo.NodeList(selector && selector.nodeName ? [selector] : selector); + } + }; + can.append = function (wrapped, html) { + return wrapped.forEach(function (node) { + dojo.place(html, node); + }); + }; + var data = {}, uuid = can.uuid = +new Date(), exp = can.expando = 'can' + uuid; + function getData(node, name) { + var id = node[exp], store = id && data[id]; + return name === undefined ? store || setData(node) : store && store[name]; + } + function setData(node, name, value) { + var id = node[exp] || (node[exp] = ++uuid), store = data[id] || (data[id] = {}); + if (name !== undefined) { + store[name] = value; + } + return store; + } + var cleanData = function (elems) { + var nodes = []; + for (var i = 0, len = elems.length; i < len; i++) { + if (elems[i].nodeType === 1) { + nodes.push(elems[i]); + } + } + can.trigger(new dojo.NodeList(nodes), 'removed', [], false); + i = 0; + for (var elem; (elem = elems[i]) !== undefined; i++) { + var id = elem[exp]; + delete data[id]; + } + }; + can.data = function (wrapped, name, value) { + return value === undefined ? wrapped.length === 0 ? undefined : getData(wrapped[0], name) : wrapped.forEach(function (node) { + setData(node, name, value); + }); + }; + can.cleanData = function (elem, prop) { + var id = elem[exp]; + delete data[id][prop]; + }; + dojo.empty = function (node) { + for (var c; c = node.lastChild;) { + dojo.destroy(c); + } + }; + var destroy = dojo.destroy; + dojo.destroy = function (node) { + node = dojo.byId(node); + var nodes = [node]; + if (node.getElementsByTagName) { + nodes.concat(can.makeArray(node.getElementsByTagName('*'))); + } + cleanData(nodes); + return destroy.apply(dojo, arguments); + }; + var place = dojo.place; + dojo.place = function (node, refNode, position) { + if (typeof node === 'string' && /^\s*/g, '>').replace(strQuote, '"').replace(strSingleQuote, '''); + }, + getObject: function (name, roots, add) { + var parts = name ? name.split('.') : [], length = parts.length, current, r = 0, i, container, rootsLength; + roots = can.isArray(roots) ? roots : [roots || window]; + rootsLength = roots.length; + if (!length) { + return roots[0]; + } + for (r; r < rootsLength; r++) { + current = roots[r]; + container = undefined; + for (i = 0; i < length && isContainer(current); i++) { + container = current; + current = getNext(container, parts[i]); + } + if (container !== undefined && current !== undefined) { + break; + } + } + if (add === false && current !== undefined) { + delete container[parts[i - 1]]; + } + if (add === true && current === undefined) { + current = roots[0]; + for (i = 0; i < length && isContainer(current); i++) { + current = getNext(current, parts[i], true); + } + } + return current; + }, + capitalize: function (s, cache) { + return s.charAt(0).toUpperCase() + s.slice(1); + }, + camelize: function (str) { + return convertBadValues(str).replace(strHyphenMatch, function (match, chr) { + return chr ? chr.toUpperCase() : ''; + }); + }, + hyphenate: function (str) { + return convertBadValues(str).replace(strCamelMatch, function (str, offset) { + return str.charAt(0) + '-' + str.charAt(1).toLowerCase(); + }); + }, + underscore: function (s) { + return s.replace(strColons, '/').replace(strWords, '$1_$2').replace(strLowUp, '$1_$2').replace(strDash, '_').toLowerCase(); + }, + sub: function (str, data, remove) { + var obs = []; + str = str || ''; + obs.push(str.replace(strReplacer, function (whole, inside) { + var ob = can.getObject(inside, data, remove === true ? false : undefined); + if (ob === undefined || ob === null) { + obs = null; + return ''; + } + if (isContainer(ob) && obs) { + obs.push(ob); + return ''; + } + return '' + ob; + })); + return obs === null ? obs : obs.length <= 1 ? obs[0] : obs; + }, + replacer: strReplacer, + undHash: strUndHash + }); + return can; +}); +/*can@2.2.6#construct/construct*/ +define('can/construct/construct', ['can/util/string/string'], function (can) { + var initializing = 0; + var canGetDescriptor; + try { + Object.getOwnPropertyDescriptor({}); + canGetDescriptor = true; + } catch (e) { + canGetDescriptor = false; + } + var getDescriptor = function (newProps, name) { + var descriptor = Object.getOwnPropertyDescriptor(newProps, name); + if (descriptor && (descriptor.get || descriptor.set)) { + return descriptor; + } + return null; + }, inheritGetterSetter = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + var descriptor; + for (var name in newProps) { + if (descriptor = getDescriptor(newProps, name)) { + this._defineProperty(addTo, oldProps, name, descriptor); + } else { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + } + }, simpleInherit = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + for (var name in newProps) { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + }; + can.Construct = function () { + if (arguments.length) { + return can.Construct.extend.apply(can.Construct, arguments); + } + }; + can.extend(can.Construct, { + constructorExtends: true, + newInstance: function () { + var inst = this.instance(), args; + if (inst.setup) { + args = inst.setup.apply(inst, arguments); + } + if (inst.init) { + inst.init.apply(inst, args || arguments); + } + return inst; + }, + _inherit: canGetDescriptor ? inheritGetterSetter : simpleInherit, + _defineProperty: function (what, oldProps, propName, descriptor) { + Object.defineProperty(what, propName, descriptor); + }, + _overwrite: function (what, oldProps, propName, val) { + what[propName] = val; + }, + setup: function (base, fullName) { + this.defaults = can.extend(true, {}, base.defaults, this.defaults); + }, + instance: function () { + initializing = 1; + var inst = new this(); + initializing = 0; + return inst; + }, + extend: function (name, staticProperties, instanceProperties) { + var fullName = name, klass = staticProperties, proto = instanceProperties; + if (typeof fullName !== 'string') { + proto = klass; + klass = fullName; + fullName = null; + } + if (!proto) { + proto = klass; + klass = null; + } + proto = proto || {}; + var _super_class = this, _super = this.prototype, Constructor, parts, current, _fullName, _shortName, propName, shortName, namespace, prototype; + prototype = this.instance(); + can.Construct._inherit(proto, _super, prototype); + if (fullName) { + parts = fullName.split('.'); + shortName = parts.pop(); + } + var constructorName = shortName ? shortName.replace(/;/g, '') : 'Constructor'; + eval('Constructor = function ' + constructorName + '() { return init.apply(this, arguments); }'); + if (typeof constructorName === 'undefined') { + Constructor = function () { + return init.apply(this, arguments); + }; + } + function init() { + if (!initializing) { + if (this.constructor !== Constructor && arguments.length && Constructor.constructorExtends) { + can.dev.warn('can/construct/construct.js: extending a can.Construct without calling extend'); + } + return this.constructor !== Constructor && arguments.length && Constructor.constructorExtends ? Constructor.extend.apply(Constructor, arguments) : Constructor.newInstance.apply(Constructor, arguments); + } + } + for (propName in _super_class) { + if (_super_class.hasOwnProperty(propName)) { + Constructor[propName] = _super_class[propName]; + } + } + can.Construct._inherit(klass, _super_class, Constructor); + if (fullName) { + current = can.getObject(parts.join('.'), window, true); + namespace = current; + _fullName = can.underscore(fullName.replace(/\./g, '_')); + _shortName = can.underscore(shortName); + if (current[shortName]) { + can.dev.warn('can/construct/construct.js: There\'s already something called ' + fullName); + } + current[shortName] = Constructor; + } + can.extend(Constructor, { + constructor: Constructor, + prototype: prototype, + namespace: namespace, + _shortName: _shortName, + fullName: fullName, + _fullName: _fullName + }); + if (shortName !== undefined) { + Constructor.shortName = shortName; + } + Constructor.prototype.constructor = Constructor; + var t = [_super_class].concat(can.makeArray(arguments)), args = Constructor.setup.apply(Constructor, t); + if (Constructor.init) { + Constructor.init.apply(Constructor, args || t); + } + return Constructor; + } + }); + can.Construct.prototype.setup = function () { + }; + can.Construct.prototype.init = function () { + }; + return can.Construct; +}); +/*can@2.2.6#control/control*/ +define('can/control/control', [ + 'can/util/util', + 'can/construct/construct' +], function (can) { + var bind = function (el, ev, callback) { + can.bind.call(el, ev, callback); + return function () { + can.unbind.call(el, ev, callback); + }; + }, isFunction = can.isFunction, extend = can.extend, each = can.each, slice = [].slice, paramReplacer = /\{([^\}]+)\}/g, special = can.getObject('$.event.special', [can]) || {}, delegate = function (el, selector, ev, callback) { + can.delegate.call(el, selector, ev, callback); + return function () { + can.undelegate.call(el, selector, ev, callback); + }; + }, binder = function (el, ev, callback, selector) { + return selector ? delegate(el, can.trim(selector), ev, callback) : bind(el, ev, callback); + }, basicProcessor; + var Control = can.Control = can.Construct({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Control) { + var control = this, funcName; + control.actions = {}; + for (funcName in control.prototype) { + if (control._isAction(funcName)) { + control.actions[funcName] = control._action(funcName); + } + } + } + }, + _shifter: function (context, name) { + var method = typeof name === 'string' ? context[name] : name; + if (!isFunction(method)) { + method = context[method]; + } + return function () { + context.called = name; + return method.apply(context, [this.nodeName ? can.$(this) : this].concat(slice.call(arguments, 0))); + }; + }, + _isAction: function (methodName) { + var val = this.prototype[methodName], type = typeof val; + return methodName !== 'constructor' && (type === 'function' || type === 'string' && isFunction(this.prototype[val])) && !!(special[methodName] || processors[methodName] || /[^\w]/.test(methodName)); + }, + _action: function (methodName, options) { + paramReplacer.lastIndex = 0; + if (options || !paramReplacer.test(methodName)) { + var convertedName = options ? can.sub(methodName, this._lookup(options)) : methodName; + if (!convertedName) { + can.dev.log('can/control/control.js: No property found for handling ' + methodName); + return null; + } + var arr = can.isArray(convertedName), name = arr ? convertedName[1] : convertedName, parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: processors[event] || basicProcessor, + parts: [ + name, + parts.join(' '), + event + ], + delegate: arr ? convertedName[0] : undefined + }; + } + }, + _lookup: function (options) { + return [ + options, + window + ]; + }, + processors: {}, + defaults: {} + }, { + setup: function (element, options) { + var cls = this.constructor, pluginname = cls.pluginName || cls._fullName, arr; + this.element = can.$(element); + if (pluginname && pluginname !== 'can_control') { + this.element.addClass(pluginname); + } + arr = can.data(this.element, 'controls'); + if (!arr) { + arr = []; + can.data(this.element, 'controls', arr); + } + arr.push(this); + this.options = extend({}, cls.defaults, options); + this.on(); + return [ + this.element, + this.options + ]; + }, + on: function (el, selector, eventName, func) { + if (!el) { + this.off(); + var cls = this.constructor, bindings = this._bindings, actions = cls.actions, element = this.element, destroyCB = can.Control._shifter(this, 'destroy'), funcName, ready; + for (funcName in actions) { + if (actions.hasOwnProperty(funcName)) { + ready = actions[funcName] || cls._action(funcName, this.options, this); + if (ready) { + bindings.control[funcName] = ready.processor(ready.delegate || element, ready.parts[2], ready.parts[1], funcName, this); + } + } + } + can.bind.call(element, 'removed', destroyCB); + bindings.user.push(function (el) { + can.unbind.call(el, 'removed', destroyCB); + }); + return bindings.user.length; + } + if (typeof el === 'string') { + func = eventName; + eventName = selector; + selector = el; + el = this.element; + } + if (func === undefined) { + func = eventName; + eventName = selector; + selector = null; + } + if (typeof func === 'string') { + func = can.Control._shifter(this, func); + } + this._bindings.user.push(binder(el, eventName, func, selector)); + return this._bindings.user.length; + }, + off: function () { + var el = this.element[0], bindings = this._bindings; + if (bindings) { + each(bindings.user || [], function (value) { + value(el); + }); + each(bindings.control || {}, function (value) { + value(el); + }); + } + this._bindings = { + user: [], + control: {} + }; + }, + destroy: function () { + if (this.element === null) { + can.dev.warn('can/control/control.js: Control already destroyed'); + return; + } + var Class = this.constructor, pluginName = Class.pluginName || Class._fullName, controls; + this.off(); + if (pluginName && pluginName !== 'can_control') { + this.element.removeClass(pluginName); + } + controls = can.data(this.element, 'controls'); + controls.splice(can.inArray(this, controls), 1); + can.trigger(this, 'destroyed'); + this.element = null; + } + }); + var processors = can.Control.processors; + basicProcessor = function (el, event, selector, methodName, control) { + return binder(el, event, can.Control._shifter(control, methodName), selector); + }; + each([ + 'change', + 'click', + 'contextmenu', + 'dblclick', + 'keydown', + 'keyup', + 'keypress', + 'mousedown', + 'mousemove', + 'mouseout', + 'mouseover', + 'mouseup', + 'reset', + 'resize', + 'scroll', + 'select', + 'submit', + 'focusin', + 'focusout', + 'mouseenter', + 'mouseleave', + 'touchstart', + 'touchmove', + 'touchcancel', + 'touchend', + 'touchleave', + 'inserted', + 'removed' + ], function (v) { + processors[v] = basicProcessor; + }); + return Control; +}); +/*can@2.2.6#util/bind/bind*/ +define('can/util/bind/bind', ['can/util/util'], function (can) { + can.bindAndSetup = function () { + can.addEvent.apply(this, arguments); + if (!this._init) { + if (!this._bindings) { + this._bindings = 1; + if (this._bindsetup) { + this._bindsetup(); + } + } else { + this._bindings++; + } + } + return this; + }; + can.unbindAndTeardown = function (event, handler) { + var handlers = this.__bindEvents[event] || []; + var handlerCount = handlers.length; + can.removeEvent.apply(this, arguments); + if (this._bindings === null) { + this._bindings = 0; + } else { + this._bindings = this._bindings - (handlerCount - handlers.length); + } + if (!this._bindings && this._bindteardown) { + this._bindteardown(); + } + return this; + }; + return can; +}); +/*can@2.2.6#map/bubble*/ +define('can/map/bubble', ['can/util/util'], function (can) { + var bubble = can.bubble = { + event: function (map, boundEventName) { + return map.constructor._bubbleRule(boundEventName, map); + }, + childrenOf: function (parentMap, eventName) { + parentMap._each(function (child, prop) { + if (child && child.bind) { + bubble.toParent(child, parentMap, prop, eventName); + } + }); + }, + teardownChildrenFrom: function (parentMap, eventName) { + parentMap._each(function (child) { + bubble.teardownFromParent(parentMap, child, eventName); + }); + }, + toParent: function (child, parent, prop, eventName) { + can.listenTo.call(parent, child, eventName, function () { + var args = can.makeArray(arguments), ev = args.shift(); + args[0] = (can.List && parent instanceof can.List ? parent.indexOf(child) : prop) + (args[0] ? '.' + args[0] : ''); + ev.triggeredNS = ev.triggeredNS || {}; + if (ev.triggeredNS[parent._cid]) { + return; + } + ev.triggeredNS[parent._cid] = true; + can.trigger(parent, ev, args); + }); + }, + teardownFromParent: function (parent, child, eventName) { + if (child && child.unbind) { + can.stopListening.call(parent, child, eventName); + } + }, + isBubbling: function (parent, eventName) { + return parent._bubbleBindings && parent._bubbleBindings[eventName]; + }, + bind: function (parent, eventName) { + if (!parent._init) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + if (!parent._bubbleBindings) { + parent._bubbleBindings = {}; + } + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (!parent._bubbleBindings[bubbleEvent]) { + parent._bubbleBindings[bubbleEvent] = 1; + bubble.childrenOf(parent, bubbleEvent); + } else { + parent._bubbleBindings[bubbleEvent]++; + } + } + } + }, + unbind: function (parent, eventName) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (parent._bubbleBindings) { + parent._bubbleBindings[bubbleEvent]--; + } + if (parent._bubbleBindings && !parent._bubbleBindings[bubbleEvent]) { + delete parent._bubbleBindings[bubbleEvent]; + bubble.teardownChildrenFrom(parent, bubbleEvent); + if (can.isEmptyObject(parent._bubbleBindings)) { + delete parent._bubbleBindings; + } + } + } + }, + add: function (parent, child, prop) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + bubble.toParent(child, parent, prop, eventName); + } + } + } + }, + removeMany: function (parent, children) { + for (var i = 0, len = children.length; i < len; i++) { + bubble.remove(parent, children[i]); + } + }, + remove: function (parent, child) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + } + } + } + }, + set: function (parent, prop, value, current) { + if (can.Map.helpers.isObservable(value)) { + bubble.add(parent, value, prop); + } + if (can.Map.helpers.isObservable(current)) { + bubble.remove(parent, current); + } + return value; + } + }; + return bubble; +}); +/*can@2.2.6#util/batch/batch*/ +define('can/util/batch/batch', ['can/util/can'], function (can) { + var batchNum = 1, transactions = 0, batchEvents = [], stopCallbacks = [], currentBatchEvents = null; + can.batch = { + start: function (batchStopHandler) { + transactions++; + if (batchStopHandler) { + stopCallbacks.push(batchStopHandler); + } + }, + stop: function (force, callStart) { + if (force) { + transactions = 0; + } else { + transactions--; + } + if (transactions === 0) { + if (currentBatchEvents !== null) { + return; + } + currentBatchEvents = batchEvents.slice(0); + var callbacks = stopCallbacks.slice(0), i, len; + batchEvents = []; + stopCallbacks = []; + can.batch.batchNum = batchNum; + batchNum++; + if (callStart) { + can.batch.start(); + } + for (i = 0; i < currentBatchEvents.length; i++) { + can.dispatch.apply(currentBatchEvents[i][0], currentBatchEvents[i][1]); + } + currentBatchEvents = null; + for (i = 0, len = callbacks.length; i < callbacks.length; i++) { + callbacks[i](); + } + can.batch.batchNum = undefined; + } + }, + trigger: function (item, event, args) { + if (!item._init) { + event = typeof event === 'string' ? { type: event } : event; + if (currentBatchEvents) { + currentBatchEvents.push([ + item, + [ + event, + args + ] + ]); + } else if (transactions === 0) { + return can.dispatch.call(item, event, args); + } else { + event.batchNum = batchNum; + batchEvents.push([ + item, + [ + event, + args + ] + ]); + } + } + }, + afterPreviousEvents: function (handler) { + if (currentBatchEvents) { + var obj = {}; + can.bind.call(obj, 'ready', handler); + currentBatchEvents.push([ + obj, + [ + { type: 'ready' }, + [] + ] + ]); + } else { + handler(); + } + } + }; +}); +/*can@2.2.6#map/map*/ +define('can/map/map', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/map/bubble', + 'can/construct/construct', + 'can/util/batch/batch' +], function (can, bind, bubble) { + var madeMap = null; + var teardownMap = function () { + for (var cid in madeMap) { + if (madeMap[cid].added) { + delete madeMap[cid].obj._cid; + } + } + madeMap = null; + }; + var getMapFromObject = function (obj) { + return madeMap && madeMap[obj._cid] && madeMap[obj._cid].instance; + }; + var serializeMap = null; + var Map = can.Map = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Map) { + if (!this.defaults) { + this.defaults = {}; + } + this._computes = []; + if (this.prototype.define && !this.helpers.define) { + can.dev.warn('can/map/define is not included, yet there is a define property ' + 'used. You may want to add this plugin.'); + } + if (this.define && !this.helpers.define) { + can.dev.warn('The define property should be on the map\'s prototype properties, ' + 'not the static properies. Also, can/map/define is not included.'); + } + for (var prop in this.prototype) { + if (prop !== 'define' && prop !== 'constructor' && (typeof this.prototype[prop] !== 'function' || this.prototype[prop].prototype instanceof can.Construct)) { + this.defaults[prop] = this.prototype[prop]; + } else if (this.prototype[prop].isComputed) { + this._computes.push(prop); + } + } + if (this.helpers.define) { + this.helpers.define(this); + } + } + if (can.List && !(this.prototype instanceof can.List)) { + this.List = Map.List.extend({ Map: this }, {}); + } + }, + _bubble: bubble, + _bubbleRule: function (eventName) { + return eventName === 'change' || eventName.indexOf('.') >= 0 ? ['change'] : []; + }, + _computes: [], + bind: can.bindAndSetup, + on: can.bindAndSetup, + unbind: can.unbindAndTeardown, + off: can.unbindAndTeardown, + id: 'id', + helpers: { + define: null, + attrParts: function (attr, keepKey) { + if (keepKey) { + return [attr]; + } + return typeof attr === 'object' ? attr : ('' + attr).split('.'); + }, + addToMap: function (obj, instance) { + var teardown; + if (!madeMap) { + teardown = teardownMap; + madeMap = {}; + } + var hasCid = obj._cid; + var cid = can.cid(obj); + if (!madeMap[cid]) { + madeMap[cid] = { + obj: obj, + instance: instance, + added: !hasCid + }; + } + return teardown; + }, + isObservable: function (obj) { + return obj instanceof can.Map || obj && obj === can.route; + }, + canMakeObserve: function (obj) { + return obj && !can.isDeferred(obj) && (can.isArray(obj) || can.isPlainObject(obj)); + }, + serialize: function (map, how, where) { + var cid = can.cid(map), firstSerialize = false; + if (!serializeMap) { + firstSerialize = true; + serializeMap = { + attr: {}, + serialize: {} + }; + } + serializeMap[how][cid] = where; + map.each(function (val, name) { + var result, isObservable = Map.helpers.isObservable(val), serialized = isObservable && serializeMap[how][can.cid(val)]; + if (serialized) { + result = serialized; + } else { + if (how === 'serialize') { + result = Map.helpers._serialize(map, name, val); + } else { + result = Map.helpers._getValue(map, name, val, how); + } + } + if (result !== undefined) { + where[name] = result; + } + }); + can.__observe(map, '__keys'); + if (firstSerialize) { + serializeMap = null; + } + return where; + }, + _serialize: function (map, name, val) { + return Map.helpers._getValue(map, name, val, 'serialize'); + }, + _getValue: function (map, name, val, how) { + if (Map.helpers.isObservable(val)) { + return val[how](); + } else { + return val; + } + } + }, + keys: function (map) { + var keys = []; + can.__observe(map, '__keys'); + for (var keyName in map._data) { + keys.push(keyName); + } + return keys; + } + }, { + setup: function (obj) { + if (obj instanceof can.Map) { + obj = obj.serialize(); + } + this._data = {}; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + var defaultValues = this._setupDefaults(obj); + this._setupComputes(defaultValues); + var teardownMapping = obj && can.Map.helpers.addToMap(obj, this); + var data = can.extend(can.extend(true, {}, defaultValues), obj); + this.attr(data); + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + delete this._init; + }, + _setupComputes: function () { + var computes = this.constructor._computes; + for (var i = 0, len = computes.length, prop; i < len; i++) { + prop = computes[i]; + this[prop] = this[prop].clone(this); + this._computedBindings[prop] = { count: 0 }; + } + }, + _setupDefaults: function () { + return this.constructor.defaults || {}; + }, + _bindsetup: function () { + }, + _bindteardown: function () { + }, + _changes: function (ev, attr, how, newVal, oldVal) { + can.batch.trigger(this, { + type: attr, + batchNum: ev.batchNum, + target: ev.target + }, [ + newVal, + oldVal + ]); + }, + _triggerChange: function (attr, how, newVal, oldVal) { + if (bubble.isBubbling(this, 'change')) { + can.batch.trigger(this, { + type: 'change', + target: this + }, [ + attr, + how, + newVal, + oldVal + ]); + } else { + can.batch.trigger(this, attr, [ + newVal, + oldVal + ]); + } + if (how === 'remove' || how === 'add') { + can.batch.trigger(this, { + type: '__keys', + target: this + }); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var prop in data) { + if (data.hasOwnProperty(prop)) { + callback(data[prop], prop); + } + } + }, + attr: function (attr, val) { + var type = typeof attr; + if (type !== 'string' && type !== 'number') { + return this._attrs(attr, val); + } else if (arguments.length === 1) { + return this._get(attr); + } else { + this._set(attr, val); + return this; + } + }, + each: function () { + return can.each.apply(undefined, [this].concat(can.makeArray(arguments))); + }, + removeAttr: function (attr) { + var isList = can.List && this instanceof can.List, parts = can.Map.helpers.attrParts(attr), prop = parts.shift(), current = isList ? this[prop] : this._data[prop]; + if (parts.length && current) { + return current.removeAttr(parts); + } else { + if (typeof attr === 'string' && !!~attr.indexOf('.')) { + prop = attr; + } + this._remove(prop, current); + return current; + } + }, + _remove: function (prop, current) { + if (prop in this._data) { + delete this._data[prop]; + if (!(prop in this.constructor.prototype)) { + delete this[prop]; + } + this._triggerChange(prop, 'remove', undefined, current); + } + }, + _get: function (attr) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'); + if (dotIndex >= 0) { + var value = this.__get(attr); + if (value !== undefined) { + return value; + } + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + can.__observe(this, first); + var current = this.__get(first); + return current && current._get ? current._get(second) : undefined; + } else { + can.__observe(this, attr); + return this.__get(attr); + } + }, + __get: function (attr) { + if (attr) { + if (this._computedBindings[attr]) { + return this[attr](); + } else { + return this._data[attr]; + } + } else { + return this._data; + } + }, + __type: function (value, prop) { + if (!(value instanceof can.Map) && can.Map.helpers.canMakeObserve(value)) { + var cached = getMapFromObject(value); + if (cached) { + return cached; + } + if (can.isArray(value)) { + var List = can.List; + return new List(value); + } else { + var Map = this.constructor.Map || can.Map; + return new Map(value); + } + } + return value; + }, + _set: function (attr, value, keepKey) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'), current; + if (!keepKey && dotIndex >= 0) { + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + current = this._init ? undefined : this.__get(first); + if (Map.helpers.isObservable(current)) { + current._set(second, value); + } else { + throw 'can.Map: Object does not exist'; + } + } else { + if (this.__convert) { + value = this.__convert(attr, value); + } + current = this._init ? undefined : this.__get(attr); + this.__set(attr, this.__type(value, attr), current); + } + }, + __set: function (prop, value, current) { + if (value !== current) { + var changeType = current !== undefined || this.__get().hasOwnProperty(prop) ? 'set' : 'add'; + this.___set(prop, this.constructor._bubble.set(this, prop, value, current)); + if (!this._computedBindings[prop]) { + this._triggerChange(prop, changeType, value, current); + } + if (current) { + this.constructor._bubble.teardownFromParent(this, current); + } + } + }, + ___set: function (prop, val) { + if (this._computedBindings[prop]) { + this[prop](val); + } else { + this._data[prop] = val; + } + if (typeof this.constructor.prototype[prop] !== 'function' && !this._computedBindings[prop]) { + this[prop] = val; + } + }, + bind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (!computedBinding.count) { + computedBinding.count = 1; + var self = this; + computedBinding.handler = function (ev, newVal, oldVal) { + can.batch.trigger(self, { + type: eventName, + batchNum: ev.batchNum, + target: self + }, [ + newVal, + oldVal + ]); + }; + this[eventName].bind('change', computedBinding.handler); + } else { + computedBinding.count++; + } + } + this.constructor._bubble.bind(this, eventName); + return can.bindAndSetup.apply(this, arguments); + }, + unbind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (computedBinding.count === 1) { + computedBinding.count = 0; + this[eventName].unbind('change', computedBinding.handler); + delete computedBinding.handler; + } else { + computedBinding.count--; + } + } + this.constructor._bubble.unbind(this, eventName); + return can.unbindAndTeardown.apply(this, arguments); + }, + serialize: function () { + return can.Map.helpers.serialize(this, 'serialize', {}); + }, + _attrs: function (props, remove) { + if (props === undefined) { + return Map.helpers.serialize(this, 'attr', {}); + } + props = can.simpleExtend({}, props); + var prop, self = this, newVal; + can.batch.start(); + this.each(function (curVal, prop) { + if (prop === '_cid') { + return; + } + newVal = props[prop]; + if (newVal === undefined) { + if (remove) { + self.removeAttr(prop); + } + return; + } + if (self.__convert) { + newVal = self.__convert(prop, newVal); + } + if (Map.helpers.isObservable(newVal)) { + self.__set(prop, self.__type(newVal, prop), curVal); + } else if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + self.__set(prop, self.__type(newVal, prop), curVal); + } + delete props[prop]; + }); + for (prop in props) { + if (prop !== '_cid') { + newVal = props[prop]; + this._set(prop, newVal, true); + } + } + can.batch.stop(); + return this; + }, + compute: function (prop) { + if (can.isFunction(this.constructor.prototype[prop])) { + return can.compute(this[prop], this); + } else { + var reads = prop.split('.'), last = reads.length - 1, options = { args: [] }; + return can.compute(function (newVal) { + if (arguments.length) { + can.compute.read(this, reads.slice(0, last)).value.attr(reads[last], newVal); + } else { + return can.compute.read(this, reads, options).value; + } + }, this); + } + } + }); + Map.prototype.on = Map.prototype.bind; + Map.prototype.off = Map.prototype.unbind; + return Map; +}); +/*can@2.2.6#list/list*/ +define('can/list/list', [ + 'can/util/util', + 'can/map/map', + 'can/map/bubble' +], function (can, Map, bubble) { + var splice = [].splice, spliceRemovesProps = function () { + var obj = { + 0: 'a', + length: 1 + }; + splice.call(obj, 0, 1); + return !obj[0]; + }(); + var list = Map.extend({ Map: Map }, { + setup: function (instances, options) { + this.length = 0; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + this._setupComputes(); + instances = instances || []; + var teardownMapping; + if (can.isDeferred(instances)) { + this.replace(instances); + } else { + teardownMapping = instances.length && can.Map.helpers.addToMap(instances, this); + this.push.apply(this, can.makeArray(instances || [])); + } + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + can.simpleExtend(this, options); + delete this._init; + }, + _triggerChange: function (attr, how, newVal, oldVal) { + Map.prototype._triggerChange.apply(this, arguments); + var index = +attr; + if (!~('' + attr).indexOf('.') && !isNaN(index)) { + if (how === 'add') { + can.batch.trigger(this, how, [ + newVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else if (how === 'remove') { + can.batch.trigger(this, how, [ + oldVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else { + can.batch.trigger(this, how, [ + newVal, + index + ]); + } + } + }, + __get: function (attr) { + if (attr) { + if (this[attr] && this[attr].isComputed && can.isFunction(this.constructor.prototype[attr])) { + return this[attr](); + } else { + return this[attr]; + } + } else { + return this; + } + }, + __set: function (prop, value, current) { + prop = isNaN(+prop) || prop % 1 ? prop : +prop; + if (typeof prop === 'number' && prop > this.length - 1) { + var newArr = new Array(prop + 1 - this.length); + newArr[newArr.length - 1] = value; + this.push.apply(this, newArr); + return newArr; + } + return can.Map.prototype.__set.call(this, '' + prop, value, current); + }, + ___set: function (attr, val) { + this[attr] = val; + if (+attr >= this.length) { + this.length = +attr + 1; + } + }, + _remove: function (prop, current) { + if (isNaN(+prop)) { + delete this[prop]; + this._triggerChange(prop, 'remove', undefined, current); + } else { + this.splice(prop, 1); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var i = 0; i < data.length; i++) { + callback(data[i], i); + } + }, + serialize: function () { + return Map.helpers.serialize(this, 'serialize', []); + }, + splice: function (index, howMany) { + var args = can.makeArray(arguments), added = [], i, len, listIndex, allSame = args.length > 2; + index = index || 0; + for (i = 0, len = args.length - 2; i < len; i++) { + listIndex = i + 2; + args[listIndex] = this.__type(args[listIndex], listIndex); + added.push(args[listIndex]); + if (this[i + index] !== args[listIndex]) { + allSame = false; + } + } + if (allSame && this.length <= added.length) { + return added; + } + if (howMany === undefined) { + howMany = args[1] = this.length - index; + } + var removed = splice.apply(this, args); + if (!spliceRemovesProps) { + for (i = this.length; i < removed.length + this.length; i++) { + delete this[i]; + } + } + can.batch.start(); + if (howMany > 0) { + bubble.removeMany(this, removed); + this._triggerChange('' + index, 'remove', undefined, removed); + } + if (args.length > 2) { + for (i = 0, len = added.length; i < len; i++) { + bubble.set(this, i, added[i]); + } + this._triggerChange('' + index, 'add', added, removed); + } + can.batch.stop(); + return removed; + }, + _attrs: function (items, remove) { + if (items === undefined) { + return Map.helpers.serialize(this, 'attr', []); + } + items = can.makeArray(items); + can.batch.start(); + this._updateAttrs(items, remove); + can.batch.stop(); + }, + _updateAttrs: function (items, remove) { + var len = Math.min(items.length, this.length); + for (var prop = 0; prop < len; prop++) { + var curVal = this[prop], newVal = items[prop]; + if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + this._set(prop, newVal); + } else { + } + } + if (items.length > this.length) { + this.push.apply(this, items.slice(this.length)); + } else if (items.length < this.length && remove) { + this.splice(items.length); + } + } + }), getArgs = function (args) { + return args[0] && can.isArray(args[0]) ? args[0] : can.makeArray(args); + }; + can.each({ + push: 'length', + unshift: 0 + }, function (where, name) { + var orig = [][name]; + list.prototype[name] = function () { + var args = [], len = where ? this.length : 0, i = arguments.length, res, val; + while (i--) { + val = arguments[i]; + args[i] = bubble.set(this, i, this.__type(val, i)); + } + res = orig.apply(this, args); + if (!this.comparator || args.length) { + this._triggerChange('' + len, 'add', args, undefined); + } + return res; + }; + }); + can.each({ + pop: 'length', + shift: 0 + }, function (where, name) { + list.prototype[name] = function () { + if (!this.length) { + return undefined; + } + var args = getArgs(arguments), len = where && this.length ? this.length - 1 : 0; + var res = [][name].apply(this, args); + this._triggerChange('' + len, 'remove', undefined, [res]); + if (res && res.unbind) { + bubble.remove(this, res); + } + return res; + }; + }); + can.extend(list.prototype, { + indexOf: function (item, fromIndex) { + this.attr('length'); + return can.inArray(item, this, fromIndex); + }, + join: function () { + return [].join.apply(this.attr(), arguments); + }, + reverse: function () { + var list = [].reverse.call(can.makeArray(this)); + this.replace(list); + }, + slice: function () { + var temp = Array.prototype.slice.apply(this, arguments); + return new this.constructor(temp); + }, + concat: function () { + var args = []; + can.each(can.makeArray(arguments), function (arg, i) { + args[i] = arg instanceof can.List ? arg.serialize() : arg; + }); + return new this.constructor(Array.prototype.concat.apply(this.serialize(), args)); + }, + forEach: function (cb, thisarg) { + return can.each(this, cb, thisarg || this); + }, + replace: function (newList) { + if (can.isDeferred(newList)) { + newList.then(can.proxy(this.replace, this)); + } else { + this.splice.apply(this, [ + 0, + this.length + ].concat(can.makeArray(newList || []))); + } + return this; + }, + filter: function (callback, thisArg) { + var filteredList = new can.List(), self = this, filtered; + this.each(function (item, index, list) { + filtered = callback.call(thisArg | self, item, index, self); + if (filtered) { + filteredList.push(item); + } + }); + return filteredList; + } + }); + can.List = Map.List = list; + return can.List; +}); +/*can@2.2.6#compute/read*/ +define('can/compute/read', ['can/util/util'], function (can) { + var read = function (parent, reads, options) { + options = options || {}; + var state = { foundObservable: false }; + var cur = readValue(parent, 0, reads, options, state), type, prev, readLength = reads.length, i = 0; + while (i < readLength) { + prev = cur; + for (var r = 0, readersLength = read.propertyReaders.length; r < readersLength; r++) { + var reader = read.propertyReaders[r]; + if (reader.test(cur)) { + cur = reader.read(cur, reads[i], i, options, state); + break; + } + } + i = i + 1; + cur = readValue(cur, i, reads, options, state, prev); + type = typeof cur; + if (i < reads.length && (cur === null || type !== 'function' && type !== 'object')) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1, cur); + } + return { + value: undefined, + parent: prev + }; + } + } + if (cur === undefined) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1); + } + } + return { + value: cur, + parent: prev + }; + }; + var readValue = function (value, index, reads, options, state, prev) { + var usedValueReader; + do { + usedValueReader = false; + for (var i = 0, len = read.valueReaders.length; i < len; i++) { + if (read.valueReaders[i].test(value, index, reads, options)) { + value = read.valueReaders[i].read(value, index, reads, options, state, prev); + } + } + } while (usedValueReader); + return value; + }; + read.valueReaders = [ + { + name: 'compute', + test: function (value, i, reads, options) { + return value && value.isComputed; + }, + read: function (value, i, reads, options, state) { + if (options.isArgument && i === reads.length) { + return value; + } + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, i); + state.foundObservable = true; + } + return value instanceof can.Compute ? value.get() : value(); + } + }, + { + name: 'function', + test: function (value, i, reads, options) { + var type = typeof value; + return type === 'function' && !value.isComputed && (options.executeAnonymousFunctions || options.isArgument && i === reads.length) && !(can.Construct && value.prototype instanceof can.Construct) && !(can.route && value === can.route); + }, + read: function (value, i, reads, options, state, prev) { + if (options.isArgument && i === reads.length) { + return options.proxyMethods !== false ? can.proxy(value, prev) : value; + } + return value.call(prev); + } + } + ]; + read.propertyReaders = [ + { + name: 'map', + test: can.isMapLike, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + if (typeof value[prop] === 'function' && value.constructor.prototype[prop] === value[prop]) { + if (options.returnObserveMethods) { + return value[prop]; + } else if (prop === 'constructor' && value instanceof can.Construct || value[prop].prototype instanceof can.Construct) { + return value[prop]; + } else { + return value[prop].apply(value, options.args || []); + } + } else { + return value.attr(prop); + } + } + }, + { + name: 'promise', + test: function (value) { + return can.isPromise(value); + }, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + var observeData = value.__observeData; + if (!value.__observeData) { + observeData = value.__observeData = { + isPending: true, + state: 'pending', + isResolved: false, + isRejected: false, + value: undefined, + reason: undefined + }; + can.cid(observeData); + can.simpleExtend(observeData, can.event); + value.then(function (value) { + observeData.isPending = false; + observeData.isResolved = true; + observeData.value = value; + observeData.state = 'resolved'; + observeData.dispatch('state', [ + 'resolved', + 'pending' + ]); + }, function (reason) { + observeData.isPending = false; + observeData.isRejected = true; + observeData.reason = reason; + observeData.state = 'rejected'; + observeData.dispatch('state', [ + 'rejected', + 'pending' + ]); + }); + } + can.__observe(observeData, 'state'); + return prop in observeData ? observeData[prop] : value[prop]; + } + }, + { + name: 'object', + test: function () { + return true; + }, + read: function (value, prop) { + if (value == null) { + return undefined; + } else { + return value[prop]; + } + } + } + ]; + read.write = function (parent, key, value, options) { + options = options || {}; + if (can.isMapLike(parent)) { + if (!options.isArgument && parent._data && parent._data[key] && parent._data[key].isComputed) { + return parent._data[key](value); + } else { + return parent.attr(key, value); + } + } + if (parent[key] && parent[key].isComputed) { + return parent[key](value); + } + if (typeof parent === 'object') { + parent[key] = value; + } + }; + return read; +}); +/*can@2.2.6#compute/get_value_and_bind*/ +define('can/compute/get_value_and_bind', ['can/util/util'], function () { + function observe(func, context, oldInfo, onchanged) { + var info = getValueAndObserved(func, context), newObserveSet = info.observed, oldObserved = oldInfo.observed; + if (info.names !== oldInfo.names) { + bindNewSet(oldObserved, newObserveSet, onchanged); + unbindOldSet(oldObserved, onchanged); + } + can.batch.afterPreviousEvents(function () { + info.ready = true; + }); + return info; + } + var observedStack = []; + can.__isRecordingObserves = function () { + return observedStack.length; + }; + can.__observe = can.__reading = function (obj, event) { + if (observedStack.length) { + var name = obj._cid + '|' + event, top = observedStack[observedStack.length - 1]; + top.names += name; + top.observed[name] = { + obj: obj, + event: event + '' + }; + } + }; + can.__notObserve = function (fn) { + return function () { + var previousReads = can.__clearObserved(); + var res = fn.apply(this, arguments); + can.__setObserved(previousReads); + return res; + }; + }; + can.__clearObserved = can.__clearReading = function () { + if (observedStack.length) { + var ret = observedStack[observedStack.length - 1]; + observedStack[observedStack.length - 1] = { observed: {} }; + return ret; + } + }; + can.__setObserved = can.__setReading = function (o) { + if (observedStack.length) { + observedStack[observedStack.length - 1] = o; + } + }; + can.__addObserved = can.__addReading = function (o) { + if (observedStack.length) { + can.simpleExtend(observedStack[observedStack.length - 1], o); + } + }; + var getValueAndObserved = function (func, self) { + observedStack.push({ + names: '', + observed: {} + }); + var value = func.call(self); + var stackItem = observedStack.pop(); + stackItem.value = value; + return stackItem; + }; + var bindNewSet = function (oldObserved, newObserveSet, onchanged) { + for (var name in newObserveSet) { + bindOrPreventUnbinding(oldObserved, newObserveSet, name, onchanged); + } + }; + var bindOrPreventUnbinding = function (oldObserved, newObserveSet, name, onchanged) { + if (oldObserved[name]) { + delete oldObserved[name]; + } else { + var obEv = newObserveSet[name]; + obEv.obj.bind(obEv.event, onchanged); + } + }; + var unbindOldSet = function (oldObserved, onchanged) { + for (var name in oldObserved) { + var obEv = oldObserved[name]; + obEv.obj.unbind(obEv.event, onchanged); + } + }; + return observe; +}); +/*can@2.2.6#compute/proto_compute*/ +define('can/compute/proto_compute', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/compute/read', + 'can/compute/get_value_and_bind', + 'can/util/batch/batch' +], function (can, bind, read, getValueAndBind) { + var updateOnChange = function (compute, newValue, oldValue, batchNum) { + if (newValue !== oldValue) { + can.batch.trigger(compute, batchNum ? { + type: 'change', + batchNum: batchNum + } : 'change', [ + newValue, + oldValue + ]); + } + }; + var setupComputeHandlers = function (compute, func, context, singleBind) { + var readInfo, onchanged, batchNum; + singleBind = false; + return { + on: function (updater) { + var self = this; + if (!onchanged) { + onchanged = function (ev) { + if (readInfo.ready && compute.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + if (singleBind) { + newValue = func.call(context); + readInfo.value = newValue; + } else { + readInfo = getValueAndBind(func, context, readInfo, onchanged); + newValue = readInfo.value; + } + self.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }; + } + readInfo = getValueAndBind(func, context, { observed: {} }, onchanged); + if (singleBind) { + func = can.__notObserve(func); + } + compute.value = readInfo.value; + compute.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function (updater) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, onchanged); + } + } + }; + }; + var k = function () { + }; + var updater = function (newVal, oldVal, batchNum) { + this.value = newVal; + updateOnChange(this, newVal, oldVal, batchNum); + }, asyncGet = function (fn, context, lastSetValue) { + return function () { + return fn.call(context, lastSetValue.get()); + }; + }, asyncUpdater = function (context, oldUpdater) { + return function (newVal) { + if (newVal !== undefined) { + oldUpdater(newVal, context.value); + } + }; + }; + can.Compute = function (getterSetter, context, eventName, bindOnce) { + var args = []; + for (var i = 0, arglen = arguments.length; i < arglen; i++) { + args[i] = arguments[i]; + } + var contextType = typeof args[1]; + if (typeof args[0] === 'function') { + this._setupGetterSetterFn(args[0], args[1], args[2], args[3]); + } else if (args[1]) { + if (contextType === 'string') { + this._setupContextString(args[0], args[1], args[2]); + } else if (contextType === 'function') { + this._setupContextFunction(args[0], args[1], args[2]); + } else { + if (args[1] && args[1].fn) { + this._setupAsyncCompute(args[0], args[1]); + } else { + this._setupContextSettings(args[0], args[1]); + } + } + } else { + this._setupInitialValue(args[0]); + } + this._args = args; + this.isComputed = true; + can.cid(this, 'compute'); + }; + can.simpleExtend(can.Compute.prototype, { + _bindsetup: can.__notObserve(function () { + this.bound = true; + this._on(this.updater); + }), + _bindteardown: function () { + this._off(this.updater); + this.bound = false; + }, + bind: can.bindAndSetup, + unbind: can.unbindAndTeardown, + clone: function (context) { + if (context && typeof this._args[0] === 'function') { + this._args[1] = context; + } else if (context) { + this._args[2] = context; + } + return new can.Compute(this._args[0], this._args[1], this._args[2], this._args[3]); + }, + _on: k, + _off: k, + get: function () { + if (can.__isRecordingObserves() && this._canObserve !== false) { + can.__observe(this, 'change'); + if (!this.bound) { + can.Compute.temporarilyBind(this); + } + } + if (this.bound) { + return this.value; + } else { + return this._get(); + } + }, + _get: function () { + return this.value; + }, + set: function (newVal) { + var old = this.value; + var setVal = this._set(newVal, old); + if (this.hasDependencies) { + if (this._setUpdates) { + return this.value; + } + return this._get(); + } + if (setVal === undefined) { + this.value = this._get(); + } else { + this.value = setVal; + } + updateOnChange(this, this.value, old); + return this.value; + }, + _set: function (newVal) { + return this.value = newVal; + }, + updater: updater, + _computeFn: function (newVal) { + if (arguments.length) { + return this.set(newVal); + } + return this.get(); + }, + toFunction: function () { + return can.proxy(this._computeFn, this); + }, + _setupGetterSetterFn: function (getterSetter, context, eventName, bindOnce) { + this._set = can.proxy(getterSetter, context); + this._get = can.proxy(getterSetter, context); + this._canObserve = eventName === false ? false : true; + var handlers = setupComputeHandlers(this, getterSetter, context || this, bindOnce); + this._on = handlers.on; + this._off = handlers.off; + }, + _setupContextString: function (target, propertyName, eventName) { + var isObserve = can.isMapLike(target), self = this, handler = function (ev, newVal, oldVal) { + self.updater(newVal, oldVal, ev.batchNum); + }; + if (isObserve) { + this.hasDependencies = true; + this._get = function () { + return target.attr(propertyName); + }; + this._set = function (val) { + target.attr(propertyName, val); + }; + this._on = function (update) { + target.bind(eventName || propertyName, handler); + this.value = this._get(); + }; + this._off = function () { + return target.unbind(eventName || propertyName, handler); + }; + } else { + this._get = can.proxy(this._get, target); + this._set = can.proxy(this._set, target); + } + }, + _setupContextFunction: function (initialValue, setter, eventName) { + this.value = initialValue; + this._set = setter; + can.simpleExtend(this, eventName); + }, + _setupContextSettings: function (initialValue, settings) { + this.value = initialValue; + this._set = settings.set ? can.proxy(settings.set, settings) : this._set; + this._get = settings.get ? can.proxy(settings.get, settings) : this._get; + if (!settings.__selfUpdater) { + var self = this, oldUpdater = this.updater; + this.updater = function () { + oldUpdater.call(self, self._get(), self.value); + }; + } + this._on = settings.on ? settings.on : this._on; + this._off = settings.off ? settings.off : this._off; + }, + _setupAsyncCompute: function (initialValue, settings) { + this.value = initialValue; + var oldUpdater = can.proxy(this.updater, this), self = this, fn = settings.fn, data; + this.updater = oldUpdater; + var lastSetValue = new can.Compute(initialValue); + this.lastSetValue = lastSetValue; + this._setUpdates = true; + this._set = function (newVal) { + if (newVal === lastSetValue.get()) { + return this.value; + } + return lastSetValue.set(newVal); + }; + this._get = asyncGet(fn, settings.context, lastSetValue); + if (fn.length === 0) { + data = setupComputeHandlers(this, fn, settings.context); + } else if (fn.length === 1) { + data = setupComputeHandlers(this, function () { + return fn.call(settings.context, lastSetValue.get()); + }, settings); + } else { + this.updater = asyncUpdater(this, oldUpdater); + data = setupComputeHandlers(this, function () { + var res = fn.call(settings.context, lastSetValue.get(), function (newVal) { + oldUpdater(newVal, self.value); + }); + return res !== undefined ? res : this.value; + }, settings); + } + this._on = data.on; + this._off = data.off; + }, + _setupInitialValue: function (initialValue) { + this.value = initialValue; + } + }); + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.Compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.Compute.async = function (initialValue, asyncComputer, context) { + return new can.Compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.Compute.read = read; + can.Compute.set = read.write; + can.Compute.truthy = function (compute) { + return new can.Compute(function () { + var res = compute.get(); + if (typeof res === 'function') { + res = res.get(); + } + return !!res; + }); + }; + return can.Compute; +}); +/*can@2.2.6#compute/compute*/ +define('can/compute/compute', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/util/batch/batch', + 'can/compute/proto_compute' +], function (can, bind) { + can.compute = function (getterSetter, context, eventName, bindOnce) { + var internalCompute = new can.Compute(getterSetter, context, eventName, bindOnce); + var compute = function (val) { + if (arguments.length) { + return internalCompute.set(val); + } + return internalCompute.get(); + }; + compute.bind = can.proxy(internalCompute.bind, internalCompute); + compute.unbind = can.proxy(internalCompute.unbind, internalCompute); + compute.isComputed = internalCompute.isComputed; + compute.clone = function (ctx) { + if (typeof getterSetter === 'function') { + context = ctx; + } + return can.compute(getterSetter, context, ctx, bindOnce); + }; + compute.computeInstance = internalCompute; + return compute; + }; + var k = function () { + }; + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.compute.truthy = function (compute) { + return can.compute(function () { + var res = compute(); + if (typeof res === 'function') { + res = res(); + } + return !!res; + }); + }; + can.compute.async = function (initialValue, asyncComputer, context) { + return can.compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.compute.read = can.Compute.read; + can.compute.set = can.Compute.set; + return can.compute; +}); +/*can@2.2.6#observe/observe*/ +define('can/observe/observe', [ + 'can/util/util', + 'can/map/map', + 'can/list/list', + 'can/compute/compute' +], function (can) { + can.Observe = can.Map; + can.Observe.startBatch = can.batch.start; + can.Observe.stopBatch = can.batch.stop; + can.Observe.triggerBatch = can.batch.trigger; + return can; +}); +/*can@2.2.6#view/scope/compute_data*/ +define('can/view/scope/compute_data', [ + 'can/util/util', + 'can/compute/compute', + 'can/compute/get_value_and_bind' +], function (can, compute, getValueAndBind) { + var isFastPath = function (computeData) { + return computeData.reads && computeData.reads.length === 1 && computeData.root instanceof can.Map && !can.isFunction(computeData.root[computeData.reads[0]]); + }; + var getValueAndBindScopeRead = function (scopeRead, scopeReadChanged) { + return getValueAndBind(scopeRead, null, { observed: {} }, scopeReadChanged); + }; + var unbindScopeRead = function (readInfo, scopeReadChanged) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, scopeReadChanged); + } + }; + var getValueAndBindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + var target = computeData.root, prop = computeData.reads[0]; + target.bind(prop, singlePropertyReadChanged); + return { + value: computeData.initialValue, + observed: { something: true } + }; + }; + var unbindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + computeData.root.unbind(computeData.reads[0], singlePropertyReadChanged); + }; + var scopeReader = function (scope, key, options, computeData, newVal) { + if (arguments.length > 4) { + if (computeData.root.isComputed) { + computeData.root(newVal); + } else if (computeData.reads.length) { + var last = computeData.reads.length - 1; + var obj = computeData.reads.length ? can.compute.read(computeData.root, computeData.reads.slice(0, last)).value : computeData.root; + can.compute.set(obj, computeData.reads[last], newVal, options); + } + } else { + if (computeData.root) { + return can.compute.read(computeData.root, computeData.reads, options).value; + } + var data = scope.read(key, options); + computeData.scope = data.scope; + computeData.initialValue = data.value; + computeData.reads = data.reads; + computeData.root = data.rootObserve; + return data.value; + } + }; + return function (scope, key, options) { + options = options || { args: [] }; + var computeData = {}, scopeRead = function (newVal) { + if (arguments.length) { + return scopeReader(scope, key, options, computeData, newVal); + } else { + return scopeReader(scope, key, options, computeData); + } + }, batchNum, readInfo, scopeReadChanged = function (ev) { + if (readInfo.ready && compute.computeInstance.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + readInfo = getValueAndBind(scopeRead, null, readInfo, scopeReadChanged); + newValue = readInfo.value; + compute.computeInstance.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }, singlePropertyReadChanged = function (ev, newVal, oldVal) { + if (typeof newVal !== 'function') { + compute.computeInstance.updater(newVal, oldVal, ev.batchNum); + } else { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + isFastPathBound = false; + compute.computeInstance.updater(readInfo.value, oldVal, ev.batchNum); + } + }, isFastPathBound = false, compute = can.compute(undefined, { + on: function () { + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + if (isFastPath(computeData)) { + var oldReadInfo = readInfo; + readInfo = getValueAndBindSinglePropertyRead(computeData, singlePropertyReadChanged); + unbindScopeRead(oldReadInfo, scopeReadChanged); + isFastPathBound = true; + } + compute.computeInstance.value = readInfo.value; + compute.computeInstance.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function () { + if (isFastPathBound) { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + } else { + unbindScopeRead(readInfo, scopeReadChanged); + } + }, + set: scopeRead, + get: scopeRead, + __selfUpdater: true + }); + computeData.compute = compute; + return computeData; + }; +}); +/*can@2.2.6#view/scope/scope*/ +define('can/view/scope/scope', [ + 'can/util/util', + 'can/view/scope/compute_data', + 'can/construct/construct', + 'can/map/map', + 'can/list/list', + 'can/view/view', + 'can/compute/compute' +], function (can, makeComputeData) { + var escapeReg = /(\\)?\./g, escapeDotReg = /\\\./g, getNames = function (attr) { + var names = [], last = 0; + attr.replace(escapeReg, function (first, second, index) { + if (!second) { + names.push(attr.slice(last, index).replace(escapeDotReg, '.')); + last = index + first.length; + } + }); + names.push(attr.slice(last).replace(escapeDotReg, '.')); + return names; + }; + var Scope = can.Construct.extend({ read: can.compute.read }, { + init: function (context, parent) { + this._context = context; + this._parent = parent; + this.__cache = {}; + }, + attr: can.__notObserve(function (key, value) { + var options = { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }, res = this.read(key, options); + if (arguments.length === 2) { + var lastIndex = key.lastIndexOf('.'), readKey = lastIndex !== -1 ? key.substring(0, lastIndex) : '.', obj = this.read(readKey, options).value; + if (lastIndex !== -1) { + key = key.substring(lastIndex + 1, key.length); + } + can.compute.set(obj, key, value, options); + } + return res.value; + }), + add: function (context) { + if (context !== this._context) { + return new this.constructor(context, this); + } else { + return this; + } + }, + computeData: function (key, options) { + return makeComputeData(this, key, options); + }, + compute: function (key, options) { + return this.computeData(key, options).compute; + }, + read: function (attr, options) { + var stopLookup; + if (attr.substr(0, 2) === './') { + stopLookup = true; + attr = attr.substr(2); + } else if (attr.substr(0, 3) === '../') { + return this._parent.read(attr.substr(3), options); + } else if (attr === '..') { + return { value: this._parent._context }; + } else if (attr === '.' || attr === 'this') { + return { value: this._context }; + } + var names = attr.indexOf('\\.') === -1 ? attr.split('.') : getNames(attr), context, scope = this, defaultObserve, defaultReads = [], defaultPropertyDepth = -1, defaultComputeReadings, defaultScope, currentObserve, currentReads; + while (scope) { + context = scope._context; + if (context !== null && (typeof context === 'object' || typeof context === 'function')) { + var data = can.compute.read(context, names, can.simpleExtend({ + foundObservable: function (observe, nameIndex) { + currentObserve = observe; + currentReads = names.slice(nameIndex); + }, + earlyExit: function (parentValue, nameIndex) { + if (nameIndex > defaultPropertyDepth) { + defaultObserve = currentObserve; + defaultReads = currentReads; + defaultPropertyDepth = nameIndex; + defaultScope = scope; + defaultComputeReadings = can.__clearReading(); + } + }, + executeAnonymousFunctions: true + }, options)); + if (data.value !== undefined) { + return { + scope: scope, + rootObserve: currentObserve, + value: data.value, + reads: currentReads + }; + } + } + can.__clearReading(); + if (!stopLookup) { + scope = scope._parent; + } else { + scope = null; + } + } + if (defaultObserve) { + can.__setReading(defaultComputeReadings); + return { + scope: defaultScope, + rootObserve: defaultObserve, + reads: defaultReads, + value: undefined + }; + } else { + return { + names: names, + value: undefined + }; + } + } + }); + can.view.Scope = Scope; + return Scope; +}); +/*can@2.2.6#view/scanner*/ +define('can/view/scanner', [ + 'can/view/view', + 'can/view/elements', + 'can/view/callbacks/callbacks' +], function (can, elements, viewCallbacks) { + var newLine = /(\r|\n)+/g, notEndTag = /\//, clean = function (content) { + return content.split('\\').join('\\\\').split('\n').join('\\n').split('"').join('\\"').split('\t').join('\\t'); + }, getTag = function (tagName, tokens, i) { + if (tagName) { + return tagName; + } else { + while (i < tokens.length) { + if (tokens[i] === '<' && !notEndTag.test(tokens[i + 1])) { + return elements.reverseTagMap[tokens[i + 1]] || 'span'; + } + i++; + } + } + return ''; + }, bracketNum = function (content) { + return --content.split('{').length - --content.split('}').length; + }, myEval = function (script) { + eval(script); + }, attrReg = /([^\s]+)[\s]*=[\s]*$/, startTxt = 'var ___v1ew = [];', finishTxt = 'return ___v1ew.join(\'\')', put_cmd = '___v1ew.push(\n', insert_cmd = put_cmd, htmlTag = null, quote = null, beforeQuote = null, rescan = null, getAttrName = function () { + var matches = beforeQuote.match(attrReg); + return matches && matches[1]; + }, status = function () { + return quote ? '\'' + getAttrName() + '\'' : htmlTag ? 1 : 0; + }, top = function (stack) { + return stack[stack.length - 1]; + }, Scanner; + can.view.Scanner = Scanner = function (options) { + can.extend(this, { + text: {}, + tokens: [] + }, options); + this.text.options = this.text.options || ''; + this.tokenReg = []; + this.tokenSimple = { + '<': '<', + '>': '>', + '"': '"', + '\'': '\'' + }; + this.tokenComplex = []; + this.tokenMap = {}; + for (var i = 0, token; token = this.tokens[i]; i++) { + if (token[2]) { + this.tokenReg.push(token[2]); + this.tokenComplex.push({ + abbr: token[1], + re: new RegExp(token[2]), + rescan: token[3] + }); + } else { + this.tokenReg.push(token[1]); + this.tokenSimple[token[1]] = token[0]; + } + this.tokenMap[token[0]] = token[1]; + } + this.tokenReg = new RegExp('(' + this.tokenReg.slice(0).concat([ + '<', + '>', + '"', + '\'' + ]).join('|') + ')', 'g'); + }; + Scanner.prototype = { + helpers: [], + scan: function (source, name) { + var tokens = [], last = 0, simple = this.tokenSimple, complex = this.tokenComplex; + source = source.replace(newLine, '\n'); + if (this.transform) { + source = this.transform(source); + } + source.replace(this.tokenReg, function (whole, part) { + var offset = arguments[arguments.length - 2]; + if (offset > last) { + tokens.push(source.substring(last, offset)); + } + if (simple[whole]) { + tokens.push(whole); + } else { + for (var i = 0, token; token = complex[i]; i++) { + if (token.re.test(whole)) { + tokens.push(token.abbr); + if (token.rescan) { + tokens.push(token.rescan(part)); + } + break; + } + } + } + last = offset + part.length; + }); + if (last < source.length) { + tokens.push(source.substr(last)); + } + var content = '', buff = [startTxt + (this.text.start || '')], put = function (content, bonus) { + buff.push(put_cmd, '"', clean(content), '"' + (bonus || '') + ');'); + }, endStack = [], lastToken, startTag = null, magicInTag = false, specialStates = { + attributeHookups: [], + tagHookups: [], + lastTagHookup: '' + }, popTagHookup = function () { + specialStates.lastTagHookup = specialStates.tagHookups.pop() + specialStates.tagHookups.length; + }, tagName = '', tagNames = [], popTagName = false, bracketCount, specialAttribute = false, i = 0, token, tmap = this.tokenMap, attrName; + htmlTag = quote = beforeQuote = null; + for (; (token = tokens[i++]) !== undefined;) { + if (startTag === null) { + switch (token) { + case tmap.left: + case tmap.escapeLeft: + case tmap.returnLeft: + magicInTag = htmlTag && 1; + case tmap.commentLeft: + startTag = token; + if (content.length) { + put(content); + } + content = ''; + break; + case tmap.escapeFull: + magicInTag = htmlTag && 1; + rescan = 1; + startTag = tmap.escapeLeft; + if (content.length) { + put(content); + } + rescan = tokens[i++]; + content = rescan.content || rescan; + if (rescan.before) { + put(rescan.before); + } + tokens.splice(i, 0, tmap.right); + break; + case tmap.commentFull: + break; + case tmap.templateLeft: + content += tmap.left; + break; + case '<': + if (tokens[i].indexOf('!--') !== 0) { + htmlTag = 1; + magicInTag = 0; + } + content += token; + break; + case '>': + htmlTag = 0; + var emptyElement = content.substr(content.length - 1) === '/' || content.substr(content.length - 2) === '--', attrs = ''; + if (specialStates.attributeHookups.length) { + attrs = 'attrs: [\'' + specialStates.attributeHookups.join('\',\'') + '\'], '; + specialStates.attributeHookups = []; + } + if (tagName + specialStates.tagHookups.length !== specialStates.lastTagHookup && tagName === top(specialStates.tagHookups)) { + if (emptyElement) { + content = content.substr(0, content.length - 1); + } + buff.push(put_cmd, '"', clean(content), '"', ',can.view.pending({tagName:\'' + tagName + '\',' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options); + if (emptyElement) { + buff.push('}));'); + content = '/>'; + popTagHookup(); + } else if (tokens[i] === '<' && tokens[i + 1] === '/' + tagName) { + buff.push('}));'); + content = token; + popTagHookup(); + } else { + buff.push(',subtemplate: function(' + this.text.argNames + '){\n' + startTxt + (this.text.start || '')); + content = ''; + } + } else if (magicInTag || !popTagName && elements.tagToContentPropMap[tagNames[tagNames.length - 1]] || attrs) { + var pendingPart = ',can.view.pending({' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options + '}),"'; + if (emptyElement) { + put(content.substr(0, content.length - 1), pendingPart + '/>"'); + } else { + put(content, pendingPart + '>"'); + } + content = ''; + magicInTag = 0; + } else { + content += token; + } + if (emptyElement || popTagName) { + tagNames.pop(); + tagName = tagNames[tagNames.length - 1]; + popTagName = false; + } + specialStates.attributeHookups = []; + break; + case '\'': + case '"': + if (htmlTag) { + if (quote && quote === token) { + quote = null; + var attr = getAttrName(); + if (viewCallbacks.attr(attr)) { + specialStates.attributeHookups.push(attr); + } + if (specialAttribute) { + content += token; + put(content); + buff.push(finishTxt, '}));\n'); + content = ''; + specialAttribute = false; + break; + } + } else if (quote === null) { + quote = token; + beforeQuote = lastToken; + attrName = getAttrName(); + if (tagName === 'img' && attrName === 'src' || attrName === 'style') { + put(content.replace(attrReg, '')); + content = ''; + specialAttribute = true; + buff.push(insert_cmd, 'can.view.txt(2,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt); + put(attrName + '=' + token); + break; + } + } + } + default: + if (lastToken === '<') { + tagName = token.substr(0, 3) === '!--' ? '!--' : token.split(/\s/)[0]; + var isClosingTag = false, cleanedTagName; + if (tagName.indexOf('/') === 0) { + isClosingTag = true; + cleanedTagName = tagName.substr(1); + } + if (isClosingTag) { + if (top(tagNames) === cleanedTagName) { + tagName = cleanedTagName; + popTagName = true; + } + if (top(specialStates.tagHookups) === cleanedTagName) { + put(content.substr(0, content.length - 1)); + buff.push(finishTxt + '}}) );'); + content = '><'; + popTagHookup(); + } + } else { + if (tagName.lastIndexOf('/') === tagName.length - 1) { + tagName = tagName.substr(0, tagName.length - 1); + } + if (tagName !== '!--' && viewCallbacks.tag(tagName)) { + if (tagName === 'content' && elements.tagMap[top(tagNames)]) { + token = token.replace('content', elements.tagMap[top(tagNames)]); + } + specialStates.tagHookups.push(tagName); + } + tagNames.push(tagName); + } + } + content += token; + break; + } + } else { + switch (token) { + case tmap.right: + case tmap.returnRight: + switch (startTag) { + case tmap.left: + bracketCount = bracketNum(content); + if (bracketCount === 1) { + buff.push(insert_cmd, 'can.view.txt(0,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt, content); + endStack.push({ + before: '', + after: finishTxt + '}));\n' + }); + } else { + last = endStack.length && bracketCount === -1 ? endStack.pop() : { after: ';' }; + if (last.before) { + buff.push(last.before); + } + buff.push(content, ';', last.after); + } + break; + case tmap.escapeLeft: + case tmap.returnLeft: + bracketCount = bracketNum(content); + if (bracketCount) { + endStack.push({ + before: finishTxt, + after: '}));\n' + }); + } + var escaped = startTag === tmap.escapeLeft ? 1 : 0, commands = { + insert: insert_cmd, + tagName: getTag(tagName, tokens, i), + status: status(), + specialAttribute: specialAttribute + }; + for (var ii = 0; ii < this.helpers.length; ii++) { + var helper = this.helpers[ii]; + if (helper.name.test(content)) { + content = helper.fn(content, commands); + if (helper.name.source === /^>[\s]*\w*/.source) { + escaped = 0; + } + break; + } + } + if (typeof content === 'object') { + if (content.startTxt && content.end && specialAttribute) { + buff.push(insert_cmd, 'can.view.toStr( ', content.content, '() ) );'); + } else { + if (content.startTxt) { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || (content.escaped != null ? content.escaped : escaped)) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\n'); + } else if (content.startOnlyTxt) { + buff.push(insert_cmd, 'can.view.onlytxt(this,\n'); + } + buff.push(content.content); + if (content.end) { + buff.push('));'); + } + } + } else if (specialAttribute) { + buff.push(insert_cmd, content, ');'); + } else { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || escaped) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\nfunction(){ ' + (this.text.escape || '') + 'return ', content, bracketCount ? startTxt : '}));\n'); + } + if (rescan && rescan.after && rescan.after.length) { + put(rescan.after.length); + rescan = null; + } + break; + } + startTag = null; + content = ''; + break; + case tmap.templateLeft: + content += tmap.left; + break; + default: + content += token; + break; + } + } + lastToken = token; + } + if (content.length) { + put(content); + } + buff.push(';'); + var template = buff.join(''), out = { out: (this.text.outStart || '') + template + ' ' + finishTxt + (this.text.outEnd || '') }; + myEval.call(out, 'this.fn = (function(' + this.text.argNames + '){' + out.out + '});\r\n//# sourceURL=' + name + '.js'); + return out; + } + }; + can.view.pending = function (viewData) { + var hooks = can.view.getHooks(); + return can.view.hook(function (el) { + can.each(hooks, function (fn) { + fn(el); + }); + viewData.templateType = 'legacy'; + if (viewData.tagName) { + viewCallbacks.tagHandler(el, viewData.tagName, viewData); + } + can.each(viewData && viewData.attrs || [], function (attributeName) { + viewData.attributeName = attributeName; + var callback = viewCallbacks.attr(attributeName); + if (callback) { + callback(el, viewData); + } + }); + }); + }; + can.view.tag('content', function (el, tagData) { + return tagData.scope; + }); + can.view.Scanner = Scanner; + return Scanner; +}); +/*can@2.2.6#view/node_lists/node_lists*/ +define('can/view/node_lists/node_lists', [ + 'can/util/util', + 'can/view/elements' +], function (can) { + var canExpando = true; + try { + document.createTextNode('')._ = 0; + } catch (ex) { + canExpando = false; + } + var nodeMap = {}, textNodeMap = {}, expando = 'ejs_' + Math.random(), _id = 0, id = function (node, localMap) { + var _textNodeMap = localMap || textNodeMap; + var id = readId(node, _textNodeMap); + if (id) { + return id; + } else { + if (canExpando || node.nodeType !== 3) { + ++_id; + return node[expando] = (node.nodeName ? 'element_' : 'obj_') + _id; + } else { + ++_id; + _textNodeMap['text_' + _id] = node; + return 'text_' + _id; + } + } + }, readId = function (node, textNodeMap) { + if (canExpando || node.nodeType !== 3) { + return node[expando]; + } else { + for (var textNodeID in textNodeMap) { + if (textNodeMap[textNodeID] === node) { + return textNodeID; + } + } + } + }, splice = [].splice, push = [].push, itemsInChildListTree = function (list) { + var count = 0; + for (var i = 0, len = list.length; i < len; i++) { + var item = list[i]; + if (item.nodeType) { + count++; + } else { + count += itemsInChildListTree(item); + } + } + return count; + }, replacementMap = function (replacements, idMap) { + var map = {}; + for (var i = 0, len = replacements.length; i < len; i++) { + var node = nodeLists.first(replacements[i]); + map[id(node, idMap)] = replacements[i]; + } + return map; + }; + var nodeLists = { + id: id, + update: function (nodeList, newNodes) { + var oldNodes = nodeLists.unregisterChildren(nodeList); + newNodes = can.makeArray(newNodes); + var oldListLength = nodeList.length; + splice.apply(nodeList, [ + 0, + oldListLength + ].concat(newNodes)); + if (nodeList.replacements) { + nodeLists.nestReplacements(nodeList); + } else { + nodeLists.nestList(nodeList); + } + return oldNodes; + }, + nestReplacements: function (list) { + var index = 0, idMap = {}, rMap = replacementMap(list.replacements, idMap), rCount = list.replacements.length; + while (index < list.length && rCount) { + var node = list[index], replacement = rMap[readId(node, idMap)]; + if (replacement) { + list.splice(index, itemsInChildListTree(replacement), replacement); + rCount--; + } + index++; + } + list.replacements = []; + }, + nestList: function (list) { + var index = 0; + while (index < list.length) { + var node = list[index], childNodeList = nodeMap[id(node)]; + if (childNodeList) { + if (childNodeList !== list) { + list.splice(index, itemsInChildListTree(childNodeList), childNodeList); + } + } else { + nodeMap[id(node)] = list; + } + index++; + } + }, + last: function (nodeList) { + var last = nodeList[nodeList.length - 1]; + if (last.nodeType) { + return last; + } else { + return nodeLists.last(last); + } + }, + first: function (nodeList) { + var first = nodeList[0]; + if (first.nodeType) { + return first; + } else { + return nodeLists.first(first); + } + }, + flatten: function (nodeList) { + var items = []; + for (var i = 0; i < nodeList.length; i++) { + var item = nodeList[i]; + if (item.nodeType) { + items.push(item); + } else { + items.push.apply(items, nodeLists.flatten(item)); + } + } + return items; + }, + register: function (nodeList, unregistered, parent) { + nodeList.unregistered = unregistered; + nodeList.parentList = parent; + if (parent === true) { + nodeList.replacements = []; + } else if (parent) { + parent.replacements.push(nodeList); + nodeList.replacements = []; + } else { + nodeLists.nestList(nodeList); + } + return nodeList; + }, + unregisterChildren: function (nodeList) { + var nodes = []; + can.each(nodeList, function (node) { + if (node.nodeType) { + if (!nodeList.replacements) { + delete nodeMap[id(node)]; + } + nodes.push(node); + } else { + push.apply(nodes, nodeLists.unregister(node)); + } + }); + return nodes; + }, + unregister: function (nodeList) { + var nodes = nodeLists.unregisterChildren(nodeList); + if (nodeList.unregistered) { + var unregisteredCallback = nodeList.unregistered; + delete nodeList.unregistered; + delete nodeList.replacements; + unregisteredCallback(); + } + return nodes; + }, + nodeMap: nodeMap + }; + can.view.nodeLists = nodeLists; + return nodeLists; +}); +/*can@2.2.6#view/parser/parser*/ +define('can/view/parser/parser', ['can/view/view'], function (can) { + function makeMap(str) { + var obj = {}, items = str.split(','); + for (var i = 0; i < items.length; i++) { + obj[items[i]] = true; + } + return obj; + } + function handleIntermediate(intermediate, handler) { + for (var i = 0, len = intermediate.length; i < len; i++) { + var item = intermediate[i]; + handler[item.tokenType].apply(handler, item.args); + } + return intermediate; + } + var alphaNumericHU = '-:A-Za-z0-9_', attributeNames = '[a-zA-Z_:][' + alphaNumericHU + ':.]*', spaceEQspace = '\\s*=\\s*', dblQuote2dblQuote = '"((?:\\\\.|[^"])*)"', quote2quote = '\'((?:\\\\.|[^\'])*)\'', attributeEqAndValue = '(?:' + spaceEQspace + '(?:' + '(?:"[^"]*")|(?:\'[^\']*\')|[^>\\s]+))?', matchStash = '\\{\\{[^\\}]*\\}\\}\\}?', stash = '\\{\\{([^\\}]*)\\}\\}\\}?', startTag = new RegExp('^<([' + alphaNumericHU + ']+)' + '(' + '(?:\\s*' + '(?:(?:' + '(?:' + attributeNames + ')?' + attributeEqAndValue + ')|' + '(?:' + matchStash + ')+)' + ')*' + ')\\s*(\\/?)>'), endTag = new RegExp('^<\\/([' + alphaNumericHU + ']+)[^>]*>'), attr = new RegExp('(?:' + '(?:(' + attributeNames + ')|' + stash + ')' + '(?:' + spaceEQspace + '(?:' + '(?:' + dblQuote2dblQuote + ')|(?:' + quote2quote + ')|([^>\\s]+)' + ')' + ')?)', 'g'), mustache = new RegExp(stash, 'g'), txtBreak = /<|\{\{/; + var empty = makeMap('area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed'); + var block = makeMap('a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video'); + var inline = makeMap('abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var'); + var closeSelf = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr'); + var fillAttrs = makeMap('checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected'); + var special = makeMap('script,style'); + var tokenTypes = 'start,end,close,attrStart,attrEnd,attrValue,chars,comment,special,done'.split(','); + var fn = function () { + }; + var HTMLParser = function (html, handler, returnIntermediate) { + if (typeof html === 'object') { + return handleIntermediate(html, handler); + } + var intermediate = []; + handler = handler || {}; + if (returnIntermediate) { + can.each(tokenTypes, function (name) { + var callback = handler[name] || fn; + handler[name] = function () { + if (callback.apply(this, arguments) !== false) { + intermediate.push({ + tokenType: name, + args: can.makeArray(arguments) + }); + } + }; + }); + } + function parseStartTag(tag, tagName, rest, unary) { + tagName = tagName.toLowerCase(); + if (block[tagName]) { + while (stack.last() && inline[stack.last()]) { + parseEndTag('', stack.last()); + } + } + if (closeSelf[tagName] && stack.last() === tagName) { + parseEndTag('', tagName); + } + unary = empty[tagName] || !!unary; + handler.start(tagName, unary); + if (!unary) { + stack.push(tagName); + } + HTMLParser.parseAttrs(rest, handler); + handler.end(tagName, unary); + } + function parseEndTag(tag, tagName) { + var pos; + if (!tagName) { + pos = 0; + } else { + for (pos = stack.length - 1; pos >= 0; pos--) { + if (stack[pos] === tagName) { + break; + } + } + } + if (pos >= 0) { + for (var i = stack.length - 1; i >= pos; i--) { + if (handler.close) { + handler.close(stack[i]); + } + } + stack.length = pos; + } + } + function parseMustache(mustache, inside) { + if (handler.special) { + handler.special(inside); + } + } + var index, chars, match, stack = [], last = html; + stack.last = function () { + return this[this.length - 1]; + }; + while (html) { + chars = true; + if (!stack.last() || !special[stack.last()]) { + if (html.indexOf(''); + if (index >= 0) { + if (handler.comment) { + handler.comment(html.substring(4, index)); + } + html = html.substring(index + 3); + chars = false; + } + } else if (html.indexOf(']*>'), function (all, text) { + text = text.replace(/|/g, '$1$2'); + if (handler.chars) { + handler.chars(text); + } + return ''; + }); + parseEndTag('', stack.last()); + } + if (html === last) { + throw 'Parse Error: ' + html; + } + last = html; + } + parseEndTag(); + handler.done(); + return intermediate; + }; + HTMLParser.parseAttrs = function (rest, handler) { + (rest != null ? rest : '').replace(attr, function (text, name, special, dblQuote, singleQuote, val) { + if (special) { + handler.special(special); + } + if (name || dblQuote || singleQuote || val) { + var value = arguments[3] ? arguments[3] : arguments[4] ? arguments[4] : arguments[5] ? arguments[5] : fillAttrs[name.toLowerCase()] ? name : ''; + handler.attrStart(name || ''); + var last = mustache.lastIndex = 0, res = mustache.exec(value), chars; + while (res) { + chars = value.substring(last, mustache.lastIndex - res[0].length); + if (chars.length) { + handler.attrValue(chars); + } + handler.special(res[1]); + last = mustache.lastIndex; + res = mustache.exec(value); + } + chars = value.substr(last, value.length); + if (chars) { + handler.attrValue(chars); + } + handler.attrEnd(name || ''); + } + }); + }; + can.view.parser = HTMLParser; + return HTMLParser; +}); +/*can@2.2.6#view/live/live*/ +define('can/view/live/live', [ + 'can/util/util', + 'can/view/elements', + 'can/view/view', + 'can/view/node_lists/node_lists', + 'can/view/parser/parser' +], function (can, elements, view, nodeLists, parser) { + elements = elements || can.view.elements; + nodeLists = nodeLists || can.view.NodeLists; + parser = parser || can.view.parser; + var setup = function (el, bind, unbind) { + var tornDown = false, teardown = function () { + if (!tornDown) { + tornDown = true; + unbind(data); + can.unbind.call(el, 'removed', teardown); + } + return true; + }, data = { + teardownCheck: function (parent) { + return parent ? false : teardown(); + } + }; + can.bind.call(el, 'removed', teardown); + bind(data); + return data; + }, listen = function (el, compute, change) { + return setup(el, function () { + compute.bind('change', change); + }, function (data) { + compute.unbind('change', change); + if (data.nodeList) { + nodeLists.unregister(data.nodeList); + } + }); + }, getAttributeParts = function (newVal) { + var attrs = {}, attr; + parser.parseAttrs(newVal, { + attrStart: function (name) { + attrs[name] = ''; + attr = name; + }, + attrValue: function (value) { + attrs[attr] += value; + }, + attrEnd: function () { + } + }); + return attrs; + }, splice = [].splice, isNode = function (obj) { + return obj && obj.nodeType; + }, addTextNodeIfNoChildren = function (frag) { + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + }; + var live = { + list: function (el, compute, render, context, parentNode, nodeList) { + var masterNodeList = nodeList || [el], indexMap = [], afterPreviousEvents = false, isTornDown = false, add = function (ev, items, index) { + if (!afterPreviousEvents) { + return; + } + var frag = document.createDocumentFragment(), newNodeLists = [], newIndicies = []; + can.each(items, function (item, key) { + var itemNodeList = []; + if (nodeList) { + nodeLists.register(itemNodeList, null, true); + } + var itemIndex = can.compute(key + index), itemHTML = render.call(context, item, itemIndex, itemNodeList), gotText = typeof itemHTML === 'string', itemFrag = can.frag(itemHTML); + itemFrag = gotText ? can.view.hookup(itemFrag) : itemFrag; + var childNodes = can.makeArray(itemFrag.childNodes); + if (nodeList) { + nodeLists.update(itemNodeList, childNodes); + newNodeLists.push(itemNodeList); + } else { + newNodeLists.push(nodeLists.register(childNodes)); + } + frag.appendChild(itemFrag); + newIndicies.push(itemIndex); + }); + var masterListIndex = index + 1; + if (!masterNodeList[masterListIndex]) { + elements.after(masterListIndex === 1 ? [text] : [nodeLists.last(masterNodeList[masterListIndex - 1])], frag); + } else { + var el = nodeLists.first(masterNodeList[masterListIndex]); + can.insertBefore(el.parentNode, frag, el); + } + splice.apply(masterNodeList, [ + masterListIndex, + 0 + ].concat(newNodeLists)); + splice.apply(indexMap, [ + index, + 0 + ].concat(newIndicies)); + for (var i = index + newIndicies.length, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + }, remove = function (ev, items, index, duringTeardown, fullTeardown) { + if (!afterPreviousEvents) { + return; + } + if (!duringTeardown && data.teardownCheck(text.parentNode)) { + return; + } + if (index < 0) { + index = indexMap.length + index; + } + var removedMappings = masterNodeList.splice(index + 1, items.length), itemsToRemove = []; + can.each(removedMappings, function (nodeList) { + var nodesToRemove = nodeLists.unregister(nodeList); + [].push.apply(itemsToRemove, nodesToRemove); + }); + indexMap.splice(index, items.length); + for (var i = index, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + if (!fullTeardown) { + can.remove(can.$(itemsToRemove)); + } else { + nodeLists.unregister(masterNodeList); + } + }, move = function (ev, item, newIndex, currentIndex) { + if (!afterPreviousEvents) { + return; + } + newIndex = newIndex + 1; + currentIndex = currentIndex + 1; + var referenceNodeList = masterNodeList[newIndex]; + var movedElements = can.frag(nodeLists.flatten(masterNodeList[currentIndex])); + var referenceElement; + if (currentIndex < newIndex) { + referenceElement = nodeLists.last(referenceNodeList).nextSibling; + } else { + referenceElement = nodeLists.first(referenceNodeList); + } + var parentNode = masterNodeList[0].parentNode; + parentNode.insertBefore(movedElements, referenceElement); + var temp = masterNodeList[currentIndex]; + [].splice.apply(masterNodeList, [ + currentIndex, + 1 + ]); + [].splice.apply(masterNodeList, [ + newIndex, + 0, + temp + ]); + }, text = document.createTextNode(''), list, teardownList = function (fullTeardown) { + if (list && list.unbind) { + list.unbind('add', add).unbind('remove', remove).unbind('move', move); + } + remove({}, { length: masterNodeList.length - 1 }, 0, true, fullTeardown); + }, updateList = function (ev, newList, oldList) { + if (isTornDown) { + return; + } + teardownList(); + list = newList || []; + if (list.bind) { + list.bind('add', add).bind('remove', remove).bind('move', move); + } + afterPreviousEvents = true; + add({}, list, 0); + afterPreviousEvents = false; + can.batch.afterPreviousEvents(function () { + afterPreviousEvents = true; + }); + }; + parentNode = elements.getParentNode(el, parentNode); + var data = setup(parentNode, function () { + if (can.isFunction(compute)) { + compute.bind('change', updateList); + } + }, function () { + if (can.isFunction(compute)) { + compute.unbind('change', updateList); + } + teardownList(true); + }); + if (!nodeList) { + live.replace(masterNodeList, text, data.teardownCheck); + } else { + elements.replace(masterNodeList, text); + nodeLists.update(masterNodeList, [text]); + nodeList.unregistered = function () { + data.teardownCheck(); + isTornDown = true; + }; + } + updateList({}, can.isFunction(compute) ? compute() : compute); + }, + html: function (el, compute, parentNode, nodeList) { + var data; + parentNode = elements.getParentNode(el, parentNode); + data = listen(parentNode, compute, function (ev, newVal, oldVal) { + var attached = nodeLists.first(nodes).parentNode; + if (attached) { + makeAndPut(newVal); + } + data.teardownCheck(nodeLists.first(nodes).parentNode); + }); + var nodes = nodeList || [el], makeAndPut = function (val) { + var isFunction = typeof val === 'function', aNode = isNode(val), frag = can.frag(isFunction ? '' : val), oldNodes = can.makeArray(nodes); + addTextNodeIfNoChildren(frag); + if (!aNode && !isFunction) { + frag = can.view.hookup(frag, parentNode); + } + oldNodes = nodeLists.update(nodes, frag.childNodes); + if (isFunction) { + val(frag.childNodes[0]); + } + elements.replace(oldNodes, frag); + }; + data.nodeList = nodes; + if (!nodeList) { + nodeLists.register(nodes, data.teardownCheck); + } else { + nodeList.unregistered = data.teardownCheck; + } + makeAndPut(compute()); + }, + replace: function (nodes, val, teardown) { + var oldNodes = nodes.slice(0), frag = can.frag(val); + nodeLists.register(nodes, teardown); + if (typeof val === 'string') { + frag = can.view.hookup(frag, nodes[0].parentNode); + } + nodeLists.update(nodes, frag.childNodes); + elements.replace(oldNodes, frag); + return nodes; + }, + text: function (el, compute, parentNode, nodeList) { + var parent = elements.getParentNode(el, parentNode); + var data = listen(parent, compute, function (ev, newVal, oldVal) { + if (typeof node.nodeValue !== 'unknown') { + node.nodeValue = can.view.toStr(newVal); + } + data.teardownCheck(node.parentNode); + }); + var node = document.createTextNode(can.view.toStr(compute())); + if (nodeList) { + nodeList.unregistered = data.teardownCheck; + data.nodeList = nodeList; + nodeLists.update(nodeList, [node]); + elements.replace([el], node); + } else { + data.nodeList = live.replace([el], node, data.teardownCheck); + } + }, + setAttributes: function (el, newVal) { + var attrs = getAttributeParts(newVal); + for (var name in attrs) { + can.attr.set(el, name, attrs[name]); + } + }, + attributes: function (el, compute, currentValue) { + var oldAttrs = {}; + var setAttrs = function (newVal) { + var newAttrs = getAttributeParts(newVal), name; + for (name in newAttrs) { + var newValue = newAttrs[name], oldValue = oldAttrs[name]; + if (newValue !== oldValue) { + can.attr.set(el, name, newValue); + } + delete oldAttrs[name]; + } + for (name in oldAttrs) { + elements.removeAttr(el, name); + } + oldAttrs = newAttrs; + }; + listen(el, compute, function (ev, newVal) { + setAttrs(newVal); + }); + if (arguments.length >= 3) { + oldAttrs = getAttributeParts(currentValue); + } else { + setAttrs(compute()); + } + }, + attributePlaceholder: '__!!__', + attributeReplace: /__!!__/g, + attribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, hook.render()); + }); + var wrapped = can.$(el), hooks; + hooks = can.data(wrapped, 'hooks'); + if (!hooks) { + can.data(wrapped, 'hooks', hooks = {}); + } + var attr = elements.getAttr(el, attributeName), parts = attr.split(live.attributePlaceholder), goodParts = [], hook; + goodParts.push(parts.shift(), parts.join(live.attributePlaceholder)); + if (hooks[attributeName]) { + hooks[attributeName].computes.push(compute); + } else { + hooks[attributeName] = { + render: function () { + var i = 0, newAttr = attr ? attr.replace(live.attributeReplace, function () { + return elements.contentText(hook.computes[i++]()); + }) : elements.contentText(hook.computes[i++]()); + return newAttr; + }, + computes: [compute], + batchNum: undefined + }; + } + hook = hooks[attributeName]; + goodParts.splice(1, 0, compute()); + elements.setAttr(el, attributeName, goodParts.join('')); + }, + specialAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, getValue(newVal)); + }); + elements.setAttr(el, attributeName, getValue(compute())); + }, + simpleAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, newVal); + }); + elements.setAttr(el, attributeName, compute()); + } + }; + live.attr = live.simpleAttribute; + live.attrs = live.attributes; + var newLine = /(\r|\n)+/g; + var getValue = function (val) { + var regexp = /^["'].*["']$/; + val = val.replace(elements.attrReg, '').replace(newLine, ''); + return regexp.test(val) ? val.substr(1, val.length - 2) : val; + }; + can.view.live = live; + return live; +}); +/*can@2.2.6#view/render*/ +define('can/view/render', [ + 'can/view/view', + 'can/view/elements', + 'can/view/live/live', + 'can/util/string/string' +], function (can, elements, live) { + var pendingHookups = [], tagChildren = function (tagName) { + var newTag = elements.tagMap[tagName] || 'span'; + if (newTag === 'span') { + return '@@!!@@'; + } + return '<' + newTag + '>' + tagChildren(newTag) + ''; + }, contentText = function (input, tag) { + if (typeof input === 'string') { + return input; + } + if (!input && input !== 0) { + return ''; + } + var hook = input.hookup && function (el, id) { + input.hookup.call(input, el, id); + } || typeof input === 'function' && input; + if (hook) { + if (tag) { + return '<' + tag + ' ' + can.view.hook(hook) + '>'; + } else { + pendingHookups.push(hook); + } + return ''; + } + return '' + input; + }, contentEscape = function (txt, tag) { + return typeof txt === 'string' || typeof txt === 'number' ? can.esc(txt) : contentText(txt, tag); + }, withinTemplatedSectionWithinAnElement = false, emptyHandler = function () { + }; + var lastHookups; + can.extend(can.view, { + live: live, + setupLists: function () { + var old = can.view.lists, data; + can.view.lists = function (list, renderer) { + data = { + list: list, + renderer: renderer + }; + return Math.random(); + }; + return function () { + can.view.lists = old; + return data; + }; + }, + getHooks: function () { + var hooks = pendingHookups.slice(0); + lastHookups = hooks; + pendingHookups = []; + return hooks; + }, + onlytxt: function (self, func) { + return contentEscape(func.call(self)); + }, + txt: function (escape, tagName, status, self, func) { + var tag = elements.tagMap[tagName] || 'span', setupLiveBinding = false, value, listData, compute, unbind = emptyHandler, attributeName; + if (withinTemplatedSectionWithinAnElement) { + value = func.call(self); + } else { + if (typeof status === 'string' || status === 1) { + withinTemplatedSectionWithinAnElement = true; + } + var listTeardown = can.view.setupLists(); + unbind = function () { + compute.unbind('change', emptyHandler); + }; + compute = can.compute(func, self, false); + compute.bind('change', emptyHandler); + listData = listTeardown(); + value = compute(); + withinTemplatedSectionWithinAnElement = false; + setupLiveBinding = compute.computeInstance.hasDependencies; + } + if (listData) { + unbind(); + return '<' + tag + can.view.hook(function (el, parentNode) { + live.list(el, listData.list, listData.renderer, self, parentNode); + }) + '>'; + } + if (!setupLiveBinding || typeof value === 'function') { + unbind(); + return (withinTemplatedSectionWithinAnElement || escape === 2 || !escape ? contentText : contentEscape)(value, status === 0 && tag); + } + var contentProp = elements.tagToContentPropMap[tagName]; + if (status === 0 && !contentProp) { + return '<' + tag + can.view.hook(escape && typeof value !== 'object' ? function (el, parentNode) { + live.text(el, compute, parentNode); + unbind(); + } : function (el, parentNode) { + live.html(el, compute, parentNode); + unbind(); + }) + '>' + tagChildren(tag) + ''; + } else if (status === 1) { + pendingHookups.push(function (el) { + live.attributes(el, compute, compute()); + unbind(); + }); + return compute(); + } else if (escape === 2) { + attributeName = status; + pendingHookups.push(function (el) { + live.specialAttribute(el, attributeName, compute); + unbind(); + }); + return compute(); + } else { + attributeName = status === 0 ? contentProp : status; + (status === 0 ? lastHookups : pendingHookups).push(function (el) { + live.attribute(el, attributeName, compute); + unbind(); + }); + return live.attributePlaceholder; + } + } + }); + return can; +}); +/*can@2.2.6#view/stache/utils*/ +define('can/view/stache/utils', ['can/util/util'], function () { + return { + isArrayLike: function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, + isObserveLike: function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, + emptyHandler: function () { + }, + jsonParse: function (str) { + if (str[0] === '\'') { + return str.substr(1, str.length - 2); + } else if (str === 'undefined') { + return undefined; + } else if (can.global.JSON) { + return JSON.parse(str); + } else { + return eval('(' + str + ')'); + } + }, + mixins: { + last: function () { + return this.stack[this.stack.length - 1]; + }, + add: function (chars) { + this.last().add(chars); + }, + subSectionDepth: function () { + return this.stack.length - 1; + } + } + }; +}); +/*can@2.2.6#view/stache/mustache_helpers*/ +define('can/view/stache/mustache_helpers', [ + 'can/util/util', + 'can/view/stache/utils', + 'can/view/live/live' +], function (can, utils, live) { + live = live || can.view.live; + var resolve = function (value) { + if (utils.isObserveLike(value) && utils.isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + var helpers = { + 'each': function (items, options) { + var resolved = resolve(items), result = [], keys, key, i; + if (resolved instanceof can.List) { + return function (el) { + var nodeList = [el]; + nodeList.expression = 'live.list'; + can.view.nodeLists.register(nodeList, null, options.nodeList); + can.view.nodeLists.update(options.nodeList, [el]); + var cb = function (item, index, parentNodeList) { + return options.fn(options.scope.add({ '@index': index }).add(item), options.options, parentNodeList); + }; + live.list(el, items, cb, options.context, el.parentNode, nodeList); + }; + } + var expr = resolved; + if (!!expr && utils.isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + } else if (utils.isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } + return result; + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + }, + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!resolve(expr); + } + if (value) { + return options.fn(options.scope || this); + } else { + return options.inverse(options.scope || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return helpers.is.apply(this, arguments); + }, + 'unless': function (expr, options) { + return helpers['if'].apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'with': function (expr, options) { + var ctx = expr; + expr = resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + 'data': function (attr) { + var data = arguments.length === 2 ? this : arguments[1]; + return function (el) { + can.data(can.$(el), attr, data || this.context); + }; + } + }; + return { + registerHelper: function (name, callback) { + helpers[name] = callback; + }, + getHelper: function (name, options) { + var helper = options.attr('helpers.' + name); + if (!helper) { + helper = helpers[name]; + } + if (helper) { + return { fn: helper }; + } + } + }; +}); +/*can@2.2.6#view/stache/mustache_core*/ +define('can/view/stache/mustache_core', [ + 'can/util/util', + 'can/view/stache/utils', + 'can/view/stache/mustache_helpers', + 'can/view/live/live', + 'can/view/elements', + 'can/view/scope/scope', + 'can/view/node_lists/node_lists' +], function (can, utils, mustacheHelpers, live, elements, Scope, nodeLists) { + live = live || can.view.live; + elements = elements || can.view.elements; + Scope = Scope || can.view.Scope; + nodeLists = nodeLists || can.view.nodeLists; + var argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(?:(.+?)=(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(.+))))$/, mustacheLineBreakRegExp = /(?:(?:^|(\r?)\n)(\s*)(\{\{([^\}]*)\}\}\}?)([^\S\n\r]*)($|\r?\n))|(\{\{([^\}]*)\}\}\}?)/g, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, getItemsFragContent = function (items, isObserveList, helperOptions, options) { + var frag = document.createDocumentFragment(); + for (var i = 0, len = items.length; i < len; i++) { + append(frag, helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options)); + } + return frag; + }, append = function (frag, content) { + if (content) { + frag.appendChild(typeof content === 'string' ? document.createTextNode(content) : content); + } + }, getItemsStringContent = function (items, isObserveList, helperOptions, options) { + var txt = ''; + for (var i = 0, len = items.length; i < len; i++) { + txt += helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options); + } + return txt; + }, getKeyComputeData = function (key, scope, isArgument) { + var data = scope.computeData(key, { + isArgument: isArgument, + args: [ + scope.attr('.'), + scope + ] + }); + can.compute.temporarilyBind(data.compute); + return data; + }, getKeyArgValue = function (key, scope) { + var data = getKeyComputeData(key, scope, true); + if (!data.compute.computeInstance.hasDependencies) { + return data.initialValue; + } else { + return data.compute; + } + }, convertToScopes = function (helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer) { + if (truthyRenderer) { + helperOptions.fn = makeRendererConvertScopes(truthyRenderer, scope, options, nodeList); + } + if (falseyRenderer) { + helperOptions.inverse = makeRendererConvertScopes(falseyRenderer, scope, options, nodeList); + } + }, makeRendererConvertScopes = function (renderer, parentScope, parentOptions, nodeList) { + var rendererWithScope = function (ctx, opts, parentNodeList) { + return renderer(ctx || parentScope, opts, parentNodeList); + }; + return can.__notObserve(function (newScope, newOptions, parentNodeList) { + if (newScope !== undefined && !(newScope instanceof can.view.Scope)) { + newScope = parentScope.add(newScope); + } + if (newOptions !== undefined && !(newOptions instanceof core.Options)) { + newOptions = parentOptions.add(newOptions); + } + var result = rendererWithScope(newScope, newOptions || parentOptions, parentNodeList || nodeList); + return result; + }); + }; + var core = { + expressionData: function (expression) { + var args = [], hashes = {}, i = 0; + (can.trim(expression) + ' ').replace(argumentsRegExp, function (whole, arg) { + var m; + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[1] || m[2]) { + args.push(utils.jsonParse(m[1] || m[2])); + } else { + hashes[m[3]] = m[6] ? { get: m[6] } : utils.jsonParse(m[4] || m[5]); + } + } else { + args.push({ get: arg }); + } + i++; + }); + return { + name: args.shift(), + args: args, + hash: hashes + }; + }, + makeEvaluator: function (scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, stringOnly) { + var args = [], hash = {}, helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, context = scope.attr('.'), name = exprData.name, helper, looksLikeAHelper = exprData.args.length || !can.isEmptyObject(exprData.hash), initialValue, helperEvaluator; + for (var i = 0, len = exprData.args.length; i < len; i++) { + var arg = exprData.args[i]; + if (arg && isLookup(arg)) { + args.push(getKeyArgValue(arg.get, scope, true)); + } else { + args.push(arg); + } + } + for (var prop in exprData.hash) { + if (isLookup(exprData.hash[prop])) { + hash[prop] = getKeyArgValue(exprData.hash[prop].get, scope); + } else { + hash[prop] = exprData.hash[prop]; + } + } + if (isLookup(name)) { + if (looksLikeAHelper) { + helper = mustacheHelpers.getHelper(name.get, options); + if (!helper && typeof context[name.get] === 'function') { + helper = { fn: context[name.get] }; + } + } + if (!helper) { + var get = name.get; + var computeData = getKeyComputeData(name.get, scope, false), compute = computeData.compute; + initialValue = computeData.initialValue; + if (computeData.compute.computeInstance.hasDependencies) { + name = compute; + } else { + name = initialValue; + } + if (!looksLikeAHelper && initialValue === undefined) { + helper = mustacheHelpers.getHelper(get, options); + } else if (typeof initialValue === 'function') { + helper = { fn: initialValue }; + } + } + if (!helper && initialValue === undefined) { + if (looksLikeAHelper) { + can.dev.warn('can/view/stache/mustache_core.js: Unable to find helper "' + exprData.name.get + '".'); + } else { + can.dev.warn('can/view/stache/mustache_core.js: Unable to find key or helper "' + exprData.name.get + '".'); + } + } + } + if (mode === '^') { + var temp = truthyRenderer; + truthyRenderer = falseyRenderer; + falseyRenderer = temp; + } + if (helper) { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + can.simpleExtend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash, + nodeList: nodeList, + exprData: exprData + }); + args.push(helperOptions); + helperEvaluator = function () { + return helper.fn.apply(context, args) || ''; + }; + helperEvaluator.bindOnce = false; + return helperEvaluator; + } + if (!mode) { + if (name && name.isComputed) { + return name; + } else { + return function () { + return '' + (name != null ? name : ''); + }; + } + } else if (mode === '#' || mode === '^') { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + var evaluator = function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + if (utils.isArrayLike(value)) { + var isObserveList = utils.isObserveLike(value); + if (isObserveList ? value.attr('length') : value.length) { + return (stringOnly ? getItemsStringContent : getItemsFragContent)(value, isObserveList, helperOptions, options); + } else { + return helperOptions.inverse(scope, options); + } + } else { + return value ? helperOptions.fn(value || scope, options) : helperOptions.inverse(scope, options); + } + }; + evaluator.bindOnce = false; + return evaluator; + } else { + } + }, + makeLiveBindingPartialRenderer: function (partialName, state) { + partialName = can.trim(partialName); + return function (scope, options, parentSectionNodeList) { + var nodeList = [this]; + nodeList.expression = '>' + partialName; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var partialFrag = can.compute(function () { + var localPartialName = partialName; + var partial = options.attr('partials.' + localPartialName), res; + if (partial) { + res = partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + var scopePartialName = scope.read(localPartialName, { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }).value; + if (scopePartialName) { + localPartialName = scopePartialName; + } + res = can.view.render(localPartialName, scope, options); + } + return can.frag(res); + }); + live.html(this, partialFrag, this.parentNode, nodeList); + }; + }, + makeStringBranchRenderer: function (mode, expression) { + var exprData = expressionData(expression), fullExpression = mode + expression; + return function branchRenderer(scope, options, truthyRenderer, falseyRenderer) { + var evaluator = scope.__cache[fullExpression]; + if (mode || !evaluator) { + evaluator = makeEvaluator(scope, options, null, mode, exprData, truthyRenderer, falseyRenderer, true); + if (!mode) { + scope.__cache[fullExpression] = evaluator; + } + } + var res = evaluator(); + return res == null ? '' : '' + res; + }; + }, + makeLiveBindingBranchRenderer: function (mode, expression, state) { + var exprData = expressionData(expression); + return function branchRenderer(scope, options, parentSectionNodeList, truthyRenderer, falseyRenderer) { + var nodeList = [this]; + nodeList.expression = expression; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var evaluator = makeEvaluator(scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, state.tag); + var compute = can.compute(evaluator, null, false, evaluator.bindOnce === false ? false : true); + compute.bind('change', can.k); + var value = compute(); + if (typeof value === 'function') { + var old = can.__clearReading(); + value(this); + can.__setReading(old); + } else if (compute.computeInstance.hasDependencies) { + if (state.attr) { + live.simpleAttribute(this, state.attr, compute); + } else if (state.tag) { + live.attributes(this, compute); + } else if (state.text && typeof value !== 'object') { + live.text(this, compute, this.parentNode, nodeList); + } else { + live.html(this, compute, this.parentNode, nodeList); + } + } else { + if (state.attr) { + can.attr.set(this, state.attr, value); + } else if (state.tag) { + live.setAttributes(this, value); + } else if (state.text && typeof value === 'string') { + this.nodeValue = value; + } else if (value) { + elements.replace([this], can.frag(value)); + } + } + compute.unbind('change', can.k); + }; + }, + splitModeFromExpression: function (expression, state) { + expression = can.trim(expression); + var mode = expression.charAt(0); + if ('#/{&^>!'.indexOf(mode) >= 0) { + expression = can.trim(expression.substr(1)); + } else { + mode = null; + } + if (mode === '{' && state.node) { + mode = null; + } + return { + mode: mode, + expression: expression + }; + }, + cleanLineEndings: function (template) { + return template.replace(mustacheLineBreakRegExp, function (whole, returnBefore, spaceBefore, special, expression, spaceAfter, returnAfter, spaceLessSpecial, spaceLessExpression, matchIndex) { + spaceAfter = spaceAfter || ''; + returnBefore = returnBefore || ''; + spaceBefore = spaceBefore || ''; + var modeAndExpression = splitModeFromExpression(expression || spaceLessExpression, {}); + if (spaceLessSpecial || '>{'.indexOf(modeAndExpression.mode) >= 0) { + return whole; + } else if ('^#!/'.indexOf(modeAndExpression.mode) >= 0) { + return special + (matchIndex !== 0 && returnAfter.length ? returnBefore + '\n' : ''); + } else { + return spaceBefore + special + spaceAfter + (spaceBefore.length || matchIndex !== 0 ? returnBefore + '\n' : ''); + } + }); + }, + Options: can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }) + }; + var makeEvaluator = core.makeEvaluator, expressionData = core.expressionData, splitModeFromExpression = core.splitModeFromExpression; + return core; +}); +/*can@2.2.6#view/bindings/bindings*/ +define('can/view/bindings/bindings', [ + 'can/util/util', + 'can/view/stache/mustache_core', + 'can/view/callbacks/callbacks', + 'can/control/control', + 'can/view/scope/scope' +], function (can, mustacheCore) { + var isContentEditable = function () { + var values = { + '': true, + 'true': true, + 'false': false + }; + var editable = function (el) { + if (!el || !el.getAttribute) { + return; + } + var attr = el.getAttribute('contenteditable'); + return values[attr]; + }; + return function (el) { + var val = editable(el); + if (typeof val === 'boolean') { + return val; + } else { + return !!editable(el.parentNode); + } + }; + }(), removeCurly = function (value) { + if (value[0] === '{' && value[value.length - 1] === '}') { + return value.substr(1, value.length - 2); + } + return value; + }; + can.view.attr('can-value', function (el, data) { + var attr = can.trim(removeCurly(el.getAttribute('can-value'))), value = data.scope.computeData(attr, { args: [] }).compute, trueValue, falseValue; + if (el.nodeName.toLowerCase() === 'input') { + if (el.type === 'checkbox') { + if (can.attr.has(el, 'can-true-value')) { + trueValue = el.getAttribute('can-true-value'); + } else { + trueValue = true; + } + if (can.attr.has(el, 'can-false-value')) { + falseValue = el.getAttribute('can-false-value'); + } else { + falseValue = false; + } + } + if (el.type === 'checkbox' || el.type === 'radio') { + new Checked(el, { + value: value, + trueValue: trueValue, + falseValue: falseValue + }); + return; + } + } + if (el.nodeName.toLowerCase() === 'select' && el.multiple) { + new Multiselect(el, { value: value }); + return; + } + if (isContentEditable(el)) { + new Content(el, { value: value }); + return; + } + new Value(el, { value: value }); + }); + var special = { + enter: function (data, el, original) { + return { + event: 'keyup', + handler: function (ev) { + if (ev.keyCode === 13) { + return original.call(this, ev); + } + } + }; + } + }; + can.view.attr(/can-[\w\.]+/, function (el, data) { + var attributeName = data.attributeName, event = attributeName.substr('can-'.length), handler = function (ev) { + var attrVal = el.getAttribute(attributeName); + if (!attrVal) { + return; + } + var attrInfo = mustacheCore.expressionData(removeCurly(attrVal)); + var scopeData = data.scope.read(attrInfo.name.get, { + returnObserveMethods: true, + isArgument: true, + executeAnonymousFunctions: true + }); + if (!scopeData.value) { + can.dev.warn('can/view/bindings: ' + attributeName + ' couldn\'t find method named ' + attrInfo.name.get, { + element: el, + scope: data.scope + }); + return null; + } + var args = []; + var $el = can.$(this); + var viewModel = can.viewModel($el[0]); + var localScope = data.scope.add({ + '@element': $el, + '@event': ev, + '@viewModel': viewModel, + '@scope': data.scope, + '@context': data.scope._context + }); + if (!can.isEmptyObject(attrInfo.hash)) { + var hash = {}; + can.each(attrInfo.hash, function (val, key) { + if (val && val.hasOwnProperty('get')) { + var s = !val.get.indexOf('@') ? localScope : data.scope; + hash[key] = s.read(val.get, {}).value; + } else { + hash[key] = val; + } + }); + args.unshift(hash); + } + if (attrInfo.args.length) { + var arg; + for (var i = attrInfo.args.length - 1; i >= 0; i--) { + arg = attrInfo.args[i]; + if (arg && arg.hasOwnProperty('get')) { + var s = !arg.get.indexOf('@') ? localScope : data.scope; + args.unshift(s.read(arg.get, {}).value); + } else { + args.unshift(arg); + } + } + } + if (!args.length) { + args = [ + data.scope._context, + $el + ].concat(can.makeArray(arguments)); + } + return scopeData.value.apply(scopeData.parent, args); + }; + if (special[event]) { + var specialData = special[event](data, el, handler); + handler = specialData.handler; + event = specialData.event; + } + can.bind.call(el, event, handler); + }); + var Value = can.Control.extend({ + init: function () { + if (this.element[0].nodeName.toUpperCase() === 'SELECT') { + setTimeout(can.proxy(this.set, this), 1); + } else { + this.set(); + } + }, + '{value} change': 'set', + set: function () { + if (!this.element) { + return; + } + var val = this.options.value(); + this.element[0].value = val == null ? '' : val; + }, + 'change': function () { + if (!this.element) { + return; + } + var el = this.element[0]; + this.options.value(el.value); + var newVal = this.options.value(); + if (el.value !== newVal) { + el.value = newVal; + } + } + }), Checked = can.Control.extend({ + init: function () { + this.isCheckbox = this.element[0].type.toLowerCase() === 'checkbox'; + this.check(); + }, + '{value} change': 'check', + check: function () { + if (this.isCheckbox) { + var value = this.options.value(), trueValue = this.options.trueValue || true; + this.element[0].checked = value == trueValue; + } else { + var setOrRemove = this.options.value() == this.element[0].value ? 'set' : 'remove'; + can.attr[setOrRemove](this.element[0], 'checked', true); + } + }, + 'change': function () { + if (this.isCheckbox) { + this.options.value(this.element[0].checked ? this.options.trueValue : this.options.falseValue); + } else { + if (this.element[0].checked) { + this.options.value(this.element[0].value); + } + } + } + }), Multiselect = Value.extend({ + init: function () { + this.delimiter = ';'; + setTimeout(can.proxy(this.set, this), 1); + }, + set: function () { + var newVal = this.options.value(); + if (typeof newVal === 'string') { + newVal = newVal.split(this.delimiter); + this.isString = true; + } else if (newVal) { + newVal = can.makeArray(newVal); + } + var isSelected = {}; + can.each(newVal, function (val) { + isSelected[val] = true; + }); + can.each(this.element[0].childNodes, function (option) { + if (option.value) { + option.selected = !!isSelected[option.value]; + } + }); + }, + get: function () { + var values = [], children = this.element[0].childNodes; + can.each(children, function (child) { + if (child.selected && child.value) { + values.push(child.value); + } + }); + return values; + }, + 'change': function () { + var value = this.get(), currentValue = this.options.value(); + if (this.isString || typeof currentValue === 'string') { + this.isString = true; + this.options.value(value.join(this.delimiter)); + } else if (currentValue instanceof can.List) { + currentValue.attr(value, true); + } else { + this.options.value(value); + } + } + }), Content = can.Control.extend({ + init: function () { + this.set(); + this.on('blur', 'setValue'); + }, + '{value} change': 'set', + set: function () { + var val = this.options.value(); + this.element[0].innerHTML = typeof val === 'undefined' ? '' : val; + }, + setValue: function () { + this.options.value(this.element[0].innerHTML); + } + }); +}); +/*can@2.2.6#view/mustache/mustache*/ +define('can/view/mustache/mustache', [ + 'can/util/util', + 'can/view/scope/scope', + 'can/view/view', + 'can/view/scanner', + 'can/compute/compute', + 'can/view/render', + 'can/view/bindings/bindings' +], function (can) { + can.view.ext = '.mustache'; + var SCOPE = 'scope', HASH = '___h4sh', CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options}', SPECIAL_CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options, special: true}', ARG_NAMES = SCOPE + ',options', argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false|null|undefined)|((.+?)=(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false)|(.+))))$/, makeLookupLiteral = function (type) { + return '{get:"' + type.replace(/"/g, '\\"') + '"}'; + }, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, isObserveLike = function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, isArrayLike = function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, makeConvertToScopes = function (original, scope, options) { + var originalWithScope = function (ctx, opts) { + return original(ctx || scope, opts); + }; + return function (updatedScope, updatedOptions) { + if (updatedScope !== undefined && !(updatedScope instanceof can.view.Scope)) { + updatedScope = scope.add(updatedScope); + } + if (updatedOptions !== undefined && !(updatedOptions instanceof can.view.Options)) { + updatedOptions = options.add(updatedOptions); + } + return originalWithScope(updatedScope, updatedOptions || options); + }; + }; + var Mustache = function (options, helpers) { + if (this.constructor !== Mustache) { + var mustache = new Mustache(options); + return function (data, options) { + return mustache.render(data, options); + }; + } + if (typeof options === 'function') { + this.template = { fn: options }; + return; + } + can.extend(this, options); + this.template = this.scanner.scan(this.text, this.name); + }; + can.Mustache = can.global.Mustache = Mustache; + Mustache.prototype.render = function (data, options) { + if (!(data instanceof can.view.Scope)) { + data = new can.view.Scope(data || {}); + } + if (!(options instanceof can.view.Options)) { + options = new can.view.Options(options || {}); + } + options = options || {}; + return this.template.fn.call(data, data, options); + }; + can.extend(Mustache.prototype, { + scanner: new can.view.Scanner({ + text: { + start: '', + scope: SCOPE, + options: ',options: options', + argNames: ARG_NAMES + }, + tokens: [ + [ + 'returnLeft', + '{{{', + '{{[{&]' + ], + [ + 'commentFull', + '{{!}}', + '^[\\s\\t]*{{!.+?}}\\n' + ], + [ + 'commentLeft', + '{{!', + '(\\n[\\s\\t]*{{!|{{!)' + ], + [ + 'escapeFull', + '{{}}', + '(^[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}$)', + function (content) { + return { + before: /^\n.+?\n$/.test(content) ? '\n' : '', + content: content.match(/\{\{(.+?)\}\}/)[1] || '' + }; + } + ], + [ + 'escapeLeft', + '{{' + ], + [ + 'returnRight', + '}}}' + ], + [ + 'right', + '}}' + ] + ], + helpers: [ + { + name: /^>[\s]*\w*/, + fn: function (content, cmd) { + var templateName = can.trim(content.replace(/^>\s?/, '')).replace(/["|']/g, ''); + return 'can.Mustache.renderPartial(\'' + templateName + '\',' + ARG_NAMES + ')'; + } + }, + { + name: /^\s*data\s/, + fn: function (content, cmd) { + var attr = content.match(/["|'](.*)["|']/)[1]; + return 'can.proxy(function(__){' + 'can.data(can.$(__),\'' + attr + '\', this.attr(\'.\')); }, ' + SCOPE + ')'; + } + }, + { + name: /\s*\(([\$\w]+)\)\s*->([^\n]*)/, + fn: function (content) { + var quickFunc = /\s*\(([\$\w]+)\)\s*->([^\n]*)/, parts = content.match(quickFunc); + return 'can.proxy(function(__){var ' + parts[1] + '=can.$(__);with(' + SCOPE + '.attr(\'.\')){' + parts[2] + '}}, this);'; + } + }, + { + name: /^.*$/, + fn: function (content, cmd) { + var mode = false, result = { + content: '', + startTxt: false, + startOnlyTxt: false, + end: false + }; + content = can.trim(content); + if (content.length && (mode = content.match(/^([#^\/]|else$)/))) { + mode = mode[0]; + switch (mode) { + case '#': + case '^': + if (cmd.specialAttribute) { + result.startOnlyTxt = true; + } else { + result.startTxt = true; + result.escaped = 0; + } + break; + case '/': + result.end = true; + result.content += 'return ___v1ew.join("");}}])'; + return result; + } + content = content.substring(1); + } + if (mode !== 'else') { + var args = [], hashes = [], i = 0, m; + result.content += 'can.Mustache.txt(\n' + (cmd.specialAttribute ? SPECIAL_CONTEXT_OBJ : CONTEXT_OBJ) + ',\n' + (mode ? '"' + mode + '"' : 'null') + ','; + (can.trim(content) + ' ').replace(argumentsRegExp, function (whole, arg) { + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[2]) { + args.push(m[0]); + } else { + hashes.push(m[4] + ':' + (m[6] ? m[6] : makeLookupLiteral(m[5]))); + } + } else { + args.push(makeLookupLiteral(arg)); + } + i++; + }); + result.content += args.join(','); + if (hashes.length) { + result.content += ',{' + HASH + ':{' + hashes.join(',') + '}}'; + } + } + if (mode && mode !== 'else') { + result.content += ',[\n\n'; + } + switch (mode) { + case '^': + case '#': + result.content += '{fn:function(' + ARG_NAMES + '){var ___v1ew = [];'; + break; + case 'else': + result.content += 'return ___v1ew.join("");}},\n{inverse:function(' + ARG_NAMES + '){\nvar ___v1ew = [];'; + break; + default: + result.content += ')'; + break; + } + if (!mode) { + result.startTxt = true; + result.end = true; + } + return result; + } + } + ] + }) + }); + var helpers = can.view.Scanner.prototype.helpers; + for (var i = 0; i < helpers.length; i++) { + Mustache.prototype.scanner.helpers.unshift(helpers[i]); + } + Mustache.txt = function (scopeAndOptions, mode, name) { + var scope = scopeAndOptions.scope, options = scopeAndOptions.options, args = [], helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, hash, context = scope.attr('.'), getHelper = true, helper; + for (var i = 3; i < arguments.length; i++) { + var arg = arguments[i]; + if (mode && can.isArray(arg)) { + helperOptions = can.extend.apply(can, [helperOptions].concat(arg)); + } else if (arg && arg[HASH]) { + hash = arg[HASH]; + for (var prop in hash) { + if (isLookup(hash[prop])) { + hash[prop] = Mustache.get(hash[prop].get, scopeAndOptions, false, true); + } + } + } else if (arg && isLookup(arg)) { + args.push(Mustache.get(arg.get, scopeAndOptions, false, true, true)); + } else { + args.push(arg); + } + } + if (isLookup(name)) { + var get = name.get; + name = Mustache.get(name.get, scopeAndOptions, args.length, false); + getHelper = get === name; + } + helperOptions.fn = makeConvertToScopes(helperOptions.fn, scope, options); + helperOptions.inverse = makeConvertToScopes(helperOptions.inverse, scope, options); + if (mode === '^') { + var tmp = helperOptions.fn; + helperOptions.fn = helperOptions.inverse; + helperOptions.inverse = tmp; + } + if (helper = getHelper && (typeof name === 'string' && Mustache.getHelper(name, options)) || can.isFunction(name) && !name.isComputed && { fn: name }) { + can.extend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash + }); + args.push(helperOptions); + return function () { + return helper.fn.apply(context, args) || ''; + }; + } + return function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + var validArgs = args.length ? args : [value], valid = true, result = [], i, argIsObserve, arg; + if (mode) { + for (i = 0; i < validArgs.length; i++) { + arg = validArgs[i]; + argIsObserve = typeof arg !== 'undefined' && isObserveLike(arg); + if (isArrayLike(arg)) { + if (mode === '#') { + valid = valid && !!(argIsObserve ? arg.attr('length') : arg.length); + } else if (mode === '^') { + valid = valid && !(argIsObserve ? arg.attr('length') : arg.length); + } + } else { + valid = mode === '#' ? valid && !!arg : mode === '^' ? valid && !arg : valid; + } + } + } + if (valid) { + if (mode === '#') { + if (isArrayLike(value)) { + var isObserveList = isObserveLike(value); + for (i = 0; i < value.length; i++) { + result.push(helperOptions.fn(isObserveList ? value.attr('' + i) : value[i])); + } + return result.join(''); + } else { + return helperOptions.fn(value || {}) || ''; + } + } else if (mode === '^') { + return helperOptions.inverse(value || {}) || ''; + } else { + return '' + (value != null ? value : ''); + } + } + return ''; + }; + }; + Mustache.get = function (key, scopeAndOptions, isHelper, isArgument, isLookup) { + var context = scopeAndOptions.scope.attr('.'), options = scopeAndOptions.options || {}; + if (isHelper) { + if (Mustache.getHelper(key, options)) { + return key; + } + if (scopeAndOptions.scope && can.isFunction(context[key])) { + return context[key]; + } + can.dev.warn('can/view/mustache/mustache.js: Unable to find helper "' + key + '".'); + } + var computeData = scopeAndOptions.scope.computeData(key, { + isArgument: isArgument, + args: [ + context, + scopeAndOptions.scope + ] + }), compute = computeData.compute; + can.compute.temporarilyBind(compute); + var initialValue = computeData.initialValue, helperObj = Mustache.getHelper(key, options); + if (initialValue === undefined && !isHelper && !helperObj) { + can.dev.warn('can/view/mustache/mustache.js: Unable to find key "' + key + '".'); + } + if (!isLookup && (initialValue === undefined || computeData.scope !== scopeAndOptions.scope) && Mustache.getHelper(key, options)) { + return key; + } + if (!compute.computeInstance.hasDependencies) { + return initialValue; + } else { + return compute; + } + }; + Mustache.resolve = function (value) { + if (isObserveLike(value) && isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + can.view.Options = can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }); + Mustache._helpers = {}; + Mustache.registerHelper = function (name, fn) { + this._helpers[name] = { + name: name, + fn: fn + }; + }; + Mustache.getHelper = function (name, options) { + var helper; + if (options) { + helper = options.attr('helpers.' + name); + } + return helper ? { fn: helper } : this._helpers[name]; + }; + Mustache.render = function (partial, scope, options) { + if (!can.view.cached[partial]) { + var reads = can.__clearReading(); + var scopePartialName = scope.attr(partial); + if (scopePartialName) { + partial = scopePartialName; + } + can.__setReading(reads); + } + return can.view.render(partial, scope, options); + }; + Mustache.safeString = function (str) { + return { + toString: function () { + return str; + } + }; + }; + Mustache.renderPartial = function (partialName, scope, options) { + var partial = options.attr('partials.' + partialName); + if (partial) { + return partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + return can.Mustache.render(partialName, scope, options); + } + }; + can.each({ + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!Mustache.resolve(expr); + } + if (value) { + return options.fn(options.contexts || this); + } else { + return options.inverse(options.contexts || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = Mustache.resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return Mustache._helpers.is.fn.apply(this, arguments); + }, + 'unless': function (expr, options) { + return Mustache._helpers['if'].fn.apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'each': function (expr, options) { + var resolved = Mustache.resolve(expr), result = [], keys, key, i; + if (can.view.lists && (resolved instanceof can.List || expr && expr.isComputed && resolved === undefined)) { + return can.view.lists(expr, function (item, index) { + return options.fn(options.scope.add({ '@index': index }).add(item)); + }); + } + expr = resolved; + if (!!expr && isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + return result.join(''); + } else if (isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } + }, + 'with': function (expr, options) { + var ctx = expr; + expr = Mustache.resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + } + }, function (fn, name) { + Mustache.registerHelper(name, fn); + }); + can.view.register({ + suffix: 'mustache', + contentType: 'x-mustache-template', + script: function (id, src) { + return 'can.Mustache(function(' + ARG_NAMES + ') { ' + new Mustache({ + text: src, + name: id + }).template.out + ' })'; + }, + renderer: function (id, text) { + return Mustache({ + text: text, + name: id + }); + } + }); + can.mustache.registerHelper = can.proxy(can.Mustache.registerHelper, can.Mustache); + can.mustache.safeString = can.Mustache.safeString; + return can; +}); +/*can@2.2.6#component/component*/ +define('can/component/component', [ + 'can/util/util', + 'can/view/callbacks/callbacks', + 'can/view/elements', + 'can/control/control', + 'can/observe/observe', + 'can/view/mustache/mustache', + 'can/view/bindings/bindings' +], function (can, viewCallbacks, elements) { + var ignoreAttributesRegExp = /^(dataViewId|class|id)$/i, paramReplacer = /\{([^\}]+)\}/g; + var Component = can.Component = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Component) { + var self = this, scope = this.prototype.scope || this.prototype.viewModel; + this.Control = ComponentControl.extend(this.prototype.events); + if (!scope || typeof scope === 'object' && !(scope instanceof can.Map)) { + this.Map = can.Map.extend(scope || {}); + } else if (scope.prototype instanceof can.Map) { + this.Map = scope; + } + this.attributeScopeMappings = {}; + can.each(this.Map ? this.Map.defaults : {}, function (val, prop) { + if (val === '@') { + self.attributeScopeMappings[prop] = prop; + } + }); + if (this.prototype.template) { + if (typeof this.prototype.template === 'function') { + var temp = this.prototype.template; + this.renderer = function () { + return can.view.frag(temp.apply(null, arguments)); + }; + } else { + this.renderer = can.view.mustache(this.prototype.template); + } + } + can.view.tag(this.prototype.tag, function (el, options) { + new self(el, options); + }); + } + } + }, { + setup: function (el, hookupOptions) { + var initialScopeData = {}, component = this, lexicalContent = (typeof this.leakScope === 'undefined' ? false : !this.leakScope) && this.template, twoWayBindings = {}, scope = this.scope || this.viewModel, viewModelPropertyUpdates = {}, componentScope, frag, teardownFunctions = [], callTeardownFunctions = function () { + for (var i = 0, len = teardownFunctions.length; i < len; i++) { + teardownFunctions[i](); + } + }; + can.each(this.constructor.attributeScopeMappings, function (val, prop) { + initialScopeData[prop] = el.getAttribute(can.hyphenate(val)); + }); + can.each(can.makeArray(el.attributes), function (node, index) { + var name = can.camelize(node.nodeName.toLowerCase()), value = node.value; + if (ignoreAttributesRegExp.test(name) && value[0] === '{' && value[value.length - 1] === '}') { + can.dev.warn('can/component: looks like you\'re trying to pass ' + name + ' as an attribute into a component, ' + 'but it is not a supported attribute'); + } + if (component.constructor.attributeScopeMappings[name] || ignoreAttributesRegExp.test(name) || viewCallbacks.attr(node.nodeName)) { + return; + } + if (value[0] === '{' && value[value.length - 1] === '}') { + value = value.substr(1, value.length - 2); + } else { + if (hookupOptions.templateType !== 'legacy') { + initialScopeData[name] = value; + return; + } + } + var computeData = hookupOptions.scope.computeData(value, { args: [] }), compute = computeData.compute; + var handler = function (ev, newVal) { + viewModelPropertyUpdates[name] = (viewModelPropertyUpdates[name] || 0) + 1; + componentScope.attr(name, newVal); + can.batch.afterPreviousEvents(function () { + --viewModelPropertyUpdates[name]; + }); + }; + compute.bind('change', handler); + initialScopeData[name] = compute(); + if (!compute.computeInstance.hasDependencies) { + compute.unbind('change', handler); + } else { + teardownFunctions.push(function () { + compute.unbind('change', handler); + }); + twoWayBindings[name] = computeData; + } + }); + if (this.constructor.Map) { + componentScope = new this.constructor.Map(initialScopeData); + } else if (scope instanceof can.Map) { + componentScope = scope; + } else if (can.isFunction(scope)) { + var scopeResult = scope.call(this, initialScopeData, hookupOptions.scope, el); + if (scopeResult instanceof can.Map) { + componentScope = scopeResult; + } else if (scopeResult.prototype instanceof can.Map) { + componentScope = new scopeResult(initialScopeData); + } else { + componentScope = new (can.Map.extend(scopeResult))(initialScopeData); + } + } + var handlers = {}; + can.each(twoWayBindings, function (computeData, prop) { + handlers[prop] = function (ev, newVal) { + if (!viewModelPropertyUpdates[prop]) { + computeData.compute(newVal); + } + }; + componentScope.bind(prop, handlers[prop]); + }); + if (!can.isEmptyObject(this.constructor.attributeScopeMappings) || hookupOptions.templateType !== 'legacy') { + can.bind.call(el, 'attributes', function (ev) { + var camelized = can.camelize(ev.attributeName); + if (!twoWayBindings[camelized] && !ignoreAttributesRegExp.test(camelized)) { + componentScope.attr(camelized, el.getAttribute(ev.attributeName)); + } + }); + } + this.scope = this.viewModel = componentScope; + can.data(can.$(el), 'scope', this.scope); + can.data(can.$(el), 'viewModel', this.scope); + var renderedScope = lexicalContent ? this.scope : hookupOptions.scope.add(this.scope), options = { helpers: {} }; + can.each(this.helpers || {}, function (val, prop) { + if (can.isFunction(val)) { + options.helpers[prop] = function () { + return val.apply(componentScope, arguments); + }; + } + }); + teardownFunctions.push(function () { + can.each(handlers, function (handler, prop) { + componentScope.unbind(prop, handlers[prop]); + }); + }); + this._control = new this.constructor.Control(el, { + scope: this.scope, + viewModel: this.scope + }); + if (this._control && this._control.destroy) { + var oldDestroy = this._control.destroy; + this._control.destroy = function () { + oldDestroy.apply(this, arguments); + callTeardownFunctions(); + }; + this._control.on(); + } else { + can.bind.call(el, 'removed', function () { + callTeardownFunctions(); + }); + } + var nodeList = can.view.nodeLists.register([], undefined, true); + teardownFunctions.push(function () { + can.view.nodeLists.unregister(nodeList); + }); + if (this.constructor.renderer) { + if (!options.tags) { + options.tags = {}; + } + options.tags.content = function contentHookup(el, rendererOptions) { + var subtemplate = hookupOptions.subtemplate || rendererOptions.subtemplate; + if (subtemplate) { + delete options.tags.content; + var opts = !lexicalContent || subtemplate !== hookupOptions.subtemplate ? rendererOptions : hookupOptions; + if (rendererOptions.parentNodeList) { + var frag = subtemplate(opts.scope, opts.options, rendererOptions.parentNodeList); + elements.replace([el], frag); + } else { + can.view.live.replace([el], subtemplate(opts.scope, opts.options)); + } + options.tags.content = contentHookup; + } + }; + frag = this.constructor.renderer(renderedScope, hookupOptions.options.add(options), nodeList); + } else { + if (hookupOptions.templateType === 'legacy') { + frag = can.view.frag(hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options)) : ''); + } else { + frag = hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options), nodeList) : document.createDocumentFragment(); + } + } + can.appendChild(el, frag); + can.view.nodeLists.update(nodeList, el.childNodes); + } + }); + var ComponentControl = can.Control.extend({ + _lookup: function (options) { + return [ + options.scope, + options, + window + ]; + }, + _action: function (methodName, options, controlInstance) { + var hasObjectLookup, readyCompute; + paramReplacer.lastIndex = 0; + hasObjectLookup = paramReplacer.test(methodName); + if (!controlInstance && hasObjectLookup) { + return; + } else if (!hasObjectLookup) { + return can.Control._action.apply(this, arguments); + } else { + readyCompute = can.compute(function () { + var delegate; + var name = methodName.replace(paramReplacer, function (matched, key) { + var value; + if (key === 'scope' || key === 'viewModel') { + delegate = options.scope; + return ''; + } + key = key.replace(/^(scope|^viewModel)\./, ''); + value = can.compute.read(options.scope, key.split('.'), { isArgument: true }).value; + if (value === undefined) { + value = can.getObject(key); + } + if (typeof value === 'string') { + return value; + } else { + delegate = value; + return ''; + } + }); + var parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: this.processors[event] || this.processors.click, + parts: [ + name, + parts.join(' '), + event + ], + delegate: delegate || undefined + }; + }, this); + var handler = function (ev, ready) { + controlInstance._bindings.control[methodName](controlInstance.element); + controlInstance._bindings.control[methodName] = ready.processor(ready.delegate || controlInstance.element, ready.parts[2], ready.parts[1], methodName, controlInstance); + }; + readyCompute.bind('change', handler); + controlInstance._bindings.readyComputes[methodName] = { + compute: readyCompute, + handler: handler + }; + return readyCompute(); + } + } + }, { + setup: function (el, options) { + this.scope = options.scope; + this.viewModel = options.viewModel; + return can.Control.prototype.setup.call(this, el, options); + }, + off: function () { + if (this._bindings) { + can.each(this._bindings.readyComputes || {}, function (value) { + value.compute.unbind('change', value.handler); + }); + } + can.Control.prototype.off.apply(this, arguments); + this._bindings.readyComputes = {}; + } + }); + var $ = can.$; + if ($.fn) { + $.fn.scope = $.fn.viewModel = function () { + return can.viewModel.apply(can, [this].concat(can.makeArray(arguments))); + }; + } + return Component; +}); +/*can@2.2.6#model/model*/ +define('can/model/model', [ + 'can/util/util', + 'can/map/map', + 'can/list/list' +], function (can) { + var pipe = function (def, thisArg, func) { + var d = new can.Deferred(); + def.then(function () { + var args = can.makeArray(arguments), success = true; + try { + args[0] = func.apply(thisArg, args); + } catch (e) { + success = false; + d.rejectWith(d, [e].concat(args)); + } + if (success) { + d.resolveWith(d, args); + } + }, function () { + d.rejectWith(this, arguments); + }); + if (typeof def.abort === 'function') { + d.abort = function () { + return def.abort(); + }; + } + return d; + }, modelNum = 0, getId = function (inst) { + can.__observe(inst, inst.constructor.id); + return inst.__get(inst.constructor.id); + }, ajax = function (ajaxOb, data, type, dataType, success, error) { + var params = {}; + if (typeof ajaxOb === 'string') { + var parts = ajaxOb.split(/\s+/); + params.url = parts.pop(); + if (parts.length) { + params.type = parts.pop(); + } + } else { + can.extend(params, ajaxOb); + } + params.data = typeof data === 'object' && !can.isArray(data) ? can.extend(params.data || {}, data) : data; + params.url = can.sub(params.url, params.data, true); + return can.ajax(can.extend({ + type: type || 'post', + dataType: dataType || 'json', + success: success, + error: error + }, params)); + }, makeRequest = function (modelObj, type, success, error, method) { + var args; + if (can.isArray(modelObj)) { + args = modelObj[1]; + modelObj = modelObj[0]; + } else { + args = modelObj.serialize(); + } + args = [args]; + var deferred, model = modelObj.constructor, jqXHR; + if (type === 'update' || type === 'destroy') { + args.unshift(getId(modelObj)); + } + jqXHR = model[type].apply(model, args); + deferred = pipe(jqXHR, modelObj, function (data) { + modelObj[method || type + 'd'](data, jqXHR); + return modelObj; + }); + if (jqXHR.abort) { + deferred.abort = function () { + jqXHR.abort(); + }; + } + deferred.then(success, error); + return deferred; + }, converters = { + models: function (instancesRawData, oldList, xhr) { + can.Model._reqs++; + if (!instancesRawData) { + return; + } + if (instancesRawData instanceof this.List) { + return instancesRawData; + } + var self = this, tmp = [], ListClass = self.List || ML, modelList = oldList instanceof can.List ? oldList : new ListClass(), rawDataIsList = instancesRawData instanceof ML, raw = rawDataIsList ? instancesRawData.serialize() : instancesRawData; + raw = self.parseModels(raw, xhr); + if (raw.data) { + instancesRawData = raw; + raw = raw.data; + } + if (typeof raw === 'undefined' || !can.isArray(raw)) { + throw new Error('Could not get any raw data while converting using .models'); + } + if (!raw.length) { + can.dev.warn('model.js models has no data.'); + } + if (modelList.length) { + modelList.splice(0); + } + can.each(raw, function (rawPart) { + tmp.push(self.model(rawPart, xhr)); + }); + modelList.push.apply(modelList, tmp); + if (!can.isArray(instancesRawData)) { + can.each(instancesRawData, function (val, prop) { + if (prop !== 'data') { + modelList.attr(prop, val); + } + }); + } + setTimeout(can.proxy(this._clean, this), 1); + return modelList; + }, + model: function (attributes, oldModel, xhr) { + if (!attributes) { + return; + } + if (typeof attributes.serialize === 'function') { + attributes = attributes.serialize(); + } else { + attributes = this.parseModel(attributes, xhr); + } + var id = attributes[this.id]; + if ((id || id === 0) && this.store[id]) { + oldModel = this.store[id]; + } + var model = oldModel && can.isFunction(oldModel.attr) ? oldModel.attr(attributes, this.removeAttr || false) : new this(attributes); + return model; + } + }, makeParser = { + parseModel: function (prop) { + return function (attributes) { + return prop ? can.getObject(prop, attributes) : attributes; + }; + }, + parseModels: function (prop) { + return function (attributes) { + if (can.isArray(attributes)) { + return attributes; + } + prop = prop || 'data'; + var result = can.getObject(prop, attributes); + if (!can.isArray(result)) { + throw new Error('Could not get any raw data while converting using .models'); + } + return result; + }; + } + }, ajaxMethods = { + create: { + url: '_shortName', + type: 'post' + }, + update: { + data: function (id, attrs) { + attrs = attrs || {}; + var identity = this.id; + if (attrs[identity] && attrs[identity] !== id) { + attrs['new' + can.capitalize(id)] = attrs[identity]; + delete attrs[identity]; + } + attrs[identity] = id; + return attrs; + }, + type: 'put' + }, + destroy: { + type: 'delete', + data: function (id, attrs) { + attrs = attrs || {}; + attrs.id = attrs[this.id] = id; + return attrs; + } + }, + findAll: { url: '_shortName' }, + findOne: {} + }, ajaxMaker = function (ajaxMethod, str) { + return function (data) { + data = ajaxMethod.data ? ajaxMethod.data.apply(this, arguments) : data; + return ajax(str || this[ajaxMethod.url || '_url'], data, ajaxMethod.type || 'get'); + }; + }, createURLFromResource = function (model, name) { + if (!model.resource) { + return; + } + var resource = model.resource.replace(/\/+$/, ''); + if (name === 'findAll' || name === 'create') { + return resource; + } else { + return resource + '/{' + model.id + '}'; + } + }; + can.Model = can.Map.extend({ + fullName: 'can.Model', + _reqs: 0, + setup: function (base, fullName, staticProps, protoProps) { + if (typeof fullName !== 'string') { + protoProps = staticProps; + staticProps = fullName; + } + if (!protoProps) { + can.dev.warn('can/model/model.js: can.Model extended without static properties.'); + protoProps = staticProps; + } + this.store = {}; + can.Map.setup.apply(this, arguments); + if (!can.Model) { + return; + } + if (staticProps && staticProps.List) { + this.List = staticProps.List; + this.List.Map = this; + } else { + this.List = base.List.extend({ Map: this }, {}); + } + var self = this, clean = can.proxy(this._clean, self); + can.each(ajaxMethods, function (method, name) { + if (staticProps && staticProps[name] && (typeof staticProps[name] === 'string' || typeof staticProps[name] === 'object')) { + self[name] = ajaxMaker(method, staticProps[name]); + } else if (staticProps && staticProps.resource && !can.isFunction(staticProps[name])) { + self[name] = ajaxMaker(method, createURLFromResource(self, name)); + } + if (self['make' + can.capitalize(name)]) { + var newMethod = self['make' + can.capitalize(name)](self[name]); + can.Construct._overwrite(self, base, name, function () { + can.Model._reqs++; + var def = newMethod.apply(this, arguments); + var then = def.then(clean, clean); + then.abort = def.abort; + return then; + }); + } + }); + var hasCustomConverter = {}; + can.each(converters, function (converter, name) { + var parseName = 'parse' + can.capitalize(name), dataProperty = staticProps && staticProps[name] || self[name]; + if (typeof dataProperty === 'string') { + self[parseName] = dataProperty; + can.Construct._overwrite(self, base, name, converter); + } else if (staticProps && staticProps[name]) { + hasCustomConverter[parseName] = true; + } + }); + can.each(makeParser, function (maker, parseName) { + var prop = staticProps && staticProps[parseName] || self[parseName]; + if (typeof prop === 'string') { + can.Construct._overwrite(self, base, parseName, maker(prop)); + } else if ((!staticProps || !can.isFunction(staticProps[parseName])) && !self[parseName]) { + var madeParser = maker(); + madeParser.useModelConverter = hasCustomConverter[parseName]; + can.Construct._overwrite(self, base, parseName, madeParser); + } + }); + if (self.fullName === 'can.Model' || !self.fullName) { + self.fullName = 'Model' + ++modelNum; + } + can.Model._reqs = 0; + this._url = this._shortName + '/{' + this.id + '}'; + }, + _ajax: ajaxMaker, + _makeRequest: makeRequest, + _clean: function () { + can.Model._reqs--; + if (!can.Model._reqs) { + for (var id in this.store) { + if (!this.store[id]._bindings) { + delete this.store[id]; + } + } + } + return arguments[0]; + }, + models: converters.models, + model: converters.model + }, { + setup: function (attrs) { + var id = attrs && attrs[this.constructor.id]; + if (can.Model._reqs && id != null) { + this.constructor.store[id] = this; + } + can.Map.prototype.setup.apply(this, arguments); + }, + isNew: function () { + var id = getId(this); + return !(id || id === 0); + }, + save: function (success, error) { + return makeRequest(this, this.isNew() ? 'create' : 'update', success, error); + }, + destroy: function (success, error) { + if (this.isNew()) { + var self = this; + var def = can.Deferred(); + def.then(success, error); + return def.done(function (data) { + self.destroyed(data); + }).resolve(self); + } + return makeRequest(this, 'destroy', success, error, 'destroyed'); + }, + _bindsetup: function () { + var modelInstance = this.__get(this.constructor.id); + if (modelInstance != null) { + this.constructor.store[modelInstance] = this; + } + return can.Map.prototype._bindsetup.apply(this, arguments); + }, + _bindteardown: function () { + delete this.constructor.store[getId(this)]; + return can.Map.prototype._bindteardown.apply(this, arguments); + }, + ___set: function (prop, val) { + can.Map.prototype.___set.call(this, prop, val); + if (prop === this.constructor.id && this._bindings) { + this.constructor.store[getId(this)] = this; + } + } + }); + var makeGetterHandler = function (name) { + return function (data, readyState, xhr) { + return this[name](data, null, xhr); + }; + }, createUpdateDestroyHandler = function (data) { + if (this.parseModel.useModelConverter) { + return this.model(data); + } + return this.parseModel(data); + }; + var responseHandlers = { + makeFindAll: makeGetterHandler('models'), + makeFindOne: makeGetterHandler('model'), + makeCreate: createUpdateDestroyHandler, + makeUpdate: createUpdateDestroyHandler, + makeDestroy: createUpdateDestroyHandler + }; + can.each(responseHandlers, function (method, name) { + can.Model[name] = function (oldMethod) { + return function () { + var args = can.makeArray(arguments), oldArgs = can.isFunction(args[1]) ? args.splice(0, 1) : args.splice(0, 2), def = pipe(oldMethod.apply(this, oldArgs), this, method); + def.then(args[0], args[1]); + return def; + }; + }; + }); + can.each([ + 'created', + 'updated', + 'destroyed' + ], function (funcName) { + can.Model.prototype[funcName] = function (attrs) { + var self = this, constructor = self.constructor; + if (attrs && typeof attrs === 'object') { + this.attr(can.isFunction(attrs.attr) ? attrs.attr() : attrs); + } + can.dispatch.call(this, { + type: 'change', + target: this + }, [funcName]); + can.dev.log('Model.js - ' + constructor.shortName + ' ' + funcName); + can.dispatch.call(constructor, funcName, [this]); + }; + }); + var ML = can.Model.List = can.List.extend({ + _bubbleRule: function (eventName, list) { + var bubbleRules = can.List._bubbleRule(eventName, list); + bubbleRules.push('destroyed'); + return bubbleRules; + } + }, { + setup: function (params) { + if (can.isPlainObject(params) && !can.isArray(params)) { + can.List.prototype.setup.apply(this); + this.replace(can.isDeferred(params) ? params : this.constructor.Map.findAll(params)); + } else { + can.List.prototype.setup.apply(this, arguments); + } + this._init = 1; + this.bind('destroyed', can.proxy(this._destroyed, this)); + delete this._init; + }, + _destroyed: function (ev, attr) { + if (/\w+/.test(attr)) { + var index; + while ((index = this.indexOf(ev.target)) > -1) { + this.splice(index, 1); + } + } + } + }); + return can.Model; +}); +/*can@2.2.6#util/string/deparam/deparam*/ +define('can/util/string/deparam/deparam', [ + 'can/util/util', + 'can/util/string/string' +], function (can) { + var digitTest = /^\d+$/, keyBreaker = /([^\[\]]+)|(\[\])/g, paramTest = /([^?#]*)(#.*)?$/, prep = function (str) { + return decodeURIComponent(str.replace(/\+/g, ' ')); + }; + can.extend(can, { + deparam: function (params) { + var data = {}, pairs, lastPart; + if (params && paramTest.test(params)) { + pairs = params.split('&'); + can.each(pairs, function (pair) { + var parts = pair.split('='), key = prep(parts.shift()), value = prep(parts.join('=')), current = data; + if (key) { + parts = key.match(keyBreaker); + for (var j = 0, l = parts.length - 1; j < l; j++) { + if (!current[parts[j]]) { + current[parts[j]] = digitTest.test(parts[j + 1]) || parts[j + 1] === '[]' ? [] : {}; + } + current = current[parts[j]]; + } + lastPart = parts.pop(); + if (lastPart === '[]') { + current.push(value); + } else { + current[lastPart] = value; + } + } + }); + } + return data; + } + }); + return can; +}); +/*can@2.2.6#route/route*/ +define('can/route/route', [ + 'can/util/util', + 'can/map/map', + 'can/list/list', + 'can/util/string/deparam/deparam' +], function (can) { + var matcher = /\:([\w\.]+)/g, paramsMatcher = /^(?:&[^=]+=[^&]*)+/, makeProps = function (props) { + var tags = []; + can.each(props, function (val, name) { + tags.push((name === 'className' ? 'class' : name) + '="' + (name === 'href' ? val : can.esc(val)) + '"'); + }); + return tags.join(' '); + }, matchesData = function (route, data) { + var count = 0, i = 0, defaults = {}; + for (var name in route.defaults) { + if (route.defaults[name] === data[name]) { + defaults[name] = 1; + count++; + } + } + for (; i < route.names.length; i++) { + if (!data.hasOwnProperty(route.names[i])) { + return -1; + } + if (!defaults[route.names[i]]) { + count++; + } + } + return count; + }, location = window.location, wrapQuote = function (str) { + return (str + '').replace(/([.?*+\^$\[\]\\(){}|\-])/g, '\\$1'); + }, each = can.each, extend = can.extend, stringify = function (obj) { + if (obj && typeof obj === 'object') { + if (obj instanceof can.Map) { + obj = obj.attr(); + } else { + obj = can.isFunction(obj.slice) ? obj.slice() : can.extend({}, obj); + } + can.each(obj, function (val, prop) { + obj[prop] = stringify(val); + }); + } else if (obj !== undefined && obj !== null && can.isFunction(obj.toString)) { + obj = obj.toString(); + } + return obj; + }, removeBackslash = function (str) { + return str.replace(/\\/g, ''); + }, timer, curParams, lastHash, changingData, changedAttrs = [], onRouteDataChange = function (ev, attr, how, newval) { + changingData = 1; + changedAttrs.push(attr); + clearTimeout(timer); + timer = setTimeout(function () { + changingData = 0; + var serialized = can.route.data.serialize(), path = can.route.param(serialized, true); + can.route._call('setURL', path, changedAttrs); + can.batch.trigger(eventsObject, '__url', [ + path, + lastHash + ]); + lastHash = path; + changedAttrs = []; + }, 10); + }, eventsObject = can.extend({}, can.event); + can.route = function (url, defaults) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + defaults = defaults || {}; + var names = [], res, test = '', lastIndex = matcher.lastIndex = 0, next, querySeparator = can.route._call('querySeparator'), matchSlashes = can.route._call('matchSlashes'); + while (res = matcher.exec(url)) { + names.push(res[1]); + test += removeBackslash(url.substring(lastIndex, matcher.lastIndex - res[0].length)); + next = '\\' + (removeBackslash(url.substr(matcher.lastIndex, 1)) || querySeparator + (matchSlashes ? '' : '|/')); + test += '([^' + next + ']' + (defaults[res[1]] ? '*' : '+') + ')'; + lastIndex = matcher.lastIndex; + } + test += url.substr(lastIndex).replace('\\', ''); + can.route.routes[url] = { + test: new RegExp('^' + test + '($|' + wrapQuote(querySeparator) + ')'), + route: url, + names: names, + defaults: defaults, + length: url.split('/').length + }; + return can.route; + }; + extend(can.route, { + param: function (data, _setRoute) { + var route, matches = 0, matchCount, routeName = data.route, propCount = 0; + delete data.route; + each(data, function () { + propCount++; + }); + each(can.route.routes, function (temp, name) { + matchCount = matchesData(temp, data); + if (matchCount > matches) { + route = temp; + matches = matchCount; + } + if (matchCount >= propCount) { + return false; + } + }); + if (can.route.routes[routeName] && matchesData(can.route.routes[routeName], data) === matches) { + route = can.route.routes[routeName]; + } + if (route) { + var cpy = extend({}, data), res = route.route.replace(matcher, function (whole, name) { + delete cpy[name]; + return data[name] === route.defaults[name] ? '' : encodeURIComponent(data[name]); + }).replace('\\', ''), after; + each(route.defaults, function (val, name) { + if (cpy[name] === val) { + delete cpy[name]; + } + }); + after = can.param(cpy); + if (_setRoute) { + can.route.attr('route', route.route); + } + return res + (after ? can.route._call('querySeparator') + after : ''); + } + return can.isEmptyObject(data) ? '' : can.route._call('querySeparator') + can.param(data); + }, + deparam: function (url) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + var route = { length: -1 }, querySeparator = can.route._call('querySeparator'), paramsMatcher = can.route._call('paramsMatcher'); + each(can.route.routes, function (temp, name) { + if (temp.test.test(url) && temp.length > route.length) { + route = temp; + } + }); + if (route.length > -1) { + var parts = url.match(route.test), start = parts.shift(), remainder = url.substr(start.length - (parts[parts.length - 1] === querySeparator ? 1 : 0)), obj = remainder && paramsMatcher.test(remainder) ? can.deparam(remainder.slice(1)) : {}; + obj = extend(true, {}, route.defaults, obj); + each(parts, function (part, i) { + if (part && part !== querySeparator) { + obj[route.names[i]] = decodeURIComponent(part); + } + }); + obj.route = route.route; + return obj; + } + if (url.charAt(0) !== querySeparator) { + url = querySeparator + url; + } + return paramsMatcher.test(url) ? can.deparam(url.slice(1)) : {}; + }, + data: new can.Map({}), + map: function (data) { + var appState; + if (data.prototype instanceof can.Map) { + appState = new data(); + } else { + appState = data; + } + can.route.data = appState; + }, + routes: {}, + ready: function (val) { + if (val !== true) { + can.route._setup(); + can.route.setState(); + } + return can.route; + }, + url: function (options, merge) { + if (merge) { + options = can.extend({}, can.route.deparam(can.route._call('matchingPartOfURL')), options); + } + return can.route._call('root') + can.route.param(options); + }, + link: function (name, options, props, merge) { + return '' + name + ''; + }, + current: function (options) { + can.__observe(eventsObject, '__url'); + return this._call('matchingPartOfURL') === can.route.param(options); + }, + bindings: { + hashchange: { + paramsMatcher: paramsMatcher, + querySeparator: '&', + matchSlashes: false, + bind: function () { + can.bind.call(window, 'hashchange', setState); + }, + unbind: function () { + can.unbind.call(window, 'hashchange', setState); + }, + matchingPartOfURL: function () { + return location.href.split(/#!?/)[1] || ''; + }, + setURL: function (path) { + if (location.hash !== '#' + path) { + location.hash = '!' + path; + } + return path; + }, + root: '#!' + } + }, + defaultBinding: 'hashchange', + currentBinding: null, + _setup: function () { + if (!can.route.currentBinding) { + can.route._call('bind'); + can.route.bind('change', onRouteDataChange); + can.route.currentBinding = can.route.defaultBinding; + } + }, + _teardown: function () { + if (can.route.currentBinding) { + can.route._call('unbind'); + can.route.unbind('change', onRouteDataChange); + can.route.currentBinding = null; + } + clearTimeout(timer); + changingData = 0; + }, + _call: function () { + var args = can.makeArray(arguments), prop = args.shift(), binding = can.route.bindings[can.route.currentBinding || can.route.defaultBinding], method = binding[prop]; + if (method.apply) { + return method.apply(binding, args); + } else { + return method; + } + } + }); + each([ + 'bind', + 'unbind', + 'on', + 'off', + 'delegate', + 'undelegate', + 'removeAttr', + 'compute', + '_get', + '__get', + 'each' + ], function (name) { + can.route[name] = function () { + if (!can.route.data[name]) { + return; + } + return can.route.data[name].apply(can.route.data, arguments); + }; + }); + can.route.attr = function (attr, val) { + var type = typeof attr, newArguments; + if (val === undefined) { + newArguments = arguments; + } else if (type !== 'string' && type !== 'number') { + newArguments = [ + stringify(attr), + val + ]; + } else { + newArguments = [ + attr, + stringify(val) + ]; + } + return can.route.data.attr.apply(can.route.data, newArguments); + }; + var setState = can.route.setState = function () { + var hash = can.route._call('matchingPartOfURL'); + var oldParams = curParams; + curParams = can.route.deparam(hash); + if (!changingData || hash !== lastHash) { + can.batch.start(); + recursiveClean(oldParams, curParams, can.route.data); + can.route.attr(curParams); + can.batch.trigger(eventsObject, '__url', [ + hash, + lastHash + ]); + can.batch.stop(); + } + }; + var recursiveClean = function (old, cur, data) { + for (var attr in old) { + if (cur[attr] === undefined) { + data.removeAttr(attr); + } else if (Object.prototype.toString.call(old[attr]) === '[object Object]') { + recursiveClean(old[attr], cur[attr], data.attr(attr)); + } + } + }; + return can.route; +}); +/*can@2.2.6#control/route/route*/ +define('can/control/route/route', [ + 'can/util/util', + 'can/route/route', + 'can/control/control' +], function (can) { + can.Control.processors.route = function (el, event, selector, funcName, controller) { + selector = selector || ''; + if (!can.route.routes[selector]) { + if (selector[0] === '/') { + selector = selector.substring(1); + } + can.route(selector); + } + var batchNum, check = function (ev, attr, how) { + if (can.route.attr('route') === selector && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + batchNum = ev.batchNum; + var d = can.route.attr(); + delete d.route; + if (can.isFunction(controller[funcName])) { + controller[funcName](d); + } else { + controller[controller[funcName]](d); + } + } + }; + can.route.bind('change', check); + return function () { + can.route.unbind('change', check); + }; + }; + return can; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.dojo.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.dojo.js new file mode 100644 index 0000000000..f902bf2926 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.dojo.js @@ -0,0 +1,7306 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#util/can*/ +define('can/util/can', [], function () { + var glbl = typeof window !== 'undefined' ? window : global; + var can = {}; + if (typeof GLOBALCAN === 'undefined' || GLOBALCAN !== false) { + glbl.can = can; + } + can.global = glbl; + can.k = function () { + }; + can.isDeferred = can.isPromise = function (obj) { + return obj && typeof obj.then === 'function' && typeof obj.pipe === 'function'; + }; + can.isMapLike = function (obj) { + return can.Map && (obj instanceof can.Map || obj && obj.__get); + }; + var cid = 0; + can.cid = function (object, name) { + if (!object._cid) { + cid++; + object._cid = (name || '') + cid; + } + return object._cid; + }; + can.VERSION = '2.2.6'; + can.simpleExtend = function (d, s) { + for (var prop in s) { + d[prop] = s[prop]; + } + return d; + }; + can.last = function (arr) { + return arr && arr[arr.length - 1]; + }; + var protoBind = Function.prototype.bind; + if (protoBind) { + can.proxy = function (fn, context) { + return protoBind.call(fn, context); + }; + } else { + can.proxy = function (fn, context) { + return function () { + return fn.apply(context, arguments); + }; + }; + } + can.frag = function (item) { + var frag; + if (!item || typeof item === 'string') { + frag = can.buildFragment(item == null ? '' : '' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } else if (item.nodeType === 11) { + return item; + } else if (typeof item.nodeType === 'number') { + frag = document.createDocumentFragment(); + frag.appendChild(item); + return frag; + } else if (typeof item.length === 'number') { + frag = document.createDocumentFragment(); + can.each(item, function (item) { + frag.appendChild(can.frag(item)); + }); + return frag; + } else { + frag = can.buildFragment('' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } + }; + can.scope = can.viewModel = function (el, attr, val) { + el = can.$(el); + var scope = can.data(el, 'scope') || can.data(el, 'viewModel'); + if (!scope) { + scope = new can.Map(); + can.data(el, 'scope', scope); + can.data(el, 'viewModel', scope); + } + switch (arguments.length) { + case 0: + case 1: + return scope; + case 2: + return scope.attr(attr); + default: + scope.attr(attr, val); + return el; + } + }; + can['import'] = function (moduleName) { + var deferred = new can.Deferred(); + if (typeof window.System === 'object' && can.isFunction(window.System['import'])) { + window.System['import'](moduleName).then(can.proxy(deferred.resolve, deferred), can.proxy(deferred.reject, deferred)); + } else if (window.define && window.define.amd) { + window.require([moduleName], function (value) { + deferred.resolve(value); + }); + } else if (window.steal) { + steal.steal(moduleName, function (value) { + deferred.resolve(value); + }); + } else if (window.require) { + deferred.resolve(window.require(moduleName)); + } else { + deferred.resolve(); + } + return deferred.promise(); + }; + can.__observe = function () { + }; + return can; +}); +/*can@2.2.6#util/attr/attr*/ +define('can/util/attr/attr', ['can/util/can'], function (can) { + var setImmediate = can.global.setImmediate || function (cb) { + return setTimeout(cb, 0); + }, attr = { + MutationObserver: can.global.MutationObserver || can.global.WebKitMutationObserver || can.global.MozMutationObserver, + map: { + 'class': 'className', + 'value': 'value', + 'innertext': 'innerText', + 'textcontent': 'textContent', + 'checked': true, + 'disabled': true, + 'readonly': true, + 'required': true, + src: function (el, val) { + if (val == null || val === '') { + el.removeAttribute('src'); + return null; + } else { + el.setAttribute('src', val); + return val; + } + }, + style: function (el, val) { + return el.style.cssText = val || ''; + } + }, + defaultValue: [ + 'input', + 'textarea' + ], + set: function (el, attrName, val) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var tagName = el.nodeName.toString().toLowerCase(), prop = attr.map[attrName], newValue; + if (typeof prop === 'function') { + newValue = prop(el, val); + } else if (prop === true) { + newValue = el[attrName] = true; + if (attrName === 'checked' && el.type === 'radio') { + if (can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultChecked = true; + } + } + } else if (prop) { + newValue = val; + if (el[prop] !== val) { + el[prop] = val; + } + if (prop === 'value' && can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultValue = val; + } + } else { + el.setAttribute(attrName, val); + newValue = val; + } + if (!attr.MutationObserver && newValue !== oldValue) { + attr.trigger(el, attrName, oldValue); + } + }, + trigger: function (el, attrName, oldValue) { + if (can.data(can.$(el), 'canHasAttributesBindings')) { + attrName = attrName.toLowerCase(); + return setImmediate(function () { + can.trigger(el, { + type: 'attributes', + attributeName: attrName, + target: el, + oldValue: oldValue, + bubbles: false + }, []); + }); + } + }, + get: function (el, attrName) { + attrName = attrName.toLowerCase(); + var prop = attr.map[attrName]; + if (typeof prop === 'string' && el[prop]) { + return el[prop]; + } + return el.getAttribute(attrName); + }, + remove: function (el, attrName) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var setter = attr.map[attrName]; + if (typeof setter === 'function') { + setter(el, undefined); + } + if (setter === true) { + el[attrName] = false; + } else if (typeof setter === 'string') { + el[setter] = ''; + } else { + el.removeAttribute(attrName); + } + if (!attr.MutationObserver && oldValue != null) { + attr.trigger(el, attrName, oldValue); + } + }, + has: function () { + var el = can.global.document && document.createElement('div'); + if (el && el.hasAttribute) { + return function (el, name) { + return el.hasAttribute(name); + }; + } else { + return function (el, name) { + return el.getAttribute(name) !== null; + }; + } + }() + }; + return attr; +}); +/*can@2.2.6#event/event*/ +define('can/event/event', ['can/util/can'], function (can) { + can.addEvent = function (event, handler) { + var allEvents = this.__bindEvents || (this.__bindEvents = {}), eventList = allEvents[event] || (allEvents[event] = []); + eventList.push({ + handler: handler, + name: event + }); + return this; + }; + can.listenTo = function (other, event, handler) { + var idedEvents = this.__listenToEvents; + if (!idedEvents) { + idedEvents = this.__listenToEvents = {}; + } + var otherId = can.cid(other); + var othersEvents = idedEvents[otherId]; + if (!othersEvents) { + othersEvents = idedEvents[otherId] = { + obj: other, + events: {} + }; + } + var eventsEvents = othersEvents.events[event]; + if (!eventsEvents) { + eventsEvents = othersEvents.events[event] = []; + } + eventsEvents.push(handler); + can.bind.call(other, event, handler); + }; + can.stopListening = function (other, event, handler) { + var idedEvents = this.__listenToEvents, iterIdedEvents = idedEvents, i = 0; + if (!idedEvents) { + return this; + } + if (other) { + var othercid = can.cid(other); + (iterIdedEvents = {})[othercid] = idedEvents[othercid]; + if (!idedEvents[othercid]) { + return this; + } + } + for (var cid in iterIdedEvents) { + var othersEvents = iterIdedEvents[cid], eventsEvents; + other = idedEvents[cid].obj; + if (!event) { + eventsEvents = othersEvents.events; + } else { + (eventsEvents = {})[event] = othersEvents.events[event]; + } + for (var eventName in eventsEvents) { + var handlers = eventsEvents[eventName] || []; + i = 0; + while (i < handlers.length) { + if (handler && handler === handlers[i] || !handler) { + can.unbind.call(other, eventName, handlers[i]); + handlers.splice(i, 1); + } else { + i++; + } + } + if (!handlers.length) { + delete othersEvents.events[eventName]; + } + } + if (can.isEmptyObject(othersEvents.events)) { + delete idedEvents[cid]; + } + } + return this; + }; + can.removeEvent = function (event, fn, __validate) { + if (!this.__bindEvents) { + return this; + } + var events = this.__bindEvents[event] || [], i = 0, ev, isFunction = typeof fn === 'function'; + while (i < events.length) { + ev = events[i]; + if (__validate ? __validate(ev, event, fn) : isFunction && ev.handler === fn || !isFunction && (ev.cid === fn || !fn)) { + events.splice(i, 1); + } else { + i++; + } + } + return this; + }; + can.dispatch = function (event, args) { + var events = this.__bindEvents; + if (!events) { + return; + } + if (typeof event === 'string') { + event = { type: event }; + } + var eventName = event.type, handlers = (events[eventName] || []).slice(0), passed = [event]; + if (args) { + passed.push.apply(passed, args); + } + for (var i = 0, len = handlers.length; i < len; i++) { + handlers[i].handler.apply(this, passed); + } + return event; + }; + can.one = function (event, handler) { + var one = function () { + can.unbind.call(this, event, one); + return handler.apply(this, arguments); + }; + can.bind.call(this, event, one); + return this; + }; + can.event = { + on: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.on.call(this); + } else { + return can.addEvent.apply(this, arguments); + } + }, + off: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.off.call(this); + } else { + return can.removeEvent.apply(this, arguments); + } + }, + bind: can.addEvent, + unbind: can.removeEvent, + delegate: function (selector, event, handler) { + return can.addEvent.call(this, event, handler); + }, + undelegate: function (selector, event, handler) { + return can.removeEvent.call(this, event, handler); + }, + trigger: can.dispatch, + one: can.one, + addEvent: can.addEvent, + removeEvent: can.removeEvent, + listenTo: can.listenTo, + stopListening: can.stopListening, + dispatch: can.dispatch + }; + return can.event; +}); +/*can@2.2.6#util/fragment*/ +define('can/util/fragment', ['can/util/can'], function (can) { + var fragmentRE = /^\s*<(\w+)[^>]*>/, toString = {}.toString, fragment = function (html, name) { + if (name === undefined) { + name = fragmentRE.test(html) && RegExp.$1; + } + if (html && toString.call(html.replace) === '[object Function]') { + html = html.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, '<$1>'); + } + var container = document.createElement('div'), temp = document.createElement('div'); + if (name === 'tbody' || name === 'tfoot' || name === 'thead') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; + } else if (name === 'tr') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild; + } else if (name === 'td' || name === 'th') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild.firstChild; + } else if (name === 'option') { + temp.innerHTML = ''; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; + } else { + container.innerHTML = '' + html; + } + var tmp = {}, children = container.childNodes; + tmp.length = children.length; + for (var i = 0; i < children.length; i++) { + tmp[i] = children[i]; + } + return [].slice.call(tmp); + }; + can.buildFragment = function (html, nodes) { + if (html && html.nodeType === 11) { + return html; + } + var parts = fragment(html), frag = document.createDocumentFragment(); + for (var i = 0, length = parts.length; i < length; i++) { + frag.appendChild(parts[i]); + } + return frag; + }; + (function () { + var text = '<-\n>', frag = can.buildFragment(text, document); + if (text !== frag.childNodes[0].nodeValue) { + var oldBuildFragment = can.buildFragment; + can.buildFragment = function (html, nodes) { + var res = oldBuildFragment(html, nodes); + if (res.childNodes.length === 1 && res.childNodes[0].nodeType === 3) { + res.childNodes[0].nodeValue = html; + } + return res; + }; + } + }()); + return can; +}); +/*can@2.2.6#util/array/each*/ +define('can/util/array/each', ['can/util/can'], function (can) { + var isArrayLike = function (obj) { + var length = 'length' in obj && obj.length; + return typeof arr !== 'function' && (length === 0 || typeof length === 'number' && length > 0 && length - 1 in obj); + }; + can.each = function (elements, callback, context) { + var i = 0, key, len, item; + if (elements) { + if (isArrayLike(elements)) { + if (can.List && elements instanceof can.List) { + for (len = elements.attr('length'); i < len; i++) { + item = elements.attr(i); + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } else { + for (len = elements.length; i < len; i++) { + item = elements[i]; + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } + } else if (typeof elements === 'object') { + if (can.Map && elements instanceof can.Map || elements === can.route) { + var keys = can.Map.keys(elements); + for (i = 0, len = keys.length; i < len; i++) { + key = keys[i]; + item = elements.attr(key); + if (callback.call(context || item, item, key, elements) === false) { + break; + } + } + } else { + for (key in elements) { + if (elements.hasOwnProperty(key) && callback.call(context || elements[key], elements[key], key, elements) === false) { + break; + } + } + } + } + } + return elements; + }; + return can; +}); +/*can@2.2.6#util/object/isplain/isplain*/ +define('can/util/object/isplain/isplain', ['can/util/can'], function () { + var core_hasOwn = Object.prototype.hasOwnProperty, isWindow = function (obj) { + return obj !== null && obj == obj.window; + }, isPlainObject = function (obj) { + if (!obj || typeof obj !== 'object' || obj.nodeType || isWindow(obj)) { + return false; + } + try { + if (obj.constructor && !core_hasOwn.call(obj, 'constructor') && !core_hasOwn.call(obj.constructor.prototype, 'isPrototypeOf')) { + return false; + } + } catch (e) { + return false; + } + var key; + for (key in obj) { + } + return key === undefined || core_hasOwn.call(obj, key); + }; + can.isPlainObject = isPlainObject; + return can; +}); +/*can@2.2.6#util/deferred*/ +define('can/util/deferred', ['can/util/can'], function (can) { + var extend = function (target, src) { + for (var key in src) { + if (src.hasOwnProperty(key)) { + target[key] = src[key]; + } + } + }, Deferred = function (func) { + if (!(this instanceof Deferred)) { + return new Deferred(); + } + this._doneFuncs = []; + this._failFuncs = []; + this._resultArgs = null; + this._status = ''; + if (func) { + func.call(this, this); + } + }; + can.Deferred = Deferred; + can.when = Deferred.when = function () { + var args = can.makeArray(arguments); + if (args.length < 2) { + var obj = args[0]; + if (obj && (can.isFunction(obj.isResolved) && can.isFunction(obj.isRejected))) { + return obj; + } else { + return Deferred().resolve(obj); + } + } else { + var df = Deferred(), done = 0, rp = []; + can.each(args, function (arg, j) { + arg.done(function () { + rp[j] = arguments.length < 2 ? arguments[0] : arguments; + if (++done === args.length) { + df.resolve.apply(df, rp); + } + }).fail(function () { + df.reject(arguments.length === 1 ? arguments[0] : arguments); + }); + }); + return df; + } + }; + var resolveFunc = function (type, _status) { + return function (context) { + var args = this._resultArgs = arguments.length > 1 ? arguments[1] : []; + return this.exec(context, this[type], args, _status); + }; + }, doneFunc = function doneFunc(type, _status) { + return function () { + var self = this; + can.each(Array.prototype.slice.call(arguments), function (v, i, args) { + if (!v) { + return; + } + if (v.constructor === Array) { + doneFunc.apply(self, v); + } else { + if (self._status === _status) { + v.apply(self, self._resultArgs || []); + } + self[type].push(v); + } + }); + return this; + }; + }; + var isDeferred = function (obj) { + return obj && obj.then && obj.fail && obj.done; + }; + var wire = function (parentDeferred, result, setter, value) { + if (isDeferred(result)) { + result.done(can.proxy(parentDeferred.resolve, parentDeferred)).fail(can.proxy(parentDeferred.reject, parentDeferred)); + } else { + setter.call(parentDeferred, result !== undefined ? result : value); + } + }; + extend(Deferred.prototype, { + then: function (done, fail) { + var d = can.Deferred(), resolve = d.resolve, reject = d.reject; + this.done(function (value) { + if (typeof done === 'function') { + wire(d, done.apply(this, arguments), resolve, value); + } else { + resolve.apply(d, arguments); + } + }); + this.fail(function (value) { + if (typeof fail === 'function') { + wire(d, fail.apply(this, arguments), reject, value); + } else { + reject.apply(d, arguments); + } + }); + return d; + }, + resolveWith: resolveFunc('_doneFuncs', 'rs'), + rejectWith: resolveFunc('_failFuncs', 'rj'), + done: doneFunc('_doneFuncs', 'rs'), + fail: doneFunc('_failFuncs', 'rj'), + always: function () { + var args = can.makeArray(arguments); + if (args.length && args[0]) { + this.done(args[0]).fail(args[0]); + } + return this; + }, + state: function () { + switch (this._status) { + case 'rs': + return 'resolved'; + case 'rj': + return 'rejected'; + default: + return 'pending'; + } + }, + isResolved: function () { + return this._status === 'rs'; + }, + isRejected: function () { + return this._status === 'rj'; + }, + reject: function () { + return this.rejectWith(this, arguments); + }, + resolve: function () { + return this.resolveWith(this, arguments); + }, + exec: function (context, dst, args, st) { + if (this._status !== '') { + return this; + } + this._status = st; + can.each(dst, function (d) { + if (typeof d.apply === 'function') { + d.apply(context, args); + } + }); + return this; + }, + promise: function () { + var promise = this.then(); + promise.reject = promise.resolve = undefined; + return promise; + } + }); + Deferred.prototype.pipe = Deferred.prototype.then; + return can; +}); +/*can@2.2.6#util/hashchange*/ +define('can/util/hashchange', ['can/util/can'], function (can) { + (function () { + var addEvent = function (el, ev, fn) { + if (el.addEventListener) { + el.addEventListener(ev, fn, false); + } else if (el.attachEvent) { + el.attachEvent('on' + ev, fn); + } else { + el['on' + ev] = fn; + } + }, onHashchange = function () { + can.trigger(window, 'hashchange'); + }; + addEvent(window, 'hashchange', onHashchange); + }()); +}); +/*can@2.2.6#util/inserted/inserted*/ +define('can/util/inserted/inserted', ['can/util/can'], function (can) { + can.inserted = function (elems) { + elems = can.makeArray(elems); + var inDocument = false, doc = can.$(document.contains ? document : document.body), children; + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + if (!inDocument) { + if (elem.getElementsByTagName) { + if (can.has(doc, elem).length) { + inDocument = true; + } else { + return; + } + } else { + continue; + } + } + if (inDocument && elem.getElementsByTagName) { + children = can.makeArray(elem.getElementsByTagName('*')); + can.trigger(elem, 'inserted', [], false); + for (var j = 0, child; (child = children[j]) !== undefined; j++) { + can.trigger(child, 'inserted', [], false); + } + } + } + }; + can.appendChild = function (el, child) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.appendChild(child); + can.inserted(children); + }; + can.insertBefore = function (el, child, ref) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.insertBefore(child, ref); + can.inserted(children); + }; +}); +/*can@2.2.6#util/util*/ +'format steal'; +define('can/util/util', [ + 'can/util/can', + 'can/util/attr/attr', + 'can/dojo/dojo', + 'can/event/event', + 'can/util/fragment', + 'can/util/array/each', + 'can/util/object/isplain/isplain', + 'can/util/deferred', + 'can/util/hashchange', + 'can/util/inserted/inserted' +], function (can, attr, djo) { + var dojo = djo || window.dojo; + define('plugd/trigger', ['dojo/main'], function () { + var d = dojo; + var isfn = d.isFunction; + var leaveRe = /mouse(enter|leave)/; + var _fix = function (_, p) { + return 'mouse' + (p === 'enter' ? 'over' : 'out'); + }; + var mix = d._mixin; + var realTrigger; + if (d.doc.createEvent) { + realTrigger = function (n, e, a) { + var ev = d.doc.createEvent('HTMLEvents'); + e = e.replace(leaveRe, _fix); + ev.initEvent(e, e === 'removed' || e === 'inserted' ? false : true, true); + if (a) { + mix(ev, a); + } + n.dispatchEvent(ev); + }; + } else { + realTrigger = function (n, e, a) { + var ev = 'on' + e, stop = false; + try { + var evObj = document.createEventObject(); + if (e === 'inserted' || e === 'removed') { + evObj.cancelBubble = true; + } + mix(evObj, a); + n.fireEvent(ev, evObj); + } catch (er) { + var evdata = mix({ + type: e, + target: n, + faux: true, + _stopper: function () { + stop = this.cancelBubble; + } + }, a); + if (isfn(n[ev])) { + n[ev](evdata); + } + if (e === 'inserted' || e === 'removed') { + return; + } + while (!stop && n !== d.doc && n.parentNode) { + n = n.parentNode; + if (isfn(n[ev])) { + n[ev](evdata); + } + } + } + }; + } + d._trigger = function (node, event, extraArgs) { + if (typeof event !== 'string') { + extraArgs = event; + event = extraArgs.type; + delete extraArgs.type; + } + var n = d.byId(node), ev = event && event.slice(0, 2) === 'on' ? event.slice(2) : event; + realTrigger(n, ev, extraArgs); + }; + d.trigger = function (obj, event, extraArgs) { + return isfn(obj) || isfn(event) || isfn(obj[event]) ? d.hitch.apply(d, arguments)() : d._trigger.apply(d, arguments); + }; + d.NodeList.prototype.trigger = d.NodeList._adaptAsForEach(d._trigger); + if (d._Node && !d._Node.prototype.trigger) { + d.extend(d._Node, { + trigger: function (ev, data) { + d._trigger(this, ev, data); + return this; + } + }); + } + return d.trigger; + }); + require([ + 'dojo/main', + 'dojo/query', + 'plugd/trigger', + 'dojo/NodeList-dom' + ]); + can.trim = function (s) { + return s && dojo.trim(s); + }; + can.makeArray = function (arr) { + var array = []; + dojo.forEach(arr, function (item) { + array.push(item); + }); + return array; + }; + can.isArray = dojo.isArray; + can.inArray = function (item, arr, from) { + return dojo.indexOf(arr, item, from); + }; + can.map = function (arr, fn) { + return dojo.map(can.makeArray(arr || []), fn); + }; + can.extend = function (first) { + if (first === true) { + var args = can.makeArray(arguments); + args.shift(); + return dojo.mixin.apply(dojo, args); + } + return dojo.mixin.apply(dojo, arguments); + }; + can.isEmptyObject = function (object) { + var prop; + for (prop in object) { + break; + } + return prop === undefined; + }; + can.param = function (object) { + var pairs = [], add = function (key, value) { + pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(value)); + }; + for (var name in object) { + can.buildParam(name, object[name], add); + } + return pairs.join('&').replace(/%20/g, '+'); + }; + can.buildParam = function (prefix, obj, add) { + if (can.isArray(obj)) { + for (var i = 0, l = obj.length; i < l; ++i) { + add(prefix + '[]', obj[i]); + } + } else if (dojo.isObject(obj)) { + for (var name in obj) { + can.buildParam(prefix + '[' + name + ']', obj[name], add); + } + } else { + add(prefix, obj); + } + }; + can.proxy = function (func, context) { + return dojo.hitch(context, func); + }; + can.isFunction = function (f) { + return dojo.isFunction(f); + }; + var dojoId = 0, dojoAddBinding = function (nodelist, ev, cb) { + nodelist.forEach(function (node) { + node = new dojo.NodeList(node.nodeName === 'SELECT' ? [node] : node); + var events = can.data(node, 'events'); + if (!events) { + can.data(node, 'events', events = {}); + } + if (!events[ev]) { + events[ev] = {}; + } + if (cb.__bindingsIds === undefined) { + cb.__bindingsIds = dojoId++; + } + events[ev][cb.__bindingsIds] = node.on(ev, cb)[0]; + }); + }, dojoRemoveBinding = function (nodelist, ev, cb) { + nodelist.forEach(function (node) { + var currentNode = new dojo.NodeList(node), events = can.data(currentNode, 'events'); + if (!events) { + return; + } + var handlers = events[ev]; + if (!handlers) { + return; + } + var handler = handlers[cb.__bindingsIds]; + dojo.disconnect(handler); + delete handlers[cb.__bindingsIds]; + if (can.isEmptyObject(handlers)) { + delete events[ev]; + } + }); + }; + can.bind = function (ev, cb) { + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (this.on || this.nodeType) { + dojoAddBinding(new dojo.NodeList(this.nodeName === 'SELECT' ? [this] : this), ev, cb); + } else if (this.addEvent) { + this.addEvent(ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + return this; + }; + can.unbind = function (ev, cb) { + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (this.on || this.nodeType) { + dojoRemoveBinding(new dojo.NodeList(this), ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + return this; + }; + can.on = can.bind; + can.off = can.unbind; + can.trigger = function (item, event, args, bubble) { + if (!(item instanceof dojo.NodeList) && (item.nodeName || item === window)) { + item = can.$(item); + } + if (item.trigger) { + if (bubble === false) { + if (!item[0] || item[0].nodeType === 3) { + return; + } + var connect = item.on(event, function (ev) { + if (ev.stopPropagation) { + ev.stopPropagation(); + } + ev.cancelBubble = true; + if (ev._stopper) { + ev._stopper(); + } + dojo.disconnect(connect); + }); + item.trigger(event, args); + } else { + item.trigger(event, args); + } + } else { + if (typeof event === 'string') { + event = { type: event }; + } + event.target = event.target || item; + can.dispatch.call(item, event, can.makeArray(args)); + } + }; + can.delegate = function (selector, ev, cb) { + if (!selector) { + can.bind.call(this, ev, cb); + } else if (this.on || this.nodeType) { + dojoAddBinding(new dojo.NodeList(this), selector + ':' + ev, cb); + } else if (this.delegate) { + this.delegate(selector, ev, cb); + } else { + can.bind.call(this, ev, cb); + } + return this; + }; + can.undelegate = function (selector, ev, cb) { + if (!selector) { + can.unbind.call(this, ev, cb); + } else if (this.on || this.nodeType) { + dojoRemoveBinding(new dojo.NodeList(this), selector + ':' + ev, cb); + } else if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else { + can.unbind.call(this, ev, cb); + } + return this; + }; + var updateDeferred = function (xhr, d) { + for (var prop in xhr) { + if (typeof d[prop] === 'function') { + d[prop] = function () { + xhr[prop].apply(xhr, arguments); + }; + } else { + d[prop] = prop[xhr]; + } + } + }; + can.ajax = function (options) { + var type = can.capitalize((options.type || 'get').toLowerCase()), method = dojo['xhr' + type]; + var success = options.success, error = options.error, d = new can.Deferred(); + var def = method({ + url: options.url, + handleAs: options.dataType, + sync: !options.async, + headers: options.headers, + content: options.data + }); + def.then(function (data, ioargs) { + updateDeferred(xhr, d); + d.resolve(data, 'success', xhr); + if (success) { + success(data, 'success', xhr); + } + }, function (data, ioargs) { + updateDeferred(xhr, d); + d.reject(xhr, 'error'); + error(xhr, 'error'); + }); + var xhr = def.ioArgs.xhr; + updateDeferred(xhr, d); + return d; + }; + can.$ = function (selector) { + if (selector === window) { + return window; + } + if (typeof selector === 'string') { + return dojo.query(selector); + } else { + return new dojo.NodeList(selector && selector.nodeName ? [selector] : selector); + } + }; + can.append = function (wrapped, html) { + return wrapped.forEach(function (node) { + dojo.place(html, node); + }); + }; + var data = {}, uuid = can.uuid = +new Date(), exp = can.expando = 'can' + uuid; + function getData(node, name) { + var id = node[exp], store = id && data[id]; + return name === undefined ? store || setData(node) : store && store[name]; + } + function setData(node, name, value) { + var id = node[exp] || (node[exp] = ++uuid), store = data[id] || (data[id] = {}); + if (name !== undefined) { + store[name] = value; + } + return store; + } + var cleanData = function (elems) { + var nodes = []; + for (var i = 0, len = elems.length; i < len; i++) { + if (elems[i].nodeType === 1) { + nodes.push(elems[i]); + } + } + can.trigger(new dojo.NodeList(nodes), 'removed', [], false); + i = 0; + for (var elem; (elem = elems[i]) !== undefined; i++) { + var id = elem[exp]; + delete data[id]; + } + }; + can.data = function (wrapped, name, value) { + return value === undefined ? wrapped.length === 0 ? undefined : getData(wrapped[0], name) : wrapped.forEach(function (node) { + setData(node, name, value); + }); + }; + can.cleanData = function (elem, prop) { + var id = elem[exp]; + delete data[id][prop]; + }; + dojo.empty = function (node) { + for (var c; c = node.lastChild;) { + dojo.destroy(c); + } + }; + var destroy = dojo.destroy; + dojo.destroy = function (node) { + node = dojo.byId(node); + var nodes = [node]; + if (node.getElementsByTagName) { + nodes.concat(can.makeArray(node.getElementsByTagName('*'))); + } + cleanData(nodes); + return destroy.apply(dojo, arguments); + }; + var place = dojo.place; + dojo.place = function (node, refNode, position) { + if (typeof node === 'string' && /^\s*/g, '>').replace(strQuote, '"').replace(strSingleQuote, '''); + }, + getObject: function (name, roots, add) { + var parts = name ? name.split('.') : [], length = parts.length, current, r = 0, i, container, rootsLength; + roots = can.isArray(roots) ? roots : [roots || window]; + rootsLength = roots.length; + if (!length) { + return roots[0]; + } + for (r; r < rootsLength; r++) { + current = roots[r]; + container = undefined; + for (i = 0; i < length && isContainer(current); i++) { + container = current; + current = getNext(container, parts[i]); + } + if (container !== undefined && current !== undefined) { + break; + } + } + if (add === false && current !== undefined) { + delete container[parts[i - 1]]; + } + if (add === true && current === undefined) { + current = roots[0]; + for (i = 0; i < length && isContainer(current); i++) { + current = getNext(current, parts[i], true); + } + } + return current; + }, + capitalize: function (s, cache) { + return s.charAt(0).toUpperCase() + s.slice(1); + }, + camelize: function (str) { + return convertBadValues(str).replace(strHyphenMatch, function (match, chr) { + return chr ? chr.toUpperCase() : ''; + }); + }, + hyphenate: function (str) { + return convertBadValues(str).replace(strCamelMatch, function (str, offset) { + return str.charAt(0) + '-' + str.charAt(1).toLowerCase(); + }); + }, + underscore: function (s) { + return s.replace(strColons, '/').replace(strWords, '$1_$2').replace(strLowUp, '$1_$2').replace(strDash, '_').toLowerCase(); + }, + sub: function (str, data, remove) { + var obs = []; + str = str || ''; + obs.push(str.replace(strReplacer, function (whole, inside) { + var ob = can.getObject(inside, data, remove === true ? false : undefined); + if (ob === undefined || ob === null) { + obs = null; + return ''; + } + if (isContainer(ob) && obs) { + obs.push(ob); + return ''; + } + return '' + ob; + })); + return obs === null ? obs : obs.length <= 1 ? obs[0] : obs; + }, + replacer: strReplacer, + undHash: strUndHash + }); + return can; +}); +/*can@2.2.6#construct/construct*/ +define('can/construct/construct', ['can/util/string/string'], function (can) { + var initializing = 0; + var canGetDescriptor; + try { + Object.getOwnPropertyDescriptor({}); + canGetDescriptor = true; + } catch (e) { + canGetDescriptor = false; + } + var getDescriptor = function (newProps, name) { + var descriptor = Object.getOwnPropertyDescriptor(newProps, name); + if (descriptor && (descriptor.get || descriptor.set)) { + return descriptor; + } + return null; + }, inheritGetterSetter = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + var descriptor; + for (var name in newProps) { + if (descriptor = getDescriptor(newProps, name)) { + this._defineProperty(addTo, oldProps, name, descriptor); + } else { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + } + }, simpleInherit = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + for (var name in newProps) { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + }; + can.Construct = function () { + if (arguments.length) { + return can.Construct.extend.apply(can.Construct, arguments); + } + }; + can.extend(can.Construct, { + constructorExtends: true, + newInstance: function () { + var inst = this.instance(), args; + if (inst.setup) { + args = inst.setup.apply(inst, arguments); + } + if (inst.init) { + inst.init.apply(inst, args || arguments); + } + return inst; + }, + _inherit: canGetDescriptor ? inheritGetterSetter : simpleInherit, + _defineProperty: function (what, oldProps, propName, descriptor) { + Object.defineProperty(what, propName, descriptor); + }, + _overwrite: function (what, oldProps, propName, val) { + what[propName] = val; + }, + setup: function (base, fullName) { + this.defaults = can.extend(true, {}, base.defaults, this.defaults); + }, + instance: function () { + initializing = 1; + var inst = new this(); + initializing = 0; + return inst; + }, + extend: function (name, staticProperties, instanceProperties) { + var fullName = name, klass = staticProperties, proto = instanceProperties; + if (typeof fullName !== 'string') { + proto = klass; + klass = fullName; + fullName = null; + } + if (!proto) { + proto = klass; + klass = null; + } + proto = proto || {}; + var _super_class = this, _super = this.prototype, Constructor, parts, current, _fullName, _shortName, propName, shortName, namespace, prototype; + prototype = this.instance(); + can.Construct._inherit(proto, _super, prototype); + if (fullName) { + parts = fullName.split('.'); + shortName = parts.pop(); + } + if (typeof constructorName === 'undefined') { + Constructor = function () { + return init.apply(this, arguments); + }; + } + function init() { + if (!initializing) { + return this.constructor !== Constructor && arguments.length && Constructor.constructorExtends ? Constructor.extend.apply(Constructor, arguments) : Constructor.newInstance.apply(Constructor, arguments); + } + } + for (propName in _super_class) { + if (_super_class.hasOwnProperty(propName)) { + Constructor[propName] = _super_class[propName]; + } + } + can.Construct._inherit(klass, _super_class, Constructor); + if (fullName) { + current = can.getObject(parts.join('.'), window, true); + namespace = current; + _fullName = can.underscore(fullName.replace(/\./g, '_')); + _shortName = can.underscore(shortName); + current[shortName] = Constructor; + } + can.extend(Constructor, { + constructor: Constructor, + prototype: prototype, + namespace: namespace, + _shortName: _shortName, + fullName: fullName, + _fullName: _fullName + }); + if (shortName !== undefined) { + Constructor.shortName = shortName; + } + Constructor.prototype.constructor = Constructor; + var t = [_super_class].concat(can.makeArray(arguments)), args = Constructor.setup.apply(Constructor, t); + if (Constructor.init) { + Constructor.init.apply(Constructor, args || t); + } + return Constructor; + } + }); + can.Construct.prototype.setup = function () { + }; + can.Construct.prototype.init = function () { + }; + return can.Construct; +}); +/*can@2.2.6#control/control*/ +define('can/control/control', [ + 'can/util/util', + 'can/construct/construct' +], function (can) { + var bind = function (el, ev, callback) { + can.bind.call(el, ev, callback); + return function () { + can.unbind.call(el, ev, callback); + }; + }, isFunction = can.isFunction, extend = can.extend, each = can.each, slice = [].slice, paramReplacer = /\{([^\}]+)\}/g, special = can.getObject('$.event.special', [can]) || {}, delegate = function (el, selector, ev, callback) { + can.delegate.call(el, selector, ev, callback); + return function () { + can.undelegate.call(el, selector, ev, callback); + }; + }, binder = function (el, ev, callback, selector) { + return selector ? delegate(el, can.trim(selector), ev, callback) : bind(el, ev, callback); + }, basicProcessor; + var Control = can.Control = can.Construct({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Control) { + var control = this, funcName; + control.actions = {}; + for (funcName in control.prototype) { + if (control._isAction(funcName)) { + control.actions[funcName] = control._action(funcName); + } + } + } + }, + _shifter: function (context, name) { + var method = typeof name === 'string' ? context[name] : name; + if (!isFunction(method)) { + method = context[method]; + } + return function () { + context.called = name; + return method.apply(context, [this.nodeName ? can.$(this) : this].concat(slice.call(arguments, 0))); + }; + }, + _isAction: function (methodName) { + var val = this.prototype[methodName], type = typeof val; + return methodName !== 'constructor' && (type === 'function' || type === 'string' && isFunction(this.prototype[val])) && !!(special[methodName] || processors[methodName] || /[^\w]/.test(methodName)); + }, + _action: function (methodName, options) { + paramReplacer.lastIndex = 0; + if (options || !paramReplacer.test(methodName)) { + var convertedName = options ? can.sub(methodName, this._lookup(options)) : methodName; + if (!convertedName) { + return null; + } + var arr = can.isArray(convertedName), name = arr ? convertedName[1] : convertedName, parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: processors[event] || basicProcessor, + parts: [ + name, + parts.join(' '), + event + ], + delegate: arr ? convertedName[0] : undefined + }; + } + }, + _lookup: function (options) { + return [ + options, + window + ]; + }, + processors: {}, + defaults: {} + }, { + setup: function (element, options) { + var cls = this.constructor, pluginname = cls.pluginName || cls._fullName, arr; + this.element = can.$(element); + if (pluginname && pluginname !== 'can_control') { + this.element.addClass(pluginname); + } + arr = can.data(this.element, 'controls'); + if (!arr) { + arr = []; + can.data(this.element, 'controls', arr); + } + arr.push(this); + this.options = extend({}, cls.defaults, options); + this.on(); + return [ + this.element, + this.options + ]; + }, + on: function (el, selector, eventName, func) { + if (!el) { + this.off(); + var cls = this.constructor, bindings = this._bindings, actions = cls.actions, element = this.element, destroyCB = can.Control._shifter(this, 'destroy'), funcName, ready; + for (funcName in actions) { + if (actions.hasOwnProperty(funcName)) { + ready = actions[funcName] || cls._action(funcName, this.options, this); + if (ready) { + bindings.control[funcName] = ready.processor(ready.delegate || element, ready.parts[2], ready.parts[1], funcName, this); + } + } + } + can.bind.call(element, 'removed', destroyCB); + bindings.user.push(function (el) { + can.unbind.call(el, 'removed', destroyCB); + }); + return bindings.user.length; + } + if (typeof el === 'string') { + func = eventName; + eventName = selector; + selector = el; + el = this.element; + } + if (func === undefined) { + func = eventName; + eventName = selector; + selector = null; + } + if (typeof func === 'string') { + func = can.Control._shifter(this, func); + } + this._bindings.user.push(binder(el, eventName, func, selector)); + return this._bindings.user.length; + }, + off: function () { + var el = this.element[0], bindings = this._bindings; + if (bindings) { + each(bindings.user || [], function (value) { + value(el); + }); + each(bindings.control || {}, function (value) { + value(el); + }); + } + this._bindings = { + user: [], + control: {} + }; + }, + destroy: function () { + if (this.element === null) { + return; + } + var Class = this.constructor, pluginName = Class.pluginName || Class._fullName, controls; + this.off(); + if (pluginName && pluginName !== 'can_control') { + this.element.removeClass(pluginName); + } + controls = can.data(this.element, 'controls'); + controls.splice(can.inArray(this, controls), 1); + can.trigger(this, 'destroyed'); + this.element = null; + } + }); + var processors = can.Control.processors; + basicProcessor = function (el, event, selector, methodName, control) { + return binder(el, event, can.Control._shifter(control, methodName), selector); + }; + each([ + 'change', + 'click', + 'contextmenu', + 'dblclick', + 'keydown', + 'keyup', + 'keypress', + 'mousedown', + 'mousemove', + 'mouseout', + 'mouseover', + 'mouseup', + 'reset', + 'resize', + 'scroll', + 'select', + 'submit', + 'focusin', + 'focusout', + 'mouseenter', + 'mouseleave', + 'touchstart', + 'touchmove', + 'touchcancel', + 'touchend', + 'touchleave', + 'inserted', + 'removed' + ], function (v) { + processors[v] = basicProcessor; + }); + return Control; +}); +/*can@2.2.6#util/bind/bind*/ +define('can/util/bind/bind', ['can/util/util'], function (can) { + can.bindAndSetup = function () { + can.addEvent.apply(this, arguments); + if (!this._init) { + if (!this._bindings) { + this._bindings = 1; + if (this._bindsetup) { + this._bindsetup(); + } + } else { + this._bindings++; + } + } + return this; + }; + can.unbindAndTeardown = function (event, handler) { + var handlers = this.__bindEvents[event] || []; + var handlerCount = handlers.length; + can.removeEvent.apply(this, arguments); + if (this._bindings === null) { + this._bindings = 0; + } else { + this._bindings = this._bindings - (handlerCount - handlers.length); + } + if (!this._bindings && this._bindteardown) { + this._bindteardown(); + } + return this; + }; + return can; +}); +/*can@2.2.6#map/bubble*/ +define('can/map/bubble', ['can/util/util'], function (can) { + var bubble = can.bubble = { + event: function (map, boundEventName) { + return map.constructor._bubbleRule(boundEventName, map); + }, + childrenOf: function (parentMap, eventName) { + parentMap._each(function (child, prop) { + if (child && child.bind) { + bubble.toParent(child, parentMap, prop, eventName); + } + }); + }, + teardownChildrenFrom: function (parentMap, eventName) { + parentMap._each(function (child) { + bubble.teardownFromParent(parentMap, child, eventName); + }); + }, + toParent: function (child, parent, prop, eventName) { + can.listenTo.call(parent, child, eventName, function () { + var args = can.makeArray(arguments), ev = args.shift(); + args[0] = (can.List && parent instanceof can.List ? parent.indexOf(child) : prop) + (args[0] ? '.' + args[0] : ''); + ev.triggeredNS = ev.triggeredNS || {}; + if (ev.triggeredNS[parent._cid]) { + return; + } + ev.triggeredNS[parent._cid] = true; + can.trigger(parent, ev, args); + }); + }, + teardownFromParent: function (parent, child, eventName) { + if (child && child.unbind) { + can.stopListening.call(parent, child, eventName); + } + }, + isBubbling: function (parent, eventName) { + return parent._bubbleBindings && parent._bubbleBindings[eventName]; + }, + bind: function (parent, eventName) { + if (!parent._init) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + if (!parent._bubbleBindings) { + parent._bubbleBindings = {}; + } + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (!parent._bubbleBindings[bubbleEvent]) { + parent._bubbleBindings[bubbleEvent] = 1; + bubble.childrenOf(parent, bubbleEvent); + } else { + parent._bubbleBindings[bubbleEvent]++; + } + } + } + }, + unbind: function (parent, eventName) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (parent._bubbleBindings) { + parent._bubbleBindings[bubbleEvent]--; + } + if (parent._bubbleBindings && !parent._bubbleBindings[bubbleEvent]) { + delete parent._bubbleBindings[bubbleEvent]; + bubble.teardownChildrenFrom(parent, bubbleEvent); + if (can.isEmptyObject(parent._bubbleBindings)) { + delete parent._bubbleBindings; + } + } + } + }, + add: function (parent, child, prop) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + bubble.toParent(child, parent, prop, eventName); + } + } + } + }, + removeMany: function (parent, children) { + for (var i = 0, len = children.length; i < len; i++) { + bubble.remove(parent, children[i]); + } + }, + remove: function (parent, child) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + } + } + } + }, + set: function (parent, prop, value, current) { + if (can.Map.helpers.isObservable(value)) { + bubble.add(parent, value, prop); + } + if (can.Map.helpers.isObservable(current)) { + bubble.remove(parent, current); + } + return value; + } + }; + return bubble; +}); +/*can@2.2.6#util/batch/batch*/ +define('can/util/batch/batch', ['can/util/can'], function (can) { + var batchNum = 1, transactions = 0, batchEvents = [], stopCallbacks = [], currentBatchEvents = null; + can.batch = { + start: function (batchStopHandler) { + transactions++; + if (batchStopHandler) { + stopCallbacks.push(batchStopHandler); + } + }, + stop: function (force, callStart) { + if (force) { + transactions = 0; + } else { + transactions--; + } + if (transactions === 0) { + if (currentBatchEvents !== null) { + return; + } + currentBatchEvents = batchEvents.slice(0); + var callbacks = stopCallbacks.slice(0), i, len; + batchEvents = []; + stopCallbacks = []; + can.batch.batchNum = batchNum; + batchNum++; + if (callStart) { + can.batch.start(); + } + for (i = 0; i < currentBatchEvents.length; i++) { + can.dispatch.apply(currentBatchEvents[i][0], currentBatchEvents[i][1]); + } + currentBatchEvents = null; + for (i = 0, len = callbacks.length; i < callbacks.length; i++) { + callbacks[i](); + } + can.batch.batchNum = undefined; + } + }, + trigger: function (item, event, args) { + if (!item._init) { + event = typeof event === 'string' ? { type: event } : event; + if (currentBatchEvents) { + currentBatchEvents.push([ + item, + [ + event, + args + ] + ]); + } else if (transactions === 0) { + return can.dispatch.call(item, event, args); + } else { + event.batchNum = batchNum; + batchEvents.push([ + item, + [ + event, + args + ] + ]); + } + } + }, + afterPreviousEvents: function (handler) { + if (currentBatchEvents) { + var obj = {}; + can.bind.call(obj, 'ready', handler); + currentBatchEvents.push([ + obj, + [ + { type: 'ready' }, + [] + ] + ]); + } else { + handler(); + } + } + }; +}); +/*can@2.2.6#map/map*/ +define('can/map/map', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/map/bubble', + 'can/construct/construct', + 'can/util/batch/batch' +], function (can, bind, bubble) { + var madeMap = null; + var teardownMap = function () { + for (var cid in madeMap) { + if (madeMap[cid].added) { + delete madeMap[cid].obj._cid; + } + } + madeMap = null; + }; + var getMapFromObject = function (obj) { + return madeMap && madeMap[obj._cid] && madeMap[obj._cid].instance; + }; + var serializeMap = null; + var Map = can.Map = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Map) { + if (!this.defaults) { + this.defaults = {}; + } + this._computes = []; + for (var prop in this.prototype) { + if (prop !== 'define' && prop !== 'constructor' && (typeof this.prototype[prop] !== 'function' || this.prototype[prop].prototype instanceof can.Construct)) { + this.defaults[prop] = this.prototype[prop]; + } else if (this.prototype[prop].isComputed) { + this._computes.push(prop); + } + } + if (this.helpers.define) { + this.helpers.define(this); + } + } + if (can.List && !(this.prototype instanceof can.List)) { + this.List = Map.List.extend({ Map: this }, {}); + } + }, + _bubble: bubble, + _bubbleRule: function (eventName) { + return eventName === 'change' || eventName.indexOf('.') >= 0 ? ['change'] : []; + }, + _computes: [], + bind: can.bindAndSetup, + on: can.bindAndSetup, + unbind: can.unbindAndTeardown, + off: can.unbindAndTeardown, + id: 'id', + helpers: { + define: null, + attrParts: function (attr, keepKey) { + if (keepKey) { + return [attr]; + } + return typeof attr === 'object' ? attr : ('' + attr).split('.'); + }, + addToMap: function (obj, instance) { + var teardown; + if (!madeMap) { + teardown = teardownMap; + madeMap = {}; + } + var hasCid = obj._cid; + var cid = can.cid(obj); + if (!madeMap[cid]) { + madeMap[cid] = { + obj: obj, + instance: instance, + added: !hasCid + }; + } + return teardown; + }, + isObservable: function (obj) { + return obj instanceof can.Map || obj && obj === can.route; + }, + canMakeObserve: function (obj) { + return obj && !can.isDeferred(obj) && (can.isArray(obj) || can.isPlainObject(obj)); + }, + serialize: function (map, how, where) { + var cid = can.cid(map), firstSerialize = false; + if (!serializeMap) { + firstSerialize = true; + serializeMap = { + attr: {}, + serialize: {} + }; + } + serializeMap[how][cid] = where; + map.each(function (val, name) { + var result, isObservable = Map.helpers.isObservable(val), serialized = isObservable && serializeMap[how][can.cid(val)]; + if (serialized) { + result = serialized; + } else { + if (how === 'serialize') { + result = Map.helpers._serialize(map, name, val); + } else { + result = Map.helpers._getValue(map, name, val, how); + } + } + if (result !== undefined) { + where[name] = result; + } + }); + can.__observe(map, '__keys'); + if (firstSerialize) { + serializeMap = null; + } + return where; + }, + _serialize: function (map, name, val) { + return Map.helpers._getValue(map, name, val, 'serialize'); + }, + _getValue: function (map, name, val, how) { + if (Map.helpers.isObservable(val)) { + return val[how](); + } else { + return val; + } + } + }, + keys: function (map) { + var keys = []; + can.__observe(map, '__keys'); + for (var keyName in map._data) { + keys.push(keyName); + } + return keys; + } + }, { + setup: function (obj) { + if (obj instanceof can.Map) { + obj = obj.serialize(); + } + this._data = {}; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + var defaultValues = this._setupDefaults(obj); + this._setupComputes(defaultValues); + var teardownMapping = obj && can.Map.helpers.addToMap(obj, this); + var data = can.extend(can.extend(true, {}, defaultValues), obj); + this.attr(data); + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + delete this._init; + }, + _setupComputes: function () { + var computes = this.constructor._computes; + for (var i = 0, len = computes.length, prop; i < len; i++) { + prop = computes[i]; + this[prop] = this[prop].clone(this); + this._computedBindings[prop] = { count: 0 }; + } + }, + _setupDefaults: function () { + return this.constructor.defaults || {}; + }, + _bindsetup: function () { + }, + _bindteardown: function () { + }, + _changes: function (ev, attr, how, newVal, oldVal) { + can.batch.trigger(this, { + type: attr, + batchNum: ev.batchNum, + target: ev.target + }, [ + newVal, + oldVal + ]); + }, + _triggerChange: function (attr, how, newVal, oldVal) { + if (bubble.isBubbling(this, 'change')) { + can.batch.trigger(this, { + type: 'change', + target: this + }, [ + attr, + how, + newVal, + oldVal + ]); + } else { + can.batch.trigger(this, attr, [ + newVal, + oldVal + ]); + } + if (how === 'remove' || how === 'add') { + can.batch.trigger(this, { + type: '__keys', + target: this + }); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var prop in data) { + if (data.hasOwnProperty(prop)) { + callback(data[prop], prop); + } + } + }, + attr: function (attr, val) { + var type = typeof attr; + if (type !== 'string' && type !== 'number') { + return this._attrs(attr, val); + } else if (arguments.length === 1) { + return this._get(attr); + } else { + this._set(attr, val); + return this; + } + }, + each: function () { + return can.each.apply(undefined, [this].concat(can.makeArray(arguments))); + }, + removeAttr: function (attr) { + var isList = can.List && this instanceof can.List, parts = can.Map.helpers.attrParts(attr), prop = parts.shift(), current = isList ? this[prop] : this._data[prop]; + if (parts.length && current) { + return current.removeAttr(parts); + } else { + if (typeof attr === 'string' && !!~attr.indexOf('.')) { + prop = attr; + } + this._remove(prop, current); + return current; + } + }, + _remove: function (prop, current) { + if (prop in this._data) { + delete this._data[prop]; + if (!(prop in this.constructor.prototype)) { + delete this[prop]; + } + this._triggerChange(prop, 'remove', undefined, current); + } + }, + _get: function (attr) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'); + if (dotIndex >= 0) { + var value = this.__get(attr); + if (value !== undefined) { + return value; + } + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + can.__observe(this, first); + var current = this.__get(first); + return current && current._get ? current._get(second) : undefined; + } else { + can.__observe(this, attr); + return this.__get(attr); + } + }, + __get: function (attr) { + if (attr) { + if (this._computedBindings[attr]) { + return this[attr](); + } else { + return this._data[attr]; + } + } else { + return this._data; + } + }, + __type: function (value, prop) { + if (!(value instanceof can.Map) && can.Map.helpers.canMakeObserve(value)) { + var cached = getMapFromObject(value); + if (cached) { + return cached; + } + if (can.isArray(value)) { + var List = can.List; + return new List(value); + } else { + var Map = this.constructor.Map || can.Map; + return new Map(value); + } + } + return value; + }, + _set: function (attr, value, keepKey) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'), current; + if (!keepKey && dotIndex >= 0) { + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + current = this._init ? undefined : this.__get(first); + if (Map.helpers.isObservable(current)) { + current._set(second, value); + } else { + throw 'can.Map: Object does not exist'; + } + } else { + if (this.__convert) { + value = this.__convert(attr, value); + } + current = this._init ? undefined : this.__get(attr); + this.__set(attr, this.__type(value, attr), current); + } + }, + __set: function (prop, value, current) { + if (value !== current) { + var changeType = current !== undefined || this.__get().hasOwnProperty(prop) ? 'set' : 'add'; + this.___set(prop, this.constructor._bubble.set(this, prop, value, current)); + if (!this._computedBindings[prop]) { + this._triggerChange(prop, changeType, value, current); + } + if (current) { + this.constructor._bubble.teardownFromParent(this, current); + } + } + }, + ___set: function (prop, val) { + if (this._computedBindings[prop]) { + this[prop](val); + } else { + this._data[prop] = val; + } + if (typeof this.constructor.prototype[prop] !== 'function' && !this._computedBindings[prop]) { + this[prop] = val; + } + }, + bind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (!computedBinding.count) { + computedBinding.count = 1; + var self = this; + computedBinding.handler = function (ev, newVal, oldVal) { + can.batch.trigger(self, { + type: eventName, + batchNum: ev.batchNum, + target: self + }, [ + newVal, + oldVal + ]); + }; + this[eventName].bind('change', computedBinding.handler); + } else { + computedBinding.count++; + } + } + this.constructor._bubble.bind(this, eventName); + return can.bindAndSetup.apply(this, arguments); + }, + unbind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (computedBinding.count === 1) { + computedBinding.count = 0; + this[eventName].unbind('change', computedBinding.handler); + delete computedBinding.handler; + } else { + computedBinding.count--; + } + } + this.constructor._bubble.unbind(this, eventName); + return can.unbindAndTeardown.apply(this, arguments); + }, + serialize: function () { + return can.Map.helpers.serialize(this, 'serialize', {}); + }, + _attrs: function (props, remove) { + if (props === undefined) { + return Map.helpers.serialize(this, 'attr', {}); + } + props = can.simpleExtend({}, props); + var prop, self = this, newVal; + can.batch.start(); + this.each(function (curVal, prop) { + if (prop === '_cid') { + return; + } + newVal = props[prop]; + if (newVal === undefined) { + if (remove) { + self.removeAttr(prop); + } + return; + } + if (self.__convert) { + newVal = self.__convert(prop, newVal); + } + if (Map.helpers.isObservable(newVal)) { + self.__set(prop, self.__type(newVal, prop), curVal); + } else if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + self.__set(prop, self.__type(newVal, prop), curVal); + } + delete props[prop]; + }); + for (prop in props) { + if (prop !== '_cid') { + newVal = props[prop]; + this._set(prop, newVal, true); + } + } + can.batch.stop(); + return this; + }, + compute: function (prop) { + if (can.isFunction(this.constructor.prototype[prop])) { + return can.compute(this[prop], this); + } else { + var reads = prop.split('.'), last = reads.length - 1, options = { args: [] }; + return can.compute(function (newVal) { + if (arguments.length) { + can.compute.read(this, reads.slice(0, last)).value.attr(reads[last], newVal); + } else { + return can.compute.read(this, reads, options).value; + } + }, this); + } + } + }); + Map.prototype.on = Map.prototype.bind; + Map.prototype.off = Map.prototype.unbind; + return Map; +}); +/*can@2.2.6#list/list*/ +define('can/list/list', [ + 'can/util/util', + 'can/map/map', + 'can/map/bubble' +], function (can, Map, bubble) { + var splice = [].splice, spliceRemovesProps = function () { + var obj = { + 0: 'a', + length: 1 + }; + splice.call(obj, 0, 1); + return !obj[0]; + }(); + var list = Map.extend({ Map: Map }, { + setup: function (instances, options) { + this.length = 0; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + this._setupComputes(); + instances = instances || []; + var teardownMapping; + if (can.isDeferred(instances)) { + this.replace(instances); + } else { + teardownMapping = instances.length && can.Map.helpers.addToMap(instances, this); + this.push.apply(this, can.makeArray(instances || [])); + } + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + can.simpleExtend(this, options); + delete this._init; + }, + _triggerChange: function (attr, how, newVal, oldVal) { + Map.prototype._triggerChange.apply(this, arguments); + var index = +attr; + if (!~('' + attr).indexOf('.') && !isNaN(index)) { + if (how === 'add') { + can.batch.trigger(this, how, [ + newVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else if (how === 'remove') { + can.batch.trigger(this, how, [ + oldVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else { + can.batch.trigger(this, how, [ + newVal, + index + ]); + } + } + }, + __get: function (attr) { + if (attr) { + if (this[attr] && this[attr].isComputed && can.isFunction(this.constructor.prototype[attr])) { + return this[attr](); + } else { + return this[attr]; + } + } else { + return this; + } + }, + __set: function (prop, value, current) { + prop = isNaN(+prop) || prop % 1 ? prop : +prop; + if (typeof prop === 'number' && prop > this.length - 1) { + var newArr = new Array(prop + 1 - this.length); + newArr[newArr.length - 1] = value; + this.push.apply(this, newArr); + return newArr; + } + return can.Map.prototype.__set.call(this, '' + prop, value, current); + }, + ___set: function (attr, val) { + this[attr] = val; + if (+attr >= this.length) { + this.length = +attr + 1; + } + }, + _remove: function (prop, current) { + if (isNaN(+prop)) { + delete this[prop]; + this._triggerChange(prop, 'remove', undefined, current); + } else { + this.splice(prop, 1); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var i = 0; i < data.length; i++) { + callback(data[i], i); + } + }, + serialize: function () { + return Map.helpers.serialize(this, 'serialize', []); + }, + splice: function (index, howMany) { + var args = can.makeArray(arguments), added = [], i, len, listIndex, allSame = args.length > 2; + index = index || 0; + for (i = 0, len = args.length - 2; i < len; i++) { + listIndex = i + 2; + args[listIndex] = this.__type(args[listIndex], listIndex); + added.push(args[listIndex]); + if (this[i + index] !== args[listIndex]) { + allSame = false; + } + } + if (allSame && this.length <= added.length) { + return added; + } + if (howMany === undefined) { + howMany = args[1] = this.length - index; + } + var removed = splice.apply(this, args); + if (!spliceRemovesProps) { + for (i = this.length; i < removed.length + this.length; i++) { + delete this[i]; + } + } + can.batch.start(); + if (howMany > 0) { + bubble.removeMany(this, removed); + this._triggerChange('' + index, 'remove', undefined, removed); + } + if (args.length > 2) { + for (i = 0, len = added.length; i < len; i++) { + bubble.set(this, i, added[i]); + } + this._triggerChange('' + index, 'add', added, removed); + } + can.batch.stop(); + return removed; + }, + _attrs: function (items, remove) { + if (items === undefined) { + return Map.helpers.serialize(this, 'attr', []); + } + items = can.makeArray(items); + can.batch.start(); + this._updateAttrs(items, remove); + can.batch.stop(); + }, + _updateAttrs: function (items, remove) { + var len = Math.min(items.length, this.length); + for (var prop = 0; prop < len; prop++) { + var curVal = this[prop], newVal = items[prop]; + if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + this._set(prop, newVal); + } else { + } + } + if (items.length > this.length) { + this.push.apply(this, items.slice(this.length)); + } else if (items.length < this.length && remove) { + this.splice(items.length); + } + } + }), getArgs = function (args) { + return args[0] && can.isArray(args[0]) ? args[0] : can.makeArray(args); + }; + can.each({ + push: 'length', + unshift: 0 + }, function (where, name) { + var orig = [][name]; + list.prototype[name] = function () { + var args = [], len = where ? this.length : 0, i = arguments.length, res, val; + while (i--) { + val = arguments[i]; + args[i] = bubble.set(this, i, this.__type(val, i)); + } + res = orig.apply(this, args); + if (!this.comparator || args.length) { + this._triggerChange('' + len, 'add', args, undefined); + } + return res; + }; + }); + can.each({ + pop: 'length', + shift: 0 + }, function (where, name) { + list.prototype[name] = function () { + if (!this.length) { + return undefined; + } + var args = getArgs(arguments), len = where && this.length ? this.length - 1 : 0; + var res = [][name].apply(this, args); + this._triggerChange('' + len, 'remove', undefined, [res]); + if (res && res.unbind) { + bubble.remove(this, res); + } + return res; + }; + }); + can.extend(list.prototype, { + indexOf: function (item, fromIndex) { + this.attr('length'); + return can.inArray(item, this, fromIndex); + }, + join: function () { + return [].join.apply(this.attr(), arguments); + }, + reverse: function () { + var list = [].reverse.call(can.makeArray(this)); + this.replace(list); + }, + slice: function () { + var temp = Array.prototype.slice.apply(this, arguments); + return new this.constructor(temp); + }, + concat: function () { + var args = []; + can.each(can.makeArray(arguments), function (arg, i) { + args[i] = arg instanceof can.List ? arg.serialize() : arg; + }); + return new this.constructor(Array.prototype.concat.apply(this.serialize(), args)); + }, + forEach: function (cb, thisarg) { + return can.each(this, cb, thisarg || this); + }, + replace: function (newList) { + if (can.isDeferred(newList)) { + newList.then(can.proxy(this.replace, this)); + } else { + this.splice.apply(this, [ + 0, + this.length + ].concat(can.makeArray(newList || []))); + } + return this; + }, + filter: function (callback, thisArg) { + var filteredList = new can.List(), self = this, filtered; + this.each(function (item, index, list) { + filtered = callback.call(thisArg | self, item, index, self); + if (filtered) { + filteredList.push(item); + } + }); + return filteredList; + } + }); + can.List = Map.List = list; + return can.List; +}); +/*can@2.2.6#compute/read*/ +define('can/compute/read', ['can/util/util'], function (can) { + var read = function (parent, reads, options) { + options = options || {}; + var state = { foundObservable: false }; + var cur = readValue(parent, 0, reads, options, state), type, prev, readLength = reads.length, i = 0; + while (i < readLength) { + prev = cur; + for (var r = 0, readersLength = read.propertyReaders.length; r < readersLength; r++) { + var reader = read.propertyReaders[r]; + if (reader.test(cur)) { + cur = reader.read(cur, reads[i], i, options, state); + break; + } + } + i = i + 1; + cur = readValue(cur, i, reads, options, state, prev); + type = typeof cur; + if (i < reads.length && (cur === null || type !== 'function' && type !== 'object')) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1, cur); + } + return { + value: undefined, + parent: prev + }; + } + } + if (cur === undefined) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1); + } + } + return { + value: cur, + parent: prev + }; + }; + var readValue = function (value, index, reads, options, state, prev) { + var usedValueReader; + do { + usedValueReader = false; + for (var i = 0, len = read.valueReaders.length; i < len; i++) { + if (read.valueReaders[i].test(value, index, reads, options)) { + value = read.valueReaders[i].read(value, index, reads, options, state, prev); + } + } + } while (usedValueReader); + return value; + }; + read.valueReaders = [ + { + name: 'compute', + test: function (value, i, reads, options) { + return value && value.isComputed; + }, + read: function (value, i, reads, options, state) { + if (options.isArgument && i === reads.length) { + return value; + } + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, i); + state.foundObservable = true; + } + return value instanceof can.Compute ? value.get() : value(); + } + }, + { + name: 'function', + test: function (value, i, reads, options) { + var type = typeof value; + return type === 'function' && !value.isComputed && (options.executeAnonymousFunctions || options.isArgument && i === reads.length) && !(can.Construct && value.prototype instanceof can.Construct) && !(can.route && value === can.route); + }, + read: function (value, i, reads, options, state, prev) { + if (options.isArgument && i === reads.length) { + return options.proxyMethods !== false ? can.proxy(value, prev) : value; + } + return value.call(prev); + } + } + ]; + read.propertyReaders = [ + { + name: 'map', + test: can.isMapLike, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + if (typeof value[prop] === 'function' && value.constructor.prototype[prop] === value[prop]) { + if (options.returnObserveMethods) { + return value[prop]; + } else if (prop === 'constructor' && value instanceof can.Construct || value[prop].prototype instanceof can.Construct) { + return value[prop]; + } else { + return value[prop].apply(value, options.args || []); + } + } else { + return value.attr(prop); + } + } + }, + { + name: 'promise', + test: function (value) { + return can.isPromise(value); + }, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + var observeData = value.__observeData; + if (!value.__observeData) { + observeData = value.__observeData = { + isPending: true, + state: 'pending', + isResolved: false, + isRejected: false, + value: undefined, + reason: undefined + }; + can.cid(observeData); + can.simpleExtend(observeData, can.event); + value.then(function (value) { + observeData.isPending = false; + observeData.isResolved = true; + observeData.value = value; + observeData.state = 'resolved'; + observeData.dispatch('state', [ + 'resolved', + 'pending' + ]); + }, function (reason) { + observeData.isPending = false; + observeData.isRejected = true; + observeData.reason = reason; + observeData.state = 'rejected'; + observeData.dispatch('state', [ + 'rejected', + 'pending' + ]); + }); + } + can.__observe(observeData, 'state'); + return prop in observeData ? observeData[prop] : value[prop]; + } + }, + { + name: 'object', + test: function () { + return true; + }, + read: function (value, prop) { + if (value == null) { + return undefined; + } else { + return value[prop]; + } + } + } + ]; + read.write = function (parent, key, value, options) { + options = options || {}; + if (can.isMapLike(parent)) { + if (!options.isArgument && parent._data && parent._data[key] && parent._data[key].isComputed) { + return parent._data[key](value); + } else { + return parent.attr(key, value); + } + } + if (parent[key] && parent[key].isComputed) { + return parent[key](value); + } + if (typeof parent === 'object') { + parent[key] = value; + } + }; + return read; +}); +/*can@2.2.6#compute/get_value_and_bind*/ +define('can/compute/get_value_and_bind', ['can/util/util'], function () { + function observe(func, context, oldInfo, onchanged) { + var info = getValueAndObserved(func, context), newObserveSet = info.observed, oldObserved = oldInfo.observed; + if (info.names !== oldInfo.names) { + bindNewSet(oldObserved, newObserveSet, onchanged); + unbindOldSet(oldObserved, onchanged); + } + can.batch.afterPreviousEvents(function () { + info.ready = true; + }); + return info; + } + var observedStack = []; + can.__isRecordingObserves = function () { + return observedStack.length; + }; + can.__observe = can.__reading = function (obj, event) { + if (observedStack.length) { + var name = obj._cid + '|' + event, top = observedStack[observedStack.length - 1]; + top.names += name; + top.observed[name] = { + obj: obj, + event: event + '' + }; + } + }; + can.__notObserve = function (fn) { + return function () { + var previousReads = can.__clearObserved(); + var res = fn.apply(this, arguments); + can.__setObserved(previousReads); + return res; + }; + }; + can.__clearObserved = can.__clearReading = function () { + if (observedStack.length) { + var ret = observedStack[observedStack.length - 1]; + observedStack[observedStack.length - 1] = { observed: {} }; + return ret; + } + }; + can.__setObserved = can.__setReading = function (o) { + if (observedStack.length) { + observedStack[observedStack.length - 1] = o; + } + }; + can.__addObserved = can.__addReading = function (o) { + if (observedStack.length) { + can.simpleExtend(observedStack[observedStack.length - 1], o); + } + }; + var getValueAndObserved = function (func, self) { + observedStack.push({ + names: '', + observed: {} + }); + var value = func.call(self); + var stackItem = observedStack.pop(); + stackItem.value = value; + return stackItem; + }; + var bindNewSet = function (oldObserved, newObserveSet, onchanged) { + for (var name in newObserveSet) { + bindOrPreventUnbinding(oldObserved, newObserveSet, name, onchanged); + } + }; + var bindOrPreventUnbinding = function (oldObserved, newObserveSet, name, onchanged) { + if (oldObserved[name]) { + delete oldObserved[name]; + } else { + var obEv = newObserveSet[name]; + obEv.obj.bind(obEv.event, onchanged); + } + }; + var unbindOldSet = function (oldObserved, onchanged) { + for (var name in oldObserved) { + var obEv = oldObserved[name]; + obEv.obj.unbind(obEv.event, onchanged); + } + }; + return observe; +}); +/*can@2.2.6#compute/proto_compute*/ +define('can/compute/proto_compute', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/compute/read', + 'can/compute/get_value_and_bind', + 'can/util/batch/batch' +], function (can, bind, read, getValueAndBind) { + var updateOnChange = function (compute, newValue, oldValue, batchNum) { + if (newValue !== oldValue) { + can.batch.trigger(compute, batchNum ? { + type: 'change', + batchNum: batchNum + } : 'change', [ + newValue, + oldValue + ]); + } + }; + var setupComputeHandlers = function (compute, func, context, singleBind) { + var readInfo, onchanged, batchNum; + singleBind = false; + return { + on: function (updater) { + var self = this; + if (!onchanged) { + onchanged = function (ev) { + if (readInfo.ready && compute.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + if (singleBind) { + newValue = func.call(context); + readInfo.value = newValue; + } else { + readInfo = getValueAndBind(func, context, readInfo, onchanged); + newValue = readInfo.value; + } + self.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }; + } + readInfo = getValueAndBind(func, context, { observed: {} }, onchanged); + if (singleBind) { + func = can.__notObserve(func); + } + compute.value = readInfo.value; + compute.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function (updater) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, onchanged); + } + } + }; + }; + var k = function () { + }; + var updater = function (newVal, oldVal, batchNum) { + this.value = newVal; + updateOnChange(this, newVal, oldVal, batchNum); + }, asyncGet = function (fn, context, lastSetValue) { + return function () { + return fn.call(context, lastSetValue.get()); + }; + }, asyncUpdater = function (context, oldUpdater) { + return function (newVal) { + if (newVal !== undefined) { + oldUpdater(newVal, context.value); + } + }; + }; + can.Compute = function (getterSetter, context, eventName, bindOnce) { + var args = []; + for (var i = 0, arglen = arguments.length; i < arglen; i++) { + args[i] = arguments[i]; + } + var contextType = typeof args[1]; + if (typeof args[0] === 'function') { + this._setupGetterSetterFn(args[0], args[1], args[2], args[3]); + } else if (args[1]) { + if (contextType === 'string') { + this._setupContextString(args[0], args[1], args[2]); + } else if (contextType === 'function') { + this._setupContextFunction(args[0], args[1], args[2]); + } else { + if (args[1] && args[1].fn) { + this._setupAsyncCompute(args[0], args[1]); + } else { + this._setupContextSettings(args[0], args[1]); + } + } + } else { + this._setupInitialValue(args[0]); + } + this._args = args; + this.isComputed = true; + can.cid(this, 'compute'); + }; + can.simpleExtend(can.Compute.prototype, { + _bindsetup: can.__notObserve(function () { + this.bound = true; + this._on(this.updater); + }), + _bindteardown: function () { + this._off(this.updater); + this.bound = false; + }, + bind: can.bindAndSetup, + unbind: can.unbindAndTeardown, + clone: function (context) { + if (context && typeof this._args[0] === 'function') { + this._args[1] = context; + } else if (context) { + this._args[2] = context; + } + return new can.Compute(this._args[0], this._args[1], this._args[2], this._args[3]); + }, + _on: k, + _off: k, + get: function () { + if (can.__isRecordingObserves() && this._canObserve !== false) { + can.__observe(this, 'change'); + if (!this.bound) { + can.Compute.temporarilyBind(this); + } + } + if (this.bound) { + return this.value; + } else { + return this._get(); + } + }, + _get: function () { + return this.value; + }, + set: function (newVal) { + var old = this.value; + var setVal = this._set(newVal, old); + if (this.hasDependencies) { + if (this._setUpdates) { + return this.value; + } + return this._get(); + } + if (setVal === undefined) { + this.value = this._get(); + } else { + this.value = setVal; + } + updateOnChange(this, this.value, old); + return this.value; + }, + _set: function (newVal) { + return this.value = newVal; + }, + updater: updater, + _computeFn: function (newVal) { + if (arguments.length) { + return this.set(newVal); + } + return this.get(); + }, + toFunction: function () { + return can.proxy(this._computeFn, this); + }, + _setupGetterSetterFn: function (getterSetter, context, eventName, bindOnce) { + this._set = can.proxy(getterSetter, context); + this._get = can.proxy(getterSetter, context); + this._canObserve = eventName === false ? false : true; + var handlers = setupComputeHandlers(this, getterSetter, context || this, bindOnce); + this._on = handlers.on; + this._off = handlers.off; + }, + _setupContextString: function (target, propertyName, eventName) { + var isObserve = can.isMapLike(target), self = this, handler = function (ev, newVal, oldVal) { + self.updater(newVal, oldVal, ev.batchNum); + }; + if (isObserve) { + this.hasDependencies = true; + this._get = function () { + return target.attr(propertyName); + }; + this._set = function (val) { + target.attr(propertyName, val); + }; + this._on = function (update) { + target.bind(eventName || propertyName, handler); + this.value = this._get(); + }; + this._off = function () { + return target.unbind(eventName || propertyName, handler); + }; + } else { + this._get = can.proxy(this._get, target); + this._set = can.proxy(this._set, target); + } + }, + _setupContextFunction: function (initialValue, setter, eventName) { + this.value = initialValue; + this._set = setter; + can.simpleExtend(this, eventName); + }, + _setupContextSettings: function (initialValue, settings) { + this.value = initialValue; + this._set = settings.set ? can.proxy(settings.set, settings) : this._set; + this._get = settings.get ? can.proxy(settings.get, settings) : this._get; + if (!settings.__selfUpdater) { + var self = this, oldUpdater = this.updater; + this.updater = function () { + oldUpdater.call(self, self._get(), self.value); + }; + } + this._on = settings.on ? settings.on : this._on; + this._off = settings.off ? settings.off : this._off; + }, + _setupAsyncCompute: function (initialValue, settings) { + this.value = initialValue; + var oldUpdater = can.proxy(this.updater, this), self = this, fn = settings.fn, data; + this.updater = oldUpdater; + var lastSetValue = new can.Compute(initialValue); + this.lastSetValue = lastSetValue; + this._setUpdates = true; + this._set = function (newVal) { + if (newVal === lastSetValue.get()) { + return this.value; + } + return lastSetValue.set(newVal); + }; + this._get = asyncGet(fn, settings.context, lastSetValue); + if (fn.length === 0) { + data = setupComputeHandlers(this, fn, settings.context); + } else if (fn.length === 1) { + data = setupComputeHandlers(this, function () { + return fn.call(settings.context, lastSetValue.get()); + }, settings); + } else { + this.updater = asyncUpdater(this, oldUpdater); + data = setupComputeHandlers(this, function () { + var res = fn.call(settings.context, lastSetValue.get(), function (newVal) { + oldUpdater(newVal, self.value); + }); + return res !== undefined ? res : this.value; + }, settings); + } + this._on = data.on; + this._off = data.off; + }, + _setupInitialValue: function (initialValue) { + this.value = initialValue; + } + }); + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.Compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.Compute.async = function (initialValue, asyncComputer, context) { + return new can.Compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.Compute.read = read; + can.Compute.set = read.write; + can.Compute.truthy = function (compute) { + return new can.Compute(function () { + var res = compute.get(); + if (typeof res === 'function') { + res = res.get(); + } + return !!res; + }); + }; + return can.Compute; +}); +/*can@2.2.6#compute/compute*/ +define('can/compute/compute', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/util/batch/batch', + 'can/compute/proto_compute' +], function (can, bind) { + can.compute = function (getterSetter, context, eventName, bindOnce) { + var internalCompute = new can.Compute(getterSetter, context, eventName, bindOnce); + var compute = function (val) { + if (arguments.length) { + return internalCompute.set(val); + } + return internalCompute.get(); + }; + compute.bind = can.proxy(internalCompute.bind, internalCompute); + compute.unbind = can.proxy(internalCompute.unbind, internalCompute); + compute.isComputed = internalCompute.isComputed; + compute.clone = function (ctx) { + if (typeof getterSetter === 'function') { + context = ctx; + } + return can.compute(getterSetter, context, ctx, bindOnce); + }; + compute.computeInstance = internalCompute; + return compute; + }; + var k = function () { + }; + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.compute.truthy = function (compute) { + return can.compute(function () { + var res = compute(); + if (typeof res === 'function') { + res = res(); + } + return !!res; + }); + }; + can.compute.async = function (initialValue, asyncComputer, context) { + return can.compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.compute.read = can.Compute.read; + can.compute.set = can.Compute.set; + return can.compute; +}); +/*can@2.2.6#observe/observe*/ +define('can/observe/observe', [ + 'can/util/util', + 'can/map/map', + 'can/list/list', + 'can/compute/compute' +], function (can) { + can.Observe = can.Map; + can.Observe.startBatch = can.batch.start; + can.Observe.stopBatch = can.batch.stop; + can.Observe.triggerBatch = can.batch.trigger; + return can; +}); +/*can@2.2.6#view/scope/compute_data*/ +define('can/view/scope/compute_data', [ + 'can/util/util', + 'can/compute/compute', + 'can/compute/get_value_and_bind' +], function (can, compute, getValueAndBind) { + var isFastPath = function (computeData) { + return computeData.reads && computeData.reads.length === 1 && computeData.root instanceof can.Map && !can.isFunction(computeData.root[computeData.reads[0]]); + }; + var getValueAndBindScopeRead = function (scopeRead, scopeReadChanged) { + return getValueAndBind(scopeRead, null, { observed: {} }, scopeReadChanged); + }; + var unbindScopeRead = function (readInfo, scopeReadChanged) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, scopeReadChanged); + } + }; + var getValueAndBindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + var target = computeData.root, prop = computeData.reads[0]; + target.bind(prop, singlePropertyReadChanged); + return { + value: computeData.initialValue, + observed: { something: true } + }; + }; + var unbindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + computeData.root.unbind(computeData.reads[0], singlePropertyReadChanged); + }; + var scopeReader = function (scope, key, options, computeData, newVal) { + if (arguments.length > 4) { + if (computeData.root.isComputed) { + computeData.root(newVal); + } else if (computeData.reads.length) { + var last = computeData.reads.length - 1; + var obj = computeData.reads.length ? can.compute.read(computeData.root, computeData.reads.slice(0, last)).value : computeData.root; + can.compute.set(obj, computeData.reads[last], newVal, options); + } + } else { + if (computeData.root) { + return can.compute.read(computeData.root, computeData.reads, options).value; + } + var data = scope.read(key, options); + computeData.scope = data.scope; + computeData.initialValue = data.value; + computeData.reads = data.reads; + computeData.root = data.rootObserve; + return data.value; + } + }; + return function (scope, key, options) { + options = options || { args: [] }; + var computeData = {}, scopeRead = function (newVal) { + if (arguments.length) { + return scopeReader(scope, key, options, computeData, newVal); + } else { + return scopeReader(scope, key, options, computeData); + } + }, batchNum, readInfo, scopeReadChanged = function (ev) { + if (readInfo.ready && compute.computeInstance.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + readInfo = getValueAndBind(scopeRead, null, readInfo, scopeReadChanged); + newValue = readInfo.value; + compute.computeInstance.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }, singlePropertyReadChanged = function (ev, newVal, oldVal) { + if (typeof newVal !== 'function') { + compute.computeInstance.updater(newVal, oldVal, ev.batchNum); + } else { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + isFastPathBound = false; + compute.computeInstance.updater(readInfo.value, oldVal, ev.batchNum); + } + }, isFastPathBound = false, compute = can.compute(undefined, { + on: function () { + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + if (isFastPath(computeData)) { + var oldReadInfo = readInfo; + readInfo = getValueAndBindSinglePropertyRead(computeData, singlePropertyReadChanged); + unbindScopeRead(oldReadInfo, scopeReadChanged); + isFastPathBound = true; + } + compute.computeInstance.value = readInfo.value; + compute.computeInstance.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function () { + if (isFastPathBound) { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + } else { + unbindScopeRead(readInfo, scopeReadChanged); + } + }, + set: scopeRead, + get: scopeRead, + __selfUpdater: true + }); + computeData.compute = compute; + return computeData; + }; +}); +/*can@2.2.6#view/scope/scope*/ +define('can/view/scope/scope', [ + 'can/util/util', + 'can/view/scope/compute_data', + 'can/construct/construct', + 'can/map/map', + 'can/list/list', + 'can/view/view', + 'can/compute/compute' +], function (can, makeComputeData) { + var escapeReg = /(\\)?\./g, escapeDotReg = /\\\./g, getNames = function (attr) { + var names = [], last = 0; + attr.replace(escapeReg, function (first, second, index) { + if (!second) { + names.push(attr.slice(last, index).replace(escapeDotReg, '.')); + last = index + first.length; + } + }); + names.push(attr.slice(last).replace(escapeDotReg, '.')); + return names; + }; + var Scope = can.Construct.extend({ read: can.compute.read }, { + init: function (context, parent) { + this._context = context; + this._parent = parent; + this.__cache = {}; + }, + attr: can.__notObserve(function (key, value) { + var options = { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }, res = this.read(key, options); + if (arguments.length === 2) { + var lastIndex = key.lastIndexOf('.'), readKey = lastIndex !== -1 ? key.substring(0, lastIndex) : '.', obj = this.read(readKey, options).value; + if (lastIndex !== -1) { + key = key.substring(lastIndex + 1, key.length); + } + can.compute.set(obj, key, value, options); + } + return res.value; + }), + add: function (context) { + if (context !== this._context) { + return new this.constructor(context, this); + } else { + return this; + } + }, + computeData: function (key, options) { + return makeComputeData(this, key, options); + }, + compute: function (key, options) { + return this.computeData(key, options).compute; + }, + read: function (attr, options) { + var stopLookup; + if (attr.substr(0, 2) === './') { + stopLookup = true; + attr = attr.substr(2); + } else if (attr.substr(0, 3) === '../') { + return this._parent.read(attr.substr(3), options); + } else if (attr === '..') { + return { value: this._parent._context }; + } else if (attr === '.' || attr === 'this') { + return { value: this._context }; + } + var names = attr.indexOf('\\.') === -1 ? attr.split('.') : getNames(attr), context, scope = this, defaultObserve, defaultReads = [], defaultPropertyDepth = -1, defaultComputeReadings, defaultScope, currentObserve, currentReads; + while (scope) { + context = scope._context; + if (context !== null && (typeof context === 'object' || typeof context === 'function')) { + var data = can.compute.read(context, names, can.simpleExtend({ + foundObservable: function (observe, nameIndex) { + currentObserve = observe; + currentReads = names.slice(nameIndex); + }, + earlyExit: function (parentValue, nameIndex) { + if (nameIndex > defaultPropertyDepth) { + defaultObserve = currentObserve; + defaultReads = currentReads; + defaultPropertyDepth = nameIndex; + defaultScope = scope; + defaultComputeReadings = can.__clearReading(); + } + }, + executeAnonymousFunctions: true + }, options)); + if (data.value !== undefined) { + return { + scope: scope, + rootObserve: currentObserve, + value: data.value, + reads: currentReads + }; + } + } + can.__clearReading(); + if (!stopLookup) { + scope = scope._parent; + } else { + scope = null; + } + } + if (defaultObserve) { + can.__setReading(defaultComputeReadings); + return { + scope: defaultScope, + rootObserve: defaultObserve, + reads: defaultReads, + value: undefined + }; + } else { + return { + names: names, + value: undefined + }; + } + } + }); + can.view.Scope = Scope; + return Scope; +}); +/*can@2.2.6#view/scanner*/ +define('can/view/scanner', [ + 'can/view/view', + 'can/view/elements', + 'can/view/callbacks/callbacks' +], function (can, elements, viewCallbacks) { + var newLine = /(\r|\n)+/g, notEndTag = /\//, clean = function (content) { + return content.split('\\').join('\\\\').split('\n').join('\\n').split('"').join('\\"').split('\t').join('\\t'); + }, getTag = function (tagName, tokens, i) { + if (tagName) { + return tagName; + } else { + while (i < tokens.length) { + if (tokens[i] === '<' && !notEndTag.test(tokens[i + 1])) { + return elements.reverseTagMap[tokens[i + 1]] || 'span'; + } + i++; + } + } + return ''; + }, bracketNum = function (content) { + return --content.split('{').length - --content.split('}').length; + }, myEval = function (script) { + eval(script); + }, attrReg = /([^\s]+)[\s]*=[\s]*$/, startTxt = 'var ___v1ew = [];', finishTxt = 'return ___v1ew.join(\'\')', put_cmd = '___v1ew.push(\n', insert_cmd = put_cmd, htmlTag = null, quote = null, beforeQuote = null, rescan = null, getAttrName = function () { + var matches = beforeQuote.match(attrReg); + return matches && matches[1]; + }, status = function () { + return quote ? '\'' + getAttrName() + '\'' : htmlTag ? 1 : 0; + }, top = function (stack) { + return stack[stack.length - 1]; + }, Scanner; + can.view.Scanner = Scanner = function (options) { + can.extend(this, { + text: {}, + tokens: [] + }, options); + this.text.options = this.text.options || ''; + this.tokenReg = []; + this.tokenSimple = { + '<': '<', + '>': '>', + '"': '"', + '\'': '\'' + }; + this.tokenComplex = []; + this.tokenMap = {}; + for (var i = 0, token; token = this.tokens[i]; i++) { + if (token[2]) { + this.tokenReg.push(token[2]); + this.tokenComplex.push({ + abbr: token[1], + re: new RegExp(token[2]), + rescan: token[3] + }); + } else { + this.tokenReg.push(token[1]); + this.tokenSimple[token[1]] = token[0]; + } + this.tokenMap[token[0]] = token[1]; + } + this.tokenReg = new RegExp('(' + this.tokenReg.slice(0).concat([ + '<', + '>', + '"', + '\'' + ]).join('|') + ')', 'g'); + }; + Scanner.prototype = { + helpers: [], + scan: function (source, name) { + var tokens = [], last = 0, simple = this.tokenSimple, complex = this.tokenComplex; + source = source.replace(newLine, '\n'); + if (this.transform) { + source = this.transform(source); + } + source.replace(this.tokenReg, function (whole, part) { + var offset = arguments[arguments.length - 2]; + if (offset > last) { + tokens.push(source.substring(last, offset)); + } + if (simple[whole]) { + tokens.push(whole); + } else { + for (var i = 0, token; token = complex[i]; i++) { + if (token.re.test(whole)) { + tokens.push(token.abbr); + if (token.rescan) { + tokens.push(token.rescan(part)); + } + break; + } + } + } + last = offset + part.length; + }); + if (last < source.length) { + tokens.push(source.substr(last)); + } + var content = '', buff = [startTxt + (this.text.start || '')], put = function (content, bonus) { + buff.push(put_cmd, '"', clean(content), '"' + (bonus || '') + ');'); + }, endStack = [], lastToken, startTag = null, magicInTag = false, specialStates = { + attributeHookups: [], + tagHookups: [], + lastTagHookup: '' + }, popTagHookup = function () { + specialStates.lastTagHookup = specialStates.tagHookups.pop() + specialStates.tagHookups.length; + }, tagName = '', tagNames = [], popTagName = false, bracketCount, specialAttribute = false, i = 0, token, tmap = this.tokenMap, attrName; + htmlTag = quote = beforeQuote = null; + for (; (token = tokens[i++]) !== undefined;) { + if (startTag === null) { + switch (token) { + case tmap.left: + case tmap.escapeLeft: + case tmap.returnLeft: + magicInTag = htmlTag && 1; + case tmap.commentLeft: + startTag = token; + if (content.length) { + put(content); + } + content = ''; + break; + case tmap.escapeFull: + magicInTag = htmlTag && 1; + rescan = 1; + startTag = tmap.escapeLeft; + if (content.length) { + put(content); + } + rescan = tokens[i++]; + content = rescan.content || rescan; + if (rescan.before) { + put(rescan.before); + } + tokens.splice(i, 0, tmap.right); + break; + case tmap.commentFull: + break; + case tmap.templateLeft: + content += tmap.left; + break; + case '<': + if (tokens[i].indexOf('!--') !== 0) { + htmlTag = 1; + magicInTag = 0; + } + content += token; + break; + case '>': + htmlTag = 0; + var emptyElement = content.substr(content.length - 1) === '/' || content.substr(content.length - 2) === '--', attrs = ''; + if (specialStates.attributeHookups.length) { + attrs = 'attrs: [\'' + specialStates.attributeHookups.join('\',\'') + '\'], '; + specialStates.attributeHookups = []; + } + if (tagName + specialStates.tagHookups.length !== specialStates.lastTagHookup && tagName === top(specialStates.tagHookups)) { + if (emptyElement) { + content = content.substr(0, content.length - 1); + } + buff.push(put_cmd, '"', clean(content), '"', ',can.view.pending({tagName:\'' + tagName + '\',' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options); + if (emptyElement) { + buff.push('}));'); + content = '/>'; + popTagHookup(); + } else if (tokens[i] === '<' && tokens[i + 1] === '/' + tagName) { + buff.push('}));'); + content = token; + popTagHookup(); + } else { + buff.push(',subtemplate: function(' + this.text.argNames + '){\n' + startTxt + (this.text.start || '')); + content = ''; + } + } else if (magicInTag || !popTagName && elements.tagToContentPropMap[tagNames[tagNames.length - 1]] || attrs) { + var pendingPart = ',can.view.pending({' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options + '}),"'; + if (emptyElement) { + put(content.substr(0, content.length - 1), pendingPart + '/>"'); + } else { + put(content, pendingPart + '>"'); + } + content = ''; + magicInTag = 0; + } else { + content += token; + } + if (emptyElement || popTagName) { + tagNames.pop(); + tagName = tagNames[tagNames.length - 1]; + popTagName = false; + } + specialStates.attributeHookups = []; + break; + case '\'': + case '"': + if (htmlTag) { + if (quote && quote === token) { + quote = null; + var attr = getAttrName(); + if (viewCallbacks.attr(attr)) { + specialStates.attributeHookups.push(attr); + } + if (specialAttribute) { + content += token; + put(content); + buff.push(finishTxt, '}));\n'); + content = ''; + specialAttribute = false; + break; + } + } else if (quote === null) { + quote = token; + beforeQuote = lastToken; + attrName = getAttrName(); + if (tagName === 'img' && attrName === 'src' || attrName === 'style') { + put(content.replace(attrReg, '')); + content = ''; + specialAttribute = true; + buff.push(insert_cmd, 'can.view.txt(2,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt); + put(attrName + '=' + token); + break; + } + } + } + default: + if (lastToken === '<') { + tagName = token.substr(0, 3) === '!--' ? '!--' : token.split(/\s/)[0]; + var isClosingTag = false, cleanedTagName; + if (tagName.indexOf('/') === 0) { + isClosingTag = true; + cleanedTagName = tagName.substr(1); + } + if (isClosingTag) { + if (top(tagNames) === cleanedTagName) { + tagName = cleanedTagName; + popTagName = true; + } + if (top(specialStates.tagHookups) === cleanedTagName) { + put(content.substr(0, content.length - 1)); + buff.push(finishTxt + '}}) );'); + content = '><'; + popTagHookup(); + } + } else { + if (tagName.lastIndexOf('/') === tagName.length - 1) { + tagName = tagName.substr(0, tagName.length - 1); + } + if (tagName !== '!--' && viewCallbacks.tag(tagName)) { + if (tagName === 'content' && elements.tagMap[top(tagNames)]) { + token = token.replace('content', elements.tagMap[top(tagNames)]); + } + specialStates.tagHookups.push(tagName); + } + tagNames.push(tagName); + } + } + content += token; + break; + } + } else { + switch (token) { + case tmap.right: + case tmap.returnRight: + switch (startTag) { + case tmap.left: + bracketCount = bracketNum(content); + if (bracketCount === 1) { + buff.push(insert_cmd, 'can.view.txt(0,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt, content); + endStack.push({ + before: '', + after: finishTxt + '}));\n' + }); + } else { + last = endStack.length && bracketCount === -1 ? endStack.pop() : { after: ';' }; + if (last.before) { + buff.push(last.before); + } + buff.push(content, ';', last.after); + } + break; + case tmap.escapeLeft: + case tmap.returnLeft: + bracketCount = bracketNum(content); + if (bracketCount) { + endStack.push({ + before: finishTxt, + after: '}));\n' + }); + } + var escaped = startTag === tmap.escapeLeft ? 1 : 0, commands = { + insert: insert_cmd, + tagName: getTag(tagName, tokens, i), + status: status(), + specialAttribute: specialAttribute + }; + for (var ii = 0; ii < this.helpers.length; ii++) { + var helper = this.helpers[ii]; + if (helper.name.test(content)) { + content = helper.fn(content, commands); + if (helper.name.source === /^>[\s]*\w*/.source) { + escaped = 0; + } + break; + } + } + if (typeof content === 'object') { + if (content.startTxt && content.end && specialAttribute) { + buff.push(insert_cmd, 'can.view.toStr( ', content.content, '() ) );'); + } else { + if (content.startTxt) { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || (content.escaped != null ? content.escaped : escaped)) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\n'); + } else if (content.startOnlyTxt) { + buff.push(insert_cmd, 'can.view.onlytxt(this,\n'); + } + buff.push(content.content); + if (content.end) { + buff.push('));'); + } + } + } else if (specialAttribute) { + buff.push(insert_cmd, content, ');'); + } else { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || escaped) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\nfunction(){ ' + (this.text.escape || '') + 'return ', content, bracketCount ? startTxt : '}));\n'); + } + if (rescan && rescan.after && rescan.after.length) { + put(rescan.after.length); + rescan = null; + } + break; + } + startTag = null; + content = ''; + break; + case tmap.templateLeft: + content += tmap.left; + break; + default: + content += token; + break; + } + } + lastToken = token; + } + if (content.length) { + put(content); + } + buff.push(';'); + var template = buff.join(''), out = { out: (this.text.outStart || '') + template + ' ' + finishTxt + (this.text.outEnd || '') }; + myEval.call(out, 'this.fn = (function(' + this.text.argNames + '){' + out.out + '});\r\n//# sourceURL=' + name + '.js'); + return out; + } + }; + can.view.pending = function (viewData) { + var hooks = can.view.getHooks(); + return can.view.hook(function (el) { + can.each(hooks, function (fn) { + fn(el); + }); + viewData.templateType = 'legacy'; + if (viewData.tagName) { + viewCallbacks.tagHandler(el, viewData.tagName, viewData); + } + can.each(viewData && viewData.attrs || [], function (attributeName) { + viewData.attributeName = attributeName; + var callback = viewCallbacks.attr(attributeName); + if (callback) { + callback(el, viewData); + } + }); + }); + }; + can.view.tag('content', function (el, tagData) { + return tagData.scope; + }); + can.view.Scanner = Scanner; + return Scanner; +}); +/*can@2.2.6#view/node_lists/node_lists*/ +define('can/view/node_lists/node_lists', [ + 'can/util/util', + 'can/view/elements' +], function (can) { + var canExpando = true; + try { + document.createTextNode('')._ = 0; + } catch (ex) { + canExpando = false; + } + var nodeMap = {}, textNodeMap = {}, expando = 'ejs_' + Math.random(), _id = 0, id = function (node, localMap) { + var _textNodeMap = localMap || textNodeMap; + var id = readId(node, _textNodeMap); + if (id) { + return id; + } else { + if (canExpando || node.nodeType !== 3) { + ++_id; + return node[expando] = (node.nodeName ? 'element_' : 'obj_') + _id; + } else { + ++_id; + _textNodeMap['text_' + _id] = node; + return 'text_' + _id; + } + } + }, readId = function (node, textNodeMap) { + if (canExpando || node.nodeType !== 3) { + return node[expando]; + } else { + for (var textNodeID in textNodeMap) { + if (textNodeMap[textNodeID] === node) { + return textNodeID; + } + } + } + }, splice = [].splice, push = [].push, itemsInChildListTree = function (list) { + var count = 0; + for (var i = 0, len = list.length; i < len; i++) { + var item = list[i]; + if (item.nodeType) { + count++; + } else { + count += itemsInChildListTree(item); + } + } + return count; + }, replacementMap = function (replacements, idMap) { + var map = {}; + for (var i = 0, len = replacements.length; i < len; i++) { + var node = nodeLists.first(replacements[i]); + map[id(node, idMap)] = replacements[i]; + } + return map; + }; + var nodeLists = { + id: id, + update: function (nodeList, newNodes) { + var oldNodes = nodeLists.unregisterChildren(nodeList); + newNodes = can.makeArray(newNodes); + var oldListLength = nodeList.length; + splice.apply(nodeList, [ + 0, + oldListLength + ].concat(newNodes)); + if (nodeList.replacements) { + nodeLists.nestReplacements(nodeList); + } else { + nodeLists.nestList(nodeList); + } + return oldNodes; + }, + nestReplacements: function (list) { + var index = 0, idMap = {}, rMap = replacementMap(list.replacements, idMap), rCount = list.replacements.length; + while (index < list.length && rCount) { + var node = list[index], replacement = rMap[readId(node, idMap)]; + if (replacement) { + list.splice(index, itemsInChildListTree(replacement), replacement); + rCount--; + } + index++; + } + list.replacements = []; + }, + nestList: function (list) { + var index = 0; + while (index < list.length) { + var node = list[index], childNodeList = nodeMap[id(node)]; + if (childNodeList) { + if (childNodeList !== list) { + list.splice(index, itemsInChildListTree(childNodeList), childNodeList); + } + } else { + nodeMap[id(node)] = list; + } + index++; + } + }, + last: function (nodeList) { + var last = nodeList[nodeList.length - 1]; + if (last.nodeType) { + return last; + } else { + return nodeLists.last(last); + } + }, + first: function (nodeList) { + var first = nodeList[0]; + if (first.nodeType) { + return first; + } else { + return nodeLists.first(first); + } + }, + flatten: function (nodeList) { + var items = []; + for (var i = 0; i < nodeList.length; i++) { + var item = nodeList[i]; + if (item.nodeType) { + items.push(item); + } else { + items.push.apply(items, nodeLists.flatten(item)); + } + } + return items; + }, + register: function (nodeList, unregistered, parent) { + nodeList.unregistered = unregistered; + nodeList.parentList = parent; + if (parent === true) { + nodeList.replacements = []; + } else if (parent) { + parent.replacements.push(nodeList); + nodeList.replacements = []; + } else { + nodeLists.nestList(nodeList); + } + return nodeList; + }, + unregisterChildren: function (nodeList) { + var nodes = []; + can.each(nodeList, function (node) { + if (node.nodeType) { + if (!nodeList.replacements) { + delete nodeMap[id(node)]; + } + nodes.push(node); + } else { + push.apply(nodes, nodeLists.unregister(node)); + } + }); + return nodes; + }, + unregister: function (nodeList) { + var nodes = nodeLists.unregisterChildren(nodeList); + if (nodeList.unregistered) { + var unregisteredCallback = nodeList.unregistered; + delete nodeList.unregistered; + delete nodeList.replacements; + unregisteredCallback(); + } + return nodes; + }, + nodeMap: nodeMap + }; + can.view.nodeLists = nodeLists; + return nodeLists; +}); +/*can@2.2.6#view/parser/parser*/ +define('can/view/parser/parser', ['can/view/view'], function (can) { + function makeMap(str) { + var obj = {}, items = str.split(','); + for (var i = 0; i < items.length; i++) { + obj[items[i]] = true; + } + return obj; + } + function handleIntermediate(intermediate, handler) { + for (var i = 0, len = intermediate.length; i < len; i++) { + var item = intermediate[i]; + handler[item.tokenType].apply(handler, item.args); + } + return intermediate; + } + var alphaNumericHU = '-:A-Za-z0-9_', attributeNames = '[a-zA-Z_:][' + alphaNumericHU + ':.]*', spaceEQspace = '\\s*=\\s*', dblQuote2dblQuote = '"((?:\\\\.|[^"])*)"', quote2quote = '\'((?:\\\\.|[^\'])*)\'', attributeEqAndValue = '(?:' + spaceEQspace + '(?:' + '(?:"[^"]*")|(?:\'[^\']*\')|[^>\\s]+))?', matchStash = '\\{\\{[^\\}]*\\}\\}\\}?', stash = '\\{\\{([^\\}]*)\\}\\}\\}?', startTag = new RegExp('^<([' + alphaNumericHU + ']+)' + '(' + '(?:\\s*' + '(?:(?:' + '(?:' + attributeNames + ')?' + attributeEqAndValue + ')|' + '(?:' + matchStash + ')+)' + ')*' + ')\\s*(\\/?)>'), endTag = new RegExp('^<\\/([' + alphaNumericHU + ']+)[^>]*>'), attr = new RegExp('(?:' + '(?:(' + attributeNames + ')|' + stash + ')' + '(?:' + spaceEQspace + '(?:' + '(?:' + dblQuote2dblQuote + ')|(?:' + quote2quote + ')|([^>\\s]+)' + ')' + ')?)', 'g'), mustache = new RegExp(stash, 'g'), txtBreak = /<|\{\{/; + var empty = makeMap('area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed'); + var block = makeMap('a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video'); + var inline = makeMap('abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var'); + var closeSelf = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr'); + var fillAttrs = makeMap('checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected'); + var special = makeMap('script,style'); + var tokenTypes = 'start,end,close,attrStart,attrEnd,attrValue,chars,comment,special,done'.split(','); + var fn = function () { + }; + var HTMLParser = function (html, handler, returnIntermediate) { + if (typeof html === 'object') { + return handleIntermediate(html, handler); + } + var intermediate = []; + handler = handler || {}; + if (returnIntermediate) { + can.each(tokenTypes, function (name) { + var callback = handler[name] || fn; + handler[name] = function () { + if (callback.apply(this, arguments) !== false) { + intermediate.push({ + tokenType: name, + args: can.makeArray(arguments) + }); + } + }; + }); + } + function parseStartTag(tag, tagName, rest, unary) { + tagName = tagName.toLowerCase(); + if (block[tagName]) { + while (stack.last() && inline[stack.last()]) { + parseEndTag('', stack.last()); + } + } + if (closeSelf[tagName] && stack.last() === tagName) { + parseEndTag('', tagName); + } + unary = empty[tagName] || !!unary; + handler.start(tagName, unary); + if (!unary) { + stack.push(tagName); + } + HTMLParser.parseAttrs(rest, handler); + handler.end(tagName, unary); + } + function parseEndTag(tag, tagName) { + var pos; + if (!tagName) { + pos = 0; + } else { + for (pos = stack.length - 1; pos >= 0; pos--) { + if (stack[pos] === tagName) { + break; + } + } + } + if (pos >= 0) { + for (var i = stack.length - 1; i >= pos; i--) { + if (handler.close) { + handler.close(stack[i]); + } + } + stack.length = pos; + } + } + function parseMustache(mustache, inside) { + if (handler.special) { + handler.special(inside); + } + } + var index, chars, match, stack = [], last = html; + stack.last = function () { + return this[this.length - 1]; + }; + while (html) { + chars = true; + if (!stack.last() || !special[stack.last()]) { + if (html.indexOf(''); + if (index >= 0) { + if (handler.comment) { + handler.comment(html.substring(4, index)); + } + html = html.substring(index + 3); + chars = false; + } + } else if (html.indexOf(']*>'), function (all, text) { + text = text.replace(/|/g, '$1$2'); + if (handler.chars) { + handler.chars(text); + } + return ''; + }); + parseEndTag('', stack.last()); + } + if (html === last) { + throw 'Parse Error: ' + html; + } + last = html; + } + parseEndTag(); + handler.done(); + return intermediate; + }; + HTMLParser.parseAttrs = function (rest, handler) { + (rest != null ? rest : '').replace(attr, function (text, name, special, dblQuote, singleQuote, val) { + if (special) { + handler.special(special); + } + if (name || dblQuote || singleQuote || val) { + var value = arguments[3] ? arguments[3] : arguments[4] ? arguments[4] : arguments[5] ? arguments[5] : fillAttrs[name.toLowerCase()] ? name : ''; + handler.attrStart(name || ''); + var last = mustache.lastIndex = 0, res = mustache.exec(value), chars; + while (res) { + chars = value.substring(last, mustache.lastIndex - res[0].length); + if (chars.length) { + handler.attrValue(chars); + } + handler.special(res[1]); + last = mustache.lastIndex; + res = mustache.exec(value); + } + chars = value.substr(last, value.length); + if (chars) { + handler.attrValue(chars); + } + handler.attrEnd(name || ''); + } + }); + }; + can.view.parser = HTMLParser; + return HTMLParser; +}); +/*can@2.2.6#view/live/live*/ +define('can/view/live/live', [ + 'can/util/util', + 'can/view/elements', + 'can/view/view', + 'can/view/node_lists/node_lists', + 'can/view/parser/parser' +], function (can, elements, view, nodeLists, parser) { + elements = elements || can.view.elements; + nodeLists = nodeLists || can.view.NodeLists; + parser = parser || can.view.parser; + var setup = function (el, bind, unbind) { + var tornDown = false, teardown = function () { + if (!tornDown) { + tornDown = true; + unbind(data); + can.unbind.call(el, 'removed', teardown); + } + return true; + }, data = { + teardownCheck: function (parent) { + return parent ? false : teardown(); + } + }; + can.bind.call(el, 'removed', teardown); + bind(data); + return data; + }, listen = function (el, compute, change) { + return setup(el, function () { + compute.bind('change', change); + }, function (data) { + compute.unbind('change', change); + if (data.nodeList) { + nodeLists.unregister(data.nodeList); + } + }); + }, getAttributeParts = function (newVal) { + var attrs = {}, attr; + parser.parseAttrs(newVal, { + attrStart: function (name) { + attrs[name] = ''; + attr = name; + }, + attrValue: function (value) { + attrs[attr] += value; + }, + attrEnd: function () { + } + }); + return attrs; + }, splice = [].splice, isNode = function (obj) { + return obj && obj.nodeType; + }, addTextNodeIfNoChildren = function (frag) { + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + }; + var live = { + list: function (el, compute, render, context, parentNode, nodeList) { + var masterNodeList = nodeList || [el], indexMap = [], afterPreviousEvents = false, isTornDown = false, add = function (ev, items, index) { + if (!afterPreviousEvents) { + return; + } + var frag = document.createDocumentFragment(), newNodeLists = [], newIndicies = []; + can.each(items, function (item, key) { + var itemNodeList = []; + if (nodeList) { + nodeLists.register(itemNodeList, null, true); + } + var itemIndex = can.compute(key + index), itemHTML = render.call(context, item, itemIndex, itemNodeList), gotText = typeof itemHTML === 'string', itemFrag = can.frag(itemHTML); + itemFrag = gotText ? can.view.hookup(itemFrag) : itemFrag; + var childNodes = can.makeArray(itemFrag.childNodes); + if (nodeList) { + nodeLists.update(itemNodeList, childNodes); + newNodeLists.push(itemNodeList); + } else { + newNodeLists.push(nodeLists.register(childNodes)); + } + frag.appendChild(itemFrag); + newIndicies.push(itemIndex); + }); + var masterListIndex = index + 1; + if (!masterNodeList[masterListIndex]) { + elements.after(masterListIndex === 1 ? [text] : [nodeLists.last(masterNodeList[masterListIndex - 1])], frag); + } else { + var el = nodeLists.first(masterNodeList[masterListIndex]); + can.insertBefore(el.parentNode, frag, el); + } + splice.apply(masterNodeList, [ + masterListIndex, + 0 + ].concat(newNodeLists)); + splice.apply(indexMap, [ + index, + 0 + ].concat(newIndicies)); + for (var i = index + newIndicies.length, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + }, remove = function (ev, items, index, duringTeardown, fullTeardown) { + if (!afterPreviousEvents) { + return; + } + if (!duringTeardown && data.teardownCheck(text.parentNode)) { + return; + } + if (index < 0) { + index = indexMap.length + index; + } + var removedMappings = masterNodeList.splice(index + 1, items.length), itemsToRemove = []; + can.each(removedMappings, function (nodeList) { + var nodesToRemove = nodeLists.unregister(nodeList); + [].push.apply(itemsToRemove, nodesToRemove); + }); + indexMap.splice(index, items.length); + for (var i = index, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + if (!fullTeardown) { + can.remove(can.$(itemsToRemove)); + } else { + nodeLists.unregister(masterNodeList); + } + }, move = function (ev, item, newIndex, currentIndex) { + if (!afterPreviousEvents) { + return; + } + newIndex = newIndex + 1; + currentIndex = currentIndex + 1; + var referenceNodeList = masterNodeList[newIndex]; + var movedElements = can.frag(nodeLists.flatten(masterNodeList[currentIndex])); + var referenceElement; + if (currentIndex < newIndex) { + referenceElement = nodeLists.last(referenceNodeList).nextSibling; + } else { + referenceElement = nodeLists.first(referenceNodeList); + } + var parentNode = masterNodeList[0].parentNode; + parentNode.insertBefore(movedElements, referenceElement); + var temp = masterNodeList[currentIndex]; + [].splice.apply(masterNodeList, [ + currentIndex, + 1 + ]); + [].splice.apply(masterNodeList, [ + newIndex, + 0, + temp + ]); + }, text = document.createTextNode(''), list, teardownList = function (fullTeardown) { + if (list && list.unbind) { + list.unbind('add', add).unbind('remove', remove).unbind('move', move); + } + remove({}, { length: masterNodeList.length - 1 }, 0, true, fullTeardown); + }, updateList = function (ev, newList, oldList) { + if (isTornDown) { + return; + } + teardownList(); + list = newList || []; + if (list.bind) { + list.bind('add', add).bind('remove', remove).bind('move', move); + } + afterPreviousEvents = true; + add({}, list, 0); + afterPreviousEvents = false; + can.batch.afterPreviousEvents(function () { + afterPreviousEvents = true; + }); + }; + parentNode = elements.getParentNode(el, parentNode); + var data = setup(parentNode, function () { + if (can.isFunction(compute)) { + compute.bind('change', updateList); + } + }, function () { + if (can.isFunction(compute)) { + compute.unbind('change', updateList); + } + teardownList(true); + }); + if (!nodeList) { + live.replace(masterNodeList, text, data.teardownCheck); + } else { + elements.replace(masterNodeList, text); + nodeLists.update(masterNodeList, [text]); + nodeList.unregistered = function () { + data.teardownCheck(); + isTornDown = true; + }; + } + updateList({}, can.isFunction(compute) ? compute() : compute); + }, + html: function (el, compute, parentNode, nodeList) { + var data; + parentNode = elements.getParentNode(el, parentNode); + data = listen(parentNode, compute, function (ev, newVal, oldVal) { + var attached = nodeLists.first(nodes).parentNode; + if (attached) { + makeAndPut(newVal); + } + data.teardownCheck(nodeLists.first(nodes).parentNode); + }); + var nodes = nodeList || [el], makeAndPut = function (val) { + var isFunction = typeof val === 'function', aNode = isNode(val), frag = can.frag(isFunction ? '' : val), oldNodes = can.makeArray(nodes); + addTextNodeIfNoChildren(frag); + if (!aNode && !isFunction) { + frag = can.view.hookup(frag, parentNode); + } + oldNodes = nodeLists.update(nodes, frag.childNodes); + if (isFunction) { + val(frag.childNodes[0]); + } + elements.replace(oldNodes, frag); + }; + data.nodeList = nodes; + if (!nodeList) { + nodeLists.register(nodes, data.teardownCheck); + } else { + nodeList.unregistered = data.teardownCheck; + } + makeAndPut(compute()); + }, + replace: function (nodes, val, teardown) { + var oldNodes = nodes.slice(0), frag = can.frag(val); + nodeLists.register(nodes, teardown); + if (typeof val === 'string') { + frag = can.view.hookup(frag, nodes[0].parentNode); + } + nodeLists.update(nodes, frag.childNodes); + elements.replace(oldNodes, frag); + return nodes; + }, + text: function (el, compute, parentNode, nodeList) { + var parent = elements.getParentNode(el, parentNode); + var data = listen(parent, compute, function (ev, newVal, oldVal) { + if (typeof node.nodeValue !== 'unknown') { + node.nodeValue = can.view.toStr(newVal); + } + data.teardownCheck(node.parentNode); + }); + var node = document.createTextNode(can.view.toStr(compute())); + if (nodeList) { + nodeList.unregistered = data.teardownCheck; + data.nodeList = nodeList; + nodeLists.update(nodeList, [node]); + elements.replace([el], node); + } else { + data.nodeList = live.replace([el], node, data.teardownCheck); + } + }, + setAttributes: function (el, newVal) { + var attrs = getAttributeParts(newVal); + for (var name in attrs) { + can.attr.set(el, name, attrs[name]); + } + }, + attributes: function (el, compute, currentValue) { + var oldAttrs = {}; + var setAttrs = function (newVal) { + var newAttrs = getAttributeParts(newVal), name; + for (name in newAttrs) { + var newValue = newAttrs[name], oldValue = oldAttrs[name]; + if (newValue !== oldValue) { + can.attr.set(el, name, newValue); + } + delete oldAttrs[name]; + } + for (name in oldAttrs) { + elements.removeAttr(el, name); + } + oldAttrs = newAttrs; + }; + listen(el, compute, function (ev, newVal) { + setAttrs(newVal); + }); + if (arguments.length >= 3) { + oldAttrs = getAttributeParts(currentValue); + } else { + setAttrs(compute()); + } + }, + attributePlaceholder: '__!!__', + attributeReplace: /__!!__/g, + attribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, hook.render()); + }); + var wrapped = can.$(el), hooks; + hooks = can.data(wrapped, 'hooks'); + if (!hooks) { + can.data(wrapped, 'hooks', hooks = {}); + } + var attr = elements.getAttr(el, attributeName), parts = attr.split(live.attributePlaceholder), goodParts = [], hook; + goodParts.push(parts.shift(), parts.join(live.attributePlaceholder)); + if (hooks[attributeName]) { + hooks[attributeName].computes.push(compute); + } else { + hooks[attributeName] = { + render: function () { + var i = 0, newAttr = attr ? attr.replace(live.attributeReplace, function () { + return elements.contentText(hook.computes[i++]()); + }) : elements.contentText(hook.computes[i++]()); + return newAttr; + }, + computes: [compute], + batchNum: undefined + }; + } + hook = hooks[attributeName]; + goodParts.splice(1, 0, compute()); + elements.setAttr(el, attributeName, goodParts.join('')); + }, + specialAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, getValue(newVal)); + }); + elements.setAttr(el, attributeName, getValue(compute())); + }, + simpleAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, newVal); + }); + elements.setAttr(el, attributeName, compute()); + } + }; + live.attr = live.simpleAttribute; + live.attrs = live.attributes; + var newLine = /(\r|\n)+/g; + var getValue = function (val) { + var regexp = /^["'].*["']$/; + val = val.replace(elements.attrReg, '').replace(newLine, ''); + return regexp.test(val) ? val.substr(1, val.length - 2) : val; + }; + can.view.live = live; + return live; +}); +/*can@2.2.6#view/render*/ +define('can/view/render', [ + 'can/view/view', + 'can/view/elements', + 'can/view/live/live', + 'can/util/string/string' +], function (can, elements, live) { + var pendingHookups = [], tagChildren = function (tagName) { + var newTag = elements.tagMap[tagName] || 'span'; + if (newTag === 'span') { + return '@@!!@@'; + } + return '<' + newTag + '>' + tagChildren(newTag) + ''; + }, contentText = function (input, tag) { + if (typeof input === 'string') { + return input; + } + if (!input && input !== 0) { + return ''; + } + var hook = input.hookup && function (el, id) { + input.hookup.call(input, el, id); + } || typeof input === 'function' && input; + if (hook) { + if (tag) { + return '<' + tag + ' ' + can.view.hook(hook) + '>'; + } else { + pendingHookups.push(hook); + } + return ''; + } + return '' + input; + }, contentEscape = function (txt, tag) { + return typeof txt === 'string' || typeof txt === 'number' ? can.esc(txt) : contentText(txt, tag); + }, withinTemplatedSectionWithinAnElement = false, emptyHandler = function () { + }; + var lastHookups; + can.extend(can.view, { + live: live, + setupLists: function () { + var old = can.view.lists, data; + can.view.lists = function (list, renderer) { + data = { + list: list, + renderer: renderer + }; + return Math.random(); + }; + return function () { + can.view.lists = old; + return data; + }; + }, + getHooks: function () { + var hooks = pendingHookups.slice(0); + lastHookups = hooks; + pendingHookups = []; + return hooks; + }, + onlytxt: function (self, func) { + return contentEscape(func.call(self)); + }, + txt: function (escape, tagName, status, self, func) { + var tag = elements.tagMap[tagName] || 'span', setupLiveBinding = false, value, listData, compute, unbind = emptyHandler, attributeName; + if (withinTemplatedSectionWithinAnElement) { + value = func.call(self); + } else { + if (typeof status === 'string' || status === 1) { + withinTemplatedSectionWithinAnElement = true; + } + var listTeardown = can.view.setupLists(); + unbind = function () { + compute.unbind('change', emptyHandler); + }; + compute = can.compute(func, self, false); + compute.bind('change', emptyHandler); + listData = listTeardown(); + value = compute(); + withinTemplatedSectionWithinAnElement = false; + setupLiveBinding = compute.computeInstance.hasDependencies; + } + if (listData) { + unbind(); + return '<' + tag + can.view.hook(function (el, parentNode) { + live.list(el, listData.list, listData.renderer, self, parentNode); + }) + '>'; + } + if (!setupLiveBinding || typeof value === 'function') { + unbind(); + return (withinTemplatedSectionWithinAnElement || escape === 2 || !escape ? contentText : contentEscape)(value, status === 0 && tag); + } + var contentProp = elements.tagToContentPropMap[tagName]; + if (status === 0 && !contentProp) { + return '<' + tag + can.view.hook(escape && typeof value !== 'object' ? function (el, parentNode) { + live.text(el, compute, parentNode); + unbind(); + } : function (el, parentNode) { + live.html(el, compute, parentNode); + unbind(); + }) + '>' + tagChildren(tag) + ''; + } else if (status === 1) { + pendingHookups.push(function (el) { + live.attributes(el, compute, compute()); + unbind(); + }); + return compute(); + } else if (escape === 2) { + attributeName = status; + pendingHookups.push(function (el) { + live.specialAttribute(el, attributeName, compute); + unbind(); + }); + return compute(); + } else { + attributeName = status === 0 ? contentProp : status; + (status === 0 ? lastHookups : pendingHookups).push(function (el) { + live.attribute(el, attributeName, compute); + unbind(); + }); + return live.attributePlaceholder; + } + } + }); + return can; +}); +/*can@2.2.6#view/stache/utils*/ +define('can/view/stache/utils', ['can/util/util'], function () { + return { + isArrayLike: function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, + isObserveLike: function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, + emptyHandler: function () { + }, + jsonParse: function (str) { + if (str[0] === '\'') { + return str.substr(1, str.length - 2); + } else if (str === 'undefined') { + return undefined; + } else if (can.global.JSON) { + return JSON.parse(str); + } else { + return eval('(' + str + ')'); + } + }, + mixins: { + last: function () { + return this.stack[this.stack.length - 1]; + }, + add: function (chars) { + this.last().add(chars); + }, + subSectionDepth: function () { + return this.stack.length - 1; + } + } + }; +}); +/*can@2.2.6#view/stache/mustache_helpers*/ +define('can/view/stache/mustache_helpers', [ + 'can/util/util', + 'can/view/stache/utils', + 'can/view/live/live' +], function (can, utils, live) { + live = live || can.view.live; + var resolve = function (value) { + if (utils.isObserveLike(value) && utils.isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + var helpers = { + 'each': function (items, options) { + var resolved = resolve(items), result = [], keys, key, i; + if (resolved instanceof can.List) { + return function (el) { + var nodeList = [el]; + nodeList.expression = 'live.list'; + can.view.nodeLists.register(nodeList, null, options.nodeList); + can.view.nodeLists.update(options.nodeList, [el]); + var cb = function (item, index, parentNodeList) { + return options.fn(options.scope.add({ '@index': index }).add(item), options.options, parentNodeList); + }; + live.list(el, items, cb, options.context, el.parentNode, nodeList); + }; + } + var expr = resolved; + if (!!expr && utils.isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + } else if (utils.isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } + return result; + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + }, + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!resolve(expr); + } + if (value) { + return options.fn(options.scope || this); + } else { + return options.inverse(options.scope || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return helpers.is.apply(this, arguments); + }, + 'unless': function (expr, options) { + return helpers['if'].apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'with': function (expr, options) { + var ctx = expr; + expr = resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + 'data': function (attr) { + var data = arguments.length === 2 ? this : arguments[1]; + return function (el) { + can.data(can.$(el), attr, data || this.context); + }; + } + }; + return { + registerHelper: function (name, callback) { + helpers[name] = callback; + }, + getHelper: function (name, options) { + var helper = options.attr('helpers.' + name); + if (!helper) { + helper = helpers[name]; + } + if (helper) { + return { fn: helper }; + } + } + }; +}); +/*can@2.2.6#view/stache/mustache_core*/ +define('can/view/stache/mustache_core', [ + 'can/util/util', + 'can/view/stache/utils', + 'can/view/stache/mustache_helpers', + 'can/view/live/live', + 'can/view/elements', + 'can/view/scope/scope', + 'can/view/node_lists/node_lists' +], function (can, utils, mustacheHelpers, live, elements, Scope, nodeLists) { + live = live || can.view.live; + elements = elements || can.view.elements; + Scope = Scope || can.view.Scope; + nodeLists = nodeLists || can.view.nodeLists; + var argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(?:(.+?)=(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(.+))))$/, mustacheLineBreakRegExp = /(?:(?:^|(\r?)\n)(\s*)(\{\{([^\}]*)\}\}\}?)([^\S\n\r]*)($|\r?\n))|(\{\{([^\}]*)\}\}\}?)/g, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, getItemsFragContent = function (items, isObserveList, helperOptions, options) { + var frag = document.createDocumentFragment(); + for (var i = 0, len = items.length; i < len; i++) { + append(frag, helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options)); + } + return frag; + }, append = function (frag, content) { + if (content) { + frag.appendChild(typeof content === 'string' ? document.createTextNode(content) : content); + } + }, getItemsStringContent = function (items, isObserveList, helperOptions, options) { + var txt = ''; + for (var i = 0, len = items.length; i < len; i++) { + txt += helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options); + } + return txt; + }, getKeyComputeData = function (key, scope, isArgument) { + var data = scope.computeData(key, { + isArgument: isArgument, + args: [ + scope.attr('.'), + scope + ] + }); + can.compute.temporarilyBind(data.compute); + return data; + }, getKeyArgValue = function (key, scope) { + var data = getKeyComputeData(key, scope, true); + if (!data.compute.computeInstance.hasDependencies) { + return data.initialValue; + } else { + return data.compute; + } + }, convertToScopes = function (helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer) { + if (truthyRenderer) { + helperOptions.fn = makeRendererConvertScopes(truthyRenderer, scope, options, nodeList); + } + if (falseyRenderer) { + helperOptions.inverse = makeRendererConvertScopes(falseyRenderer, scope, options, nodeList); + } + }, makeRendererConvertScopes = function (renderer, parentScope, parentOptions, nodeList) { + var rendererWithScope = function (ctx, opts, parentNodeList) { + return renderer(ctx || parentScope, opts, parentNodeList); + }; + return can.__notObserve(function (newScope, newOptions, parentNodeList) { + if (newScope !== undefined && !(newScope instanceof can.view.Scope)) { + newScope = parentScope.add(newScope); + } + if (newOptions !== undefined && !(newOptions instanceof core.Options)) { + newOptions = parentOptions.add(newOptions); + } + var result = rendererWithScope(newScope, newOptions || parentOptions, parentNodeList || nodeList); + return result; + }); + }; + var core = { + expressionData: function (expression) { + var args = [], hashes = {}, i = 0; + (can.trim(expression) + ' ').replace(argumentsRegExp, function (whole, arg) { + var m; + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[1] || m[2]) { + args.push(utils.jsonParse(m[1] || m[2])); + } else { + hashes[m[3]] = m[6] ? { get: m[6] } : utils.jsonParse(m[4] || m[5]); + } + } else { + args.push({ get: arg }); + } + i++; + }); + return { + name: args.shift(), + args: args, + hash: hashes + }; + }, + makeEvaluator: function (scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, stringOnly) { + var args = [], hash = {}, helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, context = scope.attr('.'), name = exprData.name, helper, looksLikeAHelper = exprData.args.length || !can.isEmptyObject(exprData.hash), initialValue, helperEvaluator; + for (var i = 0, len = exprData.args.length; i < len; i++) { + var arg = exprData.args[i]; + if (arg && isLookup(arg)) { + args.push(getKeyArgValue(arg.get, scope, true)); + } else { + args.push(arg); + } + } + for (var prop in exprData.hash) { + if (isLookup(exprData.hash[prop])) { + hash[prop] = getKeyArgValue(exprData.hash[prop].get, scope); + } else { + hash[prop] = exprData.hash[prop]; + } + } + if (isLookup(name)) { + if (looksLikeAHelper) { + helper = mustacheHelpers.getHelper(name.get, options); + if (!helper && typeof context[name.get] === 'function') { + helper = { fn: context[name.get] }; + } + } + if (!helper) { + var get = name.get; + var computeData = getKeyComputeData(name.get, scope, false), compute = computeData.compute; + initialValue = computeData.initialValue; + if (computeData.compute.computeInstance.hasDependencies) { + name = compute; + } else { + name = initialValue; + } + if (!looksLikeAHelper && initialValue === undefined) { + helper = mustacheHelpers.getHelper(get, options); + } else if (typeof initialValue === 'function') { + helper = { fn: initialValue }; + } + } + } + if (mode === '^') { + var temp = truthyRenderer; + truthyRenderer = falseyRenderer; + falseyRenderer = temp; + } + if (helper) { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + can.simpleExtend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash, + nodeList: nodeList, + exprData: exprData + }); + args.push(helperOptions); + helperEvaluator = function () { + return helper.fn.apply(context, args) || ''; + }; + helperEvaluator.bindOnce = false; + return helperEvaluator; + } + if (!mode) { + if (name && name.isComputed) { + return name; + } else { + return function () { + return '' + (name != null ? name : ''); + }; + } + } else if (mode === '#' || mode === '^') { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + var evaluator = function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + if (utils.isArrayLike(value)) { + var isObserveList = utils.isObserveLike(value); + if (isObserveList ? value.attr('length') : value.length) { + return (stringOnly ? getItemsStringContent : getItemsFragContent)(value, isObserveList, helperOptions, options); + } else { + return helperOptions.inverse(scope, options); + } + } else { + return value ? helperOptions.fn(value || scope, options) : helperOptions.inverse(scope, options); + } + }; + evaluator.bindOnce = false; + return evaluator; + } else { + } + }, + makeLiveBindingPartialRenderer: function (partialName, state) { + partialName = can.trim(partialName); + return function (scope, options, parentSectionNodeList) { + var nodeList = [this]; + nodeList.expression = '>' + partialName; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var partialFrag = can.compute(function () { + var localPartialName = partialName; + var partial = options.attr('partials.' + localPartialName), res; + if (partial) { + res = partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + var scopePartialName = scope.read(localPartialName, { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }).value; + if (scopePartialName) { + localPartialName = scopePartialName; + } + res = can.view.render(localPartialName, scope, options); + } + return can.frag(res); + }); + live.html(this, partialFrag, this.parentNode, nodeList); + }; + }, + makeStringBranchRenderer: function (mode, expression) { + var exprData = expressionData(expression), fullExpression = mode + expression; + return function branchRenderer(scope, options, truthyRenderer, falseyRenderer) { + var evaluator = scope.__cache[fullExpression]; + if (mode || !evaluator) { + evaluator = makeEvaluator(scope, options, null, mode, exprData, truthyRenderer, falseyRenderer, true); + if (!mode) { + scope.__cache[fullExpression] = evaluator; + } + } + var res = evaluator(); + return res == null ? '' : '' + res; + }; + }, + makeLiveBindingBranchRenderer: function (mode, expression, state) { + var exprData = expressionData(expression); + return function branchRenderer(scope, options, parentSectionNodeList, truthyRenderer, falseyRenderer) { + var nodeList = [this]; + nodeList.expression = expression; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var evaluator = makeEvaluator(scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, state.tag); + var compute = can.compute(evaluator, null, false, evaluator.bindOnce === false ? false : true); + compute.bind('change', can.k); + var value = compute(); + if (typeof value === 'function') { + var old = can.__clearReading(); + value(this); + can.__setReading(old); + } else if (compute.computeInstance.hasDependencies) { + if (state.attr) { + live.simpleAttribute(this, state.attr, compute); + } else if (state.tag) { + live.attributes(this, compute); + } else if (state.text && typeof value !== 'object') { + live.text(this, compute, this.parentNode, nodeList); + } else { + live.html(this, compute, this.parentNode, nodeList); + } + } else { + if (state.attr) { + can.attr.set(this, state.attr, value); + } else if (state.tag) { + live.setAttributes(this, value); + } else if (state.text && typeof value === 'string') { + this.nodeValue = value; + } else if (value) { + elements.replace([this], can.frag(value)); + } + } + compute.unbind('change', can.k); + }; + }, + splitModeFromExpression: function (expression, state) { + expression = can.trim(expression); + var mode = expression.charAt(0); + if ('#/{&^>!'.indexOf(mode) >= 0) { + expression = can.trim(expression.substr(1)); + } else { + mode = null; + } + if (mode === '{' && state.node) { + mode = null; + } + return { + mode: mode, + expression: expression + }; + }, + cleanLineEndings: function (template) { + return template.replace(mustacheLineBreakRegExp, function (whole, returnBefore, spaceBefore, special, expression, spaceAfter, returnAfter, spaceLessSpecial, spaceLessExpression, matchIndex) { + spaceAfter = spaceAfter || ''; + returnBefore = returnBefore || ''; + spaceBefore = spaceBefore || ''; + var modeAndExpression = splitModeFromExpression(expression || spaceLessExpression, {}); + if (spaceLessSpecial || '>{'.indexOf(modeAndExpression.mode) >= 0) { + return whole; + } else if ('^#!/'.indexOf(modeAndExpression.mode) >= 0) { + return special + (matchIndex !== 0 && returnAfter.length ? returnBefore + '\n' : ''); + } else { + return spaceBefore + special + spaceAfter + (spaceBefore.length || matchIndex !== 0 ? returnBefore + '\n' : ''); + } + }); + }, + Options: can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }) + }; + var makeEvaluator = core.makeEvaluator, expressionData = core.expressionData, splitModeFromExpression = core.splitModeFromExpression; + return core; +}); +/*can@2.2.6#view/bindings/bindings*/ +define('can/view/bindings/bindings', [ + 'can/util/util', + 'can/view/stache/mustache_core', + 'can/view/callbacks/callbacks', + 'can/control/control', + 'can/view/scope/scope' +], function (can, mustacheCore) { + var isContentEditable = function () { + var values = { + '': true, + 'true': true, + 'false': false + }; + var editable = function (el) { + if (!el || !el.getAttribute) { + return; + } + var attr = el.getAttribute('contenteditable'); + return values[attr]; + }; + return function (el) { + var val = editable(el); + if (typeof val === 'boolean') { + return val; + } else { + return !!editable(el.parentNode); + } + }; + }(), removeCurly = function (value) { + if (value[0] === '{' && value[value.length - 1] === '}') { + return value.substr(1, value.length - 2); + } + return value; + }; + can.view.attr('can-value', function (el, data) { + var attr = can.trim(removeCurly(el.getAttribute('can-value'))), value = data.scope.computeData(attr, { args: [] }).compute, trueValue, falseValue; + if (el.nodeName.toLowerCase() === 'input') { + if (el.type === 'checkbox') { + if (can.attr.has(el, 'can-true-value')) { + trueValue = el.getAttribute('can-true-value'); + } else { + trueValue = true; + } + if (can.attr.has(el, 'can-false-value')) { + falseValue = el.getAttribute('can-false-value'); + } else { + falseValue = false; + } + } + if (el.type === 'checkbox' || el.type === 'radio') { + new Checked(el, { + value: value, + trueValue: trueValue, + falseValue: falseValue + }); + return; + } + } + if (el.nodeName.toLowerCase() === 'select' && el.multiple) { + new Multiselect(el, { value: value }); + return; + } + if (isContentEditable(el)) { + new Content(el, { value: value }); + return; + } + new Value(el, { value: value }); + }); + var special = { + enter: function (data, el, original) { + return { + event: 'keyup', + handler: function (ev) { + if (ev.keyCode === 13) { + return original.call(this, ev); + } + } + }; + } + }; + can.view.attr(/can-[\w\.]+/, function (el, data) { + var attributeName = data.attributeName, event = attributeName.substr('can-'.length), handler = function (ev) { + var attrVal = el.getAttribute(attributeName); + if (!attrVal) { + return; + } + var attrInfo = mustacheCore.expressionData(removeCurly(attrVal)); + var scopeData = data.scope.read(attrInfo.name.get, { + returnObserveMethods: true, + isArgument: true, + executeAnonymousFunctions: true + }); + var args = []; + var $el = can.$(this); + var viewModel = can.viewModel($el[0]); + var localScope = data.scope.add({ + '@element': $el, + '@event': ev, + '@viewModel': viewModel, + '@scope': data.scope, + '@context': data.scope._context + }); + if (!can.isEmptyObject(attrInfo.hash)) { + var hash = {}; + can.each(attrInfo.hash, function (val, key) { + if (val && val.hasOwnProperty('get')) { + var s = !val.get.indexOf('@') ? localScope : data.scope; + hash[key] = s.read(val.get, {}).value; + } else { + hash[key] = val; + } + }); + args.unshift(hash); + } + if (attrInfo.args.length) { + var arg; + for (var i = attrInfo.args.length - 1; i >= 0; i--) { + arg = attrInfo.args[i]; + if (arg && arg.hasOwnProperty('get')) { + var s = !arg.get.indexOf('@') ? localScope : data.scope; + args.unshift(s.read(arg.get, {}).value); + } else { + args.unshift(arg); + } + } + } + if (!args.length) { + args = [ + data.scope._context, + $el + ].concat(can.makeArray(arguments)); + } + return scopeData.value.apply(scopeData.parent, args); + }; + if (special[event]) { + var specialData = special[event](data, el, handler); + handler = specialData.handler; + event = specialData.event; + } + can.bind.call(el, event, handler); + }); + var Value = can.Control.extend({ + init: function () { + if (this.element[0].nodeName.toUpperCase() === 'SELECT') { + setTimeout(can.proxy(this.set, this), 1); + } else { + this.set(); + } + }, + '{value} change': 'set', + set: function () { + if (!this.element) { + return; + } + var val = this.options.value(); + this.element[0].value = val == null ? '' : val; + }, + 'change': function () { + if (!this.element) { + return; + } + var el = this.element[0]; + this.options.value(el.value); + var newVal = this.options.value(); + if (el.value !== newVal) { + el.value = newVal; + } + } + }), Checked = can.Control.extend({ + init: function () { + this.isCheckbox = this.element[0].type.toLowerCase() === 'checkbox'; + this.check(); + }, + '{value} change': 'check', + check: function () { + if (this.isCheckbox) { + var value = this.options.value(), trueValue = this.options.trueValue || true; + this.element[0].checked = value == trueValue; + } else { + var setOrRemove = this.options.value() == this.element[0].value ? 'set' : 'remove'; + can.attr[setOrRemove](this.element[0], 'checked', true); + } + }, + 'change': function () { + if (this.isCheckbox) { + this.options.value(this.element[0].checked ? this.options.trueValue : this.options.falseValue); + } else { + if (this.element[0].checked) { + this.options.value(this.element[0].value); + } + } + } + }), Multiselect = Value.extend({ + init: function () { + this.delimiter = ';'; + setTimeout(can.proxy(this.set, this), 1); + }, + set: function () { + var newVal = this.options.value(); + if (typeof newVal === 'string') { + newVal = newVal.split(this.delimiter); + this.isString = true; + } else if (newVal) { + newVal = can.makeArray(newVal); + } + var isSelected = {}; + can.each(newVal, function (val) { + isSelected[val] = true; + }); + can.each(this.element[0].childNodes, function (option) { + if (option.value) { + option.selected = !!isSelected[option.value]; + } + }); + }, + get: function () { + var values = [], children = this.element[0].childNodes; + can.each(children, function (child) { + if (child.selected && child.value) { + values.push(child.value); + } + }); + return values; + }, + 'change': function () { + var value = this.get(), currentValue = this.options.value(); + if (this.isString || typeof currentValue === 'string') { + this.isString = true; + this.options.value(value.join(this.delimiter)); + } else if (currentValue instanceof can.List) { + currentValue.attr(value, true); + } else { + this.options.value(value); + } + } + }), Content = can.Control.extend({ + init: function () { + this.set(); + this.on('blur', 'setValue'); + }, + '{value} change': 'set', + set: function () { + var val = this.options.value(); + this.element[0].innerHTML = typeof val === 'undefined' ? '' : val; + }, + setValue: function () { + this.options.value(this.element[0].innerHTML); + } + }); +}); +/*can@2.2.6#view/mustache/mustache*/ +define('can/view/mustache/mustache', [ + 'can/util/util', + 'can/view/scope/scope', + 'can/view/view', + 'can/view/scanner', + 'can/compute/compute', + 'can/view/render', + 'can/view/bindings/bindings' +], function (can) { + can.view.ext = '.mustache'; + var SCOPE = 'scope', HASH = '___h4sh', CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options}', SPECIAL_CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options, special: true}', ARG_NAMES = SCOPE + ',options', argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false|null|undefined)|((.+?)=(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false)|(.+))))$/, makeLookupLiteral = function (type) { + return '{get:"' + type.replace(/"/g, '\\"') + '"}'; + }, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, isObserveLike = function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, isArrayLike = function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, makeConvertToScopes = function (original, scope, options) { + var originalWithScope = function (ctx, opts) { + return original(ctx || scope, opts); + }; + return function (updatedScope, updatedOptions) { + if (updatedScope !== undefined && !(updatedScope instanceof can.view.Scope)) { + updatedScope = scope.add(updatedScope); + } + if (updatedOptions !== undefined && !(updatedOptions instanceof can.view.Options)) { + updatedOptions = options.add(updatedOptions); + } + return originalWithScope(updatedScope, updatedOptions || options); + }; + }; + var Mustache = function (options, helpers) { + if (this.constructor !== Mustache) { + var mustache = new Mustache(options); + return function (data, options) { + return mustache.render(data, options); + }; + } + if (typeof options === 'function') { + this.template = { fn: options }; + return; + } + can.extend(this, options); + this.template = this.scanner.scan(this.text, this.name); + }; + can.Mustache = can.global.Mustache = Mustache; + Mustache.prototype.render = function (data, options) { + if (!(data instanceof can.view.Scope)) { + data = new can.view.Scope(data || {}); + } + if (!(options instanceof can.view.Options)) { + options = new can.view.Options(options || {}); + } + options = options || {}; + return this.template.fn.call(data, data, options); + }; + can.extend(Mustache.prototype, { + scanner: new can.view.Scanner({ + text: { + start: '', + scope: SCOPE, + options: ',options: options', + argNames: ARG_NAMES + }, + tokens: [ + [ + 'returnLeft', + '{{{', + '{{[{&]' + ], + [ + 'commentFull', + '{{!}}', + '^[\\s\\t]*{{!.+?}}\\n' + ], + [ + 'commentLeft', + '{{!', + '(\\n[\\s\\t]*{{!|{{!)' + ], + [ + 'escapeFull', + '{{}}', + '(^[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}$)', + function (content) { + return { + before: /^\n.+?\n$/.test(content) ? '\n' : '', + content: content.match(/\{\{(.+?)\}\}/)[1] || '' + }; + } + ], + [ + 'escapeLeft', + '{{' + ], + [ + 'returnRight', + '}}}' + ], + [ + 'right', + '}}' + ] + ], + helpers: [ + { + name: /^>[\s]*\w*/, + fn: function (content, cmd) { + var templateName = can.trim(content.replace(/^>\s?/, '')).replace(/["|']/g, ''); + return 'can.Mustache.renderPartial(\'' + templateName + '\',' + ARG_NAMES + ')'; + } + }, + { + name: /^\s*data\s/, + fn: function (content, cmd) { + var attr = content.match(/["|'](.*)["|']/)[1]; + return 'can.proxy(function(__){' + 'can.data(can.$(__),\'' + attr + '\', this.attr(\'.\')); }, ' + SCOPE + ')'; + } + }, + { + name: /\s*\(([\$\w]+)\)\s*->([^\n]*)/, + fn: function (content) { + var quickFunc = /\s*\(([\$\w]+)\)\s*->([^\n]*)/, parts = content.match(quickFunc); + return 'can.proxy(function(__){var ' + parts[1] + '=can.$(__);with(' + SCOPE + '.attr(\'.\')){' + parts[2] + '}}, this);'; + } + }, + { + name: /^.*$/, + fn: function (content, cmd) { + var mode = false, result = { + content: '', + startTxt: false, + startOnlyTxt: false, + end: false + }; + content = can.trim(content); + if (content.length && (mode = content.match(/^([#^\/]|else$)/))) { + mode = mode[0]; + switch (mode) { + case '#': + case '^': + if (cmd.specialAttribute) { + result.startOnlyTxt = true; + } else { + result.startTxt = true; + result.escaped = 0; + } + break; + case '/': + result.end = true; + result.content += 'return ___v1ew.join("");}}])'; + return result; + } + content = content.substring(1); + } + if (mode !== 'else') { + var args = [], hashes = [], i = 0, m; + result.content += 'can.Mustache.txt(\n' + (cmd.specialAttribute ? SPECIAL_CONTEXT_OBJ : CONTEXT_OBJ) + ',\n' + (mode ? '"' + mode + '"' : 'null') + ','; + (can.trim(content) + ' ').replace(argumentsRegExp, function (whole, arg) { + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[2]) { + args.push(m[0]); + } else { + hashes.push(m[4] + ':' + (m[6] ? m[6] : makeLookupLiteral(m[5]))); + } + } else { + args.push(makeLookupLiteral(arg)); + } + i++; + }); + result.content += args.join(','); + if (hashes.length) { + result.content += ',{' + HASH + ':{' + hashes.join(',') + '}}'; + } + } + if (mode && mode !== 'else') { + result.content += ',[\n\n'; + } + switch (mode) { + case '^': + case '#': + result.content += '{fn:function(' + ARG_NAMES + '){var ___v1ew = [];'; + break; + case 'else': + result.content += 'return ___v1ew.join("");}},\n{inverse:function(' + ARG_NAMES + '){\nvar ___v1ew = [];'; + break; + default: + result.content += ')'; + break; + } + if (!mode) { + result.startTxt = true; + result.end = true; + } + return result; + } + } + ] + }) + }); + var helpers = can.view.Scanner.prototype.helpers; + for (var i = 0; i < helpers.length; i++) { + Mustache.prototype.scanner.helpers.unshift(helpers[i]); + } + Mustache.txt = function (scopeAndOptions, mode, name) { + var scope = scopeAndOptions.scope, options = scopeAndOptions.options, args = [], helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, hash, context = scope.attr('.'), getHelper = true, helper; + for (var i = 3; i < arguments.length; i++) { + var arg = arguments[i]; + if (mode && can.isArray(arg)) { + helperOptions = can.extend.apply(can, [helperOptions].concat(arg)); + } else if (arg && arg[HASH]) { + hash = arg[HASH]; + for (var prop in hash) { + if (isLookup(hash[prop])) { + hash[prop] = Mustache.get(hash[prop].get, scopeAndOptions, false, true); + } + } + } else if (arg && isLookup(arg)) { + args.push(Mustache.get(arg.get, scopeAndOptions, false, true, true)); + } else { + args.push(arg); + } + } + if (isLookup(name)) { + var get = name.get; + name = Mustache.get(name.get, scopeAndOptions, args.length, false); + getHelper = get === name; + } + helperOptions.fn = makeConvertToScopes(helperOptions.fn, scope, options); + helperOptions.inverse = makeConvertToScopes(helperOptions.inverse, scope, options); + if (mode === '^') { + var tmp = helperOptions.fn; + helperOptions.fn = helperOptions.inverse; + helperOptions.inverse = tmp; + } + if (helper = getHelper && (typeof name === 'string' && Mustache.getHelper(name, options)) || can.isFunction(name) && !name.isComputed && { fn: name }) { + can.extend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash + }); + args.push(helperOptions); + return function () { + return helper.fn.apply(context, args) || ''; + }; + } + return function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + var validArgs = args.length ? args : [value], valid = true, result = [], i, argIsObserve, arg; + if (mode) { + for (i = 0; i < validArgs.length; i++) { + arg = validArgs[i]; + argIsObserve = typeof arg !== 'undefined' && isObserveLike(arg); + if (isArrayLike(arg)) { + if (mode === '#') { + valid = valid && !!(argIsObserve ? arg.attr('length') : arg.length); + } else if (mode === '^') { + valid = valid && !(argIsObserve ? arg.attr('length') : arg.length); + } + } else { + valid = mode === '#' ? valid && !!arg : mode === '^' ? valid && !arg : valid; + } + } + } + if (valid) { + if (mode === '#') { + if (isArrayLike(value)) { + var isObserveList = isObserveLike(value); + for (i = 0; i < value.length; i++) { + result.push(helperOptions.fn(isObserveList ? value.attr('' + i) : value[i])); + } + return result.join(''); + } else { + return helperOptions.fn(value || {}) || ''; + } + } else if (mode === '^') { + return helperOptions.inverse(value || {}) || ''; + } else { + return '' + (value != null ? value : ''); + } + } + return ''; + }; + }; + Mustache.get = function (key, scopeAndOptions, isHelper, isArgument, isLookup) { + var context = scopeAndOptions.scope.attr('.'), options = scopeAndOptions.options || {}; + if (isHelper) { + if (Mustache.getHelper(key, options)) { + return key; + } + if (scopeAndOptions.scope && can.isFunction(context[key])) { + return context[key]; + } + } + var computeData = scopeAndOptions.scope.computeData(key, { + isArgument: isArgument, + args: [ + context, + scopeAndOptions.scope + ] + }), compute = computeData.compute; + can.compute.temporarilyBind(compute); + var initialValue = computeData.initialValue, helperObj = Mustache.getHelper(key, options); + if (!isLookup && (initialValue === undefined || computeData.scope !== scopeAndOptions.scope) && Mustache.getHelper(key, options)) { + return key; + } + if (!compute.computeInstance.hasDependencies) { + return initialValue; + } else { + return compute; + } + }; + Mustache.resolve = function (value) { + if (isObserveLike(value) && isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + can.view.Options = can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }); + Mustache._helpers = {}; + Mustache.registerHelper = function (name, fn) { + this._helpers[name] = { + name: name, + fn: fn + }; + }; + Mustache.getHelper = function (name, options) { + var helper; + if (options) { + helper = options.attr('helpers.' + name); + } + return helper ? { fn: helper } : this._helpers[name]; + }; + Mustache.render = function (partial, scope, options) { + if (!can.view.cached[partial]) { + var reads = can.__clearReading(); + var scopePartialName = scope.attr(partial); + if (scopePartialName) { + partial = scopePartialName; + } + can.__setReading(reads); + } + return can.view.render(partial, scope, options); + }; + Mustache.safeString = function (str) { + return { + toString: function () { + return str; + } + }; + }; + Mustache.renderPartial = function (partialName, scope, options) { + var partial = options.attr('partials.' + partialName); + if (partial) { + return partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + return can.Mustache.render(partialName, scope, options); + } + }; + can.each({ + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!Mustache.resolve(expr); + } + if (value) { + return options.fn(options.contexts || this); + } else { + return options.inverse(options.contexts || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = Mustache.resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return Mustache._helpers.is.fn.apply(this, arguments); + }, + 'unless': function (expr, options) { + return Mustache._helpers['if'].fn.apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'each': function (expr, options) { + var resolved = Mustache.resolve(expr), result = [], keys, key, i; + if (can.view.lists && (resolved instanceof can.List || expr && expr.isComputed && resolved === undefined)) { + return can.view.lists(expr, function (item, index) { + return options.fn(options.scope.add({ '@index': index }).add(item)); + }); + } + expr = resolved; + if (!!expr && isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + return result.join(''); + } else if (isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } + }, + 'with': function (expr, options) { + var ctx = expr; + expr = Mustache.resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + } + }, function (fn, name) { + Mustache.registerHelper(name, fn); + }); + can.view.register({ + suffix: 'mustache', + contentType: 'x-mustache-template', + script: function (id, src) { + return 'can.Mustache(function(' + ARG_NAMES + ') { ' + new Mustache({ + text: src, + name: id + }).template.out + ' })'; + }, + renderer: function (id, text) { + return Mustache({ + text: text, + name: id + }); + } + }); + can.mustache.registerHelper = can.proxy(can.Mustache.registerHelper, can.Mustache); + can.mustache.safeString = can.Mustache.safeString; + return can; +}); +/*can@2.2.6#component/component*/ +define('can/component/component', [ + 'can/util/util', + 'can/view/callbacks/callbacks', + 'can/view/elements', + 'can/control/control', + 'can/observe/observe', + 'can/view/mustache/mustache', + 'can/view/bindings/bindings' +], function (can, viewCallbacks, elements) { + var ignoreAttributesRegExp = /^(dataViewId|class|id)$/i, paramReplacer = /\{([^\}]+)\}/g; + var Component = can.Component = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Component) { + var self = this, scope = this.prototype.scope || this.prototype.viewModel; + this.Control = ComponentControl.extend(this.prototype.events); + if (!scope || typeof scope === 'object' && !(scope instanceof can.Map)) { + this.Map = can.Map.extend(scope || {}); + } else if (scope.prototype instanceof can.Map) { + this.Map = scope; + } + this.attributeScopeMappings = {}; + can.each(this.Map ? this.Map.defaults : {}, function (val, prop) { + if (val === '@') { + self.attributeScopeMappings[prop] = prop; + } + }); + if (this.prototype.template) { + if (typeof this.prototype.template === 'function') { + var temp = this.prototype.template; + this.renderer = function () { + return can.view.frag(temp.apply(null, arguments)); + }; + } else { + this.renderer = can.view.mustache(this.prototype.template); + } + } + can.view.tag(this.prototype.tag, function (el, options) { + new self(el, options); + }); + } + } + }, { + setup: function (el, hookupOptions) { + var initialScopeData = {}, component = this, lexicalContent = (typeof this.leakScope === 'undefined' ? false : !this.leakScope) && this.template, twoWayBindings = {}, scope = this.scope || this.viewModel, viewModelPropertyUpdates = {}, componentScope, frag, teardownFunctions = [], callTeardownFunctions = function () { + for (var i = 0, len = teardownFunctions.length; i < len; i++) { + teardownFunctions[i](); + } + }; + can.each(this.constructor.attributeScopeMappings, function (val, prop) { + initialScopeData[prop] = el.getAttribute(can.hyphenate(val)); + }); + can.each(can.makeArray(el.attributes), function (node, index) { + var name = can.camelize(node.nodeName.toLowerCase()), value = node.value; + if (component.constructor.attributeScopeMappings[name] || ignoreAttributesRegExp.test(name) || viewCallbacks.attr(node.nodeName)) { + return; + } + if (value[0] === '{' && value[value.length - 1] === '}') { + value = value.substr(1, value.length - 2); + } else { + if (hookupOptions.templateType !== 'legacy') { + initialScopeData[name] = value; + return; + } + } + var computeData = hookupOptions.scope.computeData(value, { args: [] }), compute = computeData.compute; + var handler = function (ev, newVal) { + viewModelPropertyUpdates[name] = (viewModelPropertyUpdates[name] || 0) + 1; + componentScope.attr(name, newVal); + can.batch.afterPreviousEvents(function () { + --viewModelPropertyUpdates[name]; + }); + }; + compute.bind('change', handler); + initialScopeData[name] = compute(); + if (!compute.computeInstance.hasDependencies) { + compute.unbind('change', handler); + } else { + teardownFunctions.push(function () { + compute.unbind('change', handler); + }); + twoWayBindings[name] = computeData; + } + }); + if (this.constructor.Map) { + componentScope = new this.constructor.Map(initialScopeData); + } else if (scope instanceof can.Map) { + componentScope = scope; + } else if (can.isFunction(scope)) { + var scopeResult = scope.call(this, initialScopeData, hookupOptions.scope, el); + if (scopeResult instanceof can.Map) { + componentScope = scopeResult; + } else if (scopeResult.prototype instanceof can.Map) { + componentScope = new scopeResult(initialScopeData); + } else { + componentScope = new (can.Map.extend(scopeResult))(initialScopeData); + } + } + var handlers = {}; + can.each(twoWayBindings, function (computeData, prop) { + handlers[prop] = function (ev, newVal) { + if (!viewModelPropertyUpdates[prop]) { + computeData.compute(newVal); + } + }; + componentScope.bind(prop, handlers[prop]); + }); + if (!can.isEmptyObject(this.constructor.attributeScopeMappings) || hookupOptions.templateType !== 'legacy') { + can.bind.call(el, 'attributes', function (ev) { + var camelized = can.camelize(ev.attributeName); + if (!twoWayBindings[camelized] && !ignoreAttributesRegExp.test(camelized)) { + componentScope.attr(camelized, el.getAttribute(ev.attributeName)); + } + }); + } + this.scope = this.viewModel = componentScope; + can.data(can.$(el), 'scope', this.scope); + can.data(can.$(el), 'viewModel', this.scope); + var renderedScope = lexicalContent ? this.scope : hookupOptions.scope.add(this.scope), options = { helpers: {} }; + can.each(this.helpers || {}, function (val, prop) { + if (can.isFunction(val)) { + options.helpers[prop] = function () { + return val.apply(componentScope, arguments); + }; + } + }); + teardownFunctions.push(function () { + can.each(handlers, function (handler, prop) { + componentScope.unbind(prop, handlers[prop]); + }); + }); + this._control = new this.constructor.Control(el, { + scope: this.scope, + viewModel: this.scope + }); + if (this._control && this._control.destroy) { + var oldDestroy = this._control.destroy; + this._control.destroy = function () { + oldDestroy.apply(this, arguments); + callTeardownFunctions(); + }; + this._control.on(); + } else { + can.bind.call(el, 'removed', function () { + callTeardownFunctions(); + }); + } + var nodeList = can.view.nodeLists.register([], undefined, true); + teardownFunctions.push(function () { + can.view.nodeLists.unregister(nodeList); + }); + if (this.constructor.renderer) { + if (!options.tags) { + options.tags = {}; + } + options.tags.content = function contentHookup(el, rendererOptions) { + var subtemplate = hookupOptions.subtemplate || rendererOptions.subtemplate; + if (subtemplate) { + delete options.tags.content; + var opts = !lexicalContent || subtemplate !== hookupOptions.subtemplate ? rendererOptions : hookupOptions; + if (rendererOptions.parentNodeList) { + var frag = subtemplate(opts.scope, opts.options, rendererOptions.parentNodeList); + elements.replace([el], frag); + } else { + can.view.live.replace([el], subtemplate(opts.scope, opts.options)); + } + options.tags.content = contentHookup; + } + }; + frag = this.constructor.renderer(renderedScope, hookupOptions.options.add(options), nodeList); + } else { + if (hookupOptions.templateType === 'legacy') { + frag = can.view.frag(hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options)) : ''); + } else { + frag = hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options), nodeList) : document.createDocumentFragment(); + } + } + can.appendChild(el, frag); + can.view.nodeLists.update(nodeList, el.childNodes); + } + }); + var ComponentControl = can.Control.extend({ + _lookup: function (options) { + return [ + options.scope, + options, + window + ]; + }, + _action: function (methodName, options, controlInstance) { + var hasObjectLookup, readyCompute; + paramReplacer.lastIndex = 0; + hasObjectLookup = paramReplacer.test(methodName); + if (!controlInstance && hasObjectLookup) { + return; + } else if (!hasObjectLookup) { + return can.Control._action.apply(this, arguments); + } else { + readyCompute = can.compute(function () { + var delegate; + var name = methodName.replace(paramReplacer, function (matched, key) { + var value; + if (key === 'scope' || key === 'viewModel') { + delegate = options.scope; + return ''; + } + key = key.replace(/^(scope|^viewModel)\./, ''); + value = can.compute.read(options.scope, key.split('.'), { isArgument: true }).value; + if (value === undefined) { + value = can.getObject(key); + } + if (typeof value === 'string') { + return value; + } else { + delegate = value; + return ''; + } + }); + var parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: this.processors[event] || this.processors.click, + parts: [ + name, + parts.join(' '), + event + ], + delegate: delegate || undefined + }; + }, this); + var handler = function (ev, ready) { + controlInstance._bindings.control[methodName](controlInstance.element); + controlInstance._bindings.control[methodName] = ready.processor(ready.delegate || controlInstance.element, ready.parts[2], ready.parts[1], methodName, controlInstance); + }; + readyCompute.bind('change', handler); + controlInstance._bindings.readyComputes[methodName] = { + compute: readyCompute, + handler: handler + }; + return readyCompute(); + } + } + }, { + setup: function (el, options) { + this.scope = options.scope; + this.viewModel = options.viewModel; + return can.Control.prototype.setup.call(this, el, options); + }, + off: function () { + if (this._bindings) { + can.each(this._bindings.readyComputes || {}, function (value) { + value.compute.unbind('change', value.handler); + }); + } + can.Control.prototype.off.apply(this, arguments); + this._bindings.readyComputes = {}; + } + }); + var $ = can.$; + if ($.fn) { + $.fn.scope = $.fn.viewModel = function () { + return can.viewModel.apply(can, [this].concat(can.makeArray(arguments))); + }; + } + return Component; +}); +/*can@2.2.6#model/model*/ +define('can/model/model', [ + 'can/util/util', + 'can/map/map', + 'can/list/list' +], function (can) { + var pipe = function (def, thisArg, func) { + var d = new can.Deferred(); + def.then(function () { + var args = can.makeArray(arguments), success = true; + try { + args[0] = func.apply(thisArg, args); + } catch (e) { + success = false; + d.rejectWith(d, [e].concat(args)); + } + if (success) { + d.resolveWith(d, args); + } + }, function () { + d.rejectWith(this, arguments); + }); + if (typeof def.abort === 'function') { + d.abort = function () { + return def.abort(); + }; + } + return d; + }, modelNum = 0, getId = function (inst) { + can.__observe(inst, inst.constructor.id); + return inst.__get(inst.constructor.id); + }, ajax = function (ajaxOb, data, type, dataType, success, error) { + var params = {}; + if (typeof ajaxOb === 'string') { + var parts = ajaxOb.split(/\s+/); + params.url = parts.pop(); + if (parts.length) { + params.type = parts.pop(); + } + } else { + can.extend(params, ajaxOb); + } + params.data = typeof data === 'object' && !can.isArray(data) ? can.extend(params.data || {}, data) : data; + params.url = can.sub(params.url, params.data, true); + return can.ajax(can.extend({ + type: type || 'post', + dataType: dataType || 'json', + success: success, + error: error + }, params)); + }, makeRequest = function (modelObj, type, success, error, method) { + var args; + if (can.isArray(modelObj)) { + args = modelObj[1]; + modelObj = modelObj[0]; + } else { + args = modelObj.serialize(); + } + args = [args]; + var deferred, model = modelObj.constructor, jqXHR; + if (type === 'update' || type === 'destroy') { + args.unshift(getId(modelObj)); + } + jqXHR = model[type].apply(model, args); + deferred = pipe(jqXHR, modelObj, function (data) { + modelObj[method || type + 'd'](data, jqXHR); + return modelObj; + }); + if (jqXHR.abort) { + deferred.abort = function () { + jqXHR.abort(); + }; + } + deferred.then(success, error); + return deferred; + }, converters = { + models: function (instancesRawData, oldList, xhr) { + can.Model._reqs++; + if (!instancesRawData) { + return; + } + if (instancesRawData instanceof this.List) { + return instancesRawData; + } + var self = this, tmp = [], ListClass = self.List || ML, modelList = oldList instanceof can.List ? oldList : new ListClass(), rawDataIsList = instancesRawData instanceof ML, raw = rawDataIsList ? instancesRawData.serialize() : instancesRawData; + raw = self.parseModels(raw, xhr); + if (raw.data) { + instancesRawData = raw; + raw = raw.data; + } + if (typeof raw === 'undefined' || !can.isArray(raw)) { + throw new Error('Could not get any raw data while converting using .models'); + } + if (modelList.length) { + modelList.splice(0); + } + can.each(raw, function (rawPart) { + tmp.push(self.model(rawPart, xhr)); + }); + modelList.push.apply(modelList, tmp); + if (!can.isArray(instancesRawData)) { + can.each(instancesRawData, function (val, prop) { + if (prop !== 'data') { + modelList.attr(prop, val); + } + }); + } + setTimeout(can.proxy(this._clean, this), 1); + return modelList; + }, + model: function (attributes, oldModel, xhr) { + if (!attributes) { + return; + } + if (typeof attributes.serialize === 'function') { + attributes = attributes.serialize(); + } else { + attributes = this.parseModel(attributes, xhr); + } + var id = attributes[this.id]; + if ((id || id === 0) && this.store[id]) { + oldModel = this.store[id]; + } + var model = oldModel && can.isFunction(oldModel.attr) ? oldModel.attr(attributes, this.removeAttr || false) : new this(attributes); + return model; + } + }, makeParser = { + parseModel: function (prop) { + return function (attributes) { + return prop ? can.getObject(prop, attributes) : attributes; + }; + }, + parseModels: function (prop) { + return function (attributes) { + if (can.isArray(attributes)) { + return attributes; + } + prop = prop || 'data'; + var result = can.getObject(prop, attributes); + if (!can.isArray(result)) { + throw new Error('Could not get any raw data while converting using .models'); + } + return result; + }; + } + }, ajaxMethods = { + create: { + url: '_shortName', + type: 'post' + }, + update: { + data: function (id, attrs) { + attrs = attrs || {}; + var identity = this.id; + if (attrs[identity] && attrs[identity] !== id) { + attrs['new' + can.capitalize(id)] = attrs[identity]; + delete attrs[identity]; + } + attrs[identity] = id; + return attrs; + }, + type: 'put' + }, + destroy: { + type: 'delete', + data: function (id, attrs) { + attrs = attrs || {}; + attrs.id = attrs[this.id] = id; + return attrs; + } + }, + findAll: { url: '_shortName' }, + findOne: {} + }, ajaxMaker = function (ajaxMethod, str) { + return function (data) { + data = ajaxMethod.data ? ajaxMethod.data.apply(this, arguments) : data; + return ajax(str || this[ajaxMethod.url || '_url'], data, ajaxMethod.type || 'get'); + }; + }, createURLFromResource = function (model, name) { + if (!model.resource) { + return; + } + var resource = model.resource.replace(/\/+$/, ''); + if (name === 'findAll' || name === 'create') { + return resource; + } else { + return resource + '/{' + model.id + '}'; + } + }; + can.Model = can.Map.extend({ + fullName: 'can.Model', + _reqs: 0, + setup: function (base, fullName, staticProps, protoProps) { + if (typeof fullName !== 'string') { + protoProps = staticProps; + staticProps = fullName; + } + if (!protoProps) { + protoProps = staticProps; + } + this.store = {}; + can.Map.setup.apply(this, arguments); + if (!can.Model) { + return; + } + if (staticProps && staticProps.List) { + this.List = staticProps.List; + this.List.Map = this; + } else { + this.List = base.List.extend({ Map: this }, {}); + } + var self = this, clean = can.proxy(this._clean, self); + can.each(ajaxMethods, function (method, name) { + if (staticProps && staticProps[name] && (typeof staticProps[name] === 'string' || typeof staticProps[name] === 'object')) { + self[name] = ajaxMaker(method, staticProps[name]); + } else if (staticProps && staticProps.resource && !can.isFunction(staticProps[name])) { + self[name] = ajaxMaker(method, createURLFromResource(self, name)); + } + if (self['make' + can.capitalize(name)]) { + var newMethod = self['make' + can.capitalize(name)](self[name]); + can.Construct._overwrite(self, base, name, function () { + can.Model._reqs++; + var def = newMethod.apply(this, arguments); + var then = def.then(clean, clean); + then.abort = def.abort; + return then; + }); + } + }); + var hasCustomConverter = {}; + can.each(converters, function (converter, name) { + var parseName = 'parse' + can.capitalize(name), dataProperty = staticProps && staticProps[name] || self[name]; + if (typeof dataProperty === 'string') { + self[parseName] = dataProperty; + can.Construct._overwrite(self, base, name, converter); + } else if (staticProps && staticProps[name]) { + hasCustomConverter[parseName] = true; + } + }); + can.each(makeParser, function (maker, parseName) { + var prop = staticProps && staticProps[parseName] || self[parseName]; + if (typeof prop === 'string') { + can.Construct._overwrite(self, base, parseName, maker(prop)); + } else if ((!staticProps || !can.isFunction(staticProps[parseName])) && !self[parseName]) { + var madeParser = maker(); + madeParser.useModelConverter = hasCustomConverter[parseName]; + can.Construct._overwrite(self, base, parseName, madeParser); + } + }); + if (self.fullName === 'can.Model' || !self.fullName) { + self.fullName = 'Model' + ++modelNum; + } + can.Model._reqs = 0; + this._url = this._shortName + '/{' + this.id + '}'; + }, + _ajax: ajaxMaker, + _makeRequest: makeRequest, + _clean: function () { + can.Model._reqs--; + if (!can.Model._reqs) { + for (var id in this.store) { + if (!this.store[id]._bindings) { + delete this.store[id]; + } + } + } + return arguments[0]; + }, + models: converters.models, + model: converters.model + }, { + setup: function (attrs) { + var id = attrs && attrs[this.constructor.id]; + if (can.Model._reqs && id != null) { + this.constructor.store[id] = this; + } + can.Map.prototype.setup.apply(this, arguments); + }, + isNew: function () { + var id = getId(this); + return !(id || id === 0); + }, + save: function (success, error) { + return makeRequest(this, this.isNew() ? 'create' : 'update', success, error); + }, + destroy: function (success, error) { + if (this.isNew()) { + var self = this; + var def = can.Deferred(); + def.then(success, error); + return def.done(function (data) { + self.destroyed(data); + }).resolve(self); + } + return makeRequest(this, 'destroy', success, error, 'destroyed'); + }, + _bindsetup: function () { + var modelInstance = this.__get(this.constructor.id); + if (modelInstance != null) { + this.constructor.store[modelInstance] = this; + } + return can.Map.prototype._bindsetup.apply(this, arguments); + }, + _bindteardown: function () { + delete this.constructor.store[getId(this)]; + return can.Map.prototype._bindteardown.apply(this, arguments); + }, + ___set: function (prop, val) { + can.Map.prototype.___set.call(this, prop, val); + if (prop === this.constructor.id && this._bindings) { + this.constructor.store[getId(this)] = this; + } + } + }); + var makeGetterHandler = function (name) { + return function (data, readyState, xhr) { + return this[name](data, null, xhr); + }; + }, createUpdateDestroyHandler = function (data) { + if (this.parseModel.useModelConverter) { + return this.model(data); + } + return this.parseModel(data); + }; + var responseHandlers = { + makeFindAll: makeGetterHandler('models'), + makeFindOne: makeGetterHandler('model'), + makeCreate: createUpdateDestroyHandler, + makeUpdate: createUpdateDestroyHandler, + makeDestroy: createUpdateDestroyHandler + }; + can.each(responseHandlers, function (method, name) { + can.Model[name] = function (oldMethod) { + return function () { + var args = can.makeArray(arguments), oldArgs = can.isFunction(args[1]) ? args.splice(0, 1) : args.splice(0, 2), def = pipe(oldMethod.apply(this, oldArgs), this, method); + def.then(args[0], args[1]); + return def; + }; + }; + }); + can.each([ + 'created', + 'updated', + 'destroyed' + ], function (funcName) { + can.Model.prototype[funcName] = function (attrs) { + var self = this, constructor = self.constructor; + if (attrs && typeof attrs === 'object') { + this.attr(can.isFunction(attrs.attr) ? attrs.attr() : attrs); + } + can.dispatch.call(this, { + type: 'change', + target: this + }, [funcName]); + can.dispatch.call(constructor, funcName, [this]); + }; + }); + var ML = can.Model.List = can.List.extend({ + _bubbleRule: function (eventName, list) { + var bubbleRules = can.List._bubbleRule(eventName, list); + bubbleRules.push('destroyed'); + return bubbleRules; + } + }, { + setup: function (params) { + if (can.isPlainObject(params) && !can.isArray(params)) { + can.List.prototype.setup.apply(this); + this.replace(can.isDeferred(params) ? params : this.constructor.Map.findAll(params)); + } else { + can.List.prototype.setup.apply(this, arguments); + } + this._init = 1; + this.bind('destroyed', can.proxy(this._destroyed, this)); + delete this._init; + }, + _destroyed: function (ev, attr) { + if (/\w+/.test(attr)) { + var index; + while ((index = this.indexOf(ev.target)) > -1) { + this.splice(index, 1); + } + } + } + }); + return can.Model; +}); +/*can@2.2.6#util/string/deparam/deparam*/ +define('can/util/string/deparam/deparam', [ + 'can/util/util', + 'can/util/string/string' +], function (can) { + var digitTest = /^\d+$/, keyBreaker = /([^\[\]]+)|(\[\])/g, paramTest = /([^?#]*)(#.*)?$/, prep = function (str) { + return decodeURIComponent(str.replace(/\+/g, ' ')); + }; + can.extend(can, { + deparam: function (params) { + var data = {}, pairs, lastPart; + if (params && paramTest.test(params)) { + pairs = params.split('&'); + can.each(pairs, function (pair) { + var parts = pair.split('='), key = prep(parts.shift()), value = prep(parts.join('=')), current = data; + if (key) { + parts = key.match(keyBreaker); + for (var j = 0, l = parts.length - 1; j < l; j++) { + if (!current[parts[j]]) { + current[parts[j]] = digitTest.test(parts[j + 1]) || parts[j + 1] === '[]' ? [] : {}; + } + current = current[parts[j]]; + } + lastPart = parts.pop(); + if (lastPart === '[]') { + current.push(value); + } else { + current[lastPart] = value; + } + } + }); + } + return data; + } + }); + return can; +}); +/*can@2.2.6#route/route*/ +define('can/route/route', [ + 'can/util/util', + 'can/map/map', + 'can/list/list', + 'can/util/string/deparam/deparam' +], function (can) { + var matcher = /\:([\w\.]+)/g, paramsMatcher = /^(?:&[^=]+=[^&]*)+/, makeProps = function (props) { + var tags = []; + can.each(props, function (val, name) { + tags.push((name === 'className' ? 'class' : name) + '="' + (name === 'href' ? val : can.esc(val)) + '"'); + }); + return tags.join(' '); + }, matchesData = function (route, data) { + var count = 0, i = 0, defaults = {}; + for (var name in route.defaults) { + if (route.defaults[name] === data[name]) { + defaults[name] = 1; + count++; + } + } + for (; i < route.names.length; i++) { + if (!data.hasOwnProperty(route.names[i])) { + return -1; + } + if (!defaults[route.names[i]]) { + count++; + } + } + return count; + }, location = window.location, wrapQuote = function (str) { + return (str + '').replace(/([.?*+\^$\[\]\\(){}|\-])/g, '\\$1'); + }, each = can.each, extend = can.extend, stringify = function (obj) { + if (obj && typeof obj === 'object') { + if (obj instanceof can.Map) { + obj = obj.attr(); + } else { + obj = can.isFunction(obj.slice) ? obj.slice() : can.extend({}, obj); + } + can.each(obj, function (val, prop) { + obj[prop] = stringify(val); + }); + } else if (obj !== undefined && obj !== null && can.isFunction(obj.toString)) { + obj = obj.toString(); + } + return obj; + }, removeBackslash = function (str) { + return str.replace(/\\/g, ''); + }, timer, curParams, lastHash, changingData, changedAttrs = [], onRouteDataChange = function (ev, attr, how, newval) { + changingData = 1; + changedAttrs.push(attr); + clearTimeout(timer); + timer = setTimeout(function () { + changingData = 0; + var serialized = can.route.data.serialize(), path = can.route.param(serialized, true); + can.route._call('setURL', path, changedAttrs); + can.batch.trigger(eventsObject, '__url', [ + path, + lastHash + ]); + lastHash = path; + changedAttrs = []; + }, 10); + }, eventsObject = can.extend({}, can.event); + can.route = function (url, defaults) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + defaults = defaults || {}; + var names = [], res, test = '', lastIndex = matcher.lastIndex = 0, next, querySeparator = can.route._call('querySeparator'), matchSlashes = can.route._call('matchSlashes'); + while (res = matcher.exec(url)) { + names.push(res[1]); + test += removeBackslash(url.substring(lastIndex, matcher.lastIndex - res[0].length)); + next = '\\' + (removeBackslash(url.substr(matcher.lastIndex, 1)) || querySeparator + (matchSlashes ? '' : '|/')); + test += '([^' + next + ']' + (defaults[res[1]] ? '*' : '+') + ')'; + lastIndex = matcher.lastIndex; + } + test += url.substr(lastIndex).replace('\\', ''); + can.route.routes[url] = { + test: new RegExp('^' + test + '($|' + wrapQuote(querySeparator) + ')'), + route: url, + names: names, + defaults: defaults, + length: url.split('/').length + }; + return can.route; + }; + extend(can.route, { + param: function (data, _setRoute) { + var route, matches = 0, matchCount, routeName = data.route, propCount = 0; + delete data.route; + each(data, function () { + propCount++; + }); + each(can.route.routes, function (temp, name) { + matchCount = matchesData(temp, data); + if (matchCount > matches) { + route = temp; + matches = matchCount; + } + if (matchCount >= propCount) { + return false; + } + }); + if (can.route.routes[routeName] && matchesData(can.route.routes[routeName], data) === matches) { + route = can.route.routes[routeName]; + } + if (route) { + var cpy = extend({}, data), res = route.route.replace(matcher, function (whole, name) { + delete cpy[name]; + return data[name] === route.defaults[name] ? '' : encodeURIComponent(data[name]); + }).replace('\\', ''), after; + each(route.defaults, function (val, name) { + if (cpy[name] === val) { + delete cpy[name]; + } + }); + after = can.param(cpy); + if (_setRoute) { + can.route.attr('route', route.route); + } + return res + (after ? can.route._call('querySeparator') + after : ''); + } + return can.isEmptyObject(data) ? '' : can.route._call('querySeparator') + can.param(data); + }, + deparam: function (url) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + var route = { length: -1 }, querySeparator = can.route._call('querySeparator'), paramsMatcher = can.route._call('paramsMatcher'); + each(can.route.routes, function (temp, name) { + if (temp.test.test(url) && temp.length > route.length) { + route = temp; + } + }); + if (route.length > -1) { + var parts = url.match(route.test), start = parts.shift(), remainder = url.substr(start.length - (parts[parts.length - 1] === querySeparator ? 1 : 0)), obj = remainder && paramsMatcher.test(remainder) ? can.deparam(remainder.slice(1)) : {}; + obj = extend(true, {}, route.defaults, obj); + each(parts, function (part, i) { + if (part && part !== querySeparator) { + obj[route.names[i]] = decodeURIComponent(part); + } + }); + obj.route = route.route; + return obj; + } + if (url.charAt(0) !== querySeparator) { + url = querySeparator + url; + } + return paramsMatcher.test(url) ? can.deparam(url.slice(1)) : {}; + }, + data: new can.Map({}), + map: function (data) { + var appState; + if (data.prototype instanceof can.Map) { + appState = new data(); + } else { + appState = data; + } + can.route.data = appState; + }, + routes: {}, + ready: function (val) { + if (val !== true) { + can.route._setup(); + can.route.setState(); + } + return can.route; + }, + url: function (options, merge) { + if (merge) { + options = can.extend({}, can.route.deparam(can.route._call('matchingPartOfURL')), options); + } + return can.route._call('root') + can.route.param(options); + }, + link: function (name, options, props, merge) { + return '' + name + ''; + }, + current: function (options) { + can.__observe(eventsObject, '__url'); + return this._call('matchingPartOfURL') === can.route.param(options); + }, + bindings: { + hashchange: { + paramsMatcher: paramsMatcher, + querySeparator: '&', + matchSlashes: false, + bind: function () { + can.bind.call(window, 'hashchange', setState); + }, + unbind: function () { + can.unbind.call(window, 'hashchange', setState); + }, + matchingPartOfURL: function () { + return location.href.split(/#!?/)[1] || ''; + }, + setURL: function (path) { + if (location.hash !== '#' + path) { + location.hash = '!' + path; + } + return path; + }, + root: '#!' + } + }, + defaultBinding: 'hashchange', + currentBinding: null, + _setup: function () { + if (!can.route.currentBinding) { + can.route._call('bind'); + can.route.bind('change', onRouteDataChange); + can.route.currentBinding = can.route.defaultBinding; + } + }, + _teardown: function () { + if (can.route.currentBinding) { + can.route._call('unbind'); + can.route.unbind('change', onRouteDataChange); + can.route.currentBinding = null; + } + clearTimeout(timer); + changingData = 0; + }, + _call: function () { + var args = can.makeArray(arguments), prop = args.shift(), binding = can.route.bindings[can.route.currentBinding || can.route.defaultBinding], method = binding[prop]; + if (method.apply) { + return method.apply(binding, args); + } else { + return method; + } + } + }); + each([ + 'bind', + 'unbind', + 'on', + 'off', + 'delegate', + 'undelegate', + 'removeAttr', + 'compute', + '_get', + '__get', + 'each' + ], function (name) { + can.route[name] = function () { + if (!can.route.data[name]) { + return; + } + return can.route.data[name].apply(can.route.data, arguments); + }; + }); + can.route.attr = function (attr, val) { + var type = typeof attr, newArguments; + if (val === undefined) { + newArguments = arguments; + } else if (type !== 'string' && type !== 'number') { + newArguments = [ + stringify(attr), + val + ]; + } else { + newArguments = [ + attr, + stringify(val) + ]; + } + return can.route.data.attr.apply(can.route.data, newArguments); + }; + var setState = can.route.setState = function () { + var hash = can.route._call('matchingPartOfURL'); + var oldParams = curParams; + curParams = can.route.deparam(hash); + if (!changingData || hash !== lastHash) { + can.batch.start(); + recursiveClean(oldParams, curParams, can.route.data); + can.route.attr(curParams); + can.batch.trigger(eventsObject, '__url', [ + hash, + lastHash + ]); + can.batch.stop(); + } + }; + var recursiveClean = function (old, cur, data) { + for (var attr in old) { + if (cur[attr] === undefined) { + data.removeAttr(attr); + } else if (Object.prototype.toString.call(old[attr]) === '[object Object]') { + recursiveClean(old[attr], cur[attr], data.attr(attr)); + } + } + }; + return can.route; +}); +/*can@2.2.6#control/route/route*/ +define('can/control/route/route', [ + 'can/util/util', + 'can/route/route', + 'can/control/control' +], function (can) { + can.Control.processors.route = function (el, event, selector, funcName, controller) { + selector = selector || ''; + if (!can.route.routes[selector]) { + if (selector[0] === '/') { + selector = selector.substring(1); + } + can.route(selector); + } + var batchNum, check = function (ev, attr, how) { + if (can.route.attr('route') === selector && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + batchNum = ev.batchNum; + var d = can.route.attr(); + delete d.route; + if (can.isFunction(controller[funcName])) { + controller[funcName](d); + } else { + controller[controller[funcName]](d); + } + } + }; + can.route.bind('change', check); + return function () { + can.route.unbind('change', check); + }; + }; + return can; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.dojo.min.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.dojo.min.js new file mode 100644 index 0000000000..7ab700ff9a --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.dojo.min.js @@ -0,0 +1,98 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +!function(exports,global){var origDefine=global.define,get=function(e){var o,l=e.split("."),n=global;for(o=0;o=0&&(e.defaultChecked=!0)):l?(i=a,e[l]!==a&&(e[l]=a),"value"===l&&t.inArray(o,r.defaultValue)>=0&&(e.defaultValue=a)):(e.setAttribute(n,a),i=a),r.MutationObserver||i===u||r.trigger(e,n,u)},trigger:function(r,n,a){return t.data(t.$(r),"canHasAttributesBindings")?(n=n.toLowerCase(),e(function(){t.trigger(r,{type:"attributes",attributeName:n,target:r,oldValue:a,bubbles:!1},[])})):void 0},get:function(t,e){e=e.toLowerCase();var n=r.map[e];return"string"==typeof n&&t[n]?t[n]:t.getAttribute(e)},remove:function(t,e){e=e.toLowerCase();var n;r.MutationObserver||(n=r.get(t,e));var a=r.map[e];"function"==typeof a&&a(t,void 0),a===!0?t[e]=!1:"string"==typeof a?t[a]="":t.removeAttribute(e),r.MutationObserver||null==n||r.trigger(t,e,n)},has:function(){var e=t.global.document&&document.createElement("div");return e&&e.hasAttribute?function(t,e){return t.hasAttribute(e)}:function(t,e){return null!==t.getAttribute(e)}}()};return r}); +/*can@2.2.6#event/event*/ +define("can/event/event",["can/util/can"],function(t){return t.addEvent=function(t,n){var e=this.__bindEvents||(this.__bindEvents={}),i=e[t]||(e[t]=[]);return i.push({handler:n,name:t}),this},t.listenTo=function(n,e,i){var r=this.__listenToEvents;r||(r=this.__listenToEvents={});var s=t.cid(n),o=r[s];o||(o=r[s]={obj:n,events:{}});var a=o.events[e];a||(a=o.events[e]=[]),a.push(i),t.bind.call(n,e,i)},t.stopListening=function(n,e,i){var r=this.__listenToEvents,s=r,o=0;if(!r)return this;if(n){var a=t.cid(n);if((s={})[a]=r[a],!r[a])return this}for(var v in s){var l,h=s[v];n=r[v].obj,e?(l={})[e]=h.events[e]:l=h.events;for(var u in l){var d=l[u]||[];for(o=0;oo;o++)r[o].handler.apply(this,s);return t}},t.one=function(n,e){var i=function(){return t.unbind.call(this,n,i),e.apply(this,arguments)};return t.bind.call(this,n,i),this},t.event={on:function(){return 0===arguments.length&&t.Control&&this instanceof t.Control?t.Control.prototype.on.call(this):t.addEvent.apply(this,arguments)},off:function(){return 0===arguments.length&&t.Control&&this instanceof t.Control?t.Control.prototype.off.call(this):t.removeEvent.apply(this,arguments)},bind:t.addEvent,unbind:t.removeEvent,delegate:function(n,e,i){return t.addEvent.call(this,e,i)},undelegate:function(n,e,i){return t.removeEvent.call(this,e,i)},trigger:t.dispatch,one:t.one,addEvent:t.addEvent,removeEvent:t.removeEvent,listenTo:t.listenTo,stopListening:t.stopListening,dispatch:t.dispatch},t.event}); +/*can@2.2.6#util/fragment*/ +define("can/util/fragment",["can/util/can"],function(e){var t=/^\s*<(\w+)[^>]*>/,n={}.toString,i=function(e,i){void 0===i&&(i=t.test(e)&&RegExp.$1),e&&"[object Function]"===n.call(e.replace)&&(e=e.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,"<$1>"));var l=document.createElement("div"),d=document.createElement("div");"tbody"===i||"tfoot"===i||"thead"===i?(d.innerHTML=""+e+"
            ",l=3===d.firstChild.nodeType?d.lastChild:d.firstChild):"tr"===i?(d.innerHTML=""+e+"
            ",l=3===d.firstChild.nodeType?d.lastChild:d.firstChild.firstChild):"td"===i||"th"===i?(d.innerHTML=""+e+"
            ",l=3===d.firstChild.nodeType?d.lastChild:d.firstChild.firstChild.firstChild):"option"===i?(d.innerHTML="",l=3===d.firstChild.nodeType?d.lastChild:d.firstChild):l.innerHTML=""+e;var r={},a=l.childNodes;r.length=a.length;for(var o=0;od;d++)l.appendChild(n[d]);return l},function(){var t="<-\n>",n=e.buildFragment(t,document);if(t!==n.childNodes[0].nodeValue){var i=e.buildFragment;e.buildFragment=function(e,t){var n=i(e,t);return 1===n.childNodes.length&&3===n.childNodes[0].nodeType&&(n.childNodes[0].nodeValue=e),n}}}(),e}); +/*can@2.2.6#util/array/each*/ +define("can/util/array/each",["can/util/can"],function(t){var e=function(t){var e="length"in t&&t.length;return"function"!=typeof arr&&(0===e||"number"==typeof e&&e>0&&e-1 in t)};return t.each=function(n,a,r){var f,i,l,c=0;if(n)if(e(n))if(t.List&&n instanceof t.List)for(i=n.attr("length");i>c&&(l=n.attr(c),a.call(r||l,l,c,n)!==!1);c++);else for(i=n.length;i>c&&(l=n[c],a.call(r||l,l,c,n)!==!1);c++);else if("object"==typeof n)if(t.Map&&n instanceof t.Map||n===t.route){var o=t.Map.keys(n);for(c=0,i=o.length;i>c&&(f=o[c],l=n.attr(f),a.call(r||l,l,f,n)!==!1);c++);}else for(f in n)if(n.hasOwnProperty(f)&&a.call(r||n[f],n[f],f,n)===!1)break;return n},t}); +/*can@2.2.6#util/object/isplain/isplain*/ +define("can/util/object/isplain/isplain",["can/util/can"],function(){var t=Object.prototype.hasOwnProperty,n=function(t){return null!==t&&t==t.window},r=function(r){if(!r||"object"!=typeof r||r.nodeType||n(r))return!1;try{if(r.constructor&&!t.call(r,"constructor")&&!t.call(r.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var o;for(o in r);return void 0===o||t.call(r,o)};return can.isPlainObject=r,can}); +/*can@2.2.6#util/deferred*/ +define("can/util/deferred",["can/util/can"],function(t){var e=function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},n=function(t){return this instanceof n?(this._doneFuncs=[],this._failFuncs=[],this._resultArgs=null,this._status="",void(t&&t.call(this,this))):new n};t.Deferred=n,t.when=n.when=function(){var e=t.makeArray(arguments);if(e.length<2){var r=e[0];return r&&t.isFunction(r.isResolved)&&t.isFunction(r.isRejected)?r:n().resolve(r)}var s=n(),i=0,u=[];return t.each(e,function(t,n){t.done(function(){u[n]=arguments.length<2?arguments[0]:arguments,++i===e.length&&s.resolve.apply(s,u)}).fail(function(){s.reject(1===arguments.length?arguments[0]:arguments)})}),s};var r=function(t,e){return function(n){var r=this._resultArgs=arguments.length>1?arguments[1]:[];return this.exec(n,this[t],r,e)}},s=function a(e,n){return function(){var r=this;return t.each(Array.prototype.slice.call(arguments),function(t,s,i){t&&(t.constructor===Array?a.apply(r,t):(r._status===n&&t.apply(r,r._resultArgs||[]),r[e].push(t)))}),this}},i=function(t){return t&&t.then&&t.fail&&t.done},u=function(e,n,r,s){i(n)?n.done(t.proxy(e.resolve,e)).fail(t.proxy(e.reject,e)):r.call(e,void 0!==n?n:s)};return e(n.prototype,{then:function(e,n){var r=t.Deferred(),s=r.resolve,i=r.reject;return this.done(function(t){"function"==typeof e?u(r,e.apply(this,arguments),s,t):s.apply(r,arguments)}),this.fail(function(t){"function"==typeof n?u(r,n.apply(this,arguments),i,t):i.apply(r,arguments)}),r},resolveWith:r("_doneFuncs","rs"),rejectWith:r("_failFuncs","rj"),done:s("_doneFuncs","rs"),fail:s("_failFuncs","rj"),always:function(){var e=t.makeArray(arguments);return e.length&&e[0]&&this.done(e[0]).fail(e[0]),this},state:function(){switch(this._status){case"rs":return"resolved";case"rj":return"rejected";default:return"pending"}},isResolved:function(){return"rs"===this._status},isRejected:function(){return"rj"===this._status},reject:function(){return this.rejectWith(this,arguments)},resolve:function(){return this.resolveWith(this,arguments)},exec:function(e,n,r,s){return""!==this._status?this:(this._status=s,t.each(n,function(t){"function"==typeof t.apply&&t.apply(e,r)}),this)},promise:function(){var t=this.then();return t.reject=t.resolve=void 0,t}}),n.prototype.pipe=n.prototype.then,t}); +/*can@2.2.6#util/hashchange*/ +define("can/util/hashchange",["can/util/can"],function(n){!function(){var t=function(n,t,a){n.addEventListener?n.addEventListener(t,a,!1):n.attachEvent?n.attachEvent("on"+t,a):n["on"+t]=a},a=function(){n.trigger(window,"hashchange")};t(window,"hashchange",a)}()}); +/*can@2.2.6#util/inserted/inserted*/ +define("can/util/inserted/inserted",["can/util/can"],function(e){e.inserted=function(n){n=e.makeArray(n);for(var r,i,t=!1,a=e.$(document.contains?document:document.body),d=0;void 0!==(i=n[d]);d++){if(!t){if(!i.getElementsByTagName)continue;if(!e.has(a,i).length)return;t=!0}if(t&&i.getElementsByTagName){r=e.makeArray(i.getElementsByTagName("*")),e.trigger(i,"inserted",[],!1);for(var o,s=0;void 0!==(o=r[s]);s++)e.trigger(o,"inserted",[],!1)}}},e.appendChild=function(n,r){var i;i=11===r.nodeType?e.makeArray(r.childNodes):[r],n.appendChild(r),e.inserted(i)},e.insertBefore=function(n,r,i){var t;t=11===r.nodeType?e.makeArray(r.childNodes):[r],n.insertBefore(r,i),e.inserted(t)}}); +/*can@2.2.6#util/util*/ +"format steal";define("can/util/util",["can/util/can","can/util/attr/attr","can/dojo/dojo","can/event/event","can/util/fragment","can/util/array/each","can/util/object/isplain/isplain","can/util/deferred","can/util/hashchange","can/util/inserted/inserted"],function(t,e,n){function r(t,e){var n=t[l],r=n&&c[n];return void 0===e?r||i(t):r&&r[e]}function i(t,e,n){var r=t[l]||(t[l]=++f),i=c[r]||(c[r]={});return void 0!==e&&(i[e]=n),i}var a=n||window.dojo;define("plugd/trigger",["dojo/main"],function(){var t,e=a,n=e.isFunction,r=/mouse(enter|leave)/,i=function(t,e){return"mouse"+("enter"===e?"over":"out")},o=e._mixin;return t=e.doc.createEvent?function(t,n,a){var s=e.doc.createEvent("HTMLEvents");n=n.replace(r,i),s.initEvent(n,"removed"===n||"inserted"===n?!1:!0,!0),a&&o(s,a),t.dispatchEvent(s)}:function(t,r,i){var a="on"+r,s=!1;try{var u=document.createEventObject();("inserted"===r||"removed"===r)&&(u.cancelBubble=!0),o(u,i),t.fireEvent(a,u)}catch(d){var c=o({type:r,target:t,faux:!0,_stopper:function(){s=this.cancelBubble}},i);if(n(t[a])&&t[a](c),"inserted"===r||"removed"===r)return;for(;!s&&t!==e.doc&&t.parentNode;)t=t.parentNode,n(t[a])&&t[a](c)}},e._trigger=function(n,r,i){"string"!=typeof r&&(i=r,r=i.type,delete i.type);var a=e.byId(n),o=r&&"on"===r.slice(0,2)?r.slice(2):r;t(a,o,i)},e.trigger=function(t,r,i){return n(t)||n(r)||n(t[r])?e.hitch.apply(e,arguments)():e._trigger.apply(e,arguments)},e.NodeList.prototype.trigger=e.NodeList._adaptAsForEach(e._trigger),e._Node&&!e._Node.prototype.trigger&&e.extend(e._Node,{trigger:function(t,n){return e._trigger(this,t,n),this}}),e.trigger}),require(["dojo/main","dojo/query","plugd/trigger","dojo/NodeList-dom"]),t.trim=function(t){return t&&a.trim(t)},t.makeArray=function(t){var e=[];return a.forEach(t,function(t){e.push(t)}),e},t.isArray=a.isArray,t.inArray=function(t,e,n){return a.indexOf(e,t,n)},t.map=function(e,n){return a.map(t.makeArray(e||[]),n)},t.extend=function(e){if(e===!0){var n=t.makeArray(arguments);return n.shift(),a.mixin.apply(a,n)}return a.mixin.apply(a,arguments)},t.isEmptyObject=function(t){var e;for(e in t)break;return void 0===e},t.param=function(e){var n=[],r=function(t,e){n.push(encodeURIComponent(t)+"="+encodeURIComponent(e))};for(var i in e)t.buildParam(i,e[i],r);return n.join("&").replace(/%20/g,"+")},t.buildParam=function(e,n,r){if(t.isArray(n))for(var i=0,o=n.length;o>i;++i)r(e+"[]",n[i]);else if(a.isObject(n))for(var s in n)t.buildParam(e+"["+s+"]",n[s],r);else r(e,n)},t.proxy=function(t,e){return a.hitch(e,t)},t.isFunction=function(t){return a.isFunction(t)};var o=0,s=function(e,n,r){e.forEach(function(e){e=new a.NodeList("SELECT"===e.nodeName?[e]:e);var i=t.data(e,"events");i||t.data(e,"events",i={}),i[n]||(i[n]={}),void 0===r.__bindingsIds&&(r.__bindingsIds=o++),i[n][r.__bindingsIds]=e.on(n,r)[0]})},u=function(e,n,r){e.forEach(function(e){var i=new a.NodeList(e),o=t.data(i,"events");if(o){var s=o[n];if(s){var u=s[r.__bindingsIds];a.disconnect(u),delete s[r.__bindingsIds],t.isEmptyObject(s)&&delete o[n]}}})};t.bind=function(e,n){return this.bind&&this.bind!==t.bind?this.bind(e,n):this.on||this.nodeType?s(new a.NodeList("SELECT"===this.nodeName?[this]:this),e,n):this.addEvent?this.addEvent(e,n):t.addEvent.call(this,e,n),this},t.unbind=function(e,n){return this.unbind&&this.unbind!==t.unbind?this.unbind(e,n):this.on||this.nodeType?u(new a.NodeList(this),e,n):t.removeEvent.call(this,e,n),this},t.on=t.bind,t.off=t.unbind,t.trigger=function(e,n,r,i){if(e instanceof a.NodeList||!e.nodeName&&e!==window||(e=t.$(e)),e.trigger)if(i===!1){if(!e[0]||3===e[0].nodeType)return;var o=e.on(n,function(t){t.stopPropagation&&t.stopPropagation(),t.cancelBubble=!0,t._stopper&&t._stopper(),a.disconnect(o)});e.trigger(n,r)}else e.trigger(n,r);else"string"==typeof n&&(n={type:n}),n.target=n.target||e,t.dispatch.call(e,n,t.makeArray(r))},t.delegate=function(e,n,r){return e?this.on||this.nodeType?s(new a.NodeList(this),e+":"+n,r):this.delegate?this.delegate(e,n,r):t.bind.call(this,n,r):t.bind.call(this,n,r),this},t.undelegate=function(e,n,r){return e?this.on||this.nodeType?u(new a.NodeList(this),e+":"+n,r):this.undelegate?this.undelegate(e,n,r):t.unbind.call(this,n,r):t.unbind.call(this,n,r),this};var d=function(t,e){for(var n in t)"function"==typeof e[n]?e[n]=function(){t[n].apply(t,arguments)}:e[n]=n[t]};t.ajax=function(e){var n=t.capitalize((e.type||"get").toLowerCase()),r=a["xhr"+n],i=e.success,o=e.error,s=new t.Deferred,u=r({url:e.url,handleAs:e.dataType,sync:!e.async,headers:e.headers,content:e.data});u.then(function(t,e){d(c,s),s.resolve(t,"success",c),i&&i(t,"success",c)},function(t,e){d(c,s),s.reject(c,"error"),o(c,"error")});var c=u.ioArgs.xhr;return d(c,s),s},t.$=function(t){return t===window?window:"string"==typeof t?a.query(t):new a.NodeList(t&&t.nodeName?[t]:t)},t.append=function(t,e){return t.forEach(function(t){a.place(e,t)})};var c={},f=t.uuid=+new Date,l=t.expando="can"+f,p=function(e){for(var n=[],r=0,i=e.length;i>r;r++)1===e[r].nodeType&&n.push(e[r]);t.trigger(new a.NodeList(n),"removed",[],!1),r=0;for(var o;void 0!==(o=e[r]);r++){var s=o[l];delete c[s]}};t.data=function(t,e,n){return void 0===n?0===t.length?void 0:r(t[0],e):t.forEach(function(t){i(t,e,n)})},t.cleanData=function(t,e){var n=t[l];delete c[n][e]},a.empty=function(t){for(var e;e=t.lastChild;)a.destroy(e)};var g=a.destroy;a.destroy=function(e){e=a.byId(e);var n=[e];return e.getElementsByTagName&&n.concat(t.makeArray(e.getElementsByTagName("*"))),p(n),g.apply(a,arguments)};var h=a.place;a.place=function(e,n,r){"string"==typeof e&&/^\s*=a?t.cleanData(r[n],"canHasAttributesBindings"):t.data(e,"canHasAttributesBindings",a-1),i.call(this,arguments)}})}return n};var m=a.setAttr;a.setAttr=function(e,n,r){var i=a.getAttr(e,n),o=m.apply(this,arguments),s=a.getAttr(e,n);return s!==i&&t.attr.trigger(e,n,i),o};var y=a.removeAttr;return a.removeAttr=function(e,n){var r=a.getAttr(e,n),i=y.apply(this,arguments);return null!=r&&t.attr.trigger(e,n,r),i},t}); +/*can@2.2.6#view/view*/ +define("can/view/view",["can/util/util"],function(e){var r=e.isFunction,n=e.makeArray,t=1,i=function(e){var r=function(){return c.frag(e.apply(this,arguments))};return r.render=function(){return e.apply(e,arguments)},r},u=function(e,r){if(!e.length)throw"can.view: No template or empty template:"+r},a=function(n,t){if(r(n)){var i=e.Deferred();return i.resolve(n)}var a,o,d,f="string"==typeof n?n:n.url,s=n.engine&&"."+n.engine||f.match(/\.[\w\d]+$/);if(f.match(/^#/)&&(f=f.substr(1)),(o=document.getElementById(f))&&(s="."+o.type.match(/\/(x\-)?(.+)/)[2]),s||c.cached[f]||(f+=s=c.ext),e.isArray(s)&&(s=s[0]),d=c.toId(f),f.match(/^\/\//)&&(f=f.substr(2),f=window.steal?steal.config().root.mapJoin(""+steal.id(f)):f),window.require&&require.toUrl&&(f=require.toUrl(f)),a=c.types[s],c.cached[d])return c.cached[d];if(o)return c.registerView(d,o.innerHTML,a);var p=new e.Deferred;return e.ajax({async:t,url:f,dataType:"text",error:function(e){u("",f),p.reject(e)},success:function(e){u(e,f),c.registerView(d,e,a,p)}}),p},o=function(r){var n=[];if(e.isDeferred(r))return[r];for(var t in r)e.isDeferred(r[t])&&n.push(r[t]);return n},d=function(r){return e.isArray(r)&&"success"===r[1]?r[0]:r},c=e.view=e.template=function(e,n,t,i){return r(t)&&(i=t,t=void 0),c.renderAs("fragment",e,n,t,i)};return e.extend(c,{frag:function(e,r){return c.hookup(c.fragment(e),r)},fragment:function(r){if("string"!=typeof r&&11===r.nodeType)return r;var n=e.buildFragment(r,document.body);return n.childNodes.length||n.appendChild(document.createTextNode("")),n},toId:function(r){return e.map(r.toString().split(/\/|\./g),function(e){return e?e:void 0}).join("_")},toStr:function(e){return null==e?"":""+e},hookup:function(r,n){var t,i,u=[];return e.each(r.childNodes?e.makeArray(r.childNodes):r,function(r){1===r.nodeType&&(u.push(r),u.push.apply(u,e.makeArray(r.getElementsByTagName("*"))))}),e.each(u,function(e){e.getAttribute&&(t=e.getAttribute("data-view-id"))&&(i=c.hookups[t])&&(i(e,n,t),delete c.hookups[t],e.removeAttribute("data-view-id"))}),r},hookups:{},hook:function(e){return c.hookups[++t]=e," data-view-id='"+t+"'"},cached:{},cachedRenderers:{},cache:!0,register:function(r){this.types["."+r.suffix]=r,e[r.suffix]=c[r.suffix]=function(e,n){var t,u;if(!n)return u=function(){return t||(t=r.fragRenderer?r.fragRenderer(null,e):i(r.renderer(null,e))),t.apply(this,arguments)},u.render=function(){var n=r.renderer(null,e);return n.apply(n,arguments)},u;var a=function(){return t||(t=r.fragRenderer?r.fragRenderer(e,n):r.renderer(e,n)),t.apply(this,arguments)};return r.fragRenderer?c.preload(e,a):c.preloadStringRenderer(e,a)}},types:{},ext:".ejs",registerScript:function(e,r,n){return"can.view.preloadStringRenderer('"+r+"',"+c.types["."+e].script(r,n)+");"},preload:function(r,n){var t=c.cached[r]=(new e.Deferred).resolve(function(e,r){return n.call(e,e,r)});return t.__view_id=r,c.cachedRenderers[r]=n,n},preloadStringRenderer:function(e,r){return this.preload(e,i(r))},render:function(r,n,t,i){return e.view.renderAs("string",r,n,t,i)},renderTo:function(e,r,n,t){return("string"===e&&r.render?r.render:r)(n,t)},renderAs:function(t,i,u,f,s){r(f)&&(s=f,f=void 0);var p,l,g,h,v,m=o(u);if(m.length)return l=new e.Deferred,g=e.extend({},u),m.push(a(i,!0)),e.when.apply(e,m).then(function(r){var i,a=n(arguments),o=a.pop();if(e.isDeferred(u))g=d(r);else for(var c in u)e.isDeferred(u[c])&&(g[c]=d(a.shift()));i=e.view.renderTo(t,o,g,f),l.resolve(i,g),s&&s(i,g)},function(){l.reject.apply(l,arguments)}),l;if(p=e.__clearReading(),h=r(s),l=a(i,h),p&&e.__setReading(p),h)v=l,l.then(function(r){s(u?e.view.renderTo(t,r,u,f):r)});else{if("resolved"===l.state()&&l.__view_id){var w=c.cachedRenderers[l.__view_id];return u?e.view.renderTo(t,w,u,f):w}l.then(function(r){v=u?e.view.renderTo(t,r,u,f):r})}return v},registerView:function(r,n,t,u){var a,o="object"==typeof t?t:c.types[t||c.ext];return a=o.fragRenderer?o.fragRenderer(r,n):i(o.renderer(r,n)),u=u||new e.Deferred,c.cache&&(c.cached[r]=u,u.__view_id=r,c.cachedRenderers[r]=a),u.resolve(a)}}),e}); +/*can@2.2.6#view/callbacks/callbacks*/ +define("can/view/callbacks/callbacks",["can/util/util","can/view/view"],function(t){var a=t.view.attr=function(t,a){if(!a){var r=e[t];if(!r)for(var n=0,l=i.length;l>n;n++){var s=i[n];if(s.match.test(t)){r=s.handler;break}}return r}"string"==typeof t?e[t]=a:i.push({match:t,handler:a})},e={},i=[],r=/[-\:]/,n=t.view.tag=function(a,e){if(!e){var i=l[a.toLowerCase()];return!i&&r.test(a)&&(i=function(){}),i}t.global.html5&&(t.global.html5.elements+=" "+a,t.global.html5.shivDocument()),l[a.toLowerCase()]=e},l={};return t.view.callbacks={_tags:l,_attributes:e,_regExpAttributes:i,tag:n,attr:a,tagHandler:function(a,e,i){var r,n=i.options.attr("tags."+e),s=n||l[e],c=i.scope;if(s){var o=t.__clearReading();r=s(a,i),t.__setReading(o)}else r=c;if(r&&i.subtemplate){c!==r&&(c=c.add(r));var v=i.subtemplate(c,i.options),f="string"==typeof v?t.view.frag(v):v;t.appendChild(a,f)}}},t.view.callbacks}); +/*can@2.2.6#view/elements*/ +define("can/view/elements",["can/util/util","can/view/view"],function(t){var e="undefined"!=typeof document?document:null,n=e&&function(){return 1===t.$(document.createComment("~")).length}(),o={tagToContentPropMap:{option:e&&"textContent"in document.createElement("option")?"textContent":"innerText",textarea:"value"},attrMap:t.attr.map,attrReg:/([^\s=]+)[\s]*=[\s]*/,defaultValue:t.attr.defaultValue,tagMap:{"":"span",colgroup:"col",table:"tbody",tr:"td",ol:"li",ul:"li",tbody:"tr",thead:"tr",tfoot:"tr",select:"option",optgroup:"option"},reverseTagMap:{col:"colgroup",tr:"tbody",option:"select",td:"tr",th:"tr",li:"ul"},getParentNode:function(t,e){return e&&11===t.parentNode.nodeType?e:t.parentNode},setAttr:t.attr.set,getAttr:t.attr.get,removeAttr:t.attr.remove,contentText:function(t){return"string"==typeof t?t:t||0===t?""+t:""},after:function(e,n){var o=e[e.length-1];o.nextSibling?t.insertBefore(o.parentNode,n,o.nextSibling):t.appendChild(o.parentNode,n)},replace:function(e,r){o.after(e,r),t.remove(t.$(e)).length/g,">").replace(c,""").replace(o,"'")},getObject:function(r,n,t){var a,u,i,c,o=r?r.split("."):[],l=o.length,p=0;if(n=e.isArray(n)?n:[n||window],c=n.length,!l)return n[0];for(p;c>p;p++){for(a=n[p],i=void 0,u=0;l>u&&g(a);u++)i=a,a=f(i,o[u]);if(void 0!==i&&void 0!==a)break}if(t===!1&&void 0!==a&&delete i[o[u-1]],t===!0&&void 0===a)for(a=n[0],u=0;l>u&&g(a);u++)a=f(a,o[u],!0);return a},capitalize:function(e,r){return e.charAt(0).toUpperCase()+e.slice(1)},camelize:function(e){return d(e).replace(l,function(e,r){return r?r.toUpperCase():""})},hyphenate:function(e){return d(e).replace(p,function(e,r){return e.charAt(0)+"-"+e.charAt(1).toLowerCase()})},underscore:function(e){return e.replace(n,"/").replace(t,"$1_$2").replace(a,"$1_$2").replace(u,"_").toLowerCase()},sub:function(r,n,t){var a=[];return r=r||"",a.push(r.replace(i,function(r,u){var i=e.getObject(u,n,t===!0?!1:void 0);return void 0===i||null===i?(a=null,""):g(i)&&a?(a.push(i),""):""+i})),null===a?a:a.length<=1?a[0]:a},replacer:i,undHash:r}),e}); +/*can@2.2.6#construct/construct*/ +define("can/construct/construct",["can/util/string/string"],function(t){var n,r=0;try{Object.getOwnPropertyDescriptor({}),n=!0}catch(e){n=!1}var o=function(t,n){var r=Object.getOwnPropertyDescriptor(t,n);return r&&(r.get||r.set)?r:null},u=function(n,r,e){e=e||n;var u;for(var i in n)(u=o(n,i))?this._defineProperty(e,r,i,u):t.Construct._overwrite(e,r,i,n[i])},i=function(n,r,e){e=e||n;for(var o in n)t.Construct._overwrite(e,r,o,n[o])};return t.Construct=function(){return arguments.length?t.Construct.extend.apply(t.Construct,arguments):void 0},t.extend(t.Construct,{constructorExtends:!0,newInstance:function(){var t,n=this.instance();return n.setup&&(t=n.setup.apply(n,arguments)),n.init&&n.init.apply(n,t||arguments),n},_inherit:n?u:i,_defineProperty:function(t,n,r,e){Object.defineProperty(t,r,e)},_overwrite:function(t,n,r,e){t[r]=e},setup:function(n,r){this.defaults=t.extend(!0,{},n.defaults,this.defaults)},instance:function(){r=1;var t=new this;return r=0,t},extend:function(n,e,o){function u(){return r?void 0:this.constructor!==a&&arguments.length&&a.constructorExtends?a.extend.apply(a,arguments):a.newInstance.apply(a,arguments)}var i=n,s=e,c=o;"string"!=typeof i&&(c=s,s=i,i=null),c||(c=s,s=null),c=c||{};var a,p,f,l,d,y,g,h,v,m=this,w=this.prototype;v=this.instance(),t.Construct._inherit(c,w,v),i&&(p=i.split("."),g=p.pop()),"undefined"==typeof constructorName&&(a=function(){return u.apply(this,arguments)});for(y in m)m.hasOwnProperty(y)&&(a[y]=m[y]);t.Construct._inherit(s,m,a),i&&(f=t.getObject(p.join("."),window,!0),h=f,l=t.underscore(i.replace(/\./g,"_")),d=t.underscore(g),f[g]=a),t.extend(a,{constructor:a,prototype:v,namespace:h,_shortName:d,fullName:i,_fullName:l}),void 0!==g&&(a.shortName=g),a.prototype.constructor=a;var C=[m].concat(t.makeArray(arguments)),_=a.setup.apply(a,C);return a.init&&a.init.apply(a,_||C),a}}),t.Construct.prototype.setup=function(){},t.Construct.prototype.init=function(){},t.Construct}); +/*can@2.2.6#control/control*/ +define("can/control/control",["can/util/util","can/construct/construct"],function(t){var n,e=function(n,e,o){return t.bind.call(n,e,o),function(){t.unbind.call(n,e,o)}},o=t.isFunction,s=t.extend,i=t.each,r=[].slice,u=/\{([^\}]+)\}/g,c=t.getObject("$.event.special",[t])||{},l=function(n,e,o,s){return t.delegate.call(n,e,o,s),function(){t.undelegate.call(n,e,o,s)}},a=function(n,o,s,i){return i?l(n,t.trim(i),o,s):e(n,o,s)},h=t.Control=t.Construct({setup:function(){if(t.Construct.setup.apply(this,arguments),t.Control){var n,e=this;e.actions={};for(n in e.prototype)e._isAction(n)&&(e.actions[n]=e._action(n))}},_shifter:function(n,e){var s="string"==typeof e?n[e]:e;return o(s)||(s=n[s]),function(){return n.called=e,s.apply(n,[this.nodeName?t.$(this):this].concat(r.call(arguments,0)))}},_isAction:function(t){var n=this.prototype[t],e=typeof n;return"constructor"!==t&&("function"===e||"string"===e&&o(this.prototype[n]))&&!!(c[t]||f[t]||/[^\w]/.test(t))},_action:function(e,o){if(u.lastIndex=0,o||!u.test(e)){var s=o?t.sub(e,this._lookup(o)):e;if(!s)return null;var i=t.isArray(s),r=i?s[1]:s,c=r.split(/\s+/g),l=c.pop();return{processor:f[l]||n,parts:[r,c.join(" "),l],delegate:i?s[0]:void 0}}},_lookup:function(t){return[t,window]},processors:{},defaults:{}},{setup:function(n,e){var o,i=this.constructor,r=i.pluginName||i._fullName;return this.element=t.$(n),r&&"can_control"!==r&&this.element.addClass(r),o=t.data(this.element,"controls"),o||(o=[],t.data(this.element,"controls",o)),o.push(this),this.options=s({},i.defaults,e),this.on(),[this.element,this.options]},on:function(n,e,o,s){if(!n){this.off();var i,r,u=this.constructor,c=this._bindings,l=u.actions,h=this.element,f=t.Control._shifter(this,"destroy");for(i in l)l.hasOwnProperty(i)&&(r=l[i]||u._action(i,this.options,this),r&&(c.control[i]=r.processor(r.delegate||h,r.parts[2],r.parts[1],i,this)));return t.bind.call(h,"removed",f),c.user.push(function(n){t.unbind.call(n,"removed",f)}),c.user.length}return"string"==typeof n&&(s=o,o=e,e=n,n=this.element),void 0===s&&(s=o,o=e,e=null),"string"==typeof s&&(s=t.Control._shifter(this,s)),this._bindings.user.push(a(n,o,s,e)),this._bindings.user.length},off:function(){var t=this.element[0],n=this._bindings;n&&(i(n.user||[],function(n){n(t)}),i(n.control||{},function(n){n(t)})),this._bindings={user:[],control:{}}},destroy:function(){if(null!==this.element){var n,e=this.constructor,o=e.pluginName||e._fullName;this.off(),o&&"can_control"!==o&&this.element.removeClass(o),n=t.data(this.element,"controls"),n.splice(t.inArray(this,n),1),t.trigger(this,"destroyed"),this.element=null}}}),f=t.Control.processors;return n=function(n,e,o,s,i){return a(n,e,t.Control._shifter(i,s),o)},i(["change","click","contextmenu","dblclick","keydown","keyup","keypress","mousedown","mousemove","mouseout","mouseover","mouseup","reset","resize","scroll","select","submit","focusin","focusout","mouseenter","mouseleave","touchstart","touchmove","touchcancel","touchend","touchleave","inserted","removed"],function(t){f[t]=n}),h}); +/*can@2.2.6#util/bind/bind*/ +define("can/util/bind/bind",["can/util/util"],function(i){return i.bindAndSetup=function(){return i.addEvent.apply(this,arguments),this._init||(this._bindings?this._bindings++:(this._bindings=1,this._bindsetup&&this._bindsetup())),this},i.unbindAndTeardown=function(n,t){var s=this.__bindEvents[n]||[],d=s.length;return i.removeEvent.apply(this,arguments),null===this._bindings?this._bindings=0:this._bindings=this._bindings-(d-s.length),!this._bindings&&this._bindteardown&&this._bindteardown(),this},i}); +/*can@2.2.6#map/bubble*/ +define("can/map/bubble",["can/util/util"],function(n){var e=n.bubble={event:function(n,e){return n.constructor._bubbleRule(e,n)},childrenOf:function(n,i){n._each(function(b,r){b&&b.bind&&e.toParent(b,n,r,i)})},teardownChildrenFrom:function(n,i){n._each(function(b){e.teardownFromParent(n,b,i)})},toParent:function(e,i,b,r){n.listenTo.call(i,e,r,function(){var r=n.makeArray(arguments),t=r.shift();r[0]=(n.List&&i instanceof n.List?i.indexOf(e):b)+(r[0]?"."+r[0]:""),t.triggeredNS=t.triggeredNS||{},t.triggeredNS[i._cid]||(t.triggeredNS[i._cid]=!0,n.trigger(i,t,r))})},teardownFromParent:function(e,i,b){i&&i.unbind&&n.stopListening.call(e,i,b)},isBubbling:function(n,e){return n._bubbleBindings&&n._bubbleBindings[e]},bind:function(n,i){if(!n._init){var b,r=e.event(n,i),t=r.length;n._bubbleBindings||(n._bubbleBindings={});for(var u=0;t>u;u++)b=r[u],n._bubbleBindings[b]?n._bubbleBindings[b]++:(n._bubbleBindings[b]=1,e.childrenOf(n,b))}},unbind:function(i,b){for(var r,t=e.event(i,b),u=t.length,d=0;u>d;d++)r=t[d],i._bubbleBindings&&i._bubbleBindings[r]--,i._bubbleBindings&&!i._bubbleBindings[r]&&(delete i._bubbleBindings[r],e.teardownChildrenFrom(i,r),n.isEmptyObject(i._bubbleBindings)&&delete i._bubbleBindings)},add:function(i,b,r){if(b instanceof n.Map&&i._bubbleBindings)for(var t in i._bubbleBindings)i._bubbleBindings[t]&&(e.teardownFromParent(i,b,t),e.toParent(b,i,r,t))},removeMany:function(n,i){for(var b=0,r=i.length;r>b;b++)e.remove(n,i[b])},remove:function(i,b){if(b instanceof n.Map&&i._bubbleBindings)for(var r in i._bubbleBindings)i._bubbleBindings[r]&&e.teardownFromParent(i,b,r)},set:function(i,b,r,t){return n.Map.helpers.isObservable(r)&&e.add(i,r,b),n.Map.helpers.isObservable(t)&&e.remove(i,t),r}};return e}); +/*can@2.2.6#util/batch/batch*/ +define("can/util/batch/batch",["can/util/can"],function(t){var n=1,a=0,i=[],c=[],e=null;t.batch={start:function(t){a++,t&&c.push(t)},stop:function(l,u){if(l?a=0:a--,0===a){if(null!==e)return;e=i.slice(0);var h,r,f=c.slice(0);for(i=[],c=[],t.batch.batchNum=n,n++,u&&t.batch.start(),h=0;h=0?["change"]:[]},_computes:[],bind:t.bindAndSetup,on:t.bindAndSetup,unbind:t.unbindAndTeardown,off:t.unbindAndTeardown,id:"id",helpers:{define:null,attrParts:function(t,e){return e?[t]:"object"==typeof t?t:(""+t).split(".")},addToMap:function(e,i){var r;n||(r=s,n={});var a=e._cid,o=t.cid(e);return n[o]||(n[o]={obj:e,instance:i,added:!a}),r},isObservable:function(e){return e instanceof t.Map||e&&e===t.route},canMakeObserve:function(e){return e&&!t.isDeferred(e)&&(t.isArray(e)||t.isPlainObject(e))},serialize:function(e,i,n){var s=t.cid(e),r=!1;return a||(r=!0,a={attr:{},serialize:{}}),a[i][s]=n,e.each(function(s,r){var u,h=o.helpers.isObservable(s),c=h&&a[i][t.cid(s)];u=c?c:"serialize"===i?o.helpers._serialize(e,r,s):o.helpers._getValue(e,r,s,i),void 0!==u&&(n[r]=u)}),t.__observe(e,"__keys"),r&&(a=null),n},_serialize:function(t,e,i){return o.helpers._getValue(t,e,i,"serialize")},_getValue:function(t,e,i,n){return o.helpers.isObservable(i)?i[n]():i}},keys:function(e){var i=[];t.__observe(e,"__keys");for(var n in e._data)i.push(n);return i}},{setup:function(e){e instanceof t.Map&&(e=e.serialize()),this._data={},t.cid(this,".map"),this._init=1,this._computedBindings={};var i=this._setupDefaults(e);this._setupComputes(i);var n=e&&t.Map.helpers.addToMap(e,this),s=t.extend(t.extend(!0,{},i),e);this.attr(s),n&&n(),this.bind("change",t.proxy(this._changes,this)),delete this._init},_setupComputes:function(){for(var t,e=this.constructor._computes,i=0,n=e.length;n>i;i++)t=e[i],this[t]=this[t].clone(this),this._computedBindings[t]={count:0}},_setupDefaults:function(){return this.constructor.defaults||{}},_bindsetup:function(){},_bindteardown:function(){},_changes:function(e,i,n,s,r){t.batch.trigger(this,{type:i,batchNum:e.batchNum,target:e.target},[s,r])},_triggerChange:function(e,n,s,r){i.isBubbling(this,"change")?t.batch.trigger(this,{type:"change",target:this},[e,n,s,r]):t.batch.trigger(this,e,[s,r]),("remove"===n||"add"===n)&&t.batch.trigger(this,{type:"__keys",target:this})},_each:function(t){var e=this.__get();for(var i in e)e.hasOwnProperty(i)&&t(e[i],i)},attr:function(t,e){var i=typeof t;return"string"!==i&&"number"!==i?this._attrs(t,e):1===arguments.length?this._get(t):(this._set(t,e),this)},each:function(){return t.each.apply(void 0,[this].concat(t.makeArray(arguments)))},removeAttr:function(e){var i=t.List&&this instanceof t.List,n=t.Map.helpers.attrParts(e),s=n.shift(),r=i?this[s]:this._data[s];return n.length&&r?r.removeAttr(n):("string"==typeof e&&~e.indexOf(".")&&(s=e),this._remove(s,r),r)},_remove:function(t,e){t in this._data&&(delete this._data[t],t in this.constructor.prototype||delete this[t],this._triggerChange(t,"remove",void 0,e))},_get:function(e){e=""+e;var i=e.indexOf(".");if(i>=0){var n=this.__get(e);if(void 0!==n)return n;var s=e.substr(0,i),r=e.substr(i+1);t.__observe(this,s);var a=this.__get(s);return a&&a._get?a._get(r):void 0}return t.__observe(this,e),this.__get(e)},__get:function(t){return t?this._computedBindings[t]?this[t]():this._data[t]:this._data},__type:function(e,i){if(!(e instanceof t.Map)&&t.Map.helpers.canMakeObserve(e)){var n=r(e);if(n)return n;if(t.isArray(e)){var s=t.List;return new s(e)}var a=this.constructor.Map||t.Map;return new a(e)}return e},_set:function(t,e,i){t=""+t;var n,s=t.indexOf(".");if(!i&&s>=0){var r=t.substr(0,s),a=t.substr(s+1);if(n=this._init?void 0:this.__get(r),!o.helpers.isObservable(n))throw"can.Map: Object does not exist";n._set(a,e)}else this.__convert&&(e=this.__convert(t,e)),n=this._init?void 0:this.__get(t),this.__set(t,this.__type(e,t),n)},__set:function(t,e,i){if(e!==i){var n=void 0!==i||this.__get().hasOwnProperty(t)?"set":"add";this.___set(t,this.constructor._bubble.set(this,t,e,i)),this._computedBindings[t]||this._triggerChange(t,n,e,i),i&&this.constructor._bubble.teardownFromParent(this,i)}},___set:function(t,e){this._computedBindings[t]?this[t](e):this._data[t]=e,"function"==typeof this.constructor.prototype[t]||this._computedBindings[t]||(this[t]=e)},bind:function(e,i){var n=this._computedBindings&&this._computedBindings[e];if(n)if(n.count)n.count++;else{n.count=1;var s=this;n.handler=function(i,n,r){t.batch.trigger(s,{type:e,batchNum:i.batchNum,target:s},[n,r])},this[e].bind("change",n.handler)}return this.constructor._bubble.bind(this,e),t.bindAndSetup.apply(this,arguments)},unbind:function(e,i){var n=this._computedBindings&&this._computedBindings[e];return n&&(1===n.count?(n.count=0,this[e].unbind("change",n.handler),delete n.handler):n.count--),this.constructor._bubble.unbind(this,e),t.unbindAndTeardown.apply(this,arguments)},serialize:function(){return t.Map.helpers.serialize(this,"serialize",{})},_attrs:function(e,i){if(void 0===e)return o.helpers.serialize(this,"attr",{});e=t.simpleExtend({},e);var n,s,r=this;t.batch.start(),this.each(function(t,n){if("_cid"!==n){if(s=e[n],void 0===s)return void(i&&r.removeAttr(n));r.__convert&&(s=r.__convert(n,s)),o.helpers.isObservable(s)?r.__set(n,r.__type(s,n),t):o.helpers.isObservable(t)&&o.helpers.canMakeObserve(s)?t.attr(s,i):t!==s&&r.__set(n,r.__type(s,n),t),delete e[n]}});for(n in e)"_cid"!==n&&(s=e[n],this._set(n,s,!0));return t.batch.stop(),this},compute:function(e){if(t.isFunction(this.constructor.prototype[e]))return t.compute(this[e],this);var i=e.split("."),n=i.length-1,s={args:[]};return t.compute(function(e){return arguments.length?void t.compute.read(this,i.slice(0,n)).value.attr(i[n],e):t.compute.read(this,i,s).value},this)}});return o.prototype.on=o.prototype.bind,o.prototype.off=o.prototype.unbind,o}); +/*can@2.2.6#list/list*/ +define("can/list/list",["can/util/util","can/map/map","can/map/bubble"],function(t,e,i){var r=[].splice,h=function(){var t={0:"a",length:1};return r.call(t,0,1),!t[0]}(),n=e.extend({Map:e},{setup:function(e,i){this.length=0,t.cid(this,".map"),this._init=1,this._computedBindings={},this._setupComputes(),e=e||[];var r;t.isDeferred(e)?this.replace(e):(r=e.length&&t.Map.helpers.addToMap(e,this),this.push.apply(this,t.makeArray(e||[]))),r&&r(),this.bind("change",t.proxy(this._changes,this)),t.simpleExtend(this,i),delete this._init},_triggerChange:function(i,r,h,n){e.prototype._triggerChange.apply(this,arguments);var s=+i;~(""+i).indexOf(".")||isNaN(s)||("add"===r?(t.batch.trigger(this,r,[h,s]),t.batch.trigger(this,"length",[this.length])):"remove"===r?(t.batch.trigger(this,r,[n,s]),t.batch.trigger(this,"length",[this.length])):t.batch.trigger(this,r,[h,s]))},__get:function(e){return e?this[e]&&this[e].isComputed&&t.isFunction(this.constructor.prototype[e])?this[e]():this[e]:this},__set:function(e,i,r){if(e=isNaN(+e)||e%1?e:+e,"number"==typeof e&&e>this.length-1){var h=new Array(e+1-this.length);return h[h.length-1]=i,this.push.apply(this,h),h}return t.Map.prototype.__set.call(this,""+e,i,r)},___set:function(t,e){this[t]=e,+t>=this.length&&(this.length=+t+1)},_remove:function(t,e){isNaN(+t)?(delete this[t],this._triggerChange(t,"remove",void 0,e)):this.splice(t,1)},_each:function(t){for(var e=this.__get(),i=0;i2;for(e=e||0,s=0,a=o.length-2;a>s;s++)l=s+2,o[l]=this.__type(o[l],l),g.push(o[l]),this[s+e]!==o[l]&&(c=!1);if(c&&this.length<=g.length)return g;void 0===n&&(n=o[1]=this.length-e);var p=r.apply(this,o);if(!h)for(s=this.length;s0&&(i.removeMany(this,p),this._triggerChange(""+e,"remove",void 0,p)),o.length>2){for(s=0,a=g.length;a>s;s++)i.set(this,s,g[s]);this._triggerChange(""+e,"add",g,p)}return t.batch.stop(),p},_attrs:function(i,r){return void 0===i?e.helpers.serialize(this,"attr",[]):(i=t.makeArray(i),t.batch.start(),this._updateAttrs(i,r),void t.batch.stop())},_updateAttrs:function(t,i){for(var r=Math.min(t.length,this.length),h=0;r>h;h++){var n=this[h],s=t[h];e.helpers.isObservable(n)&&e.helpers.canMakeObserve(s)?n.attr(s,i):n!==s&&this._set(h,s)}t.length>this.length?this.push.apply(this,t.slice(this.length)):t.lengthc;){s=i;for(var l=0,f=t.propertyReaders.length;f>l;l++){var v=t.propertyReaders[l];if(v.test(i)){i=v.read(i,r[c],c,o,u);break}}if(c+=1,i=n(i,c,r,o,u,s),a=typeof i,ci;i++)t.valueReaders[i].test(e,n,r,o)&&(e=t.valueReaders[i].read(e,n,r,o,a,s))}while(u);return e};return t.valueReaders=[{name:"compute",test:function(e,t,n,r){return e&&e.isComputed},read:function(t,n,r,o,a){return o.isArgument&&n===r.length?t:(!a.foundObservable&&o.foundObservable&&(o.foundObservable(t,n),a.foundObservable=!0),t instanceof e.Compute?t.get():t())}},{name:"function",test:function(t,n,r,o){var a=typeof t;return!("function"!==a||t.isComputed||!(o.executeAnonymousFunctions||o.isArgument&&n===r.length)||e.Construct&&t.prototype instanceof e.Construct||e.route&&t===e.route)},read:function(t,n,r,o,a,s){return o.isArgument&&n===r.length?o.proxyMethods!==!1?e.proxy(t,s):t:t.call(s)}}],t.propertyReaders=[{name:"map",test:e.isMapLike,read:function(t,n,r,o,a){return!a.foundObservable&&o.foundObservable&&(o.foundObservable(t,r),a.foundObservable=!0),"function"==typeof t[n]&&t.constructor.prototype[n]===t[n]?o.returnObserveMethods?t[n]:"constructor"===n&&t instanceof e.Construct||t[n].prototype instanceof e.Construct?t[n]:t[n].apply(t,o.args||[]):t.attr(n)}},{name:"promise",test:function(t){return e.isPromise(t)},read:function(t,n,r,o,a){!a.foundObservable&&o.foundObservable&&(o.foundObservable(t,r),a.foundObservable=!0);var s=t.__observeData;return t.__observeData||(s=t.__observeData={isPending:!0,state:"pending",isResolved:!1,isRejected:!1,value:void 0,reason:void 0},e.cid(s),e.simpleExtend(s,e.event),t.then(function(e){s.isPending=!1,s.isResolved=!0,s.value=e,s.state="resolved",s.dispatch("state",["resolved","pending"])},function(e){s.isPending=!1,s.isRejected=!0,s.reason=e,s.state="rejected",s.dispatch("state",["rejected","pending"])})),e.__observe(s,"state"),n in s?s[n]:t[n]}},{name:"object",test:function(){return!0},read:function(e,t){return null==e?void 0:e[t]}}],t.write=function(t,n,r,o){return o=o||{},e.isMapLike(t)?!o.isArgument&&t._data&&t._data[n]&&t._data[n].isComputed?t._data[n](r):t.attr(n,r):t[n]&&t[n].isComputed?t[n](r):void("object"==typeof t&&(t[n]=r))},t}); +/*can@2.2.6#compute/get_value_and_bind*/ +define("can/compute/get_value_and_bind",["can/util/util"],function(){function n(n,e,t,i){var v=a(n,e),o=v.observed,u=t.observed;return v.names!==t.names&&(r(u,o,i),c(u,i)),can.batch.afterPreviousEvents(function(){v.ready=!0}),v}var e=[];can.__isRecordingObserves=function(){return e.length},can.__observe=can.__reading=function(n,a){if(e.length){var r=n._cid+"|"+a,t=e[e.length-1];t.names+=r,t.observed[r]={obj:n,event:a+""}}},can.__notObserve=function(n){return function(){var e=can.__clearObserved(),a=n.apply(this,arguments);return can.__setObserved(e),a}},can.__clearObserved=can.__clearReading=function(){if(e.length){var n=e[e.length-1];return e[e.length-1]={observed:{}},n}},can.__setObserved=can.__setReading=function(n){e.length&&(e[e.length-1]=n)},can.__addObserved=can.__addReading=function(n){e.length&&can.simpleExtend(e[e.length-1],n)};var a=function(n,a){e.push({names:"",observed:{}});var r=n.call(a),t=e.pop();return t.value=r,t},r=function(n,e,a){for(var r in e)t(n,e,r,a)},t=function(n,e,a,r){if(n[a])delete n[a];else{var t=e[a];t.obj.bind(t.event,r)}},c=function(n,e){for(var a in n){var r=n[a];r.obj.unbind(r.event,e)}};return n}); +/*can@2.2.6#compute/proto_compute*/ +define("can/compute/proto_compute",["can/util/util","can/util/bind/bind","can/compute/read","can/compute/get_value_and_bind","can/util/batch/batch"],function(t,e,n,i){var s=function(e,n,i,s){n!==i&&t.batch.trigger(e,s?{type:"change",batchNum:s}:"change",[n,i])},u=function(e,n,s,u){var o,h,r;return u=!1,{on:function(a){var c=this;h||(h=function(t){if(o.ready&&e.bound&&(void 0===t.batchNum||t.batchNum!==r)){var a,f=o.value;u?(a=n.call(s),o.value=a):(o=i(n,s,o,h),a=o.value),c.updater(a,f,t.batchNum),r=r=t.batchNum}}),o=i(n,s,{observed:{}},h),u&&(n=t.__notObserve(n)),e.value=o.value,e.hasDependencies=!t.isEmptyObject(o.observed)},off:function(t){for(var e in o.observed){var n=o.observed[e];n.obj.unbind(n.event,h)}}}},o=function(){},h=function(t,e,n){this.value=t,s(this,t,e,n)},r=function(t,e,n){return function(){return t.call(e,n.get())}},a=function(t,e){return function(n){void 0!==n&&e(n,t.value)}};t.Compute=function(e,n,i,s){for(var u=[],o=0,h=arguments.length;h>o;o++)u[o]=arguments[o];var r=typeof u[1];"function"==typeof u[0]?this._setupGetterSetterFn(u[0],u[1],u[2],u[3]):u[1]?"string"===r?this._setupContextString(u[0],u[1],u[2]):"function"===r?this._setupContextFunction(u[0],u[1],u[2]):u[1]&&u[1].fn?this._setupAsyncCompute(u[0],u[1]):this._setupContextSettings(u[0],u[1]):this._setupInitialValue(u[0]),this._args=u,this.isComputed=!0,t.cid(this,"compute")},t.simpleExtend(t.Compute.prototype,{_bindsetup:t.__notObserve(function(){this.bound=!0,this._on(this.updater)}),_bindteardown:function(){this._off(this.updater),this.bound=!1},bind:t.bindAndSetup,unbind:t.unbindAndTeardown,clone:function(e){return e&&"function"==typeof this._args[0]?this._args[1]=e:e&&(this._args[2]=e),new t.Compute(this._args[0],this._args[1],this._args[2],this._args[3])},_on:o,_off:o,get:function(){return t.__isRecordingObserves()&&this._canObserve!==!1&&(t.__observe(this,"change"),this.bound||t.Compute.temporarilyBind(this)),this.bound?this.value:this._get()},_get:function(){return this.value},set:function(t){var e=this.value,n=this._set(t,e);return this.hasDependencies?this._setUpdates?this.value:this._get():(void 0===n?this.value=this._get():this.value=n,s(this,this.value,e),this.value)},_set:function(t){return this.value=t},updater:h,_computeFn:function(t){return arguments.length?this.set(t):this.get()},toFunction:function(){return t.proxy(this._computeFn,this)},_setupGetterSetterFn:function(e,n,i,s){this._set=t.proxy(e,n),this._get=t.proxy(e,n),this._canObserve=i===!1?!1:!0;var o=u(this,e,n||this,s);this._on=o.on,this._off=o.off},_setupContextString:function(e,n,i){var s=t.isMapLike(e),u=this,o=function(t,e,n){u.updater(e,n,t.batchNum)};s?(this.hasDependencies=!0,this._get=function(){return e.attr(n)},this._set=function(t){e.attr(n,t)},this._on=function(t){e.bind(i||n,o),this.value=this._get()},this._off=function(){return e.unbind(i||n,o)}):(this._get=t.proxy(this._get,e),this._set=t.proxy(this._set,e))},_setupContextFunction:function(e,n,i){this.value=e,this._set=n,t.simpleExtend(this,i)},_setupContextSettings:function(e,n){if(this.value=e,this._set=n.set?t.proxy(n.set,n):this._set,this._get=n.get?t.proxy(n.get,n):this._get,!n.__selfUpdater){var i=this,s=this.updater;this.updater=function(){s.call(i,i._get(),i.value)}}this._on=n.on?n.on:this._on,this._off=n.off?n.off:this._off},_setupAsyncCompute:function(e,n){this.value=e;var i,s=t.proxy(this.updater,this),o=this,h=n.fn;this.updater=s;var c=new t.Compute(e);this.lastSetValue=c,this._setUpdates=!0,this._set=function(t){return t===c.get()?this.value:c.set(t)},this._get=r(h,n.context,c),0===h.length?i=u(this,h,n.context):1===h.length?i=u(this,function(){return h.call(n.context,c.get())},n):(this.updater=a(this,s),i=u(this,function(){var t=h.call(n.context,c.get(),function(t){s(t,o.value)});return void 0!==t?t:this.value},n)),this._on=i.on,this._off=i.off},_setupInitialValue:function(t){this.value=t}});var c,f=function(){for(var t=0,e=c.length;e>t;t++)c[t].unbind("change",o);c=null};return t.Compute.temporarilyBind=function(t){t.bind("change",o),c||(c=[],setTimeout(f,10)),c.push(t)},t.Compute.async=function(e,n,i){return new t.Compute(e,{fn:n,context:i})},t.Compute.read=n,t.Compute.set=n.write,t.Compute.truthy=function(e){return new t.Compute(function(){var t=e.get();return"function"==typeof t&&(t=t.get()),!!t})},t.Compute}); +/*can@2.2.6#compute/compute*/ +define("can/compute/compute",["can/util/util","can/util/bind/bind","can/util/batch/batch","can/compute/proto_compute"],function(t,n){t.compute=function(n,u,e,o){var c=new t.Compute(n,u,e,o),i=function(t){return arguments.length?c.set(t):c.get()};return i.bind=t.proxy(c.bind,c),i.unbind=t.proxy(c.unbind,c),i.isComputed=c.isComputed,i.clone=function(e){return"function"==typeof n&&(u=e),t.compute(n,u,e,o)},i.computeInstance=c,i};var u,e=function(){},o=function(){for(var t=0,n=u.length;n>t;t++)u[t].unbind("change",e);u=null};return t.compute.temporarilyBind=function(t){t.bind("change",e),u||(u=[],setTimeout(o,10)),u.push(t)},t.compute.truthy=function(n){return t.compute(function(){var t=n();return"function"==typeof t&&(t=t()),!!t})},t.compute.async=function(n,u,e){return t.compute(n,{fn:u,context:e})},t.compute.read=t.Compute.read,t.compute.set=t.Compute.set,t.compute}); +/*can@2.2.6#observe/observe*/ +define("can/observe/observe",["can/util/util","can/map/map","can/list/list","can/compute/compute"],function(t){return t.Observe=t.Map,t.Observe.startBatch=t.batch.start,t.Observe.stopBatch=t.batch.stop,t.Observe.triggerBatch=t.batch.trigger,t}); +/*can@2.2.6#view/scope/compute_data*/ +define("can/view/scope/compute_data",["can/util/util","can/compute/compute","can/compute/get_value_and_bind"],function(e,t,n){var o=function(t){return t.reads&&1===t.reads.length&&t.root instanceof e.Map&&!e.isFunction(t.root[t.reads[0]])},a=function(e,t){return n(e,null,{observed:{}},t)},u=function(e,t){for(var n in e.observed){var o=e.observed[n];o.obj.unbind(o.event,t)}},r=function(e,t){var n=e.root,o=e.reads[0];return n.bind(o,t),{value:e.initialValue,observed:{something:!0}}},c=function(e,t){e.root.unbind(e.reads[0],t)},i=function(t,n,o,a,u){if(!(arguments.length>4)){if(a.root)return e.compute.read(a.root,a.reads,o).value;var r=t.read(n,o);return a.scope=r.scope,a.initialValue=r.value,a.reads=r.reads,a.root=r.rootObserve,r.value}if(a.root.isComputed)a.root(u);else if(a.reads.length){var c=a.reads.length-1,i=a.reads.length?e.compute.read(a.root,a.reads.slice(0,c)).value:a.root;e.compute.set(i,a.reads[c],u,o)}};return function(t,s,d){d=d||{args:[]};var l,v,f={},p=function(e){return arguments.length?i(t,s,d,f,e):i(t,s,d,f)},m=function(e){if(v.ready&&g.computeInstance.bound&&(void 0===e.batchNum||e.batchNum!==l)){var t,o=v.value;v=n(p,null,v,m),t=v.value,g.computeInstance.updater(t,o,e.batchNum),l=l=e.batchNum}},b=function(e,t,n){"function"!=typeof t?g.computeInstance.updater(t,n,e.batchNum):(c(f,b),v=a(p,m),h=!1,g.computeInstance.updater(v.value,n,e.batchNum))},h=!1,g=e.compute(void 0,{on:function(){if(v=a(p,m),o(f)){var t=v;v=r(f,b),u(t,m),h=!0}g.computeInstance.value=v.value,g.computeInstance.hasDependencies=!e.isEmptyObject(v.observed)},off:function(){h?c(f,b):u(v,m)},set:p,get:p,__selfUpdater:!0});return f.compute=g,f}}); +/*can@2.2.6#view/scope/scope*/ +define("can/view/scope/scope",["can/util/util","can/view/scope/compute_data","can/construct/construct","can/map/map","can/list/list","can/view/view","can/compute/compute"],function(e,t){var n=/(\\)?\./g,r=/\\\./g,u=function(e){var t=[],u=0;return e.replace(n,function(n,i,s){i||(t.push(e.slice(u,s).replace(r,".")),u=s+n.length)}),t.push(e.slice(u).replace(r,".")),t},i=e.Construct.extend({read:e.compute.read},{init:function(e,t){this._context=e,this._parent=t,this.__cache={}},attr:e.__notObserve(function(t,n){var r={isArgument:!0,returnObserveMethods:!0,proxyMethods:!1},u=this.read(t,r);if(2===arguments.length){var i=t.lastIndexOf("."),s=-1!==i?t.substring(0,i):".",a=this.read(s,r).value;-1!==i&&(t=t.substring(i+1,t.length)),e.compute.set(a,t,n,r)}return u.value}),add:function(e){return e!==this._context?new this.constructor(e,this):this},computeData:function(e,n){return t(this,e,n)},compute:function(e,t){return this.computeData(e,t).compute},read:function(t,n){var r;if("./"===t.substr(0,2))r=!0,t=t.substr(2);else{if("../"===t.substr(0,3))return this._parent.read(t.substr(3),n);if(".."===t)return{value:this._parent._context};if("."===t||"this"===t)return{value:this._context}}for(var i,s,a,c,o,l,p=-1===t.indexOf("\\.")?t.split("."):u(t),v=this,d=[],f=-1;v;){if(i=v._context,null!==i&&("object"==typeof i||"function"==typeof i)){var h=e.compute.read(i,p,e.simpleExtend({foundObservable:function(e,t){o=e,l=p.slice(t)},earlyExit:function(t,n){n>f&&(s=o,d=l,f=n,c=v,a=e.__clearReading())},executeAnonymousFunctions:!0},n));if(void 0!==h.value)return{scope:v,rootObserve:o,value:h.value,reads:l}}e.__clearReading(),v=r?null:v._parent}return s?(e.__setReading(a),{scope:c,rootObserve:s,reads:d,value:void 0}):{names:p,value:void 0}}});return e.view.Scope=i,i}); +/*can@2.2.6#view/scanner*/ +define("can/view/scanner",["can/view/view","can/view/elements","can/view/callbacks/callbacks"],function(can,elements,viewCallbacks){var newLine=/(\r|\n)+/g,notEndTag=/\//,clean=function(t){return t.split("\\").join("\\\\").split("\n").join("\\n").split('"').join('\\"').split(" ").join("\\t")},getTag=function(t,e,n){if(t)return t;for(;n":">",'"':'"',"'":"'"},this.tokenComplex=[],this.tokenMap={};for(var e,n=0;e=this.tokens[n];n++)e[2]?(this.tokenReg.push(e[2]),this.tokenComplex.push({abbr:e[1],re:new RegExp(e[2]),rescan:e[3]})):(this.tokenReg.push(e[1]),this.tokenSimple[e[1]]=e[0]),this.tokenMap[e[0]]=e[1];this.tokenReg=new RegExp("("+this.tokenReg.slice(0).concat(["<",">",'"',"'"]).join("|")+")","g")},Scanner.prototype={helpers:[],scan:function(t,e){var n=[],s=0,a=this.tokenSimple,r=this.tokenComplex;t=t.replace(newLine,"\n"),this.transform&&(t=this.transform(t)),t.replace(this.tokenReg,function(e,i){var o=arguments[arguments.length-2];if(o>s&&n.push(t.substring(s,o)),a[e])n.push(e);else for(var u,c=0;u=r[c];c++)if(u.re.test(e)){n.push(u.abbr),u.rescan&&n.push(u.rescan(i));break}s=o+i.length}),s":htmlTag=0;var H="/"===l.substr(l.length-1)||"--"===l.substr(l.length-2),N="";if(k.attributeHookups.length&&(N="attrs: ['"+k.attributeHookups.join("','")+"'], ",k.attributeHookups=[]),v+k.tagHookups.length!==k.lastTagHookup&&v===top(k.tagHookups))H&&(l=l.substr(0,l.length-1)),p.push(put_cmd,'"',clean(l),'"',",can.view.pending({tagName:'"+v+"',"+N+"scope: "+(this.text.scope||"this")+this.text.options),H?(p.push("}));"),l="/>",b()):"<"===n[d]&&n[d+1]==="/"+v?(p.push("}));"),l=u,b()):(p.push(",subtemplate: function("+this.text.argNames+"){\n"+startTxt+(this.text.start||"")),l="");else if(m||!w&&elements.tagToContentPropMap[x[x.length-1]]||N){var R=",can.view.pending({"+N+"scope: "+(this.text.scope||"this")+this.text.options+'}),"';H?h(l.substr(0,l.length-1),R+'/>"'):h(l,R+'>"'),l="",m=0}else l+=u;(H||w)&&(x.pop(),v=x[x.length-1],w=!1),k.attributeHookups=[];break;case"'":case'"':if(htmlTag)if(quote&"e===u){quote=null;var L=getAttrName();if(viewCallbacks.attr(L)&&k.attributeHookups.push(L),T){l+=u,h(l),p.push(finishTxt,"}));\n"),l="",T=!1;break}}else if(null===quote&&(quote=u,beforeQuote=i,c=getAttrName(),"img"===v&&"src"===c||"style"===c)){h(l.replace(attrReg,"")),l="",T=!0,p.push(insert_cmd,"can.view.txt(2,'"+getTag(v,n,d)+"',"+status()+",this,function(){",startTxt),h(c+"="+u);break}default:if("<"===i){v="!--"===u.substr(0,3)?"!--":u.split(/\s/)[0];var S,y=!1;0===v.indexOf("/")&&(y=!0,S=v.substr(1)),y?(top(x)===S&&(v=S,w=!0),top(k.tagHookups)===S&&(h(l.substr(0,l.length-1)),p.push(finishTxt+"}}) );"),l="><",b())):(v.lastIndexOf("/")===v.length-1&&(v=v.substr(0,v.length-1)),"!--"!==v&&viewCallbacks.tag(v)&&("content"===v&&elements.tagMap[top(x)]&&(u=u.replace("content",elements.tagMap[top(x)])),k.tagHookups.push(v)),x.push(v))}l+=u}else switch(u){case _.right:case _.returnRight:switch(f){case _.left:o=bracketNum(l),1===o?(p.push(insert_cmd,"can.view.txt(0,'"+getTag(v,n,d)+"',"+status()+",this,function(){",startTxt,l),g.push({before:"",after:finishTxt+"}));\n"})):(s=g.length&&-1===o?g.pop():{after:";"},s.before&&p.push(s.before),p.push(l,";",s.after));break;case _.escapeLeft:case _.returnLeft:o=bracketNum(l),o&&g.push({before:finishTxt,after:"}));\n"});for(var j=f===_.escapeLeft?1:0,C={insert:insert_cmd,tagName:getTag(v,n,d),status:status(),specialAttribute:T},q=0;q[\s]*\w*/.source&&(j=0);break}}"object"==typeof l?l.startTxt&&l.end&&T?p.push(insert_cmd,"can.view.toStr( ",l.content,"() ) );"):(l.startTxt?p.push(insert_cmd,"can.view.txt(\n"+("string"==typeof status()||(null!=l.escaped?l.escaped:j))+",\n'"+v+"',\n"+status()+",\nthis,\n"):l.startOnlyTxt&&p.push(insert_cmd,"can.view.onlytxt(this,\n"),p.push(l.content),l.end&&p.push("));")):T?p.push(insert_cmd,l,");"):p.push(insert_cmd,"can.view.txt(\n"+("string"==typeof status()||j)+",\n'"+v+"',\n"+status()+",\nthis,\nfunction(){ "+(this.text.escape||"")+"return ",l,o?startTxt:"}));\n"),rescan&&rescan.after&&rescan.after.length&&(h(rescan.after.length),rescan=null)}f=null,l="";break;case _.templateLeft:l+=_.left;break;default:l+=u}i=u}l.length&&h(l),p.push(";");var M=p.join(""),A={out:(this.text.outStart||"")+M+" "+finishTxt+(this.text.outEnd||"")};return myEval.call(A,"this.fn = (function("+this.text.argNames+"){"+A.out+"});\r\n//# sourceURL="+e+".js"),A}},can.view.pending=function(t){var e=can.view.getHooks();return can.view.hook(function(n){can.each(e,function(t){t(n)}),t.templateType="legacy",t.tagName&&viewCallbacks.tagHandler(n,t.tagName,t),can.each(t&&t.attrs||[],function(e){t.attributeName=e;var s=viewCallbacks.attr(e);s&&s(n,t)})})},can.view.tag("content",function(t,e){return e.scope}),can.view.Scanner=Scanner,Scanner}); +/*can@2.2.6#view/node_lists/node_lists*/ +define("can/view/node_lists/node_lists",["can/util/util","can/view/elements"],function(e){var n=!0;try{document.createTextNode("")._=0}catch(t){n=!1}var r={},a={},i="ejs_"+Math.random(),s=0,u=function(e,t){var r=t||a,u=l(e,r);return u?u:n||3!==e.nodeType?(++s,e[i]=(e.nodeName?"element_":"obj_")+s):(++s,r["text_"+s]=e,"text_"+s)},l=function(e,t){if(n||3!==e.nodeType)return e[i];for(var r in t)if(t[r]===e)return r},c=[].splice,o=[].push,p=function(e){for(var n=0,t=0,r=e.length;r>t;t++){var a=e[t];a.nodeType?n++:n+=p(a)}return n},f=function(e,n){for(var t={},r=0,a=e.length;a>r;r++){var i=d.first(e[r]);t[u(i,n)]=e[r]}return t},d={id:u,update:function(n,t){var r=d.unregisterChildren(n);t=e.makeArray(t);var a=n.length;return c.apply(n,[0,a].concat(t)),n.replacements?d.nestReplacements(n):d.nestList(n),r},nestReplacements:function(e){for(var n=0,t={},r=f(e.replacements,t),a=e.replacements.length;nr;r++){var n=e[r];t[n.tokenType].apply(t,n.args)}return e}var a="-:A-Za-z0-9_",n="[a-zA-Z_:]["+a+":.]*",s="\\s*=\\s*",i='"((?:\\\\.|[^"])*)"',o="'((?:\\\\.|[^'])*)'",l="(?:"+s+"(?:(?:\"[^\"]*\")|(?:'[^']*')|[^>\\s]+))?",c="\\{\\{[^\\}]*\\}\\}\\}?",u="\\{\\{([^\\}]*)\\}\\}\\}?",p=new RegExp("^<(["+a+"]+)((?:\\s*(?:(?:(?:"+n+")?"+l+")|(?:"+c+")+))*)\\s*(\\/?)>"),f=new RegExp("^<\\/(["+a+"]+)[^>]*>"),d=new RegExp("(?:(?:("+n+")|"+u+")(?:"+s+"(?:(?:"+i+")|(?:"+o+")|([^>\\s]+)))?)","g"),g=new RegExp(u,"g"),h=/<|\{\{/,m=t("area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed"),b=t("a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video"),v=t("abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var"),x=t("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr"),w=t("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"),y=t("script,style"),k="start,end,close,attrStart,attrEnd,attrValue,chars,comment,special,done".split(","),E=function(){},A=function(t,a,n){function s(e,t,r,n){if(t=t.toLowerCase(),b[t])for(;w.last()&&v[w.last()];)i("",w.last());x[t]&&w.last()===t&&i("",t),n=m[t]||!!n,a.start(t,n),n||w.push(t),A.parseAttrs(r,a),a.end(t,n)}function i(e,t){var r;if(t)for(r=w.length-1;r>=0&&w[r]!==t;r--);else r=0;if(r>=0){for(var n=w.length-1;n>=r;n--)a.close&&a.close(w[n]);w.length=r}}function o(e,t){a.special&&a.special(t)}if("object"==typeof t)return r(t,a);var l=[];a=a||{},n&&e.each(k,function(t){var r=a[t]||E;a[t]=function(){r.apply(this,arguments)!==!1&&l.push({tokenType:t,args:e.makeArray(arguments)})}});var c,u,d,w=[],O=t;for(w.last=function(){return this[this.length-1]};t;){if(u=!0,w.last()&&y[w.last()])t=t.replace(new RegExp("([\\s\\S]*?)]*>"),function(e,t){return t=t.replace(/|/g,"$1$2"),a.chars&&a.chars(t),""}),i("",w.last());else if(0===t.indexOf(""),c>=0&&(a.comment&&a.comment(t.substring(4,c)),t=t.substring(c+3),u=!1)):0===t.indexOf("c?t:t.substring(0,c);t=0>c?"":t.substring(c),a.chars&&R&&a.chars(R)}if(t===O)throw"Parse Error: "+t;O=t}return i(),a.done(),l};return A.parseAttrs=function(e,t){(null!=e?e:"").replace(d,function(e,r,a,n,s,i){if(a&&t.special(a),r||n||s||i){var o=arguments[3]?arguments[3]:arguments[4]?arguments[4]:arguments[5]?arguments[5]:w[r.toLowerCase()]?r:"";t.attrStart(r||"");for(var l,c=g.lastIndex=0,u=g.exec(o);u;)l=o.substring(c,g.lastIndex-u[0].length),l.length&&t.attrValue(l),t.special(u[1]),c=g.lastIndex,u=g.exec(o);l=o.substr(c,o.length),l&&t.attrValue(l),t.attrEnd(r||"")}})},e.view.parser=A,A}); +/*can@2.2.6#view/live/live*/ +define("can/view/live/live",["can/util/util","can/view/elements","can/view/view","can/view/node_lists/node_lists","can/view/parser/parser"],function(e,t,n,r,i){t=t||e.view.elements,r=r||e.view.NodeLists,i=i||e.view.parser;var a=function(t,n,r){var i=!1,a=function(){return i||(i=!0,r(o),e.unbind.call(t,"removed",a)),!0},o={teardownCheck:function(e){return e?!1:a()}};return e.bind.call(t,"removed",a),n(o),o},o=function(e,t,n){return a(e,function(){t.bind("change",n)},function(e){t.unbind("change",n),e.nodeList&&r.unregister(e.nodeList)})},c=function(e){var t,n={};return i.parseAttrs(e,{attrStart:function(e){n[e]="",t=e},attrValue:function(e){n[t]+=e},attrEnd:function(){}}),n},u=[].splice,d=function(e){return e&&e.nodeType},s=function(e){e.childNodes.length||e.appendChild(document.createTextNode(""))},l={list:function(n,i,o,c,d,s){var f,p=s||[n],v=[],h=!1,g=!1,b=function(n,i,a){if(h){var d=document.createDocumentFragment(),l=[],f=[];e.each(i,function(t,n){var i=[];s&&r.register(i,null,!0);var u=e.compute(n+a),p=o.call(c,t,u,i),v="string"==typeof p,h=e.frag(p);h=v?e.view.hookup(h):h;var g=e.makeArray(h.childNodes);s?(r.update(i,g),l.push(i)):l.push(r.register(g)),d.appendChild(h),f.push(u)});var g=a+1;if(p[g]){var b=r.first(p[g]);e.insertBefore(b.parentNode,d,b)}else t.after(1===g?[N]:[r.last(p[g-1])],d);u.apply(p,[g,0].concat(l)),u.apply(v,[a,0].concat(f));for(var m=a+f.length,w=v.length;w>m;m++)v[m](m)}},m=function(t,n,i,a,o){if(h&&(a||!y.teardownCheck(N.parentNode))){0>i&&(i=v.length+i);var c=p.splice(i+1,n.length),u=[];e.each(c,function(e){var t=r.unregister(e);[].push.apply(u,t)}),v.splice(i,n.length);for(var d=i,s=v.length;s>d;d++)v[d](d);o?r.unregister(p):e.remove(e.$(u))}},w=function(t,n,i,a){if(h){i+=1,a+=1;var o,c=p[i],u=e.frag(r.flatten(p[a]));o=i>a?r.last(c).nextSibling:r.first(c);var d=p[0].parentNode;d.insertBefore(u,o);var s=p[a];[].splice.apply(p,[a,1]),[].splice.apply(p,[i,0,s])}},N=document.createTextNode(""),k=function(e){f&&f.unbind&&f.unbind("add",b).unbind("remove",m).unbind("move",w),m({},{length:p.length-1},0,!0,e)},A=function(t,n,r){g||(k(),f=n||[],f.bind&&f.bind("add",b).bind("remove",m).bind("move",w),h=!0,b({},f,0),h=!1,e.batch.afterPreviousEvents(function(){h=!0}))};d=t.getParentNode(n,d);var y=a(d,function(){e.isFunction(i)&&i.bind("change",A)},function(){e.isFunction(i)&&i.unbind("change",A),k(!0)});s?(t.replace(p,N),r.update(p,[N]),s.unregistered=function(){y.teardownCheck(),g=!0}):l.replace(p,N,y.teardownCheck),A({},e.isFunction(i)?i():i)},html:function(n,i,a,c){var u;a=t.getParentNode(n,a),u=o(a,i,function(e,t,n){var i=r.first(l).parentNode;i&&f(t),u.teardownCheck(r.first(l).parentNode)});var l=c||[n],f=function(n){var i="function"==typeof n,o=d(n),c=e.frag(i?"":n),u=e.makeArray(l);s(c),o||i||(c=e.view.hookup(c,a)),u=r.update(l,c.childNodes),i&&n(c.childNodes[0]),t.replace(u,c)};u.nodeList=l,c?c.unregistered=u.teardownCheck:r.register(l,u.teardownCheck),f(i())},replace:function(n,i,a){var o=n.slice(0),c=e.frag(i);return r.register(n,a),"string"==typeof i&&(c=e.view.hookup(c,n[0].parentNode)),r.update(n,c.childNodes),t.replace(o,c),n},text:function(n,i,a,c){var u=t.getParentNode(n,a),d=o(u,i,function(t,n,r){"unknown"!=typeof s.nodeValue&&(s.nodeValue=e.view.toStr(n)),d.teardownCheck(s.parentNode)}),s=document.createTextNode(e.view.toStr(i()));c?(c.unregistered=d.teardownCheck,d.nodeList=c,r.update(c,[s]),t.replace([n],s)):d.nodeList=l.replace([n],s,d.teardownCheck)},setAttributes:function(t,n){var r=c(n);for(var i in r)e.attr.set(t,i,r[i])},attributes:function(n,r,i){var a={},u=function(r){var i,o=c(r);for(i in o){var u=o[i],d=a[i];u!==d&&e.attr.set(n,i,u),delete a[i]}for(i in a)t.removeAttr(n,i);a=o};o(n,r,function(e,t){u(t)}),arguments.length>=3?a=c(i):u(r())},attributePlaceholder:"__!!__",attributeReplace:/__!!__/g,attribute:function(n,r,i){o(n,i,function(e,i){t.setAttr(n,r,u.render())});var a,c=e.$(n);a=e.data(c,"hooks"),a||e.data(c,"hooks",a={});var u,d=t.getAttr(n,r),s=d.split(l.attributePlaceholder),f=[];f.push(s.shift(),s.join(l.attributePlaceholder)),a[r]?a[r].computes.push(i):a[r]={render:function(){var e=0,n=d?d.replace(l.attributeReplace,function(){return t.contentText(u.computes[e++]())}):t.contentText(u.computes[e++]());return n},computes:[i],batchNum:void 0},u=a[r],f.splice(1,0,i()),t.setAttr(n,r,f.join(""))},specialAttribute:function(e,n,r){o(e,r,function(r,i){t.setAttr(e,n,p(i))}),t.setAttr(e,n,p(r()))},simpleAttribute:function(e,n,r){o(e,r,function(r,i){t.setAttr(e,n,i)}),t.setAttr(e,n,r())}};l.attr=l.simpleAttribute,l.attrs=l.attributes;var f=/(\r|\n)+/g,p=function(e){var n=/^["'].*["']$/;return e=e.replace(t.attrReg,"").replace(f,""),n.test(e)?e.substr(1,e.length-2):e};return e.view.live=l,l}); +/*can@2.2.6#view/render*/ +define("can/view/render",["can/view/view","can/view/elements","can/view/live/live","can/util/string/string"],function(t,n,e){var i,r=[],u=function(t){var e=n.tagMap[t]||"span";return"span"===e?"@@!!@@":"<"+e+">"+u(e)+""},o=function(n,e){if("string"==typeof n)return n;if(!n&&0!==n)return"";var i=n.hookup&&function(t,e){n.hookup.call(n,t,e)}||"function"==typeof n&&n;return i?e?"<"+e+" "+t.view.hook(i)+">":(r.push(i),""):""+n},c=function(n,e){return"string"==typeof n||"number"==typeof n?t.esc(n):o(n,e)},s=!1,a=function(){};return t.extend(t.view,{live:e,setupLists:function(){var n,e=t.view.lists;return t.view.lists=function(t,e){return n={list:t,renderer:e},Math.random()},function(){return t.view.lists=e,n}},getHooks:function(){var t=r.slice(0);return i=t,r=[],t},onlytxt:function(t,n){return c(n.call(t))},txt:function(f,p,l,v,h){var w,g,d,b,y=n.tagMap[p]||"span",k=!1,m=a;if(s)w=h.call(v);else{("string"==typeof l||1===l)&&(s=!0);var x=t.view.setupLists();m=function(){d.unbind("change",a)},d=t.compute(h,v,!1),d.bind("change",a),g=x(),w=d(),s=!1,k=d.computeInstance.hasDependencies}if(g)return m(),"<"+y+t.view.hook(function(t,n){e.list(t,g.list,g.renderer,v,n)})+">";if(!k||"function"==typeof w)return m(),(s||2===f||!f?o:c)(w,0===l&&y);var M=n.tagToContentPropMap[p];return 0!==l||M?1===l?(r.push(function(t){e.attributes(t,d,d()),m()}),d()):2===f?(b=l,r.push(function(t){e.specialAttribute(t,b,d),m()}),d()):(b=0===l?M:l,(0===l?i:r).push(function(t){e.attribute(t,b,d),m()}),e.attributePlaceholder):"<"+y+t.view.hook(f&&"object"!=typeof w?function(t,n){e.text(t,d,n),m()}:function(t,n){e.html(t,d,n),m()})+">"+u(y)+""}}),t}); +/*can@2.2.6#view/stache/utils*/ +define("can/view/stache/utils",["can/util/util"],function(){return{isArrayLike:function(t){return t&&t.splice&&"number"==typeof t.length},isObserveLike:function(t){return t instanceof can.Map||t&&!!t._get},emptyHandler:function(){},jsonParse:function(str){return"'"===str[0]?str.substr(1,str.length-2):"undefined"===str?void 0:can.global.JSON?JSON.parse(str):eval("("+str+")")},mixins:{last:function(){return this.stack[this.stack.length-1]},add:function(t){this.last().add(t)},subSectionDepth:function(){return this.stack.length-1}}}}); +/*can@2.2.6#view/stache/mustache_helpers*/ +define("can/view/stache/mustache_helpers",["can/util/util","can/view/stache/utils","can/view/live/live"],function(e,n,t){t=t||e.view.live;var i=function(t){return n.isObserveLike(t)&&n.isArrayLike(t)&&t.attr("length")?t:e.isFunction(t)?t():t},r={each:function(r,s){var o,u,a,c=i(r),f=[];if(c instanceof e.List)return function(n){var i=[n];i.expression="live.list",e.view.nodeLists.register(i,null,s.nodeList),e.view.nodeLists.update(s.nodeList,[n]);var o=function(e,n,t){return s.fn(s.scope.add({"@index":n}).add(e),s.options,t)};t.list(n,r,o,s.context,n.parentNode,i)};var l=c;if(l&&n.isArrayLike(l))for(a=0;a0&&t!==n)return r.inverse();n=t}return r.fn()},eq:function(){return r.is.apply(this,arguments)},unless:function(n,t){return r["if"].apply(this,[e.isFunction(n)?e.compute(function(){return!n()}):!n,t])},"with":function(e,n){var t=e;return e=i(e),e?n.fn(t):void 0},log:function(e,n){"undefined"!=typeof console&&console.log&&(n?console.log(e,n.context):console.log(e.context))},data:function(n){var t=2===arguments.length?this:arguments[1];return function(i){e.data(e.$(i),n,t||this.context)}}};return{registerHelper:function(e,n){r[e]=n},getHelper:function(e,n){var t=n.attr("helpers."+e);return t||(t=r[e]),t?{fn:t}:void 0}}}); +/*can@2.2.6#view/stache/mustache_core*/ +define("can/view/stache/mustache_core",["can/util/util","can/view/stache/utils","can/view/stache/mustache_helpers","can/view/live/live","can/view/elements","can/view/scope/scope","can/view/node_lists/node_lists"],function(e,t,n,r,i,a,s){r=r||e.view.live,i=i||e.view.elements,a=a||e.view.Scope,s=s||e.view.nodeLists;var o=/((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g,u=/^(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(?:(.+?)=(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(.+))))$/,c=/(?:(?:^|(\r?)\n)(\s*)(\{\{([^\}]*)\}\}\}?)([^\S\n\r]*)($|\r?\n))|(\{\{([^\}]*)\}\}\}?)/g,l=function(e){return e&&"string"==typeof e.get},f=function(e,t,n,r){for(var i=document.createDocumentFragment(),a=0,s=e.length;s>a;a++)p(i,n.fn(t?e.attr(""+a):e[a],r));return i},p=function(e,t){t&&e.appendChild("string"==typeof t?document.createTextNode(t):t)},h=function(e,t,n,r){for(var i="",a=0,s=e.length;s>a;a++)i+=n.fn(t?e.attr(""+a):e[a],r);return i},d=function(t,n,r){var i=n.computeData(t,{isArgument:r,args:[n.attr("."),n]});return e.compute.temporarilyBind(i.compute),i},v=function(e,t){var n=d(e,t,!0);return n.compute.computeInstance.hasDependencies?n.compute:n.initialValue},g=function(e,t,n,r,i,a){i&&(e.fn=m(i,t,n,r)),a&&(e.inverse=m(a,t,n,r))},m=function(t,n,r,i){var a=function(e,r,i){return t(e||n,r,i)};return e.__notObserve(function(t,s,o){void 0===t||t instanceof e.view.Scope||(t=n.add(t)),void 0===s||s instanceof x.Options||(s=r.add(s));var u=a(t,s||r,o||i);return u})},x={expressionData:function(n){var r=[],i={},a=0;return(e.trim(n)+" ").replace(o,function(e,n){var s;a&&(s=n.match(u))?s[1]||s[2]?r.push(t.jsonParse(s[1]||s[2])):i[s[3]]=s[6]?{get:s[6]}:t.jsonParse(s[4]||s[5]):r.push({get:n}),a++}),{name:r.shift(),args:r,hash:i}},makeEvaluator:function(r,i,a,s,o,u,c,p){for(var m,x,y,w=[],b={},_={fn:function(){},inverse:function(){}},O=r.attr("."),k=o.name,D=o.args.length||!e.isEmptyObject(o.hash),E=0,L=o.args.length;L>E;E++){var A=o.args[E];w.push(A&&l(A)?v(A.get,r,!0):A)}for(var N in o.hash)l(o.hash[N])?b[N]=v(o.hash[N].get,r):b[N]=o.hash[N];if(l(k)&&(D&&(m=n.getHelper(k.get,i),m||"function"!=typeof O[k.get]||(m={fn:O[k.get]})),!m)){var S=k.get,B=d(k.get,r,!1),R=B.compute;x=B.initialValue,k=B.compute.computeInstance.hasDependencies?R:x,D||void 0!==x?"function"==typeof x&&(m={fn:x}):m=n.getHelper(S,i)}if("^"===s){var j=u;u=c,c=j}if(m)return g(_,r,i,a,u,c),e.simpleExtend(_,{context:O,scope:r,contexts:r,hash:b,nodeList:a,exprData:o}),w.push(_),y=function(){return m.fn.apply(O,w)||""},y.bindOnce=!1,y;if(!s)return k&&k.isComputed?k:function(){return""+(null!=k?k:"")};if("#"===s||"^"===s){g(_,r,i,a,u,c);var F=function(){var n;if(n=e.isFunction(k)&&k.isComputed?k():k,t.isArrayLike(n)){var a=t.isObserveLike(n);return(a?n.attr("length"):n.length)?(p?h:f)(n,a,_,i):_.inverse(r,i)}return n?_.fn(n||r,i):_.inverse(r,i)};return F.bindOnce=!1,F}},makeLiveBindingPartialRenderer:function(t,n){return t=e.trim(t),function(i,a,o){var u=[this];u.expression=">"+t,s.register(u,null,n.directlyNested?o||!0:!0);var c=e.compute(function(){var n,r=t,s=a.attr("partials."+r);if(s)n=s.render?s.render(i,a):s(i,a);else{var o=i.read(r,{isArgument:!0,returnObserveMethods:!0,proxyMethods:!1}).value;o&&(r=o),n=e.view.render(r,i,a)}return e.frag(n)});r.html(this,c,this.parentNode,u)}},makeStringBranchRenderer:function(e,t){var n=w(t),r=e+t;return function(t,i,a,s){var o=t.__cache[r];(e||!o)&&(o=y(t,i,null,e,n,a,s,!0),e||(t.__cache[r]=o));var u=o();return null==u?"":""+u}},makeLiveBindingBranchRenderer:function(t,n,a){var o=w(n);return function(u,c,l,f,p){var h=[this];h.expression=n,s.register(h,null,a.directlyNested?l||!0:!0);var d=y(u,c,h,t,o,f,p,a.tag),v=e.compute(d,null,!1,d.bindOnce===!1?!1:!0);v.bind("change",e.k);var g=v();if("function"==typeof g){var m=e.__clearReading();g(this),e.__setReading(m)}else v.computeInstance.hasDependencies?a.attr?r.simpleAttribute(this,a.attr,v):a.tag?r.attributes(this,v):a.text&&"object"!=typeof g?r.text(this,v,this.parentNode,h):r.html(this,v,this.parentNode,h):a.attr?e.attr.set(this,a.attr,g):a.tag?r.setAttributes(this,g):a.text&&"string"==typeof g?this.nodeValue=g:g&&i.replace([this],e.frag(g));v.unbind("change",e.k)}},splitModeFromExpression:function(t,n){t=e.trim(t);var r=t.charAt(0);return"#/{&^>!".indexOf(r)>=0?t=e.trim(t.substr(1)):r=null,"{"===r&&n.node&&(r=null),{mode:r,expression:t}},cleanLineEndings:function(e){return e.replace(c,function(e,t,n,r,i,a,s,o,u,c){a=a||"",t=t||"",n=n||"";var l=b(i||u,{});return o||">{".indexOf(l.mode)>=0?e:"^#!/".indexOf(l.mode)>=0?r+(0!==c&&s.length?t+"\n":""):n+r+a+(n.length||0!==c?t+"\n":"")})},Options:e.view.Scope.extend({init:function(t,n){t.helpers||t.partials||t.tags||(t={helpers:t}),e.view.Scope.prototype.init.apply(this,arguments)}})},y=x.makeEvaluator,w=x.expressionData,b=x.splitModeFromExpression;return x}); +/*can@2.2.6#view/bindings/bindings*/ +define("can/view/bindings/bindings",["can/util/util","can/view/stache/mustache_core","can/view/callbacks/callbacks","can/control/control","can/view/scope/scope"],function(e,t){var n=function(){var e={"":!0,"true":!0,"false":!1},t=function(t){if(t&&t.getAttribute){var n=t.getAttribute("contenteditable");return e[n]}};return function(e){var n=t(e);return"boolean"==typeof n?n:!!t(e.parentNode)}}(),i=function(e){return"{"===e[0]&&"}"===e[e.length-1]?e.substr(1,e.length-2):e};e.view.attr("can-value",function(t,a){var c,l,h=e.trim(i(t.getAttribute("can-value"))),v=a.scope.computeData(h,{args:[]}).compute;return"input"===t.nodeName.toLowerCase()&&("checkbox"===t.type&&(c=e.attr.has(t,"can-true-value")?t.getAttribute("can-true-value"):!0,l=e.attr.has(t,"can-false-value")?t.getAttribute("can-false-value"):!1),"checkbox"===t.type||"radio"===t.type)?void new o(t,{value:v,trueValue:c,falseValue:l}):"select"===t.nodeName.toLowerCase()&&t.multiple?void new u(t,{value:v}):n(t)?void new r(t,{value:v}):void new s(t,{value:v})});var a={enter:function(e,t,n){return{event:"keyup",handler:function(e){return 13===e.keyCode?n.call(this,e):void 0}}}};e.view.attr(/can-[\w\.]+/,function(n,s){var o=s.attributeName,u=o.substr("can-".length),r=function(a){var u=n.getAttribute(o);if(u){var r=t.expressionData(i(u)),c=s.scope.read(r.name.get,{returnObserveMethods:!0,isArgument:!0,executeAnonymousFunctions:!0}),l=[],h=e.$(this),v=e.viewModel(h[0]),f=s.scope.add({"@element":h,"@event":a,"@viewModel":v,"@scope":s.scope,"@context":s.scope._context});if(!e.isEmptyObject(r.hash)){var p={};e.each(r.hash,function(e,t){if(e&&e.hasOwnProperty("get")){var n=e.get.indexOf("@")?s.scope:f;p[t]=n.read(e.get,{}).value}else p[t]=e}),l.unshift(p)}if(r.args.length)for(var d,g=r.args.length-1;g>=0;g--)if(d=r.args[g],d&&d.hasOwnProperty("get")){var m=d.get.indexOf("@")?s.scope:f;l.unshift(m.read(d.get,{}).value)}else l.unshift(d);return l.length||(l=[s.scope._context,h].concat(e.makeArray(arguments))),c.value.apply(c.parent,l)}};if(a[u]){var c=a[u](s,n,r);r=c.handler,u=c.event}e.bind.call(n,u,r)});var s=e.Control.extend({init:function(){"SELECT"===this.element[0].nodeName.toUpperCase()?setTimeout(e.proxy(this.set,this),1):this.set()},"{value} change":"set",set:function(){if(this.element){var e=this.options.value();this.element[0].value=null==e?"":e}},change:function(){if(this.element){var e=this.element[0];this.options.value(e.value);var t=this.options.value();e.value!==t&&(e.value=t)}}}),o=e.Control.extend({init:function(){this.isCheckbox="checkbox"===this.element[0].type.toLowerCase(),this.check()},"{value} change":"check",check:function(){if(this.isCheckbox){var t=this.options.value(),n=this.options.trueValue||!0;this.element[0].checked=t==n}else{var i=this.options.value()==this.element[0].value?"set":"remove";e.attr[i](this.element[0],"checked",!0)}},change:function(){this.isCheckbox?this.options.value(this.element[0].checked?this.options.trueValue:this.options.falseValue):this.element[0].checked&&this.options.value(this.element[0].value)}}),u=s.extend({init:function(){this.delimiter=";",setTimeout(e.proxy(this.set,this),1)},set:function(){var t=this.options.value();"string"==typeof t?(t=t.split(this.delimiter),this.isString=!0):t&&(t=e.makeArray(t));var n={};e.each(t,function(e){n[e]=!0}),e.each(this.element[0].childNodes,function(e){e.value&&(e.selected=!!n[e.value])})},get:function(){var t=[],n=this.element[0].childNodes;return e.each(n,function(e){e.selected&&e.value&&t.push(e.value)}),t},change:function(){var t=this.get(),n=this.options.value();this.isString||"string"==typeof n?(this.isString=!0,this.options.value(t.join(this.delimiter))):n instanceof e.List?n.attr(t,!0):this.options.value(t)}}),r=e.Control.extend({init:function(){this.set(),this.on("blur","setValue")},"{value} change":"set",set:function(){var e=this.options.value();this.element[0].innerHTML="undefined"==typeof e?"":e},setValue:function(){this.options.value(this.element[0].innerHTML)}})}); +/*can@2.2.6#view/mustache/mustache*/ +define("can/view/mustache/mustache",["can/util/util","can/view/scope/scope","can/view/view","can/view/scanner","can/compute/compute","can/view/render","can/view/bindings/bindings"],function(e){e.view.ext=".mustache";var n="scope",t="___h4sh",r="{scope:"+n+",options:options}",i="{scope:"+n+",options:options, special: true}",s=n+",options",o=/((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g,a=/^(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false|null|undefined)|((.+?)=(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false)|(.+))))$/,c=function(e){return'{get:"'+e.replace(/"/g,'\\"')+'"}'},u=function(e){return e&&"string"==typeof e.get},f=function(n){return n instanceof e.Map||n&&!!n._get},p=function(e){return e&&e.splice&&"number"==typeof e.length},l=function(n,t,r){var i=function(e,r){return n(e||t,r)};return function(n,s){return void 0===n||n instanceof e.view.Scope||(n=t.add(n)),void 0===s||s instanceof e.view.Options||(s=r.add(s)),i(n,s||r)}},h=function(n,t){if(this.constructor!==h){var r=new h(n);return function(e,n){return r.render(e,n)}}return"function"==typeof n?void(this.template={fn:n}):(e.extend(this,n),void(this.template=this.scanner.scan(this.text,this.name)))};e.Mustache=e.global.Mustache=h,h.prototype.render=function(n,t){return n instanceof e.view.Scope||(n=new e.view.Scope(n||{})),t instanceof e.view.Options||(t=new e.view.Options(t||{})),t=t||{},this.template.fn.call(n,n,t)},e.extend(h.prototype,{scanner:new e.view.Scanner({text:{start:"",scope:n,options:",options: options",argNames:s},tokens:[["returnLeft","{{{","{{[{&]"],["commentFull","{{!}}","^[\\s\\t]*{{!.+?}}\\n"],["commentLeft","{{!","(\\n[\\s\\t]*{{!|{{!)"],["escapeFull","{{}}","(^[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}$)",function(e){return{before:/^\n.+?\n$/.test(e)?"\n":"",content:e.match(/\{\{(.+?)\}\}/)[1]||""}}],["escapeLeft","{{"],["returnRight","}}}"],["right","}}"]],helpers:[{name:/^>[\s]*\w*/,fn:function(n,t){var r=e.trim(n.replace(/^>\s?/,"")).replace(/["|']/g,"");return"can.Mustache.renderPartial('"+r+"',"+s+")"}},{name:/^\s*data\s/,fn:function(e,t){var r=e.match(/["|'](.*)["|']/)[1];return"can.proxy(function(__){can.data(can.$(__),'"+r+"', this.attr('.')); }, "+n+")"}},{name:/\s*\(([\$\w]+)\)\s*->([^\n]*)/,fn:function(e){var t=/\s*\(([\$\w]+)\)\s*->([^\n]*)/,r=e.match(t);return"can.proxy(function(__){var "+r[1]+"=can.$(__);with("+n+".attr('.')){"+r[2]+"}}, this);"}},{name:/^.*$/,fn:function(n,u){var f=!1,p={content:"",startTxt:!1,startOnlyTxt:!1,end:!1};if(n=e.trim(n),n.length&&(f=n.match(/^([#^\/]|else$)/))){switch(f=f[0]){case"#":case"^":u.specialAttribute?p.startOnlyTxt=!0:(p.startTxt=!0,p.escaped=0);break;case"/":return p.end=!0,p.content+='return ___v1ew.join("");}}])',p}n=n.substring(1)}if("else"!==f){var l,h=[],v=[],g=0;p.content+="can.Mustache.txt(\n"+(u.specialAttribute?i:r)+",\n"+(f?'"'+f+'"':"null")+",",(e.trim(n)+" ").replace(o,function(e,n){g&&(l=n.match(a))?l[2]?h.push(l[0]):v.push(l[4]+":"+(l[6]?l[6]:c(l[5]))):h.push(c(n)),g++}),p.content+=h.join(","),v.length&&(p.content+=",{"+t+":{"+v.join(",")+"}}")}switch(f&&"else"!==f&&(p.content+=",[\n\n"),f){case"^":case"#":p.content+="{fn:function("+s+"){var ___v1ew = [];";break;case"else":p.content+='return ___v1ew.join("");}},\n{inverse:function('+s+"){\nvar ___v1ew = [];";break;default:p.content+=")"}return f||(p.startTxt=!0,p.end=!0),p}}]})});for(var v=e.view.Scanner.prototype.helpers,g=0;g0&&t!==n)return r.inverse();n=t}return r.fn()},eq:function(){return h._helpers.is.fn.apply(this,arguments)},unless:function(n,t){return h._helpers["if"].fn.apply(this,[e.isFunction(n)?e.compute(function(){return!n()}):!n,t])},each:function(n,t){var r,i,s,o=h.resolve(n),a=[];if(e.view.lists&&(o instanceof e.List||n&&n.isComputed&&void 0===o))return e.view.lists(n,function(e,n){return t.fn(t.scope.add({"@index":n}).add(e))});if(n=o,n&&p(n)){for(s=0;st;t++)f[t]()};if(t.each(this.constructor.attributeScopeMappings,function(e,n){r[n]=i.getAttribute(t.hyphenate(e))}),t.each(t.makeArray(i.attributes),function(n,i){var c=t.camelize(n.nodeName.toLowerCase()),u=n.value;if(!(p.constructor.attributeScopeMappings[c]||o.test(c)||e.attr(n.nodeName))){if("{"===u[0]&&"}"===u[u.length-1])u=u.substr(1,u.length-2);else if("legacy"!==s.templateType)return void(r[c]=u);var h=s.scope.computeData(u,{args:[]}),m=h.compute,v=function(e,n){d[c]=(d[c]||0)+1,a.attr(c,n),t.batch.afterPreviousEvents(function(){--d[c]})};m.bind("change",v),r[c]=m(),m.computeInstance.hasDependencies?(f.push(function(){m.unbind("change",v)}),l[c]=h):m.unbind("change",v)}}),this.constructor.Map)a=new this.constructor.Map(r);else if(h instanceof t.Map)a=h;else if(t.isFunction(h)){var v=h.call(this,r,s.scope,i);a=v instanceof t.Map?v:v.prototype instanceof t.Map?new v(r):new(t.Map.extend(v))(r)}var g={};t.each(l,function(t,e){g[e]=function(n,o){d[e]||t.compute(o)},a.bind(e,g[e])}),t.isEmptyObject(this.constructor.attributeScopeMappings)&&"legacy"===s.templateType||t.bind.call(i,"attributes",function(e){var n=t.camelize(e.attributeName);l[n]||o.test(n)||a.attr(n,i.getAttribute(e.attributeName))}),this.scope=this.viewModel=a,t.data(t.$(i),"scope",this.scope),t.data(t.$(i),"viewModel",this.scope);var b=u?this.scope:s.scope.add(this.scope),y={helpers:{}};if(t.each(this.helpers||{},function(e,n){t.isFunction(e)&&(y.helpers[n]=function(){return e.apply(a,arguments)})}),f.push(function(){t.each(g,function(t,e){a.unbind(e,g[e])})}),this._control=new this.constructor.Control(i,{scope:this.scope,viewModel:this.scope}),this._control&&this._control.destroy){var w=this._control.destroy;this._control.destroy=function(){w.apply(this,arguments),m()},this._control.on()}else t.bind.call(i,"removed",function(){m()});var M=t.view.nodeLists.register([],void 0,!0);f.push(function(){t.view.nodeLists.unregister(M)}),this.constructor.renderer?(y.tags||(y.tags={}),y.tags.content=function C(e,o){var i=s.subtemplate||o.subtemplate;if(i){delete y.tags.content;var a=u&&i===s.subtemplate?s:o;if(o.parentNodeList){var c=i(a.scope,a.options,o.parentNodeList);n.replace([e],c)}else t.view.live.replace([e],i(a.scope,a.options));y.tags.content=C}},c=this.constructor.renderer(b,s.options.add(y),M)):c="legacy"===s.templateType?t.view.frag(s.subtemplate?s.subtemplate(b,s.options.add(y)):""):s.subtemplate?s.subtemplate(b,s.options.add(y),M):document.createDocumentFragment(),t.appendChild(i,c),t.view.nodeLists.update(M,i.childNodes)}}),a=t.Control.extend({_lookup:function(t){return[t.scope,t,window]},_action:function(e,n,o){var s,a;if(i.lastIndex=0,s=i.test(e),o||!s){if(s){a=t.compute(function(){var o,s=e.replace(i,function(e,i){var s;return"scope"===i||"viewModel"===i?(o=n.scope,""):(i=i.replace(/^(scope|^viewModel)\./,""),s=t.compute.read(n.scope,i.split("."),{isArgument:!0}).value,void 0===s&&(s=t.getObject(i)),"string"==typeof s?s:(o=s,""))}),a=s.split(/\s+/g),c=a.pop();return{processor:this.processors[c]||this.processors.click,parts:[s,a.join(" "),c],delegate:o||void 0}},this);var c=function(t,n){o._bindings.control[e](o.element),o._bindings.control[e]=n.processor(n.delegate||o.element,n.parts[2],n.parts[1],e,o)};return a.bind("change",c),o._bindings.readyComputes[e]={compute:a,handler:c},a()}return t.Control._action.apply(this,arguments)}}},{setup:function(e,n){return this.scope=n.scope,this.viewModel=n.viewModel,t.Control.prototype.setup.call(this,e,n)},off:function(){this._bindings&&t.each(this._bindings.readyComputes||{},function(t){t.compute.unbind("change",t.handler)}),t.Control.prototype.off.apply(this,arguments),this._bindings.readyComputes={}}}),c=t.$;return c.fn&&(c.fn.scope=c.fn.viewModel=function(){return t.viewModel.apply(t,[this].concat(t.makeArray(arguments)))}),s}); +/*can@2.2.6#model/model*/ +define("can/model/model",["can/util/util","can/map/map","can/list/list"],function(t){var e=function(e,r,i){var n=new t.Deferred;return e.then(function(){var e=t.makeArray(arguments),s=!0;try{e[0]=i.apply(r,e)}catch(o){s=!1,n.rejectWith(n,[o].concat(e))}s&&n.resolveWith(n,e)},function(){n.rejectWith(this,arguments)}),"function"==typeof e.abort&&(n.abort=function(){return e.abort()}),n},r=0,i=function(e){return t.__observe(e,e.constructor.id),e.__get(e.constructor.id)},n=function(e,r,i,n,s,o){var a={};if("string"==typeof e){var u=e.split(/\s+/);a.url=u.pop(),u.length&&(a.type=u.pop())}else t.extend(a,e);return a.data="object"!=typeof r||t.isArray(r)?r:t.extend(a.data||{},r),a.url=t.sub(a.url,a.data,!0),t.ajax(t.extend({type:i||"post",dataType:n||"json",success:s,error:o},a))},s=function(r,n,s,o,a){var u;t.isArray(r)?(u=r[1],r=r[0]):u=r.serialize(),u=[u];var c,l,d=r.constructor;return("update"===n||"destroy"===n)&&u.unshift(i(r)),l=d[n].apply(d,u),c=e(l,r,function(t){return r[a||n+"d"](t,l),r}),l.abort&&(c.abort=function(){l.abort()}),c.then(s,o),c},o={models:function(e,r,i){if(t.Model._reqs++,e){if(e instanceof this.List)return e;var n=this,s=[],o=n.List||f,a=r instanceof t.List?r:new o,u=e instanceof f,c=u?e.serialize():e;if(c=n.parseModels(c,i),c.data&&(e=c,c=c.data),"undefined"==typeof c||!t.isArray(c))throw new Error("Could not get any raw data while converting using .models");return a.length&&a.splice(0),t.each(c,function(t){s.push(n.model(t,i))}),a.push.apply(a,s),t.isArray(e)||t.each(e,function(t,e){"data"!==e&&a.attr(e,t)}),setTimeout(t.proxy(this._clean,this),1),a}},model:function(e,r,i){if(e){e="function"==typeof e.serialize?e.serialize():this.parseModel(e,i);var n=e[this.id];(n||0===n)&&this.store[n]&&(r=this.store[n]);var s=r&&t.isFunction(r.attr)?r.attr(e,this.removeAttr||!1):new this(e);return s}}},a={parseModel:function(e){return function(r){return e?t.getObject(e,r):r}},parseModels:function(e){return function(r){if(t.isArray(r))return r;e=e||"data";var i=t.getObject(e,r);if(!t.isArray(i))throw new Error("Could not get any raw data while converting using .models");return i}}},u={create:{url:"_shortName",type:"post"},update:{data:function(e,r){r=r||{};var i=this.id;return r[i]&&r[i]!==e&&(r["new"+t.capitalize(e)]=r[i],delete r[i]),r[i]=e,r},type:"put"},destroy:{type:"delete",data:function(t,e){return e=e||{},e.id=e[this.id]=t,e}},findAll:{url:"_shortName"},findOne:{}},c=function(t,e){return function(r){return r=t.data?t.data.apply(this,arguments):r,n(e||this[t.url||"_url"],r,t.type||"get")}},l=function(t,e){if(t.resource){var r=t.resource.replace(/\/+$/,"");return"findAll"===e||"create"===e?r:r+"/{"+t.id+"}"}};t.Model=t.Map.extend({fullName:"can.Model",_reqs:0,setup:function(e,i,n,s){if("string"!=typeof i&&(s=n,n=i),s||(s=n),this.store={},t.Map.setup.apply(this,arguments),t.Model){n&&n.List?(this.List=n.List,this.List.Map=this):this.List=e.List.extend({Map:this},{});var d=this,p=t.proxy(this._clean,d);t.each(u,function(r,i){if(n&&n[i]&&("string"==typeof n[i]||"object"==typeof n[i])?d[i]=c(r,n[i]):n&&n.resource&&!t.isFunction(n[i])&&(d[i]=c(r,l(d,i))),d["make"+t.capitalize(i)]){var s=d["make"+t.capitalize(i)](d[i]);t.Construct._overwrite(d,e,i,function(){t.Model._reqs++;var e=s.apply(this,arguments),r=e.then(p,p);return r.abort=e.abort,r})}});var h={};t.each(o,function(r,i){var s="parse"+t.capitalize(i),o=n&&n[i]||d[i];"string"==typeof o?(d[s]=o,t.Construct._overwrite(d,e,i,r)):n&&n[i]&&(h[s]=!0)}),t.each(a,function(r,i){var s=n&&n[i]||d[i];if("string"==typeof s)t.Construct._overwrite(d,e,i,r(s));else if(!(n&&t.isFunction(n[i])||d[i])){var o=r();o.useModelConverter=h[i],t.Construct._overwrite(d,e,i,o)}}),"can.Model"!==d.fullName&&d.fullName||(d.fullName="Model"+ ++r),t.Model._reqs=0,this._url=this._shortName+"/{"+this.id+"}"}},_ajax:c,_makeRequest:s,_clean:function(){if(t.Model._reqs--,!t.Model._reqs)for(var e in this.store)this.store[e]._bindings||delete this.store[e];return arguments[0]},models:o.models,model:o.model},{setup:function(e){var r=e&&e[this.constructor.id];t.Model._reqs&&null!=r&&(this.constructor.store[r]=this),t.Map.prototype.setup.apply(this,arguments)},isNew:function(){var t=i(this);return!(t||0===t)},save:function(t,e){return s(this,this.isNew()?"create":"update",t,e)},destroy:function(e,r){if(this.isNew()){var i=this,n=t.Deferred();return n.then(e,r),n.done(function(t){i.destroyed(t)}).resolve(i)}return s(this,"destroy",e,r,"destroyed")},_bindsetup:function(){var e=this.__get(this.constructor.id);return null!=e&&(this.constructor.store[e]=this),t.Map.prototype._bindsetup.apply(this,arguments)},_bindteardown:function(){return delete this.constructor.store[i(this)],t.Map.prototype._bindteardown.apply(this,arguments)},___set:function(e,r){t.Map.prototype.___set.call(this,e,r),e===this.constructor.id&&this._bindings&&(this.constructor.store[i(this)]=this)}});var d=function(t){return function(e,r,i){return this[t](e,null,i)}},p=function(t){return this.parseModel.useModelConverter?this.model(t):this.parseModel(t)},h={makeFindAll:d("models"),makeFindOne:d("model"),makeCreate:p,makeUpdate:p,makeDestroy:p};t.each(h,function(r,i){t.Model[i]=function(i){return function(){var n=t.makeArray(arguments),s=t.isFunction(n[1])?n.splice(0,1):n.splice(0,2),o=e(i.apply(this,s),this,r);return o.then(n[0],n[1]),o}}}),t.each(["created","updated","destroyed"],function(e){t.Model.prototype[e]=function(r){var i=this,n=i.constructor;r&&"object"==typeof r&&this.attr(t.isFunction(r.attr)?r.attr():r),t.dispatch.call(this,{type:"change",target:this},[e]),t.dispatch.call(n,e,[this])}});var f=t.Model.List=t.List.extend({_bubbleRule:function(e,r){var i=t.List._bubbleRule(e,r);return i.push("destroyed"),i}},{setup:function(e){t.isPlainObject(e)&&!t.isArray(e)?(t.List.prototype.setup.apply(this),this.replace(t.isDeferred(e)?e:this.constructor.Map.findAll(e))):t.List.prototype.setup.apply(this,arguments),this._init=1,this.bind("destroyed",t.proxy(this._destroyed,this)),delete this._init},_destroyed:function(t,e){if(/\w+/.test(e))for(var r;(r=this.indexOf(t.target))>-1;)this.splice(r,1)}});return t.Model}); +/*can@2.2.6#util/string/deparam/deparam*/ +define("can/util/string/deparam/deparam",["can/util/util","can/util/string/string"],function(t){var n=/^\d+$/,e=/([^\[\]]+)|(\[\])/g,r=/([^?#]*)(#.*)?$/,i=function(t){return decodeURIComponent(t.replace(/\+/g," "))};return t.extend(t,{deparam:function(a){var u,c,o={};return a&&r.test(a)&&(u=a.split("&"),t.each(u,function(t){var r=t.split("="),a=i(r.shift()),u=i(r.join("=")),p=o;if(a){r=a.match(e);for(var s=0,d=r.length-1;d>s;s++)p[r[s]]||(p[r[s]]=n.test(r[s+1])||"[]"===r[s+1]?[]:{}),p=p[r[s]];c=r.pop(),"[]"===c?p.push(u):p[c]=u}})),o}}),t}); +/*can@2.2.6#route/route*/ +define("can/route/route",["can/util/util","can/map/map","can/list/list","can/util/string/deparam/deparam"],function(t){var e,r,n,a,u=/\:([\w\.]+)/g,o=/^(?:&[^=]+=[^&]*)+/,i=function(e){var r=[];return t.each(e,function(e,n){r.push(("className"===n?"class":n)+'="'+("href"===n?e:t.esc(e))+'"')}),r.join(" ")},c=function(t,e){var r=0,n=0,a={};for(var u in t.defaults)t.defaults[u]===e[u]&&(a[u]=1,r++);for(;no&&(n=t,o=a),a>=l?!1:void 0}),t.route.routes[i]&&c(t.route.routes[i],e)===o&&(n=t.route.routes[i]),n){var s,h=f({},e),p=n.route.replace(u,function(t,r){return delete h[r],e[r]===n.defaults[r]?"":encodeURIComponent(e[r])}).replace("\\","");return d(n.defaults,function(t,e){h[e]===t&&delete h[e]}),s=t.param(h),r&&t.route.attr("route",n.route),p+(s?t.route._call("querySeparator")+s:"")}return t.isEmptyObject(e)?"":t.route._call("querySeparator")+t.param(e)},deparam:function(e){var r=t.route._call("root");r.lastIndexOf("/")===r.length-1&&0===e.indexOf("/")&&(e=e.substr(1));var n={length:-1},a=t.route._call("querySeparator"),u=t.route._call("paramsMatcher");if(d(t.route.routes,function(t,r){t.test.test(e)&&t.length>n.length&&(n=t)}),n.length>-1){var o=e.match(n.test),i=o.shift(),c=e.substr(i.length-(o[o.length-1]===a?1:0)),l=c&&u.test(c)?t.deparam(c.slice(1)):{};return l=f(!0,{},n.defaults,l),d(o,function(t,e){t&&t!==a&&(l[n.names[e]]=decodeURIComponent(t))}),l.route=n.route,l}return e.charAt(0)!==a&&(e=a+e),u.test(e)?t.deparam(e.slice(1)):{}},data:new t.Map({}),map:function(e){var r;r=e.prototype instanceof t.Map?new e:e,t.route.data=r},routes:{},ready:function(e){return e!==!0&&(t.route._setup(),t.route.setState()),t.route},url:function(e,r){return r&&(e=t.extend({},t.route.deparam(t.route._call("matchingPartOfURL")),e)),t.route._call("root")+t.route.param(e)},link:function(e,r,n,a){return""+e+""},current:function(e){return t.__observe(_,"__url"),this._call("matchingPartOfURL")===t.route.param(e)},bindings:{hashchange:{paramsMatcher:o,querySeparator:"&",matchSlashes:!1,bind:function(){t.bind.call(window,"hashchange",b)},unbind:function(){t.unbind.call(window,"hashchange",b)},matchingPartOfURL:function(){return l.href.split(/#!?/)[1]||""},setURL:function(t){return l.hash!=="#"+t&&(l.hash="!"+t),t},root:"#!"}},defaultBinding:"hashchange",currentBinding:null,_setup:function(){t.route.currentBinding||(t.route._call("bind"),t.route.bind("change",m),t.route.currentBinding=t.route.defaultBinding)},_teardown:function(){t.route.currentBinding&&(t.route._call("unbind"),t.route.unbind("change",m),t.route.currentBinding=null),clearTimeout(e),a=0},_call:function(){var e=t.makeArray(arguments),r=e.shift(),n=t.route.bindings[t.route.currentBinding||t.route.defaultBinding],a=n[r];return a.apply?a.apply(n,e):a}}),d(["bind","unbind","on","off","delegate","undelegate","removeAttr","compute","_get","__get","each"],function(e){t.route[e]=function(){return t.route.data[e]?t.route.data[e].apply(t.route.data,arguments):void 0}}),t.route.attr=function(e,r){var n,a=typeof e;return n=void 0===r?arguments:"string"!==a&&"number"!==a?[h(e),r]:[e,h(r)],t.route.data.attr.apply(t.route.data,n)};var b=t.route.setState=function(){var e=t.route._call("matchingPartOfURL"),u=r;r=t.route.deparam(e),a&&e===n||(t.batch.start(),v(u,r,t.route.data),t.route.attr(r),t.batch.trigger(_,"__url",[e,n]),t.batch.stop())},v=function(t,e,r){for(var n in t)void 0===e[n]?r.removeAttr(n):"[object Object]"===Object.prototype.toString.call(t[n])&&v(t[n],e[n],r.attr(n))};return t.route}); +/*can@2.2.6#control/route/route*/ +define("can/control/route/route",["can/util/util","can/route/route","can/control/control"],function(t){return t.Control.processors.route=function(o,r,u,n,e){u=u||"",t.route.routes[u]||("/"===u[0]&&(u=u.substring(1)),t.route(u));var c,i=function(o,r,i){if(t.route.attr("route")===u&&(void 0===o.batchNum||o.batchNum!==c)){c=o.batchNum;var a=t.route.attr();delete a.route,t.isFunction(e[n])?e[n](a):e[e[n]](a)}};return t.route.bind("change",i),function(){t.route.unbind("change",i)}},t}); +/*[global-shim-end]*/ +!function(){window._define=window.define,window.define=window.define.orig}(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.ejs.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.ejs.js new file mode 100644 index 0000000000..f5f76b5e71 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.ejs.js @@ -0,0 +1,227 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#view/ejs/ejs*/ +define('can/view/ejs/ejs', [ + 'can/util/util', + 'can/view/view', + 'can/util/string/string', + 'can/compute/compute', + 'can/view/scanner', + 'can/view/render' +], function (can) { + var extend = can.extend, EJS = function (options) { + if (this.constructor !== EJS) { + var ejs = new EJS(options); + return function (data, helpers) { + return ejs.render(data, helpers); + }; + } + if (typeof options === 'function') { + this.template = { fn: options }; + return; + } + extend(this, options); + this.template = this.scanner.scan(this.text, this.name); + }; + can.EJS = EJS; + EJS.prototype.render = function (object, extraHelpers) { + object = object || {}; + return this.template.fn.call(object, object, new EJS.Helpers(object, extraHelpers || {})); + }; + extend(EJS.prototype, { + scanner: new can.view.Scanner({ + text: { + outStart: 'with(_VIEW) { with (_CONTEXT) {', + outEnd: '}}', + argNames: '_CONTEXT,_VIEW', + context: 'this' + }, + tokens: [ + [ + 'templateLeft', + '<%%' + ], + [ + 'templateRight', + '%>' + ], + [ + 'returnLeft', + '<%==' + ], + [ + 'escapeLeft', + '<%=' + ], + [ + 'commentLeft', + '<%#' + ], + [ + 'left', + '<%' + ], + [ + 'right', + '%>' + ], + [ + 'returnRight', + '%>' + ] + ], + helpers: [{ + name: /\s*\(([\$\w]+)\)\s*->([^\n]*)/, + fn: function (content) { + var quickFunc = /\s*\(([\$\w]+)\)\s*->([^\n]*)/, parts = content.match(quickFunc); + return 'can.proxy(function(__){var ' + parts[1] + '=can.$(__);' + parts[2] + '}, this);'; + } + }], + transform: function (source) { + return source.replace(/<%([\s\S]+?)%>/gm, function (whole, part) { + var brackets = [], foundBracketPair, i; + part.replace(/[{}]/gm, function (bracket, offset) { + brackets.push([ + bracket, + offset + ]); + }); + do { + foundBracketPair = false; + for (i = brackets.length - 2; i >= 0; i--) { + if (brackets[i][0] === '{' && brackets[i + 1][0] === '}') { + brackets.splice(i, 2); + foundBracketPair = true; + break; + } + } + } while (foundBracketPair); + if (brackets.length >= 2) { + var result = ['<%'], bracket, last = 0; + for (i = 0; bracket = brackets[i]; i++) { + result.push(part.substring(last, last = bracket[1])); + if (bracket[0] === '{' && i < brackets.length - 1 || bracket[0] === '}' && i > 0) { + result.push(bracket[0] === '{' ? '{ %><% ' : ' %><% }'); + } else { + result.push(bracket[0]); + } + ++last; + } + result.push(part.substring(last), '%>'); + return result.join(''); + } else { + return '<%' + part + '%>'; + } + }); + } + }) + }); + EJS.Helpers = function (data, extras) { + this._data = data; + this._extras = extras; + extend(this, extras); + }; + EJS.Helpers.prototype = { + list: function (list, cb) { + can.each(list, function (item, i) { + cb(item, i, list); + }); + }, + each: function (list, cb) { + if (can.isArray(list)) { + this.list(list, cb); + } else { + can.view.lists(list, cb); + } + } + }; + can.view.register({ + suffix: 'ejs', + script: function (id, src) { + return 'can.EJS(function(_CONTEXT,_VIEW) { ' + new EJS({ + text: src, + name: id + }).template.out + ' })'; + }, + renderer: function (id, text) { + return EJS({ + text: text, + name: id + }); + } + }); + can.ejs.Helpers = EJS.Helpers; + return can; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.fixture.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.fixture.js new file mode 100644 index 0000000000..c2580d6d08 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.fixture.js @@ -0,0 +1,655 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#util/object/object*/ +define('can/util/object/object', ['can/util/util'], function (can) { + var isArray = can.isArray; + can.Object = {}; + var same = can.Object.same = function (a, b, compares, aParent, bParent, deep) { + var aType = typeof a, aArray = isArray(a), comparesType = typeof compares, compare; + if (comparesType === 'string' || compares === null) { + compares = compareMethods[compares]; + comparesType = 'function'; + } + if (comparesType === 'function') { + return compares(a, b, aParent, bParent); + } + compares = compares || {}; + if (a === null || b === null) { + return a === b; + } + if (a instanceof Date || b instanceof Date) { + return a === b; + } + if (deep === -1) { + return aType === 'object' || a === b; + } + if (aType !== typeof b || aArray !== isArray(b)) { + return false; + } + if (a === b) { + return true; + } + if (aArray) { + if (a.length !== b.length) { + return false; + } + for (var i = 0; i < a.length; i++) { + compare = compares[i] === undefined ? compares['*'] : compares[i]; + if (!same(a[i], b[i], a, b, compare)) { + return false; + } + } + return true; + } else if (aType === 'object' || aType === 'function') { + var bCopy = can.extend({}, b); + for (var prop in a) { + compare = compares[prop] === undefined ? compares['*'] : compares[prop]; + if (!same(a[prop], b[prop], compare, a, b, deep === false ? -1 : undefined)) { + return false; + } + delete bCopy[prop]; + } + for (prop in bCopy) { + if (compares[prop] === undefined || !same(undefined, b[prop], compares[prop], a, b, deep === false ? -1 : undefined)) { + return false; + } + } + return true; + } + return false; + }; + can.Object.subsets = function (checkSet, sets, compares) { + var len = sets.length, subsets = []; + for (var i = 0; i < len; i++) { + var set = sets[i]; + if (can.Object.subset(checkSet, set, compares)) { + subsets.push(set); + } + } + return subsets; + }; + can.Object.subset = function (subset, set, compares) { + compares = compares || {}; + for (var prop in set) { + if (!same(subset[prop], set[prop], compares[prop], subset, set)) { + return false; + } + } + return true; + }; + var compareMethods = { + 'null': function () { + return true; + }, + i: function (a, b) { + return ('' + a).toLowerCase() === ('' + b).toLowerCase(); + }, + eq: function (a, b) { + return a === b; + }, + similar: function (a, b) { + return a == b; + } + }; + compareMethods.eqeq = compareMethods.similar; + return can.Object; +}); +/*can@2.2.6#util/fixture/fixture*/ +define('can/util/fixture/fixture', [ + 'can/util/util', + 'can/util/string/string', + 'can/util/object/object' +], function (can) { + if (!can.Object) { + throw new Error('can.fixture depends on can.Object. Please include it before can.fixture.'); + } + var getUrl = function (url) { + if (typeof steal !== 'undefined') { + if (steal.joinURIs) { + var base = steal.config('baseUrl'); + var joined = steal.joinURIs(base, url); + return joined; + } + if (can.isFunction(steal.config)) { + if (steal.System) { + return steal.joinURIs(steal.config('baseURL'), url); + } else { + return steal.config().root.mapJoin(url).toString(); + } + } + return steal.root.join(url).toString(); + } + return (can.fixture.rootUrl || '') + url; + }; + var updateSettings = function (settings, originalOptions) { + if (!can.fixture.on || settings.fixture === false) { + return; + } + var log = function () { + }; + settings.type = settings.type || settings.method || 'GET'; + var data = overwrite(settings); + if (!settings.fixture) { + if (window.location.protocol === 'file:') { + log('ajax request to ' + settings.url + ', no fixture found'); + } + return; + } + if (typeof settings.fixture === 'string' && can.fixture[settings.fixture]) { + settings.fixture = can.fixture[settings.fixture]; + } + if (typeof settings.fixture === 'string') { + var url = settings.fixture; + if (/^\/\//.test(url)) { + url = getUrl(settings.fixture.substr(2)); + } + if (data) { + url = can.sub(url, data); + } + delete settings.fixture; + settings.url = url; + settings.data = null; + settings.type = 'GET'; + if (!settings.error) { + settings.error = function (xhr, error, message) { + throw 'fixtures.js Error ' + error + ' ' + message; + }; + } + } else { + if (settings.dataTypes) { + settings.dataTypes.splice(0, 0, 'fixture'); + } + if (data && originalOptions) { + originalOptions.data = originalOptions.data || {}; + can.extend(originalOptions.data, data); + } + } + }, extractResponse = function (status, statusText, responses, headers) { + if (typeof status !== 'number') { + headers = statusText; + responses = status; + statusText = 'success'; + status = 200; + } + if (typeof statusText !== 'string') { + headers = responses; + responses = statusText; + statusText = 'success'; + } + if (status >= 400 && status <= 599) { + this.dataType = 'text'; + } + return [ + status, + statusText, + extractResponses(this, responses), + headers + ]; + }, extractResponses = function (settings, responses) { + var next = settings.dataTypes ? settings.dataTypes[0] : settings.dataType || 'json'; + if (!responses || !responses[next]) { + var tmp = {}; + tmp[next] = responses; + responses = tmp; + } + return responses; + }; + if (can.ajaxPrefilter && can.ajaxTransport) { + can.ajaxPrefilter(updateSettings); + can.ajaxTransport('fixture', function (s, original) { + s.dataTypes.shift(); + var timeout, stopped = false; + return { + send: function (headers, callback) { + timeout = setTimeout(function () { + var success = function () { + if (stopped === false) { + callback.apply(null, extractResponse.apply(s, arguments)); + } + }, result = s.fixture(original, success, headers, s); + if (result !== undefined) { + callback(200, 'success', extractResponses(s, result), {}); + } + }, can.fixture.delay); + }, + abort: function () { + stopped = true; + clearTimeout(timeout); + } + }; + }); + } else { + var AJAX = can.ajax; + can.ajax = function (settings) { + updateSettings(settings, settings); + if (settings.fixture) { + var timeout, deferred = new can.Deferred(), stopped = false; + deferred.getResponseHeader = function () { + }; + deferred.then(settings.success, settings.fail); + deferred.abort = function () { + clearTimeout(timeout); + stopped = true; + deferred.reject(deferred); + }; + timeout = setTimeout(function () { + var success = function () { + var response = extractResponse.apply(settings, arguments), status = response[0]; + if ((status >= 200 && status < 300 || status === 304) && stopped === false) { + deferred.resolve(response[2][settings.dataType]); + } else { + deferred.reject(deferred, 'error', response[1]); + } + }, result = settings.fixture(settings, success, settings.headers, settings); + if (result !== undefined) { + deferred.resolve(result); + } + }, can.fixture.delay); + return deferred; + } else { + return AJAX(settings); + } + }; + } + var overwrites = [], find = function (settings, exact) { + for (var i = 0; i < overwrites.length; i++) { + if ($fixture._similar(settings, overwrites[i], exact)) { + return i; + } + } + return -1; + }, overwrite = function (settings) { + var index = find(settings); + if (index > -1) { + settings.fixture = overwrites[index].fixture; + return $fixture._getData(overwrites[index].url, settings.url); + } + }, getId = function (settings) { + var id = settings.data.id; + if (id === undefined && typeof settings.data === 'number') { + id = settings.data; + } + if (id === undefined) { + settings.url.replace(/\/(\d+)(\/|$|\.)/g, function (all, num) { + id = num; + }); + } + if (id === undefined) { + id = settings.url.replace(/\/(\w+)(\/|$|\.)/g, function (all, num) { + if (num !== 'update') { + id = num; + } + }); + } + if (id === undefined) { + id = Math.round(Math.random() * 1000); + } + return id; + }; + var $fixture = can.fixture = function (settings, fixture) { + if (fixture !== undefined) { + if (typeof settings === 'string') { + var matches = settings.match(/(GET|POST|PUT|DELETE) (.+)/i); + if (!matches) { + settings = { url: settings }; + } else { + settings = { + url: matches[2], + type: matches[1] + }; + } + } + var index = find(settings, !!fixture); + if (index > -1) { + overwrites.splice(index, 1); + } + if (fixture == null) { + return; + } + settings.fixture = fixture; + overwrites.push(settings); + } else { + can.each(settings, function (fixture, url) { + $fixture(url, fixture); + }); + } + }; + var replacer = can.replacer; + can.extend(can.fixture, { + _similar: function (settings, overwrite, exact) { + if (exact) { + return can.Object.same(settings, overwrite, { fixture: null }); + } else { + return can.Object.subset(settings, overwrite, can.fixture._compare); + } + }, + _compare: { + url: function (a, b) { + return !!$fixture._getData(b, a); + }, + fixture: null, + type: 'i' + }, + _getData: function (fixtureUrl, url) { + var order = [], fixtureUrlAdjusted = fixtureUrl.replace('.', '\\.').replace('?', '\\?'), res = new RegExp(fixtureUrlAdjusted.replace(replacer, function (whole, part) { + order.push(part); + return '([^/]+)'; + }) + '$').exec(url), data = {}; + if (!res) { + return null; + } + res.shift(); + can.each(order, function (name) { + data[name] = res.shift(); + }); + return data; + }, + store: function (count, make, filter) { + var currentId = 0, findOne = function (id) { + for (var i = 0; i < items.length; i++) { + if (id == items[i].id) { + return items[i]; + } + } + }, methods = {}, types, items, reset; + if (can.isArray(count) && typeof count[0] === 'string') { + types = count; + count = make; + make = filter; + filter = arguments[3]; + } else if (typeof count === 'string') { + types = [ + count + 's', + count + ]; + count = make; + make = filter; + filter = arguments[3]; + } + if (typeof count === 'number') { + items = []; + reset = function () { + items = []; + for (var i = 0; i < count; i++) { + var item = make(i, items); + if (!item.id) { + item.id = i; + } + currentId = Math.max(item.id + 1, currentId + 1) || items.length; + items.push(item); + } + if (can.isArray(types)) { + can.fixture['~' + types[0]] = items; + can.fixture['-' + types[0]] = methods.findAll; + can.fixture['-' + types[1]] = methods.findOne; + can.fixture['-' + types[1] + 'Update'] = methods.update; + can.fixture['-' + types[1] + 'Destroy'] = methods.destroy; + can.fixture['-' + types[1] + 'Create'] = methods.create; + } + }; + } else { + filter = make; + var initialItems = count; + reset = function () { + items = initialItems.slice(0); + }; + } + can.extend(methods, { + findAll: function (request) { + request = request || {}; + var retArr = items.slice(0); + request.data = request.data || {}; + can.each((request.data.order || []).slice(0).reverse(), function (name) { + var split = name.split(' '); + retArr = retArr.sort(function (a, b) { + if (split[1].toUpperCase() !== 'ASC') { + if (a[split[0]] < b[split[0]]) { + return 1; + } else if (a[split[0]] === b[split[0]]) { + return 0; + } else { + return -1; + } + } else { + if (a[split[0]] < b[split[0]]) { + return -1; + } else if (a[split[0]] === b[split[0]]) { + return 0; + } else { + return 1; + } + } + }); + }); + can.each((request.data.group || []).slice(0).reverse(), function (name) { + var split = name.split(' '); + retArr = retArr.sort(function (a, b) { + return a[split[0]] > b[split[0]]; + }); + }); + var offset = parseInt(request.data.offset, 10) || 0, limit = parseInt(request.data.limit, 10) || items.length - offset, i = 0; + for (var param in request.data) { + i = 0; + if (request.data[param] !== undefined && (param.indexOf('Id') !== -1 || param.indexOf('_id') !== -1)) { + while (i < retArr.length) { + if (request.data[param] != retArr[i][param]) { + retArr.splice(i, 1); + } else { + i++; + } + } + } + } + if (typeof filter === 'function') { + i = 0; + while (i < retArr.length) { + if (!filter(retArr[i], request)) { + retArr.splice(i, 1); + } else { + i++; + } + } + } else if (typeof filter === 'object') { + i = 0; + while (i < retArr.length) { + if (!can.Object.subset(retArr[i], request.data, filter)) { + retArr.splice(i, 1); + } else { + i++; + } + } + } + return { + 'count': retArr.length, + 'limit': request.data.limit, + 'offset': request.data.offset, + 'data': retArr.slice(offset, offset + limit) + }; + }, + findOne: function (request, response) { + var item = findOne(getId(request)); + if (typeof item === 'undefined') { + return response(404, 'Requested resource not found'); + } + response(item); + }, + update: function (request, response) { + var id = getId(request), item = findOne(id); + if (typeof item === 'undefined') { + return response(404, 'Requested resource not found'); + } + can.extend(item, request.data); + response({ id: id }, { location: request.url || '/' + getId(request) }); + }, + destroy: function (request, response) { + var id = getId(request), item = findOne(id); + if (typeof item === 'undefined') { + return response(404, 'Requested resource not found'); + } + for (var i = 0; i < items.length; i++) { + if (items[i].id == id) { + items.splice(i, 1); + break; + } + } + return {}; + }, + create: function (settings, response) { + var item = typeof make === 'function' ? make(items.length, items) : {}; + can.extend(item, settings.data); + if (!item.id) { + item.id = currentId++; + } + items.push(item); + response({ id: item.id }, { location: settings.url + '/' + item.id }); + } + }); + reset(); + return can.extend({ + getId: getId, + find: function (settings) { + return findOne(getId(settings)); + }, + reset: reset + }, methods); + }, + rand: function randomize(arr, min, max) { + if (typeof arr === 'number') { + if (typeof min === 'number') { + return arr + Math.floor(Math.random() * (min - arr)); + } else { + return Math.floor(Math.random() * arr); + } + } + var rand = randomize; + if (min === undefined) { + return rand(arr, rand(arr.length + 1)); + } + var res = []; + arr = arr.slice(0); + if (!max) { + max = min; + } + max = min + Math.round(rand(max - min)); + for (var i = 0; i < max; i++) { + res.push(arr.splice(rand(arr.length), 1)[0]); + } + return res; + }, + xhr: function (xhr) { + return can.extend({}, { + abort: can.noop, + getAllResponseHeaders: function () { + return ''; + }, + getResponseHeader: function () { + return ''; + }, + open: can.noop, + overrideMimeType: can.noop, + readyState: 4, + responseText: '', + responseXML: null, + send: can.noop, + setRequestHeader: can.noop, + status: 200, + statusText: 'OK' + }, xhr); + }, + on: true + }); + can.fixture.delay = 200; + can.fixture.rootUrl = getUrl(''); + can.fixture['-handleFunction'] = function (settings) { + if (typeof settings.fixture === 'string' && can.fixture[settings.fixture]) { + settings.fixture = can.fixture[settings.fixture]; + } + if (typeof settings.fixture === 'function') { + setTimeout(function () { + if (settings.success) { + settings.success.apply(null, settings.fixture(settings, 'success')); + } + if (settings.complete) { + settings.complete.apply(null, settings.fixture(settings, 'complete')); + } + }, can.fixture.delay); + return true; + } + return false; + }; + can.fixture.overwrites = overwrites; + can.fixture.make = can.fixture.store; + return can.fixture; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.jquery.dev.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.jquery.dev.js new file mode 100644 index 0000000000..ea972b27d2 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.jquery.dev.js @@ -0,0 +1,6815 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#util/can*/ +define('can/util/can', [], function () { + var glbl = typeof window !== 'undefined' ? window : global; + var can = {}; + if (typeof GLOBALCAN === 'undefined' || GLOBALCAN !== false) { + glbl.can = can; + } + can.global = glbl; + can.k = function () { + }; + can.isDeferred = can.isPromise = function (obj) { + return obj && typeof obj.then === 'function' && typeof obj.pipe === 'function'; + }; + can.isMapLike = function (obj) { + return can.Map && (obj instanceof can.Map || obj && obj.__get); + }; + var cid = 0; + can.cid = function (object, name) { + if (!object._cid) { + cid++; + object._cid = (name || '') + cid; + } + return object._cid; + }; + can.VERSION = '2.2.6'; + can.simpleExtend = function (d, s) { + for (var prop in s) { + d[prop] = s[prop]; + } + return d; + }; + can.last = function (arr) { + return arr && arr[arr.length - 1]; + }; + var protoBind = Function.prototype.bind; + if (protoBind) { + can.proxy = function (fn, context) { + return protoBind.call(fn, context); + }; + } else { + can.proxy = function (fn, context) { + return function () { + return fn.apply(context, arguments); + }; + }; + } + can.frag = function (item) { + var frag; + if (!item || typeof item === 'string') { + frag = can.buildFragment(item == null ? '' : '' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } else if (item.nodeType === 11) { + return item; + } else if (typeof item.nodeType === 'number') { + frag = document.createDocumentFragment(); + frag.appendChild(item); + return frag; + } else if (typeof item.length === 'number') { + frag = document.createDocumentFragment(); + can.each(item, function (item) { + frag.appendChild(can.frag(item)); + }); + return frag; + } else { + frag = can.buildFragment('' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } + }; + can.scope = can.viewModel = function (el, attr, val) { + el = can.$(el); + var scope = can.data(el, 'scope') || can.data(el, 'viewModel'); + if (!scope) { + scope = new can.Map(); + can.data(el, 'scope', scope); + can.data(el, 'viewModel', scope); + } + switch (arguments.length) { + case 0: + case 1: + return scope; + case 2: + return scope.attr(attr); + default: + scope.attr(attr, val); + return el; + } + }; + can['import'] = function (moduleName) { + var deferred = new can.Deferred(); + if (typeof window.System === 'object' && can.isFunction(window.System['import'])) { + window.System['import'](moduleName).then(can.proxy(deferred.resolve, deferred), can.proxy(deferred.reject, deferred)); + } else if (window.define && window.define.amd) { + window.require([moduleName], function (value) { + deferred.resolve(value); + }); + } else if (window.steal) { + steal.steal(moduleName, function (value) { + deferred.resolve(value); + }); + } else if (window.require) { + deferred.resolve(window.require(moduleName)); + } else { + deferred.resolve(); + } + return deferred.promise(); + }; + can.__observe = function () { + }; + return can; +}); +/*can@2.2.6#util/attr/attr*/ +define('can/util/attr/attr', ['can/util/can'], function (can) { + var setImmediate = can.global.setImmediate || function (cb) { + return setTimeout(cb, 0); + }, attr = { + MutationObserver: can.global.MutationObserver || can.global.WebKitMutationObserver || can.global.MozMutationObserver, + map: { + 'class': 'className', + 'value': 'value', + 'innertext': 'innerText', + 'textcontent': 'textContent', + 'checked': true, + 'disabled': true, + 'readonly': true, + 'required': true, + src: function (el, val) { + if (val == null || val === '') { + el.removeAttribute('src'); + return null; + } else { + el.setAttribute('src', val); + return val; + } + }, + style: function (el, val) { + return el.style.cssText = val || ''; + } + }, + defaultValue: [ + 'input', + 'textarea' + ], + set: function (el, attrName, val) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var tagName = el.nodeName.toString().toLowerCase(), prop = attr.map[attrName], newValue; + if (typeof prop === 'function') { + newValue = prop(el, val); + } else if (prop === true) { + newValue = el[attrName] = true; + if (attrName === 'checked' && el.type === 'radio') { + if (can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultChecked = true; + } + } + } else if (prop) { + newValue = val; + if (el[prop] !== val) { + el[prop] = val; + } + if (prop === 'value' && can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultValue = val; + } + } else { + el.setAttribute(attrName, val); + newValue = val; + } + if (!attr.MutationObserver && newValue !== oldValue) { + attr.trigger(el, attrName, oldValue); + } + }, + trigger: function (el, attrName, oldValue) { + if (can.data(can.$(el), 'canHasAttributesBindings')) { + attrName = attrName.toLowerCase(); + return setImmediate(function () { + can.trigger(el, { + type: 'attributes', + attributeName: attrName, + target: el, + oldValue: oldValue, + bubbles: false + }, []); + }); + } + }, + get: function (el, attrName) { + attrName = attrName.toLowerCase(); + var prop = attr.map[attrName]; + if (typeof prop === 'string' && el[prop]) { + return el[prop]; + } + return el.getAttribute(attrName); + }, + remove: function (el, attrName) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var setter = attr.map[attrName]; + if (typeof setter === 'function') { + setter(el, undefined); + } + if (setter === true) { + el[attrName] = false; + } else if (typeof setter === 'string') { + el[setter] = ''; + } else { + el.removeAttribute(attrName); + } + if (!attr.MutationObserver && oldValue != null) { + attr.trigger(el, attrName, oldValue); + } + }, + has: function () { + var el = can.global.document && document.createElement('div'); + if (el && el.hasAttribute) { + return function (el, name) { + return el.hasAttribute(name); + }; + } else { + return function (el, name) { + return el.getAttribute(name) !== null; + }; + } + }() + }; + return attr; +}); +/*can@2.2.6#event/event*/ +define('can/event/event', ['can/util/can'], function (can) { + can.addEvent = function (event, handler) { + var allEvents = this.__bindEvents || (this.__bindEvents = {}), eventList = allEvents[event] || (allEvents[event] = []); + eventList.push({ + handler: handler, + name: event + }); + return this; + }; + can.listenTo = function (other, event, handler) { + var idedEvents = this.__listenToEvents; + if (!idedEvents) { + idedEvents = this.__listenToEvents = {}; + } + var otherId = can.cid(other); + var othersEvents = idedEvents[otherId]; + if (!othersEvents) { + othersEvents = idedEvents[otherId] = { + obj: other, + events: {} + }; + } + var eventsEvents = othersEvents.events[event]; + if (!eventsEvents) { + eventsEvents = othersEvents.events[event] = []; + } + eventsEvents.push(handler); + can.bind.call(other, event, handler); + }; + can.stopListening = function (other, event, handler) { + var idedEvents = this.__listenToEvents, iterIdedEvents = idedEvents, i = 0; + if (!idedEvents) { + return this; + } + if (other) { + var othercid = can.cid(other); + (iterIdedEvents = {})[othercid] = idedEvents[othercid]; + if (!idedEvents[othercid]) { + return this; + } + } + for (var cid in iterIdedEvents) { + var othersEvents = iterIdedEvents[cid], eventsEvents; + other = idedEvents[cid].obj; + if (!event) { + eventsEvents = othersEvents.events; + } else { + (eventsEvents = {})[event] = othersEvents.events[event]; + } + for (var eventName in eventsEvents) { + var handlers = eventsEvents[eventName] || []; + i = 0; + while (i < handlers.length) { + if (handler && handler === handlers[i] || !handler) { + can.unbind.call(other, eventName, handlers[i]); + handlers.splice(i, 1); + } else { + i++; + } + } + if (!handlers.length) { + delete othersEvents.events[eventName]; + } + } + if (can.isEmptyObject(othersEvents.events)) { + delete idedEvents[cid]; + } + } + return this; + }; + can.removeEvent = function (event, fn, __validate) { + if (!this.__bindEvents) { + return this; + } + var events = this.__bindEvents[event] || [], i = 0, ev, isFunction = typeof fn === 'function'; + while (i < events.length) { + ev = events[i]; + if (__validate ? __validate(ev, event, fn) : isFunction && ev.handler === fn || !isFunction && (ev.cid === fn || !fn)) { + events.splice(i, 1); + } else { + i++; + } + } + return this; + }; + can.dispatch = function (event, args) { + var events = this.__bindEvents; + if (!events) { + return; + } + if (typeof event === 'string') { + event = { type: event }; + } + var eventName = event.type, handlers = (events[eventName] || []).slice(0), passed = [event]; + if (args) { + passed.push.apply(passed, args); + } + for (var i = 0, len = handlers.length; i < len; i++) { + handlers[i].handler.apply(this, passed); + } + return event; + }; + can.one = function (event, handler) { + var one = function () { + can.unbind.call(this, event, one); + return handler.apply(this, arguments); + }; + can.bind.call(this, event, one); + return this; + }; + can.event = { + on: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.on.call(this); + } else { + return can.addEvent.apply(this, arguments); + } + }, + off: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.off.call(this); + } else { + return can.removeEvent.apply(this, arguments); + } + }, + bind: can.addEvent, + unbind: can.removeEvent, + delegate: function (selector, event, handler) { + return can.addEvent.call(this, event, handler); + }, + undelegate: function (selector, event, handler) { + return can.removeEvent.call(this, event, handler); + }, + trigger: can.dispatch, + one: can.one, + addEvent: can.addEvent, + removeEvent: can.removeEvent, + listenTo: can.listenTo, + stopListening: can.stopListening, + dispatch: can.dispatch + }; + return can.event; +}); +/*can@2.2.6#util/array/each*/ +define('can/util/array/each', ['can/util/can'], function (can) { + var isArrayLike = function (obj) { + var length = 'length' in obj && obj.length; + return typeof arr !== 'function' && (length === 0 || typeof length === 'number' && length > 0 && length - 1 in obj); + }; + can.each = function (elements, callback, context) { + var i = 0, key, len, item; + if (elements) { + if (isArrayLike(elements)) { + if (can.List && elements instanceof can.List) { + for (len = elements.attr('length'); i < len; i++) { + item = elements.attr(i); + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } else { + for (len = elements.length; i < len; i++) { + item = elements[i]; + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } + } else if (typeof elements === 'object') { + if (can.Map && elements instanceof can.Map || elements === can.route) { + var keys = can.Map.keys(elements); + for (i = 0, len = keys.length; i < len; i++) { + key = keys[i]; + item = elements.attr(key); + if (callback.call(context || item, item, key, elements) === false) { + break; + } + } + } else { + for (key in elements) { + if (elements.hasOwnProperty(key) && callback.call(context || elements[key], elements[key], key, elements) === false) { + break; + } + } + } + } + } + return elements; + }; + return can; +}); +/*can@2.2.6#util/inserted/inserted*/ +define('can/util/inserted/inserted', ['can/util/can'], function (can) { + can.inserted = function (elems) { + elems = can.makeArray(elems); + var inDocument = false, doc = can.$(document.contains ? document : document.body), children; + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + if (!inDocument) { + if (elem.getElementsByTagName) { + if (can.has(doc, elem).length) { + inDocument = true; + } else { + return; + } + } else { + continue; + } + } + if (inDocument && elem.getElementsByTagName) { + children = can.makeArray(elem.getElementsByTagName('*')); + can.trigger(elem, 'inserted', [], false); + for (var j = 0, child; (child = children[j]) !== undefined; j++) { + can.trigger(child, 'inserted', [], false); + } + } + } + }; + can.appendChild = function (el, child) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.appendChild(child); + can.inserted(children); + }; + can.insertBefore = function (el, child, ref) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.insertBefore(child, ref); + can.inserted(children); + }; +}); +/*can@2.2.6#util/jquery/jquery*/ +define('can/util/jquery/jquery', [ + 'dist/jquery', + 'can/util/can', + 'can/util/attr/attr', + 'can/event/event', + 'can/util/array/each', + 'can/util/inserted/inserted' +], function ($, can, attr, event) { + var isBindableElement = function (node) { + return node.nodeName && (node.nodeType === 1 || node.nodeType === 9) || node == window; + }; + $ = $ || window.jQuery; + $.extend(can, $, { + trigger: function (obj, event, args, bubbles) { + if (isBindableElement(obj)) { + $.event.trigger(event, args, obj, !bubbles); + } else if (obj.trigger) { + obj.trigger(event, args); + } else { + if (typeof event === 'string') { + event = { type: event }; + } + event.target = event.target || obj; + if (args) { + if (args.length && typeof args === 'string') { + args = [args]; + } else if (!args.length) { + args = [args]; + } + } + if (!args) { + args = []; + } + can.dispatch.call(obj, event, args); + } + }, + event: can.event, + addEvent: can.addEvent, + removeEvent: can.removeEvent, + buildFragment: function (elems, context) { + var ret; + elems = [elems]; + context = context || document; + context = !context.nodeType && context[0] || context; + context = context.ownerDocument || context; + ret = $.buildFragment(elems, context); + return ret.cacheable ? $.clone(ret.fragment) : ret.fragment || ret; + }, + $: $, + each: can.each, + bind: function (ev, cb) { + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (isBindableElement(this)) { + $.event.add(this, ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + return this; + }, + unbind: function (ev, cb) { + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (isBindableElement(this)) { + $.event.remove(this, ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + return this; + }, + delegate: function (selector, ev, cb) { + if (this.delegate) { + this.delegate(selector, ev, cb); + } else if (isBindableElement(this)) { + $(this).delegate(selector, ev, cb); + } else { + can.bind.call(this, ev, cb); + } + return this; + }, + undelegate: function (selector, ev, cb) { + if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else if (isBindableElement(this)) { + $(this).undelegate(selector, ev, cb); + } else { + can.unbind.call(this, ev, cb); + } + return this; + }, + proxy: can.proxy, + attr: attr + }); + can.on = can.bind; + can.off = can.unbind; + $.each([ + 'append', + 'filter', + 'addClass', + 'remove', + 'data', + 'get', + 'has' + ], function (i, name) { + can[name] = function (wrapped) { + return wrapped[name].apply(wrapped, can.makeArray(arguments).slice(1)); + }; + }); + var oldClean = $.cleanData; + $.cleanData = function (elems) { + $.each(elems, function (i, elem) { + if (elem) { + can.trigger(elem, 'removed', [], false); + } + }); + oldClean(elems); + }; + var oldDomManip = $.fn.domManip, cbIndex; + $.fn.domManip = function (args, cb1, cb2) { + for (var i = 1; i < arguments.length; i++) { + if (typeof arguments[i] === 'function') { + cbIndex = i; + break; + } + } + return oldDomManip.apply(this, arguments); + }; + $(document.createElement('div')).append(document.createElement('div')); + $.fn.domManip = cbIndex === 2 ? function (args, table, callback) { + return oldDomManip.call(this, args, table, function (elem) { + var elems; + if (elem.nodeType === 11) { + elems = can.makeArray(elem.childNodes); + } + var ret = callback.apply(this, arguments); + can.inserted(elems ? elems : [elem]); + return ret; + }); + } : function (args, callback) { + return oldDomManip.call(this, args, function (elem) { + var elems; + if (elem.nodeType === 11) { + elems = can.makeArray(elem.childNodes); + } + var ret = callback.apply(this, arguments); + can.inserted(elems ? elems : [elem]); + return ret; + }); + }; + if (!can.attr.MutationObserver) { + var oldAttr = $.attr; + $.attr = function (el, attrName) { + var oldValue, newValue; + if (arguments.length >= 3) { + oldValue = oldAttr.call(this, el, attrName); + } + var res = oldAttr.apply(this, arguments); + if (arguments.length >= 3) { + newValue = oldAttr.call(this, el, attrName); + } + if (newValue !== oldValue) { + can.attr.trigger(el, attrName, oldValue); + } + return res; + }; + var oldRemove = $.removeAttr; + $.removeAttr = function (el, attrName) { + var oldValue = oldAttr.call(this, el, attrName), res = oldRemove.apply(this, arguments); + if (oldValue != null) { + can.attr.trigger(el, attrName, oldValue); + } + return res; + }; + $.event.special.attributes = { + setup: function () { + can.data(can.$(this), 'canHasAttributesBindings', true); + }, + teardown: function () { + $.removeData(this, 'canHasAttributesBindings'); + } + }; + } else { + $.event.special.attributes = { + setup: function () { + var self = this; + var observer = new can.attr.MutationObserver(function (mutations) { + mutations.forEach(function (mutation) { + var copy = can.simpleExtend({}, mutation); + can.trigger(self, copy, []); + }); + }); + observer.observe(this, { + attributes: true, + attributeOldValue: true + }); + can.data(can.$(this), 'canAttributesObserver', observer); + }, + teardown: function () { + can.data(can.$(this), 'canAttributesObserver').disconnect(); + $.removeData(this, 'canAttributesObserver'); + } + }; + } + (function () { + var text = '<-\n>', frag = can.buildFragment(text, document); + if (text !== frag.childNodes[0].nodeValue) { + var oldBuildFragment = can.buildFragment; + can.buildFragment = function (content, context) { + var res = oldBuildFragment(content, context); + if (res.childNodes.length === 1 && res.childNodes[0].nodeType === 3) { + res.childNodes[0].nodeValue = content; + } + return res; + }; + } + }()); + $.event.special.inserted = {}; + $.event.special.removed = {}; + return can; +}); +/*can@2.2.6#util/util*/ +define('can/util/util', ['can/util/jquery/jquery'], function (can) { + return can; +}); +/*can@2.2.6#view/view*/ +define('can/view/view', ['can/util/util'], function (can) { + var isFunction = can.isFunction, makeArray = can.makeArray, hookupId = 1; + var makeRenderer = function (textRenderer) { + var renderer = function () { + return $view.frag(textRenderer.apply(this, arguments)); + }; + renderer.render = function () { + return textRenderer.apply(textRenderer, arguments); + }; + return renderer; + }; + var checkText = function (text, url) { + if (!text.length) { + throw 'can.view: No template or empty template:' + url; + } + }; + var getRenderer = function (obj, async) { + if (isFunction(obj)) { + var def = can.Deferred(); + return def.resolve(obj); + } + var url = typeof obj === 'string' ? obj : obj.url, suffix = obj.engine && '.' + obj.engine || url.match(/\.[\w\d]+$/), type, el, id; + if (url.match(/^#/)) { + url = url.substr(1); + } + if (el = document.getElementById(url)) { + suffix = '.' + el.type.match(/\/(x\-)?(.+)/)[2]; + } + if (!suffix && !$view.cached[url]) { + url += suffix = $view.ext; + } + if (can.isArray(suffix)) { + suffix = suffix[0]; + } + id = $view.toId(url); + if (url.match(/^\/\//)) { + url = url.substr(2); + url = !window.steal ? url : steal.config().root.mapJoin('' + steal.id(url)); + } + if (window.require) { + if (require.toUrl) { + url = require.toUrl(url); + } + } + type = $view.types[suffix]; + if ($view.cached[id]) { + return $view.cached[id]; + } else if (el) { + return $view.registerView(id, el.innerHTML, type); + } else { + var d = new can.Deferred(); + can.ajax({ + async: async, + url: url, + dataType: 'text', + error: function (jqXHR) { + checkText('', url); + d.reject(jqXHR); + }, + success: function (text) { + checkText(text, url); + $view.registerView(id, text, type, d); + } + }); + return d; + } + }; + var getDeferreds = function (data) { + var deferreds = []; + if (can.isDeferred(data)) { + return [data]; + } else { + for (var prop in data) { + if (can.isDeferred(data[prop])) { + deferreds.push(data[prop]); + } + } + } + return deferreds; + }; + var usefulPart = function (resolved) { + return can.isArray(resolved) && resolved[1] === 'success' ? resolved[0] : resolved; + }; + var $view = can.view = can.template = function (view, data, helpers, callback) { + if (isFunction(helpers)) { + callback = helpers; + helpers = undefined; + } + return $view.renderAs('fragment', view, data, helpers, callback); + }; + can.extend($view, { + frag: function (result, parentNode) { + return $view.hookup($view.fragment(result), parentNode); + }, + fragment: function (result) { + if (typeof result !== 'string' && result.nodeType === 11) { + return result; + } + var frag = can.buildFragment(result, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + }, + toId: function (src) { + return can.map(src.toString().split(/\/|\./g), function (part) { + if (part) { + return part; + } + }).join('_'); + }, + toStr: function (txt) { + return txt == null ? '' : '' + txt; + }, + hookup: function (fragment, parentNode) { + var hookupEls = [], id, func; + can.each(fragment.childNodes ? can.makeArray(fragment.childNodes) : fragment, function (node) { + if (node.nodeType === 1) { + hookupEls.push(node); + hookupEls.push.apply(hookupEls, can.makeArray(node.getElementsByTagName('*'))); + } + }); + can.each(hookupEls, function (el) { + if (el.getAttribute && (id = el.getAttribute('data-view-id')) && (func = $view.hookups[id])) { + func(el, parentNode, id); + delete $view.hookups[id]; + el.removeAttribute('data-view-id'); + } + }); + return fragment; + }, + hookups: {}, + hook: function (cb) { + $view.hookups[++hookupId] = cb; + return ' data-view-id=\'' + hookupId + '\''; + }, + cached: {}, + cachedRenderers: {}, + cache: true, + register: function (info) { + this.types['.' + info.suffix] = info; + can[info.suffix] = $view[info.suffix] = function (id, text) { + var renderer, renderFunc; + if (!text) { + renderFunc = function () { + if (!renderer) { + if (info.fragRenderer) { + renderer = info.fragRenderer(null, id); + } else { + renderer = makeRenderer(info.renderer(null, id)); + } + } + return renderer.apply(this, arguments); + }; + renderFunc.render = function () { + var textRenderer = info.renderer(null, id); + return textRenderer.apply(textRenderer, arguments); + }; + return renderFunc; + } + var registeredRenderer = function () { + if (!renderer) { + if (info.fragRenderer) { + renderer = info.fragRenderer(id, text); + } else { + renderer = info.renderer(id, text); + } + } + return renderer.apply(this, arguments); + }; + if (info.fragRenderer) { + return $view.preload(id, registeredRenderer); + } else { + return $view.preloadStringRenderer(id, registeredRenderer); + } + }; + }, + types: {}, + ext: '.ejs', + registerScript: function (type, id, src) { + return 'can.view.preloadStringRenderer(\'' + id + '\',' + $view.types['.' + type].script(id, src) + ');'; + }, + preload: function (id, renderer) { + var def = $view.cached[id] = new can.Deferred().resolve(function (data, helpers) { + return renderer.call(data, data, helpers); + }); + def.__view_id = id; + $view.cachedRenderers[id] = renderer; + return renderer; + }, + preloadStringRenderer: function (id, stringRenderer) { + return this.preload(id, makeRenderer(stringRenderer)); + }, + render: function (view, data, helpers, callback) { + return can.view.renderAs('string', view, data, helpers, callback); + }, + renderTo: function (format, renderer, data, helpers) { + return (format === 'string' && renderer.render ? renderer.render : renderer)(data, helpers); + }, + renderAs: function (format, view, data, helpers, callback) { + if (isFunction(helpers)) { + callback = helpers; + helpers = undefined; + } + var deferreds = getDeferreds(data); + var reading, deferred, dataCopy, async, response; + if (deferreds.length) { + deferred = new can.Deferred(); + dataCopy = can.extend({}, data); + deferreds.push(getRenderer(view, true)); + can.when.apply(can, deferreds).then(function (resolved) { + var objs = makeArray(arguments), renderer = objs.pop(), result; + if (can.isDeferred(data)) { + dataCopy = usefulPart(resolved); + } else { + for (var prop in data) { + if (can.isDeferred(data[prop])) { + dataCopy[prop] = usefulPart(objs.shift()); + } + } + } + result = can.view.renderTo(format, renderer, dataCopy, helpers); + deferred.resolve(result, dataCopy); + if (callback) { + callback(result, dataCopy); + } + }, function () { + deferred.reject.apply(deferred, arguments); + }); + return deferred; + } else { + reading = can.__clearReading(); + async = isFunction(callback); + deferred = getRenderer(view, async); + if (reading) { + can.__setReading(reading); + } + if (async) { + response = deferred; + deferred.then(function (renderer) { + callback(data ? can.view.renderTo(format, renderer, data, helpers) : renderer); + }); + } else { + if (deferred.state() === 'resolved' && deferred.__view_id) { + var currentRenderer = $view.cachedRenderers[deferred.__view_id]; + return data ? can.view.renderTo(format, currentRenderer, data, helpers) : currentRenderer; + } else { + deferred.then(function (renderer) { + response = data ? can.view.renderTo(format, renderer, data, helpers) : renderer; + }); + } + } + return response; + } + }, + registerView: function (id, text, type, def) { + var info = typeof type === 'object' ? type : $view.types[type || $view.ext], renderer; + if (info.fragRenderer) { + renderer = info.fragRenderer(id, text); + } else { + renderer = makeRenderer(info.renderer(id, text)); + } + def = def || new can.Deferred(); + if ($view.cache) { + $view.cached[id] = def; + def.__view_id = id; + $view.cachedRenderers[id] = renderer; + } + return def.resolve(renderer); + } + }); + return can; +}); +/*can@2.2.6#view/callbacks/callbacks*/ +define('can/view/callbacks/callbacks', [ + 'can/util/util', + 'can/view/view' +], function (can) { + var attr = can.view.attr = function (attributeName, attrHandler) { + if (attrHandler) { + if (typeof attributeName === 'string') { + attributes[attributeName] = attrHandler; + } else { + regExpAttributes.push({ + match: attributeName, + handler: attrHandler + }); + } + } else { + var cb = attributes[attributeName]; + if (!cb) { + for (var i = 0, len = regExpAttributes.length; i < len; i++) { + var attrMatcher = regExpAttributes[i]; + if (attrMatcher.match.test(attributeName)) { + cb = attrMatcher.handler; + break; + } + } + } + return cb; + } + }; + var attributes = {}, regExpAttributes = [], automaticCustomElementCharacters = /[-\:]/; + var tag = can.view.tag = function (tagName, tagHandler) { + if (tagHandler) { + if (can.global.html5) { + can.global.html5.elements += ' ' + tagName; + can.global.html5.shivDocument(); + } + tags[tagName.toLowerCase()] = tagHandler; + } else { + var cb = tags[tagName.toLowerCase()]; + if (!cb && automaticCustomElementCharacters.test(tagName)) { + cb = function () { + }; + } + return cb; + } + }; + var tags = {}; + can.view.callbacks = { + _tags: tags, + _attributes: attributes, + _regExpAttributes: regExpAttributes, + tag: tag, + attr: attr, + tagHandler: function (el, tagName, tagData) { + var helperTagCallback = tagData.options.attr('tags.' + tagName), tagCallback = helperTagCallback || tags[tagName]; + var scope = tagData.scope, res; + if (tagCallback) { + var reads = can.__clearReading(); + res = tagCallback(el, tagData); + can.__setReading(reads); + } else { + res = scope; + } + if (res && tagData.subtemplate) { + if (scope !== res) { + scope = scope.add(res); + } + var result = tagData.subtemplate(scope, tagData.options); + var frag = typeof result === 'string' ? can.view.frag(result) : result; + can.appendChild(el, frag); + } + } + }; + return can.view.callbacks; +}); +/*can@2.2.6#view/elements*/ +define('can/view/elements', [ + 'can/util/util', + 'can/view/view' +], function (can) { + var doc = typeof document !== 'undefined' ? document : null; + var selectsCommentNodes = doc && function () { + return can.$(document.createComment('~')).length === 1; + }(); + var elements = { + tagToContentPropMap: { + option: doc && 'textContent' in document.createElement('option') ? 'textContent' : 'innerText', + textarea: 'value' + }, + attrMap: can.attr.map, + attrReg: /([^\s=]+)[\s]*=[\s]*/, + defaultValue: can.attr.defaultValue, + tagMap: { + '': 'span', + colgroup: 'col', + table: 'tbody', + tr: 'td', + ol: 'li', + ul: 'li', + tbody: 'tr', + thead: 'tr', + tfoot: 'tr', + select: 'option', + optgroup: 'option' + }, + reverseTagMap: { + col: 'colgroup', + tr: 'tbody', + option: 'select', + td: 'tr', + th: 'tr', + li: 'ul' + }, + getParentNode: function (el, defaultParentNode) { + return defaultParentNode && el.parentNode.nodeType === 11 ? defaultParentNode : el.parentNode; + }, + setAttr: can.attr.set, + getAttr: can.attr.get, + removeAttr: can.attr.remove, + contentText: function (text) { + if (typeof text === 'string') { + return text; + } + if (!text && text !== 0) { + return ''; + } + return '' + text; + }, + after: function (oldElements, newFrag) { + var last = oldElements[oldElements.length - 1]; + if (last.nextSibling) { + can.insertBefore(last.parentNode, newFrag, last.nextSibling); + } else { + can.appendChild(last.parentNode, newFrag); + } + }, + replace: function (oldElements, newFrag) { + elements.after(oldElements, newFrag); + if (can.remove(can.$(oldElements)).length < oldElements.length && !selectsCommentNodes) { + can.each(oldElements, function (el) { + if (el.nodeType === 8) { + el.parentNode.removeChild(el); + } + }); + } + } + }; + can.view.elements = elements; + return elements; +}); +/*can@2.2.6#util/string/string*/ +define('can/util/string/string', ['can/util/util'], function (can) { + var strUndHash = /_|-/, strColons = /\=\=/, strWords = /([A-Z]+)([A-Z][a-z])/g, strLowUp = /([a-z\d])([A-Z])/g, strDash = /([a-z\d])([A-Z])/g, strReplacer = /\{([^\}]+)\}/g, strQuote = /"/g, strSingleQuote = /'/g, strHyphenMatch = /-+(.)?/g, strCamelMatch = /[a-z][A-Z]/g, getNext = function (obj, prop, add) { + var result = obj[prop]; + if (result === undefined && add === true) { + result = obj[prop] = {}; + } + return result; + }, isContainer = function (current) { + return /^f|^o/.test(typeof current); + }, convertBadValues = function (content) { + var isInvalid = content === null || content === undefined || isNaN(content) && '' + content === 'NaN'; + return '' + (isInvalid ? '' : content); + }; + can.extend(can, { + esc: function (content) { + return convertBadValues(content).replace(/&/g, '&').replace(//g, '>').replace(strQuote, '"').replace(strSingleQuote, '''); + }, + getObject: function (name, roots, add) { + var parts = name ? name.split('.') : [], length = parts.length, current, r = 0, i, container, rootsLength; + roots = can.isArray(roots) ? roots : [roots || window]; + rootsLength = roots.length; + if (!length) { + return roots[0]; + } + for (r; r < rootsLength; r++) { + current = roots[r]; + container = undefined; + for (i = 0; i < length && isContainer(current); i++) { + container = current; + current = getNext(container, parts[i]); + } + if (container !== undefined && current !== undefined) { + break; + } + } + if (add === false && current !== undefined) { + delete container[parts[i - 1]]; + } + if (add === true && current === undefined) { + current = roots[0]; + for (i = 0; i < length && isContainer(current); i++) { + current = getNext(current, parts[i], true); + } + } + return current; + }, + capitalize: function (s, cache) { + return s.charAt(0).toUpperCase() + s.slice(1); + }, + camelize: function (str) { + return convertBadValues(str).replace(strHyphenMatch, function (match, chr) { + return chr ? chr.toUpperCase() : ''; + }); + }, + hyphenate: function (str) { + return convertBadValues(str).replace(strCamelMatch, function (str, offset) { + return str.charAt(0) + '-' + str.charAt(1).toLowerCase(); + }); + }, + underscore: function (s) { + return s.replace(strColons, '/').replace(strWords, '$1_$2').replace(strLowUp, '$1_$2').replace(strDash, '_').toLowerCase(); + }, + sub: function (str, data, remove) { + var obs = []; + str = str || ''; + obs.push(str.replace(strReplacer, function (whole, inside) { + var ob = can.getObject(inside, data, remove === true ? false : undefined); + if (ob === undefined || ob === null) { + obs = null; + return ''; + } + if (isContainer(ob) && obs) { + obs.push(ob); + return ''; + } + return '' + ob; + })); + return obs === null ? obs : obs.length <= 1 ? obs[0] : obs; + }, + replacer: strReplacer, + undHash: strUndHash + }); + return can; +}); +/*can@2.2.6#construct/construct*/ +define('can/construct/construct', ['can/util/string/string'], function (can) { + var initializing = 0; + var canGetDescriptor; + try { + Object.getOwnPropertyDescriptor({}); + canGetDescriptor = true; + } catch (e) { + canGetDescriptor = false; + } + var getDescriptor = function (newProps, name) { + var descriptor = Object.getOwnPropertyDescriptor(newProps, name); + if (descriptor && (descriptor.get || descriptor.set)) { + return descriptor; + } + return null; + }, inheritGetterSetter = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + var descriptor; + for (var name in newProps) { + if (descriptor = getDescriptor(newProps, name)) { + this._defineProperty(addTo, oldProps, name, descriptor); + } else { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + } + }, simpleInherit = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + for (var name in newProps) { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + }; + can.Construct = function () { + if (arguments.length) { + return can.Construct.extend.apply(can.Construct, arguments); + } + }; + can.extend(can.Construct, { + constructorExtends: true, + newInstance: function () { + var inst = this.instance(), args; + if (inst.setup) { + args = inst.setup.apply(inst, arguments); + } + if (inst.init) { + inst.init.apply(inst, args || arguments); + } + return inst; + }, + _inherit: canGetDescriptor ? inheritGetterSetter : simpleInherit, + _defineProperty: function (what, oldProps, propName, descriptor) { + Object.defineProperty(what, propName, descriptor); + }, + _overwrite: function (what, oldProps, propName, val) { + what[propName] = val; + }, + setup: function (base, fullName) { + this.defaults = can.extend(true, {}, base.defaults, this.defaults); + }, + instance: function () { + initializing = 1; + var inst = new this(); + initializing = 0; + return inst; + }, + extend: function (name, staticProperties, instanceProperties) { + var fullName = name, klass = staticProperties, proto = instanceProperties; + if (typeof fullName !== 'string') { + proto = klass; + klass = fullName; + fullName = null; + } + if (!proto) { + proto = klass; + klass = null; + } + proto = proto || {}; + var _super_class = this, _super = this.prototype, Constructor, parts, current, _fullName, _shortName, propName, shortName, namespace, prototype; + prototype = this.instance(); + can.Construct._inherit(proto, _super, prototype); + if (fullName) { + parts = fullName.split('.'); + shortName = parts.pop(); + } + if (typeof constructorName === 'undefined') { + Constructor = function () { + return init.apply(this, arguments); + }; + } + function init() { + if (!initializing) { + return this.constructor !== Constructor && arguments.length && Constructor.constructorExtends ? Constructor.extend.apply(Constructor, arguments) : Constructor.newInstance.apply(Constructor, arguments); + } + } + for (propName in _super_class) { + if (_super_class.hasOwnProperty(propName)) { + Constructor[propName] = _super_class[propName]; + } + } + can.Construct._inherit(klass, _super_class, Constructor); + if (fullName) { + current = can.getObject(parts.join('.'), window, true); + namespace = current; + _fullName = can.underscore(fullName.replace(/\./g, '_')); + _shortName = can.underscore(shortName); + current[shortName] = Constructor; + } + can.extend(Constructor, { + constructor: Constructor, + prototype: prototype, + namespace: namespace, + _shortName: _shortName, + fullName: fullName, + _fullName: _fullName + }); + if (shortName !== undefined) { + Constructor.shortName = shortName; + } + Constructor.prototype.constructor = Constructor; + var t = [_super_class].concat(can.makeArray(arguments)), args = Constructor.setup.apply(Constructor, t); + if (Constructor.init) { + Constructor.init.apply(Constructor, args || t); + } + return Constructor; + } + }); + can.Construct.prototype.setup = function () { + }; + can.Construct.prototype.init = function () { + }; + return can.Construct; +}); +/*can@2.2.6#control/control*/ +define('can/control/control', [ + 'can/util/util', + 'can/construct/construct' +], function (can) { + var bind = function (el, ev, callback) { + can.bind.call(el, ev, callback); + return function () { + can.unbind.call(el, ev, callback); + }; + }, isFunction = can.isFunction, extend = can.extend, each = can.each, slice = [].slice, paramReplacer = /\{([^\}]+)\}/g, special = can.getObject('$.event.special', [can]) || {}, delegate = function (el, selector, ev, callback) { + can.delegate.call(el, selector, ev, callback); + return function () { + can.undelegate.call(el, selector, ev, callback); + }; + }, binder = function (el, ev, callback, selector) { + return selector ? delegate(el, can.trim(selector), ev, callback) : bind(el, ev, callback); + }, basicProcessor; + var Control = can.Control = can.Construct({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Control) { + var control = this, funcName; + control.actions = {}; + for (funcName in control.prototype) { + if (control._isAction(funcName)) { + control.actions[funcName] = control._action(funcName); + } + } + } + }, + _shifter: function (context, name) { + var method = typeof name === 'string' ? context[name] : name; + if (!isFunction(method)) { + method = context[method]; + } + return function () { + context.called = name; + return method.apply(context, [this.nodeName ? can.$(this) : this].concat(slice.call(arguments, 0))); + }; + }, + _isAction: function (methodName) { + var val = this.prototype[methodName], type = typeof val; + return methodName !== 'constructor' && (type === 'function' || type === 'string' && isFunction(this.prototype[val])) && !!(special[methodName] || processors[methodName] || /[^\w]/.test(methodName)); + }, + _action: function (methodName, options) { + paramReplacer.lastIndex = 0; + if (options || !paramReplacer.test(methodName)) { + var convertedName = options ? can.sub(methodName, this._lookup(options)) : methodName; + if (!convertedName) { + return null; + } + var arr = can.isArray(convertedName), name = arr ? convertedName[1] : convertedName, parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: processors[event] || basicProcessor, + parts: [ + name, + parts.join(' '), + event + ], + delegate: arr ? convertedName[0] : undefined + }; + } + }, + _lookup: function (options) { + return [ + options, + window + ]; + }, + processors: {}, + defaults: {} + }, { + setup: function (element, options) { + var cls = this.constructor, pluginname = cls.pluginName || cls._fullName, arr; + this.element = can.$(element); + if (pluginname && pluginname !== 'can_control') { + this.element.addClass(pluginname); + } + arr = can.data(this.element, 'controls'); + if (!arr) { + arr = []; + can.data(this.element, 'controls', arr); + } + arr.push(this); + this.options = extend({}, cls.defaults, options); + this.on(); + return [ + this.element, + this.options + ]; + }, + on: function (el, selector, eventName, func) { + if (!el) { + this.off(); + var cls = this.constructor, bindings = this._bindings, actions = cls.actions, element = this.element, destroyCB = can.Control._shifter(this, 'destroy'), funcName, ready; + for (funcName in actions) { + if (actions.hasOwnProperty(funcName)) { + ready = actions[funcName] || cls._action(funcName, this.options, this); + if (ready) { + bindings.control[funcName] = ready.processor(ready.delegate || element, ready.parts[2], ready.parts[1], funcName, this); + } + } + } + can.bind.call(element, 'removed', destroyCB); + bindings.user.push(function (el) { + can.unbind.call(el, 'removed', destroyCB); + }); + return bindings.user.length; + } + if (typeof el === 'string') { + func = eventName; + eventName = selector; + selector = el; + el = this.element; + } + if (func === undefined) { + func = eventName; + eventName = selector; + selector = null; + } + if (typeof func === 'string') { + func = can.Control._shifter(this, func); + } + this._bindings.user.push(binder(el, eventName, func, selector)); + return this._bindings.user.length; + }, + off: function () { + var el = this.element[0], bindings = this._bindings; + if (bindings) { + each(bindings.user || [], function (value) { + value(el); + }); + each(bindings.control || {}, function (value) { + value(el); + }); + } + this._bindings = { + user: [], + control: {} + }; + }, + destroy: function () { + if (this.element === null) { + return; + } + var Class = this.constructor, pluginName = Class.pluginName || Class._fullName, controls; + this.off(); + if (pluginName && pluginName !== 'can_control') { + this.element.removeClass(pluginName); + } + controls = can.data(this.element, 'controls'); + controls.splice(can.inArray(this, controls), 1); + can.trigger(this, 'destroyed'); + this.element = null; + } + }); + var processors = can.Control.processors; + basicProcessor = function (el, event, selector, methodName, control) { + return binder(el, event, can.Control._shifter(control, methodName), selector); + }; + each([ + 'change', + 'click', + 'contextmenu', + 'dblclick', + 'keydown', + 'keyup', + 'keypress', + 'mousedown', + 'mousemove', + 'mouseout', + 'mouseover', + 'mouseup', + 'reset', + 'resize', + 'scroll', + 'select', + 'submit', + 'focusin', + 'focusout', + 'mouseenter', + 'mouseleave', + 'touchstart', + 'touchmove', + 'touchcancel', + 'touchend', + 'touchleave', + 'inserted', + 'removed' + ], function (v) { + processors[v] = basicProcessor; + }); + return Control; +}); +/*can@2.2.6#util/bind/bind*/ +define('can/util/bind/bind', ['can/util/util'], function (can) { + can.bindAndSetup = function () { + can.addEvent.apply(this, arguments); + if (!this._init) { + if (!this._bindings) { + this._bindings = 1; + if (this._bindsetup) { + this._bindsetup(); + } + } else { + this._bindings++; + } + } + return this; + }; + can.unbindAndTeardown = function (event, handler) { + var handlers = this.__bindEvents[event] || []; + var handlerCount = handlers.length; + can.removeEvent.apply(this, arguments); + if (this._bindings === null) { + this._bindings = 0; + } else { + this._bindings = this._bindings - (handlerCount - handlers.length); + } + if (!this._bindings && this._bindteardown) { + this._bindteardown(); + } + return this; + }; + return can; +}); +/*can@2.2.6#map/bubble*/ +define('can/map/bubble', ['can/util/util'], function (can) { + var bubble = can.bubble = { + event: function (map, boundEventName) { + return map.constructor._bubbleRule(boundEventName, map); + }, + childrenOf: function (parentMap, eventName) { + parentMap._each(function (child, prop) { + if (child && child.bind) { + bubble.toParent(child, parentMap, prop, eventName); + } + }); + }, + teardownChildrenFrom: function (parentMap, eventName) { + parentMap._each(function (child) { + bubble.teardownFromParent(parentMap, child, eventName); + }); + }, + toParent: function (child, parent, prop, eventName) { + can.listenTo.call(parent, child, eventName, function () { + var args = can.makeArray(arguments), ev = args.shift(); + args[0] = (can.List && parent instanceof can.List ? parent.indexOf(child) : prop) + (args[0] ? '.' + args[0] : ''); + ev.triggeredNS = ev.triggeredNS || {}; + if (ev.triggeredNS[parent._cid]) { + return; + } + ev.triggeredNS[parent._cid] = true; + can.trigger(parent, ev, args); + }); + }, + teardownFromParent: function (parent, child, eventName) { + if (child && child.unbind) { + can.stopListening.call(parent, child, eventName); + } + }, + isBubbling: function (parent, eventName) { + return parent._bubbleBindings && parent._bubbleBindings[eventName]; + }, + bind: function (parent, eventName) { + if (!parent._init) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + if (!parent._bubbleBindings) { + parent._bubbleBindings = {}; + } + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (!parent._bubbleBindings[bubbleEvent]) { + parent._bubbleBindings[bubbleEvent] = 1; + bubble.childrenOf(parent, bubbleEvent); + } else { + parent._bubbleBindings[bubbleEvent]++; + } + } + } + }, + unbind: function (parent, eventName) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (parent._bubbleBindings) { + parent._bubbleBindings[bubbleEvent]--; + } + if (parent._bubbleBindings && !parent._bubbleBindings[bubbleEvent]) { + delete parent._bubbleBindings[bubbleEvent]; + bubble.teardownChildrenFrom(parent, bubbleEvent); + if (can.isEmptyObject(parent._bubbleBindings)) { + delete parent._bubbleBindings; + } + } + } + }, + add: function (parent, child, prop) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + bubble.toParent(child, parent, prop, eventName); + } + } + } + }, + removeMany: function (parent, children) { + for (var i = 0, len = children.length; i < len; i++) { + bubble.remove(parent, children[i]); + } + }, + remove: function (parent, child) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + } + } + } + }, + set: function (parent, prop, value, current) { + if (can.Map.helpers.isObservable(value)) { + bubble.add(parent, value, prop); + } + if (can.Map.helpers.isObservable(current)) { + bubble.remove(parent, current); + } + return value; + } + }; + return bubble; +}); +/*can@2.2.6#util/batch/batch*/ +define('can/util/batch/batch', ['can/util/can'], function (can) { + var batchNum = 1, transactions = 0, batchEvents = [], stopCallbacks = [], currentBatchEvents = null; + can.batch = { + start: function (batchStopHandler) { + transactions++; + if (batchStopHandler) { + stopCallbacks.push(batchStopHandler); + } + }, + stop: function (force, callStart) { + if (force) { + transactions = 0; + } else { + transactions--; + } + if (transactions === 0) { + if (currentBatchEvents !== null) { + return; + } + currentBatchEvents = batchEvents.slice(0); + var callbacks = stopCallbacks.slice(0), i, len; + batchEvents = []; + stopCallbacks = []; + can.batch.batchNum = batchNum; + batchNum++; + if (callStart) { + can.batch.start(); + } + for (i = 0; i < currentBatchEvents.length; i++) { + can.dispatch.apply(currentBatchEvents[i][0], currentBatchEvents[i][1]); + } + currentBatchEvents = null; + for (i = 0, len = callbacks.length; i < callbacks.length; i++) { + callbacks[i](); + } + can.batch.batchNum = undefined; + } + }, + trigger: function (item, event, args) { + if (!item._init) { + event = typeof event === 'string' ? { type: event } : event; + if (currentBatchEvents) { + currentBatchEvents.push([ + item, + [ + event, + args + ] + ]); + } else if (transactions === 0) { + return can.dispatch.call(item, event, args); + } else { + event.batchNum = batchNum; + batchEvents.push([ + item, + [ + event, + args + ] + ]); + } + } + }, + afterPreviousEvents: function (handler) { + if (currentBatchEvents) { + var obj = {}; + can.bind.call(obj, 'ready', handler); + currentBatchEvents.push([ + obj, + [ + { type: 'ready' }, + [] + ] + ]); + } else { + handler(); + } + } + }; +}); +/*can@2.2.6#map/map*/ +define('can/map/map', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/map/bubble', + 'can/construct/construct', + 'can/util/batch/batch' +], function (can, bind, bubble) { + var madeMap = null; + var teardownMap = function () { + for (var cid in madeMap) { + if (madeMap[cid].added) { + delete madeMap[cid].obj._cid; + } + } + madeMap = null; + }; + var getMapFromObject = function (obj) { + return madeMap && madeMap[obj._cid] && madeMap[obj._cid].instance; + }; + var serializeMap = null; + var Map = can.Map = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Map) { + if (!this.defaults) { + this.defaults = {}; + } + this._computes = []; + for (var prop in this.prototype) { + if (prop !== 'define' && prop !== 'constructor' && (typeof this.prototype[prop] !== 'function' || this.prototype[prop].prototype instanceof can.Construct)) { + this.defaults[prop] = this.prototype[prop]; + } else if (this.prototype[prop].isComputed) { + this._computes.push(prop); + } + } + if (this.helpers.define) { + this.helpers.define(this); + } + } + if (can.List && !(this.prototype instanceof can.List)) { + this.List = Map.List.extend({ Map: this }, {}); + } + }, + _bubble: bubble, + _bubbleRule: function (eventName) { + return eventName === 'change' || eventName.indexOf('.') >= 0 ? ['change'] : []; + }, + _computes: [], + bind: can.bindAndSetup, + on: can.bindAndSetup, + unbind: can.unbindAndTeardown, + off: can.unbindAndTeardown, + id: 'id', + helpers: { + define: null, + attrParts: function (attr, keepKey) { + if (keepKey) { + return [attr]; + } + return typeof attr === 'object' ? attr : ('' + attr).split('.'); + }, + addToMap: function (obj, instance) { + var teardown; + if (!madeMap) { + teardown = teardownMap; + madeMap = {}; + } + var hasCid = obj._cid; + var cid = can.cid(obj); + if (!madeMap[cid]) { + madeMap[cid] = { + obj: obj, + instance: instance, + added: !hasCid + }; + } + return teardown; + }, + isObservable: function (obj) { + return obj instanceof can.Map || obj && obj === can.route; + }, + canMakeObserve: function (obj) { + return obj && !can.isDeferred(obj) && (can.isArray(obj) || can.isPlainObject(obj)); + }, + serialize: function (map, how, where) { + var cid = can.cid(map), firstSerialize = false; + if (!serializeMap) { + firstSerialize = true; + serializeMap = { + attr: {}, + serialize: {} + }; + } + serializeMap[how][cid] = where; + map.each(function (val, name) { + var result, isObservable = Map.helpers.isObservable(val), serialized = isObservable && serializeMap[how][can.cid(val)]; + if (serialized) { + result = serialized; + } else { + if (how === 'serialize') { + result = Map.helpers._serialize(map, name, val); + } else { + result = Map.helpers._getValue(map, name, val, how); + } + } + if (result !== undefined) { + where[name] = result; + } + }); + can.__observe(map, '__keys'); + if (firstSerialize) { + serializeMap = null; + } + return where; + }, + _serialize: function (map, name, val) { + return Map.helpers._getValue(map, name, val, 'serialize'); + }, + _getValue: function (map, name, val, how) { + if (Map.helpers.isObservable(val)) { + return val[how](); + } else { + return val; + } + } + }, + keys: function (map) { + var keys = []; + can.__observe(map, '__keys'); + for (var keyName in map._data) { + keys.push(keyName); + } + return keys; + } + }, { + setup: function (obj) { + if (obj instanceof can.Map) { + obj = obj.serialize(); + } + this._data = {}; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + var defaultValues = this._setupDefaults(obj); + this._setupComputes(defaultValues); + var teardownMapping = obj && can.Map.helpers.addToMap(obj, this); + var data = can.extend(can.extend(true, {}, defaultValues), obj); + this.attr(data); + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + delete this._init; + }, + _setupComputes: function () { + var computes = this.constructor._computes; + for (var i = 0, len = computes.length, prop; i < len; i++) { + prop = computes[i]; + this[prop] = this[prop].clone(this); + this._computedBindings[prop] = { count: 0 }; + } + }, + _setupDefaults: function () { + return this.constructor.defaults || {}; + }, + _bindsetup: function () { + }, + _bindteardown: function () { + }, + _changes: function (ev, attr, how, newVal, oldVal) { + can.batch.trigger(this, { + type: attr, + batchNum: ev.batchNum, + target: ev.target + }, [ + newVal, + oldVal + ]); + }, + _triggerChange: function (attr, how, newVal, oldVal) { + if (bubble.isBubbling(this, 'change')) { + can.batch.trigger(this, { + type: 'change', + target: this + }, [ + attr, + how, + newVal, + oldVal + ]); + } else { + can.batch.trigger(this, attr, [ + newVal, + oldVal + ]); + } + if (how === 'remove' || how === 'add') { + can.batch.trigger(this, { + type: '__keys', + target: this + }); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var prop in data) { + if (data.hasOwnProperty(prop)) { + callback(data[prop], prop); + } + } + }, + attr: function (attr, val) { + var type = typeof attr; + if (type !== 'string' && type !== 'number') { + return this._attrs(attr, val); + } else if (arguments.length === 1) { + return this._get(attr); + } else { + this._set(attr, val); + return this; + } + }, + each: function () { + return can.each.apply(undefined, [this].concat(can.makeArray(arguments))); + }, + removeAttr: function (attr) { + var isList = can.List && this instanceof can.List, parts = can.Map.helpers.attrParts(attr), prop = parts.shift(), current = isList ? this[prop] : this._data[prop]; + if (parts.length && current) { + return current.removeAttr(parts); + } else { + if (typeof attr === 'string' && !!~attr.indexOf('.')) { + prop = attr; + } + this._remove(prop, current); + return current; + } + }, + _remove: function (prop, current) { + if (prop in this._data) { + delete this._data[prop]; + if (!(prop in this.constructor.prototype)) { + delete this[prop]; + } + this._triggerChange(prop, 'remove', undefined, current); + } + }, + _get: function (attr) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'); + if (dotIndex >= 0) { + var value = this.__get(attr); + if (value !== undefined) { + return value; + } + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + can.__observe(this, first); + var current = this.__get(first); + return current && current._get ? current._get(second) : undefined; + } else { + can.__observe(this, attr); + return this.__get(attr); + } + }, + __get: function (attr) { + if (attr) { + if (this._computedBindings[attr]) { + return this[attr](); + } else { + return this._data[attr]; + } + } else { + return this._data; + } + }, + __type: function (value, prop) { + if (!(value instanceof can.Map) && can.Map.helpers.canMakeObserve(value)) { + var cached = getMapFromObject(value); + if (cached) { + return cached; + } + if (can.isArray(value)) { + var List = can.List; + return new List(value); + } else { + var Map = this.constructor.Map || can.Map; + return new Map(value); + } + } + return value; + }, + _set: function (attr, value, keepKey) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'), current; + if (!keepKey && dotIndex >= 0) { + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + current = this._init ? undefined : this.__get(first); + if (Map.helpers.isObservable(current)) { + current._set(second, value); + } else { + throw 'can.Map: Object does not exist'; + } + } else { + if (this.__convert) { + value = this.__convert(attr, value); + } + current = this._init ? undefined : this.__get(attr); + this.__set(attr, this.__type(value, attr), current); + } + }, + __set: function (prop, value, current) { + if (value !== current) { + var changeType = current !== undefined || this.__get().hasOwnProperty(prop) ? 'set' : 'add'; + this.___set(prop, this.constructor._bubble.set(this, prop, value, current)); + if (!this._computedBindings[prop]) { + this._triggerChange(prop, changeType, value, current); + } + if (current) { + this.constructor._bubble.teardownFromParent(this, current); + } + } + }, + ___set: function (prop, val) { + if (this._computedBindings[prop]) { + this[prop](val); + } else { + this._data[prop] = val; + } + if (typeof this.constructor.prototype[prop] !== 'function' && !this._computedBindings[prop]) { + this[prop] = val; + } + }, + bind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (!computedBinding.count) { + computedBinding.count = 1; + var self = this; + computedBinding.handler = function (ev, newVal, oldVal) { + can.batch.trigger(self, { + type: eventName, + batchNum: ev.batchNum, + target: self + }, [ + newVal, + oldVal + ]); + }; + this[eventName].bind('change', computedBinding.handler); + } else { + computedBinding.count++; + } + } + this.constructor._bubble.bind(this, eventName); + return can.bindAndSetup.apply(this, arguments); + }, + unbind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (computedBinding.count === 1) { + computedBinding.count = 0; + this[eventName].unbind('change', computedBinding.handler); + delete computedBinding.handler; + } else { + computedBinding.count--; + } + } + this.constructor._bubble.unbind(this, eventName); + return can.unbindAndTeardown.apply(this, arguments); + }, + serialize: function () { + return can.Map.helpers.serialize(this, 'serialize', {}); + }, + _attrs: function (props, remove) { + if (props === undefined) { + return Map.helpers.serialize(this, 'attr', {}); + } + props = can.simpleExtend({}, props); + var prop, self = this, newVal; + can.batch.start(); + this.each(function (curVal, prop) { + if (prop === '_cid') { + return; + } + newVal = props[prop]; + if (newVal === undefined) { + if (remove) { + self.removeAttr(prop); + } + return; + } + if (self.__convert) { + newVal = self.__convert(prop, newVal); + } + if (Map.helpers.isObservable(newVal)) { + self.__set(prop, self.__type(newVal, prop), curVal); + } else if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + self.__set(prop, self.__type(newVal, prop), curVal); + } + delete props[prop]; + }); + for (prop in props) { + if (prop !== '_cid') { + newVal = props[prop]; + this._set(prop, newVal, true); + } + } + can.batch.stop(); + return this; + }, + compute: function (prop) { + if (can.isFunction(this.constructor.prototype[prop])) { + return can.compute(this[prop], this); + } else { + var reads = prop.split('.'), last = reads.length - 1, options = { args: [] }; + return can.compute(function (newVal) { + if (arguments.length) { + can.compute.read(this, reads.slice(0, last)).value.attr(reads[last], newVal); + } else { + return can.compute.read(this, reads, options).value; + } + }, this); + } + } + }); + Map.prototype.on = Map.prototype.bind; + Map.prototype.off = Map.prototype.unbind; + return Map; +}); +/*can@2.2.6#list/list*/ +define('can/list/list', [ + 'can/util/util', + 'can/map/map', + 'can/map/bubble' +], function (can, Map, bubble) { + var splice = [].splice, spliceRemovesProps = function () { + var obj = { + 0: 'a', + length: 1 + }; + splice.call(obj, 0, 1); + return !obj[0]; + }(); + var list = Map.extend({ Map: Map }, { + setup: function (instances, options) { + this.length = 0; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + this._setupComputes(); + instances = instances || []; + var teardownMapping; + if (can.isDeferred(instances)) { + this.replace(instances); + } else { + teardownMapping = instances.length && can.Map.helpers.addToMap(instances, this); + this.push.apply(this, can.makeArray(instances || [])); + } + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + can.simpleExtend(this, options); + delete this._init; + }, + _triggerChange: function (attr, how, newVal, oldVal) { + Map.prototype._triggerChange.apply(this, arguments); + var index = +attr; + if (!~('' + attr).indexOf('.') && !isNaN(index)) { + if (how === 'add') { + can.batch.trigger(this, how, [ + newVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else if (how === 'remove') { + can.batch.trigger(this, how, [ + oldVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else { + can.batch.trigger(this, how, [ + newVal, + index + ]); + } + } + }, + __get: function (attr) { + if (attr) { + if (this[attr] && this[attr].isComputed && can.isFunction(this.constructor.prototype[attr])) { + return this[attr](); + } else { + return this[attr]; + } + } else { + return this; + } + }, + __set: function (prop, value, current) { + prop = isNaN(+prop) || prop % 1 ? prop : +prop; + if (typeof prop === 'number' && prop > this.length - 1) { + var newArr = new Array(prop + 1 - this.length); + newArr[newArr.length - 1] = value; + this.push.apply(this, newArr); + return newArr; + } + return can.Map.prototype.__set.call(this, '' + prop, value, current); + }, + ___set: function (attr, val) { + this[attr] = val; + if (+attr >= this.length) { + this.length = +attr + 1; + } + }, + _remove: function (prop, current) { + if (isNaN(+prop)) { + delete this[prop]; + this._triggerChange(prop, 'remove', undefined, current); + } else { + this.splice(prop, 1); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var i = 0; i < data.length; i++) { + callback(data[i], i); + } + }, + serialize: function () { + return Map.helpers.serialize(this, 'serialize', []); + }, + splice: function (index, howMany) { + var args = can.makeArray(arguments), added = [], i, len, listIndex, allSame = args.length > 2; + index = index || 0; + for (i = 0, len = args.length - 2; i < len; i++) { + listIndex = i + 2; + args[listIndex] = this.__type(args[listIndex], listIndex); + added.push(args[listIndex]); + if (this[i + index] !== args[listIndex]) { + allSame = false; + } + } + if (allSame && this.length <= added.length) { + return added; + } + if (howMany === undefined) { + howMany = args[1] = this.length - index; + } + var removed = splice.apply(this, args); + if (!spliceRemovesProps) { + for (i = this.length; i < removed.length + this.length; i++) { + delete this[i]; + } + } + can.batch.start(); + if (howMany > 0) { + bubble.removeMany(this, removed); + this._triggerChange('' + index, 'remove', undefined, removed); + } + if (args.length > 2) { + for (i = 0, len = added.length; i < len; i++) { + bubble.set(this, i, added[i]); + } + this._triggerChange('' + index, 'add', added, removed); + } + can.batch.stop(); + return removed; + }, + _attrs: function (items, remove) { + if (items === undefined) { + return Map.helpers.serialize(this, 'attr', []); + } + items = can.makeArray(items); + can.batch.start(); + this._updateAttrs(items, remove); + can.batch.stop(); + }, + _updateAttrs: function (items, remove) { + var len = Math.min(items.length, this.length); + for (var prop = 0; prop < len; prop++) { + var curVal = this[prop], newVal = items[prop]; + if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + this._set(prop, newVal); + } else { + } + } + if (items.length > this.length) { + this.push.apply(this, items.slice(this.length)); + } else if (items.length < this.length && remove) { + this.splice(items.length); + } + } + }), getArgs = function (args) { + return args[0] && can.isArray(args[0]) ? args[0] : can.makeArray(args); + }; + can.each({ + push: 'length', + unshift: 0 + }, function (where, name) { + var orig = [][name]; + list.prototype[name] = function () { + var args = [], len = where ? this.length : 0, i = arguments.length, res, val; + while (i--) { + val = arguments[i]; + args[i] = bubble.set(this, i, this.__type(val, i)); + } + res = orig.apply(this, args); + if (!this.comparator || args.length) { + this._triggerChange('' + len, 'add', args, undefined); + } + return res; + }; + }); + can.each({ + pop: 'length', + shift: 0 + }, function (where, name) { + list.prototype[name] = function () { + if (!this.length) { + return undefined; + } + var args = getArgs(arguments), len = where && this.length ? this.length - 1 : 0; + var res = [][name].apply(this, args); + this._triggerChange('' + len, 'remove', undefined, [res]); + if (res && res.unbind) { + bubble.remove(this, res); + } + return res; + }; + }); + can.extend(list.prototype, { + indexOf: function (item, fromIndex) { + this.attr('length'); + return can.inArray(item, this, fromIndex); + }, + join: function () { + return [].join.apply(this.attr(), arguments); + }, + reverse: function () { + var list = [].reverse.call(can.makeArray(this)); + this.replace(list); + }, + slice: function () { + var temp = Array.prototype.slice.apply(this, arguments); + return new this.constructor(temp); + }, + concat: function () { + var args = []; + can.each(can.makeArray(arguments), function (arg, i) { + args[i] = arg instanceof can.List ? arg.serialize() : arg; + }); + return new this.constructor(Array.prototype.concat.apply(this.serialize(), args)); + }, + forEach: function (cb, thisarg) { + return can.each(this, cb, thisarg || this); + }, + replace: function (newList) { + if (can.isDeferred(newList)) { + newList.then(can.proxy(this.replace, this)); + } else { + this.splice.apply(this, [ + 0, + this.length + ].concat(can.makeArray(newList || []))); + } + return this; + }, + filter: function (callback, thisArg) { + var filteredList = new can.List(), self = this, filtered; + this.each(function (item, index, list) { + filtered = callback.call(thisArg | self, item, index, self); + if (filtered) { + filteredList.push(item); + } + }); + return filteredList; + } + }); + can.List = Map.List = list; + return can.List; +}); +/*can@2.2.6#compute/read*/ +define('can/compute/read', ['can/util/util'], function (can) { + var read = function (parent, reads, options) { + options = options || {}; + var state = { foundObservable: false }; + var cur = readValue(parent, 0, reads, options, state), type, prev, readLength = reads.length, i = 0; + while (i < readLength) { + prev = cur; + for (var r = 0, readersLength = read.propertyReaders.length; r < readersLength; r++) { + var reader = read.propertyReaders[r]; + if (reader.test(cur)) { + cur = reader.read(cur, reads[i], i, options, state); + break; + } + } + i = i + 1; + cur = readValue(cur, i, reads, options, state, prev); + type = typeof cur; + if (i < reads.length && (cur === null || type !== 'function' && type !== 'object')) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1, cur); + } + return { + value: undefined, + parent: prev + }; + } + } + if (cur === undefined) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1); + } + } + return { + value: cur, + parent: prev + }; + }; + var readValue = function (value, index, reads, options, state, prev) { + var usedValueReader; + do { + usedValueReader = false; + for (var i = 0, len = read.valueReaders.length; i < len; i++) { + if (read.valueReaders[i].test(value, index, reads, options)) { + value = read.valueReaders[i].read(value, index, reads, options, state, prev); + } + } + } while (usedValueReader); + return value; + }; + read.valueReaders = [ + { + name: 'compute', + test: function (value, i, reads, options) { + return value && value.isComputed; + }, + read: function (value, i, reads, options, state) { + if (options.isArgument && i === reads.length) { + return value; + } + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, i); + state.foundObservable = true; + } + return value instanceof can.Compute ? value.get() : value(); + } + }, + { + name: 'function', + test: function (value, i, reads, options) { + var type = typeof value; + return type === 'function' && !value.isComputed && (options.executeAnonymousFunctions || options.isArgument && i === reads.length) && !(can.Construct && value.prototype instanceof can.Construct) && !(can.route && value === can.route); + }, + read: function (value, i, reads, options, state, prev) { + if (options.isArgument && i === reads.length) { + return options.proxyMethods !== false ? can.proxy(value, prev) : value; + } + return value.call(prev); + } + } + ]; + read.propertyReaders = [ + { + name: 'map', + test: can.isMapLike, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + if (typeof value[prop] === 'function' && value.constructor.prototype[prop] === value[prop]) { + if (options.returnObserveMethods) { + return value[prop]; + } else if (prop === 'constructor' && value instanceof can.Construct || value[prop].prototype instanceof can.Construct) { + return value[prop]; + } else { + return value[prop].apply(value, options.args || []); + } + } else { + return value.attr(prop); + } + } + }, + { + name: 'promise', + test: function (value) { + return can.isPromise(value); + }, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + var observeData = value.__observeData; + if (!value.__observeData) { + observeData = value.__observeData = { + isPending: true, + state: 'pending', + isResolved: false, + isRejected: false, + value: undefined, + reason: undefined + }; + can.cid(observeData); + can.simpleExtend(observeData, can.event); + value.then(function (value) { + observeData.isPending = false; + observeData.isResolved = true; + observeData.value = value; + observeData.state = 'resolved'; + observeData.dispatch('state', [ + 'resolved', + 'pending' + ]); + }, function (reason) { + observeData.isPending = false; + observeData.isRejected = true; + observeData.reason = reason; + observeData.state = 'rejected'; + observeData.dispatch('state', [ + 'rejected', + 'pending' + ]); + }); + } + can.__observe(observeData, 'state'); + return prop in observeData ? observeData[prop] : value[prop]; + } + }, + { + name: 'object', + test: function () { + return true; + }, + read: function (value, prop) { + if (value == null) { + return undefined; + } else { + return value[prop]; + } + } + } + ]; + read.write = function (parent, key, value, options) { + options = options || {}; + if (can.isMapLike(parent)) { + if (!options.isArgument && parent._data && parent._data[key] && parent._data[key].isComputed) { + return parent._data[key](value); + } else { + return parent.attr(key, value); + } + } + if (parent[key] && parent[key].isComputed) { + return parent[key](value); + } + if (typeof parent === 'object') { + parent[key] = value; + } + }; + return read; +}); +/*can@2.2.6#compute/get_value_and_bind*/ +define('can/compute/get_value_and_bind', ['can/util/util'], function () { + function observe(func, context, oldInfo, onchanged) { + var info = getValueAndObserved(func, context), newObserveSet = info.observed, oldObserved = oldInfo.observed; + if (info.names !== oldInfo.names) { + bindNewSet(oldObserved, newObserveSet, onchanged); + unbindOldSet(oldObserved, onchanged); + } + can.batch.afterPreviousEvents(function () { + info.ready = true; + }); + return info; + } + var observedStack = []; + can.__isRecordingObserves = function () { + return observedStack.length; + }; + can.__observe = can.__reading = function (obj, event) { + if (observedStack.length) { + var name = obj._cid + '|' + event, top = observedStack[observedStack.length - 1]; + top.names += name; + top.observed[name] = { + obj: obj, + event: event + '' + }; + } + }; + can.__notObserve = function (fn) { + return function () { + var previousReads = can.__clearObserved(); + var res = fn.apply(this, arguments); + can.__setObserved(previousReads); + return res; + }; + }; + can.__clearObserved = can.__clearReading = function () { + if (observedStack.length) { + var ret = observedStack[observedStack.length - 1]; + observedStack[observedStack.length - 1] = { observed: {} }; + return ret; + } + }; + can.__setObserved = can.__setReading = function (o) { + if (observedStack.length) { + observedStack[observedStack.length - 1] = o; + } + }; + can.__addObserved = can.__addReading = function (o) { + if (observedStack.length) { + can.simpleExtend(observedStack[observedStack.length - 1], o); + } + }; + var getValueAndObserved = function (func, self) { + observedStack.push({ + names: '', + observed: {} + }); + var value = func.call(self); + var stackItem = observedStack.pop(); + stackItem.value = value; + return stackItem; + }; + var bindNewSet = function (oldObserved, newObserveSet, onchanged) { + for (var name in newObserveSet) { + bindOrPreventUnbinding(oldObserved, newObserveSet, name, onchanged); + } + }; + var bindOrPreventUnbinding = function (oldObserved, newObserveSet, name, onchanged) { + if (oldObserved[name]) { + delete oldObserved[name]; + } else { + var obEv = newObserveSet[name]; + obEv.obj.bind(obEv.event, onchanged); + } + }; + var unbindOldSet = function (oldObserved, onchanged) { + for (var name in oldObserved) { + var obEv = oldObserved[name]; + obEv.obj.unbind(obEv.event, onchanged); + } + }; + return observe; +}); +/*can@2.2.6#compute/proto_compute*/ +define('can/compute/proto_compute', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/compute/read', + 'can/compute/get_value_and_bind', + 'can/util/batch/batch' +], function (can, bind, read, getValueAndBind) { + var updateOnChange = function (compute, newValue, oldValue, batchNum) { + if (newValue !== oldValue) { + can.batch.trigger(compute, batchNum ? { + type: 'change', + batchNum: batchNum + } : 'change', [ + newValue, + oldValue + ]); + } + }; + var setupComputeHandlers = function (compute, func, context, singleBind) { + var readInfo, onchanged, batchNum; + singleBind = false; + return { + on: function (updater) { + var self = this; + if (!onchanged) { + onchanged = function (ev) { + if (readInfo.ready && compute.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + if (singleBind) { + newValue = func.call(context); + readInfo.value = newValue; + } else { + readInfo = getValueAndBind(func, context, readInfo, onchanged); + newValue = readInfo.value; + } + self.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }; + } + readInfo = getValueAndBind(func, context, { observed: {} }, onchanged); + if (singleBind) { + func = can.__notObserve(func); + } + compute.value = readInfo.value; + compute.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function (updater) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, onchanged); + } + } + }; + }; + var k = function () { + }; + var updater = function (newVal, oldVal, batchNum) { + this.value = newVal; + updateOnChange(this, newVal, oldVal, batchNum); + }, asyncGet = function (fn, context, lastSetValue) { + return function () { + return fn.call(context, lastSetValue.get()); + }; + }, asyncUpdater = function (context, oldUpdater) { + return function (newVal) { + if (newVal !== undefined) { + oldUpdater(newVal, context.value); + } + }; + }; + can.Compute = function (getterSetter, context, eventName, bindOnce) { + var args = []; + for (var i = 0, arglen = arguments.length; i < arglen; i++) { + args[i] = arguments[i]; + } + var contextType = typeof args[1]; + if (typeof args[0] === 'function') { + this._setupGetterSetterFn(args[0], args[1], args[2], args[3]); + } else if (args[1]) { + if (contextType === 'string') { + this._setupContextString(args[0], args[1], args[2]); + } else if (contextType === 'function') { + this._setupContextFunction(args[0], args[1], args[2]); + } else { + if (args[1] && args[1].fn) { + this._setupAsyncCompute(args[0], args[1]); + } else { + this._setupContextSettings(args[0], args[1]); + } + } + } else { + this._setupInitialValue(args[0]); + } + this._args = args; + this.isComputed = true; + can.cid(this, 'compute'); + }; + can.simpleExtend(can.Compute.prototype, { + _bindsetup: can.__notObserve(function () { + this.bound = true; + this._on(this.updater); + }), + _bindteardown: function () { + this._off(this.updater); + this.bound = false; + }, + bind: can.bindAndSetup, + unbind: can.unbindAndTeardown, + clone: function (context) { + if (context && typeof this._args[0] === 'function') { + this._args[1] = context; + } else if (context) { + this._args[2] = context; + } + return new can.Compute(this._args[0], this._args[1], this._args[2], this._args[3]); + }, + _on: k, + _off: k, + get: function () { + if (can.__isRecordingObserves() && this._canObserve !== false) { + can.__observe(this, 'change'); + if (!this.bound) { + can.Compute.temporarilyBind(this); + } + } + if (this.bound) { + return this.value; + } else { + return this._get(); + } + }, + _get: function () { + return this.value; + }, + set: function (newVal) { + var old = this.value; + var setVal = this._set(newVal, old); + if (this.hasDependencies) { + if (this._setUpdates) { + return this.value; + } + return this._get(); + } + if (setVal === undefined) { + this.value = this._get(); + } else { + this.value = setVal; + } + updateOnChange(this, this.value, old); + return this.value; + }, + _set: function (newVal) { + return this.value = newVal; + }, + updater: updater, + _computeFn: function (newVal) { + if (arguments.length) { + return this.set(newVal); + } + return this.get(); + }, + toFunction: function () { + return can.proxy(this._computeFn, this); + }, + _setupGetterSetterFn: function (getterSetter, context, eventName, bindOnce) { + this._set = can.proxy(getterSetter, context); + this._get = can.proxy(getterSetter, context); + this._canObserve = eventName === false ? false : true; + var handlers = setupComputeHandlers(this, getterSetter, context || this, bindOnce); + this._on = handlers.on; + this._off = handlers.off; + }, + _setupContextString: function (target, propertyName, eventName) { + var isObserve = can.isMapLike(target), self = this, handler = function (ev, newVal, oldVal) { + self.updater(newVal, oldVal, ev.batchNum); + }; + if (isObserve) { + this.hasDependencies = true; + this._get = function () { + return target.attr(propertyName); + }; + this._set = function (val) { + target.attr(propertyName, val); + }; + this._on = function (update) { + target.bind(eventName || propertyName, handler); + this.value = this._get(); + }; + this._off = function () { + return target.unbind(eventName || propertyName, handler); + }; + } else { + this._get = can.proxy(this._get, target); + this._set = can.proxy(this._set, target); + } + }, + _setupContextFunction: function (initialValue, setter, eventName) { + this.value = initialValue; + this._set = setter; + can.simpleExtend(this, eventName); + }, + _setupContextSettings: function (initialValue, settings) { + this.value = initialValue; + this._set = settings.set ? can.proxy(settings.set, settings) : this._set; + this._get = settings.get ? can.proxy(settings.get, settings) : this._get; + if (!settings.__selfUpdater) { + var self = this, oldUpdater = this.updater; + this.updater = function () { + oldUpdater.call(self, self._get(), self.value); + }; + } + this._on = settings.on ? settings.on : this._on; + this._off = settings.off ? settings.off : this._off; + }, + _setupAsyncCompute: function (initialValue, settings) { + this.value = initialValue; + var oldUpdater = can.proxy(this.updater, this), self = this, fn = settings.fn, data; + this.updater = oldUpdater; + var lastSetValue = new can.Compute(initialValue); + this.lastSetValue = lastSetValue; + this._setUpdates = true; + this._set = function (newVal) { + if (newVal === lastSetValue.get()) { + return this.value; + } + return lastSetValue.set(newVal); + }; + this._get = asyncGet(fn, settings.context, lastSetValue); + if (fn.length === 0) { + data = setupComputeHandlers(this, fn, settings.context); + } else if (fn.length === 1) { + data = setupComputeHandlers(this, function () { + return fn.call(settings.context, lastSetValue.get()); + }, settings); + } else { + this.updater = asyncUpdater(this, oldUpdater); + data = setupComputeHandlers(this, function () { + var res = fn.call(settings.context, lastSetValue.get(), function (newVal) { + oldUpdater(newVal, self.value); + }); + return res !== undefined ? res : this.value; + }, settings); + } + this._on = data.on; + this._off = data.off; + }, + _setupInitialValue: function (initialValue) { + this.value = initialValue; + } + }); + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.Compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.Compute.async = function (initialValue, asyncComputer, context) { + return new can.Compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.Compute.read = read; + can.Compute.set = read.write; + can.Compute.truthy = function (compute) { + return new can.Compute(function () { + var res = compute.get(); + if (typeof res === 'function') { + res = res.get(); + } + return !!res; + }); + }; + return can.Compute; +}); +/*can@2.2.6#compute/compute*/ +define('can/compute/compute', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/util/batch/batch', + 'can/compute/proto_compute' +], function (can, bind) { + can.compute = function (getterSetter, context, eventName, bindOnce) { + var internalCompute = new can.Compute(getterSetter, context, eventName, bindOnce); + var compute = function (val) { + if (arguments.length) { + return internalCompute.set(val); + } + return internalCompute.get(); + }; + compute.bind = can.proxy(internalCompute.bind, internalCompute); + compute.unbind = can.proxy(internalCompute.unbind, internalCompute); + compute.isComputed = internalCompute.isComputed; + compute.clone = function (ctx) { + if (typeof getterSetter === 'function') { + context = ctx; + } + return can.compute(getterSetter, context, ctx, bindOnce); + }; + compute.computeInstance = internalCompute; + return compute; + }; + var k = function () { + }; + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.compute.truthy = function (compute) { + return can.compute(function () { + var res = compute(); + if (typeof res === 'function') { + res = res(); + } + return !!res; + }); + }; + can.compute.async = function (initialValue, asyncComputer, context) { + return can.compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.compute.read = can.Compute.read; + can.compute.set = can.Compute.set; + return can.compute; +}); +/*can@2.2.6#observe/observe*/ +define('can/observe/observe', [ + 'can/util/util', + 'can/map/map', + 'can/list/list', + 'can/compute/compute' +], function (can) { + can.Observe = can.Map; + can.Observe.startBatch = can.batch.start; + can.Observe.stopBatch = can.batch.stop; + can.Observe.triggerBatch = can.batch.trigger; + return can; +}); +/*can@2.2.6#view/scope/compute_data*/ +define('can/view/scope/compute_data', [ + 'can/util/util', + 'can/compute/compute', + 'can/compute/get_value_and_bind' +], function (can, compute, getValueAndBind) { + var isFastPath = function (computeData) { + return computeData.reads && computeData.reads.length === 1 && computeData.root instanceof can.Map && !can.isFunction(computeData.root[computeData.reads[0]]); + }; + var getValueAndBindScopeRead = function (scopeRead, scopeReadChanged) { + return getValueAndBind(scopeRead, null, { observed: {} }, scopeReadChanged); + }; + var unbindScopeRead = function (readInfo, scopeReadChanged) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, scopeReadChanged); + } + }; + var getValueAndBindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + var target = computeData.root, prop = computeData.reads[0]; + target.bind(prop, singlePropertyReadChanged); + return { + value: computeData.initialValue, + observed: { something: true } + }; + }; + var unbindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + computeData.root.unbind(computeData.reads[0], singlePropertyReadChanged); + }; + var scopeReader = function (scope, key, options, computeData, newVal) { + if (arguments.length > 4) { + if (computeData.root.isComputed) { + computeData.root(newVal); + } else if (computeData.reads.length) { + var last = computeData.reads.length - 1; + var obj = computeData.reads.length ? can.compute.read(computeData.root, computeData.reads.slice(0, last)).value : computeData.root; + can.compute.set(obj, computeData.reads[last], newVal, options); + } + } else { + if (computeData.root) { + return can.compute.read(computeData.root, computeData.reads, options).value; + } + var data = scope.read(key, options); + computeData.scope = data.scope; + computeData.initialValue = data.value; + computeData.reads = data.reads; + computeData.root = data.rootObserve; + return data.value; + } + }; + return function (scope, key, options) { + options = options || { args: [] }; + var computeData = {}, scopeRead = function (newVal) { + if (arguments.length) { + return scopeReader(scope, key, options, computeData, newVal); + } else { + return scopeReader(scope, key, options, computeData); + } + }, batchNum, readInfo, scopeReadChanged = function (ev) { + if (readInfo.ready && compute.computeInstance.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + readInfo = getValueAndBind(scopeRead, null, readInfo, scopeReadChanged); + newValue = readInfo.value; + compute.computeInstance.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }, singlePropertyReadChanged = function (ev, newVal, oldVal) { + if (typeof newVal !== 'function') { + compute.computeInstance.updater(newVal, oldVal, ev.batchNum); + } else { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + isFastPathBound = false; + compute.computeInstance.updater(readInfo.value, oldVal, ev.batchNum); + } + }, isFastPathBound = false, compute = can.compute(undefined, { + on: function () { + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + if (isFastPath(computeData)) { + var oldReadInfo = readInfo; + readInfo = getValueAndBindSinglePropertyRead(computeData, singlePropertyReadChanged); + unbindScopeRead(oldReadInfo, scopeReadChanged); + isFastPathBound = true; + } + compute.computeInstance.value = readInfo.value; + compute.computeInstance.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function () { + if (isFastPathBound) { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + } else { + unbindScopeRead(readInfo, scopeReadChanged); + } + }, + set: scopeRead, + get: scopeRead, + __selfUpdater: true + }); + computeData.compute = compute; + return computeData; + }; +}); +/*can@2.2.6#view/scope/scope*/ +define('can/view/scope/scope', [ + 'can/util/util', + 'can/view/scope/compute_data', + 'can/construct/construct', + 'can/map/map', + 'can/list/list', + 'can/view/view', + 'can/compute/compute' +], function (can, makeComputeData) { + var escapeReg = /(\\)?\./g, escapeDotReg = /\\\./g, getNames = function (attr) { + var names = [], last = 0; + attr.replace(escapeReg, function (first, second, index) { + if (!second) { + names.push(attr.slice(last, index).replace(escapeDotReg, '.')); + last = index + first.length; + } + }); + names.push(attr.slice(last).replace(escapeDotReg, '.')); + return names; + }; + var Scope = can.Construct.extend({ read: can.compute.read }, { + init: function (context, parent) { + this._context = context; + this._parent = parent; + this.__cache = {}; + }, + attr: can.__notObserve(function (key, value) { + var options = { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }, res = this.read(key, options); + if (arguments.length === 2) { + var lastIndex = key.lastIndexOf('.'), readKey = lastIndex !== -1 ? key.substring(0, lastIndex) : '.', obj = this.read(readKey, options).value; + if (lastIndex !== -1) { + key = key.substring(lastIndex + 1, key.length); + } + can.compute.set(obj, key, value, options); + } + return res.value; + }), + add: function (context) { + if (context !== this._context) { + return new this.constructor(context, this); + } else { + return this; + } + }, + computeData: function (key, options) { + return makeComputeData(this, key, options); + }, + compute: function (key, options) { + return this.computeData(key, options).compute; + }, + read: function (attr, options) { + var stopLookup; + if (attr.substr(0, 2) === './') { + stopLookup = true; + attr = attr.substr(2); + } else if (attr.substr(0, 3) === '../') { + return this._parent.read(attr.substr(3), options); + } else if (attr === '..') { + return { value: this._parent._context }; + } else if (attr === '.' || attr === 'this') { + return { value: this._context }; + } + var names = attr.indexOf('\\.') === -1 ? attr.split('.') : getNames(attr), context, scope = this, defaultObserve, defaultReads = [], defaultPropertyDepth = -1, defaultComputeReadings, defaultScope, currentObserve, currentReads; + while (scope) { + context = scope._context; + if (context !== null && (typeof context === 'object' || typeof context === 'function')) { + var data = can.compute.read(context, names, can.simpleExtend({ + foundObservable: function (observe, nameIndex) { + currentObserve = observe; + currentReads = names.slice(nameIndex); + }, + earlyExit: function (parentValue, nameIndex) { + if (nameIndex > defaultPropertyDepth) { + defaultObserve = currentObserve; + defaultReads = currentReads; + defaultPropertyDepth = nameIndex; + defaultScope = scope; + defaultComputeReadings = can.__clearReading(); + } + }, + executeAnonymousFunctions: true + }, options)); + if (data.value !== undefined) { + return { + scope: scope, + rootObserve: currentObserve, + value: data.value, + reads: currentReads + }; + } + } + can.__clearReading(); + if (!stopLookup) { + scope = scope._parent; + } else { + scope = null; + } + } + if (defaultObserve) { + can.__setReading(defaultComputeReadings); + return { + scope: defaultScope, + rootObserve: defaultObserve, + reads: defaultReads, + value: undefined + }; + } else { + return { + names: names, + value: undefined + }; + } + } + }); + can.view.Scope = Scope; + return Scope; +}); +/*can@2.2.6#view/scanner*/ +define('can/view/scanner', [ + 'can/view/view', + 'can/view/elements', + 'can/view/callbacks/callbacks' +], function (can, elements, viewCallbacks) { + var newLine = /(\r|\n)+/g, notEndTag = /\//, clean = function (content) { + return content.split('\\').join('\\\\').split('\n').join('\\n').split('"').join('\\"').split('\t').join('\\t'); + }, getTag = function (tagName, tokens, i) { + if (tagName) { + return tagName; + } else { + while (i < tokens.length) { + if (tokens[i] === '<' && !notEndTag.test(tokens[i + 1])) { + return elements.reverseTagMap[tokens[i + 1]] || 'span'; + } + i++; + } + } + return ''; + }, bracketNum = function (content) { + return --content.split('{').length - --content.split('}').length; + }, myEval = function (script) { + eval(script); + }, attrReg = /([^\s]+)[\s]*=[\s]*$/, startTxt = 'var ___v1ew = [];', finishTxt = 'return ___v1ew.join(\'\')', put_cmd = '___v1ew.push(\n', insert_cmd = put_cmd, htmlTag = null, quote = null, beforeQuote = null, rescan = null, getAttrName = function () { + var matches = beforeQuote.match(attrReg); + return matches && matches[1]; + }, status = function () { + return quote ? '\'' + getAttrName() + '\'' : htmlTag ? 1 : 0; + }, top = function (stack) { + return stack[stack.length - 1]; + }, Scanner; + can.view.Scanner = Scanner = function (options) { + can.extend(this, { + text: {}, + tokens: [] + }, options); + this.text.options = this.text.options || ''; + this.tokenReg = []; + this.tokenSimple = { + '<': '<', + '>': '>', + '"': '"', + '\'': '\'' + }; + this.tokenComplex = []; + this.tokenMap = {}; + for (var i = 0, token; token = this.tokens[i]; i++) { + if (token[2]) { + this.tokenReg.push(token[2]); + this.tokenComplex.push({ + abbr: token[1], + re: new RegExp(token[2]), + rescan: token[3] + }); + } else { + this.tokenReg.push(token[1]); + this.tokenSimple[token[1]] = token[0]; + } + this.tokenMap[token[0]] = token[1]; + } + this.tokenReg = new RegExp('(' + this.tokenReg.slice(0).concat([ + '<', + '>', + '"', + '\'' + ]).join('|') + ')', 'g'); + }; + Scanner.prototype = { + helpers: [], + scan: function (source, name) { + var tokens = [], last = 0, simple = this.tokenSimple, complex = this.tokenComplex; + source = source.replace(newLine, '\n'); + if (this.transform) { + source = this.transform(source); + } + source.replace(this.tokenReg, function (whole, part) { + var offset = arguments[arguments.length - 2]; + if (offset > last) { + tokens.push(source.substring(last, offset)); + } + if (simple[whole]) { + tokens.push(whole); + } else { + for (var i = 0, token; token = complex[i]; i++) { + if (token.re.test(whole)) { + tokens.push(token.abbr); + if (token.rescan) { + tokens.push(token.rescan(part)); + } + break; + } + } + } + last = offset + part.length; + }); + if (last < source.length) { + tokens.push(source.substr(last)); + } + var content = '', buff = [startTxt + (this.text.start || '')], put = function (content, bonus) { + buff.push(put_cmd, '"', clean(content), '"' + (bonus || '') + ');'); + }, endStack = [], lastToken, startTag = null, magicInTag = false, specialStates = { + attributeHookups: [], + tagHookups: [], + lastTagHookup: '' + }, popTagHookup = function () { + specialStates.lastTagHookup = specialStates.tagHookups.pop() + specialStates.tagHookups.length; + }, tagName = '', tagNames = [], popTagName = false, bracketCount, specialAttribute = false, i = 0, token, tmap = this.tokenMap, attrName; + htmlTag = quote = beforeQuote = null; + for (; (token = tokens[i++]) !== undefined;) { + if (startTag === null) { + switch (token) { + case tmap.left: + case tmap.escapeLeft: + case tmap.returnLeft: + magicInTag = htmlTag && 1; + case tmap.commentLeft: + startTag = token; + if (content.length) { + put(content); + } + content = ''; + break; + case tmap.escapeFull: + magicInTag = htmlTag && 1; + rescan = 1; + startTag = tmap.escapeLeft; + if (content.length) { + put(content); + } + rescan = tokens[i++]; + content = rescan.content || rescan; + if (rescan.before) { + put(rescan.before); + } + tokens.splice(i, 0, tmap.right); + break; + case tmap.commentFull: + break; + case tmap.templateLeft: + content += tmap.left; + break; + case '<': + if (tokens[i].indexOf('!--') !== 0) { + htmlTag = 1; + magicInTag = 0; + } + content += token; + break; + case '>': + htmlTag = 0; + var emptyElement = content.substr(content.length - 1) === '/' || content.substr(content.length - 2) === '--', attrs = ''; + if (specialStates.attributeHookups.length) { + attrs = 'attrs: [\'' + specialStates.attributeHookups.join('\',\'') + '\'], '; + specialStates.attributeHookups = []; + } + if (tagName + specialStates.tagHookups.length !== specialStates.lastTagHookup && tagName === top(specialStates.tagHookups)) { + if (emptyElement) { + content = content.substr(0, content.length - 1); + } + buff.push(put_cmd, '"', clean(content), '"', ',can.view.pending({tagName:\'' + tagName + '\',' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options); + if (emptyElement) { + buff.push('}));'); + content = '/>'; + popTagHookup(); + } else if (tokens[i] === '<' && tokens[i + 1] === '/' + tagName) { + buff.push('}));'); + content = token; + popTagHookup(); + } else { + buff.push(',subtemplate: function(' + this.text.argNames + '){\n' + startTxt + (this.text.start || '')); + content = ''; + } + } else if (magicInTag || !popTagName && elements.tagToContentPropMap[tagNames[tagNames.length - 1]] || attrs) { + var pendingPart = ',can.view.pending({' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options + '}),"'; + if (emptyElement) { + put(content.substr(0, content.length - 1), pendingPart + '/>"'); + } else { + put(content, pendingPart + '>"'); + } + content = ''; + magicInTag = 0; + } else { + content += token; + } + if (emptyElement || popTagName) { + tagNames.pop(); + tagName = tagNames[tagNames.length - 1]; + popTagName = false; + } + specialStates.attributeHookups = []; + break; + case '\'': + case '"': + if (htmlTag) { + if (quote && quote === token) { + quote = null; + var attr = getAttrName(); + if (viewCallbacks.attr(attr)) { + specialStates.attributeHookups.push(attr); + } + if (specialAttribute) { + content += token; + put(content); + buff.push(finishTxt, '}));\n'); + content = ''; + specialAttribute = false; + break; + } + } else if (quote === null) { + quote = token; + beforeQuote = lastToken; + attrName = getAttrName(); + if (tagName === 'img' && attrName === 'src' || attrName === 'style') { + put(content.replace(attrReg, '')); + content = ''; + specialAttribute = true; + buff.push(insert_cmd, 'can.view.txt(2,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt); + put(attrName + '=' + token); + break; + } + } + } + default: + if (lastToken === '<') { + tagName = token.substr(0, 3) === '!--' ? '!--' : token.split(/\s/)[0]; + var isClosingTag = false, cleanedTagName; + if (tagName.indexOf('/') === 0) { + isClosingTag = true; + cleanedTagName = tagName.substr(1); + } + if (isClosingTag) { + if (top(tagNames) === cleanedTagName) { + tagName = cleanedTagName; + popTagName = true; + } + if (top(specialStates.tagHookups) === cleanedTagName) { + put(content.substr(0, content.length - 1)); + buff.push(finishTxt + '}}) );'); + content = '><'; + popTagHookup(); + } + } else { + if (tagName.lastIndexOf('/') === tagName.length - 1) { + tagName = tagName.substr(0, tagName.length - 1); + } + if (tagName !== '!--' && viewCallbacks.tag(tagName)) { + if (tagName === 'content' && elements.tagMap[top(tagNames)]) { + token = token.replace('content', elements.tagMap[top(tagNames)]); + } + specialStates.tagHookups.push(tagName); + } + tagNames.push(tagName); + } + } + content += token; + break; + } + } else { + switch (token) { + case tmap.right: + case tmap.returnRight: + switch (startTag) { + case tmap.left: + bracketCount = bracketNum(content); + if (bracketCount === 1) { + buff.push(insert_cmd, 'can.view.txt(0,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt, content); + endStack.push({ + before: '', + after: finishTxt + '}));\n' + }); + } else { + last = endStack.length && bracketCount === -1 ? endStack.pop() : { after: ';' }; + if (last.before) { + buff.push(last.before); + } + buff.push(content, ';', last.after); + } + break; + case tmap.escapeLeft: + case tmap.returnLeft: + bracketCount = bracketNum(content); + if (bracketCount) { + endStack.push({ + before: finishTxt, + after: '}));\n' + }); + } + var escaped = startTag === tmap.escapeLeft ? 1 : 0, commands = { + insert: insert_cmd, + tagName: getTag(tagName, tokens, i), + status: status(), + specialAttribute: specialAttribute + }; + for (var ii = 0; ii < this.helpers.length; ii++) { + var helper = this.helpers[ii]; + if (helper.name.test(content)) { + content = helper.fn(content, commands); + if (helper.name.source === /^>[\s]*\w*/.source) { + escaped = 0; + } + break; + } + } + if (typeof content === 'object') { + if (content.startTxt && content.end && specialAttribute) { + buff.push(insert_cmd, 'can.view.toStr( ', content.content, '() ) );'); + } else { + if (content.startTxt) { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || (content.escaped != null ? content.escaped : escaped)) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\n'); + } else if (content.startOnlyTxt) { + buff.push(insert_cmd, 'can.view.onlytxt(this,\n'); + } + buff.push(content.content); + if (content.end) { + buff.push('));'); + } + } + } else if (specialAttribute) { + buff.push(insert_cmd, content, ');'); + } else { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || escaped) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\nfunction(){ ' + (this.text.escape || '') + 'return ', content, bracketCount ? startTxt : '}));\n'); + } + if (rescan && rescan.after && rescan.after.length) { + put(rescan.after.length); + rescan = null; + } + break; + } + startTag = null; + content = ''; + break; + case tmap.templateLeft: + content += tmap.left; + break; + default: + content += token; + break; + } + } + lastToken = token; + } + if (content.length) { + put(content); + } + buff.push(';'); + var template = buff.join(''), out = { out: (this.text.outStart || '') + template + ' ' + finishTxt + (this.text.outEnd || '') }; + myEval.call(out, 'this.fn = (function(' + this.text.argNames + '){' + out.out + '});\r\n//# sourceURL=' + name + '.js'); + return out; + } + }; + can.view.pending = function (viewData) { + var hooks = can.view.getHooks(); + return can.view.hook(function (el) { + can.each(hooks, function (fn) { + fn(el); + }); + viewData.templateType = 'legacy'; + if (viewData.tagName) { + viewCallbacks.tagHandler(el, viewData.tagName, viewData); + } + can.each(viewData && viewData.attrs || [], function (attributeName) { + viewData.attributeName = attributeName; + var callback = viewCallbacks.attr(attributeName); + if (callback) { + callback(el, viewData); + } + }); + }); + }; + can.view.tag('content', function (el, tagData) { + return tagData.scope; + }); + can.view.Scanner = Scanner; + return Scanner; +}); +/*can@2.2.6#view/node_lists/node_lists*/ +define('can/view/node_lists/node_lists', [ + 'can/util/util', + 'can/view/elements' +], function (can) { + var canExpando = true; + try { + document.createTextNode('')._ = 0; + } catch (ex) { + canExpando = false; + } + var nodeMap = {}, textNodeMap = {}, expando = 'ejs_' + Math.random(), _id = 0, id = function (node, localMap) { + var _textNodeMap = localMap || textNodeMap; + var id = readId(node, _textNodeMap); + if (id) { + return id; + } else { + if (canExpando || node.nodeType !== 3) { + ++_id; + return node[expando] = (node.nodeName ? 'element_' : 'obj_') + _id; + } else { + ++_id; + _textNodeMap['text_' + _id] = node; + return 'text_' + _id; + } + } + }, readId = function (node, textNodeMap) { + if (canExpando || node.nodeType !== 3) { + return node[expando]; + } else { + for (var textNodeID in textNodeMap) { + if (textNodeMap[textNodeID] === node) { + return textNodeID; + } + } + } + }, splice = [].splice, push = [].push, itemsInChildListTree = function (list) { + var count = 0; + for (var i = 0, len = list.length; i < len; i++) { + var item = list[i]; + if (item.nodeType) { + count++; + } else { + count += itemsInChildListTree(item); + } + } + return count; + }, replacementMap = function (replacements, idMap) { + var map = {}; + for (var i = 0, len = replacements.length; i < len; i++) { + var node = nodeLists.first(replacements[i]); + map[id(node, idMap)] = replacements[i]; + } + return map; + }; + var nodeLists = { + id: id, + update: function (nodeList, newNodes) { + var oldNodes = nodeLists.unregisterChildren(nodeList); + newNodes = can.makeArray(newNodes); + var oldListLength = nodeList.length; + splice.apply(nodeList, [ + 0, + oldListLength + ].concat(newNodes)); + if (nodeList.replacements) { + nodeLists.nestReplacements(nodeList); + } else { + nodeLists.nestList(nodeList); + } + return oldNodes; + }, + nestReplacements: function (list) { + var index = 0, idMap = {}, rMap = replacementMap(list.replacements, idMap), rCount = list.replacements.length; + while (index < list.length && rCount) { + var node = list[index], replacement = rMap[readId(node, idMap)]; + if (replacement) { + list.splice(index, itemsInChildListTree(replacement), replacement); + rCount--; + } + index++; + } + list.replacements = []; + }, + nestList: function (list) { + var index = 0; + while (index < list.length) { + var node = list[index], childNodeList = nodeMap[id(node)]; + if (childNodeList) { + if (childNodeList !== list) { + list.splice(index, itemsInChildListTree(childNodeList), childNodeList); + } + } else { + nodeMap[id(node)] = list; + } + index++; + } + }, + last: function (nodeList) { + var last = nodeList[nodeList.length - 1]; + if (last.nodeType) { + return last; + } else { + return nodeLists.last(last); + } + }, + first: function (nodeList) { + var first = nodeList[0]; + if (first.nodeType) { + return first; + } else { + return nodeLists.first(first); + } + }, + flatten: function (nodeList) { + var items = []; + for (var i = 0; i < nodeList.length; i++) { + var item = nodeList[i]; + if (item.nodeType) { + items.push(item); + } else { + items.push.apply(items, nodeLists.flatten(item)); + } + } + return items; + }, + register: function (nodeList, unregistered, parent) { + nodeList.unregistered = unregistered; + nodeList.parentList = parent; + if (parent === true) { + nodeList.replacements = []; + } else if (parent) { + parent.replacements.push(nodeList); + nodeList.replacements = []; + } else { + nodeLists.nestList(nodeList); + } + return nodeList; + }, + unregisterChildren: function (nodeList) { + var nodes = []; + can.each(nodeList, function (node) { + if (node.nodeType) { + if (!nodeList.replacements) { + delete nodeMap[id(node)]; + } + nodes.push(node); + } else { + push.apply(nodes, nodeLists.unregister(node)); + } + }); + return nodes; + }, + unregister: function (nodeList) { + var nodes = nodeLists.unregisterChildren(nodeList); + if (nodeList.unregistered) { + var unregisteredCallback = nodeList.unregistered; + delete nodeList.unregistered; + delete nodeList.replacements; + unregisteredCallback(); + } + return nodes; + }, + nodeMap: nodeMap + }; + can.view.nodeLists = nodeLists; + return nodeLists; +}); +/*can@2.2.6#view/parser/parser*/ +define('can/view/parser/parser', ['can/view/view'], function (can) { + function makeMap(str) { + var obj = {}, items = str.split(','); + for (var i = 0; i < items.length; i++) { + obj[items[i]] = true; + } + return obj; + } + function handleIntermediate(intermediate, handler) { + for (var i = 0, len = intermediate.length; i < len; i++) { + var item = intermediate[i]; + handler[item.tokenType].apply(handler, item.args); + } + return intermediate; + } + var alphaNumericHU = '-:A-Za-z0-9_', attributeNames = '[a-zA-Z_:][' + alphaNumericHU + ':.]*', spaceEQspace = '\\s*=\\s*', dblQuote2dblQuote = '"((?:\\\\.|[^"])*)"', quote2quote = '\'((?:\\\\.|[^\'])*)\'', attributeEqAndValue = '(?:' + spaceEQspace + '(?:' + '(?:"[^"]*")|(?:\'[^\']*\')|[^>\\s]+))?', matchStash = '\\{\\{[^\\}]*\\}\\}\\}?', stash = '\\{\\{([^\\}]*)\\}\\}\\}?', startTag = new RegExp('^<([' + alphaNumericHU + ']+)' + '(' + '(?:\\s*' + '(?:(?:' + '(?:' + attributeNames + ')?' + attributeEqAndValue + ')|' + '(?:' + matchStash + ')+)' + ')*' + ')\\s*(\\/?)>'), endTag = new RegExp('^<\\/([' + alphaNumericHU + ']+)[^>]*>'), attr = new RegExp('(?:' + '(?:(' + attributeNames + ')|' + stash + ')' + '(?:' + spaceEQspace + '(?:' + '(?:' + dblQuote2dblQuote + ')|(?:' + quote2quote + ')|([^>\\s]+)' + ')' + ')?)', 'g'), mustache = new RegExp(stash, 'g'), txtBreak = /<|\{\{/; + var empty = makeMap('area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed'); + var block = makeMap('a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video'); + var inline = makeMap('abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var'); + var closeSelf = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr'); + var fillAttrs = makeMap('checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected'); + var special = makeMap('script,style'); + var tokenTypes = 'start,end,close,attrStart,attrEnd,attrValue,chars,comment,special,done'.split(','); + var fn = function () { + }; + var HTMLParser = function (html, handler, returnIntermediate) { + if (typeof html === 'object') { + return handleIntermediate(html, handler); + } + var intermediate = []; + handler = handler || {}; + if (returnIntermediate) { + can.each(tokenTypes, function (name) { + var callback = handler[name] || fn; + handler[name] = function () { + if (callback.apply(this, arguments) !== false) { + intermediate.push({ + tokenType: name, + args: can.makeArray(arguments) + }); + } + }; + }); + } + function parseStartTag(tag, tagName, rest, unary) { + tagName = tagName.toLowerCase(); + if (block[tagName]) { + while (stack.last() && inline[stack.last()]) { + parseEndTag('', stack.last()); + } + } + if (closeSelf[tagName] && stack.last() === tagName) { + parseEndTag('', tagName); + } + unary = empty[tagName] || !!unary; + handler.start(tagName, unary); + if (!unary) { + stack.push(tagName); + } + HTMLParser.parseAttrs(rest, handler); + handler.end(tagName, unary); + } + function parseEndTag(tag, tagName) { + var pos; + if (!tagName) { + pos = 0; + } else { + for (pos = stack.length - 1; pos >= 0; pos--) { + if (stack[pos] === tagName) { + break; + } + } + } + if (pos >= 0) { + for (var i = stack.length - 1; i >= pos; i--) { + if (handler.close) { + handler.close(stack[i]); + } + } + stack.length = pos; + } + } + function parseMustache(mustache, inside) { + if (handler.special) { + handler.special(inside); + } + } + var index, chars, match, stack = [], last = html; + stack.last = function () { + return this[this.length - 1]; + }; + while (html) { + chars = true; + if (!stack.last() || !special[stack.last()]) { + if (html.indexOf(''); + if (index >= 0) { + if (handler.comment) { + handler.comment(html.substring(4, index)); + } + html = html.substring(index + 3); + chars = false; + } + } else if (html.indexOf(']*>'), function (all, text) { + text = text.replace(/|/g, '$1$2'); + if (handler.chars) { + handler.chars(text); + } + return ''; + }); + parseEndTag('', stack.last()); + } + if (html === last) { + throw 'Parse Error: ' + html; + } + last = html; + } + parseEndTag(); + handler.done(); + return intermediate; + }; + HTMLParser.parseAttrs = function (rest, handler) { + (rest != null ? rest : '').replace(attr, function (text, name, special, dblQuote, singleQuote, val) { + if (special) { + handler.special(special); + } + if (name || dblQuote || singleQuote || val) { + var value = arguments[3] ? arguments[3] : arguments[4] ? arguments[4] : arguments[5] ? arguments[5] : fillAttrs[name.toLowerCase()] ? name : ''; + handler.attrStart(name || ''); + var last = mustache.lastIndex = 0, res = mustache.exec(value), chars; + while (res) { + chars = value.substring(last, mustache.lastIndex - res[0].length); + if (chars.length) { + handler.attrValue(chars); + } + handler.special(res[1]); + last = mustache.lastIndex; + res = mustache.exec(value); + } + chars = value.substr(last, value.length); + if (chars) { + handler.attrValue(chars); + } + handler.attrEnd(name || ''); + } + }); + }; + can.view.parser = HTMLParser; + return HTMLParser; +}); +/*can@2.2.6#view/live/live*/ +define('can/view/live/live', [ + 'can/util/util', + 'can/view/elements', + 'can/view/view', + 'can/view/node_lists/node_lists', + 'can/view/parser/parser' +], function (can, elements, view, nodeLists, parser) { + elements = elements || can.view.elements; + nodeLists = nodeLists || can.view.NodeLists; + parser = parser || can.view.parser; + var setup = function (el, bind, unbind) { + var tornDown = false, teardown = function () { + if (!tornDown) { + tornDown = true; + unbind(data); + can.unbind.call(el, 'removed', teardown); + } + return true; + }, data = { + teardownCheck: function (parent) { + return parent ? false : teardown(); + } + }; + can.bind.call(el, 'removed', teardown); + bind(data); + return data; + }, listen = function (el, compute, change) { + return setup(el, function () { + compute.bind('change', change); + }, function (data) { + compute.unbind('change', change); + if (data.nodeList) { + nodeLists.unregister(data.nodeList); + } + }); + }, getAttributeParts = function (newVal) { + var attrs = {}, attr; + parser.parseAttrs(newVal, { + attrStart: function (name) { + attrs[name] = ''; + attr = name; + }, + attrValue: function (value) { + attrs[attr] += value; + }, + attrEnd: function () { + } + }); + return attrs; + }, splice = [].splice, isNode = function (obj) { + return obj && obj.nodeType; + }, addTextNodeIfNoChildren = function (frag) { + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + }; + var live = { + list: function (el, compute, render, context, parentNode, nodeList) { + var masterNodeList = nodeList || [el], indexMap = [], afterPreviousEvents = false, isTornDown = false, add = function (ev, items, index) { + if (!afterPreviousEvents) { + return; + } + var frag = document.createDocumentFragment(), newNodeLists = [], newIndicies = []; + can.each(items, function (item, key) { + var itemNodeList = []; + if (nodeList) { + nodeLists.register(itemNodeList, null, true); + } + var itemIndex = can.compute(key + index), itemHTML = render.call(context, item, itemIndex, itemNodeList), gotText = typeof itemHTML === 'string', itemFrag = can.frag(itemHTML); + itemFrag = gotText ? can.view.hookup(itemFrag) : itemFrag; + var childNodes = can.makeArray(itemFrag.childNodes); + if (nodeList) { + nodeLists.update(itemNodeList, childNodes); + newNodeLists.push(itemNodeList); + } else { + newNodeLists.push(nodeLists.register(childNodes)); + } + frag.appendChild(itemFrag); + newIndicies.push(itemIndex); + }); + var masterListIndex = index + 1; + if (!masterNodeList[masterListIndex]) { + elements.after(masterListIndex === 1 ? [text] : [nodeLists.last(masterNodeList[masterListIndex - 1])], frag); + } else { + var el = nodeLists.first(masterNodeList[masterListIndex]); + can.insertBefore(el.parentNode, frag, el); + } + splice.apply(masterNodeList, [ + masterListIndex, + 0 + ].concat(newNodeLists)); + splice.apply(indexMap, [ + index, + 0 + ].concat(newIndicies)); + for (var i = index + newIndicies.length, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + }, remove = function (ev, items, index, duringTeardown, fullTeardown) { + if (!afterPreviousEvents) { + return; + } + if (!duringTeardown && data.teardownCheck(text.parentNode)) { + return; + } + if (index < 0) { + index = indexMap.length + index; + } + var removedMappings = masterNodeList.splice(index + 1, items.length), itemsToRemove = []; + can.each(removedMappings, function (nodeList) { + var nodesToRemove = nodeLists.unregister(nodeList); + [].push.apply(itemsToRemove, nodesToRemove); + }); + indexMap.splice(index, items.length); + for (var i = index, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + if (!fullTeardown) { + can.remove(can.$(itemsToRemove)); + } else { + nodeLists.unregister(masterNodeList); + } + }, move = function (ev, item, newIndex, currentIndex) { + if (!afterPreviousEvents) { + return; + } + newIndex = newIndex + 1; + currentIndex = currentIndex + 1; + var referenceNodeList = masterNodeList[newIndex]; + var movedElements = can.frag(nodeLists.flatten(masterNodeList[currentIndex])); + var referenceElement; + if (currentIndex < newIndex) { + referenceElement = nodeLists.last(referenceNodeList).nextSibling; + } else { + referenceElement = nodeLists.first(referenceNodeList); + } + var parentNode = masterNodeList[0].parentNode; + parentNode.insertBefore(movedElements, referenceElement); + var temp = masterNodeList[currentIndex]; + [].splice.apply(masterNodeList, [ + currentIndex, + 1 + ]); + [].splice.apply(masterNodeList, [ + newIndex, + 0, + temp + ]); + }, text = document.createTextNode(''), list, teardownList = function (fullTeardown) { + if (list && list.unbind) { + list.unbind('add', add).unbind('remove', remove).unbind('move', move); + } + remove({}, { length: masterNodeList.length - 1 }, 0, true, fullTeardown); + }, updateList = function (ev, newList, oldList) { + if (isTornDown) { + return; + } + teardownList(); + list = newList || []; + if (list.bind) { + list.bind('add', add).bind('remove', remove).bind('move', move); + } + afterPreviousEvents = true; + add({}, list, 0); + afterPreviousEvents = false; + can.batch.afterPreviousEvents(function () { + afterPreviousEvents = true; + }); + }; + parentNode = elements.getParentNode(el, parentNode); + var data = setup(parentNode, function () { + if (can.isFunction(compute)) { + compute.bind('change', updateList); + } + }, function () { + if (can.isFunction(compute)) { + compute.unbind('change', updateList); + } + teardownList(true); + }); + if (!nodeList) { + live.replace(masterNodeList, text, data.teardownCheck); + } else { + elements.replace(masterNodeList, text); + nodeLists.update(masterNodeList, [text]); + nodeList.unregistered = function () { + data.teardownCheck(); + isTornDown = true; + }; + } + updateList({}, can.isFunction(compute) ? compute() : compute); + }, + html: function (el, compute, parentNode, nodeList) { + var data; + parentNode = elements.getParentNode(el, parentNode); + data = listen(parentNode, compute, function (ev, newVal, oldVal) { + var attached = nodeLists.first(nodes).parentNode; + if (attached) { + makeAndPut(newVal); + } + data.teardownCheck(nodeLists.first(nodes).parentNode); + }); + var nodes = nodeList || [el], makeAndPut = function (val) { + var isFunction = typeof val === 'function', aNode = isNode(val), frag = can.frag(isFunction ? '' : val), oldNodes = can.makeArray(nodes); + addTextNodeIfNoChildren(frag); + if (!aNode && !isFunction) { + frag = can.view.hookup(frag, parentNode); + } + oldNodes = nodeLists.update(nodes, frag.childNodes); + if (isFunction) { + val(frag.childNodes[0]); + } + elements.replace(oldNodes, frag); + }; + data.nodeList = nodes; + if (!nodeList) { + nodeLists.register(nodes, data.teardownCheck); + } else { + nodeList.unregistered = data.teardownCheck; + } + makeAndPut(compute()); + }, + replace: function (nodes, val, teardown) { + var oldNodes = nodes.slice(0), frag = can.frag(val); + nodeLists.register(nodes, teardown); + if (typeof val === 'string') { + frag = can.view.hookup(frag, nodes[0].parentNode); + } + nodeLists.update(nodes, frag.childNodes); + elements.replace(oldNodes, frag); + return nodes; + }, + text: function (el, compute, parentNode, nodeList) { + var parent = elements.getParentNode(el, parentNode); + var data = listen(parent, compute, function (ev, newVal, oldVal) { + if (typeof node.nodeValue !== 'unknown') { + node.nodeValue = can.view.toStr(newVal); + } + data.teardownCheck(node.parentNode); + }); + var node = document.createTextNode(can.view.toStr(compute())); + if (nodeList) { + nodeList.unregistered = data.teardownCheck; + data.nodeList = nodeList; + nodeLists.update(nodeList, [node]); + elements.replace([el], node); + } else { + data.nodeList = live.replace([el], node, data.teardownCheck); + } + }, + setAttributes: function (el, newVal) { + var attrs = getAttributeParts(newVal); + for (var name in attrs) { + can.attr.set(el, name, attrs[name]); + } + }, + attributes: function (el, compute, currentValue) { + var oldAttrs = {}; + var setAttrs = function (newVal) { + var newAttrs = getAttributeParts(newVal), name; + for (name in newAttrs) { + var newValue = newAttrs[name], oldValue = oldAttrs[name]; + if (newValue !== oldValue) { + can.attr.set(el, name, newValue); + } + delete oldAttrs[name]; + } + for (name in oldAttrs) { + elements.removeAttr(el, name); + } + oldAttrs = newAttrs; + }; + listen(el, compute, function (ev, newVal) { + setAttrs(newVal); + }); + if (arguments.length >= 3) { + oldAttrs = getAttributeParts(currentValue); + } else { + setAttrs(compute()); + } + }, + attributePlaceholder: '__!!__', + attributeReplace: /__!!__/g, + attribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, hook.render()); + }); + var wrapped = can.$(el), hooks; + hooks = can.data(wrapped, 'hooks'); + if (!hooks) { + can.data(wrapped, 'hooks', hooks = {}); + } + var attr = elements.getAttr(el, attributeName), parts = attr.split(live.attributePlaceholder), goodParts = [], hook; + goodParts.push(parts.shift(), parts.join(live.attributePlaceholder)); + if (hooks[attributeName]) { + hooks[attributeName].computes.push(compute); + } else { + hooks[attributeName] = { + render: function () { + var i = 0, newAttr = attr ? attr.replace(live.attributeReplace, function () { + return elements.contentText(hook.computes[i++]()); + }) : elements.contentText(hook.computes[i++]()); + return newAttr; + }, + computes: [compute], + batchNum: undefined + }; + } + hook = hooks[attributeName]; + goodParts.splice(1, 0, compute()); + elements.setAttr(el, attributeName, goodParts.join('')); + }, + specialAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, getValue(newVal)); + }); + elements.setAttr(el, attributeName, getValue(compute())); + }, + simpleAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, newVal); + }); + elements.setAttr(el, attributeName, compute()); + } + }; + live.attr = live.simpleAttribute; + live.attrs = live.attributes; + var newLine = /(\r|\n)+/g; + var getValue = function (val) { + var regexp = /^["'].*["']$/; + val = val.replace(elements.attrReg, '').replace(newLine, ''); + return regexp.test(val) ? val.substr(1, val.length - 2) : val; + }; + can.view.live = live; + return live; +}); +/*can@2.2.6#view/render*/ +define('can/view/render', [ + 'can/view/view', + 'can/view/elements', + 'can/view/live/live', + 'can/util/string/string' +], function (can, elements, live) { + var pendingHookups = [], tagChildren = function (tagName) { + var newTag = elements.tagMap[tagName] || 'span'; + if (newTag === 'span') { + return '@@!!@@'; + } + return '<' + newTag + '>' + tagChildren(newTag) + ''; + }, contentText = function (input, tag) { + if (typeof input === 'string') { + return input; + } + if (!input && input !== 0) { + return ''; + } + var hook = input.hookup && function (el, id) { + input.hookup.call(input, el, id); + } || typeof input === 'function' && input; + if (hook) { + if (tag) { + return '<' + tag + ' ' + can.view.hook(hook) + '>'; + } else { + pendingHookups.push(hook); + } + return ''; + } + return '' + input; + }, contentEscape = function (txt, tag) { + return typeof txt === 'string' || typeof txt === 'number' ? can.esc(txt) : contentText(txt, tag); + }, withinTemplatedSectionWithinAnElement = false, emptyHandler = function () { + }; + var lastHookups; + can.extend(can.view, { + live: live, + setupLists: function () { + var old = can.view.lists, data; + can.view.lists = function (list, renderer) { + data = { + list: list, + renderer: renderer + }; + return Math.random(); + }; + return function () { + can.view.lists = old; + return data; + }; + }, + getHooks: function () { + var hooks = pendingHookups.slice(0); + lastHookups = hooks; + pendingHookups = []; + return hooks; + }, + onlytxt: function (self, func) { + return contentEscape(func.call(self)); + }, + txt: function (escape, tagName, status, self, func) { + var tag = elements.tagMap[tagName] || 'span', setupLiveBinding = false, value, listData, compute, unbind = emptyHandler, attributeName; + if (withinTemplatedSectionWithinAnElement) { + value = func.call(self); + } else { + if (typeof status === 'string' || status === 1) { + withinTemplatedSectionWithinAnElement = true; + } + var listTeardown = can.view.setupLists(); + unbind = function () { + compute.unbind('change', emptyHandler); + }; + compute = can.compute(func, self, false); + compute.bind('change', emptyHandler); + listData = listTeardown(); + value = compute(); + withinTemplatedSectionWithinAnElement = false; + setupLiveBinding = compute.computeInstance.hasDependencies; + } + if (listData) { + unbind(); + return '<' + tag + can.view.hook(function (el, parentNode) { + live.list(el, listData.list, listData.renderer, self, parentNode); + }) + '>'; + } + if (!setupLiveBinding || typeof value === 'function') { + unbind(); + return (withinTemplatedSectionWithinAnElement || escape === 2 || !escape ? contentText : contentEscape)(value, status === 0 && tag); + } + var contentProp = elements.tagToContentPropMap[tagName]; + if (status === 0 && !contentProp) { + return '<' + tag + can.view.hook(escape && typeof value !== 'object' ? function (el, parentNode) { + live.text(el, compute, parentNode); + unbind(); + } : function (el, parentNode) { + live.html(el, compute, parentNode); + unbind(); + }) + '>' + tagChildren(tag) + ''; + } else if (status === 1) { + pendingHookups.push(function (el) { + live.attributes(el, compute, compute()); + unbind(); + }); + return compute(); + } else if (escape === 2) { + attributeName = status; + pendingHookups.push(function (el) { + live.specialAttribute(el, attributeName, compute); + unbind(); + }); + return compute(); + } else { + attributeName = status === 0 ? contentProp : status; + (status === 0 ? lastHookups : pendingHookups).push(function (el) { + live.attribute(el, attributeName, compute); + unbind(); + }); + return live.attributePlaceholder; + } + } + }); + return can; +}); +/*can@2.2.6#view/stache/utils*/ +define('can/view/stache/utils', ['can/util/util'], function () { + return { + isArrayLike: function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, + isObserveLike: function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, + emptyHandler: function () { + }, + jsonParse: function (str) { + if (str[0] === '\'') { + return str.substr(1, str.length - 2); + } else if (str === 'undefined') { + return undefined; + } else if (can.global.JSON) { + return JSON.parse(str); + } else { + return eval('(' + str + ')'); + } + }, + mixins: { + last: function () { + return this.stack[this.stack.length - 1]; + }, + add: function (chars) { + this.last().add(chars); + }, + subSectionDepth: function () { + return this.stack.length - 1; + } + } + }; +}); +/*can@2.2.6#view/stache/mustache_helpers*/ +define('can/view/stache/mustache_helpers', [ + 'can/util/util', + 'can/view/stache/utils', + 'can/view/live/live' +], function (can, utils, live) { + live = live || can.view.live; + var resolve = function (value) { + if (utils.isObserveLike(value) && utils.isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + var helpers = { + 'each': function (items, options) { + var resolved = resolve(items), result = [], keys, key, i; + if (resolved instanceof can.List) { + return function (el) { + var nodeList = [el]; + nodeList.expression = 'live.list'; + can.view.nodeLists.register(nodeList, null, options.nodeList); + can.view.nodeLists.update(options.nodeList, [el]); + var cb = function (item, index, parentNodeList) { + return options.fn(options.scope.add({ '@index': index }).add(item), options.options, parentNodeList); + }; + live.list(el, items, cb, options.context, el.parentNode, nodeList); + }; + } + var expr = resolved; + if (!!expr && utils.isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + } else if (utils.isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } + return result; + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + }, + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!resolve(expr); + } + if (value) { + return options.fn(options.scope || this); + } else { + return options.inverse(options.scope || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return helpers.is.apply(this, arguments); + }, + 'unless': function (expr, options) { + return helpers['if'].apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'with': function (expr, options) { + var ctx = expr; + expr = resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + 'data': function (attr) { + var data = arguments.length === 2 ? this : arguments[1]; + return function (el) { + can.data(can.$(el), attr, data || this.context); + }; + } + }; + return { + registerHelper: function (name, callback) { + helpers[name] = callback; + }, + getHelper: function (name, options) { + var helper = options.attr('helpers.' + name); + if (!helper) { + helper = helpers[name]; + } + if (helper) { + return { fn: helper }; + } + } + }; +}); +/*can@2.2.6#view/stache/mustache_core*/ +define('can/view/stache/mustache_core', [ + 'can/util/util', + 'can/view/stache/utils', + 'can/view/stache/mustache_helpers', + 'can/view/live/live', + 'can/view/elements', + 'can/view/scope/scope', + 'can/view/node_lists/node_lists' +], function (can, utils, mustacheHelpers, live, elements, Scope, nodeLists) { + live = live || can.view.live; + elements = elements || can.view.elements; + Scope = Scope || can.view.Scope; + nodeLists = nodeLists || can.view.nodeLists; + var argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(?:(.+?)=(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(.+))))$/, mustacheLineBreakRegExp = /(?:(?:^|(\r?)\n)(\s*)(\{\{([^\}]*)\}\}\}?)([^\S\n\r]*)($|\r?\n))|(\{\{([^\}]*)\}\}\}?)/g, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, getItemsFragContent = function (items, isObserveList, helperOptions, options) { + var frag = document.createDocumentFragment(); + for (var i = 0, len = items.length; i < len; i++) { + append(frag, helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options)); + } + return frag; + }, append = function (frag, content) { + if (content) { + frag.appendChild(typeof content === 'string' ? document.createTextNode(content) : content); + } + }, getItemsStringContent = function (items, isObserveList, helperOptions, options) { + var txt = ''; + for (var i = 0, len = items.length; i < len; i++) { + txt += helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options); + } + return txt; + }, getKeyComputeData = function (key, scope, isArgument) { + var data = scope.computeData(key, { + isArgument: isArgument, + args: [ + scope.attr('.'), + scope + ] + }); + can.compute.temporarilyBind(data.compute); + return data; + }, getKeyArgValue = function (key, scope) { + var data = getKeyComputeData(key, scope, true); + if (!data.compute.computeInstance.hasDependencies) { + return data.initialValue; + } else { + return data.compute; + } + }, convertToScopes = function (helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer) { + if (truthyRenderer) { + helperOptions.fn = makeRendererConvertScopes(truthyRenderer, scope, options, nodeList); + } + if (falseyRenderer) { + helperOptions.inverse = makeRendererConvertScopes(falseyRenderer, scope, options, nodeList); + } + }, makeRendererConvertScopes = function (renderer, parentScope, parentOptions, nodeList) { + var rendererWithScope = function (ctx, opts, parentNodeList) { + return renderer(ctx || parentScope, opts, parentNodeList); + }; + return can.__notObserve(function (newScope, newOptions, parentNodeList) { + if (newScope !== undefined && !(newScope instanceof can.view.Scope)) { + newScope = parentScope.add(newScope); + } + if (newOptions !== undefined && !(newOptions instanceof core.Options)) { + newOptions = parentOptions.add(newOptions); + } + var result = rendererWithScope(newScope, newOptions || parentOptions, parentNodeList || nodeList); + return result; + }); + }; + var core = { + expressionData: function (expression) { + var args = [], hashes = {}, i = 0; + (can.trim(expression) + ' ').replace(argumentsRegExp, function (whole, arg) { + var m; + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[1] || m[2]) { + args.push(utils.jsonParse(m[1] || m[2])); + } else { + hashes[m[3]] = m[6] ? { get: m[6] } : utils.jsonParse(m[4] || m[5]); + } + } else { + args.push({ get: arg }); + } + i++; + }); + return { + name: args.shift(), + args: args, + hash: hashes + }; + }, + makeEvaluator: function (scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, stringOnly) { + var args = [], hash = {}, helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, context = scope.attr('.'), name = exprData.name, helper, looksLikeAHelper = exprData.args.length || !can.isEmptyObject(exprData.hash), initialValue, helperEvaluator; + for (var i = 0, len = exprData.args.length; i < len; i++) { + var arg = exprData.args[i]; + if (arg && isLookup(arg)) { + args.push(getKeyArgValue(arg.get, scope, true)); + } else { + args.push(arg); + } + } + for (var prop in exprData.hash) { + if (isLookup(exprData.hash[prop])) { + hash[prop] = getKeyArgValue(exprData.hash[prop].get, scope); + } else { + hash[prop] = exprData.hash[prop]; + } + } + if (isLookup(name)) { + if (looksLikeAHelper) { + helper = mustacheHelpers.getHelper(name.get, options); + if (!helper && typeof context[name.get] === 'function') { + helper = { fn: context[name.get] }; + } + } + if (!helper) { + var get = name.get; + var computeData = getKeyComputeData(name.get, scope, false), compute = computeData.compute; + initialValue = computeData.initialValue; + if (computeData.compute.computeInstance.hasDependencies) { + name = compute; + } else { + name = initialValue; + } + if (!looksLikeAHelper && initialValue === undefined) { + helper = mustacheHelpers.getHelper(get, options); + } else if (typeof initialValue === 'function') { + helper = { fn: initialValue }; + } + } + } + if (mode === '^') { + var temp = truthyRenderer; + truthyRenderer = falseyRenderer; + falseyRenderer = temp; + } + if (helper) { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + can.simpleExtend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash, + nodeList: nodeList, + exprData: exprData + }); + args.push(helperOptions); + helperEvaluator = function () { + return helper.fn.apply(context, args) || ''; + }; + helperEvaluator.bindOnce = false; + return helperEvaluator; + } + if (!mode) { + if (name && name.isComputed) { + return name; + } else { + return function () { + return '' + (name != null ? name : ''); + }; + } + } else if (mode === '#' || mode === '^') { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + var evaluator = function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + if (utils.isArrayLike(value)) { + var isObserveList = utils.isObserveLike(value); + if (isObserveList ? value.attr('length') : value.length) { + return (stringOnly ? getItemsStringContent : getItemsFragContent)(value, isObserveList, helperOptions, options); + } else { + return helperOptions.inverse(scope, options); + } + } else { + return value ? helperOptions.fn(value || scope, options) : helperOptions.inverse(scope, options); + } + }; + evaluator.bindOnce = false; + return evaluator; + } else { + } + }, + makeLiveBindingPartialRenderer: function (partialName, state) { + partialName = can.trim(partialName); + return function (scope, options, parentSectionNodeList) { + var nodeList = [this]; + nodeList.expression = '>' + partialName; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var partialFrag = can.compute(function () { + var localPartialName = partialName; + var partial = options.attr('partials.' + localPartialName), res; + if (partial) { + res = partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + var scopePartialName = scope.read(localPartialName, { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }).value; + if (scopePartialName) { + localPartialName = scopePartialName; + } + res = can.view.render(localPartialName, scope, options); + } + return can.frag(res); + }); + live.html(this, partialFrag, this.parentNode, nodeList); + }; + }, + makeStringBranchRenderer: function (mode, expression) { + var exprData = expressionData(expression), fullExpression = mode + expression; + return function branchRenderer(scope, options, truthyRenderer, falseyRenderer) { + var evaluator = scope.__cache[fullExpression]; + if (mode || !evaluator) { + evaluator = makeEvaluator(scope, options, null, mode, exprData, truthyRenderer, falseyRenderer, true); + if (!mode) { + scope.__cache[fullExpression] = evaluator; + } + } + var res = evaluator(); + return res == null ? '' : '' + res; + }; + }, + makeLiveBindingBranchRenderer: function (mode, expression, state) { + var exprData = expressionData(expression); + return function branchRenderer(scope, options, parentSectionNodeList, truthyRenderer, falseyRenderer) { + var nodeList = [this]; + nodeList.expression = expression; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var evaluator = makeEvaluator(scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, state.tag); + var compute = can.compute(evaluator, null, false, evaluator.bindOnce === false ? false : true); + compute.bind('change', can.k); + var value = compute(); + if (typeof value === 'function') { + var old = can.__clearReading(); + value(this); + can.__setReading(old); + } else if (compute.computeInstance.hasDependencies) { + if (state.attr) { + live.simpleAttribute(this, state.attr, compute); + } else if (state.tag) { + live.attributes(this, compute); + } else if (state.text && typeof value !== 'object') { + live.text(this, compute, this.parentNode, nodeList); + } else { + live.html(this, compute, this.parentNode, nodeList); + } + } else { + if (state.attr) { + can.attr.set(this, state.attr, value); + } else if (state.tag) { + live.setAttributes(this, value); + } else if (state.text && typeof value === 'string') { + this.nodeValue = value; + } else if (value) { + elements.replace([this], can.frag(value)); + } + } + compute.unbind('change', can.k); + }; + }, + splitModeFromExpression: function (expression, state) { + expression = can.trim(expression); + var mode = expression.charAt(0); + if ('#/{&^>!'.indexOf(mode) >= 0) { + expression = can.trim(expression.substr(1)); + } else { + mode = null; + } + if (mode === '{' && state.node) { + mode = null; + } + return { + mode: mode, + expression: expression + }; + }, + cleanLineEndings: function (template) { + return template.replace(mustacheLineBreakRegExp, function (whole, returnBefore, spaceBefore, special, expression, spaceAfter, returnAfter, spaceLessSpecial, spaceLessExpression, matchIndex) { + spaceAfter = spaceAfter || ''; + returnBefore = returnBefore || ''; + spaceBefore = spaceBefore || ''; + var modeAndExpression = splitModeFromExpression(expression || spaceLessExpression, {}); + if (spaceLessSpecial || '>{'.indexOf(modeAndExpression.mode) >= 0) { + return whole; + } else if ('^#!/'.indexOf(modeAndExpression.mode) >= 0) { + return special + (matchIndex !== 0 && returnAfter.length ? returnBefore + '\n' : ''); + } else { + return spaceBefore + special + spaceAfter + (spaceBefore.length || matchIndex !== 0 ? returnBefore + '\n' : ''); + } + }); + }, + Options: can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }) + }; + var makeEvaluator = core.makeEvaluator, expressionData = core.expressionData, splitModeFromExpression = core.splitModeFromExpression; + return core; +}); +/*can@2.2.6#view/bindings/bindings*/ +define('can/view/bindings/bindings', [ + 'can/util/util', + 'can/view/stache/mustache_core', + 'can/view/callbacks/callbacks', + 'can/control/control', + 'can/view/scope/scope' +], function (can, mustacheCore) { + var isContentEditable = function () { + var values = { + '': true, + 'true': true, + 'false': false + }; + var editable = function (el) { + if (!el || !el.getAttribute) { + return; + } + var attr = el.getAttribute('contenteditable'); + return values[attr]; + }; + return function (el) { + var val = editable(el); + if (typeof val === 'boolean') { + return val; + } else { + return !!editable(el.parentNode); + } + }; + }(), removeCurly = function (value) { + if (value[0] === '{' && value[value.length - 1] === '}') { + return value.substr(1, value.length - 2); + } + return value; + }; + can.view.attr('can-value', function (el, data) { + var attr = can.trim(removeCurly(el.getAttribute('can-value'))), value = data.scope.computeData(attr, { args: [] }).compute, trueValue, falseValue; + if (el.nodeName.toLowerCase() === 'input') { + if (el.type === 'checkbox') { + if (can.attr.has(el, 'can-true-value')) { + trueValue = el.getAttribute('can-true-value'); + } else { + trueValue = true; + } + if (can.attr.has(el, 'can-false-value')) { + falseValue = el.getAttribute('can-false-value'); + } else { + falseValue = false; + } + } + if (el.type === 'checkbox' || el.type === 'radio') { + new Checked(el, { + value: value, + trueValue: trueValue, + falseValue: falseValue + }); + return; + } + } + if (el.nodeName.toLowerCase() === 'select' && el.multiple) { + new Multiselect(el, { value: value }); + return; + } + if (isContentEditable(el)) { + new Content(el, { value: value }); + return; + } + new Value(el, { value: value }); + }); + var special = { + enter: function (data, el, original) { + return { + event: 'keyup', + handler: function (ev) { + if (ev.keyCode === 13) { + return original.call(this, ev); + } + } + }; + } + }; + can.view.attr(/can-[\w\.]+/, function (el, data) { + var attributeName = data.attributeName, event = attributeName.substr('can-'.length), handler = function (ev) { + var attrVal = el.getAttribute(attributeName); + if (!attrVal) { + return; + } + var attrInfo = mustacheCore.expressionData(removeCurly(attrVal)); + var scopeData = data.scope.read(attrInfo.name.get, { + returnObserveMethods: true, + isArgument: true, + executeAnonymousFunctions: true + }); + var args = []; + var $el = can.$(this); + var viewModel = can.viewModel($el[0]); + var localScope = data.scope.add({ + '@element': $el, + '@event': ev, + '@viewModel': viewModel, + '@scope': data.scope, + '@context': data.scope._context + }); + if (!can.isEmptyObject(attrInfo.hash)) { + var hash = {}; + can.each(attrInfo.hash, function (val, key) { + if (val && val.hasOwnProperty('get')) { + var s = !val.get.indexOf('@') ? localScope : data.scope; + hash[key] = s.read(val.get, {}).value; + } else { + hash[key] = val; + } + }); + args.unshift(hash); + } + if (attrInfo.args.length) { + var arg; + for (var i = attrInfo.args.length - 1; i >= 0; i--) { + arg = attrInfo.args[i]; + if (arg && arg.hasOwnProperty('get')) { + var s = !arg.get.indexOf('@') ? localScope : data.scope; + args.unshift(s.read(arg.get, {}).value); + } else { + args.unshift(arg); + } + } + } + if (!args.length) { + args = [ + data.scope._context, + $el + ].concat(can.makeArray(arguments)); + } + return scopeData.value.apply(scopeData.parent, args); + }; + if (special[event]) { + var specialData = special[event](data, el, handler); + handler = specialData.handler; + event = specialData.event; + } + can.bind.call(el, event, handler); + }); + var Value = can.Control.extend({ + init: function () { + if (this.element[0].nodeName.toUpperCase() === 'SELECT') { + setTimeout(can.proxy(this.set, this), 1); + } else { + this.set(); + } + }, + '{value} change': 'set', + set: function () { + if (!this.element) { + return; + } + var val = this.options.value(); + this.element[0].value = val == null ? '' : val; + }, + 'change': function () { + if (!this.element) { + return; + } + var el = this.element[0]; + this.options.value(el.value); + var newVal = this.options.value(); + if (el.value !== newVal) { + el.value = newVal; + } + } + }), Checked = can.Control.extend({ + init: function () { + this.isCheckbox = this.element[0].type.toLowerCase() === 'checkbox'; + this.check(); + }, + '{value} change': 'check', + check: function () { + if (this.isCheckbox) { + var value = this.options.value(), trueValue = this.options.trueValue || true; + this.element[0].checked = value == trueValue; + } else { + var setOrRemove = this.options.value() == this.element[0].value ? 'set' : 'remove'; + can.attr[setOrRemove](this.element[0], 'checked', true); + } + }, + 'change': function () { + if (this.isCheckbox) { + this.options.value(this.element[0].checked ? this.options.trueValue : this.options.falseValue); + } else { + if (this.element[0].checked) { + this.options.value(this.element[0].value); + } + } + } + }), Multiselect = Value.extend({ + init: function () { + this.delimiter = ';'; + setTimeout(can.proxy(this.set, this), 1); + }, + set: function () { + var newVal = this.options.value(); + if (typeof newVal === 'string') { + newVal = newVal.split(this.delimiter); + this.isString = true; + } else if (newVal) { + newVal = can.makeArray(newVal); + } + var isSelected = {}; + can.each(newVal, function (val) { + isSelected[val] = true; + }); + can.each(this.element[0].childNodes, function (option) { + if (option.value) { + option.selected = !!isSelected[option.value]; + } + }); + }, + get: function () { + var values = [], children = this.element[0].childNodes; + can.each(children, function (child) { + if (child.selected && child.value) { + values.push(child.value); + } + }); + return values; + }, + 'change': function () { + var value = this.get(), currentValue = this.options.value(); + if (this.isString || typeof currentValue === 'string') { + this.isString = true; + this.options.value(value.join(this.delimiter)); + } else if (currentValue instanceof can.List) { + currentValue.attr(value, true); + } else { + this.options.value(value); + } + } + }), Content = can.Control.extend({ + init: function () { + this.set(); + this.on('blur', 'setValue'); + }, + '{value} change': 'set', + set: function () { + var val = this.options.value(); + this.element[0].innerHTML = typeof val === 'undefined' ? '' : val; + }, + setValue: function () { + this.options.value(this.element[0].innerHTML); + } + }); +}); +/*can@2.2.6#view/mustache/mustache*/ +define('can/view/mustache/mustache', [ + 'can/util/util', + 'can/view/scope/scope', + 'can/view/view', + 'can/view/scanner', + 'can/compute/compute', + 'can/view/render', + 'can/view/bindings/bindings' +], function (can) { + can.view.ext = '.mustache'; + var SCOPE = 'scope', HASH = '___h4sh', CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options}', SPECIAL_CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options, special: true}', ARG_NAMES = SCOPE + ',options', argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false|null|undefined)|((.+?)=(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false)|(.+))))$/, makeLookupLiteral = function (type) { + return '{get:"' + type.replace(/"/g, '\\"') + '"}'; + }, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, isObserveLike = function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, isArrayLike = function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, makeConvertToScopes = function (original, scope, options) { + var originalWithScope = function (ctx, opts) { + return original(ctx || scope, opts); + }; + return function (updatedScope, updatedOptions) { + if (updatedScope !== undefined && !(updatedScope instanceof can.view.Scope)) { + updatedScope = scope.add(updatedScope); + } + if (updatedOptions !== undefined && !(updatedOptions instanceof can.view.Options)) { + updatedOptions = options.add(updatedOptions); + } + return originalWithScope(updatedScope, updatedOptions || options); + }; + }; + var Mustache = function (options, helpers) { + if (this.constructor !== Mustache) { + var mustache = new Mustache(options); + return function (data, options) { + return mustache.render(data, options); + }; + } + if (typeof options === 'function') { + this.template = { fn: options }; + return; + } + can.extend(this, options); + this.template = this.scanner.scan(this.text, this.name); + }; + can.Mustache = can.global.Mustache = Mustache; + Mustache.prototype.render = function (data, options) { + if (!(data instanceof can.view.Scope)) { + data = new can.view.Scope(data || {}); + } + if (!(options instanceof can.view.Options)) { + options = new can.view.Options(options || {}); + } + options = options || {}; + return this.template.fn.call(data, data, options); + }; + can.extend(Mustache.prototype, { + scanner: new can.view.Scanner({ + text: { + start: '', + scope: SCOPE, + options: ',options: options', + argNames: ARG_NAMES + }, + tokens: [ + [ + 'returnLeft', + '{{{', + '{{[{&]' + ], + [ + 'commentFull', + '{{!}}', + '^[\\s\\t]*{{!.+?}}\\n' + ], + [ + 'commentLeft', + '{{!', + '(\\n[\\s\\t]*{{!|{{!)' + ], + [ + 'escapeFull', + '{{}}', + '(^[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}$)', + function (content) { + return { + before: /^\n.+?\n$/.test(content) ? '\n' : '', + content: content.match(/\{\{(.+?)\}\}/)[1] || '' + }; + } + ], + [ + 'escapeLeft', + '{{' + ], + [ + 'returnRight', + '}}}' + ], + [ + 'right', + '}}' + ] + ], + helpers: [ + { + name: /^>[\s]*\w*/, + fn: function (content, cmd) { + var templateName = can.trim(content.replace(/^>\s?/, '')).replace(/["|']/g, ''); + return 'can.Mustache.renderPartial(\'' + templateName + '\',' + ARG_NAMES + ')'; + } + }, + { + name: /^\s*data\s/, + fn: function (content, cmd) { + var attr = content.match(/["|'](.*)["|']/)[1]; + return 'can.proxy(function(__){' + 'can.data(can.$(__),\'' + attr + '\', this.attr(\'.\')); }, ' + SCOPE + ')'; + } + }, + { + name: /\s*\(([\$\w]+)\)\s*->([^\n]*)/, + fn: function (content) { + var quickFunc = /\s*\(([\$\w]+)\)\s*->([^\n]*)/, parts = content.match(quickFunc); + return 'can.proxy(function(__){var ' + parts[1] + '=can.$(__);with(' + SCOPE + '.attr(\'.\')){' + parts[2] + '}}, this);'; + } + }, + { + name: /^.*$/, + fn: function (content, cmd) { + var mode = false, result = { + content: '', + startTxt: false, + startOnlyTxt: false, + end: false + }; + content = can.trim(content); + if (content.length && (mode = content.match(/^([#^\/]|else$)/))) { + mode = mode[0]; + switch (mode) { + case '#': + case '^': + if (cmd.specialAttribute) { + result.startOnlyTxt = true; + } else { + result.startTxt = true; + result.escaped = 0; + } + break; + case '/': + result.end = true; + result.content += 'return ___v1ew.join("");}}])'; + return result; + } + content = content.substring(1); + } + if (mode !== 'else') { + var args = [], hashes = [], i = 0, m; + result.content += 'can.Mustache.txt(\n' + (cmd.specialAttribute ? SPECIAL_CONTEXT_OBJ : CONTEXT_OBJ) + ',\n' + (mode ? '"' + mode + '"' : 'null') + ','; + (can.trim(content) + ' ').replace(argumentsRegExp, function (whole, arg) { + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[2]) { + args.push(m[0]); + } else { + hashes.push(m[4] + ':' + (m[6] ? m[6] : makeLookupLiteral(m[5]))); + } + } else { + args.push(makeLookupLiteral(arg)); + } + i++; + }); + result.content += args.join(','); + if (hashes.length) { + result.content += ',{' + HASH + ':{' + hashes.join(',') + '}}'; + } + } + if (mode && mode !== 'else') { + result.content += ',[\n\n'; + } + switch (mode) { + case '^': + case '#': + result.content += '{fn:function(' + ARG_NAMES + '){var ___v1ew = [];'; + break; + case 'else': + result.content += 'return ___v1ew.join("");}},\n{inverse:function(' + ARG_NAMES + '){\nvar ___v1ew = [];'; + break; + default: + result.content += ')'; + break; + } + if (!mode) { + result.startTxt = true; + result.end = true; + } + return result; + } + } + ] + }) + }); + var helpers = can.view.Scanner.prototype.helpers; + for (var i = 0; i < helpers.length; i++) { + Mustache.prototype.scanner.helpers.unshift(helpers[i]); + } + Mustache.txt = function (scopeAndOptions, mode, name) { + var scope = scopeAndOptions.scope, options = scopeAndOptions.options, args = [], helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, hash, context = scope.attr('.'), getHelper = true, helper; + for (var i = 3; i < arguments.length; i++) { + var arg = arguments[i]; + if (mode && can.isArray(arg)) { + helperOptions = can.extend.apply(can, [helperOptions].concat(arg)); + } else if (arg && arg[HASH]) { + hash = arg[HASH]; + for (var prop in hash) { + if (isLookup(hash[prop])) { + hash[prop] = Mustache.get(hash[prop].get, scopeAndOptions, false, true); + } + } + } else if (arg && isLookup(arg)) { + args.push(Mustache.get(arg.get, scopeAndOptions, false, true, true)); + } else { + args.push(arg); + } + } + if (isLookup(name)) { + var get = name.get; + name = Mustache.get(name.get, scopeAndOptions, args.length, false); + getHelper = get === name; + } + helperOptions.fn = makeConvertToScopes(helperOptions.fn, scope, options); + helperOptions.inverse = makeConvertToScopes(helperOptions.inverse, scope, options); + if (mode === '^') { + var tmp = helperOptions.fn; + helperOptions.fn = helperOptions.inverse; + helperOptions.inverse = tmp; + } + if (helper = getHelper && (typeof name === 'string' && Mustache.getHelper(name, options)) || can.isFunction(name) && !name.isComputed && { fn: name }) { + can.extend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash + }); + args.push(helperOptions); + return function () { + return helper.fn.apply(context, args) || ''; + }; + } + return function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + var validArgs = args.length ? args : [value], valid = true, result = [], i, argIsObserve, arg; + if (mode) { + for (i = 0; i < validArgs.length; i++) { + arg = validArgs[i]; + argIsObserve = typeof arg !== 'undefined' && isObserveLike(arg); + if (isArrayLike(arg)) { + if (mode === '#') { + valid = valid && !!(argIsObserve ? arg.attr('length') : arg.length); + } else if (mode === '^') { + valid = valid && !(argIsObserve ? arg.attr('length') : arg.length); + } + } else { + valid = mode === '#' ? valid && !!arg : mode === '^' ? valid && !arg : valid; + } + } + } + if (valid) { + if (mode === '#') { + if (isArrayLike(value)) { + var isObserveList = isObserveLike(value); + for (i = 0; i < value.length; i++) { + result.push(helperOptions.fn(isObserveList ? value.attr('' + i) : value[i])); + } + return result.join(''); + } else { + return helperOptions.fn(value || {}) || ''; + } + } else if (mode === '^') { + return helperOptions.inverse(value || {}) || ''; + } else { + return '' + (value != null ? value : ''); + } + } + return ''; + }; + }; + Mustache.get = function (key, scopeAndOptions, isHelper, isArgument, isLookup) { + var context = scopeAndOptions.scope.attr('.'), options = scopeAndOptions.options || {}; + if (isHelper) { + if (Mustache.getHelper(key, options)) { + return key; + } + if (scopeAndOptions.scope && can.isFunction(context[key])) { + return context[key]; + } + } + var computeData = scopeAndOptions.scope.computeData(key, { + isArgument: isArgument, + args: [ + context, + scopeAndOptions.scope + ] + }), compute = computeData.compute; + can.compute.temporarilyBind(compute); + var initialValue = computeData.initialValue, helperObj = Mustache.getHelper(key, options); + if (!isLookup && (initialValue === undefined || computeData.scope !== scopeAndOptions.scope) && Mustache.getHelper(key, options)) { + return key; + } + if (!compute.computeInstance.hasDependencies) { + return initialValue; + } else { + return compute; + } + }; + Mustache.resolve = function (value) { + if (isObserveLike(value) && isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + can.view.Options = can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }); + Mustache._helpers = {}; + Mustache.registerHelper = function (name, fn) { + this._helpers[name] = { + name: name, + fn: fn + }; + }; + Mustache.getHelper = function (name, options) { + var helper; + if (options) { + helper = options.attr('helpers.' + name); + } + return helper ? { fn: helper } : this._helpers[name]; + }; + Mustache.render = function (partial, scope, options) { + if (!can.view.cached[partial]) { + var reads = can.__clearReading(); + var scopePartialName = scope.attr(partial); + if (scopePartialName) { + partial = scopePartialName; + } + can.__setReading(reads); + } + return can.view.render(partial, scope, options); + }; + Mustache.safeString = function (str) { + return { + toString: function () { + return str; + } + }; + }; + Mustache.renderPartial = function (partialName, scope, options) { + var partial = options.attr('partials.' + partialName); + if (partial) { + return partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + return can.Mustache.render(partialName, scope, options); + } + }; + can.each({ + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!Mustache.resolve(expr); + } + if (value) { + return options.fn(options.contexts || this); + } else { + return options.inverse(options.contexts || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = Mustache.resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return Mustache._helpers.is.fn.apply(this, arguments); + }, + 'unless': function (expr, options) { + return Mustache._helpers['if'].fn.apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'each': function (expr, options) { + var resolved = Mustache.resolve(expr), result = [], keys, key, i; + if (can.view.lists && (resolved instanceof can.List || expr && expr.isComputed && resolved === undefined)) { + return can.view.lists(expr, function (item, index) { + return options.fn(options.scope.add({ '@index': index }).add(item)); + }); + } + expr = resolved; + if (!!expr && isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + return result.join(''); + } else if (isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } + }, + 'with': function (expr, options) { + var ctx = expr; + expr = Mustache.resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + } + }, function (fn, name) { + Mustache.registerHelper(name, fn); + }); + can.view.register({ + suffix: 'mustache', + contentType: 'x-mustache-template', + script: function (id, src) { + return 'can.Mustache(function(' + ARG_NAMES + ') { ' + new Mustache({ + text: src, + name: id + }).template.out + ' })'; + }, + renderer: function (id, text) { + return Mustache({ + text: text, + name: id + }); + } + }); + can.mustache.registerHelper = can.proxy(can.Mustache.registerHelper, can.Mustache); + can.mustache.safeString = can.Mustache.safeString; + return can; +}); +/*can@2.2.6#component/component*/ +define('can/component/component', [ + 'can/util/util', + 'can/view/callbacks/callbacks', + 'can/view/elements', + 'can/control/control', + 'can/observe/observe', + 'can/view/mustache/mustache', + 'can/view/bindings/bindings' +], function (can, viewCallbacks, elements) { + var ignoreAttributesRegExp = /^(dataViewId|class|id)$/i, paramReplacer = /\{([^\}]+)\}/g; + var Component = can.Component = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Component) { + var self = this, scope = this.prototype.scope || this.prototype.viewModel; + this.Control = ComponentControl.extend(this.prototype.events); + if (!scope || typeof scope === 'object' && !(scope instanceof can.Map)) { + this.Map = can.Map.extend(scope || {}); + } else if (scope.prototype instanceof can.Map) { + this.Map = scope; + } + this.attributeScopeMappings = {}; + can.each(this.Map ? this.Map.defaults : {}, function (val, prop) { + if (val === '@') { + self.attributeScopeMappings[prop] = prop; + } + }); + if (this.prototype.template) { + if (typeof this.prototype.template === 'function') { + var temp = this.prototype.template; + this.renderer = function () { + return can.view.frag(temp.apply(null, arguments)); + }; + } else { + this.renderer = can.view.mustache(this.prototype.template); + } + } + can.view.tag(this.prototype.tag, function (el, options) { + new self(el, options); + }); + } + } + }, { + setup: function (el, hookupOptions) { + var initialScopeData = {}, component = this, lexicalContent = (typeof this.leakScope === 'undefined' ? false : !this.leakScope) && this.template, twoWayBindings = {}, scope = this.scope || this.viewModel, viewModelPropertyUpdates = {}, componentScope, frag, teardownFunctions = [], callTeardownFunctions = function () { + for (var i = 0, len = teardownFunctions.length; i < len; i++) { + teardownFunctions[i](); + } + }; + can.each(this.constructor.attributeScopeMappings, function (val, prop) { + initialScopeData[prop] = el.getAttribute(can.hyphenate(val)); + }); + can.each(can.makeArray(el.attributes), function (node, index) { + var name = can.camelize(node.nodeName.toLowerCase()), value = node.value; + if (component.constructor.attributeScopeMappings[name] || ignoreAttributesRegExp.test(name) || viewCallbacks.attr(node.nodeName)) { + return; + } + if (value[0] === '{' && value[value.length - 1] === '}') { + value = value.substr(1, value.length - 2); + } else { + if (hookupOptions.templateType !== 'legacy') { + initialScopeData[name] = value; + return; + } + } + var computeData = hookupOptions.scope.computeData(value, { args: [] }), compute = computeData.compute; + var handler = function (ev, newVal) { + viewModelPropertyUpdates[name] = (viewModelPropertyUpdates[name] || 0) + 1; + componentScope.attr(name, newVal); + can.batch.afterPreviousEvents(function () { + --viewModelPropertyUpdates[name]; + }); + }; + compute.bind('change', handler); + initialScopeData[name] = compute(); + if (!compute.computeInstance.hasDependencies) { + compute.unbind('change', handler); + } else { + teardownFunctions.push(function () { + compute.unbind('change', handler); + }); + twoWayBindings[name] = computeData; + } + }); + if (this.constructor.Map) { + componentScope = new this.constructor.Map(initialScopeData); + } else if (scope instanceof can.Map) { + componentScope = scope; + } else if (can.isFunction(scope)) { + var scopeResult = scope.call(this, initialScopeData, hookupOptions.scope, el); + if (scopeResult instanceof can.Map) { + componentScope = scopeResult; + } else if (scopeResult.prototype instanceof can.Map) { + componentScope = new scopeResult(initialScopeData); + } else { + componentScope = new (can.Map.extend(scopeResult))(initialScopeData); + } + } + var handlers = {}; + can.each(twoWayBindings, function (computeData, prop) { + handlers[prop] = function (ev, newVal) { + if (!viewModelPropertyUpdates[prop]) { + computeData.compute(newVal); + } + }; + componentScope.bind(prop, handlers[prop]); + }); + if (!can.isEmptyObject(this.constructor.attributeScopeMappings) || hookupOptions.templateType !== 'legacy') { + can.bind.call(el, 'attributes', function (ev) { + var camelized = can.camelize(ev.attributeName); + if (!twoWayBindings[camelized] && !ignoreAttributesRegExp.test(camelized)) { + componentScope.attr(camelized, el.getAttribute(ev.attributeName)); + } + }); + } + this.scope = this.viewModel = componentScope; + can.data(can.$(el), 'scope', this.scope); + can.data(can.$(el), 'viewModel', this.scope); + var renderedScope = lexicalContent ? this.scope : hookupOptions.scope.add(this.scope), options = { helpers: {} }; + can.each(this.helpers || {}, function (val, prop) { + if (can.isFunction(val)) { + options.helpers[prop] = function () { + return val.apply(componentScope, arguments); + }; + } + }); + teardownFunctions.push(function () { + can.each(handlers, function (handler, prop) { + componentScope.unbind(prop, handlers[prop]); + }); + }); + this._control = new this.constructor.Control(el, { + scope: this.scope, + viewModel: this.scope + }); + if (this._control && this._control.destroy) { + var oldDestroy = this._control.destroy; + this._control.destroy = function () { + oldDestroy.apply(this, arguments); + callTeardownFunctions(); + }; + this._control.on(); + } else { + can.bind.call(el, 'removed', function () { + callTeardownFunctions(); + }); + } + var nodeList = can.view.nodeLists.register([], undefined, true); + teardownFunctions.push(function () { + can.view.nodeLists.unregister(nodeList); + }); + if (this.constructor.renderer) { + if (!options.tags) { + options.tags = {}; + } + options.tags.content = function contentHookup(el, rendererOptions) { + var subtemplate = hookupOptions.subtemplate || rendererOptions.subtemplate; + if (subtemplate) { + delete options.tags.content; + var opts = !lexicalContent || subtemplate !== hookupOptions.subtemplate ? rendererOptions : hookupOptions; + if (rendererOptions.parentNodeList) { + var frag = subtemplate(opts.scope, opts.options, rendererOptions.parentNodeList); + elements.replace([el], frag); + } else { + can.view.live.replace([el], subtemplate(opts.scope, opts.options)); + } + options.tags.content = contentHookup; + } + }; + frag = this.constructor.renderer(renderedScope, hookupOptions.options.add(options), nodeList); + } else { + if (hookupOptions.templateType === 'legacy') { + frag = can.view.frag(hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options)) : ''); + } else { + frag = hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options), nodeList) : document.createDocumentFragment(); + } + } + can.appendChild(el, frag); + can.view.nodeLists.update(nodeList, el.childNodes); + } + }); + var ComponentControl = can.Control.extend({ + _lookup: function (options) { + return [ + options.scope, + options, + window + ]; + }, + _action: function (methodName, options, controlInstance) { + var hasObjectLookup, readyCompute; + paramReplacer.lastIndex = 0; + hasObjectLookup = paramReplacer.test(methodName); + if (!controlInstance && hasObjectLookup) { + return; + } else if (!hasObjectLookup) { + return can.Control._action.apply(this, arguments); + } else { + readyCompute = can.compute(function () { + var delegate; + var name = methodName.replace(paramReplacer, function (matched, key) { + var value; + if (key === 'scope' || key === 'viewModel') { + delegate = options.scope; + return ''; + } + key = key.replace(/^(scope|^viewModel)\./, ''); + value = can.compute.read(options.scope, key.split('.'), { isArgument: true }).value; + if (value === undefined) { + value = can.getObject(key); + } + if (typeof value === 'string') { + return value; + } else { + delegate = value; + return ''; + } + }); + var parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: this.processors[event] || this.processors.click, + parts: [ + name, + parts.join(' '), + event + ], + delegate: delegate || undefined + }; + }, this); + var handler = function (ev, ready) { + controlInstance._bindings.control[methodName](controlInstance.element); + controlInstance._bindings.control[methodName] = ready.processor(ready.delegate || controlInstance.element, ready.parts[2], ready.parts[1], methodName, controlInstance); + }; + readyCompute.bind('change', handler); + controlInstance._bindings.readyComputes[methodName] = { + compute: readyCompute, + handler: handler + }; + return readyCompute(); + } + } + }, { + setup: function (el, options) { + this.scope = options.scope; + this.viewModel = options.viewModel; + return can.Control.prototype.setup.call(this, el, options); + }, + off: function () { + if (this._bindings) { + can.each(this._bindings.readyComputes || {}, function (value) { + value.compute.unbind('change', value.handler); + }); + } + can.Control.prototype.off.apply(this, arguments); + this._bindings.readyComputes = {}; + } + }); + var $ = can.$; + if ($.fn) { + $.fn.scope = $.fn.viewModel = function () { + return can.viewModel.apply(can, [this].concat(can.makeArray(arguments))); + }; + } + return Component; +}); +/*can@2.2.6#model/model*/ +define('can/model/model', [ + 'can/util/util', + 'can/map/map', + 'can/list/list' +], function (can) { + var pipe = function (def, thisArg, func) { + var d = new can.Deferred(); + def.then(function () { + var args = can.makeArray(arguments), success = true; + try { + args[0] = func.apply(thisArg, args); + } catch (e) { + success = false; + d.rejectWith(d, [e].concat(args)); + } + if (success) { + d.resolveWith(d, args); + } + }, function () { + d.rejectWith(this, arguments); + }); + if (typeof def.abort === 'function') { + d.abort = function () { + return def.abort(); + }; + } + return d; + }, modelNum = 0, getId = function (inst) { + can.__observe(inst, inst.constructor.id); + return inst.__get(inst.constructor.id); + }, ajax = function (ajaxOb, data, type, dataType, success, error) { + var params = {}; + if (typeof ajaxOb === 'string') { + var parts = ajaxOb.split(/\s+/); + params.url = parts.pop(); + if (parts.length) { + params.type = parts.pop(); + } + } else { + can.extend(params, ajaxOb); + } + params.data = typeof data === 'object' && !can.isArray(data) ? can.extend(params.data || {}, data) : data; + params.url = can.sub(params.url, params.data, true); + return can.ajax(can.extend({ + type: type || 'post', + dataType: dataType || 'json', + success: success, + error: error + }, params)); + }, makeRequest = function (modelObj, type, success, error, method) { + var args; + if (can.isArray(modelObj)) { + args = modelObj[1]; + modelObj = modelObj[0]; + } else { + args = modelObj.serialize(); + } + args = [args]; + var deferred, model = modelObj.constructor, jqXHR; + if (type === 'update' || type === 'destroy') { + args.unshift(getId(modelObj)); + } + jqXHR = model[type].apply(model, args); + deferred = pipe(jqXHR, modelObj, function (data) { + modelObj[method || type + 'd'](data, jqXHR); + return modelObj; + }); + if (jqXHR.abort) { + deferred.abort = function () { + jqXHR.abort(); + }; + } + deferred.then(success, error); + return deferred; + }, converters = { + models: function (instancesRawData, oldList, xhr) { + can.Model._reqs++; + if (!instancesRawData) { + return; + } + if (instancesRawData instanceof this.List) { + return instancesRawData; + } + var self = this, tmp = [], ListClass = self.List || ML, modelList = oldList instanceof can.List ? oldList : new ListClass(), rawDataIsList = instancesRawData instanceof ML, raw = rawDataIsList ? instancesRawData.serialize() : instancesRawData; + raw = self.parseModels(raw, xhr); + if (raw.data) { + instancesRawData = raw; + raw = raw.data; + } + if (typeof raw === 'undefined' || !can.isArray(raw)) { + throw new Error('Could not get any raw data while converting using .models'); + } + if (modelList.length) { + modelList.splice(0); + } + can.each(raw, function (rawPart) { + tmp.push(self.model(rawPart, xhr)); + }); + modelList.push.apply(modelList, tmp); + if (!can.isArray(instancesRawData)) { + can.each(instancesRawData, function (val, prop) { + if (prop !== 'data') { + modelList.attr(prop, val); + } + }); + } + setTimeout(can.proxy(this._clean, this), 1); + return modelList; + }, + model: function (attributes, oldModel, xhr) { + if (!attributes) { + return; + } + if (typeof attributes.serialize === 'function') { + attributes = attributes.serialize(); + } else { + attributes = this.parseModel(attributes, xhr); + } + var id = attributes[this.id]; + if ((id || id === 0) && this.store[id]) { + oldModel = this.store[id]; + } + var model = oldModel && can.isFunction(oldModel.attr) ? oldModel.attr(attributes, this.removeAttr || false) : new this(attributes); + return model; + } + }, makeParser = { + parseModel: function (prop) { + return function (attributes) { + return prop ? can.getObject(prop, attributes) : attributes; + }; + }, + parseModels: function (prop) { + return function (attributes) { + if (can.isArray(attributes)) { + return attributes; + } + prop = prop || 'data'; + var result = can.getObject(prop, attributes); + if (!can.isArray(result)) { + throw new Error('Could not get any raw data while converting using .models'); + } + return result; + }; + } + }, ajaxMethods = { + create: { + url: '_shortName', + type: 'post' + }, + update: { + data: function (id, attrs) { + attrs = attrs || {}; + var identity = this.id; + if (attrs[identity] && attrs[identity] !== id) { + attrs['new' + can.capitalize(id)] = attrs[identity]; + delete attrs[identity]; + } + attrs[identity] = id; + return attrs; + }, + type: 'put' + }, + destroy: { + type: 'delete', + data: function (id, attrs) { + attrs = attrs || {}; + attrs.id = attrs[this.id] = id; + return attrs; + } + }, + findAll: { url: '_shortName' }, + findOne: {} + }, ajaxMaker = function (ajaxMethod, str) { + return function (data) { + data = ajaxMethod.data ? ajaxMethod.data.apply(this, arguments) : data; + return ajax(str || this[ajaxMethod.url || '_url'], data, ajaxMethod.type || 'get'); + }; + }, createURLFromResource = function (model, name) { + if (!model.resource) { + return; + } + var resource = model.resource.replace(/\/+$/, ''); + if (name === 'findAll' || name === 'create') { + return resource; + } else { + return resource + '/{' + model.id + '}'; + } + }; + can.Model = can.Map.extend({ + fullName: 'can.Model', + _reqs: 0, + setup: function (base, fullName, staticProps, protoProps) { + if (typeof fullName !== 'string') { + protoProps = staticProps; + staticProps = fullName; + } + if (!protoProps) { + protoProps = staticProps; + } + this.store = {}; + can.Map.setup.apply(this, arguments); + if (!can.Model) { + return; + } + if (staticProps && staticProps.List) { + this.List = staticProps.List; + this.List.Map = this; + } else { + this.List = base.List.extend({ Map: this }, {}); + } + var self = this, clean = can.proxy(this._clean, self); + can.each(ajaxMethods, function (method, name) { + if (staticProps && staticProps[name] && (typeof staticProps[name] === 'string' || typeof staticProps[name] === 'object')) { + self[name] = ajaxMaker(method, staticProps[name]); + } else if (staticProps && staticProps.resource && !can.isFunction(staticProps[name])) { + self[name] = ajaxMaker(method, createURLFromResource(self, name)); + } + if (self['make' + can.capitalize(name)]) { + var newMethod = self['make' + can.capitalize(name)](self[name]); + can.Construct._overwrite(self, base, name, function () { + can.Model._reqs++; + var def = newMethod.apply(this, arguments); + var then = def.then(clean, clean); + then.abort = def.abort; + return then; + }); + } + }); + var hasCustomConverter = {}; + can.each(converters, function (converter, name) { + var parseName = 'parse' + can.capitalize(name), dataProperty = staticProps && staticProps[name] || self[name]; + if (typeof dataProperty === 'string') { + self[parseName] = dataProperty; + can.Construct._overwrite(self, base, name, converter); + } else if (staticProps && staticProps[name]) { + hasCustomConverter[parseName] = true; + } + }); + can.each(makeParser, function (maker, parseName) { + var prop = staticProps && staticProps[parseName] || self[parseName]; + if (typeof prop === 'string') { + can.Construct._overwrite(self, base, parseName, maker(prop)); + } else if ((!staticProps || !can.isFunction(staticProps[parseName])) && !self[parseName]) { + var madeParser = maker(); + madeParser.useModelConverter = hasCustomConverter[parseName]; + can.Construct._overwrite(self, base, parseName, madeParser); + } + }); + if (self.fullName === 'can.Model' || !self.fullName) { + self.fullName = 'Model' + ++modelNum; + } + can.Model._reqs = 0; + this._url = this._shortName + '/{' + this.id + '}'; + }, + _ajax: ajaxMaker, + _makeRequest: makeRequest, + _clean: function () { + can.Model._reqs--; + if (!can.Model._reqs) { + for (var id in this.store) { + if (!this.store[id]._bindings) { + delete this.store[id]; + } + } + } + return arguments[0]; + }, + models: converters.models, + model: converters.model + }, { + setup: function (attrs) { + var id = attrs && attrs[this.constructor.id]; + if (can.Model._reqs && id != null) { + this.constructor.store[id] = this; + } + can.Map.prototype.setup.apply(this, arguments); + }, + isNew: function () { + var id = getId(this); + return !(id || id === 0); + }, + save: function (success, error) { + return makeRequest(this, this.isNew() ? 'create' : 'update', success, error); + }, + destroy: function (success, error) { + if (this.isNew()) { + var self = this; + var def = can.Deferred(); + def.then(success, error); + return def.done(function (data) { + self.destroyed(data); + }).resolve(self); + } + return makeRequest(this, 'destroy', success, error, 'destroyed'); + }, + _bindsetup: function () { + var modelInstance = this.__get(this.constructor.id); + if (modelInstance != null) { + this.constructor.store[modelInstance] = this; + } + return can.Map.prototype._bindsetup.apply(this, arguments); + }, + _bindteardown: function () { + delete this.constructor.store[getId(this)]; + return can.Map.prototype._bindteardown.apply(this, arguments); + }, + ___set: function (prop, val) { + can.Map.prototype.___set.call(this, prop, val); + if (prop === this.constructor.id && this._bindings) { + this.constructor.store[getId(this)] = this; + } + } + }); + var makeGetterHandler = function (name) { + return function (data, readyState, xhr) { + return this[name](data, null, xhr); + }; + }, createUpdateDestroyHandler = function (data) { + if (this.parseModel.useModelConverter) { + return this.model(data); + } + return this.parseModel(data); + }; + var responseHandlers = { + makeFindAll: makeGetterHandler('models'), + makeFindOne: makeGetterHandler('model'), + makeCreate: createUpdateDestroyHandler, + makeUpdate: createUpdateDestroyHandler, + makeDestroy: createUpdateDestroyHandler + }; + can.each(responseHandlers, function (method, name) { + can.Model[name] = function (oldMethod) { + return function () { + var args = can.makeArray(arguments), oldArgs = can.isFunction(args[1]) ? args.splice(0, 1) : args.splice(0, 2), def = pipe(oldMethod.apply(this, oldArgs), this, method); + def.then(args[0], args[1]); + return def; + }; + }; + }); + can.each([ + 'created', + 'updated', + 'destroyed' + ], function (funcName) { + can.Model.prototype[funcName] = function (attrs) { + var self = this, constructor = self.constructor; + if (attrs && typeof attrs === 'object') { + this.attr(can.isFunction(attrs.attr) ? attrs.attr() : attrs); + } + can.dispatch.call(this, { + type: 'change', + target: this + }, [funcName]); + can.dispatch.call(constructor, funcName, [this]); + }; + }); + var ML = can.Model.List = can.List.extend({ + _bubbleRule: function (eventName, list) { + var bubbleRules = can.List._bubbleRule(eventName, list); + bubbleRules.push('destroyed'); + return bubbleRules; + } + }, { + setup: function (params) { + if (can.isPlainObject(params) && !can.isArray(params)) { + can.List.prototype.setup.apply(this); + this.replace(can.isDeferred(params) ? params : this.constructor.Map.findAll(params)); + } else { + can.List.prototype.setup.apply(this, arguments); + } + this._init = 1; + this.bind('destroyed', can.proxy(this._destroyed, this)); + delete this._init; + }, + _destroyed: function (ev, attr) { + if (/\w+/.test(attr)) { + var index; + while ((index = this.indexOf(ev.target)) > -1) { + this.splice(index, 1); + } + } + } + }); + return can.Model; +}); +/*can@2.2.6#util/string/deparam/deparam*/ +define('can/util/string/deparam/deparam', [ + 'can/util/util', + 'can/util/string/string' +], function (can) { + var digitTest = /^\d+$/, keyBreaker = /([^\[\]]+)|(\[\])/g, paramTest = /([^?#]*)(#.*)?$/, prep = function (str) { + return decodeURIComponent(str.replace(/\+/g, ' ')); + }; + can.extend(can, { + deparam: function (params) { + var data = {}, pairs, lastPart; + if (params && paramTest.test(params)) { + pairs = params.split('&'); + can.each(pairs, function (pair) { + var parts = pair.split('='), key = prep(parts.shift()), value = prep(parts.join('=')), current = data; + if (key) { + parts = key.match(keyBreaker); + for (var j = 0, l = parts.length - 1; j < l; j++) { + if (!current[parts[j]]) { + current[parts[j]] = digitTest.test(parts[j + 1]) || parts[j + 1] === '[]' ? [] : {}; + } + current = current[parts[j]]; + } + lastPart = parts.pop(); + if (lastPart === '[]') { + current.push(value); + } else { + current[lastPart] = value; + } + } + }); + } + return data; + } + }); + return can; +}); +/*can@2.2.6#route/route*/ +define('can/route/route', [ + 'can/util/util', + 'can/map/map', + 'can/list/list', + 'can/util/string/deparam/deparam' +], function (can) { + var matcher = /\:([\w\.]+)/g, paramsMatcher = /^(?:&[^=]+=[^&]*)+/, makeProps = function (props) { + var tags = []; + can.each(props, function (val, name) { + tags.push((name === 'className' ? 'class' : name) + '="' + (name === 'href' ? val : can.esc(val)) + '"'); + }); + return tags.join(' '); + }, matchesData = function (route, data) { + var count = 0, i = 0, defaults = {}; + for (var name in route.defaults) { + if (route.defaults[name] === data[name]) { + defaults[name] = 1; + count++; + } + } + for (; i < route.names.length; i++) { + if (!data.hasOwnProperty(route.names[i])) { + return -1; + } + if (!defaults[route.names[i]]) { + count++; + } + } + return count; + }, location = window.location, wrapQuote = function (str) { + return (str + '').replace(/([.?*+\^$\[\]\\(){}|\-])/g, '\\$1'); + }, each = can.each, extend = can.extend, stringify = function (obj) { + if (obj && typeof obj === 'object') { + if (obj instanceof can.Map) { + obj = obj.attr(); + } else { + obj = can.isFunction(obj.slice) ? obj.slice() : can.extend({}, obj); + } + can.each(obj, function (val, prop) { + obj[prop] = stringify(val); + }); + } else if (obj !== undefined && obj !== null && can.isFunction(obj.toString)) { + obj = obj.toString(); + } + return obj; + }, removeBackslash = function (str) { + return str.replace(/\\/g, ''); + }, timer, curParams, lastHash, changingData, changedAttrs = [], onRouteDataChange = function (ev, attr, how, newval) { + changingData = 1; + changedAttrs.push(attr); + clearTimeout(timer); + timer = setTimeout(function () { + changingData = 0; + var serialized = can.route.data.serialize(), path = can.route.param(serialized, true); + can.route._call('setURL', path, changedAttrs); + can.batch.trigger(eventsObject, '__url', [ + path, + lastHash + ]); + lastHash = path; + changedAttrs = []; + }, 10); + }, eventsObject = can.extend({}, can.event); + can.route = function (url, defaults) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + defaults = defaults || {}; + var names = [], res, test = '', lastIndex = matcher.lastIndex = 0, next, querySeparator = can.route._call('querySeparator'), matchSlashes = can.route._call('matchSlashes'); + while (res = matcher.exec(url)) { + names.push(res[1]); + test += removeBackslash(url.substring(lastIndex, matcher.lastIndex - res[0].length)); + next = '\\' + (removeBackslash(url.substr(matcher.lastIndex, 1)) || querySeparator + (matchSlashes ? '' : '|/')); + test += '([^' + next + ']' + (defaults[res[1]] ? '*' : '+') + ')'; + lastIndex = matcher.lastIndex; + } + test += url.substr(lastIndex).replace('\\', ''); + can.route.routes[url] = { + test: new RegExp('^' + test + '($|' + wrapQuote(querySeparator) + ')'), + route: url, + names: names, + defaults: defaults, + length: url.split('/').length + }; + return can.route; + }; + extend(can.route, { + param: function (data, _setRoute) { + var route, matches = 0, matchCount, routeName = data.route, propCount = 0; + delete data.route; + each(data, function () { + propCount++; + }); + each(can.route.routes, function (temp, name) { + matchCount = matchesData(temp, data); + if (matchCount > matches) { + route = temp; + matches = matchCount; + } + if (matchCount >= propCount) { + return false; + } + }); + if (can.route.routes[routeName] && matchesData(can.route.routes[routeName], data) === matches) { + route = can.route.routes[routeName]; + } + if (route) { + var cpy = extend({}, data), res = route.route.replace(matcher, function (whole, name) { + delete cpy[name]; + return data[name] === route.defaults[name] ? '' : encodeURIComponent(data[name]); + }).replace('\\', ''), after; + each(route.defaults, function (val, name) { + if (cpy[name] === val) { + delete cpy[name]; + } + }); + after = can.param(cpy); + if (_setRoute) { + can.route.attr('route', route.route); + } + return res + (after ? can.route._call('querySeparator') + after : ''); + } + return can.isEmptyObject(data) ? '' : can.route._call('querySeparator') + can.param(data); + }, + deparam: function (url) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + var route = { length: -1 }, querySeparator = can.route._call('querySeparator'), paramsMatcher = can.route._call('paramsMatcher'); + each(can.route.routes, function (temp, name) { + if (temp.test.test(url) && temp.length > route.length) { + route = temp; + } + }); + if (route.length > -1) { + var parts = url.match(route.test), start = parts.shift(), remainder = url.substr(start.length - (parts[parts.length - 1] === querySeparator ? 1 : 0)), obj = remainder && paramsMatcher.test(remainder) ? can.deparam(remainder.slice(1)) : {}; + obj = extend(true, {}, route.defaults, obj); + each(parts, function (part, i) { + if (part && part !== querySeparator) { + obj[route.names[i]] = decodeURIComponent(part); + } + }); + obj.route = route.route; + return obj; + } + if (url.charAt(0) !== querySeparator) { + url = querySeparator + url; + } + return paramsMatcher.test(url) ? can.deparam(url.slice(1)) : {}; + }, + data: new can.Map({}), + map: function (data) { + var appState; + if (data.prototype instanceof can.Map) { + appState = new data(); + } else { + appState = data; + } + can.route.data = appState; + }, + routes: {}, + ready: function (val) { + if (val !== true) { + can.route._setup(); + can.route.setState(); + } + return can.route; + }, + url: function (options, merge) { + if (merge) { + options = can.extend({}, can.route.deparam(can.route._call('matchingPartOfURL')), options); + } + return can.route._call('root') + can.route.param(options); + }, + link: function (name, options, props, merge) { + return '' + name + ''; + }, + current: function (options) { + can.__observe(eventsObject, '__url'); + return this._call('matchingPartOfURL') === can.route.param(options); + }, + bindings: { + hashchange: { + paramsMatcher: paramsMatcher, + querySeparator: '&', + matchSlashes: false, + bind: function () { + can.bind.call(window, 'hashchange', setState); + }, + unbind: function () { + can.unbind.call(window, 'hashchange', setState); + }, + matchingPartOfURL: function () { + return location.href.split(/#!?/)[1] || ''; + }, + setURL: function (path) { + if (location.hash !== '#' + path) { + location.hash = '!' + path; + } + return path; + }, + root: '#!' + } + }, + defaultBinding: 'hashchange', + currentBinding: null, + _setup: function () { + if (!can.route.currentBinding) { + can.route._call('bind'); + can.route.bind('change', onRouteDataChange); + can.route.currentBinding = can.route.defaultBinding; + } + }, + _teardown: function () { + if (can.route.currentBinding) { + can.route._call('unbind'); + can.route.unbind('change', onRouteDataChange); + can.route.currentBinding = null; + } + clearTimeout(timer); + changingData = 0; + }, + _call: function () { + var args = can.makeArray(arguments), prop = args.shift(), binding = can.route.bindings[can.route.currentBinding || can.route.defaultBinding], method = binding[prop]; + if (method.apply) { + return method.apply(binding, args); + } else { + return method; + } + } + }); + each([ + 'bind', + 'unbind', + 'on', + 'off', + 'delegate', + 'undelegate', + 'removeAttr', + 'compute', + '_get', + '__get', + 'each' + ], function (name) { + can.route[name] = function () { + if (!can.route.data[name]) { + return; + } + return can.route.data[name].apply(can.route.data, arguments); + }; + }); + can.route.attr = function (attr, val) { + var type = typeof attr, newArguments; + if (val === undefined) { + newArguments = arguments; + } else if (type !== 'string' && type !== 'number') { + newArguments = [ + stringify(attr), + val + ]; + } else { + newArguments = [ + attr, + stringify(val) + ]; + } + return can.route.data.attr.apply(can.route.data, newArguments); + }; + var setState = can.route.setState = function () { + var hash = can.route._call('matchingPartOfURL'); + var oldParams = curParams; + curParams = can.route.deparam(hash); + if (!changingData || hash !== lastHash) { + can.batch.start(); + recursiveClean(oldParams, curParams, can.route.data); + can.route.attr(curParams); + can.batch.trigger(eventsObject, '__url', [ + hash, + lastHash + ]); + can.batch.stop(); + } + }; + var recursiveClean = function (old, cur, data) { + for (var attr in old) { + if (cur[attr] === undefined) { + data.removeAttr(attr); + } else if (Object.prototype.toString.call(old[attr]) === '[object Object]') { + recursiveClean(old[attr], cur[attr], data.attr(attr)); + } + } + }; + return can.route; +}); +/*can@2.2.6#control/route/route*/ +define('can/control/route/route', [ + 'can/util/util', + 'can/route/route', + 'can/control/control' +], function (can) { + can.Control.processors.route = function (el, event, selector, funcName, controller) { + selector = selector || ''; + if (!can.route.routes[selector]) { + if (selector[0] === '/') { + selector = selector.substring(1); + } + can.route(selector); + } + var batchNum, check = function (ev, attr, how) { + if (can.route.attr('route') === selector && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + batchNum = ev.batchNum; + var d = can.route.attr(); + delete d.route; + if (can.isFunction(controller[funcName])) { + controller[funcName](d); + } else { + controller[controller[funcName]](d); + } + } + }; + can.route.bind('change', check); + return function () { + can.route.unbind('change', check); + }; + }; + return can; +}); +/*can@2.2.6#util/event*/ +define('can/util/event', [ + 'can/util/can', + 'can/event/event' +], function (can) { + return can; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.jquery.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.jquery.js new file mode 100644 index 0000000000..0eb8731940 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.jquery.js @@ -0,0 +1,6825 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#util/can*/ +define('can/util/can', [], function () { + var glbl = typeof window !== 'undefined' ? window : global; + var can = {}; + if (typeof GLOBALCAN === 'undefined' || GLOBALCAN !== false) { + glbl.can = can; + } + can.global = glbl; + can.k = function () { + }; + can.isDeferred = can.isPromise = function (obj) { + return obj && typeof obj.then === 'function' && typeof obj.pipe === 'function'; + }; + can.isMapLike = function (obj) { + return can.Map && (obj instanceof can.Map || obj && obj.__get); + }; + var cid = 0; + can.cid = function (object, name) { + if (!object._cid) { + cid++; + object._cid = (name || '') + cid; + } + return object._cid; + }; + can.VERSION = '2.2.6'; + can.simpleExtend = function (d, s) { + for (var prop in s) { + d[prop] = s[prop]; + } + return d; + }; + can.last = function (arr) { + return arr && arr[arr.length - 1]; + }; + var protoBind = Function.prototype.bind; + if (protoBind) { + can.proxy = function (fn, context) { + return protoBind.call(fn, context); + }; + } else { + can.proxy = function (fn, context) { + return function () { + return fn.apply(context, arguments); + }; + }; + } + can.frag = function (item) { + var frag; + if (!item || typeof item === 'string') { + frag = can.buildFragment(item == null ? '' : '' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } else if (item.nodeType === 11) { + return item; + } else if (typeof item.nodeType === 'number') { + frag = document.createDocumentFragment(); + frag.appendChild(item); + return frag; + } else if (typeof item.length === 'number') { + frag = document.createDocumentFragment(); + can.each(item, function (item) { + frag.appendChild(can.frag(item)); + }); + return frag; + } else { + frag = can.buildFragment('' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } + }; + can.scope = can.viewModel = function (el, attr, val) { + el = can.$(el); + var scope = can.data(el, 'scope') || can.data(el, 'viewModel'); + if (!scope) { + scope = new can.Map(); + can.data(el, 'scope', scope); + can.data(el, 'viewModel', scope); + } + switch (arguments.length) { + case 0: + case 1: + return scope; + case 2: + return scope.attr(attr); + default: + scope.attr(attr, val); + return el; + } + }; + can['import'] = function (moduleName) { + var deferred = new can.Deferred(); + if (typeof window.System === 'object' && can.isFunction(window.System['import'])) { + window.System['import'](moduleName).then(can.proxy(deferred.resolve, deferred), can.proxy(deferred.reject, deferred)); + } else if (window.define && window.define.amd) { + window.require([moduleName], function (value) { + deferred.resolve(value); + }); + } else if (window.steal) { + steal.steal(moduleName, function (value) { + deferred.resolve(value); + }); + } else if (window.require) { + deferred.resolve(window.require(moduleName)); + } else { + deferred.resolve(); + } + return deferred.promise(); + }; + can.__observe = function () { + }; + return can; +}); +/*can@2.2.6#util/attr/attr*/ +define('can/util/attr/attr', ['can/util/can'], function (can) { + var setImmediate = can.global.setImmediate || function (cb) { + return setTimeout(cb, 0); + }, attr = { + MutationObserver: can.global.MutationObserver || can.global.WebKitMutationObserver || can.global.MozMutationObserver, + map: { + 'class': 'className', + 'value': 'value', + 'innertext': 'innerText', + 'textcontent': 'textContent', + 'checked': true, + 'disabled': true, + 'readonly': true, + 'required': true, + src: function (el, val) { + if (val == null || val === '') { + el.removeAttribute('src'); + return null; + } else { + el.setAttribute('src', val); + return val; + } + }, + style: function (el, val) { + return el.style.cssText = val || ''; + } + }, + defaultValue: [ + 'input', + 'textarea' + ], + set: function (el, attrName, val) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var tagName = el.nodeName.toString().toLowerCase(), prop = attr.map[attrName], newValue; + if (typeof prop === 'function') { + newValue = prop(el, val); + } else if (prop === true) { + newValue = el[attrName] = true; + if (attrName === 'checked' && el.type === 'radio') { + if (can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultChecked = true; + } + } + } else if (prop) { + newValue = val; + if (el[prop] !== val) { + el[prop] = val; + } + if (prop === 'value' && can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultValue = val; + } + } else { + el.setAttribute(attrName, val); + newValue = val; + } + if (!attr.MutationObserver && newValue !== oldValue) { + attr.trigger(el, attrName, oldValue); + } + }, + trigger: function (el, attrName, oldValue) { + if (can.data(can.$(el), 'canHasAttributesBindings')) { + attrName = attrName.toLowerCase(); + return setImmediate(function () { + can.trigger(el, { + type: 'attributes', + attributeName: attrName, + target: el, + oldValue: oldValue, + bubbles: false + }, []); + }); + } + }, + get: function (el, attrName) { + attrName = attrName.toLowerCase(); + var prop = attr.map[attrName]; + if (typeof prop === 'string' && el[prop]) { + return el[prop]; + } + return el.getAttribute(attrName); + }, + remove: function (el, attrName) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var setter = attr.map[attrName]; + if (typeof setter === 'function') { + setter(el, undefined); + } + if (setter === true) { + el[attrName] = false; + } else if (typeof setter === 'string') { + el[setter] = ''; + } else { + el.removeAttribute(attrName); + } + if (!attr.MutationObserver && oldValue != null) { + attr.trigger(el, attrName, oldValue); + } + }, + has: function () { + var el = can.global.document && document.createElement('div'); + if (el && el.hasAttribute) { + return function (el, name) { + return el.hasAttribute(name); + }; + } else { + return function (el, name) { + return el.getAttribute(name) !== null; + }; + } + }() + }; + return attr; +}); +/*can@2.2.6#event/event*/ +define('can/event/event', ['can/util/can'], function (can) { + can.addEvent = function (event, handler) { + var allEvents = this.__bindEvents || (this.__bindEvents = {}), eventList = allEvents[event] || (allEvents[event] = []); + eventList.push({ + handler: handler, + name: event + }); + return this; + }; + can.listenTo = function (other, event, handler) { + var idedEvents = this.__listenToEvents; + if (!idedEvents) { + idedEvents = this.__listenToEvents = {}; + } + var otherId = can.cid(other); + var othersEvents = idedEvents[otherId]; + if (!othersEvents) { + othersEvents = idedEvents[otherId] = { + obj: other, + events: {} + }; + } + var eventsEvents = othersEvents.events[event]; + if (!eventsEvents) { + eventsEvents = othersEvents.events[event] = []; + } + eventsEvents.push(handler); + can.bind.call(other, event, handler); + }; + can.stopListening = function (other, event, handler) { + var idedEvents = this.__listenToEvents, iterIdedEvents = idedEvents, i = 0; + if (!idedEvents) { + return this; + } + if (other) { + var othercid = can.cid(other); + (iterIdedEvents = {})[othercid] = idedEvents[othercid]; + if (!idedEvents[othercid]) { + return this; + } + } + for (var cid in iterIdedEvents) { + var othersEvents = iterIdedEvents[cid], eventsEvents; + other = idedEvents[cid].obj; + if (!event) { + eventsEvents = othersEvents.events; + } else { + (eventsEvents = {})[event] = othersEvents.events[event]; + } + for (var eventName in eventsEvents) { + var handlers = eventsEvents[eventName] || []; + i = 0; + while (i < handlers.length) { + if (handler && handler === handlers[i] || !handler) { + can.unbind.call(other, eventName, handlers[i]); + handlers.splice(i, 1); + } else { + i++; + } + } + if (!handlers.length) { + delete othersEvents.events[eventName]; + } + } + if (can.isEmptyObject(othersEvents.events)) { + delete idedEvents[cid]; + } + } + return this; + }; + can.removeEvent = function (event, fn, __validate) { + if (!this.__bindEvents) { + return this; + } + var events = this.__bindEvents[event] || [], i = 0, ev, isFunction = typeof fn === 'function'; + while (i < events.length) { + ev = events[i]; + if (__validate ? __validate(ev, event, fn) : isFunction && ev.handler === fn || !isFunction && (ev.cid === fn || !fn)) { + events.splice(i, 1); + } else { + i++; + } + } + return this; + }; + can.dispatch = function (event, args) { + var events = this.__bindEvents; + if (!events) { + return; + } + if (typeof event === 'string') { + event = { type: event }; + } + var eventName = event.type, handlers = (events[eventName] || []).slice(0), passed = [event]; + if (args) { + passed.push.apply(passed, args); + } + for (var i = 0, len = handlers.length; i < len; i++) { + handlers[i].handler.apply(this, passed); + } + return event; + }; + can.one = function (event, handler) { + var one = function () { + can.unbind.call(this, event, one); + return handler.apply(this, arguments); + }; + can.bind.call(this, event, one); + return this; + }; + can.event = { + on: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.on.call(this); + } else { + return can.addEvent.apply(this, arguments); + } + }, + off: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.off.call(this); + } else { + return can.removeEvent.apply(this, arguments); + } + }, + bind: can.addEvent, + unbind: can.removeEvent, + delegate: function (selector, event, handler) { + return can.addEvent.call(this, event, handler); + }, + undelegate: function (selector, event, handler) { + return can.removeEvent.call(this, event, handler); + }, + trigger: can.dispatch, + one: can.one, + addEvent: can.addEvent, + removeEvent: can.removeEvent, + listenTo: can.listenTo, + stopListening: can.stopListening, + dispatch: can.dispatch + }; + return can.event; +}); +/*can@2.2.6#util/array/each*/ +define('can/util/array/each', ['can/util/can'], function (can) { + var isArrayLike = function (obj) { + var length = 'length' in obj && obj.length; + return typeof arr !== 'function' && (length === 0 || typeof length === 'number' && length > 0 && length - 1 in obj); + }; + can.each = function (elements, callback, context) { + var i = 0, key, len, item; + if (elements) { + if (isArrayLike(elements)) { + if (can.List && elements instanceof can.List) { + for (len = elements.attr('length'); i < len; i++) { + item = elements.attr(i); + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } else { + for (len = elements.length; i < len; i++) { + item = elements[i]; + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } + } else if (typeof elements === 'object') { + if (can.Map && elements instanceof can.Map || elements === can.route) { + var keys = can.Map.keys(elements); + for (i = 0, len = keys.length; i < len; i++) { + key = keys[i]; + item = elements.attr(key); + if (callback.call(context || item, item, key, elements) === false) { + break; + } + } + } else { + for (key in elements) { + if (elements.hasOwnProperty(key) && callback.call(context || elements[key], elements[key], key, elements) === false) { + break; + } + } + } + } + } + return elements; + }; + return can; +}); +/*can@2.2.6#util/inserted/inserted*/ +define('can/util/inserted/inserted', ['can/util/can'], function (can) { + can.inserted = function (elems) { + elems = can.makeArray(elems); + var inDocument = false, doc = can.$(document.contains ? document : document.body), children; + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + if (!inDocument) { + if (elem.getElementsByTagName) { + if (can.has(doc, elem).length) { + inDocument = true; + } else { + return; + } + } else { + continue; + } + } + if (inDocument && elem.getElementsByTagName) { + children = can.makeArray(elem.getElementsByTagName('*')); + can.trigger(elem, 'inserted', [], false); + for (var j = 0, child; (child = children[j]) !== undefined; j++) { + can.trigger(child, 'inserted', [], false); + } + } + } + }; + can.appendChild = function (el, child) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.appendChild(child); + can.inserted(children); + }; + can.insertBefore = function (el, child, ref) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.insertBefore(child, ref); + can.inserted(children); + }; +}); +/*can@2.2.6#util/jquery/jquery*/ +define('can/util/jquery/jquery', [ + 'dist/jquery', + 'can/util/can', + 'can/util/attr/attr', + 'can/event/event', + 'can/util/array/each', + 'can/util/inserted/inserted' +], function ($, can, attr, event) { + var isBindableElement = function (node) { + return node.nodeName && (node.nodeType === 1 || node.nodeType === 9) || node == window; + }; + $ = $ || window.jQuery; + $.extend(can, $, { + trigger: function (obj, event, args, bubbles) { + if (isBindableElement(obj)) { + $.event.trigger(event, args, obj, !bubbles); + } else if (obj.trigger) { + obj.trigger(event, args); + } else { + if (typeof event === 'string') { + event = { type: event }; + } + event.target = event.target || obj; + if (args) { + if (args.length && typeof args === 'string') { + args = [args]; + } else if (!args.length) { + args = [args]; + } + } + if (!args) { + args = []; + } + can.dispatch.call(obj, event, args); + } + }, + event: can.event, + addEvent: can.addEvent, + removeEvent: can.removeEvent, + buildFragment: function (elems, context) { + var ret; + elems = [elems]; + context = context || document; + context = !context.nodeType && context[0] || context; + context = context.ownerDocument || context; + ret = $.buildFragment(elems, context); + return ret.cacheable ? $.clone(ret.fragment) : ret.fragment || ret; + }, + $: $, + each: can.each, + bind: function (ev, cb) { + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (isBindableElement(this)) { + $.event.add(this, ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + return this; + }, + unbind: function (ev, cb) { + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (isBindableElement(this)) { + $.event.remove(this, ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + return this; + }, + delegate: function (selector, ev, cb) { + if (this.delegate) { + this.delegate(selector, ev, cb); + } else if (isBindableElement(this)) { + $(this).delegate(selector, ev, cb); + } else { + can.bind.call(this, ev, cb); + } + return this; + }, + undelegate: function (selector, ev, cb) { + if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else if (isBindableElement(this)) { + $(this).undelegate(selector, ev, cb); + } else { + can.unbind.call(this, ev, cb); + } + return this; + }, + proxy: can.proxy, + attr: attr + }); + can.on = can.bind; + can.off = can.unbind; + $.each([ + 'append', + 'filter', + 'addClass', + 'remove', + 'data', + 'get', + 'has' + ], function (i, name) { + can[name] = function (wrapped) { + return wrapped[name].apply(wrapped, can.makeArray(arguments).slice(1)); + }; + }); + var oldClean = $.cleanData; + $.cleanData = function (elems) { + $.each(elems, function (i, elem) { + if (elem) { + can.trigger(elem, 'removed', [], false); + } + }); + oldClean(elems); + }; + var oldDomManip = $.fn.domManip, cbIndex; + $.fn.domManip = function (args, cb1, cb2) { + for (var i = 1; i < arguments.length; i++) { + if (typeof arguments[i] === 'function') { + cbIndex = i; + break; + } + } + return oldDomManip.apply(this, arguments); + }; + $(document.createElement('div')).append(document.createElement('div')); + $.fn.domManip = cbIndex === 2 ? function (args, table, callback) { + return oldDomManip.call(this, args, table, function (elem) { + var elems; + if (elem.nodeType === 11) { + elems = can.makeArray(elem.childNodes); + } + var ret = callback.apply(this, arguments); + can.inserted(elems ? elems : [elem]); + return ret; + }); + } : function (args, callback) { + return oldDomManip.call(this, args, function (elem) { + var elems; + if (elem.nodeType === 11) { + elems = can.makeArray(elem.childNodes); + } + var ret = callback.apply(this, arguments); + can.inserted(elems ? elems : [elem]); + return ret; + }); + }; + if (!can.attr.MutationObserver) { + var oldAttr = $.attr; + $.attr = function (el, attrName) { + var oldValue, newValue; + if (arguments.length >= 3) { + oldValue = oldAttr.call(this, el, attrName); + } + var res = oldAttr.apply(this, arguments); + if (arguments.length >= 3) { + newValue = oldAttr.call(this, el, attrName); + } + if (newValue !== oldValue) { + can.attr.trigger(el, attrName, oldValue); + } + return res; + }; + var oldRemove = $.removeAttr; + $.removeAttr = function (el, attrName) { + var oldValue = oldAttr.call(this, el, attrName), res = oldRemove.apply(this, arguments); + if (oldValue != null) { + can.attr.trigger(el, attrName, oldValue); + } + return res; + }; + $.event.special.attributes = { + setup: function () { + can.data(can.$(this), 'canHasAttributesBindings', true); + }, + teardown: function () { + $.removeData(this, 'canHasAttributesBindings'); + } + }; + } else { + $.event.special.attributes = { + setup: function () { + var self = this; + var observer = new can.attr.MutationObserver(function (mutations) { + mutations.forEach(function (mutation) { + var copy = can.simpleExtend({}, mutation); + can.trigger(self, copy, []); + }); + }); + observer.observe(this, { + attributes: true, + attributeOldValue: true + }); + can.data(can.$(this), 'canAttributesObserver', observer); + }, + teardown: function () { + can.data(can.$(this), 'canAttributesObserver').disconnect(); + $.removeData(this, 'canAttributesObserver'); + } + }; + } + (function () { + var text = '<-\n>', frag = can.buildFragment(text, document); + if (text !== frag.childNodes[0].nodeValue) { + var oldBuildFragment = can.buildFragment; + can.buildFragment = function (content, context) { + var res = oldBuildFragment(content, context); + if (res.childNodes.length === 1 && res.childNodes[0].nodeType === 3) { + res.childNodes[0].nodeValue = content; + } + return res; + }; + } + }()); + $.event.special.inserted = {}; + $.event.special.removed = {}; + return can; +}); +/*can@2.2.6#util/util*/ +define('can/util/util', ['can/util/jquery/jquery'], function (can) { + return can; +}); +/*can@2.2.6#view/view*/ +define('can/view/view', ['can/util/util'], function (can) { + var isFunction = can.isFunction, makeArray = can.makeArray, hookupId = 1; + var makeRenderer = function (textRenderer) { + var renderer = function () { + return $view.frag(textRenderer.apply(this, arguments)); + }; + renderer.render = function () { + return textRenderer.apply(textRenderer, arguments); + }; + return renderer; + }; + var checkText = function (text, url) { + if (!text.length) { + throw 'can.view: No template or empty template:' + url; + } + }; + var getRenderer = function (obj, async) { + if (isFunction(obj)) { + var def = can.Deferred(); + return def.resolve(obj); + } + var url = typeof obj === 'string' ? obj : obj.url, suffix = obj.engine && '.' + obj.engine || url.match(/\.[\w\d]+$/), type, el, id; + if (url.match(/^#/)) { + url = url.substr(1); + } + if (el = document.getElementById(url)) { + suffix = '.' + el.type.match(/\/(x\-)?(.+)/)[2]; + } + if (!suffix && !$view.cached[url]) { + url += suffix = $view.ext; + } + if (can.isArray(suffix)) { + suffix = suffix[0]; + } + id = $view.toId(url); + if (url.match(/^\/\//)) { + url = url.substr(2); + url = !window.steal ? url : steal.config().root.mapJoin('' + steal.id(url)); + } + if (window.require) { + if (require.toUrl) { + url = require.toUrl(url); + } + } + type = $view.types[suffix]; + if ($view.cached[id]) { + return $view.cached[id]; + } else if (el) { + return $view.registerView(id, el.innerHTML, type); + } else { + var d = new can.Deferred(); + can.ajax({ + async: async, + url: url, + dataType: 'text', + error: function (jqXHR) { + checkText('', url); + d.reject(jqXHR); + }, + success: function (text) { + checkText(text, url); + $view.registerView(id, text, type, d); + } + }); + return d; + } + }; + var getDeferreds = function (data) { + var deferreds = []; + if (can.isDeferred(data)) { + return [data]; + } else { + for (var prop in data) { + if (can.isDeferred(data[prop])) { + deferreds.push(data[prop]); + } + } + } + return deferreds; + }; + var usefulPart = function (resolved) { + return can.isArray(resolved) && resolved[1] === 'success' ? resolved[0] : resolved; + }; + var $view = can.view = can.template = function (view, data, helpers, callback) { + if (isFunction(helpers)) { + callback = helpers; + helpers = undefined; + } + return $view.renderAs('fragment', view, data, helpers, callback); + }; + can.extend($view, { + frag: function (result, parentNode) { + return $view.hookup($view.fragment(result), parentNode); + }, + fragment: function (result) { + if (typeof result !== 'string' && result.nodeType === 11) { + return result; + } + var frag = can.buildFragment(result, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + }, + toId: function (src) { + return can.map(src.toString().split(/\/|\./g), function (part) { + if (part) { + return part; + } + }).join('_'); + }, + toStr: function (txt) { + return txt == null ? '' : '' + txt; + }, + hookup: function (fragment, parentNode) { + var hookupEls = [], id, func; + can.each(fragment.childNodes ? can.makeArray(fragment.childNodes) : fragment, function (node) { + if (node.nodeType === 1) { + hookupEls.push(node); + hookupEls.push.apply(hookupEls, can.makeArray(node.getElementsByTagName('*'))); + } + }); + can.each(hookupEls, function (el) { + if (el.getAttribute && (id = el.getAttribute('data-view-id')) && (func = $view.hookups[id])) { + func(el, parentNode, id); + delete $view.hookups[id]; + el.removeAttribute('data-view-id'); + } + }); + return fragment; + }, + hookups: {}, + hook: function (cb) { + $view.hookups[++hookupId] = cb; + return ' data-view-id=\'' + hookupId + '\''; + }, + cached: {}, + cachedRenderers: {}, + cache: true, + register: function (info) { + this.types['.' + info.suffix] = info; + can[info.suffix] = $view[info.suffix] = function (id, text) { + var renderer, renderFunc; + if (!text) { + renderFunc = function () { + if (!renderer) { + if (info.fragRenderer) { + renderer = info.fragRenderer(null, id); + } else { + renderer = makeRenderer(info.renderer(null, id)); + } + } + return renderer.apply(this, arguments); + }; + renderFunc.render = function () { + var textRenderer = info.renderer(null, id); + return textRenderer.apply(textRenderer, arguments); + }; + return renderFunc; + } + var registeredRenderer = function () { + if (!renderer) { + if (info.fragRenderer) { + renderer = info.fragRenderer(id, text); + } else { + renderer = info.renderer(id, text); + } + } + return renderer.apply(this, arguments); + }; + if (info.fragRenderer) { + return $view.preload(id, registeredRenderer); + } else { + return $view.preloadStringRenderer(id, registeredRenderer); + } + }; + }, + types: {}, + ext: '.ejs', + registerScript: function (type, id, src) { + return 'can.view.preloadStringRenderer(\'' + id + '\',' + $view.types['.' + type].script(id, src) + ');'; + }, + preload: function (id, renderer) { + var def = $view.cached[id] = new can.Deferred().resolve(function (data, helpers) { + return renderer.call(data, data, helpers); + }); + def.__view_id = id; + $view.cachedRenderers[id] = renderer; + return renderer; + }, + preloadStringRenderer: function (id, stringRenderer) { + return this.preload(id, makeRenderer(stringRenderer)); + }, + render: function (view, data, helpers, callback) { + return can.view.renderAs('string', view, data, helpers, callback); + }, + renderTo: function (format, renderer, data, helpers) { + return (format === 'string' && renderer.render ? renderer.render : renderer)(data, helpers); + }, + renderAs: function (format, view, data, helpers, callback) { + if (isFunction(helpers)) { + callback = helpers; + helpers = undefined; + } + var deferreds = getDeferreds(data); + var reading, deferred, dataCopy, async, response; + if (deferreds.length) { + deferred = new can.Deferred(); + dataCopy = can.extend({}, data); + deferreds.push(getRenderer(view, true)); + can.when.apply(can, deferreds).then(function (resolved) { + var objs = makeArray(arguments), renderer = objs.pop(), result; + if (can.isDeferred(data)) { + dataCopy = usefulPart(resolved); + } else { + for (var prop in data) { + if (can.isDeferred(data[prop])) { + dataCopy[prop] = usefulPart(objs.shift()); + } + } + } + result = can.view.renderTo(format, renderer, dataCopy, helpers); + deferred.resolve(result, dataCopy); + if (callback) { + callback(result, dataCopy); + } + }, function () { + deferred.reject.apply(deferred, arguments); + }); + return deferred; + } else { + reading = can.__clearReading(); + async = isFunction(callback); + deferred = getRenderer(view, async); + if (reading) { + can.__setReading(reading); + } + if (async) { + response = deferred; + deferred.then(function (renderer) { + callback(data ? can.view.renderTo(format, renderer, data, helpers) : renderer); + }); + } else { + if (deferred.state() === 'resolved' && deferred.__view_id) { + var currentRenderer = $view.cachedRenderers[deferred.__view_id]; + return data ? can.view.renderTo(format, currentRenderer, data, helpers) : currentRenderer; + } else { + deferred.then(function (renderer) { + response = data ? can.view.renderTo(format, renderer, data, helpers) : renderer; + }); + } + } + return response; + } + }, + registerView: function (id, text, type, def) { + var info = typeof type === 'object' ? type : $view.types[type || $view.ext], renderer; + if (info.fragRenderer) { + renderer = info.fragRenderer(id, text); + } else { + renderer = makeRenderer(info.renderer(id, text)); + } + def = def || new can.Deferred(); + if ($view.cache) { + $view.cached[id] = def; + def.__view_id = id; + $view.cachedRenderers[id] = renderer; + } + return def.resolve(renderer); + } + }); + return can; +}); +/*can@2.2.6#view/callbacks/callbacks*/ +define('can/view/callbacks/callbacks', [ + 'can/util/util', + 'can/view/view' +], function (can) { + var attr = can.view.attr = function (attributeName, attrHandler) { + if (attrHandler) { + if (typeof attributeName === 'string') { + attributes[attributeName] = attrHandler; + } else { + regExpAttributes.push({ + match: attributeName, + handler: attrHandler + }); + } + } else { + var cb = attributes[attributeName]; + if (!cb) { + for (var i = 0, len = regExpAttributes.length; i < len; i++) { + var attrMatcher = regExpAttributes[i]; + if (attrMatcher.match.test(attributeName)) { + cb = attrMatcher.handler; + break; + } + } + } + return cb; + } + }; + var attributes = {}, regExpAttributes = [], automaticCustomElementCharacters = /[-\:]/; + var tag = can.view.tag = function (tagName, tagHandler) { + if (tagHandler) { + if (can.global.html5) { + can.global.html5.elements += ' ' + tagName; + can.global.html5.shivDocument(); + } + tags[tagName.toLowerCase()] = tagHandler; + } else { + var cb = tags[tagName.toLowerCase()]; + if (!cb && automaticCustomElementCharacters.test(tagName)) { + cb = function () { + }; + } + return cb; + } + }; + var tags = {}; + can.view.callbacks = { + _tags: tags, + _attributes: attributes, + _regExpAttributes: regExpAttributes, + tag: tag, + attr: attr, + tagHandler: function (el, tagName, tagData) { + var helperTagCallback = tagData.options.attr('tags.' + tagName), tagCallback = helperTagCallback || tags[tagName]; + var scope = tagData.scope, res; + if (tagCallback) { + var reads = can.__clearReading(); + res = tagCallback(el, tagData); + can.__setReading(reads); + } else { + res = scope; + } + if (res && tagData.subtemplate) { + if (scope !== res) { + scope = scope.add(res); + } + var result = tagData.subtemplate(scope, tagData.options); + var frag = typeof result === 'string' ? can.view.frag(result) : result; + can.appendChild(el, frag); + } + } + }; + return can.view.callbacks; +}); +/*can@2.2.6#view/elements*/ +define('can/view/elements', [ + 'can/util/util', + 'can/view/view' +], function (can) { + var doc = typeof document !== 'undefined' ? document : null; + var selectsCommentNodes = doc && function () { + return can.$(document.createComment('~')).length === 1; + }(); + var elements = { + tagToContentPropMap: { + option: doc && 'textContent' in document.createElement('option') ? 'textContent' : 'innerText', + textarea: 'value' + }, + attrMap: can.attr.map, + attrReg: /([^\s=]+)[\s]*=[\s]*/, + defaultValue: can.attr.defaultValue, + tagMap: { + '': 'span', + colgroup: 'col', + table: 'tbody', + tr: 'td', + ol: 'li', + ul: 'li', + tbody: 'tr', + thead: 'tr', + tfoot: 'tr', + select: 'option', + optgroup: 'option' + }, + reverseTagMap: { + col: 'colgroup', + tr: 'tbody', + option: 'select', + td: 'tr', + th: 'tr', + li: 'ul' + }, + getParentNode: function (el, defaultParentNode) { + return defaultParentNode && el.parentNode.nodeType === 11 ? defaultParentNode : el.parentNode; + }, + setAttr: can.attr.set, + getAttr: can.attr.get, + removeAttr: can.attr.remove, + contentText: function (text) { + if (typeof text === 'string') { + return text; + } + if (!text && text !== 0) { + return ''; + } + return '' + text; + }, + after: function (oldElements, newFrag) { + var last = oldElements[oldElements.length - 1]; + if (last.nextSibling) { + can.insertBefore(last.parentNode, newFrag, last.nextSibling); + } else { + can.appendChild(last.parentNode, newFrag); + } + }, + replace: function (oldElements, newFrag) { + elements.after(oldElements, newFrag); + if (can.remove(can.$(oldElements)).length < oldElements.length && !selectsCommentNodes) { + can.each(oldElements, function (el) { + if (el.nodeType === 8) { + el.parentNode.removeChild(el); + } + }); + } + } + }; + can.view.elements = elements; + return elements; +}); +/*can@2.2.6#util/string/string*/ +define('can/util/string/string', ['can/util/util'], function (can) { + var strUndHash = /_|-/, strColons = /\=\=/, strWords = /([A-Z]+)([A-Z][a-z])/g, strLowUp = /([a-z\d])([A-Z])/g, strDash = /([a-z\d])([A-Z])/g, strReplacer = /\{([^\}]+)\}/g, strQuote = /"/g, strSingleQuote = /'/g, strHyphenMatch = /-+(.)?/g, strCamelMatch = /[a-z][A-Z]/g, getNext = function (obj, prop, add) { + var result = obj[prop]; + if (result === undefined && add === true) { + result = obj[prop] = {}; + } + return result; + }, isContainer = function (current) { + return /^f|^o/.test(typeof current); + }, convertBadValues = function (content) { + var isInvalid = content === null || content === undefined || isNaN(content) && '' + content === 'NaN'; + return '' + (isInvalid ? '' : content); + }; + can.extend(can, { + esc: function (content) { + return convertBadValues(content).replace(/&/g, '&').replace(//g, '>').replace(strQuote, '"').replace(strSingleQuote, '''); + }, + getObject: function (name, roots, add) { + var parts = name ? name.split('.') : [], length = parts.length, current, r = 0, i, container, rootsLength; + roots = can.isArray(roots) ? roots : [roots || window]; + rootsLength = roots.length; + if (!length) { + return roots[0]; + } + for (r; r < rootsLength; r++) { + current = roots[r]; + container = undefined; + for (i = 0; i < length && isContainer(current); i++) { + container = current; + current = getNext(container, parts[i]); + } + if (container !== undefined && current !== undefined) { + break; + } + } + if (add === false && current !== undefined) { + delete container[parts[i - 1]]; + } + if (add === true && current === undefined) { + current = roots[0]; + for (i = 0; i < length && isContainer(current); i++) { + current = getNext(current, parts[i], true); + } + } + return current; + }, + capitalize: function (s, cache) { + return s.charAt(0).toUpperCase() + s.slice(1); + }, + camelize: function (str) { + return convertBadValues(str).replace(strHyphenMatch, function (match, chr) { + return chr ? chr.toUpperCase() : ''; + }); + }, + hyphenate: function (str) { + return convertBadValues(str).replace(strCamelMatch, function (str, offset) { + return str.charAt(0) + '-' + str.charAt(1).toLowerCase(); + }); + }, + underscore: function (s) { + return s.replace(strColons, '/').replace(strWords, '$1_$2').replace(strLowUp, '$1_$2').replace(strDash, '_').toLowerCase(); + }, + sub: function (str, data, remove) { + var obs = []; + str = str || ''; + obs.push(str.replace(strReplacer, function (whole, inside) { + var ob = can.getObject(inside, data, remove === true ? false : undefined); + if (ob === undefined || ob === null) { + obs = null; + return ''; + } + if (isContainer(ob) && obs) { + obs.push(ob); + return ''; + } + return '' + ob; + })); + return obs === null ? obs : obs.length <= 1 ? obs[0] : obs; + }, + replacer: strReplacer, + undHash: strUndHash + }); + return can; +}); +/*can@2.2.6#construct/construct*/ +define('can/construct/construct', ['can/util/string/string'], function (can) { + var initializing = 0; + var canGetDescriptor; + try { + Object.getOwnPropertyDescriptor({}); + canGetDescriptor = true; + } catch (e) { + canGetDescriptor = false; + } + var getDescriptor = function (newProps, name) { + var descriptor = Object.getOwnPropertyDescriptor(newProps, name); + if (descriptor && (descriptor.get || descriptor.set)) { + return descriptor; + } + return null; + }, inheritGetterSetter = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + var descriptor; + for (var name in newProps) { + if (descriptor = getDescriptor(newProps, name)) { + this._defineProperty(addTo, oldProps, name, descriptor); + } else { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + } + }, simpleInherit = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + for (var name in newProps) { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + }; + can.Construct = function () { + if (arguments.length) { + return can.Construct.extend.apply(can.Construct, arguments); + } + }; + can.extend(can.Construct, { + constructorExtends: true, + newInstance: function () { + var inst = this.instance(), args; + if (inst.setup) { + args = inst.setup.apply(inst, arguments); + } + if (inst.init) { + inst.init.apply(inst, args || arguments); + } + return inst; + }, + _inherit: canGetDescriptor ? inheritGetterSetter : simpleInherit, + _defineProperty: function (what, oldProps, propName, descriptor) { + Object.defineProperty(what, propName, descriptor); + }, + _overwrite: function (what, oldProps, propName, val) { + what[propName] = val; + }, + setup: function (base, fullName) { + this.defaults = can.extend(true, {}, base.defaults, this.defaults); + }, + instance: function () { + initializing = 1; + var inst = new this(); + initializing = 0; + return inst; + }, + extend: function (name, staticProperties, instanceProperties) { + var fullName = name, klass = staticProperties, proto = instanceProperties; + if (typeof fullName !== 'string') { + proto = klass; + klass = fullName; + fullName = null; + } + if (!proto) { + proto = klass; + klass = null; + } + proto = proto || {}; + var _super_class = this, _super = this.prototype, Constructor, parts, current, _fullName, _shortName, propName, shortName, namespace, prototype; + prototype = this.instance(); + can.Construct._inherit(proto, _super, prototype); + if (fullName) { + parts = fullName.split('.'); + shortName = parts.pop(); + } + if (typeof constructorName === 'undefined') { + Constructor = function () { + return init.apply(this, arguments); + }; + } + function init() { + if (!initializing) { + return this.constructor !== Constructor && arguments.length && Constructor.constructorExtends ? Constructor.extend.apply(Constructor, arguments) : Constructor.newInstance.apply(Constructor, arguments); + } + } + for (propName in _super_class) { + if (_super_class.hasOwnProperty(propName)) { + Constructor[propName] = _super_class[propName]; + } + } + can.Construct._inherit(klass, _super_class, Constructor); + if (fullName) { + current = can.getObject(parts.join('.'), window, true); + namespace = current; + _fullName = can.underscore(fullName.replace(/\./g, '_')); + _shortName = can.underscore(shortName); + current[shortName] = Constructor; + } + can.extend(Constructor, { + constructor: Constructor, + prototype: prototype, + namespace: namespace, + _shortName: _shortName, + fullName: fullName, + _fullName: _fullName + }); + if (shortName !== undefined) { + Constructor.shortName = shortName; + } + Constructor.prototype.constructor = Constructor; + var t = [_super_class].concat(can.makeArray(arguments)), args = Constructor.setup.apply(Constructor, t); + if (Constructor.init) { + Constructor.init.apply(Constructor, args || t); + } + return Constructor; + } + }); + can.Construct.prototype.setup = function () { + }; + can.Construct.prototype.init = function () { + }; + return can.Construct; +}); +/*can@2.2.6#control/control*/ +define('can/control/control', [ + 'can/util/util', + 'can/construct/construct' +], function (can) { + var bind = function (el, ev, callback) { + can.bind.call(el, ev, callback); + return function () { + can.unbind.call(el, ev, callback); + }; + }, isFunction = can.isFunction, extend = can.extend, each = can.each, slice = [].slice, paramReplacer = /\{([^\}]+)\}/g, special = can.getObject('$.event.special', [can]) || {}, delegate = function (el, selector, ev, callback) { + can.delegate.call(el, selector, ev, callback); + return function () { + can.undelegate.call(el, selector, ev, callback); + }; + }, binder = function (el, ev, callback, selector) { + return selector ? delegate(el, can.trim(selector), ev, callback) : bind(el, ev, callback); + }, basicProcessor; + var Control = can.Control = can.Construct({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Control) { + var control = this, funcName; + control.actions = {}; + for (funcName in control.prototype) { + if (control._isAction(funcName)) { + control.actions[funcName] = control._action(funcName); + } + } + } + }, + _shifter: function (context, name) { + var method = typeof name === 'string' ? context[name] : name; + if (!isFunction(method)) { + method = context[method]; + } + return function () { + context.called = name; + return method.apply(context, [this.nodeName ? can.$(this) : this].concat(slice.call(arguments, 0))); + }; + }, + _isAction: function (methodName) { + var val = this.prototype[methodName], type = typeof val; + return methodName !== 'constructor' && (type === 'function' || type === 'string' && isFunction(this.prototype[val])) && !!(special[methodName] || processors[methodName] || /[^\w]/.test(methodName)); + }, + _action: function (methodName, options) { + paramReplacer.lastIndex = 0; + if (options || !paramReplacer.test(methodName)) { + var convertedName = options ? can.sub(methodName, this._lookup(options)) : methodName; + if (!convertedName) { + return null; + } + var arr = can.isArray(convertedName), name = arr ? convertedName[1] : convertedName, parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: processors[event] || basicProcessor, + parts: [ + name, + parts.join(' '), + event + ], + delegate: arr ? convertedName[0] : undefined + }; + } + }, + _lookup: function (options) { + return [ + options, + window + ]; + }, + processors: {}, + defaults: {} + }, { + setup: function (element, options) { + var cls = this.constructor, pluginname = cls.pluginName || cls._fullName, arr; + this.element = can.$(element); + if (pluginname && pluginname !== 'can_control') { + this.element.addClass(pluginname); + } + arr = can.data(this.element, 'controls'); + if (!arr) { + arr = []; + can.data(this.element, 'controls', arr); + } + arr.push(this); + this.options = extend({}, cls.defaults, options); + this.on(); + return [ + this.element, + this.options + ]; + }, + on: function (el, selector, eventName, func) { + if (!el) { + this.off(); + var cls = this.constructor, bindings = this._bindings, actions = cls.actions, element = this.element, destroyCB = can.Control._shifter(this, 'destroy'), funcName, ready; + for (funcName in actions) { + if (actions.hasOwnProperty(funcName)) { + ready = actions[funcName] || cls._action(funcName, this.options, this); + if (ready) { + bindings.control[funcName] = ready.processor(ready.delegate || element, ready.parts[2], ready.parts[1], funcName, this); + } + } + } + can.bind.call(element, 'removed', destroyCB); + bindings.user.push(function (el) { + can.unbind.call(el, 'removed', destroyCB); + }); + return bindings.user.length; + } + if (typeof el === 'string') { + func = eventName; + eventName = selector; + selector = el; + el = this.element; + } + if (func === undefined) { + func = eventName; + eventName = selector; + selector = null; + } + if (typeof func === 'string') { + func = can.Control._shifter(this, func); + } + this._bindings.user.push(binder(el, eventName, func, selector)); + return this._bindings.user.length; + }, + off: function () { + var el = this.element[0], bindings = this._bindings; + if (bindings) { + each(bindings.user || [], function (value) { + value(el); + }); + each(bindings.control || {}, function (value) { + value(el); + }); + } + this._bindings = { + user: [], + control: {} + }; + }, + destroy: function () { + if (this.element === null) { + return; + } + var Class = this.constructor, pluginName = Class.pluginName || Class._fullName, controls; + this.off(); + if (pluginName && pluginName !== 'can_control') { + this.element.removeClass(pluginName); + } + controls = can.data(this.element, 'controls'); + controls.splice(can.inArray(this, controls), 1); + can.trigger(this, 'destroyed'); + this.element = null; + } + }); + var processors = can.Control.processors; + basicProcessor = function (el, event, selector, methodName, control) { + return binder(el, event, can.Control._shifter(control, methodName), selector); + }; + each([ + 'change', + 'click', + 'contextmenu', + 'dblclick', + 'keydown', + 'keyup', + 'keypress', + 'mousedown', + 'mousemove', + 'mouseout', + 'mouseover', + 'mouseup', + 'reset', + 'resize', + 'scroll', + 'select', + 'submit', + 'focusin', + 'focusout', + 'mouseenter', + 'mouseleave', + 'touchstart', + 'touchmove', + 'touchcancel', + 'touchend', + 'touchleave', + 'inserted', + 'removed' + ], function (v) { + processors[v] = basicProcessor; + }); + return Control; +}); +/*can@2.2.6#util/bind/bind*/ +define('can/util/bind/bind', ['can/util/util'], function (can) { + can.bindAndSetup = function () { + can.addEvent.apply(this, arguments); + if (!this._init) { + if (!this._bindings) { + this._bindings = 1; + if (this._bindsetup) { + this._bindsetup(); + } + } else { + this._bindings++; + } + } + return this; + }; + can.unbindAndTeardown = function (event, handler) { + var handlers = this.__bindEvents[event] || []; + var handlerCount = handlers.length; + can.removeEvent.apply(this, arguments); + if (this._bindings === null) { + this._bindings = 0; + } else { + this._bindings = this._bindings - (handlerCount - handlers.length); + } + if (!this._bindings && this._bindteardown) { + this._bindteardown(); + } + return this; + }; + return can; +}); +/*can@2.2.6#map/bubble*/ +define('can/map/bubble', ['can/util/util'], function (can) { + var bubble = can.bubble = { + event: function (map, boundEventName) { + return map.constructor._bubbleRule(boundEventName, map); + }, + childrenOf: function (parentMap, eventName) { + parentMap._each(function (child, prop) { + if (child && child.bind) { + bubble.toParent(child, parentMap, prop, eventName); + } + }); + }, + teardownChildrenFrom: function (parentMap, eventName) { + parentMap._each(function (child) { + bubble.teardownFromParent(parentMap, child, eventName); + }); + }, + toParent: function (child, parent, prop, eventName) { + can.listenTo.call(parent, child, eventName, function () { + var args = can.makeArray(arguments), ev = args.shift(); + args[0] = (can.List && parent instanceof can.List ? parent.indexOf(child) : prop) + (args[0] ? '.' + args[0] : ''); + ev.triggeredNS = ev.triggeredNS || {}; + if (ev.triggeredNS[parent._cid]) { + return; + } + ev.triggeredNS[parent._cid] = true; + can.trigger(parent, ev, args); + }); + }, + teardownFromParent: function (parent, child, eventName) { + if (child && child.unbind) { + can.stopListening.call(parent, child, eventName); + } + }, + isBubbling: function (parent, eventName) { + return parent._bubbleBindings && parent._bubbleBindings[eventName]; + }, + bind: function (parent, eventName) { + if (!parent._init) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + if (!parent._bubbleBindings) { + parent._bubbleBindings = {}; + } + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (!parent._bubbleBindings[bubbleEvent]) { + parent._bubbleBindings[bubbleEvent] = 1; + bubble.childrenOf(parent, bubbleEvent); + } else { + parent._bubbleBindings[bubbleEvent]++; + } + } + } + }, + unbind: function (parent, eventName) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (parent._bubbleBindings) { + parent._bubbleBindings[bubbleEvent]--; + } + if (parent._bubbleBindings && !parent._bubbleBindings[bubbleEvent]) { + delete parent._bubbleBindings[bubbleEvent]; + bubble.teardownChildrenFrom(parent, bubbleEvent); + if (can.isEmptyObject(parent._bubbleBindings)) { + delete parent._bubbleBindings; + } + } + } + }, + add: function (parent, child, prop) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + bubble.toParent(child, parent, prop, eventName); + } + } + } + }, + removeMany: function (parent, children) { + for (var i = 0, len = children.length; i < len; i++) { + bubble.remove(parent, children[i]); + } + }, + remove: function (parent, child) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + } + } + } + }, + set: function (parent, prop, value, current) { + if (can.Map.helpers.isObservable(value)) { + bubble.add(parent, value, prop); + } + if (can.Map.helpers.isObservable(current)) { + bubble.remove(parent, current); + } + return value; + } + }; + return bubble; +}); +/*can@2.2.6#util/batch/batch*/ +define('can/util/batch/batch', ['can/util/can'], function (can) { + var batchNum = 1, transactions = 0, batchEvents = [], stopCallbacks = [], currentBatchEvents = null; + can.batch = { + start: function (batchStopHandler) { + transactions++; + if (batchStopHandler) { + stopCallbacks.push(batchStopHandler); + } + }, + stop: function (force, callStart) { + if (force) { + transactions = 0; + } else { + transactions--; + } + if (transactions === 0) { + if (currentBatchEvents !== null) { + return; + } + currentBatchEvents = batchEvents.slice(0); + var callbacks = stopCallbacks.slice(0), i, len; + batchEvents = []; + stopCallbacks = []; + can.batch.batchNum = batchNum; + batchNum++; + if (callStart) { + can.batch.start(); + } + for (i = 0; i < currentBatchEvents.length; i++) { + can.dispatch.apply(currentBatchEvents[i][0], currentBatchEvents[i][1]); + } + currentBatchEvents = null; + for (i = 0, len = callbacks.length; i < callbacks.length; i++) { + callbacks[i](); + } + can.batch.batchNum = undefined; + } + }, + trigger: function (item, event, args) { + if (!item._init) { + event = typeof event === 'string' ? { type: event } : event; + if (currentBatchEvents) { + currentBatchEvents.push([ + item, + [ + event, + args + ] + ]); + } else if (transactions === 0) { + return can.dispatch.call(item, event, args); + } else { + event.batchNum = batchNum; + batchEvents.push([ + item, + [ + event, + args + ] + ]); + } + } + }, + afterPreviousEvents: function (handler) { + if (currentBatchEvents) { + var obj = {}; + can.bind.call(obj, 'ready', handler); + currentBatchEvents.push([ + obj, + [ + { type: 'ready' }, + [] + ] + ]); + } else { + handler(); + } + } + }; +}); +/*can@2.2.6#map/map*/ +define('can/map/map', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/map/bubble', + 'can/construct/construct', + 'can/util/batch/batch' +], function (can, bind, bubble) { + var madeMap = null; + var teardownMap = function () { + for (var cid in madeMap) { + if (madeMap[cid].added) { + delete madeMap[cid].obj._cid; + } + } + madeMap = null; + }; + var getMapFromObject = function (obj) { + return madeMap && madeMap[obj._cid] && madeMap[obj._cid].instance; + }; + var serializeMap = null; + var Map = can.Map = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Map) { + if (!this.defaults) { + this.defaults = {}; + } + this._computes = []; + for (var prop in this.prototype) { + if (prop !== 'define' && prop !== 'constructor' && (typeof this.prototype[prop] !== 'function' || this.prototype[prop].prototype instanceof can.Construct)) { + this.defaults[prop] = this.prototype[prop]; + } else if (this.prototype[prop].isComputed) { + this._computes.push(prop); + } + } + if (this.helpers.define) { + this.helpers.define(this); + } + } + if (can.List && !(this.prototype instanceof can.List)) { + this.List = Map.List.extend({ Map: this }, {}); + } + }, + _bubble: bubble, + _bubbleRule: function (eventName) { + return eventName === 'change' || eventName.indexOf('.') >= 0 ? ['change'] : []; + }, + _computes: [], + bind: can.bindAndSetup, + on: can.bindAndSetup, + unbind: can.unbindAndTeardown, + off: can.unbindAndTeardown, + id: 'id', + helpers: { + define: null, + attrParts: function (attr, keepKey) { + if (keepKey) { + return [attr]; + } + return typeof attr === 'object' ? attr : ('' + attr).split('.'); + }, + addToMap: function (obj, instance) { + var teardown; + if (!madeMap) { + teardown = teardownMap; + madeMap = {}; + } + var hasCid = obj._cid; + var cid = can.cid(obj); + if (!madeMap[cid]) { + madeMap[cid] = { + obj: obj, + instance: instance, + added: !hasCid + }; + } + return teardown; + }, + isObservable: function (obj) { + return obj instanceof can.Map || obj && obj === can.route; + }, + canMakeObserve: function (obj) { + return obj && !can.isDeferred(obj) && (can.isArray(obj) || can.isPlainObject(obj)); + }, + serialize: function (map, how, where) { + var cid = can.cid(map), firstSerialize = false; + if (!serializeMap) { + firstSerialize = true; + serializeMap = { + attr: {}, + serialize: {} + }; + } + serializeMap[how][cid] = where; + map.each(function (val, name) { + var result, isObservable = Map.helpers.isObservable(val), serialized = isObservable && serializeMap[how][can.cid(val)]; + if (serialized) { + result = serialized; + } else { + if (how === 'serialize') { + result = Map.helpers._serialize(map, name, val); + } else { + result = Map.helpers._getValue(map, name, val, how); + } + } + if (result !== undefined) { + where[name] = result; + } + }); + can.__observe(map, '__keys'); + if (firstSerialize) { + serializeMap = null; + } + return where; + }, + _serialize: function (map, name, val) { + return Map.helpers._getValue(map, name, val, 'serialize'); + }, + _getValue: function (map, name, val, how) { + if (Map.helpers.isObservable(val)) { + return val[how](); + } else { + return val; + } + } + }, + keys: function (map) { + var keys = []; + can.__observe(map, '__keys'); + for (var keyName in map._data) { + keys.push(keyName); + } + return keys; + } + }, { + setup: function (obj) { + if (obj instanceof can.Map) { + obj = obj.serialize(); + } + this._data = {}; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + var defaultValues = this._setupDefaults(obj); + this._setupComputes(defaultValues); + var teardownMapping = obj && can.Map.helpers.addToMap(obj, this); + var data = can.extend(can.extend(true, {}, defaultValues), obj); + this.attr(data); + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + delete this._init; + }, + _setupComputes: function () { + var computes = this.constructor._computes; + for (var i = 0, len = computes.length, prop; i < len; i++) { + prop = computes[i]; + this[prop] = this[prop].clone(this); + this._computedBindings[prop] = { count: 0 }; + } + }, + _setupDefaults: function () { + return this.constructor.defaults || {}; + }, + _bindsetup: function () { + }, + _bindteardown: function () { + }, + _changes: function (ev, attr, how, newVal, oldVal) { + can.batch.trigger(this, { + type: attr, + batchNum: ev.batchNum, + target: ev.target + }, [ + newVal, + oldVal + ]); + }, + _triggerChange: function (attr, how, newVal, oldVal) { + if (bubble.isBubbling(this, 'change')) { + can.batch.trigger(this, { + type: 'change', + target: this + }, [ + attr, + how, + newVal, + oldVal + ]); + } else { + can.batch.trigger(this, attr, [ + newVal, + oldVal + ]); + } + if (how === 'remove' || how === 'add') { + can.batch.trigger(this, { + type: '__keys', + target: this + }); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var prop in data) { + if (data.hasOwnProperty(prop)) { + callback(data[prop], prop); + } + } + }, + attr: function (attr, val) { + var type = typeof attr; + if (type !== 'string' && type !== 'number') { + return this._attrs(attr, val); + } else if (arguments.length === 1) { + return this._get(attr); + } else { + this._set(attr, val); + return this; + } + }, + each: function () { + return can.each.apply(undefined, [this].concat(can.makeArray(arguments))); + }, + removeAttr: function (attr) { + var isList = can.List && this instanceof can.List, parts = can.Map.helpers.attrParts(attr), prop = parts.shift(), current = isList ? this[prop] : this._data[prop]; + if (parts.length && current) { + return current.removeAttr(parts); + } else { + if (typeof attr === 'string' && !!~attr.indexOf('.')) { + prop = attr; + } + this._remove(prop, current); + return current; + } + }, + _remove: function (prop, current) { + if (prop in this._data) { + delete this._data[prop]; + if (!(prop in this.constructor.prototype)) { + delete this[prop]; + } + this._triggerChange(prop, 'remove', undefined, current); + } + }, + _get: function (attr) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'); + if (dotIndex >= 0) { + var value = this.__get(attr); + if (value !== undefined) { + return value; + } + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + can.__observe(this, first); + var current = this.__get(first); + return current && current._get ? current._get(second) : undefined; + } else { + can.__observe(this, attr); + return this.__get(attr); + } + }, + __get: function (attr) { + if (attr) { + if (this._computedBindings[attr]) { + return this[attr](); + } else { + return this._data[attr]; + } + } else { + return this._data; + } + }, + __type: function (value, prop) { + if (!(value instanceof can.Map) && can.Map.helpers.canMakeObserve(value)) { + var cached = getMapFromObject(value); + if (cached) { + return cached; + } + if (can.isArray(value)) { + var List = can.List; + return new List(value); + } else { + var Map = this.constructor.Map || can.Map; + return new Map(value); + } + } + return value; + }, + _set: function (attr, value, keepKey) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'), current; + if (!keepKey && dotIndex >= 0) { + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + current = this._init ? undefined : this.__get(first); + if (Map.helpers.isObservable(current)) { + current._set(second, value); + } else { + throw 'can.Map: Object does not exist'; + } + } else { + if (this.__convert) { + value = this.__convert(attr, value); + } + current = this._init ? undefined : this.__get(attr); + this.__set(attr, this.__type(value, attr), current); + } + }, + __set: function (prop, value, current) { + if (value !== current) { + var changeType = current !== undefined || this.__get().hasOwnProperty(prop) ? 'set' : 'add'; + this.___set(prop, this.constructor._bubble.set(this, prop, value, current)); + if (!this._computedBindings[prop]) { + this._triggerChange(prop, changeType, value, current); + } + if (current) { + this.constructor._bubble.teardownFromParent(this, current); + } + } + }, + ___set: function (prop, val) { + if (this._computedBindings[prop]) { + this[prop](val); + } else { + this._data[prop] = val; + } + if (typeof this.constructor.prototype[prop] !== 'function' && !this._computedBindings[prop]) { + this[prop] = val; + } + }, + bind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (!computedBinding.count) { + computedBinding.count = 1; + var self = this; + computedBinding.handler = function (ev, newVal, oldVal) { + can.batch.trigger(self, { + type: eventName, + batchNum: ev.batchNum, + target: self + }, [ + newVal, + oldVal + ]); + }; + this[eventName].bind('change', computedBinding.handler); + } else { + computedBinding.count++; + } + } + this.constructor._bubble.bind(this, eventName); + return can.bindAndSetup.apply(this, arguments); + }, + unbind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (computedBinding.count === 1) { + computedBinding.count = 0; + this[eventName].unbind('change', computedBinding.handler); + delete computedBinding.handler; + } else { + computedBinding.count--; + } + } + this.constructor._bubble.unbind(this, eventName); + return can.unbindAndTeardown.apply(this, arguments); + }, + serialize: function () { + return can.Map.helpers.serialize(this, 'serialize', {}); + }, + _attrs: function (props, remove) { + if (props === undefined) { + return Map.helpers.serialize(this, 'attr', {}); + } + props = can.simpleExtend({}, props); + var prop, self = this, newVal; + can.batch.start(); + this.each(function (curVal, prop) { + if (prop === '_cid') { + return; + } + newVal = props[prop]; + if (newVal === undefined) { + if (remove) { + self.removeAttr(prop); + } + return; + } + if (self.__convert) { + newVal = self.__convert(prop, newVal); + } + if (Map.helpers.isObservable(newVal)) { + self.__set(prop, self.__type(newVal, prop), curVal); + } else if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + self.__set(prop, self.__type(newVal, prop), curVal); + } + delete props[prop]; + }); + for (prop in props) { + if (prop !== '_cid') { + newVal = props[prop]; + this._set(prop, newVal, true); + } + } + can.batch.stop(); + return this; + }, + compute: function (prop) { + if (can.isFunction(this.constructor.prototype[prop])) { + return can.compute(this[prop], this); + } else { + var reads = prop.split('.'), last = reads.length - 1, options = { args: [] }; + return can.compute(function (newVal) { + if (arguments.length) { + can.compute.read(this, reads.slice(0, last)).value.attr(reads[last], newVal); + } else { + return can.compute.read(this, reads, options).value; + } + }, this); + } + } + }); + Map.prototype.on = Map.prototype.bind; + Map.prototype.off = Map.prototype.unbind; + return Map; +}); +/*can@2.2.6#list/list*/ +define('can/list/list', [ + 'can/util/util', + 'can/map/map', + 'can/map/bubble' +], function (can, Map, bubble) { + var splice = [].splice, spliceRemovesProps = function () { + var obj = { + 0: 'a', + length: 1 + }; + splice.call(obj, 0, 1); + return !obj[0]; + }(); + var list = Map.extend({ Map: Map }, { + setup: function (instances, options) { + this.length = 0; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + this._setupComputes(); + instances = instances || []; + var teardownMapping; + if (can.isDeferred(instances)) { + this.replace(instances); + } else { + teardownMapping = instances.length && can.Map.helpers.addToMap(instances, this); + this.push.apply(this, can.makeArray(instances || [])); + } + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + can.simpleExtend(this, options); + delete this._init; + }, + _triggerChange: function (attr, how, newVal, oldVal) { + Map.prototype._triggerChange.apply(this, arguments); + var index = +attr; + if (!~('' + attr).indexOf('.') && !isNaN(index)) { + if (how === 'add') { + can.batch.trigger(this, how, [ + newVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else if (how === 'remove') { + can.batch.trigger(this, how, [ + oldVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else { + can.batch.trigger(this, how, [ + newVal, + index + ]); + } + } + }, + __get: function (attr) { + if (attr) { + if (this[attr] && this[attr].isComputed && can.isFunction(this.constructor.prototype[attr])) { + return this[attr](); + } else { + return this[attr]; + } + } else { + return this; + } + }, + __set: function (prop, value, current) { + prop = isNaN(+prop) || prop % 1 ? prop : +prop; + if (typeof prop === 'number' && prop > this.length - 1) { + var newArr = new Array(prop + 1 - this.length); + newArr[newArr.length - 1] = value; + this.push.apply(this, newArr); + return newArr; + } + return can.Map.prototype.__set.call(this, '' + prop, value, current); + }, + ___set: function (attr, val) { + this[attr] = val; + if (+attr >= this.length) { + this.length = +attr + 1; + } + }, + _remove: function (prop, current) { + if (isNaN(+prop)) { + delete this[prop]; + this._triggerChange(prop, 'remove', undefined, current); + } else { + this.splice(prop, 1); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var i = 0; i < data.length; i++) { + callback(data[i], i); + } + }, + serialize: function () { + return Map.helpers.serialize(this, 'serialize', []); + }, + splice: function (index, howMany) { + var args = can.makeArray(arguments), added = [], i, len, listIndex, allSame = args.length > 2; + index = index || 0; + for (i = 0, len = args.length - 2; i < len; i++) { + listIndex = i + 2; + args[listIndex] = this.__type(args[listIndex], listIndex); + added.push(args[listIndex]); + if (this[i + index] !== args[listIndex]) { + allSame = false; + } + } + if (allSame && this.length <= added.length) { + return added; + } + if (howMany === undefined) { + howMany = args[1] = this.length - index; + } + var removed = splice.apply(this, args); + if (!spliceRemovesProps) { + for (i = this.length; i < removed.length + this.length; i++) { + delete this[i]; + } + } + can.batch.start(); + if (howMany > 0) { + bubble.removeMany(this, removed); + this._triggerChange('' + index, 'remove', undefined, removed); + } + if (args.length > 2) { + for (i = 0, len = added.length; i < len; i++) { + bubble.set(this, i, added[i]); + } + this._triggerChange('' + index, 'add', added, removed); + } + can.batch.stop(); + return removed; + }, + _attrs: function (items, remove) { + if (items === undefined) { + return Map.helpers.serialize(this, 'attr', []); + } + items = can.makeArray(items); + can.batch.start(); + this._updateAttrs(items, remove); + can.batch.stop(); + }, + _updateAttrs: function (items, remove) { + var len = Math.min(items.length, this.length); + for (var prop = 0; prop < len; prop++) { + var curVal = this[prop], newVal = items[prop]; + if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + this._set(prop, newVal); + } else { + } + } + if (items.length > this.length) { + this.push.apply(this, items.slice(this.length)); + } else if (items.length < this.length && remove) { + this.splice(items.length); + } + } + }), getArgs = function (args) { + return args[0] && can.isArray(args[0]) ? args[0] : can.makeArray(args); + }; + can.each({ + push: 'length', + unshift: 0 + }, function (where, name) { + var orig = [][name]; + list.prototype[name] = function () { + var args = [], len = where ? this.length : 0, i = arguments.length, res, val; + while (i--) { + val = arguments[i]; + args[i] = bubble.set(this, i, this.__type(val, i)); + } + res = orig.apply(this, args); + if (!this.comparator || args.length) { + this._triggerChange('' + len, 'add', args, undefined); + } + return res; + }; + }); + can.each({ + pop: 'length', + shift: 0 + }, function (where, name) { + list.prototype[name] = function () { + if (!this.length) { + return undefined; + } + var args = getArgs(arguments), len = where && this.length ? this.length - 1 : 0; + var res = [][name].apply(this, args); + this._triggerChange('' + len, 'remove', undefined, [res]); + if (res && res.unbind) { + bubble.remove(this, res); + } + return res; + }; + }); + can.extend(list.prototype, { + indexOf: function (item, fromIndex) { + this.attr('length'); + return can.inArray(item, this, fromIndex); + }, + join: function () { + return [].join.apply(this.attr(), arguments); + }, + reverse: function () { + var list = [].reverse.call(can.makeArray(this)); + this.replace(list); + }, + slice: function () { + var temp = Array.prototype.slice.apply(this, arguments); + return new this.constructor(temp); + }, + concat: function () { + var args = []; + can.each(can.makeArray(arguments), function (arg, i) { + args[i] = arg instanceof can.List ? arg.serialize() : arg; + }); + return new this.constructor(Array.prototype.concat.apply(this.serialize(), args)); + }, + forEach: function (cb, thisarg) { + return can.each(this, cb, thisarg || this); + }, + replace: function (newList) { + if (can.isDeferred(newList)) { + newList.then(can.proxy(this.replace, this)); + } else { + this.splice.apply(this, [ + 0, + this.length + ].concat(can.makeArray(newList || []))); + } + return this; + }, + filter: function (callback, thisArg) { + var filteredList = new can.List(), self = this, filtered; + this.each(function (item, index, list) { + filtered = callback.call(thisArg | self, item, index, self); + if (filtered) { + filteredList.push(item); + } + }); + return filteredList; + } + }); + can.List = Map.List = list; + return can.List; +}); +/*can@2.2.6#compute/read*/ +define('can/compute/read', ['can/util/util'], function (can) { + var read = function (parent, reads, options) { + options = options || {}; + var state = { foundObservable: false }; + var cur = readValue(parent, 0, reads, options, state), type, prev, readLength = reads.length, i = 0; + while (i < readLength) { + prev = cur; + for (var r = 0, readersLength = read.propertyReaders.length; r < readersLength; r++) { + var reader = read.propertyReaders[r]; + if (reader.test(cur)) { + cur = reader.read(cur, reads[i], i, options, state); + break; + } + } + i = i + 1; + cur = readValue(cur, i, reads, options, state, prev); + type = typeof cur; + if (i < reads.length && (cur === null || type !== 'function' && type !== 'object')) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1, cur); + } + return { + value: undefined, + parent: prev + }; + } + } + if (cur === undefined) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1); + } + } + return { + value: cur, + parent: prev + }; + }; + var readValue = function (value, index, reads, options, state, prev) { + var usedValueReader; + do { + usedValueReader = false; + for (var i = 0, len = read.valueReaders.length; i < len; i++) { + if (read.valueReaders[i].test(value, index, reads, options)) { + value = read.valueReaders[i].read(value, index, reads, options, state, prev); + } + } + } while (usedValueReader); + return value; + }; + read.valueReaders = [ + { + name: 'compute', + test: function (value, i, reads, options) { + return value && value.isComputed; + }, + read: function (value, i, reads, options, state) { + if (options.isArgument && i === reads.length) { + return value; + } + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, i); + state.foundObservable = true; + } + return value instanceof can.Compute ? value.get() : value(); + } + }, + { + name: 'function', + test: function (value, i, reads, options) { + var type = typeof value; + return type === 'function' && !value.isComputed && (options.executeAnonymousFunctions || options.isArgument && i === reads.length) && !(can.Construct && value.prototype instanceof can.Construct) && !(can.route && value === can.route); + }, + read: function (value, i, reads, options, state, prev) { + if (options.isArgument && i === reads.length) { + return options.proxyMethods !== false ? can.proxy(value, prev) : value; + } + return value.call(prev); + } + } + ]; + read.propertyReaders = [ + { + name: 'map', + test: can.isMapLike, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + if (typeof value[prop] === 'function' && value.constructor.prototype[prop] === value[prop]) { + if (options.returnObserveMethods) { + return value[prop]; + } else if (prop === 'constructor' && value instanceof can.Construct || value[prop].prototype instanceof can.Construct) { + return value[prop]; + } else { + return value[prop].apply(value, options.args || []); + } + } else { + return value.attr(prop); + } + } + }, + { + name: 'promise', + test: function (value) { + return can.isPromise(value); + }, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + var observeData = value.__observeData; + if (!value.__observeData) { + observeData = value.__observeData = { + isPending: true, + state: 'pending', + isResolved: false, + isRejected: false, + value: undefined, + reason: undefined + }; + can.cid(observeData); + can.simpleExtend(observeData, can.event); + value.then(function (value) { + observeData.isPending = false; + observeData.isResolved = true; + observeData.value = value; + observeData.state = 'resolved'; + observeData.dispatch('state', [ + 'resolved', + 'pending' + ]); + }, function (reason) { + observeData.isPending = false; + observeData.isRejected = true; + observeData.reason = reason; + observeData.state = 'rejected'; + observeData.dispatch('state', [ + 'rejected', + 'pending' + ]); + }); + } + can.__observe(observeData, 'state'); + return prop in observeData ? observeData[prop] : value[prop]; + } + }, + { + name: 'object', + test: function () { + return true; + }, + read: function (value, prop) { + if (value == null) { + return undefined; + } else { + return value[prop]; + } + } + } + ]; + read.write = function (parent, key, value, options) { + options = options || {}; + if (can.isMapLike(parent)) { + if (!options.isArgument && parent._data && parent._data[key] && parent._data[key].isComputed) { + return parent._data[key](value); + } else { + return parent.attr(key, value); + } + } + if (parent[key] && parent[key].isComputed) { + return parent[key](value); + } + if (typeof parent === 'object') { + parent[key] = value; + } + }; + return read; +}); +/*can@2.2.6#compute/get_value_and_bind*/ +define('can/compute/get_value_and_bind', ['can/util/util'], function () { + function observe(func, context, oldInfo, onchanged) { + var info = getValueAndObserved(func, context), newObserveSet = info.observed, oldObserved = oldInfo.observed; + if (info.names !== oldInfo.names) { + bindNewSet(oldObserved, newObserveSet, onchanged); + unbindOldSet(oldObserved, onchanged); + } + can.batch.afterPreviousEvents(function () { + info.ready = true; + }); + return info; + } + var observedStack = []; + can.__isRecordingObserves = function () { + return observedStack.length; + }; + can.__observe = can.__reading = function (obj, event) { + if (observedStack.length) { + var name = obj._cid + '|' + event, top = observedStack[observedStack.length - 1]; + top.names += name; + top.observed[name] = { + obj: obj, + event: event + '' + }; + } + }; + can.__notObserve = function (fn) { + return function () { + var previousReads = can.__clearObserved(); + var res = fn.apply(this, arguments); + can.__setObserved(previousReads); + return res; + }; + }; + can.__clearObserved = can.__clearReading = function () { + if (observedStack.length) { + var ret = observedStack[observedStack.length - 1]; + observedStack[observedStack.length - 1] = { observed: {} }; + return ret; + } + }; + can.__setObserved = can.__setReading = function (o) { + if (observedStack.length) { + observedStack[observedStack.length - 1] = o; + } + }; + can.__addObserved = can.__addReading = function (o) { + if (observedStack.length) { + can.simpleExtend(observedStack[observedStack.length - 1], o); + } + }; + var getValueAndObserved = function (func, self) { + observedStack.push({ + names: '', + observed: {} + }); + var value = func.call(self); + var stackItem = observedStack.pop(); + stackItem.value = value; + return stackItem; + }; + var bindNewSet = function (oldObserved, newObserveSet, onchanged) { + for (var name in newObserveSet) { + bindOrPreventUnbinding(oldObserved, newObserveSet, name, onchanged); + } + }; + var bindOrPreventUnbinding = function (oldObserved, newObserveSet, name, onchanged) { + if (oldObserved[name]) { + delete oldObserved[name]; + } else { + var obEv = newObserveSet[name]; + obEv.obj.bind(obEv.event, onchanged); + } + }; + var unbindOldSet = function (oldObserved, onchanged) { + for (var name in oldObserved) { + var obEv = oldObserved[name]; + obEv.obj.unbind(obEv.event, onchanged); + } + }; + return observe; +}); +/*can@2.2.6#compute/proto_compute*/ +define('can/compute/proto_compute', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/compute/read', + 'can/compute/get_value_and_bind', + 'can/util/batch/batch' +], function (can, bind, read, getValueAndBind) { + var updateOnChange = function (compute, newValue, oldValue, batchNum) { + if (newValue !== oldValue) { + can.batch.trigger(compute, batchNum ? { + type: 'change', + batchNum: batchNum + } : 'change', [ + newValue, + oldValue + ]); + } + }; + var setupComputeHandlers = function (compute, func, context, singleBind) { + var readInfo, onchanged, batchNum; + singleBind = false; + return { + on: function (updater) { + var self = this; + if (!onchanged) { + onchanged = function (ev) { + if (readInfo.ready && compute.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + if (singleBind) { + newValue = func.call(context); + readInfo.value = newValue; + } else { + readInfo = getValueAndBind(func, context, readInfo, onchanged); + newValue = readInfo.value; + } + self.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }; + } + readInfo = getValueAndBind(func, context, { observed: {} }, onchanged); + if (singleBind) { + func = can.__notObserve(func); + } + compute.value = readInfo.value; + compute.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function (updater) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, onchanged); + } + } + }; + }; + var k = function () { + }; + var updater = function (newVal, oldVal, batchNum) { + this.value = newVal; + updateOnChange(this, newVal, oldVal, batchNum); + }, asyncGet = function (fn, context, lastSetValue) { + return function () { + return fn.call(context, lastSetValue.get()); + }; + }, asyncUpdater = function (context, oldUpdater) { + return function (newVal) { + if (newVal !== undefined) { + oldUpdater(newVal, context.value); + } + }; + }; + can.Compute = function (getterSetter, context, eventName, bindOnce) { + var args = []; + for (var i = 0, arglen = arguments.length; i < arglen; i++) { + args[i] = arguments[i]; + } + var contextType = typeof args[1]; + if (typeof args[0] === 'function') { + this._setupGetterSetterFn(args[0], args[1], args[2], args[3]); + } else if (args[1]) { + if (contextType === 'string') { + this._setupContextString(args[0], args[1], args[2]); + } else if (contextType === 'function') { + this._setupContextFunction(args[0], args[1], args[2]); + } else { + if (args[1] && args[1].fn) { + this._setupAsyncCompute(args[0], args[1]); + } else { + this._setupContextSettings(args[0], args[1]); + } + } + } else { + this._setupInitialValue(args[0]); + } + this._args = args; + this.isComputed = true; + can.cid(this, 'compute'); + }; + can.simpleExtend(can.Compute.prototype, { + _bindsetup: can.__notObserve(function () { + this.bound = true; + this._on(this.updater); + }), + _bindteardown: function () { + this._off(this.updater); + this.bound = false; + }, + bind: can.bindAndSetup, + unbind: can.unbindAndTeardown, + clone: function (context) { + if (context && typeof this._args[0] === 'function') { + this._args[1] = context; + } else if (context) { + this._args[2] = context; + } + return new can.Compute(this._args[0], this._args[1], this._args[2], this._args[3]); + }, + _on: k, + _off: k, + get: function () { + if (can.__isRecordingObserves() && this._canObserve !== false) { + can.__observe(this, 'change'); + if (!this.bound) { + can.Compute.temporarilyBind(this); + } + } + if (this.bound) { + return this.value; + } else { + return this._get(); + } + }, + _get: function () { + return this.value; + }, + set: function (newVal) { + var old = this.value; + var setVal = this._set(newVal, old); + if (this.hasDependencies) { + if (this._setUpdates) { + return this.value; + } + return this._get(); + } + if (setVal === undefined) { + this.value = this._get(); + } else { + this.value = setVal; + } + updateOnChange(this, this.value, old); + return this.value; + }, + _set: function (newVal) { + return this.value = newVal; + }, + updater: updater, + _computeFn: function (newVal) { + if (arguments.length) { + return this.set(newVal); + } + return this.get(); + }, + toFunction: function () { + return can.proxy(this._computeFn, this); + }, + _setupGetterSetterFn: function (getterSetter, context, eventName, bindOnce) { + this._set = can.proxy(getterSetter, context); + this._get = can.proxy(getterSetter, context); + this._canObserve = eventName === false ? false : true; + var handlers = setupComputeHandlers(this, getterSetter, context || this, bindOnce); + this._on = handlers.on; + this._off = handlers.off; + }, + _setupContextString: function (target, propertyName, eventName) { + var isObserve = can.isMapLike(target), self = this, handler = function (ev, newVal, oldVal) { + self.updater(newVal, oldVal, ev.batchNum); + }; + if (isObserve) { + this.hasDependencies = true; + this._get = function () { + return target.attr(propertyName); + }; + this._set = function (val) { + target.attr(propertyName, val); + }; + this._on = function (update) { + target.bind(eventName || propertyName, handler); + this.value = this._get(); + }; + this._off = function () { + return target.unbind(eventName || propertyName, handler); + }; + } else { + this._get = can.proxy(this._get, target); + this._set = can.proxy(this._set, target); + } + }, + _setupContextFunction: function (initialValue, setter, eventName) { + this.value = initialValue; + this._set = setter; + can.simpleExtend(this, eventName); + }, + _setupContextSettings: function (initialValue, settings) { + this.value = initialValue; + this._set = settings.set ? can.proxy(settings.set, settings) : this._set; + this._get = settings.get ? can.proxy(settings.get, settings) : this._get; + if (!settings.__selfUpdater) { + var self = this, oldUpdater = this.updater; + this.updater = function () { + oldUpdater.call(self, self._get(), self.value); + }; + } + this._on = settings.on ? settings.on : this._on; + this._off = settings.off ? settings.off : this._off; + }, + _setupAsyncCompute: function (initialValue, settings) { + this.value = initialValue; + var oldUpdater = can.proxy(this.updater, this), self = this, fn = settings.fn, data; + this.updater = oldUpdater; + var lastSetValue = new can.Compute(initialValue); + this.lastSetValue = lastSetValue; + this._setUpdates = true; + this._set = function (newVal) { + if (newVal === lastSetValue.get()) { + return this.value; + } + return lastSetValue.set(newVal); + }; + this._get = asyncGet(fn, settings.context, lastSetValue); + if (fn.length === 0) { + data = setupComputeHandlers(this, fn, settings.context); + } else if (fn.length === 1) { + data = setupComputeHandlers(this, function () { + return fn.call(settings.context, lastSetValue.get()); + }, settings); + } else { + this.updater = asyncUpdater(this, oldUpdater); + data = setupComputeHandlers(this, function () { + var res = fn.call(settings.context, lastSetValue.get(), function (newVal) { + oldUpdater(newVal, self.value); + }); + return res !== undefined ? res : this.value; + }, settings); + } + this._on = data.on; + this._off = data.off; + }, + _setupInitialValue: function (initialValue) { + this.value = initialValue; + } + }); + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.Compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.Compute.async = function (initialValue, asyncComputer, context) { + return new can.Compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.Compute.read = read; + can.Compute.set = read.write; + can.Compute.truthy = function (compute) { + return new can.Compute(function () { + var res = compute.get(); + if (typeof res === 'function') { + res = res.get(); + } + return !!res; + }); + }; + return can.Compute; +}); +/*can@2.2.6#compute/compute*/ +define('can/compute/compute', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/util/batch/batch', + 'can/compute/proto_compute' +], function (can, bind) { + can.compute = function (getterSetter, context, eventName, bindOnce) { + var internalCompute = new can.Compute(getterSetter, context, eventName, bindOnce); + var compute = function (val) { + if (arguments.length) { + return internalCompute.set(val); + } + return internalCompute.get(); + }; + compute.bind = can.proxy(internalCompute.bind, internalCompute); + compute.unbind = can.proxy(internalCompute.unbind, internalCompute); + compute.isComputed = internalCompute.isComputed; + compute.clone = function (ctx) { + if (typeof getterSetter === 'function') { + context = ctx; + } + return can.compute(getterSetter, context, ctx, bindOnce); + }; + compute.computeInstance = internalCompute; + return compute; + }; + var k = function () { + }; + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.compute.truthy = function (compute) { + return can.compute(function () { + var res = compute(); + if (typeof res === 'function') { + res = res(); + } + return !!res; + }); + }; + can.compute.async = function (initialValue, asyncComputer, context) { + return can.compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.compute.read = can.Compute.read; + can.compute.set = can.Compute.set; + return can.compute; +}); +/*can@2.2.6#observe/observe*/ +define('can/observe/observe', [ + 'can/util/util', + 'can/map/map', + 'can/list/list', + 'can/compute/compute' +], function (can) { + can.Observe = can.Map; + can.Observe.startBatch = can.batch.start; + can.Observe.stopBatch = can.batch.stop; + can.Observe.triggerBatch = can.batch.trigger; + return can; +}); +/*can@2.2.6#view/scope/compute_data*/ +define('can/view/scope/compute_data', [ + 'can/util/util', + 'can/compute/compute', + 'can/compute/get_value_and_bind' +], function (can, compute, getValueAndBind) { + var isFastPath = function (computeData) { + return computeData.reads && computeData.reads.length === 1 && computeData.root instanceof can.Map && !can.isFunction(computeData.root[computeData.reads[0]]); + }; + var getValueAndBindScopeRead = function (scopeRead, scopeReadChanged) { + return getValueAndBind(scopeRead, null, { observed: {} }, scopeReadChanged); + }; + var unbindScopeRead = function (readInfo, scopeReadChanged) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, scopeReadChanged); + } + }; + var getValueAndBindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + var target = computeData.root, prop = computeData.reads[0]; + target.bind(prop, singlePropertyReadChanged); + return { + value: computeData.initialValue, + observed: { something: true } + }; + }; + var unbindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + computeData.root.unbind(computeData.reads[0], singlePropertyReadChanged); + }; + var scopeReader = function (scope, key, options, computeData, newVal) { + if (arguments.length > 4) { + if (computeData.root.isComputed) { + computeData.root(newVal); + } else if (computeData.reads.length) { + var last = computeData.reads.length - 1; + var obj = computeData.reads.length ? can.compute.read(computeData.root, computeData.reads.slice(0, last)).value : computeData.root; + can.compute.set(obj, computeData.reads[last], newVal, options); + } + } else { + if (computeData.root) { + return can.compute.read(computeData.root, computeData.reads, options).value; + } + var data = scope.read(key, options); + computeData.scope = data.scope; + computeData.initialValue = data.value; + computeData.reads = data.reads; + computeData.root = data.rootObserve; + return data.value; + } + }; + return function (scope, key, options) { + options = options || { args: [] }; + var computeData = {}, scopeRead = function (newVal) { + if (arguments.length) { + return scopeReader(scope, key, options, computeData, newVal); + } else { + return scopeReader(scope, key, options, computeData); + } + }, batchNum, readInfo, scopeReadChanged = function (ev) { + if (readInfo.ready && compute.computeInstance.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + readInfo = getValueAndBind(scopeRead, null, readInfo, scopeReadChanged); + newValue = readInfo.value; + compute.computeInstance.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }, singlePropertyReadChanged = function (ev, newVal, oldVal) { + if (typeof newVal !== 'function') { + compute.computeInstance.updater(newVal, oldVal, ev.batchNum); + } else { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + isFastPathBound = false; + compute.computeInstance.updater(readInfo.value, oldVal, ev.batchNum); + } + }, isFastPathBound = false, compute = can.compute(undefined, { + on: function () { + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + if (isFastPath(computeData)) { + var oldReadInfo = readInfo; + readInfo = getValueAndBindSinglePropertyRead(computeData, singlePropertyReadChanged); + unbindScopeRead(oldReadInfo, scopeReadChanged); + isFastPathBound = true; + } + compute.computeInstance.value = readInfo.value; + compute.computeInstance.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function () { + if (isFastPathBound) { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + } else { + unbindScopeRead(readInfo, scopeReadChanged); + } + }, + set: scopeRead, + get: scopeRead, + __selfUpdater: true + }); + computeData.compute = compute; + return computeData; + }; +}); +/*can@2.2.6#view/scope/scope*/ +define('can/view/scope/scope', [ + 'can/util/util', + 'can/view/scope/compute_data', + 'can/construct/construct', + 'can/map/map', + 'can/list/list', + 'can/view/view', + 'can/compute/compute' +], function (can, makeComputeData) { + var escapeReg = /(\\)?\./g, escapeDotReg = /\\\./g, getNames = function (attr) { + var names = [], last = 0; + attr.replace(escapeReg, function (first, second, index) { + if (!second) { + names.push(attr.slice(last, index).replace(escapeDotReg, '.')); + last = index + first.length; + } + }); + names.push(attr.slice(last).replace(escapeDotReg, '.')); + return names; + }; + var Scope = can.Construct.extend({ read: can.compute.read }, { + init: function (context, parent) { + this._context = context; + this._parent = parent; + this.__cache = {}; + }, + attr: can.__notObserve(function (key, value) { + var options = { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }, res = this.read(key, options); + if (arguments.length === 2) { + var lastIndex = key.lastIndexOf('.'), readKey = lastIndex !== -1 ? key.substring(0, lastIndex) : '.', obj = this.read(readKey, options).value; + if (lastIndex !== -1) { + key = key.substring(lastIndex + 1, key.length); + } + can.compute.set(obj, key, value, options); + } + return res.value; + }), + add: function (context) { + if (context !== this._context) { + return new this.constructor(context, this); + } else { + return this; + } + }, + computeData: function (key, options) { + return makeComputeData(this, key, options); + }, + compute: function (key, options) { + return this.computeData(key, options).compute; + }, + read: function (attr, options) { + var stopLookup; + if (attr.substr(0, 2) === './') { + stopLookup = true; + attr = attr.substr(2); + } else if (attr.substr(0, 3) === '../') { + return this._parent.read(attr.substr(3), options); + } else if (attr === '..') { + return { value: this._parent._context }; + } else if (attr === '.' || attr === 'this') { + return { value: this._context }; + } + var names = attr.indexOf('\\.') === -1 ? attr.split('.') : getNames(attr), context, scope = this, defaultObserve, defaultReads = [], defaultPropertyDepth = -1, defaultComputeReadings, defaultScope, currentObserve, currentReads; + while (scope) { + context = scope._context; + if (context !== null && (typeof context === 'object' || typeof context === 'function')) { + var data = can.compute.read(context, names, can.simpleExtend({ + foundObservable: function (observe, nameIndex) { + currentObserve = observe; + currentReads = names.slice(nameIndex); + }, + earlyExit: function (parentValue, nameIndex) { + if (nameIndex > defaultPropertyDepth) { + defaultObserve = currentObserve; + defaultReads = currentReads; + defaultPropertyDepth = nameIndex; + defaultScope = scope; + defaultComputeReadings = can.__clearReading(); + } + }, + executeAnonymousFunctions: true + }, options)); + if (data.value !== undefined) { + return { + scope: scope, + rootObserve: currentObserve, + value: data.value, + reads: currentReads + }; + } + } + can.__clearReading(); + if (!stopLookup) { + scope = scope._parent; + } else { + scope = null; + } + } + if (defaultObserve) { + can.__setReading(defaultComputeReadings); + return { + scope: defaultScope, + rootObserve: defaultObserve, + reads: defaultReads, + value: undefined + }; + } else { + return { + names: names, + value: undefined + }; + } + } + }); + can.view.Scope = Scope; + return Scope; +}); +/*can@2.2.6#view/scanner*/ +define('can/view/scanner', [ + 'can/view/view', + 'can/view/elements', + 'can/view/callbacks/callbacks' +], function (can, elements, viewCallbacks) { + var newLine = /(\r|\n)+/g, notEndTag = /\//, clean = function (content) { + return content.split('\\').join('\\\\').split('\n').join('\\n').split('"').join('\\"').split('\t').join('\\t'); + }, getTag = function (tagName, tokens, i) { + if (tagName) { + return tagName; + } else { + while (i < tokens.length) { + if (tokens[i] === '<' && !notEndTag.test(tokens[i + 1])) { + return elements.reverseTagMap[tokens[i + 1]] || 'span'; + } + i++; + } + } + return ''; + }, bracketNum = function (content) { + return --content.split('{').length - --content.split('}').length; + }, myEval = function (script) { + eval(script); + }, attrReg = /([^\s]+)[\s]*=[\s]*$/, startTxt = 'var ___v1ew = [];', finishTxt = 'return ___v1ew.join(\'\')', put_cmd = '___v1ew.push(\n', insert_cmd = put_cmd, htmlTag = null, quote = null, beforeQuote = null, rescan = null, getAttrName = function () { + var matches = beforeQuote.match(attrReg); + return matches && matches[1]; + }, status = function () { + return quote ? '\'' + getAttrName() + '\'' : htmlTag ? 1 : 0; + }, top = function (stack) { + return stack[stack.length - 1]; + }, Scanner; + can.view.Scanner = Scanner = function (options) { + can.extend(this, { + text: {}, + tokens: [] + }, options); + this.text.options = this.text.options || ''; + this.tokenReg = []; + this.tokenSimple = { + '<': '<', + '>': '>', + '"': '"', + '\'': '\'' + }; + this.tokenComplex = []; + this.tokenMap = {}; + for (var i = 0, token; token = this.tokens[i]; i++) { + if (token[2]) { + this.tokenReg.push(token[2]); + this.tokenComplex.push({ + abbr: token[1], + re: new RegExp(token[2]), + rescan: token[3] + }); + } else { + this.tokenReg.push(token[1]); + this.tokenSimple[token[1]] = token[0]; + } + this.tokenMap[token[0]] = token[1]; + } + this.tokenReg = new RegExp('(' + this.tokenReg.slice(0).concat([ + '<', + '>', + '"', + '\'' + ]).join('|') + ')', 'g'); + }; + Scanner.prototype = { + helpers: [], + scan: function (source, name) { + var tokens = [], last = 0, simple = this.tokenSimple, complex = this.tokenComplex; + source = source.replace(newLine, '\n'); + if (this.transform) { + source = this.transform(source); + } + source.replace(this.tokenReg, function (whole, part) { + var offset = arguments[arguments.length - 2]; + if (offset > last) { + tokens.push(source.substring(last, offset)); + } + if (simple[whole]) { + tokens.push(whole); + } else { + for (var i = 0, token; token = complex[i]; i++) { + if (token.re.test(whole)) { + tokens.push(token.abbr); + if (token.rescan) { + tokens.push(token.rescan(part)); + } + break; + } + } + } + last = offset + part.length; + }); + if (last < source.length) { + tokens.push(source.substr(last)); + } + var content = '', buff = [startTxt + (this.text.start || '')], put = function (content, bonus) { + buff.push(put_cmd, '"', clean(content), '"' + (bonus || '') + ');'); + }, endStack = [], lastToken, startTag = null, magicInTag = false, specialStates = { + attributeHookups: [], + tagHookups: [], + lastTagHookup: '' + }, popTagHookup = function () { + specialStates.lastTagHookup = specialStates.tagHookups.pop() + specialStates.tagHookups.length; + }, tagName = '', tagNames = [], popTagName = false, bracketCount, specialAttribute = false, i = 0, token, tmap = this.tokenMap, attrName; + htmlTag = quote = beforeQuote = null; + for (; (token = tokens[i++]) !== undefined;) { + if (startTag === null) { + switch (token) { + case tmap.left: + case tmap.escapeLeft: + case tmap.returnLeft: + magicInTag = htmlTag && 1; + case tmap.commentLeft: + startTag = token; + if (content.length) { + put(content); + } + content = ''; + break; + case tmap.escapeFull: + magicInTag = htmlTag && 1; + rescan = 1; + startTag = tmap.escapeLeft; + if (content.length) { + put(content); + } + rescan = tokens[i++]; + content = rescan.content || rescan; + if (rescan.before) { + put(rescan.before); + } + tokens.splice(i, 0, tmap.right); + break; + case tmap.commentFull: + break; + case tmap.templateLeft: + content += tmap.left; + break; + case '<': + if (tokens[i].indexOf('!--') !== 0) { + htmlTag = 1; + magicInTag = 0; + } + content += token; + break; + case '>': + htmlTag = 0; + var emptyElement = content.substr(content.length - 1) === '/' || content.substr(content.length - 2) === '--', attrs = ''; + if (specialStates.attributeHookups.length) { + attrs = 'attrs: [\'' + specialStates.attributeHookups.join('\',\'') + '\'], '; + specialStates.attributeHookups = []; + } + if (tagName + specialStates.tagHookups.length !== specialStates.lastTagHookup && tagName === top(specialStates.tagHookups)) { + if (emptyElement) { + content = content.substr(0, content.length - 1); + } + buff.push(put_cmd, '"', clean(content), '"', ',can.view.pending({tagName:\'' + tagName + '\',' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options); + if (emptyElement) { + buff.push('}));'); + content = '/>'; + popTagHookup(); + } else if (tokens[i] === '<' && tokens[i + 1] === '/' + tagName) { + buff.push('}));'); + content = token; + popTagHookup(); + } else { + buff.push(',subtemplate: function(' + this.text.argNames + '){\n' + startTxt + (this.text.start || '')); + content = ''; + } + } else if (magicInTag || !popTagName && elements.tagToContentPropMap[tagNames[tagNames.length - 1]] || attrs) { + var pendingPart = ',can.view.pending({' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options + '}),"'; + if (emptyElement) { + put(content.substr(0, content.length - 1), pendingPart + '/>"'); + } else { + put(content, pendingPart + '>"'); + } + content = ''; + magicInTag = 0; + } else { + content += token; + } + if (emptyElement || popTagName) { + tagNames.pop(); + tagName = tagNames[tagNames.length - 1]; + popTagName = false; + } + specialStates.attributeHookups = []; + break; + case '\'': + case '"': + if (htmlTag) { + if (quote && quote === token) { + quote = null; + var attr = getAttrName(); + if (viewCallbacks.attr(attr)) { + specialStates.attributeHookups.push(attr); + } + if (specialAttribute) { + content += token; + put(content); + buff.push(finishTxt, '}));\n'); + content = ''; + specialAttribute = false; + break; + } + } else if (quote === null) { + quote = token; + beforeQuote = lastToken; + attrName = getAttrName(); + if (tagName === 'img' && attrName === 'src' || attrName === 'style') { + put(content.replace(attrReg, '')); + content = ''; + specialAttribute = true; + buff.push(insert_cmd, 'can.view.txt(2,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt); + put(attrName + '=' + token); + break; + } + } + } + default: + if (lastToken === '<') { + tagName = token.substr(0, 3) === '!--' ? '!--' : token.split(/\s/)[0]; + var isClosingTag = false, cleanedTagName; + if (tagName.indexOf('/') === 0) { + isClosingTag = true; + cleanedTagName = tagName.substr(1); + } + if (isClosingTag) { + if (top(tagNames) === cleanedTagName) { + tagName = cleanedTagName; + popTagName = true; + } + if (top(specialStates.tagHookups) === cleanedTagName) { + put(content.substr(0, content.length - 1)); + buff.push(finishTxt + '}}) );'); + content = '><'; + popTagHookup(); + } + } else { + if (tagName.lastIndexOf('/') === tagName.length - 1) { + tagName = tagName.substr(0, tagName.length - 1); + } + if (tagName !== '!--' && viewCallbacks.tag(tagName)) { + if (tagName === 'content' && elements.tagMap[top(tagNames)]) { + token = token.replace('content', elements.tagMap[top(tagNames)]); + } + specialStates.tagHookups.push(tagName); + } + tagNames.push(tagName); + } + } + content += token; + break; + } + } else { + switch (token) { + case tmap.right: + case tmap.returnRight: + switch (startTag) { + case tmap.left: + bracketCount = bracketNum(content); + if (bracketCount === 1) { + buff.push(insert_cmd, 'can.view.txt(0,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt, content); + endStack.push({ + before: '', + after: finishTxt + '}));\n' + }); + } else { + last = endStack.length && bracketCount === -1 ? endStack.pop() : { after: ';' }; + if (last.before) { + buff.push(last.before); + } + buff.push(content, ';', last.after); + } + break; + case tmap.escapeLeft: + case tmap.returnLeft: + bracketCount = bracketNum(content); + if (bracketCount) { + endStack.push({ + before: finishTxt, + after: '}));\n' + }); + } + var escaped = startTag === tmap.escapeLeft ? 1 : 0, commands = { + insert: insert_cmd, + tagName: getTag(tagName, tokens, i), + status: status(), + specialAttribute: specialAttribute + }; + for (var ii = 0; ii < this.helpers.length; ii++) { + var helper = this.helpers[ii]; + if (helper.name.test(content)) { + content = helper.fn(content, commands); + if (helper.name.source === /^>[\s]*\w*/.source) { + escaped = 0; + } + break; + } + } + if (typeof content === 'object') { + if (content.startTxt && content.end && specialAttribute) { + buff.push(insert_cmd, 'can.view.toStr( ', content.content, '() ) );'); + } else { + if (content.startTxt) { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || (content.escaped != null ? content.escaped : escaped)) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\n'); + } else if (content.startOnlyTxt) { + buff.push(insert_cmd, 'can.view.onlytxt(this,\n'); + } + buff.push(content.content); + if (content.end) { + buff.push('));'); + } + } + } else if (specialAttribute) { + buff.push(insert_cmd, content, ');'); + } else { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || escaped) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\nfunction(){ ' + (this.text.escape || '') + 'return ', content, bracketCount ? startTxt : '}));\n'); + } + if (rescan && rescan.after && rescan.after.length) { + put(rescan.after.length); + rescan = null; + } + break; + } + startTag = null; + content = ''; + break; + case tmap.templateLeft: + content += tmap.left; + break; + default: + content += token; + break; + } + } + lastToken = token; + } + if (content.length) { + put(content); + } + buff.push(';'); + var template = buff.join(''), out = { out: (this.text.outStart || '') + template + ' ' + finishTxt + (this.text.outEnd || '') }; + myEval.call(out, 'this.fn = (function(' + this.text.argNames + '){' + out.out + '});\r\n//# sourceURL=' + name + '.js'); + return out; + } + }; + can.view.pending = function (viewData) { + var hooks = can.view.getHooks(); + return can.view.hook(function (el) { + can.each(hooks, function (fn) { + fn(el); + }); + viewData.templateType = 'legacy'; + if (viewData.tagName) { + viewCallbacks.tagHandler(el, viewData.tagName, viewData); + } + can.each(viewData && viewData.attrs || [], function (attributeName) { + viewData.attributeName = attributeName; + var callback = viewCallbacks.attr(attributeName); + if (callback) { + callback(el, viewData); + } + }); + }); + }; + can.view.tag('content', function (el, tagData) { + return tagData.scope; + }); + can.view.Scanner = Scanner; + return Scanner; +}); +/*can@2.2.6#view/node_lists/node_lists*/ +define('can/view/node_lists/node_lists', [ + 'can/util/util', + 'can/view/elements' +], function (can) { + var canExpando = true; + try { + document.createTextNode('')._ = 0; + } catch (ex) { + canExpando = false; + } + var nodeMap = {}, textNodeMap = {}, expando = 'ejs_' + Math.random(), _id = 0, id = function (node, localMap) { + var _textNodeMap = localMap || textNodeMap; + var id = readId(node, _textNodeMap); + if (id) { + return id; + } else { + if (canExpando || node.nodeType !== 3) { + ++_id; + return node[expando] = (node.nodeName ? 'element_' : 'obj_') + _id; + } else { + ++_id; + _textNodeMap['text_' + _id] = node; + return 'text_' + _id; + } + } + }, readId = function (node, textNodeMap) { + if (canExpando || node.nodeType !== 3) { + return node[expando]; + } else { + for (var textNodeID in textNodeMap) { + if (textNodeMap[textNodeID] === node) { + return textNodeID; + } + } + } + }, splice = [].splice, push = [].push, itemsInChildListTree = function (list) { + var count = 0; + for (var i = 0, len = list.length; i < len; i++) { + var item = list[i]; + if (item.nodeType) { + count++; + } else { + count += itemsInChildListTree(item); + } + } + return count; + }, replacementMap = function (replacements, idMap) { + var map = {}; + for (var i = 0, len = replacements.length; i < len; i++) { + var node = nodeLists.first(replacements[i]); + map[id(node, idMap)] = replacements[i]; + } + return map; + }; + var nodeLists = { + id: id, + update: function (nodeList, newNodes) { + var oldNodes = nodeLists.unregisterChildren(nodeList); + newNodes = can.makeArray(newNodes); + var oldListLength = nodeList.length; + splice.apply(nodeList, [ + 0, + oldListLength + ].concat(newNodes)); + if (nodeList.replacements) { + nodeLists.nestReplacements(nodeList); + } else { + nodeLists.nestList(nodeList); + } + return oldNodes; + }, + nestReplacements: function (list) { + var index = 0, idMap = {}, rMap = replacementMap(list.replacements, idMap), rCount = list.replacements.length; + while (index < list.length && rCount) { + var node = list[index], replacement = rMap[readId(node, idMap)]; + if (replacement) { + list.splice(index, itemsInChildListTree(replacement), replacement); + rCount--; + } + index++; + } + list.replacements = []; + }, + nestList: function (list) { + var index = 0; + while (index < list.length) { + var node = list[index], childNodeList = nodeMap[id(node)]; + if (childNodeList) { + if (childNodeList !== list) { + list.splice(index, itemsInChildListTree(childNodeList), childNodeList); + } + } else { + nodeMap[id(node)] = list; + } + index++; + } + }, + last: function (nodeList) { + var last = nodeList[nodeList.length - 1]; + if (last.nodeType) { + return last; + } else { + return nodeLists.last(last); + } + }, + first: function (nodeList) { + var first = nodeList[0]; + if (first.nodeType) { + return first; + } else { + return nodeLists.first(first); + } + }, + flatten: function (nodeList) { + var items = []; + for (var i = 0; i < nodeList.length; i++) { + var item = nodeList[i]; + if (item.nodeType) { + items.push(item); + } else { + items.push.apply(items, nodeLists.flatten(item)); + } + } + return items; + }, + register: function (nodeList, unregistered, parent) { + nodeList.unregistered = unregistered; + nodeList.parentList = parent; + if (parent === true) { + nodeList.replacements = []; + } else if (parent) { + parent.replacements.push(nodeList); + nodeList.replacements = []; + } else { + nodeLists.nestList(nodeList); + } + return nodeList; + }, + unregisterChildren: function (nodeList) { + var nodes = []; + can.each(nodeList, function (node) { + if (node.nodeType) { + if (!nodeList.replacements) { + delete nodeMap[id(node)]; + } + nodes.push(node); + } else { + push.apply(nodes, nodeLists.unregister(node)); + } + }); + return nodes; + }, + unregister: function (nodeList) { + var nodes = nodeLists.unregisterChildren(nodeList); + if (nodeList.unregistered) { + var unregisteredCallback = nodeList.unregistered; + delete nodeList.unregistered; + delete nodeList.replacements; + unregisteredCallback(); + } + return nodes; + }, + nodeMap: nodeMap + }; + can.view.nodeLists = nodeLists; + return nodeLists; +}); +/*can@2.2.6#view/parser/parser*/ +define('can/view/parser/parser', ['can/view/view'], function (can) { + function makeMap(str) { + var obj = {}, items = str.split(','); + for (var i = 0; i < items.length; i++) { + obj[items[i]] = true; + } + return obj; + } + function handleIntermediate(intermediate, handler) { + for (var i = 0, len = intermediate.length; i < len; i++) { + var item = intermediate[i]; + handler[item.tokenType].apply(handler, item.args); + } + return intermediate; + } + var alphaNumericHU = '-:A-Za-z0-9_', attributeNames = '[a-zA-Z_:][' + alphaNumericHU + ':.]*', spaceEQspace = '\\s*=\\s*', dblQuote2dblQuote = '"((?:\\\\.|[^"])*)"', quote2quote = '\'((?:\\\\.|[^\'])*)\'', attributeEqAndValue = '(?:' + spaceEQspace + '(?:' + '(?:"[^"]*")|(?:\'[^\']*\')|[^>\\s]+))?', matchStash = '\\{\\{[^\\}]*\\}\\}\\}?', stash = '\\{\\{([^\\}]*)\\}\\}\\}?', startTag = new RegExp('^<([' + alphaNumericHU + ']+)' + '(' + '(?:\\s*' + '(?:(?:' + '(?:' + attributeNames + ')?' + attributeEqAndValue + ')|' + '(?:' + matchStash + ')+)' + ')*' + ')\\s*(\\/?)>'), endTag = new RegExp('^<\\/([' + alphaNumericHU + ']+)[^>]*>'), attr = new RegExp('(?:' + '(?:(' + attributeNames + ')|' + stash + ')' + '(?:' + spaceEQspace + '(?:' + '(?:' + dblQuote2dblQuote + ')|(?:' + quote2quote + ')|([^>\\s]+)' + ')' + ')?)', 'g'), mustache = new RegExp(stash, 'g'), txtBreak = /<|\{\{/; + var empty = makeMap('area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed'); + var block = makeMap('a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video'); + var inline = makeMap('abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var'); + var closeSelf = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr'); + var fillAttrs = makeMap('checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected'); + var special = makeMap('script,style'); + var tokenTypes = 'start,end,close,attrStart,attrEnd,attrValue,chars,comment,special,done'.split(','); + var fn = function () { + }; + var HTMLParser = function (html, handler, returnIntermediate) { + if (typeof html === 'object') { + return handleIntermediate(html, handler); + } + var intermediate = []; + handler = handler || {}; + if (returnIntermediate) { + can.each(tokenTypes, function (name) { + var callback = handler[name] || fn; + handler[name] = function () { + if (callback.apply(this, arguments) !== false) { + intermediate.push({ + tokenType: name, + args: can.makeArray(arguments) + }); + } + }; + }); + } + function parseStartTag(tag, tagName, rest, unary) { + tagName = tagName.toLowerCase(); + if (block[tagName]) { + while (stack.last() && inline[stack.last()]) { + parseEndTag('', stack.last()); + } + } + if (closeSelf[tagName] && stack.last() === tagName) { + parseEndTag('', tagName); + } + unary = empty[tagName] || !!unary; + handler.start(tagName, unary); + if (!unary) { + stack.push(tagName); + } + HTMLParser.parseAttrs(rest, handler); + handler.end(tagName, unary); + } + function parseEndTag(tag, tagName) { + var pos; + if (!tagName) { + pos = 0; + } else { + for (pos = stack.length - 1; pos >= 0; pos--) { + if (stack[pos] === tagName) { + break; + } + } + } + if (pos >= 0) { + for (var i = stack.length - 1; i >= pos; i--) { + if (handler.close) { + handler.close(stack[i]); + } + } + stack.length = pos; + } + } + function parseMustache(mustache, inside) { + if (handler.special) { + handler.special(inside); + } + } + var index, chars, match, stack = [], last = html; + stack.last = function () { + return this[this.length - 1]; + }; + while (html) { + chars = true; + if (!stack.last() || !special[stack.last()]) { + if (html.indexOf(''); + if (index >= 0) { + if (handler.comment) { + handler.comment(html.substring(4, index)); + } + html = html.substring(index + 3); + chars = false; + } + } else if (html.indexOf(']*>'), function (all, text) { + text = text.replace(/|/g, '$1$2'); + if (handler.chars) { + handler.chars(text); + } + return ''; + }); + parseEndTag('', stack.last()); + } + if (html === last) { + throw 'Parse Error: ' + html; + } + last = html; + } + parseEndTag(); + handler.done(); + return intermediate; + }; + HTMLParser.parseAttrs = function (rest, handler) { + (rest != null ? rest : '').replace(attr, function (text, name, special, dblQuote, singleQuote, val) { + if (special) { + handler.special(special); + } + if (name || dblQuote || singleQuote || val) { + var value = arguments[3] ? arguments[3] : arguments[4] ? arguments[4] : arguments[5] ? arguments[5] : fillAttrs[name.toLowerCase()] ? name : ''; + handler.attrStart(name || ''); + var last = mustache.lastIndex = 0, res = mustache.exec(value), chars; + while (res) { + chars = value.substring(last, mustache.lastIndex - res[0].length); + if (chars.length) { + handler.attrValue(chars); + } + handler.special(res[1]); + last = mustache.lastIndex; + res = mustache.exec(value); + } + chars = value.substr(last, value.length); + if (chars) { + handler.attrValue(chars); + } + handler.attrEnd(name || ''); + } + }); + }; + can.view.parser = HTMLParser; + return HTMLParser; +}); +/*can@2.2.6#view/live/live*/ +define('can/view/live/live', [ + 'can/util/util', + 'can/view/elements', + 'can/view/view', + 'can/view/node_lists/node_lists', + 'can/view/parser/parser' +], function (can, elements, view, nodeLists, parser) { + elements = elements || can.view.elements; + nodeLists = nodeLists || can.view.NodeLists; + parser = parser || can.view.parser; + var setup = function (el, bind, unbind) { + var tornDown = false, teardown = function () { + if (!tornDown) { + tornDown = true; + unbind(data); + can.unbind.call(el, 'removed', teardown); + } + return true; + }, data = { + teardownCheck: function (parent) { + return parent ? false : teardown(); + } + }; + can.bind.call(el, 'removed', teardown); + bind(data); + return data; + }, listen = function (el, compute, change) { + return setup(el, function () { + compute.bind('change', change); + }, function (data) { + compute.unbind('change', change); + if (data.nodeList) { + nodeLists.unregister(data.nodeList); + } + }); + }, getAttributeParts = function (newVal) { + var attrs = {}, attr; + parser.parseAttrs(newVal, { + attrStart: function (name) { + attrs[name] = ''; + attr = name; + }, + attrValue: function (value) { + attrs[attr] += value; + }, + attrEnd: function () { + } + }); + return attrs; + }, splice = [].splice, isNode = function (obj) { + return obj && obj.nodeType; + }, addTextNodeIfNoChildren = function (frag) { + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + }; + var live = { + list: function (el, compute, render, context, parentNode, nodeList) { + var masterNodeList = nodeList || [el], indexMap = [], afterPreviousEvents = false, isTornDown = false, add = function (ev, items, index) { + if (!afterPreviousEvents) { + return; + } + var frag = document.createDocumentFragment(), newNodeLists = [], newIndicies = []; + can.each(items, function (item, key) { + var itemNodeList = []; + if (nodeList) { + nodeLists.register(itemNodeList, null, true); + } + var itemIndex = can.compute(key + index), itemHTML = render.call(context, item, itemIndex, itemNodeList), gotText = typeof itemHTML === 'string', itemFrag = can.frag(itemHTML); + itemFrag = gotText ? can.view.hookup(itemFrag) : itemFrag; + var childNodes = can.makeArray(itemFrag.childNodes); + if (nodeList) { + nodeLists.update(itemNodeList, childNodes); + newNodeLists.push(itemNodeList); + } else { + newNodeLists.push(nodeLists.register(childNodes)); + } + frag.appendChild(itemFrag); + newIndicies.push(itemIndex); + }); + var masterListIndex = index + 1; + if (!masterNodeList[masterListIndex]) { + elements.after(masterListIndex === 1 ? [text] : [nodeLists.last(masterNodeList[masterListIndex - 1])], frag); + } else { + var el = nodeLists.first(masterNodeList[masterListIndex]); + can.insertBefore(el.parentNode, frag, el); + } + splice.apply(masterNodeList, [ + masterListIndex, + 0 + ].concat(newNodeLists)); + splice.apply(indexMap, [ + index, + 0 + ].concat(newIndicies)); + for (var i = index + newIndicies.length, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + }, remove = function (ev, items, index, duringTeardown, fullTeardown) { + if (!afterPreviousEvents) { + return; + } + if (!duringTeardown && data.teardownCheck(text.parentNode)) { + return; + } + if (index < 0) { + index = indexMap.length + index; + } + var removedMappings = masterNodeList.splice(index + 1, items.length), itemsToRemove = []; + can.each(removedMappings, function (nodeList) { + var nodesToRemove = nodeLists.unregister(nodeList); + [].push.apply(itemsToRemove, nodesToRemove); + }); + indexMap.splice(index, items.length); + for (var i = index, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + if (!fullTeardown) { + can.remove(can.$(itemsToRemove)); + } else { + nodeLists.unregister(masterNodeList); + } + }, move = function (ev, item, newIndex, currentIndex) { + if (!afterPreviousEvents) { + return; + } + newIndex = newIndex + 1; + currentIndex = currentIndex + 1; + var referenceNodeList = masterNodeList[newIndex]; + var movedElements = can.frag(nodeLists.flatten(masterNodeList[currentIndex])); + var referenceElement; + if (currentIndex < newIndex) { + referenceElement = nodeLists.last(referenceNodeList).nextSibling; + } else { + referenceElement = nodeLists.first(referenceNodeList); + } + var parentNode = masterNodeList[0].parentNode; + parentNode.insertBefore(movedElements, referenceElement); + var temp = masterNodeList[currentIndex]; + [].splice.apply(masterNodeList, [ + currentIndex, + 1 + ]); + [].splice.apply(masterNodeList, [ + newIndex, + 0, + temp + ]); + }, text = document.createTextNode(''), list, teardownList = function (fullTeardown) { + if (list && list.unbind) { + list.unbind('add', add).unbind('remove', remove).unbind('move', move); + } + remove({}, { length: masterNodeList.length - 1 }, 0, true, fullTeardown); + }, updateList = function (ev, newList, oldList) { + if (isTornDown) { + return; + } + teardownList(); + list = newList || []; + if (list.bind) { + list.bind('add', add).bind('remove', remove).bind('move', move); + } + afterPreviousEvents = true; + add({}, list, 0); + afterPreviousEvents = false; + can.batch.afterPreviousEvents(function () { + afterPreviousEvents = true; + }); + }; + parentNode = elements.getParentNode(el, parentNode); + var data = setup(parentNode, function () { + if (can.isFunction(compute)) { + compute.bind('change', updateList); + } + }, function () { + if (can.isFunction(compute)) { + compute.unbind('change', updateList); + } + teardownList(true); + }); + if (!nodeList) { + live.replace(masterNodeList, text, data.teardownCheck); + } else { + elements.replace(masterNodeList, text); + nodeLists.update(masterNodeList, [text]); + nodeList.unregistered = function () { + data.teardownCheck(); + isTornDown = true; + }; + } + updateList({}, can.isFunction(compute) ? compute() : compute); + }, + html: function (el, compute, parentNode, nodeList) { + var data; + parentNode = elements.getParentNode(el, parentNode); + data = listen(parentNode, compute, function (ev, newVal, oldVal) { + var attached = nodeLists.first(nodes).parentNode; + if (attached) { + makeAndPut(newVal); + } + data.teardownCheck(nodeLists.first(nodes).parentNode); + }); + var nodes = nodeList || [el], makeAndPut = function (val) { + var isFunction = typeof val === 'function', aNode = isNode(val), frag = can.frag(isFunction ? '' : val), oldNodes = can.makeArray(nodes); + addTextNodeIfNoChildren(frag); + if (!aNode && !isFunction) { + frag = can.view.hookup(frag, parentNode); + } + oldNodes = nodeLists.update(nodes, frag.childNodes); + if (isFunction) { + val(frag.childNodes[0]); + } + elements.replace(oldNodes, frag); + }; + data.nodeList = nodes; + if (!nodeList) { + nodeLists.register(nodes, data.teardownCheck); + } else { + nodeList.unregistered = data.teardownCheck; + } + makeAndPut(compute()); + }, + replace: function (nodes, val, teardown) { + var oldNodes = nodes.slice(0), frag = can.frag(val); + nodeLists.register(nodes, teardown); + if (typeof val === 'string') { + frag = can.view.hookup(frag, nodes[0].parentNode); + } + nodeLists.update(nodes, frag.childNodes); + elements.replace(oldNodes, frag); + return nodes; + }, + text: function (el, compute, parentNode, nodeList) { + var parent = elements.getParentNode(el, parentNode); + var data = listen(parent, compute, function (ev, newVal, oldVal) { + if (typeof node.nodeValue !== 'unknown') { + node.nodeValue = can.view.toStr(newVal); + } + data.teardownCheck(node.parentNode); + }); + var node = document.createTextNode(can.view.toStr(compute())); + if (nodeList) { + nodeList.unregistered = data.teardownCheck; + data.nodeList = nodeList; + nodeLists.update(nodeList, [node]); + elements.replace([el], node); + } else { + data.nodeList = live.replace([el], node, data.teardownCheck); + } + }, + setAttributes: function (el, newVal) { + var attrs = getAttributeParts(newVal); + for (var name in attrs) { + can.attr.set(el, name, attrs[name]); + } + }, + attributes: function (el, compute, currentValue) { + var oldAttrs = {}; + var setAttrs = function (newVal) { + var newAttrs = getAttributeParts(newVal), name; + for (name in newAttrs) { + var newValue = newAttrs[name], oldValue = oldAttrs[name]; + if (newValue !== oldValue) { + can.attr.set(el, name, newValue); + } + delete oldAttrs[name]; + } + for (name in oldAttrs) { + elements.removeAttr(el, name); + } + oldAttrs = newAttrs; + }; + listen(el, compute, function (ev, newVal) { + setAttrs(newVal); + }); + if (arguments.length >= 3) { + oldAttrs = getAttributeParts(currentValue); + } else { + setAttrs(compute()); + } + }, + attributePlaceholder: '__!!__', + attributeReplace: /__!!__/g, + attribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, hook.render()); + }); + var wrapped = can.$(el), hooks; + hooks = can.data(wrapped, 'hooks'); + if (!hooks) { + can.data(wrapped, 'hooks', hooks = {}); + } + var attr = elements.getAttr(el, attributeName), parts = attr.split(live.attributePlaceholder), goodParts = [], hook; + goodParts.push(parts.shift(), parts.join(live.attributePlaceholder)); + if (hooks[attributeName]) { + hooks[attributeName].computes.push(compute); + } else { + hooks[attributeName] = { + render: function () { + var i = 0, newAttr = attr ? attr.replace(live.attributeReplace, function () { + return elements.contentText(hook.computes[i++]()); + }) : elements.contentText(hook.computes[i++]()); + return newAttr; + }, + computes: [compute], + batchNum: undefined + }; + } + hook = hooks[attributeName]; + goodParts.splice(1, 0, compute()); + elements.setAttr(el, attributeName, goodParts.join('')); + }, + specialAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, getValue(newVal)); + }); + elements.setAttr(el, attributeName, getValue(compute())); + }, + simpleAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, newVal); + }); + elements.setAttr(el, attributeName, compute()); + } + }; + live.attr = live.simpleAttribute; + live.attrs = live.attributes; + var newLine = /(\r|\n)+/g; + var getValue = function (val) { + var regexp = /^["'].*["']$/; + val = val.replace(elements.attrReg, '').replace(newLine, ''); + return regexp.test(val) ? val.substr(1, val.length - 2) : val; + }; + can.view.live = live; + return live; +}); +/*can@2.2.6#view/render*/ +define('can/view/render', [ + 'can/view/view', + 'can/view/elements', + 'can/view/live/live', + 'can/util/string/string' +], function (can, elements, live) { + var pendingHookups = [], tagChildren = function (tagName) { + var newTag = elements.tagMap[tagName] || 'span'; + if (newTag === 'span') { + return '@@!!@@'; + } + return '<' + newTag + '>' + tagChildren(newTag) + ''; + }, contentText = function (input, tag) { + if (typeof input === 'string') { + return input; + } + if (!input && input !== 0) { + return ''; + } + var hook = input.hookup && function (el, id) { + input.hookup.call(input, el, id); + } || typeof input === 'function' && input; + if (hook) { + if (tag) { + return '<' + tag + ' ' + can.view.hook(hook) + '>'; + } else { + pendingHookups.push(hook); + } + return ''; + } + return '' + input; + }, contentEscape = function (txt, tag) { + return typeof txt === 'string' || typeof txt === 'number' ? can.esc(txt) : contentText(txt, tag); + }, withinTemplatedSectionWithinAnElement = false, emptyHandler = function () { + }; + var lastHookups; + can.extend(can.view, { + live: live, + setupLists: function () { + var old = can.view.lists, data; + can.view.lists = function (list, renderer) { + data = { + list: list, + renderer: renderer + }; + return Math.random(); + }; + return function () { + can.view.lists = old; + return data; + }; + }, + getHooks: function () { + var hooks = pendingHookups.slice(0); + lastHookups = hooks; + pendingHookups = []; + return hooks; + }, + onlytxt: function (self, func) { + return contentEscape(func.call(self)); + }, + txt: function (escape, tagName, status, self, func) { + var tag = elements.tagMap[tagName] || 'span', setupLiveBinding = false, value, listData, compute, unbind = emptyHandler, attributeName; + if (withinTemplatedSectionWithinAnElement) { + value = func.call(self); + } else { + if (typeof status === 'string' || status === 1) { + withinTemplatedSectionWithinAnElement = true; + } + var listTeardown = can.view.setupLists(); + unbind = function () { + compute.unbind('change', emptyHandler); + }; + compute = can.compute(func, self, false); + compute.bind('change', emptyHandler); + listData = listTeardown(); + value = compute(); + withinTemplatedSectionWithinAnElement = false; + setupLiveBinding = compute.computeInstance.hasDependencies; + } + if (listData) { + unbind(); + return '<' + tag + can.view.hook(function (el, parentNode) { + live.list(el, listData.list, listData.renderer, self, parentNode); + }) + '>'; + } + if (!setupLiveBinding || typeof value === 'function') { + unbind(); + return (withinTemplatedSectionWithinAnElement || escape === 2 || !escape ? contentText : contentEscape)(value, status === 0 && tag); + } + var contentProp = elements.tagToContentPropMap[tagName]; + if (status === 0 && !contentProp) { + return '<' + tag + can.view.hook(escape && typeof value !== 'object' ? function (el, parentNode) { + live.text(el, compute, parentNode); + unbind(); + } : function (el, parentNode) { + live.html(el, compute, parentNode); + unbind(); + }) + '>' + tagChildren(tag) + ''; + } else if (status === 1) { + pendingHookups.push(function (el) { + live.attributes(el, compute, compute()); + unbind(); + }); + return compute(); + } else if (escape === 2) { + attributeName = status; + pendingHookups.push(function (el) { + live.specialAttribute(el, attributeName, compute); + unbind(); + }); + return compute(); + } else { + attributeName = status === 0 ? contentProp : status; + (status === 0 ? lastHookups : pendingHookups).push(function (el) { + live.attribute(el, attributeName, compute); + unbind(); + }); + return live.attributePlaceholder; + } + } + }); + return can; +}); +/*can@2.2.6#view/stache/utils*/ +define('can/view/stache/utils', ['can/util/util'], function () { + return { + isArrayLike: function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, + isObserveLike: function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, + emptyHandler: function () { + }, + jsonParse: function (str) { + if (str[0] === '\'') { + return str.substr(1, str.length - 2); + } else if (str === 'undefined') { + return undefined; + } else if (can.global.JSON) { + return JSON.parse(str); + } else { + return eval('(' + str + ')'); + } + }, + mixins: { + last: function () { + return this.stack[this.stack.length - 1]; + }, + add: function (chars) { + this.last().add(chars); + }, + subSectionDepth: function () { + return this.stack.length - 1; + } + } + }; +}); +/*can@2.2.6#view/stache/mustache_helpers*/ +define('can/view/stache/mustache_helpers', [ + 'can/util/util', + 'can/view/stache/utils', + 'can/view/live/live' +], function (can, utils, live) { + live = live || can.view.live; + var resolve = function (value) { + if (utils.isObserveLike(value) && utils.isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + var helpers = { + 'each': function (items, options) { + var resolved = resolve(items), result = [], keys, key, i; + if (resolved instanceof can.List) { + return function (el) { + var nodeList = [el]; + nodeList.expression = 'live.list'; + can.view.nodeLists.register(nodeList, null, options.nodeList); + can.view.nodeLists.update(options.nodeList, [el]); + var cb = function (item, index, parentNodeList) { + return options.fn(options.scope.add({ '@index': index }).add(item), options.options, parentNodeList); + }; + live.list(el, items, cb, options.context, el.parentNode, nodeList); + }; + } + var expr = resolved; + if (!!expr && utils.isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + } else if (utils.isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } + return result; + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + }, + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!resolve(expr); + } + if (value) { + return options.fn(options.scope || this); + } else { + return options.inverse(options.scope || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return helpers.is.apply(this, arguments); + }, + 'unless': function (expr, options) { + return helpers['if'].apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'with': function (expr, options) { + var ctx = expr; + expr = resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + 'data': function (attr) { + var data = arguments.length === 2 ? this : arguments[1]; + return function (el) { + can.data(can.$(el), attr, data || this.context); + }; + } + }; + return { + registerHelper: function (name, callback) { + helpers[name] = callback; + }, + getHelper: function (name, options) { + var helper = options.attr('helpers.' + name); + if (!helper) { + helper = helpers[name]; + } + if (helper) { + return { fn: helper }; + } + } + }; +}); +/*can@2.2.6#view/stache/mustache_core*/ +define('can/view/stache/mustache_core', [ + 'can/util/util', + 'can/view/stache/utils', + 'can/view/stache/mustache_helpers', + 'can/view/live/live', + 'can/view/elements', + 'can/view/scope/scope', + 'can/view/node_lists/node_lists' +], function (can, utils, mustacheHelpers, live, elements, Scope, nodeLists) { + live = live || can.view.live; + elements = elements || can.view.elements; + Scope = Scope || can.view.Scope; + nodeLists = nodeLists || can.view.nodeLists; + var argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(?:(.+?)=(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(.+))))$/, mustacheLineBreakRegExp = /(?:(?:^|(\r?)\n)(\s*)(\{\{([^\}]*)\}\}\}?)([^\S\n\r]*)($|\r?\n))|(\{\{([^\}]*)\}\}\}?)/g, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, getItemsFragContent = function (items, isObserveList, helperOptions, options) { + var frag = document.createDocumentFragment(); + for (var i = 0, len = items.length; i < len; i++) { + append(frag, helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options)); + } + return frag; + }, append = function (frag, content) { + if (content) { + frag.appendChild(typeof content === 'string' ? document.createTextNode(content) : content); + } + }, getItemsStringContent = function (items, isObserveList, helperOptions, options) { + var txt = ''; + for (var i = 0, len = items.length; i < len; i++) { + txt += helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options); + } + return txt; + }, getKeyComputeData = function (key, scope, isArgument) { + var data = scope.computeData(key, { + isArgument: isArgument, + args: [ + scope.attr('.'), + scope + ] + }); + can.compute.temporarilyBind(data.compute); + return data; + }, getKeyArgValue = function (key, scope) { + var data = getKeyComputeData(key, scope, true); + if (!data.compute.computeInstance.hasDependencies) { + return data.initialValue; + } else { + return data.compute; + } + }, convertToScopes = function (helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer) { + if (truthyRenderer) { + helperOptions.fn = makeRendererConvertScopes(truthyRenderer, scope, options, nodeList); + } + if (falseyRenderer) { + helperOptions.inverse = makeRendererConvertScopes(falseyRenderer, scope, options, nodeList); + } + }, makeRendererConvertScopes = function (renderer, parentScope, parentOptions, nodeList) { + var rendererWithScope = function (ctx, opts, parentNodeList) { + return renderer(ctx || parentScope, opts, parentNodeList); + }; + return can.__notObserve(function (newScope, newOptions, parentNodeList) { + if (newScope !== undefined && !(newScope instanceof can.view.Scope)) { + newScope = parentScope.add(newScope); + } + if (newOptions !== undefined && !(newOptions instanceof core.Options)) { + newOptions = parentOptions.add(newOptions); + } + var result = rendererWithScope(newScope, newOptions || parentOptions, parentNodeList || nodeList); + return result; + }); + }; + var core = { + expressionData: function (expression) { + var args = [], hashes = {}, i = 0; + (can.trim(expression) + ' ').replace(argumentsRegExp, function (whole, arg) { + var m; + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[1] || m[2]) { + args.push(utils.jsonParse(m[1] || m[2])); + } else { + hashes[m[3]] = m[6] ? { get: m[6] } : utils.jsonParse(m[4] || m[5]); + } + } else { + args.push({ get: arg }); + } + i++; + }); + return { + name: args.shift(), + args: args, + hash: hashes + }; + }, + makeEvaluator: function (scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, stringOnly) { + var args = [], hash = {}, helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, context = scope.attr('.'), name = exprData.name, helper, looksLikeAHelper = exprData.args.length || !can.isEmptyObject(exprData.hash), initialValue, helperEvaluator; + for (var i = 0, len = exprData.args.length; i < len; i++) { + var arg = exprData.args[i]; + if (arg && isLookup(arg)) { + args.push(getKeyArgValue(arg.get, scope, true)); + } else { + args.push(arg); + } + } + for (var prop in exprData.hash) { + if (isLookup(exprData.hash[prop])) { + hash[prop] = getKeyArgValue(exprData.hash[prop].get, scope); + } else { + hash[prop] = exprData.hash[prop]; + } + } + if (isLookup(name)) { + if (looksLikeAHelper) { + helper = mustacheHelpers.getHelper(name.get, options); + if (!helper && typeof context[name.get] === 'function') { + helper = { fn: context[name.get] }; + } + } + if (!helper) { + var get = name.get; + var computeData = getKeyComputeData(name.get, scope, false), compute = computeData.compute; + initialValue = computeData.initialValue; + if (computeData.compute.computeInstance.hasDependencies) { + name = compute; + } else { + name = initialValue; + } + if (!looksLikeAHelper && initialValue === undefined) { + helper = mustacheHelpers.getHelper(get, options); + } else if (typeof initialValue === 'function') { + helper = { fn: initialValue }; + } + } + } + if (mode === '^') { + var temp = truthyRenderer; + truthyRenderer = falseyRenderer; + falseyRenderer = temp; + } + if (helper) { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + can.simpleExtend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash, + nodeList: nodeList, + exprData: exprData + }); + args.push(helperOptions); + helperEvaluator = function () { + return helper.fn.apply(context, args) || ''; + }; + helperEvaluator.bindOnce = false; + return helperEvaluator; + } + if (!mode) { + if (name && name.isComputed) { + return name; + } else { + return function () { + return '' + (name != null ? name : ''); + }; + } + } else if (mode === '#' || mode === '^') { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + var evaluator = function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + if (utils.isArrayLike(value)) { + var isObserveList = utils.isObserveLike(value); + if (isObserveList ? value.attr('length') : value.length) { + return (stringOnly ? getItemsStringContent : getItemsFragContent)(value, isObserveList, helperOptions, options); + } else { + return helperOptions.inverse(scope, options); + } + } else { + return value ? helperOptions.fn(value || scope, options) : helperOptions.inverse(scope, options); + } + }; + evaluator.bindOnce = false; + return evaluator; + } else { + } + }, + makeLiveBindingPartialRenderer: function (partialName, state) { + partialName = can.trim(partialName); + return function (scope, options, parentSectionNodeList) { + var nodeList = [this]; + nodeList.expression = '>' + partialName; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var partialFrag = can.compute(function () { + var localPartialName = partialName; + var partial = options.attr('partials.' + localPartialName), res; + if (partial) { + res = partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + var scopePartialName = scope.read(localPartialName, { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }).value; + if (scopePartialName) { + localPartialName = scopePartialName; + } + res = can.view.render(localPartialName, scope, options); + } + return can.frag(res); + }); + live.html(this, partialFrag, this.parentNode, nodeList); + }; + }, + makeStringBranchRenderer: function (mode, expression) { + var exprData = expressionData(expression), fullExpression = mode + expression; + return function branchRenderer(scope, options, truthyRenderer, falseyRenderer) { + var evaluator = scope.__cache[fullExpression]; + if (mode || !evaluator) { + evaluator = makeEvaluator(scope, options, null, mode, exprData, truthyRenderer, falseyRenderer, true); + if (!mode) { + scope.__cache[fullExpression] = evaluator; + } + } + var res = evaluator(); + return res == null ? '' : '' + res; + }; + }, + makeLiveBindingBranchRenderer: function (mode, expression, state) { + var exprData = expressionData(expression); + return function branchRenderer(scope, options, parentSectionNodeList, truthyRenderer, falseyRenderer) { + var nodeList = [this]; + nodeList.expression = expression; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var evaluator = makeEvaluator(scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, state.tag); + var compute = can.compute(evaluator, null, false, evaluator.bindOnce === false ? false : true); + compute.bind('change', can.k); + var value = compute(); + if (typeof value === 'function') { + var old = can.__clearReading(); + value(this); + can.__setReading(old); + } else if (compute.computeInstance.hasDependencies) { + if (state.attr) { + live.simpleAttribute(this, state.attr, compute); + } else if (state.tag) { + live.attributes(this, compute); + } else if (state.text && typeof value !== 'object') { + live.text(this, compute, this.parentNode, nodeList); + } else { + live.html(this, compute, this.parentNode, nodeList); + } + } else { + if (state.attr) { + can.attr.set(this, state.attr, value); + } else if (state.tag) { + live.setAttributes(this, value); + } else if (state.text && typeof value === 'string') { + this.nodeValue = value; + } else if (value) { + elements.replace([this], can.frag(value)); + } + } + compute.unbind('change', can.k); + }; + }, + splitModeFromExpression: function (expression, state) { + expression = can.trim(expression); + var mode = expression.charAt(0); + if ('#/{&^>!'.indexOf(mode) >= 0) { + expression = can.trim(expression.substr(1)); + } else { + mode = null; + } + if (mode === '{' && state.node) { + mode = null; + } + return { + mode: mode, + expression: expression + }; + }, + cleanLineEndings: function (template) { + return template.replace(mustacheLineBreakRegExp, function (whole, returnBefore, spaceBefore, special, expression, spaceAfter, returnAfter, spaceLessSpecial, spaceLessExpression, matchIndex) { + spaceAfter = spaceAfter || ''; + returnBefore = returnBefore || ''; + spaceBefore = spaceBefore || ''; + var modeAndExpression = splitModeFromExpression(expression || spaceLessExpression, {}); + if (spaceLessSpecial || '>{'.indexOf(modeAndExpression.mode) >= 0) { + return whole; + } else if ('^#!/'.indexOf(modeAndExpression.mode) >= 0) { + return special + (matchIndex !== 0 && returnAfter.length ? returnBefore + '\n' : ''); + } else { + return spaceBefore + special + spaceAfter + (spaceBefore.length || matchIndex !== 0 ? returnBefore + '\n' : ''); + } + }); + }, + Options: can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }) + }; + var makeEvaluator = core.makeEvaluator, expressionData = core.expressionData, splitModeFromExpression = core.splitModeFromExpression; + return core; +}); +/*can@2.2.6#view/bindings/bindings*/ +define('can/view/bindings/bindings', [ + 'can/util/util', + 'can/view/stache/mustache_core', + 'can/view/callbacks/callbacks', + 'can/control/control', + 'can/view/scope/scope' +], function (can, mustacheCore) { + var isContentEditable = function () { + var values = { + '': true, + 'true': true, + 'false': false + }; + var editable = function (el) { + if (!el || !el.getAttribute) { + return; + } + var attr = el.getAttribute('contenteditable'); + return values[attr]; + }; + return function (el) { + var val = editable(el); + if (typeof val === 'boolean') { + return val; + } else { + return !!editable(el.parentNode); + } + }; + }(), removeCurly = function (value) { + if (value[0] === '{' && value[value.length - 1] === '}') { + return value.substr(1, value.length - 2); + } + return value; + }; + can.view.attr('can-value', function (el, data) { + var attr = can.trim(removeCurly(el.getAttribute('can-value'))), value = data.scope.computeData(attr, { args: [] }).compute, trueValue, falseValue; + if (el.nodeName.toLowerCase() === 'input') { + if (el.type === 'checkbox') { + if (can.attr.has(el, 'can-true-value')) { + trueValue = el.getAttribute('can-true-value'); + } else { + trueValue = true; + } + if (can.attr.has(el, 'can-false-value')) { + falseValue = el.getAttribute('can-false-value'); + } else { + falseValue = false; + } + } + if (el.type === 'checkbox' || el.type === 'radio') { + new Checked(el, { + value: value, + trueValue: trueValue, + falseValue: falseValue + }); + return; + } + } + if (el.nodeName.toLowerCase() === 'select' && el.multiple) { + new Multiselect(el, { value: value }); + return; + } + if (isContentEditable(el)) { + new Content(el, { value: value }); + return; + } + new Value(el, { value: value }); + }); + var special = { + enter: function (data, el, original) { + return { + event: 'keyup', + handler: function (ev) { + if (ev.keyCode === 13) { + return original.call(this, ev); + } + } + }; + } + }; + can.view.attr(/can-[\w\.]+/, function (el, data) { + var attributeName = data.attributeName, event = attributeName.substr('can-'.length), handler = function (ev) { + var attrVal = el.getAttribute(attributeName); + if (!attrVal) { + return; + } + var attrInfo = mustacheCore.expressionData(removeCurly(attrVal)); + var scopeData = data.scope.read(attrInfo.name.get, { + returnObserveMethods: true, + isArgument: true, + executeAnonymousFunctions: true + }); + var args = []; + var $el = can.$(this); + var viewModel = can.viewModel($el[0]); + var localScope = data.scope.add({ + '@element': $el, + '@event': ev, + '@viewModel': viewModel, + '@scope': data.scope, + '@context': data.scope._context + }); + if (!can.isEmptyObject(attrInfo.hash)) { + var hash = {}; + can.each(attrInfo.hash, function (val, key) { + if (val && val.hasOwnProperty('get')) { + var s = !val.get.indexOf('@') ? localScope : data.scope; + hash[key] = s.read(val.get, {}).value; + } else { + hash[key] = val; + } + }); + args.unshift(hash); + } + if (attrInfo.args.length) { + var arg; + for (var i = attrInfo.args.length - 1; i >= 0; i--) { + arg = attrInfo.args[i]; + if (arg && arg.hasOwnProperty('get')) { + var s = !arg.get.indexOf('@') ? localScope : data.scope; + args.unshift(s.read(arg.get, {}).value); + } else { + args.unshift(arg); + } + } + } + if (!args.length) { + args = [ + data.scope._context, + $el + ].concat(can.makeArray(arguments)); + } + return scopeData.value.apply(scopeData.parent, args); + }; + if (special[event]) { + var specialData = special[event](data, el, handler); + handler = specialData.handler; + event = specialData.event; + } + can.bind.call(el, event, handler); + }); + var Value = can.Control.extend({ + init: function () { + if (this.element[0].nodeName.toUpperCase() === 'SELECT') { + setTimeout(can.proxy(this.set, this), 1); + } else { + this.set(); + } + }, + '{value} change': 'set', + set: function () { + if (!this.element) { + return; + } + var val = this.options.value(); + this.element[0].value = val == null ? '' : val; + }, + 'change': function () { + if (!this.element) { + return; + } + var el = this.element[0]; + this.options.value(el.value); + var newVal = this.options.value(); + if (el.value !== newVal) { + el.value = newVal; + } + } + }), Checked = can.Control.extend({ + init: function () { + this.isCheckbox = this.element[0].type.toLowerCase() === 'checkbox'; + this.check(); + }, + '{value} change': 'check', + check: function () { + if (this.isCheckbox) { + var value = this.options.value(), trueValue = this.options.trueValue || true; + this.element[0].checked = value == trueValue; + } else { + var setOrRemove = this.options.value() == this.element[0].value ? 'set' : 'remove'; + can.attr[setOrRemove](this.element[0], 'checked', true); + } + }, + 'change': function () { + if (this.isCheckbox) { + this.options.value(this.element[0].checked ? this.options.trueValue : this.options.falseValue); + } else { + if (this.element[0].checked) { + this.options.value(this.element[0].value); + } + } + } + }), Multiselect = Value.extend({ + init: function () { + this.delimiter = ';'; + setTimeout(can.proxy(this.set, this), 1); + }, + set: function () { + var newVal = this.options.value(); + if (typeof newVal === 'string') { + newVal = newVal.split(this.delimiter); + this.isString = true; + } else if (newVal) { + newVal = can.makeArray(newVal); + } + var isSelected = {}; + can.each(newVal, function (val) { + isSelected[val] = true; + }); + can.each(this.element[0].childNodes, function (option) { + if (option.value) { + option.selected = !!isSelected[option.value]; + } + }); + }, + get: function () { + var values = [], children = this.element[0].childNodes; + can.each(children, function (child) { + if (child.selected && child.value) { + values.push(child.value); + } + }); + return values; + }, + 'change': function () { + var value = this.get(), currentValue = this.options.value(); + if (this.isString || typeof currentValue === 'string') { + this.isString = true; + this.options.value(value.join(this.delimiter)); + } else if (currentValue instanceof can.List) { + currentValue.attr(value, true); + } else { + this.options.value(value); + } + } + }), Content = can.Control.extend({ + init: function () { + this.set(); + this.on('blur', 'setValue'); + }, + '{value} change': 'set', + set: function () { + var val = this.options.value(); + this.element[0].innerHTML = typeof val === 'undefined' ? '' : val; + }, + setValue: function () { + this.options.value(this.element[0].innerHTML); + } + }); +}); +/*can@2.2.6#view/mustache/mustache*/ +define('can/view/mustache/mustache', [ + 'can/util/util', + 'can/view/scope/scope', + 'can/view/view', + 'can/view/scanner', + 'can/compute/compute', + 'can/view/render', + 'can/view/bindings/bindings' +], function (can) { + can.view.ext = '.mustache'; + var SCOPE = 'scope', HASH = '___h4sh', CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options}', SPECIAL_CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options, special: true}', ARG_NAMES = SCOPE + ',options', argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false|null|undefined)|((.+?)=(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false)|(.+))))$/, makeLookupLiteral = function (type) { + return '{get:"' + type.replace(/"/g, '\\"') + '"}'; + }, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, isObserveLike = function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, isArrayLike = function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, makeConvertToScopes = function (original, scope, options) { + var originalWithScope = function (ctx, opts) { + return original(ctx || scope, opts); + }; + return function (updatedScope, updatedOptions) { + if (updatedScope !== undefined && !(updatedScope instanceof can.view.Scope)) { + updatedScope = scope.add(updatedScope); + } + if (updatedOptions !== undefined && !(updatedOptions instanceof can.view.Options)) { + updatedOptions = options.add(updatedOptions); + } + return originalWithScope(updatedScope, updatedOptions || options); + }; + }; + var Mustache = function (options, helpers) { + if (this.constructor !== Mustache) { + var mustache = new Mustache(options); + return function (data, options) { + return mustache.render(data, options); + }; + } + if (typeof options === 'function') { + this.template = { fn: options }; + return; + } + can.extend(this, options); + this.template = this.scanner.scan(this.text, this.name); + }; + can.Mustache = can.global.Mustache = Mustache; + Mustache.prototype.render = function (data, options) { + if (!(data instanceof can.view.Scope)) { + data = new can.view.Scope(data || {}); + } + if (!(options instanceof can.view.Options)) { + options = new can.view.Options(options || {}); + } + options = options || {}; + return this.template.fn.call(data, data, options); + }; + can.extend(Mustache.prototype, { + scanner: new can.view.Scanner({ + text: { + start: '', + scope: SCOPE, + options: ',options: options', + argNames: ARG_NAMES + }, + tokens: [ + [ + 'returnLeft', + '{{{', + '{{[{&]' + ], + [ + 'commentFull', + '{{!}}', + '^[\\s\\t]*{{!.+?}}\\n' + ], + [ + 'commentLeft', + '{{!', + '(\\n[\\s\\t]*{{!|{{!)' + ], + [ + 'escapeFull', + '{{}}', + '(^[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}$)', + function (content) { + return { + before: /^\n.+?\n$/.test(content) ? '\n' : '', + content: content.match(/\{\{(.+?)\}\}/)[1] || '' + }; + } + ], + [ + 'escapeLeft', + '{{' + ], + [ + 'returnRight', + '}}}' + ], + [ + 'right', + '}}' + ] + ], + helpers: [ + { + name: /^>[\s]*\w*/, + fn: function (content, cmd) { + var templateName = can.trim(content.replace(/^>\s?/, '')).replace(/["|']/g, ''); + return 'can.Mustache.renderPartial(\'' + templateName + '\',' + ARG_NAMES + ')'; + } + }, + { + name: /^\s*data\s/, + fn: function (content, cmd) { + var attr = content.match(/["|'](.*)["|']/)[1]; + return 'can.proxy(function(__){' + 'can.data(can.$(__),\'' + attr + '\', this.attr(\'.\')); }, ' + SCOPE + ')'; + } + }, + { + name: /\s*\(([\$\w]+)\)\s*->([^\n]*)/, + fn: function (content) { + var quickFunc = /\s*\(([\$\w]+)\)\s*->([^\n]*)/, parts = content.match(quickFunc); + return 'can.proxy(function(__){var ' + parts[1] + '=can.$(__);with(' + SCOPE + '.attr(\'.\')){' + parts[2] + '}}, this);'; + } + }, + { + name: /^.*$/, + fn: function (content, cmd) { + var mode = false, result = { + content: '', + startTxt: false, + startOnlyTxt: false, + end: false + }; + content = can.trim(content); + if (content.length && (mode = content.match(/^([#^\/]|else$)/))) { + mode = mode[0]; + switch (mode) { + case '#': + case '^': + if (cmd.specialAttribute) { + result.startOnlyTxt = true; + } else { + result.startTxt = true; + result.escaped = 0; + } + break; + case '/': + result.end = true; + result.content += 'return ___v1ew.join("");}}])'; + return result; + } + content = content.substring(1); + } + if (mode !== 'else') { + var args = [], hashes = [], i = 0, m; + result.content += 'can.Mustache.txt(\n' + (cmd.specialAttribute ? SPECIAL_CONTEXT_OBJ : CONTEXT_OBJ) + ',\n' + (mode ? '"' + mode + '"' : 'null') + ','; + (can.trim(content) + ' ').replace(argumentsRegExp, function (whole, arg) { + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[2]) { + args.push(m[0]); + } else { + hashes.push(m[4] + ':' + (m[6] ? m[6] : makeLookupLiteral(m[5]))); + } + } else { + args.push(makeLookupLiteral(arg)); + } + i++; + }); + result.content += args.join(','); + if (hashes.length) { + result.content += ',{' + HASH + ':{' + hashes.join(',') + '}}'; + } + } + if (mode && mode !== 'else') { + result.content += ',[\n\n'; + } + switch (mode) { + case '^': + case '#': + result.content += '{fn:function(' + ARG_NAMES + '){var ___v1ew = [];'; + break; + case 'else': + result.content += 'return ___v1ew.join("");}},\n{inverse:function(' + ARG_NAMES + '){\nvar ___v1ew = [];'; + break; + default: + result.content += ')'; + break; + } + if (!mode) { + result.startTxt = true; + result.end = true; + } + return result; + } + } + ] + }) + }); + var helpers = can.view.Scanner.prototype.helpers; + for (var i = 0; i < helpers.length; i++) { + Mustache.prototype.scanner.helpers.unshift(helpers[i]); + } + Mustache.txt = function (scopeAndOptions, mode, name) { + var scope = scopeAndOptions.scope, options = scopeAndOptions.options, args = [], helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, hash, context = scope.attr('.'), getHelper = true, helper; + for (var i = 3; i < arguments.length; i++) { + var arg = arguments[i]; + if (mode && can.isArray(arg)) { + helperOptions = can.extend.apply(can, [helperOptions].concat(arg)); + } else if (arg && arg[HASH]) { + hash = arg[HASH]; + for (var prop in hash) { + if (isLookup(hash[prop])) { + hash[prop] = Mustache.get(hash[prop].get, scopeAndOptions, false, true); + } + } + } else if (arg && isLookup(arg)) { + args.push(Mustache.get(arg.get, scopeAndOptions, false, true, true)); + } else { + args.push(arg); + } + } + if (isLookup(name)) { + var get = name.get; + name = Mustache.get(name.get, scopeAndOptions, args.length, false); + getHelper = get === name; + } + helperOptions.fn = makeConvertToScopes(helperOptions.fn, scope, options); + helperOptions.inverse = makeConvertToScopes(helperOptions.inverse, scope, options); + if (mode === '^') { + var tmp = helperOptions.fn; + helperOptions.fn = helperOptions.inverse; + helperOptions.inverse = tmp; + } + if (helper = getHelper && (typeof name === 'string' && Mustache.getHelper(name, options)) || can.isFunction(name) && !name.isComputed && { fn: name }) { + can.extend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash + }); + args.push(helperOptions); + return function () { + return helper.fn.apply(context, args) || ''; + }; + } + return function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + var validArgs = args.length ? args : [value], valid = true, result = [], i, argIsObserve, arg; + if (mode) { + for (i = 0; i < validArgs.length; i++) { + arg = validArgs[i]; + argIsObserve = typeof arg !== 'undefined' && isObserveLike(arg); + if (isArrayLike(arg)) { + if (mode === '#') { + valid = valid && !!(argIsObserve ? arg.attr('length') : arg.length); + } else if (mode === '^') { + valid = valid && !(argIsObserve ? arg.attr('length') : arg.length); + } + } else { + valid = mode === '#' ? valid && !!arg : mode === '^' ? valid && !arg : valid; + } + } + } + if (valid) { + if (mode === '#') { + if (isArrayLike(value)) { + var isObserveList = isObserveLike(value); + for (i = 0; i < value.length; i++) { + result.push(helperOptions.fn(isObserveList ? value.attr('' + i) : value[i])); + } + return result.join(''); + } else { + return helperOptions.fn(value || {}) || ''; + } + } else if (mode === '^') { + return helperOptions.inverse(value || {}) || ''; + } else { + return '' + (value != null ? value : ''); + } + } + return ''; + }; + }; + Mustache.get = function (key, scopeAndOptions, isHelper, isArgument, isLookup) { + var context = scopeAndOptions.scope.attr('.'), options = scopeAndOptions.options || {}; + if (isHelper) { + if (Mustache.getHelper(key, options)) { + return key; + } + if (scopeAndOptions.scope && can.isFunction(context[key])) { + return context[key]; + } + } + var computeData = scopeAndOptions.scope.computeData(key, { + isArgument: isArgument, + args: [ + context, + scopeAndOptions.scope + ] + }), compute = computeData.compute; + can.compute.temporarilyBind(compute); + var initialValue = computeData.initialValue, helperObj = Mustache.getHelper(key, options); + if (!isLookup && (initialValue === undefined || computeData.scope !== scopeAndOptions.scope) && Mustache.getHelper(key, options)) { + return key; + } + if (!compute.computeInstance.hasDependencies) { + return initialValue; + } else { + return compute; + } + }; + Mustache.resolve = function (value) { + if (isObserveLike(value) && isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + can.view.Options = can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }); + Mustache._helpers = {}; + Mustache.registerHelper = function (name, fn) { + this._helpers[name] = { + name: name, + fn: fn + }; + }; + Mustache.getHelper = function (name, options) { + var helper; + if (options) { + helper = options.attr('helpers.' + name); + } + return helper ? { fn: helper } : this._helpers[name]; + }; + Mustache.render = function (partial, scope, options) { + if (!can.view.cached[partial]) { + var reads = can.__clearReading(); + var scopePartialName = scope.attr(partial); + if (scopePartialName) { + partial = scopePartialName; + } + can.__setReading(reads); + } + return can.view.render(partial, scope, options); + }; + Mustache.safeString = function (str) { + return { + toString: function () { + return str; + } + }; + }; + Mustache.renderPartial = function (partialName, scope, options) { + var partial = options.attr('partials.' + partialName); + if (partial) { + return partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + return can.Mustache.render(partialName, scope, options); + } + }; + can.each({ + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!Mustache.resolve(expr); + } + if (value) { + return options.fn(options.contexts || this); + } else { + return options.inverse(options.contexts || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = Mustache.resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return Mustache._helpers.is.fn.apply(this, arguments); + }, + 'unless': function (expr, options) { + return Mustache._helpers['if'].fn.apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'each': function (expr, options) { + var resolved = Mustache.resolve(expr), result = [], keys, key, i; + if (can.view.lists && (resolved instanceof can.List || expr && expr.isComputed && resolved === undefined)) { + return can.view.lists(expr, function (item, index) { + return options.fn(options.scope.add({ '@index': index }).add(item)); + }); + } + expr = resolved; + if (!!expr && isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + return result.join(''); + } else if (isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } + }, + 'with': function (expr, options) { + var ctx = expr; + expr = Mustache.resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + } + }, function (fn, name) { + Mustache.registerHelper(name, fn); + }); + can.view.register({ + suffix: 'mustache', + contentType: 'x-mustache-template', + script: function (id, src) { + return 'can.Mustache(function(' + ARG_NAMES + ') { ' + new Mustache({ + text: src, + name: id + }).template.out + ' })'; + }, + renderer: function (id, text) { + return Mustache({ + text: text, + name: id + }); + } + }); + can.mustache.registerHelper = can.proxy(can.Mustache.registerHelper, can.Mustache); + can.mustache.safeString = can.Mustache.safeString; + return can; +}); +/*can@2.2.6#component/component*/ +define('can/component/component', [ + 'can/util/util', + 'can/view/callbacks/callbacks', + 'can/view/elements', + 'can/control/control', + 'can/observe/observe', + 'can/view/mustache/mustache', + 'can/view/bindings/bindings' +], function (can, viewCallbacks, elements) { + var ignoreAttributesRegExp = /^(dataViewId|class|id)$/i, paramReplacer = /\{([^\}]+)\}/g; + var Component = can.Component = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Component) { + var self = this, scope = this.prototype.scope || this.prototype.viewModel; + this.Control = ComponentControl.extend(this.prototype.events); + if (!scope || typeof scope === 'object' && !(scope instanceof can.Map)) { + this.Map = can.Map.extend(scope || {}); + } else if (scope.prototype instanceof can.Map) { + this.Map = scope; + } + this.attributeScopeMappings = {}; + can.each(this.Map ? this.Map.defaults : {}, function (val, prop) { + if (val === '@') { + self.attributeScopeMappings[prop] = prop; + } + }); + if (this.prototype.template) { + if (typeof this.prototype.template === 'function') { + var temp = this.prototype.template; + this.renderer = function () { + return can.view.frag(temp.apply(null, arguments)); + }; + } else { + this.renderer = can.view.mustache(this.prototype.template); + } + } + can.view.tag(this.prototype.tag, function (el, options) { + new self(el, options); + }); + } + } + }, { + setup: function (el, hookupOptions) { + var initialScopeData = {}, component = this, lexicalContent = (typeof this.leakScope === 'undefined' ? false : !this.leakScope) && this.template, twoWayBindings = {}, scope = this.scope || this.viewModel, viewModelPropertyUpdates = {}, componentScope, frag, teardownFunctions = [], callTeardownFunctions = function () { + for (var i = 0, len = teardownFunctions.length; i < len; i++) { + teardownFunctions[i](); + } + }; + can.each(this.constructor.attributeScopeMappings, function (val, prop) { + initialScopeData[prop] = el.getAttribute(can.hyphenate(val)); + }); + can.each(can.makeArray(el.attributes), function (node, index) { + var name = can.camelize(node.nodeName.toLowerCase()), value = node.value; + if (component.constructor.attributeScopeMappings[name] || ignoreAttributesRegExp.test(name) || viewCallbacks.attr(node.nodeName)) { + return; + } + if (value[0] === '{' && value[value.length - 1] === '}') { + value = value.substr(1, value.length - 2); + } else { + if (hookupOptions.templateType !== 'legacy') { + initialScopeData[name] = value; + return; + } + } + var computeData = hookupOptions.scope.computeData(value, { args: [] }), compute = computeData.compute; + var handler = function (ev, newVal) { + viewModelPropertyUpdates[name] = (viewModelPropertyUpdates[name] || 0) + 1; + componentScope.attr(name, newVal); + can.batch.afterPreviousEvents(function () { + --viewModelPropertyUpdates[name]; + }); + }; + compute.bind('change', handler); + initialScopeData[name] = compute(); + if (!compute.computeInstance.hasDependencies) { + compute.unbind('change', handler); + } else { + teardownFunctions.push(function () { + compute.unbind('change', handler); + }); + twoWayBindings[name] = computeData; + } + }); + if (this.constructor.Map) { + componentScope = new this.constructor.Map(initialScopeData); + } else if (scope instanceof can.Map) { + componentScope = scope; + } else if (can.isFunction(scope)) { + var scopeResult = scope.call(this, initialScopeData, hookupOptions.scope, el); + if (scopeResult instanceof can.Map) { + componentScope = scopeResult; + } else if (scopeResult.prototype instanceof can.Map) { + componentScope = new scopeResult(initialScopeData); + } else { + componentScope = new (can.Map.extend(scopeResult))(initialScopeData); + } + } + var handlers = {}; + can.each(twoWayBindings, function (computeData, prop) { + handlers[prop] = function (ev, newVal) { + if (!viewModelPropertyUpdates[prop]) { + computeData.compute(newVal); + } + }; + componentScope.bind(prop, handlers[prop]); + }); + if (!can.isEmptyObject(this.constructor.attributeScopeMappings) || hookupOptions.templateType !== 'legacy') { + can.bind.call(el, 'attributes', function (ev) { + var camelized = can.camelize(ev.attributeName); + if (!twoWayBindings[camelized] && !ignoreAttributesRegExp.test(camelized)) { + componentScope.attr(camelized, el.getAttribute(ev.attributeName)); + } + }); + } + this.scope = this.viewModel = componentScope; + can.data(can.$(el), 'scope', this.scope); + can.data(can.$(el), 'viewModel', this.scope); + var renderedScope = lexicalContent ? this.scope : hookupOptions.scope.add(this.scope), options = { helpers: {} }; + can.each(this.helpers || {}, function (val, prop) { + if (can.isFunction(val)) { + options.helpers[prop] = function () { + return val.apply(componentScope, arguments); + }; + } + }); + teardownFunctions.push(function () { + can.each(handlers, function (handler, prop) { + componentScope.unbind(prop, handlers[prop]); + }); + }); + this._control = new this.constructor.Control(el, { + scope: this.scope, + viewModel: this.scope + }); + if (this._control && this._control.destroy) { + var oldDestroy = this._control.destroy; + this._control.destroy = function () { + oldDestroy.apply(this, arguments); + callTeardownFunctions(); + }; + this._control.on(); + } else { + can.bind.call(el, 'removed', function () { + callTeardownFunctions(); + }); + } + var nodeList = can.view.nodeLists.register([], undefined, true); + teardownFunctions.push(function () { + can.view.nodeLists.unregister(nodeList); + }); + if (this.constructor.renderer) { + if (!options.tags) { + options.tags = {}; + } + options.tags.content = function contentHookup(el, rendererOptions) { + var subtemplate = hookupOptions.subtemplate || rendererOptions.subtemplate; + if (subtemplate) { + delete options.tags.content; + var opts = !lexicalContent || subtemplate !== hookupOptions.subtemplate ? rendererOptions : hookupOptions; + if (rendererOptions.parentNodeList) { + var frag = subtemplate(opts.scope, opts.options, rendererOptions.parentNodeList); + elements.replace([el], frag); + } else { + can.view.live.replace([el], subtemplate(opts.scope, opts.options)); + } + options.tags.content = contentHookup; + } + }; + frag = this.constructor.renderer(renderedScope, hookupOptions.options.add(options), nodeList); + } else { + if (hookupOptions.templateType === 'legacy') { + frag = can.view.frag(hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options)) : ''); + } else { + frag = hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options), nodeList) : document.createDocumentFragment(); + } + } + can.appendChild(el, frag); + can.view.nodeLists.update(nodeList, el.childNodes); + } + }); + var ComponentControl = can.Control.extend({ + _lookup: function (options) { + return [ + options.scope, + options, + window + ]; + }, + _action: function (methodName, options, controlInstance) { + var hasObjectLookup, readyCompute; + paramReplacer.lastIndex = 0; + hasObjectLookup = paramReplacer.test(methodName); + if (!controlInstance && hasObjectLookup) { + return; + } else if (!hasObjectLookup) { + return can.Control._action.apply(this, arguments); + } else { + readyCompute = can.compute(function () { + var delegate; + var name = methodName.replace(paramReplacer, function (matched, key) { + var value; + if (key === 'scope' || key === 'viewModel') { + delegate = options.scope; + return ''; + } + key = key.replace(/^(scope|^viewModel)\./, ''); + value = can.compute.read(options.scope, key.split('.'), { isArgument: true }).value; + if (value === undefined) { + value = can.getObject(key); + } + if (typeof value === 'string') { + return value; + } else { + delegate = value; + return ''; + } + }); + var parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: this.processors[event] || this.processors.click, + parts: [ + name, + parts.join(' '), + event + ], + delegate: delegate || undefined + }; + }, this); + var handler = function (ev, ready) { + controlInstance._bindings.control[methodName](controlInstance.element); + controlInstance._bindings.control[methodName] = ready.processor(ready.delegate || controlInstance.element, ready.parts[2], ready.parts[1], methodName, controlInstance); + }; + readyCompute.bind('change', handler); + controlInstance._bindings.readyComputes[methodName] = { + compute: readyCompute, + handler: handler + }; + return readyCompute(); + } + } + }, { + setup: function (el, options) { + this.scope = options.scope; + this.viewModel = options.viewModel; + return can.Control.prototype.setup.call(this, el, options); + }, + off: function () { + if (this._bindings) { + can.each(this._bindings.readyComputes || {}, function (value) { + value.compute.unbind('change', value.handler); + }); + } + can.Control.prototype.off.apply(this, arguments); + this._bindings.readyComputes = {}; + } + }); + var $ = can.$; + if ($.fn) { + $.fn.scope = $.fn.viewModel = function () { + return can.viewModel.apply(can, [this].concat(can.makeArray(arguments))); + }; + } + return Component; +}); +/*can@2.2.6#model/model*/ +define('can/model/model', [ + 'can/util/util', + 'can/map/map', + 'can/list/list' +], function (can) { + var pipe = function (def, thisArg, func) { + var d = new can.Deferred(); + def.then(function () { + var args = can.makeArray(arguments), success = true; + try { + args[0] = func.apply(thisArg, args); + } catch (e) { + success = false; + d.rejectWith(d, [e].concat(args)); + } + if (success) { + d.resolveWith(d, args); + } + }, function () { + d.rejectWith(this, arguments); + }); + if (typeof def.abort === 'function') { + d.abort = function () { + return def.abort(); + }; + } + return d; + }, modelNum = 0, getId = function (inst) { + can.__observe(inst, inst.constructor.id); + return inst.__get(inst.constructor.id); + }, ajax = function (ajaxOb, data, type, dataType, success, error) { + var params = {}; + if (typeof ajaxOb === 'string') { + var parts = ajaxOb.split(/\s+/); + params.url = parts.pop(); + if (parts.length) { + params.type = parts.pop(); + } + } else { + can.extend(params, ajaxOb); + } + params.data = typeof data === 'object' && !can.isArray(data) ? can.extend(params.data || {}, data) : data; + params.url = can.sub(params.url, params.data, true); + return can.ajax(can.extend({ + type: type || 'post', + dataType: dataType || 'json', + success: success, + error: error + }, params)); + }, makeRequest = function (modelObj, type, success, error, method) { + var args; + if (can.isArray(modelObj)) { + args = modelObj[1]; + modelObj = modelObj[0]; + } else { + args = modelObj.serialize(); + } + args = [args]; + var deferred, model = modelObj.constructor, jqXHR; + if (type === 'update' || type === 'destroy') { + args.unshift(getId(modelObj)); + } + jqXHR = model[type].apply(model, args); + deferred = pipe(jqXHR, modelObj, function (data) { + modelObj[method || type + 'd'](data, jqXHR); + return modelObj; + }); + if (jqXHR.abort) { + deferred.abort = function () { + jqXHR.abort(); + }; + } + deferred.then(success, error); + return deferred; + }, converters = { + models: function (instancesRawData, oldList, xhr) { + can.Model._reqs++; + if (!instancesRawData) { + return; + } + if (instancesRawData instanceof this.List) { + return instancesRawData; + } + var self = this, tmp = [], ListClass = self.List || ML, modelList = oldList instanceof can.List ? oldList : new ListClass(), rawDataIsList = instancesRawData instanceof ML, raw = rawDataIsList ? instancesRawData.serialize() : instancesRawData; + raw = self.parseModels(raw, xhr); + if (raw.data) { + instancesRawData = raw; + raw = raw.data; + } + if (typeof raw === 'undefined' || !can.isArray(raw)) { + throw new Error('Could not get any raw data while converting using .models'); + } + if (modelList.length) { + modelList.splice(0); + } + can.each(raw, function (rawPart) { + tmp.push(self.model(rawPart, xhr)); + }); + modelList.push.apply(modelList, tmp); + if (!can.isArray(instancesRawData)) { + can.each(instancesRawData, function (val, prop) { + if (prop !== 'data') { + modelList.attr(prop, val); + } + }); + } + setTimeout(can.proxy(this._clean, this), 1); + return modelList; + }, + model: function (attributes, oldModel, xhr) { + if (!attributes) { + return; + } + if (typeof attributes.serialize === 'function') { + attributes = attributes.serialize(); + } else { + attributes = this.parseModel(attributes, xhr); + } + var id = attributes[this.id]; + if ((id || id === 0) && this.store[id]) { + oldModel = this.store[id]; + } + var model = oldModel && can.isFunction(oldModel.attr) ? oldModel.attr(attributes, this.removeAttr || false) : new this(attributes); + return model; + } + }, makeParser = { + parseModel: function (prop) { + return function (attributes) { + return prop ? can.getObject(prop, attributes) : attributes; + }; + }, + parseModels: function (prop) { + return function (attributes) { + if (can.isArray(attributes)) { + return attributes; + } + prop = prop || 'data'; + var result = can.getObject(prop, attributes); + if (!can.isArray(result)) { + throw new Error('Could not get any raw data while converting using .models'); + } + return result; + }; + } + }, ajaxMethods = { + create: { + url: '_shortName', + type: 'post' + }, + update: { + data: function (id, attrs) { + attrs = attrs || {}; + var identity = this.id; + if (attrs[identity] && attrs[identity] !== id) { + attrs['new' + can.capitalize(id)] = attrs[identity]; + delete attrs[identity]; + } + attrs[identity] = id; + return attrs; + }, + type: 'put' + }, + destroy: { + type: 'delete', + data: function (id, attrs) { + attrs = attrs || {}; + attrs.id = attrs[this.id] = id; + return attrs; + } + }, + findAll: { url: '_shortName' }, + findOne: {} + }, ajaxMaker = function (ajaxMethod, str) { + return function (data) { + data = ajaxMethod.data ? ajaxMethod.data.apply(this, arguments) : data; + return ajax(str || this[ajaxMethod.url || '_url'], data, ajaxMethod.type || 'get'); + }; + }, createURLFromResource = function (model, name) { + if (!model.resource) { + return; + } + var resource = model.resource.replace(/\/+$/, ''); + if (name === 'findAll' || name === 'create') { + return resource; + } else { + return resource + '/{' + model.id + '}'; + } + }; + can.Model = can.Map.extend({ + fullName: 'can.Model', + _reqs: 0, + setup: function (base, fullName, staticProps, protoProps) { + if (typeof fullName !== 'string') { + protoProps = staticProps; + staticProps = fullName; + } + if (!protoProps) { + protoProps = staticProps; + } + this.store = {}; + can.Map.setup.apply(this, arguments); + if (!can.Model) { + return; + } + if (staticProps && staticProps.List) { + this.List = staticProps.List; + this.List.Map = this; + } else { + this.List = base.List.extend({ Map: this }, {}); + } + var self = this, clean = can.proxy(this._clean, self); + can.each(ajaxMethods, function (method, name) { + if (staticProps && staticProps[name] && (typeof staticProps[name] === 'string' || typeof staticProps[name] === 'object')) { + self[name] = ajaxMaker(method, staticProps[name]); + } else if (staticProps && staticProps.resource && !can.isFunction(staticProps[name])) { + self[name] = ajaxMaker(method, createURLFromResource(self, name)); + } + if (self['make' + can.capitalize(name)]) { + var newMethod = self['make' + can.capitalize(name)](self[name]); + can.Construct._overwrite(self, base, name, function () { + can.Model._reqs++; + var def = newMethod.apply(this, arguments); + var then = def.then(clean, clean); + then.abort = def.abort; + return then; + }); + } + }); + var hasCustomConverter = {}; + can.each(converters, function (converter, name) { + var parseName = 'parse' + can.capitalize(name), dataProperty = staticProps && staticProps[name] || self[name]; + if (typeof dataProperty === 'string') { + self[parseName] = dataProperty; + can.Construct._overwrite(self, base, name, converter); + } else if (staticProps && staticProps[name]) { + hasCustomConverter[parseName] = true; + } + }); + can.each(makeParser, function (maker, parseName) { + var prop = staticProps && staticProps[parseName] || self[parseName]; + if (typeof prop === 'string') { + can.Construct._overwrite(self, base, parseName, maker(prop)); + } else if ((!staticProps || !can.isFunction(staticProps[parseName])) && !self[parseName]) { + var madeParser = maker(); + madeParser.useModelConverter = hasCustomConverter[parseName]; + can.Construct._overwrite(self, base, parseName, madeParser); + } + }); + if (self.fullName === 'can.Model' || !self.fullName) { + self.fullName = 'Model' + ++modelNum; + } + can.Model._reqs = 0; + this._url = this._shortName + '/{' + this.id + '}'; + }, + _ajax: ajaxMaker, + _makeRequest: makeRequest, + _clean: function () { + can.Model._reqs--; + if (!can.Model._reqs) { + for (var id in this.store) { + if (!this.store[id]._bindings) { + delete this.store[id]; + } + } + } + return arguments[0]; + }, + models: converters.models, + model: converters.model + }, { + setup: function (attrs) { + var id = attrs && attrs[this.constructor.id]; + if (can.Model._reqs && id != null) { + this.constructor.store[id] = this; + } + can.Map.prototype.setup.apply(this, arguments); + }, + isNew: function () { + var id = getId(this); + return !(id || id === 0); + }, + save: function (success, error) { + return makeRequest(this, this.isNew() ? 'create' : 'update', success, error); + }, + destroy: function (success, error) { + if (this.isNew()) { + var self = this; + var def = can.Deferred(); + def.then(success, error); + return def.done(function (data) { + self.destroyed(data); + }).resolve(self); + } + return makeRequest(this, 'destroy', success, error, 'destroyed'); + }, + _bindsetup: function () { + var modelInstance = this.__get(this.constructor.id); + if (modelInstance != null) { + this.constructor.store[modelInstance] = this; + } + return can.Map.prototype._bindsetup.apply(this, arguments); + }, + _bindteardown: function () { + delete this.constructor.store[getId(this)]; + return can.Map.prototype._bindteardown.apply(this, arguments); + }, + ___set: function (prop, val) { + can.Map.prototype.___set.call(this, prop, val); + if (prop === this.constructor.id && this._bindings) { + this.constructor.store[getId(this)] = this; + } + } + }); + var makeGetterHandler = function (name) { + return function (data, readyState, xhr) { + return this[name](data, null, xhr); + }; + }, createUpdateDestroyHandler = function (data) { + if (this.parseModel.useModelConverter) { + return this.model(data); + } + return this.parseModel(data); + }; + var responseHandlers = { + makeFindAll: makeGetterHandler('models'), + makeFindOne: makeGetterHandler('model'), + makeCreate: createUpdateDestroyHandler, + makeUpdate: createUpdateDestroyHandler, + makeDestroy: createUpdateDestroyHandler + }; + can.each(responseHandlers, function (method, name) { + can.Model[name] = function (oldMethod) { + return function () { + var args = can.makeArray(arguments), oldArgs = can.isFunction(args[1]) ? args.splice(0, 1) : args.splice(0, 2), def = pipe(oldMethod.apply(this, oldArgs), this, method); + def.then(args[0], args[1]); + return def; + }; + }; + }); + can.each([ + 'created', + 'updated', + 'destroyed' + ], function (funcName) { + can.Model.prototype[funcName] = function (attrs) { + var self = this, constructor = self.constructor; + if (attrs && typeof attrs === 'object') { + this.attr(can.isFunction(attrs.attr) ? attrs.attr() : attrs); + } + can.dispatch.call(this, { + type: 'change', + target: this + }, [funcName]); + can.dispatch.call(constructor, funcName, [this]); + }; + }); + var ML = can.Model.List = can.List.extend({ + _bubbleRule: function (eventName, list) { + var bubbleRules = can.List._bubbleRule(eventName, list); + bubbleRules.push('destroyed'); + return bubbleRules; + } + }, { + setup: function (params) { + if (can.isPlainObject(params) && !can.isArray(params)) { + can.List.prototype.setup.apply(this); + this.replace(can.isDeferred(params) ? params : this.constructor.Map.findAll(params)); + } else { + can.List.prototype.setup.apply(this, arguments); + } + this._init = 1; + this.bind('destroyed', can.proxy(this._destroyed, this)); + delete this._init; + }, + _destroyed: function (ev, attr) { + if (/\w+/.test(attr)) { + var index; + while ((index = this.indexOf(ev.target)) > -1) { + this.splice(index, 1); + } + } + } + }); + return can.Model; +}); +/*can@2.2.6#util/string/deparam/deparam*/ +define('can/util/string/deparam/deparam', [ + 'can/util/util', + 'can/util/string/string' +], function (can) { + var digitTest = /^\d+$/, keyBreaker = /([^\[\]]+)|(\[\])/g, paramTest = /([^?#]*)(#.*)?$/, prep = function (str) { + return decodeURIComponent(str.replace(/\+/g, ' ')); + }; + can.extend(can, { + deparam: function (params) { + var data = {}, pairs, lastPart; + if (params && paramTest.test(params)) { + pairs = params.split('&'); + can.each(pairs, function (pair) { + var parts = pair.split('='), key = prep(parts.shift()), value = prep(parts.join('=')), current = data; + if (key) { + parts = key.match(keyBreaker); + for (var j = 0, l = parts.length - 1; j < l; j++) { + if (!current[parts[j]]) { + current[parts[j]] = digitTest.test(parts[j + 1]) || parts[j + 1] === '[]' ? [] : {}; + } + current = current[parts[j]]; + } + lastPart = parts.pop(); + if (lastPart === '[]') { + current.push(value); + } else { + current[lastPart] = value; + } + } + }); + } + return data; + } + }); + return can; +}); +/*can@2.2.6#route/route*/ +define('can/route/route', [ + 'can/util/util', + 'can/map/map', + 'can/list/list', + 'can/util/string/deparam/deparam' +], function (can) { + var matcher = /\:([\w\.]+)/g, paramsMatcher = /^(?:&[^=]+=[^&]*)+/, makeProps = function (props) { + var tags = []; + can.each(props, function (val, name) { + tags.push((name === 'className' ? 'class' : name) + '="' + (name === 'href' ? val : can.esc(val)) + '"'); + }); + return tags.join(' '); + }, matchesData = function (route, data) { + var count = 0, i = 0, defaults = {}; + for (var name in route.defaults) { + if (route.defaults[name] === data[name]) { + defaults[name] = 1; + count++; + } + } + for (; i < route.names.length; i++) { + if (!data.hasOwnProperty(route.names[i])) { + return -1; + } + if (!defaults[route.names[i]]) { + count++; + } + } + return count; + }, location = window.location, wrapQuote = function (str) { + return (str + '').replace(/([.?*+\^$\[\]\\(){}|\-])/g, '\\$1'); + }, each = can.each, extend = can.extend, stringify = function (obj) { + if (obj && typeof obj === 'object') { + if (obj instanceof can.Map) { + obj = obj.attr(); + } else { + obj = can.isFunction(obj.slice) ? obj.slice() : can.extend({}, obj); + } + can.each(obj, function (val, prop) { + obj[prop] = stringify(val); + }); + } else if (obj !== undefined && obj !== null && can.isFunction(obj.toString)) { + obj = obj.toString(); + } + return obj; + }, removeBackslash = function (str) { + return str.replace(/\\/g, ''); + }, timer, curParams, lastHash, changingData, changedAttrs = [], onRouteDataChange = function (ev, attr, how, newval) { + changingData = 1; + changedAttrs.push(attr); + clearTimeout(timer); + timer = setTimeout(function () { + changingData = 0; + var serialized = can.route.data.serialize(), path = can.route.param(serialized, true); + can.route._call('setURL', path, changedAttrs); + can.batch.trigger(eventsObject, '__url', [ + path, + lastHash + ]); + lastHash = path; + changedAttrs = []; + }, 10); + }, eventsObject = can.extend({}, can.event); + can.route = function (url, defaults) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + defaults = defaults || {}; + var names = [], res, test = '', lastIndex = matcher.lastIndex = 0, next, querySeparator = can.route._call('querySeparator'), matchSlashes = can.route._call('matchSlashes'); + while (res = matcher.exec(url)) { + names.push(res[1]); + test += removeBackslash(url.substring(lastIndex, matcher.lastIndex - res[0].length)); + next = '\\' + (removeBackslash(url.substr(matcher.lastIndex, 1)) || querySeparator + (matchSlashes ? '' : '|/')); + test += '([^' + next + ']' + (defaults[res[1]] ? '*' : '+') + ')'; + lastIndex = matcher.lastIndex; + } + test += url.substr(lastIndex).replace('\\', ''); + can.route.routes[url] = { + test: new RegExp('^' + test + '($|' + wrapQuote(querySeparator) + ')'), + route: url, + names: names, + defaults: defaults, + length: url.split('/').length + }; + return can.route; + }; + extend(can.route, { + param: function (data, _setRoute) { + var route, matches = 0, matchCount, routeName = data.route, propCount = 0; + delete data.route; + each(data, function () { + propCount++; + }); + each(can.route.routes, function (temp, name) { + matchCount = matchesData(temp, data); + if (matchCount > matches) { + route = temp; + matches = matchCount; + } + if (matchCount >= propCount) { + return false; + } + }); + if (can.route.routes[routeName] && matchesData(can.route.routes[routeName], data) === matches) { + route = can.route.routes[routeName]; + } + if (route) { + var cpy = extend({}, data), res = route.route.replace(matcher, function (whole, name) { + delete cpy[name]; + return data[name] === route.defaults[name] ? '' : encodeURIComponent(data[name]); + }).replace('\\', ''), after; + each(route.defaults, function (val, name) { + if (cpy[name] === val) { + delete cpy[name]; + } + }); + after = can.param(cpy); + if (_setRoute) { + can.route.attr('route', route.route); + } + return res + (after ? can.route._call('querySeparator') + after : ''); + } + return can.isEmptyObject(data) ? '' : can.route._call('querySeparator') + can.param(data); + }, + deparam: function (url) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + var route = { length: -1 }, querySeparator = can.route._call('querySeparator'), paramsMatcher = can.route._call('paramsMatcher'); + each(can.route.routes, function (temp, name) { + if (temp.test.test(url) && temp.length > route.length) { + route = temp; + } + }); + if (route.length > -1) { + var parts = url.match(route.test), start = parts.shift(), remainder = url.substr(start.length - (parts[parts.length - 1] === querySeparator ? 1 : 0)), obj = remainder && paramsMatcher.test(remainder) ? can.deparam(remainder.slice(1)) : {}; + obj = extend(true, {}, route.defaults, obj); + each(parts, function (part, i) { + if (part && part !== querySeparator) { + obj[route.names[i]] = decodeURIComponent(part); + } + }); + obj.route = route.route; + return obj; + } + if (url.charAt(0) !== querySeparator) { + url = querySeparator + url; + } + return paramsMatcher.test(url) ? can.deparam(url.slice(1)) : {}; + }, + data: new can.Map({}), + map: function (data) { + var appState; + if (data.prototype instanceof can.Map) { + appState = new data(); + } else { + appState = data; + } + can.route.data = appState; + }, + routes: {}, + ready: function (val) { + if (val !== true) { + can.route._setup(); + can.route.setState(); + } + return can.route; + }, + url: function (options, merge) { + if (merge) { + options = can.extend({}, can.route.deparam(can.route._call('matchingPartOfURL')), options); + } + return can.route._call('root') + can.route.param(options); + }, + link: function (name, options, props, merge) { + return '' + name + ''; + }, + current: function (options) { + can.__observe(eventsObject, '__url'); + return this._call('matchingPartOfURL') === can.route.param(options); + }, + bindings: { + hashchange: { + paramsMatcher: paramsMatcher, + querySeparator: '&', + matchSlashes: false, + bind: function () { + can.bind.call(window, 'hashchange', setState); + }, + unbind: function () { + can.unbind.call(window, 'hashchange', setState); + }, + matchingPartOfURL: function () { + return location.href.split(/#!?/)[1] || ''; + }, + setURL: function (path) { + if (location.hash !== '#' + path) { + location.hash = '!' + path; + } + return path; + }, + root: '#!' + } + }, + defaultBinding: 'hashchange', + currentBinding: null, + _setup: function () { + if (!can.route.currentBinding) { + can.route._call('bind'); + can.route.bind('change', onRouteDataChange); + can.route.currentBinding = can.route.defaultBinding; + } + }, + _teardown: function () { + if (can.route.currentBinding) { + can.route._call('unbind'); + can.route.unbind('change', onRouteDataChange); + can.route.currentBinding = null; + } + clearTimeout(timer); + changingData = 0; + }, + _call: function () { + var args = can.makeArray(arguments), prop = args.shift(), binding = can.route.bindings[can.route.currentBinding || can.route.defaultBinding], method = binding[prop]; + if (method.apply) { + return method.apply(binding, args); + } else { + return method; + } + } + }); + each([ + 'bind', + 'unbind', + 'on', + 'off', + 'delegate', + 'undelegate', + 'removeAttr', + 'compute', + '_get', + '__get', + 'each' + ], function (name) { + can.route[name] = function () { + if (!can.route.data[name]) { + return; + } + return can.route.data[name].apply(can.route.data, arguments); + }; + }); + can.route.attr = function (attr, val) { + var type = typeof attr, newArguments; + if (val === undefined) { + newArguments = arguments; + } else if (type !== 'string' && type !== 'number') { + newArguments = [ + stringify(attr), + val + ]; + } else { + newArguments = [ + attr, + stringify(val) + ]; + } + return can.route.data.attr.apply(can.route.data, newArguments); + }; + var setState = can.route.setState = function () { + var hash = can.route._call('matchingPartOfURL'); + var oldParams = curParams; + curParams = can.route.deparam(hash); + if (!changingData || hash !== lastHash) { + can.batch.start(); + recursiveClean(oldParams, curParams, can.route.data); + can.route.attr(curParams); + can.batch.trigger(eventsObject, '__url', [ + hash, + lastHash + ]); + can.batch.stop(); + } + }; + var recursiveClean = function (old, cur, data) { + for (var attr in old) { + if (cur[attr] === undefined) { + data.removeAttr(attr); + } else if (Object.prototype.toString.call(old[attr]) === '[object Object]') { + recursiveClean(old[attr], cur[attr], data.attr(attr)); + } + } + }; + return can.route; +}); +/*can@2.2.6#control/route/route*/ +define('can/control/route/route', [ + 'can/util/util', + 'can/route/route', + 'can/control/control' +], function (can) { + can.Control.processors.route = function (el, event, selector, funcName, controller) { + selector = selector || ''; + if (!can.route.routes[selector]) { + if (selector[0] === '/') { + selector = selector.substring(1); + } + can.route(selector); + } + var batchNum, check = function (ev, attr, how) { + if (can.route.attr('route') === selector && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + batchNum = ev.batchNum; + var d = can.route.attr(); + delete d.route; + if (can.isFunction(controller[funcName])) { + controller[funcName](d); + } else { + controller[controller[funcName]](d); + } + } + }; + can.route.bind('change', check); + return function () { + can.route.unbind('change', check); + }; + }; + return can; +}); +/*can@2.2.6#util/event*/ +define('can/util/event', [ + 'can/util/can', + 'can/event/event' +], function (can) { + return can; +}); +/*can@2.2.6#can*/ +define('can/can', [ + 'can/util/util', + 'can/control/route/route', + 'can/model/model', + 'can/view/mustache/mustache', + 'can/component/component' +], function (can) { + return can; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.jquery.min.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.jquery.min.js new file mode 100644 index 0000000000..b8da15527c --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.jquery.min.js @@ -0,0 +1,94 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +!function(exports,global){var origDefine=global.define,get=function(e){var o,l=e.split("."),n=global;for(o=0;o=0&&(e.defaultChecked=!0)):l?(i=a,e[l]!==a&&(e[l]=a),"value"===l&&t.inArray(o,r.defaultValue)>=0&&(e.defaultValue=a)):(e.setAttribute(n,a),i=a),r.MutationObserver||i===u||r.trigger(e,n,u)},trigger:function(r,n,a){return t.data(t.$(r),"canHasAttributesBindings")?(n=n.toLowerCase(),e(function(){t.trigger(r,{type:"attributes",attributeName:n,target:r,oldValue:a,bubbles:!1},[])})):void 0},get:function(t,e){e=e.toLowerCase();var n=r.map[e];return"string"==typeof n&&t[n]?t[n]:t.getAttribute(e)},remove:function(t,e){e=e.toLowerCase();var n;r.MutationObserver||(n=r.get(t,e));var a=r.map[e];"function"==typeof a&&a(t,void 0),a===!0?t[e]=!1:"string"==typeof a?t[a]="":t.removeAttribute(e),r.MutationObserver||null==n||r.trigger(t,e,n)},has:function(){var e=t.global.document&&document.createElement("div");return e&&e.hasAttribute?function(t,e){return t.hasAttribute(e)}:function(t,e){return null!==t.getAttribute(e)}}()};return r}); +/*can@2.2.6#event/event*/ +define("can/event/event",["can/util/can"],function(t){return t.addEvent=function(t,n){var e=this.__bindEvents||(this.__bindEvents={}),i=e[t]||(e[t]=[]);return i.push({handler:n,name:t}),this},t.listenTo=function(n,e,i){var r=this.__listenToEvents;r||(r=this.__listenToEvents={});var s=t.cid(n),o=r[s];o||(o=r[s]={obj:n,events:{}});var a=o.events[e];a||(a=o.events[e]=[]),a.push(i),t.bind.call(n,e,i)},t.stopListening=function(n,e,i){var r=this.__listenToEvents,s=r,o=0;if(!r)return this;if(n){var a=t.cid(n);if((s={})[a]=r[a],!r[a])return this}for(var v in s){var l,h=s[v];n=r[v].obj,e?(l={})[e]=h.events[e]:l=h.events;for(var u in l){var d=l[u]||[];for(o=0;oo;o++)r[o].handler.apply(this,s);return t}},t.one=function(n,e){var i=function(){return t.unbind.call(this,n,i),e.apply(this,arguments)};return t.bind.call(this,n,i),this},t.event={on:function(){return 0===arguments.length&&t.Control&&this instanceof t.Control?t.Control.prototype.on.call(this):t.addEvent.apply(this,arguments)},off:function(){return 0===arguments.length&&t.Control&&this instanceof t.Control?t.Control.prototype.off.call(this):t.removeEvent.apply(this,arguments)},bind:t.addEvent,unbind:t.removeEvent,delegate:function(n,e,i){return t.addEvent.call(this,e,i)},undelegate:function(n,e,i){return t.removeEvent.call(this,e,i)},trigger:t.dispatch,one:t.one,addEvent:t.addEvent,removeEvent:t.removeEvent,listenTo:t.listenTo,stopListening:t.stopListening,dispatch:t.dispatch},t.event}); +/*can@2.2.6#util/array/each*/ +define("can/util/array/each",["can/util/can"],function(t){var e=function(t){var e="length"in t&&t.length;return"function"!=typeof arr&&(0===e||"number"==typeof e&&e>0&&e-1 in t)};return t.each=function(n,a,r){var f,i,l,c=0;if(n)if(e(n))if(t.List&&n instanceof t.List)for(i=n.attr("length");i>c&&(l=n.attr(c),a.call(r||l,l,c,n)!==!1);c++);else for(i=n.length;i>c&&(l=n[c],a.call(r||l,l,c,n)!==!1);c++);else if("object"==typeof n)if(t.Map&&n instanceof t.Map||n===t.route){var o=t.Map.keys(n);for(c=0,i=o.length;i>c&&(f=o[c],l=n.attr(f),a.call(r||l,l,f,n)!==!1);c++);}else for(f in n)if(n.hasOwnProperty(f)&&a.call(r||n[f],n[f],f,n)===!1)break;return n},t}); +/*can@2.2.6#util/inserted/inserted*/ +define("can/util/inserted/inserted",["can/util/can"],function(e){e.inserted=function(n){n=e.makeArray(n);for(var r,i,t=!1,a=e.$(document.contains?document:document.body),d=0;void 0!==(i=n[d]);d++){if(!t){if(!i.getElementsByTagName)continue;if(!e.has(a,i).length)return;t=!0}if(t&&i.getElementsByTagName){r=e.makeArray(i.getElementsByTagName("*")),e.trigger(i,"inserted",[],!1);for(var o,s=0;void 0!==(o=r[s]);s++)e.trigger(o,"inserted",[],!1)}}},e.appendChild=function(n,r){var i;i=11===r.nodeType?e.makeArray(r.childNodes):[r],n.appendChild(r),e.inserted(i)},e.insertBefore=function(n,r,i){var t;t=11===r.nodeType?e.makeArray(r.childNodes):[r],n.insertBefore(r,i),e.inserted(t)}}); +/*can@2.2.6#util/jquery/jquery*/ +define("can/util/jquery/jquery",["dist/jquery","can/util/can","can/util/attr/attr","can/event/event","can/util/array/each","can/util/inserted/inserted"],function(t,e,n,r){var i=function(t){return t.nodeName&&(1===t.nodeType||9===t.nodeType)||t==window};t=t||window.jQuery,t.extend(e,t,{trigger:function(n,r,a,u){i(n)?t.event.trigger(r,a,n,!u):n.trigger?n.trigger(r,a):("string"==typeof r&&(r={type:r}),r.target=r.target||n,a&&(a.length&&"string"==typeof a?a=[a]:a.length||(a=[a])),a||(a=[]),e.dispatch.call(n,r,a))},event:e.event,addEvent:e.addEvent,removeEvent:e.removeEvent,buildFragment:function(e,n){var r;return e=[e],n=n||document,n=!n.nodeType&&n[0]||n,n=n.ownerDocument||n,r=t.buildFragment(e,n),r.cacheable?t.clone(r.fragment):r.fragment||r},$:t,each:e.each,bind:function(n,r){return this.bind&&this.bind!==e.bind?this.bind(n,r):i(this)?t.event.add(this,n,r):e.addEvent.call(this,n,r),this},unbind:function(n,r){return this.unbind&&this.unbind!==e.unbind?this.unbind(n,r):i(this)?t.event.remove(this,n,r):e.removeEvent.call(this,n,r),this},delegate:function(n,r,a){return this.delegate?this.delegate(n,r,a):i(this)?t(this).delegate(n,r,a):e.bind.call(this,r,a),this},undelegate:function(n,r,a){return this.undelegate?this.undelegate(n,r,a):i(this)?t(this).undelegate(n,r,a):e.unbind.call(this,r,a),this},proxy:e.proxy,attr:n}),e.on=e.bind,e.off=e.unbind,t.each(["append","filter","addClass","remove","data","get","has"],function(t,n){e[n]=function(t){return t[n].apply(t,e.makeArray(arguments).slice(1))}});var a=t.cleanData;t.cleanData=function(n){t.each(n,function(t,n){n&&e.trigger(n,"removed",[],!1)}),a(n)};var u,s=t.fn.domManip;if(t.fn.domManip=function(t,e,n){for(var r=1;r=3&&(r=d.call(this,t,n));var a=d.apply(this,arguments);return arguments.length>=3&&(i=d.call(this,t,n)),i!==r&&e.attr.trigger(t,n,r),a};var c=t.removeAttr;t.removeAttr=function(t,n){var r=d.call(this,t,n),i=c.apply(this,arguments);return null!=r&&e.attr.trigger(t,n,r),i},t.event.special.attributes={setup:function(){e.data(e.$(this),"canHasAttributesBindings",!0)},teardown:function(){t.removeData(this,"canHasAttributesBindings")}}}return function(){var t="<-\n>",n=e.buildFragment(t,document);if(t!==n.childNodes[0].nodeValue){var r=e.buildFragment;e.buildFragment=function(t,e){var n=r(t,e);return 1===n.childNodes.length&&3===n.childNodes[0].nodeType&&(n.childNodes[0].nodeValue=t),n}}}(),t.event.special.inserted={},t.event.special.removed={},e}); +/*can@2.2.6#util/util*/ +define("can/util/util",["can/util/jquery/jquery"],function(u){return u}); +/*can@2.2.6#view/view*/ +define("can/view/view",["can/util/util"],function(e){var r=e.isFunction,n=e.makeArray,t=1,i=function(e){var r=function(){return c.frag(e.apply(this,arguments))};return r.render=function(){return e.apply(e,arguments)},r},u=function(e,r){if(!e.length)throw"can.view: No template or empty template:"+r},a=function(n,t){if(r(n)){var i=e.Deferred();return i.resolve(n)}var a,o,d,f="string"==typeof n?n:n.url,s=n.engine&&"."+n.engine||f.match(/\.[\w\d]+$/);if(f.match(/^#/)&&(f=f.substr(1)),(o=document.getElementById(f))&&(s="."+o.type.match(/\/(x\-)?(.+)/)[2]),s||c.cached[f]||(f+=s=c.ext),e.isArray(s)&&(s=s[0]),d=c.toId(f),f.match(/^\/\//)&&(f=f.substr(2),f=window.steal?steal.config().root.mapJoin(""+steal.id(f)):f),window.require&&require.toUrl&&(f=require.toUrl(f)),a=c.types[s],c.cached[d])return c.cached[d];if(o)return c.registerView(d,o.innerHTML,a);var p=new e.Deferred;return e.ajax({async:t,url:f,dataType:"text",error:function(e){u("",f),p.reject(e)},success:function(e){u(e,f),c.registerView(d,e,a,p)}}),p},o=function(r){var n=[];if(e.isDeferred(r))return[r];for(var t in r)e.isDeferred(r[t])&&n.push(r[t]);return n},d=function(r){return e.isArray(r)&&"success"===r[1]?r[0]:r},c=e.view=e.template=function(e,n,t,i){return r(t)&&(i=t,t=void 0),c.renderAs("fragment",e,n,t,i)};return e.extend(c,{frag:function(e,r){return c.hookup(c.fragment(e),r)},fragment:function(r){if("string"!=typeof r&&11===r.nodeType)return r;var n=e.buildFragment(r,document.body);return n.childNodes.length||n.appendChild(document.createTextNode("")),n},toId:function(r){return e.map(r.toString().split(/\/|\./g),function(e){return e?e:void 0}).join("_")},toStr:function(e){return null==e?"":""+e},hookup:function(r,n){var t,i,u=[];return e.each(r.childNodes?e.makeArray(r.childNodes):r,function(r){1===r.nodeType&&(u.push(r),u.push.apply(u,e.makeArray(r.getElementsByTagName("*"))))}),e.each(u,function(e){e.getAttribute&&(t=e.getAttribute("data-view-id"))&&(i=c.hookups[t])&&(i(e,n,t),delete c.hookups[t],e.removeAttribute("data-view-id"))}),r},hookups:{},hook:function(e){return c.hookups[++t]=e," data-view-id='"+t+"'"},cached:{},cachedRenderers:{},cache:!0,register:function(r){this.types["."+r.suffix]=r,e[r.suffix]=c[r.suffix]=function(e,n){var t,u;if(!n)return u=function(){return t||(t=r.fragRenderer?r.fragRenderer(null,e):i(r.renderer(null,e))),t.apply(this,arguments)},u.render=function(){var n=r.renderer(null,e);return n.apply(n,arguments)},u;var a=function(){return t||(t=r.fragRenderer?r.fragRenderer(e,n):r.renderer(e,n)),t.apply(this,arguments)};return r.fragRenderer?c.preload(e,a):c.preloadStringRenderer(e,a)}},types:{},ext:".ejs",registerScript:function(e,r,n){return"can.view.preloadStringRenderer('"+r+"',"+c.types["."+e].script(r,n)+");"},preload:function(r,n){var t=c.cached[r]=(new e.Deferred).resolve(function(e,r){return n.call(e,e,r)});return t.__view_id=r,c.cachedRenderers[r]=n,n},preloadStringRenderer:function(e,r){return this.preload(e,i(r))},render:function(r,n,t,i){return e.view.renderAs("string",r,n,t,i)},renderTo:function(e,r,n,t){return("string"===e&&r.render?r.render:r)(n,t)},renderAs:function(t,i,u,f,s){r(f)&&(s=f,f=void 0);var p,l,g,h,v,m=o(u);if(m.length)return l=new e.Deferred,g=e.extend({},u),m.push(a(i,!0)),e.when.apply(e,m).then(function(r){var i,a=n(arguments),o=a.pop();if(e.isDeferred(u))g=d(r);else for(var c in u)e.isDeferred(u[c])&&(g[c]=d(a.shift()));i=e.view.renderTo(t,o,g,f),l.resolve(i,g),s&&s(i,g)},function(){l.reject.apply(l,arguments)}),l;if(p=e.__clearReading(),h=r(s),l=a(i,h),p&&e.__setReading(p),h)v=l,l.then(function(r){s(u?e.view.renderTo(t,r,u,f):r)});else{if("resolved"===l.state()&&l.__view_id){var w=c.cachedRenderers[l.__view_id];return u?e.view.renderTo(t,w,u,f):w}l.then(function(r){v=u?e.view.renderTo(t,r,u,f):r})}return v},registerView:function(r,n,t,u){var a,o="object"==typeof t?t:c.types[t||c.ext];return a=o.fragRenderer?o.fragRenderer(r,n):i(o.renderer(r,n)),u=u||new e.Deferred,c.cache&&(c.cached[r]=u,u.__view_id=r,c.cachedRenderers[r]=a),u.resolve(a)}}),e}); +/*can@2.2.6#view/callbacks/callbacks*/ +define("can/view/callbacks/callbacks",["can/util/util","can/view/view"],function(t){var a=t.view.attr=function(t,a){if(!a){var r=e[t];if(!r)for(var n=0,l=i.length;l>n;n++){var s=i[n];if(s.match.test(t)){r=s.handler;break}}return r}"string"==typeof t?e[t]=a:i.push({match:t,handler:a})},e={},i=[],r=/[-\:]/,n=t.view.tag=function(a,e){if(!e){var i=l[a.toLowerCase()];return!i&&r.test(a)&&(i=function(){}),i}t.global.html5&&(t.global.html5.elements+=" "+a,t.global.html5.shivDocument()),l[a.toLowerCase()]=e},l={};return t.view.callbacks={_tags:l,_attributes:e,_regExpAttributes:i,tag:n,attr:a,tagHandler:function(a,e,i){var r,n=i.options.attr("tags."+e),s=n||l[e],c=i.scope;if(s){var o=t.__clearReading();r=s(a,i),t.__setReading(o)}else r=c;if(r&&i.subtemplate){c!==r&&(c=c.add(r));var v=i.subtemplate(c,i.options),f="string"==typeof v?t.view.frag(v):v;t.appendChild(a,f)}}},t.view.callbacks}); +/*can@2.2.6#view/elements*/ +define("can/view/elements",["can/util/util","can/view/view"],function(t){var e="undefined"!=typeof document?document:null,n=e&&function(){return 1===t.$(document.createComment("~")).length}(),o={tagToContentPropMap:{option:e&&"textContent"in document.createElement("option")?"textContent":"innerText",textarea:"value"},attrMap:t.attr.map,attrReg:/([^\s=]+)[\s]*=[\s]*/,defaultValue:t.attr.defaultValue,tagMap:{"":"span",colgroup:"col",table:"tbody",tr:"td",ol:"li",ul:"li",tbody:"tr",thead:"tr",tfoot:"tr",select:"option",optgroup:"option"},reverseTagMap:{col:"colgroup",tr:"tbody",option:"select",td:"tr",th:"tr",li:"ul"},getParentNode:function(t,e){return e&&11===t.parentNode.nodeType?e:t.parentNode},setAttr:t.attr.set,getAttr:t.attr.get,removeAttr:t.attr.remove,contentText:function(t){return"string"==typeof t?t:t||0===t?""+t:""},after:function(e,n){var o=e[e.length-1];o.nextSibling?t.insertBefore(o.parentNode,n,o.nextSibling):t.appendChild(o.parentNode,n)},replace:function(e,r){o.after(e,r),t.remove(t.$(e)).length/g,">").replace(c,""").replace(o,"'")},getObject:function(r,n,t){var a,u,i,c,o=r?r.split("."):[],l=o.length,p=0;if(n=e.isArray(n)?n:[n||window],c=n.length,!l)return n[0];for(p;c>p;p++){for(a=n[p],i=void 0,u=0;l>u&&g(a);u++)i=a,a=f(i,o[u]);if(void 0!==i&&void 0!==a)break}if(t===!1&&void 0!==a&&delete i[o[u-1]],t===!0&&void 0===a)for(a=n[0],u=0;l>u&&g(a);u++)a=f(a,o[u],!0);return a},capitalize:function(e,r){return e.charAt(0).toUpperCase()+e.slice(1)},camelize:function(e){return d(e).replace(l,function(e,r){return r?r.toUpperCase():""})},hyphenate:function(e){return d(e).replace(p,function(e,r){return e.charAt(0)+"-"+e.charAt(1).toLowerCase()})},underscore:function(e){return e.replace(n,"/").replace(t,"$1_$2").replace(a,"$1_$2").replace(u,"_").toLowerCase()},sub:function(r,n,t){var a=[];return r=r||"",a.push(r.replace(i,function(r,u){var i=e.getObject(u,n,t===!0?!1:void 0);return void 0===i||null===i?(a=null,""):g(i)&&a?(a.push(i),""):""+i})),null===a?a:a.length<=1?a[0]:a},replacer:i,undHash:r}),e}); +/*can@2.2.6#construct/construct*/ +define("can/construct/construct",["can/util/string/string"],function(t){var n,r=0;try{Object.getOwnPropertyDescriptor({}),n=!0}catch(e){n=!1}var o=function(t,n){var r=Object.getOwnPropertyDescriptor(t,n);return r&&(r.get||r.set)?r:null},u=function(n,r,e){e=e||n;var u;for(var i in n)(u=o(n,i))?this._defineProperty(e,r,i,u):t.Construct._overwrite(e,r,i,n[i])},i=function(n,r,e){e=e||n;for(var o in n)t.Construct._overwrite(e,r,o,n[o])};return t.Construct=function(){return arguments.length?t.Construct.extend.apply(t.Construct,arguments):void 0},t.extend(t.Construct,{constructorExtends:!0,newInstance:function(){var t,n=this.instance();return n.setup&&(t=n.setup.apply(n,arguments)),n.init&&n.init.apply(n,t||arguments),n},_inherit:n?u:i,_defineProperty:function(t,n,r,e){Object.defineProperty(t,r,e)},_overwrite:function(t,n,r,e){t[r]=e},setup:function(n,r){this.defaults=t.extend(!0,{},n.defaults,this.defaults)},instance:function(){r=1;var t=new this;return r=0,t},extend:function(n,e,o){function u(){return r?void 0:this.constructor!==a&&arguments.length&&a.constructorExtends?a.extend.apply(a,arguments):a.newInstance.apply(a,arguments)}var i=n,s=e,c=o;"string"!=typeof i&&(c=s,s=i,i=null),c||(c=s,s=null),c=c||{};var a,p,f,l,d,y,g,h,v,m=this,w=this.prototype;v=this.instance(),t.Construct._inherit(c,w,v),i&&(p=i.split("."),g=p.pop()),"undefined"==typeof constructorName&&(a=function(){return u.apply(this,arguments)});for(y in m)m.hasOwnProperty(y)&&(a[y]=m[y]);t.Construct._inherit(s,m,a),i&&(f=t.getObject(p.join("."),window,!0),h=f,l=t.underscore(i.replace(/\./g,"_")),d=t.underscore(g),f[g]=a),t.extend(a,{constructor:a,prototype:v,namespace:h,_shortName:d,fullName:i,_fullName:l}),void 0!==g&&(a.shortName=g),a.prototype.constructor=a;var C=[m].concat(t.makeArray(arguments)),_=a.setup.apply(a,C);return a.init&&a.init.apply(a,_||C),a}}),t.Construct.prototype.setup=function(){},t.Construct.prototype.init=function(){},t.Construct}); +/*can@2.2.6#control/control*/ +define("can/control/control",["can/util/util","can/construct/construct"],function(t){var n,e=function(n,e,o){return t.bind.call(n,e,o),function(){t.unbind.call(n,e,o)}},o=t.isFunction,s=t.extend,i=t.each,r=[].slice,u=/\{([^\}]+)\}/g,c=t.getObject("$.event.special",[t])||{},l=function(n,e,o,s){return t.delegate.call(n,e,o,s),function(){t.undelegate.call(n,e,o,s)}},a=function(n,o,s,i){return i?l(n,t.trim(i),o,s):e(n,o,s)},h=t.Control=t.Construct({setup:function(){if(t.Construct.setup.apply(this,arguments),t.Control){var n,e=this;e.actions={};for(n in e.prototype)e._isAction(n)&&(e.actions[n]=e._action(n))}},_shifter:function(n,e){var s="string"==typeof e?n[e]:e;return o(s)||(s=n[s]),function(){return n.called=e,s.apply(n,[this.nodeName?t.$(this):this].concat(r.call(arguments,0)))}},_isAction:function(t){var n=this.prototype[t],e=typeof n;return"constructor"!==t&&("function"===e||"string"===e&&o(this.prototype[n]))&&!!(c[t]||f[t]||/[^\w]/.test(t))},_action:function(e,o){if(u.lastIndex=0,o||!u.test(e)){var s=o?t.sub(e,this._lookup(o)):e;if(!s)return null;var i=t.isArray(s),r=i?s[1]:s,c=r.split(/\s+/g),l=c.pop();return{processor:f[l]||n,parts:[r,c.join(" "),l],delegate:i?s[0]:void 0}}},_lookup:function(t){return[t,window]},processors:{},defaults:{}},{setup:function(n,e){var o,i=this.constructor,r=i.pluginName||i._fullName;return this.element=t.$(n),r&&"can_control"!==r&&this.element.addClass(r),o=t.data(this.element,"controls"),o||(o=[],t.data(this.element,"controls",o)),o.push(this),this.options=s({},i.defaults,e),this.on(),[this.element,this.options]},on:function(n,e,o,s){if(!n){this.off();var i,r,u=this.constructor,c=this._bindings,l=u.actions,h=this.element,f=t.Control._shifter(this,"destroy");for(i in l)l.hasOwnProperty(i)&&(r=l[i]||u._action(i,this.options,this),r&&(c.control[i]=r.processor(r.delegate||h,r.parts[2],r.parts[1],i,this)));return t.bind.call(h,"removed",f),c.user.push(function(n){t.unbind.call(n,"removed",f)}),c.user.length}return"string"==typeof n&&(s=o,o=e,e=n,n=this.element),void 0===s&&(s=o,o=e,e=null),"string"==typeof s&&(s=t.Control._shifter(this,s)),this._bindings.user.push(a(n,o,s,e)),this._bindings.user.length},off:function(){var t=this.element[0],n=this._bindings;n&&(i(n.user||[],function(n){n(t)}),i(n.control||{},function(n){n(t)})),this._bindings={user:[],control:{}}},destroy:function(){if(null!==this.element){var n,e=this.constructor,o=e.pluginName||e._fullName;this.off(),o&&"can_control"!==o&&this.element.removeClass(o),n=t.data(this.element,"controls"),n.splice(t.inArray(this,n),1),t.trigger(this,"destroyed"),this.element=null}}}),f=t.Control.processors;return n=function(n,e,o,s,i){return a(n,e,t.Control._shifter(i,s),o)},i(["change","click","contextmenu","dblclick","keydown","keyup","keypress","mousedown","mousemove","mouseout","mouseover","mouseup","reset","resize","scroll","select","submit","focusin","focusout","mouseenter","mouseleave","touchstart","touchmove","touchcancel","touchend","touchleave","inserted","removed"],function(t){f[t]=n}),h}); +/*can@2.2.6#util/bind/bind*/ +define("can/util/bind/bind",["can/util/util"],function(i){return i.bindAndSetup=function(){return i.addEvent.apply(this,arguments),this._init||(this._bindings?this._bindings++:(this._bindings=1,this._bindsetup&&this._bindsetup())),this},i.unbindAndTeardown=function(n,t){var s=this.__bindEvents[n]||[],d=s.length;return i.removeEvent.apply(this,arguments),null===this._bindings?this._bindings=0:this._bindings=this._bindings-(d-s.length),!this._bindings&&this._bindteardown&&this._bindteardown(),this},i}); +/*can@2.2.6#map/bubble*/ +define("can/map/bubble",["can/util/util"],function(n){var e=n.bubble={event:function(n,e){return n.constructor._bubbleRule(e,n)},childrenOf:function(n,i){n._each(function(b,r){b&&b.bind&&e.toParent(b,n,r,i)})},teardownChildrenFrom:function(n,i){n._each(function(b){e.teardownFromParent(n,b,i)})},toParent:function(e,i,b,r){n.listenTo.call(i,e,r,function(){var r=n.makeArray(arguments),t=r.shift();r[0]=(n.List&&i instanceof n.List?i.indexOf(e):b)+(r[0]?"."+r[0]:""),t.triggeredNS=t.triggeredNS||{},t.triggeredNS[i._cid]||(t.triggeredNS[i._cid]=!0,n.trigger(i,t,r))})},teardownFromParent:function(e,i,b){i&&i.unbind&&n.stopListening.call(e,i,b)},isBubbling:function(n,e){return n._bubbleBindings&&n._bubbleBindings[e]},bind:function(n,i){if(!n._init){var b,r=e.event(n,i),t=r.length;n._bubbleBindings||(n._bubbleBindings={});for(var u=0;t>u;u++)b=r[u],n._bubbleBindings[b]?n._bubbleBindings[b]++:(n._bubbleBindings[b]=1,e.childrenOf(n,b))}},unbind:function(i,b){for(var r,t=e.event(i,b),u=t.length,d=0;u>d;d++)r=t[d],i._bubbleBindings&&i._bubbleBindings[r]--,i._bubbleBindings&&!i._bubbleBindings[r]&&(delete i._bubbleBindings[r],e.teardownChildrenFrom(i,r),n.isEmptyObject(i._bubbleBindings)&&delete i._bubbleBindings)},add:function(i,b,r){if(b instanceof n.Map&&i._bubbleBindings)for(var t in i._bubbleBindings)i._bubbleBindings[t]&&(e.teardownFromParent(i,b,t),e.toParent(b,i,r,t))},removeMany:function(n,i){for(var b=0,r=i.length;r>b;b++)e.remove(n,i[b])},remove:function(i,b){if(b instanceof n.Map&&i._bubbleBindings)for(var r in i._bubbleBindings)i._bubbleBindings[r]&&e.teardownFromParent(i,b,r)},set:function(i,b,r,t){return n.Map.helpers.isObservable(r)&&e.add(i,r,b),n.Map.helpers.isObservable(t)&&e.remove(i,t),r}};return e}); +/*can@2.2.6#util/batch/batch*/ +define("can/util/batch/batch",["can/util/can"],function(t){var n=1,a=0,i=[],c=[],e=null;t.batch={start:function(t){a++,t&&c.push(t)},stop:function(l,u){if(l?a=0:a--,0===a){if(null!==e)return;e=i.slice(0);var h,r,f=c.slice(0);for(i=[],c=[],t.batch.batchNum=n,n++,u&&t.batch.start(),h=0;h=0?["change"]:[]},_computes:[],bind:t.bindAndSetup,on:t.bindAndSetup,unbind:t.unbindAndTeardown,off:t.unbindAndTeardown,id:"id",helpers:{define:null,attrParts:function(t,e){return e?[t]:"object"==typeof t?t:(""+t).split(".")},addToMap:function(e,i){var r;n||(r=s,n={});var a=e._cid,o=t.cid(e);return n[o]||(n[o]={obj:e,instance:i,added:!a}),r},isObservable:function(e){return e instanceof t.Map||e&&e===t.route},canMakeObserve:function(e){return e&&!t.isDeferred(e)&&(t.isArray(e)||t.isPlainObject(e))},serialize:function(e,i,n){var s=t.cid(e),r=!1;return a||(r=!0,a={attr:{},serialize:{}}),a[i][s]=n,e.each(function(s,r){var u,h=o.helpers.isObservable(s),c=h&&a[i][t.cid(s)];u=c?c:"serialize"===i?o.helpers._serialize(e,r,s):o.helpers._getValue(e,r,s,i),void 0!==u&&(n[r]=u)}),t.__observe(e,"__keys"),r&&(a=null),n},_serialize:function(t,e,i){return o.helpers._getValue(t,e,i,"serialize")},_getValue:function(t,e,i,n){return o.helpers.isObservable(i)?i[n]():i}},keys:function(e){var i=[];t.__observe(e,"__keys");for(var n in e._data)i.push(n);return i}},{setup:function(e){e instanceof t.Map&&(e=e.serialize()),this._data={},t.cid(this,".map"),this._init=1,this._computedBindings={};var i=this._setupDefaults(e);this._setupComputes(i);var n=e&&t.Map.helpers.addToMap(e,this),s=t.extend(t.extend(!0,{},i),e);this.attr(s),n&&n(),this.bind("change",t.proxy(this._changes,this)),delete this._init},_setupComputes:function(){for(var t,e=this.constructor._computes,i=0,n=e.length;n>i;i++)t=e[i],this[t]=this[t].clone(this),this._computedBindings[t]={count:0}},_setupDefaults:function(){return this.constructor.defaults||{}},_bindsetup:function(){},_bindteardown:function(){},_changes:function(e,i,n,s,r){t.batch.trigger(this,{type:i,batchNum:e.batchNum,target:e.target},[s,r])},_triggerChange:function(e,n,s,r){i.isBubbling(this,"change")?t.batch.trigger(this,{type:"change",target:this},[e,n,s,r]):t.batch.trigger(this,e,[s,r]),("remove"===n||"add"===n)&&t.batch.trigger(this,{type:"__keys",target:this})},_each:function(t){var e=this.__get();for(var i in e)e.hasOwnProperty(i)&&t(e[i],i)},attr:function(t,e){var i=typeof t;return"string"!==i&&"number"!==i?this._attrs(t,e):1===arguments.length?this._get(t):(this._set(t,e),this)},each:function(){return t.each.apply(void 0,[this].concat(t.makeArray(arguments)))},removeAttr:function(e){var i=t.List&&this instanceof t.List,n=t.Map.helpers.attrParts(e),s=n.shift(),r=i?this[s]:this._data[s];return n.length&&r?r.removeAttr(n):("string"==typeof e&&~e.indexOf(".")&&(s=e),this._remove(s,r),r)},_remove:function(t,e){t in this._data&&(delete this._data[t],t in this.constructor.prototype||delete this[t],this._triggerChange(t,"remove",void 0,e))},_get:function(e){e=""+e;var i=e.indexOf(".");if(i>=0){var n=this.__get(e);if(void 0!==n)return n;var s=e.substr(0,i),r=e.substr(i+1);t.__observe(this,s);var a=this.__get(s);return a&&a._get?a._get(r):void 0}return t.__observe(this,e),this.__get(e)},__get:function(t){return t?this._computedBindings[t]?this[t]():this._data[t]:this._data},__type:function(e,i){if(!(e instanceof t.Map)&&t.Map.helpers.canMakeObserve(e)){var n=r(e);if(n)return n;if(t.isArray(e)){var s=t.List;return new s(e)}var a=this.constructor.Map||t.Map;return new a(e)}return e},_set:function(t,e,i){t=""+t;var n,s=t.indexOf(".");if(!i&&s>=0){var r=t.substr(0,s),a=t.substr(s+1);if(n=this._init?void 0:this.__get(r),!o.helpers.isObservable(n))throw"can.Map: Object does not exist";n._set(a,e)}else this.__convert&&(e=this.__convert(t,e)),n=this._init?void 0:this.__get(t),this.__set(t,this.__type(e,t),n)},__set:function(t,e,i){if(e!==i){var n=void 0!==i||this.__get().hasOwnProperty(t)?"set":"add";this.___set(t,this.constructor._bubble.set(this,t,e,i)),this._computedBindings[t]||this._triggerChange(t,n,e,i),i&&this.constructor._bubble.teardownFromParent(this,i)}},___set:function(t,e){this._computedBindings[t]?this[t](e):this._data[t]=e,"function"==typeof this.constructor.prototype[t]||this._computedBindings[t]||(this[t]=e)},bind:function(e,i){var n=this._computedBindings&&this._computedBindings[e];if(n)if(n.count)n.count++;else{n.count=1;var s=this;n.handler=function(i,n,r){t.batch.trigger(s,{type:e,batchNum:i.batchNum,target:s},[n,r])},this[e].bind("change",n.handler)}return this.constructor._bubble.bind(this,e),t.bindAndSetup.apply(this,arguments)},unbind:function(e,i){var n=this._computedBindings&&this._computedBindings[e];return n&&(1===n.count?(n.count=0,this[e].unbind("change",n.handler),delete n.handler):n.count--),this.constructor._bubble.unbind(this,e),t.unbindAndTeardown.apply(this,arguments)},serialize:function(){return t.Map.helpers.serialize(this,"serialize",{})},_attrs:function(e,i){if(void 0===e)return o.helpers.serialize(this,"attr",{});e=t.simpleExtend({},e);var n,s,r=this;t.batch.start(),this.each(function(t,n){if("_cid"!==n){if(s=e[n],void 0===s)return void(i&&r.removeAttr(n));r.__convert&&(s=r.__convert(n,s)),o.helpers.isObservable(s)?r.__set(n,r.__type(s,n),t):o.helpers.isObservable(t)&&o.helpers.canMakeObserve(s)?t.attr(s,i):t!==s&&r.__set(n,r.__type(s,n),t),delete e[n]}});for(n in e)"_cid"!==n&&(s=e[n],this._set(n,s,!0));return t.batch.stop(),this},compute:function(e){if(t.isFunction(this.constructor.prototype[e]))return t.compute(this[e],this);var i=e.split("."),n=i.length-1,s={args:[]};return t.compute(function(e){return arguments.length?void t.compute.read(this,i.slice(0,n)).value.attr(i[n],e):t.compute.read(this,i,s).value},this)}});return o.prototype.on=o.prototype.bind,o.prototype.off=o.prototype.unbind,o}); +/*can@2.2.6#list/list*/ +define("can/list/list",["can/util/util","can/map/map","can/map/bubble"],function(t,e,i){var r=[].splice,h=function(){var t={0:"a",length:1};return r.call(t,0,1),!t[0]}(),n=e.extend({Map:e},{setup:function(e,i){this.length=0,t.cid(this,".map"),this._init=1,this._computedBindings={},this._setupComputes(),e=e||[];var r;t.isDeferred(e)?this.replace(e):(r=e.length&&t.Map.helpers.addToMap(e,this),this.push.apply(this,t.makeArray(e||[]))),r&&r(),this.bind("change",t.proxy(this._changes,this)),t.simpleExtend(this,i),delete this._init},_triggerChange:function(i,r,h,n){e.prototype._triggerChange.apply(this,arguments);var s=+i;~(""+i).indexOf(".")||isNaN(s)||("add"===r?(t.batch.trigger(this,r,[h,s]),t.batch.trigger(this,"length",[this.length])):"remove"===r?(t.batch.trigger(this,r,[n,s]),t.batch.trigger(this,"length",[this.length])):t.batch.trigger(this,r,[h,s]))},__get:function(e){return e?this[e]&&this[e].isComputed&&t.isFunction(this.constructor.prototype[e])?this[e]():this[e]:this},__set:function(e,i,r){if(e=isNaN(+e)||e%1?e:+e,"number"==typeof e&&e>this.length-1){var h=new Array(e+1-this.length);return h[h.length-1]=i,this.push.apply(this,h),h}return t.Map.prototype.__set.call(this,""+e,i,r)},___set:function(t,e){this[t]=e,+t>=this.length&&(this.length=+t+1)},_remove:function(t,e){isNaN(+t)?(delete this[t],this._triggerChange(t,"remove",void 0,e)):this.splice(t,1)},_each:function(t){for(var e=this.__get(),i=0;i2;for(e=e||0,s=0,a=o.length-2;a>s;s++)l=s+2,o[l]=this.__type(o[l],l),g.push(o[l]),this[s+e]!==o[l]&&(c=!1);if(c&&this.length<=g.length)return g;void 0===n&&(n=o[1]=this.length-e);var p=r.apply(this,o);if(!h)for(s=this.length;s0&&(i.removeMany(this,p),this._triggerChange(""+e,"remove",void 0,p)),o.length>2){for(s=0,a=g.length;a>s;s++)i.set(this,s,g[s]);this._triggerChange(""+e,"add",g,p)}return t.batch.stop(),p},_attrs:function(i,r){return void 0===i?e.helpers.serialize(this,"attr",[]):(i=t.makeArray(i),t.batch.start(),this._updateAttrs(i,r),void t.batch.stop())},_updateAttrs:function(t,i){for(var r=Math.min(t.length,this.length),h=0;r>h;h++){var n=this[h],s=t[h];e.helpers.isObservable(n)&&e.helpers.canMakeObserve(s)?n.attr(s,i):n!==s&&this._set(h,s)}t.length>this.length?this.push.apply(this,t.slice(this.length)):t.lengthc;){s=i;for(var l=0,f=t.propertyReaders.length;f>l;l++){var v=t.propertyReaders[l];if(v.test(i)){i=v.read(i,r[c],c,o,u);break}}if(c+=1,i=n(i,c,r,o,u,s),a=typeof i,ci;i++)t.valueReaders[i].test(e,n,r,o)&&(e=t.valueReaders[i].read(e,n,r,o,a,s))}while(u);return e};return t.valueReaders=[{name:"compute",test:function(e,t,n,r){return e&&e.isComputed},read:function(t,n,r,o,a){return o.isArgument&&n===r.length?t:(!a.foundObservable&&o.foundObservable&&(o.foundObservable(t,n),a.foundObservable=!0),t instanceof e.Compute?t.get():t())}},{name:"function",test:function(t,n,r,o){var a=typeof t;return!("function"!==a||t.isComputed||!(o.executeAnonymousFunctions||o.isArgument&&n===r.length)||e.Construct&&t.prototype instanceof e.Construct||e.route&&t===e.route)},read:function(t,n,r,o,a,s){return o.isArgument&&n===r.length?o.proxyMethods!==!1?e.proxy(t,s):t:t.call(s)}}],t.propertyReaders=[{name:"map",test:e.isMapLike,read:function(t,n,r,o,a){return!a.foundObservable&&o.foundObservable&&(o.foundObservable(t,r),a.foundObservable=!0),"function"==typeof t[n]&&t.constructor.prototype[n]===t[n]?o.returnObserveMethods?t[n]:"constructor"===n&&t instanceof e.Construct||t[n].prototype instanceof e.Construct?t[n]:t[n].apply(t,o.args||[]):t.attr(n)}},{name:"promise",test:function(t){return e.isPromise(t)},read:function(t,n,r,o,a){!a.foundObservable&&o.foundObservable&&(o.foundObservable(t,r),a.foundObservable=!0);var s=t.__observeData;return t.__observeData||(s=t.__observeData={isPending:!0,state:"pending",isResolved:!1,isRejected:!1,value:void 0,reason:void 0},e.cid(s),e.simpleExtend(s,e.event),t.then(function(e){s.isPending=!1,s.isResolved=!0,s.value=e,s.state="resolved",s.dispatch("state",["resolved","pending"])},function(e){s.isPending=!1,s.isRejected=!0,s.reason=e,s.state="rejected",s.dispatch("state",["rejected","pending"])})),e.__observe(s,"state"),n in s?s[n]:t[n]}},{name:"object",test:function(){return!0},read:function(e,t){return null==e?void 0:e[t]}}],t.write=function(t,n,r,o){return o=o||{},e.isMapLike(t)?!o.isArgument&&t._data&&t._data[n]&&t._data[n].isComputed?t._data[n](r):t.attr(n,r):t[n]&&t[n].isComputed?t[n](r):void("object"==typeof t&&(t[n]=r))},t}); +/*can@2.2.6#compute/get_value_and_bind*/ +define("can/compute/get_value_and_bind",["can/util/util"],function(){function n(n,e,t,i){var v=a(n,e),o=v.observed,u=t.observed;return v.names!==t.names&&(r(u,o,i),c(u,i)),can.batch.afterPreviousEvents(function(){v.ready=!0}),v}var e=[];can.__isRecordingObserves=function(){return e.length},can.__observe=can.__reading=function(n,a){if(e.length){var r=n._cid+"|"+a,t=e[e.length-1];t.names+=r,t.observed[r]={obj:n,event:a+""}}},can.__notObserve=function(n){return function(){var e=can.__clearObserved(),a=n.apply(this,arguments);return can.__setObserved(e),a}},can.__clearObserved=can.__clearReading=function(){if(e.length){var n=e[e.length-1];return e[e.length-1]={observed:{}},n}},can.__setObserved=can.__setReading=function(n){e.length&&(e[e.length-1]=n)},can.__addObserved=can.__addReading=function(n){e.length&&can.simpleExtend(e[e.length-1],n)};var a=function(n,a){e.push({names:"",observed:{}});var r=n.call(a),t=e.pop();return t.value=r,t},r=function(n,e,a){for(var r in e)t(n,e,r,a)},t=function(n,e,a,r){if(n[a])delete n[a];else{var t=e[a];t.obj.bind(t.event,r)}},c=function(n,e){for(var a in n){var r=n[a];r.obj.unbind(r.event,e)}};return n}); +/*can@2.2.6#compute/proto_compute*/ +define("can/compute/proto_compute",["can/util/util","can/util/bind/bind","can/compute/read","can/compute/get_value_and_bind","can/util/batch/batch"],function(t,e,n,i){var s=function(e,n,i,s){n!==i&&t.batch.trigger(e,s?{type:"change",batchNum:s}:"change",[n,i])},u=function(e,n,s,u){var o,h,r;return u=!1,{on:function(a){var c=this;h||(h=function(t){if(o.ready&&e.bound&&(void 0===t.batchNum||t.batchNum!==r)){var a,f=o.value;u?(a=n.call(s),o.value=a):(o=i(n,s,o,h),a=o.value),c.updater(a,f,t.batchNum),r=r=t.batchNum}}),o=i(n,s,{observed:{}},h),u&&(n=t.__notObserve(n)),e.value=o.value,e.hasDependencies=!t.isEmptyObject(o.observed)},off:function(t){for(var e in o.observed){var n=o.observed[e];n.obj.unbind(n.event,h)}}}},o=function(){},h=function(t,e,n){this.value=t,s(this,t,e,n)},r=function(t,e,n){return function(){return t.call(e,n.get())}},a=function(t,e){return function(n){void 0!==n&&e(n,t.value)}};t.Compute=function(e,n,i,s){for(var u=[],o=0,h=arguments.length;h>o;o++)u[o]=arguments[o];var r=typeof u[1];"function"==typeof u[0]?this._setupGetterSetterFn(u[0],u[1],u[2],u[3]):u[1]?"string"===r?this._setupContextString(u[0],u[1],u[2]):"function"===r?this._setupContextFunction(u[0],u[1],u[2]):u[1]&&u[1].fn?this._setupAsyncCompute(u[0],u[1]):this._setupContextSettings(u[0],u[1]):this._setupInitialValue(u[0]),this._args=u,this.isComputed=!0,t.cid(this,"compute")},t.simpleExtend(t.Compute.prototype,{_bindsetup:t.__notObserve(function(){this.bound=!0,this._on(this.updater)}),_bindteardown:function(){this._off(this.updater),this.bound=!1},bind:t.bindAndSetup,unbind:t.unbindAndTeardown,clone:function(e){return e&&"function"==typeof this._args[0]?this._args[1]=e:e&&(this._args[2]=e),new t.Compute(this._args[0],this._args[1],this._args[2],this._args[3])},_on:o,_off:o,get:function(){return t.__isRecordingObserves()&&this._canObserve!==!1&&(t.__observe(this,"change"),this.bound||t.Compute.temporarilyBind(this)),this.bound?this.value:this._get()},_get:function(){return this.value},set:function(t){var e=this.value,n=this._set(t,e);return this.hasDependencies?this._setUpdates?this.value:this._get():(void 0===n?this.value=this._get():this.value=n,s(this,this.value,e),this.value)},_set:function(t){return this.value=t},updater:h,_computeFn:function(t){return arguments.length?this.set(t):this.get()},toFunction:function(){return t.proxy(this._computeFn,this)},_setupGetterSetterFn:function(e,n,i,s){this._set=t.proxy(e,n),this._get=t.proxy(e,n),this._canObserve=i===!1?!1:!0;var o=u(this,e,n||this,s);this._on=o.on,this._off=o.off},_setupContextString:function(e,n,i){var s=t.isMapLike(e),u=this,o=function(t,e,n){u.updater(e,n,t.batchNum)};s?(this.hasDependencies=!0,this._get=function(){return e.attr(n)},this._set=function(t){e.attr(n,t)},this._on=function(t){e.bind(i||n,o),this.value=this._get()},this._off=function(){return e.unbind(i||n,o)}):(this._get=t.proxy(this._get,e),this._set=t.proxy(this._set,e))},_setupContextFunction:function(e,n,i){this.value=e,this._set=n,t.simpleExtend(this,i)},_setupContextSettings:function(e,n){if(this.value=e,this._set=n.set?t.proxy(n.set,n):this._set,this._get=n.get?t.proxy(n.get,n):this._get,!n.__selfUpdater){var i=this,s=this.updater;this.updater=function(){s.call(i,i._get(),i.value)}}this._on=n.on?n.on:this._on,this._off=n.off?n.off:this._off},_setupAsyncCompute:function(e,n){this.value=e;var i,s=t.proxy(this.updater,this),o=this,h=n.fn;this.updater=s;var c=new t.Compute(e);this.lastSetValue=c,this._setUpdates=!0,this._set=function(t){return t===c.get()?this.value:c.set(t)},this._get=r(h,n.context,c),0===h.length?i=u(this,h,n.context):1===h.length?i=u(this,function(){return h.call(n.context,c.get())},n):(this.updater=a(this,s),i=u(this,function(){var t=h.call(n.context,c.get(),function(t){s(t,o.value)});return void 0!==t?t:this.value},n)),this._on=i.on,this._off=i.off},_setupInitialValue:function(t){this.value=t}});var c,f=function(){for(var t=0,e=c.length;e>t;t++)c[t].unbind("change",o);c=null};return t.Compute.temporarilyBind=function(t){t.bind("change",o),c||(c=[],setTimeout(f,10)),c.push(t)},t.Compute.async=function(e,n,i){return new t.Compute(e,{fn:n,context:i})},t.Compute.read=n,t.Compute.set=n.write,t.Compute.truthy=function(e){return new t.Compute(function(){var t=e.get();return"function"==typeof t&&(t=t.get()),!!t})},t.Compute}); +/*can@2.2.6#compute/compute*/ +define("can/compute/compute",["can/util/util","can/util/bind/bind","can/util/batch/batch","can/compute/proto_compute"],function(t,n){t.compute=function(n,u,e,o){var c=new t.Compute(n,u,e,o),i=function(t){return arguments.length?c.set(t):c.get()};return i.bind=t.proxy(c.bind,c),i.unbind=t.proxy(c.unbind,c),i.isComputed=c.isComputed,i.clone=function(e){return"function"==typeof n&&(u=e),t.compute(n,u,e,o)},i.computeInstance=c,i};var u,e=function(){},o=function(){for(var t=0,n=u.length;n>t;t++)u[t].unbind("change",e);u=null};return t.compute.temporarilyBind=function(t){t.bind("change",e),u||(u=[],setTimeout(o,10)),u.push(t)},t.compute.truthy=function(n){return t.compute(function(){var t=n();return"function"==typeof t&&(t=t()),!!t})},t.compute.async=function(n,u,e){return t.compute(n,{fn:u,context:e})},t.compute.read=t.Compute.read,t.compute.set=t.Compute.set,t.compute}); +/*can@2.2.6#observe/observe*/ +define("can/observe/observe",["can/util/util","can/map/map","can/list/list","can/compute/compute"],function(t){return t.Observe=t.Map,t.Observe.startBatch=t.batch.start,t.Observe.stopBatch=t.batch.stop,t.Observe.triggerBatch=t.batch.trigger,t}); +/*can@2.2.6#view/scope/compute_data*/ +define("can/view/scope/compute_data",["can/util/util","can/compute/compute","can/compute/get_value_and_bind"],function(e,t,n){var o=function(t){return t.reads&&1===t.reads.length&&t.root instanceof e.Map&&!e.isFunction(t.root[t.reads[0]])},a=function(e,t){return n(e,null,{observed:{}},t)},u=function(e,t){for(var n in e.observed){var o=e.observed[n];o.obj.unbind(o.event,t)}},r=function(e,t){var n=e.root,o=e.reads[0];return n.bind(o,t),{value:e.initialValue,observed:{something:!0}}},c=function(e,t){e.root.unbind(e.reads[0],t)},i=function(t,n,o,a,u){if(!(arguments.length>4)){if(a.root)return e.compute.read(a.root,a.reads,o).value;var r=t.read(n,o);return a.scope=r.scope,a.initialValue=r.value,a.reads=r.reads,a.root=r.rootObserve,r.value}if(a.root.isComputed)a.root(u);else if(a.reads.length){var c=a.reads.length-1,i=a.reads.length?e.compute.read(a.root,a.reads.slice(0,c)).value:a.root;e.compute.set(i,a.reads[c],u,o)}};return function(t,s,d){d=d||{args:[]};var l,v,f={},p=function(e){return arguments.length?i(t,s,d,f,e):i(t,s,d,f)},m=function(e){if(v.ready&&g.computeInstance.bound&&(void 0===e.batchNum||e.batchNum!==l)){var t,o=v.value;v=n(p,null,v,m),t=v.value,g.computeInstance.updater(t,o,e.batchNum),l=l=e.batchNum}},b=function(e,t,n){"function"!=typeof t?g.computeInstance.updater(t,n,e.batchNum):(c(f,b),v=a(p,m),h=!1,g.computeInstance.updater(v.value,n,e.batchNum))},h=!1,g=e.compute(void 0,{on:function(){if(v=a(p,m),o(f)){var t=v;v=r(f,b),u(t,m),h=!0}g.computeInstance.value=v.value,g.computeInstance.hasDependencies=!e.isEmptyObject(v.observed)},off:function(){h?c(f,b):u(v,m)},set:p,get:p,__selfUpdater:!0});return f.compute=g,f}}); +/*can@2.2.6#view/scope/scope*/ +define("can/view/scope/scope",["can/util/util","can/view/scope/compute_data","can/construct/construct","can/map/map","can/list/list","can/view/view","can/compute/compute"],function(e,t){var n=/(\\)?\./g,r=/\\\./g,u=function(e){var t=[],u=0;return e.replace(n,function(n,i,s){i||(t.push(e.slice(u,s).replace(r,".")),u=s+n.length)}),t.push(e.slice(u).replace(r,".")),t},i=e.Construct.extend({read:e.compute.read},{init:function(e,t){this._context=e,this._parent=t,this.__cache={}},attr:e.__notObserve(function(t,n){var r={isArgument:!0,returnObserveMethods:!0,proxyMethods:!1},u=this.read(t,r);if(2===arguments.length){var i=t.lastIndexOf("."),s=-1!==i?t.substring(0,i):".",a=this.read(s,r).value;-1!==i&&(t=t.substring(i+1,t.length)),e.compute.set(a,t,n,r)}return u.value}),add:function(e){return e!==this._context?new this.constructor(e,this):this},computeData:function(e,n){return t(this,e,n)},compute:function(e,t){return this.computeData(e,t).compute},read:function(t,n){var r;if("./"===t.substr(0,2))r=!0,t=t.substr(2);else{if("../"===t.substr(0,3))return this._parent.read(t.substr(3),n);if(".."===t)return{value:this._parent._context};if("."===t||"this"===t)return{value:this._context}}for(var i,s,a,c,o,l,p=-1===t.indexOf("\\.")?t.split("."):u(t),v=this,d=[],f=-1;v;){if(i=v._context,null!==i&&("object"==typeof i||"function"==typeof i)){var h=e.compute.read(i,p,e.simpleExtend({foundObservable:function(e,t){o=e,l=p.slice(t)},earlyExit:function(t,n){n>f&&(s=o,d=l,f=n,c=v,a=e.__clearReading())},executeAnonymousFunctions:!0},n));if(void 0!==h.value)return{scope:v,rootObserve:o,value:h.value,reads:l}}e.__clearReading(),v=r?null:v._parent}return s?(e.__setReading(a),{scope:c,rootObserve:s,reads:d,value:void 0}):{names:p,value:void 0}}});return e.view.Scope=i,i}); +/*can@2.2.6#view/scanner*/ +define("can/view/scanner",["can/view/view","can/view/elements","can/view/callbacks/callbacks"],function(can,elements,viewCallbacks){var newLine=/(\r|\n)+/g,notEndTag=/\//,clean=function(t){return t.split("\\").join("\\\\").split("\n").join("\\n").split('"').join('\\"').split(" ").join("\\t")},getTag=function(t,e,n){if(t)return t;for(;n":">",'"':'"',"'":"'"},this.tokenComplex=[],this.tokenMap={};for(var e,n=0;e=this.tokens[n];n++)e[2]?(this.tokenReg.push(e[2]),this.tokenComplex.push({abbr:e[1],re:new RegExp(e[2]),rescan:e[3]})):(this.tokenReg.push(e[1]),this.tokenSimple[e[1]]=e[0]),this.tokenMap[e[0]]=e[1];this.tokenReg=new RegExp("("+this.tokenReg.slice(0).concat(["<",">",'"',"'"]).join("|")+")","g")},Scanner.prototype={helpers:[],scan:function(t,e){var n=[],s=0,a=this.tokenSimple,r=this.tokenComplex;t=t.replace(newLine,"\n"),this.transform&&(t=this.transform(t)),t.replace(this.tokenReg,function(e,i){var o=arguments[arguments.length-2];if(o>s&&n.push(t.substring(s,o)),a[e])n.push(e);else for(var u,c=0;u=r[c];c++)if(u.re.test(e)){n.push(u.abbr),u.rescan&&n.push(u.rescan(i));break}s=o+i.length}),s":htmlTag=0;var H="/"===l.substr(l.length-1)||"--"===l.substr(l.length-2),N="";if(k.attributeHookups.length&&(N="attrs: ['"+k.attributeHookups.join("','")+"'], ",k.attributeHookups=[]),v+k.tagHookups.length!==k.lastTagHookup&&v===top(k.tagHookups))H&&(l=l.substr(0,l.length-1)),p.push(put_cmd,'"',clean(l),'"',",can.view.pending({tagName:'"+v+"',"+N+"scope: "+(this.text.scope||"this")+this.text.options),H?(p.push("}));"),l="/>",b()):"<"===n[d]&&n[d+1]==="/"+v?(p.push("}));"),l=u,b()):(p.push(",subtemplate: function("+this.text.argNames+"){\n"+startTxt+(this.text.start||"")),l="");else if(m||!w&&elements.tagToContentPropMap[x[x.length-1]]||N){var R=",can.view.pending({"+N+"scope: "+(this.text.scope||"this")+this.text.options+'}),"';H?h(l.substr(0,l.length-1),R+'/>"'):h(l,R+'>"'),l="",m=0}else l+=u;(H||w)&&(x.pop(),v=x[x.length-1],w=!1),k.attributeHookups=[];break;case"'":case'"':if(htmlTag)if(quote&"e===u){quote=null;var L=getAttrName();if(viewCallbacks.attr(L)&&k.attributeHookups.push(L),T){l+=u,h(l),p.push(finishTxt,"}));\n"),l="",T=!1;break}}else if(null===quote&&(quote=u,beforeQuote=i,c=getAttrName(),"img"===v&&"src"===c||"style"===c)){h(l.replace(attrReg,"")),l="",T=!0,p.push(insert_cmd,"can.view.txt(2,'"+getTag(v,n,d)+"',"+status()+",this,function(){",startTxt),h(c+"="+u);break}default:if("<"===i){v="!--"===u.substr(0,3)?"!--":u.split(/\s/)[0];var S,y=!1;0===v.indexOf("/")&&(y=!0,S=v.substr(1)),y?(top(x)===S&&(v=S,w=!0),top(k.tagHookups)===S&&(h(l.substr(0,l.length-1)),p.push(finishTxt+"}}) );"),l="><",b())):(v.lastIndexOf("/")===v.length-1&&(v=v.substr(0,v.length-1)),"!--"!==v&&viewCallbacks.tag(v)&&("content"===v&&elements.tagMap[top(x)]&&(u=u.replace("content",elements.tagMap[top(x)])),k.tagHookups.push(v)),x.push(v))}l+=u}else switch(u){case _.right:case _.returnRight:switch(f){case _.left:o=bracketNum(l),1===o?(p.push(insert_cmd,"can.view.txt(0,'"+getTag(v,n,d)+"',"+status()+",this,function(){",startTxt,l),g.push({before:"",after:finishTxt+"}));\n"})):(s=g.length&&-1===o?g.pop():{after:";"},s.before&&p.push(s.before),p.push(l,";",s.after));break;case _.escapeLeft:case _.returnLeft:o=bracketNum(l),o&&g.push({before:finishTxt,after:"}));\n"});for(var j=f===_.escapeLeft?1:0,C={insert:insert_cmd,tagName:getTag(v,n,d),status:status(),specialAttribute:T},q=0;q[\s]*\w*/.source&&(j=0);break}}"object"==typeof l?l.startTxt&&l.end&&T?p.push(insert_cmd,"can.view.toStr( ",l.content,"() ) );"):(l.startTxt?p.push(insert_cmd,"can.view.txt(\n"+("string"==typeof status()||(null!=l.escaped?l.escaped:j))+",\n'"+v+"',\n"+status()+",\nthis,\n"):l.startOnlyTxt&&p.push(insert_cmd,"can.view.onlytxt(this,\n"),p.push(l.content),l.end&&p.push("));")):T?p.push(insert_cmd,l,");"):p.push(insert_cmd,"can.view.txt(\n"+("string"==typeof status()||j)+",\n'"+v+"',\n"+status()+",\nthis,\nfunction(){ "+(this.text.escape||"")+"return ",l,o?startTxt:"}));\n"),rescan&&rescan.after&&rescan.after.length&&(h(rescan.after.length),rescan=null)}f=null,l="";break;case _.templateLeft:l+=_.left;break;default:l+=u}i=u}l.length&&h(l),p.push(";");var M=p.join(""),A={out:(this.text.outStart||"")+M+" "+finishTxt+(this.text.outEnd||"")};return myEval.call(A,"this.fn = (function("+this.text.argNames+"){"+A.out+"});\r\n//# sourceURL="+e+".js"),A}},can.view.pending=function(t){var e=can.view.getHooks();return can.view.hook(function(n){can.each(e,function(t){t(n)}),t.templateType="legacy",t.tagName&&viewCallbacks.tagHandler(n,t.tagName,t),can.each(t&&t.attrs||[],function(e){t.attributeName=e;var s=viewCallbacks.attr(e);s&&s(n,t)})})},can.view.tag("content",function(t,e){return e.scope}),can.view.Scanner=Scanner,Scanner}); +/*can@2.2.6#view/node_lists/node_lists*/ +define("can/view/node_lists/node_lists",["can/util/util","can/view/elements"],function(e){var n=!0;try{document.createTextNode("")._=0}catch(t){n=!1}var r={},a={},i="ejs_"+Math.random(),s=0,u=function(e,t){var r=t||a,u=l(e,r);return u?u:n||3!==e.nodeType?(++s,e[i]=(e.nodeName?"element_":"obj_")+s):(++s,r["text_"+s]=e,"text_"+s)},l=function(e,t){if(n||3!==e.nodeType)return e[i];for(var r in t)if(t[r]===e)return r},c=[].splice,o=[].push,p=function(e){for(var n=0,t=0,r=e.length;r>t;t++){var a=e[t];a.nodeType?n++:n+=p(a)}return n},f=function(e,n){for(var t={},r=0,a=e.length;a>r;r++){var i=d.first(e[r]);t[u(i,n)]=e[r]}return t},d={id:u,update:function(n,t){var r=d.unregisterChildren(n);t=e.makeArray(t);var a=n.length;return c.apply(n,[0,a].concat(t)),n.replacements?d.nestReplacements(n):d.nestList(n),r},nestReplacements:function(e){for(var n=0,t={},r=f(e.replacements,t),a=e.replacements.length;nr;r++){var n=e[r];t[n.tokenType].apply(t,n.args)}return e}var a="-:A-Za-z0-9_",n="[a-zA-Z_:]["+a+":.]*",s="\\s*=\\s*",i='"((?:\\\\.|[^"])*)"',o="'((?:\\\\.|[^'])*)'",l="(?:"+s+"(?:(?:\"[^\"]*\")|(?:'[^']*')|[^>\\s]+))?",c="\\{\\{[^\\}]*\\}\\}\\}?",u="\\{\\{([^\\}]*)\\}\\}\\}?",p=new RegExp("^<(["+a+"]+)((?:\\s*(?:(?:(?:"+n+")?"+l+")|(?:"+c+")+))*)\\s*(\\/?)>"),f=new RegExp("^<\\/(["+a+"]+)[^>]*>"),d=new RegExp("(?:(?:("+n+")|"+u+")(?:"+s+"(?:(?:"+i+")|(?:"+o+")|([^>\\s]+)))?)","g"),g=new RegExp(u,"g"),h=/<|\{\{/,m=t("area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed"),b=t("a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video"),v=t("abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var"),x=t("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr"),w=t("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"),y=t("script,style"),k="start,end,close,attrStart,attrEnd,attrValue,chars,comment,special,done".split(","),E=function(){},A=function(t,a,n){function s(e,t,r,n){if(t=t.toLowerCase(),b[t])for(;w.last()&&v[w.last()];)i("",w.last());x[t]&&w.last()===t&&i("",t),n=m[t]||!!n,a.start(t,n),n||w.push(t),A.parseAttrs(r,a),a.end(t,n)}function i(e,t){var r;if(t)for(r=w.length-1;r>=0&&w[r]!==t;r--);else r=0;if(r>=0){for(var n=w.length-1;n>=r;n--)a.close&&a.close(w[n]);w.length=r}}function o(e,t){a.special&&a.special(t)}if("object"==typeof t)return r(t,a);var l=[];a=a||{},n&&e.each(k,function(t){var r=a[t]||E;a[t]=function(){r.apply(this,arguments)!==!1&&l.push({tokenType:t,args:e.makeArray(arguments)})}});var c,u,d,w=[],O=t;for(w.last=function(){return this[this.length-1]};t;){if(u=!0,w.last()&&y[w.last()])t=t.replace(new RegExp("([\\s\\S]*?)]*>"),function(e,t){return t=t.replace(/|/g,"$1$2"),a.chars&&a.chars(t),""}),i("",w.last());else if(0===t.indexOf(""),c>=0&&(a.comment&&a.comment(t.substring(4,c)),t=t.substring(c+3),u=!1)):0===t.indexOf("c?t:t.substring(0,c);t=0>c?"":t.substring(c),a.chars&&R&&a.chars(R)}if(t===O)throw"Parse Error: "+t;O=t}return i(),a.done(),l};return A.parseAttrs=function(e,t){(null!=e?e:"").replace(d,function(e,r,a,n,s,i){if(a&&t.special(a),r||n||s||i){var o=arguments[3]?arguments[3]:arguments[4]?arguments[4]:arguments[5]?arguments[5]:w[r.toLowerCase()]?r:"";t.attrStart(r||"");for(var l,c=g.lastIndex=0,u=g.exec(o);u;)l=o.substring(c,g.lastIndex-u[0].length),l.length&&t.attrValue(l),t.special(u[1]),c=g.lastIndex,u=g.exec(o);l=o.substr(c,o.length),l&&t.attrValue(l),t.attrEnd(r||"")}})},e.view.parser=A,A}); +/*can@2.2.6#view/live/live*/ +define("can/view/live/live",["can/util/util","can/view/elements","can/view/view","can/view/node_lists/node_lists","can/view/parser/parser"],function(e,t,n,r,i){t=t||e.view.elements,r=r||e.view.NodeLists,i=i||e.view.parser;var a=function(t,n,r){var i=!1,a=function(){return i||(i=!0,r(o),e.unbind.call(t,"removed",a)),!0},o={teardownCheck:function(e){return e?!1:a()}};return e.bind.call(t,"removed",a),n(o),o},o=function(e,t,n){return a(e,function(){t.bind("change",n)},function(e){t.unbind("change",n),e.nodeList&&r.unregister(e.nodeList)})},c=function(e){var t,n={};return i.parseAttrs(e,{attrStart:function(e){n[e]="",t=e},attrValue:function(e){n[t]+=e},attrEnd:function(){}}),n},u=[].splice,d=function(e){return e&&e.nodeType},s=function(e){e.childNodes.length||e.appendChild(document.createTextNode(""))},l={list:function(n,i,o,c,d,s){var f,p=s||[n],v=[],h=!1,g=!1,b=function(n,i,a){if(h){var d=document.createDocumentFragment(),l=[],f=[];e.each(i,function(t,n){var i=[];s&&r.register(i,null,!0);var u=e.compute(n+a),p=o.call(c,t,u,i),v="string"==typeof p,h=e.frag(p);h=v?e.view.hookup(h):h;var g=e.makeArray(h.childNodes);s?(r.update(i,g),l.push(i)):l.push(r.register(g)),d.appendChild(h),f.push(u)});var g=a+1;if(p[g]){var b=r.first(p[g]);e.insertBefore(b.parentNode,d,b)}else t.after(1===g?[N]:[r.last(p[g-1])],d);u.apply(p,[g,0].concat(l)),u.apply(v,[a,0].concat(f));for(var m=a+f.length,w=v.length;w>m;m++)v[m](m)}},m=function(t,n,i,a,o){if(h&&(a||!y.teardownCheck(N.parentNode))){0>i&&(i=v.length+i);var c=p.splice(i+1,n.length),u=[];e.each(c,function(e){var t=r.unregister(e);[].push.apply(u,t)}),v.splice(i,n.length);for(var d=i,s=v.length;s>d;d++)v[d](d);o?r.unregister(p):e.remove(e.$(u))}},w=function(t,n,i,a){if(h){i+=1,a+=1;var o,c=p[i],u=e.frag(r.flatten(p[a]));o=i>a?r.last(c).nextSibling:r.first(c);var d=p[0].parentNode;d.insertBefore(u,o);var s=p[a];[].splice.apply(p,[a,1]),[].splice.apply(p,[i,0,s])}},N=document.createTextNode(""),k=function(e){f&&f.unbind&&f.unbind("add",b).unbind("remove",m).unbind("move",w),m({},{length:p.length-1},0,!0,e)},A=function(t,n,r){g||(k(),f=n||[],f.bind&&f.bind("add",b).bind("remove",m).bind("move",w),h=!0,b({},f,0),h=!1,e.batch.afterPreviousEvents(function(){h=!0}))};d=t.getParentNode(n,d);var y=a(d,function(){e.isFunction(i)&&i.bind("change",A)},function(){e.isFunction(i)&&i.unbind("change",A),k(!0)});s?(t.replace(p,N),r.update(p,[N]),s.unregistered=function(){y.teardownCheck(),g=!0}):l.replace(p,N,y.teardownCheck),A({},e.isFunction(i)?i():i)},html:function(n,i,a,c){var u;a=t.getParentNode(n,a),u=o(a,i,function(e,t,n){var i=r.first(l).parentNode;i&&f(t),u.teardownCheck(r.first(l).parentNode)});var l=c||[n],f=function(n){var i="function"==typeof n,o=d(n),c=e.frag(i?"":n),u=e.makeArray(l);s(c),o||i||(c=e.view.hookup(c,a)),u=r.update(l,c.childNodes),i&&n(c.childNodes[0]),t.replace(u,c)};u.nodeList=l,c?c.unregistered=u.teardownCheck:r.register(l,u.teardownCheck),f(i())},replace:function(n,i,a){var o=n.slice(0),c=e.frag(i);return r.register(n,a),"string"==typeof i&&(c=e.view.hookup(c,n[0].parentNode)),r.update(n,c.childNodes),t.replace(o,c),n},text:function(n,i,a,c){var u=t.getParentNode(n,a),d=o(u,i,function(t,n,r){"unknown"!=typeof s.nodeValue&&(s.nodeValue=e.view.toStr(n)),d.teardownCheck(s.parentNode)}),s=document.createTextNode(e.view.toStr(i()));c?(c.unregistered=d.teardownCheck,d.nodeList=c,r.update(c,[s]),t.replace([n],s)):d.nodeList=l.replace([n],s,d.teardownCheck)},setAttributes:function(t,n){var r=c(n);for(var i in r)e.attr.set(t,i,r[i])},attributes:function(n,r,i){var a={},u=function(r){var i,o=c(r);for(i in o){var u=o[i],d=a[i];u!==d&&e.attr.set(n,i,u),delete a[i]}for(i in a)t.removeAttr(n,i);a=o};o(n,r,function(e,t){u(t)}),arguments.length>=3?a=c(i):u(r())},attributePlaceholder:"__!!__",attributeReplace:/__!!__/g,attribute:function(n,r,i){o(n,i,function(e,i){t.setAttr(n,r,u.render())});var a,c=e.$(n);a=e.data(c,"hooks"),a||e.data(c,"hooks",a={});var u,d=t.getAttr(n,r),s=d.split(l.attributePlaceholder),f=[];f.push(s.shift(),s.join(l.attributePlaceholder)),a[r]?a[r].computes.push(i):a[r]={render:function(){var e=0,n=d?d.replace(l.attributeReplace,function(){return t.contentText(u.computes[e++]())}):t.contentText(u.computes[e++]());return n},computes:[i],batchNum:void 0},u=a[r],f.splice(1,0,i()),t.setAttr(n,r,f.join(""))},specialAttribute:function(e,n,r){o(e,r,function(r,i){t.setAttr(e,n,p(i))}),t.setAttr(e,n,p(r()))},simpleAttribute:function(e,n,r){o(e,r,function(r,i){t.setAttr(e,n,i)}),t.setAttr(e,n,r())}};l.attr=l.simpleAttribute,l.attrs=l.attributes;var f=/(\r|\n)+/g,p=function(e){var n=/^["'].*["']$/;return e=e.replace(t.attrReg,"").replace(f,""),n.test(e)?e.substr(1,e.length-2):e};return e.view.live=l,l}); +/*can@2.2.6#view/render*/ +define("can/view/render",["can/view/view","can/view/elements","can/view/live/live","can/util/string/string"],function(t,n,e){var i,r=[],u=function(t){var e=n.tagMap[t]||"span";return"span"===e?"@@!!@@":"<"+e+">"+u(e)+""},o=function(n,e){if("string"==typeof n)return n;if(!n&&0!==n)return"";var i=n.hookup&&function(t,e){n.hookup.call(n,t,e)}||"function"==typeof n&&n;return i?e?"<"+e+" "+t.view.hook(i)+">":(r.push(i),""):""+n},c=function(n,e){return"string"==typeof n||"number"==typeof n?t.esc(n):o(n,e)},s=!1,a=function(){};return t.extend(t.view,{live:e,setupLists:function(){var n,e=t.view.lists;return t.view.lists=function(t,e){return n={list:t,renderer:e},Math.random()},function(){return t.view.lists=e,n}},getHooks:function(){var t=r.slice(0);return i=t,r=[],t},onlytxt:function(t,n){return c(n.call(t))},txt:function(f,p,l,v,h){var w,g,d,b,y=n.tagMap[p]||"span",k=!1,m=a;if(s)w=h.call(v);else{("string"==typeof l||1===l)&&(s=!0);var x=t.view.setupLists();m=function(){d.unbind("change",a)},d=t.compute(h,v,!1),d.bind("change",a),g=x(),w=d(),s=!1,k=d.computeInstance.hasDependencies}if(g)return m(),"<"+y+t.view.hook(function(t,n){e.list(t,g.list,g.renderer,v,n)})+">";if(!k||"function"==typeof w)return m(),(s||2===f||!f?o:c)(w,0===l&&y);var M=n.tagToContentPropMap[p];return 0!==l||M?1===l?(r.push(function(t){e.attributes(t,d,d()),m()}),d()):2===f?(b=l,r.push(function(t){e.specialAttribute(t,b,d),m()}),d()):(b=0===l?M:l,(0===l?i:r).push(function(t){e.attribute(t,b,d),m()}),e.attributePlaceholder):"<"+y+t.view.hook(f&&"object"!=typeof w?function(t,n){e.text(t,d,n),m()}:function(t,n){e.html(t,d,n),m()})+">"+u(y)+""}}),t}); +/*can@2.2.6#view/stache/utils*/ +define("can/view/stache/utils",["can/util/util"],function(){return{isArrayLike:function(t){return t&&t.splice&&"number"==typeof t.length},isObserveLike:function(t){return t instanceof can.Map||t&&!!t._get},emptyHandler:function(){},jsonParse:function(str){return"'"===str[0]?str.substr(1,str.length-2):"undefined"===str?void 0:can.global.JSON?JSON.parse(str):eval("("+str+")")},mixins:{last:function(){return this.stack[this.stack.length-1]},add:function(t){this.last().add(t)},subSectionDepth:function(){return this.stack.length-1}}}}); +/*can@2.2.6#view/stache/mustache_helpers*/ +define("can/view/stache/mustache_helpers",["can/util/util","can/view/stache/utils","can/view/live/live"],function(e,n,t){t=t||e.view.live;var i=function(t){return n.isObserveLike(t)&&n.isArrayLike(t)&&t.attr("length")?t:e.isFunction(t)?t():t},r={each:function(r,s){var o,u,a,c=i(r),f=[];if(c instanceof e.List)return function(n){var i=[n];i.expression="live.list",e.view.nodeLists.register(i,null,s.nodeList),e.view.nodeLists.update(s.nodeList,[n]);var o=function(e,n,t){return s.fn(s.scope.add({"@index":n}).add(e),s.options,t)};t.list(n,r,o,s.context,n.parentNode,i)};var l=c;if(l&&n.isArrayLike(l))for(a=0;a0&&t!==n)return r.inverse();n=t}return r.fn()},eq:function(){return r.is.apply(this,arguments)},unless:function(n,t){return r["if"].apply(this,[e.isFunction(n)?e.compute(function(){return!n()}):!n,t])},"with":function(e,n){var t=e;return e=i(e),e?n.fn(t):void 0},log:function(e,n){"undefined"!=typeof console&&console.log&&(n?console.log(e,n.context):console.log(e.context))},data:function(n){var t=2===arguments.length?this:arguments[1];return function(i){e.data(e.$(i),n,t||this.context)}}};return{registerHelper:function(e,n){r[e]=n},getHelper:function(e,n){var t=n.attr("helpers."+e);return t||(t=r[e]),t?{fn:t}:void 0}}}); +/*can@2.2.6#view/stache/mustache_core*/ +define("can/view/stache/mustache_core",["can/util/util","can/view/stache/utils","can/view/stache/mustache_helpers","can/view/live/live","can/view/elements","can/view/scope/scope","can/view/node_lists/node_lists"],function(e,t,n,r,i,a,s){r=r||e.view.live,i=i||e.view.elements,a=a||e.view.Scope,s=s||e.view.nodeLists;var o=/((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g,u=/^(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(?:(.+?)=(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(.+))))$/,c=/(?:(?:^|(\r?)\n)(\s*)(\{\{([^\}]*)\}\}\}?)([^\S\n\r]*)($|\r?\n))|(\{\{([^\}]*)\}\}\}?)/g,l=function(e){return e&&"string"==typeof e.get},f=function(e,t,n,r){for(var i=document.createDocumentFragment(),a=0,s=e.length;s>a;a++)p(i,n.fn(t?e.attr(""+a):e[a],r));return i},p=function(e,t){t&&e.appendChild("string"==typeof t?document.createTextNode(t):t)},h=function(e,t,n,r){for(var i="",a=0,s=e.length;s>a;a++)i+=n.fn(t?e.attr(""+a):e[a],r);return i},d=function(t,n,r){var i=n.computeData(t,{isArgument:r,args:[n.attr("."),n]});return e.compute.temporarilyBind(i.compute),i},v=function(e,t){var n=d(e,t,!0);return n.compute.computeInstance.hasDependencies?n.compute:n.initialValue},g=function(e,t,n,r,i,a){i&&(e.fn=m(i,t,n,r)),a&&(e.inverse=m(a,t,n,r))},m=function(t,n,r,i){var a=function(e,r,i){return t(e||n,r,i)};return e.__notObserve(function(t,s,o){void 0===t||t instanceof e.view.Scope||(t=n.add(t)),void 0===s||s instanceof x.Options||(s=r.add(s));var u=a(t,s||r,o||i);return u})},x={expressionData:function(n){var r=[],i={},a=0;return(e.trim(n)+" ").replace(o,function(e,n){var s;a&&(s=n.match(u))?s[1]||s[2]?r.push(t.jsonParse(s[1]||s[2])):i[s[3]]=s[6]?{get:s[6]}:t.jsonParse(s[4]||s[5]):r.push({get:n}),a++}),{name:r.shift(),args:r,hash:i}},makeEvaluator:function(r,i,a,s,o,u,c,p){for(var m,x,y,w=[],b={},_={fn:function(){},inverse:function(){}},O=r.attr("."),k=o.name,D=o.args.length||!e.isEmptyObject(o.hash),E=0,L=o.args.length;L>E;E++){var A=o.args[E];w.push(A&&l(A)?v(A.get,r,!0):A)}for(var N in o.hash)l(o.hash[N])?b[N]=v(o.hash[N].get,r):b[N]=o.hash[N];if(l(k)&&(D&&(m=n.getHelper(k.get,i),m||"function"!=typeof O[k.get]||(m={fn:O[k.get]})),!m)){var S=k.get,B=d(k.get,r,!1),R=B.compute;x=B.initialValue,k=B.compute.computeInstance.hasDependencies?R:x,D||void 0!==x?"function"==typeof x&&(m={fn:x}):m=n.getHelper(S,i)}if("^"===s){var j=u;u=c,c=j}if(m)return g(_,r,i,a,u,c),e.simpleExtend(_,{context:O,scope:r,contexts:r,hash:b,nodeList:a,exprData:o}),w.push(_),y=function(){return m.fn.apply(O,w)||""},y.bindOnce=!1,y;if(!s)return k&&k.isComputed?k:function(){return""+(null!=k?k:"")};if("#"===s||"^"===s){g(_,r,i,a,u,c);var F=function(){var n;if(n=e.isFunction(k)&&k.isComputed?k():k,t.isArrayLike(n)){var a=t.isObserveLike(n);return(a?n.attr("length"):n.length)?(p?h:f)(n,a,_,i):_.inverse(r,i)}return n?_.fn(n||r,i):_.inverse(r,i)};return F.bindOnce=!1,F}},makeLiveBindingPartialRenderer:function(t,n){return t=e.trim(t),function(i,a,o){var u=[this];u.expression=">"+t,s.register(u,null,n.directlyNested?o||!0:!0);var c=e.compute(function(){var n,r=t,s=a.attr("partials."+r);if(s)n=s.render?s.render(i,a):s(i,a);else{var o=i.read(r,{isArgument:!0,returnObserveMethods:!0,proxyMethods:!1}).value;o&&(r=o),n=e.view.render(r,i,a)}return e.frag(n)});r.html(this,c,this.parentNode,u)}},makeStringBranchRenderer:function(e,t){var n=w(t),r=e+t;return function(t,i,a,s){var o=t.__cache[r];(e||!o)&&(o=y(t,i,null,e,n,a,s,!0),e||(t.__cache[r]=o));var u=o();return null==u?"":""+u}},makeLiveBindingBranchRenderer:function(t,n,a){var o=w(n);return function(u,c,l,f,p){var h=[this];h.expression=n,s.register(h,null,a.directlyNested?l||!0:!0);var d=y(u,c,h,t,o,f,p,a.tag),v=e.compute(d,null,!1,d.bindOnce===!1?!1:!0);v.bind("change",e.k);var g=v();if("function"==typeof g){var m=e.__clearReading();g(this),e.__setReading(m)}else v.computeInstance.hasDependencies?a.attr?r.simpleAttribute(this,a.attr,v):a.tag?r.attributes(this,v):a.text&&"object"!=typeof g?r.text(this,v,this.parentNode,h):r.html(this,v,this.parentNode,h):a.attr?e.attr.set(this,a.attr,g):a.tag?r.setAttributes(this,g):a.text&&"string"==typeof g?this.nodeValue=g:g&&i.replace([this],e.frag(g));v.unbind("change",e.k)}},splitModeFromExpression:function(t,n){t=e.trim(t);var r=t.charAt(0);return"#/{&^>!".indexOf(r)>=0?t=e.trim(t.substr(1)):r=null,"{"===r&&n.node&&(r=null),{mode:r,expression:t}},cleanLineEndings:function(e){return e.replace(c,function(e,t,n,r,i,a,s,o,u,c){a=a||"",t=t||"",n=n||"";var l=b(i||u,{});return o||">{".indexOf(l.mode)>=0?e:"^#!/".indexOf(l.mode)>=0?r+(0!==c&&s.length?t+"\n":""):n+r+a+(n.length||0!==c?t+"\n":"")})},Options:e.view.Scope.extend({init:function(t,n){t.helpers||t.partials||t.tags||(t={helpers:t}),e.view.Scope.prototype.init.apply(this,arguments)}})},y=x.makeEvaluator,w=x.expressionData,b=x.splitModeFromExpression;return x}); +/*can@2.2.6#view/bindings/bindings*/ +define("can/view/bindings/bindings",["can/util/util","can/view/stache/mustache_core","can/view/callbacks/callbacks","can/control/control","can/view/scope/scope"],function(e,t){var n=function(){var e={"":!0,"true":!0,"false":!1},t=function(t){if(t&&t.getAttribute){var n=t.getAttribute("contenteditable");return e[n]}};return function(e){var n=t(e);return"boolean"==typeof n?n:!!t(e.parentNode)}}(),i=function(e){return"{"===e[0]&&"}"===e[e.length-1]?e.substr(1,e.length-2):e};e.view.attr("can-value",function(t,a){var c,l,h=e.trim(i(t.getAttribute("can-value"))),v=a.scope.computeData(h,{args:[]}).compute;return"input"===t.nodeName.toLowerCase()&&("checkbox"===t.type&&(c=e.attr.has(t,"can-true-value")?t.getAttribute("can-true-value"):!0,l=e.attr.has(t,"can-false-value")?t.getAttribute("can-false-value"):!1),"checkbox"===t.type||"radio"===t.type)?void new o(t,{value:v,trueValue:c,falseValue:l}):"select"===t.nodeName.toLowerCase()&&t.multiple?void new u(t,{value:v}):n(t)?void new r(t,{value:v}):void new s(t,{value:v})});var a={enter:function(e,t,n){return{event:"keyup",handler:function(e){return 13===e.keyCode?n.call(this,e):void 0}}}};e.view.attr(/can-[\w\.]+/,function(n,s){var o=s.attributeName,u=o.substr("can-".length),r=function(a){var u=n.getAttribute(o);if(u){var r=t.expressionData(i(u)),c=s.scope.read(r.name.get,{returnObserveMethods:!0,isArgument:!0,executeAnonymousFunctions:!0}),l=[],h=e.$(this),v=e.viewModel(h[0]),f=s.scope.add({"@element":h,"@event":a,"@viewModel":v,"@scope":s.scope,"@context":s.scope._context});if(!e.isEmptyObject(r.hash)){var p={};e.each(r.hash,function(e,t){if(e&&e.hasOwnProperty("get")){var n=e.get.indexOf("@")?s.scope:f;p[t]=n.read(e.get,{}).value}else p[t]=e}),l.unshift(p)}if(r.args.length)for(var d,g=r.args.length-1;g>=0;g--)if(d=r.args[g],d&&d.hasOwnProperty("get")){var m=d.get.indexOf("@")?s.scope:f;l.unshift(m.read(d.get,{}).value)}else l.unshift(d);return l.length||(l=[s.scope._context,h].concat(e.makeArray(arguments))),c.value.apply(c.parent,l)}};if(a[u]){var c=a[u](s,n,r);r=c.handler,u=c.event}e.bind.call(n,u,r)});var s=e.Control.extend({init:function(){"SELECT"===this.element[0].nodeName.toUpperCase()?setTimeout(e.proxy(this.set,this),1):this.set()},"{value} change":"set",set:function(){if(this.element){var e=this.options.value();this.element[0].value=null==e?"":e}},change:function(){if(this.element){var e=this.element[0];this.options.value(e.value);var t=this.options.value();e.value!==t&&(e.value=t)}}}),o=e.Control.extend({init:function(){this.isCheckbox="checkbox"===this.element[0].type.toLowerCase(),this.check()},"{value} change":"check",check:function(){if(this.isCheckbox){var t=this.options.value(),n=this.options.trueValue||!0;this.element[0].checked=t==n}else{var i=this.options.value()==this.element[0].value?"set":"remove";e.attr[i](this.element[0],"checked",!0)}},change:function(){this.isCheckbox?this.options.value(this.element[0].checked?this.options.trueValue:this.options.falseValue):this.element[0].checked&&this.options.value(this.element[0].value)}}),u=s.extend({init:function(){this.delimiter=";",setTimeout(e.proxy(this.set,this),1)},set:function(){var t=this.options.value();"string"==typeof t?(t=t.split(this.delimiter),this.isString=!0):t&&(t=e.makeArray(t));var n={};e.each(t,function(e){n[e]=!0}),e.each(this.element[0].childNodes,function(e){e.value&&(e.selected=!!n[e.value])})},get:function(){var t=[],n=this.element[0].childNodes;return e.each(n,function(e){e.selected&&e.value&&t.push(e.value)}),t},change:function(){var t=this.get(),n=this.options.value();this.isString||"string"==typeof n?(this.isString=!0,this.options.value(t.join(this.delimiter))):n instanceof e.List?n.attr(t,!0):this.options.value(t)}}),r=e.Control.extend({init:function(){this.set(),this.on("blur","setValue")},"{value} change":"set",set:function(){var e=this.options.value();this.element[0].innerHTML="undefined"==typeof e?"":e},setValue:function(){this.options.value(this.element[0].innerHTML)}})}); +/*can@2.2.6#view/mustache/mustache*/ +define("can/view/mustache/mustache",["can/util/util","can/view/scope/scope","can/view/view","can/view/scanner","can/compute/compute","can/view/render","can/view/bindings/bindings"],function(e){e.view.ext=".mustache";var n="scope",t="___h4sh",r="{scope:"+n+",options:options}",i="{scope:"+n+",options:options, special: true}",s=n+",options",o=/((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g,a=/^(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false|null|undefined)|((.+?)=(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false)|(.+))))$/,c=function(e){return'{get:"'+e.replace(/"/g,'\\"')+'"}'},u=function(e){return e&&"string"==typeof e.get},f=function(n){return n instanceof e.Map||n&&!!n._get},p=function(e){return e&&e.splice&&"number"==typeof e.length},l=function(n,t,r){var i=function(e,r){return n(e||t,r)};return function(n,s){return void 0===n||n instanceof e.view.Scope||(n=t.add(n)),void 0===s||s instanceof e.view.Options||(s=r.add(s)),i(n,s||r)}},h=function(n,t){if(this.constructor!==h){var r=new h(n);return function(e,n){return r.render(e,n)}}return"function"==typeof n?void(this.template={fn:n}):(e.extend(this,n),void(this.template=this.scanner.scan(this.text,this.name)))};e.Mustache=e.global.Mustache=h,h.prototype.render=function(n,t){return n instanceof e.view.Scope||(n=new e.view.Scope(n||{})),t instanceof e.view.Options||(t=new e.view.Options(t||{})),t=t||{},this.template.fn.call(n,n,t)},e.extend(h.prototype,{scanner:new e.view.Scanner({text:{start:"",scope:n,options:",options: options",argNames:s},tokens:[["returnLeft","{{{","{{[{&]"],["commentFull","{{!}}","^[\\s\\t]*{{!.+?}}\\n"],["commentLeft","{{!","(\\n[\\s\\t]*{{!|{{!)"],["escapeFull","{{}}","(^[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}$)",function(e){return{before:/^\n.+?\n$/.test(e)?"\n":"",content:e.match(/\{\{(.+?)\}\}/)[1]||""}}],["escapeLeft","{{"],["returnRight","}}}"],["right","}}"]],helpers:[{name:/^>[\s]*\w*/,fn:function(n,t){var r=e.trim(n.replace(/^>\s?/,"")).replace(/["|']/g,"");return"can.Mustache.renderPartial('"+r+"',"+s+")"}},{name:/^\s*data\s/,fn:function(e,t){var r=e.match(/["|'](.*)["|']/)[1];return"can.proxy(function(__){can.data(can.$(__),'"+r+"', this.attr('.')); }, "+n+")"}},{name:/\s*\(([\$\w]+)\)\s*->([^\n]*)/,fn:function(e){var t=/\s*\(([\$\w]+)\)\s*->([^\n]*)/,r=e.match(t);return"can.proxy(function(__){var "+r[1]+"=can.$(__);with("+n+".attr('.')){"+r[2]+"}}, this);"}},{name:/^.*$/,fn:function(n,u){var f=!1,p={content:"",startTxt:!1,startOnlyTxt:!1,end:!1};if(n=e.trim(n),n.length&&(f=n.match(/^([#^\/]|else$)/))){switch(f=f[0]){case"#":case"^":u.specialAttribute?p.startOnlyTxt=!0:(p.startTxt=!0,p.escaped=0);break;case"/":return p.end=!0,p.content+='return ___v1ew.join("");}}])',p}n=n.substring(1)}if("else"!==f){var l,h=[],v=[],g=0;p.content+="can.Mustache.txt(\n"+(u.specialAttribute?i:r)+",\n"+(f?'"'+f+'"':"null")+",",(e.trim(n)+" ").replace(o,function(e,n){g&&(l=n.match(a))?l[2]?h.push(l[0]):v.push(l[4]+":"+(l[6]?l[6]:c(l[5]))):h.push(c(n)),g++}),p.content+=h.join(","),v.length&&(p.content+=",{"+t+":{"+v.join(",")+"}}")}switch(f&&"else"!==f&&(p.content+=",[\n\n"),f){case"^":case"#":p.content+="{fn:function("+s+"){var ___v1ew = [];";break;case"else":p.content+='return ___v1ew.join("");}},\n{inverse:function('+s+"){\nvar ___v1ew = [];";break;default:p.content+=")"}return f||(p.startTxt=!0,p.end=!0),p}}]})});for(var v=e.view.Scanner.prototype.helpers,g=0;g0&&t!==n)return r.inverse();n=t}return r.fn()},eq:function(){return h._helpers.is.fn.apply(this,arguments)},unless:function(n,t){return h._helpers["if"].fn.apply(this,[e.isFunction(n)?e.compute(function(){return!n()}):!n,t])},each:function(n,t){var r,i,s,o=h.resolve(n),a=[];if(e.view.lists&&(o instanceof e.List||n&&n.isComputed&&void 0===o))return e.view.lists(n,function(e,n){return t.fn(t.scope.add({"@index":n}).add(e))});if(n=o,n&&p(n)){for(s=0;st;t++)f[t]()};if(t.each(this.constructor.attributeScopeMappings,function(e,n){r[n]=i.getAttribute(t.hyphenate(e))}),t.each(t.makeArray(i.attributes),function(n,i){var c=t.camelize(n.nodeName.toLowerCase()),u=n.value;if(!(p.constructor.attributeScopeMappings[c]||o.test(c)||e.attr(n.nodeName))){if("{"===u[0]&&"}"===u[u.length-1])u=u.substr(1,u.length-2);else if("legacy"!==s.templateType)return void(r[c]=u);var h=s.scope.computeData(u,{args:[]}),m=h.compute,v=function(e,n){d[c]=(d[c]||0)+1,a.attr(c,n),t.batch.afterPreviousEvents(function(){--d[c]})};m.bind("change",v),r[c]=m(),m.computeInstance.hasDependencies?(f.push(function(){m.unbind("change",v)}),l[c]=h):m.unbind("change",v)}}),this.constructor.Map)a=new this.constructor.Map(r);else if(h instanceof t.Map)a=h;else if(t.isFunction(h)){var v=h.call(this,r,s.scope,i);a=v instanceof t.Map?v:v.prototype instanceof t.Map?new v(r):new(t.Map.extend(v))(r)}var g={};t.each(l,function(t,e){g[e]=function(n,o){d[e]||t.compute(o)},a.bind(e,g[e])}),t.isEmptyObject(this.constructor.attributeScopeMappings)&&"legacy"===s.templateType||t.bind.call(i,"attributes",function(e){var n=t.camelize(e.attributeName);l[n]||o.test(n)||a.attr(n,i.getAttribute(e.attributeName))}),this.scope=this.viewModel=a,t.data(t.$(i),"scope",this.scope),t.data(t.$(i),"viewModel",this.scope);var b=u?this.scope:s.scope.add(this.scope),y={helpers:{}};if(t.each(this.helpers||{},function(e,n){t.isFunction(e)&&(y.helpers[n]=function(){return e.apply(a,arguments)})}),f.push(function(){t.each(g,function(t,e){a.unbind(e,g[e])})}),this._control=new this.constructor.Control(i,{scope:this.scope,viewModel:this.scope}),this._control&&this._control.destroy){var w=this._control.destroy;this._control.destroy=function(){w.apply(this,arguments),m()},this._control.on()}else t.bind.call(i,"removed",function(){m()});var M=t.view.nodeLists.register([],void 0,!0);f.push(function(){t.view.nodeLists.unregister(M)}),this.constructor.renderer?(y.tags||(y.tags={}),y.tags.content=function C(e,o){var i=s.subtemplate||o.subtemplate;if(i){delete y.tags.content;var a=u&&i===s.subtemplate?s:o;if(o.parentNodeList){var c=i(a.scope,a.options,o.parentNodeList);n.replace([e],c)}else t.view.live.replace([e],i(a.scope,a.options));y.tags.content=C}},c=this.constructor.renderer(b,s.options.add(y),M)):c="legacy"===s.templateType?t.view.frag(s.subtemplate?s.subtemplate(b,s.options.add(y)):""):s.subtemplate?s.subtemplate(b,s.options.add(y),M):document.createDocumentFragment(),t.appendChild(i,c),t.view.nodeLists.update(M,i.childNodes)}}),a=t.Control.extend({_lookup:function(t){return[t.scope,t,window]},_action:function(e,n,o){var s,a;if(i.lastIndex=0,s=i.test(e),o||!s){if(s){a=t.compute(function(){var o,s=e.replace(i,function(e,i){var s;return"scope"===i||"viewModel"===i?(o=n.scope,""):(i=i.replace(/^(scope|^viewModel)\./,""),s=t.compute.read(n.scope,i.split("."),{isArgument:!0}).value,void 0===s&&(s=t.getObject(i)),"string"==typeof s?s:(o=s,""))}),a=s.split(/\s+/g),c=a.pop();return{processor:this.processors[c]||this.processors.click,parts:[s,a.join(" "),c],delegate:o||void 0}},this);var c=function(t,n){o._bindings.control[e](o.element),o._bindings.control[e]=n.processor(n.delegate||o.element,n.parts[2],n.parts[1],e,o)};return a.bind("change",c),o._bindings.readyComputes[e]={compute:a,handler:c},a()}return t.Control._action.apply(this,arguments)}}},{setup:function(e,n){return this.scope=n.scope,this.viewModel=n.viewModel,t.Control.prototype.setup.call(this,e,n)},off:function(){this._bindings&&t.each(this._bindings.readyComputes||{},function(t){t.compute.unbind("change",t.handler)}),t.Control.prototype.off.apply(this,arguments),this._bindings.readyComputes={}}}),c=t.$;return c.fn&&(c.fn.scope=c.fn.viewModel=function(){return t.viewModel.apply(t,[this].concat(t.makeArray(arguments)))}),s}); +/*can@2.2.6#model/model*/ +define("can/model/model",["can/util/util","can/map/map","can/list/list"],function(t){var e=function(e,r,i){var n=new t.Deferred;return e.then(function(){var e=t.makeArray(arguments),s=!0;try{e[0]=i.apply(r,e)}catch(o){s=!1,n.rejectWith(n,[o].concat(e))}s&&n.resolveWith(n,e)},function(){n.rejectWith(this,arguments)}),"function"==typeof e.abort&&(n.abort=function(){return e.abort()}),n},r=0,i=function(e){return t.__observe(e,e.constructor.id),e.__get(e.constructor.id)},n=function(e,r,i,n,s,o){var a={};if("string"==typeof e){var u=e.split(/\s+/);a.url=u.pop(),u.length&&(a.type=u.pop())}else t.extend(a,e);return a.data="object"!=typeof r||t.isArray(r)?r:t.extend(a.data||{},r),a.url=t.sub(a.url,a.data,!0),t.ajax(t.extend({type:i||"post",dataType:n||"json",success:s,error:o},a))},s=function(r,n,s,o,a){var u;t.isArray(r)?(u=r[1],r=r[0]):u=r.serialize(),u=[u];var c,l,d=r.constructor;return("update"===n||"destroy"===n)&&u.unshift(i(r)),l=d[n].apply(d,u),c=e(l,r,function(t){return r[a||n+"d"](t,l),r}),l.abort&&(c.abort=function(){l.abort()}),c.then(s,o),c},o={models:function(e,r,i){if(t.Model._reqs++,e){if(e instanceof this.List)return e;var n=this,s=[],o=n.List||f,a=r instanceof t.List?r:new o,u=e instanceof f,c=u?e.serialize():e;if(c=n.parseModels(c,i),c.data&&(e=c,c=c.data),"undefined"==typeof c||!t.isArray(c))throw new Error("Could not get any raw data while converting using .models");return a.length&&a.splice(0),t.each(c,function(t){s.push(n.model(t,i))}),a.push.apply(a,s),t.isArray(e)||t.each(e,function(t,e){"data"!==e&&a.attr(e,t)}),setTimeout(t.proxy(this._clean,this),1),a}},model:function(e,r,i){if(e){e="function"==typeof e.serialize?e.serialize():this.parseModel(e,i);var n=e[this.id];(n||0===n)&&this.store[n]&&(r=this.store[n]);var s=r&&t.isFunction(r.attr)?r.attr(e,this.removeAttr||!1):new this(e);return s}}},a={parseModel:function(e){return function(r){return e?t.getObject(e,r):r}},parseModels:function(e){return function(r){if(t.isArray(r))return r;e=e||"data";var i=t.getObject(e,r);if(!t.isArray(i))throw new Error("Could not get any raw data while converting using .models");return i}}},u={create:{url:"_shortName",type:"post"},update:{data:function(e,r){r=r||{};var i=this.id;return r[i]&&r[i]!==e&&(r["new"+t.capitalize(e)]=r[i],delete r[i]),r[i]=e,r},type:"put"},destroy:{type:"delete",data:function(t,e){return e=e||{},e.id=e[this.id]=t,e}},findAll:{url:"_shortName"},findOne:{}},c=function(t,e){return function(r){return r=t.data?t.data.apply(this,arguments):r,n(e||this[t.url||"_url"],r,t.type||"get")}},l=function(t,e){if(t.resource){var r=t.resource.replace(/\/+$/,"");return"findAll"===e||"create"===e?r:r+"/{"+t.id+"}"}};t.Model=t.Map.extend({fullName:"can.Model",_reqs:0,setup:function(e,i,n,s){if("string"!=typeof i&&(s=n,n=i),s||(s=n),this.store={},t.Map.setup.apply(this,arguments),t.Model){n&&n.List?(this.List=n.List,this.List.Map=this):this.List=e.List.extend({Map:this},{});var d=this,p=t.proxy(this._clean,d);t.each(u,function(r,i){if(n&&n[i]&&("string"==typeof n[i]||"object"==typeof n[i])?d[i]=c(r,n[i]):n&&n.resource&&!t.isFunction(n[i])&&(d[i]=c(r,l(d,i))),d["make"+t.capitalize(i)]){var s=d["make"+t.capitalize(i)](d[i]);t.Construct._overwrite(d,e,i,function(){t.Model._reqs++;var e=s.apply(this,arguments),r=e.then(p,p);return r.abort=e.abort,r})}});var h={};t.each(o,function(r,i){var s="parse"+t.capitalize(i),o=n&&n[i]||d[i];"string"==typeof o?(d[s]=o,t.Construct._overwrite(d,e,i,r)):n&&n[i]&&(h[s]=!0)}),t.each(a,function(r,i){var s=n&&n[i]||d[i];if("string"==typeof s)t.Construct._overwrite(d,e,i,r(s));else if(!(n&&t.isFunction(n[i])||d[i])){var o=r();o.useModelConverter=h[i],t.Construct._overwrite(d,e,i,o)}}),"can.Model"!==d.fullName&&d.fullName||(d.fullName="Model"+ ++r),t.Model._reqs=0,this._url=this._shortName+"/{"+this.id+"}"}},_ajax:c,_makeRequest:s,_clean:function(){if(t.Model._reqs--,!t.Model._reqs)for(var e in this.store)this.store[e]._bindings||delete this.store[e];return arguments[0]},models:o.models,model:o.model},{setup:function(e){var r=e&&e[this.constructor.id];t.Model._reqs&&null!=r&&(this.constructor.store[r]=this),t.Map.prototype.setup.apply(this,arguments)},isNew:function(){var t=i(this);return!(t||0===t)},save:function(t,e){return s(this,this.isNew()?"create":"update",t,e)},destroy:function(e,r){if(this.isNew()){var i=this,n=t.Deferred();return n.then(e,r),n.done(function(t){i.destroyed(t)}).resolve(i)}return s(this,"destroy",e,r,"destroyed")},_bindsetup:function(){var e=this.__get(this.constructor.id);return null!=e&&(this.constructor.store[e]=this),t.Map.prototype._bindsetup.apply(this,arguments)},_bindteardown:function(){return delete this.constructor.store[i(this)],t.Map.prototype._bindteardown.apply(this,arguments)},___set:function(e,r){t.Map.prototype.___set.call(this,e,r),e===this.constructor.id&&this._bindings&&(this.constructor.store[i(this)]=this)}});var d=function(t){return function(e,r,i){return this[t](e,null,i)}},p=function(t){return this.parseModel.useModelConverter?this.model(t):this.parseModel(t)},h={makeFindAll:d("models"),makeFindOne:d("model"),makeCreate:p,makeUpdate:p,makeDestroy:p};t.each(h,function(r,i){t.Model[i]=function(i){return function(){var n=t.makeArray(arguments),s=t.isFunction(n[1])?n.splice(0,1):n.splice(0,2),o=e(i.apply(this,s),this,r);return o.then(n[0],n[1]),o}}}),t.each(["created","updated","destroyed"],function(e){t.Model.prototype[e]=function(r){var i=this,n=i.constructor;r&&"object"==typeof r&&this.attr(t.isFunction(r.attr)?r.attr():r),t.dispatch.call(this,{type:"change",target:this},[e]),t.dispatch.call(n,e,[this])}});var f=t.Model.List=t.List.extend({_bubbleRule:function(e,r){var i=t.List._bubbleRule(e,r);return i.push("destroyed"),i}},{setup:function(e){t.isPlainObject(e)&&!t.isArray(e)?(t.List.prototype.setup.apply(this),this.replace(t.isDeferred(e)?e:this.constructor.Map.findAll(e))):t.List.prototype.setup.apply(this,arguments),this._init=1,this.bind("destroyed",t.proxy(this._destroyed,this)),delete this._init},_destroyed:function(t,e){if(/\w+/.test(e))for(var r;(r=this.indexOf(t.target))>-1;)this.splice(r,1)}});return t.Model}); +/*can@2.2.6#util/string/deparam/deparam*/ +define("can/util/string/deparam/deparam",["can/util/util","can/util/string/string"],function(t){var n=/^\d+$/,e=/([^\[\]]+)|(\[\])/g,r=/([^?#]*)(#.*)?$/,i=function(t){return decodeURIComponent(t.replace(/\+/g," "))};return t.extend(t,{deparam:function(a){var u,c,o={};return a&&r.test(a)&&(u=a.split("&"),t.each(u,function(t){var r=t.split("="),a=i(r.shift()),u=i(r.join("=")),p=o;if(a){r=a.match(e);for(var s=0,d=r.length-1;d>s;s++)p[r[s]]||(p[r[s]]=n.test(r[s+1])||"[]"===r[s+1]?[]:{}),p=p[r[s]];c=r.pop(),"[]"===c?p.push(u):p[c]=u}})),o}}),t}); +/*can@2.2.6#route/route*/ +define("can/route/route",["can/util/util","can/map/map","can/list/list","can/util/string/deparam/deparam"],function(t){var e,r,n,a,u=/\:([\w\.]+)/g,o=/^(?:&[^=]+=[^&]*)+/,i=function(e){var r=[];return t.each(e,function(e,n){r.push(("className"===n?"class":n)+'="'+("href"===n?e:t.esc(e))+'"')}),r.join(" ")},c=function(t,e){var r=0,n=0,a={};for(var u in t.defaults)t.defaults[u]===e[u]&&(a[u]=1,r++);for(;no&&(n=t,o=a),a>=l?!1:void 0}),t.route.routes[i]&&c(t.route.routes[i],e)===o&&(n=t.route.routes[i]),n){var s,h=f({},e),p=n.route.replace(u,function(t,r){return delete h[r],e[r]===n.defaults[r]?"":encodeURIComponent(e[r])}).replace("\\","");return d(n.defaults,function(t,e){h[e]===t&&delete h[e]}),s=t.param(h),r&&t.route.attr("route",n.route),p+(s?t.route._call("querySeparator")+s:"")}return t.isEmptyObject(e)?"":t.route._call("querySeparator")+t.param(e)},deparam:function(e){var r=t.route._call("root");r.lastIndexOf("/")===r.length-1&&0===e.indexOf("/")&&(e=e.substr(1));var n={length:-1},a=t.route._call("querySeparator"),u=t.route._call("paramsMatcher");if(d(t.route.routes,function(t,r){t.test.test(e)&&t.length>n.length&&(n=t)}),n.length>-1){var o=e.match(n.test),i=o.shift(),c=e.substr(i.length-(o[o.length-1]===a?1:0)),l=c&&u.test(c)?t.deparam(c.slice(1)):{};return l=f(!0,{},n.defaults,l),d(o,function(t,e){t&&t!==a&&(l[n.names[e]]=decodeURIComponent(t))}),l.route=n.route,l}return e.charAt(0)!==a&&(e=a+e),u.test(e)?t.deparam(e.slice(1)):{}},data:new t.Map({}),map:function(e){var r;r=e.prototype instanceof t.Map?new e:e,t.route.data=r},routes:{},ready:function(e){return e!==!0&&(t.route._setup(),t.route.setState()),t.route},url:function(e,r){return r&&(e=t.extend({},t.route.deparam(t.route._call("matchingPartOfURL")),e)),t.route._call("root")+t.route.param(e)},link:function(e,r,n,a){return""+e+""},current:function(e){return t.__observe(_,"__url"),this._call("matchingPartOfURL")===t.route.param(e)},bindings:{hashchange:{paramsMatcher:o,querySeparator:"&",matchSlashes:!1,bind:function(){t.bind.call(window,"hashchange",b)},unbind:function(){t.unbind.call(window,"hashchange",b)},matchingPartOfURL:function(){return l.href.split(/#!?/)[1]||""},setURL:function(t){return l.hash!=="#"+t&&(l.hash="!"+t),t},root:"#!"}},defaultBinding:"hashchange",currentBinding:null,_setup:function(){t.route.currentBinding||(t.route._call("bind"),t.route.bind("change",m),t.route.currentBinding=t.route.defaultBinding)},_teardown:function(){t.route.currentBinding&&(t.route._call("unbind"),t.route.unbind("change",m),t.route.currentBinding=null),clearTimeout(e),a=0},_call:function(){var e=t.makeArray(arguments),r=e.shift(),n=t.route.bindings[t.route.currentBinding||t.route.defaultBinding],a=n[r];return a.apply?a.apply(n,e):a}}),d(["bind","unbind","on","off","delegate","undelegate","removeAttr","compute","_get","__get","each"],function(e){t.route[e]=function(){return t.route.data[e]?t.route.data[e].apply(t.route.data,arguments):void 0}}),t.route.attr=function(e,r){var n,a=typeof e;return n=void 0===r?arguments:"string"!==a&&"number"!==a?[h(e),r]:[e,h(r)],t.route.data.attr.apply(t.route.data,n)};var b=t.route.setState=function(){var e=t.route._call("matchingPartOfURL"),u=r;r=t.route.deparam(e),a&&e===n||(t.batch.start(),v(u,r,t.route.data),t.route.attr(r),t.batch.trigger(_,"__url",[e,n]),t.batch.stop())},v=function(t,e,r){for(var n in t)void 0===e[n]?r.removeAttr(n):"[object Object]"===Object.prototype.toString.call(t[n])&&v(t[n],e[n],r.attr(n))};return t.route}); +/*can@2.2.6#control/route/route*/ +define("can/control/route/route",["can/util/util","can/route/route","can/control/control"],function(t){return t.Control.processors.route=function(o,r,u,n,e){u=u||"",t.route.routes[u]||("/"===u[0]&&(u=u.substring(1)),t.route(u));var c,i=function(o,r,i){if(t.route.attr("route")===u&&(void 0===o.batchNum||o.batchNum!==c)){c=o.batchNum;var a=t.route.attr();delete a.route,t.isFunction(e[n])?e[n](a):e[e[n]](a)}};return t.route.bind("change",i),function(){t.route.unbind("change",i)}},t}); +/*can@2.2.6#util/event*/ +define("can/util/event",["can/util/can","can/event/event"],function(n){return n}); +/*[global-shim-end]*/ +!function(){window._define=window.define,window.define=window.define.orig}(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.list.promise.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.list.promise.js new file mode 100644 index 0000000000..af133c60a5 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.list.promise.js @@ -0,0 +1,124 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#list/promise/promise*/ +define('can/list/promise/promise', ['can/list/list'], function (list) { + var oldReplace = can.List.prototype.replace; + can.List.prototype.replace = function (data) { + var result = oldReplace.apply(this, arguments); + if (can.isDeferred(data)) { + can.batch.start(); + this.attr('state', data.state()); + this.removeAttr('reason'); + can.batch.stop(); + var self = this; + var deferred = this._deferred = new can.Deferred(); + data.then(function () { + self.attr('state', data.state()); + deferred.resolve(self); + }, function (reason) { + can.batch.start(); + self.attr('state', data.state()); + self.attr('reason', reason); + can.batch.stop(); + deferred.reject(reason); + }); + } + return result; + }; + can.each({ + isResolved: 'resolved', + isPending: 'pending', + isRejected: 'rejected' + }, function (value, method) { + can.List.prototype[method] = function () { + return this.attr('state') === value; + }; + }); + can.each([ + 'then', + 'done', + 'fail', + 'always', + 'promise' + ], function (name) { + can.List.prototype[name] = function () { + if (!this._deferred) { + this._deferred = new can.Deferred(); + this._deferred.resolve(this); + } + return this._deferred[name].apply(this._deferred, arguments); + }; + }); +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.list.sort.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.list.sort.js new file mode 100644 index 0000000000..1269aad5dd --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.list.sort.js @@ -0,0 +1,264 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#list/sort/sort*/ +define('can/list/sort/sort', [ + 'can/util/util', + 'can/list/list' +], function () { + var oldBubbleRule = can.List._bubbleRule; + can.List._bubbleRule = function (eventName, list) { + var oldBubble = oldBubbleRule.apply(this, arguments); + if (list.comparator && can.inArray('change', oldBubble) === -1) { + oldBubble.push('change'); + } + return oldBubble; + }; + var proto = can.List.prototype, _changes = proto._changes, setup = proto.setup, unbind = proto.unbind; + can.extend(proto, { + setup: function (instances, options) { + setup.apply(this, arguments); + this._comparatorBound = false; + this._init = 1; + this.bind('comparator', can.proxy(this._comparatorUpdated, this)); + delete this._init; + if (this.comparator) { + this.sort(); + } + }, + _comparatorUpdated: function (ev, newValue) { + if (newValue || newValue === 0) { + this.sort(); + if (this._bindings > 0 && !this._comparatorBound) { + this.bind('change', this._comparatorBound = function () { + }); + } + } else if (this._comparatorBound) { + unbind.call(this, 'change', this._comparatorBound); + this._comparatorBound = false; + } + }, + unbind: function (ev, handler) { + var res = unbind.apply(this, arguments); + if (this._comparatorBound && this._bindings === 1) { + unbind.call(this, 'change', this._comparatorBound); + this._comparatorBound = false; + } + return res; + }, + _comparator: function (a, b) { + var comparator = this.comparator; + if (comparator && typeof comparator === 'function') { + return comparator(a, b); + } + return a === b ? 0 : a < b ? -1 : 1; + }, + _changes: function (ev, attr, how, newVal, oldVal) { + if (this.comparator && /^\d+/.test(attr)) { + if (ev.batchNum && ev.batchNum !== this._lastBatchNum) { + this.sort(); + this._lastBatchNum = ev.batchNum; + return; + } + var currentIndex = +/^\d+/.exec(attr)[0], item = this[currentIndex]; + if (typeof item !== 'undefined') { + var newIndex = this._getInsertIndex(item, currentIndex); + if (newIndex !== currentIndex) { + this._swapItems(currentIndex, newIndex); + can.trigger(this, 'length', [this.length]); + } + } + } + _changes.apply(this, arguments); + }, + _getInsertIndex: function (item, currentIndex) { + var a = this._getComparatorValue(item), b, offset = 0; + for (var i = 0; i < this.length; i++) { + b = this._getComparatorValue(this[i]); + if (typeof currentIndex !== 'undefined' && i === currentIndex) { + offset = -1; + continue; + } + if (this._comparator(a, b) < 0) { + return i + offset; + } + } + return i + offset; + }, + _getComparatorValue: function (item, overwrittenComparator) { + var comparator = typeof overwrittenComparator === 'string' ? overwrittenComparator : this.comparator; + if (item && comparator && typeof comparator === 'string') { + item = typeof item[comparator] === 'function' ? item[comparator]() : item.attr(comparator); + } + return item; + }, + _getComparatorValues: function () { + var self = this; + var a = []; + this.each(function (item, index) { + a.push(self._getComparatorValue(item)); + }); + return a; + }, + sort: function (comparator, silent) { + var a, b, c, isSorted; + var comparatorFn = can.isFunction(comparator) ? comparator : this._comparator; + for (var i, iMin, j = 0, n = this.length; j < n - 1; j++) { + iMin = j; + isSorted = true; + c = undefined; + for (i = j + 1; i < n; i++) { + a = this._getComparatorValue(this.attr(i), comparator); + b = this._getComparatorValue(this.attr(iMin), comparator); + if (comparatorFn.call(this, a, b) < 0) { + isSorted = false; + iMin = i; + } + if (c && comparatorFn.call(this, a, c) < 0) { + isSorted = false; + } + c = a; + } + if (isSorted) { + break; + } + if (iMin !== j) { + this._swapItems(iMin, j, silent); + } + } + if (!silent) { + can.trigger(this, 'length', [this.length]); + } + return this; + }, + _swapItems: function (oldIndex, newIndex, silent) { + var temporaryItemReference = this[oldIndex]; + [].splice.call(this, oldIndex, 1); + [].splice.call(this, newIndex, 0, temporaryItemReference); + if (!silent) { + can.trigger(this, 'move', [ + temporaryItemReference, + newIndex, + oldIndex + ]); + } + } + }); + var getArgs = function (args) { + return args[0] && can.isArray(args[0]) ? args[0] : can.makeArray(args); + }; + can.each({ + push: 'length', + unshift: 0 + }, function (where, name) { + var proto = can.List.prototype, old = proto[name]; + proto[name] = function () { + if (this.comparator && arguments.length) { + var args = getArgs(arguments); + var i = args.length; + while (i--) { + var val = can.bubble.set(this, i, this.__type(args[i], i)); + var newIndex = this._getInsertIndex(val); + Array.prototype.splice.apply(this, [ + newIndex, + 0, + val + ]); + this._triggerChange('' + newIndex, 'add', [val], undefined); + } + can.batch.trigger(this, 'reset', [args]); + return this; + } else { + return old.apply(this, arguments); + } + }; + }); + (function () { + var proto = can.List.prototype; + var oldSplice = proto.splice; + proto.splice = function (index, howMany) { + var args = can.makeArray(arguments), newElements = [], i, len; + if (!this.comparator) { + return oldSplice.apply(this, args); + } + for (i = 2, len = args.length; i < len; i++) { + args[i] = this.__type(args[i], i); + newElements.push(args[i]); + } + oldSplice.call(this, index, howMany); + proto.push.apply(this, newElements); + }; + }()); + return can.Map; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.attributes.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.attributes.js new file mode 100644 index 0000000000..d4bf45c090 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.attributes.js @@ -0,0 +1,187 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#map/attributes/attributes*/ +define('can/map/attributes/attributes', [ + 'can/util/util', + 'can/map/map', + 'can/list/list' +], function (can, Map) { + can.each([ + can.Map, + can.Model + ], function (clss) { + if (clss === undefined) { + return; + } + var isObject = function (obj) { + return typeof obj === 'object' && obj !== null && obj; + }; + can.extend(clss, { + attributes: {}, + convert: { + 'date': function (str) { + var type = typeof str; + if (type === 'string') { + str = Date.parse(str); + return isNaN(str) ? null : new Date(str); + } else if (type === 'number') { + return new Date(str); + } else { + return str; + } + }, + 'number': function (val) { + return parseFloat(val); + }, + 'boolean': function (val) { + if (val === 'false' || val === '0' || !val) { + return false; + } + return true; + }, + 'default': function (val, oldVal, error, type) { + if (can.Map.prototype.isPrototypeOf(type.prototype) && typeof type.model === 'function' && typeof type.models === 'function') { + return type[can.isArray(val) ? 'models' : 'model'](val); + } + if (can.Map.prototype.isPrototypeOf(type.prototype)) { + if (can.isArray(val) && typeof type.List === 'function') { + return new type.List(val); + } + return new type(val); + } + if (typeof type === 'function') { + return type(val, oldVal); + } + var construct = can.getObject(type), context = window, realType; + if (type.indexOf('.') >= 0) { + realType = type.substring(0, type.lastIndexOf('.')); + context = can.getObject(realType); + } + return typeof construct === 'function' ? construct.call(context, val, oldVal) : val; + } + }, + serialize: { + 'default': function (val, type) { + return isObject(val) && val.serialize ? val.serialize() : val; + }, + 'date': function (val) { + return val && val.getTime(); + } + } + }); + var oldSetup = clss.setup; + clss.setup = function (superClass, stat, proto) { + var self = this; + oldSetup.call(self, superClass, stat, proto); + can.each(['attributes'], function (name) { + if (!self[name] || superClass[name] === self[name]) { + self[name] = {}; + } + }); + can.each([ + 'convert', + 'serialize' + ], function (name) { + if (superClass[name] !== self[name]) { + self[name] = can.extend({}, superClass[name], self[name]); + } + }); + }; + }); + can.Map.prototype.__convert = function (prop, value) { + var Class = this.constructor, oldVal = this.__get(prop), type, converter; + if (Class.attributes) { + type = Class.attributes[prop]; + converter = Class.convert[type] || Class.convert['default']; + } + return value === null || !type ? value : converter.call(Class, value, oldVal, function () { + }, type); + }; + var oldSerialize = can.Map.helpers._serialize; + can.Map.helpers._serialize = function (map, name, val) { + var constructor = map.constructor, type = constructor.attributes ? constructor.attributes[name] : 0, converter = constructor.serialize ? constructor.serialize[type] : 0; + return val && typeof val.serialize === 'function' ? oldSerialize.apply(this, arguments) : converter ? converter(val, type) : oldSerialize.apply(this, arguments); + }; + var mapSerialize = can.Map.prototype.serialize; + can.Map.prototype.serialize = function (attrName) { + var baseResult = mapSerialize.apply(this, arguments); + if (attrName) { + return baseResult[attrName]; + } else { + return baseResult; + } + }; + return can.Map; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.backup.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.backup.js new file mode 100644 index 0000000000..f4d08b6e4b --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.backup.js @@ -0,0 +1,209 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#util/object/object*/ +define('can/util/object/object', ['can/util/util'], function (can) { + var isArray = can.isArray; + can.Object = {}; + var same = can.Object.same = function (a, b, compares, aParent, bParent, deep) { + var aType = typeof a, aArray = isArray(a), comparesType = typeof compares, compare; + if (comparesType === 'string' || compares === null) { + compares = compareMethods[compares]; + comparesType = 'function'; + } + if (comparesType === 'function') { + return compares(a, b, aParent, bParent); + } + compares = compares || {}; + if (a === null || b === null) { + return a === b; + } + if (a instanceof Date || b instanceof Date) { + return a === b; + } + if (deep === -1) { + return aType === 'object' || a === b; + } + if (aType !== typeof b || aArray !== isArray(b)) { + return false; + } + if (a === b) { + return true; + } + if (aArray) { + if (a.length !== b.length) { + return false; + } + for (var i = 0; i < a.length; i++) { + compare = compares[i] === undefined ? compares['*'] : compares[i]; + if (!same(a[i], b[i], a, b, compare)) { + return false; + } + } + return true; + } else if (aType === 'object' || aType === 'function') { + var bCopy = can.extend({}, b); + for (var prop in a) { + compare = compares[prop] === undefined ? compares['*'] : compares[prop]; + if (!same(a[prop], b[prop], compare, a, b, deep === false ? -1 : undefined)) { + return false; + } + delete bCopy[prop]; + } + for (prop in bCopy) { + if (compares[prop] === undefined || !same(undefined, b[prop], compares[prop], a, b, deep === false ? -1 : undefined)) { + return false; + } + } + return true; + } + return false; + }; + can.Object.subsets = function (checkSet, sets, compares) { + var len = sets.length, subsets = []; + for (var i = 0; i < len; i++) { + var set = sets[i]; + if (can.Object.subset(checkSet, set, compares)) { + subsets.push(set); + } + } + return subsets; + }; + can.Object.subset = function (subset, set, compares) { + compares = compares || {}; + for (var prop in set) { + if (!same(subset[prop], set[prop], compares[prop], subset, set)) { + return false; + } + } + return true; + }; + var compareMethods = { + 'null': function () { + return true; + }, + i: function (a, b) { + return ('' + a).toLowerCase() === ('' + b).toLowerCase(); + }, + eq: function (a, b) { + return a === b; + }, + similar: function (a, b) { + return a == b; + } + }; + compareMethods.eqeq = compareMethods.similar; + return can.Object; +}); +/*can@2.2.6#map/backup/backup*/ +define('can/map/backup/backup', [ + 'can/util/util', + 'can/compute/compute', + 'can/map/map', + 'can/util/object/object' +], function (can) { + var flatProps = function (a, cur) { + var obj = {}; + for (var prop in a) { + if (typeof a[prop] !== 'object' || a[prop] === null || a[prop] instanceof Date) { + obj[prop] = a[prop]; + } else { + obj[prop] = cur.attr(prop); + } + } + return obj; + }; + var oldSetup = can.Map.prototype.setup; + can.extend(can.Map.prototype, { + setup: function () { + this._backupStore = can.compute(); + return oldSetup.apply(this, arguments); + }, + backup: function () { + this._backupStore(this.attr()); + return this; + }, + isDirty: function (checkAssociations) { + return this._backupStore() && !can.Object.same(this.attr(), this._backupStore(), undefined, undefined, undefined, !!checkAssociations); + }, + restore: function (restoreAssociations) { + var props = restoreAssociations ? this._backupStore() : flatProps(this._backupStore(), this); + if (this.isDirty(restoreAssociations)) { + this.attr(props, true); + } + return this; + } + }); + return can.Map; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.define.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.define.js new file mode 100644 index 0000000000..d0e372891c --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.define.js @@ -0,0 +1,315 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#map/define/define*/ +define('can/map/define/define', [ + 'can/util/util', + 'can/observe/observe' +], function (can) { + var define = can.define = {}; + var getPropDefineBehavior = function (behavior, attr, define) { + var prop, defaultProp; + if (define) { + prop = define[attr]; + defaultProp = define['*']; + if (prop && prop[behavior] !== undefined) { + return prop[behavior]; + } else if (defaultProp && defaultProp[behavior] !== undefined) { + return defaultProp[behavior]; + } + } + }; + can.Map.helpers.define = function (Map) { + var definitions = Map.prototype.define; + Map.defaultGenerators = {}; + for (var prop in definitions) { + var type = definitions[prop].type; + if (typeof type === 'string') { + if (typeof define.types[type] === 'object') { + delete definitions[prop].type; + can.extend(definitions[prop], define.types[type]); + } + } + if ('value' in definitions[prop]) { + if (typeof definitions[prop].value === 'function') { + Map.defaultGenerators[prop] = definitions[prop].value; + } else { + Map.defaults[prop] = definitions[prop].value; + } + } + if (typeof definitions[prop].Value === 'function') { + (function (Constructor) { + Map.defaultGenerators[prop] = function () { + return new Constructor(); + }; + }(definitions[prop].Value)); + } + } + }; + var oldSetupDefaults = can.Map.prototype._setupDefaults; + can.Map.prototype._setupDefaults = function (obj) { + var defaults = oldSetupDefaults.call(this), propsCommittedToAttr = {}, Map = this.constructor, originalGet = this._get; + this._get = function (originalProp) { + prop = originalProp.indexOf('.') !== -1 ? originalProp.substr(0, originalProp.indexOf('.')) : prop; + if (prop in defaults && !(prop in propsCommittedToAttr)) { + this.attr(prop, defaults[prop]); + propsCommittedToAttr[prop] = true; + } + return originalGet.apply(this, arguments); + }; + for (var prop in Map.defaultGenerators) { + if (!obj || !(prop in obj)) { + defaults[prop] = Map.defaultGenerators[prop].call(this); + } + } + this._get = originalGet; + return defaults; + }; + var proto = can.Map.prototype, oldSet = proto.__set; + proto.__set = function (prop, value, current, success, error) { + var errorCallback = function (errors) { + var stub = error && error.call(self, errors); + if (stub !== false) { + can.trigger(self, 'error', [ + prop, + errors + ], true); + } + return false; + }, self = this, setter = getPropDefineBehavior('set', prop, this.define), getter = getPropDefineBehavior('get', prop, this.define); + if (setter) { + can.batch.start(); + var setterCalled = false, setValue = setter.call(this, value, function (value) { + if (getter) { + self[prop](value); + } else { + oldSet.call(self, prop, value, current, success, errorCallback); + } + setterCalled = true; + }, errorCallback, getter ? this[prop].computeInstance.lastSetValue.get() : current); + if (getter) { + if (setValue !== undefined && !setterCalled && setter.length >= 1) { + this[prop](setValue); + } + can.batch.stop(); + return; + } else if (setValue === undefined && !setterCalled && setter.length >= 1) { + can.batch.stop(); + return; + } else { + if (!setterCalled) { + oldSet.call(self, prop, setter.length === 0 && setValue === undefined ? value : setValue, current, success, errorCallback); + } + can.batch.stop(); + return this; + } + } else { + oldSet.call(self, prop, value, current, success, errorCallback); + } + return this; + }; + define.types = { + 'date': function (str) { + var type = typeof str; + if (type === 'string') { + str = Date.parse(str); + return isNaN(str) ? null : new Date(str); + } else if (type === 'number') { + return new Date(str); + } else { + return str; + } + }, + 'number': function (val) { + if (val == null) { + return val; + } + return +val; + }, + 'boolean': function (val) { + if (val === 'false' || val === '0' || !val) { + return false; + } + return true; + }, + 'htmlbool': function (val) { + return typeof val === 'string' || !!val; + }, + '*': function (val) { + return val; + }, + 'string': function (val) { + if (val == null) { + return val; + } + return '' + val; + }, + 'compute': { + set: function (newValue, setVal, setErr, oldValue) { + if (newValue.isComputed) { + return newValue; + } + if (oldValue && oldValue.isComputed) { + oldValue(newValue); + return oldValue; + } + return newValue; + }, + get: function (value) { + return value && value.isComputed ? value() : value; + } + } + }; + var oldType = proto.__type; + proto.__type = function (value, prop) { + var type = getPropDefineBehavior('type', prop, this.define), Type = getPropDefineBehavior('Type', prop, this.define), newValue = value; + if (typeof type === 'string') { + type = define.types[type]; + } + if (type || Type) { + if (type) { + newValue = type.call(this, newValue, prop); + } + if (Type && !(newValue instanceof Type)) { + newValue = new Type(newValue); + } + return newValue; + } else if (can.isPlainObject(newValue) && newValue.define) { + newValue = can.Map.extend(newValue); + newValue = new newValue(); + } + return oldType.call(this, newValue, prop); + }; + var oldRemove = proto._remove; + proto._remove = function (prop, current) { + var remove = getPropDefineBehavior('remove', prop, this.define), res; + if (remove) { + can.batch.start(); + res = remove.call(this, current); + if (res === false) { + can.batch.stop(); + return; + } else { + res = oldRemove.call(this, prop, current); + can.batch.stop(); + return res; + } + } + return oldRemove.call(this, prop, current); + }; + var oldSetupComputes = proto._setupComputes; + proto._setupComputes = function (defaultsValues) { + oldSetupComputes.apply(this, arguments); + for (var attr in this.define) { + var def = this.define[attr], get = def.get; + if (get) { + this[attr] = can.compute.async(defaultsValues[attr], get, this); + this._computedBindings[attr] = { count: 0 }; + } + } + }; + var oldSingleSerialize = can.Map.helpers._serialize; + can.Map.helpers._serialize = function (map, name, val) { + return serializeProp(map, name, val); + }; + var serializeProp = function (map, attr, val) { + var serializer = attr === '*' ? false : getPropDefineBehavior('serialize', attr, map.define); + if (serializer === undefined) { + return oldSingleSerialize.apply(this, arguments); + } else if (serializer !== false) { + return typeof serializer === 'function' ? serializer.call(map, val, attr) : oldSingleSerialize.apply(this, arguments); + } + }; + var oldSerialize = proto.serialize; + proto.serialize = function (property) { + var serialized = oldSerialize.apply(this, arguments); + if (property) { + return serialized; + } + var serializer, val; + for (var attr in this.define) { + if (!(attr in serialized)) { + serializer = this.define && this.define[attr] && this.define[attr].serialize; + if (serializer) { + val = serializeProp(this, attr, this.attr(attr)); + if (val !== undefined) { + serialized[attr] = val; + } + } + } + } + return serialized; + }; + return can.define; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.delegate.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.delegate.js new file mode 100644 index 0000000000..9e1a2369aa --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.delegate.js @@ -0,0 +1,199 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#map/delegate/delegate*/ +define('can/map/delegate/delegate', [ + 'can/util/util', + 'can/map/map' +], function (can) { + var delegateMatches = function (parts, props) { + var len = parts.length, i = 0, matchedProps = [], prop; + for (i; i < len; i++) { + prop = props[i]; + if (typeof prop !== 'string') { + return null; + } else if (parts[i] === '**') { + return props.join('.'); + } else if (parts[i] === '*') { + matchedProps.push(prop); + } else if (prop === parts[i]) { + matchedProps.push(prop); + } else { + return null; + } + } + return matchedProps.join('.'); + }, delegateHandler = function (event, prop, how, newVal, oldVal) { + var props = prop.split('.'), delegates = (this._observe_delegates || []).slice(0), delegate, attr, matchedAttr, hasMatch, valuesEqual; + event.attr = prop; + event.lastAttr = props[props.length - 1]; + for (var i = 0; delegate = delegates[i++];) { + if (event.batchNum && delegate.batchNum === event.batchNum || delegate.undelegated) { + continue; + } + hasMatch = undefined; + valuesEqual = true; + for (var a = 0; a < delegate.attrs.length; a++) { + attr = delegate.attrs[a]; + matchedAttr = delegateMatches(attr.parts, props); + if (matchedAttr) { + hasMatch = matchedAttr; + } + if (attr.value && valuesEqual) { + valuesEqual = attr.value === '' + this.attr(attr.attr); + } else if (valuesEqual && delegate.attrs.length > 1) { + valuesEqual = this.attr(attr.attr) !== undefined; + } + } + if (hasMatch && valuesEqual) { + var from = prop.replace(hasMatch + '.', ''); + if (event.batchNum) { + delegate.batchNum = event.batchNum; + } + if (delegate.event === 'change') { + prop = from; + event.curAttr = hasMatch; + delegate.callback.apply(this.attr(hasMatch), can.makeArray(arguments)); + } else if (delegate.event === how) { + delegate.callback.apply(this.attr(hasMatch), [ + event, + newVal, + oldVal, + from + ]); + } else if (delegate.event === 'set' && how === 'add') { + delegate.callback.apply(this.attr(hasMatch), [ + event, + newVal, + oldVal, + from + ]); + } + } + } + }; + can.extend(can.Map.prototype, { + delegate: function (selector, event, handler) { + selector = can.trim(selector); + var delegates = this._observe_delegates || (this._observe_delegates = []), attrs = [], selectorRegex = /([^\s=,]+)(?:=("[^",]*"|'[^',]*'|[^\s"',]*))?(,?)\s*/g, matches; + while ((matches = selectorRegex.exec(selector)) !== null) { + if (matches[2] && can.inArray(matches[2].substr(0, 1), [ + '"', + '\'' + ]) >= 0) { + matches[2] = matches[2].substr(1, -1); + } + attrs.push({ + attr: matches[1], + parts: matches[1].split('.'), + value: matches[2], + or: matches[3] === ',' + }); + } + delegates.push({ + selector: selector, + attrs: attrs, + callback: handler, + event: event + }); + if (delegates.length === 1) { + this.bind('change', delegateHandler); + } + return this; + }, + undelegate: function (selector, event, handler) { + selector = selector && can.trim(selector); + var i = 0, delegates = this._observe_delegates || [], delegateOb; + if (selector) { + while (i < delegates.length) { + delegateOb = delegates[i]; + if (delegateOb.callback === handler || !handler && delegateOb.selector === selector) { + delegateOb.undelegated = true; + delegates.splice(i, 1); + } else { + i++; + } + } + } else { + delegates = []; + } + if (!delegates.length) { + this.unbind('change', delegateHandler); + } + return this; + } + }); + can.Map.prototype.delegate.matches = delegateMatches; + return can.Map; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.lazy.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.lazy.js new file mode 100644 index 0000000000..d739d51a57 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.lazy.js @@ -0,0 +1,383 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#map/lazy/bubble*/ +define('can/map/lazy/bubble', [ + 'can/util/util', + 'can/map/bubble' +], function (can) { + var bubble = can.bubble; + return can.extend({}, bubble, { + childrenOf: function (parentMap, eventName) { + if (parentMap._nestedReference) { + parentMap._nestedReference.each(function (child, ref) { + if (child && child.bind) { + bubble.toParent(child, parentMap, ref(), eventName); + } + }); + } else { + bubble._each.apply(this, arguments); + } + } + }); +}); +/*can@2.2.6#map/lazy/nested_reference*/ +define('can/map/lazy/nested_reference', ['can/util/util'], function (can) { + var pathIterator = function (root, propPath, callback) { + var props = propPath.split('.'), cur = root, part; + while (part = props.shift()) { + cur = cur[part]; + if (callback) { + callback(cur, part); + } + } + return cur; + }; + var ArrIndex = function (array) { + this.array = array; + }; + ArrIndex.prototype.toString = function () { + return '' + can.inArray(this.item, this.array); + }; + var NestedReference = function (root) { + this.root = root; + this.references = []; + }; + NestedReference.ArrIndex = ArrIndex; + can.extend(NestedReference.prototype, { + make: function (propPath) { + var path = [], arrIndex; + if (can.isArray(this.root) || this.root instanceof can.LazyList) { + arrIndex = new ArrIndex(this.root); + } + pathIterator(this.root, propPath, function (item, prop) { + if (arrIndex) { + arrIndex.item = item; + path.push(arrIndex); + arrIndex = undefined; + } else { + path.push(prop); + if (can.isArray(item)) { + arrIndex = new ArrIndex(item); + } + } + }); + var pathFunc = function () { + return path.join('.'); + }; + this.references.push(pathFunc); + return pathFunc; + }, + removeChildren: function (path, callback) { + var i = 0; + while (i < this.references.length) { + var reference = this.references[i](); + if (reference.indexOf(path) === 0) { + callback(this.get(reference), reference); + this.references.splice(i, 1); + } else { + i++; + } + } + }, + get: function (path) { + return pathIterator(this.root, path); + }, + each: function (callback) { + var self = this; + can.each(this.references, function (ref) { + var path = ref(); + callback(self.get(path), ref, path); + }); + } + }); + can.NestedReference = NestedReference; +}); +/*can@2.2.6#map/lazy/lazy*/ +define('can/map/lazy/lazy', [ + 'can/util/util', + 'can/map/lazy/bubble', + 'can/map/map', + 'can/list/list', + 'can/map/lazy/nested_reference' +], function (can, bubble) { + can.LazyMap = can.Map.extend({ _bubble: bubble }, { + setup: function (obj) { + this.constructor.Map = this.constructor; + this.constructor.List = can.LazyList; + this._data = can.extend(can.extend(true, {}, this._setupDefaults() || {}), obj); + can.cid(this, '.lazyMap'); + this._init = 1; + this._computedBindings = {}; + this._setupComputes(); + var teardownMapping = obj && can.Map.helpers.addToMap(obj, this); + this._nestedReference = new can.NestedReference(this._data); + if (teardownMapping) { + teardownMapping(); + } + can.each(this._data, can.proxy(function (value, prop) { + this.___set(prop, value); + }, this)); + this.bind('change', can.proxy(this._changes, this)); + delete this._init; + }, + _addChild: function (path, newChild, setNewChild) { + var self = this; + this._nestedReference.removeChildren(path, function (oldChild, oldChildPath) { + bubble.remove(self, oldChild); + if (newChild) { + var newChildPath = oldChildPath.replace(path + '.', ''); + if (path === newChildPath) { + oldChild._nestedReference.each(function (obj, path) { + newChild._nestedReference.make(path()); + if (self._bindings) { + bubble.add(this, newChild, path()); + } + }); + } else { + var reference = newChild._nestedReference.make(newChildPath); + if (self._bindings) { + bubble.add(oldChild, newChild, reference()); + } + } + } + }); + if (setNewChild) { + setNewChild(); + } + if (newChild) { + var reference = this._nestedReference.make(path); + if (this._bindings) { + bubble.add(this, newChild, reference()); + } + } + return newChild; + }, + removeAttr: function (attr) { + var data = this._goto(attr); + if (data.parts.length) { + return data.value.removeAttr(data.parts.join('.')); + } else { + if (can.isArray(data.parent)) { + data.parent.splice(data.prop, 1); + this._triggerChange(attr, 'remove', undefined, [this.__type(data.value, data.prop)]); + } else { + if (data.parent[data.prop]) { + delete data.parent[data.prop]; + can.batch.trigger(this, data.path.length ? data.path.join('.') + '.__keys' : '__keys'); + this._triggerChange(attr, 'remove', undefined, this.__type(data.value, data.prop)); + } + } + this._nestedReference.removeChildren(); + return data.value; + } + }, + __type: function (value, prop) { + if (!(value instanceof can.LazyMap) && can.Map.helpers.canMakeObserve(value)) { + if (can.isArray(value)) { + var List = can.LazyList; + return new List(value); + } else { + var Map = this.constructor.Map || can.LazyMap; + return new Map(value); + } + } + return value; + }, + _goto: function (attr, keepKey) { + var parts = can.Map.helpers.attrParts(attr, keepKey).slice(0), prev, path = [], part; + var cur = this instanceof can.List ? this[parts.shift()] : this.__get(); + while (cur && !can.Map.helpers.isObservable(cur) && parts.length) { + if (part !== undefined) { + path.push(part); + } + prev = cur; + cur = cur[part = parts.shift()]; + } + return { + parts: parts, + prop: part, + value: cur, + parent: prev, + path: path + }; + }, + _get: function (attr) { + can.__observe(this, attr); + var data = this._goto(attr); + if (can.Map.helpers.isObservable(data.value)) { + if (data.parts.length) { + return data.value._get(data.parts); + } else { + return data.value; + } + } else if (data.value && can.Map.helpers.canMakeObserve(data.value)) { + var converted = this.__type(data.value, data.prop); + this._addChild(attr, converted, function () { + data.parent[data.prop] = converted; + }); + return converted; + } else if (data.value !== undefined) { + return data.value; + } else { + return this.__get(attr); + } + }, + _set: function (attr, value, keepKey) { + var data = this._goto(attr, keepKey); + if (can.Map.helpers.isObservable(data.value) && data.parts.length) { + return data.value._set(data.parts, value); + } else if (!data.parts.length) { + this.__set(attr, value, data.value, data); + } else { + throw 'can.LazyMap: object does not exist'; + } + }, + __set: function (prop, value, current, data, convert) { + convert = convert || true; + if (value !== current) { + var changeType = data.parent.hasOwnProperty(data.prop) ? 'set' : 'add'; + if (convert && can.Map.helpers.canMakeObserve(value)) { + value = this.__type(value, prop); + var self = this; + this._addChild(prop, value, function () { + self.___set(prop, value, data); + }); + } else { + this.___set(prop, value, data); + } + if (changeType === 'add') { + can.batch.trigger(this, data.path.length ? data.path.join('.') + '.__keys' : '__keys', undefined); + } + this._triggerChange(prop, changeType, value, current); + } + }, + ___set: function (prop, val, data) { + if (this[prop] && this[prop].isComputed && can.isFunction(this.constructor.prototype[prop])) { + this[prop](val); + } else if (data) { + data.parent[data.prop] = val; + } else { + this._data[prop] = val; + } + if (!can.isFunction(this.constructor.prototype[prop])) { + this[prop] = val; + } + }, + _attrs: function (props, remove) { + if (props === undefined) { + return can.Map.helpers.serialize(this, 'attr', {}); + } + props = can.extend({}, props); + var self = this, prop, data, newVal; + can.batch.start(); + this.each(function (curVal, prop) { + newVal = props[prop]; + data = self._goto(prop, true); + if (newVal === undefined) { + if (remove) { + self.removeAttr(prop); + } + return; + } else if (!can.Map.helpers.isObservable(curVal) && can.Map.helpers.canMakeObserve(curVal)) { + curVal = self.attr(prop); + } + if (self.__convert) { + newVal = self.__convert(prop, newVal); + } + if (newVal instanceof can.Map) { + self.__set(prop, newVal, curVal, data); + } else if (can.Map.helpers.isObservable(curVal) && can.Map.helpers.canMakeObserve(newVal) && curVal.attr) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + self.__set(prop, newVal, curVal, data); + } + delete props[prop]; + }); + for (prop in props) { + newVal = props[prop]; + this._set(prop, newVal, true); + } + can.batch.stop(); + return this; + } + }); + can.LazyList = can.List.extend({ Map: can.LazyMap }, { + setup: function () { + can.List.prototype.setup.apply(this, arguments); + this._nestedReference = new can.NestedReference(this); + } + }); + return can.LazyMap; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.list.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.list.js new file mode 100644 index 0000000000..4631208ace --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.list.js @@ -0,0 +1,143 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#map/list/list*/ +define('can/map/list/list', [ + 'can/util/util', + 'can/map/map', + 'can/list/list', + 'can/compute/compute' +], function (can) { + can.extend(can.List.prototype, { + filter: function (callback) { + var filtered = new this.constructor(); + var self = this; + var generator = function (element, index) { + var binder = function (ev, val) { + var index = filtered.indexOf(element); + if (!val && index !== -1) { + filtered.splice(index, 1); + } + if (val && index === -1) { + filtered.push(element); + } + }; + var compute = can.compute(function () { + return callback(element, self.indexOf(element), self); + }); + compute.bind('change', binder); + binder(null, compute()); + }; + this.bind('add', function (ev, data, index) { + can.each(data, function (element, i) { + generator(element, index + i); + }); + }); + this.bind('remove', function (ev, data, index) { + can.each(data, function (element, i) { + var index = filtered.indexOf(element); + if (index !== -1) { + filtered.splice(index, 1); + } + }); + }); + this.forEach(generator); + return filtered; + }, + map: function (callback) { + var mapped = new can.List(); + var self = this; + var generator = function (element, index) { + var compute = can.compute(function () { + return callback(element, index, self); + }); + compute.bind('change', function (ev, val) { + mapped.splice(index, 1, val); + }); + mapped.splice(index, 0, compute()); + }; + this.forEach(generator); + this.bind('add', function (ev, data, index) { + can.each(data, function (element, i) { + generator(element, index + i); + }); + }); + this.bind('remove', function (ev, data, index) { + mapped.splice(index, data.length); + }); + return mapped; + } + }); + return can.List; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.setter.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.setter.js new file mode 100644 index 0000000000..f8857bd8d5 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.setter.js @@ -0,0 +1,118 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#map/setter/setter*/ +define('can/map/setter/setter', [ + 'can/util/util', + 'can/map/map' +], function (can) { + can.classize = function (s, join) { + var parts = s.split(can.undHash), i = 0; + for (; i < parts.length; i++) { + parts[i] = can.capitalize(parts[i]); + } + return parts.join(join || ''); + }; + var classize = can.classize, proto = can.Map.prototype, old = proto.__set; + proto.__set = function (prop, value, current, success, error) { + var cap = classize(prop), setName = 'set' + cap, errorCallback = function (errors) { + var stub = error && error.call(self, errors); + if (stub !== false) { + can.trigger(self, 'error', [ + prop, + errors + ], true); + } + return false; + }, self = this; + if (this[setName]) { + can.batch.start(); + value = this[setName](value, function (value) { + old.call(self, prop, value, current, success, errorCallback); + }, errorCallback); + if (value === undefined) { + can.batch.stop(); + return; + } else { + old.call(self, prop, value, current, success, errorCallback); + can.batch.stop(); + return this; + } + } else { + old.call(self, prop, value, current, success, errorCallback); + } + return this; + }; + return can.Map; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.sort.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.sort.js new file mode 100644 index 0000000000..30386c2f96 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.sort.js @@ -0,0 +1,268 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#list/sort/sort*/ +define('can/list/sort/sort', [ + 'can/util/util', + 'can/list/list' +], function () { + var oldBubbleRule = can.List._bubbleRule; + can.List._bubbleRule = function (eventName, list) { + var oldBubble = oldBubbleRule.apply(this, arguments); + if (list.comparator && can.inArray('change', oldBubble) === -1) { + oldBubble.push('change'); + } + return oldBubble; + }; + var proto = can.List.prototype, _changes = proto._changes, setup = proto.setup, unbind = proto.unbind; + can.extend(proto, { + setup: function (instances, options) { + setup.apply(this, arguments); + this._comparatorBound = false; + this._init = 1; + this.bind('comparator', can.proxy(this._comparatorUpdated, this)); + delete this._init; + if (this.comparator) { + this.sort(); + } + }, + _comparatorUpdated: function (ev, newValue) { + if (newValue || newValue === 0) { + this.sort(); + if (this._bindings > 0 && !this._comparatorBound) { + this.bind('change', this._comparatorBound = function () { + }); + } + } else if (this._comparatorBound) { + unbind.call(this, 'change', this._comparatorBound); + this._comparatorBound = false; + } + }, + unbind: function (ev, handler) { + var res = unbind.apply(this, arguments); + if (this._comparatorBound && this._bindings === 1) { + unbind.call(this, 'change', this._comparatorBound); + this._comparatorBound = false; + } + return res; + }, + _comparator: function (a, b) { + var comparator = this.comparator; + if (comparator && typeof comparator === 'function') { + return comparator(a, b); + } + return a === b ? 0 : a < b ? -1 : 1; + }, + _changes: function (ev, attr, how, newVal, oldVal) { + if (this.comparator && /^\d+/.test(attr)) { + if (ev.batchNum && ev.batchNum !== this._lastBatchNum) { + this.sort(); + this._lastBatchNum = ev.batchNum; + return; + } + var currentIndex = +/^\d+/.exec(attr)[0], item = this[currentIndex]; + if (typeof item !== 'undefined') { + var newIndex = this._getInsertIndex(item, currentIndex); + if (newIndex !== currentIndex) { + this._swapItems(currentIndex, newIndex); + can.trigger(this, 'length', [this.length]); + } + } + } + _changes.apply(this, arguments); + }, + _getInsertIndex: function (item, currentIndex) { + var a = this._getComparatorValue(item), b, offset = 0; + for (var i = 0; i < this.length; i++) { + b = this._getComparatorValue(this[i]); + if (typeof currentIndex !== 'undefined' && i === currentIndex) { + offset = -1; + continue; + } + if (this._comparator(a, b) < 0) { + return i + offset; + } + } + return i + offset; + }, + _getComparatorValue: function (item, overwrittenComparator) { + var comparator = typeof overwrittenComparator === 'string' ? overwrittenComparator : this.comparator; + if (item && comparator && typeof comparator === 'string') { + item = typeof item[comparator] === 'function' ? item[comparator]() : item.attr(comparator); + } + return item; + }, + _getComparatorValues: function () { + var self = this; + var a = []; + this.each(function (item, index) { + a.push(self._getComparatorValue(item)); + }); + return a; + }, + sort: function (comparator, silent) { + var a, b, c, isSorted; + var comparatorFn = can.isFunction(comparator) ? comparator : this._comparator; + for (var i, iMin, j = 0, n = this.length; j < n - 1; j++) { + iMin = j; + isSorted = true; + c = undefined; + for (i = j + 1; i < n; i++) { + a = this._getComparatorValue(this.attr(i), comparator); + b = this._getComparatorValue(this.attr(iMin), comparator); + if (comparatorFn.call(this, a, b) < 0) { + isSorted = false; + iMin = i; + } + if (c && comparatorFn.call(this, a, c) < 0) { + isSorted = false; + } + c = a; + } + if (isSorted) { + break; + } + if (iMin !== j) { + this._swapItems(iMin, j, silent); + } + } + if (!silent) { + can.trigger(this, 'length', [this.length]); + } + return this; + }, + _swapItems: function (oldIndex, newIndex, silent) { + var temporaryItemReference = this[oldIndex]; + [].splice.call(this, oldIndex, 1); + [].splice.call(this, newIndex, 0, temporaryItemReference); + if (!silent) { + can.trigger(this, 'move', [ + temporaryItemReference, + newIndex, + oldIndex + ]); + } + } + }); + var getArgs = function (args) { + return args[0] && can.isArray(args[0]) ? args[0] : can.makeArray(args); + }; + can.each({ + push: 'length', + unshift: 0 + }, function (where, name) { + var proto = can.List.prototype, old = proto[name]; + proto[name] = function () { + if (this.comparator && arguments.length) { + var args = getArgs(arguments); + var i = args.length; + while (i--) { + var val = can.bubble.set(this, i, this.__type(args[i], i)); + var newIndex = this._getInsertIndex(val); + Array.prototype.splice.apply(this, [ + newIndex, + 0, + val + ]); + this._triggerChange('' + newIndex, 'add', [val], undefined); + } + can.batch.trigger(this, 'reset', [args]); + return this; + } else { + return old.apply(this, arguments); + } + }; + }); + (function () { + var proto = can.List.prototype; + var oldSplice = proto.splice; + proto.splice = function (index, howMany) { + var args = can.makeArray(arguments), newElements = [], i, len; + if (!this.comparator) { + return oldSplice.apply(this, args); + } + for (i = 2, len = args.length; i < len; i++) { + args[i] = this.__type(args[i], i); + newElements.push(args[i]); + } + oldSplice.call(this, index, howMany); + proto.push.apply(this, newElements); + }; + }()); + return can.Map; +}); +/*can@2.2.6#map/sort/sort*/ +define('can/map/sort/sort', ['can/list/sort/sort'], function (sortPlugin) { + return sortPlugin; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.validations.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.validations.js new file mode 100644 index 0000000000..0f6dcfb07b --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.map.validations.js @@ -0,0 +1,227 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#map/validations/validations*/ +define('can/map/validations/validations', [ + 'can/util/util', + 'can/map/map' +], function (can) { + var validate = function (attrNames, options, proc) { + if (!proc) { + proc = options; + options = {}; + } + options = options || {}; + attrNames = typeof attrNames === 'string' ? [attrNames] : can.makeArray(attrNames); + if (options.testIf && !options.testIf.call(this)) { + return; + } + var self = this; + can.each(attrNames, function (attrName) { + if (!self.validations[attrName]) { + self.validations[attrName] = []; + } + self.validations[attrName].push(function (newVal) { + var res = proc.call(this, newVal, attrName); + return res === undefined ? undefined : options.message || res; + }); + }); + }; + var old = can.Map.prototype.__set; + can.Map.prototype.__set = function (prop, value, current, success, error) { + var self = this, validations = self.constructor.validations, errorCallback = function (errors) { + var stub = error && error.call(self, errors); + if (stub !== false) { + can.trigger(self, 'error', [ + prop, + errors + ], true); + } + return false; + }; + old.call(self, prop, value, current, success, errorCallback); + if (validations && validations[prop]) { + var errors = self.errors(prop); + if (errors) { + errorCallback(errors); + } + } + return this; + }; + can.each([ + can.Map, + can.Model + ], function (clss) { + if (clss === undefined) { + return; + } + var oldSetup = clss.setup; + can.extend(clss, { + setup: function (superClass) { + oldSetup.apply(this, arguments); + if (!this.validations || superClass.validations === this.validations) { + this.validations = {}; + } + }, + validate: validate, + validationMessages: { + format: 'is invalid', + inclusion: 'is not a valid option (perhaps out of range)', + lengthShort: 'is too short', + lengthLong: 'is too long', + presence: 'can\'t be empty', + range: 'is out of range', + numericality: 'must be a number' + }, + validateFormatOf: function (attrNames, regexp, options) { + validate.call(this, attrNames, options, function (value) { + if (typeof value !== 'undefined' && value !== null && value !== '' && String(value).match(regexp) === null) { + return this.constructor.validationMessages.format; + } + }); + }, + validateInclusionOf: function (attrNames, inArray, options) { + validate.call(this, attrNames, options, function (value) { + if (typeof value === 'undefined') { + return; + } + for (var i = 0; i < inArray.length; i++) { + if (inArray[i] === value) { + return; + } + } + return this.constructor.validationMessages.inclusion; + }); + }, + validateLengthOf: function (attrNames, min, max, options) { + validate.call(this, attrNames, options, function (value) { + if ((typeof value === 'undefined' || value === null) && min > 0 || typeof value !== 'undefined' && value !== null && value.length < min) { + return this.constructor.validationMessages.lengthShort + ' (min=' + min + ')'; + } else if (typeof value !== 'undefined' && value !== null && value.length > max) { + return this.constructor.validationMessages.lengthLong + ' (max=' + max + ')'; + } + }); + }, + validatePresenceOf: function (attrNames, options) { + validate.call(this, attrNames, options, function (value) { + if (typeof value === 'undefined' || value === '' || value === null) { + return this.constructor.validationMessages.presence; + } + }); + }, + validateRangeOf: function (attrNames, low, hi, options) { + validate.call(this, attrNames, options, function (value) { + if ((typeof value === 'undefined' || value === null) && low > 0 || typeof value !== 'undefined' && value !== null && (value < low || value > hi)) { + return this.constructor.validationMessages.range + ' [' + low + ',' + hi + ']'; + } + }); + }, + validatesNumericalityOf: function (attrNames) { + validate.call(this, attrNames, function (value) { + var res = !isNaN(parseFloat(value)) && isFinite(value); + if (!res) { + return this.constructor.validationMessages.numericality; + } + }); + } + }); + }); + can.extend(can.Map.prototype, { + errors: function (attrs, newVal) { + if (attrs) { + attrs = can.isArray(attrs) ? attrs : [attrs]; + } + var errors = {}, self = this, addErrors = function (attr, funcs) { + can.each(funcs, function (func) { + var res = func.call(self, isTest ? self.__convert ? self.__convert(attr, newVal) : newVal : self.attr(attr)); + if (res) { + if (!errors[attr]) { + errors[attr] = []; + } + errors[attr].push(res); + } + }); + }, validations = this.constructor.validations || {}, isTest = attrs && attrs.length === 1 && arguments.length === 2; + can.each(attrs || validations, function (funcs, attr) { + if (typeof attr === 'number') { + attr = funcs; + funcs = validations[attr]; + } + addErrors(attr, funcs || []); + }); + return can.isEmptyObject(errors) ? null : isTest ? errors[attrs[0]] : errors; + } + }); + return can.Map; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.model.queue.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.model.queue.js new file mode 100644 index 0000000000..69d53c148e --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.model.queue.js @@ -0,0 +1,310 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#util/object/object*/ +define('can/util/object/object', ['can/util/util'], function (can) { + var isArray = can.isArray; + can.Object = {}; + var same = can.Object.same = function (a, b, compares, aParent, bParent, deep) { + var aType = typeof a, aArray = isArray(a), comparesType = typeof compares, compare; + if (comparesType === 'string' || compares === null) { + compares = compareMethods[compares]; + comparesType = 'function'; + } + if (comparesType === 'function') { + return compares(a, b, aParent, bParent); + } + compares = compares || {}; + if (a === null || b === null) { + return a === b; + } + if (a instanceof Date || b instanceof Date) { + return a === b; + } + if (deep === -1) { + return aType === 'object' || a === b; + } + if (aType !== typeof b || aArray !== isArray(b)) { + return false; + } + if (a === b) { + return true; + } + if (aArray) { + if (a.length !== b.length) { + return false; + } + for (var i = 0; i < a.length; i++) { + compare = compares[i] === undefined ? compares['*'] : compares[i]; + if (!same(a[i], b[i], a, b, compare)) { + return false; + } + } + return true; + } else if (aType === 'object' || aType === 'function') { + var bCopy = can.extend({}, b); + for (var prop in a) { + compare = compares[prop] === undefined ? compares['*'] : compares[prop]; + if (!same(a[prop], b[prop], compare, a, b, deep === false ? -1 : undefined)) { + return false; + } + delete bCopy[prop]; + } + for (prop in bCopy) { + if (compares[prop] === undefined || !same(undefined, b[prop], compares[prop], a, b, deep === false ? -1 : undefined)) { + return false; + } + } + return true; + } + return false; + }; + can.Object.subsets = function (checkSet, sets, compares) { + var len = sets.length, subsets = []; + for (var i = 0; i < len; i++) { + var set = sets[i]; + if (can.Object.subset(checkSet, set, compares)) { + subsets.push(set); + } + } + return subsets; + }; + can.Object.subset = function (subset, set, compares) { + compares = compares || {}; + for (var prop in set) { + if (!same(subset[prop], set[prop], compares[prop], subset, set)) { + return false; + } + } + return true; + }; + var compareMethods = { + 'null': function () { + return true; + }, + i: function (a, b) { + return ('' + a).toLowerCase() === ('' + b).toLowerCase(); + }, + eq: function (a, b) { + return a === b; + }, + similar: function (a, b) { + return a == b; + } + }; + compareMethods.eqeq = compareMethods.similar; + return can.Object; +}); +/*can@2.2.6#map/backup/backup*/ +define('can/map/backup/backup', [ + 'can/util/util', + 'can/compute/compute', + 'can/map/map', + 'can/util/object/object' +], function (can) { + var flatProps = function (a, cur) { + var obj = {}; + for (var prop in a) { + if (typeof a[prop] !== 'object' || a[prop] === null || a[prop] instanceof Date) { + obj[prop] = a[prop]; + } else { + obj[prop] = cur.attr(prop); + } + } + return obj; + }; + var oldSetup = can.Map.prototype.setup; + can.extend(can.Map.prototype, { + setup: function () { + this._backupStore = can.compute(); + return oldSetup.apply(this, arguments); + }, + backup: function () { + this._backupStore(this.attr()); + return this; + }, + isDirty: function (checkAssociations) { + return this._backupStore() && !can.Object.same(this.attr(), this._backupStore(), undefined, undefined, undefined, !!checkAssociations); + }, + restore: function (restoreAssociations) { + var props = restoreAssociations ? this._backupStore() : flatProps(this._backupStore(), this); + if (this.isDirty(restoreAssociations)) { + this.attr(props, true); + } + return this; + } + }); + return can.Map; +}); +/*can@2.2.6#model/queue/queue*/ +define('can/model/queue/queue', [ + 'can/util/util', + 'can/model/model', + 'can/map/backup/backup' +], function (can) { + var cleanAttrs = function (changedAttrs, attrs) { + var newAttrs = can.extend(true, {}, attrs), current, path; + if (changedAttrs) { + for (var i = 0; i < changedAttrs.length; i++) { + current = newAttrs; + path = changedAttrs[i].split('.'); + while (path.length > 1) { + current = current && current[path.shift()]; + } + if (current) { + delete current[path.shift()]; + } + } + } + return newAttrs; + }, queueRequests = function (success, error, method, callback) { + this._changedAttrs = this._changedAttrs || []; + var def = new can.Deferred(), self = this, attrs = this.serialize(), queue = this._requestQueue, changedAttrs = this._changedAttrs, reqFn, index; + reqFn = function (self, type, success, error) { + return function () { + return self.constructor._makeRequest([ + self, + attrs + ], type || (self.isNew() ? 'create' : 'update'), success, error, callback); + }; + }(this, method, function () { + def.resolveWith(self, arguments); + queue.splice(0, 1); + if (queue.length > 0) { + queue[0] = queue[0](); + } else { + changedAttrs.splice(0); + } + }, function () { + def.rejectWith(self, arguments); + queue.splice(0); + changedAttrs.splice(0); + }); + index = queue.push(reqFn) - 1; + if (queue.length === 1) { + queue[0] = queue[0](); + } + def.abort = function () { + var abort; + abort = queue[index].abort && queue[index].abort(); + queue.splice(index); + if (queue.length === 0) { + changedAttrs.splice(0); + } + return abort; + }; + def.then(success, error); + return def; + }, _triggerChange = can.Model.prototype._triggerChange, destroyFn = can.Model.prototype.destroy, setupFn = can.Model.prototype.setup; + can.each([ + 'created', + 'updated', + 'destroyed' + ], function (fn) { + var prototypeFn = can.Model.prototype[fn]; + can.Model.prototype[fn] = function (attrs) { + if (attrs && typeof attrs === 'object') { + attrs = attrs.attr ? attrs.attr() : attrs; + this._backupStore(attrs); + attrs = cleanAttrs(this._changedAttrs || [], attrs); + } + prototypeFn.call(this, attrs); + }; + }); + can.extend(can.Model.prototype, { + setup: function () { + setupFn.apply(this, arguments); + this._requestQueue = new can.List(); + }, + _triggerChange: function (attr, how, newVal, oldVal) { + if (this._changedAttrs) { + this._changedAttrs.push(attr); + } + _triggerChange.apply(this, arguments); + }, + hasQueuedRequests: function () { + return this._requestQueue.attr('length') > 1; + }, + save: function () { + return queueRequests.apply(this, arguments); + }, + destroy: function (success, error) { + if (this.isNew()) { + return destroyFn.call(this, success, error); + } + return queueRequests.call(this, success, error, 'destroy', 'destroyed'); + } + }); + return can; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.mootools.dev.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.mootools.dev.js new file mode 100644 index 0000000000..7d8ba5e523 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.mootools.dev.js @@ -0,0 +1,7261 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#util/can*/ +define('can/util/can', [], function () { + var glbl = typeof window !== 'undefined' ? window : global; + var can = {}; + if (typeof GLOBALCAN === 'undefined' || GLOBALCAN !== false) { + glbl.can = can; + } + can.global = glbl; + can.k = function () { + }; + can.isDeferred = can.isPromise = function (obj) { + return obj && typeof obj.then === 'function' && typeof obj.pipe === 'function'; + }; + can.isMapLike = function (obj) { + return can.Map && (obj instanceof can.Map || obj && obj.__get); + }; + var cid = 0; + can.cid = function (object, name) { + if (!object._cid) { + cid++; + object._cid = (name || '') + cid; + } + return object._cid; + }; + can.VERSION = '2.2.6'; + can.simpleExtend = function (d, s) { + for (var prop in s) { + d[prop] = s[prop]; + } + return d; + }; + can.last = function (arr) { + return arr && arr[arr.length - 1]; + }; + var protoBind = Function.prototype.bind; + if (protoBind) { + can.proxy = function (fn, context) { + return protoBind.call(fn, context); + }; + } else { + can.proxy = function (fn, context) { + return function () { + return fn.apply(context, arguments); + }; + }; + } + can.frag = function (item) { + var frag; + if (!item || typeof item === 'string') { + frag = can.buildFragment(item == null ? '' : '' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } else if (item.nodeType === 11) { + return item; + } else if (typeof item.nodeType === 'number') { + frag = document.createDocumentFragment(); + frag.appendChild(item); + return frag; + } else if (typeof item.length === 'number') { + frag = document.createDocumentFragment(); + can.each(item, function (item) { + frag.appendChild(can.frag(item)); + }); + return frag; + } else { + frag = can.buildFragment('' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } + }; + can.scope = can.viewModel = function (el, attr, val) { + el = can.$(el); + var scope = can.data(el, 'scope') || can.data(el, 'viewModel'); + if (!scope) { + scope = new can.Map(); + can.data(el, 'scope', scope); + can.data(el, 'viewModel', scope); + } + switch (arguments.length) { + case 0: + case 1: + return scope; + case 2: + return scope.attr(attr); + default: + scope.attr(attr, val); + return el; + } + }; + can['import'] = function (moduleName) { + var deferred = new can.Deferred(); + if (typeof window.System === 'object' && can.isFunction(window.System['import'])) { + window.System['import'](moduleName).then(can.proxy(deferred.resolve, deferred), can.proxy(deferred.reject, deferred)); + } else if (window.define && window.define.amd) { + window.require([moduleName], function (value) { + deferred.resolve(value); + }); + } else if (window.steal) { + steal.steal(moduleName, function (value) { + deferred.resolve(value); + }); + } else if (window.require) { + deferred.resolve(window.require(moduleName)); + } else { + deferred.resolve(); + } + return deferred.promise(); + }; + can.__observe = function () { + }; + can.dev = { + warnTimeout: 5000, + logLevel: 0, + warn: function (out) { + var ll = this.logLevel; + if (ll < 2) { + Array.prototype.unshift.call(arguments, 'WARN:'); + if (typeof window !== undefined && window.console && console.warn) { + this._logger('warn', Array.prototype.slice.call(arguments)); + } else if (window.console && console.log) { + this._logger('log', Array.prototype.slice.call(arguments)); + } else if (window.opera && window.opera.postError) { + window.opera.postError('steal.js WARNING: ' + out); + } + } + }, + log: function (out) { + var ll = this.logLevel; + if (ll < 1) { + if (window.console && console.log) { + Array.prototype.unshift.call(arguments, 'Info:'); + this._logger('log', Array.prototype.slice.call(arguments)); + } else if (window.opera && window.opera.postError) { + window.opera.postError('steal.js INFO: ' + out); + } + } + }, + _logger: function (type, arr) { + if (console.log.apply) { + console[type].apply(console, arr); + } else { + console[type](arr); + } + } + }; + return can; +}); +/*can@2.2.6#util/attr/attr*/ +define('can/util/attr/attr', ['can/util/can'], function (can) { + var setImmediate = can.global.setImmediate || function (cb) { + return setTimeout(cb, 0); + }, attr = { + MutationObserver: can.global.MutationObserver || can.global.WebKitMutationObserver || can.global.MozMutationObserver, + map: { + 'class': 'className', + 'value': 'value', + 'innertext': 'innerText', + 'textcontent': 'textContent', + 'checked': true, + 'disabled': true, + 'readonly': true, + 'required': true, + src: function (el, val) { + if (val == null || val === '') { + el.removeAttribute('src'); + return null; + } else { + el.setAttribute('src', val); + return val; + } + }, + style: function (el, val) { + return el.style.cssText = val || ''; + } + }, + defaultValue: [ + 'input', + 'textarea' + ], + set: function (el, attrName, val) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var tagName = el.nodeName.toString().toLowerCase(), prop = attr.map[attrName], newValue; + if (typeof prop === 'function') { + newValue = prop(el, val); + } else if (prop === true) { + newValue = el[attrName] = true; + if (attrName === 'checked' && el.type === 'radio') { + if (can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultChecked = true; + } + } + } else if (prop) { + newValue = val; + if (el[prop] !== val) { + el[prop] = val; + } + if (prop === 'value' && can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultValue = val; + } + } else { + el.setAttribute(attrName, val); + newValue = val; + } + if (!attr.MutationObserver && newValue !== oldValue) { + attr.trigger(el, attrName, oldValue); + } + }, + trigger: function (el, attrName, oldValue) { + if (can.data(can.$(el), 'canHasAttributesBindings')) { + attrName = attrName.toLowerCase(); + return setImmediate(function () { + can.trigger(el, { + type: 'attributes', + attributeName: attrName, + target: el, + oldValue: oldValue, + bubbles: false + }, []); + }); + } + }, + get: function (el, attrName) { + attrName = attrName.toLowerCase(); + var prop = attr.map[attrName]; + if (typeof prop === 'string' && el[prop]) { + return el[prop]; + } + return el.getAttribute(attrName); + }, + remove: function (el, attrName) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var setter = attr.map[attrName]; + if (typeof setter === 'function') { + setter(el, undefined); + } + if (setter === true) { + el[attrName] = false; + } else if (typeof setter === 'string') { + el[setter] = ''; + } else { + el.removeAttribute(attrName); + } + if (!attr.MutationObserver && oldValue != null) { + attr.trigger(el, attrName, oldValue); + } + }, + has: function () { + var el = can.global.document && document.createElement('div'); + if (el && el.hasAttribute) { + return function (el, name) { + return el.hasAttribute(name); + }; + } else { + return function (el, name) { + return el.getAttribute(name) !== null; + }; + } + }() + }; + return attr; +}); +/*can@2.2.6#event/event*/ +define('can/event/event', ['can/util/can'], function (can) { + can.addEvent = function (event, handler) { + var allEvents = this.__bindEvents || (this.__bindEvents = {}), eventList = allEvents[event] || (allEvents[event] = []); + eventList.push({ + handler: handler, + name: event + }); + return this; + }; + can.listenTo = function (other, event, handler) { + var idedEvents = this.__listenToEvents; + if (!idedEvents) { + idedEvents = this.__listenToEvents = {}; + } + var otherId = can.cid(other); + var othersEvents = idedEvents[otherId]; + if (!othersEvents) { + othersEvents = idedEvents[otherId] = { + obj: other, + events: {} + }; + } + var eventsEvents = othersEvents.events[event]; + if (!eventsEvents) { + eventsEvents = othersEvents.events[event] = []; + } + eventsEvents.push(handler); + can.bind.call(other, event, handler); + }; + can.stopListening = function (other, event, handler) { + var idedEvents = this.__listenToEvents, iterIdedEvents = idedEvents, i = 0; + if (!idedEvents) { + return this; + } + if (other) { + var othercid = can.cid(other); + (iterIdedEvents = {})[othercid] = idedEvents[othercid]; + if (!idedEvents[othercid]) { + return this; + } + } + for (var cid in iterIdedEvents) { + var othersEvents = iterIdedEvents[cid], eventsEvents; + other = idedEvents[cid].obj; + if (!event) { + eventsEvents = othersEvents.events; + } else { + (eventsEvents = {})[event] = othersEvents.events[event]; + } + for (var eventName in eventsEvents) { + var handlers = eventsEvents[eventName] || []; + i = 0; + while (i < handlers.length) { + if (handler && handler === handlers[i] || !handler) { + can.unbind.call(other, eventName, handlers[i]); + handlers.splice(i, 1); + } else { + i++; + } + } + if (!handlers.length) { + delete othersEvents.events[eventName]; + } + } + if (can.isEmptyObject(othersEvents.events)) { + delete idedEvents[cid]; + } + } + return this; + }; + can.removeEvent = function (event, fn, __validate) { + if (!this.__bindEvents) { + return this; + } + var events = this.__bindEvents[event] || [], i = 0, ev, isFunction = typeof fn === 'function'; + while (i < events.length) { + ev = events[i]; + if (__validate ? __validate(ev, event, fn) : isFunction && ev.handler === fn || !isFunction && (ev.cid === fn || !fn)) { + events.splice(i, 1); + } else { + i++; + } + } + return this; + }; + can.dispatch = function (event, args) { + var events = this.__bindEvents; + if (!events) { + return; + } + if (typeof event === 'string') { + event = { type: event }; + } + var eventName = event.type, handlers = (events[eventName] || []).slice(0), passed = [event]; + if (args) { + passed.push.apply(passed, args); + } + for (var i = 0, len = handlers.length; i < len; i++) { + handlers[i].handler.apply(this, passed); + } + return event; + }; + can.one = function (event, handler) { + var one = function () { + can.unbind.call(this, event, one); + return handler.apply(this, arguments); + }; + can.bind.call(this, event, one); + return this; + }; + can.event = { + on: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.on.call(this); + } else { + return can.addEvent.apply(this, arguments); + } + }, + off: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.off.call(this); + } else { + return can.removeEvent.apply(this, arguments); + } + }, + bind: can.addEvent, + unbind: can.removeEvent, + delegate: function (selector, event, handler) { + return can.addEvent.call(this, event, handler); + }, + undelegate: function (selector, event, handler) { + return can.removeEvent.call(this, event, handler); + }, + trigger: can.dispatch, + one: can.one, + addEvent: can.addEvent, + removeEvent: can.removeEvent, + listenTo: can.listenTo, + stopListening: can.stopListening, + dispatch: can.dispatch + }; + return can.event; +}); +/*can@2.2.6#util/fragment*/ +define('can/util/fragment', ['can/util/can'], function (can) { + var fragmentRE = /^\s*<(\w+)[^>]*>/, toString = {}.toString, fragment = function (html, name) { + if (name === undefined) { + name = fragmentRE.test(html) && RegExp.$1; + } + if (html && toString.call(html.replace) === '[object Function]') { + html = html.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, '<$1>'); + } + var container = document.createElement('div'), temp = document.createElement('div'); + if (name === 'tbody' || name === 'tfoot' || name === 'thead') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; + } else if (name === 'tr') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild; + } else if (name === 'td' || name === 'th') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild.firstChild; + } else if (name === 'option') { + temp.innerHTML = ''; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; + } else { + container.innerHTML = '' + html; + } + var tmp = {}, children = container.childNodes; + tmp.length = children.length; + for (var i = 0; i < children.length; i++) { + tmp[i] = children[i]; + } + return [].slice.call(tmp); + }; + can.buildFragment = function (html, nodes) { + if (html && html.nodeType === 11) { + return html; + } + var parts = fragment(html), frag = document.createDocumentFragment(); + for (var i = 0, length = parts.length; i < length; i++) { + frag.appendChild(parts[i]); + } + return frag; + }; + (function () { + var text = '<-\n>', frag = can.buildFragment(text, document); + if (text !== frag.childNodes[0].nodeValue) { + var oldBuildFragment = can.buildFragment; + can.buildFragment = function (html, nodes) { + var res = oldBuildFragment(html, nodes); + if (res.childNodes.length === 1 && res.childNodes[0].nodeType === 3) { + res.childNodes[0].nodeValue = html; + } + return res; + }; + } + }()); + return can; +}); +/*can@2.2.6#util/deferred*/ +define('can/util/deferred', ['can/util/can'], function (can) { + var extend = function (target, src) { + for (var key in src) { + if (src.hasOwnProperty(key)) { + target[key] = src[key]; + } + } + }, Deferred = function (func) { + if (!(this instanceof Deferred)) { + return new Deferred(); + } + this._doneFuncs = []; + this._failFuncs = []; + this._resultArgs = null; + this._status = ''; + if (func) { + func.call(this, this); + } + }; + can.Deferred = Deferred; + can.when = Deferred.when = function () { + var args = can.makeArray(arguments); + if (args.length < 2) { + var obj = args[0]; + if (obj && (can.isFunction(obj.isResolved) && can.isFunction(obj.isRejected))) { + return obj; + } else { + return Deferred().resolve(obj); + } + } else { + var df = Deferred(), done = 0, rp = []; + can.each(args, function (arg, j) { + arg.done(function () { + rp[j] = arguments.length < 2 ? arguments[0] : arguments; + if (++done === args.length) { + df.resolve.apply(df, rp); + } + }).fail(function () { + df.reject(arguments.length === 1 ? arguments[0] : arguments); + }); + }); + return df; + } + }; + var resolveFunc = function (type, _status) { + return function (context) { + var args = this._resultArgs = arguments.length > 1 ? arguments[1] : []; + return this.exec(context, this[type], args, _status); + }; + }, doneFunc = function doneFunc(type, _status) { + return function () { + var self = this; + can.each(Array.prototype.slice.call(arguments), function (v, i, args) { + if (!v) { + return; + } + if (v.constructor === Array) { + doneFunc.apply(self, v); + } else { + if (self._status === _status) { + v.apply(self, self._resultArgs || []); + } + self[type].push(v); + } + }); + return this; + }; + }; + var isDeferred = function (obj) { + return obj && obj.then && obj.fail && obj.done; + }; + var wire = function (parentDeferred, result, setter, value) { + if (isDeferred(result)) { + result.done(can.proxy(parentDeferred.resolve, parentDeferred)).fail(can.proxy(parentDeferred.reject, parentDeferred)); + } else { + setter.call(parentDeferred, result !== undefined ? result : value); + } + }; + extend(Deferred.prototype, { + then: function (done, fail) { + var d = can.Deferred(), resolve = d.resolve, reject = d.reject; + this.done(function (value) { + if (typeof done === 'function') { + wire(d, done.apply(this, arguments), resolve, value); + } else { + resolve.apply(d, arguments); + } + }); + this.fail(function (value) { + if (typeof fail === 'function') { + wire(d, fail.apply(this, arguments), reject, value); + } else { + reject.apply(d, arguments); + } + }); + return d; + }, + resolveWith: resolveFunc('_doneFuncs', 'rs'), + rejectWith: resolveFunc('_failFuncs', 'rj'), + done: doneFunc('_doneFuncs', 'rs'), + fail: doneFunc('_failFuncs', 'rj'), + always: function () { + var args = can.makeArray(arguments); + if (args.length && args[0]) { + this.done(args[0]).fail(args[0]); + } + return this; + }, + state: function () { + switch (this._status) { + case 'rs': + return 'resolved'; + case 'rj': + return 'rejected'; + default: + return 'pending'; + } + }, + isResolved: function () { + return this._status === 'rs'; + }, + isRejected: function () { + return this._status === 'rj'; + }, + reject: function () { + return this.rejectWith(this, arguments); + }, + resolve: function () { + return this.resolveWith(this, arguments); + }, + exec: function (context, dst, args, st) { + if (this._status !== '') { + return this; + } + this._status = st; + can.each(dst, function (d) { + if (typeof d.apply === 'function') { + d.apply(context, args); + } + }); + return this; + }, + promise: function () { + var promise = this.then(); + promise.reject = promise.resolve = undefined; + return promise; + } + }); + Deferred.prototype.pipe = Deferred.prototype.then; + return can; +}); +/*can@2.2.6#util/array/each*/ +define('can/util/array/each', ['can/util/can'], function (can) { + var isArrayLike = function (obj) { + var length = 'length' in obj && obj.length; + return typeof arr !== 'function' && (length === 0 || typeof length === 'number' && length > 0 && length - 1 in obj); + }; + can.each = function (elements, callback, context) { + var i = 0, key, len, item; + if (elements) { + if (isArrayLike(elements)) { + if (can.List && elements instanceof can.List) { + for (len = elements.attr('length'); i < len; i++) { + item = elements.attr(i); + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } else { + for (len = elements.length; i < len; i++) { + item = elements[i]; + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } + } else if (typeof elements === 'object') { + if (can.Map && elements instanceof can.Map || elements === can.route) { + var keys = can.Map.keys(elements); + for (i = 0, len = keys.length; i < len; i++) { + key = keys[i]; + item = elements.attr(key); + if (callback.call(context || item, item, key, elements) === false) { + break; + } + } + } else { + for (key in elements) { + if (elements.hasOwnProperty(key) && callback.call(context || elements[key], elements[key], key, elements) === false) { + break; + } + } + } + } + } + return elements; + }; + return can; +}); +/*can@2.2.6#util/object/isplain/isplain*/ +define('can/util/object/isplain/isplain', ['can/util/can'], function () { + var core_hasOwn = Object.prototype.hasOwnProperty, isWindow = function (obj) { + return obj !== null && obj == obj.window; + }, isPlainObject = function (obj) { + if (!obj || typeof obj !== 'object' || obj.nodeType || isWindow(obj)) { + return false; + } + try { + if (obj.constructor && !core_hasOwn.call(obj, 'constructor') && !core_hasOwn.call(obj.constructor.prototype, 'isPrototypeOf')) { + return false; + } + } catch (e) { + return false; + } + var key; + for (key in obj) { + } + return key === undefined || core_hasOwn.call(obj, key); + }; + can.isPlainObject = isPlainObject; + return can; +}); +/*can@2.2.6#util/inserted/inserted*/ +define('can/util/inserted/inserted', ['can/util/can'], function (can) { + can.inserted = function (elems) { + elems = can.makeArray(elems); + var inDocument = false, doc = can.$(document.contains ? document : document.body), children; + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + if (!inDocument) { + if (elem.getElementsByTagName) { + if (can.has(doc, elem).length) { + inDocument = true; + } else { + return; + } + } else { + continue; + } + } + if (inDocument && elem.getElementsByTagName) { + children = can.makeArray(elem.getElementsByTagName('*')); + can.trigger(elem, 'inserted', [], false); + for (var j = 0, child; (child = children[j]) !== undefined; j++) { + can.trigger(child, 'inserted', [], false); + } + } + } + }; + can.appendChild = function (el, child) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.appendChild(child); + can.inserted(children); + }; + can.insertBefore = function (el, child, ref) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.insertBefore(child, ref); + can.inserted(children); + }; +}); +/*can@2.2.6#util/util*/ +define('can/util/util', [ + 'can/util/can', + 'can/util/attr/attr', + 'can/mootools/mootools', + 'can/event/event', + 'can/util/fragment', + 'can/util/deferred', + 'can/util/array/each', + 'can/util/object/isplain/isplain', + 'can/util/inserted/inserted' +], function (can, attr) { + can.trim = function (s) { + return s ? s.trim() : s; + }; + var extend = function () { + var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, length = arguments.length, deep = false; + if (typeof target === 'boolean') { + deep = target; + target = arguments[1] || {}; + i = 2; + } + if (typeof target !== 'object' && !can.isFunction(target)) { + target = {}; + } + if (length === i) { + target = this; + --i; + } + for (; i < length; i++) { + if ((options = arguments[i]) !== null) { + for (name in options) { + src = target[name]; + copy = options[name]; + if (target === copy) { + continue; + } + if (deep && copy && (can.isPlainObject(copy) || (copyIsArray = can.isArray(copy)))) { + if (copyIsArray) { + copyIsArray = false; + clone = src && can.isArray(src) ? src : []; + } else { + clone = src && can.isPlainObject(src) ? src : {}; + } + target[name] = can.extend(deep, clone, copy); + } else if (copy !== undefined) { + target[name] = copy; + } + } + } + } + return target; + }; + can.extend = extend; + can.makeArray = function (item) { + if (item === null) { + return []; + } + try { + return Type.isEnumerable(item) && typeof item !== 'string' ? Array.prototype.slice.call(item) : [item]; + } catch (ex) { + var arr = [], i; + for (i = 0; i < item.length; ++i) { + arr.push(item[i]); + } + return arr; + } + }; + can.isArray = function (arr) { + return typeOf(arr) === 'array'; + }; + can.inArray = function (item, arr, fromIndex) { + if (!arr) { + return -1; + } + return Array.prototype.indexOf.call(arr, item, fromIndex); + }; + can.map = function (arr, fn) { + return Array.from(arr || []).map(fn); + }; + can.param = function (object) { + return Object.toQueryString(object); + }; + can.isEmptyObject = function (object) { + return Object.keys(object).length === 0; + }; + can.isFunction = function (f) { + return typeOf(f) === 'function'; + }; + can.bind = function (ev, cb) { + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (this.nodeName && (this.nodeType && this.nodeType !== 11)) { + can.$(this).addEvent(ev, cb); + } else if (this.addEvent) { + this.addEvent(ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + return this; + }; + can.unbind = function (ev, cb) { + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (this.nodeName && (this.nodeType && this.nodeType !== 11)) { + can.$(this).removeEvent(ev, cb); + } else if (this.removeEvent) { + this.removeEvent(ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + return this; + }; + can.on = can.bind; + can.off = can.unbind; + can.trigger = function (item, event, args, bubble) { + bubble = bubble === undefined ? true : bubble; + args = args || []; + var propagating = true; + if (item.fireEvent) { + item = item[0] || item; + while (item && propagating) { + if (!event.type) { + event = { + type: event, + target: item, + stopPropagation: function () { + propagating = false; + } + }; + } + var events = item !== window ? can.$(item).retrieve('events')[0] : item.retrieve('events'); + if (events && events[event.type]) { + events[event.type].keys.each(function (fn) { + fn.apply(item, [event].concat(args)); + }, this); + } + if (bubble && item.parentNode && item.parentNode.nodeType !== 11) { + item = item.parentNode; + } else { + item = null; + } + } + } else { + if (typeof event === 'string') { + event = { type: event }; + } + event.target = event.target || item; + can.dispatch.call(item, event, can.makeArray(args)); + } + }; + can.delegate = function (selector, ev, cb) { + if (this.delegate) { + this.delegate(selector, ev, cb); + } else if (this.addEvent) { + this.addEvent(ev + ':relay(' + selector + ')', cb); + } else { + can.bind.call(this, ev, cb); + } + return this; + }; + can.undelegate = function (selector, ev, cb) { + if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else if (this.removeEvent) { + this.removeEvent(ev + ':relay(' + selector + ')', cb); + } else { + can.unbind.call(this, ev, cb); + } + return this; + }; + var optionsMap = { + type: 'method', + success: undefined, + error: undefined + }; + var updateDeferred = function (xhr, d) { + for (var prop in xhr) { + if (typeof d[prop] === 'function') { + d[prop] = function () { + xhr[prop].apply(xhr, arguments); + }; + } else { + d[prop] = prop[xhr]; + } + } + }; + can.ajax = function (options) { + var d = can.Deferred(), requestOptions = can.extend({}, options), request; + for (var option in optionsMap) { + if (requestOptions[option] !== undefined) { + requestOptions[optionsMap[option]] = requestOptions[option]; + delete requestOptions[option]; + } + } + requestOptions.method = requestOptions.method || 'get'; + requestOptions.url = requestOptions.url.toString(); + var success = options.onSuccess || options.success, error = options.onFailure || options.error; + requestOptions.onSuccess = function (response, xml) { + var data = response; + updateDeferred(request.xhr, d); + d.resolve(data, 'success', request.xhr); + if (success) { + success(data, 'success', request.xhr); + } + }; + requestOptions.onFailure = function () { + updateDeferred(request.xhr, d); + d.reject(request.xhr, 'error'); + if (error) { + error(request.xhr, 'error'); + } + }; + if (options.dataType === 'json') { + request = new Request.JSON(requestOptions); + } else { + request = new Request(requestOptions); + } + request.send(); + updateDeferred(request.xhr, d); + return d; + }; + can.$ = function (selector) { + if (selector === window) { + return window; + } + return $$(selector && selector.nodeName ? [selector] : selector); + }; + var old = document.id; + document.id = function (el) { + if (el && el.nodeType === 11) { + return el; + } else { + return old.apply(document, arguments); + } + }; + can.append = function (wrapped, html) { + if (typeof html === 'string') { + html = can.buildFragment(html); + } + return wrapped.grab(html); + }; + can.filter = function (wrapped, filter) { + return wrapped.filter(filter); + }; + can.data = function (wrapped, key, value) { + if (value === undefined) { + return wrapped[0].retrieve(key); + } else { + return wrapped.store(key, value); + } + }; + can.addClass = function (wrapped, className) { + return wrapped.addClass(className); + }; + can.remove = function (wrapped) { + var filtered = wrapped.filter(function (node) { + if (node.nodeType !== 1) { + node.parentNode.removeChild(node); + } else { + return true; + } + }); + filtered.destroy(); + return filtered; + }; + can.has = function (wrapped, element) { + if (Slick.contains(wrapped[0], element)) { + return wrapped; + } else { + return []; + } + }; + var destroy = Element.prototype.destroy, grab = Element.prototype.grab, oldSet = Element.prototype.set; + Element.implement({ + destroy: function () { + can.trigger(this, 'removed', [], false); + var elems = this.getElementsByTagName('*'); + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + can.trigger(elem, 'removed', [], false); + } + destroy.apply(this, arguments); + }, + grab: function (el) { + var elems; + if (el && el.nodeType === 11) { + elems = can.makeArray(el.childNodes); + } else { + elems = [el]; + } + var ret = grab.apply(this, arguments); + can.inserted(elems); + return ret; + }, + set: function (attrName, value) { + var isAttributeOrProp = can.inArray(attrName, [ + 'events', + 'html', + 'load', + 'morph', + 'send', + 'tag', + 'tween' + ]) === -1, newValue, oldValue; + if (isAttributeOrProp) { + oldValue = this.get(attrName); + } + var res = oldSet.apply(this, arguments); + if (isAttributeOrProp) { + newValue = this.get(attrName); + } + if (newValue !== oldValue) { + can.attr.trigger(this, attrName, oldValue); + } + return res; + }.overloadSetter() + }); + can.get = function (wrapped, index) { + return wrapped[index]; + }; + var idOf = Slick.uidOf; + Slick.uidOf = function (node) { + if (node.nodeType === 1 || node === window || node.document === document) { + return idOf(node); + } else { + return Math.random(); + } + }; + Element.NativeEvents.hashchange = 2; + can.attr = attr; + delete attr.MutationObserver; + Element.Events.attributes = { + onAdd: function () { + var el = can.$(this); + can.data(el, 'canHasAttributesBindings', (can.data(el, 'canHasAttributesBindings') || 0) + 1); + }, + onRemove: function () { + var el = can.$(this), cur = can.data(el, 'canHasAttributesBindings') || 0; + if (cur <= 0) { + can.cleanData(el, 'canHasAttributesBindings'); + } else { + can.data(el, 'canHasAttributesBindings', cur - 1); + } + } + }; + return can; +}); +/*can@2.2.6#view/view*/ +define('can/view/view', ['can/util/util'], function (can) { + var isFunction = can.isFunction, makeArray = can.makeArray, hookupId = 1; + var makeRenderer = function (textRenderer) { + var renderer = function () { + return $view.frag(textRenderer.apply(this, arguments)); + }; + renderer.render = function () { + return textRenderer.apply(textRenderer, arguments); + }; + return renderer; + }; + var checkText = function (text, url) { + if (!text.length) { + can.dev.log('can/view/view.js: There is no template or an empty template at ' + url); + throw 'can.view: No template or empty template:' + url; + } + }; + var getRenderer = function (obj, async) { + if (isFunction(obj)) { + var def = can.Deferred(); + return def.resolve(obj); + } + var url = typeof obj === 'string' ? obj : obj.url, suffix = obj.engine && '.' + obj.engine || url.match(/\.[\w\d]+$/), type, el, id; + if (url.match(/^#/)) { + url = url.substr(1); + } + if (el = document.getElementById(url)) { + suffix = '.' + el.type.match(/\/(x\-)?(.+)/)[2]; + } + if (!suffix && !$view.cached[url]) { + url += suffix = $view.ext; + } + if (can.isArray(suffix)) { + suffix = suffix[0]; + } + id = $view.toId(url); + if (url.match(/^\/\//)) { + url = url.substr(2); + url = !window.steal ? url : steal.config().root.mapJoin('' + steal.id(url)); + } + if (window.require) { + if (require.toUrl) { + url = require.toUrl(url); + } + } + type = $view.types[suffix]; + if ($view.cached[id]) { + return $view.cached[id]; + } else if (el) { + return $view.registerView(id, el.innerHTML, type); + } else { + var d = new can.Deferred(); + can.ajax({ + async: async, + url: url, + dataType: 'text', + error: function (jqXHR) { + checkText('', url); + d.reject(jqXHR); + }, + success: function (text) { + checkText(text, url); + $view.registerView(id, text, type, d); + } + }); + return d; + } + }; + var getDeferreds = function (data) { + var deferreds = []; + if (can.isDeferred(data)) { + return [data]; + } else { + for (var prop in data) { + if (can.isDeferred(data[prop])) { + deferreds.push(data[prop]); + } + } + } + return deferreds; + }; + var usefulPart = function (resolved) { + return can.isArray(resolved) && resolved[1] === 'success' ? resolved[0] : resolved; + }; + var $view = can.view = can.template = function (view, data, helpers, callback) { + if (isFunction(helpers)) { + callback = helpers; + helpers = undefined; + } + return $view.renderAs('fragment', view, data, helpers, callback); + }; + can.extend($view, { + frag: function (result, parentNode) { + return $view.hookup($view.fragment(result), parentNode); + }, + fragment: function (result) { + if (typeof result !== 'string' && result.nodeType === 11) { + return result; + } + var frag = can.buildFragment(result, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + }, + toId: function (src) { + return can.map(src.toString().split(/\/|\./g), function (part) { + if (part) { + return part; + } + }).join('_'); + }, + toStr: function (txt) { + return txt == null ? '' : '' + txt; + }, + hookup: function (fragment, parentNode) { + var hookupEls = [], id, func; + can.each(fragment.childNodes ? can.makeArray(fragment.childNodes) : fragment, function (node) { + if (node.nodeType === 1) { + hookupEls.push(node); + hookupEls.push.apply(hookupEls, can.makeArray(node.getElementsByTagName('*'))); + } + }); + can.each(hookupEls, function (el) { + if (el.getAttribute && (id = el.getAttribute('data-view-id')) && (func = $view.hookups[id])) { + func(el, parentNode, id); + delete $view.hookups[id]; + el.removeAttribute('data-view-id'); + } + }); + return fragment; + }, + hookups: {}, + hook: function (cb) { + $view.hookups[++hookupId] = cb; + return ' data-view-id=\'' + hookupId + '\''; + }, + cached: {}, + cachedRenderers: {}, + cache: true, + register: function (info) { + this.types['.' + info.suffix] = info; + if (typeof window !== 'undefined' && window.steal && steal.type) { + steal.type(info.suffix + ' view js', function (options, success, error) { + var type = $view.types['.' + options.type], id = $view.toId(options.id + ''); + options.text = type.script(id, options.text); + success(); + }); + } + can[info.suffix] = $view[info.suffix] = function (id, text) { + var renderer, renderFunc; + if (!text) { + renderFunc = function () { + if (!renderer) { + if (info.fragRenderer) { + renderer = info.fragRenderer(null, id); + } else { + renderer = makeRenderer(info.renderer(null, id)); + } + } + return renderer.apply(this, arguments); + }; + renderFunc.render = function () { + var textRenderer = info.renderer(null, id); + return textRenderer.apply(textRenderer, arguments); + }; + return renderFunc; + } + var registeredRenderer = function () { + if (!renderer) { + if (info.fragRenderer) { + renderer = info.fragRenderer(id, text); + } else { + renderer = info.renderer(id, text); + } + } + return renderer.apply(this, arguments); + }; + if (info.fragRenderer) { + return $view.preload(id, registeredRenderer); + } else { + return $view.preloadStringRenderer(id, registeredRenderer); + } + }; + }, + types: {}, + ext: '.ejs', + registerScript: function (type, id, src) { + return 'can.view.preloadStringRenderer(\'' + id + '\',' + $view.types['.' + type].script(id, src) + ');'; + }, + preload: function (id, renderer) { + var def = $view.cached[id] = new can.Deferred().resolve(function (data, helpers) { + return renderer.call(data, data, helpers); + }); + def.__view_id = id; + $view.cachedRenderers[id] = renderer; + return renderer; + }, + preloadStringRenderer: function (id, stringRenderer) { + return this.preload(id, makeRenderer(stringRenderer)); + }, + render: function (view, data, helpers, callback) { + return can.view.renderAs('string', view, data, helpers, callback); + }, + renderTo: function (format, renderer, data, helpers) { + return (format === 'string' && renderer.render ? renderer.render : renderer)(data, helpers); + }, + renderAs: function (format, view, data, helpers, callback) { + if (isFunction(helpers)) { + callback = helpers; + helpers = undefined; + } + var deferreds = getDeferreds(data); + var reading, deferred, dataCopy, async, response; + if (deferreds.length) { + deferred = new can.Deferred(); + dataCopy = can.extend({}, data); + deferreds.push(getRenderer(view, true)); + can.when.apply(can, deferreds).then(function (resolved) { + var objs = makeArray(arguments), renderer = objs.pop(), result; + if (can.isDeferred(data)) { + dataCopy = usefulPart(resolved); + } else { + for (var prop in data) { + if (can.isDeferred(data[prop])) { + dataCopy[prop] = usefulPart(objs.shift()); + } + } + } + result = can.view.renderTo(format, renderer, dataCopy, helpers); + deferred.resolve(result, dataCopy); + if (callback) { + callback(result, dataCopy); + } + }, function () { + deferred.reject.apply(deferred, arguments); + }); + return deferred; + } else { + reading = can.__clearReading(); + async = isFunction(callback); + deferred = getRenderer(view, async); + if (reading) { + can.__setReading(reading); + } + if (async) { + response = deferred; + deferred.then(function (renderer) { + callback(data ? can.view.renderTo(format, renderer, data, helpers) : renderer); + }); + } else { + if (deferred.state() === 'resolved' && deferred.__view_id) { + var currentRenderer = $view.cachedRenderers[deferred.__view_id]; + return data ? can.view.renderTo(format, currentRenderer, data, helpers) : currentRenderer; + } else { + deferred.then(function (renderer) { + response = data ? can.view.renderTo(format, renderer, data, helpers) : renderer; + }); + } + } + return response; + } + }, + registerView: function (id, text, type, def) { + var info = typeof type === 'object' ? type : $view.types[type || $view.ext], renderer; + if (info.fragRenderer) { + renderer = info.fragRenderer(id, text); + } else { + renderer = makeRenderer(info.renderer(id, text)); + } + def = def || new can.Deferred(); + if ($view.cache) { + $view.cached[id] = def; + def.__view_id = id; + $view.cachedRenderers[id] = renderer; + } + return def.resolve(renderer); + } + }); + if (typeof window !== 'undefined' && window.steal && steal.type) { + steal.type('view js', function (options, success, error) { + var type = $view.types['.' + options.type], id = $view.toId(options.id); + var dependency = type.plugin || 'can/view/' + options.type, preload = type.fragRenderer ? 'preload' : 'preloadStringRenderer'; + options.text = 'steal(\'can/view\',\'' + dependency + '\',function(can){return ' + 'can.view.' + preload + '(\'' + id + '\',' + options.text + ');\n})'; + success(); + }); + } + return can; +}); +/*can@2.2.6#view/callbacks/callbacks*/ +define('can/view/callbacks/callbacks', [ + 'can/util/util', + 'can/view/view' +], function (can) { + var attr = can.view.attr = function (attributeName, attrHandler) { + if (attrHandler) { + if (typeof attributeName === 'string') { + attributes[attributeName] = attrHandler; + } else { + regExpAttributes.push({ + match: attributeName, + handler: attrHandler + }); + } + } else { + var cb = attributes[attributeName]; + if (!cb) { + for (var i = 0, len = regExpAttributes.length; i < len; i++) { + var attrMatcher = regExpAttributes[i]; + if (attrMatcher.match.test(attributeName)) { + cb = attrMatcher.handler; + break; + } + } + } + return cb; + } + }; + var attributes = {}, regExpAttributes = [], automaticCustomElementCharacters = /[-\:]/; + var tag = can.view.tag = function (tagName, tagHandler) { + if (tagHandler) { + if (typeof tags[tagName.toLowerCase()] !== 'undefined') { + can.dev.warn('Custom tag: ' + tagName.toLowerCase() + ' is already defined'); + } + if (can.global.html5) { + can.global.html5.elements += ' ' + tagName; + can.global.html5.shivDocument(); + } + tags[tagName.toLowerCase()] = tagHandler; + } else { + var cb = tags[tagName.toLowerCase()]; + if (!cb && automaticCustomElementCharacters.test(tagName)) { + cb = function () { + }; + } + return cb; + } + }; + var tags = {}; + can.view.callbacks = { + _tags: tags, + _attributes: attributes, + _regExpAttributes: regExpAttributes, + tag: tag, + attr: attr, + tagHandler: function (el, tagName, tagData) { + var helperTagCallback = tagData.options.attr('tags.' + tagName), tagCallback = helperTagCallback || tags[tagName]; + var scope = tagData.scope, res; + if (tagCallback) { + var reads = can.__clearReading(); + res = tagCallback(el, tagData); + can.__setReading(reads); + } else { + res = scope; + } + if (!tagCallback) { + can.dev.warn('can/view/scanner.js: No custom element found for ' + tagName); + } + if (res && tagData.subtemplate) { + if (scope !== res) { + scope = scope.add(res); + } + var result = tagData.subtemplate(scope, tagData.options); + var frag = typeof result === 'string' ? can.view.frag(result) : result; + can.appendChild(el, frag); + } + } + }; + return can.view.callbacks; +}); +/*can@2.2.6#view/elements*/ +define('can/view/elements', [ + 'can/util/util', + 'can/view/view' +], function (can) { + var doc = typeof document !== 'undefined' ? document : null; + var selectsCommentNodes = doc && function () { + return can.$(document.createComment('~')).length === 1; + }(); + var elements = { + tagToContentPropMap: { + option: doc && 'textContent' in document.createElement('option') ? 'textContent' : 'innerText', + textarea: 'value' + }, + attrMap: can.attr.map, + attrReg: /([^\s=]+)[\s]*=[\s]*/, + defaultValue: can.attr.defaultValue, + tagMap: { + '': 'span', + colgroup: 'col', + table: 'tbody', + tr: 'td', + ol: 'li', + ul: 'li', + tbody: 'tr', + thead: 'tr', + tfoot: 'tr', + select: 'option', + optgroup: 'option' + }, + reverseTagMap: { + col: 'colgroup', + tr: 'tbody', + option: 'select', + td: 'tr', + th: 'tr', + li: 'ul' + }, + getParentNode: function (el, defaultParentNode) { + return defaultParentNode && el.parentNode.nodeType === 11 ? defaultParentNode : el.parentNode; + }, + setAttr: can.attr.set, + getAttr: can.attr.get, + removeAttr: can.attr.remove, + contentText: function (text) { + if (typeof text === 'string') { + return text; + } + if (!text && text !== 0) { + return ''; + } + return '' + text; + }, + after: function (oldElements, newFrag) { + var last = oldElements[oldElements.length - 1]; + if (last.nextSibling) { + can.insertBefore(last.parentNode, newFrag, last.nextSibling); + } else { + can.appendChild(last.parentNode, newFrag); + } + }, + replace: function (oldElements, newFrag) { + elements.after(oldElements, newFrag); + if (can.remove(can.$(oldElements)).length < oldElements.length && !selectsCommentNodes) { + can.each(oldElements, function (el) { + if (el.nodeType === 8) { + el.parentNode.removeChild(el); + } + }); + } + } + }; + can.view.elements = elements; + return elements; +}); +/*can@2.2.6#util/string/string*/ +define('can/util/string/string', ['can/util/util'], function (can) { + var strUndHash = /_|-/, strColons = /\=\=/, strWords = /([A-Z]+)([A-Z][a-z])/g, strLowUp = /([a-z\d])([A-Z])/g, strDash = /([a-z\d])([A-Z])/g, strReplacer = /\{([^\}]+)\}/g, strQuote = /"/g, strSingleQuote = /'/g, strHyphenMatch = /-+(.)?/g, strCamelMatch = /[a-z][A-Z]/g, getNext = function (obj, prop, add) { + var result = obj[prop]; + if (result === undefined && add === true) { + result = obj[prop] = {}; + } + return result; + }, isContainer = function (current) { + return /^f|^o/.test(typeof current); + }, convertBadValues = function (content) { + var isInvalid = content === null || content === undefined || isNaN(content) && '' + content === 'NaN'; + return '' + (isInvalid ? '' : content); + }; + can.extend(can, { + esc: function (content) { + return convertBadValues(content).replace(/&/g, '&').replace(//g, '>').replace(strQuote, '"').replace(strSingleQuote, '''); + }, + getObject: function (name, roots, add) { + var parts = name ? name.split('.') : [], length = parts.length, current, r = 0, i, container, rootsLength; + roots = can.isArray(roots) ? roots : [roots || window]; + rootsLength = roots.length; + if (!length) { + return roots[0]; + } + for (r; r < rootsLength; r++) { + current = roots[r]; + container = undefined; + for (i = 0; i < length && isContainer(current); i++) { + container = current; + current = getNext(container, parts[i]); + } + if (container !== undefined && current !== undefined) { + break; + } + } + if (add === false && current !== undefined) { + delete container[parts[i - 1]]; + } + if (add === true && current === undefined) { + current = roots[0]; + for (i = 0; i < length && isContainer(current); i++) { + current = getNext(current, parts[i], true); + } + } + return current; + }, + capitalize: function (s, cache) { + return s.charAt(0).toUpperCase() + s.slice(1); + }, + camelize: function (str) { + return convertBadValues(str).replace(strHyphenMatch, function (match, chr) { + return chr ? chr.toUpperCase() : ''; + }); + }, + hyphenate: function (str) { + return convertBadValues(str).replace(strCamelMatch, function (str, offset) { + return str.charAt(0) + '-' + str.charAt(1).toLowerCase(); + }); + }, + underscore: function (s) { + return s.replace(strColons, '/').replace(strWords, '$1_$2').replace(strLowUp, '$1_$2').replace(strDash, '_').toLowerCase(); + }, + sub: function (str, data, remove) { + var obs = []; + str = str || ''; + obs.push(str.replace(strReplacer, function (whole, inside) { + var ob = can.getObject(inside, data, remove === true ? false : undefined); + if (ob === undefined || ob === null) { + obs = null; + return ''; + } + if (isContainer(ob) && obs) { + obs.push(ob); + return ''; + } + return '' + ob; + })); + return obs === null ? obs : obs.length <= 1 ? obs[0] : obs; + }, + replacer: strReplacer, + undHash: strUndHash + }); + return can; +}); +/*can@2.2.6#construct/construct*/ +define('can/construct/construct', ['can/util/string/string'], function (can) { + var initializing = 0; + var canGetDescriptor; + try { + Object.getOwnPropertyDescriptor({}); + canGetDescriptor = true; + } catch (e) { + canGetDescriptor = false; + } + var getDescriptor = function (newProps, name) { + var descriptor = Object.getOwnPropertyDescriptor(newProps, name); + if (descriptor && (descriptor.get || descriptor.set)) { + return descriptor; + } + return null; + }, inheritGetterSetter = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + var descriptor; + for (var name in newProps) { + if (descriptor = getDescriptor(newProps, name)) { + this._defineProperty(addTo, oldProps, name, descriptor); + } else { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + } + }, simpleInherit = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + for (var name in newProps) { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + }; + can.Construct = function () { + if (arguments.length) { + return can.Construct.extend.apply(can.Construct, arguments); + } + }; + can.extend(can.Construct, { + constructorExtends: true, + newInstance: function () { + var inst = this.instance(), args; + if (inst.setup) { + args = inst.setup.apply(inst, arguments); + } + if (inst.init) { + inst.init.apply(inst, args || arguments); + } + return inst; + }, + _inherit: canGetDescriptor ? inheritGetterSetter : simpleInherit, + _defineProperty: function (what, oldProps, propName, descriptor) { + Object.defineProperty(what, propName, descriptor); + }, + _overwrite: function (what, oldProps, propName, val) { + what[propName] = val; + }, + setup: function (base, fullName) { + this.defaults = can.extend(true, {}, base.defaults, this.defaults); + }, + instance: function () { + initializing = 1; + var inst = new this(); + initializing = 0; + return inst; + }, + extend: function (name, staticProperties, instanceProperties) { + var fullName = name, klass = staticProperties, proto = instanceProperties; + if (typeof fullName !== 'string') { + proto = klass; + klass = fullName; + fullName = null; + } + if (!proto) { + proto = klass; + klass = null; + } + proto = proto || {}; + var _super_class = this, _super = this.prototype, Constructor, parts, current, _fullName, _shortName, propName, shortName, namespace, prototype; + prototype = this.instance(); + can.Construct._inherit(proto, _super, prototype); + if (fullName) { + parts = fullName.split('.'); + shortName = parts.pop(); + } + var constructorName = shortName ? shortName.replace(/;/g, '') : 'Constructor'; + eval('Constructor = function ' + constructorName + '() { return init.apply(this, arguments); }'); + if (typeof constructorName === 'undefined') { + Constructor = function () { + return init.apply(this, arguments); + }; + } + function init() { + if (!initializing) { + if (this.constructor !== Constructor && arguments.length && Constructor.constructorExtends) { + can.dev.warn('can/construct/construct.js: extending a can.Construct without calling extend'); + } + return this.constructor !== Constructor && arguments.length && Constructor.constructorExtends ? Constructor.extend.apply(Constructor, arguments) : Constructor.newInstance.apply(Constructor, arguments); + } + } + for (propName in _super_class) { + if (_super_class.hasOwnProperty(propName)) { + Constructor[propName] = _super_class[propName]; + } + } + can.Construct._inherit(klass, _super_class, Constructor); + if (fullName) { + current = can.getObject(parts.join('.'), window, true); + namespace = current; + _fullName = can.underscore(fullName.replace(/\./g, '_')); + _shortName = can.underscore(shortName); + if (current[shortName]) { + can.dev.warn('can/construct/construct.js: There\'s already something called ' + fullName); + } + current[shortName] = Constructor; + } + can.extend(Constructor, { + constructor: Constructor, + prototype: prototype, + namespace: namespace, + _shortName: _shortName, + fullName: fullName, + _fullName: _fullName + }); + if (shortName !== undefined) { + Constructor.shortName = shortName; + } + Constructor.prototype.constructor = Constructor; + var t = [_super_class].concat(can.makeArray(arguments)), args = Constructor.setup.apply(Constructor, t); + if (Constructor.init) { + Constructor.init.apply(Constructor, args || t); + } + return Constructor; + } + }); + can.Construct.prototype.setup = function () { + }; + can.Construct.prototype.init = function () { + }; + return can.Construct; +}); +/*can@2.2.6#control/control*/ +define('can/control/control', [ + 'can/util/util', + 'can/construct/construct' +], function (can) { + var bind = function (el, ev, callback) { + can.bind.call(el, ev, callback); + return function () { + can.unbind.call(el, ev, callback); + }; + }, isFunction = can.isFunction, extend = can.extend, each = can.each, slice = [].slice, paramReplacer = /\{([^\}]+)\}/g, special = can.getObject('$.event.special', [can]) || {}, delegate = function (el, selector, ev, callback) { + can.delegate.call(el, selector, ev, callback); + return function () { + can.undelegate.call(el, selector, ev, callback); + }; + }, binder = function (el, ev, callback, selector) { + return selector ? delegate(el, can.trim(selector), ev, callback) : bind(el, ev, callback); + }, basicProcessor; + var Control = can.Control = can.Construct({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Control) { + var control = this, funcName; + control.actions = {}; + for (funcName in control.prototype) { + if (control._isAction(funcName)) { + control.actions[funcName] = control._action(funcName); + } + } + } + }, + _shifter: function (context, name) { + var method = typeof name === 'string' ? context[name] : name; + if (!isFunction(method)) { + method = context[method]; + } + return function () { + context.called = name; + return method.apply(context, [this.nodeName ? can.$(this) : this].concat(slice.call(arguments, 0))); + }; + }, + _isAction: function (methodName) { + var val = this.prototype[methodName], type = typeof val; + return methodName !== 'constructor' && (type === 'function' || type === 'string' && isFunction(this.prototype[val])) && !!(special[methodName] || processors[methodName] || /[^\w]/.test(methodName)); + }, + _action: function (methodName, options) { + paramReplacer.lastIndex = 0; + if (options || !paramReplacer.test(methodName)) { + var convertedName = options ? can.sub(methodName, this._lookup(options)) : methodName; + if (!convertedName) { + can.dev.log('can/control/control.js: No property found for handling ' + methodName); + return null; + } + var arr = can.isArray(convertedName), name = arr ? convertedName[1] : convertedName, parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: processors[event] || basicProcessor, + parts: [ + name, + parts.join(' '), + event + ], + delegate: arr ? convertedName[0] : undefined + }; + } + }, + _lookup: function (options) { + return [ + options, + window + ]; + }, + processors: {}, + defaults: {} + }, { + setup: function (element, options) { + var cls = this.constructor, pluginname = cls.pluginName || cls._fullName, arr; + this.element = can.$(element); + if (pluginname && pluginname !== 'can_control') { + this.element.addClass(pluginname); + } + arr = can.data(this.element, 'controls'); + if (!arr) { + arr = []; + can.data(this.element, 'controls', arr); + } + arr.push(this); + this.options = extend({}, cls.defaults, options); + this.on(); + return [ + this.element, + this.options + ]; + }, + on: function (el, selector, eventName, func) { + if (!el) { + this.off(); + var cls = this.constructor, bindings = this._bindings, actions = cls.actions, element = this.element, destroyCB = can.Control._shifter(this, 'destroy'), funcName, ready; + for (funcName in actions) { + if (actions.hasOwnProperty(funcName)) { + ready = actions[funcName] || cls._action(funcName, this.options, this); + if (ready) { + bindings.control[funcName] = ready.processor(ready.delegate || element, ready.parts[2], ready.parts[1], funcName, this); + } + } + } + can.bind.call(element, 'removed', destroyCB); + bindings.user.push(function (el) { + can.unbind.call(el, 'removed', destroyCB); + }); + return bindings.user.length; + } + if (typeof el === 'string') { + func = eventName; + eventName = selector; + selector = el; + el = this.element; + } + if (func === undefined) { + func = eventName; + eventName = selector; + selector = null; + } + if (typeof func === 'string') { + func = can.Control._shifter(this, func); + } + this._bindings.user.push(binder(el, eventName, func, selector)); + return this._bindings.user.length; + }, + off: function () { + var el = this.element[0], bindings = this._bindings; + if (bindings) { + each(bindings.user || [], function (value) { + value(el); + }); + each(bindings.control || {}, function (value) { + value(el); + }); + } + this._bindings = { + user: [], + control: {} + }; + }, + destroy: function () { + if (this.element === null) { + can.dev.warn('can/control/control.js: Control already destroyed'); + return; + } + var Class = this.constructor, pluginName = Class.pluginName || Class._fullName, controls; + this.off(); + if (pluginName && pluginName !== 'can_control') { + this.element.removeClass(pluginName); + } + controls = can.data(this.element, 'controls'); + controls.splice(can.inArray(this, controls), 1); + can.trigger(this, 'destroyed'); + this.element = null; + } + }); + var processors = can.Control.processors; + basicProcessor = function (el, event, selector, methodName, control) { + return binder(el, event, can.Control._shifter(control, methodName), selector); + }; + each([ + 'change', + 'click', + 'contextmenu', + 'dblclick', + 'keydown', + 'keyup', + 'keypress', + 'mousedown', + 'mousemove', + 'mouseout', + 'mouseover', + 'mouseup', + 'reset', + 'resize', + 'scroll', + 'select', + 'submit', + 'focusin', + 'focusout', + 'mouseenter', + 'mouseleave', + 'touchstart', + 'touchmove', + 'touchcancel', + 'touchend', + 'touchleave', + 'inserted', + 'removed' + ], function (v) { + processors[v] = basicProcessor; + }); + return Control; +}); +/*can@2.2.6#util/bind/bind*/ +define('can/util/bind/bind', ['can/util/util'], function (can) { + can.bindAndSetup = function () { + can.addEvent.apply(this, arguments); + if (!this._init) { + if (!this._bindings) { + this._bindings = 1; + if (this._bindsetup) { + this._bindsetup(); + } + } else { + this._bindings++; + } + } + return this; + }; + can.unbindAndTeardown = function (event, handler) { + var handlers = this.__bindEvents[event] || []; + var handlerCount = handlers.length; + can.removeEvent.apply(this, arguments); + if (this._bindings === null) { + this._bindings = 0; + } else { + this._bindings = this._bindings - (handlerCount - handlers.length); + } + if (!this._bindings && this._bindteardown) { + this._bindteardown(); + } + return this; + }; + return can; +}); +/*can@2.2.6#map/bubble*/ +define('can/map/bubble', ['can/util/util'], function (can) { + var bubble = can.bubble = { + event: function (map, boundEventName) { + return map.constructor._bubbleRule(boundEventName, map); + }, + childrenOf: function (parentMap, eventName) { + parentMap._each(function (child, prop) { + if (child && child.bind) { + bubble.toParent(child, parentMap, prop, eventName); + } + }); + }, + teardownChildrenFrom: function (parentMap, eventName) { + parentMap._each(function (child) { + bubble.teardownFromParent(parentMap, child, eventName); + }); + }, + toParent: function (child, parent, prop, eventName) { + can.listenTo.call(parent, child, eventName, function () { + var args = can.makeArray(arguments), ev = args.shift(); + args[0] = (can.List && parent instanceof can.List ? parent.indexOf(child) : prop) + (args[0] ? '.' + args[0] : ''); + ev.triggeredNS = ev.triggeredNS || {}; + if (ev.triggeredNS[parent._cid]) { + return; + } + ev.triggeredNS[parent._cid] = true; + can.trigger(parent, ev, args); + }); + }, + teardownFromParent: function (parent, child, eventName) { + if (child && child.unbind) { + can.stopListening.call(parent, child, eventName); + } + }, + isBubbling: function (parent, eventName) { + return parent._bubbleBindings && parent._bubbleBindings[eventName]; + }, + bind: function (parent, eventName) { + if (!parent._init) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + if (!parent._bubbleBindings) { + parent._bubbleBindings = {}; + } + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (!parent._bubbleBindings[bubbleEvent]) { + parent._bubbleBindings[bubbleEvent] = 1; + bubble.childrenOf(parent, bubbleEvent); + } else { + parent._bubbleBindings[bubbleEvent]++; + } + } + } + }, + unbind: function (parent, eventName) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (parent._bubbleBindings) { + parent._bubbleBindings[bubbleEvent]--; + } + if (parent._bubbleBindings && !parent._bubbleBindings[bubbleEvent]) { + delete parent._bubbleBindings[bubbleEvent]; + bubble.teardownChildrenFrom(parent, bubbleEvent); + if (can.isEmptyObject(parent._bubbleBindings)) { + delete parent._bubbleBindings; + } + } + } + }, + add: function (parent, child, prop) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + bubble.toParent(child, parent, prop, eventName); + } + } + } + }, + removeMany: function (parent, children) { + for (var i = 0, len = children.length; i < len; i++) { + bubble.remove(parent, children[i]); + } + }, + remove: function (parent, child) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + } + } + } + }, + set: function (parent, prop, value, current) { + if (can.Map.helpers.isObservable(value)) { + bubble.add(parent, value, prop); + } + if (can.Map.helpers.isObservable(current)) { + bubble.remove(parent, current); + } + return value; + } + }; + return bubble; +}); +/*can@2.2.6#util/batch/batch*/ +define('can/util/batch/batch', ['can/util/can'], function (can) { + var batchNum = 1, transactions = 0, batchEvents = [], stopCallbacks = [], currentBatchEvents = null; + can.batch = { + start: function (batchStopHandler) { + transactions++; + if (batchStopHandler) { + stopCallbacks.push(batchStopHandler); + } + }, + stop: function (force, callStart) { + if (force) { + transactions = 0; + } else { + transactions--; + } + if (transactions === 0) { + if (currentBatchEvents !== null) { + return; + } + currentBatchEvents = batchEvents.slice(0); + var callbacks = stopCallbacks.slice(0), i, len; + batchEvents = []; + stopCallbacks = []; + can.batch.batchNum = batchNum; + batchNum++; + if (callStart) { + can.batch.start(); + } + for (i = 0; i < currentBatchEvents.length; i++) { + can.dispatch.apply(currentBatchEvents[i][0], currentBatchEvents[i][1]); + } + currentBatchEvents = null; + for (i = 0, len = callbacks.length; i < callbacks.length; i++) { + callbacks[i](); + } + can.batch.batchNum = undefined; + } + }, + trigger: function (item, event, args) { + if (!item._init) { + event = typeof event === 'string' ? { type: event } : event; + if (currentBatchEvents) { + currentBatchEvents.push([ + item, + [ + event, + args + ] + ]); + } else if (transactions === 0) { + return can.dispatch.call(item, event, args); + } else { + event.batchNum = batchNum; + batchEvents.push([ + item, + [ + event, + args + ] + ]); + } + } + }, + afterPreviousEvents: function (handler) { + if (currentBatchEvents) { + var obj = {}; + can.bind.call(obj, 'ready', handler); + currentBatchEvents.push([ + obj, + [ + { type: 'ready' }, + [] + ] + ]); + } else { + handler(); + } + } + }; +}); +/*can@2.2.6#map/map*/ +define('can/map/map', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/map/bubble', + 'can/construct/construct', + 'can/util/batch/batch' +], function (can, bind, bubble) { + var madeMap = null; + var teardownMap = function () { + for (var cid in madeMap) { + if (madeMap[cid].added) { + delete madeMap[cid].obj._cid; + } + } + madeMap = null; + }; + var getMapFromObject = function (obj) { + return madeMap && madeMap[obj._cid] && madeMap[obj._cid].instance; + }; + var serializeMap = null; + var Map = can.Map = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Map) { + if (!this.defaults) { + this.defaults = {}; + } + this._computes = []; + if (this.prototype.define && !this.helpers.define) { + can.dev.warn('can/map/define is not included, yet there is a define property ' + 'used. You may want to add this plugin.'); + } + if (this.define && !this.helpers.define) { + can.dev.warn('The define property should be on the map\'s prototype properties, ' + 'not the static properies. Also, can/map/define is not included.'); + } + for (var prop in this.prototype) { + if (prop !== 'define' && prop !== 'constructor' && (typeof this.prototype[prop] !== 'function' || this.prototype[prop].prototype instanceof can.Construct)) { + this.defaults[prop] = this.prototype[prop]; + } else if (this.prototype[prop].isComputed) { + this._computes.push(prop); + } + } + if (this.helpers.define) { + this.helpers.define(this); + } + } + if (can.List && !(this.prototype instanceof can.List)) { + this.List = Map.List.extend({ Map: this }, {}); + } + }, + _bubble: bubble, + _bubbleRule: function (eventName) { + return eventName === 'change' || eventName.indexOf('.') >= 0 ? ['change'] : []; + }, + _computes: [], + bind: can.bindAndSetup, + on: can.bindAndSetup, + unbind: can.unbindAndTeardown, + off: can.unbindAndTeardown, + id: 'id', + helpers: { + define: null, + attrParts: function (attr, keepKey) { + if (keepKey) { + return [attr]; + } + return typeof attr === 'object' ? attr : ('' + attr).split('.'); + }, + addToMap: function (obj, instance) { + var teardown; + if (!madeMap) { + teardown = teardownMap; + madeMap = {}; + } + var hasCid = obj._cid; + var cid = can.cid(obj); + if (!madeMap[cid]) { + madeMap[cid] = { + obj: obj, + instance: instance, + added: !hasCid + }; + } + return teardown; + }, + isObservable: function (obj) { + return obj instanceof can.Map || obj && obj === can.route; + }, + canMakeObserve: function (obj) { + return obj && !can.isDeferred(obj) && (can.isArray(obj) || can.isPlainObject(obj)); + }, + serialize: function (map, how, where) { + var cid = can.cid(map), firstSerialize = false; + if (!serializeMap) { + firstSerialize = true; + serializeMap = { + attr: {}, + serialize: {} + }; + } + serializeMap[how][cid] = where; + map.each(function (val, name) { + var result, isObservable = Map.helpers.isObservable(val), serialized = isObservable && serializeMap[how][can.cid(val)]; + if (serialized) { + result = serialized; + } else { + if (how === 'serialize') { + result = Map.helpers._serialize(map, name, val); + } else { + result = Map.helpers._getValue(map, name, val, how); + } + } + if (result !== undefined) { + where[name] = result; + } + }); + can.__observe(map, '__keys'); + if (firstSerialize) { + serializeMap = null; + } + return where; + }, + _serialize: function (map, name, val) { + return Map.helpers._getValue(map, name, val, 'serialize'); + }, + _getValue: function (map, name, val, how) { + if (Map.helpers.isObservable(val)) { + return val[how](); + } else { + return val; + } + } + }, + keys: function (map) { + var keys = []; + can.__observe(map, '__keys'); + for (var keyName in map._data) { + keys.push(keyName); + } + return keys; + } + }, { + setup: function (obj) { + if (obj instanceof can.Map) { + obj = obj.serialize(); + } + this._data = {}; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + var defaultValues = this._setupDefaults(obj); + this._setupComputes(defaultValues); + var teardownMapping = obj && can.Map.helpers.addToMap(obj, this); + var data = can.extend(can.extend(true, {}, defaultValues), obj); + this.attr(data); + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + delete this._init; + }, + _setupComputes: function () { + var computes = this.constructor._computes; + for (var i = 0, len = computes.length, prop; i < len; i++) { + prop = computes[i]; + this[prop] = this[prop].clone(this); + this._computedBindings[prop] = { count: 0 }; + } + }, + _setupDefaults: function () { + return this.constructor.defaults || {}; + }, + _bindsetup: function () { + }, + _bindteardown: function () { + }, + _changes: function (ev, attr, how, newVal, oldVal) { + can.batch.trigger(this, { + type: attr, + batchNum: ev.batchNum, + target: ev.target + }, [ + newVal, + oldVal + ]); + }, + _triggerChange: function (attr, how, newVal, oldVal) { + if (bubble.isBubbling(this, 'change')) { + can.batch.trigger(this, { + type: 'change', + target: this + }, [ + attr, + how, + newVal, + oldVal + ]); + } else { + can.batch.trigger(this, attr, [ + newVal, + oldVal + ]); + } + if (how === 'remove' || how === 'add') { + can.batch.trigger(this, { + type: '__keys', + target: this + }); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var prop in data) { + if (data.hasOwnProperty(prop)) { + callback(data[prop], prop); + } + } + }, + attr: function (attr, val) { + var type = typeof attr; + if (type !== 'string' && type !== 'number') { + return this._attrs(attr, val); + } else if (arguments.length === 1) { + return this._get(attr); + } else { + this._set(attr, val); + return this; + } + }, + each: function () { + return can.each.apply(undefined, [this].concat(can.makeArray(arguments))); + }, + removeAttr: function (attr) { + var isList = can.List && this instanceof can.List, parts = can.Map.helpers.attrParts(attr), prop = parts.shift(), current = isList ? this[prop] : this._data[prop]; + if (parts.length && current) { + return current.removeAttr(parts); + } else { + if (typeof attr === 'string' && !!~attr.indexOf('.')) { + prop = attr; + } + this._remove(prop, current); + return current; + } + }, + _remove: function (prop, current) { + if (prop in this._data) { + delete this._data[prop]; + if (!(prop in this.constructor.prototype)) { + delete this[prop]; + } + this._triggerChange(prop, 'remove', undefined, current); + } + }, + _get: function (attr) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'); + if (dotIndex >= 0) { + var value = this.__get(attr); + if (value !== undefined) { + return value; + } + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + can.__observe(this, first); + var current = this.__get(first); + return current && current._get ? current._get(second) : undefined; + } else { + can.__observe(this, attr); + return this.__get(attr); + } + }, + __get: function (attr) { + if (attr) { + if (this._computedBindings[attr]) { + return this[attr](); + } else { + return this._data[attr]; + } + } else { + return this._data; + } + }, + __type: function (value, prop) { + if (!(value instanceof can.Map) && can.Map.helpers.canMakeObserve(value)) { + var cached = getMapFromObject(value); + if (cached) { + return cached; + } + if (can.isArray(value)) { + var List = can.List; + return new List(value); + } else { + var Map = this.constructor.Map || can.Map; + return new Map(value); + } + } + return value; + }, + _set: function (attr, value, keepKey) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'), current; + if (!keepKey && dotIndex >= 0) { + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + current = this._init ? undefined : this.__get(first); + if (Map.helpers.isObservable(current)) { + current._set(second, value); + } else { + throw 'can.Map: Object does not exist'; + } + } else { + if (this.__convert) { + value = this.__convert(attr, value); + } + current = this._init ? undefined : this.__get(attr); + this.__set(attr, this.__type(value, attr), current); + } + }, + __set: function (prop, value, current) { + if (value !== current) { + var changeType = current !== undefined || this.__get().hasOwnProperty(prop) ? 'set' : 'add'; + this.___set(prop, this.constructor._bubble.set(this, prop, value, current)); + if (!this._computedBindings[prop]) { + this._triggerChange(prop, changeType, value, current); + } + if (current) { + this.constructor._bubble.teardownFromParent(this, current); + } + } + }, + ___set: function (prop, val) { + if (this._computedBindings[prop]) { + this[prop](val); + } else { + this._data[prop] = val; + } + if (typeof this.constructor.prototype[prop] !== 'function' && !this._computedBindings[prop]) { + this[prop] = val; + } + }, + bind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (!computedBinding.count) { + computedBinding.count = 1; + var self = this; + computedBinding.handler = function (ev, newVal, oldVal) { + can.batch.trigger(self, { + type: eventName, + batchNum: ev.batchNum, + target: self + }, [ + newVal, + oldVal + ]); + }; + this[eventName].bind('change', computedBinding.handler); + } else { + computedBinding.count++; + } + } + this.constructor._bubble.bind(this, eventName); + return can.bindAndSetup.apply(this, arguments); + }, + unbind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (computedBinding.count === 1) { + computedBinding.count = 0; + this[eventName].unbind('change', computedBinding.handler); + delete computedBinding.handler; + } else { + computedBinding.count--; + } + } + this.constructor._bubble.unbind(this, eventName); + return can.unbindAndTeardown.apply(this, arguments); + }, + serialize: function () { + return can.Map.helpers.serialize(this, 'serialize', {}); + }, + _attrs: function (props, remove) { + if (props === undefined) { + return Map.helpers.serialize(this, 'attr', {}); + } + props = can.simpleExtend({}, props); + var prop, self = this, newVal; + can.batch.start(); + this.each(function (curVal, prop) { + if (prop === '_cid') { + return; + } + newVal = props[prop]; + if (newVal === undefined) { + if (remove) { + self.removeAttr(prop); + } + return; + } + if (self.__convert) { + newVal = self.__convert(prop, newVal); + } + if (Map.helpers.isObservable(newVal)) { + self.__set(prop, self.__type(newVal, prop), curVal); + } else if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + self.__set(prop, self.__type(newVal, prop), curVal); + } + delete props[prop]; + }); + for (prop in props) { + if (prop !== '_cid') { + newVal = props[prop]; + this._set(prop, newVal, true); + } + } + can.batch.stop(); + return this; + }, + compute: function (prop) { + if (can.isFunction(this.constructor.prototype[prop])) { + return can.compute(this[prop], this); + } else { + var reads = prop.split('.'), last = reads.length - 1, options = { args: [] }; + return can.compute(function (newVal) { + if (arguments.length) { + can.compute.read(this, reads.slice(0, last)).value.attr(reads[last], newVal); + } else { + return can.compute.read(this, reads, options).value; + } + }, this); + } + } + }); + Map.prototype.on = Map.prototype.bind; + Map.prototype.off = Map.prototype.unbind; + return Map; +}); +/*can@2.2.6#list/list*/ +define('can/list/list', [ + 'can/util/util', + 'can/map/map', + 'can/map/bubble' +], function (can, Map, bubble) { + var splice = [].splice, spliceRemovesProps = function () { + var obj = { + 0: 'a', + length: 1 + }; + splice.call(obj, 0, 1); + return !obj[0]; + }(); + var list = Map.extend({ Map: Map }, { + setup: function (instances, options) { + this.length = 0; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + this._setupComputes(); + instances = instances || []; + var teardownMapping; + if (can.isDeferred(instances)) { + this.replace(instances); + } else { + teardownMapping = instances.length && can.Map.helpers.addToMap(instances, this); + this.push.apply(this, can.makeArray(instances || [])); + } + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + can.simpleExtend(this, options); + delete this._init; + }, + _triggerChange: function (attr, how, newVal, oldVal) { + Map.prototype._triggerChange.apply(this, arguments); + var index = +attr; + if (!~('' + attr).indexOf('.') && !isNaN(index)) { + if (how === 'add') { + can.batch.trigger(this, how, [ + newVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else if (how === 'remove') { + can.batch.trigger(this, how, [ + oldVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else { + can.batch.trigger(this, how, [ + newVal, + index + ]); + } + } + }, + __get: function (attr) { + if (attr) { + if (this[attr] && this[attr].isComputed && can.isFunction(this.constructor.prototype[attr])) { + return this[attr](); + } else { + return this[attr]; + } + } else { + return this; + } + }, + __set: function (prop, value, current) { + prop = isNaN(+prop) || prop % 1 ? prop : +prop; + if (typeof prop === 'number' && prop > this.length - 1) { + var newArr = new Array(prop + 1 - this.length); + newArr[newArr.length - 1] = value; + this.push.apply(this, newArr); + return newArr; + } + return can.Map.prototype.__set.call(this, '' + prop, value, current); + }, + ___set: function (attr, val) { + this[attr] = val; + if (+attr >= this.length) { + this.length = +attr + 1; + } + }, + _remove: function (prop, current) { + if (isNaN(+prop)) { + delete this[prop]; + this._triggerChange(prop, 'remove', undefined, current); + } else { + this.splice(prop, 1); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var i = 0; i < data.length; i++) { + callback(data[i], i); + } + }, + serialize: function () { + return Map.helpers.serialize(this, 'serialize', []); + }, + splice: function (index, howMany) { + var args = can.makeArray(arguments), added = [], i, len, listIndex, allSame = args.length > 2; + index = index || 0; + for (i = 0, len = args.length - 2; i < len; i++) { + listIndex = i + 2; + args[listIndex] = this.__type(args[listIndex], listIndex); + added.push(args[listIndex]); + if (this[i + index] !== args[listIndex]) { + allSame = false; + } + } + if (allSame && this.length <= added.length) { + return added; + } + if (howMany === undefined) { + howMany = args[1] = this.length - index; + } + var removed = splice.apply(this, args); + if (!spliceRemovesProps) { + for (i = this.length; i < removed.length + this.length; i++) { + delete this[i]; + } + } + can.batch.start(); + if (howMany > 0) { + bubble.removeMany(this, removed); + this._triggerChange('' + index, 'remove', undefined, removed); + } + if (args.length > 2) { + for (i = 0, len = added.length; i < len; i++) { + bubble.set(this, i, added[i]); + } + this._triggerChange('' + index, 'add', added, removed); + } + can.batch.stop(); + return removed; + }, + _attrs: function (items, remove) { + if (items === undefined) { + return Map.helpers.serialize(this, 'attr', []); + } + items = can.makeArray(items); + can.batch.start(); + this._updateAttrs(items, remove); + can.batch.stop(); + }, + _updateAttrs: function (items, remove) { + var len = Math.min(items.length, this.length); + for (var prop = 0; prop < len; prop++) { + var curVal = this[prop], newVal = items[prop]; + if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + this._set(prop, newVal); + } else { + } + } + if (items.length > this.length) { + this.push.apply(this, items.slice(this.length)); + } else if (items.length < this.length && remove) { + this.splice(items.length); + } + } + }), getArgs = function (args) { + return args[0] && can.isArray(args[0]) ? args[0] : can.makeArray(args); + }; + can.each({ + push: 'length', + unshift: 0 + }, function (where, name) { + var orig = [][name]; + list.prototype[name] = function () { + var args = [], len = where ? this.length : 0, i = arguments.length, res, val; + while (i--) { + val = arguments[i]; + args[i] = bubble.set(this, i, this.__type(val, i)); + } + res = orig.apply(this, args); + if (!this.comparator || args.length) { + this._triggerChange('' + len, 'add', args, undefined); + } + return res; + }; + }); + can.each({ + pop: 'length', + shift: 0 + }, function (where, name) { + list.prototype[name] = function () { + if (!this.length) { + return undefined; + } + var args = getArgs(arguments), len = where && this.length ? this.length - 1 : 0; + var res = [][name].apply(this, args); + this._triggerChange('' + len, 'remove', undefined, [res]); + if (res && res.unbind) { + bubble.remove(this, res); + } + return res; + }; + }); + can.extend(list.prototype, { + indexOf: function (item, fromIndex) { + this.attr('length'); + return can.inArray(item, this, fromIndex); + }, + join: function () { + return [].join.apply(this.attr(), arguments); + }, + reverse: function () { + var list = [].reverse.call(can.makeArray(this)); + this.replace(list); + }, + slice: function () { + var temp = Array.prototype.slice.apply(this, arguments); + return new this.constructor(temp); + }, + concat: function () { + var args = []; + can.each(can.makeArray(arguments), function (arg, i) { + args[i] = arg instanceof can.List ? arg.serialize() : arg; + }); + return new this.constructor(Array.prototype.concat.apply(this.serialize(), args)); + }, + forEach: function (cb, thisarg) { + return can.each(this, cb, thisarg || this); + }, + replace: function (newList) { + if (can.isDeferred(newList)) { + newList.then(can.proxy(this.replace, this)); + } else { + this.splice.apply(this, [ + 0, + this.length + ].concat(can.makeArray(newList || []))); + } + return this; + }, + filter: function (callback, thisArg) { + var filteredList = new can.List(), self = this, filtered; + this.each(function (item, index, list) { + filtered = callback.call(thisArg | self, item, index, self); + if (filtered) { + filteredList.push(item); + } + }); + return filteredList; + } + }); + can.List = Map.List = list; + return can.List; +}); +/*can@2.2.6#compute/read*/ +define('can/compute/read', ['can/util/util'], function (can) { + var read = function (parent, reads, options) { + options = options || {}; + var state = { foundObservable: false }; + var cur = readValue(parent, 0, reads, options, state), type, prev, readLength = reads.length, i = 0; + while (i < readLength) { + prev = cur; + for (var r = 0, readersLength = read.propertyReaders.length; r < readersLength; r++) { + var reader = read.propertyReaders[r]; + if (reader.test(cur)) { + cur = reader.read(cur, reads[i], i, options, state); + break; + } + } + i = i + 1; + cur = readValue(cur, i, reads, options, state, prev); + type = typeof cur; + if (i < reads.length && (cur === null || type !== 'function' && type !== 'object')) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1, cur); + } + return { + value: undefined, + parent: prev + }; + } + } + if (cur === undefined) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1); + } + } + return { + value: cur, + parent: prev + }; + }; + var readValue = function (value, index, reads, options, state, prev) { + var usedValueReader; + do { + usedValueReader = false; + for (var i = 0, len = read.valueReaders.length; i < len; i++) { + if (read.valueReaders[i].test(value, index, reads, options)) { + value = read.valueReaders[i].read(value, index, reads, options, state, prev); + } + } + } while (usedValueReader); + return value; + }; + read.valueReaders = [ + { + name: 'compute', + test: function (value, i, reads, options) { + return value && value.isComputed; + }, + read: function (value, i, reads, options, state) { + if (options.isArgument && i === reads.length) { + return value; + } + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, i); + state.foundObservable = true; + } + return value instanceof can.Compute ? value.get() : value(); + } + }, + { + name: 'function', + test: function (value, i, reads, options) { + var type = typeof value; + return type === 'function' && !value.isComputed && (options.executeAnonymousFunctions || options.isArgument && i === reads.length) && !(can.Construct && value.prototype instanceof can.Construct) && !(can.route && value === can.route); + }, + read: function (value, i, reads, options, state, prev) { + if (options.isArgument && i === reads.length) { + return options.proxyMethods !== false ? can.proxy(value, prev) : value; + } + return value.call(prev); + } + } + ]; + read.propertyReaders = [ + { + name: 'map', + test: can.isMapLike, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + if (typeof value[prop] === 'function' && value.constructor.prototype[prop] === value[prop]) { + if (options.returnObserveMethods) { + return value[prop]; + } else if (prop === 'constructor' && value instanceof can.Construct || value[prop].prototype instanceof can.Construct) { + return value[prop]; + } else { + return value[prop].apply(value, options.args || []); + } + } else { + return value.attr(prop); + } + } + }, + { + name: 'promise', + test: function (value) { + return can.isPromise(value); + }, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + var observeData = value.__observeData; + if (!value.__observeData) { + observeData = value.__observeData = { + isPending: true, + state: 'pending', + isResolved: false, + isRejected: false, + value: undefined, + reason: undefined + }; + can.cid(observeData); + can.simpleExtend(observeData, can.event); + value.then(function (value) { + observeData.isPending = false; + observeData.isResolved = true; + observeData.value = value; + observeData.state = 'resolved'; + observeData.dispatch('state', [ + 'resolved', + 'pending' + ]); + }, function (reason) { + observeData.isPending = false; + observeData.isRejected = true; + observeData.reason = reason; + observeData.state = 'rejected'; + observeData.dispatch('state', [ + 'rejected', + 'pending' + ]); + }); + } + can.__observe(observeData, 'state'); + return prop in observeData ? observeData[prop] : value[prop]; + } + }, + { + name: 'object', + test: function () { + return true; + }, + read: function (value, prop) { + if (value == null) { + return undefined; + } else { + return value[prop]; + } + } + } + ]; + read.write = function (parent, key, value, options) { + options = options || {}; + if (can.isMapLike(parent)) { + if (!options.isArgument && parent._data && parent._data[key] && parent._data[key].isComputed) { + return parent._data[key](value); + } else { + return parent.attr(key, value); + } + } + if (parent[key] && parent[key].isComputed) { + return parent[key](value); + } + if (typeof parent === 'object') { + parent[key] = value; + } + }; + return read; +}); +/*can@2.2.6#compute/get_value_and_bind*/ +define('can/compute/get_value_and_bind', ['can/util/util'], function () { + function observe(func, context, oldInfo, onchanged) { + var info = getValueAndObserved(func, context), newObserveSet = info.observed, oldObserved = oldInfo.observed; + if (info.names !== oldInfo.names) { + bindNewSet(oldObserved, newObserveSet, onchanged); + unbindOldSet(oldObserved, onchanged); + } + can.batch.afterPreviousEvents(function () { + info.ready = true; + }); + return info; + } + var observedStack = []; + can.__isRecordingObserves = function () { + return observedStack.length; + }; + can.__observe = can.__reading = function (obj, event) { + if (observedStack.length) { + var name = obj._cid + '|' + event, top = observedStack[observedStack.length - 1]; + top.names += name; + top.observed[name] = { + obj: obj, + event: event + '' + }; + } + }; + can.__notObserve = function (fn) { + return function () { + var previousReads = can.__clearObserved(); + var res = fn.apply(this, arguments); + can.__setObserved(previousReads); + return res; + }; + }; + can.__clearObserved = can.__clearReading = function () { + if (observedStack.length) { + var ret = observedStack[observedStack.length - 1]; + observedStack[observedStack.length - 1] = { observed: {} }; + return ret; + } + }; + can.__setObserved = can.__setReading = function (o) { + if (observedStack.length) { + observedStack[observedStack.length - 1] = o; + } + }; + can.__addObserved = can.__addReading = function (o) { + if (observedStack.length) { + can.simpleExtend(observedStack[observedStack.length - 1], o); + } + }; + var getValueAndObserved = function (func, self) { + observedStack.push({ + names: '', + observed: {} + }); + var value = func.call(self); + var stackItem = observedStack.pop(); + stackItem.value = value; + return stackItem; + }; + var bindNewSet = function (oldObserved, newObserveSet, onchanged) { + for (var name in newObserveSet) { + bindOrPreventUnbinding(oldObserved, newObserveSet, name, onchanged); + } + }; + var bindOrPreventUnbinding = function (oldObserved, newObserveSet, name, onchanged) { + if (oldObserved[name]) { + delete oldObserved[name]; + } else { + var obEv = newObserveSet[name]; + obEv.obj.bind(obEv.event, onchanged); + } + }; + var unbindOldSet = function (oldObserved, onchanged) { + for (var name in oldObserved) { + var obEv = oldObserved[name]; + obEv.obj.unbind(obEv.event, onchanged); + } + }; + return observe; +}); +/*can@2.2.6#compute/proto_compute*/ +define('can/compute/proto_compute', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/compute/read', + 'can/compute/get_value_and_bind', + 'can/util/batch/batch' +], function (can, bind, read, getValueAndBind) { + var updateOnChange = function (compute, newValue, oldValue, batchNum) { + if (newValue !== oldValue) { + can.batch.trigger(compute, batchNum ? { + type: 'change', + batchNum: batchNum + } : 'change', [ + newValue, + oldValue + ]); + } + }; + var setupComputeHandlers = function (compute, func, context, singleBind) { + var readInfo, onchanged, batchNum; + singleBind = false; + return { + on: function (updater) { + var self = this; + if (!onchanged) { + onchanged = function (ev) { + if (readInfo.ready && compute.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + if (singleBind) { + newValue = func.call(context); + readInfo.value = newValue; + } else { + readInfo = getValueAndBind(func, context, readInfo, onchanged); + newValue = readInfo.value; + } + self.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }; + } + readInfo = getValueAndBind(func, context, { observed: {} }, onchanged); + if (singleBind) { + func = can.__notObserve(func); + } + compute.value = readInfo.value; + compute.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function (updater) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, onchanged); + } + } + }; + }; + var k = function () { + }; + var updater = function (newVal, oldVal, batchNum) { + this.value = newVal; + updateOnChange(this, newVal, oldVal, batchNum); + }, asyncGet = function (fn, context, lastSetValue) { + return function () { + return fn.call(context, lastSetValue.get()); + }; + }, asyncUpdater = function (context, oldUpdater) { + return function (newVal) { + if (newVal !== undefined) { + oldUpdater(newVal, context.value); + } + }; + }; + can.Compute = function (getterSetter, context, eventName, bindOnce) { + var args = []; + for (var i = 0, arglen = arguments.length; i < arglen; i++) { + args[i] = arguments[i]; + } + var contextType = typeof args[1]; + if (typeof args[0] === 'function') { + this._setupGetterSetterFn(args[0], args[1], args[2], args[3]); + } else if (args[1]) { + if (contextType === 'string') { + this._setupContextString(args[0], args[1], args[2]); + } else if (contextType === 'function') { + this._setupContextFunction(args[0], args[1], args[2]); + } else { + if (args[1] && args[1].fn) { + this._setupAsyncCompute(args[0], args[1]); + } else { + this._setupContextSettings(args[0], args[1]); + } + } + } else { + this._setupInitialValue(args[0]); + } + this._args = args; + this.isComputed = true; + can.cid(this, 'compute'); + }; + can.simpleExtend(can.Compute.prototype, { + _bindsetup: can.__notObserve(function () { + this.bound = true; + this._on(this.updater); + }), + _bindteardown: function () { + this._off(this.updater); + this.bound = false; + }, + bind: can.bindAndSetup, + unbind: can.unbindAndTeardown, + clone: function (context) { + if (context && typeof this._args[0] === 'function') { + this._args[1] = context; + } else if (context) { + this._args[2] = context; + } + return new can.Compute(this._args[0], this._args[1], this._args[2], this._args[3]); + }, + _on: k, + _off: k, + get: function () { + if (can.__isRecordingObserves() && this._canObserve !== false) { + can.__observe(this, 'change'); + if (!this.bound) { + can.Compute.temporarilyBind(this); + } + } + if (this.bound) { + return this.value; + } else { + return this._get(); + } + }, + _get: function () { + return this.value; + }, + set: function (newVal) { + var old = this.value; + var setVal = this._set(newVal, old); + if (this.hasDependencies) { + if (this._setUpdates) { + return this.value; + } + return this._get(); + } + if (setVal === undefined) { + this.value = this._get(); + } else { + this.value = setVal; + } + updateOnChange(this, this.value, old); + return this.value; + }, + _set: function (newVal) { + return this.value = newVal; + }, + updater: updater, + _computeFn: function (newVal) { + if (arguments.length) { + return this.set(newVal); + } + return this.get(); + }, + toFunction: function () { + return can.proxy(this._computeFn, this); + }, + _setupGetterSetterFn: function (getterSetter, context, eventName, bindOnce) { + this._set = can.proxy(getterSetter, context); + this._get = can.proxy(getterSetter, context); + this._canObserve = eventName === false ? false : true; + var handlers = setupComputeHandlers(this, getterSetter, context || this, bindOnce); + this._on = handlers.on; + this._off = handlers.off; + }, + _setupContextString: function (target, propertyName, eventName) { + var isObserve = can.isMapLike(target), self = this, handler = function (ev, newVal, oldVal) { + self.updater(newVal, oldVal, ev.batchNum); + }; + if (isObserve) { + this.hasDependencies = true; + this._get = function () { + return target.attr(propertyName); + }; + this._set = function (val) { + target.attr(propertyName, val); + }; + this._on = function (update) { + target.bind(eventName || propertyName, handler); + this.value = this._get(); + }; + this._off = function () { + return target.unbind(eventName || propertyName, handler); + }; + } else { + this._get = can.proxy(this._get, target); + this._set = can.proxy(this._set, target); + } + }, + _setupContextFunction: function (initialValue, setter, eventName) { + this.value = initialValue; + this._set = setter; + can.simpleExtend(this, eventName); + }, + _setupContextSettings: function (initialValue, settings) { + this.value = initialValue; + this._set = settings.set ? can.proxy(settings.set, settings) : this._set; + this._get = settings.get ? can.proxy(settings.get, settings) : this._get; + if (!settings.__selfUpdater) { + var self = this, oldUpdater = this.updater; + this.updater = function () { + oldUpdater.call(self, self._get(), self.value); + }; + } + this._on = settings.on ? settings.on : this._on; + this._off = settings.off ? settings.off : this._off; + }, + _setupAsyncCompute: function (initialValue, settings) { + this.value = initialValue; + var oldUpdater = can.proxy(this.updater, this), self = this, fn = settings.fn, data; + this.updater = oldUpdater; + var lastSetValue = new can.Compute(initialValue); + this.lastSetValue = lastSetValue; + this._setUpdates = true; + this._set = function (newVal) { + if (newVal === lastSetValue.get()) { + return this.value; + } + return lastSetValue.set(newVal); + }; + this._get = asyncGet(fn, settings.context, lastSetValue); + if (fn.length === 0) { + data = setupComputeHandlers(this, fn, settings.context); + } else if (fn.length === 1) { + data = setupComputeHandlers(this, function () { + return fn.call(settings.context, lastSetValue.get()); + }, settings); + } else { + this.updater = asyncUpdater(this, oldUpdater); + data = setupComputeHandlers(this, function () { + var res = fn.call(settings.context, lastSetValue.get(), function (newVal) { + oldUpdater(newVal, self.value); + }); + return res !== undefined ? res : this.value; + }, settings); + } + this._on = data.on; + this._off = data.off; + }, + _setupInitialValue: function (initialValue) { + this.value = initialValue; + } + }); + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.Compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.Compute.async = function (initialValue, asyncComputer, context) { + return new can.Compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.Compute.read = read; + can.Compute.set = read.write; + can.Compute.truthy = function (compute) { + return new can.Compute(function () { + var res = compute.get(); + if (typeof res === 'function') { + res = res.get(); + } + return !!res; + }); + }; + return can.Compute; +}); +/*can@2.2.6#compute/compute*/ +define('can/compute/compute', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/util/batch/batch', + 'can/compute/proto_compute' +], function (can, bind) { + can.compute = function (getterSetter, context, eventName, bindOnce) { + var internalCompute = new can.Compute(getterSetter, context, eventName, bindOnce); + var compute = function (val) { + if (arguments.length) { + return internalCompute.set(val); + } + return internalCompute.get(); + }; + compute.bind = can.proxy(internalCompute.bind, internalCompute); + compute.unbind = can.proxy(internalCompute.unbind, internalCompute); + compute.isComputed = internalCompute.isComputed; + compute.clone = function (ctx) { + if (typeof getterSetter === 'function') { + context = ctx; + } + return can.compute(getterSetter, context, ctx, bindOnce); + }; + compute.computeInstance = internalCompute; + return compute; + }; + var k = function () { + }; + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.compute.truthy = function (compute) { + return can.compute(function () { + var res = compute(); + if (typeof res === 'function') { + res = res(); + } + return !!res; + }); + }; + can.compute.async = function (initialValue, asyncComputer, context) { + return can.compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.compute.read = can.Compute.read; + can.compute.set = can.Compute.set; + return can.compute; +}); +/*can@2.2.6#observe/observe*/ +define('can/observe/observe', [ + 'can/util/util', + 'can/map/map', + 'can/list/list', + 'can/compute/compute' +], function (can) { + can.Observe = can.Map; + can.Observe.startBatch = can.batch.start; + can.Observe.stopBatch = can.batch.stop; + can.Observe.triggerBatch = can.batch.trigger; + return can; +}); +/*can@2.2.6#view/scope/compute_data*/ +define('can/view/scope/compute_data', [ + 'can/util/util', + 'can/compute/compute', + 'can/compute/get_value_and_bind' +], function (can, compute, getValueAndBind) { + var isFastPath = function (computeData) { + return computeData.reads && computeData.reads.length === 1 && computeData.root instanceof can.Map && !can.isFunction(computeData.root[computeData.reads[0]]); + }; + var getValueAndBindScopeRead = function (scopeRead, scopeReadChanged) { + return getValueAndBind(scopeRead, null, { observed: {} }, scopeReadChanged); + }; + var unbindScopeRead = function (readInfo, scopeReadChanged) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, scopeReadChanged); + } + }; + var getValueAndBindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + var target = computeData.root, prop = computeData.reads[0]; + target.bind(prop, singlePropertyReadChanged); + return { + value: computeData.initialValue, + observed: { something: true } + }; + }; + var unbindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + computeData.root.unbind(computeData.reads[0], singlePropertyReadChanged); + }; + var scopeReader = function (scope, key, options, computeData, newVal) { + if (arguments.length > 4) { + if (computeData.root.isComputed) { + computeData.root(newVal); + } else if (computeData.reads.length) { + var last = computeData.reads.length - 1; + var obj = computeData.reads.length ? can.compute.read(computeData.root, computeData.reads.slice(0, last)).value : computeData.root; + can.compute.set(obj, computeData.reads[last], newVal, options); + } + } else { + if (computeData.root) { + return can.compute.read(computeData.root, computeData.reads, options).value; + } + var data = scope.read(key, options); + computeData.scope = data.scope; + computeData.initialValue = data.value; + computeData.reads = data.reads; + computeData.root = data.rootObserve; + return data.value; + } + }; + return function (scope, key, options) { + options = options || { args: [] }; + var computeData = {}, scopeRead = function (newVal) { + if (arguments.length) { + return scopeReader(scope, key, options, computeData, newVal); + } else { + return scopeReader(scope, key, options, computeData); + } + }, batchNum, readInfo, scopeReadChanged = function (ev) { + if (readInfo.ready && compute.computeInstance.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + readInfo = getValueAndBind(scopeRead, null, readInfo, scopeReadChanged); + newValue = readInfo.value; + compute.computeInstance.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }, singlePropertyReadChanged = function (ev, newVal, oldVal) { + if (typeof newVal !== 'function') { + compute.computeInstance.updater(newVal, oldVal, ev.batchNum); + } else { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + isFastPathBound = false; + compute.computeInstance.updater(readInfo.value, oldVal, ev.batchNum); + } + }, isFastPathBound = false, compute = can.compute(undefined, { + on: function () { + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + if (isFastPath(computeData)) { + var oldReadInfo = readInfo; + readInfo = getValueAndBindSinglePropertyRead(computeData, singlePropertyReadChanged); + unbindScopeRead(oldReadInfo, scopeReadChanged); + isFastPathBound = true; + } + compute.computeInstance.value = readInfo.value; + compute.computeInstance.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function () { + if (isFastPathBound) { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + } else { + unbindScopeRead(readInfo, scopeReadChanged); + } + }, + set: scopeRead, + get: scopeRead, + __selfUpdater: true + }); + computeData.compute = compute; + return computeData; + }; +}); +/*can@2.2.6#view/scope/scope*/ +define('can/view/scope/scope', [ + 'can/util/util', + 'can/view/scope/compute_data', + 'can/construct/construct', + 'can/map/map', + 'can/list/list', + 'can/view/view', + 'can/compute/compute' +], function (can, makeComputeData) { + var escapeReg = /(\\)?\./g, escapeDotReg = /\\\./g, getNames = function (attr) { + var names = [], last = 0; + attr.replace(escapeReg, function (first, second, index) { + if (!second) { + names.push(attr.slice(last, index).replace(escapeDotReg, '.')); + last = index + first.length; + } + }); + names.push(attr.slice(last).replace(escapeDotReg, '.')); + return names; + }; + var Scope = can.Construct.extend({ read: can.compute.read }, { + init: function (context, parent) { + this._context = context; + this._parent = parent; + this.__cache = {}; + }, + attr: can.__notObserve(function (key, value) { + var options = { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }, res = this.read(key, options); + if (arguments.length === 2) { + var lastIndex = key.lastIndexOf('.'), readKey = lastIndex !== -1 ? key.substring(0, lastIndex) : '.', obj = this.read(readKey, options).value; + if (lastIndex !== -1) { + key = key.substring(lastIndex + 1, key.length); + } + can.compute.set(obj, key, value, options); + } + return res.value; + }), + add: function (context) { + if (context !== this._context) { + return new this.constructor(context, this); + } else { + return this; + } + }, + computeData: function (key, options) { + return makeComputeData(this, key, options); + }, + compute: function (key, options) { + return this.computeData(key, options).compute; + }, + read: function (attr, options) { + var stopLookup; + if (attr.substr(0, 2) === './') { + stopLookup = true; + attr = attr.substr(2); + } else if (attr.substr(0, 3) === '../') { + return this._parent.read(attr.substr(3), options); + } else if (attr === '..') { + return { value: this._parent._context }; + } else if (attr === '.' || attr === 'this') { + return { value: this._context }; + } + var names = attr.indexOf('\\.') === -1 ? attr.split('.') : getNames(attr), context, scope = this, defaultObserve, defaultReads = [], defaultPropertyDepth = -1, defaultComputeReadings, defaultScope, currentObserve, currentReads; + while (scope) { + context = scope._context; + if (context !== null && (typeof context === 'object' || typeof context === 'function')) { + var data = can.compute.read(context, names, can.simpleExtend({ + foundObservable: function (observe, nameIndex) { + currentObserve = observe; + currentReads = names.slice(nameIndex); + }, + earlyExit: function (parentValue, nameIndex) { + if (nameIndex > defaultPropertyDepth) { + defaultObserve = currentObserve; + defaultReads = currentReads; + defaultPropertyDepth = nameIndex; + defaultScope = scope; + defaultComputeReadings = can.__clearReading(); + } + }, + executeAnonymousFunctions: true + }, options)); + if (data.value !== undefined) { + return { + scope: scope, + rootObserve: currentObserve, + value: data.value, + reads: currentReads + }; + } + } + can.__clearReading(); + if (!stopLookup) { + scope = scope._parent; + } else { + scope = null; + } + } + if (defaultObserve) { + can.__setReading(defaultComputeReadings); + return { + scope: defaultScope, + rootObserve: defaultObserve, + reads: defaultReads, + value: undefined + }; + } else { + return { + names: names, + value: undefined + }; + } + } + }); + can.view.Scope = Scope; + return Scope; +}); +/*can@2.2.6#view/scanner*/ +define('can/view/scanner', [ + 'can/view/view', + 'can/view/elements', + 'can/view/callbacks/callbacks' +], function (can, elements, viewCallbacks) { + var newLine = /(\r|\n)+/g, notEndTag = /\//, clean = function (content) { + return content.split('\\').join('\\\\').split('\n').join('\\n').split('"').join('\\"').split('\t').join('\\t'); + }, getTag = function (tagName, tokens, i) { + if (tagName) { + return tagName; + } else { + while (i < tokens.length) { + if (tokens[i] === '<' && !notEndTag.test(tokens[i + 1])) { + return elements.reverseTagMap[tokens[i + 1]] || 'span'; + } + i++; + } + } + return ''; + }, bracketNum = function (content) { + return --content.split('{').length - --content.split('}').length; + }, myEval = function (script) { + eval(script); + }, attrReg = /([^\s]+)[\s]*=[\s]*$/, startTxt = 'var ___v1ew = [];', finishTxt = 'return ___v1ew.join(\'\')', put_cmd = '___v1ew.push(\n', insert_cmd = put_cmd, htmlTag = null, quote = null, beforeQuote = null, rescan = null, getAttrName = function () { + var matches = beforeQuote.match(attrReg); + return matches && matches[1]; + }, status = function () { + return quote ? '\'' + getAttrName() + '\'' : htmlTag ? 1 : 0; + }, top = function (stack) { + return stack[stack.length - 1]; + }, Scanner; + can.view.Scanner = Scanner = function (options) { + can.extend(this, { + text: {}, + tokens: [] + }, options); + this.text.options = this.text.options || ''; + this.tokenReg = []; + this.tokenSimple = { + '<': '<', + '>': '>', + '"': '"', + '\'': '\'' + }; + this.tokenComplex = []; + this.tokenMap = {}; + for (var i = 0, token; token = this.tokens[i]; i++) { + if (token[2]) { + this.tokenReg.push(token[2]); + this.tokenComplex.push({ + abbr: token[1], + re: new RegExp(token[2]), + rescan: token[3] + }); + } else { + this.tokenReg.push(token[1]); + this.tokenSimple[token[1]] = token[0]; + } + this.tokenMap[token[0]] = token[1]; + } + this.tokenReg = new RegExp('(' + this.tokenReg.slice(0).concat([ + '<', + '>', + '"', + '\'' + ]).join('|') + ')', 'g'); + }; + Scanner.prototype = { + helpers: [], + scan: function (source, name) { + var tokens = [], last = 0, simple = this.tokenSimple, complex = this.tokenComplex; + source = source.replace(newLine, '\n'); + if (this.transform) { + source = this.transform(source); + } + source.replace(this.tokenReg, function (whole, part) { + var offset = arguments[arguments.length - 2]; + if (offset > last) { + tokens.push(source.substring(last, offset)); + } + if (simple[whole]) { + tokens.push(whole); + } else { + for (var i = 0, token; token = complex[i]; i++) { + if (token.re.test(whole)) { + tokens.push(token.abbr); + if (token.rescan) { + tokens.push(token.rescan(part)); + } + break; + } + } + } + last = offset + part.length; + }); + if (last < source.length) { + tokens.push(source.substr(last)); + } + var content = '', buff = [startTxt + (this.text.start || '')], put = function (content, bonus) { + buff.push(put_cmd, '"', clean(content), '"' + (bonus || '') + ');'); + }, endStack = [], lastToken, startTag = null, magicInTag = false, specialStates = { + attributeHookups: [], + tagHookups: [], + lastTagHookup: '' + }, popTagHookup = function () { + specialStates.lastTagHookup = specialStates.tagHookups.pop() + specialStates.tagHookups.length; + }, tagName = '', tagNames = [], popTagName = false, bracketCount, specialAttribute = false, i = 0, token, tmap = this.tokenMap, attrName; + htmlTag = quote = beforeQuote = null; + for (; (token = tokens[i++]) !== undefined;) { + if (startTag === null) { + switch (token) { + case tmap.left: + case tmap.escapeLeft: + case tmap.returnLeft: + magicInTag = htmlTag && 1; + case tmap.commentLeft: + startTag = token; + if (content.length) { + put(content); + } + content = ''; + break; + case tmap.escapeFull: + magicInTag = htmlTag && 1; + rescan = 1; + startTag = tmap.escapeLeft; + if (content.length) { + put(content); + } + rescan = tokens[i++]; + content = rescan.content || rescan; + if (rescan.before) { + put(rescan.before); + } + tokens.splice(i, 0, tmap.right); + break; + case tmap.commentFull: + break; + case tmap.templateLeft: + content += tmap.left; + break; + case '<': + if (tokens[i].indexOf('!--') !== 0) { + htmlTag = 1; + magicInTag = 0; + } + content += token; + break; + case '>': + htmlTag = 0; + var emptyElement = content.substr(content.length - 1) === '/' || content.substr(content.length - 2) === '--', attrs = ''; + if (specialStates.attributeHookups.length) { + attrs = 'attrs: [\'' + specialStates.attributeHookups.join('\',\'') + '\'], '; + specialStates.attributeHookups = []; + } + if (tagName + specialStates.tagHookups.length !== specialStates.lastTagHookup && tagName === top(specialStates.tagHookups)) { + if (emptyElement) { + content = content.substr(0, content.length - 1); + } + buff.push(put_cmd, '"', clean(content), '"', ',can.view.pending({tagName:\'' + tagName + '\',' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options); + if (emptyElement) { + buff.push('}));'); + content = '/>'; + popTagHookup(); + } else if (tokens[i] === '<' && tokens[i + 1] === '/' + tagName) { + buff.push('}));'); + content = token; + popTagHookup(); + } else { + buff.push(',subtemplate: function(' + this.text.argNames + '){\n' + startTxt + (this.text.start || '')); + content = ''; + } + } else if (magicInTag || !popTagName && elements.tagToContentPropMap[tagNames[tagNames.length - 1]] || attrs) { + var pendingPart = ',can.view.pending({' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options + '}),"'; + if (emptyElement) { + put(content.substr(0, content.length - 1), pendingPart + '/>"'); + } else { + put(content, pendingPart + '>"'); + } + content = ''; + magicInTag = 0; + } else { + content += token; + } + if (emptyElement || popTagName) { + tagNames.pop(); + tagName = tagNames[tagNames.length - 1]; + popTagName = false; + } + specialStates.attributeHookups = []; + break; + case '\'': + case '"': + if (htmlTag) { + if (quote && quote === token) { + quote = null; + var attr = getAttrName(); + if (viewCallbacks.attr(attr)) { + specialStates.attributeHookups.push(attr); + } + if (specialAttribute) { + content += token; + put(content); + buff.push(finishTxt, '}));\n'); + content = ''; + specialAttribute = false; + break; + } + } else if (quote === null) { + quote = token; + beforeQuote = lastToken; + attrName = getAttrName(); + if (tagName === 'img' && attrName === 'src' || attrName === 'style') { + put(content.replace(attrReg, '')); + content = ''; + specialAttribute = true; + buff.push(insert_cmd, 'can.view.txt(2,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt); + put(attrName + '=' + token); + break; + } + } + } + default: + if (lastToken === '<') { + tagName = token.substr(0, 3) === '!--' ? '!--' : token.split(/\s/)[0]; + var isClosingTag = false, cleanedTagName; + if (tagName.indexOf('/') === 0) { + isClosingTag = true; + cleanedTagName = tagName.substr(1); + } + if (isClosingTag) { + if (top(tagNames) === cleanedTagName) { + tagName = cleanedTagName; + popTagName = true; + } + if (top(specialStates.tagHookups) === cleanedTagName) { + put(content.substr(0, content.length - 1)); + buff.push(finishTxt + '}}) );'); + content = '><'; + popTagHookup(); + } + } else { + if (tagName.lastIndexOf('/') === tagName.length - 1) { + tagName = tagName.substr(0, tagName.length - 1); + } + if (tagName !== '!--' && viewCallbacks.tag(tagName)) { + if (tagName === 'content' && elements.tagMap[top(tagNames)]) { + token = token.replace('content', elements.tagMap[top(tagNames)]); + } + specialStates.tagHookups.push(tagName); + } + tagNames.push(tagName); + } + } + content += token; + break; + } + } else { + switch (token) { + case tmap.right: + case tmap.returnRight: + switch (startTag) { + case tmap.left: + bracketCount = bracketNum(content); + if (bracketCount === 1) { + buff.push(insert_cmd, 'can.view.txt(0,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt, content); + endStack.push({ + before: '', + after: finishTxt + '}));\n' + }); + } else { + last = endStack.length && bracketCount === -1 ? endStack.pop() : { after: ';' }; + if (last.before) { + buff.push(last.before); + } + buff.push(content, ';', last.after); + } + break; + case tmap.escapeLeft: + case tmap.returnLeft: + bracketCount = bracketNum(content); + if (bracketCount) { + endStack.push({ + before: finishTxt, + after: '}));\n' + }); + } + var escaped = startTag === tmap.escapeLeft ? 1 : 0, commands = { + insert: insert_cmd, + tagName: getTag(tagName, tokens, i), + status: status(), + specialAttribute: specialAttribute + }; + for (var ii = 0; ii < this.helpers.length; ii++) { + var helper = this.helpers[ii]; + if (helper.name.test(content)) { + content = helper.fn(content, commands); + if (helper.name.source === /^>[\s]*\w*/.source) { + escaped = 0; + } + break; + } + } + if (typeof content === 'object') { + if (content.startTxt && content.end && specialAttribute) { + buff.push(insert_cmd, 'can.view.toStr( ', content.content, '() ) );'); + } else { + if (content.startTxt) { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || (content.escaped != null ? content.escaped : escaped)) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\n'); + } else if (content.startOnlyTxt) { + buff.push(insert_cmd, 'can.view.onlytxt(this,\n'); + } + buff.push(content.content); + if (content.end) { + buff.push('));'); + } + } + } else if (specialAttribute) { + buff.push(insert_cmd, content, ');'); + } else { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || escaped) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\nfunction(){ ' + (this.text.escape || '') + 'return ', content, bracketCount ? startTxt : '}));\n'); + } + if (rescan && rescan.after && rescan.after.length) { + put(rescan.after.length); + rescan = null; + } + break; + } + startTag = null; + content = ''; + break; + case tmap.templateLeft: + content += tmap.left; + break; + default: + content += token; + break; + } + } + lastToken = token; + } + if (content.length) { + put(content); + } + buff.push(';'); + var template = buff.join(''), out = { out: (this.text.outStart || '') + template + ' ' + finishTxt + (this.text.outEnd || '') }; + myEval.call(out, 'this.fn = (function(' + this.text.argNames + '){' + out.out + '});\r\n//# sourceURL=' + name + '.js'); + return out; + } + }; + can.view.pending = function (viewData) { + var hooks = can.view.getHooks(); + return can.view.hook(function (el) { + can.each(hooks, function (fn) { + fn(el); + }); + viewData.templateType = 'legacy'; + if (viewData.tagName) { + viewCallbacks.tagHandler(el, viewData.tagName, viewData); + } + can.each(viewData && viewData.attrs || [], function (attributeName) { + viewData.attributeName = attributeName; + var callback = viewCallbacks.attr(attributeName); + if (callback) { + callback(el, viewData); + } + }); + }); + }; + can.view.tag('content', function (el, tagData) { + return tagData.scope; + }); + can.view.Scanner = Scanner; + return Scanner; +}); +/*can@2.2.6#view/node_lists/node_lists*/ +define('can/view/node_lists/node_lists', [ + 'can/util/util', + 'can/view/elements' +], function (can) { + var canExpando = true; + try { + document.createTextNode('')._ = 0; + } catch (ex) { + canExpando = false; + } + var nodeMap = {}, textNodeMap = {}, expando = 'ejs_' + Math.random(), _id = 0, id = function (node, localMap) { + var _textNodeMap = localMap || textNodeMap; + var id = readId(node, _textNodeMap); + if (id) { + return id; + } else { + if (canExpando || node.nodeType !== 3) { + ++_id; + return node[expando] = (node.nodeName ? 'element_' : 'obj_') + _id; + } else { + ++_id; + _textNodeMap['text_' + _id] = node; + return 'text_' + _id; + } + } + }, readId = function (node, textNodeMap) { + if (canExpando || node.nodeType !== 3) { + return node[expando]; + } else { + for (var textNodeID in textNodeMap) { + if (textNodeMap[textNodeID] === node) { + return textNodeID; + } + } + } + }, splice = [].splice, push = [].push, itemsInChildListTree = function (list) { + var count = 0; + for (var i = 0, len = list.length; i < len; i++) { + var item = list[i]; + if (item.nodeType) { + count++; + } else { + count += itemsInChildListTree(item); + } + } + return count; + }, replacementMap = function (replacements, idMap) { + var map = {}; + for (var i = 0, len = replacements.length; i < len; i++) { + var node = nodeLists.first(replacements[i]); + map[id(node, idMap)] = replacements[i]; + } + return map; + }; + var nodeLists = { + id: id, + update: function (nodeList, newNodes) { + var oldNodes = nodeLists.unregisterChildren(nodeList); + newNodes = can.makeArray(newNodes); + var oldListLength = nodeList.length; + splice.apply(nodeList, [ + 0, + oldListLength + ].concat(newNodes)); + if (nodeList.replacements) { + nodeLists.nestReplacements(nodeList); + } else { + nodeLists.nestList(nodeList); + } + return oldNodes; + }, + nestReplacements: function (list) { + var index = 0, idMap = {}, rMap = replacementMap(list.replacements, idMap), rCount = list.replacements.length; + while (index < list.length && rCount) { + var node = list[index], replacement = rMap[readId(node, idMap)]; + if (replacement) { + list.splice(index, itemsInChildListTree(replacement), replacement); + rCount--; + } + index++; + } + list.replacements = []; + }, + nestList: function (list) { + var index = 0; + while (index < list.length) { + var node = list[index], childNodeList = nodeMap[id(node)]; + if (childNodeList) { + if (childNodeList !== list) { + list.splice(index, itemsInChildListTree(childNodeList), childNodeList); + } + } else { + nodeMap[id(node)] = list; + } + index++; + } + }, + last: function (nodeList) { + var last = nodeList[nodeList.length - 1]; + if (last.nodeType) { + return last; + } else { + return nodeLists.last(last); + } + }, + first: function (nodeList) { + var first = nodeList[0]; + if (first.nodeType) { + return first; + } else { + return nodeLists.first(first); + } + }, + flatten: function (nodeList) { + var items = []; + for (var i = 0; i < nodeList.length; i++) { + var item = nodeList[i]; + if (item.nodeType) { + items.push(item); + } else { + items.push.apply(items, nodeLists.flatten(item)); + } + } + return items; + }, + register: function (nodeList, unregistered, parent) { + nodeList.unregistered = unregistered; + nodeList.parentList = parent; + if (parent === true) { + nodeList.replacements = []; + } else if (parent) { + parent.replacements.push(nodeList); + nodeList.replacements = []; + } else { + nodeLists.nestList(nodeList); + } + return nodeList; + }, + unregisterChildren: function (nodeList) { + var nodes = []; + can.each(nodeList, function (node) { + if (node.nodeType) { + if (!nodeList.replacements) { + delete nodeMap[id(node)]; + } + nodes.push(node); + } else { + push.apply(nodes, nodeLists.unregister(node)); + } + }); + return nodes; + }, + unregister: function (nodeList) { + var nodes = nodeLists.unregisterChildren(nodeList); + if (nodeList.unregistered) { + var unregisteredCallback = nodeList.unregistered; + delete nodeList.unregistered; + delete nodeList.replacements; + unregisteredCallback(); + } + return nodes; + }, + nodeMap: nodeMap + }; + can.view.nodeLists = nodeLists; + return nodeLists; +}); +/*can@2.2.6#view/parser/parser*/ +define('can/view/parser/parser', ['can/view/view'], function (can) { + function makeMap(str) { + var obj = {}, items = str.split(','); + for (var i = 0; i < items.length; i++) { + obj[items[i]] = true; + } + return obj; + } + function handleIntermediate(intermediate, handler) { + for (var i = 0, len = intermediate.length; i < len; i++) { + var item = intermediate[i]; + handler[item.tokenType].apply(handler, item.args); + } + return intermediate; + } + var alphaNumericHU = '-:A-Za-z0-9_', attributeNames = '[a-zA-Z_:][' + alphaNumericHU + ':.]*', spaceEQspace = '\\s*=\\s*', dblQuote2dblQuote = '"((?:\\\\.|[^"])*)"', quote2quote = '\'((?:\\\\.|[^\'])*)\'', attributeEqAndValue = '(?:' + spaceEQspace + '(?:' + '(?:"[^"]*")|(?:\'[^\']*\')|[^>\\s]+))?', matchStash = '\\{\\{[^\\}]*\\}\\}\\}?', stash = '\\{\\{([^\\}]*)\\}\\}\\}?', startTag = new RegExp('^<([' + alphaNumericHU + ']+)' + '(' + '(?:\\s*' + '(?:(?:' + '(?:' + attributeNames + ')?' + attributeEqAndValue + ')|' + '(?:' + matchStash + ')+)' + ')*' + ')\\s*(\\/?)>'), endTag = new RegExp('^<\\/([' + alphaNumericHU + ']+)[^>]*>'), attr = new RegExp('(?:' + '(?:(' + attributeNames + ')|' + stash + ')' + '(?:' + spaceEQspace + '(?:' + '(?:' + dblQuote2dblQuote + ')|(?:' + quote2quote + ')|([^>\\s]+)' + ')' + ')?)', 'g'), mustache = new RegExp(stash, 'g'), txtBreak = /<|\{\{/; + var empty = makeMap('area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed'); + var block = makeMap('a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video'); + var inline = makeMap('abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var'); + var closeSelf = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr'); + var fillAttrs = makeMap('checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected'); + var special = makeMap('script,style'); + var tokenTypes = 'start,end,close,attrStart,attrEnd,attrValue,chars,comment,special,done'.split(','); + var fn = function () { + }; + var HTMLParser = function (html, handler, returnIntermediate) { + if (typeof html === 'object') { + return handleIntermediate(html, handler); + } + var intermediate = []; + handler = handler || {}; + if (returnIntermediate) { + can.each(tokenTypes, function (name) { + var callback = handler[name] || fn; + handler[name] = function () { + if (callback.apply(this, arguments) !== false) { + intermediate.push({ + tokenType: name, + args: can.makeArray(arguments) + }); + } + }; + }); + } + function parseStartTag(tag, tagName, rest, unary) { + tagName = tagName.toLowerCase(); + if (block[tagName]) { + while (stack.last() && inline[stack.last()]) { + parseEndTag('', stack.last()); + } + } + if (closeSelf[tagName] && stack.last() === tagName) { + parseEndTag('', tagName); + } + unary = empty[tagName] || !!unary; + handler.start(tagName, unary); + if (!unary) { + stack.push(tagName); + } + HTMLParser.parseAttrs(rest, handler); + handler.end(tagName, unary); + } + function parseEndTag(tag, tagName) { + var pos; + if (!tagName) { + pos = 0; + } else { + for (pos = stack.length - 1; pos >= 0; pos--) { + if (stack[pos] === tagName) { + break; + } + } + } + if (pos >= 0) { + for (var i = stack.length - 1; i >= pos; i--) { + if (handler.close) { + handler.close(stack[i]); + } + } + stack.length = pos; + } + } + function parseMustache(mustache, inside) { + if (handler.special) { + handler.special(inside); + } + } + var index, chars, match, stack = [], last = html; + stack.last = function () { + return this[this.length - 1]; + }; + while (html) { + chars = true; + if (!stack.last() || !special[stack.last()]) { + if (html.indexOf(''); + if (index >= 0) { + if (handler.comment) { + handler.comment(html.substring(4, index)); + } + html = html.substring(index + 3); + chars = false; + } + } else if (html.indexOf(']*>'), function (all, text) { + text = text.replace(/|/g, '$1$2'); + if (handler.chars) { + handler.chars(text); + } + return ''; + }); + parseEndTag('', stack.last()); + } + if (html === last) { + throw 'Parse Error: ' + html; + } + last = html; + } + parseEndTag(); + handler.done(); + return intermediate; + }; + HTMLParser.parseAttrs = function (rest, handler) { + (rest != null ? rest : '').replace(attr, function (text, name, special, dblQuote, singleQuote, val) { + if (special) { + handler.special(special); + } + if (name || dblQuote || singleQuote || val) { + var value = arguments[3] ? arguments[3] : arguments[4] ? arguments[4] : arguments[5] ? arguments[5] : fillAttrs[name.toLowerCase()] ? name : ''; + handler.attrStart(name || ''); + var last = mustache.lastIndex = 0, res = mustache.exec(value), chars; + while (res) { + chars = value.substring(last, mustache.lastIndex - res[0].length); + if (chars.length) { + handler.attrValue(chars); + } + handler.special(res[1]); + last = mustache.lastIndex; + res = mustache.exec(value); + } + chars = value.substr(last, value.length); + if (chars) { + handler.attrValue(chars); + } + handler.attrEnd(name || ''); + } + }); + }; + can.view.parser = HTMLParser; + return HTMLParser; +}); +/*can@2.2.6#view/live/live*/ +define('can/view/live/live', [ + 'can/util/util', + 'can/view/elements', + 'can/view/view', + 'can/view/node_lists/node_lists', + 'can/view/parser/parser' +], function (can, elements, view, nodeLists, parser) { + elements = elements || can.view.elements; + nodeLists = nodeLists || can.view.NodeLists; + parser = parser || can.view.parser; + var setup = function (el, bind, unbind) { + var tornDown = false, teardown = function () { + if (!tornDown) { + tornDown = true; + unbind(data); + can.unbind.call(el, 'removed', teardown); + } + return true; + }, data = { + teardownCheck: function (parent) { + return parent ? false : teardown(); + } + }; + can.bind.call(el, 'removed', teardown); + bind(data); + return data; + }, listen = function (el, compute, change) { + return setup(el, function () { + compute.bind('change', change); + }, function (data) { + compute.unbind('change', change); + if (data.nodeList) { + nodeLists.unregister(data.nodeList); + } + }); + }, getAttributeParts = function (newVal) { + var attrs = {}, attr; + parser.parseAttrs(newVal, { + attrStart: function (name) { + attrs[name] = ''; + attr = name; + }, + attrValue: function (value) { + attrs[attr] += value; + }, + attrEnd: function () { + } + }); + return attrs; + }, splice = [].splice, isNode = function (obj) { + return obj && obj.nodeType; + }, addTextNodeIfNoChildren = function (frag) { + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + }; + var live = { + list: function (el, compute, render, context, parentNode, nodeList) { + var masterNodeList = nodeList || [el], indexMap = [], afterPreviousEvents = false, isTornDown = false, add = function (ev, items, index) { + if (!afterPreviousEvents) { + return; + } + var frag = document.createDocumentFragment(), newNodeLists = [], newIndicies = []; + can.each(items, function (item, key) { + var itemNodeList = []; + if (nodeList) { + nodeLists.register(itemNodeList, null, true); + } + var itemIndex = can.compute(key + index), itemHTML = render.call(context, item, itemIndex, itemNodeList), gotText = typeof itemHTML === 'string', itemFrag = can.frag(itemHTML); + itemFrag = gotText ? can.view.hookup(itemFrag) : itemFrag; + var childNodes = can.makeArray(itemFrag.childNodes); + if (nodeList) { + nodeLists.update(itemNodeList, childNodes); + newNodeLists.push(itemNodeList); + } else { + newNodeLists.push(nodeLists.register(childNodes)); + } + frag.appendChild(itemFrag); + newIndicies.push(itemIndex); + }); + var masterListIndex = index + 1; + if (!masterNodeList[masterListIndex]) { + elements.after(masterListIndex === 1 ? [text] : [nodeLists.last(masterNodeList[masterListIndex - 1])], frag); + } else { + var el = nodeLists.first(masterNodeList[masterListIndex]); + can.insertBefore(el.parentNode, frag, el); + } + splice.apply(masterNodeList, [ + masterListIndex, + 0 + ].concat(newNodeLists)); + splice.apply(indexMap, [ + index, + 0 + ].concat(newIndicies)); + for (var i = index + newIndicies.length, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + }, remove = function (ev, items, index, duringTeardown, fullTeardown) { + if (!afterPreviousEvents) { + return; + } + if (!duringTeardown && data.teardownCheck(text.parentNode)) { + return; + } + if (index < 0) { + index = indexMap.length + index; + } + var removedMappings = masterNodeList.splice(index + 1, items.length), itemsToRemove = []; + can.each(removedMappings, function (nodeList) { + var nodesToRemove = nodeLists.unregister(nodeList); + [].push.apply(itemsToRemove, nodesToRemove); + }); + indexMap.splice(index, items.length); + for (var i = index, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + if (!fullTeardown) { + can.remove(can.$(itemsToRemove)); + } else { + nodeLists.unregister(masterNodeList); + } + }, move = function (ev, item, newIndex, currentIndex) { + if (!afterPreviousEvents) { + return; + } + newIndex = newIndex + 1; + currentIndex = currentIndex + 1; + var referenceNodeList = masterNodeList[newIndex]; + var movedElements = can.frag(nodeLists.flatten(masterNodeList[currentIndex])); + var referenceElement; + if (currentIndex < newIndex) { + referenceElement = nodeLists.last(referenceNodeList).nextSibling; + } else { + referenceElement = nodeLists.first(referenceNodeList); + } + var parentNode = masterNodeList[0].parentNode; + parentNode.insertBefore(movedElements, referenceElement); + var temp = masterNodeList[currentIndex]; + [].splice.apply(masterNodeList, [ + currentIndex, + 1 + ]); + [].splice.apply(masterNodeList, [ + newIndex, + 0, + temp + ]); + }, text = document.createTextNode(''), list, teardownList = function (fullTeardown) { + if (list && list.unbind) { + list.unbind('add', add).unbind('remove', remove).unbind('move', move); + } + remove({}, { length: masterNodeList.length - 1 }, 0, true, fullTeardown); + }, updateList = function (ev, newList, oldList) { + if (isTornDown) { + return; + } + teardownList(); + list = newList || []; + if (list.bind) { + list.bind('add', add).bind('remove', remove).bind('move', move); + } + afterPreviousEvents = true; + add({}, list, 0); + afterPreviousEvents = false; + can.batch.afterPreviousEvents(function () { + afterPreviousEvents = true; + }); + }; + parentNode = elements.getParentNode(el, parentNode); + var data = setup(parentNode, function () { + if (can.isFunction(compute)) { + compute.bind('change', updateList); + } + }, function () { + if (can.isFunction(compute)) { + compute.unbind('change', updateList); + } + teardownList(true); + }); + if (!nodeList) { + live.replace(masterNodeList, text, data.teardownCheck); + } else { + elements.replace(masterNodeList, text); + nodeLists.update(masterNodeList, [text]); + nodeList.unregistered = function () { + data.teardownCheck(); + isTornDown = true; + }; + } + updateList({}, can.isFunction(compute) ? compute() : compute); + }, + html: function (el, compute, parentNode, nodeList) { + var data; + parentNode = elements.getParentNode(el, parentNode); + data = listen(parentNode, compute, function (ev, newVal, oldVal) { + var attached = nodeLists.first(nodes).parentNode; + if (attached) { + makeAndPut(newVal); + } + data.teardownCheck(nodeLists.first(nodes).parentNode); + }); + var nodes = nodeList || [el], makeAndPut = function (val) { + var isFunction = typeof val === 'function', aNode = isNode(val), frag = can.frag(isFunction ? '' : val), oldNodes = can.makeArray(nodes); + addTextNodeIfNoChildren(frag); + if (!aNode && !isFunction) { + frag = can.view.hookup(frag, parentNode); + } + oldNodes = nodeLists.update(nodes, frag.childNodes); + if (isFunction) { + val(frag.childNodes[0]); + } + elements.replace(oldNodes, frag); + }; + data.nodeList = nodes; + if (!nodeList) { + nodeLists.register(nodes, data.teardownCheck); + } else { + nodeList.unregistered = data.teardownCheck; + } + makeAndPut(compute()); + }, + replace: function (nodes, val, teardown) { + var oldNodes = nodes.slice(0), frag = can.frag(val); + nodeLists.register(nodes, teardown); + if (typeof val === 'string') { + frag = can.view.hookup(frag, nodes[0].parentNode); + } + nodeLists.update(nodes, frag.childNodes); + elements.replace(oldNodes, frag); + return nodes; + }, + text: function (el, compute, parentNode, nodeList) { + var parent = elements.getParentNode(el, parentNode); + var data = listen(parent, compute, function (ev, newVal, oldVal) { + if (typeof node.nodeValue !== 'unknown') { + node.nodeValue = can.view.toStr(newVal); + } + data.teardownCheck(node.parentNode); + }); + var node = document.createTextNode(can.view.toStr(compute())); + if (nodeList) { + nodeList.unregistered = data.teardownCheck; + data.nodeList = nodeList; + nodeLists.update(nodeList, [node]); + elements.replace([el], node); + } else { + data.nodeList = live.replace([el], node, data.teardownCheck); + } + }, + setAttributes: function (el, newVal) { + var attrs = getAttributeParts(newVal); + for (var name in attrs) { + can.attr.set(el, name, attrs[name]); + } + }, + attributes: function (el, compute, currentValue) { + var oldAttrs = {}; + var setAttrs = function (newVal) { + var newAttrs = getAttributeParts(newVal), name; + for (name in newAttrs) { + var newValue = newAttrs[name], oldValue = oldAttrs[name]; + if (newValue !== oldValue) { + can.attr.set(el, name, newValue); + } + delete oldAttrs[name]; + } + for (name in oldAttrs) { + elements.removeAttr(el, name); + } + oldAttrs = newAttrs; + }; + listen(el, compute, function (ev, newVal) { + setAttrs(newVal); + }); + if (arguments.length >= 3) { + oldAttrs = getAttributeParts(currentValue); + } else { + setAttrs(compute()); + } + }, + attributePlaceholder: '__!!__', + attributeReplace: /__!!__/g, + attribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, hook.render()); + }); + var wrapped = can.$(el), hooks; + hooks = can.data(wrapped, 'hooks'); + if (!hooks) { + can.data(wrapped, 'hooks', hooks = {}); + } + var attr = elements.getAttr(el, attributeName), parts = attr.split(live.attributePlaceholder), goodParts = [], hook; + goodParts.push(parts.shift(), parts.join(live.attributePlaceholder)); + if (hooks[attributeName]) { + hooks[attributeName].computes.push(compute); + } else { + hooks[attributeName] = { + render: function () { + var i = 0, newAttr = attr ? attr.replace(live.attributeReplace, function () { + return elements.contentText(hook.computes[i++]()); + }) : elements.contentText(hook.computes[i++]()); + return newAttr; + }, + computes: [compute], + batchNum: undefined + }; + } + hook = hooks[attributeName]; + goodParts.splice(1, 0, compute()); + elements.setAttr(el, attributeName, goodParts.join('')); + }, + specialAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, getValue(newVal)); + }); + elements.setAttr(el, attributeName, getValue(compute())); + }, + simpleAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, newVal); + }); + elements.setAttr(el, attributeName, compute()); + } + }; + live.attr = live.simpleAttribute; + live.attrs = live.attributes; + var newLine = /(\r|\n)+/g; + var getValue = function (val) { + var regexp = /^["'].*["']$/; + val = val.replace(elements.attrReg, '').replace(newLine, ''); + return regexp.test(val) ? val.substr(1, val.length - 2) : val; + }; + can.view.live = live; + return live; +}); +/*can@2.2.6#view/render*/ +define('can/view/render', [ + 'can/view/view', + 'can/view/elements', + 'can/view/live/live', + 'can/util/string/string' +], function (can, elements, live) { + var pendingHookups = [], tagChildren = function (tagName) { + var newTag = elements.tagMap[tagName] || 'span'; + if (newTag === 'span') { + return '@@!!@@'; + } + return '<' + newTag + '>' + tagChildren(newTag) + ''; + }, contentText = function (input, tag) { + if (typeof input === 'string') { + return input; + } + if (!input && input !== 0) { + return ''; + } + var hook = input.hookup && function (el, id) { + input.hookup.call(input, el, id); + } || typeof input === 'function' && input; + if (hook) { + if (tag) { + return '<' + tag + ' ' + can.view.hook(hook) + '>'; + } else { + pendingHookups.push(hook); + } + return ''; + } + return '' + input; + }, contentEscape = function (txt, tag) { + return typeof txt === 'string' || typeof txt === 'number' ? can.esc(txt) : contentText(txt, tag); + }, withinTemplatedSectionWithinAnElement = false, emptyHandler = function () { + }; + var lastHookups; + can.extend(can.view, { + live: live, + setupLists: function () { + var old = can.view.lists, data; + can.view.lists = function (list, renderer) { + data = { + list: list, + renderer: renderer + }; + return Math.random(); + }; + return function () { + can.view.lists = old; + return data; + }; + }, + getHooks: function () { + var hooks = pendingHookups.slice(0); + lastHookups = hooks; + pendingHookups = []; + return hooks; + }, + onlytxt: function (self, func) { + return contentEscape(func.call(self)); + }, + txt: function (escape, tagName, status, self, func) { + var tag = elements.tagMap[tagName] || 'span', setupLiveBinding = false, value, listData, compute, unbind = emptyHandler, attributeName; + if (withinTemplatedSectionWithinAnElement) { + value = func.call(self); + } else { + if (typeof status === 'string' || status === 1) { + withinTemplatedSectionWithinAnElement = true; + } + var listTeardown = can.view.setupLists(); + unbind = function () { + compute.unbind('change', emptyHandler); + }; + compute = can.compute(func, self, false); + compute.bind('change', emptyHandler); + listData = listTeardown(); + value = compute(); + withinTemplatedSectionWithinAnElement = false; + setupLiveBinding = compute.computeInstance.hasDependencies; + } + if (listData) { + unbind(); + return '<' + tag + can.view.hook(function (el, parentNode) { + live.list(el, listData.list, listData.renderer, self, parentNode); + }) + '>'; + } + if (!setupLiveBinding || typeof value === 'function') { + unbind(); + return (withinTemplatedSectionWithinAnElement || escape === 2 || !escape ? contentText : contentEscape)(value, status === 0 && tag); + } + var contentProp = elements.tagToContentPropMap[tagName]; + if (status === 0 && !contentProp) { + return '<' + tag + can.view.hook(escape && typeof value !== 'object' ? function (el, parentNode) { + live.text(el, compute, parentNode); + unbind(); + } : function (el, parentNode) { + live.html(el, compute, parentNode); + unbind(); + }) + '>' + tagChildren(tag) + ''; + } else if (status === 1) { + pendingHookups.push(function (el) { + live.attributes(el, compute, compute()); + unbind(); + }); + return compute(); + } else if (escape === 2) { + attributeName = status; + pendingHookups.push(function (el) { + live.specialAttribute(el, attributeName, compute); + unbind(); + }); + return compute(); + } else { + attributeName = status === 0 ? contentProp : status; + (status === 0 ? lastHookups : pendingHookups).push(function (el) { + live.attribute(el, attributeName, compute); + unbind(); + }); + return live.attributePlaceholder; + } + } + }); + return can; +}); +/*can@2.2.6#view/stache/utils*/ +define('can/view/stache/utils', ['can/util/util'], function () { + return { + isArrayLike: function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, + isObserveLike: function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, + emptyHandler: function () { + }, + jsonParse: function (str) { + if (str[0] === '\'') { + return str.substr(1, str.length - 2); + } else if (str === 'undefined') { + return undefined; + } else if (can.global.JSON) { + return JSON.parse(str); + } else { + return eval('(' + str + ')'); + } + }, + mixins: { + last: function () { + return this.stack[this.stack.length - 1]; + }, + add: function (chars) { + this.last().add(chars); + }, + subSectionDepth: function () { + return this.stack.length - 1; + } + } + }; +}); +/*can@2.2.6#view/stache/mustache_helpers*/ +define('can/view/stache/mustache_helpers', [ + 'can/util/util', + 'can/view/stache/utils', + 'can/view/live/live' +], function (can, utils, live) { + live = live || can.view.live; + var resolve = function (value) { + if (utils.isObserveLike(value) && utils.isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + var helpers = { + 'each': function (items, options) { + var resolved = resolve(items), result = [], keys, key, i; + if (resolved instanceof can.List) { + return function (el) { + var nodeList = [el]; + nodeList.expression = 'live.list'; + can.view.nodeLists.register(nodeList, null, options.nodeList); + can.view.nodeLists.update(options.nodeList, [el]); + var cb = function (item, index, parentNodeList) { + return options.fn(options.scope.add({ '@index': index }).add(item), options.options, parentNodeList); + }; + live.list(el, items, cb, options.context, el.parentNode, nodeList); + }; + } + var expr = resolved; + if (!!expr && utils.isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + } else if (utils.isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } + return result; + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + }, + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!resolve(expr); + } + if (value) { + return options.fn(options.scope || this); + } else { + return options.inverse(options.scope || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return helpers.is.apply(this, arguments); + }, + 'unless': function (expr, options) { + return helpers['if'].apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'with': function (expr, options) { + var ctx = expr; + expr = resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + 'data': function (attr) { + var data = arguments.length === 2 ? this : arguments[1]; + return function (el) { + can.data(can.$(el), attr, data || this.context); + }; + } + }; + return { + registerHelper: function (name, callback) { + helpers[name] = callback; + }, + getHelper: function (name, options) { + var helper = options.attr('helpers.' + name); + if (!helper) { + helper = helpers[name]; + } + if (helper) { + return { fn: helper }; + } + } + }; +}); +/*can@2.2.6#view/stache/mustache_core*/ +define('can/view/stache/mustache_core', [ + 'can/util/util', + 'can/view/stache/utils', + 'can/view/stache/mustache_helpers', + 'can/view/live/live', + 'can/view/elements', + 'can/view/scope/scope', + 'can/view/node_lists/node_lists' +], function (can, utils, mustacheHelpers, live, elements, Scope, nodeLists) { + live = live || can.view.live; + elements = elements || can.view.elements; + Scope = Scope || can.view.Scope; + nodeLists = nodeLists || can.view.nodeLists; + var argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(?:(.+?)=(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(.+))))$/, mustacheLineBreakRegExp = /(?:(?:^|(\r?)\n)(\s*)(\{\{([^\}]*)\}\}\}?)([^\S\n\r]*)($|\r?\n))|(\{\{([^\}]*)\}\}\}?)/g, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, getItemsFragContent = function (items, isObserveList, helperOptions, options) { + var frag = document.createDocumentFragment(); + for (var i = 0, len = items.length; i < len; i++) { + append(frag, helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options)); + } + return frag; + }, append = function (frag, content) { + if (content) { + frag.appendChild(typeof content === 'string' ? document.createTextNode(content) : content); + } + }, getItemsStringContent = function (items, isObserveList, helperOptions, options) { + var txt = ''; + for (var i = 0, len = items.length; i < len; i++) { + txt += helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options); + } + return txt; + }, getKeyComputeData = function (key, scope, isArgument) { + var data = scope.computeData(key, { + isArgument: isArgument, + args: [ + scope.attr('.'), + scope + ] + }); + can.compute.temporarilyBind(data.compute); + return data; + }, getKeyArgValue = function (key, scope) { + var data = getKeyComputeData(key, scope, true); + if (!data.compute.computeInstance.hasDependencies) { + return data.initialValue; + } else { + return data.compute; + } + }, convertToScopes = function (helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer) { + if (truthyRenderer) { + helperOptions.fn = makeRendererConvertScopes(truthyRenderer, scope, options, nodeList); + } + if (falseyRenderer) { + helperOptions.inverse = makeRendererConvertScopes(falseyRenderer, scope, options, nodeList); + } + }, makeRendererConvertScopes = function (renderer, parentScope, parentOptions, nodeList) { + var rendererWithScope = function (ctx, opts, parentNodeList) { + return renderer(ctx || parentScope, opts, parentNodeList); + }; + return can.__notObserve(function (newScope, newOptions, parentNodeList) { + if (newScope !== undefined && !(newScope instanceof can.view.Scope)) { + newScope = parentScope.add(newScope); + } + if (newOptions !== undefined && !(newOptions instanceof core.Options)) { + newOptions = parentOptions.add(newOptions); + } + var result = rendererWithScope(newScope, newOptions || parentOptions, parentNodeList || nodeList); + return result; + }); + }; + var core = { + expressionData: function (expression) { + var args = [], hashes = {}, i = 0; + (can.trim(expression) + ' ').replace(argumentsRegExp, function (whole, arg) { + var m; + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[1] || m[2]) { + args.push(utils.jsonParse(m[1] || m[2])); + } else { + hashes[m[3]] = m[6] ? { get: m[6] } : utils.jsonParse(m[4] || m[5]); + } + } else { + args.push({ get: arg }); + } + i++; + }); + return { + name: args.shift(), + args: args, + hash: hashes + }; + }, + makeEvaluator: function (scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, stringOnly) { + var args = [], hash = {}, helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, context = scope.attr('.'), name = exprData.name, helper, looksLikeAHelper = exprData.args.length || !can.isEmptyObject(exprData.hash), initialValue, helperEvaluator; + for (var i = 0, len = exprData.args.length; i < len; i++) { + var arg = exprData.args[i]; + if (arg && isLookup(arg)) { + args.push(getKeyArgValue(arg.get, scope, true)); + } else { + args.push(arg); + } + } + for (var prop in exprData.hash) { + if (isLookup(exprData.hash[prop])) { + hash[prop] = getKeyArgValue(exprData.hash[prop].get, scope); + } else { + hash[prop] = exprData.hash[prop]; + } + } + if (isLookup(name)) { + if (looksLikeAHelper) { + helper = mustacheHelpers.getHelper(name.get, options); + if (!helper && typeof context[name.get] === 'function') { + helper = { fn: context[name.get] }; + } + } + if (!helper) { + var get = name.get; + var computeData = getKeyComputeData(name.get, scope, false), compute = computeData.compute; + initialValue = computeData.initialValue; + if (computeData.compute.computeInstance.hasDependencies) { + name = compute; + } else { + name = initialValue; + } + if (!looksLikeAHelper && initialValue === undefined) { + helper = mustacheHelpers.getHelper(get, options); + } else if (typeof initialValue === 'function') { + helper = { fn: initialValue }; + } + } + if (!helper && initialValue === undefined) { + if (looksLikeAHelper) { + can.dev.warn('can/view/stache/mustache_core.js: Unable to find helper "' + exprData.name.get + '".'); + } else { + can.dev.warn('can/view/stache/mustache_core.js: Unable to find key or helper "' + exprData.name.get + '".'); + } + } + } + if (mode === '^') { + var temp = truthyRenderer; + truthyRenderer = falseyRenderer; + falseyRenderer = temp; + } + if (helper) { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + can.simpleExtend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash, + nodeList: nodeList, + exprData: exprData + }); + args.push(helperOptions); + helperEvaluator = function () { + return helper.fn.apply(context, args) || ''; + }; + helperEvaluator.bindOnce = false; + return helperEvaluator; + } + if (!mode) { + if (name && name.isComputed) { + return name; + } else { + return function () { + return '' + (name != null ? name : ''); + }; + } + } else if (mode === '#' || mode === '^') { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + var evaluator = function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + if (utils.isArrayLike(value)) { + var isObserveList = utils.isObserveLike(value); + if (isObserveList ? value.attr('length') : value.length) { + return (stringOnly ? getItemsStringContent : getItemsFragContent)(value, isObserveList, helperOptions, options); + } else { + return helperOptions.inverse(scope, options); + } + } else { + return value ? helperOptions.fn(value || scope, options) : helperOptions.inverse(scope, options); + } + }; + evaluator.bindOnce = false; + return evaluator; + } else { + } + }, + makeLiveBindingPartialRenderer: function (partialName, state) { + partialName = can.trim(partialName); + return function (scope, options, parentSectionNodeList) { + var nodeList = [this]; + nodeList.expression = '>' + partialName; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var partialFrag = can.compute(function () { + var localPartialName = partialName; + var partial = options.attr('partials.' + localPartialName), res; + if (partial) { + res = partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + var scopePartialName = scope.read(localPartialName, { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }).value; + if (scopePartialName) { + localPartialName = scopePartialName; + } + res = can.view.render(localPartialName, scope, options); + } + return can.frag(res); + }); + live.html(this, partialFrag, this.parentNode, nodeList); + }; + }, + makeStringBranchRenderer: function (mode, expression) { + var exprData = expressionData(expression), fullExpression = mode + expression; + return function branchRenderer(scope, options, truthyRenderer, falseyRenderer) { + var evaluator = scope.__cache[fullExpression]; + if (mode || !evaluator) { + evaluator = makeEvaluator(scope, options, null, mode, exprData, truthyRenderer, falseyRenderer, true); + if (!mode) { + scope.__cache[fullExpression] = evaluator; + } + } + var res = evaluator(); + return res == null ? '' : '' + res; + }; + }, + makeLiveBindingBranchRenderer: function (mode, expression, state) { + var exprData = expressionData(expression); + return function branchRenderer(scope, options, parentSectionNodeList, truthyRenderer, falseyRenderer) { + var nodeList = [this]; + nodeList.expression = expression; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var evaluator = makeEvaluator(scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, state.tag); + var compute = can.compute(evaluator, null, false, evaluator.bindOnce === false ? false : true); + compute.bind('change', can.k); + var value = compute(); + if (typeof value === 'function') { + var old = can.__clearReading(); + value(this); + can.__setReading(old); + } else if (compute.computeInstance.hasDependencies) { + if (state.attr) { + live.simpleAttribute(this, state.attr, compute); + } else if (state.tag) { + live.attributes(this, compute); + } else if (state.text && typeof value !== 'object') { + live.text(this, compute, this.parentNode, nodeList); + } else { + live.html(this, compute, this.parentNode, nodeList); + } + } else { + if (state.attr) { + can.attr.set(this, state.attr, value); + } else if (state.tag) { + live.setAttributes(this, value); + } else if (state.text && typeof value === 'string') { + this.nodeValue = value; + } else if (value) { + elements.replace([this], can.frag(value)); + } + } + compute.unbind('change', can.k); + }; + }, + splitModeFromExpression: function (expression, state) { + expression = can.trim(expression); + var mode = expression.charAt(0); + if ('#/{&^>!'.indexOf(mode) >= 0) { + expression = can.trim(expression.substr(1)); + } else { + mode = null; + } + if (mode === '{' && state.node) { + mode = null; + } + return { + mode: mode, + expression: expression + }; + }, + cleanLineEndings: function (template) { + return template.replace(mustacheLineBreakRegExp, function (whole, returnBefore, spaceBefore, special, expression, spaceAfter, returnAfter, spaceLessSpecial, spaceLessExpression, matchIndex) { + spaceAfter = spaceAfter || ''; + returnBefore = returnBefore || ''; + spaceBefore = spaceBefore || ''; + var modeAndExpression = splitModeFromExpression(expression || spaceLessExpression, {}); + if (spaceLessSpecial || '>{'.indexOf(modeAndExpression.mode) >= 0) { + return whole; + } else if ('^#!/'.indexOf(modeAndExpression.mode) >= 0) { + return special + (matchIndex !== 0 && returnAfter.length ? returnBefore + '\n' : ''); + } else { + return spaceBefore + special + spaceAfter + (spaceBefore.length || matchIndex !== 0 ? returnBefore + '\n' : ''); + } + }); + }, + Options: can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }) + }; + var makeEvaluator = core.makeEvaluator, expressionData = core.expressionData, splitModeFromExpression = core.splitModeFromExpression; + return core; +}); +/*can@2.2.6#view/bindings/bindings*/ +define('can/view/bindings/bindings', [ + 'can/util/util', + 'can/view/stache/mustache_core', + 'can/view/callbacks/callbacks', + 'can/control/control', + 'can/view/scope/scope' +], function (can, mustacheCore) { + var isContentEditable = function () { + var values = { + '': true, + 'true': true, + 'false': false + }; + var editable = function (el) { + if (!el || !el.getAttribute) { + return; + } + var attr = el.getAttribute('contenteditable'); + return values[attr]; + }; + return function (el) { + var val = editable(el); + if (typeof val === 'boolean') { + return val; + } else { + return !!editable(el.parentNode); + } + }; + }(), removeCurly = function (value) { + if (value[0] === '{' && value[value.length - 1] === '}') { + return value.substr(1, value.length - 2); + } + return value; + }; + can.view.attr('can-value', function (el, data) { + var attr = can.trim(removeCurly(el.getAttribute('can-value'))), value = data.scope.computeData(attr, { args: [] }).compute, trueValue, falseValue; + if (el.nodeName.toLowerCase() === 'input') { + if (el.type === 'checkbox') { + if (can.attr.has(el, 'can-true-value')) { + trueValue = el.getAttribute('can-true-value'); + } else { + trueValue = true; + } + if (can.attr.has(el, 'can-false-value')) { + falseValue = el.getAttribute('can-false-value'); + } else { + falseValue = false; + } + } + if (el.type === 'checkbox' || el.type === 'radio') { + new Checked(el, { + value: value, + trueValue: trueValue, + falseValue: falseValue + }); + return; + } + } + if (el.nodeName.toLowerCase() === 'select' && el.multiple) { + new Multiselect(el, { value: value }); + return; + } + if (isContentEditable(el)) { + new Content(el, { value: value }); + return; + } + new Value(el, { value: value }); + }); + var special = { + enter: function (data, el, original) { + return { + event: 'keyup', + handler: function (ev) { + if (ev.keyCode === 13) { + return original.call(this, ev); + } + } + }; + } + }; + can.view.attr(/can-[\w\.]+/, function (el, data) { + var attributeName = data.attributeName, event = attributeName.substr('can-'.length), handler = function (ev) { + var attrVal = el.getAttribute(attributeName); + if (!attrVal) { + return; + } + var attrInfo = mustacheCore.expressionData(removeCurly(attrVal)); + var scopeData = data.scope.read(attrInfo.name.get, { + returnObserveMethods: true, + isArgument: true, + executeAnonymousFunctions: true + }); + if (!scopeData.value) { + can.dev.warn('can/view/bindings: ' + attributeName + ' couldn\'t find method named ' + attrInfo.name.get, { + element: el, + scope: data.scope + }); + return null; + } + var args = []; + var $el = can.$(this); + var viewModel = can.viewModel($el[0]); + var localScope = data.scope.add({ + '@element': $el, + '@event': ev, + '@viewModel': viewModel, + '@scope': data.scope, + '@context': data.scope._context + }); + if (!can.isEmptyObject(attrInfo.hash)) { + var hash = {}; + can.each(attrInfo.hash, function (val, key) { + if (val && val.hasOwnProperty('get')) { + var s = !val.get.indexOf('@') ? localScope : data.scope; + hash[key] = s.read(val.get, {}).value; + } else { + hash[key] = val; + } + }); + args.unshift(hash); + } + if (attrInfo.args.length) { + var arg; + for (var i = attrInfo.args.length - 1; i >= 0; i--) { + arg = attrInfo.args[i]; + if (arg && arg.hasOwnProperty('get')) { + var s = !arg.get.indexOf('@') ? localScope : data.scope; + args.unshift(s.read(arg.get, {}).value); + } else { + args.unshift(arg); + } + } + } + if (!args.length) { + args = [ + data.scope._context, + $el + ].concat(can.makeArray(arguments)); + } + return scopeData.value.apply(scopeData.parent, args); + }; + if (special[event]) { + var specialData = special[event](data, el, handler); + handler = specialData.handler; + event = specialData.event; + } + can.bind.call(el, event, handler); + }); + var Value = can.Control.extend({ + init: function () { + if (this.element[0].nodeName.toUpperCase() === 'SELECT') { + setTimeout(can.proxy(this.set, this), 1); + } else { + this.set(); + } + }, + '{value} change': 'set', + set: function () { + if (!this.element) { + return; + } + var val = this.options.value(); + this.element[0].value = val == null ? '' : val; + }, + 'change': function () { + if (!this.element) { + return; + } + var el = this.element[0]; + this.options.value(el.value); + var newVal = this.options.value(); + if (el.value !== newVal) { + el.value = newVal; + } + } + }), Checked = can.Control.extend({ + init: function () { + this.isCheckbox = this.element[0].type.toLowerCase() === 'checkbox'; + this.check(); + }, + '{value} change': 'check', + check: function () { + if (this.isCheckbox) { + var value = this.options.value(), trueValue = this.options.trueValue || true; + this.element[0].checked = value == trueValue; + } else { + var setOrRemove = this.options.value() == this.element[0].value ? 'set' : 'remove'; + can.attr[setOrRemove](this.element[0], 'checked', true); + } + }, + 'change': function () { + if (this.isCheckbox) { + this.options.value(this.element[0].checked ? this.options.trueValue : this.options.falseValue); + } else { + if (this.element[0].checked) { + this.options.value(this.element[0].value); + } + } + } + }), Multiselect = Value.extend({ + init: function () { + this.delimiter = ';'; + setTimeout(can.proxy(this.set, this), 1); + }, + set: function () { + var newVal = this.options.value(); + if (typeof newVal === 'string') { + newVal = newVal.split(this.delimiter); + this.isString = true; + } else if (newVal) { + newVal = can.makeArray(newVal); + } + var isSelected = {}; + can.each(newVal, function (val) { + isSelected[val] = true; + }); + can.each(this.element[0].childNodes, function (option) { + if (option.value) { + option.selected = !!isSelected[option.value]; + } + }); + }, + get: function () { + var values = [], children = this.element[0].childNodes; + can.each(children, function (child) { + if (child.selected && child.value) { + values.push(child.value); + } + }); + return values; + }, + 'change': function () { + var value = this.get(), currentValue = this.options.value(); + if (this.isString || typeof currentValue === 'string') { + this.isString = true; + this.options.value(value.join(this.delimiter)); + } else if (currentValue instanceof can.List) { + currentValue.attr(value, true); + } else { + this.options.value(value); + } + } + }), Content = can.Control.extend({ + init: function () { + this.set(); + this.on('blur', 'setValue'); + }, + '{value} change': 'set', + set: function () { + var val = this.options.value(); + this.element[0].innerHTML = typeof val === 'undefined' ? '' : val; + }, + setValue: function () { + this.options.value(this.element[0].innerHTML); + } + }); +}); +/*can@2.2.6#view/mustache/mustache*/ +define('can/view/mustache/mustache', [ + 'can/util/util', + 'can/view/scope/scope', + 'can/view/view', + 'can/view/scanner', + 'can/compute/compute', + 'can/view/render', + 'can/view/bindings/bindings' +], function (can) { + can.view.ext = '.mustache'; + var SCOPE = 'scope', HASH = '___h4sh', CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options}', SPECIAL_CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options, special: true}', ARG_NAMES = SCOPE + ',options', argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false|null|undefined)|((.+?)=(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false)|(.+))))$/, makeLookupLiteral = function (type) { + return '{get:"' + type.replace(/"/g, '\\"') + '"}'; + }, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, isObserveLike = function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, isArrayLike = function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, makeConvertToScopes = function (original, scope, options) { + var originalWithScope = function (ctx, opts) { + return original(ctx || scope, opts); + }; + return function (updatedScope, updatedOptions) { + if (updatedScope !== undefined && !(updatedScope instanceof can.view.Scope)) { + updatedScope = scope.add(updatedScope); + } + if (updatedOptions !== undefined && !(updatedOptions instanceof can.view.Options)) { + updatedOptions = options.add(updatedOptions); + } + return originalWithScope(updatedScope, updatedOptions || options); + }; + }; + var Mustache = function (options, helpers) { + if (this.constructor !== Mustache) { + var mustache = new Mustache(options); + return function (data, options) { + return mustache.render(data, options); + }; + } + if (typeof options === 'function') { + this.template = { fn: options }; + return; + } + can.extend(this, options); + this.template = this.scanner.scan(this.text, this.name); + }; + can.Mustache = can.global.Mustache = Mustache; + Mustache.prototype.render = function (data, options) { + if (!(data instanceof can.view.Scope)) { + data = new can.view.Scope(data || {}); + } + if (!(options instanceof can.view.Options)) { + options = new can.view.Options(options || {}); + } + options = options || {}; + return this.template.fn.call(data, data, options); + }; + can.extend(Mustache.prototype, { + scanner: new can.view.Scanner({ + text: { + start: '', + scope: SCOPE, + options: ',options: options', + argNames: ARG_NAMES + }, + tokens: [ + [ + 'returnLeft', + '{{{', + '{{[{&]' + ], + [ + 'commentFull', + '{{!}}', + '^[\\s\\t]*{{!.+?}}\\n' + ], + [ + 'commentLeft', + '{{!', + '(\\n[\\s\\t]*{{!|{{!)' + ], + [ + 'escapeFull', + '{{}}', + '(^[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}$)', + function (content) { + return { + before: /^\n.+?\n$/.test(content) ? '\n' : '', + content: content.match(/\{\{(.+?)\}\}/)[1] || '' + }; + } + ], + [ + 'escapeLeft', + '{{' + ], + [ + 'returnRight', + '}}}' + ], + [ + 'right', + '}}' + ] + ], + helpers: [ + { + name: /^>[\s]*\w*/, + fn: function (content, cmd) { + var templateName = can.trim(content.replace(/^>\s?/, '')).replace(/["|']/g, ''); + return 'can.Mustache.renderPartial(\'' + templateName + '\',' + ARG_NAMES + ')'; + } + }, + { + name: /^\s*data\s/, + fn: function (content, cmd) { + var attr = content.match(/["|'](.*)["|']/)[1]; + return 'can.proxy(function(__){' + 'can.data(can.$(__),\'' + attr + '\', this.attr(\'.\')); }, ' + SCOPE + ')'; + } + }, + { + name: /\s*\(([\$\w]+)\)\s*->([^\n]*)/, + fn: function (content) { + var quickFunc = /\s*\(([\$\w]+)\)\s*->([^\n]*)/, parts = content.match(quickFunc); + return 'can.proxy(function(__){var ' + parts[1] + '=can.$(__);with(' + SCOPE + '.attr(\'.\')){' + parts[2] + '}}, this);'; + } + }, + { + name: /^.*$/, + fn: function (content, cmd) { + var mode = false, result = { + content: '', + startTxt: false, + startOnlyTxt: false, + end: false + }; + content = can.trim(content); + if (content.length && (mode = content.match(/^([#^\/]|else$)/))) { + mode = mode[0]; + switch (mode) { + case '#': + case '^': + if (cmd.specialAttribute) { + result.startOnlyTxt = true; + } else { + result.startTxt = true; + result.escaped = 0; + } + break; + case '/': + result.end = true; + result.content += 'return ___v1ew.join("");}}])'; + return result; + } + content = content.substring(1); + } + if (mode !== 'else') { + var args = [], hashes = [], i = 0, m; + result.content += 'can.Mustache.txt(\n' + (cmd.specialAttribute ? SPECIAL_CONTEXT_OBJ : CONTEXT_OBJ) + ',\n' + (mode ? '"' + mode + '"' : 'null') + ','; + (can.trim(content) + ' ').replace(argumentsRegExp, function (whole, arg) { + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[2]) { + args.push(m[0]); + } else { + hashes.push(m[4] + ':' + (m[6] ? m[6] : makeLookupLiteral(m[5]))); + } + } else { + args.push(makeLookupLiteral(arg)); + } + i++; + }); + result.content += args.join(','); + if (hashes.length) { + result.content += ',{' + HASH + ':{' + hashes.join(',') + '}}'; + } + } + if (mode && mode !== 'else') { + result.content += ',[\n\n'; + } + switch (mode) { + case '^': + case '#': + result.content += '{fn:function(' + ARG_NAMES + '){var ___v1ew = [];'; + break; + case 'else': + result.content += 'return ___v1ew.join("");}},\n{inverse:function(' + ARG_NAMES + '){\nvar ___v1ew = [];'; + break; + default: + result.content += ')'; + break; + } + if (!mode) { + result.startTxt = true; + result.end = true; + } + return result; + } + } + ] + }) + }); + var helpers = can.view.Scanner.prototype.helpers; + for (var i = 0; i < helpers.length; i++) { + Mustache.prototype.scanner.helpers.unshift(helpers[i]); + } + Mustache.txt = function (scopeAndOptions, mode, name) { + var scope = scopeAndOptions.scope, options = scopeAndOptions.options, args = [], helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, hash, context = scope.attr('.'), getHelper = true, helper; + for (var i = 3; i < arguments.length; i++) { + var arg = arguments[i]; + if (mode && can.isArray(arg)) { + helperOptions = can.extend.apply(can, [helperOptions].concat(arg)); + } else if (arg && arg[HASH]) { + hash = arg[HASH]; + for (var prop in hash) { + if (isLookup(hash[prop])) { + hash[prop] = Mustache.get(hash[prop].get, scopeAndOptions, false, true); + } + } + } else if (arg && isLookup(arg)) { + args.push(Mustache.get(arg.get, scopeAndOptions, false, true, true)); + } else { + args.push(arg); + } + } + if (isLookup(name)) { + var get = name.get; + name = Mustache.get(name.get, scopeAndOptions, args.length, false); + getHelper = get === name; + } + helperOptions.fn = makeConvertToScopes(helperOptions.fn, scope, options); + helperOptions.inverse = makeConvertToScopes(helperOptions.inverse, scope, options); + if (mode === '^') { + var tmp = helperOptions.fn; + helperOptions.fn = helperOptions.inverse; + helperOptions.inverse = tmp; + } + if (helper = getHelper && (typeof name === 'string' && Mustache.getHelper(name, options)) || can.isFunction(name) && !name.isComputed && { fn: name }) { + can.extend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash + }); + args.push(helperOptions); + return function () { + return helper.fn.apply(context, args) || ''; + }; + } + return function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + var validArgs = args.length ? args : [value], valid = true, result = [], i, argIsObserve, arg; + if (mode) { + for (i = 0; i < validArgs.length; i++) { + arg = validArgs[i]; + argIsObserve = typeof arg !== 'undefined' && isObserveLike(arg); + if (isArrayLike(arg)) { + if (mode === '#') { + valid = valid && !!(argIsObserve ? arg.attr('length') : arg.length); + } else if (mode === '^') { + valid = valid && !(argIsObserve ? arg.attr('length') : arg.length); + } + } else { + valid = mode === '#' ? valid && !!arg : mode === '^' ? valid && !arg : valid; + } + } + } + if (valid) { + if (mode === '#') { + if (isArrayLike(value)) { + var isObserveList = isObserveLike(value); + for (i = 0; i < value.length; i++) { + result.push(helperOptions.fn(isObserveList ? value.attr('' + i) : value[i])); + } + return result.join(''); + } else { + return helperOptions.fn(value || {}) || ''; + } + } else if (mode === '^') { + return helperOptions.inverse(value || {}) || ''; + } else { + return '' + (value != null ? value : ''); + } + } + return ''; + }; + }; + Mustache.get = function (key, scopeAndOptions, isHelper, isArgument, isLookup) { + var context = scopeAndOptions.scope.attr('.'), options = scopeAndOptions.options || {}; + if (isHelper) { + if (Mustache.getHelper(key, options)) { + return key; + } + if (scopeAndOptions.scope && can.isFunction(context[key])) { + return context[key]; + } + can.dev.warn('can/view/mustache/mustache.js: Unable to find helper "' + key + '".'); + } + var computeData = scopeAndOptions.scope.computeData(key, { + isArgument: isArgument, + args: [ + context, + scopeAndOptions.scope + ] + }), compute = computeData.compute; + can.compute.temporarilyBind(compute); + var initialValue = computeData.initialValue, helperObj = Mustache.getHelper(key, options); + if (initialValue === undefined && !isHelper && !helperObj) { + can.dev.warn('can/view/mustache/mustache.js: Unable to find key "' + key + '".'); + } + if (!isLookup && (initialValue === undefined || computeData.scope !== scopeAndOptions.scope) && Mustache.getHelper(key, options)) { + return key; + } + if (!compute.computeInstance.hasDependencies) { + return initialValue; + } else { + return compute; + } + }; + Mustache.resolve = function (value) { + if (isObserveLike(value) && isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + can.view.Options = can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }); + Mustache._helpers = {}; + Mustache.registerHelper = function (name, fn) { + this._helpers[name] = { + name: name, + fn: fn + }; + }; + Mustache.getHelper = function (name, options) { + var helper; + if (options) { + helper = options.attr('helpers.' + name); + } + return helper ? { fn: helper } : this._helpers[name]; + }; + Mustache.render = function (partial, scope, options) { + if (!can.view.cached[partial]) { + var reads = can.__clearReading(); + var scopePartialName = scope.attr(partial); + if (scopePartialName) { + partial = scopePartialName; + } + can.__setReading(reads); + } + return can.view.render(partial, scope, options); + }; + Mustache.safeString = function (str) { + return { + toString: function () { + return str; + } + }; + }; + Mustache.renderPartial = function (partialName, scope, options) { + var partial = options.attr('partials.' + partialName); + if (partial) { + return partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + return can.Mustache.render(partialName, scope, options); + } + }; + can.each({ + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!Mustache.resolve(expr); + } + if (value) { + return options.fn(options.contexts || this); + } else { + return options.inverse(options.contexts || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = Mustache.resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return Mustache._helpers.is.fn.apply(this, arguments); + }, + 'unless': function (expr, options) { + return Mustache._helpers['if'].fn.apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'each': function (expr, options) { + var resolved = Mustache.resolve(expr), result = [], keys, key, i; + if (can.view.lists && (resolved instanceof can.List || expr && expr.isComputed && resolved === undefined)) { + return can.view.lists(expr, function (item, index) { + return options.fn(options.scope.add({ '@index': index }).add(item)); + }); + } + expr = resolved; + if (!!expr && isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + return result.join(''); + } else if (isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } + }, + 'with': function (expr, options) { + var ctx = expr; + expr = Mustache.resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + } + }, function (fn, name) { + Mustache.registerHelper(name, fn); + }); + can.view.register({ + suffix: 'mustache', + contentType: 'x-mustache-template', + script: function (id, src) { + return 'can.Mustache(function(' + ARG_NAMES + ') { ' + new Mustache({ + text: src, + name: id + }).template.out + ' })'; + }, + renderer: function (id, text) { + return Mustache({ + text: text, + name: id + }); + } + }); + can.mustache.registerHelper = can.proxy(can.Mustache.registerHelper, can.Mustache); + can.mustache.safeString = can.Mustache.safeString; + return can; +}); +/*can@2.2.6#component/component*/ +define('can/component/component', [ + 'can/util/util', + 'can/view/callbacks/callbacks', + 'can/view/elements', + 'can/control/control', + 'can/observe/observe', + 'can/view/mustache/mustache', + 'can/view/bindings/bindings' +], function (can, viewCallbacks, elements) { + var ignoreAttributesRegExp = /^(dataViewId|class|id)$/i, paramReplacer = /\{([^\}]+)\}/g; + var Component = can.Component = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Component) { + var self = this, scope = this.prototype.scope || this.prototype.viewModel; + this.Control = ComponentControl.extend(this.prototype.events); + if (!scope || typeof scope === 'object' && !(scope instanceof can.Map)) { + this.Map = can.Map.extend(scope || {}); + } else if (scope.prototype instanceof can.Map) { + this.Map = scope; + } + this.attributeScopeMappings = {}; + can.each(this.Map ? this.Map.defaults : {}, function (val, prop) { + if (val === '@') { + self.attributeScopeMappings[prop] = prop; + } + }); + if (this.prototype.template) { + if (typeof this.prototype.template === 'function') { + var temp = this.prototype.template; + this.renderer = function () { + return can.view.frag(temp.apply(null, arguments)); + }; + } else { + this.renderer = can.view.mustache(this.prototype.template); + } + } + can.view.tag(this.prototype.tag, function (el, options) { + new self(el, options); + }); + } + } + }, { + setup: function (el, hookupOptions) { + var initialScopeData = {}, component = this, lexicalContent = (typeof this.leakScope === 'undefined' ? false : !this.leakScope) && this.template, twoWayBindings = {}, scope = this.scope || this.viewModel, viewModelPropertyUpdates = {}, componentScope, frag, teardownFunctions = [], callTeardownFunctions = function () { + for (var i = 0, len = teardownFunctions.length; i < len; i++) { + teardownFunctions[i](); + } + }; + can.each(this.constructor.attributeScopeMappings, function (val, prop) { + initialScopeData[prop] = el.getAttribute(can.hyphenate(val)); + }); + can.each(can.makeArray(el.attributes), function (node, index) { + var name = can.camelize(node.nodeName.toLowerCase()), value = node.value; + if (ignoreAttributesRegExp.test(name) && value[0] === '{' && value[value.length - 1] === '}') { + can.dev.warn('can/component: looks like you\'re trying to pass ' + name + ' as an attribute into a component, ' + 'but it is not a supported attribute'); + } + if (component.constructor.attributeScopeMappings[name] || ignoreAttributesRegExp.test(name) || viewCallbacks.attr(node.nodeName)) { + return; + } + if (value[0] === '{' && value[value.length - 1] === '}') { + value = value.substr(1, value.length - 2); + } else { + if (hookupOptions.templateType !== 'legacy') { + initialScopeData[name] = value; + return; + } + } + var computeData = hookupOptions.scope.computeData(value, { args: [] }), compute = computeData.compute; + var handler = function (ev, newVal) { + viewModelPropertyUpdates[name] = (viewModelPropertyUpdates[name] || 0) + 1; + componentScope.attr(name, newVal); + can.batch.afterPreviousEvents(function () { + --viewModelPropertyUpdates[name]; + }); + }; + compute.bind('change', handler); + initialScopeData[name] = compute(); + if (!compute.computeInstance.hasDependencies) { + compute.unbind('change', handler); + } else { + teardownFunctions.push(function () { + compute.unbind('change', handler); + }); + twoWayBindings[name] = computeData; + } + }); + if (this.constructor.Map) { + componentScope = new this.constructor.Map(initialScopeData); + } else if (scope instanceof can.Map) { + componentScope = scope; + } else if (can.isFunction(scope)) { + var scopeResult = scope.call(this, initialScopeData, hookupOptions.scope, el); + if (scopeResult instanceof can.Map) { + componentScope = scopeResult; + } else if (scopeResult.prototype instanceof can.Map) { + componentScope = new scopeResult(initialScopeData); + } else { + componentScope = new (can.Map.extend(scopeResult))(initialScopeData); + } + } + var handlers = {}; + can.each(twoWayBindings, function (computeData, prop) { + handlers[prop] = function (ev, newVal) { + if (!viewModelPropertyUpdates[prop]) { + computeData.compute(newVal); + } + }; + componentScope.bind(prop, handlers[prop]); + }); + if (!can.isEmptyObject(this.constructor.attributeScopeMappings) || hookupOptions.templateType !== 'legacy') { + can.bind.call(el, 'attributes', function (ev) { + var camelized = can.camelize(ev.attributeName); + if (!twoWayBindings[camelized] && !ignoreAttributesRegExp.test(camelized)) { + componentScope.attr(camelized, el.getAttribute(ev.attributeName)); + } + }); + } + this.scope = this.viewModel = componentScope; + can.data(can.$(el), 'scope', this.scope); + can.data(can.$(el), 'viewModel', this.scope); + var renderedScope = lexicalContent ? this.scope : hookupOptions.scope.add(this.scope), options = { helpers: {} }; + can.each(this.helpers || {}, function (val, prop) { + if (can.isFunction(val)) { + options.helpers[prop] = function () { + return val.apply(componentScope, arguments); + }; + } + }); + teardownFunctions.push(function () { + can.each(handlers, function (handler, prop) { + componentScope.unbind(prop, handlers[prop]); + }); + }); + this._control = new this.constructor.Control(el, { + scope: this.scope, + viewModel: this.scope + }); + if (this._control && this._control.destroy) { + var oldDestroy = this._control.destroy; + this._control.destroy = function () { + oldDestroy.apply(this, arguments); + callTeardownFunctions(); + }; + this._control.on(); + } else { + can.bind.call(el, 'removed', function () { + callTeardownFunctions(); + }); + } + var nodeList = can.view.nodeLists.register([], undefined, true); + teardownFunctions.push(function () { + can.view.nodeLists.unregister(nodeList); + }); + if (this.constructor.renderer) { + if (!options.tags) { + options.tags = {}; + } + options.tags.content = function contentHookup(el, rendererOptions) { + var subtemplate = hookupOptions.subtemplate || rendererOptions.subtemplate; + if (subtemplate) { + delete options.tags.content; + var opts = !lexicalContent || subtemplate !== hookupOptions.subtemplate ? rendererOptions : hookupOptions; + if (rendererOptions.parentNodeList) { + var frag = subtemplate(opts.scope, opts.options, rendererOptions.parentNodeList); + elements.replace([el], frag); + } else { + can.view.live.replace([el], subtemplate(opts.scope, opts.options)); + } + options.tags.content = contentHookup; + } + }; + frag = this.constructor.renderer(renderedScope, hookupOptions.options.add(options), nodeList); + } else { + if (hookupOptions.templateType === 'legacy') { + frag = can.view.frag(hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options)) : ''); + } else { + frag = hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options), nodeList) : document.createDocumentFragment(); + } + } + can.appendChild(el, frag); + can.view.nodeLists.update(nodeList, el.childNodes); + } + }); + var ComponentControl = can.Control.extend({ + _lookup: function (options) { + return [ + options.scope, + options, + window + ]; + }, + _action: function (methodName, options, controlInstance) { + var hasObjectLookup, readyCompute; + paramReplacer.lastIndex = 0; + hasObjectLookup = paramReplacer.test(methodName); + if (!controlInstance && hasObjectLookup) { + return; + } else if (!hasObjectLookup) { + return can.Control._action.apply(this, arguments); + } else { + readyCompute = can.compute(function () { + var delegate; + var name = methodName.replace(paramReplacer, function (matched, key) { + var value; + if (key === 'scope' || key === 'viewModel') { + delegate = options.scope; + return ''; + } + key = key.replace(/^(scope|^viewModel)\./, ''); + value = can.compute.read(options.scope, key.split('.'), { isArgument: true }).value; + if (value === undefined) { + value = can.getObject(key); + } + if (typeof value === 'string') { + return value; + } else { + delegate = value; + return ''; + } + }); + var parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: this.processors[event] || this.processors.click, + parts: [ + name, + parts.join(' '), + event + ], + delegate: delegate || undefined + }; + }, this); + var handler = function (ev, ready) { + controlInstance._bindings.control[methodName](controlInstance.element); + controlInstance._bindings.control[methodName] = ready.processor(ready.delegate || controlInstance.element, ready.parts[2], ready.parts[1], methodName, controlInstance); + }; + readyCompute.bind('change', handler); + controlInstance._bindings.readyComputes[methodName] = { + compute: readyCompute, + handler: handler + }; + return readyCompute(); + } + } + }, { + setup: function (el, options) { + this.scope = options.scope; + this.viewModel = options.viewModel; + return can.Control.prototype.setup.call(this, el, options); + }, + off: function () { + if (this._bindings) { + can.each(this._bindings.readyComputes || {}, function (value) { + value.compute.unbind('change', value.handler); + }); + } + can.Control.prototype.off.apply(this, arguments); + this._bindings.readyComputes = {}; + } + }); + var $ = can.$; + if ($.fn) { + $.fn.scope = $.fn.viewModel = function () { + return can.viewModel.apply(can, [this].concat(can.makeArray(arguments))); + }; + } + return Component; +}); +/*can@2.2.6#model/model*/ +define('can/model/model', [ + 'can/util/util', + 'can/map/map', + 'can/list/list' +], function (can) { + var pipe = function (def, thisArg, func) { + var d = new can.Deferred(); + def.then(function () { + var args = can.makeArray(arguments), success = true; + try { + args[0] = func.apply(thisArg, args); + } catch (e) { + success = false; + d.rejectWith(d, [e].concat(args)); + } + if (success) { + d.resolveWith(d, args); + } + }, function () { + d.rejectWith(this, arguments); + }); + if (typeof def.abort === 'function') { + d.abort = function () { + return def.abort(); + }; + } + return d; + }, modelNum = 0, getId = function (inst) { + can.__observe(inst, inst.constructor.id); + return inst.__get(inst.constructor.id); + }, ajax = function (ajaxOb, data, type, dataType, success, error) { + var params = {}; + if (typeof ajaxOb === 'string') { + var parts = ajaxOb.split(/\s+/); + params.url = parts.pop(); + if (parts.length) { + params.type = parts.pop(); + } + } else { + can.extend(params, ajaxOb); + } + params.data = typeof data === 'object' && !can.isArray(data) ? can.extend(params.data || {}, data) : data; + params.url = can.sub(params.url, params.data, true); + return can.ajax(can.extend({ + type: type || 'post', + dataType: dataType || 'json', + success: success, + error: error + }, params)); + }, makeRequest = function (modelObj, type, success, error, method) { + var args; + if (can.isArray(modelObj)) { + args = modelObj[1]; + modelObj = modelObj[0]; + } else { + args = modelObj.serialize(); + } + args = [args]; + var deferred, model = modelObj.constructor, jqXHR; + if (type === 'update' || type === 'destroy') { + args.unshift(getId(modelObj)); + } + jqXHR = model[type].apply(model, args); + deferred = pipe(jqXHR, modelObj, function (data) { + modelObj[method || type + 'd'](data, jqXHR); + return modelObj; + }); + if (jqXHR.abort) { + deferred.abort = function () { + jqXHR.abort(); + }; + } + deferred.then(success, error); + return deferred; + }, converters = { + models: function (instancesRawData, oldList, xhr) { + can.Model._reqs++; + if (!instancesRawData) { + return; + } + if (instancesRawData instanceof this.List) { + return instancesRawData; + } + var self = this, tmp = [], ListClass = self.List || ML, modelList = oldList instanceof can.List ? oldList : new ListClass(), rawDataIsList = instancesRawData instanceof ML, raw = rawDataIsList ? instancesRawData.serialize() : instancesRawData; + raw = self.parseModels(raw, xhr); + if (raw.data) { + instancesRawData = raw; + raw = raw.data; + } + if (typeof raw === 'undefined' || !can.isArray(raw)) { + throw new Error('Could not get any raw data while converting using .models'); + } + if (!raw.length) { + can.dev.warn('model.js models has no data.'); + } + if (modelList.length) { + modelList.splice(0); + } + can.each(raw, function (rawPart) { + tmp.push(self.model(rawPart, xhr)); + }); + modelList.push.apply(modelList, tmp); + if (!can.isArray(instancesRawData)) { + can.each(instancesRawData, function (val, prop) { + if (prop !== 'data') { + modelList.attr(prop, val); + } + }); + } + setTimeout(can.proxy(this._clean, this), 1); + return modelList; + }, + model: function (attributes, oldModel, xhr) { + if (!attributes) { + return; + } + if (typeof attributes.serialize === 'function') { + attributes = attributes.serialize(); + } else { + attributes = this.parseModel(attributes, xhr); + } + var id = attributes[this.id]; + if ((id || id === 0) && this.store[id]) { + oldModel = this.store[id]; + } + var model = oldModel && can.isFunction(oldModel.attr) ? oldModel.attr(attributes, this.removeAttr || false) : new this(attributes); + return model; + } + }, makeParser = { + parseModel: function (prop) { + return function (attributes) { + return prop ? can.getObject(prop, attributes) : attributes; + }; + }, + parseModels: function (prop) { + return function (attributes) { + if (can.isArray(attributes)) { + return attributes; + } + prop = prop || 'data'; + var result = can.getObject(prop, attributes); + if (!can.isArray(result)) { + throw new Error('Could not get any raw data while converting using .models'); + } + return result; + }; + } + }, ajaxMethods = { + create: { + url: '_shortName', + type: 'post' + }, + update: { + data: function (id, attrs) { + attrs = attrs || {}; + var identity = this.id; + if (attrs[identity] && attrs[identity] !== id) { + attrs['new' + can.capitalize(id)] = attrs[identity]; + delete attrs[identity]; + } + attrs[identity] = id; + return attrs; + }, + type: 'put' + }, + destroy: { + type: 'delete', + data: function (id, attrs) { + attrs = attrs || {}; + attrs.id = attrs[this.id] = id; + return attrs; + } + }, + findAll: { url: '_shortName' }, + findOne: {} + }, ajaxMaker = function (ajaxMethod, str) { + return function (data) { + data = ajaxMethod.data ? ajaxMethod.data.apply(this, arguments) : data; + return ajax(str || this[ajaxMethod.url || '_url'], data, ajaxMethod.type || 'get'); + }; + }, createURLFromResource = function (model, name) { + if (!model.resource) { + return; + } + var resource = model.resource.replace(/\/+$/, ''); + if (name === 'findAll' || name === 'create') { + return resource; + } else { + return resource + '/{' + model.id + '}'; + } + }; + can.Model = can.Map.extend({ + fullName: 'can.Model', + _reqs: 0, + setup: function (base, fullName, staticProps, protoProps) { + if (typeof fullName !== 'string') { + protoProps = staticProps; + staticProps = fullName; + } + if (!protoProps) { + can.dev.warn('can/model/model.js: can.Model extended without static properties.'); + protoProps = staticProps; + } + this.store = {}; + can.Map.setup.apply(this, arguments); + if (!can.Model) { + return; + } + if (staticProps && staticProps.List) { + this.List = staticProps.List; + this.List.Map = this; + } else { + this.List = base.List.extend({ Map: this }, {}); + } + var self = this, clean = can.proxy(this._clean, self); + can.each(ajaxMethods, function (method, name) { + if (staticProps && staticProps[name] && (typeof staticProps[name] === 'string' || typeof staticProps[name] === 'object')) { + self[name] = ajaxMaker(method, staticProps[name]); + } else if (staticProps && staticProps.resource && !can.isFunction(staticProps[name])) { + self[name] = ajaxMaker(method, createURLFromResource(self, name)); + } + if (self['make' + can.capitalize(name)]) { + var newMethod = self['make' + can.capitalize(name)](self[name]); + can.Construct._overwrite(self, base, name, function () { + can.Model._reqs++; + var def = newMethod.apply(this, arguments); + var then = def.then(clean, clean); + then.abort = def.abort; + return then; + }); + } + }); + var hasCustomConverter = {}; + can.each(converters, function (converter, name) { + var parseName = 'parse' + can.capitalize(name), dataProperty = staticProps && staticProps[name] || self[name]; + if (typeof dataProperty === 'string') { + self[parseName] = dataProperty; + can.Construct._overwrite(self, base, name, converter); + } else if (staticProps && staticProps[name]) { + hasCustomConverter[parseName] = true; + } + }); + can.each(makeParser, function (maker, parseName) { + var prop = staticProps && staticProps[parseName] || self[parseName]; + if (typeof prop === 'string') { + can.Construct._overwrite(self, base, parseName, maker(prop)); + } else if ((!staticProps || !can.isFunction(staticProps[parseName])) && !self[parseName]) { + var madeParser = maker(); + madeParser.useModelConverter = hasCustomConverter[parseName]; + can.Construct._overwrite(self, base, parseName, madeParser); + } + }); + if (self.fullName === 'can.Model' || !self.fullName) { + self.fullName = 'Model' + ++modelNum; + } + can.Model._reqs = 0; + this._url = this._shortName + '/{' + this.id + '}'; + }, + _ajax: ajaxMaker, + _makeRequest: makeRequest, + _clean: function () { + can.Model._reqs--; + if (!can.Model._reqs) { + for (var id in this.store) { + if (!this.store[id]._bindings) { + delete this.store[id]; + } + } + } + return arguments[0]; + }, + models: converters.models, + model: converters.model + }, { + setup: function (attrs) { + var id = attrs && attrs[this.constructor.id]; + if (can.Model._reqs && id != null) { + this.constructor.store[id] = this; + } + can.Map.prototype.setup.apply(this, arguments); + }, + isNew: function () { + var id = getId(this); + return !(id || id === 0); + }, + save: function (success, error) { + return makeRequest(this, this.isNew() ? 'create' : 'update', success, error); + }, + destroy: function (success, error) { + if (this.isNew()) { + var self = this; + var def = can.Deferred(); + def.then(success, error); + return def.done(function (data) { + self.destroyed(data); + }).resolve(self); + } + return makeRequest(this, 'destroy', success, error, 'destroyed'); + }, + _bindsetup: function () { + var modelInstance = this.__get(this.constructor.id); + if (modelInstance != null) { + this.constructor.store[modelInstance] = this; + } + return can.Map.prototype._bindsetup.apply(this, arguments); + }, + _bindteardown: function () { + delete this.constructor.store[getId(this)]; + return can.Map.prototype._bindteardown.apply(this, arguments); + }, + ___set: function (prop, val) { + can.Map.prototype.___set.call(this, prop, val); + if (prop === this.constructor.id && this._bindings) { + this.constructor.store[getId(this)] = this; + } + } + }); + var makeGetterHandler = function (name) { + return function (data, readyState, xhr) { + return this[name](data, null, xhr); + }; + }, createUpdateDestroyHandler = function (data) { + if (this.parseModel.useModelConverter) { + return this.model(data); + } + return this.parseModel(data); + }; + var responseHandlers = { + makeFindAll: makeGetterHandler('models'), + makeFindOne: makeGetterHandler('model'), + makeCreate: createUpdateDestroyHandler, + makeUpdate: createUpdateDestroyHandler, + makeDestroy: createUpdateDestroyHandler + }; + can.each(responseHandlers, function (method, name) { + can.Model[name] = function (oldMethod) { + return function () { + var args = can.makeArray(arguments), oldArgs = can.isFunction(args[1]) ? args.splice(0, 1) : args.splice(0, 2), def = pipe(oldMethod.apply(this, oldArgs), this, method); + def.then(args[0], args[1]); + return def; + }; + }; + }); + can.each([ + 'created', + 'updated', + 'destroyed' + ], function (funcName) { + can.Model.prototype[funcName] = function (attrs) { + var self = this, constructor = self.constructor; + if (attrs && typeof attrs === 'object') { + this.attr(can.isFunction(attrs.attr) ? attrs.attr() : attrs); + } + can.dispatch.call(this, { + type: 'change', + target: this + }, [funcName]); + can.dev.log('Model.js - ' + constructor.shortName + ' ' + funcName); + can.dispatch.call(constructor, funcName, [this]); + }; + }); + var ML = can.Model.List = can.List.extend({ + _bubbleRule: function (eventName, list) { + var bubbleRules = can.List._bubbleRule(eventName, list); + bubbleRules.push('destroyed'); + return bubbleRules; + } + }, { + setup: function (params) { + if (can.isPlainObject(params) && !can.isArray(params)) { + can.List.prototype.setup.apply(this); + this.replace(can.isDeferred(params) ? params : this.constructor.Map.findAll(params)); + } else { + can.List.prototype.setup.apply(this, arguments); + } + this._init = 1; + this.bind('destroyed', can.proxy(this._destroyed, this)); + delete this._init; + }, + _destroyed: function (ev, attr) { + if (/\w+/.test(attr)) { + var index; + while ((index = this.indexOf(ev.target)) > -1) { + this.splice(index, 1); + } + } + } + }); + return can.Model; +}); +/*can@2.2.6#util/string/deparam/deparam*/ +define('can/util/string/deparam/deparam', [ + 'can/util/util', + 'can/util/string/string' +], function (can) { + var digitTest = /^\d+$/, keyBreaker = /([^\[\]]+)|(\[\])/g, paramTest = /([^?#]*)(#.*)?$/, prep = function (str) { + return decodeURIComponent(str.replace(/\+/g, ' ')); + }; + can.extend(can, { + deparam: function (params) { + var data = {}, pairs, lastPart; + if (params && paramTest.test(params)) { + pairs = params.split('&'); + can.each(pairs, function (pair) { + var parts = pair.split('='), key = prep(parts.shift()), value = prep(parts.join('=')), current = data; + if (key) { + parts = key.match(keyBreaker); + for (var j = 0, l = parts.length - 1; j < l; j++) { + if (!current[parts[j]]) { + current[parts[j]] = digitTest.test(parts[j + 1]) || parts[j + 1] === '[]' ? [] : {}; + } + current = current[parts[j]]; + } + lastPart = parts.pop(); + if (lastPart === '[]') { + current.push(value); + } else { + current[lastPart] = value; + } + } + }); + } + return data; + } + }); + return can; +}); +/*can@2.2.6#route/route*/ +define('can/route/route', [ + 'can/util/util', + 'can/map/map', + 'can/list/list', + 'can/util/string/deparam/deparam' +], function (can) { + var matcher = /\:([\w\.]+)/g, paramsMatcher = /^(?:&[^=]+=[^&]*)+/, makeProps = function (props) { + var tags = []; + can.each(props, function (val, name) { + tags.push((name === 'className' ? 'class' : name) + '="' + (name === 'href' ? val : can.esc(val)) + '"'); + }); + return tags.join(' '); + }, matchesData = function (route, data) { + var count = 0, i = 0, defaults = {}; + for (var name in route.defaults) { + if (route.defaults[name] === data[name]) { + defaults[name] = 1; + count++; + } + } + for (; i < route.names.length; i++) { + if (!data.hasOwnProperty(route.names[i])) { + return -1; + } + if (!defaults[route.names[i]]) { + count++; + } + } + return count; + }, location = window.location, wrapQuote = function (str) { + return (str + '').replace(/([.?*+\^$\[\]\\(){}|\-])/g, '\\$1'); + }, each = can.each, extend = can.extend, stringify = function (obj) { + if (obj && typeof obj === 'object') { + if (obj instanceof can.Map) { + obj = obj.attr(); + } else { + obj = can.isFunction(obj.slice) ? obj.slice() : can.extend({}, obj); + } + can.each(obj, function (val, prop) { + obj[prop] = stringify(val); + }); + } else if (obj !== undefined && obj !== null && can.isFunction(obj.toString)) { + obj = obj.toString(); + } + return obj; + }, removeBackslash = function (str) { + return str.replace(/\\/g, ''); + }, timer, curParams, lastHash, changingData, changedAttrs = [], onRouteDataChange = function (ev, attr, how, newval) { + changingData = 1; + changedAttrs.push(attr); + clearTimeout(timer); + timer = setTimeout(function () { + changingData = 0; + var serialized = can.route.data.serialize(), path = can.route.param(serialized, true); + can.route._call('setURL', path, changedAttrs); + can.batch.trigger(eventsObject, '__url', [ + path, + lastHash + ]); + lastHash = path; + changedAttrs = []; + }, 10); + }, eventsObject = can.extend({}, can.event); + can.route = function (url, defaults) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + defaults = defaults || {}; + var names = [], res, test = '', lastIndex = matcher.lastIndex = 0, next, querySeparator = can.route._call('querySeparator'), matchSlashes = can.route._call('matchSlashes'); + while (res = matcher.exec(url)) { + names.push(res[1]); + test += removeBackslash(url.substring(lastIndex, matcher.lastIndex - res[0].length)); + next = '\\' + (removeBackslash(url.substr(matcher.lastIndex, 1)) || querySeparator + (matchSlashes ? '' : '|/')); + test += '([^' + next + ']' + (defaults[res[1]] ? '*' : '+') + ')'; + lastIndex = matcher.lastIndex; + } + test += url.substr(lastIndex).replace('\\', ''); + can.route.routes[url] = { + test: new RegExp('^' + test + '($|' + wrapQuote(querySeparator) + ')'), + route: url, + names: names, + defaults: defaults, + length: url.split('/').length + }; + return can.route; + }; + extend(can.route, { + param: function (data, _setRoute) { + var route, matches = 0, matchCount, routeName = data.route, propCount = 0; + delete data.route; + each(data, function () { + propCount++; + }); + each(can.route.routes, function (temp, name) { + matchCount = matchesData(temp, data); + if (matchCount > matches) { + route = temp; + matches = matchCount; + } + if (matchCount >= propCount) { + return false; + } + }); + if (can.route.routes[routeName] && matchesData(can.route.routes[routeName], data) === matches) { + route = can.route.routes[routeName]; + } + if (route) { + var cpy = extend({}, data), res = route.route.replace(matcher, function (whole, name) { + delete cpy[name]; + return data[name] === route.defaults[name] ? '' : encodeURIComponent(data[name]); + }).replace('\\', ''), after; + each(route.defaults, function (val, name) { + if (cpy[name] === val) { + delete cpy[name]; + } + }); + after = can.param(cpy); + if (_setRoute) { + can.route.attr('route', route.route); + } + return res + (after ? can.route._call('querySeparator') + after : ''); + } + return can.isEmptyObject(data) ? '' : can.route._call('querySeparator') + can.param(data); + }, + deparam: function (url) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + var route = { length: -1 }, querySeparator = can.route._call('querySeparator'), paramsMatcher = can.route._call('paramsMatcher'); + each(can.route.routes, function (temp, name) { + if (temp.test.test(url) && temp.length > route.length) { + route = temp; + } + }); + if (route.length > -1) { + var parts = url.match(route.test), start = parts.shift(), remainder = url.substr(start.length - (parts[parts.length - 1] === querySeparator ? 1 : 0)), obj = remainder && paramsMatcher.test(remainder) ? can.deparam(remainder.slice(1)) : {}; + obj = extend(true, {}, route.defaults, obj); + each(parts, function (part, i) { + if (part && part !== querySeparator) { + obj[route.names[i]] = decodeURIComponent(part); + } + }); + obj.route = route.route; + return obj; + } + if (url.charAt(0) !== querySeparator) { + url = querySeparator + url; + } + return paramsMatcher.test(url) ? can.deparam(url.slice(1)) : {}; + }, + data: new can.Map({}), + map: function (data) { + var appState; + if (data.prototype instanceof can.Map) { + appState = new data(); + } else { + appState = data; + } + can.route.data = appState; + }, + routes: {}, + ready: function (val) { + if (val !== true) { + can.route._setup(); + can.route.setState(); + } + return can.route; + }, + url: function (options, merge) { + if (merge) { + options = can.extend({}, can.route.deparam(can.route._call('matchingPartOfURL')), options); + } + return can.route._call('root') + can.route.param(options); + }, + link: function (name, options, props, merge) { + return '' + name + ''; + }, + current: function (options) { + can.__observe(eventsObject, '__url'); + return this._call('matchingPartOfURL') === can.route.param(options); + }, + bindings: { + hashchange: { + paramsMatcher: paramsMatcher, + querySeparator: '&', + matchSlashes: false, + bind: function () { + can.bind.call(window, 'hashchange', setState); + }, + unbind: function () { + can.unbind.call(window, 'hashchange', setState); + }, + matchingPartOfURL: function () { + return location.href.split(/#!?/)[1] || ''; + }, + setURL: function (path) { + if (location.hash !== '#' + path) { + location.hash = '!' + path; + } + return path; + }, + root: '#!' + } + }, + defaultBinding: 'hashchange', + currentBinding: null, + _setup: function () { + if (!can.route.currentBinding) { + can.route._call('bind'); + can.route.bind('change', onRouteDataChange); + can.route.currentBinding = can.route.defaultBinding; + } + }, + _teardown: function () { + if (can.route.currentBinding) { + can.route._call('unbind'); + can.route.unbind('change', onRouteDataChange); + can.route.currentBinding = null; + } + clearTimeout(timer); + changingData = 0; + }, + _call: function () { + var args = can.makeArray(arguments), prop = args.shift(), binding = can.route.bindings[can.route.currentBinding || can.route.defaultBinding], method = binding[prop]; + if (method.apply) { + return method.apply(binding, args); + } else { + return method; + } + } + }); + each([ + 'bind', + 'unbind', + 'on', + 'off', + 'delegate', + 'undelegate', + 'removeAttr', + 'compute', + '_get', + '__get', + 'each' + ], function (name) { + can.route[name] = function () { + if (!can.route.data[name]) { + return; + } + return can.route.data[name].apply(can.route.data, arguments); + }; + }); + can.route.attr = function (attr, val) { + var type = typeof attr, newArguments; + if (val === undefined) { + newArguments = arguments; + } else if (type !== 'string' && type !== 'number') { + newArguments = [ + stringify(attr), + val + ]; + } else { + newArguments = [ + attr, + stringify(val) + ]; + } + return can.route.data.attr.apply(can.route.data, newArguments); + }; + var setState = can.route.setState = function () { + var hash = can.route._call('matchingPartOfURL'); + var oldParams = curParams; + curParams = can.route.deparam(hash); + if (!changingData || hash !== lastHash) { + can.batch.start(); + recursiveClean(oldParams, curParams, can.route.data); + can.route.attr(curParams); + can.batch.trigger(eventsObject, '__url', [ + hash, + lastHash + ]); + can.batch.stop(); + } + }; + var recursiveClean = function (old, cur, data) { + for (var attr in old) { + if (cur[attr] === undefined) { + data.removeAttr(attr); + } else if (Object.prototype.toString.call(old[attr]) === '[object Object]') { + recursiveClean(old[attr], cur[attr], data.attr(attr)); + } + } + }; + return can.route; +}); +/*can@2.2.6#control/route/route*/ +define('can/control/route/route', [ + 'can/util/util', + 'can/route/route', + 'can/control/control' +], function (can) { + can.Control.processors.route = function (el, event, selector, funcName, controller) { + selector = selector || ''; + if (!can.route.routes[selector]) { + if (selector[0] === '/') { + selector = selector.substring(1); + } + can.route(selector); + } + var batchNum, check = function (ev, attr, how) { + if (can.route.attr('route') === selector && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + batchNum = ev.batchNum; + var d = can.route.attr(); + delete d.route; + if (can.isFunction(controller[funcName])) { + controller[funcName](d); + } else { + controller[controller[funcName]](d); + } + } + }; + can.route.bind('change', check); + return function () { + can.route.unbind('change', check); + }; + }; + return can; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.mootools.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.mootools.js new file mode 100644 index 0000000000..6a3cfcc4a1 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.mootools.js @@ -0,0 +1,7162 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#util/can*/ +define('can/util/can', [], function () { + var glbl = typeof window !== 'undefined' ? window : global; + var can = {}; + if (typeof GLOBALCAN === 'undefined' || GLOBALCAN !== false) { + glbl.can = can; + } + can.global = glbl; + can.k = function () { + }; + can.isDeferred = can.isPromise = function (obj) { + return obj && typeof obj.then === 'function' && typeof obj.pipe === 'function'; + }; + can.isMapLike = function (obj) { + return can.Map && (obj instanceof can.Map || obj && obj.__get); + }; + var cid = 0; + can.cid = function (object, name) { + if (!object._cid) { + cid++; + object._cid = (name || '') + cid; + } + return object._cid; + }; + can.VERSION = '2.2.6'; + can.simpleExtend = function (d, s) { + for (var prop in s) { + d[prop] = s[prop]; + } + return d; + }; + can.last = function (arr) { + return arr && arr[arr.length - 1]; + }; + var protoBind = Function.prototype.bind; + if (protoBind) { + can.proxy = function (fn, context) { + return protoBind.call(fn, context); + }; + } else { + can.proxy = function (fn, context) { + return function () { + return fn.apply(context, arguments); + }; + }; + } + can.frag = function (item) { + var frag; + if (!item || typeof item === 'string') { + frag = can.buildFragment(item == null ? '' : '' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } else if (item.nodeType === 11) { + return item; + } else if (typeof item.nodeType === 'number') { + frag = document.createDocumentFragment(); + frag.appendChild(item); + return frag; + } else if (typeof item.length === 'number') { + frag = document.createDocumentFragment(); + can.each(item, function (item) { + frag.appendChild(can.frag(item)); + }); + return frag; + } else { + frag = can.buildFragment('' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } + }; + can.scope = can.viewModel = function (el, attr, val) { + el = can.$(el); + var scope = can.data(el, 'scope') || can.data(el, 'viewModel'); + if (!scope) { + scope = new can.Map(); + can.data(el, 'scope', scope); + can.data(el, 'viewModel', scope); + } + switch (arguments.length) { + case 0: + case 1: + return scope; + case 2: + return scope.attr(attr); + default: + scope.attr(attr, val); + return el; + } + }; + can['import'] = function (moduleName) { + var deferred = new can.Deferred(); + if (typeof window.System === 'object' && can.isFunction(window.System['import'])) { + window.System['import'](moduleName).then(can.proxy(deferred.resolve, deferred), can.proxy(deferred.reject, deferred)); + } else if (window.define && window.define.amd) { + window.require([moduleName], function (value) { + deferred.resolve(value); + }); + } else if (window.steal) { + steal.steal(moduleName, function (value) { + deferred.resolve(value); + }); + } else if (window.require) { + deferred.resolve(window.require(moduleName)); + } else { + deferred.resolve(); + } + return deferred.promise(); + }; + can.__observe = function () { + }; + return can; +}); +/*can@2.2.6#util/attr/attr*/ +define('can/util/attr/attr', ['can/util/can'], function (can) { + var setImmediate = can.global.setImmediate || function (cb) { + return setTimeout(cb, 0); + }, attr = { + MutationObserver: can.global.MutationObserver || can.global.WebKitMutationObserver || can.global.MozMutationObserver, + map: { + 'class': 'className', + 'value': 'value', + 'innertext': 'innerText', + 'textcontent': 'textContent', + 'checked': true, + 'disabled': true, + 'readonly': true, + 'required': true, + src: function (el, val) { + if (val == null || val === '') { + el.removeAttribute('src'); + return null; + } else { + el.setAttribute('src', val); + return val; + } + }, + style: function (el, val) { + return el.style.cssText = val || ''; + } + }, + defaultValue: [ + 'input', + 'textarea' + ], + set: function (el, attrName, val) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var tagName = el.nodeName.toString().toLowerCase(), prop = attr.map[attrName], newValue; + if (typeof prop === 'function') { + newValue = prop(el, val); + } else if (prop === true) { + newValue = el[attrName] = true; + if (attrName === 'checked' && el.type === 'radio') { + if (can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultChecked = true; + } + } + } else if (prop) { + newValue = val; + if (el[prop] !== val) { + el[prop] = val; + } + if (prop === 'value' && can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultValue = val; + } + } else { + el.setAttribute(attrName, val); + newValue = val; + } + if (!attr.MutationObserver && newValue !== oldValue) { + attr.trigger(el, attrName, oldValue); + } + }, + trigger: function (el, attrName, oldValue) { + if (can.data(can.$(el), 'canHasAttributesBindings')) { + attrName = attrName.toLowerCase(); + return setImmediate(function () { + can.trigger(el, { + type: 'attributes', + attributeName: attrName, + target: el, + oldValue: oldValue, + bubbles: false + }, []); + }); + } + }, + get: function (el, attrName) { + attrName = attrName.toLowerCase(); + var prop = attr.map[attrName]; + if (typeof prop === 'string' && el[prop]) { + return el[prop]; + } + return el.getAttribute(attrName); + }, + remove: function (el, attrName) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var setter = attr.map[attrName]; + if (typeof setter === 'function') { + setter(el, undefined); + } + if (setter === true) { + el[attrName] = false; + } else if (typeof setter === 'string') { + el[setter] = ''; + } else { + el.removeAttribute(attrName); + } + if (!attr.MutationObserver && oldValue != null) { + attr.trigger(el, attrName, oldValue); + } + }, + has: function () { + var el = can.global.document && document.createElement('div'); + if (el && el.hasAttribute) { + return function (el, name) { + return el.hasAttribute(name); + }; + } else { + return function (el, name) { + return el.getAttribute(name) !== null; + }; + } + }() + }; + return attr; +}); +/*can@2.2.6#event/event*/ +define('can/event/event', ['can/util/can'], function (can) { + can.addEvent = function (event, handler) { + var allEvents = this.__bindEvents || (this.__bindEvents = {}), eventList = allEvents[event] || (allEvents[event] = []); + eventList.push({ + handler: handler, + name: event + }); + return this; + }; + can.listenTo = function (other, event, handler) { + var idedEvents = this.__listenToEvents; + if (!idedEvents) { + idedEvents = this.__listenToEvents = {}; + } + var otherId = can.cid(other); + var othersEvents = idedEvents[otherId]; + if (!othersEvents) { + othersEvents = idedEvents[otherId] = { + obj: other, + events: {} + }; + } + var eventsEvents = othersEvents.events[event]; + if (!eventsEvents) { + eventsEvents = othersEvents.events[event] = []; + } + eventsEvents.push(handler); + can.bind.call(other, event, handler); + }; + can.stopListening = function (other, event, handler) { + var idedEvents = this.__listenToEvents, iterIdedEvents = idedEvents, i = 0; + if (!idedEvents) { + return this; + } + if (other) { + var othercid = can.cid(other); + (iterIdedEvents = {})[othercid] = idedEvents[othercid]; + if (!idedEvents[othercid]) { + return this; + } + } + for (var cid in iterIdedEvents) { + var othersEvents = iterIdedEvents[cid], eventsEvents; + other = idedEvents[cid].obj; + if (!event) { + eventsEvents = othersEvents.events; + } else { + (eventsEvents = {})[event] = othersEvents.events[event]; + } + for (var eventName in eventsEvents) { + var handlers = eventsEvents[eventName] || []; + i = 0; + while (i < handlers.length) { + if (handler && handler === handlers[i] || !handler) { + can.unbind.call(other, eventName, handlers[i]); + handlers.splice(i, 1); + } else { + i++; + } + } + if (!handlers.length) { + delete othersEvents.events[eventName]; + } + } + if (can.isEmptyObject(othersEvents.events)) { + delete idedEvents[cid]; + } + } + return this; + }; + can.removeEvent = function (event, fn, __validate) { + if (!this.__bindEvents) { + return this; + } + var events = this.__bindEvents[event] || [], i = 0, ev, isFunction = typeof fn === 'function'; + while (i < events.length) { + ev = events[i]; + if (__validate ? __validate(ev, event, fn) : isFunction && ev.handler === fn || !isFunction && (ev.cid === fn || !fn)) { + events.splice(i, 1); + } else { + i++; + } + } + return this; + }; + can.dispatch = function (event, args) { + var events = this.__bindEvents; + if (!events) { + return; + } + if (typeof event === 'string') { + event = { type: event }; + } + var eventName = event.type, handlers = (events[eventName] || []).slice(0), passed = [event]; + if (args) { + passed.push.apply(passed, args); + } + for (var i = 0, len = handlers.length; i < len; i++) { + handlers[i].handler.apply(this, passed); + } + return event; + }; + can.one = function (event, handler) { + var one = function () { + can.unbind.call(this, event, one); + return handler.apply(this, arguments); + }; + can.bind.call(this, event, one); + return this; + }; + can.event = { + on: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.on.call(this); + } else { + return can.addEvent.apply(this, arguments); + } + }, + off: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.off.call(this); + } else { + return can.removeEvent.apply(this, arguments); + } + }, + bind: can.addEvent, + unbind: can.removeEvent, + delegate: function (selector, event, handler) { + return can.addEvent.call(this, event, handler); + }, + undelegate: function (selector, event, handler) { + return can.removeEvent.call(this, event, handler); + }, + trigger: can.dispatch, + one: can.one, + addEvent: can.addEvent, + removeEvent: can.removeEvent, + listenTo: can.listenTo, + stopListening: can.stopListening, + dispatch: can.dispatch + }; + return can.event; +}); +/*can@2.2.6#util/fragment*/ +define('can/util/fragment', ['can/util/can'], function (can) { + var fragmentRE = /^\s*<(\w+)[^>]*>/, toString = {}.toString, fragment = function (html, name) { + if (name === undefined) { + name = fragmentRE.test(html) && RegExp.$1; + } + if (html && toString.call(html.replace) === '[object Function]') { + html = html.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, '<$1>'); + } + var container = document.createElement('div'), temp = document.createElement('div'); + if (name === 'tbody' || name === 'tfoot' || name === 'thead') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; + } else if (name === 'tr') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild; + } else if (name === 'td' || name === 'th') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild.firstChild; + } else if (name === 'option') { + temp.innerHTML = ''; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; + } else { + container.innerHTML = '' + html; + } + var tmp = {}, children = container.childNodes; + tmp.length = children.length; + for (var i = 0; i < children.length; i++) { + tmp[i] = children[i]; + } + return [].slice.call(tmp); + }; + can.buildFragment = function (html, nodes) { + if (html && html.nodeType === 11) { + return html; + } + var parts = fragment(html), frag = document.createDocumentFragment(); + for (var i = 0, length = parts.length; i < length; i++) { + frag.appendChild(parts[i]); + } + return frag; + }; + (function () { + var text = '<-\n>', frag = can.buildFragment(text, document); + if (text !== frag.childNodes[0].nodeValue) { + var oldBuildFragment = can.buildFragment; + can.buildFragment = function (html, nodes) { + var res = oldBuildFragment(html, nodes); + if (res.childNodes.length === 1 && res.childNodes[0].nodeType === 3) { + res.childNodes[0].nodeValue = html; + } + return res; + }; + } + }()); + return can; +}); +/*can@2.2.6#util/deferred*/ +define('can/util/deferred', ['can/util/can'], function (can) { + var extend = function (target, src) { + for (var key in src) { + if (src.hasOwnProperty(key)) { + target[key] = src[key]; + } + } + }, Deferred = function (func) { + if (!(this instanceof Deferred)) { + return new Deferred(); + } + this._doneFuncs = []; + this._failFuncs = []; + this._resultArgs = null; + this._status = ''; + if (func) { + func.call(this, this); + } + }; + can.Deferred = Deferred; + can.when = Deferred.when = function () { + var args = can.makeArray(arguments); + if (args.length < 2) { + var obj = args[0]; + if (obj && (can.isFunction(obj.isResolved) && can.isFunction(obj.isRejected))) { + return obj; + } else { + return Deferred().resolve(obj); + } + } else { + var df = Deferred(), done = 0, rp = []; + can.each(args, function (arg, j) { + arg.done(function () { + rp[j] = arguments.length < 2 ? arguments[0] : arguments; + if (++done === args.length) { + df.resolve.apply(df, rp); + } + }).fail(function () { + df.reject(arguments.length === 1 ? arguments[0] : arguments); + }); + }); + return df; + } + }; + var resolveFunc = function (type, _status) { + return function (context) { + var args = this._resultArgs = arguments.length > 1 ? arguments[1] : []; + return this.exec(context, this[type], args, _status); + }; + }, doneFunc = function doneFunc(type, _status) { + return function () { + var self = this; + can.each(Array.prototype.slice.call(arguments), function (v, i, args) { + if (!v) { + return; + } + if (v.constructor === Array) { + doneFunc.apply(self, v); + } else { + if (self._status === _status) { + v.apply(self, self._resultArgs || []); + } + self[type].push(v); + } + }); + return this; + }; + }; + var isDeferred = function (obj) { + return obj && obj.then && obj.fail && obj.done; + }; + var wire = function (parentDeferred, result, setter, value) { + if (isDeferred(result)) { + result.done(can.proxy(parentDeferred.resolve, parentDeferred)).fail(can.proxy(parentDeferred.reject, parentDeferred)); + } else { + setter.call(parentDeferred, result !== undefined ? result : value); + } + }; + extend(Deferred.prototype, { + then: function (done, fail) { + var d = can.Deferred(), resolve = d.resolve, reject = d.reject; + this.done(function (value) { + if (typeof done === 'function') { + wire(d, done.apply(this, arguments), resolve, value); + } else { + resolve.apply(d, arguments); + } + }); + this.fail(function (value) { + if (typeof fail === 'function') { + wire(d, fail.apply(this, arguments), reject, value); + } else { + reject.apply(d, arguments); + } + }); + return d; + }, + resolveWith: resolveFunc('_doneFuncs', 'rs'), + rejectWith: resolveFunc('_failFuncs', 'rj'), + done: doneFunc('_doneFuncs', 'rs'), + fail: doneFunc('_failFuncs', 'rj'), + always: function () { + var args = can.makeArray(arguments); + if (args.length && args[0]) { + this.done(args[0]).fail(args[0]); + } + return this; + }, + state: function () { + switch (this._status) { + case 'rs': + return 'resolved'; + case 'rj': + return 'rejected'; + default: + return 'pending'; + } + }, + isResolved: function () { + return this._status === 'rs'; + }, + isRejected: function () { + return this._status === 'rj'; + }, + reject: function () { + return this.rejectWith(this, arguments); + }, + resolve: function () { + return this.resolveWith(this, arguments); + }, + exec: function (context, dst, args, st) { + if (this._status !== '') { + return this; + } + this._status = st; + can.each(dst, function (d) { + if (typeof d.apply === 'function') { + d.apply(context, args); + } + }); + return this; + }, + promise: function () { + var promise = this.then(); + promise.reject = promise.resolve = undefined; + return promise; + } + }); + Deferred.prototype.pipe = Deferred.prototype.then; + return can; +}); +/*can@2.2.6#util/array/each*/ +define('can/util/array/each', ['can/util/can'], function (can) { + var isArrayLike = function (obj) { + var length = 'length' in obj && obj.length; + return typeof arr !== 'function' && (length === 0 || typeof length === 'number' && length > 0 && length - 1 in obj); + }; + can.each = function (elements, callback, context) { + var i = 0, key, len, item; + if (elements) { + if (isArrayLike(elements)) { + if (can.List && elements instanceof can.List) { + for (len = elements.attr('length'); i < len; i++) { + item = elements.attr(i); + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } else { + for (len = elements.length; i < len; i++) { + item = elements[i]; + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } + } else if (typeof elements === 'object') { + if (can.Map && elements instanceof can.Map || elements === can.route) { + var keys = can.Map.keys(elements); + for (i = 0, len = keys.length; i < len; i++) { + key = keys[i]; + item = elements.attr(key); + if (callback.call(context || item, item, key, elements) === false) { + break; + } + } + } else { + for (key in elements) { + if (elements.hasOwnProperty(key) && callback.call(context || elements[key], elements[key], key, elements) === false) { + break; + } + } + } + } + } + return elements; + }; + return can; +}); +/*can@2.2.6#util/object/isplain/isplain*/ +define('can/util/object/isplain/isplain', ['can/util/can'], function () { + var core_hasOwn = Object.prototype.hasOwnProperty, isWindow = function (obj) { + return obj !== null && obj == obj.window; + }, isPlainObject = function (obj) { + if (!obj || typeof obj !== 'object' || obj.nodeType || isWindow(obj)) { + return false; + } + try { + if (obj.constructor && !core_hasOwn.call(obj, 'constructor') && !core_hasOwn.call(obj.constructor.prototype, 'isPrototypeOf')) { + return false; + } + } catch (e) { + return false; + } + var key; + for (key in obj) { + } + return key === undefined || core_hasOwn.call(obj, key); + }; + can.isPlainObject = isPlainObject; + return can; +}); +/*can@2.2.6#util/inserted/inserted*/ +define('can/util/inserted/inserted', ['can/util/can'], function (can) { + can.inserted = function (elems) { + elems = can.makeArray(elems); + var inDocument = false, doc = can.$(document.contains ? document : document.body), children; + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + if (!inDocument) { + if (elem.getElementsByTagName) { + if (can.has(doc, elem).length) { + inDocument = true; + } else { + return; + } + } else { + continue; + } + } + if (inDocument && elem.getElementsByTagName) { + children = can.makeArray(elem.getElementsByTagName('*')); + can.trigger(elem, 'inserted', [], false); + for (var j = 0, child; (child = children[j]) !== undefined; j++) { + can.trigger(child, 'inserted', [], false); + } + } + } + }; + can.appendChild = function (el, child) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.appendChild(child); + can.inserted(children); + }; + can.insertBefore = function (el, child, ref) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.insertBefore(child, ref); + can.inserted(children); + }; +}); +/*can@2.2.6#util/util*/ +define('can/util/util', [ + 'can/util/can', + 'can/util/attr/attr', + 'can/mootools/mootools', + 'can/event/event', + 'can/util/fragment', + 'can/util/deferred', + 'can/util/array/each', + 'can/util/object/isplain/isplain', + 'can/util/inserted/inserted' +], function (can, attr) { + can.trim = function (s) { + return s ? s.trim() : s; + }; + var extend = function () { + var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, length = arguments.length, deep = false; + if (typeof target === 'boolean') { + deep = target; + target = arguments[1] || {}; + i = 2; + } + if (typeof target !== 'object' && !can.isFunction(target)) { + target = {}; + } + if (length === i) { + target = this; + --i; + } + for (; i < length; i++) { + if ((options = arguments[i]) !== null) { + for (name in options) { + src = target[name]; + copy = options[name]; + if (target === copy) { + continue; + } + if (deep && copy && (can.isPlainObject(copy) || (copyIsArray = can.isArray(copy)))) { + if (copyIsArray) { + copyIsArray = false; + clone = src && can.isArray(src) ? src : []; + } else { + clone = src && can.isPlainObject(src) ? src : {}; + } + target[name] = can.extend(deep, clone, copy); + } else if (copy !== undefined) { + target[name] = copy; + } + } + } + } + return target; + }; + can.extend = extend; + can.makeArray = function (item) { + if (item === null) { + return []; + } + try { + return Type.isEnumerable(item) && typeof item !== 'string' ? Array.prototype.slice.call(item) : [item]; + } catch (ex) { + var arr = [], i; + for (i = 0; i < item.length; ++i) { + arr.push(item[i]); + } + return arr; + } + }; + can.isArray = function (arr) { + return typeOf(arr) === 'array'; + }; + can.inArray = function (item, arr, fromIndex) { + if (!arr) { + return -1; + } + return Array.prototype.indexOf.call(arr, item, fromIndex); + }; + can.map = function (arr, fn) { + return Array.from(arr || []).map(fn); + }; + can.param = function (object) { + return Object.toQueryString(object); + }; + can.isEmptyObject = function (object) { + return Object.keys(object).length === 0; + }; + can.isFunction = function (f) { + return typeOf(f) === 'function'; + }; + can.bind = function (ev, cb) { + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (this.nodeName && (this.nodeType && this.nodeType !== 11)) { + can.$(this).addEvent(ev, cb); + } else if (this.addEvent) { + this.addEvent(ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + return this; + }; + can.unbind = function (ev, cb) { + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (this.nodeName && (this.nodeType && this.nodeType !== 11)) { + can.$(this).removeEvent(ev, cb); + } else if (this.removeEvent) { + this.removeEvent(ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + return this; + }; + can.on = can.bind; + can.off = can.unbind; + can.trigger = function (item, event, args, bubble) { + bubble = bubble === undefined ? true : bubble; + args = args || []; + var propagating = true; + if (item.fireEvent) { + item = item[0] || item; + while (item && propagating) { + if (!event.type) { + event = { + type: event, + target: item, + stopPropagation: function () { + propagating = false; + } + }; + } + var events = item !== window ? can.$(item).retrieve('events')[0] : item.retrieve('events'); + if (events && events[event.type]) { + events[event.type].keys.each(function (fn) { + fn.apply(item, [event].concat(args)); + }, this); + } + if (bubble && item.parentNode && item.parentNode.nodeType !== 11) { + item = item.parentNode; + } else { + item = null; + } + } + } else { + if (typeof event === 'string') { + event = { type: event }; + } + event.target = event.target || item; + can.dispatch.call(item, event, can.makeArray(args)); + } + }; + can.delegate = function (selector, ev, cb) { + if (this.delegate) { + this.delegate(selector, ev, cb); + } else if (this.addEvent) { + this.addEvent(ev + ':relay(' + selector + ')', cb); + } else { + can.bind.call(this, ev, cb); + } + return this; + }; + can.undelegate = function (selector, ev, cb) { + if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else if (this.removeEvent) { + this.removeEvent(ev + ':relay(' + selector + ')', cb); + } else { + can.unbind.call(this, ev, cb); + } + return this; + }; + var optionsMap = { + type: 'method', + success: undefined, + error: undefined + }; + var updateDeferred = function (xhr, d) { + for (var prop in xhr) { + if (typeof d[prop] === 'function') { + d[prop] = function () { + xhr[prop].apply(xhr, arguments); + }; + } else { + d[prop] = prop[xhr]; + } + } + }; + can.ajax = function (options) { + var d = can.Deferred(), requestOptions = can.extend({}, options), request; + for (var option in optionsMap) { + if (requestOptions[option] !== undefined) { + requestOptions[optionsMap[option]] = requestOptions[option]; + delete requestOptions[option]; + } + } + requestOptions.method = requestOptions.method || 'get'; + requestOptions.url = requestOptions.url.toString(); + var success = options.onSuccess || options.success, error = options.onFailure || options.error; + requestOptions.onSuccess = function (response, xml) { + var data = response; + updateDeferred(request.xhr, d); + d.resolve(data, 'success', request.xhr); + if (success) { + success(data, 'success', request.xhr); + } + }; + requestOptions.onFailure = function () { + updateDeferred(request.xhr, d); + d.reject(request.xhr, 'error'); + if (error) { + error(request.xhr, 'error'); + } + }; + if (options.dataType === 'json') { + request = new Request.JSON(requestOptions); + } else { + request = new Request(requestOptions); + } + request.send(); + updateDeferred(request.xhr, d); + return d; + }; + can.$ = function (selector) { + if (selector === window) { + return window; + } + return $$(selector && selector.nodeName ? [selector] : selector); + }; + var old = document.id; + document.id = function (el) { + if (el && el.nodeType === 11) { + return el; + } else { + return old.apply(document, arguments); + } + }; + can.append = function (wrapped, html) { + if (typeof html === 'string') { + html = can.buildFragment(html); + } + return wrapped.grab(html); + }; + can.filter = function (wrapped, filter) { + return wrapped.filter(filter); + }; + can.data = function (wrapped, key, value) { + if (value === undefined) { + return wrapped[0].retrieve(key); + } else { + return wrapped.store(key, value); + } + }; + can.addClass = function (wrapped, className) { + return wrapped.addClass(className); + }; + can.remove = function (wrapped) { + var filtered = wrapped.filter(function (node) { + if (node.nodeType !== 1) { + node.parentNode.removeChild(node); + } else { + return true; + } + }); + filtered.destroy(); + return filtered; + }; + can.has = function (wrapped, element) { + if (Slick.contains(wrapped[0], element)) { + return wrapped; + } else { + return []; + } + }; + var destroy = Element.prototype.destroy, grab = Element.prototype.grab, oldSet = Element.prototype.set; + Element.implement({ + destroy: function () { + can.trigger(this, 'removed', [], false); + var elems = this.getElementsByTagName('*'); + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + can.trigger(elem, 'removed', [], false); + } + destroy.apply(this, arguments); + }, + grab: function (el) { + var elems; + if (el && el.nodeType === 11) { + elems = can.makeArray(el.childNodes); + } else { + elems = [el]; + } + var ret = grab.apply(this, arguments); + can.inserted(elems); + return ret; + }, + set: function (attrName, value) { + var isAttributeOrProp = can.inArray(attrName, [ + 'events', + 'html', + 'load', + 'morph', + 'send', + 'tag', + 'tween' + ]) === -1, newValue, oldValue; + if (isAttributeOrProp) { + oldValue = this.get(attrName); + } + var res = oldSet.apply(this, arguments); + if (isAttributeOrProp) { + newValue = this.get(attrName); + } + if (newValue !== oldValue) { + can.attr.trigger(this, attrName, oldValue); + } + return res; + }.overloadSetter() + }); + can.get = function (wrapped, index) { + return wrapped[index]; + }; + var idOf = Slick.uidOf; + Slick.uidOf = function (node) { + if (node.nodeType === 1 || node === window || node.document === document) { + return idOf(node); + } else { + return Math.random(); + } + }; + Element.NativeEvents.hashchange = 2; + can.attr = attr; + delete attr.MutationObserver; + Element.Events.attributes = { + onAdd: function () { + var el = can.$(this); + can.data(el, 'canHasAttributesBindings', (can.data(el, 'canHasAttributesBindings') || 0) + 1); + }, + onRemove: function () { + var el = can.$(this), cur = can.data(el, 'canHasAttributesBindings') || 0; + if (cur <= 0) { + can.cleanData(el, 'canHasAttributesBindings'); + } else { + can.data(el, 'canHasAttributesBindings', cur - 1); + } + } + }; + return can; +}); +/*can@2.2.6#view/view*/ +define('can/view/view', ['can/util/util'], function (can) { + var isFunction = can.isFunction, makeArray = can.makeArray, hookupId = 1; + var makeRenderer = function (textRenderer) { + var renderer = function () { + return $view.frag(textRenderer.apply(this, arguments)); + }; + renderer.render = function () { + return textRenderer.apply(textRenderer, arguments); + }; + return renderer; + }; + var checkText = function (text, url) { + if (!text.length) { + throw 'can.view: No template or empty template:' + url; + } + }; + var getRenderer = function (obj, async) { + if (isFunction(obj)) { + var def = can.Deferred(); + return def.resolve(obj); + } + var url = typeof obj === 'string' ? obj : obj.url, suffix = obj.engine && '.' + obj.engine || url.match(/\.[\w\d]+$/), type, el, id; + if (url.match(/^#/)) { + url = url.substr(1); + } + if (el = document.getElementById(url)) { + suffix = '.' + el.type.match(/\/(x\-)?(.+)/)[2]; + } + if (!suffix && !$view.cached[url]) { + url += suffix = $view.ext; + } + if (can.isArray(suffix)) { + suffix = suffix[0]; + } + id = $view.toId(url); + if (url.match(/^\/\//)) { + url = url.substr(2); + url = !window.steal ? url : steal.config().root.mapJoin('' + steal.id(url)); + } + if (window.require) { + if (require.toUrl) { + url = require.toUrl(url); + } + } + type = $view.types[suffix]; + if ($view.cached[id]) { + return $view.cached[id]; + } else if (el) { + return $view.registerView(id, el.innerHTML, type); + } else { + var d = new can.Deferred(); + can.ajax({ + async: async, + url: url, + dataType: 'text', + error: function (jqXHR) { + checkText('', url); + d.reject(jqXHR); + }, + success: function (text) { + checkText(text, url); + $view.registerView(id, text, type, d); + } + }); + return d; + } + }; + var getDeferreds = function (data) { + var deferreds = []; + if (can.isDeferred(data)) { + return [data]; + } else { + for (var prop in data) { + if (can.isDeferred(data[prop])) { + deferreds.push(data[prop]); + } + } + } + return deferreds; + }; + var usefulPart = function (resolved) { + return can.isArray(resolved) && resolved[1] === 'success' ? resolved[0] : resolved; + }; + var $view = can.view = can.template = function (view, data, helpers, callback) { + if (isFunction(helpers)) { + callback = helpers; + helpers = undefined; + } + return $view.renderAs('fragment', view, data, helpers, callback); + }; + can.extend($view, { + frag: function (result, parentNode) { + return $view.hookup($view.fragment(result), parentNode); + }, + fragment: function (result) { + if (typeof result !== 'string' && result.nodeType === 11) { + return result; + } + var frag = can.buildFragment(result, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + }, + toId: function (src) { + return can.map(src.toString().split(/\/|\./g), function (part) { + if (part) { + return part; + } + }).join('_'); + }, + toStr: function (txt) { + return txt == null ? '' : '' + txt; + }, + hookup: function (fragment, parentNode) { + var hookupEls = [], id, func; + can.each(fragment.childNodes ? can.makeArray(fragment.childNodes) : fragment, function (node) { + if (node.nodeType === 1) { + hookupEls.push(node); + hookupEls.push.apply(hookupEls, can.makeArray(node.getElementsByTagName('*'))); + } + }); + can.each(hookupEls, function (el) { + if (el.getAttribute && (id = el.getAttribute('data-view-id')) && (func = $view.hookups[id])) { + func(el, parentNode, id); + delete $view.hookups[id]; + el.removeAttribute('data-view-id'); + } + }); + return fragment; + }, + hookups: {}, + hook: function (cb) { + $view.hookups[++hookupId] = cb; + return ' data-view-id=\'' + hookupId + '\''; + }, + cached: {}, + cachedRenderers: {}, + cache: true, + register: function (info) { + this.types['.' + info.suffix] = info; + can[info.suffix] = $view[info.suffix] = function (id, text) { + var renderer, renderFunc; + if (!text) { + renderFunc = function () { + if (!renderer) { + if (info.fragRenderer) { + renderer = info.fragRenderer(null, id); + } else { + renderer = makeRenderer(info.renderer(null, id)); + } + } + return renderer.apply(this, arguments); + }; + renderFunc.render = function () { + var textRenderer = info.renderer(null, id); + return textRenderer.apply(textRenderer, arguments); + }; + return renderFunc; + } + var registeredRenderer = function () { + if (!renderer) { + if (info.fragRenderer) { + renderer = info.fragRenderer(id, text); + } else { + renderer = info.renderer(id, text); + } + } + return renderer.apply(this, arguments); + }; + if (info.fragRenderer) { + return $view.preload(id, registeredRenderer); + } else { + return $view.preloadStringRenderer(id, registeredRenderer); + } + }; + }, + types: {}, + ext: '.ejs', + registerScript: function (type, id, src) { + return 'can.view.preloadStringRenderer(\'' + id + '\',' + $view.types['.' + type].script(id, src) + ');'; + }, + preload: function (id, renderer) { + var def = $view.cached[id] = new can.Deferred().resolve(function (data, helpers) { + return renderer.call(data, data, helpers); + }); + def.__view_id = id; + $view.cachedRenderers[id] = renderer; + return renderer; + }, + preloadStringRenderer: function (id, stringRenderer) { + return this.preload(id, makeRenderer(stringRenderer)); + }, + render: function (view, data, helpers, callback) { + return can.view.renderAs('string', view, data, helpers, callback); + }, + renderTo: function (format, renderer, data, helpers) { + return (format === 'string' && renderer.render ? renderer.render : renderer)(data, helpers); + }, + renderAs: function (format, view, data, helpers, callback) { + if (isFunction(helpers)) { + callback = helpers; + helpers = undefined; + } + var deferreds = getDeferreds(data); + var reading, deferred, dataCopy, async, response; + if (deferreds.length) { + deferred = new can.Deferred(); + dataCopy = can.extend({}, data); + deferreds.push(getRenderer(view, true)); + can.when.apply(can, deferreds).then(function (resolved) { + var objs = makeArray(arguments), renderer = objs.pop(), result; + if (can.isDeferred(data)) { + dataCopy = usefulPart(resolved); + } else { + for (var prop in data) { + if (can.isDeferred(data[prop])) { + dataCopy[prop] = usefulPart(objs.shift()); + } + } + } + result = can.view.renderTo(format, renderer, dataCopy, helpers); + deferred.resolve(result, dataCopy); + if (callback) { + callback(result, dataCopy); + } + }, function () { + deferred.reject.apply(deferred, arguments); + }); + return deferred; + } else { + reading = can.__clearReading(); + async = isFunction(callback); + deferred = getRenderer(view, async); + if (reading) { + can.__setReading(reading); + } + if (async) { + response = deferred; + deferred.then(function (renderer) { + callback(data ? can.view.renderTo(format, renderer, data, helpers) : renderer); + }); + } else { + if (deferred.state() === 'resolved' && deferred.__view_id) { + var currentRenderer = $view.cachedRenderers[deferred.__view_id]; + return data ? can.view.renderTo(format, currentRenderer, data, helpers) : currentRenderer; + } else { + deferred.then(function (renderer) { + response = data ? can.view.renderTo(format, renderer, data, helpers) : renderer; + }); + } + } + return response; + } + }, + registerView: function (id, text, type, def) { + var info = typeof type === 'object' ? type : $view.types[type || $view.ext], renderer; + if (info.fragRenderer) { + renderer = info.fragRenderer(id, text); + } else { + renderer = makeRenderer(info.renderer(id, text)); + } + def = def || new can.Deferred(); + if ($view.cache) { + $view.cached[id] = def; + def.__view_id = id; + $view.cachedRenderers[id] = renderer; + } + return def.resolve(renderer); + } + }); + return can; +}); +/*can@2.2.6#view/callbacks/callbacks*/ +define('can/view/callbacks/callbacks', [ + 'can/util/util', + 'can/view/view' +], function (can) { + var attr = can.view.attr = function (attributeName, attrHandler) { + if (attrHandler) { + if (typeof attributeName === 'string') { + attributes[attributeName] = attrHandler; + } else { + regExpAttributes.push({ + match: attributeName, + handler: attrHandler + }); + } + } else { + var cb = attributes[attributeName]; + if (!cb) { + for (var i = 0, len = regExpAttributes.length; i < len; i++) { + var attrMatcher = regExpAttributes[i]; + if (attrMatcher.match.test(attributeName)) { + cb = attrMatcher.handler; + break; + } + } + } + return cb; + } + }; + var attributes = {}, regExpAttributes = [], automaticCustomElementCharacters = /[-\:]/; + var tag = can.view.tag = function (tagName, tagHandler) { + if (tagHandler) { + if (can.global.html5) { + can.global.html5.elements += ' ' + tagName; + can.global.html5.shivDocument(); + } + tags[tagName.toLowerCase()] = tagHandler; + } else { + var cb = tags[tagName.toLowerCase()]; + if (!cb && automaticCustomElementCharacters.test(tagName)) { + cb = function () { + }; + } + return cb; + } + }; + var tags = {}; + can.view.callbacks = { + _tags: tags, + _attributes: attributes, + _regExpAttributes: regExpAttributes, + tag: tag, + attr: attr, + tagHandler: function (el, tagName, tagData) { + var helperTagCallback = tagData.options.attr('tags.' + tagName), tagCallback = helperTagCallback || tags[tagName]; + var scope = tagData.scope, res; + if (tagCallback) { + var reads = can.__clearReading(); + res = tagCallback(el, tagData); + can.__setReading(reads); + } else { + res = scope; + } + if (res && tagData.subtemplate) { + if (scope !== res) { + scope = scope.add(res); + } + var result = tagData.subtemplate(scope, tagData.options); + var frag = typeof result === 'string' ? can.view.frag(result) : result; + can.appendChild(el, frag); + } + } + }; + return can.view.callbacks; +}); +/*can@2.2.6#view/elements*/ +define('can/view/elements', [ + 'can/util/util', + 'can/view/view' +], function (can) { + var doc = typeof document !== 'undefined' ? document : null; + var selectsCommentNodes = doc && function () { + return can.$(document.createComment('~')).length === 1; + }(); + var elements = { + tagToContentPropMap: { + option: doc && 'textContent' in document.createElement('option') ? 'textContent' : 'innerText', + textarea: 'value' + }, + attrMap: can.attr.map, + attrReg: /([^\s=]+)[\s]*=[\s]*/, + defaultValue: can.attr.defaultValue, + tagMap: { + '': 'span', + colgroup: 'col', + table: 'tbody', + tr: 'td', + ol: 'li', + ul: 'li', + tbody: 'tr', + thead: 'tr', + tfoot: 'tr', + select: 'option', + optgroup: 'option' + }, + reverseTagMap: { + col: 'colgroup', + tr: 'tbody', + option: 'select', + td: 'tr', + th: 'tr', + li: 'ul' + }, + getParentNode: function (el, defaultParentNode) { + return defaultParentNode && el.parentNode.nodeType === 11 ? defaultParentNode : el.parentNode; + }, + setAttr: can.attr.set, + getAttr: can.attr.get, + removeAttr: can.attr.remove, + contentText: function (text) { + if (typeof text === 'string') { + return text; + } + if (!text && text !== 0) { + return ''; + } + return '' + text; + }, + after: function (oldElements, newFrag) { + var last = oldElements[oldElements.length - 1]; + if (last.nextSibling) { + can.insertBefore(last.parentNode, newFrag, last.nextSibling); + } else { + can.appendChild(last.parentNode, newFrag); + } + }, + replace: function (oldElements, newFrag) { + elements.after(oldElements, newFrag); + if (can.remove(can.$(oldElements)).length < oldElements.length && !selectsCommentNodes) { + can.each(oldElements, function (el) { + if (el.nodeType === 8) { + el.parentNode.removeChild(el); + } + }); + } + } + }; + can.view.elements = elements; + return elements; +}); +/*can@2.2.6#util/string/string*/ +define('can/util/string/string', ['can/util/util'], function (can) { + var strUndHash = /_|-/, strColons = /\=\=/, strWords = /([A-Z]+)([A-Z][a-z])/g, strLowUp = /([a-z\d])([A-Z])/g, strDash = /([a-z\d])([A-Z])/g, strReplacer = /\{([^\}]+)\}/g, strQuote = /"/g, strSingleQuote = /'/g, strHyphenMatch = /-+(.)?/g, strCamelMatch = /[a-z][A-Z]/g, getNext = function (obj, prop, add) { + var result = obj[prop]; + if (result === undefined && add === true) { + result = obj[prop] = {}; + } + return result; + }, isContainer = function (current) { + return /^f|^o/.test(typeof current); + }, convertBadValues = function (content) { + var isInvalid = content === null || content === undefined || isNaN(content) && '' + content === 'NaN'; + return '' + (isInvalid ? '' : content); + }; + can.extend(can, { + esc: function (content) { + return convertBadValues(content).replace(/&/g, '&').replace(//g, '>').replace(strQuote, '"').replace(strSingleQuote, '''); + }, + getObject: function (name, roots, add) { + var parts = name ? name.split('.') : [], length = parts.length, current, r = 0, i, container, rootsLength; + roots = can.isArray(roots) ? roots : [roots || window]; + rootsLength = roots.length; + if (!length) { + return roots[0]; + } + for (r; r < rootsLength; r++) { + current = roots[r]; + container = undefined; + for (i = 0; i < length && isContainer(current); i++) { + container = current; + current = getNext(container, parts[i]); + } + if (container !== undefined && current !== undefined) { + break; + } + } + if (add === false && current !== undefined) { + delete container[parts[i - 1]]; + } + if (add === true && current === undefined) { + current = roots[0]; + for (i = 0; i < length && isContainer(current); i++) { + current = getNext(current, parts[i], true); + } + } + return current; + }, + capitalize: function (s, cache) { + return s.charAt(0).toUpperCase() + s.slice(1); + }, + camelize: function (str) { + return convertBadValues(str).replace(strHyphenMatch, function (match, chr) { + return chr ? chr.toUpperCase() : ''; + }); + }, + hyphenate: function (str) { + return convertBadValues(str).replace(strCamelMatch, function (str, offset) { + return str.charAt(0) + '-' + str.charAt(1).toLowerCase(); + }); + }, + underscore: function (s) { + return s.replace(strColons, '/').replace(strWords, '$1_$2').replace(strLowUp, '$1_$2').replace(strDash, '_').toLowerCase(); + }, + sub: function (str, data, remove) { + var obs = []; + str = str || ''; + obs.push(str.replace(strReplacer, function (whole, inside) { + var ob = can.getObject(inside, data, remove === true ? false : undefined); + if (ob === undefined || ob === null) { + obs = null; + return ''; + } + if (isContainer(ob) && obs) { + obs.push(ob); + return ''; + } + return '' + ob; + })); + return obs === null ? obs : obs.length <= 1 ? obs[0] : obs; + }, + replacer: strReplacer, + undHash: strUndHash + }); + return can; +}); +/*can@2.2.6#construct/construct*/ +define('can/construct/construct', ['can/util/string/string'], function (can) { + var initializing = 0; + var canGetDescriptor; + try { + Object.getOwnPropertyDescriptor({}); + canGetDescriptor = true; + } catch (e) { + canGetDescriptor = false; + } + var getDescriptor = function (newProps, name) { + var descriptor = Object.getOwnPropertyDescriptor(newProps, name); + if (descriptor && (descriptor.get || descriptor.set)) { + return descriptor; + } + return null; + }, inheritGetterSetter = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + var descriptor; + for (var name in newProps) { + if (descriptor = getDescriptor(newProps, name)) { + this._defineProperty(addTo, oldProps, name, descriptor); + } else { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + } + }, simpleInherit = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + for (var name in newProps) { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + }; + can.Construct = function () { + if (arguments.length) { + return can.Construct.extend.apply(can.Construct, arguments); + } + }; + can.extend(can.Construct, { + constructorExtends: true, + newInstance: function () { + var inst = this.instance(), args; + if (inst.setup) { + args = inst.setup.apply(inst, arguments); + } + if (inst.init) { + inst.init.apply(inst, args || arguments); + } + return inst; + }, + _inherit: canGetDescriptor ? inheritGetterSetter : simpleInherit, + _defineProperty: function (what, oldProps, propName, descriptor) { + Object.defineProperty(what, propName, descriptor); + }, + _overwrite: function (what, oldProps, propName, val) { + what[propName] = val; + }, + setup: function (base, fullName) { + this.defaults = can.extend(true, {}, base.defaults, this.defaults); + }, + instance: function () { + initializing = 1; + var inst = new this(); + initializing = 0; + return inst; + }, + extend: function (name, staticProperties, instanceProperties) { + var fullName = name, klass = staticProperties, proto = instanceProperties; + if (typeof fullName !== 'string') { + proto = klass; + klass = fullName; + fullName = null; + } + if (!proto) { + proto = klass; + klass = null; + } + proto = proto || {}; + var _super_class = this, _super = this.prototype, Constructor, parts, current, _fullName, _shortName, propName, shortName, namespace, prototype; + prototype = this.instance(); + can.Construct._inherit(proto, _super, prototype); + if (fullName) { + parts = fullName.split('.'); + shortName = parts.pop(); + } + if (typeof constructorName === 'undefined') { + Constructor = function () { + return init.apply(this, arguments); + }; + } + function init() { + if (!initializing) { + return this.constructor !== Constructor && arguments.length && Constructor.constructorExtends ? Constructor.extend.apply(Constructor, arguments) : Constructor.newInstance.apply(Constructor, arguments); + } + } + for (propName in _super_class) { + if (_super_class.hasOwnProperty(propName)) { + Constructor[propName] = _super_class[propName]; + } + } + can.Construct._inherit(klass, _super_class, Constructor); + if (fullName) { + current = can.getObject(parts.join('.'), window, true); + namespace = current; + _fullName = can.underscore(fullName.replace(/\./g, '_')); + _shortName = can.underscore(shortName); + current[shortName] = Constructor; + } + can.extend(Constructor, { + constructor: Constructor, + prototype: prototype, + namespace: namespace, + _shortName: _shortName, + fullName: fullName, + _fullName: _fullName + }); + if (shortName !== undefined) { + Constructor.shortName = shortName; + } + Constructor.prototype.constructor = Constructor; + var t = [_super_class].concat(can.makeArray(arguments)), args = Constructor.setup.apply(Constructor, t); + if (Constructor.init) { + Constructor.init.apply(Constructor, args || t); + } + return Constructor; + } + }); + can.Construct.prototype.setup = function () { + }; + can.Construct.prototype.init = function () { + }; + return can.Construct; +}); +/*can@2.2.6#control/control*/ +define('can/control/control', [ + 'can/util/util', + 'can/construct/construct' +], function (can) { + var bind = function (el, ev, callback) { + can.bind.call(el, ev, callback); + return function () { + can.unbind.call(el, ev, callback); + }; + }, isFunction = can.isFunction, extend = can.extend, each = can.each, slice = [].slice, paramReplacer = /\{([^\}]+)\}/g, special = can.getObject('$.event.special', [can]) || {}, delegate = function (el, selector, ev, callback) { + can.delegate.call(el, selector, ev, callback); + return function () { + can.undelegate.call(el, selector, ev, callback); + }; + }, binder = function (el, ev, callback, selector) { + return selector ? delegate(el, can.trim(selector), ev, callback) : bind(el, ev, callback); + }, basicProcessor; + var Control = can.Control = can.Construct({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Control) { + var control = this, funcName; + control.actions = {}; + for (funcName in control.prototype) { + if (control._isAction(funcName)) { + control.actions[funcName] = control._action(funcName); + } + } + } + }, + _shifter: function (context, name) { + var method = typeof name === 'string' ? context[name] : name; + if (!isFunction(method)) { + method = context[method]; + } + return function () { + context.called = name; + return method.apply(context, [this.nodeName ? can.$(this) : this].concat(slice.call(arguments, 0))); + }; + }, + _isAction: function (methodName) { + var val = this.prototype[methodName], type = typeof val; + return methodName !== 'constructor' && (type === 'function' || type === 'string' && isFunction(this.prototype[val])) && !!(special[methodName] || processors[methodName] || /[^\w]/.test(methodName)); + }, + _action: function (methodName, options) { + paramReplacer.lastIndex = 0; + if (options || !paramReplacer.test(methodName)) { + var convertedName = options ? can.sub(methodName, this._lookup(options)) : methodName; + if (!convertedName) { + return null; + } + var arr = can.isArray(convertedName), name = arr ? convertedName[1] : convertedName, parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: processors[event] || basicProcessor, + parts: [ + name, + parts.join(' '), + event + ], + delegate: arr ? convertedName[0] : undefined + }; + } + }, + _lookup: function (options) { + return [ + options, + window + ]; + }, + processors: {}, + defaults: {} + }, { + setup: function (element, options) { + var cls = this.constructor, pluginname = cls.pluginName || cls._fullName, arr; + this.element = can.$(element); + if (pluginname && pluginname !== 'can_control') { + this.element.addClass(pluginname); + } + arr = can.data(this.element, 'controls'); + if (!arr) { + arr = []; + can.data(this.element, 'controls', arr); + } + arr.push(this); + this.options = extend({}, cls.defaults, options); + this.on(); + return [ + this.element, + this.options + ]; + }, + on: function (el, selector, eventName, func) { + if (!el) { + this.off(); + var cls = this.constructor, bindings = this._bindings, actions = cls.actions, element = this.element, destroyCB = can.Control._shifter(this, 'destroy'), funcName, ready; + for (funcName in actions) { + if (actions.hasOwnProperty(funcName)) { + ready = actions[funcName] || cls._action(funcName, this.options, this); + if (ready) { + bindings.control[funcName] = ready.processor(ready.delegate || element, ready.parts[2], ready.parts[1], funcName, this); + } + } + } + can.bind.call(element, 'removed', destroyCB); + bindings.user.push(function (el) { + can.unbind.call(el, 'removed', destroyCB); + }); + return bindings.user.length; + } + if (typeof el === 'string') { + func = eventName; + eventName = selector; + selector = el; + el = this.element; + } + if (func === undefined) { + func = eventName; + eventName = selector; + selector = null; + } + if (typeof func === 'string') { + func = can.Control._shifter(this, func); + } + this._bindings.user.push(binder(el, eventName, func, selector)); + return this._bindings.user.length; + }, + off: function () { + var el = this.element[0], bindings = this._bindings; + if (bindings) { + each(bindings.user || [], function (value) { + value(el); + }); + each(bindings.control || {}, function (value) { + value(el); + }); + } + this._bindings = { + user: [], + control: {} + }; + }, + destroy: function () { + if (this.element === null) { + return; + } + var Class = this.constructor, pluginName = Class.pluginName || Class._fullName, controls; + this.off(); + if (pluginName && pluginName !== 'can_control') { + this.element.removeClass(pluginName); + } + controls = can.data(this.element, 'controls'); + controls.splice(can.inArray(this, controls), 1); + can.trigger(this, 'destroyed'); + this.element = null; + } + }); + var processors = can.Control.processors; + basicProcessor = function (el, event, selector, methodName, control) { + return binder(el, event, can.Control._shifter(control, methodName), selector); + }; + each([ + 'change', + 'click', + 'contextmenu', + 'dblclick', + 'keydown', + 'keyup', + 'keypress', + 'mousedown', + 'mousemove', + 'mouseout', + 'mouseover', + 'mouseup', + 'reset', + 'resize', + 'scroll', + 'select', + 'submit', + 'focusin', + 'focusout', + 'mouseenter', + 'mouseleave', + 'touchstart', + 'touchmove', + 'touchcancel', + 'touchend', + 'touchleave', + 'inserted', + 'removed' + ], function (v) { + processors[v] = basicProcessor; + }); + return Control; +}); +/*can@2.2.6#util/bind/bind*/ +define('can/util/bind/bind', ['can/util/util'], function (can) { + can.bindAndSetup = function () { + can.addEvent.apply(this, arguments); + if (!this._init) { + if (!this._bindings) { + this._bindings = 1; + if (this._bindsetup) { + this._bindsetup(); + } + } else { + this._bindings++; + } + } + return this; + }; + can.unbindAndTeardown = function (event, handler) { + var handlers = this.__bindEvents[event] || []; + var handlerCount = handlers.length; + can.removeEvent.apply(this, arguments); + if (this._bindings === null) { + this._bindings = 0; + } else { + this._bindings = this._bindings - (handlerCount - handlers.length); + } + if (!this._bindings && this._bindteardown) { + this._bindteardown(); + } + return this; + }; + return can; +}); +/*can@2.2.6#map/bubble*/ +define('can/map/bubble', ['can/util/util'], function (can) { + var bubble = can.bubble = { + event: function (map, boundEventName) { + return map.constructor._bubbleRule(boundEventName, map); + }, + childrenOf: function (parentMap, eventName) { + parentMap._each(function (child, prop) { + if (child && child.bind) { + bubble.toParent(child, parentMap, prop, eventName); + } + }); + }, + teardownChildrenFrom: function (parentMap, eventName) { + parentMap._each(function (child) { + bubble.teardownFromParent(parentMap, child, eventName); + }); + }, + toParent: function (child, parent, prop, eventName) { + can.listenTo.call(parent, child, eventName, function () { + var args = can.makeArray(arguments), ev = args.shift(); + args[0] = (can.List && parent instanceof can.List ? parent.indexOf(child) : prop) + (args[0] ? '.' + args[0] : ''); + ev.triggeredNS = ev.triggeredNS || {}; + if (ev.triggeredNS[parent._cid]) { + return; + } + ev.triggeredNS[parent._cid] = true; + can.trigger(parent, ev, args); + }); + }, + teardownFromParent: function (parent, child, eventName) { + if (child && child.unbind) { + can.stopListening.call(parent, child, eventName); + } + }, + isBubbling: function (parent, eventName) { + return parent._bubbleBindings && parent._bubbleBindings[eventName]; + }, + bind: function (parent, eventName) { + if (!parent._init) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + if (!parent._bubbleBindings) { + parent._bubbleBindings = {}; + } + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (!parent._bubbleBindings[bubbleEvent]) { + parent._bubbleBindings[bubbleEvent] = 1; + bubble.childrenOf(parent, bubbleEvent); + } else { + parent._bubbleBindings[bubbleEvent]++; + } + } + } + }, + unbind: function (parent, eventName) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (parent._bubbleBindings) { + parent._bubbleBindings[bubbleEvent]--; + } + if (parent._bubbleBindings && !parent._bubbleBindings[bubbleEvent]) { + delete parent._bubbleBindings[bubbleEvent]; + bubble.teardownChildrenFrom(parent, bubbleEvent); + if (can.isEmptyObject(parent._bubbleBindings)) { + delete parent._bubbleBindings; + } + } + } + }, + add: function (parent, child, prop) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + bubble.toParent(child, parent, prop, eventName); + } + } + } + }, + removeMany: function (parent, children) { + for (var i = 0, len = children.length; i < len; i++) { + bubble.remove(parent, children[i]); + } + }, + remove: function (parent, child) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + } + } + } + }, + set: function (parent, prop, value, current) { + if (can.Map.helpers.isObservable(value)) { + bubble.add(parent, value, prop); + } + if (can.Map.helpers.isObservable(current)) { + bubble.remove(parent, current); + } + return value; + } + }; + return bubble; +}); +/*can@2.2.6#util/batch/batch*/ +define('can/util/batch/batch', ['can/util/can'], function (can) { + var batchNum = 1, transactions = 0, batchEvents = [], stopCallbacks = [], currentBatchEvents = null; + can.batch = { + start: function (batchStopHandler) { + transactions++; + if (batchStopHandler) { + stopCallbacks.push(batchStopHandler); + } + }, + stop: function (force, callStart) { + if (force) { + transactions = 0; + } else { + transactions--; + } + if (transactions === 0) { + if (currentBatchEvents !== null) { + return; + } + currentBatchEvents = batchEvents.slice(0); + var callbacks = stopCallbacks.slice(0), i, len; + batchEvents = []; + stopCallbacks = []; + can.batch.batchNum = batchNum; + batchNum++; + if (callStart) { + can.batch.start(); + } + for (i = 0; i < currentBatchEvents.length; i++) { + can.dispatch.apply(currentBatchEvents[i][0], currentBatchEvents[i][1]); + } + currentBatchEvents = null; + for (i = 0, len = callbacks.length; i < callbacks.length; i++) { + callbacks[i](); + } + can.batch.batchNum = undefined; + } + }, + trigger: function (item, event, args) { + if (!item._init) { + event = typeof event === 'string' ? { type: event } : event; + if (currentBatchEvents) { + currentBatchEvents.push([ + item, + [ + event, + args + ] + ]); + } else if (transactions === 0) { + return can.dispatch.call(item, event, args); + } else { + event.batchNum = batchNum; + batchEvents.push([ + item, + [ + event, + args + ] + ]); + } + } + }, + afterPreviousEvents: function (handler) { + if (currentBatchEvents) { + var obj = {}; + can.bind.call(obj, 'ready', handler); + currentBatchEvents.push([ + obj, + [ + { type: 'ready' }, + [] + ] + ]); + } else { + handler(); + } + } + }; +}); +/*can@2.2.6#map/map*/ +define('can/map/map', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/map/bubble', + 'can/construct/construct', + 'can/util/batch/batch' +], function (can, bind, bubble) { + var madeMap = null; + var teardownMap = function () { + for (var cid in madeMap) { + if (madeMap[cid].added) { + delete madeMap[cid].obj._cid; + } + } + madeMap = null; + }; + var getMapFromObject = function (obj) { + return madeMap && madeMap[obj._cid] && madeMap[obj._cid].instance; + }; + var serializeMap = null; + var Map = can.Map = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Map) { + if (!this.defaults) { + this.defaults = {}; + } + this._computes = []; + for (var prop in this.prototype) { + if (prop !== 'define' && prop !== 'constructor' && (typeof this.prototype[prop] !== 'function' || this.prototype[prop].prototype instanceof can.Construct)) { + this.defaults[prop] = this.prototype[prop]; + } else if (this.prototype[prop].isComputed) { + this._computes.push(prop); + } + } + if (this.helpers.define) { + this.helpers.define(this); + } + } + if (can.List && !(this.prototype instanceof can.List)) { + this.List = Map.List.extend({ Map: this }, {}); + } + }, + _bubble: bubble, + _bubbleRule: function (eventName) { + return eventName === 'change' || eventName.indexOf('.') >= 0 ? ['change'] : []; + }, + _computes: [], + bind: can.bindAndSetup, + on: can.bindAndSetup, + unbind: can.unbindAndTeardown, + off: can.unbindAndTeardown, + id: 'id', + helpers: { + define: null, + attrParts: function (attr, keepKey) { + if (keepKey) { + return [attr]; + } + return typeof attr === 'object' ? attr : ('' + attr).split('.'); + }, + addToMap: function (obj, instance) { + var teardown; + if (!madeMap) { + teardown = teardownMap; + madeMap = {}; + } + var hasCid = obj._cid; + var cid = can.cid(obj); + if (!madeMap[cid]) { + madeMap[cid] = { + obj: obj, + instance: instance, + added: !hasCid + }; + } + return teardown; + }, + isObservable: function (obj) { + return obj instanceof can.Map || obj && obj === can.route; + }, + canMakeObserve: function (obj) { + return obj && !can.isDeferred(obj) && (can.isArray(obj) || can.isPlainObject(obj)); + }, + serialize: function (map, how, where) { + var cid = can.cid(map), firstSerialize = false; + if (!serializeMap) { + firstSerialize = true; + serializeMap = { + attr: {}, + serialize: {} + }; + } + serializeMap[how][cid] = where; + map.each(function (val, name) { + var result, isObservable = Map.helpers.isObservable(val), serialized = isObservable && serializeMap[how][can.cid(val)]; + if (serialized) { + result = serialized; + } else { + if (how === 'serialize') { + result = Map.helpers._serialize(map, name, val); + } else { + result = Map.helpers._getValue(map, name, val, how); + } + } + if (result !== undefined) { + where[name] = result; + } + }); + can.__observe(map, '__keys'); + if (firstSerialize) { + serializeMap = null; + } + return where; + }, + _serialize: function (map, name, val) { + return Map.helpers._getValue(map, name, val, 'serialize'); + }, + _getValue: function (map, name, val, how) { + if (Map.helpers.isObservable(val)) { + return val[how](); + } else { + return val; + } + } + }, + keys: function (map) { + var keys = []; + can.__observe(map, '__keys'); + for (var keyName in map._data) { + keys.push(keyName); + } + return keys; + } + }, { + setup: function (obj) { + if (obj instanceof can.Map) { + obj = obj.serialize(); + } + this._data = {}; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + var defaultValues = this._setupDefaults(obj); + this._setupComputes(defaultValues); + var teardownMapping = obj && can.Map.helpers.addToMap(obj, this); + var data = can.extend(can.extend(true, {}, defaultValues), obj); + this.attr(data); + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + delete this._init; + }, + _setupComputes: function () { + var computes = this.constructor._computes; + for (var i = 0, len = computes.length, prop; i < len; i++) { + prop = computes[i]; + this[prop] = this[prop].clone(this); + this._computedBindings[prop] = { count: 0 }; + } + }, + _setupDefaults: function () { + return this.constructor.defaults || {}; + }, + _bindsetup: function () { + }, + _bindteardown: function () { + }, + _changes: function (ev, attr, how, newVal, oldVal) { + can.batch.trigger(this, { + type: attr, + batchNum: ev.batchNum, + target: ev.target + }, [ + newVal, + oldVal + ]); + }, + _triggerChange: function (attr, how, newVal, oldVal) { + if (bubble.isBubbling(this, 'change')) { + can.batch.trigger(this, { + type: 'change', + target: this + }, [ + attr, + how, + newVal, + oldVal + ]); + } else { + can.batch.trigger(this, attr, [ + newVal, + oldVal + ]); + } + if (how === 'remove' || how === 'add') { + can.batch.trigger(this, { + type: '__keys', + target: this + }); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var prop in data) { + if (data.hasOwnProperty(prop)) { + callback(data[prop], prop); + } + } + }, + attr: function (attr, val) { + var type = typeof attr; + if (type !== 'string' && type !== 'number') { + return this._attrs(attr, val); + } else if (arguments.length === 1) { + return this._get(attr); + } else { + this._set(attr, val); + return this; + } + }, + each: function () { + return can.each.apply(undefined, [this].concat(can.makeArray(arguments))); + }, + removeAttr: function (attr) { + var isList = can.List && this instanceof can.List, parts = can.Map.helpers.attrParts(attr), prop = parts.shift(), current = isList ? this[prop] : this._data[prop]; + if (parts.length && current) { + return current.removeAttr(parts); + } else { + if (typeof attr === 'string' && !!~attr.indexOf('.')) { + prop = attr; + } + this._remove(prop, current); + return current; + } + }, + _remove: function (prop, current) { + if (prop in this._data) { + delete this._data[prop]; + if (!(prop in this.constructor.prototype)) { + delete this[prop]; + } + this._triggerChange(prop, 'remove', undefined, current); + } + }, + _get: function (attr) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'); + if (dotIndex >= 0) { + var value = this.__get(attr); + if (value !== undefined) { + return value; + } + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + can.__observe(this, first); + var current = this.__get(first); + return current && current._get ? current._get(second) : undefined; + } else { + can.__observe(this, attr); + return this.__get(attr); + } + }, + __get: function (attr) { + if (attr) { + if (this._computedBindings[attr]) { + return this[attr](); + } else { + return this._data[attr]; + } + } else { + return this._data; + } + }, + __type: function (value, prop) { + if (!(value instanceof can.Map) && can.Map.helpers.canMakeObserve(value)) { + var cached = getMapFromObject(value); + if (cached) { + return cached; + } + if (can.isArray(value)) { + var List = can.List; + return new List(value); + } else { + var Map = this.constructor.Map || can.Map; + return new Map(value); + } + } + return value; + }, + _set: function (attr, value, keepKey) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'), current; + if (!keepKey && dotIndex >= 0) { + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + current = this._init ? undefined : this.__get(first); + if (Map.helpers.isObservable(current)) { + current._set(second, value); + } else { + throw 'can.Map: Object does not exist'; + } + } else { + if (this.__convert) { + value = this.__convert(attr, value); + } + current = this._init ? undefined : this.__get(attr); + this.__set(attr, this.__type(value, attr), current); + } + }, + __set: function (prop, value, current) { + if (value !== current) { + var changeType = current !== undefined || this.__get().hasOwnProperty(prop) ? 'set' : 'add'; + this.___set(prop, this.constructor._bubble.set(this, prop, value, current)); + if (!this._computedBindings[prop]) { + this._triggerChange(prop, changeType, value, current); + } + if (current) { + this.constructor._bubble.teardownFromParent(this, current); + } + } + }, + ___set: function (prop, val) { + if (this._computedBindings[prop]) { + this[prop](val); + } else { + this._data[prop] = val; + } + if (typeof this.constructor.prototype[prop] !== 'function' && !this._computedBindings[prop]) { + this[prop] = val; + } + }, + bind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (!computedBinding.count) { + computedBinding.count = 1; + var self = this; + computedBinding.handler = function (ev, newVal, oldVal) { + can.batch.trigger(self, { + type: eventName, + batchNum: ev.batchNum, + target: self + }, [ + newVal, + oldVal + ]); + }; + this[eventName].bind('change', computedBinding.handler); + } else { + computedBinding.count++; + } + } + this.constructor._bubble.bind(this, eventName); + return can.bindAndSetup.apply(this, arguments); + }, + unbind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (computedBinding.count === 1) { + computedBinding.count = 0; + this[eventName].unbind('change', computedBinding.handler); + delete computedBinding.handler; + } else { + computedBinding.count--; + } + } + this.constructor._bubble.unbind(this, eventName); + return can.unbindAndTeardown.apply(this, arguments); + }, + serialize: function () { + return can.Map.helpers.serialize(this, 'serialize', {}); + }, + _attrs: function (props, remove) { + if (props === undefined) { + return Map.helpers.serialize(this, 'attr', {}); + } + props = can.simpleExtend({}, props); + var prop, self = this, newVal; + can.batch.start(); + this.each(function (curVal, prop) { + if (prop === '_cid') { + return; + } + newVal = props[prop]; + if (newVal === undefined) { + if (remove) { + self.removeAttr(prop); + } + return; + } + if (self.__convert) { + newVal = self.__convert(prop, newVal); + } + if (Map.helpers.isObservable(newVal)) { + self.__set(prop, self.__type(newVal, prop), curVal); + } else if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + self.__set(prop, self.__type(newVal, prop), curVal); + } + delete props[prop]; + }); + for (prop in props) { + if (prop !== '_cid') { + newVal = props[prop]; + this._set(prop, newVal, true); + } + } + can.batch.stop(); + return this; + }, + compute: function (prop) { + if (can.isFunction(this.constructor.prototype[prop])) { + return can.compute(this[prop], this); + } else { + var reads = prop.split('.'), last = reads.length - 1, options = { args: [] }; + return can.compute(function (newVal) { + if (arguments.length) { + can.compute.read(this, reads.slice(0, last)).value.attr(reads[last], newVal); + } else { + return can.compute.read(this, reads, options).value; + } + }, this); + } + } + }); + Map.prototype.on = Map.prototype.bind; + Map.prototype.off = Map.prototype.unbind; + return Map; +}); +/*can@2.2.6#list/list*/ +define('can/list/list', [ + 'can/util/util', + 'can/map/map', + 'can/map/bubble' +], function (can, Map, bubble) { + var splice = [].splice, spliceRemovesProps = function () { + var obj = { + 0: 'a', + length: 1 + }; + splice.call(obj, 0, 1); + return !obj[0]; + }(); + var list = Map.extend({ Map: Map }, { + setup: function (instances, options) { + this.length = 0; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + this._setupComputes(); + instances = instances || []; + var teardownMapping; + if (can.isDeferred(instances)) { + this.replace(instances); + } else { + teardownMapping = instances.length && can.Map.helpers.addToMap(instances, this); + this.push.apply(this, can.makeArray(instances || [])); + } + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + can.simpleExtend(this, options); + delete this._init; + }, + _triggerChange: function (attr, how, newVal, oldVal) { + Map.prototype._triggerChange.apply(this, arguments); + var index = +attr; + if (!~('' + attr).indexOf('.') && !isNaN(index)) { + if (how === 'add') { + can.batch.trigger(this, how, [ + newVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else if (how === 'remove') { + can.batch.trigger(this, how, [ + oldVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else { + can.batch.trigger(this, how, [ + newVal, + index + ]); + } + } + }, + __get: function (attr) { + if (attr) { + if (this[attr] && this[attr].isComputed && can.isFunction(this.constructor.prototype[attr])) { + return this[attr](); + } else { + return this[attr]; + } + } else { + return this; + } + }, + __set: function (prop, value, current) { + prop = isNaN(+prop) || prop % 1 ? prop : +prop; + if (typeof prop === 'number' && prop > this.length - 1) { + var newArr = new Array(prop + 1 - this.length); + newArr[newArr.length - 1] = value; + this.push.apply(this, newArr); + return newArr; + } + return can.Map.prototype.__set.call(this, '' + prop, value, current); + }, + ___set: function (attr, val) { + this[attr] = val; + if (+attr >= this.length) { + this.length = +attr + 1; + } + }, + _remove: function (prop, current) { + if (isNaN(+prop)) { + delete this[prop]; + this._triggerChange(prop, 'remove', undefined, current); + } else { + this.splice(prop, 1); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var i = 0; i < data.length; i++) { + callback(data[i], i); + } + }, + serialize: function () { + return Map.helpers.serialize(this, 'serialize', []); + }, + splice: function (index, howMany) { + var args = can.makeArray(arguments), added = [], i, len, listIndex, allSame = args.length > 2; + index = index || 0; + for (i = 0, len = args.length - 2; i < len; i++) { + listIndex = i + 2; + args[listIndex] = this.__type(args[listIndex], listIndex); + added.push(args[listIndex]); + if (this[i + index] !== args[listIndex]) { + allSame = false; + } + } + if (allSame && this.length <= added.length) { + return added; + } + if (howMany === undefined) { + howMany = args[1] = this.length - index; + } + var removed = splice.apply(this, args); + if (!spliceRemovesProps) { + for (i = this.length; i < removed.length + this.length; i++) { + delete this[i]; + } + } + can.batch.start(); + if (howMany > 0) { + bubble.removeMany(this, removed); + this._triggerChange('' + index, 'remove', undefined, removed); + } + if (args.length > 2) { + for (i = 0, len = added.length; i < len; i++) { + bubble.set(this, i, added[i]); + } + this._triggerChange('' + index, 'add', added, removed); + } + can.batch.stop(); + return removed; + }, + _attrs: function (items, remove) { + if (items === undefined) { + return Map.helpers.serialize(this, 'attr', []); + } + items = can.makeArray(items); + can.batch.start(); + this._updateAttrs(items, remove); + can.batch.stop(); + }, + _updateAttrs: function (items, remove) { + var len = Math.min(items.length, this.length); + for (var prop = 0; prop < len; prop++) { + var curVal = this[prop], newVal = items[prop]; + if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + this._set(prop, newVal); + } else { + } + } + if (items.length > this.length) { + this.push.apply(this, items.slice(this.length)); + } else if (items.length < this.length && remove) { + this.splice(items.length); + } + } + }), getArgs = function (args) { + return args[0] && can.isArray(args[0]) ? args[0] : can.makeArray(args); + }; + can.each({ + push: 'length', + unshift: 0 + }, function (where, name) { + var orig = [][name]; + list.prototype[name] = function () { + var args = [], len = where ? this.length : 0, i = arguments.length, res, val; + while (i--) { + val = arguments[i]; + args[i] = bubble.set(this, i, this.__type(val, i)); + } + res = orig.apply(this, args); + if (!this.comparator || args.length) { + this._triggerChange('' + len, 'add', args, undefined); + } + return res; + }; + }); + can.each({ + pop: 'length', + shift: 0 + }, function (where, name) { + list.prototype[name] = function () { + if (!this.length) { + return undefined; + } + var args = getArgs(arguments), len = where && this.length ? this.length - 1 : 0; + var res = [][name].apply(this, args); + this._triggerChange('' + len, 'remove', undefined, [res]); + if (res && res.unbind) { + bubble.remove(this, res); + } + return res; + }; + }); + can.extend(list.prototype, { + indexOf: function (item, fromIndex) { + this.attr('length'); + return can.inArray(item, this, fromIndex); + }, + join: function () { + return [].join.apply(this.attr(), arguments); + }, + reverse: function () { + var list = [].reverse.call(can.makeArray(this)); + this.replace(list); + }, + slice: function () { + var temp = Array.prototype.slice.apply(this, arguments); + return new this.constructor(temp); + }, + concat: function () { + var args = []; + can.each(can.makeArray(arguments), function (arg, i) { + args[i] = arg instanceof can.List ? arg.serialize() : arg; + }); + return new this.constructor(Array.prototype.concat.apply(this.serialize(), args)); + }, + forEach: function (cb, thisarg) { + return can.each(this, cb, thisarg || this); + }, + replace: function (newList) { + if (can.isDeferred(newList)) { + newList.then(can.proxy(this.replace, this)); + } else { + this.splice.apply(this, [ + 0, + this.length + ].concat(can.makeArray(newList || []))); + } + return this; + }, + filter: function (callback, thisArg) { + var filteredList = new can.List(), self = this, filtered; + this.each(function (item, index, list) { + filtered = callback.call(thisArg | self, item, index, self); + if (filtered) { + filteredList.push(item); + } + }); + return filteredList; + } + }); + can.List = Map.List = list; + return can.List; +}); +/*can@2.2.6#compute/read*/ +define('can/compute/read', ['can/util/util'], function (can) { + var read = function (parent, reads, options) { + options = options || {}; + var state = { foundObservable: false }; + var cur = readValue(parent, 0, reads, options, state), type, prev, readLength = reads.length, i = 0; + while (i < readLength) { + prev = cur; + for (var r = 0, readersLength = read.propertyReaders.length; r < readersLength; r++) { + var reader = read.propertyReaders[r]; + if (reader.test(cur)) { + cur = reader.read(cur, reads[i], i, options, state); + break; + } + } + i = i + 1; + cur = readValue(cur, i, reads, options, state, prev); + type = typeof cur; + if (i < reads.length && (cur === null || type !== 'function' && type !== 'object')) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1, cur); + } + return { + value: undefined, + parent: prev + }; + } + } + if (cur === undefined) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1); + } + } + return { + value: cur, + parent: prev + }; + }; + var readValue = function (value, index, reads, options, state, prev) { + var usedValueReader; + do { + usedValueReader = false; + for (var i = 0, len = read.valueReaders.length; i < len; i++) { + if (read.valueReaders[i].test(value, index, reads, options)) { + value = read.valueReaders[i].read(value, index, reads, options, state, prev); + } + } + } while (usedValueReader); + return value; + }; + read.valueReaders = [ + { + name: 'compute', + test: function (value, i, reads, options) { + return value && value.isComputed; + }, + read: function (value, i, reads, options, state) { + if (options.isArgument && i === reads.length) { + return value; + } + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, i); + state.foundObservable = true; + } + return value instanceof can.Compute ? value.get() : value(); + } + }, + { + name: 'function', + test: function (value, i, reads, options) { + var type = typeof value; + return type === 'function' && !value.isComputed && (options.executeAnonymousFunctions || options.isArgument && i === reads.length) && !(can.Construct && value.prototype instanceof can.Construct) && !(can.route && value === can.route); + }, + read: function (value, i, reads, options, state, prev) { + if (options.isArgument && i === reads.length) { + return options.proxyMethods !== false ? can.proxy(value, prev) : value; + } + return value.call(prev); + } + } + ]; + read.propertyReaders = [ + { + name: 'map', + test: can.isMapLike, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + if (typeof value[prop] === 'function' && value.constructor.prototype[prop] === value[prop]) { + if (options.returnObserveMethods) { + return value[prop]; + } else if (prop === 'constructor' && value instanceof can.Construct || value[prop].prototype instanceof can.Construct) { + return value[prop]; + } else { + return value[prop].apply(value, options.args || []); + } + } else { + return value.attr(prop); + } + } + }, + { + name: 'promise', + test: function (value) { + return can.isPromise(value); + }, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + var observeData = value.__observeData; + if (!value.__observeData) { + observeData = value.__observeData = { + isPending: true, + state: 'pending', + isResolved: false, + isRejected: false, + value: undefined, + reason: undefined + }; + can.cid(observeData); + can.simpleExtend(observeData, can.event); + value.then(function (value) { + observeData.isPending = false; + observeData.isResolved = true; + observeData.value = value; + observeData.state = 'resolved'; + observeData.dispatch('state', [ + 'resolved', + 'pending' + ]); + }, function (reason) { + observeData.isPending = false; + observeData.isRejected = true; + observeData.reason = reason; + observeData.state = 'rejected'; + observeData.dispatch('state', [ + 'rejected', + 'pending' + ]); + }); + } + can.__observe(observeData, 'state'); + return prop in observeData ? observeData[prop] : value[prop]; + } + }, + { + name: 'object', + test: function () { + return true; + }, + read: function (value, prop) { + if (value == null) { + return undefined; + } else { + return value[prop]; + } + } + } + ]; + read.write = function (parent, key, value, options) { + options = options || {}; + if (can.isMapLike(parent)) { + if (!options.isArgument && parent._data && parent._data[key] && parent._data[key].isComputed) { + return parent._data[key](value); + } else { + return parent.attr(key, value); + } + } + if (parent[key] && parent[key].isComputed) { + return parent[key](value); + } + if (typeof parent === 'object') { + parent[key] = value; + } + }; + return read; +}); +/*can@2.2.6#compute/get_value_and_bind*/ +define('can/compute/get_value_and_bind', ['can/util/util'], function () { + function observe(func, context, oldInfo, onchanged) { + var info = getValueAndObserved(func, context), newObserveSet = info.observed, oldObserved = oldInfo.observed; + if (info.names !== oldInfo.names) { + bindNewSet(oldObserved, newObserveSet, onchanged); + unbindOldSet(oldObserved, onchanged); + } + can.batch.afterPreviousEvents(function () { + info.ready = true; + }); + return info; + } + var observedStack = []; + can.__isRecordingObserves = function () { + return observedStack.length; + }; + can.__observe = can.__reading = function (obj, event) { + if (observedStack.length) { + var name = obj._cid + '|' + event, top = observedStack[observedStack.length - 1]; + top.names += name; + top.observed[name] = { + obj: obj, + event: event + '' + }; + } + }; + can.__notObserve = function (fn) { + return function () { + var previousReads = can.__clearObserved(); + var res = fn.apply(this, arguments); + can.__setObserved(previousReads); + return res; + }; + }; + can.__clearObserved = can.__clearReading = function () { + if (observedStack.length) { + var ret = observedStack[observedStack.length - 1]; + observedStack[observedStack.length - 1] = { observed: {} }; + return ret; + } + }; + can.__setObserved = can.__setReading = function (o) { + if (observedStack.length) { + observedStack[observedStack.length - 1] = o; + } + }; + can.__addObserved = can.__addReading = function (o) { + if (observedStack.length) { + can.simpleExtend(observedStack[observedStack.length - 1], o); + } + }; + var getValueAndObserved = function (func, self) { + observedStack.push({ + names: '', + observed: {} + }); + var value = func.call(self); + var stackItem = observedStack.pop(); + stackItem.value = value; + return stackItem; + }; + var bindNewSet = function (oldObserved, newObserveSet, onchanged) { + for (var name in newObserveSet) { + bindOrPreventUnbinding(oldObserved, newObserveSet, name, onchanged); + } + }; + var bindOrPreventUnbinding = function (oldObserved, newObserveSet, name, onchanged) { + if (oldObserved[name]) { + delete oldObserved[name]; + } else { + var obEv = newObserveSet[name]; + obEv.obj.bind(obEv.event, onchanged); + } + }; + var unbindOldSet = function (oldObserved, onchanged) { + for (var name in oldObserved) { + var obEv = oldObserved[name]; + obEv.obj.unbind(obEv.event, onchanged); + } + }; + return observe; +}); +/*can@2.2.6#compute/proto_compute*/ +define('can/compute/proto_compute', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/compute/read', + 'can/compute/get_value_and_bind', + 'can/util/batch/batch' +], function (can, bind, read, getValueAndBind) { + var updateOnChange = function (compute, newValue, oldValue, batchNum) { + if (newValue !== oldValue) { + can.batch.trigger(compute, batchNum ? { + type: 'change', + batchNum: batchNum + } : 'change', [ + newValue, + oldValue + ]); + } + }; + var setupComputeHandlers = function (compute, func, context, singleBind) { + var readInfo, onchanged, batchNum; + singleBind = false; + return { + on: function (updater) { + var self = this; + if (!onchanged) { + onchanged = function (ev) { + if (readInfo.ready && compute.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + if (singleBind) { + newValue = func.call(context); + readInfo.value = newValue; + } else { + readInfo = getValueAndBind(func, context, readInfo, onchanged); + newValue = readInfo.value; + } + self.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }; + } + readInfo = getValueAndBind(func, context, { observed: {} }, onchanged); + if (singleBind) { + func = can.__notObserve(func); + } + compute.value = readInfo.value; + compute.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function (updater) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, onchanged); + } + } + }; + }; + var k = function () { + }; + var updater = function (newVal, oldVal, batchNum) { + this.value = newVal; + updateOnChange(this, newVal, oldVal, batchNum); + }, asyncGet = function (fn, context, lastSetValue) { + return function () { + return fn.call(context, lastSetValue.get()); + }; + }, asyncUpdater = function (context, oldUpdater) { + return function (newVal) { + if (newVal !== undefined) { + oldUpdater(newVal, context.value); + } + }; + }; + can.Compute = function (getterSetter, context, eventName, bindOnce) { + var args = []; + for (var i = 0, arglen = arguments.length; i < arglen; i++) { + args[i] = arguments[i]; + } + var contextType = typeof args[1]; + if (typeof args[0] === 'function') { + this._setupGetterSetterFn(args[0], args[1], args[2], args[3]); + } else if (args[1]) { + if (contextType === 'string') { + this._setupContextString(args[0], args[1], args[2]); + } else if (contextType === 'function') { + this._setupContextFunction(args[0], args[1], args[2]); + } else { + if (args[1] && args[1].fn) { + this._setupAsyncCompute(args[0], args[1]); + } else { + this._setupContextSettings(args[0], args[1]); + } + } + } else { + this._setupInitialValue(args[0]); + } + this._args = args; + this.isComputed = true; + can.cid(this, 'compute'); + }; + can.simpleExtend(can.Compute.prototype, { + _bindsetup: can.__notObserve(function () { + this.bound = true; + this._on(this.updater); + }), + _bindteardown: function () { + this._off(this.updater); + this.bound = false; + }, + bind: can.bindAndSetup, + unbind: can.unbindAndTeardown, + clone: function (context) { + if (context && typeof this._args[0] === 'function') { + this._args[1] = context; + } else if (context) { + this._args[2] = context; + } + return new can.Compute(this._args[0], this._args[1], this._args[2], this._args[3]); + }, + _on: k, + _off: k, + get: function () { + if (can.__isRecordingObserves() && this._canObserve !== false) { + can.__observe(this, 'change'); + if (!this.bound) { + can.Compute.temporarilyBind(this); + } + } + if (this.bound) { + return this.value; + } else { + return this._get(); + } + }, + _get: function () { + return this.value; + }, + set: function (newVal) { + var old = this.value; + var setVal = this._set(newVal, old); + if (this.hasDependencies) { + if (this._setUpdates) { + return this.value; + } + return this._get(); + } + if (setVal === undefined) { + this.value = this._get(); + } else { + this.value = setVal; + } + updateOnChange(this, this.value, old); + return this.value; + }, + _set: function (newVal) { + return this.value = newVal; + }, + updater: updater, + _computeFn: function (newVal) { + if (arguments.length) { + return this.set(newVal); + } + return this.get(); + }, + toFunction: function () { + return can.proxy(this._computeFn, this); + }, + _setupGetterSetterFn: function (getterSetter, context, eventName, bindOnce) { + this._set = can.proxy(getterSetter, context); + this._get = can.proxy(getterSetter, context); + this._canObserve = eventName === false ? false : true; + var handlers = setupComputeHandlers(this, getterSetter, context || this, bindOnce); + this._on = handlers.on; + this._off = handlers.off; + }, + _setupContextString: function (target, propertyName, eventName) { + var isObserve = can.isMapLike(target), self = this, handler = function (ev, newVal, oldVal) { + self.updater(newVal, oldVal, ev.batchNum); + }; + if (isObserve) { + this.hasDependencies = true; + this._get = function () { + return target.attr(propertyName); + }; + this._set = function (val) { + target.attr(propertyName, val); + }; + this._on = function (update) { + target.bind(eventName || propertyName, handler); + this.value = this._get(); + }; + this._off = function () { + return target.unbind(eventName || propertyName, handler); + }; + } else { + this._get = can.proxy(this._get, target); + this._set = can.proxy(this._set, target); + } + }, + _setupContextFunction: function (initialValue, setter, eventName) { + this.value = initialValue; + this._set = setter; + can.simpleExtend(this, eventName); + }, + _setupContextSettings: function (initialValue, settings) { + this.value = initialValue; + this._set = settings.set ? can.proxy(settings.set, settings) : this._set; + this._get = settings.get ? can.proxy(settings.get, settings) : this._get; + if (!settings.__selfUpdater) { + var self = this, oldUpdater = this.updater; + this.updater = function () { + oldUpdater.call(self, self._get(), self.value); + }; + } + this._on = settings.on ? settings.on : this._on; + this._off = settings.off ? settings.off : this._off; + }, + _setupAsyncCompute: function (initialValue, settings) { + this.value = initialValue; + var oldUpdater = can.proxy(this.updater, this), self = this, fn = settings.fn, data; + this.updater = oldUpdater; + var lastSetValue = new can.Compute(initialValue); + this.lastSetValue = lastSetValue; + this._setUpdates = true; + this._set = function (newVal) { + if (newVal === lastSetValue.get()) { + return this.value; + } + return lastSetValue.set(newVal); + }; + this._get = asyncGet(fn, settings.context, lastSetValue); + if (fn.length === 0) { + data = setupComputeHandlers(this, fn, settings.context); + } else if (fn.length === 1) { + data = setupComputeHandlers(this, function () { + return fn.call(settings.context, lastSetValue.get()); + }, settings); + } else { + this.updater = asyncUpdater(this, oldUpdater); + data = setupComputeHandlers(this, function () { + var res = fn.call(settings.context, lastSetValue.get(), function (newVal) { + oldUpdater(newVal, self.value); + }); + return res !== undefined ? res : this.value; + }, settings); + } + this._on = data.on; + this._off = data.off; + }, + _setupInitialValue: function (initialValue) { + this.value = initialValue; + } + }); + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.Compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.Compute.async = function (initialValue, asyncComputer, context) { + return new can.Compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.Compute.read = read; + can.Compute.set = read.write; + can.Compute.truthy = function (compute) { + return new can.Compute(function () { + var res = compute.get(); + if (typeof res === 'function') { + res = res.get(); + } + return !!res; + }); + }; + return can.Compute; +}); +/*can@2.2.6#compute/compute*/ +define('can/compute/compute', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/util/batch/batch', + 'can/compute/proto_compute' +], function (can, bind) { + can.compute = function (getterSetter, context, eventName, bindOnce) { + var internalCompute = new can.Compute(getterSetter, context, eventName, bindOnce); + var compute = function (val) { + if (arguments.length) { + return internalCompute.set(val); + } + return internalCompute.get(); + }; + compute.bind = can.proxy(internalCompute.bind, internalCompute); + compute.unbind = can.proxy(internalCompute.unbind, internalCompute); + compute.isComputed = internalCompute.isComputed; + compute.clone = function (ctx) { + if (typeof getterSetter === 'function') { + context = ctx; + } + return can.compute(getterSetter, context, ctx, bindOnce); + }; + compute.computeInstance = internalCompute; + return compute; + }; + var k = function () { + }; + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.compute.truthy = function (compute) { + return can.compute(function () { + var res = compute(); + if (typeof res === 'function') { + res = res(); + } + return !!res; + }); + }; + can.compute.async = function (initialValue, asyncComputer, context) { + return can.compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.compute.read = can.Compute.read; + can.compute.set = can.Compute.set; + return can.compute; +}); +/*can@2.2.6#observe/observe*/ +define('can/observe/observe', [ + 'can/util/util', + 'can/map/map', + 'can/list/list', + 'can/compute/compute' +], function (can) { + can.Observe = can.Map; + can.Observe.startBatch = can.batch.start; + can.Observe.stopBatch = can.batch.stop; + can.Observe.triggerBatch = can.batch.trigger; + return can; +}); +/*can@2.2.6#view/scope/compute_data*/ +define('can/view/scope/compute_data', [ + 'can/util/util', + 'can/compute/compute', + 'can/compute/get_value_and_bind' +], function (can, compute, getValueAndBind) { + var isFastPath = function (computeData) { + return computeData.reads && computeData.reads.length === 1 && computeData.root instanceof can.Map && !can.isFunction(computeData.root[computeData.reads[0]]); + }; + var getValueAndBindScopeRead = function (scopeRead, scopeReadChanged) { + return getValueAndBind(scopeRead, null, { observed: {} }, scopeReadChanged); + }; + var unbindScopeRead = function (readInfo, scopeReadChanged) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, scopeReadChanged); + } + }; + var getValueAndBindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + var target = computeData.root, prop = computeData.reads[0]; + target.bind(prop, singlePropertyReadChanged); + return { + value: computeData.initialValue, + observed: { something: true } + }; + }; + var unbindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + computeData.root.unbind(computeData.reads[0], singlePropertyReadChanged); + }; + var scopeReader = function (scope, key, options, computeData, newVal) { + if (arguments.length > 4) { + if (computeData.root.isComputed) { + computeData.root(newVal); + } else if (computeData.reads.length) { + var last = computeData.reads.length - 1; + var obj = computeData.reads.length ? can.compute.read(computeData.root, computeData.reads.slice(0, last)).value : computeData.root; + can.compute.set(obj, computeData.reads[last], newVal, options); + } + } else { + if (computeData.root) { + return can.compute.read(computeData.root, computeData.reads, options).value; + } + var data = scope.read(key, options); + computeData.scope = data.scope; + computeData.initialValue = data.value; + computeData.reads = data.reads; + computeData.root = data.rootObserve; + return data.value; + } + }; + return function (scope, key, options) { + options = options || { args: [] }; + var computeData = {}, scopeRead = function (newVal) { + if (arguments.length) { + return scopeReader(scope, key, options, computeData, newVal); + } else { + return scopeReader(scope, key, options, computeData); + } + }, batchNum, readInfo, scopeReadChanged = function (ev) { + if (readInfo.ready && compute.computeInstance.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + readInfo = getValueAndBind(scopeRead, null, readInfo, scopeReadChanged); + newValue = readInfo.value; + compute.computeInstance.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }, singlePropertyReadChanged = function (ev, newVal, oldVal) { + if (typeof newVal !== 'function') { + compute.computeInstance.updater(newVal, oldVal, ev.batchNum); + } else { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + isFastPathBound = false; + compute.computeInstance.updater(readInfo.value, oldVal, ev.batchNum); + } + }, isFastPathBound = false, compute = can.compute(undefined, { + on: function () { + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + if (isFastPath(computeData)) { + var oldReadInfo = readInfo; + readInfo = getValueAndBindSinglePropertyRead(computeData, singlePropertyReadChanged); + unbindScopeRead(oldReadInfo, scopeReadChanged); + isFastPathBound = true; + } + compute.computeInstance.value = readInfo.value; + compute.computeInstance.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function () { + if (isFastPathBound) { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + } else { + unbindScopeRead(readInfo, scopeReadChanged); + } + }, + set: scopeRead, + get: scopeRead, + __selfUpdater: true + }); + computeData.compute = compute; + return computeData; + }; +}); +/*can@2.2.6#view/scope/scope*/ +define('can/view/scope/scope', [ + 'can/util/util', + 'can/view/scope/compute_data', + 'can/construct/construct', + 'can/map/map', + 'can/list/list', + 'can/view/view', + 'can/compute/compute' +], function (can, makeComputeData) { + var escapeReg = /(\\)?\./g, escapeDotReg = /\\\./g, getNames = function (attr) { + var names = [], last = 0; + attr.replace(escapeReg, function (first, second, index) { + if (!second) { + names.push(attr.slice(last, index).replace(escapeDotReg, '.')); + last = index + first.length; + } + }); + names.push(attr.slice(last).replace(escapeDotReg, '.')); + return names; + }; + var Scope = can.Construct.extend({ read: can.compute.read }, { + init: function (context, parent) { + this._context = context; + this._parent = parent; + this.__cache = {}; + }, + attr: can.__notObserve(function (key, value) { + var options = { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }, res = this.read(key, options); + if (arguments.length === 2) { + var lastIndex = key.lastIndexOf('.'), readKey = lastIndex !== -1 ? key.substring(0, lastIndex) : '.', obj = this.read(readKey, options).value; + if (lastIndex !== -1) { + key = key.substring(lastIndex + 1, key.length); + } + can.compute.set(obj, key, value, options); + } + return res.value; + }), + add: function (context) { + if (context !== this._context) { + return new this.constructor(context, this); + } else { + return this; + } + }, + computeData: function (key, options) { + return makeComputeData(this, key, options); + }, + compute: function (key, options) { + return this.computeData(key, options).compute; + }, + read: function (attr, options) { + var stopLookup; + if (attr.substr(0, 2) === './') { + stopLookup = true; + attr = attr.substr(2); + } else if (attr.substr(0, 3) === '../') { + return this._parent.read(attr.substr(3), options); + } else if (attr === '..') { + return { value: this._parent._context }; + } else if (attr === '.' || attr === 'this') { + return { value: this._context }; + } + var names = attr.indexOf('\\.') === -1 ? attr.split('.') : getNames(attr), context, scope = this, defaultObserve, defaultReads = [], defaultPropertyDepth = -1, defaultComputeReadings, defaultScope, currentObserve, currentReads; + while (scope) { + context = scope._context; + if (context !== null && (typeof context === 'object' || typeof context === 'function')) { + var data = can.compute.read(context, names, can.simpleExtend({ + foundObservable: function (observe, nameIndex) { + currentObserve = observe; + currentReads = names.slice(nameIndex); + }, + earlyExit: function (parentValue, nameIndex) { + if (nameIndex > defaultPropertyDepth) { + defaultObserve = currentObserve; + defaultReads = currentReads; + defaultPropertyDepth = nameIndex; + defaultScope = scope; + defaultComputeReadings = can.__clearReading(); + } + }, + executeAnonymousFunctions: true + }, options)); + if (data.value !== undefined) { + return { + scope: scope, + rootObserve: currentObserve, + value: data.value, + reads: currentReads + }; + } + } + can.__clearReading(); + if (!stopLookup) { + scope = scope._parent; + } else { + scope = null; + } + } + if (defaultObserve) { + can.__setReading(defaultComputeReadings); + return { + scope: defaultScope, + rootObserve: defaultObserve, + reads: defaultReads, + value: undefined + }; + } else { + return { + names: names, + value: undefined + }; + } + } + }); + can.view.Scope = Scope; + return Scope; +}); +/*can@2.2.6#view/scanner*/ +define('can/view/scanner', [ + 'can/view/view', + 'can/view/elements', + 'can/view/callbacks/callbacks' +], function (can, elements, viewCallbacks) { + var newLine = /(\r|\n)+/g, notEndTag = /\//, clean = function (content) { + return content.split('\\').join('\\\\').split('\n').join('\\n').split('"').join('\\"').split('\t').join('\\t'); + }, getTag = function (tagName, tokens, i) { + if (tagName) { + return tagName; + } else { + while (i < tokens.length) { + if (tokens[i] === '<' && !notEndTag.test(tokens[i + 1])) { + return elements.reverseTagMap[tokens[i + 1]] || 'span'; + } + i++; + } + } + return ''; + }, bracketNum = function (content) { + return --content.split('{').length - --content.split('}').length; + }, myEval = function (script) { + eval(script); + }, attrReg = /([^\s]+)[\s]*=[\s]*$/, startTxt = 'var ___v1ew = [];', finishTxt = 'return ___v1ew.join(\'\')', put_cmd = '___v1ew.push(\n', insert_cmd = put_cmd, htmlTag = null, quote = null, beforeQuote = null, rescan = null, getAttrName = function () { + var matches = beforeQuote.match(attrReg); + return matches && matches[1]; + }, status = function () { + return quote ? '\'' + getAttrName() + '\'' : htmlTag ? 1 : 0; + }, top = function (stack) { + return stack[stack.length - 1]; + }, Scanner; + can.view.Scanner = Scanner = function (options) { + can.extend(this, { + text: {}, + tokens: [] + }, options); + this.text.options = this.text.options || ''; + this.tokenReg = []; + this.tokenSimple = { + '<': '<', + '>': '>', + '"': '"', + '\'': '\'' + }; + this.tokenComplex = []; + this.tokenMap = {}; + for (var i = 0, token; token = this.tokens[i]; i++) { + if (token[2]) { + this.tokenReg.push(token[2]); + this.tokenComplex.push({ + abbr: token[1], + re: new RegExp(token[2]), + rescan: token[3] + }); + } else { + this.tokenReg.push(token[1]); + this.tokenSimple[token[1]] = token[0]; + } + this.tokenMap[token[0]] = token[1]; + } + this.tokenReg = new RegExp('(' + this.tokenReg.slice(0).concat([ + '<', + '>', + '"', + '\'' + ]).join('|') + ')', 'g'); + }; + Scanner.prototype = { + helpers: [], + scan: function (source, name) { + var tokens = [], last = 0, simple = this.tokenSimple, complex = this.tokenComplex; + source = source.replace(newLine, '\n'); + if (this.transform) { + source = this.transform(source); + } + source.replace(this.tokenReg, function (whole, part) { + var offset = arguments[arguments.length - 2]; + if (offset > last) { + tokens.push(source.substring(last, offset)); + } + if (simple[whole]) { + tokens.push(whole); + } else { + for (var i = 0, token; token = complex[i]; i++) { + if (token.re.test(whole)) { + tokens.push(token.abbr); + if (token.rescan) { + tokens.push(token.rescan(part)); + } + break; + } + } + } + last = offset + part.length; + }); + if (last < source.length) { + tokens.push(source.substr(last)); + } + var content = '', buff = [startTxt + (this.text.start || '')], put = function (content, bonus) { + buff.push(put_cmd, '"', clean(content), '"' + (bonus || '') + ');'); + }, endStack = [], lastToken, startTag = null, magicInTag = false, specialStates = { + attributeHookups: [], + tagHookups: [], + lastTagHookup: '' + }, popTagHookup = function () { + specialStates.lastTagHookup = specialStates.tagHookups.pop() + specialStates.tagHookups.length; + }, tagName = '', tagNames = [], popTagName = false, bracketCount, specialAttribute = false, i = 0, token, tmap = this.tokenMap, attrName; + htmlTag = quote = beforeQuote = null; + for (; (token = tokens[i++]) !== undefined;) { + if (startTag === null) { + switch (token) { + case tmap.left: + case tmap.escapeLeft: + case tmap.returnLeft: + magicInTag = htmlTag && 1; + case tmap.commentLeft: + startTag = token; + if (content.length) { + put(content); + } + content = ''; + break; + case tmap.escapeFull: + magicInTag = htmlTag && 1; + rescan = 1; + startTag = tmap.escapeLeft; + if (content.length) { + put(content); + } + rescan = tokens[i++]; + content = rescan.content || rescan; + if (rescan.before) { + put(rescan.before); + } + tokens.splice(i, 0, tmap.right); + break; + case tmap.commentFull: + break; + case tmap.templateLeft: + content += tmap.left; + break; + case '<': + if (tokens[i].indexOf('!--') !== 0) { + htmlTag = 1; + magicInTag = 0; + } + content += token; + break; + case '>': + htmlTag = 0; + var emptyElement = content.substr(content.length - 1) === '/' || content.substr(content.length - 2) === '--', attrs = ''; + if (specialStates.attributeHookups.length) { + attrs = 'attrs: [\'' + specialStates.attributeHookups.join('\',\'') + '\'], '; + specialStates.attributeHookups = []; + } + if (tagName + specialStates.tagHookups.length !== specialStates.lastTagHookup && tagName === top(specialStates.tagHookups)) { + if (emptyElement) { + content = content.substr(0, content.length - 1); + } + buff.push(put_cmd, '"', clean(content), '"', ',can.view.pending({tagName:\'' + tagName + '\',' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options); + if (emptyElement) { + buff.push('}));'); + content = '/>'; + popTagHookup(); + } else if (tokens[i] === '<' && tokens[i + 1] === '/' + tagName) { + buff.push('}));'); + content = token; + popTagHookup(); + } else { + buff.push(',subtemplate: function(' + this.text.argNames + '){\n' + startTxt + (this.text.start || '')); + content = ''; + } + } else if (magicInTag || !popTagName && elements.tagToContentPropMap[tagNames[tagNames.length - 1]] || attrs) { + var pendingPart = ',can.view.pending({' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options + '}),"'; + if (emptyElement) { + put(content.substr(0, content.length - 1), pendingPart + '/>"'); + } else { + put(content, pendingPart + '>"'); + } + content = ''; + magicInTag = 0; + } else { + content += token; + } + if (emptyElement || popTagName) { + tagNames.pop(); + tagName = tagNames[tagNames.length - 1]; + popTagName = false; + } + specialStates.attributeHookups = []; + break; + case '\'': + case '"': + if (htmlTag) { + if (quote && quote === token) { + quote = null; + var attr = getAttrName(); + if (viewCallbacks.attr(attr)) { + specialStates.attributeHookups.push(attr); + } + if (specialAttribute) { + content += token; + put(content); + buff.push(finishTxt, '}));\n'); + content = ''; + specialAttribute = false; + break; + } + } else if (quote === null) { + quote = token; + beforeQuote = lastToken; + attrName = getAttrName(); + if (tagName === 'img' && attrName === 'src' || attrName === 'style') { + put(content.replace(attrReg, '')); + content = ''; + specialAttribute = true; + buff.push(insert_cmd, 'can.view.txt(2,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt); + put(attrName + '=' + token); + break; + } + } + } + default: + if (lastToken === '<') { + tagName = token.substr(0, 3) === '!--' ? '!--' : token.split(/\s/)[0]; + var isClosingTag = false, cleanedTagName; + if (tagName.indexOf('/') === 0) { + isClosingTag = true; + cleanedTagName = tagName.substr(1); + } + if (isClosingTag) { + if (top(tagNames) === cleanedTagName) { + tagName = cleanedTagName; + popTagName = true; + } + if (top(specialStates.tagHookups) === cleanedTagName) { + put(content.substr(0, content.length - 1)); + buff.push(finishTxt + '}}) );'); + content = '><'; + popTagHookup(); + } + } else { + if (tagName.lastIndexOf('/') === tagName.length - 1) { + tagName = tagName.substr(0, tagName.length - 1); + } + if (tagName !== '!--' && viewCallbacks.tag(tagName)) { + if (tagName === 'content' && elements.tagMap[top(tagNames)]) { + token = token.replace('content', elements.tagMap[top(tagNames)]); + } + specialStates.tagHookups.push(tagName); + } + tagNames.push(tagName); + } + } + content += token; + break; + } + } else { + switch (token) { + case tmap.right: + case tmap.returnRight: + switch (startTag) { + case tmap.left: + bracketCount = bracketNum(content); + if (bracketCount === 1) { + buff.push(insert_cmd, 'can.view.txt(0,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt, content); + endStack.push({ + before: '', + after: finishTxt + '}));\n' + }); + } else { + last = endStack.length && bracketCount === -1 ? endStack.pop() : { after: ';' }; + if (last.before) { + buff.push(last.before); + } + buff.push(content, ';', last.after); + } + break; + case tmap.escapeLeft: + case tmap.returnLeft: + bracketCount = bracketNum(content); + if (bracketCount) { + endStack.push({ + before: finishTxt, + after: '}));\n' + }); + } + var escaped = startTag === tmap.escapeLeft ? 1 : 0, commands = { + insert: insert_cmd, + tagName: getTag(tagName, tokens, i), + status: status(), + specialAttribute: specialAttribute + }; + for (var ii = 0; ii < this.helpers.length; ii++) { + var helper = this.helpers[ii]; + if (helper.name.test(content)) { + content = helper.fn(content, commands); + if (helper.name.source === /^>[\s]*\w*/.source) { + escaped = 0; + } + break; + } + } + if (typeof content === 'object') { + if (content.startTxt && content.end && specialAttribute) { + buff.push(insert_cmd, 'can.view.toStr( ', content.content, '() ) );'); + } else { + if (content.startTxt) { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || (content.escaped != null ? content.escaped : escaped)) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\n'); + } else if (content.startOnlyTxt) { + buff.push(insert_cmd, 'can.view.onlytxt(this,\n'); + } + buff.push(content.content); + if (content.end) { + buff.push('));'); + } + } + } else if (specialAttribute) { + buff.push(insert_cmd, content, ');'); + } else { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || escaped) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\nfunction(){ ' + (this.text.escape || '') + 'return ', content, bracketCount ? startTxt : '}));\n'); + } + if (rescan && rescan.after && rescan.after.length) { + put(rescan.after.length); + rescan = null; + } + break; + } + startTag = null; + content = ''; + break; + case tmap.templateLeft: + content += tmap.left; + break; + default: + content += token; + break; + } + } + lastToken = token; + } + if (content.length) { + put(content); + } + buff.push(';'); + var template = buff.join(''), out = { out: (this.text.outStart || '') + template + ' ' + finishTxt + (this.text.outEnd || '') }; + myEval.call(out, 'this.fn = (function(' + this.text.argNames + '){' + out.out + '});\r\n//# sourceURL=' + name + '.js'); + return out; + } + }; + can.view.pending = function (viewData) { + var hooks = can.view.getHooks(); + return can.view.hook(function (el) { + can.each(hooks, function (fn) { + fn(el); + }); + viewData.templateType = 'legacy'; + if (viewData.tagName) { + viewCallbacks.tagHandler(el, viewData.tagName, viewData); + } + can.each(viewData && viewData.attrs || [], function (attributeName) { + viewData.attributeName = attributeName; + var callback = viewCallbacks.attr(attributeName); + if (callback) { + callback(el, viewData); + } + }); + }); + }; + can.view.tag('content', function (el, tagData) { + return tagData.scope; + }); + can.view.Scanner = Scanner; + return Scanner; +}); +/*can@2.2.6#view/node_lists/node_lists*/ +define('can/view/node_lists/node_lists', [ + 'can/util/util', + 'can/view/elements' +], function (can) { + var canExpando = true; + try { + document.createTextNode('')._ = 0; + } catch (ex) { + canExpando = false; + } + var nodeMap = {}, textNodeMap = {}, expando = 'ejs_' + Math.random(), _id = 0, id = function (node, localMap) { + var _textNodeMap = localMap || textNodeMap; + var id = readId(node, _textNodeMap); + if (id) { + return id; + } else { + if (canExpando || node.nodeType !== 3) { + ++_id; + return node[expando] = (node.nodeName ? 'element_' : 'obj_') + _id; + } else { + ++_id; + _textNodeMap['text_' + _id] = node; + return 'text_' + _id; + } + } + }, readId = function (node, textNodeMap) { + if (canExpando || node.nodeType !== 3) { + return node[expando]; + } else { + for (var textNodeID in textNodeMap) { + if (textNodeMap[textNodeID] === node) { + return textNodeID; + } + } + } + }, splice = [].splice, push = [].push, itemsInChildListTree = function (list) { + var count = 0; + for (var i = 0, len = list.length; i < len; i++) { + var item = list[i]; + if (item.nodeType) { + count++; + } else { + count += itemsInChildListTree(item); + } + } + return count; + }, replacementMap = function (replacements, idMap) { + var map = {}; + for (var i = 0, len = replacements.length; i < len; i++) { + var node = nodeLists.first(replacements[i]); + map[id(node, idMap)] = replacements[i]; + } + return map; + }; + var nodeLists = { + id: id, + update: function (nodeList, newNodes) { + var oldNodes = nodeLists.unregisterChildren(nodeList); + newNodes = can.makeArray(newNodes); + var oldListLength = nodeList.length; + splice.apply(nodeList, [ + 0, + oldListLength + ].concat(newNodes)); + if (nodeList.replacements) { + nodeLists.nestReplacements(nodeList); + } else { + nodeLists.nestList(nodeList); + } + return oldNodes; + }, + nestReplacements: function (list) { + var index = 0, idMap = {}, rMap = replacementMap(list.replacements, idMap), rCount = list.replacements.length; + while (index < list.length && rCount) { + var node = list[index], replacement = rMap[readId(node, idMap)]; + if (replacement) { + list.splice(index, itemsInChildListTree(replacement), replacement); + rCount--; + } + index++; + } + list.replacements = []; + }, + nestList: function (list) { + var index = 0; + while (index < list.length) { + var node = list[index], childNodeList = nodeMap[id(node)]; + if (childNodeList) { + if (childNodeList !== list) { + list.splice(index, itemsInChildListTree(childNodeList), childNodeList); + } + } else { + nodeMap[id(node)] = list; + } + index++; + } + }, + last: function (nodeList) { + var last = nodeList[nodeList.length - 1]; + if (last.nodeType) { + return last; + } else { + return nodeLists.last(last); + } + }, + first: function (nodeList) { + var first = nodeList[0]; + if (first.nodeType) { + return first; + } else { + return nodeLists.first(first); + } + }, + flatten: function (nodeList) { + var items = []; + for (var i = 0; i < nodeList.length; i++) { + var item = nodeList[i]; + if (item.nodeType) { + items.push(item); + } else { + items.push.apply(items, nodeLists.flatten(item)); + } + } + return items; + }, + register: function (nodeList, unregistered, parent) { + nodeList.unregistered = unregistered; + nodeList.parentList = parent; + if (parent === true) { + nodeList.replacements = []; + } else if (parent) { + parent.replacements.push(nodeList); + nodeList.replacements = []; + } else { + nodeLists.nestList(nodeList); + } + return nodeList; + }, + unregisterChildren: function (nodeList) { + var nodes = []; + can.each(nodeList, function (node) { + if (node.nodeType) { + if (!nodeList.replacements) { + delete nodeMap[id(node)]; + } + nodes.push(node); + } else { + push.apply(nodes, nodeLists.unregister(node)); + } + }); + return nodes; + }, + unregister: function (nodeList) { + var nodes = nodeLists.unregisterChildren(nodeList); + if (nodeList.unregistered) { + var unregisteredCallback = nodeList.unregistered; + delete nodeList.unregistered; + delete nodeList.replacements; + unregisteredCallback(); + } + return nodes; + }, + nodeMap: nodeMap + }; + can.view.nodeLists = nodeLists; + return nodeLists; +}); +/*can@2.2.6#view/parser/parser*/ +define('can/view/parser/parser', ['can/view/view'], function (can) { + function makeMap(str) { + var obj = {}, items = str.split(','); + for (var i = 0; i < items.length; i++) { + obj[items[i]] = true; + } + return obj; + } + function handleIntermediate(intermediate, handler) { + for (var i = 0, len = intermediate.length; i < len; i++) { + var item = intermediate[i]; + handler[item.tokenType].apply(handler, item.args); + } + return intermediate; + } + var alphaNumericHU = '-:A-Za-z0-9_', attributeNames = '[a-zA-Z_:][' + alphaNumericHU + ':.]*', spaceEQspace = '\\s*=\\s*', dblQuote2dblQuote = '"((?:\\\\.|[^"])*)"', quote2quote = '\'((?:\\\\.|[^\'])*)\'', attributeEqAndValue = '(?:' + spaceEQspace + '(?:' + '(?:"[^"]*")|(?:\'[^\']*\')|[^>\\s]+))?', matchStash = '\\{\\{[^\\}]*\\}\\}\\}?', stash = '\\{\\{([^\\}]*)\\}\\}\\}?', startTag = new RegExp('^<([' + alphaNumericHU + ']+)' + '(' + '(?:\\s*' + '(?:(?:' + '(?:' + attributeNames + ')?' + attributeEqAndValue + ')|' + '(?:' + matchStash + ')+)' + ')*' + ')\\s*(\\/?)>'), endTag = new RegExp('^<\\/([' + alphaNumericHU + ']+)[^>]*>'), attr = new RegExp('(?:' + '(?:(' + attributeNames + ')|' + stash + ')' + '(?:' + spaceEQspace + '(?:' + '(?:' + dblQuote2dblQuote + ')|(?:' + quote2quote + ')|([^>\\s]+)' + ')' + ')?)', 'g'), mustache = new RegExp(stash, 'g'), txtBreak = /<|\{\{/; + var empty = makeMap('area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed'); + var block = makeMap('a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video'); + var inline = makeMap('abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var'); + var closeSelf = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr'); + var fillAttrs = makeMap('checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected'); + var special = makeMap('script,style'); + var tokenTypes = 'start,end,close,attrStart,attrEnd,attrValue,chars,comment,special,done'.split(','); + var fn = function () { + }; + var HTMLParser = function (html, handler, returnIntermediate) { + if (typeof html === 'object') { + return handleIntermediate(html, handler); + } + var intermediate = []; + handler = handler || {}; + if (returnIntermediate) { + can.each(tokenTypes, function (name) { + var callback = handler[name] || fn; + handler[name] = function () { + if (callback.apply(this, arguments) !== false) { + intermediate.push({ + tokenType: name, + args: can.makeArray(arguments) + }); + } + }; + }); + } + function parseStartTag(tag, tagName, rest, unary) { + tagName = tagName.toLowerCase(); + if (block[tagName]) { + while (stack.last() && inline[stack.last()]) { + parseEndTag('', stack.last()); + } + } + if (closeSelf[tagName] && stack.last() === tagName) { + parseEndTag('', tagName); + } + unary = empty[tagName] || !!unary; + handler.start(tagName, unary); + if (!unary) { + stack.push(tagName); + } + HTMLParser.parseAttrs(rest, handler); + handler.end(tagName, unary); + } + function parseEndTag(tag, tagName) { + var pos; + if (!tagName) { + pos = 0; + } else { + for (pos = stack.length - 1; pos >= 0; pos--) { + if (stack[pos] === tagName) { + break; + } + } + } + if (pos >= 0) { + for (var i = stack.length - 1; i >= pos; i--) { + if (handler.close) { + handler.close(stack[i]); + } + } + stack.length = pos; + } + } + function parseMustache(mustache, inside) { + if (handler.special) { + handler.special(inside); + } + } + var index, chars, match, stack = [], last = html; + stack.last = function () { + return this[this.length - 1]; + }; + while (html) { + chars = true; + if (!stack.last() || !special[stack.last()]) { + if (html.indexOf(''); + if (index >= 0) { + if (handler.comment) { + handler.comment(html.substring(4, index)); + } + html = html.substring(index + 3); + chars = false; + } + } else if (html.indexOf(']*>'), function (all, text) { + text = text.replace(/|/g, '$1$2'); + if (handler.chars) { + handler.chars(text); + } + return ''; + }); + parseEndTag('', stack.last()); + } + if (html === last) { + throw 'Parse Error: ' + html; + } + last = html; + } + parseEndTag(); + handler.done(); + return intermediate; + }; + HTMLParser.parseAttrs = function (rest, handler) { + (rest != null ? rest : '').replace(attr, function (text, name, special, dblQuote, singleQuote, val) { + if (special) { + handler.special(special); + } + if (name || dblQuote || singleQuote || val) { + var value = arguments[3] ? arguments[3] : arguments[4] ? arguments[4] : arguments[5] ? arguments[5] : fillAttrs[name.toLowerCase()] ? name : ''; + handler.attrStart(name || ''); + var last = mustache.lastIndex = 0, res = mustache.exec(value), chars; + while (res) { + chars = value.substring(last, mustache.lastIndex - res[0].length); + if (chars.length) { + handler.attrValue(chars); + } + handler.special(res[1]); + last = mustache.lastIndex; + res = mustache.exec(value); + } + chars = value.substr(last, value.length); + if (chars) { + handler.attrValue(chars); + } + handler.attrEnd(name || ''); + } + }); + }; + can.view.parser = HTMLParser; + return HTMLParser; +}); +/*can@2.2.6#view/live/live*/ +define('can/view/live/live', [ + 'can/util/util', + 'can/view/elements', + 'can/view/view', + 'can/view/node_lists/node_lists', + 'can/view/parser/parser' +], function (can, elements, view, nodeLists, parser) { + elements = elements || can.view.elements; + nodeLists = nodeLists || can.view.NodeLists; + parser = parser || can.view.parser; + var setup = function (el, bind, unbind) { + var tornDown = false, teardown = function () { + if (!tornDown) { + tornDown = true; + unbind(data); + can.unbind.call(el, 'removed', teardown); + } + return true; + }, data = { + teardownCheck: function (parent) { + return parent ? false : teardown(); + } + }; + can.bind.call(el, 'removed', teardown); + bind(data); + return data; + }, listen = function (el, compute, change) { + return setup(el, function () { + compute.bind('change', change); + }, function (data) { + compute.unbind('change', change); + if (data.nodeList) { + nodeLists.unregister(data.nodeList); + } + }); + }, getAttributeParts = function (newVal) { + var attrs = {}, attr; + parser.parseAttrs(newVal, { + attrStart: function (name) { + attrs[name] = ''; + attr = name; + }, + attrValue: function (value) { + attrs[attr] += value; + }, + attrEnd: function () { + } + }); + return attrs; + }, splice = [].splice, isNode = function (obj) { + return obj && obj.nodeType; + }, addTextNodeIfNoChildren = function (frag) { + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + }; + var live = { + list: function (el, compute, render, context, parentNode, nodeList) { + var masterNodeList = nodeList || [el], indexMap = [], afterPreviousEvents = false, isTornDown = false, add = function (ev, items, index) { + if (!afterPreviousEvents) { + return; + } + var frag = document.createDocumentFragment(), newNodeLists = [], newIndicies = []; + can.each(items, function (item, key) { + var itemNodeList = []; + if (nodeList) { + nodeLists.register(itemNodeList, null, true); + } + var itemIndex = can.compute(key + index), itemHTML = render.call(context, item, itemIndex, itemNodeList), gotText = typeof itemHTML === 'string', itemFrag = can.frag(itemHTML); + itemFrag = gotText ? can.view.hookup(itemFrag) : itemFrag; + var childNodes = can.makeArray(itemFrag.childNodes); + if (nodeList) { + nodeLists.update(itemNodeList, childNodes); + newNodeLists.push(itemNodeList); + } else { + newNodeLists.push(nodeLists.register(childNodes)); + } + frag.appendChild(itemFrag); + newIndicies.push(itemIndex); + }); + var masterListIndex = index + 1; + if (!masterNodeList[masterListIndex]) { + elements.after(masterListIndex === 1 ? [text] : [nodeLists.last(masterNodeList[masterListIndex - 1])], frag); + } else { + var el = nodeLists.first(masterNodeList[masterListIndex]); + can.insertBefore(el.parentNode, frag, el); + } + splice.apply(masterNodeList, [ + masterListIndex, + 0 + ].concat(newNodeLists)); + splice.apply(indexMap, [ + index, + 0 + ].concat(newIndicies)); + for (var i = index + newIndicies.length, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + }, remove = function (ev, items, index, duringTeardown, fullTeardown) { + if (!afterPreviousEvents) { + return; + } + if (!duringTeardown && data.teardownCheck(text.parentNode)) { + return; + } + if (index < 0) { + index = indexMap.length + index; + } + var removedMappings = masterNodeList.splice(index + 1, items.length), itemsToRemove = []; + can.each(removedMappings, function (nodeList) { + var nodesToRemove = nodeLists.unregister(nodeList); + [].push.apply(itemsToRemove, nodesToRemove); + }); + indexMap.splice(index, items.length); + for (var i = index, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + if (!fullTeardown) { + can.remove(can.$(itemsToRemove)); + } else { + nodeLists.unregister(masterNodeList); + } + }, move = function (ev, item, newIndex, currentIndex) { + if (!afterPreviousEvents) { + return; + } + newIndex = newIndex + 1; + currentIndex = currentIndex + 1; + var referenceNodeList = masterNodeList[newIndex]; + var movedElements = can.frag(nodeLists.flatten(masterNodeList[currentIndex])); + var referenceElement; + if (currentIndex < newIndex) { + referenceElement = nodeLists.last(referenceNodeList).nextSibling; + } else { + referenceElement = nodeLists.first(referenceNodeList); + } + var parentNode = masterNodeList[0].parentNode; + parentNode.insertBefore(movedElements, referenceElement); + var temp = masterNodeList[currentIndex]; + [].splice.apply(masterNodeList, [ + currentIndex, + 1 + ]); + [].splice.apply(masterNodeList, [ + newIndex, + 0, + temp + ]); + }, text = document.createTextNode(''), list, teardownList = function (fullTeardown) { + if (list && list.unbind) { + list.unbind('add', add).unbind('remove', remove).unbind('move', move); + } + remove({}, { length: masterNodeList.length - 1 }, 0, true, fullTeardown); + }, updateList = function (ev, newList, oldList) { + if (isTornDown) { + return; + } + teardownList(); + list = newList || []; + if (list.bind) { + list.bind('add', add).bind('remove', remove).bind('move', move); + } + afterPreviousEvents = true; + add({}, list, 0); + afterPreviousEvents = false; + can.batch.afterPreviousEvents(function () { + afterPreviousEvents = true; + }); + }; + parentNode = elements.getParentNode(el, parentNode); + var data = setup(parentNode, function () { + if (can.isFunction(compute)) { + compute.bind('change', updateList); + } + }, function () { + if (can.isFunction(compute)) { + compute.unbind('change', updateList); + } + teardownList(true); + }); + if (!nodeList) { + live.replace(masterNodeList, text, data.teardownCheck); + } else { + elements.replace(masterNodeList, text); + nodeLists.update(masterNodeList, [text]); + nodeList.unregistered = function () { + data.teardownCheck(); + isTornDown = true; + }; + } + updateList({}, can.isFunction(compute) ? compute() : compute); + }, + html: function (el, compute, parentNode, nodeList) { + var data; + parentNode = elements.getParentNode(el, parentNode); + data = listen(parentNode, compute, function (ev, newVal, oldVal) { + var attached = nodeLists.first(nodes).parentNode; + if (attached) { + makeAndPut(newVal); + } + data.teardownCheck(nodeLists.first(nodes).parentNode); + }); + var nodes = nodeList || [el], makeAndPut = function (val) { + var isFunction = typeof val === 'function', aNode = isNode(val), frag = can.frag(isFunction ? '' : val), oldNodes = can.makeArray(nodes); + addTextNodeIfNoChildren(frag); + if (!aNode && !isFunction) { + frag = can.view.hookup(frag, parentNode); + } + oldNodes = nodeLists.update(nodes, frag.childNodes); + if (isFunction) { + val(frag.childNodes[0]); + } + elements.replace(oldNodes, frag); + }; + data.nodeList = nodes; + if (!nodeList) { + nodeLists.register(nodes, data.teardownCheck); + } else { + nodeList.unregistered = data.teardownCheck; + } + makeAndPut(compute()); + }, + replace: function (nodes, val, teardown) { + var oldNodes = nodes.slice(0), frag = can.frag(val); + nodeLists.register(nodes, teardown); + if (typeof val === 'string') { + frag = can.view.hookup(frag, nodes[0].parentNode); + } + nodeLists.update(nodes, frag.childNodes); + elements.replace(oldNodes, frag); + return nodes; + }, + text: function (el, compute, parentNode, nodeList) { + var parent = elements.getParentNode(el, parentNode); + var data = listen(parent, compute, function (ev, newVal, oldVal) { + if (typeof node.nodeValue !== 'unknown') { + node.nodeValue = can.view.toStr(newVal); + } + data.teardownCheck(node.parentNode); + }); + var node = document.createTextNode(can.view.toStr(compute())); + if (nodeList) { + nodeList.unregistered = data.teardownCheck; + data.nodeList = nodeList; + nodeLists.update(nodeList, [node]); + elements.replace([el], node); + } else { + data.nodeList = live.replace([el], node, data.teardownCheck); + } + }, + setAttributes: function (el, newVal) { + var attrs = getAttributeParts(newVal); + for (var name in attrs) { + can.attr.set(el, name, attrs[name]); + } + }, + attributes: function (el, compute, currentValue) { + var oldAttrs = {}; + var setAttrs = function (newVal) { + var newAttrs = getAttributeParts(newVal), name; + for (name in newAttrs) { + var newValue = newAttrs[name], oldValue = oldAttrs[name]; + if (newValue !== oldValue) { + can.attr.set(el, name, newValue); + } + delete oldAttrs[name]; + } + for (name in oldAttrs) { + elements.removeAttr(el, name); + } + oldAttrs = newAttrs; + }; + listen(el, compute, function (ev, newVal) { + setAttrs(newVal); + }); + if (arguments.length >= 3) { + oldAttrs = getAttributeParts(currentValue); + } else { + setAttrs(compute()); + } + }, + attributePlaceholder: '__!!__', + attributeReplace: /__!!__/g, + attribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, hook.render()); + }); + var wrapped = can.$(el), hooks; + hooks = can.data(wrapped, 'hooks'); + if (!hooks) { + can.data(wrapped, 'hooks', hooks = {}); + } + var attr = elements.getAttr(el, attributeName), parts = attr.split(live.attributePlaceholder), goodParts = [], hook; + goodParts.push(parts.shift(), parts.join(live.attributePlaceholder)); + if (hooks[attributeName]) { + hooks[attributeName].computes.push(compute); + } else { + hooks[attributeName] = { + render: function () { + var i = 0, newAttr = attr ? attr.replace(live.attributeReplace, function () { + return elements.contentText(hook.computes[i++]()); + }) : elements.contentText(hook.computes[i++]()); + return newAttr; + }, + computes: [compute], + batchNum: undefined + }; + } + hook = hooks[attributeName]; + goodParts.splice(1, 0, compute()); + elements.setAttr(el, attributeName, goodParts.join('')); + }, + specialAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, getValue(newVal)); + }); + elements.setAttr(el, attributeName, getValue(compute())); + }, + simpleAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, newVal); + }); + elements.setAttr(el, attributeName, compute()); + } + }; + live.attr = live.simpleAttribute; + live.attrs = live.attributes; + var newLine = /(\r|\n)+/g; + var getValue = function (val) { + var regexp = /^["'].*["']$/; + val = val.replace(elements.attrReg, '').replace(newLine, ''); + return regexp.test(val) ? val.substr(1, val.length - 2) : val; + }; + can.view.live = live; + return live; +}); +/*can@2.2.6#view/render*/ +define('can/view/render', [ + 'can/view/view', + 'can/view/elements', + 'can/view/live/live', + 'can/util/string/string' +], function (can, elements, live) { + var pendingHookups = [], tagChildren = function (tagName) { + var newTag = elements.tagMap[tagName] || 'span'; + if (newTag === 'span') { + return '@@!!@@'; + } + return '<' + newTag + '>' + tagChildren(newTag) + ''; + }, contentText = function (input, tag) { + if (typeof input === 'string') { + return input; + } + if (!input && input !== 0) { + return ''; + } + var hook = input.hookup && function (el, id) { + input.hookup.call(input, el, id); + } || typeof input === 'function' && input; + if (hook) { + if (tag) { + return '<' + tag + ' ' + can.view.hook(hook) + '>'; + } else { + pendingHookups.push(hook); + } + return ''; + } + return '' + input; + }, contentEscape = function (txt, tag) { + return typeof txt === 'string' || typeof txt === 'number' ? can.esc(txt) : contentText(txt, tag); + }, withinTemplatedSectionWithinAnElement = false, emptyHandler = function () { + }; + var lastHookups; + can.extend(can.view, { + live: live, + setupLists: function () { + var old = can.view.lists, data; + can.view.lists = function (list, renderer) { + data = { + list: list, + renderer: renderer + }; + return Math.random(); + }; + return function () { + can.view.lists = old; + return data; + }; + }, + getHooks: function () { + var hooks = pendingHookups.slice(0); + lastHookups = hooks; + pendingHookups = []; + return hooks; + }, + onlytxt: function (self, func) { + return contentEscape(func.call(self)); + }, + txt: function (escape, tagName, status, self, func) { + var tag = elements.tagMap[tagName] || 'span', setupLiveBinding = false, value, listData, compute, unbind = emptyHandler, attributeName; + if (withinTemplatedSectionWithinAnElement) { + value = func.call(self); + } else { + if (typeof status === 'string' || status === 1) { + withinTemplatedSectionWithinAnElement = true; + } + var listTeardown = can.view.setupLists(); + unbind = function () { + compute.unbind('change', emptyHandler); + }; + compute = can.compute(func, self, false); + compute.bind('change', emptyHandler); + listData = listTeardown(); + value = compute(); + withinTemplatedSectionWithinAnElement = false; + setupLiveBinding = compute.computeInstance.hasDependencies; + } + if (listData) { + unbind(); + return '<' + tag + can.view.hook(function (el, parentNode) { + live.list(el, listData.list, listData.renderer, self, parentNode); + }) + '>'; + } + if (!setupLiveBinding || typeof value === 'function') { + unbind(); + return (withinTemplatedSectionWithinAnElement || escape === 2 || !escape ? contentText : contentEscape)(value, status === 0 && tag); + } + var contentProp = elements.tagToContentPropMap[tagName]; + if (status === 0 && !contentProp) { + return '<' + tag + can.view.hook(escape && typeof value !== 'object' ? function (el, parentNode) { + live.text(el, compute, parentNode); + unbind(); + } : function (el, parentNode) { + live.html(el, compute, parentNode); + unbind(); + }) + '>' + tagChildren(tag) + ''; + } else if (status === 1) { + pendingHookups.push(function (el) { + live.attributes(el, compute, compute()); + unbind(); + }); + return compute(); + } else if (escape === 2) { + attributeName = status; + pendingHookups.push(function (el) { + live.specialAttribute(el, attributeName, compute); + unbind(); + }); + return compute(); + } else { + attributeName = status === 0 ? contentProp : status; + (status === 0 ? lastHookups : pendingHookups).push(function (el) { + live.attribute(el, attributeName, compute); + unbind(); + }); + return live.attributePlaceholder; + } + } + }); + return can; +}); +/*can@2.2.6#view/stache/utils*/ +define('can/view/stache/utils', ['can/util/util'], function () { + return { + isArrayLike: function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, + isObserveLike: function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, + emptyHandler: function () { + }, + jsonParse: function (str) { + if (str[0] === '\'') { + return str.substr(1, str.length - 2); + } else if (str === 'undefined') { + return undefined; + } else if (can.global.JSON) { + return JSON.parse(str); + } else { + return eval('(' + str + ')'); + } + }, + mixins: { + last: function () { + return this.stack[this.stack.length - 1]; + }, + add: function (chars) { + this.last().add(chars); + }, + subSectionDepth: function () { + return this.stack.length - 1; + } + } + }; +}); +/*can@2.2.6#view/stache/mustache_helpers*/ +define('can/view/stache/mustache_helpers', [ + 'can/util/util', + 'can/view/stache/utils', + 'can/view/live/live' +], function (can, utils, live) { + live = live || can.view.live; + var resolve = function (value) { + if (utils.isObserveLike(value) && utils.isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + var helpers = { + 'each': function (items, options) { + var resolved = resolve(items), result = [], keys, key, i; + if (resolved instanceof can.List) { + return function (el) { + var nodeList = [el]; + nodeList.expression = 'live.list'; + can.view.nodeLists.register(nodeList, null, options.nodeList); + can.view.nodeLists.update(options.nodeList, [el]); + var cb = function (item, index, parentNodeList) { + return options.fn(options.scope.add({ '@index': index }).add(item), options.options, parentNodeList); + }; + live.list(el, items, cb, options.context, el.parentNode, nodeList); + }; + } + var expr = resolved; + if (!!expr && utils.isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + } else if (utils.isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } + return result; + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + }, + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!resolve(expr); + } + if (value) { + return options.fn(options.scope || this); + } else { + return options.inverse(options.scope || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return helpers.is.apply(this, arguments); + }, + 'unless': function (expr, options) { + return helpers['if'].apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'with': function (expr, options) { + var ctx = expr; + expr = resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + 'data': function (attr) { + var data = arguments.length === 2 ? this : arguments[1]; + return function (el) { + can.data(can.$(el), attr, data || this.context); + }; + } + }; + return { + registerHelper: function (name, callback) { + helpers[name] = callback; + }, + getHelper: function (name, options) { + var helper = options.attr('helpers.' + name); + if (!helper) { + helper = helpers[name]; + } + if (helper) { + return { fn: helper }; + } + } + }; +}); +/*can@2.2.6#view/stache/mustache_core*/ +define('can/view/stache/mustache_core', [ + 'can/util/util', + 'can/view/stache/utils', + 'can/view/stache/mustache_helpers', + 'can/view/live/live', + 'can/view/elements', + 'can/view/scope/scope', + 'can/view/node_lists/node_lists' +], function (can, utils, mustacheHelpers, live, elements, Scope, nodeLists) { + live = live || can.view.live; + elements = elements || can.view.elements; + Scope = Scope || can.view.Scope; + nodeLists = nodeLists || can.view.nodeLists; + var argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(?:(.+?)=(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(.+))))$/, mustacheLineBreakRegExp = /(?:(?:^|(\r?)\n)(\s*)(\{\{([^\}]*)\}\}\}?)([^\S\n\r]*)($|\r?\n))|(\{\{([^\}]*)\}\}\}?)/g, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, getItemsFragContent = function (items, isObserveList, helperOptions, options) { + var frag = document.createDocumentFragment(); + for (var i = 0, len = items.length; i < len; i++) { + append(frag, helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options)); + } + return frag; + }, append = function (frag, content) { + if (content) { + frag.appendChild(typeof content === 'string' ? document.createTextNode(content) : content); + } + }, getItemsStringContent = function (items, isObserveList, helperOptions, options) { + var txt = ''; + for (var i = 0, len = items.length; i < len; i++) { + txt += helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options); + } + return txt; + }, getKeyComputeData = function (key, scope, isArgument) { + var data = scope.computeData(key, { + isArgument: isArgument, + args: [ + scope.attr('.'), + scope + ] + }); + can.compute.temporarilyBind(data.compute); + return data; + }, getKeyArgValue = function (key, scope) { + var data = getKeyComputeData(key, scope, true); + if (!data.compute.computeInstance.hasDependencies) { + return data.initialValue; + } else { + return data.compute; + } + }, convertToScopes = function (helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer) { + if (truthyRenderer) { + helperOptions.fn = makeRendererConvertScopes(truthyRenderer, scope, options, nodeList); + } + if (falseyRenderer) { + helperOptions.inverse = makeRendererConvertScopes(falseyRenderer, scope, options, nodeList); + } + }, makeRendererConvertScopes = function (renderer, parentScope, parentOptions, nodeList) { + var rendererWithScope = function (ctx, opts, parentNodeList) { + return renderer(ctx || parentScope, opts, parentNodeList); + }; + return can.__notObserve(function (newScope, newOptions, parentNodeList) { + if (newScope !== undefined && !(newScope instanceof can.view.Scope)) { + newScope = parentScope.add(newScope); + } + if (newOptions !== undefined && !(newOptions instanceof core.Options)) { + newOptions = parentOptions.add(newOptions); + } + var result = rendererWithScope(newScope, newOptions || parentOptions, parentNodeList || nodeList); + return result; + }); + }; + var core = { + expressionData: function (expression) { + var args = [], hashes = {}, i = 0; + (can.trim(expression) + ' ').replace(argumentsRegExp, function (whole, arg) { + var m; + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[1] || m[2]) { + args.push(utils.jsonParse(m[1] || m[2])); + } else { + hashes[m[3]] = m[6] ? { get: m[6] } : utils.jsonParse(m[4] || m[5]); + } + } else { + args.push({ get: arg }); + } + i++; + }); + return { + name: args.shift(), + args: args, + hash: hashes + }; + }, + makeEvaluator: function (scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, stringOnly) { + var args = [], hash = {}, helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, context = scope.attr('.'), name = exprData.name, helper, looksLikeAHelper = exprData.args.length || !can.isEmptyObject(exprData.hash), initialValue, helperEvaluator; + for (var i = 0, len = exprData.args.length; i < len; i++) { + var arg = exprData.args[i]; + if (arg && isLookup(arg)) { + args.push(getKeyArgValue(arg.get, scope, true)); + } else { + args.push(arg); + } + } + for (var prop in exprData.hash) { + if (isLookup(exprData.hash[prop])) { + hash[prop] = getKeyArgValue(exprData.hash[prop].get, scope); + } else { + hash[prop] = exprData.hash[prop]; + } + } + if (isLookup(name)) { + if (looksLikeAHelper) { + helper = mustacheHelpers.getHelper(name.get, options); + if (!helper && typeof context[name.get] === 'function') { + helper = { fn: context[name.get] }; + } + } + if (!helper) { + var get = name.get; + var computeData = getKeyComputeData(name.get, scope, false), compute = computeData.compute; + initialValue = computeData.initialValue; + if (computeData.compute.computeInstance.hasDependencies) { + name = compute; + } else { + name = initialValue; + } + if (!looksLikeAHelper && initialValue === undefined) { + helper = mustacheHelpers.getHelper(get, options); + } else if (typeof initialValue === 'function') { + helper = { fn: initialValue }; + } + } + } + if (mode === '^') { + var temp = truthyRenderer; + truthyRenderer = falseyRenderer; + falseyRenderer = temp; + } + if (helper) { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + can.simpleExtend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash, + nodeList: nodeList, + exprData: exprData + }); + args.push(helperOptions); + helperEvaluator = function () { + return helper.fn.apply(context, args) || ''; + }; + helperEvaluator.bindOnce = false; + return helperEvaluator; + } + if (!mode) { + if (name && name.isComputed) { + return name; + } else { + return function () { + return '' + (name != null ? name : ''); + }; + } + } else if (mode === '#' || mode === '^') { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + var evaluator = function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + if (utils.isArrayLike(value)) { + var isObserveList = utils.isObserveLike(value); + if (isObserveList ? value.attr('length') : value.length) { + return (stringOnly ? getItemsStringContent : getItemsFragContent)(value, isObserveList, helperOptions, options); + } else { + return helperOptions.inverse(scope, options); + } + } else { + return value ? helperOptions.fn(value || scope, options) : helperOptions.inverse(scope, options); + } + }; + evaluator.bindOnce = false; + return evaluator; + } else { + } + }, + makeLiveBindingPartialRenderer: function (partialName, state) { + partialName = can.trim(partialName); + return function (scope, options, parentSectionNodeList) { + var nodeList = [this]; + nodeList.expression = '>' + partialName; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var partialFrag = can.compute(function () { + var localPartialName = partialName; + var partial = options.attr('partials.' + localPartialName), res; + if (partial) { + res = partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + var scopePartialName = scope.read(localPartialName, { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }).value; + if (scopePartialName) { + localPartialName = scopePartialName; + } + res = can.view.render(localPartialName, scope, options); + } + return can.frag(res); + }); + live.html(this, partialFrag, this.parentNode, nodeList); + }; + }, + makeStringBranchRenderer: function (mode, expression) { + var exprData = expressionData(expression), fullExpression = mode + expression; + return function branchRenderer(scope, options, truthyRenderer, falseyRenderer) { + var evaluator = scope.__cache[fullExpression]; + if (mode || !evaluator) { + evaluator = makeEvaluator(scope, options, null, mode, exprData, truthyRenderer, falseyRenderer, true); + if (!mode) { + scope.__cache[fullExpression] = evaluator; + } + } + var res = evaluator(); + return res == null ? '' : '' + res; + }; + }, + makeLiveBindingBranchRenderer: function (mode, expression, state) { + var exprData = expressionData(expression); + return function branchRenderer(scope, options, parentSectionNodeList, truthyRenderer, falseyRenderer) { + var nodeList = [this]; + nodeList.expression = expression; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var evaluator = makeEvaluator(scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, state.tag); + var compute = can.compute(evaluator, null, false, evaluator.bindOnce === false ? false : true); + compute.bind('change', can.k); + var value = compute(); + if (typeof value === 'function') { + var old = can.__clearReading(); + value(this); + can.__setReading(old); + } else if (compute.computeInstance.hasDependencies) { + if (state.attr) { + live.simpleAttribute(this, state.attr, compute); + } else if (state.tag) { + live.attributes(this, compute); + } else if (state.text && typeof value !== 'object') { + live.text(this, compute, this.parentNode, nodeList); + } else { + live.html(this, compute, this.parentNode, nodeList); + } + } else { + if (state.attr) { + can.attr.set(this, state.attr, value); + } else if (state.tag) { + live.setAttributes(this, value); + } else if (state.text && typeof value === 'string') { + this.nodeValue = value; + } else if (value) { + elements.replace([this], can.frag(value)); + } + } + compute.unbind('change', can.k); + }; + }, + splitModeFromExpression: function (expression, state) { + expression = can.trim(expression); + var mode = expression.charAt(0); + if ('#/{&^>!'.indexOf(mode) >= 0) { + expression = can.trim(expression.substr(1)); + } else { + mode = null; + } + if (mode === '{' && state.node) { + mode = null; + } + return { + mode: mode, + expression: expression + }; + }, + cleanLineEndings: function (template) { + return template.replace(mustacheLineBreakRegExp, function (whole, returnBefore, spaceBefore, special, expression, spaceAfter, returnAfter, spaceLessSpecial, spaceLessExpression, matchIndex) { + spaceAfter = spaceAfter || ''; + returnBefore = returnBefore || ''; + spaceBefore = spaceBefore || ''; + var modeAndExpression = splitModeFromExpression(expression || spaceLessExpression, {}); + if (spaceLessSpecial || '>{'.indexOf(modeAndExpression.mode) >= 0) { + return whole; + } else if ('^#!/'.indexOf(modeAndExpression.mode) >= 0) { + return special + (matchIndex !== 0 && returnAfter.length ? returnBefore + '\n' : ''); + } else { + return spaceBefore + special + spaceAfter + (spaceBefore.length || matchIndex !== 0 ? returnBefore + '\n' : ''); + } + }); + }, + Options: can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }) + }; + var makeEvaluator = core.makeEvaluator, expressionData = core.expressionData, splitModeFromExpression = core.splitModeFromExpression; + return core; +}); +/*can@2.2.6#view/bindings/bindings*/ +define('can/view/bindings/bindings', [ + 'can/util/util', + 'can/view/stache/mustache_core', + 'can/view/callbacks/callbacks', + 'can/control/control', + 'can/view/scope/scope' +], function (can, mustacheCore) { + var isContentEditable = function () { + var values = { + '': true, + 'true': true, + 'false': false + }; + var editable = function (el) { + if (!el || !el.getAttribute) { + return; + } + var attr = el.getAttribute('contenteditable'); + return values[attr]; + }; + return function (el) { + var val = editable(el); + if (typeof val === 'boolean') { + return val; + } else { + return !!editable(el.parentNode); + } + }; + }(), removeCurly = function (value) { + if (value[0] === '{' && value[value.length - 1] === '}') { + return value.substr(1, value.length - 2); + } + return value; + }; + can.view.attr('can-value', function (el, data) { + var attr = can.trim(removeCurly(el.getAttribute('can-value'))), value = data.scope.computeData(attr, { args: [] }).compute, trueValue, falseValue; + if (el.nodeName.toLowerCase() === 'input') { + if (el.type === 'checkbox') { + if (can.attr.has(el, 'can-true-value')) { + trueValue = el.getAttribute('can-true-value'); + } else { + trueValue = true; + } + if (can.attr.has(el, 'can-false-value')) { + falseValue = el.getAttribute('can-false-value'); + } else { + falseValue = false; + } + } + if (el.type === 'checkbox' || el.type === 'radio') { + new Checked(el, { + value: value, + trueValue: trueValue, + falseValue: falseValue + }); + return; + } + } + if (el.nodeName.toLowerCase() === 'select' && el.multiple) { + new Multiselect(el, { value: value }); + return; + } + if (isContentEditable(el)) { + new Content(el, { value: value }); + return; + } + new Value(el, { value: value }); + }); + var special = { + enter: function (data, el, original) { + return { + event: 'keyup', + handler: function (ev) { + if (ev.keyCode === 13) { + return original.call(this, ev); + } + } + }; + } + }; + can.view.attr(/can-[\w\.]+/, function (el, data) { + var attributeName = data.attributeName, event = attributeName.substr('can-'.length), handler = function (ev) { + var attrVal = el.getAttribute(attributeName); + if (!attrVal) { + return; + } + var attrInfo = mustacheCore.expressionData(removeCurly(attrVal)); + var scopeData = data.scope.read(attrInfo.name.get, { + returnObserveMethods: true, + isArgument: true, + executeAnonymousFunctions: true + }); + var args = []; + var $el = can.$(this); + var viewModel = can.viewModel($el[0]); + var localScope = data.scope.add({ + '@element': $el, + '@event': ev, + '@viewModel': viewModel, + '@scope': data.scope, + '@context': data.scope._context + }); + if (!can.isEmptyObject(attrInfo.hash)) { + var hash = {}; + can.each(attrInfo.hash, function (val, key) { + if (val && val.hasOwnProperty('get')) { + var s = !val.get.indexOf('@') ? localScope : data.scope; + hash[key] = s.read(val.get, {}).value; + } else { + hash[key] = val; + } + }); + args.unshift(hash); + } + if (attrInfo.args.length) { + var arg; + for (var i = attrInfo.args.length - 1; i >= 0; i--) { + arg = attrInfo.args[i]; + if (arg && arg.hasOwnProperty('get')) { + var s = !arg.get.indexOf('@') ? localScope : data.scope; + args.unshift(s.read(arg.get, {}).value); + } else { + args.unshift(arg); + } + } + } + if (!args.length) { + args = [ + data.scope._context, + $el + ].concat(can.makeArray(arguments)); + } + return scopeData.value.apply(scopeData.parent, args); + }; + if (special[event]) { + var specialData = special[event](data, el, handler); + handler = specialData.handler; + event = specialData.event; + } + can.bind.call(el, event, handler); + }); + var Value = can.Control.extend({ + init: function () { + if (this.element[0].nodeName.toUpperCase() === 'SELECT') { + setTimeout(can.proxy(this.set, this), 1); + } else { + this.set(); + } + }, + '{value} change': 'set', + set: function () { + if (!this.element) { + return; + } + var val = this.options.value(); + this.element[0].value = val == null ? '' : val; + }, + 'change': function () { + if (!this.element) { + return; + } + var el = this.element[0]; + this.options.value(el.value); + var newVal = this.options.value(); + if (el.value !== newVal) { + el.value = newVal; + } + } + }), Checked = can.Control.extend({ + init: function () { + this.isCheckbox = this.element[0].type.toLowerCase() === 'checkbox'; + this.check(); + }, + '{value} change': 'check', + check: function () { + if (this.isCheckbox) { + var value = this.options.value(), trueValue = this.options.trueValue || true; + this.element[0].checked = value == trueValue; + } else { + var setOrRemove = this.options.value() == this.element[0].value ? 'set' : 'remove'; + can.attr[setOrRemove](this.element[0], 'checked', true); + } + }, + 'change': function () { + if (this.isCheckbox) { + this.options.value(this.element[0].checked ? this.options.trueValue : this.options.falseValue); + } else { + if (this.element[0].checked) { + this.options.value(this.element[0].value); + } + } + } + }), Multiselect = Value.extend({ + init: function () { + this.delimiter = ';'; + setTimeout(can.proxy(this.set, this), 1); + }, + set: function () { + var newVal = this.options.value(); + if (typeof newVal === 'string') { + newVal = newVal.split(this.delimiter); + this.isString = true; + } else if (newVal) { + newVal = can.makeArray(newVal); + } + var isSelected = {}; + can.each(newVal, function (val) { + isSelected[val] = true; + }); + can.each(this.element[0].childNodes, function (option) { + if (option.value) { + option.selected = !!isSelected[option.value]; + } + }); + }, + get: function () { + var values = [], children = this.element[0].childNodes; + can.each(children, function (child) { + if (child.selected && child.value) { + values.push(child.value); + } + }); + return values; + }, + 'change': function () { + var value = this.get(), currentValue = this.options.value(); + if (this.isString || typeof currentValue === 'string') { + this.isString = true; + this.options.value(value.join(this.delimiter)); + } else if (currentValue instanceof can.List) { + currentValue.attr(value, true); + } else { + this.options.value(value); + } + } + }), Content = can.Control.extend({ + init: function () { + this.set(); + this.on('blur', 'setValue'); + }, + '{value} change': 'set', + set: function () { + var val = this.options.value(); + this.element[0].innerHTML = typeof val === 'undefined' ? '' : val; + }, + setValue: function () { + this.options.value(this.element[0].innerHTML); + } + }); +}); +/*can@2.2.6#view/mustache/mustache*/ +define('can/view/mustache/mustache', [ + 'can/util/util', + 'can/view/scope/scope', + 'can/view/view', + 'can/view/scanner', + 'can/compute/compute', + 'can/view/render', + 'can/view/bindings/bindings' +], function (can) { + can.view.ext = '.mustache'; + var SCOPE = 'scope', HASH = '___h4sh', CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options}', SPECIAL_CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options, special: true}', ARG_NAMES = SCOPE + ',options', argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false|null|undefined)|((.+?)=(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false)|(.+))))$/, makeLookupLiteral = function (type) { + return '{get:"' + type.replace(/"/g, '\\"') + '"}'; + }, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, isObserveLike = function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, isArrayLike = function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, makeConvertToScopes = function (original, scope, options) { + var originalWithScope = function (ctx, opts) { + return original(ctx || scope, opts); + }; + return function (updatedScope, updatedOptions) { + if (updatedScope !== undefined && !(updatedScope instanceof can.view.Scope)) { + updatedScope = scope.add(updatedScope); + } + if (updatedOptions !== undefined && !(updatedOptions instanceof can.view.Options)) { + updatedOptions = options.add(updatedOptions); + } + return originalWithScope(updatedScope, updatedOptions || options); + }; + }; + var Mustache = function (options, helpers) { + if (this.constructor !== Mustache) { + var mustache = new Mustache(options); + return function (data, options) { + return mustache.render(data, options); + }; + } + if (typeof options === 'function') { + this.template = { fn: options }; + return; + } + can.extend(this, options); + this.template = this.scanner.scan(this.text, this.name); + }; + can.Mustache = can.global.Mustache = Mustache; + Mustache.prototype.render = function (data, options) { + if (!(data instanceof can.view.Scope)) { + data = new can.view.Scope(data || {}); + } + if (!(options instanceof can.view.Options)) { + options = new can.view.Options(options || {}); + } + options = options || {}; + return this.template.fn.call(data, data, options); + }; + can.extend(Mustache.prototype, { + scanner: new can.view.Scanner({ + text: { + start: '', + scope: SCOPE, + options: ',options: options', + argNames: ARG_NAMES + }, + tokens: [ + [ + 'returnLeft', + '{{{', + '{{[{&]' + ], + [ + 'commentFull', + '{{!}}', + '^[\\s\\t]*{{!.+?}}\\n' + ], + [ + 'commentLeft', + '{{!', + '(\\n[\\s\\t]*{{!|{{!)' + ], + [ + 'escapeFull', + '{{}}', + '(^[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}$)', + function (content) { + return { + before: /^\n.+?\n$/.test(content) ? '\n' : '', + content: content.match(/\{\{(.+?)\}\}/)[1] || '' + }; + } + ], + [ + 'escapeLeft', + '{{' + ], + [ + 'returnRight', + '}}}' + ], + [ + 'right', + '}}' + ] + ], + helpers: [ + { + name: /^>[\s]*\w*/, + fn: function (content, cmd) { + var templateName = can.trim(content.replace(/^>\s?/, '')).replace(/["|']/g, ''); + return 'can.Mustache.renderPartial(\'' + templateName + '\',' + ARG_NAMES + ')'; + } + }, + { + name: /^\s*data\s/, + fn: function (content, cmd) { + var attr = content.match(/["|'](.*)["|']/)[1]; + return 'can.proxy(function(__){' + 'can.data(can.$(__),\'' + attr + '\', this.attr(\'.\')); }, ' + SCOPE + ')'; + } + }, + { + name: /\s*\(([\$\w]+)\)\s*->([^\n]*)/, + fn: function (content) { + var quickFunc = /\s*\(([\$\w]+)\)\s*->([^\n]*)/, parts = content.match(quickFunc); + return 'can.proxy(function(__){var ' + parts[1] + '=can.$(__);with(' + SCOPE + '.attr(\'.\')){' + parts[2] + '}}, this);'; + } + }, + { + name: /^.*$/, + fn: function (content, cmd) { + var mode = false, result = { + content: '', + startTxt: false, + startOnlyTxt: false, + end: false + }; + content = can.trim(content); + if (content.length && (mode = content.match(/^([#^\/]|else$)/))) { + mode = mode[0]; + switch (mode) { + case '#': + case '^': + if (cmd.specialAttribute) { + result.startOnlyTxt = true; + } else { + result.startTxt = true; + result.escaped = 0; + } + break; + case '/': + result.end = true; + result.content += 'return ___v1ew.join("");}}])'; + return result; + } + content = content.substring(1); + } + if (mode !== 'else') { + var args = [], hashes = [], i = 0, m; + result.content += 'can.Mustache.txt(\n' + (cmd.specialAttribute ? SPECIAL_CONTEXT_OBJ : CONTEXT_OBJ) + ',\n' + (mode ? '"' + mode + '"' : 'null') + ','; + (can.trim(content) + ' ').replace(argumentsRegExp, function (whole, arg) { + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[2]) { + args.push(m[0]); + } else { + hashes.push(m[4] + ':' + (m[6] ? m[6] : makeLookupLiteral(m[5]))); + } + } else { + args.push(makeLookupLiteral(arg)); + } + i++; + }); + result.content += args.join(','); + if (hashes.length) { + result.content += ',{' + HASH + ':{' + hashes.join(',') + '}}'; + } + } + if (mode && mode !== 'else') { + result.content += ',[\n\n'; + } + switch (mode) { + case '^': + case '#': + result.content += '{fn:function(' + ARG_NAMES + '){var ___v1ew = [];'; + break; + case 'else': + result.content += 'return ___v1ew.join("");}},\n{inverse:function(' + ARG_NAMES + '){\nvar ___v1ew = [];'; + break; + default: + result.content += ')'; + break; + } + if (!mode) { + result.startTxt = true; + result.end = true; + } + return result; + } + } + ] + }) + }); + var helpers = can.view.Scanner.prototype.helpers; + for (var i = 0; i < helpers.length; i++) { + Mustache.prototype.scanner.helpers.unshift(helpers[i]); + } + Mustache.txt = function (scopeAndOptions, mode, name) { + var scope = scopeAndOptions.scope, options = scopeAndOptions.options, args = [], helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, hash, context = scope.attr('.'), getHelper = true, helper; + for (var i = 3; i < arguments.length; i++) { + var arg = arguments[i]; + if (mode && can.isArray(arg)) { + helperOptions = can.extend.apply(can, [helperOptions].concat(arg)); + } else if (arg && arg[HASH]) { + hash = arg[HASH]; + for (var prop in hash) { + if (isLookup(hash[prop])) { + hash[prop] = Mustache.get(hash[prop].get, scopeAndOptions, false, true); + } + } + } else if (arg && isLookup(arg)) { + args.push(Mustache.get(arg.get, scopeAndOptions, false, true, true)); + } else { + args.push(arg); + } + } + if (isLookup(name)) { + var get = name.get; + name = Mustache.get(name.get, scopeAndOptions, args.length, false); + getHelper = get === name; + } + helperOptions.fn = makeConvertToScopes(helperOptions.fn, scope, options); + helperOptions.inverse = makeConvertToScopes(helperOptions.inverse, scope, options); + if (mode === '^') { + var tmp = helperOptions.fn; + helperOptions.fn = helperOptions.inverse; + helperOptions.inverse = tmp; + } + if (helper = getHelper && (typeof name === 'string' && Mustache.getHelper(name, options)) || can.isFunction(name) && !name.isComputed && { fn: name }) { + can.extend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash + }); + args.push(helperOptions); + return function () { + return helper.fn.apply(context, args) || ''; + }; + } + return function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + var validArgs = args.length ? args : [value], valid = true, result = [], i, argIsObserve, arg; + if (mode) { + for (i = 0; i < validArgs.length; i++) { + arg = validArgs[i]; + argIsObserve = typeof arg !== 'undefined' && isObserveLike(arg); + if (isArrayLike(arg)) { + if (mode === '#') { + valid = valid && !!(argIsObserve ? arg.attr('length') : arg.length); + } else if (mode === '^') { + valid = valid && !(argIsObserve ? arg.attr('length') : arg.length); + } + } else { + valid = mode === '#' ? valid && !!arg : mode === '^' ? valid && !arg : valid; + } + } + } + if (valid) { + if (mode === '#') { + if (isArrayLike(value)) { + var isObserveList = isObserveLike(value); + for (i = 0; i < value.length; i++) { + result.push(helperOptions.fn(isObserveList ? value.attr('' + i) : value[i])); + } + return result.join(''); + } else { + return helperOptions.fn(value || {}) || ''; + } + } else if (mode === '^') { + return helperOptions.inverse(value || {}) || ''; + } else { + return '' + (value != null ? value : ''); + } + } + return ''; + }; + }; + Mustache.get = function (key, scopeAndOptions, isHelper, isArgument, isLookup) { + var context = scopeAndOptions.scope.attr('.'), options = scopeAndOptions.options || {}; + if (isHelper) { + if (Mustache.getHelper(key, options)) { + return key; + } + if (scopeAndOptions.scope && can.isFunction(context[key])) { + return context[key]; + } + } + var computeData = scopeAndOptions.scope.computeData(key, { + isArgument: isArgument, + args: [ + context, + scopeAndOptions.scope + ] + }), compute = computeData.compute; + can.compute.temporarilyBind(compute); + var initialValue = computeData.initialValue, helperObj = Mustache.getHelper(key, options); + if (!isLookup && (initialValue === undefined || computeData.scope !== scopeAndOptions.scope) && Mustache.getHelper(key, options)) { + return key; + } + if (!compute.computeInstance.hasDependencies) { + return initialValue; + } else { + return compute; + } + }; + Mustache.resolve = function (value) { + if (isObserveLike(value) && isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + can.view.Options = can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }); + Mustache._helpers = {}; + Mustache.registerHelper = function (name, fn) { + this._helpers[name] = { + name: name, + fn: fn + }; + }; + Mustache.getHelper = function (name, options) { + var helper; + if (options) { + helper = options.attr('helpers.' + name); + } + return helper ? { fn: helper } : this._helpers[name]; + }; + Mustache.render = function (partial, scope, options) { + if (!can.view.cached[partial]) { + var reads = can.__clearReading(); + var scopePartialName = scope.attr(partial); + if (scopePartialName) { + partial = scopePartialName; + } + can.__setReading(reads); + } + return can.view.render(partial, scope, options); + }; + Mustache.safeString = function (str) { + return { + toString: function () { + return str; + } + }; + }; + Mustache.renderPartial = function (partialName, scope, options) { + var partial = options.attr('partials.' + partialName); + if (partial) { + return partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + return can.Mustache.render(partialName, scope, options); + } + }; + can.each({ + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!Mustache.resolve(expr); + } + if (value) { + return options.fn(options.contexts || this); + } else { + return options.inverse(options.contexts || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = Mustache.resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return Mustache._helpers.is.fn.apply(this, arguments); + }, + 'unless': function (expr, options) { + return Mustache._helpers['if'].fn.apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'each': function (expr, options) { + var resolved = Mustache.resolve(expr), result = [], keys, key, i; + if (can.view.lists && (resolved instanceof can.List || expr && expr.isComputed && resolved === undefined)) { + return can.view.lists(expr, function (item, index) { + return options.fn(options.scope.add({ '@index': index }).add(item)); + }); + } + expr = resolved; + if (!!expr && isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + return result.join(''); + } else if (isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } + }, + 'with': function (expr, options) { + var ctx = expr; + expr = Mustache.resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + } + }, function (fn, name) { + Mustache.registerHelper(name, fn); + }); + can.view.register({ + suffix: 'mustache', + contentType: 'x-mustache-template', + script: function (id, src) { + return 'can.Mustache(function(' + ARG_NAMES + ') { ' + new Mustache({ + text: src, + name: id + }).template.out + ' })'; + }, + renderer: function (id, text) { + return Mustache({ + text: text, + name: id + }); + } + }); + can.mustache.registerHelper = can.proxy(can.Mustache.registerHelper, can.Mustache); + can.mustache.safeString = can.Mustache.safeString; + return can; +}); +/*can@2.2.6#component/component*/ +define('can/component/component', [ + 'can/util/util', + 'can/view/callbacks/callbacks', + 'can/view/elements', + 'can/control/control', + 'can/observe/observe', + 'can/view/mustache/mustache', + 'can/view/bindings/bindings' +], function (can, viewCallbacks, elements) { + var ignoreAttributesRegExp = /^(dataViewId|class|id)$/i, paramReplacer = /\{([^\}]+)\}/g; + var Component = can.Component = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Component) { + var self = this, scope = this.prototype.scope || this.prototype.viewModel; + this.Control = ComponentControl.extend(this.prototype.events); + if (!scope || typeof scope === 'object' && !(scope instanceof can.Map)) { + this.Map = can.Map.extend(scope || {}); + } else if (scope.prototype instanceof can.Map) { + this.Map = scope; + } + this.attributeScopeMappings = {}; + can.each(this.Map ? this.Map.defaults : {}, function (val, prop) { + if (val === '@') { + self.attributeScopeMappings[prop] = prop; + } + }); + if (this.prototype.template) { + if (typeof this.prototype.template === 'function') { + var temp = this.prototype.template; + this.renderer = function () { + return can.view.frag(temp.apply(null, arguments)); + }; + } else { + this.renderer = can.view.mustache(this.prototype.template); + } + } + can.view.tag(this.prototype.tag, function (el, options) { + new self(el, options); + }); + } + } + }, { + setup: function (el, hookupOptions) { + var initialScopeData = {}, component = this, lexicalContent = (typeof this.leakScope === 'undefined' ? false : !this.leakScope) && this.template, twoWayBindings = {}, scope = this.scope || this.viewModel, viewModelPropertyUpdates = {}, componentScope, frag, teardownFunctions = [], callTeardownFunctions = function () { + for (var i = 0, len = teardownFunctions.length; i < len; i++) { + teardownFunctions[i](); + } + }; + can.each(this.constructor.attributeScopeMappings, function (val, prop) { + initialScopeData[prop] = el.getAttribute(can.hyphenate(val)); + }); + can.each(can.makeArray(el.attributes), function (node, index) { + var name = can.camelize(node.nodeName.toLowerCase()), value = node.value; + if (component.constructor.attributeScopeMappings[name] || ignoreAttributesRegExp.test(name) || viewCallbacks.attr(node.nodeName)) { + return; + } + if (value[0] === '{' && value[value.length - 1] === '}') { + value = value.substr(1, value.length - 2); + } else { + if (hookupOptions.templateType !== 'legacy') { + initialScopeData[name] = value; + return; + } + } + var computeData = hookupOptions.scope.computeData(value, { args: [] }), compute = computeData.compute; + var handler = function (ev, newVal) { + viewModelPropertyUpdates[name] = (viewModelPropertyUpdates[name] || 0) + 1; + componentScope.attr(name, newVal); + can.batch.afterPreviousEvents(function () { + --viewModelPropertyUpdates[name]; + }); + }; + compute.bind('change', handler); + initialScopeData[name] = compute(); + if (!compute.computeInstance.hasDependencies) { + compute.unbind('change', handler); + } else { + teardownFunctions.push(function () { + compute.unbind('change', handler); + }); + twoWayBindings[name] = computeData; + } + }); + if (this.constructor.Map) { + componentScope = new this.constructor.Map(initialScopeData); + } else if (scope instanceof can.Map) { + componentScope = scope; + } else if (can.isFunction(scope)) { + var scopeResult = scope.call(this, initialScopeData, hookupOptions.scope, el); + if (scopeResult instanceof can.Map) { + componentScope = scopeResult; + } else if (scopeResult.prototype instanceof can.Map) { + componentScope = new scopeResult(initialScopeData); + } else { + componentScope = new (can.Map.extend(scopeResult))(initialScopeData); + } + } + var handlers = {}; + can.each(twoWayBindings, function (computeData, prop) { + handlers[prop] = function (ev, newVal) { + if (!viewModelPropertyUpdates[prop]) { + computeData.compute(newVal); + } + }; + componentScope.bind(prop, handlers[prop]); + }); + if (!can.isEmptyObject(this.constructor.attributeScopeMappings) || hookupOptions.templateType !== 'legacy') { + can.bind.call(el, 'attributes', function (ev) { + var camelized = can.camelize(ev.attributeName); + if (!twoWayBindings[camelized] && !ignoreAttributesRegExp.test(camelized)) { + componentScope.attr(camelized, el.getAttribute(ev.attributeName)); + } + }); + } + this.scope = this.viewModel = componentScope; + can.data(can.$(el), 'scope', this.scope); + can.data(can.$(el), 'viewModel', this.scope); + var renderedScope = lexicalContent ? this.scope : hookupOptions.scope.add(this.scope), options = { helpers: {} }; + can.each(this.helpers || {}, function (val, prop) { + if (can.isFunction(val)) { + options.helpers[prop] = function () { + return val.apply(componentScope, arguments); + }; + } + }); + teardownFunctions.push(function () { + can.each(handlers, function (handler, prop) { + componentScope.unbind(prop, handlers[prop]); + }); + }); + this._control = new this.constructor.Control(el, { + scope: this.scope, + viewModel: this.scope + }); + if (this._control && this._control.destroy) { + var oldDestroy = this._control.destroy; + this._control.destroy = function () { + oldDestroy.apply(this, arguments); + callTeardownFunctions(); + }; + this._control.on(); + } else { + can.bind.call(el, 'removed', function () { + callTeardownFunctions(); + }); + } + var nodeList = can.view.nodeLists.register([], undefined, true); + teardownFunctions.push(function () { + can.view.nodeLists.unregister(nodeList); + }); + if (this.constructor.renderer) { + if (!options.tags) { + options.tags = {}; + } + options.tags.content = function contentHookup(el, rendererOptions) { + var subtemplate = hookupOptions.subtemplate || rendererOptions.subtemplate; + if (subtemplate) { + delete options.tags.content; + var opts = !lexicalContent || subtemplate !== hookupOptions.subtemplate ? rendererOptions : hookupOptions; + if (rendererOptions.parentNodeList) { + var frag = subtemplate(opts.scope, opts.options, rendererOptions.parentNodeList); + elements.replace([el], frag); + } else { + can.view.live.replace([el], subtemplate(opts.scope, opts.options)); + } + options.tags.content = contentHookup; + } + }; + frag = this.constructor.renderer(renderedScope, hookupOptions.options.add(options), nodeList); + } else { + if (hookupOptions.templateType === 'legacy') { + frag = can.view.frag(hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options)) : ''); + } else { + frag = hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options), nodeList) : document.createDocumentFragment(); + } + } + can.appendChild(el, frag); + can.view.nodeLists.update(nodeList, el.childNodes); + } + }); + var ComponentControl = can.Control.extend({ + _lookup: function (options) { + return [ + options.scope, + options, + window + ]; + }, + _action: function (methodName, options, controlInstance) { + var hasObjectLookup, readyCompute; + paramReplacer.lastIndex = 0; + hasObjectLookup = paramReplacer.test(methodName); + if (!controlInstance && hasObjectLookup) { + return; + } else if (!hasObjectLookup) { + return can.Control._action.apply(this, arguments); + } else { + readyCompute = can.compute(function () { + var delegate; + var name = methodName.replace(paramReplacer, function (matched, key) { + var value; + if (key === 'scope' || key === 'viewModel') { + delegate = options.scope; + return ''; + } + key = key.replace(/^(scope|^viewModel)\./, ''); + value = can.compute.read(options.scope, key.split('.'), { isArgument: true }).value; + if (value === undefined) { + value = can.getObject(key); + } + if (typeof value === 'string') { + return value; + } else { + delegate = value; + return ''; + } + }); + var parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: this.processors[event] || this.processors.click, + parts: [ + name, + parts.join(' '), + event + ], + delegate: delegate || undefined + }; + }, this); + var handler = function (ev, ready) { + controlInstance._bindings.control[methodName](controlInstance.element); + controlInstance._bindings.control[methodName] = ready.processor(ready.delegate || controlInstance.element, ready.parts[2], ready.parts[1], methodName, controlInstance); + }; + readyCompute.bind('change', handler); + controlInstance._bindings.readyComputes[methodName] = { + compute: readyCompute, + handler: handler + }; + return readyCompute(); + } + } + }, { + setup: function (el, options) { + this.scope = options.scope; + this.viewModel = options.viewModel; + return can.Control.prototype.setup.call(this, el, options); + }, + off: function () { + if (this._bindings) { + can.each(this._bindings.readyComputes || {}, function (value) { + value.compute.unbind('change', value.handler); + }); + } + can.Control.prototype.off.apply(this, arguments); + this._bindings.readyComputes = {}; + } + }); + var $ = can.$; + if ($.fn) { + $.fn.scope = $.fn.viewModel = function () { + return can.viewModel.apply(can, [this].concat(can.makeArray(arguments))); + }; + } + return Component; +}); +/*can@2.2.6#model/model*/ +define('can/model/model', [ + 'can/util/util', + 'can/map/map', + 'can/list/list' +], function (can) { + var pipe = function (def, thisArg, func) { + var d = new can.Deferred(); + def.then(function () { + var args = can.makeArray(arguments), success = true; + try { + args[0] = func.apply(thisArg, args); + } catch (e) { + success = false; + d.rejectWith(d, [e].concat(args)); + } + if (success) { + d.resolveWith(d, args); + } + }, function () { + d.rejectWith(this, arguments); + }); + if (typeof def.abort === 'function') { + d.abort = function () { + return def.abort(); + }; + } + return d; + }, modelNum = 0, getId = function (inst) { + can.__observe(inst, inst.constructor.id); + return inst.__get(inst.constructor.id); + }, ajax = function (ajaxOb, data, type, dataType, success, error) { + var params = {}; + if (typeof ajaxOb === 'string') { + var parts = ajaxOb.split(/\s+/); + params.url = parts.pop(); + if (parts.length) { + params.type = parts.pop(); + } + } else { + can.extend(params, ajaxOb); + } + params.data = typeof data === 'object' && !can.isArray(data) ? can.extend(params.data || {}, data) : data; + params.url = can.sub(params.url, params.data, true); + return can.ajax(can.extend({ + type: type || 'post', + dataType: dataType || 'json', + success: success, + error: error + }, params)); + }, makeRequest = function (modelObj, type, success, error, method) { + var args; + if (can.isArray(modelObj)) { + args = modelObj[1]; + modelObj = modelObj[0]; + } else { + args = modelObj.serialize(); + } + args = [args]; + var deferred, model = modelObj.constructor, jqXHR; + if (type === 'update' || type === 'destroy') { + args.unshift(getId(modelObj)); + } + jqXHR = model[type].apply(model, args); + deferred = pipe(jqXHR, modelObj, function (data) { + modelObj[method || type + 'd'](data, jqXHR); + return modelObj; + }); + if (jqXHR.abort) { + deferred.abort = function () { + jqXHR.abort(); + }; + } + deferred.then(success, error); + return deferred; + }, converters = { + models: function (instancesRawData, oldList, xhr) { + can.Model._reqs++; + if (!instancesRawData) { + return; + } + if (instancesRawData instanceof this.List) { + return instancesRawData; + } + var self = this, tmp = [], ListClass = self.List || ML, modelList = oldList instanceof can.List ? oldList : new ListClass(), rawDataIsList = instancesRawData instanceof ML, raw = rawDataIsList ? instancesRawData.serialize() : instancesRawData; + raw = self.parseModels(raw, xhr); + if (raw.data) { + instancesRawData = raw; + raw = raw.data; + } + if (typeof raw === 'undefined' || !can.isArray(raw)) { + throw new Error('Could not get any raw data while converting using .models'); + } + if (modelList.length) { + modelList.splice(0); + } + can.each(raw, function (rawPart) { + tmp.push(self.model(rawPart, xhr)); + }); + modelList.push.apply(modelList, tmp); + if (!can.isArray(instancesRawData)) { + can.each(instancesRawData, function (val, prop) { + if (prop !== 'data') { + modelList.attr(prop, val); + } + }); + } + setTimeout(can.proxy(this._clean, this), 1); + return modelList; + }, + model: function (attributes, oldModel, xhr) { + if (!attributes) { + return; + } + if (typeof attributes.serialize === 'function') { + attributes = attributes.serialize(); + } else { + attributes = this.parseModel(attributes, xhr); + } + var id = attributes[this.id]; + if ((id || id === 0) && this.store[id]) { + oldModel = this.store[id]; + } + var model = oldModel && can.isFunction(oldModel.attr) ? oldModel.attr(attributes, this.removeAttr || false) : new this(attributes); + return model; + } + }, makeParser = { + parseModel: function (prop) { + return function (attributes) { + return prop ? can.getObject(prop, attributes) : attributes; + }; + }, + parseModels: function (prop) { + return function (attributes) { + if (can.isArray(attributes)) { + return attributes; + } + prop = prop || 'data'; + var result = can.getObject(prop, attributes); + if (!can.isArray(result)) { + throw new Error('Could not get any raw data while converting using .models'); + } + return result; + }; + } + }, ajaxMethods = { + create: { + url: '_shortName', + type: 'post' + }, + update: { + data: function (id, attrs) { + attrs = attrs || {}; + var identity = this.id; + if (attrs[identity] && attrs[identity] !== id) { + attrs['new' + can.capitalize(id)] = attrs[identity]; + delete attrs[identity]; + } + attrs[identity] = id; + return attrs; + }, + type: 'put' + }, + destroy: { + type: 'delete', + data: function (id, attrs) { + attrs = attrs || {}; + attrs.id = attrs[this.id] = id; + return attrs; + } + }, + findAll: { url: '_shortName' }, + findOne: {} + }, ajaxMaker = function (ajaxMethod, str) { + return function (data) { + data = ajaxMethod.data ? ajaxMethod.data.apply(this, arguments) : data; + return ajax(str || this[ajaxMethod.url || '_url'], data, ajaxMethod.type || 'get'); + }; + }, createURLFromResource = function (model, name) { + if (!model.resource) { + return; + } + var resource = model.resource.replace(/\/+$/, ''); + if (name === 'findAll' || name === 'create') { + return resource; + } else { + return resource + '/{' + model.id + '}'; + } + }; + can.Model = can.Map.extend({ + fullName: 'can.Model', + _reqs: 0, + setup: function (base, fullName, staticProps, protoProps) { + if (typeof fullName !== 'string') { + protoProps = staticProps; + staticProps = fullName; + } + if (!protoProps) { + protoProps = staticProps; + } + this.store = {}; + can.Map.setup.apply(this, arguments); + if (!can.Model) { + return; + } + if (staticProps && staticProps.List) { + this.List = staticProps.List; + this.List.Map = this; + } else { + this.List = base.List.extend({ Map: this }, {}); + } + var self = this, clean = can.proxy(this._clean, self); + can.each(ajaxMethods, function (method, name) { + if (staticProps && staticProps[name] && (typeof staticProps[name] === 'string' || typeof staticProps[name] === 'object')) { + self[name] = ajaxMaker(method, staticProps[name]); + } else if (staticProps && staticProps.resource && !can.isFunction(staticProps[name])) { + self[name] = ajaxMaker(method, createURLFromResource(self, name)); + } + if (self['make' + can.capitalize(name)]) { + var newMethod = self['make' + can.capitalize(name)](self[name]); + can.Construct._overwrite(self, base, name, function () { + can.Model._reqs++; + var def = newMethod.apply(this, arguments); + var then = def.then(clean, clean); + then.abort = def.abort; + return then; + }); + } + }); + var hasCustomConverter = {}; + can.each(converters, function (converter, name) { + var parseName = 'parse' + can.capitalize(name), dataProperty = staticProps && staticProps[name] || self[name]; + if (typeof dataProperty === 'string') { + self[parseName] = dataProperty; + can.Construct._overwrite(self, base, name, converter); + } else if (staticProps && staticProps[name]) { + hasCustomConverter[parseName] = true; + } + }); + can.each(makeParser, function (maker, parseName) { + var prop = staticProps && staticProps[parseName] || self[parseName]; + if (typeof prop === 'string') { + can.Construct._overwrite(self, base, parseName, maker(prop)); + } else if ((!staticProps || !can.isFunction(staticProps[parseName])) && !self[parseName]) { + var madeParser = maker(); + madeParser.useModelConverter = hasCustomConverter[parseName]; + can.Construct._overwrite(self, base, parseName, madeParser); + } + }); + if (self.fullName === 'can.Model' || !self.fullName) { + self.fullName = 'Model' + ++modelNum; + } + can.Model._reqs = 0; + this._url = this._shortName + '/{' + this.id + '}'; + }, + _ajax: ajaxMaker, + _makeRequest: makeRequest, + _clean: function () { + can.Model._reqs--; + if (!can.Model._reqs) { + for (var id in this.store) { + if (!this.store[id]._bindings) { + delete this.store[id]; + } + } + } + return arguments[0]; + }, + models: converters.models, + model: converters.model + }, { + setup: function (attrs) { + var id = attrs && attrs[this.constructor.id]; + if (can.Model._reqs && id != null) { + this.constructor.store[id] = this; + } + can.Map.prototype.setup.apply(this, arguments); + }, + isNew: function () { + var id = getId(this); + return !(id || id === 0); + }, + save: function (success, error) { + return makeRequest(this, this.isNew() ? 'create' : 'update', success, error); + }, + destroy: function (success, error) { + if (this.isNew()) { + var self = this; + var def = can.Deferred(); + def.then(success, error); + return def.done(function (data) { + self.destroyed(data); + }).resolve(self); + } + return makeRequest(this, 'destroy', success, error, 'destroyed'); + }, + _bindsetup: function () { + var modelInstance = this.__get(this.constructor.id); + if (modelInstance != null) { + this.constructor.store[modelInstance] = this; + } + return can.Map.prototype._bindsetup.apply(this, arguments); + }, + _bindteardown: function () { + delete this.constructor.store[getId(this)]; + return can.Map.prototype._bindteardown.apply(this, arguments); + }, + ___set: function (prop, val) { + can.Map.prototype.___set.call(this, prop, val); + if (prop === this.constructor.id && this._bindings) { + this.constructor.store[getId(this)] = this; + } + } + }); + var makeGetterHandler = function (name) { + return function (data, readyState, xhr) { + return this[name](data, null, xhr); + }; + }, createUpdateDestroyHandler = function (data) { + if (this.parseModel.useModelConverter) { + return this.model(data); + } + return this.parseModel(data); + }; + var responseHandlers = { + makeFindAll: makeGetterHandler('models'), + makeFindOne: makeGetterHandler('model'), + makeCreate: createUpdateDestroyHandler, + makeUpdate: createUpdateDestroyHandler, + makeDestroy: createUpdateDestroyHandler + }; + can.each(responseHandlers, function (method, name) { + can.Model[name] = function (oldMethod) { + return function () { + var args = can.makeArray(arguments), oldArgs = can.isFunction(args[1]) ? args.splice(0, 1) : args.splice(0, 2), def = pipe(oldMethod.apply(this, oldArgs), this, method); + def.then(args[0], args[1]); + return def; + }; + }; + }); + can.each([ + 'created', + 'updated', + 'destroyed' + ], function (funcName) { + can.Model.prototype[funcName] = function (attrs) { + var self = this, constructor = self.constructor; + if (attrs && typeof attrs === 'object') { + this.attr(can.isFunction(attrs.attr) ? attrs.attr() : attrs); + } + can.dispatch.call(this, { + type: 'change', + target: this + }, [funcName]); + can.dispatch.call(constructor, funcName, [this]); + }; + }); + var ML = can.Model.List = can.List.extend({ + _bubbleRule: function (eventName, list) { + var bubbleRules = can.List._bubbleRule(eventName, list); + bubbleRules.push('destroyed'); + return bubbleRules; + } + }, { + setup: function (params) { + if (can.isPlainObject(params) && !can.isArray(params)) { + can.List.prototype.setup.apply(this); + this.replace(can.isDeferred(params) ? params : this.constructor.Map.findAll(params)); + } else { + can.List.prototype.setup.apply(this, arguments); + } + this._init = 1; + this.bind('destroyed', can.proxy(this._destroyed, this)); + delete this._init; + }, + _destroyed: function (ev, attr) { + if (/\w+/.test(attr)) { + var index; + while ((index = this.indexOf(ev.target)) > -1) { + this.splice(index, 1); + } + } + } + }); + return can.Model; +}); +/*can@2.2.6#util/string/deparam/deparam*/ +define('can/util/string/deparam/deparam', [ + 'can/util/util', + 'can/util/string/string' +], function (can) { + var digitTest = /^\d+$/, keyBreaker = /([^\[\]]+)|(\[\])/g, paramTest = /([^?#]*)(#.*)?$/, prep = function (str) { + return decodeURIComponent(str.replace(/\+/g, ' ')); + }; + can.extend(can, { + deparam: function (params) { + var data = {}, pairs, lastPart; + if (params && paramTest.test(params)) { + pairs = params.split('&'); + can.each(pairs, function (pair) { + var parts = pair.split('='), key = prep(parts.shift()), value = prep(parts.join('=')), current = data; + if (key) { + parts = key.match(keyBreaker); + for (var j = 0, l = parts.length - 1; j < l; j++) { + if (!current[parts[j]]) { + current[parts[j]] = digitTest.test(parts[j + 1]) || parts[j + 1] === '[]' ? [] : {}; + } + current = current[parts[j]]; + } + lastPart = parts.pop(); + if (lastPart === '[]') { + current.push(value); + } else { + current[lastPart] = value; + } + } + }); + } + return data; + } + }); + return can; +}); +/*can@2.2.6#route/route*/ +define('can/route/route', [ + 'can/util/util', + 'can/map/map', + 'can/list/list', + 'can/util/string/deparam/deparam' +], function (can) { + var matcher = /\:([\w\.]+)/g, paramsMatcher = /^(?:&[^=]+=[^&]*)+/, makeProps = function (props) { + var tags = []; + can.each(props, function (val, name) { + tags.push((name === 'className' ? 'class' : name) + '="' + (name === 'href' ? val : can.esc(val)) + '"'); + }); + return tags.join(' '); + }, matchesData = function (route, data) { + var count = 0, i = 0, defaults = {}; + for (var name in route.defaults) { + if (route.defaults[name] === data[name]) { + defaults[name] = 1; + count++; + } + } + for (; i < route.names.length; i++) { + if (!data.hasOwnProperty(route.names[i])) { + return -1; + } + if (!defaults[route.names[i]]) { + count++; + } + } + return count; + }, location = window.location, wrapQuote = function (str) { + return (str + '').replace(/([.?*+\^$\[\]\\(){}|\-])/g, '\\$1'); + }, each = can.each, extend = can.extend, stringify = function (obj) { + if (obj && typeof obj === 'object') { + if (obj instanceof can.Map) { + obj = obj.attr(); + } else { + obj = can.isFunction(obj.slice) ? obj.slice() : can.extend({}, obj); + } + can.each(obj, function (val, prop) { + obj[prop] = stringify(val); + }); + } else if (obj !== undefined && obj !== null && can.isFunction(obj.toString)) { + obj = obj.toString(); + } + return obj; + }, removeBackslash = function (str) { + return str.replace(/\\/g, ''); + }, timer, curParams, lastHash, changingData, changedAttrs = [], onRouteDataChange = function (ev, attr, how, newval) { + changingData = 1; + changedAttrs.push(attr); + clearTimeout(timer); + timer = setTimeout(function () { + changingData = 0; + var serialized = can.route.data.serialize(), path = can.route.param(serialized, true); + can.route._call('setURL', path, changedAttrs); + can.batch.trigger(eventsObject, '__url', [ + path, + lastHash + ]); + lastHash = path; + changedAttrs = []; + }, 10); + }, eventsObject = can.extend({}, can.event); + can.route = function (url, defaults) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + defaults = defaults || {}; + var names = [], res, test = '', lastIndex = matcher.lastIndex = 0, next, querySeparator = can.route._call('querySeparator'), matchSlashes = can.route._call('matchSlashes'); + while (res = matcher.exec(url)) { + names.push(res[1]); + test += removeBackslash(url.substring(lastIndex, matcher.lastIndex - res[0].length)); + next = '\\' + (removeBackslash(url.substr(matcher.lastIndex, 1)) || querySeparator + (matchSlashes ? '' : '|/')); + test += '([^' + next + ']' + (defaults[res[1]] ? '*' : '+') + ')'; + lastIndex = matcher.lastIndex; + } + test += url.substr(lastIndex).replace('\\', ''); + can.route.routes[url] = { + test: new RegExp('^' + test + '($|' + wrapQuote(querySeparator) + ')'), + route: url, + names: names, + defaults: defaults, + length: url.split('/').length + }; + return can.route; + }; + extend(can.route, { + param: function (data, _setRoute) { + var route, matches = 0, matchCount, routeName = data.route, propCount = 0; + delete data.route; + each(data, function () { + propCount++; + }); + each(can.route.routes, function (temp, name) { + matchCount = matchesData(temp, data); + if (matchCount > matches) { + route = temp; + matches = matchCount; + } + if (matchCount >= propCount) { + return false; + } + }); + if (can.route.routes[routeName] && matchesData(can.route.routes[routeName], data) === matches) { + route = can.route.routes[routeName]; + } + if (route) { + var cpy = extend({}, data), res = route.route.replace(matcher, function (whole, name) { + delete cpy[name]; + return data[name] === route.defaults[name] ? '' : encodeURIComponent(data[name]); + }).replace('\\', ''), after; + each(route.defaults, function (val, name) { + if (cpy[name] === val) { + delete cpy[name]; + } + }); + after = can.param(cpy); + if (_setRoute) { + can.route.attr('route', route.route); + } + return res + (after ? can.route._call('querySeparator') + after : ''); + } + return can.isEmptyObject(data) ? '' : can.route._call('querySeparator') + can.param(data); + }, + deparam: function (url) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + var route = { length: -1 }, querySeparator = can.route._call('querySeparator'), paramsMatcher = can.route._call('paramsMatcher'); + each(can.route.routes, function (temp, name) { + if (temp.test.test(url) && temp.length > route.length) { + route = temp; + } + }); + if (route.length > -1) { + var parts = url.match(route.test), start = parts.shift(), remainder = url.substr(start.length - (parts[parts.length - 1] === querySeparator ? 1 : 0)), obj = remainder && paramsMatcher.test(remainder) ? can.deparam(remainder.slice(1)) : {}; + obj = extend(true, {}, route.defaults, obj); + each(parts, function (part, i) { + if (part && part !== querySeparator) { + obj[route.names[i]] = decodeURIComponent(part); + } + }); + obj.route = route.route; + return obj; + } + if (url.charAt(0) !== querySeparator) { + url = querySeparator + url; + } + return paramsMatcher.test(url) ? can.deparam(url.slice(1)) : {}; + }, + data: new can.Map({}), + map: function (data) { + var appState; + if (data.prototype instanceof can.Map) { + appState = new data(); + } else { + appState = data; + } + can.route.data = appState; + }, + routes: {}, + ready: function (val) { + if (val !== true) { + can.route._setup(); + can.route.setState(); + } + return can.route; + }, + url: function (options, merge) { + if (merge) { + options = can.extend({}, can.route.deparam(can.route._call('matchingPartOfURL')), options); + } + return can.route._call('root') + can.route.param(options); + }, + link: function (name, options, props, merge) { + return '' + name + ''; + }, + current: function (options) { + can.__observe(eventsObject, '__url'); + return this._call('matchingPartOfURL') === can.route.param(options); + }, + bindings: { + hashchange: { + paramsMatcher: paramsMatcher, + querySeparator: '&', + matchSlashes: false, + bind: function () { + can.bind.call(window, 'hashchange', setState); + }, + unbind: function () { + can.unbind.call(window, 'hashchange', setState); + }, + matchingPartOfURL: function () { + return location.href.split(/#!?/)[1] || ''; + }, + setURL: function (path) { + if (location.hash !== '#' + path) { + location.hash = '!' + path; + } + return path; + }, + root: '#!' + } + }, + defaultBinding: 'hashchange', + currentBinding: null, + _setup: function () { + if (!can.route.currentBinding) { + can.route._call('bind'); + can.route.bind('change', onRouteDataChange); + can.route.currentBinding = can.route.defaultBinding; + } + }, + _teardown: function () { + if (can.route.currentBinding) { + can.route._call('unbind'); + can.route.unbind('change', onRouteDataChange); + can.route.currentBinding = null; + } + clearTimeout(timer); + changingData = 0; + }, + _call: function () { + var args = can.makeArray(arguments), prop = args.shift(), binding = can.route.bindings[can.route.currentBinding || can.route.defaultBinding], method = binding[prop]; + if (method.apply) { + return method.apply(binding, args); + } else { + return method; + } + } + }); + each([ + 'bind', + 'unbind', + 'on', + 'off', + 'delegate', + 'undelegate', + 'removeAttr', + 'compute', + '_get', + '__get', + 'each' + ], function (name) { + can.route[name] = function () { + if (!can.route.data[name]) { + return; + } + return can.route.data[name].apply(can.route.data, arguments); + }; + }); + can.route.attr = function (attr, val) { + var type = typeof attr, newArguments; + if (val === undefined) { + newArguments = arguments; + } else if (type !== 'string' && type !== 'number') { + newArguments = [ + stringify(attr), + val + ]; + } else { + newArguments = [ + attr, + stringify(val) + ]; + } + return can.route.data.attr.apply(can.route.data, newArguments); + }; + var setState = can.route.setState = function () { + var hash = can.route._call('matchingPartOfURL'); + var oldParams = curParams; + curParams = can.route.deparam(hash); + if (!changingData || hash !== lastHash) { + can.batch.start(); + recursiveClean(oldParams, curParams, can.route.data); + can.route.attr(curParams); + can.batch.trigger(eventsObject, '__url', [ + hash, + lastHash + ]); + can.batch.stop(); + } + }; + var recursiveClean = function (old, cur, data) { + for (var attr in old) { + if (cur[attr] === undefined) { + data.removeAttr(attr); + } else if (Object.prototype.toString.call(old[attr]) === '[object Object]') { + recursiveClean(old[attr], cur[attr], data.attr(attr)); + } + } + }; + return can.route; +}); +/*can@2.2.6#control/route/route*/ +define('can/control/route/route', [ + 'can/util/util', + 'can/route/route', + 'can/control/control' +], function (can) { + can.Control.processors.route = function (el, event, selector, funcName, controller) { + selector = selector || ''; + if (!can.route.routes[selector]) { + if (selector[0] === '/') { + selector = selector.substring(1); + } + can.route(selector); + } + var batchNum, check = function (ev, attr, how) { + if (can.route.attr('route') === selector && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + batchNum = ev.batchNum; + var d = can.route.attr(); + delete d.route; + if (can.isFunction(controller[funcName])) { + controller[funcName](d); + } else { + controller[controller[funcName]](d); + } + } + }; + can.route.bind('change', check); + return function () { + can.route.unbind('change', check); + }; + }; + return can; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.mootools.min.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.mootools.min.js new file mode 100644 index 0000000000..29c6cdad00 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.mootools.min.js @@ -0,0 +1,96 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +!function(exports,global){var origDefine=global.define,get=function(e){var o,l=e.split("."),n=global;for(o=0;o=0&&(e.defaultChecked=!0)):l?(i=a,e[l]!==a&&(e[l]=a),"value"===l&&t.inArray(o,r.defaultValue)>=0&&(e.defaultValue=a)):(e.setAttribute(n,a),i=a),r.MutationObserver||i===u||r.trigger(e,n,u)},trigger:function(r,n,a){return t.data(t.$(r),"canHasAttributesBindings")?(n=n.toLowerCase(),e(function(){t.trigger(r,{type:"attributes",attributeName:n,target:r,oldValue:a,bubbles:!1},[])})):void 0},get:function(t,e){e=e.toLowerCase();var n=r.map[e];return"string"==typeof n&&t[n]?t[n]:t.getAttribute(e)},remove:function(t,e){e=e.toLowerCase();var n;r.MutationObserver||(n=r.get(t,e));var a=r.map[e];"function"==typeof a&&a(t,void 0),a===!0?t[e]=!1:"string"==typeof a?t[a]="":t.removeAttribute(e),r.MutationObserver||null==n||r.trigger(t,e,n)},has:function(){var e=t.global.document&&document.createElement("div");return e&&e.hasAttribute?function(t,e){return t.hasAttribute(e)}:function(t,e){return null!==t.getAttribute(e)}}()};return r}); +/*can@2.2.6#event/event*/ +define("can/event/event",["can/util/can"],function(t){return t.addEvent=function(t,n){var e=this.__bindEvents||(this.__bindEvents={}),i=e[t]||(e[t]=[]);return i.push({handler:n,name:t}),this},t.listenTo=function(n,e,i){var r=this.__listenToEvents;r||(r=this.__listenToEvents={});var s=t.cid(n),o=r[s];o||(o=r[s]={obj:n,events:{}});var a=o.events[e];a||(a=o.events[e]=[]),a.push(i),t.bind.call(n,e,i)},t.stopListening=function(n,e,i){var r=this.__listenToEvents,s=r,o=0;if(!r)return this;if(n){var a=t.cid(n);if((s={})[a]=r[a],!r[a])return this}for(var v in s){var l,h=s[v];n=r[v].obj,e?(l={})[e]=h.events[e]:l=h.events;for(var u in l){var d=l[u]||[];for(o=0;oo;o++)r[o].handler.apply(this,s);return t}},t.one=function(n,e){var i=function(){return t.unbind.call(this,n,i),e.apply(this,arguments)};return t.bind.call(this,n,i),this},t.event={on:function(){return 0===arguments.length&&t.Control&&this instanceof t.Control?t.Control.prototype.on.call(this):t.addEvent.apply(this,arguments)},off:function(){return 0===arguments.length&&t.Control&&this instanceof t.Control?t.Control.prototype.off.call(this):t.removeEvent.apply(this,arguments)},bind:t.addEvent,unbind:t.removeEvent,delegate:function(n,e,i){return t.addEvent.call(this,e,i)},undelegate:function(n,e,i){return t.removeEvent.call(this,e,i)},trigger:t.dispatch,one:t.one,addEvent:t.addEvent,removeEvent:t.removeEvent,listenTo:t.listenTo,stopListening:t.stopListening,dispatch:t.dispatch},t.event}); +/*can@2.2.6#util/fragment*/ +define("can/util/fragment",["can/util/can"],function(e){var t=/^\s*<(\w+)[^>]*>/,n={}.toString,i=function(e,i){void 0===i&&(i=t.test(e)&&RegExp.$1),e&&"[object Function]"===n.call(e.replace)&&(e=e.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,"<$1>"));var l=document.createElement("div"),d=document.createElement("div");"tbody"===i||"tfoot"===i||"thead"===i?(d.innerHTML=""+e+"
            ",l=3===d.firstChild.nodeType?d.lastChild:d.firstChild):"tr"===i?(d.innerHTML=""+e+"
            ",l=3===d.firstChild.nodeType?d.lastChild:d.firstChild.firstChild):"td"===i||"th"===i?(d.innerHTML=""+e+"
            ",l=3===d.firstChild.nodeType?d.lastChild:d.firstChild.firstChild.firstChild):"option"===i?(d.innerHTML="",l=3===d.firstChild.nodeType?d.lastChild:d.firstChild):l.innerHTML=""+e;var r={},a=l.childNodes;r.length=a.length;for(var o=0;od;d++)l.appendChild(n[d]);return l},function(){var t="<-\n>",n=e.buildFragment(t,document);if(t!==n.childNodes[0].nodeValue){var i=e.buildFragment;e.buildFragment=function(e,t){var n=i(e,t);return 1===n.childNodes.length&&3===n.childNodes[0].nodeType&&(n.childNodes[0].nodeValue=e),n}}}(),e}); +/*can@2.2.6#util/deferred*/ +define("can/util/deferred",["can/util/can"],function(t){var e=function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},n=function(t){return this instanceof n?(this._doneFuncs=[],this._failFuncs=[],this._resultArgs=null,this._status="",void(t&&t.call(this,this))):new n};t.Deferred=n,t.when=n.when=function(){var e=t.makeArray(arguments);if(e.length<2){var r=e[0];return r&&t.isFunction(r.isResolved)&&t.isFunction(r.isRejected)?r:n().resolve(r)}var s=n(),i=0,u=[];return t.each(e,function(t,n){t.done(function(){u[n]=arguments.length<2?arguments[0]:arguments,++i===e.length&&s.resolve.apply(s,u)}).fail(function(){s.reject(1===arguments.length?arguments[0]:arguments)})}),s};var r=function(t,e){return function(n){var r=this._resultArgs=arguments.length>1?arguments[1]:[];return this.exec(n,this[t],r,e)}},s=function a(e,n){return function(){var r=this;return t.each(Array.prototype.slice.call(arguments),function(t,s,i){t&&(t.constructor===Array?a.apply(r,t):(r._status===n&&t.apply(r,r._resultArgs||[]),r[e].push(t)))}),this}},i=function(t){return t&&t.then&&t.fail&&t.done},u=function(e,n,r,s){i(n)?n.done(t.proxy(e.resolve,e)).fail(t.proxy(e.reject,e)):r.call(e,void 0!==n?n:s)};return e(n.prototype,{then:function(e,n){var r=t.Deferred(),s=r.resolve,i=r.reject;return this.done(function(t){"function"==typeof e?u(r,e.apply(this,arguments),s,t):s.apply(r,arguments)}),this.fail(function(t){"function"==typeof n?u(r,n.apply(this,arguments),i,t):i.apply(r,arguments)}),r},resolveWith:r("_doneFuncs","rs"),rejectWith:r("_failFuncs","rj"),done:s("_doneFuncs","rs"),fail:s("_failFuncs","rj"),always:function(){var e=t.makeArray(arguments);return e.length&&e[0]&&this.done(e[0]).fail(e[0]),this},state:function(){switch(this._status){case"rs":return"resolved";case"rj":return"rejected";default:return"pending"}},isResolved:function(){return"rs"===this._status},isRejected:function(){return"rj"===this._status},reject:function(){return this.rejectWith(this,arguments)},resolve:function(){return this.resolveWith(this,arguments)},exec:function(e,n,r,s){return""!==this._status?this:(this._status=s,t.each(n,function(t){"function"==typeof t.apply&&t.apply(e,r)}),this)},promise:function(){var t=this.then();return t.reject=t.resolve=void 0,t}}),n.prototype.pipe=n.prototype.then,t}); +/*can@2.2.6#util/array/each*/ +define("can/util/array/each",["can/util/can"],function(t){var e=function(t){var e="length"in t&&t.length;return"function"!=typeof arr&&(0===e||"number"==typeof e&&e>0&&e-1 in t)};return t.each=function(n,a,r){var f,i,l,c=0;if(n)if(e(n))if(t.List&&n instanceof t.List)for(i=n.attr("length");i>c&&(l=n.attr(c),a.call(r||l,l,c,n)!==!1);c++);else for(i=n.length;i>c&&(l=n[c],a.call(r||l,l,c,n)!==!1);c++);else if("object"==typeof n)if(t.Map&&n instanceof t.Map||n===t.route){var o=t.Map.keys(n);for(c=0,i=o.length;i>c&&(f=o[c],l=n.attr(f),a.call(r||l,l,f,n)!==!1);c++);}else for(f in n)if(n.hasOwnProperty(f)&&a.call(r||n[f],n[f],f,n)===!1)break;return n},t}); +/*can@2.2.6#util/object/isplain/isplain*/ +define("can/util/object/isplain/isplain",["can/util/can"],function(){var t=Object.prototype.hasOwnProperty,n=function(t){return null!==t&&t==t.window},r=function(r){if(!r||"object"!=typeof r||r.nodeType||n(r))return!1;try{if(r.constructor&&!t.call(r,"constructor")&&!t.call(r.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var o;for(o in r);return void 0===o||t.call(r,o)};return can.isPlainObject=r,can}); +/*can@2.2.6#util/inserted/inserted*/ +define("can/util/inserted/inserted",["can/util/can"],function(e){e.inserted=function(n){n=e.makeArray(n);for(var r,i,t=!1,a=e.$(document.contains?document:document.body),d=0;void 0!==(i=n[d]);d++){if(!t){if(!i.getElementsByTagName)continue;if(!e.has(a,i).length)return;t=!0}if(t&&i.getElementsByTagName){r=e.makeArray(i.getElementsByTagName("*")),e.trigger(i,"inserted",[],!1);for(var o,s=0;void 0!==(o=r[s]);s++)e.trigger(o,"inserted",[],!1)}}},e.appendChild=function(n,r){var i;i=11===r.nodeType?e.makeArray(r.childNodes):[r],n.appendChild(r),e.inserted(i)},e.insertBefore=function(n,r,i){var t;t=11===r.nodeType?e.makeArray(r.childNodes):[r],n.insertBefore(r,i),e.inserted(t)}}); +/*can@2.2.6#util/util*/ +define("can/util/util",["can/util/can","can/util/attr/attr","can/mootools/mootools","can/event/event","can/util/fragment","can/util/deferred","can/util/array/each","can/util/object/isplain/isplain","can/util/inserted/inserted"],function(t,e){t.trim=function(t){return t?t.trim():t};var n=function(){var e,n,r,i,a,o,s=arguments[0]||{},u=1,d=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},u=2),"object"==typeof s||t.isFunction(s)||(s={}),d===u&&(s=this,--u);d>u;u++)if(null!==(e=arguments[u]))for(n in e)r=s[n],i=e[n],s!==i&&(c&&i&&(t.isPlainObject(i)||(a=t.isArray(i)))?(a?(a=!1,o=r&&t.isArray(r)?r:[]):o=r&&t.isPlainObject(r)?r:{},s[n]=t.extend(c,o,i)):void 0!==i&&(s[n]=i));return s};t.extend=n,t.makeArray=function(t){if(null===t)return[];try{return Type.isEnumerable(t)&&"string"!=typeof t?Array.prototype.slice.call(t):[t]}catch(e){var n,r=[];for(n=0;n=n?t.cleanData(e,"canHasAttributesBindings"):t.data(e,"canHasAttributesBindings",n-1)}},t}); +/*can@2.2.6#view/view*/ +define("can/view/view",["can/util/util"],function(e){var r=e.isFunction,n=e.makeArray,t=1,i=function(e){var r=function(){return c.frag(e.apply(this,arguments))};return r.render=function(){return e.apply(e,arguments)},r},u=function(e,r){if(!e.length)throw"can.view: No template or empty template:"+r},a=function(n,t){if(r(n)){var i=e.Deferred();return i.resolve(n)}var a,o,d,f="string"==typeof n?n:n.url,s=n.engine&&"."+n.engine||f.match(/\.[\w\d]+$/);if(f.match(/^#/)&&(f=f.substr(1)),(o=document.getElementById(f))&&(s="."+o.type.match(/\/(x\-)?(.+)/)[2]),s||c.cached[f]||(f+=s=c.ext),e.isArray(s)&&(s=s[0]),d=c.toId(f),f.match(/^\/\//)&&(f=f.substr(2),f=window.steal?steal.config().root.mapJoin(""+steal.id(f)):f),window.require&&require.toUrl&&(f=require.toUrl(f)),a=c.types[s],c.cached[d])return c.cached[d];if(o)return c.registerView(d,o.innerHTML,a);var p=new e.Deferred;return e.ajax({async:t,url:f,dataType:"text",error:function(e){u("",f),p.reject(e)},success:function(e){u(e,f),c.registerView(d,e,a,p)}}),p},o=function(r){var n=[];if(e.isDeferred(r))return[r];for(var t in r)e.isDeferred(r[t])&&n.push(r[t]);return n},d=function(r){return e.isArray(r)&&"success"===r[1]?r[0]:r},c=e.view=e.template=function(e,n,t,i){return r(t)&&(i=t,t=void 0),c.renderAs("fragment",e,n,t,i)};return e.extend(c,{frag:function(e,r){return c.hookup(c.fragment(e),r)},fragment:function(r){if("string"!=typeof r&&11===r.nodeType)return r;var n=e.buildFragment(r,document.body);return n.childNodes.length||n.appendChild(document.createTextNode("")),n},toId:function(r){return e.map(r.toString().split(/\/|\./g),function(e){return e?e:void 0}).join("_")},toStr:function(e){return null==e?"":""+e},hookup:function(r,n){var t,i,u=[];return e.each(r.childNodes?e.makeArray(r.childNodes):r,function(r){1===r.nodeType&&(u.push(r),u.push.apply(u,e.makeArray(r.getElementsByTagName("*"))))}),e.each(u,function(e){e.getAttribute&&(t=e.getAttribute("data-view-id"))&&(i=c.hookups[t])&&(i(e,n,t),delete c.hookups[t],e.removeAttribute("data-view-id"))}),r},hookups:{},hook:function(e){return c.hookups[++t]=e," data-view-id='"+t+"'"},cached:{},cachedRenderers:{},cache:!0,register:function(r){this.types["."+r.suffix]=r,e[r.suffix]=c[r.suffix]=function(e,n){var t,u;if(!n)return u=function(){return t||(t=r.fragRenderer?r.fragRenderer(null,e):i(r.renderer(null,e))),t.apply(this,arguments)},u.render=function(){var n=r.renderer(null,e);return n.apply(n,arguments)},u;var a=function(){return t||(t=r.fragRenderer?r.fragRenderer(e,n):r.renderer(e,n)),t.apply(this,arguments)};return r.fragRenderer?c.preload(e,a):c.preloadStringRenderer(e,a)}},types:{},ext:".ejs",registerScript:function(e,r,n){return"can.view.preloadStringRenderer('"+r+"',"+c.types["."+e].script(r,n)+");"},preload:function(r,n){var t=c.cached[r]=(new e.Deferred).resolve(function(e,r){return n.call(e,e,r)});return t.__view_id=r,c.cachedRenderers[r]=n,n},preloadStringRenderer:function(e,r){return this.preload(e,i(r))},render:function(r,n,t,i){return e.view.renderAs("string",r,n,t,i)},renderTo:function(e,r,n,t){return("string"===e&&r.render?r.render:r)(n,t)},renderAs:function(t,i,u,f,s){r(f)&&(s=f,f=void 0);var p,l,g,h,v,m=o(u);if(m.length)return l=new e.Deferred,g=e.extend({},u),m.push(a(i,!0)),e.when.apply(e,m).then(function(r){var i,a=n(arguments),o=a.pop();if(e.isDeferred(u))g=d(r);else for(var c in u)e.isDeferred(u[c])&&(g[c]=d(a.shift()));i=e.view.renderTo(t,o,g,f),l.resolve(i,g),s&&s(i,g)},function(){l.reject.apply(l,arguments)}),l;if(p=e.__clearReading(),h=r(s),l=a(i,h),p&&e.__setReading(p),h)v=l,l.then(function(r){s(u?e.view.renderTo(t,r,u,f):r)});else{if("resolved"===l.state()&&l.__view_id){var w=c.cachedRenderers[l.__view_id];return u?e.view.renderTo(t,w,u,f):w}l.then(function(r){v=u?e.view.renderTo(t,r,u,f):r})}return v},registerView:function(r,n,t,u){var a,o="object"==typeof t?t:c.types[t||c.ext];return a=o.fragRenderer?o.fragRenderer(r,n):i(o.renderer(r,n)),u=u||new e.Deferred,c.cache&&(c.cached[r]=u,u.__view_id=r,c.cachedRenderers[r]=a),u.resolve(a)}}),e}); +/*can@2.2.6#view/callbacks/callbacks*/ +define("can/view/callbacks/callbacks",["can/util/util","can/view/view"],function(t){var a=t.view.attr=function(t,a){if(!a){var r=e[t];if(!r)for(var n=0,l=i.length;l>n;n++){var s=i[n];if(s.match.test(t)){r=s.handler;break}}return r}"string"==typeof t?e[t]=a:i.push({match:t,handler:a})},e={},i=[],r=/[-\:]/,n=t.view.tag=function(a,e){if(!e){var i=l[a.toLowerCase()];return!i&&r.test(a)&&(i=function(){}),i}t.global.html5&&(t.global.html5.elements+=" "+a,t.global.html5.shivDocument()),l[a.toLowerCase()]=e},l={};return t.view.callbacks={_tags:l,_attributes:e,_regExpAttributes:i,tag:n,attr:a,tagHandler:function(a,e,i){var r,n=i.options.attr("tags."+e),s=n||l[e],c=i.scope;if(s){var o=t.__clearReading();r=s(a,i),t.__setReading(o)}else r=c;if(r&&i.subtemplate){c!==r&&(c=c.add(r));var v=i.subtemplate(c,i.options),f="string"==typeof v?t.view.frag(v):v;t.appendChild(a,f)}}},t.view.callbacks}); +/*can@2.2.6#view/elements*/ +define("can/view/elements",["can/util/util","can/view/view"],function(t){var e="undefined"!=typeof document?document:null,n=e&&function(){return 1===t.$(document.createComment("~")).length}(),o={tagToContentPropMap:{option:e&&"textContent"in document.createElement("option")?"textContent":"innerText",textarea:"value"},attrMap:t.attr.map,attrReg:/([^\s=]+)[\s]*=[\s]*/,defaultValue:t.attr.defaultValue,tagMap:{"":"span",colgroup:"col",table:"tbody",tr:"td",ol:"li",ul:"li",tbody:"tr",thead:"tr",tfoot:"tr",select:"option",optgroup:"option"},reverseTagMap:{col:"colgroup",tr:"tbody",option:"select",td:"tr",th:"tr",li:"ul"},getParentNode:function(t,e){return e&&11===t.parentNode.nodeType?e:t.parentNode},setAttr:t.attr.set,getAttr:t.attr.get,removeAttr:t.attr.remove,contentText:function(t){return"string"==typeof t?t:t||0===t?""+t:""},after:function(e,n){var o=e[e.length-1];o.nextSibling?t.insertBefore(o.parentNode,n,o.nextSibling):t.appendChild(o.parentNode,n)},replace:function(e,r){o.after(e,r),t.remove(t.$(e)).length/g,">").replace(c,""").replace(o,"'")},getObject:function(r,n,t){var a,u,i,c,o=r?r.split("."):[],l=o.length,p=0;if(n=e.isArray(n)?n:[n||window],c=n.length,!l)return n[0];for(p;c>p;p++){for(a=n[p],i=void 0,u=0;l>u&&g(a);u++)i=a,a=f(i,o[u]);if(void 0!==i&&void 0!==a)break}if(t===!1&&void 0!==a&&delete i[o[u-1]],t===!0&&void 0===a)for(a=n[0],u=0;l>u&&g(a);u++)a=f(a,o[u],!0);return a},capitalize:function(e,r){return e.charAt(0).toUpperCase()+e.slice(1)},camelize:function(e){return d(e).replace(l,function(e,r){return r?r.toUpperCase():""})},hyphenate:function(e){return d(e).replace(p,function(e,r){return e.charAt(0)+"-"+e.charAt(1).toLowerCase()})},underscore:function(e){return e.replace(n,"/").replace(t,"$1_$2").replace(a,"$1_$2").replace(u,"_").toLowerCase()},sub:function(r,n,t){var a=[];return r=r||"",a.push(r.replace(i,function(r,u){var i=e.getObject(u,n,t===!0?!1:void 0);return void 0===i||null===i?(a=null,""):g(i)&&a?(a.push(i),""):""+i})),null===a?a:a.length<=1?a[0]:a},replacer:i,undHash:r}),e}); +/*can@2.2.6#construct/construct*/ +define("can/construct/construct",["can/util/string/string"],function(t){var n,r=0;try{Object.getOwnPropertyDescriptor({}),n=!0}catch(e){n=!1}var o=function(t,n){var r=Object.getOwnPropertyDescriptor(t,n);return r&&(r.get||r.set)?r:null},u=function(n,r,e){e=e||n;var u;for(var i in n)(u=o(n,i))?this._defineProperty(e,r,i,u):t.Construct._overwrite(e,r,i,n[i])},i=function(n,r,e){e=e||n;for(var o in n)t.Construct._overwrite(e,r,o,n[o])};return t.Construct=function(){return arguments.length?t.Construct.extend.apply(t.Construct,arguments):void 0},t.extend(t.Construct,{constructorExtends:!0,newInstance:function(){var t,n=this.instance();return n.setup&&(t=n.setup.apply(n,arguments)),n.init&&n.init.apply(n,t||arguments),n},_inherit:n?u:i,_defineProperty:function(t,n,r,e){Object.defineProperty(t,r,e)},_overwrite:function(t,n,r,e){t[r]=e},setup:function(n,r){this.defaults=t.extend(!0,{},n.defaults,this.defaults)},instance:function(){r=1;var t=new this;return r=0,t},extend:function(n,e,o){function u(){return r?void 0:this.constructor!==a&&arguments.length&&a.constructorExtends?a.extend.apply(a,arguments):a.newInstance.apply(a,arguments)}var i=n,s=e,c=o;"string"!=typeof i&&(c=s,s=i,i=null),c||(c=s,s=null),c=c||{};var a,p,f,l,d,y,g,h,v,m=this,w=this.prototype;v=this.instance(),t.Construct._inherit(c,w,v),i&&(p=i.split("."),g=p.pop()),"undefined"==typeof constructorName&&(a=function(){return u.apply(this,arguments)});for(y in m)m.hasOwnProperty(y)&&(a[y]=m[y]);t.Construct._inherit(s,m,a),i&&(f=t.getObject(p.join("."),window,!0),h=f,l=t.underscore(i.replace(/\./g,"_")),d=t.underscore(g),f[g]=a),t.extend(a,{constructor:a,prototype:v,namespace:h,_shortName:d,fullName:i,_fullName:l}),void 0!==g&&(a.shortName=g),a.prototype.constructor=a;var C=[m].concat(t.makeArray(arguments)),_=a.setup.apply(a,C);return a.init&&a.init.apply(a,_||C),a}}),t.Construct.prototype.setup=function(){},t.Construct.prototype.init=function(){},t.Construct}); +/*can@2.2.6#control/control*/ +define("can/control/control",["can/util/util","can/construct/construct"],function(t){var n,e=function(n,e,o){return t.bind.call(n,e,o),function(){t.unbind.call(n,e,o)}},o=t.isFunction,s=t.extend,i=t.each,r=[].slice,u=/\{([^\}]+)\}/g,c=t.getObject("$.event.special",[t])||{},l=function(n,e,o,s){return t.delegate.call(n,e,o,s),function(){t.undelegate.call(n,e,o,s)}},a=function(n,o,s,i){return i?l(n,t.trim(i),o,s):e(n,o,s)},h=t.Control=t.Construct({setup:function(){if(t.Construct.setup.apply(this,arguments),t.Control){var n,e=this;e.actions={};for(n in e.prototype)e._isAction(n)&&(e.actions[n]=e._action(n))}},_shifter:function(n,e){var s="string"==typeof e?n[e]:e;return o(s)||(s=n[s]),function(){return n.called=e,s.apply(n,[this.nodeName?t.$(this):this].concat(r.call(arguments,0)))}},_isAction:function(t){var n=this.prototype[t],e=typeof n;return"constructor"!==t&&("function"===e||"string"===e&&o(this.prototype[n]))&&!!(c[t]||f[t]||/[^\w]/.test(t))},_action:function(e,o){if(u.lastIndex=0,o||!u.test(e)){var s=o?t.sub(e,this._lookup(o)):e;if(!s)return null;var i=t.isArray(s),r=i?s[1]:s,c=r.split(/\s+/g),l=c.pop();return{processor:f[l]||n,parts:[r,c.join(" "),l],delegate:i?s[0]:void 0}}},_lookup:function(t){return[t,window]},processors:{},defaults:{}},{setup:function(n,e){var o,i=this.constructor,r=i.pluginName||i._fullName;return this.element=t.$(n),r&&"can_control"!==r&&this.element.addClass(r),o=t.data(this.element,"controls"),o||(o=[],t.data(this.element,"controls",o)),o.push(this),this.options=s({},i.defaults,e),this.on(),[this.element,this.options]},on:function(n,e,o,s){if(!n){this.off();var i,r,u=this.constructor,c=this._bindings,l=u.actions,h=this.element,f=t.Control._shifter(this,"destroy");for(i in l)l.hasOwnProperty(i)&&(r=l[i]||u._action(i,this.options,this),r&&(c.control[i]=r.processor(r.delegate||h,r.parts[2],r.parts[1],i,this)));return t.bind.call(h,"removed",f),c.user.push(function(n){t.unbind.call(n,"removed",f)}),c.user.length}return"string"==typeof n&&(s=o,o=e,e=n,n=this.element),void 0===s&&(s=o,o=e,e=null),"string"==typeof s&&(s=t.Control._shifter(this,s)),this._bindings.user.push(a(n,o,s,e)),this._bindings.user.length},off:function(){var t=this.element[0],n=this._bindings;n&&(i(n.user||[],function(n){n(t)}),i(n.control||{},function(n){n(t)})),this._bindings={user:[],control:{}}},destroy:function(){if(null!==this.element){var n,e=this.constructor,o=e.pluginName||e._fullName;this.off(),o&&"can_control"!==o&&this.element.removeClass(o),n=t.data(this.element,"controls"),n.splice(t.inArray(this,n),1),t.trigger(this,"destroyed"),this.element=null}}}),f=t.Control.processors;return n=function(n,e,o,s,i){return a(n,e,t.Control._shifter(i,s),o)},i(["change","click","contextmenu","dblclick","keydown","keyup","keypress","mousedown","mousemove","mouseout","mouseover","mouseup","reset","resize","scroll","select","submit","focusin","focusout","mouseenter","mouseleave","touchstart","touchmove","touchcancel","touchend","touchleave","inserted","removed"],function(t){f[t]=n}),h}); +/*can@2.2.6#util/bind/bind*/ +define("can/util/bind/bind",["can/util/util"],function(i){return i.bindAndSetup=function(){return i.addEvent.apply(this,arguments),this._init||(this._bindings?this._bindings++:(this._bindings=1,this._bindsetup&&this._bindsetup())),this},i.unbindAndTeardown=function(n,t){var s=this.__bindEvents[n]||[],d=s.length;return i.removeEvent.apply(this,arguments),null===this._bindings?this._bindings=0:this._bindings=this._bindings-(d-s.length),!this._bindings&&this._bindteardown&&this._bindteardown(),this},i}); +/*can@2.2.6#map/bubble*/ +define("can/map/bubble",["can/util/util"],function(n){var e=n.bubble={event:function(n,e){return n.constructor._bubbleRule(e,n)},childrenOf:function(n,i){n._each(function(b,r){b&&b.bind&&e.toParent(b,n,r,i)})},teardownChildrenFrom:function(n,i){n._each(function(b){e.teardownFromParent(n,b,i)})},toParent:function(e,i,b,r){n.listenTo.call(i,e,r,function(){var r=n.makeArray(arguments),t=r.shift();r[0]=(n.List&&i instanceof n.List?i.indexOf(e):b)+(r[0]?"."+r[0]:""),t.triggeredNS=t.triggeredNS||{},t.triggeredNS[i._cid]||(t.triggeredNS[i._cid]=!0,n.trigger(i,t,r))})},teardownFromParent:function(e,i,b){i&&i.unbind&&n.stopListening.call(e,i,b)},isBubbling:function(n,e){return n._bubbleBindings&&n._bubbleBindings[e]},bind:function(n,i){if(!n._init){var b,r=e.event(n,i),t=r.length;n._bubbleBindings||(n._bubbleBindings={});for(var u=0;t>u;u++)b=r[u],n._bubbleBindings[b]?n._bubbleBindings[b]++:(n._bubbleBindings[b]=1,e.childrenOf(n,b))}},unbind:function(i,b){for(var r,t=e.event(i,b),u=t.length,d=0;u>d;d++)r=t[d],i._bubbleBindings&&i._bubbleBindings[r]--,i._bubbleBindings&&!i._bubbleBindings[r]&&(delete i._bubbleBindings[r],e.teardownChildrenFrom(i,r),n.isEmptyObject(i._bubbleBindings)&&delete i._bubbleBindings)},add:function(i,b,r){if(b instanceof n.Map&&i._bubbleBindings)for(var t in i._bubbleBindings)i._bubbleBindings[t]&&(e.teardownFromParent(i,b,t),e.toParent(b,i,r,t))},removeMany:function(n,i){for(var b=0,r=i.length;r>b;b++)e.remove(n,i[b])},remove:function(i,b){if(b instanceof n.Map&&i._bubbleBindings)for(var r in i._bubbleBindings)i._bubbleBindings[r]&&e.teardownFromParent(i,b,r)},set:function(i,b,r,t){return n.Map.helpers.isObservable(r)&&e.add(i,r,b),n.Map.helpers.isObservable(t)&&e.remove(i,t),r}};return e}); +/*can@2.2.6#util/batch/batch*/ +define("can/util/batch/batch",["can/util/can"],function(t){var n=1,a=0,i=[],c=[],e=null;t.batch={start:function(t){a++,t&&c.push(t)},stop:function(l,u){if(l?a=0:a--,0===a){if(null!==e)return;e=i.slice(0);var h,r,f=c.slice(0);for(i=[],c=[],t.batch.batchNum=n,n++,u&&t.batch.start(),h=0;h=0?["change"]:[]},_computes:[],bind:t.bindAndSetup,on:t.bindAndSetup,unbind:t.unbindAndTeardown,off:t.unbindAndTeardown,id:"id",helpers:{define:null,attrParts:function(t,e){return e?[t]:"object"==typeof t?t:(""+t).split(".")},addToMap:function(e,i){var r;n||(r=s,n={});var a=e._cid,o=t.cid(e);return n[o]||(n[o]={obj:e,instance:i,added:!a}),r},isObservable:function(e){return e instanceof t.Map||e&&e===t.route},canMakeObserve:function(e){return e&&!t.isDeferred(e)&&(t.isArray(e)||t.isPlainObject(e))},serialize:function(e,i,n){var s=t.cid(e),r=!1;return a||(r=!0,a={attr:{},serialize:{}}),a[i][s]=n,e.each(function(s,r){var u,h=o.helpers.isObservable(s),c=h&&a[i][t.cid(s)];u=c?c:"serialize"===i?o.helpers._serialize(e,r,s):o.helpers._getValue(e,r,s,i),void 0!==u&&(n[r]=u)}),t.__observe(e,"__keys"),r&&(a=null),n},_serialize:function(t,e,i){return o.helpers._getValue(t,e,i,"serialize")},_getValue:function(t,e,i,n){return o.helpers.isObservable(i)?i[n]():i}},keys:function(e){var i=[];t.__observe(e,"__keys");for(var n in e._data)i.push(n);return i}},{setup:function(e){e instanceof t.Map&&(e=e.serialize()),this._data={},t.cid(this,".map"),this._init=1,this._computedBindings={};var i=this._setupDefaults(e);this._setupComputes(i);var n=e&&t.Map.helpers.addToMap(e,this),s=t.extend(t.extend(!0,{},i),e);this.attr(s),n&&n(),this.bind("change",t.proxy(this._changes,this)),delete this._init},_setupComputes:function(){for(var t,e=this.constructor._computes,i=0,n=e.length;n>i;i++)t=e[i],this[t]=this[t].clone(this),this._computedBindings[t]={count:0}},_setupDefaults:function(){return this.constructor.defaults||{}},_bindsetup:function(){},_bindteardown:function(){},_changes:function(e,i,n,s,r){t.batch.trigger(this,{type:i,batchNum:e.batchNum,target:e.target},[s,r])},_triggerChange:function(e,n,s,r){i.isBubbling(this,"change")?t.batch.trigger(this,{type:"change",target:this},[e,n,s,r]):t.batch.trigger(this,e,[s,r]),("remove"===n||"add"===n)&&t.batch.trigger(this,{type:"__keys",target:this})},_each:function(t){var e=this.__get();for(var i in e)e.hasOwnProperty(i)&&t(e[i],i)},attr:function(t,e){var i=typeof t;return"string"!==i&&"number"!==i?this._attrs(t,e):1===arguments.length?this._get(t):(this._set(t,e),this)},each:function(){return t.each.apply(void 0,[this].concat(t.makeArray(arguments)))},removeAttr:function(e){var i=t.List&&this instanceof t.List,n=t.Map.helpers.attrParts(e),s=n.shift(),r=i?this[s]:this._data[s];return n.length&&r?r.removeAttr(n):("string"==typeof e&&~e.indexOf(".")&&(s=e),this._remove(s,r),r)},_remove:function(t,e){t in this._data&&(delete this._data[t],t in this.constructor.prototype||delete this[t],this._triggerChange(t,"remove",void 0,e))},_get:function(e){e=""+e;var i=e.indexOf(".");if(i>=0){var n=this.__get(e);if(void 0!==n)return n;var s=e.substr(0,i),r=e.substr(i+1);t.__observe(this,s);var a=this.__get(s);return a&&a._get?a._get(r):void 0}return t.__observe(this,e),this.__get(e)},__get:function(t){return t?this._computedBindings[t]?this[t]():this._data[t]:this._data},__type:function(e,i){if(!(e instanceof t.Map)&&t.Map.helpers.canMakeObserve(e)){var n=r(e);if(n)return n;if(t.isArray(e)){var s=t.List;return new s(e)}var a=this.constructor.Map||t.Map;return new a(e)}return e},_set:function(t,e,i){t=""+t;var n,s=t.indexOf(".");if(!i&&s>=0){var r=t.substr(0,s),a=t.substr(s+1);if(n=this._init?void 0:this.__get(r),!o.helpers.isObservable(n))throw"can.Map: Object does not exist";n._set(a,e)}else this.__convert&&(e=this.__convert(t,e)),n=this._init?void 0:this.__get(t),this.__set(t,this.__type(e,t),n)},__set:function(t,e,i){if(e!==i){var n=void 0!==i||this.__get().hasOwnProperty(t)?"set":"add";this.___set(t,this.constructor._bubble.set(this,t,e,i)),this._computedBindings[t]||this._triggerChange(t,n,e,i),i&&this.constructor._bubble.teardownFromParent(this,i)}},___set:function(t,e){this._computedBindings[t]?this[t](e):this._data[t]=e,"function"==typeof this.constructor.prototype[t]||this._computedBindings[t]||(this[t]=e)},bind:function(e,i){var n=this._computedBindings&&this._computedBindings[e];if(n)if(n.count)n.count++;else{n.count=1;var s=this;n.handler=function(i,n,r){t.batch.trigger(s,{type:e,batchNum:i.batchNum,target:s},[n,r])},this[e].bind("change",n.handler)}return this.constructor._bubble.bind(this,e),t.bindAndSetup.apply(this,arguments)},unbind:function(e,i){var n=this._computedBindings&&this._computedBindings[e];return n&&(1===n.count?(n.count=0,this[e].unbind("change",n.handler),delete n.handler):n.count--),this.constructor._bubble.unbind(this,e),t.unbindAndTeardown.apply(this,arguments)},serialize:function(){return t.Map.helpers.serialize(this,"serialize",{})},_attrs:function(e,i){if(void 0===e)return o.helpers.serialize(this,"attr",{});e=t.simpleExtend({},e);var n,s,r=this;t.batch.start(),this.each(function(t,n){if("_cid"!==n){if(s=e[n],void 0===s)return void(i&&r.removeAttr(n));r.__convert&&(s=r.__convert(n,s)),o.helpers.isObservable(s)?r.__set(n,r.__type(s,n),t):o.helpers.isObservable(t)&&o.helpers.canMakeObserve(s)?t.attr(s,i):t!==s&&r.__set(n,r.__type(s,n),t),delete e[n]}});for(n in e)"_cid"!==n&&(s=e[n],this._set(n,s,!0));return t.batch.stop(),this},compute:function(e){if(t.isFunction(this.constructor.prototype[e]))return t.compute(this[e],this);var i=e.split("."),n=i.length-1,s={args:[]};return t.compute(function(e){return arguments.length?void t.compute.read(this,i.slice(0,n)).value.attr(i[n],e):t.compute.read(this,i,s).value},this)}});return o.prototype.on=o.prototype.bind,o.prototype.off=o.prototype.unbind,o}); +/*can@2.2.6#list/list*/ +define("can/list/list",["can/util/util","can/map/map","can/map/bubble"],function(t,e,i){var r=[].splice,h=function(){var t={0:"a",length:1};return r.call(t,0,1),!t[0]}(),n=e.extend({Map:e},{setup:function(e,i){this.length=0,t.cid(this,".map"),this._init=1,this._computedBindings={},this._setupComputes(),e=e||[];var r;t.isDeferred(e)?this.replace(e):(r=e.length&&t.Map.helpers.addToMap(e,this),this.push.apply(this,t.makeArray(e||[]))),r&&r(),this.bind("change",t.proxy(this._changes,this)),t.simpleExtend(this,i),delete this._init},_triggerChange:function(i,r,h,n){e.prototype._triggerChange.apply(this,arguments);var s=+i;~(""+i).indexOf(".")||isNaN(s)||("add"===r?(t.batch.trigger(this,r,[h,s]),t.batch.trigger(this,"length",[this.length])):"remove"===r?(t.batch.trigger(this,r,[n,s]),t.batch.trigger(this,"length",[this.length])):t.batch.trigger(this,r,[h,s]))},__get:function(e){return e?this[e]&&this[e].isComputed&&t.isFunction(this.constructor.prototype[e])?this[e]():this[e]:this},__set:function(e,i,r){if(e=isNaN(+e)||e%1?e:+e,"number"==typeof e&&e>this.length-1){var h=new Array(e+1-this.length);return h[h.length-1]=i,this.push.apply(this,h),h}return t.Map.prototype.__set.call(this,""+e,i,r)},___set:function(t,e){this[t]=e,+t>=this.length&&(this.length=+t+1)},_remove:function(t,e){isNaN(+t)?(delete this[t],this._triggerChange(t,"remove",void 0,e)):this.splice(t,1)},_each:function(t){for(var e=this.__get(),i=0;i2;for(e=e||0,s=0,a=o.length-2;a>s;s++)l=s+2,o[l]=this.__type(o[l],l),g.push(o[l]),this[s+e]!==o[l]&&(c=!1);if(c&&this.length<=g.length)return g;void 0===n&&(n=o[1]=this.length-e);var p=r.apply(this,o);if(!h)for(s=this.length;s0&&(i.removeMany(this,p),this._triggerChange(""+e,"remove",void 0,p)),o.length>2){for(s=0,a=g.length;a>s;s++)i.set(this,s,g[s]);this._triggerChange(""+e,"add",g,p)}return t.batch.stop(),p},_attrs:function(i,r){return void 0===i?e.helpers.serialize(this,"attr",[]):(i=t.makeArray(i),t.batch.start(),this._updateAttrs(i,r),void t.batch.stop())},_updateAttrs:function(t,i){for(var r=Math.min(t.length,this.length),h=0;r>h;h++){var n=this[h],s=t[h];e.helpers.isObservable(n)&&e.helpers.canMakeObserve(s)?n.attr(s,i):n!==s&&this._set(h,s)}t.length>this.length?this.push.apply(this,t.slice(this.length)):t.lengthc;){s=i;for(var l=0,f=t.propertyReaders.length;f>l;l++){var v=t.propertyReaders[l];if(v.test(i)){i=v.read(i,r[c],c,o,u);break}}if(c+=1,i=n(i,c,r,o,u,s),a=typeof i,ci;i++)t.valueReaders[i].test(e,n,r,o)&&(e=t.valueReaders[i].read(e,n,r,o,a,s))}while(u);return e};return t.valueReaders=[{name:"compute",test:function(e,t,n,r){return e&&e.isComputed},read:function(t,n,r,o,a){return o.isArgument&&n===r.length?t:(!a.foundObservable&&o.foundObservable&&(o.foundObservable(t,n),a.foundObservable=!0),t instanceof e.Compute?t.get():t())}},{name:"function",test:function(t,n,r,o){var a=typeof t;return!("function"!==a||t.isComputed||!(o.executeAnonymousFunctions||o.isArgument&&n===r.length)||e.Construct&&t.prototype instanceof e.Construct||e.route&&t===e.route)},read:function(t,n,r,o,a,s){return o.isArgument&&n===r.length?o.proxyMethods!==!1?e.proxy(t,s):t:t.call(s)}}],t.propertyReaders=[{name:"map",test:e.isMapLike,read:function(t,n,r,o,a){return!a.foundObservable&&o.foundObservable&&(o.foundObservable(t,r),a.foundObservable=!0),"function"==typeof t[n]&&t.constructor.prototype[n]===t[n]?o.returnObserveMethods?t[n]:"constructor"===n&&t instanceof e.Construct||t[n].prototype instanceof e.Construct?t[n]:t[n].apply(t,o.args||[]):t.attr(n)}},{name:"promise",test:function(t){return e.isPromise(t)},read:function(t,n,r,o,a){!a.foundObservable&&o.foundObservable&&(o.foundObservable(t,r),a.foundObservable=!0);var s=t.__observeData;return t.__observeData||(s=t.__observeData={isPending:!0,state:"pending",isResolved:!1,isRejected:!1,value:void 0,reason:void 0},e.cid(s),e.simpleExtend(s,e.event),t.then(function(e){s.isPending=!1,s.isResolved=!0,s.value=e,s.state="resolved",s.dispatch("state",["resolved","pending"])},function(e){s.isPending=!1,s.isRejected=!0,s.reason=e,s.state="rejected",s.dispatch("state",["rejected","pending"])})),e.__observe(s,"state"),n in s?s[n]:t[n]}},{name:"object",test:function(){return!0},read:function(e,t){return null==e?void 0:e[t]}}],t.write=function(t,n,r,o){return o=o||{},e.isMapLike(t)?!o.isArgument&&t._data&&t._data[n]&&t._data[n].isComputed?t._data[n](r):t.attr(n,r):t[n]&&t[n].isComputed?t[n](r):void("object"==typeof t&&(t[n]=r))},t}); +/*can@2.2.6#compute/get_value_and_bind*/ +define("can/compute/get_value_and_bind",["can/util/util"],function(){function n(n,e,t,i){var v=a(n,e),o=v.observed,u=t.observed;return v.names!==t.names&&(r(u,o,i),c(u,i)),can.batch.afterPreviousEvents(function(){v.ready=!0}),v}var e=[];can.__isRecordingObserves=function(){return e.length},can.__observe=can.__reading=function(n,a){if(e.length){var r=n._cid+"|"+a,t=e[e.length-1];t.names+=r,t.observed[r]={obj:n,event:a+""}}},can.__notObserve=function(n){return function(){var e=can.__clearObserved(),a=n.apply(this,arguments);return can.__setObserved(e),a}},can.__clearObserved=can.__clearReading=function(){if(e.length){var n=e[e.length-1];return e[e.length-1]={observed:{}},n}},can.__setObserved=can.__setReading=function(n){e.length&&(e[e.length-1]=n)},can.__addObserved=can.__addReading=function(n){e.length&&can.simpleExtend(e[e.length-1],n)};var a=function(n,a){e.push({names:"",observed:{}});var r=n.call(a),t=e.pop();return t.value=r,t},r=function(n,e,a){for(var r in e)t(n,e,r,a)},t=function(n,e,a,r){if(n[a])delete n[a];else{var t=e[a];t.obj.bind(t.event,r)}},c=function(n,e){for(var a in n){var r=n[a];r.obj.unbind(r.event,e)}};return n}); +/*can@2.2.6#compute/proto_compute*/ +define("can/compute/proto_compute",["can/util/util","can/util/bind/bind","can/compute/read","can/compute/get_value_and_bind","can/util/batch/batch"],function(t,e,n,i){var s=function(e,n,i,s){n!==i&&t.batch.trigger(e,s?{type:"change",batchNum:s}:"change",[n,i])},u=function(e,n,s,u){var o,h,r;return u=!1,{on:function(a){var c=this;h||(h=function(t){if(o.ready&&e.bound&&(void 0===t.batchNum||t.batchNum!==r)){var a,f=o.value;u?(a=n.call(s),o.value=a):(o=i(n,s,o,h),a=o.value),c.updater(a,f,t.batchNum),r=r=t.batchNum}}),o=i(n,s,{observed:{}},h),u&&(n=t.__notObserve(n)),e.value=o.value,e.hasDependencies=!t.isEmptyObject(o.observed)},off:function(t){for(var e in o.observed){var n=o.observed[e];n.obj.unbind(n.event,h)}}}},o=function(){},h=function(t,e,n){this.value=t,s(this,t,e,n)},r=function(t,e,n){return function(){return t.call(e,n.get())}},a=function(t,e){return function(n){void 0!==n&&e(n,t.value)}};t.Compute=function(e,n,i,s){for(var u=[],o=0,h=arguments.length;h>o;o++)u[o]=arguments[o];var r=typeof u[1];"function"==typeof u[0]?this._setupGetterSetterFn(u[0],u[1],u[2],u[3]):u[1]?"string"===r?this._setupContextString(u[0],u[1],u[2]):"function"===r?this._setupContextFunction(u[0],u[1],u[2]):u[1]&&u[1].fn?this._setupAsyncCompute(u[0],u[1]):this._setupContextSettings(u[0],u[1]):this._setupInitialValue(u[0]),this._args=u,this.isComputed=!0,t.cid(this,"compute")},t.simpleExtend(t.Compute.prototype,{_bindsetup:t.__notObserve(function(){this.bound=!0,this._on(this.updater)}),_bindteardown:function(){this._off(this.updater),this.bound=!1},bind:t.bindAndSetup,unbind:t.unbindAndTeardown,clone:function(e){return e&&"function"==typeof this._args[0]?this._args[1]=e:e&&(this._args[2]=e),new t.Compute(this._args[0],this._args[1],this._args[2],this._args[3])},_on:o,_off:o,get:function(){return t.__isRecordingObserves()&&this._canObserve!==!1&&(t.__observe(this,"change"),this.bound||t.Compute.temporarilyBind(this)),this.bound?this.value:this._get()},_get:function(){return this.value},set:function(t){var e=this.value,n=this._set(t,e);return this.hasDependencies?this._setUpdates?this.value:this._get():(void 0===n?this.value=this._get():this.value=n,s(this,this.value,e),this.value)},_set:function(t){return this.value=t},updater:h,_computeFn:function(t){return arguments.length?this.set(t):this.get()},toFunction:function(){return t.proxy(this._computeFn,this)},_setupGetterSetterFn:function(e,n,i,s){this._set=t.proxy(e,n),this._get=t.proxy(e,n),this._canObserve=i===!1?!1:!0;var o=u(this,e,n||this,s);this._on=o.on,this._off=o.off},_setupContextString:function(e,n,i){var s=t.isMapLike(e),u=this,o=function(t,e,n){u.updater(e,n,t.batchNum)};s?(this.hasDependencies=!0,this._get=function(){return e.attr(n)},this._set=function(t){e.attr(n,t)},this._on=function(t){e.bind(i||n,o),this.value=this._get()},this._off=function(){return e.unbind(i||n,o)}):(this._get=t.proxy(this._get,e),this._set=t.proxy(this._set,e))},_setupContextFunction:function(e,n,i){this.value=e,this._set=n,t.simpleExtend(this,i)},_setupContextSettings:function(e,n){if(this.value=e,this._set=n.set?t.proxy(n.set,n):this._set,this._get=n.get?t.proxy(n.get,n):this._get,!n.__selfUpdater){var i=this,s=this.updater;this.updater=function(){s.call(i,i._get(),i.value)}}this._on=n.on?n.on:this._on,this._off=n.off?n.off:this._off},_setupAsyncCompute:function(e,n){this.value=e;var i,s=t.proxy(this.updater,this),o=this,h=n.fn;this.updater=s;var c=new t.Compute(e);this.lastSetValue=c,this._setUpdates=!0,this._set=function(t){return t===c.get()?this.value:c.set(t)},this._get=r(h,n.context,c),0===h.length?i=u(this,h,n.context):1===h.length?i=u(this,function(){return h.call(n.context,c.get())},n):(this.updater=a(this,s),i=u(this,function(){var t=h.call(n.context,c.get(),function(t){s(t,o.value)});return void 0!==t?t:this.value},n)),this._on=i.on,this._off=i.off},_setupInitialValue:function(t){this.value=t}});var c,f=function(){for(var t=0,e=c.length;e>t;t++)c[t].unbind("change",o);c=null};return t.Compute.temporarilyBind=function(t){t.bind("change",o),c||(c=[],setTimeout(f,10)),c.push(t)},t.Compute.async=function(e,n,i){return new t.Compute(e,{fn:n,context:i})},t.Compute.read=n,t.Compute.set=n.write,t.Compute.truthy=function(e){return new t.Compute(function(){var t=e.get();return"function"==typeof t&&(t=t.get()),!!t})},t.Compute}); +/*can@2.2.6#compute/compute*/ +define("can/compute/compute",["can/util/util","can/util/bind/bind","can/util/batch/batch","can/compute/proto_compute"],function(t,n){t.compute=function(n,u,e,o){var c=new t.Compute(n,u,e,o),i=function(t){return arguments.length?c.set(t):c.get()};return i.bind=t.proxy(c.bind,c),i.unbind=t.proxy(c.unbind,c),i.isComputed=c.isComputed,i.clone=function(e){return"function"==typeof n&&(u=e),t.compute(n,u,e,o)},i.computeInstance=c,i};var u,e=function(){},o=function(){for(var t=0,n=u.length;n>t;t++)u[t].unbind("change",e);u=null};return t.compute.temporarilyBind=function(t){t.bind("change",e),u||(u=[],setTimeout(o,10)),u.push(t)},t.compute.truthy=function(n){return t.compute(function(){var t=n();return"function"==typeof t&&(t=t()),!!t})},t.compute.async=function(n,u,e){return t.compute(n,{fn:u,context:e})},t.compute.read=t.Compute.read,t.compute.set=t.Compute.set,t.compute}); +/*can@2.2.6#observe/observe*/ +define("can/observe/observe",["can/util/util","can/map/map","can/list/list","can/compute/compute"],function(t){return t.Observe=t.Map,t.Observe.startBatch=t.batch.start,t.Observe.stopBatch=t.batch.stop,t.Observe.triggerBatch=t.batch.trigger,t}); +/*can@2.2.6#view/scope/compute_data*/ +define("can/view/scope/compute_data",["can/util/util","can/compute/compute","can/compute/get_value_and_bind"],function(e,t,n){var o=function(t){return t.reads&&1===t.reads.length&&t.root instanceof e.Map&&!e.isFunction(t.root[t.reads[0]])},a=function(e,t){return n(e,null,{observed:{}},t)},u=function(e,t){for(var n in e.observed){var o=e.observed[n];o.obj.unbind(o.event,t)}},r=function(e,t){var n=e.root,o=e.reads[0];return n.bind(o,t),{value:e.initialValue,observed:{something:!0}}},c=function(e,t){e.root.unbind(e.reads[0],t)},i=function(t,n,o,a,u){if(!(arguments.length>4)){if(a.root)return e.compute.read(a.root,a.reads,o).value;var r=t.read(n,o);return a.scope=r.scope,a.initialValue=r.value,a.reads=r.reads,a.root=r.rootObserve,r.value}if(a.root.isComputed)a.root(u);else if(a.reads.length){var c=a.reads.length-1,i=a.reads.length?e.compute.read(a.root,a.reads.slice(0,c)).value:a.root;e.compute.set(i,a.reads[c],u,o)}};return function(t,s,d){d=d||{args:[]};var l,v,f={},p=function(e){return arguments.length?i(t,s,d,f,e):i(t,s,d,f)},m=function(e){if(v.ready&&g.computeInstance.bound&&(void 0===e.batchNum||e.batchNum!==l)){var t,o=v.value;v=n(p,null,v,m),t=v.value,g.computeInstance.updater(t,o,e.batchNum),l=l=e.batchNum}},b=function(e,t,n){"function"!=typeof t?g.computeInstance.updater(t,n,e.batchNum):(c(f,b),v=a(p,m),h=!1,g.computeInstance.updater(v.value,n,e.batchNum))},h=!1,g=e.compute(void 0,{on:function(){if(v=a(p,m),o(f)){var t=v;v=r(f,b),u(t,m),h=!0}g.computeInstance.value=v.value,g.computeInstance.hasDependencies=!e.isEmptyObject(v.observed)},off:function(){h?c(f,b):u(v,m)},set:p,get:p,__selfUpdater:!0});return f.compute=g,f}}); +/*can@2.2.6#view/scope/scope*/ +define("can/view/scope/scope",["can/util/util","can/view/scope/compute_data","can/construct/construct","can/map/map","can/list/list","can/view/view","can/compute/compute"],function(e,t){var n=/(\\)?\./g,r=/\\\./g,u=function(e){var t=[],u=0;return e.replace(n,function(n,i,s){i||(t.push(e.slice(u,s).replace(r,".")),u=s+n.length)}),t.push(e.slice(u).replace(r,".")),t},i=e.Construct.extend({read:e.compute.read},{init:function(e,t){this._context=e,this._parent=t,this.__cache={}},attr:e.__notObserve(function(t,n){var r={isArgument:!0,returnObserveMethods:!0,proxyMethods:!1},u=this.read(t,r);if(2===arguments.length){var i=t.lastIndexOf("."),s=-1!==i?t.substring(0,i):".",a=this.read(s,r).value;-1!==i&&(t=t.substring(i+1,t.length)),e.compute.set(a,t,n,r)}return u.value}),add:function(e){return e!==this._context?new this.constructor(e,this):this},computeData:function(e,n){return t(this,e,n)},compute:function(e,t){return this.computeData(e,t).compute},read:function(t,n){var r;if("./"===t.substr(0,2))r=!0,t=t.substr(2);else{if("../"===t.substr(0,3))return this._parent.read(t.substr(3),n);if(".."===t)return{value:this._parent._context};if("."===t||"this"===t)return{value:this._context}}for(var i,s,a,c,o,l,p=-1===t.indexOf("\\.")?t.split("."):u(t),v=this,d=[],f=-1;v;){if(i=v._context,null!==i&&("object"==typeof i||"function"==typeof i)){var h=e.compute.read(i,p,e.simpleExtend({foundObservable:function(e,t){o=e,l=p.slice(t)},earlyExit:function(t,n){n>f&&(s=o,d=l,f=n,c=v,a=e.__clearReading())},executeAnonymousFunctions:!0},n));if(void 0!==h.value)return{scope:v,rootObserve:o,value:h.value,reads:l}}e.__clearReading(),v=r?null:v._parent}return s?(e.__setReading(a),{scope:c,rootObserve:s,reads:d,value:void 0}):{names:p,value:void 0}}});return e.view.Scope=i,i}); +/*can@2.2.6#view/scanner*/ +define("can/view/scanner",["can/view/view","can/view/elements","can/view/callbacks/callbacks"],function(can,elements,viewCallbacks){var newLine=/(\r|\n)+/g,notEndTag=/\//,clean=function(t){return t.split("\\").join("\\\\").split("\n").join("\\n").split('"').join('\\"').split(" ").join("\\t")},getTag=function(t,e,n){if(t)return t;for(;n":">",'"':'"',"'":"'"},this.tokenComplex=[],this.tokenMap={};for(var e,n=0;e=this.tokens[n];n++)e[2]?(this.tokenReg.push(e[2]),this.tokenComplex.push({abbr:e[1],re:new RegExp(e[2]),rescan:e[3]})):(this.tokenReg.push(e[1]),this.tokenSimple[e[1]]=e[0]),this.tokenMap[e[0]]=e[1];this.tokenReg=new RegExp("("+this.tokenReg.slice(0).concat(["<",">",'"',"'"]).join("|")+")","g")},Scanner.prototype={helpers:[],scan:function(t,e){var n=[],s=0,a=this.tokenSimple,r=this.tokenComplex;t=t.replace(newLine,"\n"),this.transform&&(t=this.transform(t)),t.replace(this.tokenReg,function(e,i){var o=arguments[arguments.length-2];if(o>s&&n.push(t.substring(s,o)),a[e])n.push(e);else for(var u,c=0;u=r[c];c++)if(u.re.test(e)){n.push(u.abbr),u.rescan&&n.push(u.rescan(i));break}s=o+i.length}),s":htmlTag=0;var H="/"===l.substr(l.length-1)||"--"===l.substr(l.length-2),N="";if(k.attributeHookups.length&&(N="attrs: ['"+k.attributeHookups.join("','")+"'], ",k.attributeHookups=[]),v+k.tagHookups.length!==k.lastTagHookup&&v===top(k.tagHookups))H&&(l=l.substr(0,l.length-1)),p.push(put_cmd,'"',clean(l),'"',",can.view.pending({tagName:'"+v+"',"+N+"scope: "+(this.text.scope||"this")+this.text.options),H?(p.push("}));"),l="/>",b()):"<"===n[d]&&n[d+1]==="/"+v?(p.push("}));"),l=u,b()):(p.push(",subtemplate: function("+this.text.argNames+"){\n"+startTxt+(this.text.start||"")),l="");else if(m||!w&&elements.tagToContentPropMap[x[x.length-1]]||N){var R=",can.view.pending({"+N+"scope: "+(this.text.scope||"this")+this.text.options+'}),"';H?h(l.substr(0,l.length-1),R+'/>"'):h(l,R+'>"'),l="",m=0}else l+=u;(H||w)&&(x.pop(),v=x[x.length-1],w=!1),k.attributeHookups=[];break;case"'":case'"':if(htmlTag)if(quote&"e===u){quote=null;var L=getAttrName();if(viewCallbacks.attr(L)&&k.attributeHookups.push(L),T){l+=u,h(l),p.push(finishTxt,"}));\n"),l="",T=!1;break}}else if(null===quote&&(quote=u,beforeQuote=i,c=getAttrName(),"img"===v&&"src"===c||"style"===c)){h(l.replace(attrReg,"")),l="",T=!0,p.push(insert_cmd,"can.view.txt(2,'"+getTag(v,n,d)+"',"+status()+",this,function(){",startTxt),h(c+"="+u);break}default:if("<"===i){v="!--"===u.substr(0,3)?"!--":u.split(/\s/)[0];var S,y=!1;0===v.indexOf("/")&&(y=!0,S=v.substr(1)),y?(top(x)===S&&(v=S,w=!0),top(k.tagHookups)===S&&(h(l.substr(0,l.length-1)),p.push(finishTxt+"}}) );"),l="><",b())):(v.lastIndexOf("/")===v.length-1&&(v=v.substr(0,v.length-1)),"!--"!==v&&viewCallbacks.tag(v)&&("content"===v&&elements.tagMap[top(x)]&&(u=u.replace("content",elements.tagMap[top(x)])),k.tagHookups.push(v)),x.push(v))}l+=u}else switch(u){case _.right:case _.returnRight:switch(f){case _.left:o=bracketNum(l),1===o?(p.push(insert_cmd,"can.view.txt(0,'"+getTag(v,n,d)+"',"+status()+",this,function(){",startTxt,l),g.push({before:"",after:finishTxt+"}));\n"})):(s=g.length&&-1===o?g.pop():{after:";"},s.before&&p.push(s.before),p.push(l,";",s.after));break;case _.escapeLeft:case _.returnLeft:o=bracketNum(l),o&&g.push({before:finishTxt,after:"}));\n"});for(var j=f===_.escapeLeft?1:0,C={insert:insert_cmd,tagName:getTag(v,n,d),status:status(),specialAttribute:T},q=0;q[\s]*\w*/.source&&(j=0);break}}"object"==typeof l?l.startTxt&&l.end&&T?p.push(insert_cmd,"can.view.toStr( ",l.content,"() ) );"):(l.startTxt?p.push(insert_cmd,"can.view.txt(\n"+("string"==typeof status()||(null!=l.escaped?l.escaped:j))+",\n'"+v+"',\n"+status()+",\nthis,\n"):l.startOnlyTxt&&p.push(insert_cmd,"can.view.onlytxt(this,\n"),p.push(l.content),l.end&&p.push("));")):T?p.push(insert_cmd,l,");"):p.push(insert_cmd,"can.view.txt(\n"+("string"==typeof status()||j)+",\n'"+v+"',\n"+status()+",\nthis,\nfunction(){ "+(this.text.escape||"")+"return ",l,o?startTxt:"}));\n"),rescan&&rescan.after&&rescan.after.length&&(h(rescan.after.length),rescan=null)}f=null,l="";break;case _.templateLeft:l+=_.left;break;default:l+=u}i=u}l.length&&h(l),p.push(";");var M=p.join(""),A={out:(this.text.outStart||"")+M+" "+finishTxt+(this.text.outEnd||"")};return myEval.call(A,"this.fn = (function("+this.text.argNames+"){"+A.out+"});\r\n//# sourceURL="+e+".js"),A}},can.view.pending=function(t){var e=can.view.getHooks();return can.view.hook(function(n){can.each(e,function(t){t(n)}),t.templateType="legacy",t.tagName&&viewCallbacks.tagHandler(n,t.tagName,t),can.each(t&&t.attrs||[],function(e){t.attributeName=e;var s=viewCallbacks.attr(e);s&&s(n,t)})})},can.view.tag("content",function(t,e){return e.scope}),can.view.Scanner=Scanner,Scanner}); +/*can@2.2.6#view/node_lists/node_lists*/ +define("can/view/node_lists/node_lists",["can/util/util","can/view/elements"],function(e){var n=!0;try{document.createTextNode("")._=0}catch(t){n=!1}var r={},a={},i="ejs_"+Math.random(),s=0,u=function(e,t){var r=t||a,u=l(e,r);return u?u:n||3!==e.nodeType?(++s,e[i]=(e.nodeName?"element_":"obj_")+s):(++s,r["text_"+s]=e,"text_"+s)},l=function(e,t){if(n||3!==e.nodeType)return e[i];for(var r in t)if(t[r]===e)return r},c=[].splice,o=[].push,p=function(e){for(var n=0,t=0,r=e.length;r>t;t++){var a=e[t];a.nodeType?n++:n+=p(a)}return n},f=function(e,n){for(var t={},r=0,a=e.length;a>r;r++){var i=d.first(e[r]);t[u(i,n)]=e[r]}return t},d={id:u,update:function(n,t){var r=d.unregisterChildren(n);t=e.makeArray(t);var a=n.length;return c.apply(n,[0,a].concat(t)),n.replacements?d.nestReplacements(n):d.nestList(n),r},nestReplacements:function(e){for(var n=0,t={},r=f(e.replacements,t),a=e.replacements.length;nr;r++){var n=e[r];t[n.tokenType].apply(t,n.args)}return e}var a="-:A-Za-z0-9_",n="[a-zA-Z_:]["+a+":.]*",s="\\s*=\\s*",i='"((?:\\\\.|[^"])*)"',o="'((?:\\\\.|[^'])*)'",l="(?:"+s+"(?:(?:\"[^\"]*\")|(?:'[^']*')|[^>\\s]+))?",c="\\{\\{[^\\}]*\\}\\}\\}?",u="\\{\\{([^\\}]*)\\}\\}\\}?",p=new RegExp("^<(["+a+"]+)((?:\\s*(?:(?:(?:"+n+")?"+l+")|(?:"+c+")+))*)\\s*(\\/?)>"),f=new RegExp("^<\\/(["+a+"]+)[^>]*>"),d=new RegExp("(?:(?:("+n+")|"+u+")(?:"+s+"(?:(?:"+i+")|(?:"+o+")|([^>\\s]+)))?)","g"),g=new RegExp(u,"g"),h=/<|\{\{/,m=t("area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed"),b=t("a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video"),v=t("abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var"),x=t("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr"),w=t("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"),y=t("script,style"),k="start,end,close,attrStart,attrEnd,attrValue,chars,comment,special,done".split(","),E=function(){},A=function(t,a,n){function s(e,t,r,n){if(t=t.toLowerCase(),b[t])for(;w.last()&&v[w.last()];)i("",w.last());x[t]&&w.last()===t&&i("",t),n=m[t]||!!n,a.start(t,n),n||w.push(t),A.parseAttrs(r,a),a.end(t,n)}function i(e,t){var r;if(t)for(r=w.length-1;r>=0&&w[r]!==t;r--);else r=0;if(r>=0){for(var n=w.length-1;n>=r;n--)a.close&&a.close(w[n]);w.length=r}}function o(e,t){a.special&&a.special(t)}if("object"==typeof t)return r(t,a);var l=[];a=a||{},n&&e.each(k,function(t){var r=a[t]||E;a[t]=function(){r.apply(this,arguments)!==!1&&l.push({tokenType:t,args:e.makeArray(arguments)})}});var c,u,d,w=[],O=t;for(w.last=function(){return this[this.length-1]};t;){if(u=!0,w.last()&&y[w.last()])t=t.replace(new RegExp("([\\s\\S]*?)]*>"),function(e,t){return t=t.replace(/|/g,"$1$2"),a.chars&&a.chars(t),""}),i("",w.last());else if(0===t.indexOf(""),c>=0&&(a.comment&&a.comment(t.substring(4,c)),t=t.substring(c+3),u=!1)):0===t.indexOf("c?t:t.substring(0,c);t=0>c?"":t.substring(c),a.chars&&R&&a.chars(R)}if(t===O)throw"Parse Error: "+t;O=t}return i(),a.done(),l};return A.parseAttrs=function(e,t){(null!=e?e:"").replace(d,function(e,r,a,n,s,i){if(a&&t.special(a),r||n||s||i){var o=arguments[3]?arguments[3]:arguments[4]?arguments[4]:arguments[5]?arguments[5]:w[r.toLowerCase()]?r:"";t.attrStart(r||"");for(var l,c=g.lastIndex=0,u=g.exec(o);u;)l=o.substring(c,g.lastIndex-u[0].length),l.length&&t.attrValue(l),t.special(u[1]),c=g.lastIndex,u=g.exec(o);l=o.substr(c,o.length),l&&t.attrValue(l),t.attrEnd(r||"")}})},e.view.parser=A,A}); +/*can@2.2.6#view/live/live*/ +define("can/view/live/live",["can/util/util","can/view/elements","can/view/view","can/view/node_lists/node_lists","can/view/parser/parser"],function(e,t,n,r,i){t=t||e.view.elements,r=r||e.view.NodeLists,i=i||e.view.parser;var a=function(t,n,r){var i=!1,a=function(){return i||(i=!0,r(o),e.unbind.call(t,"removed",a)),!0},o={teardownCheck:function(e){return e?!1:a()}};return e.bind.call(t,"removed",a),n(o),o},o=function(e,t,n){return a(e,function(){t.bind("change",n)},function(e){t.unbind("change",n),e.nodeList&&r.unregister(e.nodeList)})},c=function(e){var t,n={};return i.parseAttrs(e,{attrStart:function(e){n[e]="",t=e},attrValue:function(e){n[t]+=e},attrEnd:function(){}}),n},u=[].splice,d=function(e){return e&&e.nodeType},s=function(e){e.childNodes.length||e.appendChild(document.createTextNode(""))},l={list:function(n,i,o,c,d,s){var f,p=s||[n],v=[],h=!1,g=!1,b=function(n,i,a){if(h){var d=document.createDocumentFragment(),l=[],f=[];e.each(i,function(t,n){var i=[];s&&r.register(i,null,!0);var u=e.compute(n+a),p=o.call(c,t,u,i),v="string"==typeof p,h=e.frag(p);h=v?e.view.hookup(h):h;var g=e.makeArray(h.childNodes);s?(r.update(i,g),l.push(i)):l.push(r.register(g)),d.appendChild(h),f.push(u)});var g=a+1;if(p[g]){var b=r.first(p[g]);e.insertBefore(b.parentNode,d,b)}else t.after(1===g?[N]:[r.last(p[g-1])],d);u.apply(p,[g,0].concat(l)),u.apply(v,[a,0].concat(f));for(var m=a+f.length,w=v.length;w>m;m++)v[m](m)}},m=function(t,n,i,a,o){if(h&&(a||!y.teardownCheck(N.parentNode))){0>i&&(i=v.length+i);var c=p.splice(i+1,n.length),u=[];e.each(c,function(e){var t=r.unregister(e);[].push.apply(u,t)}),v.splice(i,n.length);for(var d=i,s=v.length;s>d;d++)v[d](d);o?r.unregister(p):e.remove(e.$(u))}},w=function(t,n,i,a){if(h){i+=1,a+=1;var o,c=p[i],u=e.frag(r.flatten(p[a]));o=i>a?r.last(c).nextSibling:r.first(c);var d=p[0].parentNode;d.insertBefore(u,o);var s=p[a];[].splice.apply(p,[a,1]),[].splice.apply(p,[i,0,s])}},N=document.createTextNode(""),k=function(e){f&&f.unbind&&f.unbind("add",b).unbind("remove",m).unbind("move",w),m({},{length:p.length-1},0,!0,e)},A=function(t,n,r){g||(k(),f=n||[],f.bind&&f.bind("add",b).bind("remove",m).bind("move",w),h=!0,b({},f,0),h=!1,e.batch.afterPreviousEvents(function(){h=!0}))};d=t.getParentNode(n,d);var y=a(d,function(){e.isFunction(i)&&i.bind("change",A)},function(){e.isFunction(i)&&i.unbind("change",A),k(!0)});s?(t.replace(p,N),r.update(p,[N]),s.unregistered=function(){y.teardownCheck(),g=!0}):l.replace(p,N,y.teardownCheck),A({},e.isFunction(i)?i():i)},html:function(n,i,a,c){var u;a=t.getParentNode(n,a),u=o(a,i,function(e,t,n){var i=r.first(l).parentNode;i&&f(t),u.teardownCheck(r.first(l).parentNode)});var l=c||[n],f=function(n){var i="function"==typeof n,o=d(n),c=e.frag(i?"":n),u=e.makeArray(l);s(c),o||i||(c=e.view.hookup(c,a)),u=r.update(l,c.childNodes),i&&n(c.childNodes[0]),t.replace(u,c)};u.nodeList=l,c?c.unregistered=u.teardownCheck:r.register(l,u.teardownCheck),f(i())},replace:function(n,i,a){var o=n.slice(0),c=e.frag(i);return r.register(n,a),"string"==typeof i&&(c=e.view.hookup(c,n[0].parentNode)),r.update(n,c.childNodes),t.replace(o,c),n},text:function(n,i,a,c){var u=t.getParentNode(n,a),d=o(u,i,function(t,n,r){"unknown"!=typeof s.nodeValue&&(s.nodeValue=e.view.toStr(n)),d.teardownCheck(s.parentNode)}),s=document.createTextNode(e.view.toStr(i()));c?(c.unregistered=d.teardownCheck,d.nodeList=c,r.update(c,[s]),t.replace([n],s)):d.nodeList=l.replace([n],s,d.teardownCheck)},setAttributes:function(t,n){var r=c(n);for(var i in r)e.attr.set(t,i,r[i])},attributes:function(n,r,i){var a={},u=function(r){var i,o=c(r);for(i in o){var u=o[i],d=a[i];u!==d&&e.attr.set(n,i,u),delete a[i]}for(i in a)t.removeAttr(n,i);a=o};o(n,r,function(e,t){u(t)}),arguments.length>=3?a=c(i):u(r())},attributePlaceholder:"__!!__",attributeReplace:/__!!__/g,attribute:function(n,r,i){o(n,i,function(e,i){t.setAttr(n,r,u.render())});var a,c=e.$(n);a=e.data(c,"hooks"),a||e.data(c,"hooks",a={});var u,d=t.getAttr(n,r),s=d.split(l.attributePlaceholder),f=[];f.push(s.shift(),s.join(l.attributePlaceholder)),a[r]?a[r].computes.push(i):a[r]={render:function(){var e=0,n=d?d.replace(l.attributeReplace,function(){return t.contentText(u.computes[e++]())}):t.contentText(u.computes[e++]());return n},computes:[i],batchNum:void 0},u=a[r],f.splice(1,0,i()),t.setAttr(n,r,f.join(""))},specialAttribute:function(e,n,r){o(e,r,function(r,i){t.setAttr(e,n,p(i))}),t.setAttr(e,n,p(r()))},simpleAttribute:function(e,n,r){o(e,r,function(r,i){t.setAttr(e,n,i)}),t.setAttr(e,n,r())}};l.attr=l.simpleAttribute,l.attrs=l.attributes;var f=/(\r|\n)+/g,p=function(e){var n=/^["'].*["']$/;return e=e.replace(t.attrReg,"").replace(f,""),n.test(e)?e.substr(1,e.length-2):e};return e.view.live=l,l}); +/*can@2.2.6#view/render*/ +define("can/view/render",["can/view/view","can/view/elements","can/view/live/live","can/util/string/string"],function(t,n,e){var i,r=[],u=function(t){var e=n.tagMap[t]||"span";return"span"===e?"@@!!@@":"<"+e+">"+u(e)+""},o=function(n,e){if("string"==typeof n)return n;if(!n&&0!==n)return"";var i=n.hookup&&function(t,e){n.hookup.call(n,t,e)}||"function"==typeof n&&n;return i?e?"<"+e+" "+t.view.hook(i)+">":(r.push(i),""):""+n},c=function(n,e){return"string"==typeof n||"number"==typeof n?t.esc(n):o(n,e)},s=!1,a=function(){};return t.extend(t.view,{live:e,setupLists:function(){var n,e=t.view.lists;return t.view.lists=function(t,e){return n={list:t,renderer:e},Math.random()},function(){return t.view.lists=e,n}},getHooks:function(){var t=r.slice(0);return i=t,r=[],t},onlytxt:function(t,n){return c(n.call(t))},txt:function(f,p,l,v,h){var w,g,d,b,y=n.tagMap[p]||"span",k=!1,m=a;if(s)w=h.call(v);else{("string"==typeof l||1===l)&&(s=!0);var x=t.view.setupLists();m=function(){d.unbind("change",a)},d=t.compute(h,v,!1),d.bind("change",a),g=x(),w=d(),s=!1,k=d.computeInstance.hasDependencies}if(g)return m(),"<"+y+t.view.hook(function(t,n){e.list(t,g.list,g.renderer,v,n)})+">";if(!k||"function"==typeof w)return m(),(s||2===f||!f?o:c)(w,0===l&&y);var M=n.tagToContentPropMap[p];return 0!==l||M?1===l?(r.push(function(t){e.attributes(t,d,d()),m()}),d()):2===f?(b=l,r.push(function(t){e.specialAttribute(t,b,d),m()}),d()):(b=0===l?M:l,(0===l?i:r).push(function(t){e.attribute(t,b,d),m()}),e.attributePlaceholder):"<"+y+t.view.hook(f&&"object"!=typeof w?function(t,n){e.text(t,d,n),m()}:function(t,n){e.html(t,d,n),m()})+">"+u(y)+""}}),t}); +/*can@2.2.6#view/stache/utils*/ +define("can/view/stache/utils",["can/util/util"],function(){return{isArrayLike:function(t){return t&&t.splice&&"number"==typeof t.length},isObserveLike:function(t){return t instanceof can.Map||t&&!!t._get},emptyHandler:function(){},jsonParse:function(str){return"'"===str[0]?str.substr(1,str.length-2):"undefined"===str?void 0:can.global.JSON?JSON.parse(str):eval("("+str+")")},mixins:{last:function(){return this.stack[this.stack.length-1]},add:function(t){this.last().add(t)},subSectionDepth:function(){return this.stack.length-1}}}}); +/*can@2.2.6#view/stache/mustache_helpers*/ +define("can/view/stache/mustache_helpers",["can/util/util","can/view/stache/utils","can/view/live/live"],function(e,n,t){t=t||e.view.live;var i=function(t){return n.isObserveLike(t)&&n.isArrayLike(t)&&t.attr("length")?t:e.isFunction(t)?t():t},r={each:function(r,s){var o,u,a,c=i(r),f=[];if(c instanceof e.List)return function(n){var i=[n];i.expression="live.list",e.view.nodeLists.register(i,null,s.nodeList),e.view.nodeLists.update(s.nodeList,[n]);var o=function(e,n,t){return s.fn(s.scope.add({"@index":n}).add(e),s.options,t)};t.list(n,r,o,s.context,n.parentNode,i)};var l=c;if(l&&n.isArrayLike(l))for(a=0;a0&&t!==n)return r.inverse();n=t}return r.fn()},eq:function(){return r.is.apply(this,arguments)},unless:function(n,t){return r["if"].apply(this,[e.isFunction(n)?e.compute(function(){return!n()}):!n,t])},"with":function(e,n){var t=e;return e=i(e),e?n.fn(t):void 0},log:function(e,n){"undefined"!=typeof console&&console.log&&(n?console.log(e,n.context):console.log(e.context))},data:function(n){var t=2===arguments.length?this:arguments[1];return function(i){e.data(e.$(i),n,t||this.context)}}};return{registerHelper:function(e,n){r[e]=n},getHelper:function(e,n){var t=n.attr("helpers."+e);return t||(t=r[e]),t?{fn:t}:void 0}}}); +/*can@2.2.6#view/stache/mustache_core*/ +define("can/view/stache/mustache_core",["can/util/util","can/view/stache/utils","can/view/stache/mustache_helpers","can/view/live/live","can/view/elements","can/view/scope/scope","can/view/node_lists/node_lists"],function(e,t,n,r,i,a,s){r=r||e.view.live,i=i||e.view.elements,a=a||e.view.Scope,s=s||e.view.nodeLists;var o=/((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g,u=/^(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(?:(.+?)=(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(.+))))$/,c=/(?:(?:^|(\r?)\n)(\s*)(\{\{([^\}]*)\}\}\}?)([^\S\n\r]*)($|\r?\n))|(\{\{([^\}]*)\}\}\}?)/g,l=function(e){return e&&"string"==typeof e.get},f=function(e,t,n,r){for(var i=document.createDocumentFragment(),a=0,s=e.length;s>a;a++)p(i,n.fn(t?e.attr(""+a):e[a],r));return i},p=function(e,t){t&&e.appendChild("string"==typeof t?document.createTextNode(t):t)},h=function(e,t,n,r){for(var i="",a=0,s=e.length;s>a;a++)i+=n.fn(t?e.attr(""+a):e[a],r);return i},d=function(t,n,r){var i=n.computeData(t,{isArgument:r,args:[n.attr("."),n]});return e.compute.temporarilyBind(i.compute),i},v=function(e,t){var n=d(e,t,!0);return n.compute.computeInstance.hasDependencies?n.compute:n.initialValue},g=function(e,t,n,r,i,a){i&&(e.fn=m(i,t,n,r)),a&&(e.inverse=m(a,t,n,r))},m=function(t,n,r,i){var a=function(e,r,i){return t(e||n,r,i)};return e.__notObserve(function(t,s,o){void 0===t||t instanceof e.view.Scope||(t=n.add(t)),void 0===s||s instanceof x.Options||(s=r.add(s));var u=a(t,s||r,o||i);return u})},x={expressionData:function(n){var r=[],i={},a=0;return(e.trim(n)+" ").replace(o,function(e,n){var s;a&&(s=n.match(u))?s[1]||s[2]?r.push(t.jsonParse(s[1]||s[2])):i[s[3]]=s[6]?{get:s[6]}:t.jsonParse(s[4]||s[5]):r.push({get:n}),a++}),{name:r.shift(),args:r,hash:i}},makeEvaluator:function(r,i,a,s,o,u,c,p){for(var m,x,y,w=[],b={},_={fn:function(){},inverse:function(){}},O=r.attr("."),k=o.name,D=o.args.length||!e.isEmptyObject(o.hash),E=0,L=o.args.length;L>E;E++){var A=o.args[E];w.push(A&&l(A)?v(A.get,r,!0):A)}for(var N in o.hash)l(o.hash[N])?b[N]=v(o.hash[N].get,r):b[N]=o.hash[N];if(l(k)&&(D&&(m=n.getHelper(k.get,i),m||"function"!=typeof O[k.get]||(m={fn:O[k.get]})),!m)){var S=k.get,B=d(k.get,r,!1),R=B.compute;x=B.initialValue,k=B.compute.computeInstance.hasDependencies?R:x,D||void 0!==x?"function"==typeof x&&(m={fn:x}):m=n.getHelper(S,i)}if("^"===s){var j=u;u=c,c=j}if(m)return g(_,r,i,a,u,c),e.simpleExtend(_,{context:O,scope:r,contexts:r,hash:b,nodeList:a,exprData:o}),w.push(_),y=function(){return m.fn.apply(O,w)||""},y.bindOnce=!1,y;if(!s)return k&&k.isComputed?k:function(){return""+(null!=k?k:"")};if("#"===s||"^"===s){g(_,r,i,a,u,c);var F=function(){var n;if(n=e.isFunction(k)&&k.isComputed?k():k,t.isArrayLike(n)){var a=t.isObserveLike(n);return(a?n.attr("length"):n.length)?(p?h:f)(n,a,_,i):_.inverse(r,i)}return n?_.fn(n||r,i):_.inverse(r,i)};return F.bindOnce=!1,F}},makeLiveBindingPartialRenderer:function(t,n){return t=e.trim(t),function(i,a,o){var u=[this];u.expression=">"+t,s.register(u,null,n.directlyNested?o||!0:!0);var c=e.compute(function(){var n,r=t,s=a.attr("partials."+r);if(s)n=s.render?s.render(i,a):s(i,a);else{var o=i.read(r,{isArgument:!0,returnObserveMethods:!0,proxyMethods:!1}).value;o&&(r=o),n=e.view.render(r,i,a)}return e.frag(n)});r.html(this,c,this.parentNode,u)}},makeStringBranchRenderer:function(e,t){var n=w(t),r=e+t;return function(t,i,a,s){var o=t.__cache[r];(e||!o)&&(o=y(t,i,null,e,n,a,s,!0),e||(t.__cache[r]=o));var u=o();return null==u?"":""+u}},makeLiveBindingBranchRenderer:function(t,n,a){var o=w(n);return function(u,c,l,f,p){var h=[this];h.expression=n,s.register(h,null,a.directlyNested?l||!0:!0);var d=y(u,c,h,t,o,f,p,a.tag),v=e.compute(d,null,!1,d.bindOnce===!1?!1:!0);v.bind("change",e.k);var g=v();if("function"==typeof g){var m=e.__clearReading();g(this),e.__setReading(m)}else v.computeInstance.hasDependencies?a.attr?r.simpleAttribute(this,a.attr,v):a.tag?r.attributes(this,v):a.text&&"object"!=typeof g?r.text(this,v,this.parentNode,h):r.html(this,v,this.parentNode,h):a.attr?e.attr.set(this,a.attr,g):a.tag?r.setAttributes(this,g):a.text&&"string"==typeof g?this.nodeValue=g:g&&i.replace([this],e.frag(g));v.unbind("change",e.k)}},splitModeFromExpression:function(t,n){t=e.trim(t);var r=t.charAt(0);return"#/{&^>!".indexOf(r)>=0?t=e.trim(t.substr(1)):r=null,"{"===r&&n.node&&(r=null),{mode:r,expression:t}},cleanLineEndings:function(e){return e.replace(c,function(e,t,n,r,i,a,s,o,u,c){a=a||"",t=t||"",n=n||"";var l=b(i||u,{});return o||">{".indexOf(l.mode)>=0?e:"^#!/".indexOf(l.mode)>=0?r+(0!==c&&s.length?t+"\n":""):n+r+a+(n.length||0!==c?t+"\n":"")})},Options:e.view.Scope.extend({init:function(t,n){t.helpers||t.partials||t.tags||(t={helpers:t}),e.view.Scope.prototype.init.apply(this,arguments)}})},y=x.makeEvaluator,w=x.expressionData,b=x.splitModeFromExpression;return x}); +/*can@2.2.6#view/bindings/bindings*/ +define("can/view/bindings/bindings",["can/util/util","can/view/stache/mustache_core","can/view/callbacks/callbacks","can/control/control","can/view/scope/scope"],function(e,t){var n=function(){var e={"":!0,"true":!0,"false":!1},t=function(t){if(t&&t.getAttribute){var n=t.getAttribute("contenteditable");return e[n]}};return function(e){var n=t(e);return"boolean"==typeof n?n:!!t(e.parentNode)}}(),i=function(e){return"{"===e[0]&&"}"===e[e.length-1]?e.substr(1,e.length-2):e};e.view.attr("can-value",function(t,a){var c,l,h=e.trim(i(t.getAttribute("can-value"))),v=a.scope.computeData(h,{args:[]}).compute;return"input"===t.nodeName.toLowerCase()&&("checkbox"===t.type&&(c=e.attr.has(t,"can-true-value")?t.getAttribute("can-true-value"):!0,l=e.attr.has(t,"can-false-value")?t.getAttribute("can-false-value"):!1),"checkbox"===t.type||"radio"===t.type)?void new o(t,{value:v,trueValue:c,falseValue:l}):"select"===t.nodeName.toLowerCase()&&t.multiple?void new u(t,{value:v}):n(t)?void new r(t,{value:v}):void new s(t,{value:v})});var a={enter:function(e,t,n){return{event:"keyup",handler:function(e){return 13===e.keyCode?n.call(this,e):void 0}}}};e.view.attr(/can-[\w\.]+/,function(n,s){var o=s.attributeName,u=o.substr("can-".length),r=function(a){var u=n.getAttribute(o);if(u){var r=t.expressionData(i(u)),c=s.scope.read(r.name.get,{returnObserveMethods:!0,isArgument:!0,executeAnonymousFunctions:!0}),l=[],h=e.$(this),v=e.viewModel(h[0]),f=s.scope.add({"@element":h,"@event":a,"@viewModel":v,"@scope":s.scope,"@context":s.scope._context});if(!e.isEmptyObject(r.hash)){var p={};e.each(r.hash,function(e,t){if(e&&e.hasOwnProperty("get")){var n=e.get.indexOf("@")?s.scope:f;p[t]=n.read(e.get,{}).value}else p[t]=e}),l.unshift(p)}if(r.args.length)for(var d,g=r.args.length-1;g>=0;g--)if(d=r.args[g],d&&d.hasOwnProperty("get")){var m=d.get.indexOf("@")?s.scope:f;l.unshift(m.read(d.get,{}).value)}else l.unshift(d);return l.length||(l=[s.scope._context,h].concat(e.makeArray(arguments))),c.value.apply(c.parent,l)}};if(a[u]){var c=a[u](s,n,r);r=c.handler,u=c.event}e.bind.call(n,u,r)});var s=e.Control.extend({init:function(){"SELECT"===this.element[0].nodeName.toUpperCase()?setTimeout(e.proxy(this.set,this),1):this.set()},"{value} change":"set",set:function(){if(this.element){var e=this.options.value();this.element[0].value=null==e?"":e}},change:function(){if(this.element){var e=this.element[0];this.options.value(e.value);var t=this.options.value();e.value!==t&&(e.value=t)}}}),o=e.Control.extend({init:function(){this.isCheckbox="checkbox"===this.element[0].type.toLowerCase(),this.check()},"{value} change":"check",check:function(){if(this.isCheckbox){var t=this.options.value(),n=this.options.trueValue||!0;this.element[0].checked=t==n}else{var i=this.options.value()==this.element[0].value?"set":"remove";e.attr[i](this.element[0],"checked",!0)}},change:function(){this.isCheckbox?this.options.value(this.element[0].checked?this.options.trueValue:this.options.falseValue):this.element[0].checked&&this.options.value(this.element[0].value)}}),u=s.extend({init:function(){this.delimiter=";",setTimeout(e.proxy(this.set,this),1)},set:function(){var t=this.options.value();"string"==typeof t?(t=t.split(this.delimiter),this.isString=!0):t&&(t=e.makeArray(t));var n={};e.each(t,function(e){n[e]=!0}),e.each(this.element[0].childNodes,function(e){e.value&&(e.selected=!!n[e.value])})},get:function(){var t=[],n=this.element[0].childNodes;return e.each(n,function(e){e.selected&&e.value&&t.push(e.value)}),t},change:function(){var t=this.get(),n=this.options.value();this.isString||"string"==typeof n?(this.isString=!0,this.options.value(t.join(this.delimiter))):n instanceof e.List?n.attr(t,!0):this.options.value(t)}}),r=e.Control.extend({init:function(){this.set(),this.on("blur","setValue")},"{value} change":"set",set:function(){var e=this.options.value();this.element[0].innerHTML="undefined"==typeof e?"":e},setValue:function(){this.options.value(this.element[0].innerHTML)}})}); +/*can@2.2.6#view/mustache/mustache*/ +define("can/view/mustache/mustache",["can/util/util","can/view/scope/scope","can/view/view","can/view/scanner","can/compute/compute","can/view/render","can/view/bindings/bindings"],function(e){e.view.ext=".mustache";var n="scope",t="___h4sh",r="{scope:"+n+",options:options}",i="{scope:"+n+",options:options, special: true}",s=n+",options",o=/((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g,a=/^(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false|null|undefined)|((.+?)=(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false)|(.+))))$/,c=function(e){return'{get:"'+e.replace(/"/g,'\\"')+'"}'},u=function(e){return e&&"string"==typeof e.get},f=function(n){return n instanceof e.Map||n&&!!n._get},p=function(e){return e&&e.splice&&"number"==typeof e.length},l=function(n,t,r){var i=function(e,r){return n(e||t,r)};return function(n,s){return void 0===n||n instanceof e.view.Scope||(n=t.add(n)),void 0===s||s instanceof e.view.Options||(s=r.add(s)),i(n,s||r)}},h=function(n,t){if(this.constructor!==h){var r=new h(n);return function(e,n){return r.render(e,n)}}return"function"==typeof n?void(this.template={fn:n}):(e.extend(this,n),void(this.template=this.scanner.scan(this.text,this.name)))};e.Mustache=e.global.Mustache=h,h.prototype.render=function(n,t){return n instanceof e.view.Scope||(n=new e.view.Scope(n||{})),t instanceof e.view.Options||(t=new e.view.Options(t||{})),t=t||{},this.template.fn.call(n,n,t)},e.extend(h.prototype,{scanner:new e.view.Scanner({text:{start:"",scope:n,options:",options: options",argNames:s},tokens:[["returnLeft","{{{","{{[{&]"],["commentFull","{{!}}","^[\\s\\t]*{{!.+?}}\\n"],["commentLeft","{{!","(\\n[\\s\\t]*{{!|{{!)"],["escapeFull","{{}}","(^[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}$)",function(e){return{before:/^\n.+?\n$/.test(e)?"\n":"",content:e.match(/\{\{(.+?)\}\}/)[1]||""}}],["escapeLeft","{{"],["returnRight","}}}"],["right","}}"]],helpers:[{name:/^>[\s]*\w*/,fn:function(n,t){var r=e.trim(n.replace(/^>\s?/,"")).replace(/["|']/g,"");return"can.Mustache.renderPartial('"+r+"',"+s+")"}},{name:/^\s*data\s/,fn:function(e,t){var r=e.match(/["|'](.*)["|']/)[1];return"can.proxy(function(__){can.data(can.$(__),'"+r+"', this.attr('.')); }, "+n+")"}},{name:/\s*\(([\$\w]+)\)\s*->([^\n]*)/,fn:function(e){var t=/\s*\(([\$\w]+)\)\s*->([^\n]*)/,r=e.match(t);return"can.proxy(function(__){var "+r[1]+"=can.$(__);with("+n+".attr('.')){"+r[2]+"}}, this);"}},{name:/^.*$/,fn:function(n,u){var f=!1,p={content:"",startTxt:!1,startOnlyTxt:!1,end:!1};if(n=e.trim(n),n.length&&(f=n.match(/^([#^\/]|else$)/))){switch(f=f[0]){case"#":case"^":u.specialAttribute?p.startOnlyTxt=!0:(p.startTxt=!0,p.escaped=0);break;case"/":return p.end=!0,p.content+='return ___v1ew.join("");}}])',p}n=n.substring(1)}if("else"!==f){var l,h=[],v=[],g=0;p.content+="can.Mustache.txt(\n"+(u.specialAttribute?i:r)+",\n"+(f?'"'+f+'"':"null")+",",(e.trim(n)+" ").replace(o,function(e,n){g&&(l=n.match(a))?l[2]?h.push(l[0]):v.push(l[4]+":"+(l[6]?l[6]:c(l[5]))):h.push(c(n)),g++}),p.content+=h.join(","),v.length&&(p.content+=",{"+t+":{"+v.join(",")+"}}")}switch(f&&"else"!==f&&(p.content+=",[\n\n"),f){case"^":case"#":p.content+="{fn:function("+s+"){var ___v1ew = [];";break;case"else":p.content+='return ___v1ew.join("");}},\n{inverse:function('+s+"){\nvar ___v1ew = [];";break;default:p.content+=")"}return f||(p.startTxt=!0,p.end=!0),p}}]})});for(var v=e.view.Scanner.prototype.helpers,g=0;g0&&t!==n)return r.inverse();n=t}return r.fn()},eq:function(){return h._helpers.is.fn.apply(this,arguments)},unless:function(n,t){return h._helpers["if"].fn.apply(this,[e.isFunction(n)?e.compute(function(){return!n()}):!n,t])},each:function(n,t){var r,i,s,o=h.resolve(n),a=[];if(e.view.lists&&(o instanceof e.List||n&&n.isComputed&&void 0===o))return e.view.lists(n,function(e,n){return t.fn(t.scope.add({"@index":n}).add(e))});if(n=o,n&&p(n)){for(s=0;st;t++)f[t]()};if(t.each(this.constructor.attributeScopeMappings,function(e,n){r[n]=i.getAttribute(t.hyphenate(e))}),t.each(t.makeArray(i.attributes),function(n,i){var c=t.camelize(n.nodeName.toLowerCase()),u=n.value;if(!(p.constructor.attributeScopeMappings[c]||o.test(c)||e.attr(n.nodeName))){if("{"===u[0]&&"}"===u[u.length-1])u=u.substr(1,u.length-2);else if("legacy"!==s.templateType)return void(r[c]=u);var h=s.scope.computeData(u,{args:[]}),m=h.compute,v=function(e,n){d[c]=(d[c]||0)+1,a.attr(c,n),t.batch.afterPreviousEvents(function(){--d[c]})};m.bind("change",v),r[c]=m(),m.computeInstance.hasDependencies?(f.push(function(){m.unbind("change",v)}),l[c]=h):m.unbind("change",v)}}),this.constructor.Map)a=new this.constructor.Map(r);else if(h instanceof t.Map)a=h;else if(t.isFunction(h)){var v=h.call(this,r,s.scope,i);a=v instanceof t.Map?v:v.prototype instanceof t.Map?new v(r):new(t.Map.extend(v))(r)}var g={};t.each(l,function(t,e){g[e]=function(n,o){d[e]||t.compute(o)},a.bind(e,g[e])}),t.isEmptyObject(this.constructor.attributeScopeMappings)&&"legacy"===s.templateType||t.bind.call(i,"attributes",function(e){var n=t.camelize(e.attributeName);l[n]||o.test(n)||a.attr(n,i.getAttribute(e.attributeName))}),this.scope=this.viewModel=a,t.data(t.$(i),"scope",this.scope),t.data(t.$(i),"viewModel",this.scope);var b=u?this.scope:s.scope.add(this.scope),y={helpers:{}};if(t.each(this.helpers||{},function(e,n){t.isFunction(e)&&(y.helpers[n]=function(){return e.apply(a,arguments)})}),f.push(function(){t.each(g,function(t,e){a.unbind(e,g[e])})}),this._control=new this.constructor.Control(i,{scope:this.scope,viewModel:this.scope}),this._control&&this._control.destroy){var w=this._control.destroy;this._control.destroy=function(){w.apply(this,arguments),m()},this._control.on()}else t.bind.call(i,"removed",function(){m()});var M=t.view.nodeLists.register([],void 0,!0);f.push(function(){t.view.nodeLists.unregister(M)}),this.constructor.renderer?(y.tags||(y.tags={}),y.tags.content=function C(e,o){var i=s.subtemplate||o.subtemplate;if(i){delete y.tags.content;var a=u&&i===s.subtemplate?s:o;if(o.parentNodeList){var c=i(a.scope,a.options,o.parentNodeList);n.replace([e],c)}else t.view.live.replace([e],i(a.scope,a.options));y.tags.content=C}},c=this.constructor.renderer(b,s.options.add(y),M)):c="legacy"===s.templateType?t.view.frag(s.subtemplate?s.subtemplate(b,s.options.add(y)):""):s.subtemplate?s.subtemplate(b,s.options.add(y),M):document.createDocumentFragment(),t.appendChild(i,c),t.view.nodeLists.update(M,i.childNodes)}}),a=t.Control.extend({_lookup:function(t){return[t.scope,t,window]},_action:function(e,n,o){var s,a;if(i.lastIndex=0,s=i.test(e),o||!s){if(s){a=t.compute(function(){var o,s=e.replace(i,function(e,i){var s;return"scope"===i||"viewModel"===i?(o=n.scope,""):(i=i.replace(/^(scope|^viewModel)\./,""),s=t.compute.read(n.scope,i.split("."),{isArgument:!0}).value,void 0===s&&(s=t.getObject(i)),"string"==typeof s?s:(o=s,""))}),a=s.split(/\s+/g),c=a.pop();return{processor:this.processors[c]||this.processors.click,parts:[s,a.join(" "),c],delegate:o||void 0}},this);var c=function(t,n){o._bindings.control[e](o.element),o._bindings.control[e]=n.processor(n.delegate||o.element,n.parts[2],n.parts[1],e,o)};return a.bind("change",c),o._bindings.readyComputes[e]={compute:a,handler:c},a()}return t.Control._action.apply(this,arguments)}}},{setup:function(e,n){return this.scope=n.scope,this.viewModel=n.viewModel,t.Control.prototype.setup.call(this,e,n)},off:function(){this._bindings&&t.each(this._bindings.readyComputes||{},function(t){t.compute.unbind("change",t.handler)}),t.Control.prototype.off.apply(this,arguments),this._bindings.readyComputes={}}}),c=t.$;return c.fn&&(c.fn.scope=c.fn.viewModel=function(){return t.viewModel.apply(t,[this].concat(t.makeArray(arguments)))}),s}); +/*can@2.2.6#model/model*/ +define("can/model/model",["can/util/util","can/map/map","can/list/list"],function(t){var e=function(e,r,i){var n=new t.Deferred;return e.then(function(){var e=t.makeArray(arguments),s=!0;try{e[0]=i.apply(r,e)}catch(o){s=!1,n.rejectWith(n,[o].concat(e))}s&&n.resolveWith(n,e)},function(){n.rejectWith(this,arguments)}),"function"==typeof e.abort&&(n.abort=function(){return e.abort()}),n},r=0,i=function(e){return t.__observe(e,e.constructor.id),e.__get(e.constructor.id)},n=function(e,r,i,n,s,o){var a={};if("string"==typeof e){var u=e.split(/\s+/);a.url=u.pop(),u.length&&(a.type=u.pop())}else t.extend(a,e);return a.data="object"!=typeof r||t.isArray(r)?r:t.extend(a.data||{},r),a.url=t.sub(a.url,a.data,!0),t.ajax(t.extend({type:i||"post",dataType:n||"json",success:s,error:o},a))},s=function(r,n,s,o,a){var u;t.isArray(r)?(u=r[1],r=r[0]):u=r.serialize(),u=[u];var c,l,d=r.constructor;return("update"===n||"destroy"===n)&&u.unshift(i(r)),l=d[n].apply(d,u),c=e(l,r,function(t){return r[a||n+"d"](t,l),r}),l.abort&&(c.abort=function(){l.abort()}),c.then(s,o),c},o={models:function(e,r,i){if(t.Model._reqs++,e){if(e instanceof this.List)return e;var n=this,s=[],o=n.List||f,a=r instanceof t.List?r:new o,u=e instanceof f,c=u?e.serialize():e;if(c=n.parseModels(c,i),c.data&&(e=c,c=c.data),"undefined"==typeof c||!t.isArray(c))throw new Error("Could not get any raw data while converting using .models");return a.length&&a.splice(0),t.each(c,function(t){s.push(n.model(t,i))}),a.push.apply(a,s),t.isArray(e)||t.each(e,function(t,e){"data"!==e&&a.attr(e,t)}),setTimeout(t.proxy(this._clean,this),1),a}},model:function(e,r,i){if(e){e="function"==typeof e.serialize?e.serialize():this.parseModel(e,i);var n=e[this.id];(n||0===n)&&this.store[n]&&(r=this.store[n]);var s=r&&t.isFunction(r.attr)?r.attr(e,this.removeAttr||!1):new this(e);return s}}},a={parseModel:function(e){return function(r){return e?t.getObject(e,r):r}},parseModels:function(e){return function(r){if(t.isArray(r))return r;e=e||"data";var i=t.getObject(e,r);if(!t.isArray(i))throw new Error("Could not get any raw data while converting using .models");return i}}},u={create:{url:"_shortName",type:"post"},update:{data:function(e,r){r=r||{};var i=this.id;return r[i]&&r[i]!==e&&(r["new"+t.capitalize(e)]=r[i],delete r[i]),r[i]=e,r},type:"put"},destroy:{type:"delete",data:function(t,e){return e=e||{},e.id=e[this.id]=t,e}},findAll:{url:"_shortName"},findOne:{}},c=function(t,e){return function(r){return r=t.data?t.data.apply(this,arguments):r,n(e||this[t.url||"_url"],r,t.type||"get")}},l=function(t,e){if(t.resource){var r=t.resource.replace(/\/+$/,"");return"findAll"===e||"create"===e?r:r+"/{"+t.id+"}"}};t.Model=t.Map.extend({fullName:"can.Model",_reqs:0,setup:function(e,i,n,s){if("string"!=typeof i&&(s=n,n=i),s||(s=n),this.store={},t.Map.setup.apply(this,arguments),t.Model){n&&n.List?(this.List=n.List,this.List.Map=this):this.List=e.List.extend({Map:this},{});var d=this,p=t.proxy(this._clean,d);t.each(u,function(r,i){if(n&&n[i]&&("string"==typeof n[i]||"object"==typeof n[i])?d[i]=c(r,n[i]):n&&n.resource&&!t.isFunction(n[i])&&(d[i]=c(r,l(d,i))),d["make"+t.capitalize(i)]){var s=d["make"+t.capitalize(i)](d[i]);t.Construct._overwrite(d,e,i,function(){t.Model._reqs++;var e=s.apply(this,arguments),r=e.then(p,p);return r.abort=e.abort,r})}});var h={};t.each(o,function(r,i){var s="parse"+t.capitalize(i),o=n&&n[i]||d[i];"string"==typeof o?(d[s]=o,t.Construct._overwrite(d,e,i,r)):n&&n[i]&&(h[s]=!0)}),t.each(a,function(r,i){var s=n&&n[i]||d[i];if("string"==typeof s)t.Construct._overwrite(d,e,i,r(s));else if(!(n&&t.isFunction(n[i])||d[i])){var o=r();o.useModelConverter=h[i],t.Construct._overwrite(d,e,i,o)}}),"can.Model"!==d.fullName&&d.fullName||(d.fullName="Model"+ ++r),t.Model._reqs=0,this._url=this._shortName+"/{"+this.id+"}"}},_ajax:c,_makeRequest:s,_clean:function(){if(t.Model._reqs--,!t.Model._reqs)for(var e in this.store)this.store[e]._bindings||delete this.store[e];return arguments[0]},models:o.models,model:o.model},{setup:function(e){var r=e&&e[this.constructor.id];t.Model._reqs&&null!=r&&(this.constructor.store[r]=this),t.Map.prototype.setup.apply(this,arguments)},isNew:function(){var t=i(this);return!(t||0===t)},save:function(t,e){return s(this,this.isNew()?"create":"update",t,e)},destroy:function(e,r){if(this.isNew()){var i=this,n=t.Deferred();return n.then(e,r),n.done(function(t){i.destroyed(t)}).resolve(i)}return s(this,"destroy",e,r,"destroyed")},_bindsetup:function(){var e=this.__get(this.constructor.id);return null!=e&&(this.constructor.store[e]=this),t.Map.prototype._bindsetup.apply(this,arguments)},_bindteardown:function(){return delete this.constructor.store[i(this)],t.Map.prototype._bindteardown.apply(this,arguments)},___set:function(e,r){t.Map.prototype.___set.call(this,e,r),e===this.constructor.id&&this._bindings&&(this.constructor.store[i(this)]=this)}});var d=function(t){return function(e,r,i){return this[t](e,null,i)}},p=function(t){return this.parseModel.useModelConverter?this.model(t):this.parseModel(t)},h={makeFindAll:d("models"),makeFindOne:d("model"),makeCreate:p,makeUpdate:p,makeDestroy:p};t.each(h,function(r,i){t.Model[i]=function(i){return function(){var n=t.makeArray(arguments),s=t.isFunction(n[1])?n.splice(0,1):n.splice(0,2),o=e(i.apply(this,s),this,r);return o.then(n[0],n[1]),o}}}),t.each(["created","updated","destroyed"],function(e){t.Model.prototype[e]=function(r){var i=this,n=i.constructor;r&&"object"==typeof r&&this.attr(t.isFunction(r.attr)?r.attr():r),t.dispatch.call(this,{type:"change",target:this},[e]),t.dispatch.call(n,e,[this])}});var f=t.Model.List=t.List.extend({_bubbleRule:function(e,r){var i=t.List._bubbleRule(e,r);return i.push("destroyed"),i}},{setup:function(e){t.isPlainObject(e)&&!t.isArray(e)?(t.List.prototype.setup.apply(this),this.replace(t.isDeferred(e)?e:this.constructor.Map.findAll(e))):t.List.prototype.setup.apply(this,arguments),this._init=1,this.bind("destroyed",t.proxy(this._destroyed,this)),delete this._init},_destroyed:function(t,e){if(/\w+/.test(e))for(var r;(r=this.indexOf(t.target))>-1;)this.splice(r,1)}});return t.Model}); +/*can@2.2.6#util/string/deparam/deparam*/ +define("can/util/string/deparam/deparam",["can/util/util","can/util/string/string"],function(t){var n=/^\d+$/,e=/([^\[\]]+)|(\[\])/g,r=/([^?#]*)(#.*)?$/,i=function(t){return decodeURIComponent(t.replace(/\+/g," "))};return t.extend(t,{deparam:function(a){var u,c,o={};return a&&r.test(a)&&(u=a.split("&"),t.each(u,function(t){var r=t.split("="),a=i(r.shift()),u=i(r.join("=")),p=o;if(a){r=a.match(e);for(var s=0,d=r.length-1;d>s;s++)p[r[s]]||(p[r[s]]=n.test(r[s+1])||"[]"===r[s+1]?[]:{}),p=p[r[s]];c=r.pop(),"[]"===c?p.push(u):p[c]=u}})),o}}),t}); +/*can@2.2.6#route/route*/ +define("can/route/route",["can/util/util","can/map/map","can/list/list","can/util/string/deparam/deparam"],function(t){var e,r,n,a,u=/\:([\w\.]+)/g,o=/^(?:&[^=]+=[^&]*)+/,i=function(e){var r=[];return t.each(e,function(e,n){r.push(("className"===n?"class":n)+'="'+("href"===n?e:t.esc(e))+'"')}),r.join(" ")},c=function(t,e){var r=0,n=0,a={};for(var u in t.defaults)t.defaults[u]===e[u]&&(a[u]=1,r++);for(;no&&(n=t,o=a),a>=l?!1:void 0}),t.route.routes[i]&&c(t.route.routes[i],e)===o&&(n=t.route.routes[i]),n){var s,h=f({},e),p=n.route.replace(u,function(t,r){return delete h[r],e[r]===n.defaults[r]?"":encodeURIComponent(e[r])}).replace("\\","");return d(n.defaults,function(t,e){h[e]===t&&delete h[e]}),s=t.param(h),r&&t.route.attr("route",n.route),p+(s?t.route._call("querySeparator")+s:"")}return t.isEmptyObject(e)?"":t.route._call("querySeparator")+t.param(e)},deparam:function(e){var r=t.route._call("root");r.lastIndexOf("/")===r.length-1&&0===e.indexOf("/")&&(e=e.substr(1));var n={length:-1},a=t.route._call("querySeparator"),u=t.route._call("paramsMatcher");if(d(t.route.routes,function(t,r){t.test.test(e)&&t.length>n.length&&(n=t)}),n.length>-1){var o=e.match(n.test),i=o.shift(),c=e.substr(i.length-(o[o.length-1]===a?1:0)),l=c&&u.test(c)?t.deparam(c.slice(1)):{};return l=f(!0,{},n.defaults,l),d(o,function(t,e){t&&t!==a&&(l[n.names[e]]=decodeURIComponent(t))}),l.route=n.route,l}return e.charAt(0)!==a&&(e=a+e),u.test(e)?t.deparam(e.slice(1)):{}},data:new t.Map({}),map:function(e){var r;r=e.prototype instanceof t.Map?new e:e,t.route.data=r},routes:{},ready:function(e){return e!==!0&&(t.route._setup(),t.route.setState()),t.route},url:function(e,r){return r&&(e=t.extend({},t.route.deparam(t.route._call("matchingPartOfURL")),e)),t.route._call("root")+t.route.param(e)},link:function(e,r,n,a){return""+e+""},current:function(e){return t.__observe(_,"__url"),this._call("matchingPartOfURL")===t.route.param(e)},bindings:{hashchange:{paramsMatcher:o,querySeparator:"&",matchSlashes:!1,bind:function(){t.bind.call(window,"hashchange",b)},unbind:function(){t.unbind.call(window,"hashchange",b)},matchingPartOfURL:function(){return l.href.split(/#!?/)[1]||""},setURL:function(t){return l.hash!=="#"+t&&(l.hash="!"+t),t},root:"#!"}},defaultBinding:"hashchange",currentBinding:null,_setup:function(){t.route.currentBinding||(t.route._call("bind"),t.route.bind("change",m),t.route.currentBinding=t.route.defaultBinding)},_teardown:function(){t.route.currentBinding&&(t.route._call("unbind"),t.route.unbind("change",m),t.route.currentBinding=null),clearTimeout(e),a=0},_call:function(){var e=t.makeArray(arguments),r=e.shift(),n=t.route.bindings[t.route.currentBinding||t.route.defaultBinding],a=n[r];return a.apply?a.apply(n,e):a}}),d(["bind","unbind","on","off","delegate","undelegate","removeAttr","compute","_get","__get","each"],function(e){t.route[e]=function(){return t.route.data[e]?t.route.data[e].apply(t.route.data,arguments):void 0}}),t.route.attr=function(e,r){var n,a=typeof e;return n=void 0===r?arguments:"string"!==a&&"number"!==a?[h(e),r]:[e,h(r)],t.route.data.attr.apply(t.route.data,n)};var b=t.route.setState=function(){var e=t.route._call("matchingPartOfURL"),u=r;r=t.route.deparam(e),a&&e===n||(t.batch.start(),v(u,r,t.route.data),t.route.attr(r),t.batch.trigger(_,"__url",[e,n]),t.batch.stop())},v=function(t,e,r){for(var n in t)void 0===e[n]?r.removeAttr(n):"[object Object]"===Object.prototype.toString.call(t[n])&&v(t[n],e[n],r.attr(n))};return t.route}); +/*can@2.2.6#control/route/route*/ +define("can/control/route/route",["can/util/util","can/route/route","can/control/control"],function(t){return t.Control.processors.route=function(o,r,u,n,e){u=u||"",t.route.routes[u]||("/"===u[0]&&(u=u.substring(1)),t.route(u));var c,i=function(o,r,i){if(t.route.attr("route")===u&&(void 0===o.batchNum||o.batchNum!==c)){c=o.batchNum;var a=t.route.attr();delete a.route,t.isFunction(e[n])?e[n](a):e[e[n]](a)}};return t.route.bind("change",i),function(){t.route.unbind("change",i)}},t}); +/*[global-shim-end]*/ +!function(){window._define=window.define,window.define=window.define.orig}(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.object.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.object.js new file mode 100644 index 0000000000..0373019e6f --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.object.js @@ -0,0 +1,168 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#util/object/object*/ +define('can/util/object/object', ['can/util/util'], function (can) { + var isArray = can.isArray; + can.Object = {}; + var same = can.Object.same = function (a, b, compares, aParent, bParent, deep) { + var aType = typeof a, aArray = isArray(a), comparesType = typeof compares, compare; + if (comparesType === 'string' || compares === null) { + compares = compareMethods[compares]; + comparesType = 'function'; + } + if (comparesType === 'function') { + return compares(a, b, aParent, bParent); + } + compares = compares || {}; + if (a === null || b === null) { + return a === b; + } + if (a instanceof Date || b instanceof Date) { + return a === b; + } + if (deep === -1) { + return aType === 'object' || a === b; + } + if (aType !== typeof b || aArray !== isArray(b)) { + return false; + } + if (a === b) { + return true; + } + if (aArray) { + if (a.length !== b.length) { + return false; + } + for (var i = 0; i < a.length; i++) { + compare = compares[i] === undefined ? compares['*'] : compares[i]; + if (!same(a[i], b[i], a, b, compare)) { + return false; + } + } + return true; + } else if (aType === 'object' || aType === 'function') { + var bCopy = can.extend({}, b); + for (var prop in a) { + compare = compares[prop] === undefined ? compares['*'] : compares[prop]; + if (!same(a[prop], b[prop], compare, a, b, deep === false ? -1 : undefined)) { + return false; + } + delete bCopy[prop]; + } + for (prop in bCopy) { + if (compares[prop] === undefined || !same(undefined, b[prop], compares[prop], a, b, deep === false ? -1 : undefined)) { + return false; + } + } + return true; + } + return false; + }; + can.Object.subsets = function (checkSet, sets, compares) { + var len = sets.length, subsets = []; + for (var i = 0; i < len; i++) { + var set = sets[i]; + if (can.Object.subset(checkSet, set, compares)) { + subsets.push(set); + } + } + return subsets; + }; + can.Object.subset = function (subset, set, compares) { + compares = compares || {}; + for (var prop in set) { + if (!same(subset[prop], set[prop], compares[prop], subset, set)) { + return false; + } + } + return true; + }; + var compareMethods = { + 'null': function () { + return true; + }, + i: function (a, b) { + return ('' + a).toLowerCase() === ('' + b).toLowerCase(); + }, + eq: function (a, b) { + return a === b; + }, + similar: function (a, b) { + return a == b; + } + }; + compareMethods.eqeq = compareMethods.similar; + return can.Object; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.route.pushstate.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.route.pushstate.js new file mode 100644 index 0000000000..da57517136 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.route.pushstate.js @@ -0,0 +1,191 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#route/pushstate/pushstate*/ +define('can/route/pushstate/pushstate', [ + 'can/util/util', + 'can/route/route' +], function (can) { + 'use strict'; + if (window.history && history.pushState) { + can.route.bindings.pushstate = { + root: '/', + matchSlashes: false, + paramsMatcher: /^\?(?:[^=]+=[^&]*&)*[^=]+=[^&]*/, + querySeparator: '?', + bind: function () { + can.delegate.call(can.$(document.documentElement), 'a', 'click', anchorClickHandler); + can.each(methodsToOverwrite, function (method) { + originalMethods[method] = window.history[method]; + window.history[method] = function (state, title, url) { + var absolute = url.indexOf('http') === 0; + var searchHash = window.location.search + window.location.hash; + if (!absolute && url !== window.location.pathname + searchHash || absolute && url !== window.location.href + searchHash) { + originalMethods[method].apply(window.history, arguments); + can.route.setState(); + } + }; + }); + can.bind.call(window, 'popstate', can.route.setState); + }, + unbind: function () { + can.undelegate.call(can.$(document.documentElement), 'click', 'a', anchorClickHandler); + can.each(methodsToOverwrite, function (method) { + window.history[method] = originalMethods[method]; + }); + can.unbind.call(window, 'popstate', can.route.setState); + }, + matchingPartOfURL: function () { + var root = cleanRoot(), loc = location.pathname + location.search, index = loc.indexOf(root); + return loc.substr(index + root.length); + }, + setURL: function (path, changed) { + var method = 'pushState'; + if (includeHash && path.indexOf('#') === -1 && window.location.hash) { + path += window.location.hash; + } + if (replaceStateAttrs.length > 0) { + var toRemove = []; + for (var i = 0, l = changed.length; i < l; i++) { + if (can.inArray(changed[i], replaceStateAttrs) !== -1) { + method = 'replaceState'; + } + if (can.inArray(changed[i], replaceStateAttrs.once) !== -1) { + toRemove.push(changed[i]); + } + } + if (toRemove.length > 0) { + removeAttrs(replaceStateAttrs, toRemove); + removeAttrs(replaceStateAttrs.once, toRemove); + } + } + window.history[method](null, null, can.route._call('root') + path); + } + }; + var anchorClickHandler = function (e) { + if (!(e.isDefaultPrevented ? e.isDefaultPrevented() : e.defaultPrevented === true)) { + var node = this._node || this; + var linksHost = node.host || window.location.host; + if (window.location.host === linksHost) { + var root = cleanRoot(); + if (node.pathname.indexOf(root) === 0) { + var url = (node.pathname + node.search).substr(root.length); + var curParams = can.route.deparam(url); + if (curParams.hasOwnProperty('route')) { + includeHash = true; + window.history.pushState(null, null, node.href); + if (e.preventDefault) { + e.preventDefault(); + } + } + } + } + } + }, cleanRoot = function () { + var domain = location.protocol + '//' + location.host, root = can.route._call('root'), index = root.indexOf(domain); + if (index === 0) { + return root.substr(domain.length); + } + return root; + }, removeAttrs = function (arr, attrs) { + var index; + for (var i = attrs.length - 1; i >= 0; i--) { + if ((index = can.inArray(attrs[i], arr)) !== -1) { + arr.splice(index, 1); + } + } + }, methodsToOverwrite = [ + 'pushState', + 'replaceState' + ], originalMethods = {}, includeHash = false, replaceStateAttrs = []; + can.route.defaultBinding = 'pushstate'; + can.extend(can.route, { + replaceStateOn: function () { + var attrs = can.makeArray(arguments); + Array.prototype.push.apply(replaceStateAttrs, attrs); + }, + replaceStateOnce: function () { + var attrs = can.makeArray(arguments); + replaceStateAttrs.once = can.makeArray(replaceStateAttrs.once); + Array.prototype.push.apply(replaceStateAttrs.once, attrs); + can.route.replaceStateOn.apply(this, arguments); + }, + replaceStateOff: function () { + var attrs = can.makeArray(arguments); + removeAttrs(replaceStateAttrs, attrs); + } + }); + } + return can; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.stache.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.stache.js new file mode 100644 index 0000000000..d2b0e7bed3 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.stache.js @@ -0,0 +1,764 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#view/target/target*/ +define('can/view/target/target', [ + 'can/util/util', + 'can/view/elements' +], function (can, elements) { + var processNodes = function (nodes, paths, location) { + var frag = document.createDocumentFragment(); + for (var i = 0, len = nodes.length; i < len; i++) { + var node = nodes[i]; + frag.appendChild(processNode(node, paths, location.concat(i))); + } + return frag; + }, keepsTextNodes = typeof document !== 'undefined' && function () { + var testFrag = document.createDocumentFragment(); + var div = document.createElement('div'); + div.appendChild(document.createTextNode('')); + div.appendChild(document.createTextNode('')); + testFrag.appendChild(div); + var cloned = testFrag.cloneNode(true); + return cloned.childNodes[0].childNodes.length === 2; + }(), clonesWork = typeof document !== 'undefined' && function () { + var a = document.createElement('a'); + a.innerHTML = ''; + var clone = a.cloneNode(true); + return clone.innerHTML === ''; + }(), namespacesWork = typeof document !== 'undefined' && !!document.createElementNS; + var cloneNode = clonesWork ? function (el) { + return el.cloneNode(true); + } : function (node) { + var copy; + if (node.nodeType === 1) { + copy = document.createElement(node.nodeName); + } else if (node.nodeType === 3) { + copy = document.createTextNode(node.nodeValue); + } else if (node.nodeType === 8) { + copy = document.createComment(node.nodeValue); + } else if (node.nodeType === 11) { + copy = document.createDocumentFragment(); + } + if (node.attributes) { + var attributes = can.makeArray(node.attributes); + can.each(attributes, function (node) { + if (node && node.specified) { + copy.setAttribute(node.nodeName, node.nodeValue); + } + }); + } + if (node.childNodes) { + can.each(node.childNodes, function (child) { + copy.appendChild(cloneNode(child)); + }); + } + return copy; + }; + function processNode(node, paths, location) { + var callback, loc = location, nodeType = typeof node, el, p, i, len; + var getCallback = function () { + if (!callback) { + callback = { + path: location, + callbacks: [] + }; + paths.push(callback); + loc = []; + } + return callback; + }; + if (nodeType === 'object') { + if (node.tag) { + if (namespacesWork && node.namespace) { + el = document.createElementNS(node.namespace, node.tag); + } else { + el = document.createElement(node.tag); + } + if (node.attrs) { + for (var attrName in node.attrs) { + var value = node.attrs[attrName]; + if (typeof value === 'function') { + getCallback().callbacks.push({ callback: value }); + } else { + el.setAttribute(attrName, value); + } + } + } + if (node.attributes) { + for (i = 0, len = node.attributes.length; i < len; i++) { + getCallback().callbacks.push({ callback: node.attributes[i] }); + } + } + if (node.children && node.children.length) { + if (callback) { + p = callback.paths = []; + } else { + p = paths; + } + el.appendChild(processNodes(node.children, p, loc)); + } + } else if (node.comment) { + el = document.createComment(node.comment); + if (node.callbacks) { + for (i = 0, len = node.attributes.length; i < len; i++) { + getCallback().callbacks.push({ callback: node.callbacks[i] }); + } + } + } + } else if (nodeType === 'string') { + el = document.createTextNode(node); + } else if (nodeType === 'function') { + if (keepsTextNodes) { + el = document.createTextNode(''); + getCallback().callbacks.push({ callback: node }); + } else { + el = document.createComment('~'); + getCallback().callbacks.push({ + callback: function () { + var el = document.createTextNode(''); + elements.replace([this], el); + return node.apply(el, arguments); + } + }); + } + } + return el; + } + function hydratePath(el, pathData, args) { + var path = pathData.path, callbacks = pathData.callbacks, paths = pathData.paths, callbackData, child = el; + for (var i = 0, len = path.length; i < len; i++) { + child = child.childNodes[path[i]]; + } + for (i = 0, len = callbacks.length; i < len; i++) { + callbackData = callbacks[i]; + callbackData.callback.apply(child, args); + } + if (paths && paths.length) { + for (i = paths.length - 1; i >= 0; i--) { + hydratePath(child, paths[i], args); + } + } + } + function makeTarget(nodes) { + var paths = []; + var frag = processNodes(nodes, paths, []); + return { + paths: paths, + clone: frag, + hydrate: function () { + var cloned = cloneNode(this.clone); + var args = can.makeArray(arguments); + for (var i = paths.length - 1; i >= 0; i--) { + hydratePath(cloned, paths[i], args); + } + return cloned; + } + }; + } + makeTarget.keepsTextNodes = keepsTextNodes; + can.view.target = makeTarget; + return makeTarget; +}); +/*can@2.2.6#view/stache/html_section*/ +define('can/view/stache/html_section', [ + 'can/util/util', + 'can/view/target/target', + 'can/view/stache/utils', + 'can/view/stache/mustache_core' +], function (can, target, utils, mustacheCore) { + var decodeHTML = typeof document !== 'undefined' && function () { + var el = document.createElement('div'); + return function (html) { + if (html.indexOf('&') === -1) { + return html.replace(/\r\n/g, '\n'); + } + el.innerHTML = html; + return el.childNodes.length === 0 ? '' : el.childNodes[0].nodeValue; + }; + }(); + var HTMLSectionBuilder = function () { + this.stack = [new HTMLSection()]; + }; + can.extend(HTMLSectionBuilder.prototype, utils.mixins); + can.extend(HTMLSectionBuilder.prototype, { + startSubSection: function (process) { + var newSection = new HTMLSection(process); + this.stack.push(newSection); + return newSection; + }, + endSubSectionAndReturnRenderer: function () { + if (this.last().isEmpty()) { + this.stack.pop(); + return null; + } else { + var htmlSection = this.endSection(); + return can.proxy(htmlSection.compiled.hydrate, htmlSection.compiled); + } + }, + startSection: function (process) { + var newSection = new HTMLSection(process); + this.last().add(newSection.targetCallback); + this.stack.push(newSection); + }, + endSection: function () { + this.last().compile(); + return this.stack.pop(); + }, + inverse: function () { + this.last().inverse(); + }, + compile: function () { + var compiled = this.stack.pop().compile(); + return function (scope, options, nodeList) { + if (!(scope instanceof can.view.Scope)) { + scope = new can.view.Scope(scope || {}); + } + if (!(options instanceof mustacheCore.Options)) { + options = new mustacheCore.Options(options || {}); + } + return compiled.hydrate(scope, options, nodeList); + }; + }, + push: function (chars) { + this.last().push(chars); + }, + pop: function () { + return this.last().pop(); + } + }); + var HTMLSection = function (process) { + this.data = 'targetData'; + this.targetData = []; + this.targetStack = []; + var self = this; + this.targetCallback = function (scope, options, sectionNode) { + process.call(this, scope, options, sectionNode, can.proxy(self.compiled.hydrate, self.compiled), self.inverseCompiled && can.proxy(self.inverseCompiled.hydrate, self.inverseCompiled)); + }; + }; + can.extend(HTMLSection.prototype, { + inverse: function () { + this.inverseData = []; + this.data = 'inverseData'; + }, + push: function (data) { + this.add(data); + this.targetStack.push(data); + }, + pop: function () { + return this.targetStack.pop(); + }, + add: function (data) { + if (typeof data === 'string') { + data = decodeHTML(data); + } + if (this.targetStack.length) { + this.targetStack[this.targetStack.length - 1].children.push(data); + } else { + this[this.data].push(data); + } + }, + compile: function () { + this.compiled = target(this.targetData); + if (this.inverseData) { + this.inverseCompiled = target(this.inverseData); + delete this.inverseData; + } + delete this.targetData; + delete this.targetStack; + return this.compiled; + }, + children: function () { + if (this.targetStack.length) { + return this.targetStack[this.targetStack.length - 1].children; + } else { + return this[this.data]; + } + }, + isEmpty: function () { + return !this.targetData.length; + } + }); + return HTMLSectionBuilder; +}); +/*can@2.2.6#view/stache/text_section*/ +define('can/view/stache/text_section', [ + 'can/util/util', + 'can/view/live/live', + 'can/view/stache/utils' +], function (can, live, utils) { + live = live || can.view.live; + var TextSectionBuilder = function () { + this.stack = [new TextSection()]; + }, emptyHandler = function () { + }; + can.extend(TextSectionBuilder.prototype, utils.mixins); + can.extend(TextSectionBuilder.prototype, { + startSection: function (process) { + var subSection = new TextSection(); + this.last().add({ + process: process, + truthy: subSection + }); + this.stack.push(subSection); + }, + endSection: function () { + this.stack.pop(); + }, + inverse: function () { + this.stack.pop(); + var falseySection = new TextSection(); + this.last().last().falsey = falseySection; + this.stack.push(falseySection); + }, + compile: function (state) { + var renderer = this.stack[0].compile(); + return function (scope, options) { + var compute = can.compute(function () { + return renderer(scope, options); + }, this, false, true); + compute.bind('change', emptyHandler); + var value = compute(); + if (compute.computeInstance.hasDependencies) { + if (state.attr) { + live.simpleAttribute(this, state.attr, compute); + } else { + live.attributes(this, compute); + } + compute.unbind('change', emptyHandler); + } else { + if (state.attr) { + can.attr.set(this, state.attr, value); + } else { + live.setAttributes(this, value); + } + } + }; + } + }); + var passTruthyFalsey = function (process, truthy, falsey) { + return function (scope, options) { + return process.call(this, scope, options, truthy, falsey); + }; + }; + var TextSection = function () { + this.values = []; + }; + can.extend(TextSection.prototype, { + add: function (data) { + this.values.push(data); + }, + last: function () { + return this.values[this.values.length - 1]; + }, + compile: function () { + var values = this.values, len = values.length; + for (var i = 0; i < len; i++) { + var value = this.values[i]; + if (typeof value === 'object') { + values[i] = passTruthyFalsey(value.process, value.truthy && value.truthy.compile(), value.falsey && value.falsey.compile()); + } + } + return function (scope, options) { + var txt = '', value; + for (var i = 0; i < len; i++) { + value = values[i]; + txt += typeof value === 'string' ? value : value.call(this, scope, options); + } + return txt; + }; + } + }); + return TextSectionBuilder; +}); +/*can@2.2.6#view/stache/intermediate_and_imports*/ +define('can/view/stache/intermediate_and_imports', [ + 'can/view/stache/mustache_core', + 'can/view/parser/parser' +], function (mustacheCore, parser) { + return function (source) { + var template = mustacheCore.cleanLineEndings(source); + var imports = [], inImport = false, inFrom = false; + var keepToken = function () { + return inImport ? false : true; + }; + var intermediate = parser(template, { + start: function (tagName, unary) { + if (tagName === 'can-import') { + inImport = true; + } + return keepToken(); + }, + end: function (tagName, unary) { + if (tagName === 'can-import') { + inImport = false; + return false; + } + return keepToken(); + }, + attrStart: function (attrName) { + if (attrName === 'from') { + inFrom = true; + } + return keepToken(); + }, + attrEnd: function (attrName) { + if (attrName === 'from') { + inFrom = false; + } + return keepToken(); + }, + attrValue: function (value) { + if (inFrom && inImport) { + imports.push(value); + } + return keepToken(); + }, + chars: keepToken, + comment: keepToken, + special: keepToken, + done: keepToken + }, true); + return { + intermediate: intermediate, + imports: imports + }; + }; +}); +/*can@2.2.6#view/stache/stache*/ +define('can/view/stache/stache', [ + 'can/util/util', + 'can/view/parser/parser', + 'can/view/target/target', + 'can/view/stache/html_section', + 'can/view/stache/text_section', + 'can/view/stache/mustache_core', + 'can/view/stache/mustache_helpers', + 'can/view/stache/intermediate_and_imports', + 'can/view/callbacks/callbacks', + 'can/view/bindings/bindings' +], function (can, parser, target, HTMLSectionBuilder, TextSectionBuilder, mustacheCore, mustacheHelpers, getIntermediateAndImports, viewCallbacks) { + parser = parser || can.view.parser; + viewCallbacks = viewCallbacks || can.view.callbacks; + var svgNamespace = 'http://www.w3.org/2000/svg'; + var namespaces = { + 'svg': svgNamespace, + 'g': svgNamespace + }; + function stache(template) { + if (typeof template === 'string') { + template = mustacheCore.cleanLineEndings(template); + } + var section = new HTMLSectionBuilder(), state = { + node: null, + attr: null, + sectionElementStack: [], + text: false, + namespaceStack: [] + }, makeRendererAndUpdateSection = function (section, mode, stache) { + if (mode === '>') { + section.add(mustacheCore.makeLiveBindingPartialRenderer(stache, state)); + } else if (mode === '/') { + section.endSection(); + if (section instanceof HTMLSectionBuilder) { + state.sectionElementStack.pop(); + } + } else if (mode === 'else') { + section.inverse(); + } else { + var makeRenderer = section instanceof HTMLSectionBuilder ? mustacheCore.makeLiveBindingBranchRenderer : mustacheCore.makeStringBranchRenderer; + if (mode === '{' || mode === '&') { + section.add(makeRenderer(null, stache, copyState())); + } else if (mode === '#' || mode === '^') { + section.startSection(makeRenderer(mode, stache, copyState())); + if (section instanceof HTMLSectionBuilder) { + state.sectionElementStack.push('section'); + } + } else { + section.add(makeRenderer(null, stache, copyState({ text: true }))); + } + } + }, copyState = function (overwrites) { + var lastElement = state.sectionElementStack[state.sectionElementStack.length - 1]; + var cur = { + tag: state.node && state.node.tag, + attr: state.attr && state.attr.name, + directlyNested: state.sectionElementStack.length ? lastElement === 'section' || lastElement === 'custom' : true + }; + return overwrites ? can.simpleExtend(cur, overwrites) : cur; + }, addAttributesCallback = function (node, callback) { + if (!node.attributes) { + node.attributes = []; + } + node.attributes.push(callback); + }; + parser(template, { + start: function (tagName, unary) { + var matchedNamespace = namespaces[tagName]; + if (matchedNamespace && !unary) { + state.namespaceStack.push(matchedNamespace); + } + state.node = { + tag: tagName, + children: [], + namespace: matchedNamespace || can.last(state.namespaceStack) + }; + }, + end: function (tagName, unary) { + var isCustomTag = viewCallbacks.tag(tagName); + if (unary) { + section.add(state.node); + if (isCustomTag) { + addAttributesCallback(state.node, function (scope, options, parentNodeList) { + viewCallbacks.tagHandler(this, tagName, { + scope: scope, + options: options, + subtemplate: null, + templateType: 'stache', + parentNodeList: parentNodeList + }); + }); + } + } else { + section.push(state.node); + state.sectionElementStack.push(isCustomTag ? 'custom' : 'element'); + if (isCustomTag) { + section.startSubSection(); + } + } + state.node = null; + }, + close: function (tagName) { + var matchedNamespace = namespaces[tagName]; + if (matchedNamespace) { + state.namespaceStack.pop(); + } + var isCustomTag = viewCallbacks.tag(tagName), renderer; + if (isCustomTag) { + renderer = section.endSubSectionAndReturnRenderer(); + } + var oldNode = section.pop(); + if (isCustomTag) { + addAttributesCallback(oldNode, function (scope, options, parentNodeList) { + viewCallbacks.tagHandler(this, tagName, { + scope: scope, + options: options, + subtemplate: renderer, + templateType: 'stache', + parentNodeList: parentNodeList + }); + }); + } + state.sectionElementStack.pop(); + }, + attrStart: function (attrName) { + if (state.node.section) { + state.node.section.add(attrName + '="'); + } else { + state.attr = { + name: attrName, + value: '' + }; + } + }, + attrEnd: function (attrName) { + if (state.node.section) { + state.node.section.add('" '); + } else { + if (!state.node.attrs) { + state.node.attrs = {}; + } + state.node.attrs[state.attr.name] = state.attr.section ? state.attr.section.compile(copyState()) : state.attr.value; + var attrCallback = viewCallbacks.attr(attrName); + if (attrCallback) { + if (!state.node.attributes) { + state.node.attributes = []; + } + state.node.attributes.push(function (scope, options) { + attrCallback(this, { + attributeName: attrName, + scope: scope, + options: options + }); + }); + } + state.attr = null; + } + }, + attrValue: function (value) { + var section = state.node.section || state.attr.section; + if (section) { + section.add(value); + } else { + state.attr.value += value; + } + }, + chars: function (text) { + section.add(text); + }, + special: function (text) { + var firstAndText = mustacheCore.splitModeFromExpression(text, state), mode = firstAndText.mode, expression = firstAndText.expression; + if (expression === 'else') { + (state.attr && state.attr.section ? state.attr.section : section).inverse(); + return; + } + if (mode === '!') { + return; + } + if (state.node && state.node.section) { + makeRendererAndUpdateSection(state.node.section, mode, expression); + if (state.node.section.subSectionDepth() === 0) { + state.node.attributes.push(state.node.section.compile(copyState())); + delete state.node.section; + } + } else if (state.attr) { + if (!state.attr.section) { + state.attr.section = new TextSectionBuilder(); + if (state.attr.value) { + state.attr.section.add(state.attr.value); + } + } + makeRendererAndUpdateSection(state.attr.section, mode, expression); + } else if (state.node) { + if (!state.node.attributes) { + state.node.attributes = []; + } + if (!mode) { + state.node.attributes.push(mustacheCore.makeLiveBindingBranchRenderer(null, expression, copyState())); + } else if (mode === '#' || mode === '^') { + if (!state.node.section) { + state.node.section = new TextSectionBuilder(); + } + makeRendererAndUpdateSection(state.node.section, mode, expression); + } else { + throw mode + ' is currently not supported within a tag.'; + } + } else { + makeRendererAndUpdateSection(section, mode, expression); + } + }, + comment: function (text) { + section.add({ comment: text }); + }, + done: function () { + } + }); + return section.compile(); + } + var escMap = { + '\n': '\\n', + '\r': '\\r', + '\u2028': '\\u2028', + '\u2029': '\\u2029' + }; + var esc = function (string) { + return ('' + string).replace(/["'\\\n\r\u2028\u2029]/g, function (character) { + if ('\'"\\'.indexOf(character) >= 0) { + return '\\' + character; + } else { + return escMap[character]; + } + }); + }; + can.view.register({ + suffix: 'stache', + contentType: 'x-stache-template', + fragRenderer: function (id, text) { + return stache(text); + }, + script: function (id, src) { + return 'can.stache("' + esc(src) + '")'; + } + }); + can.view.ext = '.stache'; + can.extend(can.stache, mustacheHelpers); + can.extend(stache, mustacheHelpers); + can.stache.safeString = stache.safeString = function (text) { + return { + toString: function () { + return text; + } + }; + }; + can.stache.async = function (source) { + var iAi = getIntermediateAndImports(source); + var importPromises = can.map(iAi.imports, function (moduleName) { + return can['import'](moduleName); + }); + return can.when.apply(can, importPromises).then(function () { + return stache(iAi.intermediate); + }); + }; + return stache; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.util.domless.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.util.domless.js new file mode 100644 index 0000000000..f3f7b05c4e --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.util.domless.js @@ -0,0 +1,183 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#util/array/makeArray*/ +define('can/util/array/makeArray', ['can/util/array/each'], function (can) { + can.makeArray = function (arr) { + var ret = []; + can.each(arr, function (a, i) { + ret[i] = a; + }); + return ret; + }; + return can; +}); +/*can@2.2.6#util/domless/domless*/ +define('can/util/domless/domless', [ + 'can/util/can', + 'can/util/attr/attr', + 'can/util/array/each', + 'can/util/array/makeArray' +], function (can, attr) { + var core_trim = String.prototype.trim; + var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g; + function likeArray(obj) { + return typeof obj.length === 'number'; + } + function flatten(array) { + return array.length > 0 ? Array.prototype.concat.apply([], array) : array; + } + can.isArray = function (arr) { + return arr instanceof Array; + }; + can.isFunction = function () { + if (typeof document !== 'undefined' && typeof document.getElementsByTagName('body') === 'function') { + return function (value) { + return Object.prototype.toString.call(value) === '[object Function]'; + }; + } else { + return function (value) { + return typeof value === 'function'; + }; + } + }(); + can.trim = core_trim && !core_trim.call('\uFEFF\xA0') ? function (text) { + return text == null ? '' : core_trim.call(text); + } : function (text) { + return text == null ? '' : (text + '').replace(rtrim, ''); + }; + can.extend = function () { + var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, length = arguments.length, deep = false; + if (typeof target === 'boolean') { + deep = target; + target = arguments[1] || {}; + i = 2; + } + if (typeof target !== 'object' && !can.isFunction(target)) { + target = {}; + } + if (length === i) { + target = this; + --i; + } + for (; i < length; i++) { + if ((options = arguments[i]) != null) { + for (name in options) { + src = target[name]; + copy = options[name]; + if (target === copy) { + continue; + } + if (deep && copy && (can.isPlainObject(copy) || (copyIsArray = can.isArray(copy)))) { + if (copyIsArray) { + copyIsArray = false; + clone = src && can.isArray(src) ? src : []; + } else { + clone = src && can.isPlainObject(src) ? src : {}; + } + target[name] = can.extend(deep, clone, copy); + } else if (copy !== undefined) { + target[name] = copy; + } + } + } + } + return target; + }; + can.map = function (elements, callback) { + var values = [], putValue = function (val, index) { + var value = callback(val, index); + if (value != null) { + values.push(value); + } + }; + if (likeArray(elements)) { + for (var i = 0, l = elements.length; i < l; i++) { + putValue(elements[i], i); + } + } else { + for (var key in elements) { + putValue(elements[key], key); + } + } + return flatten(values); + }; + can.proxy = function (cb, that) { + return function () { + return cb.apply(that, arguments); + }; + }; + can.attr = attr; + return can; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.util.function.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.util.function.js new file mode 100644 index 0000000000..6cb8e8e236 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.util.function.js @@ -0,0 +1,109 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#util/function/function*/ +define('can/util/function/function', ['can/util/util'], function (can) { + can.debounce = function (fn, time, context) { + var timeout; + return function () { + var args = arguments; + clearTimeout(timeout); + timeout = setTimeout(can.proxy(function () { + fn.apply(this, args); + }, context || this), time); + }; + }; + can.throttle = function (fn, time, context) { + var run; + return function () { + var args = arguments; + var ctx = context || this; + if (!run) { + run = true; + setTimeout(function () { + fn.apply(ctx, args); + run = false; + }, time); + } + }; + }; + can.defer = function (fn, context) { + var args = arguments; + var ctx = context || this; + setTimeout(function () { + fn.apply(ctx, args); + }, 0); + }; + return can; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.view.ejs.system.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.view.ejs.system.js new file mode 100644 index 0000000000..36446f5393 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.view.ejs.system.js @@ -0,0 +1,238 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#view/ejs/ejs*/ +define('can/view/ejs/ejs', [ + 'can/util/util', + 'can/view/view', + 'can/util/string/string', + 'can/compute/compute', + 'can/view/scanner', + 'can/view/render' +], function (can) { + var extend = can.extend, EJS = function (options) { + if (this.constructor !== EJS) { + var ejs = new EJS(options); + return function (data, helpers) { + return ejs.render(data, helpers); + }; + } + if (typeof options === 'function') { + this.template = { fn: options }; + return; + } + extend(this, options); + this.template = this.scanner.scan(this.text, this.name); + }; + can.EJS = EJS; + EJS.prototype.render = function (object, extraHelpers) { + object = object || {}; + return this.template.fn.call(object, object, new EJS.Helpers(object, extraHelpers || {})); + }; + extend(EJS.prototype, { + scanner: new can.view.Scanner({ + text: { + outStart: 'with(_VIEW) { with (_CONTEXT) {', + outEnd: '}}', + argNames: '_CONTEXT,_VIEW', + context: 'this' + }, + tokens: [ + [ + 'templateLeft', + '<%%' + ], + [ + 'templateRight', + '%>' + ], + [ + 'returnLeft', + '<%==' + ], + [ + 'escapeLeft', + '<%=' + ], + [ + 'commentLeft', + '<%#' + ], + [ + 'left', + '<%' + ], + [ + 'right', + '%>' + ], + [ + 'returnRight', + '%>' + ] + ], + helpers: [{ + name: /\s*\(([\$\w]+)\)\s*->([^\n]*)/, + fn: function (content) { + var quickFunc = /\s*\(([\$\w]+)\)\s*->([^\n]*)/, parts = content.match(quickFunc); + return 'can.proxy(function(__){var ' + parts[1] + '=can.$(__);' + parts[2] + '}, this);'; + } + }], + transform: function (source) { + return source.replace(/<%([\s\S]+?)%>/gm, function (whole, part) { + var brackets = [], foundBracketPair, i; + part.replace(/[{}]/gm, function (bracket, offset) { + brackets.push([ + bracket, + offset + ]); + }); + do { + foundBracketPair = false; + for (i = brackets.length - 2; i >= 0; i--) { + if (brackets[i][0] === '{' && brackets[i + 1][0] === '}') { + brackets.splice(i, 2); + foundBracketPair = true; + break; + } + } + } while (foundBracketPair); + if (brackets.length >= 2) { + var result = ['<%'], bracket, last = 0; + for (i = 0; bracket = brackets[i]; i++) { + result.push(part.substring(last, last = bracket[1])); + if (bracket[0] === '{' && i < brackets.length - 1 || bracket[0] === '}' && i > 0) { + result.push(bracket[0] === '{' ? '{ %><% ' : ' %><% }'); + } else { + result.push(bracket[0]); + } + ++last; + } + result.push(part.substring(last), '%>'); + return result.join(''); + } else { + return '<%' + part + '%>'; + } + }); + } + }) + }); + EJS.Helpers = function (data, extras) { + this._data = data; + this._extras = extras; + extend(this, extras); + }; + EJS.Helpers.prototype = { + list: function (list, cb) { + can.each(list, function (item, i) { + cb(item, i, list); + }); + }, + each: function (list, cb) { + if (can.isArray(list)) { + this.list(list, cb); + } else { + can.view.lists(list, cb); + } + } + }; + can.view.register({ + suffix: 'ejs', + script: function (id, src) { + return 'can.EJS(function(_CONTEXT,_VIEW) { ' + new EJS({ + text: src, + name: id + }).template.out + ' })'; + }, + renderer: function (id, text) { + return EJS({ + text: text, + name: id + }); + } + }); + can.ejs.Helpers = EJS.Helpers; + return can; +}); +/*can@2.2.6#view/ejs/system*/ +'format steal'; +define('can/view/ejs/system', ['can/view/ejs/ejs'], function (can) { + function translate(load) { + return 'define([\'can/view/ejs/ejs\'],function(can){' + 'return can.view.preloadStringRenderer(\'' + load.metadata.pluginArgument + '\',' + 'can.EJS(function(_CONTEXT,_VIEW) { ' + new can.EJS({ + text: load.source, + name: load.name + }).template.out + ' })' + ')' + '})'; + } + return { translate: translate }; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.view.modifiers.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.view.modifiers.js new file mode 100644 index 0000000000..5bb7581c5f --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.view.modifiers.js @@ -0,0 +1,166 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#view/modifiers/modifiers*/ +define('can/view/modifiers/modifiers', [ + 'dist/jquery', + 'can/util/util', + 'can/view/view' +], function ($, can) { + $ = $ || window.$; + var convert, modify, isTemplate, isHTML, isDOM, getCallback, noHookup = { + 'val': true, + 'text': true + }; + convert = function (func_name) { + var old = $.fn[func_name]; + $.fn[func_name] = function () { + var args = can.makeArray(arguments), callbackNum, callback, self = this, result; + if (can.isDeferred(args[0])) { + args[0].done(function (res) { + modify.call(self, [res], old); + }); + return this; + } else if (isTemplate(args)) { + if (callbackNum = getCallback(args)) { + callback = args[callbackNum]; + args[callbackNum] = function (result) { + modify.call(self, [result], old); + callback.call(self, result); + }; + can.view.apply(can.view, args); + return this; + } + result = can.view.apply(can.view, args); + if (!can.isDeferred(result)) { + args = [result]; + } else { + result.done(function (res) { + modify.call(self, [res], old); + }); + return this; + } + } + return noHookup[func_name] ? old.apply(this, args) : modify.call(this, args, old); + }; + }; + modify = function (args, old) { + var res; + for (var hasHookups in can.view.hookups) { + break; + } + if (hasHookups && args[0] && isHTML(args[0])) { + args[0] = can.view.frag(args[0]).childNodes; + } + res = old.apply(this, args); + return res; + }; + isTemplate = function (args) { + var secArgType = typeof args[1]; + return typeof args[0] === 'string' && (secArgType === 'object' || secArgType === 'function') && !isDOM(args[1]); + }; + isDOM = function (arg) { + return arg.nodeType || arg[0] && arg[0].nodeType; + }; + isHTML = function (arg) { + if (isDOM(arg)) { + return true; + } else if (typeof arg === 'string') { + arg = can.trim(arg); + return arg.substr(0, 1) === '<' && arg.substr(arg.length - 1, 1) === '>' && arg.length >= 3; + } else { + return false; + } + }; + getCallback = function (args) { + return typeof args[3] === 'function' ? 3 : typeof args[2] === 'function' && 2; + }; + $.fn.hookup = function () { + can.view.frag(this); + return this; + }; + can.each([ + 'prepend', + 'append', + 'after', + 'before', + 'text', + 'html', + 'replaceWith', + 'val' + ], function (func) { + convert(func); + }); + return can; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.view.mustache.system.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.view.mustache.system.js new file mode 100644 index 0000000000..1f27fa1077 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.view.mustache.system.js @@ -0,0 +1,85 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#view/mustache/system*/ +'format steal'; +define('can/view/mustache/system', ['can/view/mustache/mustache'], function (can) { + function translate(load) { + return 'define([\'can/view/mustache/mustache\'],function(can){' + 'return can.view.preloadStringRenderer(\'' + load.metadata.pluginArgument + '\',' + 'can.Mustache(function(scope,options) { ' + new can.Mustache({ + text: load.source, + name: load.name + }).template.out + ' })' + ')' + '})'; + } + return { translate: translate }; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.view.stache.system.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.view.stache.system.js new file mode 100644 index 0000000000..404a8fe362 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.view.stache.system.js @@ -0,0 +1,777 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#view/target/target*/ +define('can/view/target/target', [ + 'can/util/util', + 'can/view/elements' +], function (can, elements) { + var processNodes = function (nodes, paths, location) { + var frag = document.createDocumentFragment(); + for (var i = 0, len = nodes.length; i < len; i++) { + var node = nodes[i]; + frag.appendChild(processNode(node, paths, location.concat(i))); + } + return frag; + }, keepsTextNodes = typeof document !== 'undefined' && function () { + var testFrag = document.createDocumentFragment(); + var div = document.createElement('div'); + div.appendChild(document.createTextNode('')); + div.appendChild(document.createTextNode('')); + testFrag.appendChild(div); + var cloned = testFrag.cloneNode(true); + return cloned.childNodes[0].childNodes.length === 2; + }(), clonesWork = typeof document !== 'undefined' && function () { + var a = document.createElement('a'); + a.innerHTML = ''; + var clone = a.cloneNode(true); + return clone.innerHTML === ''; + }(), namespacesWork = typeof document !== 'undefined' && !!document.createElementNS; + var cloneNode = clonesWork ? function (el) { + return el.cloneNode(true); + } : function (node) { + var copy; + if (node.nodeType === 1) { + copy = document.createElement(node.nodeName); + } else if (node.nodeType === 3) { + copy = document.createTextNode(node.nodeValue); + } else if (node.nodeType === 8) { + copy = document.createComment(node.nodeValue); + } else if (node.nodeType === 11) { + copy = document.createDocumentFragment(); + } + if (node.attributes) { + var attributes = can.makeArray(node.attributes); + can.each(attributes, function (node) { + if (node && node.specified) { + copy.setAttribute(node.nodeName, node.nodeValue); + } + }); + } + if (node.childNodes) { + can.each(node.childNodes, function (child) { + copy.appendChild(cloneNode(child)); + }); + } + return copy; + }; + function processNode(node, paths, location) { + var callback, loc = location, nodeType = typeof node, el, p, i, len; + var getCallback = function () { + if (!callback) { + callback = { + path: location, + callbacks: [] + }; + paths.push(callback); + loc = []; + } + return callback; + }; + if (nodeType === 'object') { + if (node.tag) { + if (namespacesWork && node.namespace) { + el = document.createElementNS(node.namespace, node.tag); + } else { + el = document.createElement(node.tag); + } + if (node.attrs) { + for (var attrName in node.attrs) { + var value = node.attrs[attrName]; + if (typeof value === 'function') { + getCallback().callbacks.push({ callback: value }); + } else { + el.setAttribute(attrName, value); + } + } + } + if (node.attributes) { + for (i = 0, len = node.attributes.length; i < len; i++) { + getCallback().callbacks.push({ callback: node.attributes[i] }); + } + } + if (node.children && node.children.length) { + if (callback) { + p = callback.paths = []; + } else { + p = paths; + } + el.appendChild(processNodes(node.children, p, loc)); + } + } else if (node.comment) { + el = document.createComment(node.comment); + if (node.callbacks) { + for (i = 0, len = node.attributes.length; i < len; i++) { + getCallback().callbacks.push({ callback: node.callbacks[i] }); + } + } + } + } else if (nodeType === 'string') { + el = document.createTextNode(node); + } else if (nodeType === 'function') { + if (keepsTextNodes) { + el = document.createTextNode(''); + getCallback().callbacks.push({ callback: node }); + } else { + el = document.createComment('~'); + getCallback().callbacks.push({ + callback: function () { + var el = document.createTextNode(''); + elements.replace([this], el); + return node.apply(el, arguments); + } + }); + } + } + return el; + } + function hydratePath(el, pathData, args) { + var path = pathData.path, callbacks = pathData.callbacks, paths = pathData.paths, callbackData, child = el; + for (var i = 0, len = path.length; i < len; i++) { + child = child.childNodes[path[i]]; + } + for (i = 0, len = callbacks.length; i < len; i++) { + callbackData = callbacks[i]; + callbackData.callback.apply(child, args); + } + if (paths && paths.length) { + for (i = paths.length - 1; i >= 0; i--) { + hydratePath(child, paths[i], args); + } + } + } + function makeTarget(nodes) { + var paths = []; + var frag = processNodes(nodes, paths, []); + return { + paths: paths, + clone: frag, + hydrate: function () { + var cloned = cloneNode(this.clone); + var args = can.makeArray(arguments); + for (var i = paths.length - 1; i >= 0; i--) { + hydratePath(cloned, paths[i], args); + } + return cloned; + } + }; + } + makeTarget.keepsTextNodes = keepsTextNodes; + can.view.target = makeTarget; + return makeTarget; +}); +/*can@2.2.6#view/stache/html_section*/ +define('can/view/stache/html_section', [ + 'can/util/util', + 'can/view/target/target', + 'can/view/stache/utils', + 'can/view/stache/mustache_core' +], function (can, target, utils, mustacheCore) { + var decodeHTML = typeof document !== 'undefined' && function () { + var el = document.createElement('div'); + return function (html) { + if (html.indexOf('&') === -1) { + return html.replace(/\r\n/g, '\n'); + } + el.innerHTML = html; + return el.childNodes.length === 0 ? '' : el.childNodes[0].nodeValue; + }; + }(); + var HTMLSectionBuilder = function () { + this.stack = [new HTMLSection()]; + }; + can.extend(HTMLSectionBuilder.prototype, utils.mixins); + can.extend(HTMLSectionBuilder.prototype, { + startSubSection: function (process) { + var newSection = new HTMLSection(process); + this.stack.push(newSection); + return newSection; + }, + endSubSectionAndReturnRenderer: function () { + if (this.last().isEmpty()) { + this.stack.pop(); + return null; + } else { + var htmlSection = this.endSection(); + return can.proxy(htmlSection.compiled.hydrate, htmlSection.compiled); + } + }, + startSection: function (process) { + var newSection = new HTMLSection(process); + this.last().add(newSection.targetCallback); + this.stack.push(newSection); + }, + endSection: function () { + this.last().compile(); + return this.stack.pop(); + }, + inverse: function () { + this.last().inverse(); + }, + compile: function () { + var compiled = this.stack.pop().compile(); + return function (scope, options, nodeList) { + if (!(scope instanceof can.view.Scope)) { + scope = new can.view.Scope(scope || {}); + } + if (!(options instanceof mustacheCore.Options)) { + options = new mustacheCore.Options(options || {}); + } + return compiled.hydrate(scope, options, nodeList); + }; + }, + push: function (chars) { + this.last().push(chars); + }, + pop: function () { + return this.last().pop(); + } + }); + var HTMLSection = function (process) { + this.data = 'targetData'; + this.targetData = []; + this.targetStack = []; + var self = this; + this.targetCallback = function (scope, options, sectionNode) { + process.call(this, scope, options, sectionNode, can.proxy(self.compiled.hydrate, self.compiled), self.inverseCompiled && can.proxy(self.inverseCompiled.hydrate, self.inverseCompiled)); + }; + }; + can.extend(HTMLSection.prototype, { + inverse: function () { + this.inverseData = []; + this.data = 'inverseData'; + }, + push: function (data) { + this.add(data); + this.targetStack.push(data); + }, + pop: function () { + return this.targetStack.pop(); + }, + add: function (data) { + if (typeof data === 'string') { + data = decodeHTML(data); + } + if (this.targetStack.length) { + this.targetStack[this.targetStack.length - 1].children.push(data); + } else { + this[this.data].push(data); + } + }, + compile: function () { + this.compiled = target(this.targetData); + if (this.inverseData) { + this.inverseCompiled = target(this.inverseData); + delete this.inverseData; + } + delete this.targetData; + delete this.targetStack; + return this.compiled; + }, + children: function () { + if (this.targetStack.length) { + return this.targetStack[this.targetStack.length - 1].children; + } else { + return this[this.data]; + } + }, + isEmpty: function () { + return !this.targetData.length; + } + }); + return HTMLSectionBuilder; +}); +/*can@2.2.6#view/stache/text_section*/ +define('can/view/stache/text_section', [ + 'can/util/util', + 'can/view/live/live', + 'can/view/stache/utils' +], function (can, live, utils) { + live = live || can.view.live; + var TextSectionBuilder = function () { + this.stack = [new TextSection()]; + }, emptyHandler = function () { + }; + can.extend(TextSectionBuilder.prototype, utils.mixins); + can.extend(TextSectionBuilder.prototype, { + startSection: function (process) { + var subSection = new TextSection(); + this.last().add({ + process: process, + truthy: subSection + }); + this.stack.push(subSection); + }, + endSection: function () { + this.stack.pop(); + }, + inverse: function () { + this.stack.pop(); + var falseySection = new TextSection(); + this.last().last().falsey = falseySection; + this.stack.push(falseySection); + }, + compile: function (state) { + var renderer = this.stack[0].compile(); + return function (scope, options) { + var compute = can.compute(function () { + return renderer(scope, options); + }, this, false, true); + compute.bind('change', emptyHandler); + var value = compute(); + if (compute.computeInstance.hasDependencies) { + if (state.attr) { + live.simpleAttribute(this, state.attr, compute); + } else { + live.attributes(this, compute); + } + compute.unbind('change', emptyHandler); + } else { + if (state.attr) { + can.attr.set(this, state.attr, value); + } else { + live.setAttributes(this, value); + } + } + }; + } + }); + var passTruthyFalsey = function (process, truthy, falsey) { + return function (scope, options) { + return process.call(this, scope, options, truthy, falsey); + }; + }; + var TextSection = function () { + this.values = []; + }; + can.extend(TextSection.prototype, { + add: function (data) { + this.values.push(data); + }, + last: function () { + return this.values[this.values.length - 1]; + }, + compile: function () { + var values = this.values, len = values.length; + for (var i = 0; i < len; i++) { + var value = this.values[i]; + if (typeof value === 'object') { + values[i] = passTruthyFalsey(value.process, value.truthy && value.truthy.compile(), value.falsey && value.falsey.compile()); + } + } + return function (scope, options) { + var txt = '', value; + for (var i = 0; i < len; i++) { + value = values[i]; + txt += typeof value === 'string' ? value : value.call(this, scope, options); + } + return txt; + }; + } + }); + return TextSectionBuilder; +}); +/*can@2.2.6#view/stache/intermediate_and_imports*/ +define('can/view/stache/intermediate_and_imports', [ + 'can/view/stache/mustache_core', + 'can/view/parser/parser' +], function (mustacheCore, parser) { + return function (source) { + var template = mustacheCore.cleanLineEndings(source); + var imports = [], inImport = false, inFrom = false; + var keepToken = function () { + return inImport ? false : true; + }; + var intermediate = parser(template, { + start: function (tagName, unary) { + if (tagName === 'can-import') { + inImport = true; + } + return keepToken(); + }, + end: function (tagName, unary) { + if (tagName === 'can-import') { + inImport = false; + return false; + } + return keepToken(); + }, + attrStart: function (attrName) { + if (attrName === 'from') { + inFrom = true; + } + return keepToken(); + }, + attrEnd: function (attrName) { + if (attrName === 'from') { + inFrom = false; + } + return keepToken(); + }, + attrValue: function (value) { + if (inFrom && inImport) { + imports.push(value); + } + return keepToken(); + }, + chars: keepToken, + comment: keepToken, + special: keepToken, + done: keepToken + }, true); + return { + intermediate: intermediate, + imports: imports + }; + }; +}); +/*can@2.2.6#view/stache/stache*/ +define('can/view/stache/stache', [ + 'can/util/util', + 'can/view/parser/parser', + 'can/view/target/target', + 'can/view/stache/html_section', + 'can/view/stache/text_section', + 'can/view/stache/mustache_core', + 'can/view/stache/mustache_helpers', + 'can/view/stache/intermediate_and_imports', + 'can/view/callbacks/callbacks', + 'can/view/bindings/bindings' +], function (can, parser, target, HTMLSectionBuilder, TextSectionBuilder, mustacheCore, mustacheHelpers, getIntermediateAndImports, viewCallbacks) { + parser = parser || can.view.parser; + viewCallbacks = viewCallbacks || can.view.callbacks; + var svgNamespace = 'http://www.w3.org/2000/svg'; + var namespaces = { + 'svg': svgNamespace, + 'g': svgNamespace + }; + function stache(template) { + if (typeof template === 'string') { + template = mustacheCore.cleanLineEndings(template); + } + var section = new HTMLSectionBuilder(), state = { + node: null, + attr: null, + sectionElementStack: [], + text: false, + namespaceStack: [] + }, makeRendererAndUpdateSection = function (section, mode, stache) { + if (mode === '>') { + section.add(mustacheCore.makeLiveBindingPartialRenderer(stache, state)); + } else if (mode === '/') { + section.endSection(); + if (section instanceof HTMLSectionBuilder) { + state.sectionElementStack.pop(); + } + } else if (mode === 'else') { + section.inverse(); + } else { + var makeRenderer = section instanceof HTMLSectionBuilder ? mustacheCore.makeLiveBindingBranchRenderer : mustacheCore.makeStringBranchRenderer; + if (mode === '{' || mode === '&') { + section.add(makeRenderer(null, stache, copyState())); + } else if (mode === '#' || mode === '^') { + section.startSection(makeRenderer(mode, stache, copyState())); + if (section instanceof HTMLSectionBuilder) { + state.sectionElementStack.push('section'); + } + } else { + section.add(makeRenderer(null, stache, copyState({ text: true }))); + } + } + }, copyState = function (overwrites) { + var lastElement = state.sectionElementStack[state.sectionElementStack.length - 1]; + var cur = { + tag: state.node && state.node.tag, + attr: state.attr && state.attr.name, + directlyNested: state.sectionElementStack.length ? lastElement === 'section' || lastElement === 'custom' : true + }; + return overwrites ? can.simpleExtend(cur, overwrites) : cur; + }, addAttributesCallback = function (node, callback) { + if (!node.attributes) { + node.attributes = []; + } + node.attributes.push(callback); + }; + parser(template, { + start: function (tagName, unary) { + var matchedNamespace = namespaces[tagName]; + if (matchedNamespace && !unary) { + state.namespaceStack.push(matchedNamespace); + } + state.node = { + tag: tagName, + children: [], + namespace: matchedNamespace || can.last(state.namespaceStack) + }; + }, + end: function (tagName, unary) { + var isCustomTag = viewCallbacks.tag(tagName); + if (unary) { + section.add(state.node); + if (isCustomTag) { + addAttributesCallback(state.node, function (scope, options, parentNodeList) { + viewCallbacks.tagHandler(this, tagName, { + scope: scope, + options: options, + subtemplate: null, + templateType: 'stache', + parentNodeList: parentNodeList + }); + }); + } + } else { + section.push(state.node); + state.sectionElementStack.push(isCustomTag ? 'custom' : 'element'); + if (isCustomTag) { + section.startSubSection(); + } + } + state.node = null; + }, + close: function (tagName) { + var matchedNamespace = namespaces[tagName]; + if (matchedNamespace) { + state.namespaceStack.pop(); + } + var isCustomTag = viewCallbacks.tag(tagName), renderer; + if (isCustomTag) { + renderer = section.endSubSectionAndReturnRenderer(); + } + var oldNode = section.pop(); + if (isCustomTag) { + addAttributesCallback(oldNode, function (scope, options, parentNodeList) { + viewCallbacks.tagHandler(this, tagName, { + scope: scope, + options: options, + subtemplate: renderer, + templateType: 'stache', + parentNodeList: parentNodeList + }); + }); + } + state.sectionElementStack.pop(); + }, + attrStart: function (attrName) { + if (state.node.section) { + state.node.section.add(attrName + '="'); + } else { + state.attr = { + name: attrName, + value: '' + }; + } + }, + attrEnd: function (attrName) { + if (state.node.section) { + state.node.section.add('" '); + } else { + if (!state.node.attrs) { + state.node.attrs = {}; + } + state.node.attrs[state.attr.name] = state.attr.section ? state.attr.section.compile(copyState()) : state.attr.value; + var attrCallback = viewCallbacks.attr(attrName); + if (attrCallback) { + if (!state.node.attributes) { + state.node.attributes = []; + } + state.node.attributes.push(function (scope, options) { + attrCallback(this, { + attributeName: attrName, + scope: scope, + options: options + }); + }); + } + state.attr = null; + } + }, + attrValue: function (value) { + var section = state.node.section || state.attr.section; + if (section) { + section.add(value); + } else { + state.attr.value += value; + } + }, + chars: function (text) { + section.add(text); + }, + special: function (text) { + var firstAndText = mustacheCore.splitModeFromExpression(text, state), mode = firstAndText.mode, expression = firstAndText.expression; + if (expression === 'else') { + (state.attr && state.attr.section ? state.attr.section : section).inverse(); + return; + } + if (mode === '!') { + return; + } + if (state.node && state.node.section) { + makeRendererAndUpdateSection(state.node.section, mode, expression); + if (state.node.section.subSectionDepth() === 0) { + state.node.attributes.push(state.node.section.compile(copyState())); + delete state.node.section; + } + } else if (state.attr) { + if (!state.attr.section) { + state.attr.section = new TextSectionBuilder(); + if (state.attr.value) { + state.attr.section.add(state.attr.value); + } + } + makeRendererAndUpdateSection(state.attr.section, mode, expression); + } else if (state.node) { + if (!state.node.attributes) { + state.node.attributes = []; + } + if (!mode) { + state.node.attributes.push(mustacheCore.makeLiveBindingBranchRenderer(null, expression, copyState())); + } else if (mode === '#' || mode === '^') { + if (!state.node.section) { + state.node.section = new TextSectionBuilder(); + } + makeRendererAndUpdateSection(state.node.section, mode, expression); + } else { + throw mode + ' is currently not supported within a tag.'; + } + } else { + makeRendererAndUpdateSection(section, mode, expression); + } + }, + comment: function (text) { + section.add({ comment: text }); + }, + done: function () { + } + }); + return section.compile(); + } + var escMap = { + '\n': '\\n', + '\r': '\\r', + '\u2028': '\\u2028', + '\u2029': '\\u2029' + }; + var esc = function (string) { + return ('' + string).replace(/["'\\\n\r\u2028\u2029]/g, function (character) { + if ('\'"\\'.indexOf(character) >= 0) { + return '\\' + character; + } else { + return escMap[character]; + } + }); + }; + can.view.register({ + suffix: 'stache', + contentType: 'x-stache-template', + fragRenderer: function (id, text) { + return stache(text); + }, + script: function (id, src) { + return 'can.stache("' + esc(src) + '")'; + } + }); + can.view.ext = '.stache'; + can.extend(can.stache, mustacheHelpers); + can.extend(stache, mustacheHelpers); + can.stache.safeString = stache.safeString = function (text) { + return { + toString: function () { + return text; + } + }; + }; + can.stache.async = function (source) { + var iAi = getIntermediateAndImports(source); + var importPromises = can.map(iAi.imports, function (moduleName) { + return can['import'](moduleName); + }); + return can.when.apply(can, importPromises).then(function () { + return stache(iAi.intermediate); + }); + }; + return stache; +}); +/*can@2.2.6#view/stache/system*/ +'format steal'; +define('can/view/stache/system', [ + 'can/view/stache/stache', + 'can/view/stache/intermediate_and_imports' +], function (stache, getIntermediateAndImports) { + function translate(load) { + var intermediateAndImports = getIntermediateAndImports(load.source); + intermediateAndImports.imports.unshift('can/view/stache/stache'); + return 'define(' + JSON.stringify(intermediateAndImports.imports) + ',function(stache){' + 'return stache(' + JSON.stringify(intermediateAndImports.intermediate) + ')' + '})'; + } + return { translate: translate }; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.yui.dev.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.yui.dev.js new file mode 100644 index 0000000000..9968b17554 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.yui.dev.js @@ -0,0 +1,7336 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#util/can*/ +define('can/util/can', [], function () { + var glbl = typeof window !== 'undefined' ? window : global; + var can = {}; + if (typeof GLOBALCAN === 'undefined' || GLOBALCAN !== false) { + glbl.can = can; + } + can.global = glbl; + can.k = function () { + }; + can.isDeferred = can.isPromise = function (obj) { + return obj && typeof obj.then === 'function' && typeof obj.pipe === 'function'; + }; + can.isMapLike = function (obj) { + return can.Map && (obj instanceof can.Map || obj && obj.__get); + }; + var cid = 0; + can.cid = function (object, name) { + if (!object._cid) { + cid++; + object._cid = (name || '') + cid; + } + return object._cid; + }; + can.VERSION = '2.2.6'; + can.simpleExtend = function (d, s) { + for (var prop in s) { + d[prop] = s[prop]; + } + return d; + }; + can.last = function (arr) { + return arr && arr[arr.length - 1]; + }; + var protoBind = Function.prototype.bind; + if (protoBind) { + can.proxy = function (fn, context) { + return protoBind.call(fn, context); + }; + } else { + can.proxy = function (fn, context) { + return function () { + return fn.apply(context, arguments); + }; + }; + } + can.frag = function (item) { + var frag; + if (!item || typeof item === 'string') { + frag = can.buildFragment(item == null ? '' : '' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } else if (item.nodeType === 11) { + return item; + } else if (typeof item.nodeType === 'number') { + frag = document.createDocumentFragment(); + frag.appendChild(item); + return frag; + } else if (typeof item.length === 'number') { + frag = document.createDocumentFragment(); + can.each(item, function (item) { + frag.appendChild(can.frag(item)); + }); + return frag; + } else { + frag = can.buildFragment('' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } + }; + can.scope = can.viewModel = function (el, attr, val) { + el = can.$(el); + var scope = can.data(el, 'scope') || can.data(el, 'viewModel'); + if (!scope) { + scope = new can.Map(); + can.data(el, 'scope', scope); + can.data(el, 'viewModel', scope); + } + switch (arguments.length) { + case 0: + case 1: + return scope; + case 2: + return scope.attr(attr); + default: + scope.attr(attr, val); + return el; + } + }; + can['import'] = function (moduleName) { + var deferred = new can.Deferred(); + if (typeof window.System === 'object' && can.isFunction(window.System['import'])) { + window.System['import'](moduleName).then(can.proxy(deferred.resolve, deferred), can.proxy(deferred.reject, deferred)); + } else if (window.define && window.define.amd) { + window.require([moduleName], function (value) { + deferred.resolve(value); + }); + } else if (window.steal) { + steal.steal(moduleName, function (value) { + deferred.resolve(value); + }); + } else if (window.require) { + deferred.resolve(window.require(moduleName)); + } else { + deferred.resolve(); + } + return deferred.promise(); + }; + can.__observe = function () { + }; + can.dev = { + warnTimeout: 5000, + logLevel: 0, + warn: function (out) { + var ll = this.logLevel; + if (ll < 2) { + Array.prototype.unshift.call(arguments, 'WARN:'); + if (typeof window !== undefined && window.console && console.warn) { + this._logger('warn', Array.prototype.slice.call(arguments)); + } else if (window.console && console.log) { + this._logger('log', Array.prototype.slice.call(arguments)); + } else if (window.opera && window.opera.postError) { + window.opera.postError('steal.js WARNING: ' + out); + } + } + }, + log: function (out) { + var ll = this.logLevel; + if (ll < 1) { + if (window.console && console.log) { + Array.prototype.unshift.call(arguments, 'Info:'); + this._logger('log', Array.prototype.slice.call(arguments)); + } else if (window.opera && window.opera.postError) { + window.opera.postError('steal.js INFO: ' + out); + } + } + }, + _logger: function (type, arr) { + if (console.log.apply) { + console[type].apply(console, arr); + } else { + console[type](arr); + } + } + }; + return can; +}); +/*can@2.2.6#util/attr/attr*/ +define('can/util/attr/attr', ['can/util/can'], function (can) { + var setImmediate = can.global.setImmediate || function (cb) { + return setTimeout(cb, 0); + }, attr = { + MutationObserver: can.global.MutationObserver || can.global.WebKitMutationObserver || can.global.MozMutationObserver, + map: { + 'class': 'className', + 'value': 'value', + 'innertext': 'innerText', + 'textcontent': 'textContent', + 'checked': true, + 'disabled': true, + 'readonly': true, + 'required': true, + src: function (el, val) { + if (val == null || val === '') { + el.removeAttribute('src'); + return null; + } else { + el.setAttribute('src', val); + return val; + } + }, + style: function (el, val) { + return el.style.cssText = val || ''; + } + }, + defaultValue: [ + 'input', + 'textarea' + ], + set: function (el, attrName, val) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var tagName = el.nodeName.toString().toLowerCase(), prop = attr.map[attrName], newValue; + if (typeof prop === 'function') { + newValue = prop(el, val); + } else if (prop === true) { + newValue = el[attrName] = true; + if (attrName === 'checked' && el.type === 'radio') { + if (can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultChecked = true; + } + } + } else if (prop) { + newValue = val; + if (el[prop] !== val) { + el[prop] = val; + } + if (prop === 'value' && can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultValue = val; + } + } else { + el.setAttribute(attrName, val); + newValue = val; + } + if (!attr.MutationObserver && newValue !== oldValue) { + attr.trigger(el, attrName, oldValue); + } + }, + trigger: function (el, attrName, oldValue) { + if (can.data(can.$(el), 'canHasAttributesBindings')) { + attrName = attrName.toLowerCase(); + return setImmediate(function () { + can.trigger(el, { + type: 'attributes', + attributeName: attrName, + target: el, + oldValue: oldValue, + bubbles: false + }, []); + }); + } + }, + get: function (el, attrName) { + attrName = attrName.toLowerCase(); + var prop = attr.map[attrName]; + if (typeof prop === 'string' && el[prop]) { + return el[prop]; + } + return el.getAttribute(attrName); + }, + remove: function (el, attrName) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var setter = attr.map[attrName]; + if (typeof setter === 'function') { + setter(el, undefined); + } + if (setter === true) { + el[attrName] = false; + } else if (typeof setter === 'string') { + el[setter] = ''; + } else { + el.removeAttribute(attrName); + } + if (!attr.MutationObserver && oldValue != null) { + attr.trigger(el, attrName, oldValue); + } + }, + has: function () { + var el = can.global.document && document.createElement('div'); + if (el && el.hasAttribute) { + return function (el, name) { + return el.hasAttribute(name); + }; + } else { + return function (el, name) { + return el.getAttribute(name) !== null; + }; + } + }() + }; + return attr; +}); +/*can@2.2.6#event/event*/ +define('can/event/event', ['can/util/can'], function (can) { + can.addEvent = function (event, handler) { + var allEvents = this.__bindEvents || (this.__bindEvents = {}), eventList = allEvents[event] || (allEvents[event] = []); + eventList.push({ + handler: handler, + name: event + }); + return this; + }; + can.listenTo = function (other, event, handler) { + var idedEvents = this.__listenToEvents; + if (!idedEvents) { + idedEvents = this.__listenToEvents = {}; + } + var otherId = can.cid(other); + var othersEvents = idedEvents[otherId]; + if (!othersEvents) { + othersEvents = idedEvents[otherId] = { + obj: other, + events: {} + }; + } + var eventsEvents = othersEvents.events[event]; + if (!eventsEvents) { + eventsEvents = othersEvents.events[event] = []; + } + eventsEvents.push(handler); + can.bind.call(other, event, handler); + }; + can.stopListening = function (other, event, handler) { + var idedEvents = this.__listenToEvents, iterIdedEvents = idedEvents, i = 0; + if (!idedEvents) { + return this; + } + if (other) { + var othercid = can.cid(other); + (iterIdedEvents = {})[othercid] = idedEvents[othercid]; + if (!idedEvents[othercid]) { + return this; + } + } + for (var cid in iterIdedEvents) { + var othersEvents = iterIdedEvents[cid], eventsEvents; + other = idedEvents[cid].obj; + if (!event) { + eventsEvents = othersEvents.events; + } else { + (eventsEvents = {})[event] = othersEvents.events[event]; + } + for (var eventName in eventsEvents) { + var handlers = eventsEvents[eventName] || []; + i = 0; + while (i < handlers.length) { + if (handler && handler === handlers[i] || !handler) { + can.unbind.call(other, eventName, handlers[i]); + handlers.splice(i, 1); + } else { + i++; + } + } + if (!handlers.length) { + delete othersEvents.events[eventName]; + } + } + if (can.isEmptyObject(othersEvents.events)) { + delete idedEvents[cid]; + } + } + return this; + }; + can.removeEvent = function (event, fn, __validate) { + if (!this.__bindEvents) { + return this; + } + var events = this.__bindEvents[event] || [], i = 0, ev, isFunction = typeof fn === 'function'; + while (i < events.length) { + ev = events[i]; + if (__validate ? __validate(ev, event, fn) : isFunction && ev.handler === fn || !isFunction && (ev.cid === fn || !fn)) { + events.splice(i, 1); + } else { + i++; + } + } + return this; + }; + can.dispatch = function (event, args) { + var events = this.__bindEvents; + if (!events) { + return; + } + if (typeof event === 'string') { + event = { type: event }; + } + var eventName = event.type, handlers = (events[eventName] || []).slice(0), passed = [event]; + if (args) { + passed.push.apply(passed, args); + } + for (var i = 0, len = handlers.length; i < len; i++) { + handlers[i].handler.apply(this, passed); + } + return event; + }; + can.one = function (event, handler) { + var one = function () { + can.unbind.call(this, event, one); + return handler.apply(this, arguments); + }; + can.bind.call(this, event, one); + return this; + }; + can.event = { + on: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.on.call(this); + } else { + return can.addEvent.apply(this, arguments); + } + }, + off: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.off.call(this); + } else { + return can.removeEvent.apply(this, arguments); + } + }, + bind: can.addEvent, + unbind: can.removeEvent, + delegate: function (selector, event, handler) { + return can.addEvent.call(this, event, handler); + }, + undelegate: function (selector, event, handler) { + return can.removeEvent.call(this, event, handler); + }, + trigger: can.dispatch, + one: can.one, + addEvent: can.addEvent, + removeEvent: can.removeEvent, + listenTo: can.listenTo, + stopListening: can.stopListening, + dispatch: can.dispatch + }; + return can.event; +}); +/*can@2.2.6#util/fragment*/ +define('can/util/fragment', ['can/util/can'], function (can) { + var fragmentRE = /^\s*<(\w+)[^>]*>/, toString = {}.toString, fragment = function (html, name) { + if (name === undefined) { + name = fragmentRE.test(html) && RegExp.$1; + } + if (html && toString.call(html.replace) === '[object Function]') { + html = html.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, '<$1>'); + } + var container = document.createElement('div'), temp = document.createElement('div'); + if (name === 'tbody' || name === 'tfoot' || name === 'thead') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; + } else if (name === 'tr') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild; + } else if (name === 'td' || name === 'th') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild.firstChild; + } else if (name === 'option') { + temp.innerHTML = ''; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; + } else { + container.innerHTML = '' + html; + } + var tmp = {}, children = container.childNodes; + tmp.length = children.length; + for (var i = 0; i < children.length; i++) { + tmp[i] = children[i]; + } + return [].slice.call(tmp); + }; + can.buildFragment = function (html, nodes) { + if (html && html.nodeType === 11) { + return html; + } + var parts = fragment(html), frag = document.createDocumentFragment(); + for (var i = 0, length = parts.length; i < length; i++) { + frag.appendChild(parts[i]); + } + return frag; + }; + (function () { + var text = '<-\n>', frag = can.buildFragment(text, document); + if (text !== frag.childNodes[0].nodeValue) { + var oldBuildFragment = can.buildFragment; + can.buildFragment = function (html, nodes) { + var res = oldBuildFragment(html, nodes); + if (res.childNodes.length === 1 && res.childNodes[0].nodeType === 3) { + res.childNodes[0].nodeValue = html; + } + return res; + }; + } + }()); + return can; +}); +/*can@2.2.6#util/array/each*/ +define('can/util/array/each', ['can/util/can'], function (can) { + var isArrayLike = function (obj) { + var length = 'length' in obj && obj.length; + return typeof arr !== 'function' && (length === 0 || typeof length === 'number' && length > 0 && length - 1 in obj); + }; + can.each = function (elements, callback, context) { + var i = 0, key, len, item; + if (elements) { + if (isArrayLike(elements)) { + if (can.List && elements instanceof can.List) { + for (len = elements.attr('length'); i < len; i++) { + item = elements.attr(i); + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } else { + for (len = elements.length; i < len; i++) { + item = elements[i]; + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } + } else if (typeof elements === 'object') { + if (can.Map && elements instanceof can.Map || elements === can.route) { + var keys = can.Map.keys(elements); + for (i = 0, len = keys.length; i < len; i++) { + key = keys[i]; + item = elements.attr(key); + if (callback.call(context || item, item, key, elements) === false) { + break; + } + } + } else { + for (key in elements) { + if (elements.hasOwnProperty(key) && callback.call(context || elements[key], elements[key], key, elements) === false) { + break; + } + } + } + } + } + return elements; + }; + return can; +}); +/*can@2.2.6#util/object/isplain/isplain*/ +define('can/util/object/isplain/isplain', ['can/util/can'], function () { + var core_hasOwn = Object.prototype.hasOwnProperty, isWindow = function (obj) { + return obj !== null && obj == obj.window; + }, isPlainObject = function (obj) { + if (!obj || typeof obj !== 'object' || obj.nodeType || isWindow(obj)) { + return false; + } + try { + if (obj.constructor && !core_hasOwn.call(obj, 'constructor') && !core_hasOwn.call(obj.constructor.prototype, 'isPrototypeOf')) { + return false; + } + } catch (e) { + return false; + } + var key; + for (key in obj) { + } + return key === undefined || core_hasOwn.call(obj, key); + }; + can.isPlainObject = isPlainObject; + return can; +}); +/*can@2.2.6#util/deferred*/ +define('can/util/deferred', ['can/util/can'], function (can) { + var extend = function (target, src) { + for (var key in src) { + if (src.hasOwnProperty(key)) { + target[key] = src[key]; + } + } + }, Deferred = function (func) { + if (!(this instanceof Deferred)) { + return new Deferred(); + } + this._doneFuncs = []; + this._failFuncs = []; + this._resultArgs = null; + this._status = ''; + if (func) { + func.call(this, this); + } + }; + can.Deferred = Deferred; + can.when = Deferred.when = function () { + var args = can.makeArray(arguments); + if (args.length < 2) { + var obj = args[0]; + if (obj && (can.isFunction(obj.isResolved) && can.isFunction(obj.isRejected))) { + return obj; + } else { + return Deferred().resolve(obj); + } + } else { + var df = Deferred(), done = 0, rp = []; + can.each(args, function (arg, j) { + arg.done(function () { + rp[j] = arguments.length < 2 ? arguments[0] : arguments; + if (++done === args.length) { + df.resolve.apply(df, rp); + } + }).fail(function () { + df.reject(arguments.length === 1 ? arguments[0] : arguments); + }); + }); + return df; + } + }; + var resolveFunc = function (type, _status) { + return function (context) { + var args = this._resultArgs = arguments.length > 1 ? arguments[1] : []; + return this.exec(context, this[type], args, _status); + }; + }, doneFunc = function doneFunc(type, _status) { + return function () { + var self = this; + can.each(Array.prototype.slice.call(arguments), function (v, i, args) { + if (!v) { + return; + } + if (v.constructor === Array) { + doneFunc.apply(self, v); + } else { + if (self._status === _status) { + v.apply(self, self._resultArgs || []); + } + self[type].push(v); + } + }); + return this; + }; + }; + var isDeferred = function (obj) { + return obj && obj.then && obj.fail && obj.done; + }; + var wire = function (parentDeferred, result, setter, value) { + if (isDeferred(result)) { + result.done(can.proxy(parentDeferred.resolve, parentDeferred)).fail(can.proxy(parentDeferred.reject, parentDeferred)); + } else { + setter.call(parentDeferred, result !== undefined ? result : value); + } + }; + extend(Deferred.prototype, { + then: function (done, fail) { + var d = can.Deferred(), resolve = d.resolve, reject = d.reject; + this.done(function (value) { + if (typeof done === 'function') { + wire(d, done.apply(this, arguments), resolve, value); + } else { + resolve.apply(d, arguments); + } + }); + this.fail(function (value) { + if (typeof fail === 'function') { + wire(d, fail.apply(this, arguments), reject, value); + } else { + reject.apply(d, arguments); + } + }); + return d; + }, + resolveWith: resolveFunc('_doneFuncs', 'rs'), + rejectWith: resolveFunc('_failFuncs', 'rj'), + done: doneFunc('_doneFuncs', 'rs'), + fail: doneFunc('_failFuncs', 'rj'), + always: function () { + var args = can.makeArray(arguments); + if (args.length && args[0]) { + this.done(args[0]).fail(args[0]); + } + return this; + }, + state: function () { + switch (this._status) { + case 'rs': + return 'resolved'; + case 'rj': + return 'rejected'; + default: + return 'pending'; + } + }, + isResolved: function () { + return this._status === 'rs'; + }, + isRejected: function () { + return this._status === 'rj'; + }, + reject: function () { + return this.rejectWith(this, arguments); + }, + resolve: function () { + return this.resolveWith(this, arguments); + }, + exec: function (context, dst, args, st) { + if (this._status !== '') { + return this; + } + this._status = st; + can.each(dst, function (d) { + if (typeof d.apply === 'function') { + d.apply(context, args); + } + }); + return this; + }, + promise: function () { + var promise = this.then(); + promise.reject = promise.resolve = undefined; + return promise; + } + }); + Deferred.prototype.pipe = Deferred.prototype.then; + return can; +}); +/*can@2.2.6#util/hashchange*/ +define('can/util/hashchange', ['can/util/can'], function (can) { + (function () { + var addEvent = function (el, ev, fn) { + if (el.addEventListener) { + el.addEventListener(ev, fn, false); + } else if (el.attachEvent) { + el.attachEvent('on' + ev, fn); + } else { + el['on' + ev] = fn; + } + }, onHashchange = function () { + can.trigger(window, 'hashchange'); + }; + addEvent(window, 'hashchange', onHashchange); + }()); +}); +/*can@2.2.6#util/inserted/inserted*/ +define('can/util/inserted/inserted', ['can/util/can'], function (can) { + can.inserted = function (elems) { + elems = can.makeArray(elems); + var inDocument = false, doc = can.$(document.contains ? document : document.body), children; + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + if (!inDocument) { + if (elem.getElementsByTagName) { + if (can.has(doc, elem).length) { + inDocument = true; + } else { + return; + } + } else { + continue; + } + } + if (inDocument && elem.getElementsByTagName) { + children = can.makeArray(elem.getElementsByTagName('*')); + can.trigger(elem, 'inserted', [], false); + for (var j = 0, child; (child = children[j]) !== undefined; j++) { + can.trigger(child, 'inserted', [], false); + } + } + } + }; + can.appendChild = function (el, child) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.appendChild(child); + can.inserted(children); + }; + can.insertBefore = function (el, child, ref) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.insertBefore(child, ref); + can.inserted(children); + }; +}); +/*can@2.2.6#util/util*/ +define('can/util/util', [ + 'can/util/can', + 'can/util/attr/attr', + 'can/yui/yui', + 'can/event/event', + 'can/util/fragment', + 'can/util/array/each', + 'can/util/object/isplain/isplain', + 'can/util/deferred', + 'can/util/hashchange', + 'can/util/inserted/inserted' +], function (can, attr, YUI) { + YUI = YUI || window.YUI; + YUI.add('can-modifications', function (Y, NAME) { + var addHTML = Y.DOM.addHTML; + Y.DOM.addHTML = function (node, content, where) { + if (typeof content === 'string' || typeof content === 'number') { + content = can.buildFragment(content); + } + var elems; + if (content.nodeType === 11) { + elems = can.makeArray(content.childNodes); + } else { + elems = [content]; + } + var ret = addHTML.call(this, node, content, where); + can.inserted(elems); + return ret; + }; + var oldOn = Y.Node.prototype.on; + Y.Node.prototype.on = function (type, fn) { + if (type === 'attributes') { + var el = can.$(this); + can.data(el, 'canHasAttributesBindings', (can.data(el, 'canHasAttributesBindings') || 0) + 1); + var handle = oldOn.apply(this, arguments), oldDetach = handle.detach; + handle.detach = function () { + var cur = can.data(el, 'canHasAttributesBindings') || 0; + if (cur <= 0) { + can.cleanData(el, 'canHasAttributesBindings'); + } else { + can.data(el, 'canHasAttributesBindings', cur - 1); + } + return oldDetach.apply(this, arguments); + }; + return handle; + } else { + return oldOn.apply(this, arguments); + } + }; + }, '3.7.3', { 'requires': ['node-base'] }); + var Y = can.Y = can.Y || YUI().use('*'); + can.trim = function (s) { + return Y.Lang.trim(s); + }; + can.makeArray = function (arr) { + if (!arr) { + return []; + } + return Y.Array(arr); + }; + can.isArray = Y.Lang.isArray; + can.inArray = function (item, arr, fromIndex) { + if (!arr) { + return -1; + } + return Y.Array.indexOf(arr, item, fromIndex); + }; + can.map = function (arr, fn) { + return Y.Array.map(can.makeArray(arr || []), fn); + }; + can.extend = function (first) { + var deep = first === true ? 1 : 0, target = arguments[deep], i = deep + 1, arg; + for (; arg = arguments[i]; i++) { + Y.mix(target, arg, true, null, null, !!deep); + } + return target; + }; + can.param = function (object) { + return Y.QueryString.stringify(object, { arrayKey: true }); + }; + can.isEmptyObject = function (object) { + return Y.Object.isEmpty(object); + }; + can.proxy = function (func, context) { + return Y.bind.apply(Y, arguments); + }; + can.isFunction = function (f) { + return Y.Lang.isFunction(f); + }; + var prepareNodeList = function (nodelist) { + nodelist.each(function (node, i) { + nodelist[i] = node.getDOMNode(); + }); + nodelist.length = nodelist.size(); + return nodelist; + }; + can.$ = function (selector) { + if (selector === window) { + return window; + } else if (selector instanceof Y.NodeList) { + return prepareNodeList(selector); + } else if (typeof selector === 'object' && !can.isArray(selector) && typeof selector.nodeType === 'undefined' && !selector.getDOMNode) { + return new Y.NodeList(selector); + } else { + return prepareNodeList(Y.all(selector)); + } + }; + can.get = function (wrapped, index) { + return wrapped._nodes[index]; + }; + can.append = function (wrapped, html) { + wrapped.each(function (node) { + if (typeof html === 'string') { + html = can.buildFragment(html, node); + } + node.append(html); + }); + }; + can.addClass = function (wrapped, className) { + return wrapped.addClass(className); + }; + can.data = function (wrapped, key, value) { + if (!wrapped.item(0)) { + return; + } + if (value === undefined) { + return wrapped.item(0).getData(key); + } else { + return wrapped.item(0).setData(key, value); + } + }; + can.remove = function (wrapped) { + return wrapped.remove() && wrapped.destroy(); + }; + can.has = function (wrapped, node) { + if (Y.DOM.contains(wrapped[0], node)) { + return wrapped; + } else { + return []; + } + }; + can._yNodeRemove = can._yNodeRemove || Y.Node.prototype.remove; + Y.Node.prototype.remove = function () { + var node = this.getDOMNode(); + if (node.nodeType === 1) { + can.trigger(this, 'removed', [], false); + var elems = node.getElementsByTagName('*'); + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + can.trigger(elem, 'removed', [], false); + } + } + can._yNodeRemove.apply(this, arguments); + }; + Y.NodeList.addMethod('remove', Y.Node.prototype.remove); + var optionsMap = { + type: 'method', + success: undefined, + error: undefined + }; + var updateDeferred = function (request, d) { + if (request && request.io) { + var xhr = request.io; + for (var prop in xhr) { + if (typeof d[prop] === 'function') { + d[prop] = function () { + xhr[prop].apply(xhr, arguments); + }; + } else { + d[prop] = prop[xhr]; + } + } + } + }; + can.ajax = function (options) { + var d = can.Deferred(), requestOptions = can.extend({}, options); + for (var option in optionsMap) { + if (requestOptions[option] !== undefined) { + requestOptions[optionsMap[option]] = requestOptions[option]; + delete requestOptions[option]; + } + } + requestOptions.sync = !options.async; + var success = options.success, error = options.error; + requestOptions.on = { + success: function (transactionid, response) { + var data = response.responseText; + if (options.dataType === 'json') { + data = eval('(' + data + ')'); + } + updateDeferred(request, d); + d.resolve(data); + if (success) { + success(data, 'success', request); + } + }, + failure: function (transactionid, response) { + updateDeferred(request, d); + d.reject(request, 'error'); + if (error) { + error(request, 'error'); + } + } + }; + var request = Y.io(requestOptions.url, requestOptions); + updateDeferred(request, d); + return d; + }; + var yuiEventId = 0, addBinding = function (nodelist, selector, ev, cb) { + if (nodelist instanceof Y.NodeList || !nodelist.on || nodelist.getDOMNode) { + nodelist.each(function (node) { + node = can.$(node); + var events = can.data(node, 'events'), eventName = ev + ':' + selector; + if (!events) { + can.data(node, 'events', events = {}); + } + if (!events[eventName]) { + events[eventName] = {}; + } + if (cb.__bindingsIds === undefined) { + cb.__bindingsIds = yuiEventId++; + } + events[eventName][cb.__bindingsIds] = selector ? node.item(0).delegate(ev, cb, selector) : node.item(0).on(ev, cb); + }); + } else { + var obj = nodelist, events = obj.__canEvents = obj.__canEvents || {}; + if (!events[ev]) { + events[ev] = {}; + } + if (cb.__bindingsIds === undefined) { + cb.__bindingsIds = yuiEventId++; + } + events[ev][cb.__bindingsIds] = obj.on(ev, cb); + } + }, removeBinding = function (nodelist, selector, ev, cb) { + if (nodelist instanceof Y.NodeList || !nodelist.on || nodelist.getDOMNode) { + nodelist.each(function (node) { + node = can.$(node); + var events = can.data(node, 'events'); + if (events) { + var eventName = ev + ':' + selector, handlers = events[eventName], handler = handlers[cb.__bindingsIds]; + handler.detach(); + delete handlers[cb.__bindingsIds]; + if (can.isEmptyObject(handlers)) { + delete events[ev]; + } + if (can.isEmptyObject(events)) { + } + } + }); + } else { + var obj = nodelist, events = obj.__canEvents || {}, handlers = events[ev], handler = handlers[cb.__bindingsIds]; + handler.detach(); + delete handlers[cb.__bindingsIds]; + if (can.isEmptyObject(handlers)) { + delete events[ev]; + } + if (can.isEmptyObject(events)) { + } + } + }; + can.bind = function (ev, cb) { + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (this.on || this.nodeType) { + addBinding(can.$(this), undefined, ev, cb); + } else if (this.addEvent) { + this.addEvent(ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + return this; + }; + can.unbind = function (ev, cb) { + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (this.on || this.nodeType) { + removeBinding(can.$(this), undefined, ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + return this; + }; + can.on = can.bind; + can.off = can.unbind; + can.trigger = function (item, event, args, bubble) { + if (item instanceof Y.NodeList) { + item = item.item(0); + } + if (item.getDOMNode) { + item = item.getDOMNode(); + } + if (item.nodeName) { + item = Y.Node(item); + if (bubble === false) { + item.once(event, function (ev) { + if (ev.stopPropagation) { + ev.stopPropagation(); + } + ev.cancelBubble = true; + if (ev._stopper) { + ev._stopper(); + } + }); + } + if (typeof event !== 'string') { + args = event; + event = args.type; + delete args.type; + } + realTrigger(item.getDOMNode(), event, args || {}); + } else { + if (typeof event === 'string') { + event = { type: event }; + } + event.target = event.target || item; + can.dispatch.call(item, event, can.makeArray(args)); + } + }; + Y.mix(Y.Node.DOM_EVENTS, { + removed: true, + inserted: true, + attributes: true, + foo: true + }); + Y.Env.evt.plugins.attributes = { + on: function () { + var args = can.makeArray(arguments); + return Y.Event._attach(args, { facade: false }); + } + }; + can.delegate = function (selector, ev, cb) { + if (this.on || this.nodeType) { + addBinding(can.$(this), selector, ev, cb); + } else if (this.delegate) { + this.delegate(selector, ev, cb); + } else { + can.bind.call(this, ev, cb); + } + return this; + }; + can.undelegate = function (selector, ev, cb) { + if (this.on || this.nodeType) { + removeBinding(can.$(this), selector, ev, cb); + } else if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else { + can.unbind.call(this, ev, cb); + } + return this; + }; + var realTrigger, realTriggerHandler = function (n, e, evdata) { + var node = Y.Node(n), handlers = can.Y.Event.getListeners(node._yuid, e), i; + if (handlers) { + for (i = 0; i < handlers.length; i++) { + if (handlers[i].fire) { + handlers[i].fire(evdata); + } else if (handlers[i].handles) { + can.each(handlers[i].handles, function (handle) { + handle.evt.fire(evdata); + }); + } else { + throw 'can not fire event'; + } + } + } + }, fakeTrigger = function (n, e, a) { + var stop = false; + var evdata = can.extend({ + type: e, + target: n, + faux: true, + _stopper: function () { + stop = this.cancelBubble; + }, + stopPropagation: function () { + stop = this.cancelBubble; + }, + preventDefault: function () { + } + }, a); + realTriggerHandler(n, e, evdata); + if (e === 'inserted' || e === 'removed') { + return; + } + while (!stop && n !== document && n.parentNode) { + n = n.parentNode; + realTriggerHandler(n, e, evdata); + } + }; + if (document.createEvent) { + realTrigger = function (n, e, a) { + fakeTrigger(n, e, a); + return; + }; + } else { + realTrigger = function (n, e, a) { + fakeTrigger(n, e, a); + return; + }; + } + can.attr = attr; + delete attr.MutationObserver; + return can; +}); +/*can@2.2.6#view/view*/ +define('can/view/view', ['can/util/util'], function (can) { + var isFunction = can.isFunction, makeArray = can.makeArray, hookupId = 1; + var makeRenderer = function (textRenderer) { + var renderer = function () { + return $view.frag(textRenderer.apply(this, arguments)); + }; + renderer.render = function () { + return textRenderer.apply(textRenderer, arguments); + }; + return renderer; + }; + var checkText = function (text, url) { + if (!text.length) { + can.dev.log('can/view/view.js: There is no template or an empty template at ' + url); + throw 'can.view: No template or empty template:' + url; + } + }; + var getRenderer = function (obj, async) { + if (isFunction(obj)) { + var def = can.Deferred(); + return def.resolve(obj); + } + var url = typeof obj === 'string' ? obj : obj.url, suffix = obj.engine && '.' + obj.engine || url.match(/\.[\w\d]+$/), type, el, id; + if (url.match(/^#/)) { + url = url.substr(1); + } + if (el = document.getElementById(url)) { + suffix = '.' + el.type.match(/\/(x\-)?(.+)/)[2]; + } + if (!suffix && !$view.cached[url]) { + url += suffix = $view.ext; + } + if (can.isArray(suffix)) { + suffix = suffix[0]; + } + id = $view.toId(url); + if (url.match(/^\/\//)) { + url = url.substr(2); + url = !window.steal ? url : steal.config().root.mapJoin('' + steal.id(url)); + } + if (window.require) { + if (require.toUrl) { + url = require.toUrl(url); + } + } + type = $view.types[suffix]; + if ($view.cached[id]) { + return $view.cached[id]; + } else if (el) { + return $view.registerView(id, el.innerHTML, type); + } else { + var d = new can.Deferred(); + can.ajax({ + async: async, + url: url, + dataType: 'text', + error: function (jqXHR) { + checkText('', url); + d.reject(jqXHR); + }, + success: function (text) { + checkText(text, url); + $view.registerView(id, text, type, d); + } + }); + return d; + } + }; + var getDeferreds = function (data) { + var deferreds = []; + if (can.isDeferred(data)) { + return [data]; + } else { + for (var prop in data) { + if (can.isDeferred(data[prop])) { + deferreds.push(data[prop]); + } + } + } + return deferreds; + }; + var usefulPart = function (resolved) { + return can.isArray(resolved) && resolved[1] === 'success' ? resolved[0] : resolved; + }; + var $view = can.view = can.template = function (view, data, helpers, callback) { + if (isFunction(helpers)) { + callback = helpers; + helpers = undefined; + } + return $view.renderAs('fragment', view, data, helpers, callback); + }; + can.extend($view, { + frag: function (result, parentNode) { + return $view.hookup($view.fragment(result), parentNode); + }, + fragment: function (result) { + if (typeof result !== 'string' && result.nodeType === 11) { + return result; + } + var frag = can.buildFragment(result, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + }, + toId: function (src) { + return can.map(src.toString().split(/\/|\./g), function (part) { + if (part) { + return part; + } + }).join('_'); + }, + toStr: function (txt) { + return txt == null ? '' : '' + txt; + }, + hookup: function (fragment, parentNode) { + var hookupEls = [], id, func; + can.each(fragment.childNodes ? can.makeArray(fragment.childNodes) : fragment, function (node) { + if (node.nodeType === 1) { + hookupEls.push(node); + hookupEls.push.apply(hookupEls, can.makeArray(node.getElementsByTagName('*'))); + } + }); + can.each(hookupEls, function (el) { + if (el.getAttribute && (id = el.getAttribute('data-view-id')) && (func = $view.hookups[id])) { + func(el, parentNode, id); + delete $view.hookups[id]; + el.removeAttribute('data-view-id'); + } + }); + return fragment; + }, + hookups: {}, + hook: function (cb) { + $view.hookups[++hookupId] = cb; + return ' data-view-id=\'' + hookupId + '\''; + }, + cached: {}, + cachedRenderers: {}, + cache: true, + register: function (info) { + this.types['.' + info.suffix] = info; + if (typeof window !== 'undefined' && window.steal && steal.type) { + steal.type(info.suffix + ' view js', function (options, success, error) { + var type = $view.types['.' + options.type], id = $view.toId(options.id + ''); + options.text = type.script(id, options.text); + success(); + }); + } + can[info.suffix] = $view[info.suffix] = function (id, text) { + var renderer, renderFunc; + if (!text) { + renderFunc = function () { + if (!renderer) { + if (info.fragRenderer) { + renderer = info.fragRenderer(null, id); + } else { + renderer = makeRenderer(info.renderer(null, id)); + } + } + return renderer.apply(this, arguments); + }; + renderFunc.render = function () { + var textRenderer = info.renderer(null, id); + return textRenderer.apply(textRenderer, arguments); + }; + return renderFunc; + } + var registeredRenderer = function () { + if (!renderer) { + if (info.fragRenderer) { + renderer = info.fragRenderer(id, text); + } else { + renderer = info.renderer(id, text); + } + } + return renderer.apply(this, arguments); + }; + if (info.fragRenderer) { + return $view.preload(id, registeredRenderer); + } else { + return $view.preloadStringRenderer(id, registeredRenderer); + } + }; + }, + types: {}, + ext: '.ejs', + registerScript: function (type, id, src) { + return 'can.view.preloadStringRenderer(\'' + id + '\',' + $view.types['.' + type].script(id, src) + ');'; + }, + preload: function (id, renderer) { + var def = $view.cached[id] = new can.Deferred().resolve(function (data, helpers) { + return renderer.call(data, data, helpers); + }); + def.__view_id = id; + $view.cachedRenderers[id] = renderer; + return renderer; + }, + preloadStringRenderer: function (id, stringRenderer) { + return this.preload(id, makeRenderer(stringRenderer)); + }, + render: function (view, data, helpers, callback) { + return can.view.renderAs('string', view, data, helpers, callback); + }, + renderTo: function (format, renderer, data, helpers) { + return (format === 'string' && renderer.render ? renderer.render : renderer)(data, helpers); + }, + renderAs: function (format, view, data, helpers, callback) { + if (isFunction(helpers)) { + callback = helpers; + helpers = undefined; + } + var deferreds = getDeferreds(data); + var reading, deferred, dataCopy, async, response; + if (deferreds.length) { + deferred = new can.Deferred(); + dataCopy = can.extend({}, data); + deferreds.push(getRenderer(view, true)); + can.when.apply(can, deferreds).then(function (resolved) { + var objs = makeArray(arguments), renderer = objs.pop(), result; + if (can.isDeferred(data)) { + dataCopy = usefulPart(resolved); + } else { + for (var prop in data) { + if (can.isDeferred(data[prop])) { + dataCopy[prop] = usefulPart(objs.shift()); + } + } + } + result = can.view.renderTo(format, renderer, dataCopy, helpers); + deferred.resolve(result, dataCopy); + if (callback) { + callback(result, dataCopy); + } + }, function () { + deferred.reject.apply(deferred, arguments); + }); + return deferred; + } else { + reading = can.__clearReading(); + async = isFunction(callback); + deferred = getRenderer(view, async); + if (reading) { + can.__setReading(reading); + } + if (async) { + response = deferred; + deferred.then(function (renderer) { + callback(data ? can.view.renderTo(format, renderer, data, helpers) : renderer); + }); + } else { + if (deferred.state() === 'resolved' && deferred.__view_id) { + var currentRenderer = $view.cachedRenderers[deferred.__view_id]; + return data ? can.view.renderTo(format, currentRenderer, data, helpers) : currentRenderer; + } else { + deferred.then(function (renderer) { + response = data ? can.view.renderTo(format, renderer, data, helpers) : renderer; + }); + } + } + return response; + } + }, + registerView: function (id, text, type, def) { + var info = typeof type === 'object' ? type : $view.types[type || $view.ext], renderer; + if (info.fragRenderer) { + renderer = info.fragRenderer(id, text); + } else { + renderer = makeRenderer(info.renderer(id, text)); + } + def = def || new can.Deferred(); + if ($view.cache) { + $view.cached[id] = def; + def.__view_id = id; + $view.cachedRenderers[id] = renderer; + } + return def.resolve(renderer); + } + }); + if (typeof window !== 'undefined' && window.steal && steal.type) { + steal.type('view js', function (options, success, error) { + var type = $view.types['.' + options.type], id = $view.toId(options.id); + var dependency = type.plugin || 'can/view/' + options.type, preload = type.fragRenderer ? 'preload' : 'preloadStringRenderer'; + options.text = 'steal(\'can/view\',\'' + dependency + '\',function(can){return ' + 'can.view.' + preload + '(\'' + id + '\',' + options.text + ');\n})'; + success(); + }); + } + return can; +}); +/*can@2.2.6#view/callbacks/callbacks*/ +define('can/view/callbacks/callbacks', [ + 'can/util/util', + 'can/view/view' +], function (can) { + var attr = can.view.attr = function (attributeName, attrHandler) { + if (attrHandler) { + if (typeof attributeName === 'string') { + attributes[attributeName] = attrHandler; + } else { + regExpAttributes.push({ + match: attributeName, + handler: attrHandler + }); + } + } else { + var cb = attributes[attributeName]; + if (!cb) { + for (var i = 0, len = regExpAttributes.length; i < len; i++) { + var attrMatcher = regExpAttributes[i]; + if (attrMatcher.match.test(attributeName)) { + cb = attrMatcher.handler; + break; + } + } + } + return cb; + } + }; + var attributes = {}, regExpAttributes = [], automaticCustomElementCharacters = /[-\:]/; + var tag = can.view.tag = function (tagName, tagHandler) { + if (tagHandler) { + if (typeof tags[tagName.toLowerCase()] !== 'undefined') { + can.dev.warn('Custom tag: ' + tagName.toLowerCase() + ' is already defined'); + } + if (can.global.html5) { + can.global.html5.elements += ' ' + tagName; + can.global.html5.shivDocument(); + } + tags[tagName.toLowerCase()] = tagHandler; + } else { + var cb = tags[tagName.toLowerCase()]; + if (!cb && automaticCustomElementCharacters.test(tagName)) { + cb = function () { + }; + } + return cb; + } + }; + var tags = {}; + can.view.callbacks = { + _tags: tags, + _attributes: attributes, + _regExpAttributes: regExpAttributes, + tag: tag, + attr: attr, + tagHandler: function (el, tagName, tagData) { + var helperTagCallback = tagData.options.attr('tags.' + tagName), tagCallback = helperTagCallback || tags[tagName]; + var scope = tagData.scope, res; + if (tagCallback) { + var reads = can.__clearReading(); + res = tagCallback(el, tagData); + can.__setReading(reads); + } else { + res = scope; + } + if (!tagCallback) { + can.dev.warn('can/view/scanner.js: No custom element found for ' + tagName); + } + if (res && tagData.subtemplate) { + if (scope !== res) { + scope = scope.add(res); + } + var result = tagData.subtemplate(scope, tagData.options); + var frag = typeof result === 'string' ? can.view.frag(result) : result; + can.appendChild(el, frag); + } + } + }; + return can.view.callbacks; +}); +/*can@2.2.6#view/elements*/ +define('can/view/elements', [ + 'can/util/util', + 'can/view/view' +], function (can) { + var doc = typeof document !== 'undefined' ? document : null; + var selectsCommentNodes = doc && function () { + return can.$(document.createComment('~')).length === 1; + }(); + var elements = { + tagToContentPropMap: { + option: doc && 'textContent' in document.createElement('option') ? 'textContent' : 'innerText', + textarea: 'value' + }, + attrMap: can.attr.map, + attrReg: /([^\s=]+)[\s]*=[\s]*/, + defaultValue: can.attr.defaultValue, + tagMap: { + '': 'span', + colgroup: 'col', + table: 'tbody', + tr: 'td', + ol: 'li', + ul: 'li', + tbody: 'tr', + thead: 'tr', + tfoot: 'tr', + select: 'option', + optgroup: 'option' + }, + reverseTagMap: { + col: 'colgroup', + tr: 'tbody', + option: 'select', + td: 'tr', + th: 'tr', + li: 'ul' + }, + getParentNode: function (el, defaultParentNode) { + return defaultParentNode && el.parentNode.nodeType === 11 ? defaultParentNode : el.parentNode; + }, + setAttr: can.attr.set, + getAttr: can.attr.get, + removeAttr: can.attr.remove, + contentText: function (text) { + if (typeof text === 'string') { + return text; + } + if (!text && text !== 0) { + return ''; + } + return '' + text; + }, + after: function (oldElements, newFrag) { + var last = oldElements[oldElements.length - 1]; + if (last.nextSibling) { + can.insertBefore(last.parentNode, newFrag, last.nextSibling); + } else { + can.appendChild(last.parentNode, newFrag); + } + }, + replace: function (oldElements, newFrag) { + elements.after(oldElements, newFrag); + if (can.remove(can.$(oldElements)).length < oldElements.length && !selectsCommentNodes) { + can.each(oldElements, function (el) { + if (el.nodeType === 8) { + el.parentNode.removeChild(el); + } + }); + } + } + }; + can.view.elements = elements; + return elements; +}); +/*can@2.2.6#util/string/string*/ +define('can/util/string/string', ['can/util/util'], function (can) { + var strUndHash = /_|-/, strColons = /\=\=/, strWords = /([A-Z]+)([A-Z][a-z])/g, strLowUp = /([a-z\d])([A-Z])/g, strDash = /([a-z\d])([A-Z])/g, strReplacer = /\{([^\}]+)\}/g, strQuote = /"/g, strSingleQuote = /'/g, strHyphenMatch = /-+(.)?/g, strCamelMatch = /[a-z][A-Z]/g, getNext = function (obj, prop, add) { + var result = obj[prop]; + if (result === undefined && add === true) { + result = obj[prop] = {}; + } + return result; + }, isContainer = function (current) { + return /^f|^o/.test(typeof current); + }, convertBadValues = function (content) { + var isInvalid = content === null || content === undefined || isNaN(content) && '' + content === 'NaN'; + return '' + (isInvalid ? '' : content); + }; + can.extend(can, { + esc: function (content) { + return convertBadValues(content).replace(/&/g, '&').replace(//g, '>').replace(strQuote, '"').replace(strSingleQuote, '''); + }, + getObject: function (name, roots, add) { + var parts = name ? name.split('.') : [], length = parts.length, current, r = 0, i, container, rootsLength; + roots = can.isArray(roots) ? roots : [roots || window]; + rootsLength = roots.length; + if (!length) { + return roots[0]; + } + for (r; r < rootsLength; r++) { + current = roots[r]; + container = undefined; + for (i = 0; i < length && isContainer(current); i++) { + container = current; + current = getNext(container, parts[i]); + } + if (container !== undefined && current !== undefined) { + break; + } + } + if (add === false && current !== undefined) { + delete container[parts[i - 1]]; + } + if (add === true && current === undefined) { + current = roots[0]; + for (i = 0; i < length && isContainer(current); i++) { + current = getNext(current, parts[i], true); + } + } + return current; + }, + capitalize: function (s, cache) { + return s.charAt(0).toUpperCase() + s.slice(1); + }, + camelize: function (str) { + return convertBadValues(str).replace(strHyphenMatch, function (match, chr) { + return chr ? chr.toUpperCase() : ''; + }); + }, + hyphenate: function (str) { + return convertBadValues(str).replace(strCamelMatch, function (str, offset) { + return str.charAt(0) + '-' + str.charAt(1).toLowerCase(); + }); + }, + underscore: function (s) { + return s.replace(strColons, '/').replace(strWords, '$1_$2').replace(strLowUp, '$1_$2').replace(strDash, '_').toLowerCase(); + }, + sub: function (str, data, remove) { + var obs = []; + str = str || ''; + obs.push(str.replace(strReplacer, function (whole, inside) { + var ob = can.getObject(inside, data, remove === true ? false : undefined); + if (ob === undefined || ob === null) { + obs = null; + return ''; + } + if (isContainer(ob) && obs) { + obs.push(ob); + return ''; + } + return '' + ob; + })); + return obs === null ? obs : obs.length <= 1 ? obs[0] : obs; + }, + replacer: strReplacer, + undHash: strUndHash + }); + return can; +}); +/*can@2.2.6#construct/construct*/ +define('can/construct/construct', ['can/util/string/string'], function (can) { + var initializing = 0; + var canGetDescriptor; + try { + Object.getOwnPropertyDescriptor({}); + canGetDescriptor = true; + } catch (e) { + canGetDescriptor = false; + } + var getDescriptor = function (newProps, name) { + var descriptor = Object.getOwnPropertyDescriptor(newProps, name); + if (descriptor && (descriptor.get || descriptor.set)) { + return descriptor; + } + return null; + }, inheritGetterSetter = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + var descriptor; + for (var name in newProps) { + if (descriptor = getDescriptor(newProps, name)) { + this._defineProperty(addTo, oldProps, name, descriptor); + } else { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + } + }, simpleInherit = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + for (var name in newProps) { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + }; + can.Construct = function () { + if (arguments.length) { + return can.Construct.extend.apply(can.Construct, arguments); + } + }; + can.extend(can.Construct, { + constructorExtends: true, + newInstance: function () { + var inst = this.instance(), args; + if (inst.setup) { + args = inst.setup.apply(inst, arguments); + } + if (inst.init) { + inst.init.apply(inst, args || arguments); + } + return inst; + }, + _inherit: canGetDescriptor ? inheritGetterSetter : simpleInherit, + _defineProperty: function (what, oldProps, propName, descriptor) { + Object.defineProperty(what, propName, descriptor); + }, + _overwrite: function (what, oldProps, propName, val) { + what[propName] = val; + }, + setup: function (base, fullName) { + this.defaults = can.extend(true, {}, base.defaults, this.defaults); + }, + instance: function () { + initializing = 1; + var inst = new this(); + initializing = 0; + return inst; + }, + extend: function (name, staticProperties, instanceProperties) { + var fullName = name, klass = staticProperties, proto = instanceProperties; + if (typeof fullName !== 'string') { + proto = klass; + klass = fullName; + fullName = null; + } + if (!proto) { + proto = klass; + klass = null; + } + proto = proto || {}; + var _super_class = this, _super = this.prototype, Constructor, parts, current, _fullName, _shortName, propName, shortName, namespace, prototype; + prototype = this.instance(); + can.Construct._inherit(proto, _super, prototype); + if (fullName) { + parts = fullName.split('.'); + shortName = parts.pop(); + } + var constructorName = shortName ? shortName.replace(/;/g, '') : 'Constructor'; + eval('Constructor = function ' + constructorName + '() { return init.apply(this, arguments); }'); + if (typeof constructorName === 'undefined') { + Constructor = function () { + return init.apply(this, arguments); + }; + } + function init() { + if (!initializing) { + if (this.constructor !== Constructor && arguments.length && Constructor.constructorExtends) { + can.dev.warn('can/construct/construct.js: extending a can.Construct without calling extend'); + } + return this.constructor !== Constructor && arguments.length && Constructor.constructorExtends ? Constructor.extend.apply(Constructor, arguments) : Constructor.newInstance.apply(Constructor, arguments); + } + } + for (propName in _super_class) { + if (_super_class.hasOwnProperty(propName)) { + Constructor[propName] = _super_class[propName]; + } + } + can.Construct._inherit(klass, _super_class, Constructor); + if (fullName) { + current = can.getObject(parts.join('.'), window, true); + namespace = current; + _fullName = can.underscore(fullName.replace(/\./g, '_')); + _shortName = can.underscore(shortName); + if (current[shortName]) { + can.dev.warn('can/construct/construct.js: There\'s already something called ' + fullName); + } + current[shortName] = Constructor; + } + can.extend(Constructor, { + constructor: Constructor, + prototype: prototype, + namespace: namespace, + _shortName: _shortName, + fullName: fullName, + _fullName: _fullName + }); + if (shortName !== undefined) { + Constructor.shortName = shortName; + } + Constructor.prototype.constructor = Constructor; + var t = [_super_class].concat(can.makeArray(arguments)), args = Constructor.setup.apply(Constructor, t); + if (Constructor.init) { + Constructor.init.apply(Constructor, args || t); + } + return Constructor; + } + }); + can.Construct.prototype.setup = function () { + }; + can.Construct.prototype.init = function () { + }; + return can.Construct; +}); +/*can@2.2.6#control/control*/ +define('can/control/control', [ + 'can/util/util', + 'can/construct/construct' +], function (can) { + var bind = function (el, ev, callback) { + can.bind.call(el, ev, callback); + return function () { + can.unbind.call(el, ev, callback); + }; + }, isFunction = can.isFunction, extend = can.extend, each = can.each, slice = [].slice, paramReplacer = /\{([^\}]+)\}/g, special = can.getObject('$.event.special', [can]) || {}, delegate = function (el, selector, ev, callback) { + can.delegate.call(el, selector, ev, callback); + return function () { + can.undelegate.call(el, selector, ev, callback); + }; + }, binder = function (el, ev, callback, selector) { + return selector ? delegate(el, can.trim(selector), ev, callback) : bind(el, ev, callback); + }, basicProcessor; + var Control = can.Control = can.Construct({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Control) { + var control = this, funcName; + control.actions = {}; + for (funcName in control.prototype) { + if (control._isAction(funcName)) { + control.actions[funcName] = control._action(funcName); + } + } + } + }, + _shifter: function (context, name) { + var method = typeof name === 'string' ? context[name] : name; + if (!isFunction(method)) { + method = context[method]; + } + return function () { + context.called = name; + return method.apply(context, [this.nodeName ? can.$(this) : this].concat(slice.call(arguments, 0))); + }; + }, + _isAction: function (methodName) { + var val = this.prototype[methodName], type = typeof val; + return methodName !== 'constructor' && (type === 'function' || type === 'string' && isFunction(this.prototype[val])) && !!(special[methodName] || processors[methodName] || /[^\w]/.test(methodName)); + }, + _action: function (methodName, options) { + paramReplacer.lastIndex = 0; + if (options || !paramReplacer.test(methodName)) { + var convertedName = options ? can.sub(methodName, this._lookup(options)) : methodName; + if (!convertedName) { + can.dev.log('can/control/control.js: No property found for handling ' + methodName); + return null; + } + var arr = can.isArray(convertedName), name = arr ? convertedName[1] : convertedName, parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: processors[event] || basicProcessor, + parts: [ + name, + parts.join(' '), + event + ], + delegate: arr ? convertedName[0] : undefined + }; + } + }, + _lookup: function (options) { + return [ + options, + window + ]; + }, + processors: {}, + defaults: {} + }, { + setup: function (element, options) { + var cls = this.constructor, pluginname = cls.pluginName || cls._fullName, arr; + this.element = can.$(element); + if (pluginname && pluginname !== 'can_control') { + this.element.addClass(pluginname); + } + arr = can.data(this.element, 'controls'); + if (!arr) { + arr = []; + can.data(this.element, 'controls', arr); + } + arr.push(this); + this.options = extend({}, cls.defaults, options); + this.on(); + return [ + this.element, + this.options + ]; + }, + on: function (el, selector, eventName, func) { + if (!el) { + this.off(); + var cls = this.constructor, bindings = this._bindings, actions = cls.actions, element = this.element, destroyCB = can.Control._shifter(this, 'destroy'), funcName, ready; + for (funcName in actions) { + if (actions.hasOwnProperty(funcName)) { + ready = actions[funcName] || cls._action(funcName, this.options, this); + if (ready) { + bindings.control[funcName] = ready.processor(ready.delegate || element, ready.parts[2], ready.parts[1], funcName, this); + } + } + } + can.bind.call(element, 'removed', destroyCB); + bindings.user.push(function (el) { + can.unbind.call(el, 'removed', destroyCB); + }); + return bindings.user.length; + } + if (typeof el === 'string') { + func = eventName; + eventName = selector; + selector = el; + el = this.element; + } + if (func === undefined) { + func = eventName; + eventName = selector; + selector = null; + } + if (typeof func === 'string') { + func = can.Control._shifter(this, func); + } + this._bindings.user.push(binder(el, eventName, func, selector)); + return this._bindings.user.length; + }, + off: function () { + var el = this.element[0], bindings = this._bindings; + if (bindings) { + each(bindings.user || [], function (value) { + value(el); + }); + each(bindings.control || {}, function (value) { + value(el); + }); + } + this._bindings = { + user: [], + control: {} + }; + }, + destroy: function () { + if (this.element === null) { + can.dev.warn('can/control/control.js: Control already destroyed'); + return; + } + var Class = this.constructor, pluginName = Class.pluginName || Class._fullName, controls; + this.off(); + if (pluginName && pluginName !== 'can_control') { + this.element.removeClass(pluginName); + } + controls = can.data(this.element, 'controls'); + controls.splice(can.inArray(this, controls), 1); + can.trigger(this, 'destroyed'); + this.element = null; + } + }); + var processors = can.Control.processors; + basicProcessor = function (el, event, selector, methodName, control) { + return binder(el, event, can.Control._shifter(control, methodName), selector); + }; + each([ + 'change', + 'click', + 'contextmenu', + 'dblclick', + 'keydown', + 'keyup', + 'keypress', + 'mousedown', + 'mousemove', + 'mouseout', + 'mouseover', + 'mouseup', + 'reset', + 'resize', + 'scroll', + 'select', + 'submit', + 'focusin', + 'focusout', + 'mouseenter', + 'mouseleave', + 'touchstart', + 'touchmove', + 'touchcancel', + 'touchend', + 'touchleave', + 'inserted', + 'removed' + ], function (v) { + processors[v] = basicProcessor; + }); + return Control; +}); +/*can@2.2.6#util/bind/bind*/ +define('can/util/bind/bind', ['can/util/util'], function (can) { + can.bindAndSetup = function () { + can.addEvent.apply(this, arguments); + if (!this._init) { + if (!this._bindings) { + this._bindings = 1; + if (this._bindsetup) { + this._bindsetup(); + } + } else { + this._bindings++; + } + } + return this; + }; + can.unbindAndTeardown = function (event, handler) { + var handlers = this.__bindEvents[event] || []; + var handlerCount = handlers.length; + can.removeEvent.apply(this, arguments); + if (this._bindings === null) { + this._bindings = 0; + } else { + this._bindings = this._bindings - (handlerCount - handlers.length); + } + if (!this._bindings && this._bindteardown) { + this._bindteardown(); + } + return this; + }; + return can; +}); +/*can@2.2.6#map/bubble*/ +define('can/map/bubble', ['can/util/util'], function (can) { + var bubble = can.bubble = { + event: function (map, boundEventName) { + return map.constructor._bubbleRule(boundEventName, map); + }, + childrenOf: function (parentMap, eventName) { + parentMap._each(function (child, prop) { + if (child && child.bind) { + bubble.toParent(child, parentMap, prop, eventName); + } + }); + }, + teardownChildrenFrom: function (parentMap, eventName) { + parentMap._each(function (child) { + bubble.teardownFromParent(parentMap, child, eventName); + }); + }, + toParent: function (child, parent, prop, eventName) { + can.listenTo.call(parent, child, eventName, function () { + var args = can.makeArray(arguments), ev = args.shift(); + args[0] = (can.List && parent instanceof can.List ? parent.indexOf(child) : prop) + (args[0] ? '.' + args[0] : ''); + ev.triggeredNS = ev.triggeredNS || {}; + if (ev.triggeredNS[parent._cid]) { + return; + } + ev.triggeredNS[parent._cid] = true; + can.trigger(parent, ev, args); + }); + }, + teardownFromParent: function (parent, child, eventName) { + if (child && child.unbind) { + can.stopListening.call(parent, child, eventName); + } + }, + isBubbling: function (parent, eventName) { + return parent._bubbleBindings && parent._bubbleBindings[eventName]; + }, + bind: function (parent, eventName) { + if (!parent._init) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + if (!parent._bubbleBindings) { + parent._bubbleBindings = {}; + } + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (!parent._bubbleBindings[bubbleEvent]) { + parent._bubbleBindings[bubbleEvent] = 1; + bubble.childrenOf(parent, bubbleEvent); + } else { + parent._bubbleBindings[bubbleEvent]++; + } + } + } + }, + unbind: function (parent, eventName) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (parent._bubbleBindings) { + parent._bubbleBindings[bubbleEvent]--; + } + if (parent._bubbleBindings && !parent._bubbleBindings[bubbleEvent]) { + delete parent._bubbleBindings[bubbleEvent]; + bubble.teardownChildrenFrom(parent, bubbleEvent); + if (can.isEmptyObject(parent._bubbleBindings)) { + delete parent._bubbleBindings; + } + } + } + }, + add: function (parent, child, prop) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + bubble.toParent(child, parent, prop, eventName); + } + } + } + }, + removeMany: function (parent, children) { + for (var i = 0, len = children.length; i < len; i++) { + bubble.remove(parent, children[i]); + } + }, + remove: function (parent, child) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + } + } + } + }, + set: function (parent, prop, value, current) { + if (can.Map.helpers.isObservable(value)) { + bubble.add(parent, value, prop); + } + if (can.Map.helpers.isObservable(current)) { + bubble.remove(parent, current); + } + return value; + } + }; + return bubble; +}); +/*can@2.2.6#util/batch/batch*/ +define('can/util/batch/batch', ['can/util/can'], function (can) { + var batchNum = 1, transactions = 0, batchEvents = [], stopCallbacks = [], currentBatchEvents = null; + can.batch = { + start: function (batchStopHandler) { + transactions++; + if (batchStopHandler) { + stopCallbacks.push(batchStopHandler); + } + }, + stop: function (force, callStart) { + if (force) { + transactions = 0; + } else { + transactions--; + } + if (transactions === 0) { + if (currentBatchEvents !== null) { + return; + } + currentBatchEvents = batchEvents.slice(0); + var callbacks = stopCallbacks.slice(0), i, len; + batchEvents = []; + stopCallbacks = []; + can.batch.batchNum = batchNum; + batchNum++; + if (callStart) { + can.batch.start(); + } + for (i = 0; i < currentBatchEvents.length; i++) { + can.dispatch.apply(currentBatchEvents[i][0], currentBatchEvents[i][1]); + } + currentBatchEvents = null; + for (i = 0, len = callbacks.length; i < callbacks.length; i++) { + callbacks[i](); + } + can.batch.batchNum = undefined; + } + }, + trigger: function (item, event, args) { + if (!item._init) { + event = typeof event === 'string' ? { type: event } : event; + if (currentBatchEvents) { + currentBatchEvents.push([ + item, + [ + event, + args + ] + ]); + } else if (transactions === 0) { + return can.dispatch.call(item, event, args); + } else { + event.batchNum = batchNum; + batchEvents.push([ + item, + [ + event, + args + ] + ]); + } + } + }, + afterPreviousEvents: function (handler) { + if (currentBatchEvents) { + var obj = {}; + can.bind.call(obj, 'ready', handler); + currentBatchEvents.push([ + obj, + [ + { type: 'ready' }, + [] + ] + ]); + } else { + handler(); + } + } + }; +}); +/*can@2.2.6#map/map*/ +define('can/map/map', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/map/bubble', + 'can/construct/construct', + 'can/util/batch/batch' +], function (can, bind, bubble) { + var madeMap = null; + var teardownMap = function () { + for (var cid in madeMap) { + if (madeMap[cid].added) { + delete madeMap[cid].obj._cid; + } + } + madeMap = null; + }; + var getMapFromObject = function (obj) { + return madeMap && madeMap[obj._cid] && madeMap[obj._cid].instance; + }; + var serializeMap = null; + var Map = can.Map = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Map) { + if (!this.defaults) { + this.defaults = {}; + } + this._computes = []; + if (this.prototype.define && !this.helpers.define) { + can.dev.warn('can/map/define is not included, yet there is a define property ' + 'used. You may want to add this plugin.'); + } + if (this.define && !this.helpers.define) { + can.dev.warn('The define property should be on the map\'s prototype properties, ' + 'not the static properies. Also, can/map/define is not included.'); + } + for (var prop in this.prototype) { + if (prop !== 'define' && prop !== 'constructor' && (typeof this.prototype[prop] !== 'function' || this.prototype[prop].prototype instanceof can.Construct)) { + this.defaults[prop] = this.prototype[prop]; + } else if (this.prototype[prop].isComputed) { + this._computes.push(prop); + } + } + if (this.helpers.define) { + this.helpers.define(this); + } + } + if (can.List && !(this.prototype instanceof can.List)) { + this.List = Map.List.extend({ Map: this }, {}); + } + }, + _bubble: bubble, + _bubbleRule: function (eventName) { + return eventName === 'change' || eventName.indexOf('.') >= 0 ? ['change'] : []; + }, + _computes: [], + bind: can.bindAndSetup, + on: can.bindAndSetup, + unbind: can.unbindAndTeardown, + off: can.unbindAndTeardown, + id: 'id', + helpers: { + define: null, + attrParts: function (attr, keepKey) { + if (keepKey) { + return [attr]; + } + return typeof attr === 'object' ? attr : ('' + attr).split('.'); + }, + addToMap: function (obj, instance) { + var teardown; + if (!madeMap) { + teardown = teardownMap; + madeMap = {}; + } + var hasCid = obj._cid; + var cid = can.cid(obj); + if (!madeMap[cid]) { + madeMap[cid] = { + obj: obj, + instance: instance, + added: !hasCid + }; + } + return teardown; + }, + isObservable: function (obj) { + return obj instanceof can.Map || obj && obj === can.route; + }, + canMakeObserve: function (obj) { + return obj && !can.isDeferred(obj) && (can.isArray(obj) || can.isPlainObject(obj)); + }, + serialize: function (map, how, where) { + var cid = can.cid(map), firstSerialize = false; + if (!serializeMap) { + firstSerialize = true; + serializeMap = { + attr: {}, + serialize: {} + }; + } + serializeMap[how][cid] = where; + map.each(function (val, name) { + var result, isObservable = Map.helpers.isObservable(val), serialized = isObservable && serializeMap[how][can.cid(val)]; + if (serialized) { + result = serialized; + } else { + if (how === 'serialize') { + result = Map.helpers._serialize(map, name, val); + } else { + result = Map.helpers._getValue(map, name, val, how); + } + } + if (result !== undefined) { + where[name] = result; + } + }); + can.__observe(map, '__keys'); + if (firstSerialize) { + serializeMap = null; + } + return where; + }, + _serialize: function (map, name, val) { + return Map.helpers._getValue(map, name, val, 'serialize'); + }, + _getValue: function (map, name, val, how) { + if (Map.helpers.isObservable(val)) { + return val[how](); + } else { + return val; + } + } + }, + keys: function (map) { + var keys = []; + can.__observe(map, '__keys'); + for (var keyName in map._data) { + keys.push(keyName); + } + return keys; + } + }, { + setup: function (obj) { + if (obj instanceof can.Map) { + obj = obj.serialize(); + } + this._data = {}; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + var defaultValues = this._setupDefaults(obj); + this._setupComputes(defaultValues); + var teardownMapping = obj && can.Map.helpers.addToMap(obj, this); + var data = can.extend(can.extend(true, {}, defaultValues), obj); + this.attr(data); + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + delete this._init; + }, + _setupComputes: function () { + var computes = this.constructor._computes; + for (var i = 0, len = computes.length, prop; i < len; i++) { + prop = computes[i]; + this[prop] = this[prop].clone(this); + this._computedBindings[prop] = { count: 0 }; + } + }, + _setupDefaults: function () { + return this.constructor.defaults || {}; + }, + _bindsetup: function () { + }, + _bindteardown: function () { + }, + _changes: function (ev, attr, how, newVal, oldVal) { + can.batch.trigger(this, { + type: attr, + batchNum: ev.batchNum, + target: ev.target + }, [ + newVal, + oldVal + ]); + }, + _triggerChange: function (attr, how, newVal, oldVal) { + if (bubble.isBubbling(this, 'change')) { + can.batch.trigger(this, { + type: 'change', + target: this + }, [ + attr, + how, + newVal, + oldVal + ]); + } else { + can.batch.trigger(this, attr, [ + newVal, + oldVal + ]); + } + if (how === 'remove' || how === 'add') { + can.batch.trigger(this, { + type: '__keys', + target: this + }); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var prop in data) { + if (data.hasOwnProperty(prop)) { + callback(data[prop], prop); + } + } + }, + attr: function (attr, val) { + var type = typeof attr; + if (type !== 'string' && type !== 'number') { + return this._attrs(attr, val); + } else if (arguments.length === 1) { + return this._get(attr); + } else { + this._set(attr, val); + return this; + } + }, + each: function () { + return can.each.apply(undefined, [this].concat(can.makeArray(arguments))); + }, + removeAttr: function (attr) { + var isList = can.List && this instanceof can.List, parts = can.Map.helpers.attrParts(attr), prop = parts.shift(), current = isList ? this[prop] : this._data[prop]; + if (parts.length && current) { + return current.removeAttr(parts); + } else { + if (typeof attr === 'string' && !!~attr.indexOf('.')) { + prop = attr; + } + this._remove(prop, current); + return current; + } + }, + _remove: function (prop, current) { + if (prop in this._data) { + delete this._data[prop]; + if (!(prop in this.constructor.prototype)) { + delete this[prop]; + } + this._triggerChange(prop, 'remove', undefined, current); + } + }, + _get: function (attr) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'); + if (dotIndex >= 0) { + var value = this.__get(attr); + if (value !== undefined) { + return value; + } + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + can.__observe(this, first); + var current = this.__get(first); + return current && current._get ? current._get(second) : undefined; + } else { + can.__observe(this, attr); + return this.__get(attr); + } + }, + __get: function (attr) { + if (attr) { + if (this._computedBindings[attr]) { + return this[attr](); + } else { + return this._data[attr]; + } + } else { + return this._data; + } + }, + __type: function (value, prop) { + if (!(value instanceof can.Map) && can.Map.helpers.canMakeObserve(value)) { + var cached = getMapFromObject(value); + if (cached) { + return cached; + } + if (can.isArray(value)) { + var List = can.List; + return new List(value); + } else { + var Map = this.constructor.Map || can.Map; + return new Map(value); + } + } + return value; + }, + _set: function (attr, value, keepKey) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'), current; + if (!keepKey && dotIndex >= 0) { + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + current = this._init ? undefined : this.__get(first); + if (Map.helpers.isObservable(current)) { + current._set(second, value); + } else { + throw 'can.Map: Object does not exist'; + } + } else { + if (this.__convert) { + value = this.__convert(attr, value); + } + current = this._init ? undefined : this.__get(attr); + this.__set(attr, this.__type(value, attr), current); + } + }, + __set: function (prop, value, current) { + if (value !== current) { + var changeType = current !== undefined || this.__get().hasOwnProperty(prop) ? 'set' : 'add'; + this.___set(prop, this.constructor._bubble.set(this, prop, value, current)); + if (!this._computedBindings[prop]) { + this._triggerChange(prop, changeType, value, current); + } + if (current) { + this.constructor._bubble.teardownFromParent(this, current); + } + } + }, + ___set: function (prop, val) { + if (this._computedBindings[prop]) { + this[prop](val); + } else { + this._data[prop] = val; + } + if (typeof this.constructor.prototype[prop] !== 'function' && !this._computedBindings[prop]) { + this[prop] = val; + } + }, + bind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (!computedBinding.count) { + computedBinding.count = 1; + var self = this; + computedBinding.handler = function (ev, newVal, oldVal) { + can.batch.trigger(self, { + type: eventName, + batchNum: ev.batchNum, + target: self + }, [ + newVal, + oldVal + ]); + }; + this[eventName].bind('change', computedBinding.handler); + } else { + computedBinding.count++; + } + } + this.constructor._bubble.bind(this, eventName); + return can.bindAndSetup.apply(this, arguments); + }, + unbind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (computedBinding.count === 1) { + computedBinding.count = 0; + this[eventName].unbind('change', computedBinding.handler); + delete computedBinding.handler; + } else { + computedBinding.count--; + } + } + this.constructor._bubble.unbind(this, eventName); + return can.unbindAndTeardown.apply(this, arguments); + }, + serialize: function () { + return can.Map.helpers.serialize(this, 'serialize', {}); + }, + _attrs: function (props, remove) { + if (props === undefined) { + return Map.helpers.serialize(this, 'attr', {}); + } + props = can.simpleExtend({}, props); + var prop, self = this, newVal; + can.batch.start(); + this.each(function (curVal, prop) { + if (prop === '_cid') { + return; + } + newVal = props[prop]; + if (newVal === undefined) { + if (remove) { + self.removeAttr(prop); + } + return; + } + if (self.__convert) { + newVal = self.__convert(prop, newVal); + } + if (Map.helpers.isObservable(newVal)) { + self.__set(prop, self.__type(newVal, prop), curVal); + } else if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + self.__set(prop, self.__type(newVal, prop), curVal); + } + delete props[prop]; + }); + for (prop in props) { + if (prop !== '_cid') { + newVal = props[prop]; + this._set(prop, newVal, true); + } + } + can.batch.stop(); + return this; + }, + compute: function (prop) { + if (can.isFunction(this.constructor.prototype[prop])) { + return can.compute(this[prop], this); + } else { + var reads = prop.split('.'), last = reads.length - 1, options = { args: [] }; + return can.compute(function (newVal) { + if (arguments.length) { + can.compute.read(this, reads.slice(0, last)).value.attr(reads[last], newVal); + } else { + return can.compute.read(this, reads, options).value; + } + }, this); + } + } + }); + Map.prototype.on = Map.prototype.bind; + Map.prototype.off = Map.prototype.unbind; + return Map; +}); +/*can@2.2.6#list/list*/ +define('can/list/list', [ + 'can/util/util', + 'can/map/map', + 'can/map/bubble' +], function (can, Map, bubble) { + var splice = [].splice, spliceRemovesProps = function () { + var obj = { + 0: 'a', + length: 1 + }; + splice.call(obj, 0, 1); + return !obj[0]; + }(); + var list = Map.extend({ Map: Map }, { + setup: function (instances, options) { + this.length = 0; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + this._setupComputes(); + instances = instances || []; + var teardownMapping; + if (can.isDeferred(instances)) { + this.replace(instances); + } else { + teardownMapping = instances.length && can.Map.helpers.addToMap(instances, this); + this.push.apply(this, can.makeArray(instances || [])); + } + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + can.simpleExtend(this, options); + delete this._init; + }, + _triggerChange: function (attr, how, newVal, oldVal) { + Map.prototype._triggerChange.apply(this, arguments); + var index = +attr; + if (!~('' + attr).indexOf('.') && !isNaN(index)) { + if (how === 'add') { + can.batch.trigger(this, how, [ + newVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else if (how === 'remove') { + can.batch.trigger(this, how, [ + oldVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else { + can.batch.trigger(this, how, [ + newVal, + index + ]); + } + } + }, + __get: function (attr) { + if (attr) { + if (this[attr] && this[attr].isComputed && can.isFunction(this.constructor.prototype[attr])) { + return this[attr](); + } else { + return this[attr]; + } + } else { + return this; + } + }, + __set: function (prop, value, current) { + prop = isNaN(+prop) || prop % 1 ? prop : +prop; + if (typeof prop === 'number' && prop > this.length - 1) { + var newArr = new Array(prop + 1 - this.length); + newArr[newArr.length - 1] = value; + this.push.apply(this, newArr); + return newArr; + } + return can.Map.prototype.__set.call(this, '' + prop, value, current); + }, + ___set: function (attr, val) { + this[attr] = val; + if (+attr >= this.length) { + this.length = +attr + 1; + } + }, + _remove: function (prop, current) { + if (isNaN(+prop)) { + delete this[prop]; + this._triggerChange(prop, 'remove', undefined, current); + } else { + this.splice(prop, 1); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var i = 0; i < data.length; i++) { + callback(data[i], i); + } + }, + serialize: function () { + return Map.helpers.serialize(this, 'serialize', []); + }, + splice: function (index, howMany) { + var args = can.makeArray(arguments), added = [], i, len, listIndex, allSame = args.length > 2; + index = index || 0; + for (i = 0, len = args.length - 2; i < len; i++) { + listIndex = i + 2; + args[listIndex] = this.__type(args[listIndex], listIndex); + added.push(args[listIndex]); + if (this[i + index] !== args[listIndex]) { + allSame = false; + } + } + if (allSame && this.length <= added.length) { + return added; + } + if (howMany === undefined) { + howMany = args[1] = this.length - index; + } + var removed = splice.apply(this, args); + if (!spliceRemovesProps) { + for (i = this.length; i < removed.length + this.length; i++) { + delete this[i]; + } + } + can.batch.start(); + if (howMany > 0) { + bubble.removeMany(this, removed); + this._triggerChange('' + index, 'remove', undefined, removed); + } + if (args.length > 2) { + for (i = 0, len = added.length; i < len; i++) { + bubble.set(this, i, added[i]); + } + this._triggerChange('' + index, 'add', added, removed); + } + can.batch.stop(); + return removed; + }, + _attrs: function (items, remove) { + if (items === undefined) { + return Map.helpers.serialize(this, 'attr', []); + } + items = can.makeArray(items); + can.batch.start(); + this._updateAttrs(items, remove); + can.batch.stop(); + }, + _updateAttrs: function (items, remove) { + var len = Math.min(items.length, this.length); + for (var prop = 0; prop < len; prop++) { + var curVal = this[prop], newVal = items[prop]; + if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + this._set(prop, newVal); + } else { + } + } + if (items.length > this.length) { + this.push.apply(this, items.slice(this.length)); + } else if (items.length < this.length && remove) { + this.splice(items.length); + } + } + }), getArgs = function (args) { + return args[0] && can.isArray(args[0]) ? args[0] : can.makeArray(args); + }; + can.each({ + push: 'length', + unshift: 0 + }, function (where, name) { + var orig = [][name]; + list.prototype[name] = function () { + var args = [], len = where ? this.length : 0, i = arguments.length, res, val; + while (i--) { + val = arguments[i]; + args[i] = bubble.set(this, i, this.__type(val, i)); + } + res = orig.apply(this, args); + if (!this.comparator || args.length) { + this._triggerChange('' + len, 'add', args, undefined); + } + return res; + }; + }); + can.each({ + pop: 'length', + shift: 0 + }, function (where, name) { + list.prototype[name] = function () { + if (!this.length) { + return undefined; + } + var args = getArgs(arguments), len = where && this.length ? this.length - 1 : 0; + var res = [][name].apply(this, args); + this._triggerChange('' + len, 'remove', undefined, [res]); + if (res && res.unbind) { + bubble.remove(this, res); + } + return res; + }; + }); + can.extend(list.prototype, { + indexOf: function (item, fromIndex) { + this.attr('length'); + return can.inArray(item, this, fromIndex); + }, + join: function () { + return [].join.apply(this.attr(), arguments); + }, + reverse: function () { + var list = [].reverse.call(can.makeArray(this)); + this.replace(list); + }, + slice: function () { + var temp = Array.prototype.slice.apply(this, arguments); + return new this.constructor(temp); + }, + concat: function () { + var args = []; + can.each(can.makeArray(arguments), function (arg, i) { + args[i] = arg instanceof can.List ? arg.serialize() : arg; + }); + return new this.constructor(Array.prototype.concat.apply(this.serialize(), args)); + }, + forEach: function (cb, thisarg) { + return can.each(this, cb, thisarg || this); + }, + replace: function (newList) { + if (can.isDeferred(newList)) { + newList.then(can.proxy(this.replace, this)); + } else { + this.splice.apply(this, [ + 0, + this.length + ].concat(can.makeArray(newList || []))); + } + return this; + }, + filter: function (callback, thisArg) { + var filteredList = new can.List(), self = this, filtered; + this.each(function (item, index, list) { + filtered = callback.call(thisArg | self, item, index, self); + if (filtered) { + filteredList.push(item); + } + }); + return filteredList; + } + }); + can.List = Map.List = list; + return can.List; +}); +/*can@2.2.6#compute/read*/ +define('can/compute/read', ['can/util/util'], function (can) { + var read = function (parent, reads, options) { + options = options || {}; + var state = { foundObservable: false }; + var cur = readValue(parent, 0, reads, options, state), type, prev, readLength = reads.length, i = 0; + while (i < readLength) { + prev = cur; + for (var r = 0, readersLength = read.propertyReaders.length; r < readersLength; r++) { + var reader = read.propertyReaders[r]; + if (reader.test(cur)) { + cur = reader.read(cur, reads[i], i, options, state); + break; + } + } + i = i + 1; + cur = readValue(cur, i, reads, options, state, prev); + type = typeof cur; + if (i < reads.length && (cur === null || type !== 'function' && type !== 'object')) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1, cur); + } + return { + value: undefined, + parent: prev + }; + } + } + if (cur === undefined) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1); + } + } + return { + value: cur, + parent: prev + }; + }; + var readValue = function (value, index, reads, options, state, prev) { + var usedValueReader; + do { + usedValueReader = false; + for (var i = 0, len = read.valueReaders.length; i < len; i++) { + if (read.valueReaders[i].test(value, index, reads, options)) { + value = read.valueReaders[i].read(value, index, reads, options, state, prev); + } + } + } while (usedValueReader); + return value; + }; + read.valueReaders = [ + { + name: 'compute', + test: function (value, i, reads, options) { + return value && value.isComputed; + }, + read: function (value, i, reads, options, state) { + if (options.isArgument && i === reads.length) { + return value; + } + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, i); + state.foundObservable = true; + } + return value instanceof can.Compute ? value.get() : value(); + } + }, + { + name: 'function', + test: function (value, i, reads, options) { + var type = typeof value; + return type === 'function' && !value.isComputed && (options.executeAnonymousFunctions || options.isArgument && i === reads.length) && !(can.Construct && value.prototype instanceof can.Construct) && !(can.route && value === can.route); + }, + read: function (value, i, reads, options, state, prev) { + if (options.isArgument && i === reads.length) { + return options.proxyMethods !== false ? can.proxy(value, prev) : value; + } + return value.call(prev); + } + } + ]; + read.propertyReaders = [ + { + name: 'map', + test: can.isMapLike, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + if (typeof value[prop] === 'function' && value.constructor.prototype[prop] === value[prop]) { + if (options.returnObserveMethods) { + return value[prop]; + } else if (prop === 'constructor' && value instanceof can.Construct || value[prop].prototype instanceof can.Construct) { + return value[prop]; + } else { + return value[prop].apply(value, options.args || []); + } + } else { + return value.attr(prop); + } + } + }, + { + name: 'promise', + test: function (value) { + return can.isPromise(value); + }, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + var observeData = value.__observeData; + if (!value.__observeData) { + observeData = value.__observeData = { + isPending: true, + state: 'pending', + isResolved: false, + isRejected: false, + value: undefined, + reason: undefined + }; + can.cid(observeData); + can.simpleExtend(observeData, can.event); + value.then(function (value) { + observeData.isPending = false; + observeData.isResolved = true; + observeData.value = value; + observeData.state = 'resolved'; + observeData.dispatch('state', [ + 'resolved', + 'pending' + ]); + }, function (reason) { + observeData.isPending = false; + observeData.isRejected = true; + observeData.reason = reason; + observeData.state = 'rejected'; + observeData.dispatch('state', [ + 'rejected', + 'pending' + ]); + }); + } + can.__observe(observeData, 'state'); + return prop in observeData ? observeData[prop] : value[prop]; + } + }, + { + name: 'object', + test: function () { + return true; + }, + read: function (value, prop) { + if (value == null) { + return undefined; + } else { + return value[prop]; + } + } + } + ]; + read.write = function (parent, key, value, options) { + options = options || {}; + if (can.isMapLike(parent)) { + if (!options.isArgument && parent._data && parent._data[key] && parent._data[key].isComputed) { + return parent._data[key](value); + } else { + return parent.attr(key, value); + } + } + if (parent[key] && parent[key].isComputed) { + return parent[key](value); + } + if (typeof parent === 'object') { + parent[key] = value; + } + }; + return read; +}); +/*can@2.2.6#compute/get_value_and_bind*/ +define('can/compute/get_value_and_bind', ['can/util/util'], function () { + function observe(func, context, oldInfo, onchanged) { + var info = getValueAndObserved(func, context), newObserveSet = info.observed, oldObserved = oldInfo.observed; + if (info.names !== oldInfo.names) { + bindNewSet(oldObserved, newObserveSet, onchanged); + unbindOldSet(oldObserved, onchanged); + } + can.batch.afterPreviousEvents(function () { + info.ready = true; + }); + return info; + } + var observedStack = []; + can.__isRecordingObserves = function () { + return observedStack.length; + }; + can.__observe = can.__reading = function (obj, event) { + if (observedStack.length) { + var name = obj._cid + '|' + event, top = observedStack[observedStack.length - 1]; + top.names += name; + top.observed[name] = { + obj: obj, + event: event + '' + }; + } + }; + can.__notObserve = function (fn) { + return function () { + var previousReads = can.__clearObserved(); + var res = fn.apply(this, arguments); + can.__setObserved(previousReads); + return res; + }; + }; + can.__clearObserved = can.__clearReading = function () { + if (observedStack.length) { + var ret = observedStack[observedStack.length - 1]; + observedStack[observedStack.length - 1] = { observed: {} }; + return ret; + } + }; + can.__setObserved = can.__setReading = function (o) { + if (observedStack.length) { + observedStack[observedStack.length - 1] = o; + } + }; + can.__addObserved = can.__addReading = function (o) { + if (observedStack.length) { + can.simpleExtend(observedStack[observedStack.length - 1], o); + } + }; + var getValueAndObserved = function (func, self) { + observedStack.push({ + names: '', + observed: {} + }); + var value = func.call(self); + var stackItem = observedStack.pop(); + stackItem.value = value; + return stackItem; + }; + var bindNewSet = function (oldObserved, newObserveSet, onchanged) { + for (var name in newObserveSet) { + bindOrPreventUnbinding(oldObserved, newObserveSet, name, onchanged); + } + }; + var bindOrPreventUnbinding = function (oldObserved, newObserveSet, name, onchanged) { + if (oldObserved[name]) { + delete oldObserved[name]; + } else { + var obEv = newObserveSet[name]; + obEv.obj.bind(obEv.event, onchanged); + } + }; + var unbindOldSet = function (oldObserved, onchanged) { + for (var name in oldObserved) { + var obEv = oldObserved[name]; + obEv.obj.unbind(obEv.event, onchanged); + } + }; + return observe; +}); +/*can@2.2.6#compute/proto_compute*/ +define('can/compute/proto_compute', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/compute/read', + 'can/compute/get_value_and_bind', + 'can/util/batch/batch' +], function (can, bind, read, getValueAndBind) { + var updateOnChange = function (compute, newValue, oldValue, batchNum) { + if (newValue !== oldValue) { + can.batch.trigger(compute, batchNum ? { + type: 'change', + batchNum: batchNum + } : 'change', [ + newValue, + oldValue + ]); + } + }; + var setupComputeHandlers = function (compute, func, context, singleBind) { + var readInfo, onchanged, batchNum; + singleBind = false; + return { + on: function (updater) { + var self = this; + if (!onchanged) { + onchanged = function (ev) { + if (readInfo.ready && compute.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + if (singleBind) { + newValue = func.call(context); + readInfo.value = newValue; + } else { + readInfo = getValueAndBind(func, context, readInfo, onchanged); + newValue = readInfo.value; + } + self.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }; + } + readInfo = getValueAndBind(func, context, { observed: {} }, onchanged); + if (singleBind) { + func = can.__notObserve(func); + } + compute.value = readInfo.value; + compute.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function (updater) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, onchanged); + } + } + }; + }; + var k = function () { + }; + var updater = function (newVal, oldVal, batchNum) { + this.value = newVal; + updateOnChange(this, newVal, oldVal, batchNum); + }, asyncGet = function (fn, context, lastSetValue) { + return function () { + return fn.call(context, lastSetValue.get()); + }; + }, asyncUpdater = function (context, oldUpdater) { + return function (newVal) { + if (newVal !== undefined) { + oldUpdater(newVal, context.value); + } + }; + }; + can.Compute = function (getterSetter, context, eventName, bindOnce) { + var args = []; + for (var i = 0, arglen = arguments.length; i < arglen; i++) { + args[i] = arguments[i]; + } + var contextType = typeof args[1]; + if (typeof args[0] === 'function') { + this._setupGetterSetterFn(args[0], args[1], args[2], args[3]); + } else if (args[1]) { + if (contextType === 'string') { + this._setupContextString(args[0], args[1], args[2]); + } else if (contextType === 'function') { + this._setupContextFunction(args[0], args[1], args[2]); + } else { + if (args[1] && args[1].fn) { + this._setupAsyncCompute(args[0], args[1]); + } else { + this._setupContextSettings(args[0], args[1]); + } + } + } else { + this._setupInitialValue(args[0]); + } + this._args = args; + this.isComputed = true; + can.cid(this, 'compute'); + }; + can.simpleExtend(can.Compute.prototype, { + _bindsetup: can.__notObserve(function () { + this.bound = true; + this._on(this.updater); + }), + _bindteardown: function () { + this._off(this.updater); + this.bound = false; + }, + bind: can.bindAndSetup, + unbind: can.unbindAndTeardown, + clone: function (context) { + if (context && typeof this._args[0] === 'function') { + this._args[1] = context; + } else if (context) { + this._args[2] = context; + } + return new can.Compute(this._args[0], this._args[1], this._args[2], this._args[3]); + }, + _on: k, + _off: k, + get: function () { + if (can.__isRecordingObserves() && this._canObserve !== false) { + can.__observe(this, 'change'); + if (!this.bound) { + can.Compute.temporarilyBind(this); + } + } + if (this.bound) { + return this.value; + } else { + return this._get(); + } + }, + _get: function () { + return this.value; + }, + set: function (newVal) { + var old = this.value; + var setVal = this._set(newVal, old); + if (this.hasDependencies) { + if (this._setUpdates) { + return this.value; + } + return this._get(); + } + if (setVal === undefined) { + this.value = this._get(); + } else { + this.value = setVal; + } + updateOnChange(this, this.value, old); + return this.value; + }, + _set: function (newVal) { + return this.value = newVal; + }, + updater: updater, + _computeFn: function (newVal) { + if (arguments.length) { + return this.set(newVal); + } + return this.get(); + }, + toFunction: function () { + return can.proxy(this._computeFn, this); + }, + _setupGetterSetterFn: function (getterSetter, context, eventName, bindOnce) { + this._set = can.proxy(getterSetter, context); + this._get = can.proxy(getterSetter, context); + this._canObserve = eventName === false ? false : true; + var handlers = setupComputeHandlers(this, getterSetter, context || this, bindOnce); + this._on = handlers.on; + this._off = handlers.off; + }, + _setupContextString: function (target, propertyName, eventName) { + var isObserve = can.isMapLike(target), self = this, handler = function (ev, newVal, oldVal) { + self.updater(newVal, oldVal, ev.batchNum); + }; + if (isObserve) { + this.hasDependencies = true; + this._get = function () { + return target.attr(propertyName); + }; + this._set = function (val) { + target.attr(propertyName, val); + }; + this._on = function (update) { + target.bind(eventName || propertyName, handler); + this.value = this._get(); + }; + this._off = function () { + return target.unbind(eventName || propertyName, handler); + }; + } else { + this._get = can.proxy(this._get, target); + this._set = can.proxy(this._set, target); + } + }, + _setupContextFunction: function (initialValue, setter, eventName) { + this.value = initialValue; + this._set = setter; + can.simpleExtend(this, eventName); + }, + _setupContextSettings: function (initialValue, settings) { + this.value = initialValue; + this._set = settings.set ? can.proxy(settings.set, settings) : this._set; + this._get = settings.get ? can.proxy(settings.get, settings) : this._get; + if (!settings.__selfUpdater) { + var self = this, oldUpdater = this.updater; + this.updater = function () { + oldUpdater.call(self, self._get(), self.value); + }; + } + this._on = settings.on ? settings.on : this._on; + this._off = settings.off ? settings.off : this._off; + }, + _setupAsyncCompute: function (initialValue, settings) { + this.value = initialValue; + var oldUpdater = can.proxy(this.updater, this), self = this, fn = settings.fn, data; + this.updater = oldUpdater; + var lastSetValue = new can.Compute(initialValue); + this.lastSetValue = lastSetValue; + this._setUpdates = true; + this._set = function (newVal) { + if (newVal === lastSetValue.get()) { + return this.value; + } + return lastSetValue.set(newVal); + }; + this._get = asyncGet(fn, settings.context, lastSetValue); + if (fn.length === 0) { + data = setupComputeHandlers(this, fn, settings.context); + } else if (fn.length === 1) { + data = setupComputeHandlers(this, function () { + return fn.call(settings.context, lastSetValue.get()); + }, settings); + } else { + this.updater = asyncUpdater(this, oldUpdater); + data = setupComputeHandlers(this, function () { + var res = fn.call(settings.context, lastSetValue.get(), function (newVal) { + oldUpdater(newVal, self.value); + }); + return res !== undefined ? res : this.value; + }, settings); + } + this._on = data.on; + this._off = data.off; + }, + _setupInitialValue: function (initialValue) { + this.value = initialValue; + } + }); + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.Compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.Compute.async = function (initialValue, asyncComputer, context) { + return new can.Compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.Compute.read = read; + can.Compute.set = read.write; + can.Compute.truthy = function (compute) { + return new can.Compute(function () { + var res = compute.get(); + if (typeof res === 'function') { + res = res.get(); + } + return !!res; + }); + }; + return can.Compute; +}); +/*can@2.2.6#compute/compute*/ +define('can/compute/compute', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/util/batch/batch', + 'can/compute/proto_compute' +], function (can, bind) { + can.compute = function (getterSetter, context, eventName, bindOnce) { + var internalCompute = new can.Compute(getterSetter, context, eventName, bindOnce); + var compute = function (val) { + if (arguments.length) { + return internalCompute.set(val); + } + return internalCompute.get(); + }; + compute.bind = can.proxy(internalCompute.bind, internalCompute); + compute.unbind = can.proxy(internalCompute.unbind, internalCompute); + compute.isComputed = internalCompute.isComputed; + compute.clone = function (ctx) { + if (typeof getterSetter === 'function') { + context = ctx; + } + return can.compute(getterSetter, context, ctx, bindOnce); + }; + compute.computeInstance = internalCompute; + return compute; + }; + var k = function () { + }; + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.compute.truthy = function (compute) { + return can.compute(function () { + var res = compute(); + if (typeof res === 'function') { + res = res(); + } + return !!res; + }); + }; + can.compute.async = function (initialValue, asyncComputer, context) { + return can.compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.compute.read = can.Compute.read; + can.compute.set = can.Compute.set; + return can.compute; +}); +/*can@2.2.6#observe/observe*/ +define('can/observe/observe', [ + 'can/util/util', + 'can/map/map', + 'can/list/list', + 'can/compute/compute' +], function (can) { + can.Observe = can.Map; + can.Observe.startBatch = can.batch.start; + can.Observe.stopBatch = can.batch.stop; + can.Observe.triggerBatch = can.batch.trigger; + return can; +}); +/*can@2.2.6#view/scope/compute_data*/ +define('can/view/scope/compute_data', [ + 'can/util/util', + 'can/compute/compute', + 'can/compute/get_value_and_bind' +], function (can, compute, getValueAndBind) { + var isFastPath = function (computeData) { + return computeData.reads && computeData.reads.length === 1 && computeData.root instanceof can.Map && !can.isFunction(computeData.root[computeData.reads[0]]); + }; + var getValueAndBindScopeRead = function (scopeRead, scopeReadChanged) { + return getValueAndBind(scopeRead, null, { observed: {} }, scopeReadChanged); + }; + var unbindScopeRead = function (readInfo, scopeReadChanged) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, scopeReadChanged); + } + }; + var getValueAndBindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + var target = computeData.root, prop = computeData.reads[0]; + target.bind(prop, singlePropertyReadChanged); + return { + value: computeData.initialValue, + observed: { something: true } + }; + }; + var unbindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + computeData.root.unbind(computeData.reads[0], singlePropertyReadChanged); + }; + var scopeReader = function (scope, key, options, computeData, newVal) { + if (arguments.length > 4) { + if (computeData.root.isComputed) { + computeData.root(newVal); + } else if (computeData.reads.length) { + var last = computeData.reads.length - 1; + var obj = computeData.reads.length ? can.compute.read(computeData.root, computeData.reads.slice(0, last)).value : computeData.root; + can.compute.set(obj, computeData.reads[last], newVal, options); + } + } else { + if (computeData.root) { + return can.compute.read(computeData.root, computeData.reads, options).value; + } + var data = scope.read(key, options); + computeData.scope = data.scope; + computeData.initialValue = data.value; + computeData.reads = data.reads; + computeData.root = data.rootObserve; + return data.value; + } + }; + return function (scope, key, options) { + options = options || { args: [] }; + var computeData = {}, scopeRead = function (newVal) { + if (arguments.length) { + return scopeReader(scope, key, options, computeData, newVal); + } else { + return scopeReader(scope, key, options, computeData); + } + }, batchNum, readInfo, scopeReadChanged = function (ev) { + if (readInfo.ready && compute.computeInstance.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + readInfo = getValueAndBind(scopeRead, null, readInfo, scopeReadChanged); + newValue = readInfo.value; + compute.computeInstance.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }, singlePropertyReadChanged = function (ev, newVal, oldVal) { + if (typeof newVal !== 'function') { + compute.computeInstance.updater(newVal, oldVal, ev.batchNum); + } else { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + isFastPathBound = false; + compute.computeInstance.updater(readInfo.value, oldVal, ev.batchNum); + } + }, isFastPathBound = false, compute = can.compute(undefined, { + on: function () { + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + if (isFastPath(computeData)) { + var oldReadInfo = readInfo; + readInfo = getValueAndBindSinglePropertyRead(computeData, singlePropertyReadChanged); + unbindScopeRead(oldReadInfo, scopeReadChanged); + isFastPathBound = true; + } + compute.computeInstance.value = readInfo.value; + compute.computeInstance.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function () { + if (isFastPathBound) { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + } else { + unbindScopeRead(readInfo, scopeReadChanged); + } + }, + set: scopeRead, + get: scopeRead, + __selfUpdater: true + }); + computeData.compute = compute; + return computeData; + }; +}); +/*can@2.2.6#view/scope/scope*/ +define('can/view/scope/scope', [ + 'can/util/util', + 'can/view/scope/compute_data', + 'can/construct/construct', + 'can/map/map', + 'can/list/list', + 'can/view/view', + 'can/compute/compute' +], function (can, makeComputeData) { + var escapeReg = /(\\)?\./g, escapeDotReg = /\\\./g, getNames = function (attr) { + var names = [], last = 0; + attr.replace(escapeReg, function (first, second, index) { + if (!second) { + names.push(attr.slice(last, index).replace(escapeDotReg, '.')); + last = index + first.length; + } + }); + names.push(attr.slice(last).replace(escapeDotReg, '.')); + return names; + }; + var Scope = can.Construct.extend({ read: can.compute.read }, { + init: function (context, parent) { + this._context = context; + this._parent = parent; + this.__cache = {}; + }, + attr: can.__notObserve(function (key, value) { + var options = { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }, res = this.read(key, options); + if (arguments.length === 2) { + var lastIndex = key.lastIndexOf('.'), readKey = lastIndex !== -1 ? key.substring(0, lastIndex) : '.', obj = this.read(readKey, options).value; + if (lastIndex !== -1) { + key = key.substring(lastIndex + 1, key.length); + } + can.compute.set(obj, key, value, options); + } + return res.value; + }), + add: function (context) { + if (context !== this._context) { + return new this.constructor(context, this); + } else { + return this; + } + }, + computeData: function (key, options) { + return makeComputeData(this, key, options); + }, + compute: function (key, options) { + return this.computeData(key, options).compute; + }, + read: function (attr, options) { + var stopLookup; + if (attr.substr(0, 2) === './') { + stopLookup = true; + attr = attr.substr(2); + } else if (attr.substr(0, 3) === '../') { + return this._parent.read(attr.substr(3), options); + } else if (attr === '..') { + return { value: this._parent._context }; + } else if (attr === '.' || attr === 'this') { + return { value: this._context }; + } + var names = attr.indexOf('\\.') === -1 ? attr.split('.') : getNames(attr), context, scope = this, defaultObserve, defaultReads = [], defaultPropertyDepth = -1, defaultComputeReadings, defaultScope, currentObserve, currentReads; + while (scope) { + context = scope._context; + if (context !== null && (typeof context === 'object' || typeof context === 'function')) { + var data = can.compute.read(context, names, can.simpleExtend({ + foundObservable: function (observe, nameIndex) { + currentObserve = observe; + currentReads = names.slice(nameIndex); + }, + earlyExit: function (parentValue, nameIndex) { + if (nameIndex > defaultPropertyDepth) { + defaultObserve = currentObserve; + defaultReads = currentReads; + defaultPropertyDepth = nameIndex; + defaultScope = scope; + defaultComputeReadings = can.__clearReading(); + } + }, + executeAnonymousFunctions: true + }, options)); + if (data.value !== undefined) { + return { + scope: scope, + rootObserve: currentObserve, + value: data.value, + reads: currentReads + }; + } + } + can.__clearReading(); + if (!stopLookup) { + scope = scope._parent; + } else { + scope = null; + } + } + if (defaultObserve) { + can.__setReading(defaultComputeReadings); + return { + scope: defaultScope, + rootObserve: defaultObserve, + reads: defaultReads, + value: undefined + }; + } else { + return { + names: names, + value: undefined + }; + } + } + }); + can.view.Scope = Scope; + return Scope; +}); +/*can@2.2.6#view/scanner*/ +define('can/view/scanner', [ + 'can/view/view', + 'can/view/elements', + 'can/view/callbacks/callbacks' +], function (can, elements, viewCallbacks) { + var newLine = /(\r|\n)+/g, notEndTag = /\//, clean = function (content) { + return content.split('\\').join('\\\\').split('\n').join('\\n').split('"').join('\\"').split('\t').join('\\t'); + }, getTag = function (tagName, tokens, i) { + if (tagName) { + return tagName; + } else { + while (i < tokens.length) { + if (tokens[i] === '<' && !notEndTag.test(tokens[i + 1])) { + return elements.reverseTagMap[tokens[i + 1]] || 'span'; + } + i++; + } + } + return ''; + }, bracketNum = function (content) { + return --content.split('{').length - --content.split('}').length; + }, myEval = function (script) { + eval(script); + }, attrReg = /([^\s]+)[\s]*=[\s]*$/, startTxt = 'var ___v1ew = [];', finishTxt = 'return ___v1ew.join(\'\')', put_cmd = '___v1ew.push(\n', insert_cmd = put_cmd, htmlTag = null, quote = null, beforeQuote = null, rescan = null, getAttrName = function () { + var matches = beforeQuote.match(attrReg); + return matches && matches[1]; + }, status = function () { + return quote ? '\'' + getAttrName() + '\'' : htmlTag ? 1 : 0; + }, top = function (stack) { + return stack[stack.length - 1]; + }, Scanner; + can.view.Scanner = Scanner = function (options) { + can.extend(this, { + text: {}, + tokens: [] + }, options); + this.text.options = this.text.options || ''; + this.tokenReg = []; + this.tokenSimple = { + '<': '<', + '>': '>', + '"': '"', + '\'': '\'' + }; + this.tokenComplex = []; + this.tokenMap = {}; + for (var i = 0, token; token = this.tokens[i]; i++) { + if (token[2]) { + this.tokenReg.push(token[2]); + this.tokenComplex.push({ + abbr: token[1], + re: new RegExp(token[2]), + rescan: token[3] + }); + } else { + this.tokenReg.push(token[1]); + this.tokenSimple[token[1]] = token[0]; + } + this.tokenMap[token[0]] = token[1]; + } + this.tokenReg = new RegExp('(' + this.tokenReg.slice(0).concat([ + '<', + '>', + '"', + '\'' + ]).join('|') + ')', 'g'); + }; + Scanner.prototype = { + helpers: [], + scan: function (source, name) { + var tokens = [], last = 0, simple = this.tokenSimple, complex = this.tokenComplex; + source = source.replace(newLine, '\n'); + if (this.transform) { + source = this.transform(source); + } + source.replace(this.tokenReg, function (whole, part) { + var offset = arguments[arguments.length - 2]; + if (offset > last) { + tokens.push(source.substring(last, offset)); + } + if (simple[whole]) { + tokens.push(whole); + } else { + for (var i = 0, token; token = complex[i]; i++) { + if (token.re.test(whole)) { + tokens.push(token.abbr); + if (token.rescan) { + tokens.push(token.rescan(part)); + } + break; + } + } + } + last = offset + part.length; + }); + if (last < source.length) { + tokens.push(source.substr(last)); + } + var content = '', buff = [startTxt + (this.text.start || '')], put = function (content, bonus) { + buff.push(put_cmd, '"', clean(content), '"' + (bonus || '') + ');'); + }, endStack = [], lastToken, startTag = null, magicInTag = false, specialStates = { + attributeHookups: [], + tagHookups: [], + lastTagHookup: '' + }, popTagHookup = function () { + specialStates.lastTagHookup = specialStates.tagHookups.pop() + specialStates.tagHookups.length; + }, tagName = '', tagNames = [], popTagName = false, bracketCount, specialAttribute = false, i = 0, token, tmap = this.tokenMap, attrName; + htmlTag = quote = beforeQuote = null; + for (; (token = tokens[i++]) !== undefined;) { + if (startTag === null) { + switch (token) { + case tmap.left: + case tmap.escapeLeft: + case tmap.returnLeft: + magicInTag = htmlTag && 1; + case tmap.commentLeft: + startTag = token; + if (content.length) { + put(content); + } + content = ''; + break; + case tmap.escapeFull: + magicInTag = htmlTag && 1; + rescan = 1; + startTag = tmap.escapeLeft; + if (content.length) { + put(content); + } + rescan = tokens[i++]; + content = rescan.content || rescan; + if (rescan.before) { + put(rescan.before); + } + tokens.splice(i, 0, tmap.right); + break; + case tmap.commentFull: + break; + case tmap.templateLeft: + content += tmap.left; + break; + case '<': + if (tokens[i].indexOf('!--') !== 0) { + htmlTag = 1; + magicInTag = 0; + } + content += token; + break; + case '>': + htmlTag = 0; + var emptyElement = content.substr(content.length - 1) === '/' || content.substr(content.length - 2) === '--', attrs = ''; + if (specialStates.attributeHookups.length) { + attrs = 'attrs: [\'' + specialStates.attributeHookups.join('\',\'') + '\'], '; + specialStates.attributeHookups = []; + } + if (tagName + specialStates.tagHookups.length !== specialStates.lastTagHookup && tagName === top(specialStates.tagHookups)) { + if (emptyElement) { + content = content.substr(0, content.length - 1); + } + buff.push(put_cmd, '"', clean(content), '"', ',can.view.pending({tagName:\'' + tagName + '\',' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options); + if (emptyElement) { + buff.push('}));'); + content = '/>'; + popTagHookup(); + } else if (tokens[i] === '<' && tokens[i + 1] === '/' + tagName) { + buff.push('}));'); + content = token; + popTagHookup(); + } else { + buff.push(',subtemplate: function(' + this.text.argNames + '){\n' + startTxt + (this.text.start || '')); + content = ''; + } + } else if (magicInTag || !popTagName && elements.tagToContentPropMap[tagNames[tagNames.length - 1]] || attrs) { + var pendingPart = ',can.view.pending({' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options + '}),"'; + if (emptyElement) { + put(content.substr(0, content.length - 1), pendingPart + '/>"'); + } else { + put(content, pendingPart + '>"'); + } + content = ''; + magicInTag = 0; + } else { + content += token; + } + if (emptyElement || popTagName) { + tagNames.pop(); + tagName = tagNames[tagNames.length - 1]; + popTagName = false; + } + specialStates.attributeHookups = []; + break; + case '\'': + case '"': + if (htmlTag) { + if (quote && quote === token) { + quote = null; + var attr = getAttrName(); + if (viewCallbacks.attr(attr)) { + specialStates.attributeHookups.push(attr); + } + if (specialAttribute) { + content += token; + put(content); + buff.push(finishTxt, '}));\n'); + content = ''; + specialAttribute = false; + break; + } + } else if (quote === null) { + quote = token; + beforeQuote = lastToken; + attrName = getAttrName(); + if (tagName === 'img' && attrName === 'src' || attrName === 'style') { + put(content.replace(attrReg, '')); + content = ''; + specialAttribute = true; + buff.push(insert_cmd, 'can.view.txt(2,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt); + put(attrName + '=' + token); + break; + } + } + } + default: + if (lastToken === '<') { + tagName = token.substr(0, 3) === '!--' ? '!--' : token.split(/\s/)[0]; + var isClosingTag = false, cleanedTagName; + if (tagName.indexOf('/') === 0) { + isClosingTag = true; + cleanedTagName = tagName.substr(1); + } + if (isClosingTag) { + if (top(tagNames) === cleanedTagName) { + tagName = cleanedTagName; + popTagName = true; + } + if (top(specialStates.tagHookups) === cleanedTagName) { + put(content.substr(0, content.length - 1)); + buff.push(finishTxt + '}}) );'); + content = '><'; + popTagHookup(); + } + } else { + if (tagName.lastIndexOf('/') === tagName.length - 1) { + tagName = tagName.substr(0, tagName.length - 1); + } + if (tagName !== '!--' && viewCallbacks.tag(tagName)) { + if (tagName === 'content' && elements.tagMap[top(tagNames)]) { + token = token.replace('content', elements.tagMap[top(tagNames)]); + } + specialStates.tagHookups.push(tagName); + } + tagNames.push(tagName); + } + } + content += token; + break; + } + } else { + switch (token) { + case tmap.right: + case tmap.returnRight: + switch (startTag) { + case tmap.left: + bracketCount = bracketNum(content); + if (bracketCount === 1) { + buff.push(insert_cmd, 'can.view.txt(0,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt, content); + endStack.push({ + before: '', + after: finishTxt + '}));\n' + }); + } else { + last = endStack.length && bracketCount === -1 ? endStack.pop() : { after: ';' }; + if (last.before) { + buff.push(last.before); + } + buff.push(content, ';', last.after); + } + break; + case tmap.escapeLeft: + case tmap.returnLeft: + bracketCount = bracketNum(content); + if (bracketCount) { + endStack.push({ + before: finishTxt, + after: '}));\n' + }); + } + var escaped = startTag === tmap.escapeLeft ? 1 : 0, commands = { + insert: insert_cmd, + tagName: getTag(tagName, tokens, i), + status: status(), + specialAttribute: specialAttribute + }; + for (var ii = 0; ii < this.helpers.length; ii++) { + var helper = this.helpers[ii]; + if (helper.name.test(content)) { + content = helper.fn(content, commands); + if (helper.name.source === /^>[\s]*\w*/.source) { + escaped = 0; + } + break; + } + } + if (typeof content === 'object') { + if (content.startTxt && content.end && specialAttribute) { + buff.push(insert_cmd, 'can.view.toStr( ', content.content, '() ) );'); + } else { + if (content.startTxt) { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || (content.escaped != null ? content.escaped : escaped)) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\n'); + } else if (content.startOnlyTxt) { + buff.push(insert_cmd, 'can.view.onlytxt(this,\n'); + } + buff.push(content.content); + if (content.end) { + buff.push('));'); + } + } + } else if (specialAttribute) { + buff.push(insert_cmd, content, ');'); + } else { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || escaped) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\nfunction(){ ' + (this.text.escape || '') + 'return ', content, bracketCount ? startTxt : '}));\n'); + } + if (rescan && rescan.after && rescan.after.length) { + put(rescan.after.length); + rescan = null; + } + break; + } + startTag = null; + content = ''; + break; + case tmap.templateLeft: + content += tmap.left; + break; + default: + content += token; + break; + } + } + lastToken = token; + } + if (content.length) { + put(content); + } + buff.push(';'); + var template = buff.join(''), out = { out: (this.text.outStart || '') + template + ' ' + finishTxt + (this.text.outEnd || '') }; + myEval.call(out, 'this.fn = (function(' + this.text.argNames + '){' + out.out + '});\r\n//# sourceURL=' + name + '.js'); + return out; + } + }; + can.view.pending = function (viewData) { + var hooks = can.view.getHooks(); + return can.view.hook(function (el) { + can.each(hooks, function (fn) { + fn(el); + }); + viewData.templateType = 'legacy'; + if (viewData.tagName) { + viewCallbacks.tagHandler(el, viewData.tagName, viewData); + } + can.each(viewData && viewData.attrs || [], function (attributeName) { + viewData.attributeName = attributeName; + var callback = viewCallbacks.attr(attributeName); + if (callback) { + callback(el, viewData); + } + }); + }); + }; + can.view.tag('content', function (el, tagData) { + return tagData.scope; + }); + can.view.Scanner = Scanner; + return Scanner; +}); +/*can@2.2.6#view/node_lists/node_lists*/ +define('can/view/node_lists/node_lists', [ + 'can/util/util', + 'can/view/elements' +], function (can) { + var canExpando = true; + try { + document.createTextNode('')._ = 0; + } catch (ex) { + canExpando = false; + } + var nodeMap = {}, textNodeMap = {}, expando = 'ejs_' + Math.random(), _id = 0, id = function (node, localMap) { + var _textNodeMap = localMap || textNodeMap; + var id = readId(node, _textNodeMap); + if (id) { + return id; + } else { + if (canExpando || node.nodeType !== 3) { + ++_id; + return node[expando] = (node.nodeName ? 'element_' : 'obj_') + _id; + } else { + ++_id; + _textNodeMap['text_' + _id] = node; + return 'text_' + _id; + } + } + }, readId = function (node, textNodeMap) { + if (canExpando || node.nodeType !== 3) { + return node[expando]; + } else { + for (var textNodeID in textNodeMap) { + if (textNodeMap[textNodeID] === node) { + return textNodeID; + } + } + } + }, splice = [].splice, push = [].push, itemsInChildListTree = function (list) { + var count = 0; + for (var i = 0, len = list.length; i < len; i++) { + var item = list[i]; + if (item.nodeType) { + count++; + } else { + count += itemsInChildListTree(item); + } + } + return count; + }, replacementMap = function (replacements, idMap) { + var map = {}; + for (var i = 0, len = replacements.length; i < len; i++) { + var node = nodeLists.first(replacements[i]); + map[id(node, idMap)] = replacements[i]; + } + return map; + }; + var nodeLists = { + id: id, + update: function (nodeList, newNodes) { + var oldNodes = nodeLists.unregisterChildren(nodeList); + newNodes = can.makeArray(newNodes); + var oldListLength = nodeList.length; + splice.apply(nodeList, [ + 0, + oldListLength + ].concat(newNodes)); + if (nodeList.replacements) { + nodeLists.nestReplacements(nodeList); + } else { + nodeLists.nestList(nodeList); + } + return oldNodes; + }, + nestReplacements: function (list) { + var index = 0, idMap = {}, rMap = replacementMap(list.replacements, idMap), rCount = list.replacements.length; + while (index < list.length && rCount) { + var node = list[index], replacement = rMap[readId(node, idMap)]; + if (replacement) { + list.splice(index, itemsInChildListTree(replacement), replacement); + rCount--; + } + index++; + } + list.replacements = []; + }, + nestList: function (list) { + var index = 0; + while (index < list.length) { + var node = list[index], childNodeList = nodeMap[id(node)]; + if (childNodeList) { + if (childNodeList !== list) { + list.splice(index, itemsInChildListTree(childNodeList), childNodeList); + } + } else { + nodeMap[id(node)] = list; + } + index++; + } + }, + last: function (nodeList) { + var last = nodeList[nodeList.length - 1]; + if (last.nodeType) { + return last; + } else { + return nodeLists.last(last); + } + }, + first: function (nodeList) { + var first = nodeList[0]; + if (first.nodeType) { + return first; + } else { + return nodeLists.first(first); + } + }, + flatten: function (nodeList) { + var items = []; + for (var i = 0; i < nodeList.length; i++) { + var item = nodeList[i]; + if (item.nodeType) { + items.push(item); + } else { + items.push.apply(items, nodeLists.flatten(item)); + } + } + return items; + }, + register: function (nodeList, unregistered, parent) { + nodeList.unregistered = unregistered; + nodeList.parentList = parent; + if (parent === true) { + nodeList.replacements = []; + } else if (parent) { + parent.replacements.push(nodeList); + nodeList.replacements = []; + } else { + nodeLists.nestList(nodeList); + } + return nodeList; + }, + unregisterChildren: function (nodeList) { + var nodes = []; + can.each(nodeList, function (node) { + if (node.nodeType) { + if (!nodeList.replacements) { + delete nodeMap[id(node)]; + } + nodes.push(node); + } else { + push.apply(nodes, nodeLists.unregister(node)); + } + }); + return nodes; + }, + unregister: function (nodeList) { + var nodes = nodeLists.unregisterChildren(nodeList); + if (nodeList.unregistered) { + var unregisteredCallback = nodeList.unregistered; + delete nodeList.unregistered; + delete nodeList.replacements; + unregisteredCallback(); + } + return nodes; + }, + nodeMap: nodeMap + }; + can.view.nodeLists = nodeLists; + return nodeLists; +}); +/*can@2.2.6#view/parser/parser*/ +define('can/view/parser/parser', ['can/view/view'], function (can) { + function makeMap(str) { + var obj = {}, items = str.split(','); + for (var i = 0; i < items.length; i++) { + obj[items[i]] = true; + } + return obj; + } + function handleIntermediate(intermediate, handler) { + for (var i = 0, len = intermediate.length; i < len; i++) { + var item = intermediate[i]; + handler[item.tokenType].apply(handler, item.args); + } + return intermediate; + } + var alphaNumericHU = '-:A-Za-z0-9_', attributeNames = '[a-zA-Z_:][' + alphaNumericHU + ':.]*', spaceEQspace = '\\s*=\\s*', dblQuote2dblQuote = '"((?:\\\\.|[^"])*)"', quote2quote = '\'((?:\\\\.|[^\'])*)\'', attributeEqAndValue = '(?:' + spaceEQspace + '(?:' + '(?:"[^"]*")|(?:\'[^\']*\')|[^>\\s]+))?', matchStash = '\\{\\{[^\\}]*\\}\\}\\}?', stash = '\\{\\{([^\\}]*)\\}\\}\\}?', startTag = new RegExp('^<([' + alphaNumericHU + ']+)' + '(' + '(?:\\s*' + '(?:(?:' + '(?:' + attributeNames + ')?' + attributeEqAndValue + ')|' + '(?:' + matchStash + ')+)' + ')*' + ')\\s*(\\/?)>'), endTag = new RegExp('^<\\/([' + alphaNumericHU + ']+)[^>]*>'), attr = new RegExp('(?:' + '(?:(' + attributeNames + ')|' + stash + ')' + '(?:' + spaceEQspace + '(?:' + '(?:' + dblQuote2dblQuote + ')|(?:' + quote2quote + ')|([^>\\s]+)' + ')' + ')?)', 'g'), mustache = new RegExp(stash, 'g'), txtBreak = /<|\{\{/; + var empty = makeMap('area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed'); + var block = makeMap('a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video'); + var inline = makeMap('abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var'); + var closeSelf = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr'); + var fillAttrs = makeMap('checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected'); + var special = makeMap('script,style'); + var tokenTypes = 'start,end,close,attrStart,attrEnd,attrValue,chars,comment,special,done'.split(','); + var fn = function () { + }; + var HTMLParser = function (html, handler, returnIntermediate) { + if (typeof html === 'object') { + return handleIntermediate(html, handler); + } + var intermediate = []; + handler = handler || {}; + if (returnIntermediate) { + can.each(tokenTypes, function (name) { + var callback = handler[name] || fn; + handler[name] = function () { + if (callback.apply(this, arguments) !== false) { + intermediate.push({ + tokenType: name, + args: can.makeArray(arguments) + }); + } + }; + }); + } + function parseStartTag(tag, tagName, rest, unary) { + tagName = tagName.toLowerCase(); + if (block[tagName]) { + while (stack.last() && inline[stack.last()]) { + parseEndTag('', stack.last()); + } + } + if (closeSelf[tagName] && stack.last() === tagName) { + parseEndTag('', tagName); + } + unary = empty[tagName] || !!unary; + handler.start(tagName, unary); + if (!unary) { + stack.push(tagName); + } + HTMLParser.parseAttrs(rest, handler); + handler.end(tagName, unary); + } + function parseEndTag(tag, tagName) { + var pos; + if (!tagName) { + pos = 0; + } else { + for (pos = stack.length - 1; pos >= 0; pos--) { + if (stack[pos] === tagName) { + break; + } + } + } + if (pos >= 0) { + for (var i = stack.length - 1; i >= pos; i--) { + if (handler.close) { + handler.close(stack[i]); + } + } + stack.length = pos; + } + } + function parseMustache(mustache, inside) { + if (handler.special) { + handler.special(inside); + } + } + var index, chars, match, stack = [], last = html; + stack.last = function () { + return this[this.length - 1]; + }; + while (html) { + chars = true; + if (!stack.last() || !special[stack.last()]) { + if (html.indexOf(''); + if (index >= 0) { + if (handler.comment) { + handler.comment(html.substring(4, index)); + } + html = html.substring(index + 3); + chars = false; + } + } else if (html.indexOf(']*>'), function (all, text) { + text = text.replace(/|/g, '$1$2'); + if (handler.chars) { + handler.chars(text); + } + return ''; + }); + parseEndTag('', stack.last()); + } + if (html === last) { + throw 'Parse Error: ' + html; + } + last = html; + } + parseEndTag(); + handler.done(); + return intermediate; + }; + HTMLParser.parseAttrs = function (rest, handler) { + (rest != null ? rest : '').replace(attr, function (text, name, special, dblQuote, singleQuote, val) { + if (special) { + handler.special(special); + } + if (name || dblQuote || singleQuote || val) { + var value = arguments[3] ? arguments[3] : arguments[4] ? arguments[4] : arguments[5] ? arguments[5] : fillAttrs[name.toLowerCase()] ? name : ''; + handler.attrStart(name || ''); + var last = mustache.lastIndex = 0, res = mustache.exec(value), chars; + while (res) { + chars = value.substring(last, mustache.lastIndex - res[0].length); + if (chars.length) { + handler.attrValue(chars); + } + handler.special(res[1]); + last = mustache.lastIndex; + res = mustache.exec(value); + } + chars = value.substr(last, value.length); + if (chars) { + handler.attrValue(chars); + } + handler.attrEnd(name || ''); + } + }); + }; + can.view.parser = HTMLParser; + return HTMLParser; +}); +/*can@2.2.6#view/live/live*/ +define('can/view/live/live', [ + 'can/util/util', + 'can/view/elements', + 'can/view/view', + 'can/view/node_lists/node_lists', + 'can/view/parser/parser' +], function (can, elements, view, nodeLists, parser) { + elements = elements || can.view.elements; + nodeLists = nodeLists || can.view.NodeLists; + parser = parser || can.view.parser; + var setup = function (el, bind, unbind) { + var tornDown = false, teardown = function () { + if (!tornDown) { + tornDown = true; + unbind(data); + can.unbind.call(el, 'removed', teardown); + } + return true; + }, data = { + teardownCheck: function (parent) { + return parent ? false : teardown(); + } + }; + can.bind.call(el, 'removed', teardown); + bind(data); + return data; + }, listen = function (el, compute, change) { + return setup(el, function () { + compute.bind('change', change); + }, function (data) { + compute.unbind('change', change); + if (data.nodeList) { + nodeLists.unregister(data.nodeList); + } + }); + }, getAttributeParts = function (newVal) { + var attrs = {}, attr; + parser.parseAttrs(newVal, { + attrStart: function (name) { + attrs[name] = ''; + attr = name; + }, + attrValue: function (value) { + attrs[attr] += value; + }, + attrEnd: function () { + } + }); + return attrs; + }, splice = [].splice, isNode = function (obj) { + return obj && obj.nodeType; + }, addTextNodeIfNoChildren = function (frag) { + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + }; + var live = { + list: function (el, compute, render, context, parentNode, nodeList) { + var masterNodeList = nodeList || [el], indexMap = [], afterPreviousEvents = false, isTornDown = false, add = function (ev, items, index) { + if (!afterPreviousEvents) { + return; + } + var frag = document.createDocumentFragment(), newNodeLists = [], newIndicies = []; + can.each(items, function (item, key) { + var itemNodeList = []; + if (nodeList) { + nodeLists.register(itemNodeList, null, true); + } + var itemIndex = can.compute(key + index), itemHTML = render.call(context, item, itemIndex, itemNodeList), gotText = typeof itemHTML === 'string', itemFrag = can.frag(itemHTML); + itemFrag = gotText ? can.view.hookup(itemFrag) : itemFrag; + var childNodes = can.makeArray(itemFrag.childNodes); + if (nodeList) { + nodeLists.update(itemNodeList, childNodes); + newNodeLists.push(itemNodeList); + } else { + newNodeLists.push(nodeLists.register(childNodes)); + } + frag.appendChild(itemFrag); + newIndicies.push(itemIndex); + }); + var masterListIndex = index + 1; + if (!masterNodeList[masterListIndex]) { + elements.after(masterListIndex === 1 ? [text] : [nodeLists.last(masterNodeList[masterListIndex - 1])], frag); + } else { + var el = nodeLists.first(masterNodeList[masterListIndex]); + can.insertBefore(el.parentNode, frag, el); + } + splice.apply(masterNodeList, [ + masterListIndex, + 0 + ].concat(newNodeLists)); + splice.apply(indexMap, [ + index, + 0 + ].concat(newIndicies)); + for (var i = index + newIndicies.length, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + }, remove = function (ev, items, index, duringTeardown, fullTeardown) { + if (!afterPreviousEvents) { + return; + } + if (!duringTeardown && data.teardownCheck(text.parentNode)) { + return; + } + if (index < 0) { + index = indexMap.length + index; + } + var removedMappings = masterNodeList.splice(index + 1, items.length), itemsToRemove = []; + can.each(removedMappings, function (nodeList) { + var nodesToRemove = nodeLists.unregister(nodeList); + [].push.apply(itemsToRemove, nodesToRemove); + }); + indexMap.splice(index, items.length); + for (var i = index, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + if (!fullTeardown) { + can.remove(can.$(itemsToRemove)); + } else { + nodeLists.unregister(masterNodeList); + } + }, move = function (ev, item, newIndex, currentIndex) { + if (!afterPreviousEvents) { + return; + } + newIndex = newIndex + 1; + currentIndex = currentIndex + 1; + var referenceNodeList = masterNodeList[newIndex]; + var movedElements = can.frag(nodeLists.flatten(masterNodeList[currentIndex])); + var referenceElement; + if (currentIndex < newIndex) { + referenceElement = nodeLists.last(referenceNodeList).nextSibling; + } else { + referenceElement = nodeLists.first(referenceNodeList); + } + var parentNode = masterNodeList[0].parentNode; + parentNode.insertBefore(movedElements, referenceElement); + var temp = masterNodeList[currentIndex]; + [].splice.apply(masterNodeList, [ + currentIndex, + 1 + ]); + [].splice.apply(masterNodeList, [ + newIndex, + 0, + temp + ]); + }, text = document.createTextNode(''), list, teardownList = function (fullTeardown) { + if (list && list.unbind) { + list.unbind('add', add).unbind('remove', remove).unbind('move', move); + } + remove({}, { length: masterNodeList.length - 1 }, 0, true, fullTeardown); + }, updateList = function (ev, newList, oldList) { + if (isTornDown) { + return; + } + teardownList(); + list = newList || []; + if (list.bind) { + list.bind('add', add).bind('remove', remove).bind('move', move); + } + afterPreviousEvents = true; + add({}, list, 0); + afterPreviousEvents = false; + can.batch.afterPreviousEvents(function () { + afterPreviousEvents = true; + }); + }; + parentNode = elements.getParentNode(el, parentNode); + var data = setup(parentNode, function () { + if (can.isFunction(compute)) { + compute.bind('change', updateList); + } + }, function () { + if (can.isFunction(compute)) { + compute.unbind('change', updateList); + } + teardownList(true); + }); + if (!nodeList) { + live.replace(masterNodeList, text, data.teardownCheck); + } else { + elements.replace(masterNodeList, text); + nodeLists.update(masterNodeList, [text]); + nodeList.unregistered = function () { + data.teardownCheck(); + isTornDown = true; + }; + } + updateList({}, can.isFunction(compute) ? compute() : compute); + }, + html: function (el, compute, parentNode, nodeList) { + var data; + parentNode = elements.getParentNode(el, parentNode); + data = listen(parentNode, compute, function (ev, newVal, oldVal) { + var attached = nodeLists.first(nodes).parentNode; + if (attached) { + makeAndPut(newVal); + } + data.teardownCheck(nodeLists.first(nodes).parentNode); + }); + var nodes = nodeList || [el], makeAndPut = function (val) { + var isFunction = typeof val === 'function', aNode = isNode(val), frag = can.frag(isFunction ? '' : val), oldNodes = can.makeArray(nodes); + addTextNodeIfNoChildren(frag); + if (!aNode && !isFunction) { + frag = can.view.hookup(frag, parentNode); + } + oldNodes = nodeLists.update(nodes, frag.childNodes); + if (isFunction) { + val(frag.childNodes[0]); + } + elements.replace(oldNodes, frag); + }; + data.nodeList = nodes; + if (!nodeList) { + nodeLists.register(nodes, data.teardownCheck); + } else { + nodeList.unregistered = data.teardownCheck; + } + makeAndPut(compute()); + }, + replace: function (nodes, val, teardown) { + var oldNodes = nodes.slice(0), frag = can.frag(val); + nodeLists.register(nodes, teardown); + if (typeof val === 'string') { + frag = can.view.hookup(frag, nodes[0].parentNode); + } + nodeLists.update(nodes, frag.childNodes); + elements.replace(oldNodes, frag); + return nodes; + }, + text: function (el, compute, parentNode, nodeList) { + var parent = elements.getParentNode(el, parentNode); + var data = listen(parent, compute, function (ev, newVal, oldVal) { + if (typeof node.nodeValue !== 'unknown') { + node.nodeValue = can.view.toStr(newVal); + } + data.teardownCheck(node.parentNode); + }); + var node = document.createTextNode(can.view.toStr(compute())); + if (nodeList) { + nodeList.unregistered = data.teardownCheck; + data.nodeList = nodeList; + nodeLists.update(nodeList, [node]); + elements.replace([el], node); + } else { + data.nodeList = live.replace([el], node, data.teardownCheck); + } + }, + setAttributes: function (el, newVal) { + var attrs = getAttributeParts(newVal); + for (var name in attrs) { + can.attr.set(el, name, attrs[name]); + } + }, + attributes: function (el, compute, currentValue) { + var oldAttrs = {}; + var setAttrs = function (newVal) { + var newAttrs = getAttributeParts(newVal), name; + for (name in newAttrs) { + var newValue = newAttrs[name], oldValue = oldAttrs[name]; + if (newValue !== oldValue) { + can.attr.set(el, name, newValue); + } + delete oldAttrs[name]; + } + for (name in oldAttrs) { + elements.removeAttr(el, name); + } + oldAttrs = newAttrs; + }; + listen(el, compute, function (ev, newVal) { + setAttrs(newVal); + }); + if (arguments.length >= 3) { + oldAttrs = getAttributeParts(currentValue); + } else { + setAttrs(compute()); + } + }, + attributePlaceholder: '__!!__', + attributeReplace: /__!!__/g, + attribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, hook.render()); + }); + var wrapped = can.$(el), hooks; + hooks = can.data(wrapped, 'hooks'); + if (!hooks) { + can.data(wrapped, 'hooks', hooks = {}); + } + var attr = elements.getAttr(el, attributeName), parts = attr.split(live.attributePlaceholder), goodParts = [], hook; + goodParts.push(parts.shift(), parts.join(live.attributePlaceholder)); + if (hooks[attributeName]) { + hooks[attributeName].computes.push(compute); + } else { + hooks[attributeName] = { + render: function () { + var i = 0, newAttr = attr ? attr.replace(live.attributeReplace, function () { + return elements.contentText(hook.computes[i++]()); + }) : elements.contentText(hook.computes[i++]()); + return newAttr; + }, + computes: [compute], + batchNum: undefined + }; + } + hook = hooks[attributeName]; + goodParts.splice(1, 0, compute()); + elements.setAttr(el, attributeName, goodParts.join('')); + }, + specialAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, getValue(newVal)); + }); + elements.setAttr(el, attributeName, getValue(compute())); + }, + simpleAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, newVal); + }); + elements.setAttr(el, attributeName, compute()); + } + }; + live.attr = live.simpleAttribute; + live.attrs = live.attributes; + var newLine = /(\r|\n)+/g; + var getValue = function (val) { + var regexp = /^["'].*["']$/; + val = val.replace(elements.attrReg, '').replace(newLine, ''); + return regexp.test(val) ? val.substr(1, val.length - 2) : val; + }; + can.view.live = live; + return live; +}); +/*can@2.2.6#view/render*/ +define('can/view/render', [ + 'can/view/view', + 'can/view/elements', + 'can/view/live/live', + 'can/util/string/string' +], function (can, elements, live) { + var pendingHookups = [], tagChildren = function (tagName) { + var newTag = elements.tagMap[tagName] || 'span'; + if (newTag === 'span') { + return '@@!!@@'; + } + return '<' + newTag + '>' + tagChildren(newTag) + ''; + }, contentText = function (input, tag) { + if (typeof input === 'string') { + return input; + } + if (!input && input !== 0) { + return ''; + } + var hook = input.hookup && function (el, id) { + input.hookup.call(input, el, id); + } || typeof input === 'function' && input; + if (hook) { + if (tag) { + return '<' + tag + ' ' + can.view.hook(hook) + '>'; + } else { + pendingHookups.push(hook); + } + return ''; + } + return '' + input; + }, contentEscape = function (txt, tag) { + return typeof txt === 'string' || typeof txt === 'number' ? can.esc(txt) : contentText(txt, tag); + }, withinTemplatedSectionWithinAnElement = false, emptyHandler = function () { + }; + var lastHookups; + can.extend(can.view, { + live: live, + setupLists: function () { + var old = can.view.lists, data; + can.view.lists = function (list, renderer) { + data = { + list: list, + renderer: renderer + }; + return Math.random(); + }; + return function () { + can.view.lists = old; + return data; + }; + }, + getHooks: function () { + var hooks = pendingHookups.slice(0); + lastHookups = hooks; + pendingHookups = []; + return hooks; + }, + onlytxt: function (self, func) { + return contentEscape(func.call(self)); + }, + txt: function (escape, tagName, status, self, func) { + var tag = elements.tagMap[tagName] || 'span', setupLiveBinding = false, value, listData, compute, unbind = emptyHandler, attributeName; + if (withinTemplatedSectionWithinAnElement) { + value = func.call(self); + } else { + if (typeof status === 'string' || status === 1) { + withinTemplatedSectionWithinAnElement = true; + } + var listTeardown = can.view.setupLists(); + unbind = function () { + compute.unbind('change', emptyHandler); + }; + compute = can.compute(func, self, false); + compute.bind('change', emptyHandler); + listData = listTeardown(); + value = compute(); + withinTemplatedSectionWithinAnElement = false; + setupLiveBinding = compute.computeInstance.hasDependencies; + } + if (listData) { + unbind(); + return '<' + tag + can.view.hook(function (el, parentNode) { + live.list(el, listData.list, listData.renderer, self, parentNode); + }) + '>'; + } + if (!setupLiveBinding || typeof value === 'function') { + unbind(); + return (withinTemplatedSectionWithinAnElement || escape === 2 || !escape ? contentText : contentEscape)(value, status === 0 && tag); + } + var contentProp = elements.tagToContentPropMap[tagName]; + if (status === 0 && !contentProp) { + return '<' + tag + can.view.hook(escape && typeof value !== 'object' ? function (el, parentNode) { + live.text(el, compute, parentNode); + unbind(); + } : function (el, parentNode) { + live.html(el, compute, parentNode); + unbind(); + }) + '>' + tagChildren(tag) + ''; + } else if (status === 1) { + pendingHookups.push(function (el) { + live.attributes(el, compute, compute()); + unbind(); + }); + return compute(); + } else if (escape === 2) { + attributeName = status; + pendingHookups.push(function (el) { + live.specialAttribute(el, attributeName, compute); + unbind(); + }); + return compute(); + } else { + attributeName = status === 0 ? contentProp : status; + (status === 0 ? lastHookups : pendingHookups).push(function (el) { + live.attribute(el, attributeName, compute); + unbind(); + }); + return live.attributePlaceholder; + } + } + }); + return can; +}); +/*can@2.2.6#view/stache/utils*/ +define('can/view/stache/utils', ['can/util/util'], function () { + return { + isArrayLike: function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, + isObserveLike: function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, + emptyHandler: function () { + }, + jsonParse: function (str) { + if (str[0] === '\'') { + return str.substr(1, str.length - 2); + } else if (str === 'undefined') { + return undefined; + } else if (can.global.JSON) { + return JSON.parse(str); + } else { + return eval('(' + str + ')'); + } + }, + mixins: { + last: function () { + return this.stack[this.stack.length - 1]; + }, + add: function (chars) { + this.last().add(chars); + }, + subSectionDepth: function () { + return this.stack.length - 1; + } + } + }; +}); +/*can@2.2.6#view/stache/mustache_helpers*/ +define('can/view/stache/mustache_helpers', [ + 'can/util/util', + 'can/view/stache/utils', + 'can/view/live/live' +], function (can, utils, live) { + live = live || can.view.live; + var resolve = function (value) { + if (utils.isObserveLike(value) && utils.isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + var helpers = { + 'each': function (items, options) { + var resolved = resolve(items), result = [], keys, key, i; + if (resolved instanceof can.List) { + return function (el) { + var nodeList = [el]; + nodeList.expression = 'live.list'; + can.view.nodeLists.register(nodeList, null, options.nodeList); + can.view.nodeLists.update(options.nodeList, [el]); + var cb = function (item, index, parentNodeList) { + return options.fn(options.scope.add({ '@index': index }).add(item), options.options, parentNodeList); + }; + live.list(el, items, cb, options.context, el.parentNode, nodeList); + }; + } + var expr = resolved; + if (!!expr && utils.isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + } else if (utils.isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } + return result; + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + }, + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!resolve(expr); + } + if (value) { + return options.fn(options.scope || this); + } else { + return options.inverse(options.scope || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return helpers.is.apply(this, arguments); + }, + 'unless': function (expr, options) { + return helpers['if'].apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'with': function (expr, options) { + var ctx = expr; + expr = resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + 'data': function (attr) { + var data = arguments.length === 2 ? this : arguments[1]; + return function (el) { + can.data(can.$(el), attr, data || this.context); + }; + } + }; + return { + registerHelper: function (name, callback) { + helpers[name] = callback; + }, + getHelper: function (name, options) { + var helper = options.attr('helpers.' + name); + if (!helper) { + helper = helpers[name]; + } + if (helper) { + return { fn: helper }; + } + } + }; +}); +/*can@2.2.6#view/stache/mustache_core*/ +define('can/view/stache/mustache_core', [ + 'can/util/util', + 'can/view/stache/utils', + 'can/view/stache/mustache_helpers', + 'can/view/live/live', + 'can/view/elements', + 'can/view/scope/scope', + 'can/view/node_lists/node_lists' +], function (can, utils, mustacheHelpers, live, elements, Scope, nodeLists) { + live = live || can.view.live; + elements = elements || can.view.elements; + Scope = Scope || can.view.Scope; + nodeLists = nodeLists || can.view.nodeLists; + var argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(?:(.+?)=(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(.+))))$/, mustacheLineBreakRegExp = /(?:(?:^|(\r?)\n)(\s*)(\{\{([^\}]*)\}\}\}?)([^\S\n\r]*)($|\r?\n))|(\{\{([^\}]*)\}\}\}?)/g, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, getItemsFragContent = function (items, isObserveList, helperOptions, options) { + var frag = document.createDocumentFragment(); + for (var i = 0, len = items.length; i < len; i++) { + append(frag, helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options)); + } + return frag; + }, append = function (frag, content) { + if (content) { + frag.appendChild(typeof content === 'string' ? document.createTextNode(content) : content); + } + }, getItemsStringContent = function (items, isObserveList, helperOptions, options) { + var txt = ''; + for (var i = 0, len = items.length; i < len; i++) { + txt += helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options); + } + return txt; + }, getKeyComputeData = function (key, scope, isArgument) { + var data = scope.computeData(key, { + isArgument: isArgument, + args: [ + scope.attr('.'), + scope + ] + }); + can.compute.temporarilyBind(data.compute); + return data; + }, getKeyArgValue = function (key, scope) { + var data = getKeyComputeData(key, scope, true); + if (!data.compute.computeInstance.hasDependencies) { + return data.initialValue; + } else { + return data.compute; + } + }, convertToScopes = function (helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer) { + if (truthyRenderer) { + helperOptions.fn = makeRendererConvertScopes(truthyRenderer, scope, options, nodeList); + } + if (falseyRenderer) { + helperOptions.inverse = makeRendererConvertScopes(falseyRenderer, scope, options, nodeList); + } + }, makeRendererConvertScopes = function (renderer, parentScope, parentOptions, nodeList) { + var rendererWithScope = function (ctx, opts, parentNodeList) { + return renderer(ctx || parentScope, opts, parentNodeList); + }; + return can.__notObserve(function (newScope, newOptions, parentNodeList) { + if (newScope !== undefined && !(newScope instanceof can.view.Scope)) { + newScope = parentScope.add(newScope); + } + if (newOptions !== undefined && !(newOptions instanceof core.Options)) { + newOptions = parentOptions.add(newOptions); + } + var result = rendererWithScope(newScope, newOptions || parentOptions, parentNodeList || nodeList); + return result; + }); + }; + var core = { + expressionData: function (expression) { + var args = [], hashes = {}, i = 0; + (can.trim(expression) + ' ').replace(argumentsRegExp, function (whole, arg) { + var m; + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[1] || m[2]) { + args.push(utils.jsonParse(m[1] || m[2])); + } else { + hashes[m[3]] = m[6] ? { get: m[6] } : utils.jsonParse(m[4] || m[5]); + } + } else { + args.push({ get: arg }); + } + i++; + }); + return { + name: args.shift(), + args: args, + hash: hashes + }; + }, + makeEvaluator: function (scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, stringOnly) { + var args = [], hash = {}, helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, context = scope.attr('.'), name = exprData.name, helper, looksLikeAHelper = exprData.args.length || !can.isEmptyObject(exprData.hash), initialValue, helperEvaluator; + for (var i = 0, len = exprData.args.length; i < len; i++) { + var arg = exprData.args[i]; + if (arg && isLookup(arg)) { + args.push(getKeyArgValue(arg.get, scope, true)); + } else { + args.push(arg); + } + } + for (var prop in exprData.hash) { + if (isLookup(exprData.hash[prop])) { + hash[prop] = getKeyArgValue(exprData.hash[prop].get, scope); + } else { + hash[prop] = exprData.hash[prop]; + } + } + if (isLookup(name)) { + if (looksLikeAHelper) { + helper = mustacheHelpers.getHelper(name.get, options); + if (!helper && typeof context[name.get] === 'function') { + helper = { fn: context[name.get] }; + } + } + if (!helper) { + var get = name.get; + var computeData = getKeyComputeData(name.get, scope, false), compute = computeData.compute; + initialValue = computeData.initialValue; + if (computeData.compute.computeInstance.hasDependencies) { + name = compute; + } else { + name = initialValue; + } + if (!looksLikeAHelper && initialValue === undefined) { + helper = mustacheHelpers.getHelper(get, options); + } else if (typeof initialValue === 'function') { + helper = { fn: initialValue }; + } + } + if (!helper && initialValue === undefined) { + if (looksLikeAHelper) { + can.dev.warn('can/view/stache/mustache_core.js: Unable to find helper "' + exprData.name.get + '".'); + } else { + can.dev.warn('can/view/stache/mustache_core.js: Unable to find key or helper "' + exprData.name.get + '".'); + } + } + } + if (mode === '^') { + var temp = truthyRenderer; + truthyRenderer = falseyRenderer; + falseyRenderer = temp; + } + if (helper) { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + can.simpleExtend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash, + nodeList: nodeList, + exprData: exprData + }); + args.push(helperOptions); + helperEvaluator = function () { + return helper.fn.apply(context, args) || ''; + }; + helperEvaluator.bindOnce = false; + return helperEvaluator; + } + if (!mode) { + if (name && name.isComputed) { + return name; + } else { + return function () { + return '' + (name != null ? name : ''); + }; + } + } else if (mode === '#' || mode === '^') { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + var evaluator = function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + if (utils.isArrayLike(value)) { + var isObserveList = utils.isObserveLike(value); + if (isObserveList ? value.attr('length') : value.length) { + return (stringOnly ? getItemsStringContent : getItemsFragContent)(value, isObserveList, helperOptions, options); + } else { + return helperOptions.inverse(scope, options); + } + } else { + return value ? helperOptions.fn(value || scope, options) : helperOptions.inverse(scope, options); + } + }; + evaluator.bindOnce = false; + return evaluator; + } else { + } + }, + makeLiveBindingPartialRenderer: function (partialName, state) { + partialName = can.trim(partialName); + return function (scope, options, parentSectionNodeList) { + var nodeList = [this]; + nodeList.expression = '>' + partialName; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var partialFrag = can.compute(function () { + var localPartialName = partialName; + var partial = options.attr('partials.' + localPartialName), res; + if (partial) { + res = partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + var scopePartialName = scope.read(localPartialName, { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }).value; + if (scopePartialName) { + localPartialName = scopePartialName; + } + res = can.view.render(localPartialName, scope, options); + } + return can.frag(res); + }); + live.html(this, partialFrag, this.parentNode, nodeList); + }; + }, + makeStringBranchRenderer: function (mode, expression) { + var exprData = expressionData(expression), fullExpression = mode + expression; + return function branchRenderer(scope, options, truthyRenderer, falseyRenderer) { + var evaluator = scope.__cache[fullExpression]; + if (mode || !evaluator) { + evaluator = makeEvaluator(scope, options, null, mode, exprData, truthyRenderer, falseyRenderer, true); + if (!mode) { + scope.__cache[fullExpression] = evaluator; + } + } + var res = evaluator(); + return res == null ? '' : '' + res; + }; + }, + makeLiveBindingBranchRenderer: function (mode, expression, state) { + var exprData = expressionData(expression); + return function branchRenderer(scope, options, parentSectionNodeList, truthyRenderer, falseyRenderer) { + var nodeList = [this]; + nodeList.expression = expression; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var evaluator = makeEvaluator(scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, state.tag); + var compute = can.compute(evaluator, null, false, evaluator.bindOnce === false ? false : true); + compute.bind('change', can.k); + var value = compute(); + if (typeof value === 'function') { + var old = can.__clearReading(); + value(this); + can.__setReading(old); + } else if (compute.computeInstance.hasDependencies) { + if (state.attr) { + live.simpleAttribute(this, state.attr, compute); + } else if (state.tag) { + live.attributes(this, compute); + } else if (state.text && typeof value !== 'object') { + live.text(this, compute, this.parentNode, nodeList); + } else { + live.html(this, compute, this.parentNode, nodeList); + } + } else { + if (state.attr) { + can.attr.set(this, state.attr, value); + } else if (state.tag) { + live.setAttributes(this, value); + } else if (state.text && typeof value === 'string') { + this.nodeValue = value; + } else if (value) { + elements.replace([this], can.frag(value)); + } + } + compute.unbind('change', can.k); + }; + }, + splitModeFromExpression: function (expression, state) { + expression = can.trim(expression); + var mode = expression.charAt(0); + if ('#/{&^>!'.indexOf(mode) >= 0) { + expression = can.trim(expression.substr(1)); + } else { + mode = null; + } + if (mode === '{' && state.node) { + mode = null; + } + return { + mode: mode, + expression: expression + }; + }, + cleanLineEndings: function (template) { + return template.replace(mustacheLineBreakRegExp, function (whole, returnBefore, spaceBefore, special, expression, spaceAfter, returnAfter, spaceLessSpecial, spaceLessExpression, matchIndex) { + spaceAfter = spaceAfter || ''; + returnBefore = returnBefore || ''; + spaceBefore = spaceBefore || ''; + var modeAndExpression = splitModeFromExpression(expression || spaceLessExpression, {}); + if (spaceLessSpecial || '>{'.indexOf(modeAndExpression.mode) >= 0) { + return whole; + } else if ('^#!/'.indexOf(modeAndExpression.mode) >= 0) { + return special + (matchIndex !== 0 && returnAfter.length ? returnBefore + '\n' : ''); + } else { + return spaceBefore + special + spaceAfter + (spaceBefore.length || matchIndex !== 0 ? returnBefore + '\n' : ''); + } + }); + }, + Options: can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }) + }; + var makeEvaluator = core.makeEvaluator, expressionData = core.expressionData, splitModeFromExpression = core.splitModeFromExpression; + return core; +}); +/*can@2.2.6#view/bindings/bindings*/ +define('can/view/bindings/bindings', [ + 'can/util/util', + 'can/view/stache/mustache_core', + 'can/view/callbacks/callbacks', + 'can/control/control', + 'can/view/scope/scope' +], function (can, mustacheCore) { + var isContentEditable = function () { + var values = { + '': true, + 'true': true, + 'false': false + }; + var editable = function (el) { + if (!el || !el.getAttribute) { + return; + } + var attr = el.getAttribute('contenteditable'); + return values[attr]; + }; + return function (el) { + var val = editable(el); + if (typeof val === 'boolean') { + return val; + } else { + return !!editable(el.parentNode); + } + }; + }(), removeCurly = function (value) { + if (value[0] === '{' && value[value.length - 1] === '}') { + return value.substr(1, value.length - 2); + } + return value; + }; + can.view.attr('can-value', function (el, data) { + var attr = can.trim(removeCurly(el.getAttribute('can-value'))), value = data.scope.computeData(attr, { args: [] }).compute, trueValue, falseValue; + if (el.nodeName.toLowerCase() === 'input') { + if (el.type === 'checkbox') { + if (can.attr.has(el, 'can-true-value')) { + trueValue = el.getAttribute('can-true-value'); + } else { + trueValue = true; + } + if (can.attr.has(el, 'can-false-value')) { + falseValue = el.getAttribute('can-false-value'); + } else { + falseValue = false; + } + } + if (el.type === 'checkbox' || el.type === 'radio') { + new Checked(el, { + value: value, + trueValue: trueValue, + falseValue: falseValue + }); + return; + } + } + if (el.nodeName.toLowerCase() === 'select' && el.multiple) { + new Multiselect(el, { value: value }); + return; + } + if (isContentEditable(el)) { + new Content(el, { value: value }); + return; + } + new Value(el, { value: value }); + }); + var special = { + enter: function (data, el, original) { + return { + event: 'keyup', + handler: function (ev) { + if (ev.keyCode === 13) { + return original.call(this, ev); + } + } + }; + } + }; + can.view.attr(/can-[\w\.]+/, function (el, data) { + var attributeName = data.attributeName, event = attributeName.substr('can-'.length), handler = function (ev) { + var attrVal = el.getAttribute(attributeName); + if (!attrVal) { + return; + } + var attrInfo = mustacheCore.expressionData(removeCurly(attrVal)); + var scopeData = data.scope.read(attrInfo.name.get, { + returnObserveMethods: true, + isArgument: true, + executeAnonymousFunctions: true + }); + if (!scopeData.value) { + can.dev.warn('can/view/bindings: ' + attributeName + ' couldn\'t find method named ' + attrInfo.name.get, { + element: el, + scope: data.scope + }); + return null; + } + var args = []; + var $el = can.$(this); + var viewModel = can.viewModel($el[0]); + var localScope = data.scope.add({ + '@element': $el, + '@event': ev, + '@viewModel': viewModel, + '@scope': data.scope, + '@context': data.scope._context + }); + if (!can.isEmptyObject(attrInfo.hash)) { + var hash = {}; + can.each(attrInfo.hash, function (val, key) { + if (val && val.hasOwnProperty('get')) { + var s = !val.get.indexOf('@') ? localScope : data.scope; + hash[key] = s.read(val.get, {}).value; + } else { + hash[key] = val; + } + }); + args.unshift(hash); + } + if (attrInfo.args.length) { + var arg; + for (var i = attrInfo.args.length - 1; i >= 0; i--) { + arg = attrInfo.args[i]; + if (arg && arg.hasOwnProperty('get')) { + var s = !arg.get.indexOf('@') ? localScope : data.scope; + args.unshift(s.read(arg.get, {}).value); + } else { + args.unshift(arg); + } + } + } + if (!args.length) { + args = [ + data.scope._context, + $el + ].concat(can.makeArray(arguments)); + } + return scopeData.value.apply(scopeData.parent, args); + }; + if (special[event]) { + var specialData = special[event](data, el, handler); + handler = specialData.handler; + event = specialData.event; + } + can.bind.call(el, event, handler); + }); + var Value = can.Control.extend({ + init: function () { + if (this.element[0].nodeName.toUpperCase() === 'SELECT') { + setTimeout(can.proxy(this.set, this), 1); + } else { + this.set(); + } + }, + '{value} change': 'set', + set: function () { + if (!this.element) { + return; + } + var val = this.options.value(); + this.element[0].value = val == null ? '' : val; + }, + 'change': function () { + if (!this.element) { + return; + } + var el = this.element[0]; + this.options.value(el.value); + var newVal = this.options.value(); + if (el.value !== newVal) { + el.value = newVal; + } + } + }), Checked = can.Control.extend({ + init: function () { + this.isCheckbox = this.element[0].type.toLowerCase() === 'checkbox'; + this.check(); + }, + '{value} change': 'check', + check: function () { + if (this.isCheckbox) { + var value = this.options.value(), trueValue = this.options.trueValue || true; + this.element[0].checked = value == trueValue; + } else { + var setOrRemove = this.options.value() == this.element[0].value ? 'set' : 'remove'; + can.attr[setOrRemove](this.element[0], 'checked', true); + } + }, + 'change': function () { + if (this.isCheckbox) { + this.options.value(this.element[0].checked ? this.options.trueValue : this.options.falseValue); + } else { + if (this.element[0].checked) { + this.options.value(this.element[0].value); + } + } + } + }), Multiselect = Value.extend({ + init: function () { + this.delimiter = ';'; + setTimeout(can.proxy(this.set, this), 1); + }, + set: function () { + var newVal = this.options.value(); + if (typeof newVal === 'string') { + newVal = newVal.split(this.delimiter); + this.isString = true; + } else if (newVal) { + newVal = can.makeArray(newVal); + } + var isSelected = {}; + can.each(newVal, function (val) { + isSelected[val] = true; + }); + can.each(this.element[0].childNodes, function (option) { + if (option.value) { + option.selected = !!isSelected[option.value]; + } + }); + }, + get: function () { + var values = [], children = this.element[0].childNodes; + can.each(children, function (child) { + if (child.selected && child.value) { + values.push(child.value); + } + }); + return values; + }, + 'change': function () { + var value = this.get(), currentValue = this.options.value(); + if (this.isString || typeof currentValue === 'string') { + this.isString = true; + this.options.value(value.join(this.delimiter)); + } else if (currentValue instanceof can.List) { + currentValue.attr(value, true); + } else { + this.options.value(value); + } + } + }), Content = can.Control.extend({ + init: function () { + this.set(); + this.on('blur', 'setValue'); + }, + '{value} change': 'set', + set: function () { + var val = this.options.value(); + this.element[0].innerHTML = typeof val === 'undefined' ? '' : val; + }, + setValue: function () { + this.options.value(this.element[0].innerHTML); + } + }); +}); +/*can@2.2.6#view/mustache/mustache*/ +define('can/view/mustache/mustache', [ + 'can/util/util', + 'can/view/scope/scope', + 'can/view/view', + 'can/view/scanner', + 'can/compute/compute', + 'can/view/render', + 'can/view/bindings/bindings' +], function (can) { + can.view.ext = '.mustache'; + var SCOPE = 'scope', HASH = '___h4sh', CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options}', SPECIAL_CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options, special: true}', ARG_NAMES = SCOPE + ',options', argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false|null|undefined)|((.+?)=(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false)|(.+))))$/, makeLookupLiteral = function (type) { + return '{get:"' + type.replace(/"/g, '\\"') + '"}'; + }, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, isObserveLike = function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, isArrayLike = function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, makeConvertToScopes = function (original, scope, options) { + var originalWithScope = function (ctx, opts) { + return original(ctx || scope, opts); + }; + return function (updatedScope, updatedOptions) { + if (updatedScope !== undefined && !(updatedScope instanceof can.view.Scope)) { + updatedScope = scope.add(updatedScope); + } + if (updatedOptions !== undefined && !(updatedOptions instanceof can.view.Options)) { + updatedOptions = options.add(updatedOptions); + } + return originalWithScope(updatedScope, updatedOptions || options); + }; + }; + var Mustache = function (options, helpers) { + if (this.constructor !== Mustache) { + var mustache = new Mustache(options); + return function (data, options) { + return mustache.render(data, options); + }; + } + if (typeof options === 'function') { + this.template = { fn: options }; + return; + } + can.extend(this, options); + this.template = this.scanner.scan(this.text, this.name); + }; + can.Mustache = can.global.Mustache = Mustache; + Mustache.prototype.render = function (data, options) { + if (!(data instanceof can.view.Scope)) { + data = new can.view.Scope(data || {}); + } + if (!(options instanceof can.view.Options)) { + options = new can.view.Options(options || {}); + } + options = options || {}; + return this.template.fn.call(data, data, options); + }; + can.extend(Mustache.prototype, { + scanner: new can.view.Scanner({ + text: { + start: '', + scope: SCOPE, + options: ',options: options', + argNames: ARG_NAMES + }, + tokens: [ + [ + 'returnLeft', + '{{{', + '{{[{&]' + ], + [ + 'commentFull', + '{{!}}', + '^[\\s\\t]*{{!.+?}}\\n' + ], + [ + 'commentLeft', + '{{!', + '(\\n[\\s\\t]*{{!|{{!)' + ], + [ + 'escapeFull', + '{{}}', + '(^[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}$)', + function (content) { + return { + before: /^\n.+?\n$/.test(content) ? '\n' : '', + content: content.match(/\{\{(.+?)\}\}/)[1] || '' + }; + } + ], + [ + 'escapeLeft', + '{{' + ], + [ + 'returnRight', + '}}}' + ], + [ + 'right', + '}}' + ] + ], + helpers: [ + { + name: /^>[\s]*\w*/, + fn: function (content, cmd) { + var templateName = can.trim(content.replace(/^>\s?/, '')).replace(/["|']/g, ''); + return 'can.Mustache.renderPartial(\'' + templateName + '\',' + ARG_NAMES + ')'; + } + }, + { + name: /^\s*data\s/, + fn: function (content, cmd) { + var attr = content.match(/["|'](.*)["|']/)[1]; + return 'can.proxy(function(__){' + 'can.data(can.$(__),\'' + attr + '\', this.attr(\'.\')); }, ' + SCOPE + ')'; + } + }, + { + name: /\s*\(([\$\w]+)\)\s*->([^\n]*)/, + fn: function (content) { + var quickFunc = /\s*\(([\$\w]+)\)\s*->([^\n]*)/, parts = content.match(quickFunc); + return 'can.proxy(function(__){var ' + parts[1] + '=can.$(__);with(' + SCOPE + '.attr(\'.\')){' + parts[2] + '}}, this);'; + } + }, + { + name: /^.*$/, + fn: function (content, cmd) { + var mode = false, result = { + content: '', + startTxt: false, + startOnlyTxt: false, + end: false + }; + content = can.trim(content); + if (content.length && (mode = content.match(/^([#^\/]|else$)/))) { + mode = mode[0]; + switch (mode) { + case '#': + case '^': + if (cmd.specialAttribute) { + result.startOnlyTxt = true; + } else { + result.startTxt = true; + result.escaped = 0; + } + break; + case '/': + result.end = true; + result.content += 'return ___v1ew.join("");}}])'; + return result; + } + content = content.substring(1); + } + if (mode !== 'else') { + var args = [], hashes = [], i = 0, m; + result.content += 'can.Mustache.txt(\n' + (cmd.specialAttribute ? SPECIAL_CONTEXT_OBJ : CONTEXT_OBJ) + ',\n' + (mode ? '"' + mode + '"' : 'null') + ','; + (can.trim(content) + ' ').replace(argumentsRegExp, function (whole, arg) { + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[2]) { + args.push(m[0]); + } else { + hashes.push(m[4] + ':' + (m[6] ? m[6] : makeLookupLiteral(m[5]))); + } + } else { + args.push(makeLookupLiteral(arg)); + } + i++; + }); + result.content += args.join(','); + if (hashes.length) { + result.content += ',{' + HASH + ':{' + hashes.join(',') + '}}'; + } + } + if (mode && mode !== 'else') { + result.content += ',[\n\n'; + } + switch (mode) { + case '^': + case '#': + result.content += '{fn:function(' + ARG_NAMES + '){var ___v1ew = [];'; + break; + case 'else': + result.content += 'return ___v1ew.join("");}},\n{inverse:function(' + ARG_NAMES + '){\nvar ___v1ew = [];'; + break; + default: + result.content += ')'; + break; + } + if (!mode) { + result.startTxt = true; + result.end = true; + } + return result; + } + } + ] + }) + }); + var helpers = can.view.Scanner.prototype.helpers; + for (var i = 0; i < helpers.length; i++) { + Mustache.prototype.scanner.helpers.unshift(helpers[i]); + } + Mustache.txt = function (scopeAndOptions, mode, name) { + var scope = scopeAndOptions.scope, options = scopeAndOptions.options, args = [], helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, hash, context = scope.attr('.'), getHelper = true, helper; + for (var i = 3; i < arguments.length; i++) { + var arg = arguments[i]; + if (mode && can.isArray(arg)) { + helperOptions = can.extend.apply(can, [helperOptions].concat(arg)); + } else if (arg && arg[HASH]) { + hash = arg[HASH]; + for (var prop in hash) { + if (isLookup(hash[prop])) { + hash[prop] = Mustache.get(hash[prop].get, scopeAndOptions, false, true); + } + } + } else if (arg && isLookup(arg)) { + args.push(Mustache.get(arg.get, scopeAndOptions, false, true, true)); + } else { + args.push(arg); + } + } + if (isLookup(name)) { + var get = name.get; + name = Mustache.get(name.get, scopeAndOptions, args.length, false); + getHelper = get === name; + } + helperOptions.fn = makeConvertToScopes(helperOptions.fn, scope, options); + helperOptions.inverse = makeConvertToScopes(helperOptions.inverse, scope, options); + if (mode === '^') { + var tmp = helperOptions.fn; + helperOptions.fn = helperOptions.inverse; + helperOptions.inverse = tmp; + } + if (helper = getHelper && (typeof name === 'string' && Mustache.getHelper(name, options)) || can.isFunction(name) && !name.isComputed && { fn: name }) { + can.extend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash + }); + args.push(helperOptions); + return function () { + return helper.fn.apply(context, args) || ''; + }; + } + return function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + var validArgs = args.length ? args : [value], valid = true, result = [], i, argIsObserve, arg; + if (mode) { + for (i = 0; i < validArgs.length; i++) { + arg = validArgs[i]; + argIsObserve = typeof arg !== 'undefined' && isObserveLike(arg); + if (isArrayLike(arg)) { + if (mode === '#') { + valid = valid && !!(argIsObserve ? arg.attr('length') : arg.length); + } else if (mode === '^') { + valid = valid && !(argIsObserve ? arg.attr('length') : arg.length); + } + } else { + valid = mode === '#' ? valid && !!arg : mode === '^' ? valid && !arg : valid; + } + } + } + if (valid) { + if (mode === '#') { + if (isArrayLike(value)) { + var isObserveList = isObserveLike(value); + for (i = 0; i < value.length; i++) { + result.push(helperOptions.fn(isObserveList ? value.attr('' + i) : value[i])); + } + return result.join(''); + } else { + return helperOptions.fn(value || {}) || ''; + } + } else if (mode === '^') { + return helperOptions.inverse(value || {}) || ''; + } else { + return '' + (value != null ? value : ''); + } + } + return ''; + }; + }; + Mustache.get = function (key, scopeAndOptions, isHelper, isArgument, isLookup) { + var context = scopeAndOptions.scope.attr('.'), options = scopeAndOptions.options || {}; + if (isHelper) { + if (Mustache.getHelper(key, options)) { + return key; + } + if (scopeAndOptions.scope && can.isFunction(context[key])) { + return context[key]; + } + can.dev.warn('can/view/mustache/mustache.js: Unable to find helper "' + key + '".'); + } + var computeData = scopeAndOptions.scope.computeData(key, { + isArgument: isArgument, + args: [ + context, + scopeAndOptions.scope + ] + }), compute = computeData.compute; + can.compute.temporarilyBind(compute); + var initialValue = computeData.initialValue, helperObj = Mustache.getHelper(key, options); + if (initialValue === undefined && !isHelper && !helperObj) { + can.dev.warn('can/view/mustache/mustache.js: Unable to find key "' + key + '".'); + } + if (!isLookup && (initialValue === undefined || computeData.scope !== scopeAndOptions.scope) && Mustache.getHelper(key, options)) { + return key; + } + if (!compute.computeInstance.hasDependencies) { + return initialValue; + } else { + return compute; + } + }; + Mustache.resolve = function (value) { + if (isObserveLike(value) && isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + can.view.Options = can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }); + Mustache._helpers = {}; + Mustache.registerHelper = function (name, fn) { + this._helpers[name] = { + name: name, + fn: fn + }; + }; + Mustache.getHelper = function (name, options) { + var helper; + if (options) { + helper = options.attr('helpers.' + name); + } + return helper ? { fn: helper } : this._helpers[name]; + }; + Mustache.render = function (partial, scope, options) { + if (!can.view.cached[partial]) { + var reads = can.__clearReading(); + var scopePartialName = scope.attr(partial); + if (scopePartialName) { + partial = scopePartialName; + } + can.__setReading(reads); + } + return can.view.render(partial, scope, options); + }; + Mustache.safeString = function (str) { + return { + toString: function () { + return str; + } + }; + }; + Mustache.renderPartial = function (partialName, scope, options) { + var partial = options.attr('partials.' + partialName); + if (partial) { + return partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + return can.Mustache.render(partialName, scope, options); + } + }; + can.each({ + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!Mustache.resolve(expr); + } + if (value) { + return options.fn(options.contexts || this); + } else { + return options.inverse(options.contexts || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = Mustache.resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return Mustache._helpers.is.fn.apply(this, arguments); + }, + 'unless': function (expr, options) { + return Mustache._helpers['if'].fn.apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'each': function (expr, options) { + var resolved = Mustache.resolve(expr), result = [], keys, key, i; + if (can.view.lists && (resolved instanceof can.List || expr && expr.isComputed && resolved === undefined)) { + return can.view.lists(expr, function (item, index) { + return options.fn(options.scope.add({ '@index': index }).add(item)); + }); + } + expr = resolved; + if (!!expr && isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + return result.join(''); + } else if (isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } + }, + 'with': function (expr, options) { + var ctx = expr; + expr = Mustache.resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + } + }, function (fn, name) { + Mustache.registerHelper(name, fn); + }); + can.view.register({ + suffix: 'mustache', + contentType: 'x-mustache-template', + script: function (id, src) { + return 'can.Mustache(function(' + ARG_NAMES + ') { ' + new Mustache({ + text: src, + name: id + }).template.out + ' })'; + }, + renderer: function (id, text) { + return Mustache({ + text: text, + name: id + }); + } + }); + can.mustache.registerHelper = can.proxy(can.Mustache.registerHelper, can.Mustache); + can.mustache.safeString = can.Mustache.safeString; + return can; +}); +/*can@2.2.6#component/component*/ +define('can/component/component', [ + 'can/util/util', + 'can/view/callbacks/callbacks', + 'can/view/elements', + 'can/control/control', + 'can/observe/observe', + 'can/view/mustache/mustache', + 'can/view/bindings/bindings' +], function (can, viewCallbacks, elements) { + var ignoreAttributesRegExp = /^(dataViewId|class|id)$/i, paramReplacer = /\{([^\}]+)\}/g; + var Component = can.Component = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Component) { + var self = this, scope = this.prototype.scope || this.prototype.viewModel; + this.Control = ComponentControl.extend(this.prototype.events); + if (!scope || typeof scope === 'object' && !(scope instanceof can.Map)) { + this.Map = can.Map.extend(scope || {}); + } else if (scope.prototype instanceof can.Map) { + this.Map = scope; + } + this.attributeScopeMappings = {}; + can.each(this.Map ? this.Map.defaults : {}, function (val, prop) { + if (val === '@') { + self.attributeScopeMappings[prop] = prop; + } + }); + if (this.prototype.template) { + if (typeof this.prototype.template === 'function') { + var temp = this.prototype.template; + this.renderer = function () { + return can.view.frag(temp.apply(null, arguments)); + }; + } else { + this.renderer = can.view.mustache(this.prototype.template); + } + } + can.view.tag(this.prototype.tag, function (el, options) { + new self(el, options); + }); + } + } + }, { + setup: function (el, hookupOptions) { + var initialScopeData = {}, component = this, lexicalContent = (typeof this.leakScope === 'undefined' ? false : !this.leakScope) && this.template, twoWayBindings = {}, scope = this.scope || this.viewModel, viewModelPropertyUpdates = {}, componentScope, frag, teardownFunctions = [], callTeardownFunctions = function () { + for (var i = 0, len = teardownFunctions.length; i < len; i++) { + teardownFunctions[i](); + } + }; + can.each(this.constructor.attributeScopeMappings, function (val, prop) { + initialScopeData[prop] = el.getAttribute(can.hyphenate(val)); + }); + can.each(can.makeArray(el.attributes), function (node, index) { + var name = can.camelize(node.nodeName.toLowerCase()), value = node.value; + if (ignoreAttributesRegExp.test(name) && value[0] === '{' && value[value.length - 1] === '}') { + can.dev.warn('can/component: looks like you\'re trying to pass ' + name + ' as an attribute into a component, ' + 'but it is not a supported attribute'); + } + if (component.constructor.attributeScopeMappings[name] || ignoreAttributesRegExp.test(name) || viewCallbacks.attr(node.nodeName)) { + return; + } + if (value[0] === '{' && value[value.length - 1] === '}') { + value = value.substr(1, value.length - 2); + } else { + if (hookupOptions.templateType !== 'legacy') { + initialScopeData[name] = value; + return; + } + } + var computeData = hookupOptions.scope.computeData(value, { args: [] }), compute = computeData.compute; + var handler = function (ev, newVal) { + viewModelPropertyUpdates[name] = (viewModelPropertyUpdates[name] || 0) + 1; + componentScope.attr(name, newVal); + can.batch.afterPreviousEvents(function () { + --viewModelPropertyUpdates[name]; + }); + }; + compute.bind('change', handler); + initialScopeData[name] = compute(); + if (!compute.computeInstance.hasDependencies) { + compute.unbind('change', handler); + } else { + teardownFunctions.push(function () { + compute.unbind('change', handler); + }); + twoWayBindings[name] = computeData; + } + }); + if (this.constructor.Map) { + componentScope = new this.constructor.Map(initialScopeData); + } else if (scope instanceof can.Map) { + componentScope = scope; + } else if (can.isFunction(scope)) { + var scopeResult = scope.call(this, initialScopeData, hookupOptions.scope, el); + if (scopeResult instanceof can.Map) { + componentScope = scopeResult; + } else if (scopeResult.prototype instanceof can.Map) { + componentScope = new scopeResult(initialScopeData); + } else { + componentScope = new (can.Map.extend(scopeResult))(initialScopeData); + } + } + var handlers = {}; + can.each(twoWayBindings, function (computeData, prop) { + handlers[prop] = function (ev, newVal) { + if (!viewModelPropertyUpdates[prop]) { + computeData.compute(newVal); + } + }; + componentScope.bind(prop, handlers[prop]); + }); + if (!can.isEmptyObject(this.constructor.attributeScopeMappings) || hookupOptions.templateType !== 'legacy') { + can.bind.call(el, 'attributes', function (ev) { + var camelized = can.camelize(ev.attributeName); + if (!twoWayBindings[camelized] && !ignoreAttributesRegExp.test(camelized)) { + componentScope.attr(camelized, el.getAttribute(ev.attributeName)); + } + }); + } + this.scope = this.viewModel = componentScope; + can.data(can.$(el), 'scope', this.scope); + can.data(can.$(el), 'viewModel', this.scope); + var renderedScope = lexicalContent ? this.scope : hookupOptions.scope.add(this.scope), options = { helpers: {} }; + can.each(this.helpers || {}, function (val, prop) { + if (can.isFunction(val)) { + options.helpers[prop] = function () { + return val.apply(componentScope, arguments); + }; + } + }); + teardownFunctions.push(function () { + can.each(handlers, function (handler, prop) { + componentScope.unbind(prop, handlers[prop]); + }); + }); + this._control = new this.constructor.Control(el, { + scope: this.scope, + viewModel: this.scope + }); + if (this._control && this._control.destroy) { + var oldDestroy = this._control.destroy; + this._control.destroy = function () { + oldDestroy.apply(this, arguments); + callTeardownFunctions(); + }; + this._control.on(); + } else { + can.bind.call(el, 'removed', function () { + callTeardownFunctions(); + }); + } + var nodeList = can.view.nodeLists.register([], undefined, true); + teardownFunctions.push(function () { + can.view.nodeLists.unregister(nodeList); + }); + if (this.constructor.renderer) { + if (!options.tags) { + options.tags = {}; + } + options.tags.content = function contentHookup(el, rendererOptions) { + var subtemplate = hookupOptions.subtemplate || rendererOptions.subtemplate; + if (subtemplate) { + delete options.tags.content; + var opts = !lexicalContent || subtemplate !== hookupOptions.subtemplate ? rendererOptions : hookupOptions; + if (rendererOptions.parentNodeList) { + var frag = subtemplate(opts.scope, opts.options, rendererOptions.parentNodeList); + elements.replace([el], frag); + } else { + can.view.live.replace([el], subtemplate(opts.scope, opts.options)); + } + options.tags.content = contentHookup; + } + }; + frag = this.constructor.renderer(renderedScope, hookupOptions.options.add(options), nodeList); + } else { + if (hookupOptions.templateType === 'legacy') { + frag = can.view.frag(hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options)) : ''); + } else { + frag = hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options), nodeList) : document.createDocumentFragment(); + } + } + can.appendChild(el, frag); + can.view.nodeLists.update(nodeList, el.childNodes); + } + }); + var ComponentControl = can.Control.extend({ + _lookup: function (options) { + return [ + options.scope, + options, + window + ]; + }, + _action: function (methodName, options, controlInstance) { + var hasObjectLookup, readyCompute; + paramReplacer.lastIndex = 0; + hasObjectLookup = paramReplacer.test(methodName); + if (!controlInstance && hasObjectLookup) { + return; + } else if (!hasObjectLookup) { + return can.Control._action.apply(this, arguments); + } else { + readyCompute = can.compute(function () { + var delegate; + var name = methodName.replace(paramReplacer, function (matched, key) { + var value; + if (key === 'scope' || key === 'viewModel') { + delegate = options.scope; + return ''; + } + key = key.replace(/^(scope|^viewModel)\./, ''); + value = can.compute.read(options.scope, key.split('.'), { isArgument: true }).value; + if (value === undefined) { + value = can.getObject(key); + } + if (typeof value === 'string') { + return value; + } else { + delegate = value; + return ''; + } + }); + var parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: this.processors[event] || this.processors.click, + parts: [ + name, + parts.join(' '), + event + ], + delegate: delegate || undefined + }; + }, this); + var handler = function (ev, ready) { + controlInstance._bindings.control[methodName](controlInstance.element); + controlInstance._bindings.control[methodName] = ready.processor(ready.delegate || controlInstance.element, ready.parts[2], ready.parts[1], methodName, controlInstance); + }; + readyCompute.bind('change', handler); + controlInstance._bindings.readyComputes[methodName] = { + compute: readyCompute, + handler: handler + }; + return readyCompute(); + } + } + }, { + setup: function (el, options) { + this.scope = options.scope; + this.viewModel = options.viewModel; + return can.Control.prototype.setup.call(this, el, options); + }, + off: function () { + if (this._bindings) { + can.each(this._bindings.readyComputes || {}, function (value) { + value.compute.unbind('change', value.handler); + }); + } + can.Control.prototype.off.apply(this, arguments); + this._bindings.readyComputes = {}; + } + }); + var $ = can.$; + if ($.fn) { + $.fn.scope = $.fn.viewModel = function () { + return can.viewModel.apply(can, [this].concat(can.makeArray(arguments))); + }; + } + return Component; +}); +/*can@2.2.6#model/model*/ +define('can/model/model', [ + 'can/util/util', + 'can/map/map', + 'can/list/list' +], function (can) { + var pipe = function (def, thisArg, func) { + var d = new can.Deferred(); + def.then(function () { + var args = can.makeArray(arguments), success = true; + try { + args[0] = func.apply(thisArg, args); + } catch (e) { + success = false; + d.rejectWith(d, [e].concat(args)); + } + if (success) { + d.resolveWith(d, args); + } + }, function () { + d.rejectWith(this, arguments); + }); + if (typeof def.abort === 'function') { + d.abort = function () { + return def.abort(); + }; + } + return d; + }, modelNum = 0, getId = function (inst) { + can.__observe(inst, inst.constructor.id); + return inst.__get(inst.constructor.id); + }, ajax = function (ajaxOb, data, type, dataType, success, error) { + var params = {}; + if (typeof ajaxOb === 'string') { + var parts = ajaxOb.split(/\s+/); + params.url = parts.pop(); + if (parts.length) { + params.type = parts.pop(); + } + } else { + can.extend(params, ajaxOb); + } + params.data = typeof data === 'object' && !can.isArray(data) ? can.extend(params.data || {}, data) : data; + params.url = can.sub(params.url, params.data, true); + return can.ajax(can.extend({ + type: type || 'post', + dataType: dataType || 'json', + success: success, + error: error + }, params)); + }, makeRequest = function (modelObj, type, success, error, method) { + var args; + if (can.isArray(modelObj)) { + args = modelObj[1]; + modelObj = modelObj[0]; + } else { + args = modelObj.serialize(); + } + args = [args]; + var deferred, model = modelObj.constructor, jqXHR; + if (type === 'update' || type === 'destroy') { + args.unshift(getId(modelObj)); + } + jqXHR = model[type].apply(model, args); + deferred = pipe(jqXHR, modelObj, function (data) { + modelObj[method || type + 'd'](data, jqXHR); + return modelObj; + }); + if (jqXHR.abort) { + deferred.abort = function () { + jqXHR.abort(); + }; + } + deferred.then(success, error); + return deferred; + }, converters = { + models: function (instancesRawData, oldList, xhr) { + can.Model._reqs++; + if (!instancesRawData) { + return; + } + if (instancesRawData instanceof this.List) { + return instancesRawData; + } + var self = this, tmp = [], ListClass = self.List || ML, modelList = oldList instanceof can.List ? oldList : new ListClass(), rawDataIsList = instancesRawData instanceof ML, raw = rawDataIsList ? instancesRawData.serialize() : instancesRawData; + raw = self.parseModels(raw, xhr); + if (raw.data) { + instancesRawData = raw; + raw = raw.data; + } + if (typeof raw === 'undefined' || !can.isArray(raw)) { + throw new Error('Could not get any raw data while converting using .models'); + } + if (!raw.length) { + can.dev.warn('model.js models has no data.'); + } + if (modelList.length) { + modelList.splice(0); + } + can.each(raw, function (rawPart) { + tmp.push(self.model(rawPart, xhr)); + }); + modelList.push.apply(modelList, tmp); + if (!can.isArray(instancesRawData)) { + can.each(instancesRawData, function (val, prop) { + if (prop !== 'data') { + modelList.attr(prop, val); + } + }); + } + setTimeout(can.proxy(this._clean, this), 1); + return modelList; + }, + model: function (attributes, oldModel, xhr) { + if (!attributes) { + return; + } + if (typeof attributes.serialize === 'function') { + attributes = attributes.serialize(); + } else { + attributes = this.parseModel(attributes, xhr); + } + var id = attributes[this.id]; + if ((id || id === 0) && this.store[id]) { + oldModel = this.store[id]; + } + var model = oldModel && can.isFunction(oldModel.attr) ? oldModel.attr(attributes, this.removeAttr || false) : new this(attributes); + return model; + } + }, makeParser = { + parseModel: function (prop) { + return function (attributes) { + return prop ? can.getObject(prop, attributes) : attributes; + }; + }, + parseModels: function (prop) { + return function (attributes) { + if (can.isArray(attributes)) { + return attributes; + } + prop = prop || 'data'; + var result = can.getObject(prop, attributes); + if (!can.isArray(result)) { + throw new Error('Could not get any raw data while converting using .models'); + } + return result; + }; + } + }, ajaxMethods = { + create: { + url: '_shortName', + type: 'post' + }, + update: { + data: function (id, attrs) { + attrs = attrs || {}; + var identity = this.id; + if (attrs[identity] && attrs[identity] !== id) { + attrs['new' + can.capitalize(id)] = attrs[identity]; + delete attrs[identity]; + } + attrs[identity] = id; + return attrs; + }, + type: 'put' + }, + destroy: { + type: 'delete', + data: function (id, attrs) { + attrs = attrs || {}; + attrs.id = attrs[this.id] = id; + return attrs; + } + }, + findAll: { url: '_shortName' }, + findOne: {} + }, ajaxMaker = function (ajaxMethod, str) { + return function (data) { + data = ajaxMethod.data ? ajaxMethod.data.apply(this, arguments) : data; + return ajax(str || this[ajaxMethod.url || '_url'], data, ajaxMethod.type || 'get'); + }; + }, createURLFromResource = function (model, name) { + if (!model.resource) { + return; + } + var resource = model.resource.replace(/\/+$/, ''); + if (name === 'findAll' || name === 'create') { + return resource; + } else { + return resource + '/{' + model.id + '}'; + } + }; + can.Model = can.Map.extend({ + fullName: 'can.Model', + _reqs: 0, + setup: function (base, fullName, staticProps, protoProps) { + if (typeof fullName !== 'string') { + protoProps = staticProps; + staticProps = fullName; + } + if (!protoProps) { + can.dev.warn('can/model/model.js: can.Model extended without static properties.'); + protoProps = staticProps; + } + this.store = {}; + can.Map.setup.apply(this, arguments); + if (!can.Model) { + return; + } + if (staticProps && staticProps.List) { + this.List = staticProps.List; + this.List.Map = this; + } else { + this.List = base.List.extend({ Map: this }, {}); + } + var self = this, clean = can.proxy(this._clean, self); + can.each(ajaxMethods, function (method, name) { + if (staticProps && staticProps[name] && (typeof staticProps[name] === 'string' || typeof staticProps[name] === 'object')) { + self[name] = ajaxMaker(method, staticProps[name]); + } else if (staticProps && staticProps.resource && !can.isFunction(staticProps[name])) { + self[name] = ajaxMaker(method, createURLFromResource(self, name)); + } + if (self['make' + can.capitalize(name)]) { + var newMethod = self['make' + can.capitalize(name)](self[name]); + can.Construct._overwrite(self, base, name, function () { + can.Model._reqs++; + var def = newMethod.apply(this, arguments); + var then = def.then(clean, clean); + then.abort = def.abort; + return then; + }); + } + }); + var hasCustomConverter = {}; + can.each(converters, function (converter, name) { + var parseName = 'parse' + can.capitalize(name), dataProperty = staticProps && staticProps[name] || self[name]; + if (typeof dataProperty === 'string') { + self[parseName] = dataProperty; + can.Construct._overwrite(self, base, name, converter); + } else if (staticProps && staticProps[name]) { + hasCustomConverter[parseName] = true; + } + }); + can.each(makeParser, function (maker, parseName) { + var prop = staticProps && staticProps[parseName] || self[parseName]; + if (typeof prop === 'string') { + can.Construct._overwrite(self, base, parseName, maker(prop)); + } else if ((!staticProps || !can.isFunction(staticProps[parseName])) && !self[parseName]) { + var madeParser = maker(); + madeParser.useModelConverter = hasCustomConverter[parseName]; + can.Construct._overwrite(self, base, parseName, madeParser); + } + }); + if (self.fullName === 'can.Model' || !self.fullName) { + self.fullName = 'Model' + ++modelNum; + } + can.Model._reqs = 0; + this._url = this._shortName + '/{' + this.id + '}'; + }, + _ajax: ajaxMaker, + _makeRequest: makeRequest, + _clean: function () { + can.Model._reqs--; + if (!can.Model._reqs) { + for (var id in this.store) { + if (!this.store[id]._bindings) { + delete this.store[id]; + } + } + } + return arguments[0]; + }, + models: converters.models, + model: converters.model + }, { + setup: function (attrs) { + var id = attrs && attrs[this.constructor.id]; + if (can.Model._reqs && id != null) { + this.constructor.store[id] = this; + } + can.Map.prototype.setup.apply(this, arguments); + }, + isNew: function () { + var id = getId(this); + return !(id || id === 0); + }, + save: function (success, error) { + return makeRequest(this, this.isNew() ? 'create' : 'update', success, error); + }, + destroy: function (success, error) { + if (this.isNew()) { + var self = this; + var def = can.Deferred(); + def.then(success, error); + return def.done(function (data) { + self.destroyed(data); + }).resolve(self); + } + return makeRequest(this, 'destroy', success, error, 'destroyed'); + }, + _bindsetup: function () { + var modelInstance = this.__get(this.constructor.id); + if (modelInstance != null) { + this.constructor.store[modelInstance] = this; + } + return can.Map.prototype._bindsetup.apply(this, arguments); + }, + _bindteardown: function () { + delete this.constructor.store[getId(this)]; + return can.Map.prototype._bindteardown.apply(this, arguments); + }, + ___set: function (prop, val) { + can.Map.prototype.___set.call(this, prop, val); + if (prop === this.constructor.id && this._bindings) { + this.constructor.store[getId(this)] = this; + } + } + }); + var makeGetterHandler = function (name) { + return function (data, readyState, xhr) { + return this[name](data, null, xhr); + }; + }, createUpdateDestroyHandler = function (data) { + if (this.parseModel.useModelConverter) { + return this.model(data); + } + return this.parseModel(data); + }; + var responseHandlers = { + makeFindAll: makeGetterHandler('models'), + makeFindOne: makeGetterHandler('model'), + makeCreate: createUpdateDestroyHandler, + makeUpdate: createUpdateDestroyHandler, + makeDestroy: createUpdateDestroyHandler + }; + can.each(responseHandlers, function (method, name) { + can.Model[name] = function (oldMethod) { + return function () { + var args = can.makeArray(arguments), oldArgs = can.isFunction(args[1]) ? args.splice(0, 1) : args.splice(0, 2), def = pipe(oldMethod.apply(this, oldArgs), this, method); + def.then(args[0], args[1]); + return def; + }; + }; + }); + can.each([ + 'created', + 'updated', + 'destroyed' + ], function (funcName) { + can.Model.prototype[funcName] = function (attrs) { + var self = this, constructor = self.constructor; + if (attrs && typeof attrs === 'object') { + this.attr(can.isFunction(attrs.attr) ? attrs.attr() : attrs); + } + can.dispatch.call(this, { + type: 'change', + target: this + }, [funcName]); + can.dev.log('Model.js - ' + constructor.shortName + ' ' + funcName); + can.dispatch.call(constructor, funcName, [this]); + }; + }); + var ML = can.Model.List = can.List.extend({ + _bubbleRule: function (eventName, list) { + var bubbleRules = can.List._bubbleRule(eventName, list); + bubbleRules.push('destroyed'); + return bubbleRules; + } + }, { + setup: function (params) { + if (can.isPlainObject(params) && !can.isArray(params)) { + can.List.prototype.setup.apply(this); + this.replace(can.isDeferred(params) ? params : this.constructor.Map.findAll(params)); + } else { + can.List.prototype.setup.apply(this, arguments); + } + this._init = 1; + this.bind('destroyed', can.proxy(this._destroyed, this)); + delete this._init; + }, + _destroyed: function (ev, attr) { + if (/\w+/.test(attr)) { + var index; + while ((index = this.indexOf(ev.target)) > -1) { + this.splice(index, 1); + } + } + } + }); + return can.Model; +}); +/*can@2.2.6#util/string/deparam/deparam*/ +define('can/util/string/deparam/deparam', [ + 'can/util/util', + 'can/util/string/string' +], function (can) { + var digitTest = /^\d+$/, keyBreaker = /([^\[\]]+)|(\[\])/g, paramTest = /([^?#]*)(#.*)?$/, prep = function (str) { + return decodeURIComponent(str.replace(/\+/g, ' ')); + }; + can.extend(can, { + deparam: function (params) { + var data = {}, pairs, lastPart; + if (params && paramTest.test(params)) { + pairs = params.split('&'); + can.each(pairs, function (pair) { + var parts = pair.split('='), key = prep(parts.shift()), value = prep(parts.join('=')), current = data; + if (key) { + parts = key.match(keyBreaker); + for (var j = 0, l = parts.length - 1; j < l; j++) { + if (!current[parts[j]]) { + current[parts[j]] = digitTest.test(parts[j + 1]) || parts[j + 1] === '[]' ? [] : {}; + } + current = current[parts[j]]; + } + lastPart = parts.pop(); + if (lastPart === '[]') { + current.push(value); + } else { + current[lastPart] = value; + } + } + }); + } + return data; + } + }); + return can; +}); +/*can@2.2.6#route/route*/ +define('can/route/route', [ + 'can/util/util', + 'can/map/map', + 'can/list/list', + 'can/util/string/deparam/deparam' +], function (can) { + var matcher = /\:([\w\.]+)/g, paramsMatcher = /^(?:&[^=]+=[^&]*)+/, makeProps = function (props) { + var tags = []; + can.each(props, function (val, name) { + tags.push((name === 'className' ? 'class' : name) + '="' + (name === 'href' ? val : can.esc(val)) + '"'); + }); + return tags.join(' '); + }, matchesData = function (route, data) { + var count = 0, i = 0, defaults = {}; + for (var name in route.defaults) { + if (route.defaults[name] === data[name]) { + defaults[name] = 1; + count++; + } + } + for (; i < route.names.length; i++) { + if (!data.hasOwnProperty(route.names[i])) { + return -1; + } + if (!defaults[route.names[i]]) { + count++; + } + } + return count; + }, location = window.location, wrapQuote = function (str) { + return (str + '').replace(/([.?*+\^$\[\]\\(){}|\-])/g, '\\$1'); + }, each = can.each, extend = can.extend, stringify = function (obj) { + if (obj && typeof obj === 'object') { + if (obj instanceof can.Map) { + obj = obj.attr(); + } else { + obj = can.isFunction(obj.slice) ? obj.slice() : can.extend({}, obj); + } + can.each(obj, function (val, prop) { + obj[prop] = stringify(val); + }); + } else if (obj !== undefined && obj !== null && can.isFunction(obj.toString)) { + obj = obj.toString(); + } + return obj; + }, removeBackslash = function (str) { + return str.replace(/\\/g, ''); + }, timer, curParams, lastHash, changingData, changedAttrs = [], onRouteDataChange = function (ev, attr, how, newval) { + changingData = 1; + changedAttrs.push(attr); + clearTimeout(timer); + timer = setTimeout(function () { + changingData = 0; + var serialized = can.route.data.serialize(), path = can.route.param(serialized, true); + can.route._call('setURL', path, changedAttrs); + can.batch.trigger(eventsObject, '__url', [ + path, + lastHash + ]); + lastHash = path; + changedAttrs = []; + }, 10); + }, eventsObject = can.extend({}, can.event); + can.route = function (url, defaults) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + defaults = defaults || {}; + var names = [], res, test = '', lastIndex = matcher.lastIndex = 0, next, querySeparator = can.route._call('querySeparator'), matchSlashes = can.route._call('matchSlashes'); + while (res = matcher.exec(url)) { + names.push(res[1]); + test += removeBackslash(url.substring(lastIndex, matcher.lastIndex - res[0].length)); + next = '\\' + (removeBackslash(url.substr(matcher.lastIndex, 1)) || querySeparator + (matchSlashes ? '' : '|/')); + test += '([^' + next + ']' + (defaults[res[1]] ? '*' : '+') + ')'; + lastIndex = matcher.lastIndex; + } + test += url.substr(lastIndex).replace('\\', ''); + can.route.routes[url] = { + test: new RegExp('^' + test + '($|' + wrapQuote(querySeparator) + ')'), + route: url, + names: names, + defaults: defaults, + length: url.split('/').length + }; + return can.route; + }; + extend(can.route, { + param: function (data, _setRoute) { + var route, matches = 0, matchCount, routeName = data.route, propCount = 0; + delete data.route; + each(data, function () { + propCount++; + }); + each(can.route.routes, function (temp, name) { + matchCount = matchesData(temp, data); + if (matchCount > matches) { + route = temp; + matches = matchCount; + } + if (matchCount >= propCount) { + return false; + } + }); + if (can.route.routes[routeName] && matchesData(can.route.routes[routeName], data) === matches) { + route = can.route.routes[routeName]; + } + if (route) { + var cpy = extend({}, data), res = route.route.replace(matcher, function (whole, name) { + delete cpy[name]; + return data[name] === route.defaults[name] ? '' : encodeURIComponent(data[name]); + }).replace('\\', ''), after; + each(route.defaults, function (val, name) { + if (cpy[name] === val) { + delete cpy[name]; + } + }); + after = can.param(cpy); + if (_setRoute) { + can.route.attr('route', route.route); + } + return res + (after ? can.route._call('querySeparator') + after : ''); + } + return can.isEmptyObject(data) ? '' : can.route._call('querySeparator') + can.param(data); + }, + deparam: function (url) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + var route = { length: -1 }, querySeparator = can.route._call('querySeparator'), paramsMatcher = can.route._call('paramsMatcher'); + each(can.route.routes, function (temp, name) { + if (temp.test.test(url) && temp.length > route.length) { + route = temp; + } + }); + if (route.length > -1) { + var parts = url.match(route.test), start = parts.shift(), remainder = url.substr(start.length - (parts[parts.length - 1] === querySeparator ? 1 : 0)), obj = remainder && paramsMatcher.test(remainder) ? can.deparam(remainder.slice(1)) : {}; + obj = extend(true, {}, route.defaults, obj); + each(parts, function (part, i) { + if (part && part !== querySeparator) { + obj[route.names[i]] = decodeURIComponent(part); + } + }); + obj.route = route.route; + return obj; + } + if (url.charAt(0) !== querySeparator) { + url = querySeparator + url; + } + return paramsMatcher.test(url) ? can.deparam(url.slice(1)) : {}; + }, + data: new can.Map({}), + map: function (data) { + var appState; + if (data.prototype instanceof can.Map) { + appState = new data(); + } else { + appState = data; + } + can.route.data = appState; + }, + routes: {}, + ready: function (val) { + if (val !== true) { + can.route._setup(); + can.route.setState(); + } + return can.route; + }, + url: function (options, merge) { + if (merge) { + options = can.extend({}, can.route.deparam(can.route._call('matchingPartOfURL')), options); + } + return can.route._call('root') + can.route.param(options); + }, + link: function (name, options, props, merge) { + return '' + name + ''; + }, + current: function (options) { + can.__observe(eventsObject, '__url'); + return this._call('matchingPartOfURL') === can.route.param(options); + }, + bindings: { + hashchange: { + paramsMatcher: paramsMatcher, + querySeparator: '&', + matchSlashes: false, + bind: function () { + can.bind.call(window, 'hashchange', setState); + }, + unbind: function () { + can.unbind.call(window, 'hashchange', setState); + }, + matchingPartOfURL: function () { + return location.href.split(/#!?/)[1] || ''; + }, + setURL: function (path) { + if (location.hash !== '#' + path) { + location.hash = '!' + path; + } + return path; + }, + root: '#!' + } + }, + defaultBinding: 'hashchange', + currentBinding: null, + _setup: function () { + if (!can.route.currentBinding) { + can.route._call('bind'); + can.route.bind('change', onRouteDataChange); + can.route.currentBinding = can.route.defaultBinding; + } + }, + _teardown: function () { + if (can.route.currentBinding) { + can.route._call('unbind'); + can.route.unbind('change', onRouteDataChange); + can.route.currentBinding = null; + } + clearTimeout(timer); + changingData = 0; + }, + _call: function () { + var args = can.makeArray(arguments), prop = args.shift(), binding = can.route.bindings[can.route.currentBinding || can.route.defaultBinding], method = binding[prop]; + if (method.apply) { + return method.apply(binding, args); + } else { + return method; + } + } + }); + each([ + 'bind', + 'unbind', + 'on', + 'off', + 'delegate', + 'undelegate', + 'removeAttr', + 'compute', + '_get', + '__get', + 'each' + ], function (name) { + can.route[name] = function () { + if (!can.route.data[name]) { + return; + } + return can.route.data[name].apply(can.route.data, arguments); + }; + }); + can.route.attr = function (attr, val) { + var type = typeof attr, newArguments; + if (val === undefined) { + newArguments = arguments; + } else if (type !== 'string' && type !== 'number') { + newArguments = [ + stringify(attr), + val + ]; + } else { + newArguments = [ + attr, + stringify(val) + ]; + } + return can.route.data.attr.apply(can.route.data, newArguments); + }; + var setState = can.route.setState = function () { + var hash = can.route._call('matchingPartOfURL'); + var oldParams = curParams; + curParams = can.route.deparam(hash); + if (!changingData || hash !== lastHash) { + can.batch.start(); + recursiveClean(oldParams, curParams, can.route.data); + can.route.attr(curParams); + can.batch.trigger(eventsObject, '__url', [ + hash, + lastHash + ]); + can.batch.stop(); + } + }; + var recursiveClean = function (old, cur, data) { + for (var attr in old) { + if (cur[attr] === undefined) { + data.removeAttr(attr); + } else if (Object.prototype.toString.call(old[attr]) === '[object Object]') { + recursiveClean(old[attr], cur[attr], data.attr(attr)); + } + } + }; + return can.route; +}); +/*can@2.2.6#control/route/route*/ +define('can/control/route/route', [ + 'can/util/util', + 'can/route/route', + 'can/control/control' +], function (can) { + can.Control.processors.route = function (el, event, selector, funcName, controller) { + selector = selector || ''; + if (!can.route.routes[selector]) { + if (selector[0] === '/') { + selector = selector.substring(1); + } + can.route(selector); + } + var batchNum, check = function (ev, attr, how) { + if (can.route.attr('route') === selector && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + batchNum = ev.batchNum; + var d = can.route.attr(); + delete d.route; + if (can.isFunction(controller[funcName])) { + controller[funcName](d); + } else { + controller[controller[funcName]](d); + } + } + }; + can.route.bind('change', check); + return function () { + can.route.unbind('change', check); + }; + }; + return can; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.yui.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.yui.js new file mode 100644 index 0000000000..ca3e2fcaf4 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.yui.js @@ -0,0 +1,7237 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#util/can*/ +define('can/util/can', [], function () { + var glbl = typeof window !== 'undefined' ? window : global; + var can = {}; + if (typeof GLOBALCAN === 'undefined' || GLOBALCAN !== false) { + glbl.can = can; + } + can.global = glbl; + can.k = function () { + }; + can.isDeferred = can.isPromise = function (obj) { + return obj && typeof obj.then === 'function' && typeof obj.pipe === 'function'; + }; + can.isMapLike = function (obj) { + return can.Map && (obj instanceof can.Map || obj && obj.__get); + }; + var cid = 0; + can.cid = function (object, name) { + if (!object._cid) { + cid++; + object._cid = (name || '') + cid; + } + return object._cid; + }; + can.VERSION = '2.2.6'; + can.simpleExtend = function (d, s) { + for (var prop in s) { + d[prop] = s[prop]; + } + return d; + }; + can.last = function (arr) { + return arr && arr[arr.length - 1]; + }; + var protoBind = Function.prototype.bind; + if (protoBind) { + can.proxy = function (fn, context) { + return protoBind.call(fn, context); + }; + } else { + can.proxy = function (fn, context) { + return function () { + return fn.apply(context, arguments); + }; + }; + } + can.frag = function (item) { + var frag; + if (!item || typeof item === 'string') { + frag = can.buildFragment(item == null ? '' : '' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } else if (item.nodeType === 11) { + return item; + } else if (typeof item.nodeType === 'number') { + frag = document.createDocumentFragment(); + frag.appendChild(item); + return frag; + } else if (typeof item.length === 'number') { + frag = document.createDocumentFragment(); + can.each(item, function (item) { + frag.appendChild(can.frag(item)); + }); + return frag; + } else { + frag = can.buildFragment('' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } + }; + can.scope = can.viewModel = function (el, attr, val) { + el = can.$(el); + var scope = can.data(el, 'scope') || can.data(el, 'viewModel'); + if (!scope) { + scope = new can.Map(); + can.data(el, 'scope', scope); + can.data(el, 'viewModel', scope); + } + switch (arguments.length) { + case 0: + case 1: + return scope; + case 2: + return scope.attr(attr); + default: + scope.attr(attr, val); + return el; + } + }; + can['import'] = function (moduleName) { + var deferred = new can.Deferred(); + if (typeof window.System === 'object' && can.isFunction(window.System['import'])) { + window.System['import'](moduleName).then(can.proxy(deferred.resolve, deferred), can.proxy(deferred.reject, deferred)); + } else if (window.define && window.define.amd) { + window.require([moduleName], function (value) { + deferred.resolve(value); + }); + } else if (window.steal) { + steal.steal(moduleName, function (value) { + deferred.resolve(value); + }); + } else if (window.require) { + deferred.resolve(window.require(moduleName)); + } else { + deferred.resolve(); + } + return deferred.promise(); + }; + can.__observe = function () { + }; + return can; +}); +/*can@2.2.6#util/attr/attr*/ +define('can/util/attr/attr', ['can/util/can'], function (can) { + var setImmediate = can.global.setImmediate || function (cb) { + return setTimeout(cb, 0); + }, attr = { + MutationObserver: can.global.MutationObserver || can.global.WebKitMutationObserver || can.global.MozMutationObserver, + map: { + 'class': 'className', + 'value': 'value', + 'innertext': 'innerText', + 'textcontent': 'textContent', + 'checked': true, + 'disabled': true, + 'readonly': true, + 'required': true, + src: function (el, val) { + if (val == null || val === '') { + el.removeAttribute('src'); + return null; + } else { + el.setAttribute('src', val); + return val; + } + }, + style: function (el, val) { + return el.style.cssText = val || ''; + } + }, + defaultValue: [ + 'input', + 'textarea' + ], + set: function (el, attrName, val) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var tagName = el.nodeName.toString().toLowerCase(), prop = attr.map[attrName], newValue; + if (typeof prop === 'function') { + newValue = prop(el, val); + } else if (prop === true) { + newValue = el[attrName] = true; + if (attrName === 'checked' && el.type === 'radio') { + if (can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultChecked = true; + } + } + } else if (prop) { + newValue = val; + if (el[prop] !== val) { + el[prop] = val; + } + if (prop === 'value' && can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultValue = val; + } + } else { + el.setAttribute(attrName, val); + newValue = val; + } + if (!attr.MutationObserver && newValue !== oldValue) { + attr.trigger(el, attrName, oldValue); + } + }, + trigger: function (el, attrName, oldValue) { + if (can.data(can.$(el), 'canHasAttributesBindings')) { + attrName = attrName.toLowerCase(); + return setImmediate(function () { + can.trigger(el, { + type: 'attributes', + attributeName: attrName, + target: el, + oldValue: oldValue, + bubbles: false + }, []); + }); + } + }, + get: function (el, attrName) { + attrName = attrName.toLowerCase(); + var prop = attr.map[attrName]; + if (typeof prop === 'string' && el[prop]) { + return el[prop]; + } + return el.getAttribute(attrName); + }, + remove: function (el, attrName) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var setter = attr.map[attrName]; + if (typeof setter === 'function') { + setter(el, undefined); + } + if (setter === true) { + el[attrName] = false; + } else if (typeof setter === 'string') { + el[setter] = ''; + } else { + el.removeAttribute(attrName); + } + if (!attr.MutationObserver && oldValue != null) { + attr.trigger(el, attrName, oldValue); + } + }, + has: function () { + var el = can.global.document && document.createElement('div'); + if (el && el.hasAttribute) { + return function (el, name) { + return el.hasAttribute(name); + }; + } else { + return function (el, name) { + return el.getAttribute(name) !== null; + }; + } + }() + }; + return attr; +}); +/*can@2.2.6#event/event*/ +define('can/event/event', ['can/util/can'], function (can) { + can.addEvent = function (event, handler) { + var allEvents = this.__bindEvents || (this.__bindEvents = {}), eventList = allEvents[event] || (allEvents[event] = []); + eventList.push({ + handler: handler, + name: event + }); + return this; + }; + can.listenTo = function (other, event, handler) { + var idedEvents = this.__listenToEvents; + if (!idedEvents) { + idedEvents = this.__listenToEvents = {}; + } + var otherId = can.cid(other); + var othersEvents = idedEvents[otherId]; + if (!othersEvents) { + othersEvents = idedEvents[otherId] = { + obj: other, + events: {} + }; + } + var eventsEvents = othersEvents.events[event]; + if (!eventsEvents) { + eventsEvents = othersEvents.events[event] = []; + } + eventsEvents.push(handler); + can.bind.call(other, event, handler); + }; + can.stopListening = function (other, event, handler) { + var idedEvents = this.__listenToEvents, iterIdedEvents = idedEvents, i = 0; + if (!idedEvents) { + return this; + } + if (other) { + var othercid = can.cid(other); + (iterIdedEvents = {})[othercid] = idedEvents[othercid]; + if (!idedEvents[othercid]) { + return this; + } + } + for (var cid in iterIdedEvents) { + var othersEvents = iterIdedEvents[cid], eventsEvents; + other = idedEvents[cid].obj; + if (!event) { + eventsEvents = othersEvents.events; + } else { + (eventsEvents = {})[event] = othersEvents.events[event]; + } + for (var eventName in eventsEvents) { + var handlers = eventsEvents[eventName] || []; + i = 0; + while (i < handlers.length) { + if (handler && handler === handlers[i] || !handler) { + can.unbind.call(other, eventName, handlers[i]); + handlers.splice(i, 1); + } else { + i++; + } + } + if (!handlers.length) { + delete othersEvents.events[eventName]; + } + } + if (can.isEmptyObject(othersEvents.events)) { + delete idedEvents[cid]; + } + } + return this; + }; + can.removeEvent = function (event, fn, __validate) { + if (!this.__bindEvents) { + return this; + } + var events = this.__bindEvents[event] || [], i = 0, ev, isFunction = typeof fn === 'function'; + while (i < events.length) { + ev = events[i]; + if (__validate ? __validate(ev, event, fn) : isFunction && ev.handler === fn || !isFunction && (ev.cid === fn || !fn)) { + events.splice(i, 1); + } else { + i++; + } + } + return this; + }; + can.dispatch = function (event, args) { + var events = this.__bindEvents; + if (!events) { + return; + } + if (typeof event === 'string') { + event = { type: event }; + } + var eventName = event.type, handlers = (events[eventName] || []).slice(0), passed = [event]; + if (args) { + passed.push.apply(passed, args); + } + for (var i = 0, len = handlers.length; i < len; i++) { + handlers[i].handler.apply(this, passed); + } + return event; + }; + can.one = function (event, handler) { + var one = function () { + can.unbind.call(this, event, one); + return handler.apply(this, arguments); + }; + can.bind.call(this, event, one); + return this; + }; + can.event = { + on: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.on.call(this); + } else { + return can.addEvent.apply(this, arguments); + } + }, + off: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.off.call(this); + } else { + return can.removeEvent.apply(this, arguments); + } + }, + bind: can.addEvent, + unbind: can.removeEvent, + delegate: function (selector, event, handler) { + return can.addEvent.call(this, event, handler); + }, + undelegate: function (selector, event, handler) { + return can.removeEvent.call(this, event, handler); + }, + trigger: can.dispatch, + one: can.one, + addEvent: can.addEvent, + removeEvent: can.removeEvent, + listenTo: can.listenTo, + stopListening: can.stopListening, + dispatch: can.dispatch + }; + return can.event; +}); +/*can@2.2.6#util/fragment*/ +define('can/util/fragment', ['can/util/can'], function (can) { + var fragmentRE = /^\s*<(\w+)[^>]*>/, toString = {}.toString, fragment = function (html, name) { + if (name === undefined) { + name = fragmentRE.test(html) && RegExp.$1; + } + if (html && toString.call(html.replace) === '[object Function]') { + html = html.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, '<$1>'); + } + var container = document.createElement('div'), temp = document.createElement('div'); + if (name === 'tbody' || name === 'tfoot' || name === 'thead') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; + } else if (name === 'tr') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild; + } else if (name === 'td' || name === 'th') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild.firstChild; + } else if (name === 'option') { + temp.innerHTML = ''; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; + } else { + container.innerHTML = '' + html; + } + var tmp = {}, children = container.childNodes; + tmp.length = children.length; + for (var i = 0; i < children.length; i++) { + tmp[i] = children[i]; + } + return [].slice.call(tmp); + }; + can.buildFragment = function (html, nodes) { + if (html && html.nodeType === 11) { + return html; + } + var parts = fragment(html), frag = document.createDocumentFragment(); + for (var i = 0, length = parts.length; i < length; i++) { + frag.appendChild(parts[i]); + } + return frag; + }; + (function () { + var text = '<-\n>', frag = can.buildFragment(text, document); + if (text !== frag.childNodes[0].nodeValue) { + var oldBuildFragment = can.buildFragment; + can.buildFragment = function (html, nodes) { + var res = oldBuildFragment(html, nodes); + if (res.childNodes.length === 1 && res.childNodes[0].nodeType === 3) { + res.childNodes[0].nodeValue = html; + } + return res; + }; + } + }()); + return can; +}); +/*can@2.2.6#util/array/each*/ +define('can/util/array/each', ['can/util/can'], function (can) { + var isArrayLike = function (obj) { + var length = 'length' in obj && obj.length; + return typeof arr !== 'function' && (length === 0 || typeof length === 'number' && length > 0 && length - 1 in obj); + }; + can.each = function (elements, callback, context) { + var i = 0, key, len, item; + if (elements) { + if (isArrayLike(elements)) { + if (can.List && elements instanceof can.List) { + for (len = elements.attr('length'); i < len; i++) { + item = elements.attr(i); + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } else { + for (len = elements.length; i < len; i++) { + item = elements[i]; + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } + } else if (typeof elements === 'object') { + if (can.Map && elements instanceof can.Map || elements === can.route) { + var keys = can.Map.keys(elements); + for (i = 0, len = keys.length; i < len; i++) { + key = keys[i]; + item = elements.attr(key); + if (callback.call(context || item, item, key, elements) === false) { + break; + } + } + } else { + for (key in elements) { + if (elements.hasOwnProperty(key) && callback.call(context || elements[key], elements[key], key, elements) === false) { + break; + } + } + } + } + } + return elements; + }; + return can; +}); +/*can@2.2.6#util/object/isplain/isplain*/ +define('can/util/object/isplain/isplain', ['can/util/can'], function () { + var core_hasOwn = Object.prototype.hasOwnProperty, isWindow = function (obj) { + return obj !== null && obj == obj.window; + }, isPlainObject = function (obj) { + if (!obj || typeof obj !== 'object' || obj.nodeType || isWindow(obj)) { + return false; + } + try { + if (obj.constructor && !core_hasOwn.call(obj, 'constructor') && !core_hasOwn.call(obj.constructor.prototype, 'isPrototypeOf')) { + return false; + } + } catch (e) { + return false; + } + var key; + for (key in obj) { + } + return key === undefined || core_hasOwn.call(obj, key); + }; + can.isPlainObject = isPlainObject; + return can; +}); +/*can@2.2.6#util/deferred*/ +define('can/util/deferred', ['can/util/can'], function (can) { + var extend = function (target, src) { + for (var key in src) { + if (src.hasOwnProperty(key)) { + target[key] = src[key]; + } + } + }, Deferred = function (func) { + if (!(this instanceof Deferred)) { + return new Deferred(); + } + this._doneFuncs = []; + this._failFuncs = []; + this._resultArgs = null; + this._status = ''; + if (func) { + func.call(this, this); + } + }; + can.Deferred = Deferred; + can.when = Deferred.when = function () { + var args = can.makeArray(arguments); + if (args.length < 2) { + var obj = args[0]; + if (obj && (can.isFunction(obj.isResolved) && can.isFunction(obj.isRejected))) { + return obj; + } else { + return Deferred().resolve(obj); + } + } else { + var df = Deferred(), done = 0, rp = []; + can.each(args, function (arg, j) { + arg.done(function () { + rp[j] = arguments.length < 2 ? arguments[0] : arguments; + if (++done === args.length) { + df.resolve.apply(df, rp); + } + }).fail(function () { + df.reject(arguments.length === 1 ? arguments[0] : arguments); + }); + }); + return df; + } + }; + var resolveFunc = function (type, _status) { + return function (context) { + var args = this._resultArgs = arguments.length > 1 ? arguments[1] : []; + return this.exec(context, this[type], args, _status); + }; + }, doneFunc = function doneFunc(type, _status) { + return function () { + var self = this; + can.each(Array.prototype.slice.call(arguments), function (v, i, args) { + if (!v) { + return; + } + if (v.constructor === Array) { + doneFunc.apply(self, v); + } else { + if (self._status === _status) { + v.apply(self, self._resultArgs || []); + } + self[type].push(v); + } + }); + return this; + }; + }; + var isDeferred = function (obj) { + return obj && obj.then && obj.fail && obj.done; + }; + var wire = function (parentDeferred, result, setter, value) { + if (isDeferred(result)) { + result.done(can.proxy(parentDeferred.resolve, parentDeferred)).fail(can.proxy(parentDeferred.reject, parentDeferred)); + } else { + setter.call(parentDeferred, result !== undefined ? result : value); + } + }; + extend(Deferred.prototype, { + then: function (done, fail) { + var d = can.Deferred(), resolve = d.resolve, reject = d.reject; + this.done(function (value) { + if (typeof done === 'function') { + wire(d, done.apply(this, arguments), resolve, value); + } else { + resolve.apply(d, arguments); + } + }); + this.fail(function (value) { + if (typeof fail === 'function') { + wire(d, fail.apply(this, arguments), reject, value); + } else { + reject.apply(d, arguments); + } + }); + return d; + }, + resolveWith: resolveFunc('_doneFuncs', 'rs'), + rejectWith: resolveFunc('_failFuncs', 'rj'), + done: doneFunc('_doneFuncs', 'rs'), + fail: doneFunc('_failFuncs', 'rj'), + always: function () { + var args = can.makeArray(arguments); + if (args.length && args[0]) { + this.done(args[0]).fail(args[0]); + } + return this; + }, + state: function () { + switch (this._status) { + case 'rs': + return 'resolved'; + case 'rj': + return 'rejected'; + default: + return 'pending'; + } + }, + isResolved: function () { + return this._status === 'rs'; + }, + isRejected: function () { + return this._status === 'rj'; + }, + reject: function () { + return this.rejectWith(this, arguments); + }, + resolve: function () { + return this.resolveWith(this, arguments); + }, + exec: function (context, dst, args, st) { + if (this._status !== '') { + return this; + } + this._status = st; + can.each(dst, function (d) { + if (typeof d.apply === 'function') { + d.apply(context, args); + } + }); + return this; + }, + promise: function () { + var promise = this.then(); + promise.reject = promise.resolve = undefined; + return promise; + } + }); + Deferred.prototype.pipe = Deferred.prototype.then; + return can; +}); +/*can@2.2.6#util/hashchange*/ +define('can/util/hashchange', ['can/util/can'], function (can) { + (function () { + var addEvent = function (el, ev, fn) { + if (el.addEventListener) { + el.addEventListener(ev, fn, false); + } else if (el.attachEvent) { + el.attachEvent('on' + ev, fn); + } else { + el['on' + ev] = fn; + } + }, onHashchange = function () { + can.trigger(window, 'hashchange'); + }; + addEvent(window, 'hashchange', onHashchange); + }()); +}); +/*can@2.2.6#util/inserted/inserted*/ +define('can/util/inserted/inserted', ['can/util/can'], function (can) { + can.inserted = function (elems) { + elems = can.makeArray(elems); + var inDocument = false, doc = can.$(document.contains ? document : document.body), children; + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + if (!inDocument) { + if (elem.getElementsByTagName) { + if (can.has(doc, elem).length) { + inDocument = true; + } else { + return; + } + } else { + continue; + } + } + if (inDocument && elem.getElementsByTagName) { + children = can.makeArray(elem.getElementsByTagName('*')); + can.trigger(elem, 'inserted', [], false); + for (var j = 0, child; (child = children[j]) !== undefined; j++) { + can.trigger(child, 'inserted', [], false); + } + } + } + }; + can.appendChild = function (el, child) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.appendChild(child); + can.inserted(children); + }; + can.insertBefore = function (el, child, ref) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.insertBefore(child, ref); + can.inserted(children); + }; +}); +/*can@2.2.6#util/util*/ +define('can/util/util', [ + 'can/util/can', + 'can/util/attr/attr', + 'can/yui/yui', + 'can/event/event', + 'can/util/fragment', + 'can/util/array/each', + 'can/util/object/isplain/isplain', + 'can/util/deferred', + 'can/util/hashchange', + 'can/util/inserted/inserted' +], function (can, attr, YUI) { + YUI = YUI || window.YUI; + YUI.add('can-modifications', function (Y, NAME) { + var addHTML = Y.DOM.addHTML; + Y.DOM.addHTML = function (node, content, where) { + if (typeof content === 'string' || typeof content === 'number') { + content = can.buildFragment(content); + } + var elems; + if (content.nodeType === 11) { + elems = can.makeArray(content.childNodes); + } else { + elems = [content]; + } + var ret = addHTML.call(this, node, content, where); + can.inserted(elems); + return ret; + }; + var oldOn = Y.Node.prototype.on; + Y.Node.prototype.on = function (type, fn) { + if (type === 'attributes') { + var el = can.$(this); + can.data(el, 'canHasAttributesBindings', (can.data(el, 'canHasAttributesBindings') || 0) + 1); + var handle = oldOn.apply(this, arguments), oldDetach = handle.detach; + handle.detach = function () { + var cur = can.data(el, 'canHasAttributesBindings') || 0; + if (cur <= 0) { + can.cleanData(el, 'canHasAttributesBindings'); + } else { + can.data(el, 'canHasAttributesBindings', cur - 1); + } + return oldDetach.apply(this, arguments); + }; + return handle; + } else { + return oldOn.apply(this, arguments); + } + }; + }, '3.7.3', { 'requires': ['node-base'] }); + var Y = can.Y = can.Y || YUI().use('*'); + can.trim = function (s) { + return Y.Lang.trim(s); + }; + can.makeArray = function (arr) { + if (!arr) { + return []; + } + return Y.Array(arr); + }; + can.isArray = Y.Lang.isArray; + can.inArray = function (item, arr, fromIndex) { + if (!arr) { + return -1; + } + return Y.Array.indexOf(arr, item, fromIndex); + }; + can.map = function (arr, fn) { + return Y.Array.map(can.makeArray(arr || []), fn); + }; + can.extend = function (first) { + var deep = first === true ? 1 : 0, target = arguments[deep], i = deep + 1, arg; + for (; arg = arguments[i]; i++) { + Y.mix(target, arg, true, null, null, !!deep); + } + return target; + }; + can.param = function (object) { + return Y.QueryString.stringify(object, { arrayKey: true }); + }; + can.isEmptyObject = function (object) { + return Y.Object.isEmpty(object); + }; + can.proxy = function (func, context) { + return Y.bind.apply(Y, arguments); + }; + can.isFunction = function (f) { + return Y.Lang.isFunction(f); + }; + var prepareNodeList = function (nodelist) { + nodelist.each(function (node, i) { + nodelist[i] = node.getDOMNode(); + }); + nodelist.length = nodelist.size(); + return nodelist; + }; + can.$ = function (selector) { + if (selector === window) { + return window; + } else if (selector instanceof Y.NodeList) { + return prepareNodeList(selector); + } else if (typeof selector === 'object' && !can.isArray(selector) && typeof selector.nodeType === 'undefined' && !selector.getDOMNode) { + return new Y.NodeList(selector); + } else { + return prepareNodeList(Y.all(selector)); + } + }; + can.get = function (wrapped, index) { + return wrapped._nodes[index]; + }; + can.append = function (wrapped, html) { + wrapped.each(function (node) { + if (typeof html === 'string') { + html = can.buildFragment(html, node); + } + node.append(html); + }); + }; + can.addClass = function (wrapped, className) { + return wrapped.addClass(className); + }; + can.data = function (wrapped, key, value) { + if (!wrapped.item(0)) { + return; + } + if (value === undefined) { + return wrapped.item(0).getData(key); + } else { + return wrapped.item(0).setData(key, value); + } + }; + can.remove = function (wrapped) { + return wrapped.remove() && wrapped.destroy(); + }; + can.has = function (wrapped, node) { + if (Y.DOM.contains(wrapped[0], node)) { + return wrapped; + } else { + return []; + } + }; + can._yNodeRemove = can._yNodeRemove || Y.Node.prototype.remove; + Y.Node.prototype.remove = function () { + var node = this.getDOMNode(); + if (node.nodeType === 1) { + can.trigger(this, 'removed', [], false); + var elems = node.getElementsByTagName('*'); + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + can.trigger(elem, 'removed', [], false); + } + } + can._yNodeRemove.apply(this, arguments); + }; + Y.NodeList.addMethod('remove', Y.Node.prototype.remove); + var optionsMap = { + type: 'method', + success: undefined, + error: undefined + }; + var updateDeferred = function (request, d) { + if (request && request.io) { + var xhr = request.io; + for (var prop in xhr) { + if (typeof d[prop] === 'function') { + d[prop] = function () { + xhr[prop].apply(xhr, arguments); + }; + } else { + d[prop] = prop[xhr]; + } + } + } + }; + can.ajax = function (options) { + var d = can.Deferred(), requestOptions = can.extend({}, options); + for (var option in optionsMap) { + if (requestOptions[option] !== undefined) { + requestOptions[optionsMap[option]] = requestOptions[option]; + delete requestOptions[option]; + } + } + requestOptions.sync = !options.async; + var success = options.success, error = options.error; + requestOptions.on = { + success: function (transactionid, response) { + var data = response.responseText; + if (options.dataType === 'json') { + data = eval('(' + data + ')'); + } + updateDeferred(request, d); + d.resolve(data); + if (success) { + success(data, 'success', request); + } + }, + failure: function (transactionid, response) { + updateDeferred(request, d); + d.reject(request, 'error'); + if (error) { + error(request, 'error'); + } + } + }; + var request = Y.io(requestOptions.url, requestOptions); + updateDeferred(request, d); + return d; + }; + var yuiEventId = 0, addBinding = function (nodelist, selector, ev, cb) { + if (nodelist instanceof Y.NodeList || !nodelist.on || nodelist.getDOMNode) { + nodelist.each(function (node) { + node = can.$(node); + var events = can.data(node, 'events'), eventName = ev + ':' + selector; + if (!events) { + can.data(node, 'events', events = {}); + } + if (!events[eventName]) { + events[eventName] = {}; + } + if (cb.__bindingsIds === undefined) { + cb.__bindingsIds = yuiEventId++; + } + events[eventName][cb.__bindingsIds] = selector ? node.item(0).delegate(ev, cb, selector) : node.item(0).on(ev, cb); + }); + } else { + var obj = nodelist, events = obj.__canEvents = obj.__canEvents || {}; + if (!events[ev]) { + events[ev] = {}; + } + if (cb.__bindingsIds === undefined) { + cb.__bindingsIds = yuiEventId++; + } + events[ev][cb.__bindingsIds] = obj.on(ev, cb); + } + }, removeBinding = function (nodelist, selector, ev, cb) { + if (nodelist instanceof Y.NodeList || !nodelist.on || nodelist.getDOMNode) { + nodelist.each(function (node) { + node = can.$(node); + var events = can.data(node, 'events'); + if (events) { + var eventName = ev + ':' + selector, handlers = events[eventName], handler = handlers[cb.__bindingsIds]; + handler.detach(); + delete handlers[cb.__bindingsIds]; + if (can.isEmptyObject(handlers)) { + delete events[ev]; + } + if (can.isEmptyObject(events)) { + } + } + }); + } else { + var obj = nodelist, events = obj.__canEvents || {}, handlers = events[ev], handler = handlers[cb.__bindingsIds]; + handler.detach(); + delete handlers[cb.__bindingsIds]; + if (can.isEmptyObject(handlers)) { + delete events[ev]; + } + if (can.isEmptyObject(events)) { + } + } + }; + can.bind = function (ev, cb) { + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (this.on || this.nodeType) { + addBinding(can.$(this), undefined, ev, cb); + } else if (this.addEvent) { + this.addEvent(ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + return this; + }; + can.unbind = function (ev, cb) { + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (this.on || this.nodeType) { + removeBinding(can.$(this), undefined, ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + return this; + }; + can.on = can.bind; + can.off = can.unbind; + can.trigger = function (item, event, args, bubble) { + if (item instanceof Y.NodeList) { + item = item.item(0); + } + if (item.getDOMNode) { + item = item.getDOMNode(); + } + if (item.nodeName) { + item = Y.Node(item); + if (bubble === false) { + item.once(event, function (ev) { + if (ev.stopPropagation) { + ev.stopPropagation(); + } + ev.cancelBubble = true; + if (ev._stopper) { + ev._stopper(); + } + }); + } + if (typeof event !== 'string') { + args = event; + event = args.type; + delete args.type; + } + realTrigger(item.getDOMNode(), event, args || {}); + } else { + if (typeof event === 'string') { + event = { type: event }; + } + event.target = event.target || item; + can.dispatch.call(item, event, can.makeArray(args)); + } + }; + Y.mix(Y.Node.DOM_EVENTS, { + removed: true, + inserted: true, + attributes: true, + foo: true + }); + Y.Env.evt.plugins.attributes = { + on: function () { + var args = can.makeArray(arguments); + return Y.Event._attach(args, { facade: false }); + } + }; + can.delegate = function (selector, ev, cb) { + if (this.on || this.nodeType) { + addBinding(can.$(this), selector, ev, cb); + } else if (this.delegate) { + this.delegate(selector, ev, cb); + } else { + can.bind.call(this, ev, cb); + } + return this; + }; + can.undelegate = function (selector, ev, cb) { + if (this.on || this.nodeType) { + removeBinding(can.$(this), selector, ev, cb); + } else if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else { + can.unbind.call(this, ev, cb); + } + return this; + }; + var realTrigger, realTriggerHandler = function (n, e, evdata) { + var node = Y.Node(n), handlers = can.Y.Event.getListeners(node._yuid, e), i; + if (handlers) { + for (i = 0; i < handlers.length; i++) { + if (handlers[i].fire) { + handlers[i].fire(evdata); + } else if (handlers[i].handles) { + can.each(handlers[i].handles, function (handle) { + handle.evt.fire(evdata); + }); + } else { + throw 'can not fire event'; + } + } + } + }, fakeTrigger = function (n, e, a) { + var stop = false; + var evdata = can.extend({ + type: e, + target: n, + faux: true, + _stopper: function () { + stop = this.cancelBubble; + }, + stopPropagation: function () { + stop = this.cancelBubble; + }, + preventDefault: function () { + } + }, a); + realTriggerHandler(n, e, evdata); + if (e === 'inserted' || e === 'removed') { + return; + } + while (!stop && n !== document && n.parentNode) { + n = n.parentNode; + realTriggerHandler(n, e, evdata); + } + }; + if (document.createEvent) { + realTrigger = function (n, e, a) { + fakeTrigger(n, e, a); + return; + }; + } else { + realTrigger = function (n, e, a) { + fakeTrigger(n, e, a); + return; + }; + } + can.attr = attr; + delete attr.MutationObserver; + return can; +}); +/*can@2.2.6#view/view*/ +define('can/view/view', ['can/util/util'], function (can) { + var isFunction = can.isFunction, makeArray = can.makeArray, hookupId = 1; + var makeRenderer = function (textRenderer) { + var renderer = function () { + return $view.frag(textRenderer.apply(this, arguments)); + }; + renderer.render = function () { + return textRenderer.apply(textRenderer, arguments); + }; + return renderer; + }; + var checkText = function (text, url) { + if (!text.length) { + throw 'can.view: No template or empty template:' + url; + } + }; + var getRenderer = function (obj, async) { + if (isFunction(obj)) { + var def = can.Deferred(); + return def.resolve(obj); + } + var url = typeof obj === 'string' ? obj : obj.url, suffix = obj.engine && '.' + obj.engine || url.match(/\.[\w\d]+$/), type, el, id; + if (url.match(/^#/)) { + url = url.substr(1); + } + if (el = document.getElementById(url)) { + suffix = '.' + el.type.match(/\/(x\-)?(.+)/)[2]; + } + if (!suffix && !$view.cached[url]) { + url += suffix = $view.ext; + } + if (can.isArray(suffix)) { + suffix = suffix[0]; + } + id = $view.toId(url); + if (url.match(/^\/\//)) { + url = url.substr(2); + url = !window.steal ? url : steal.config().root.mapJoin('' + steal.id(url)); + } + if (window.require) { + if (require.toUrl) { + url = require.toUrl(url); + } + } + type = $view.types[suffix]; + if ($view.cached[id]) { + return $view.cached[id]; + } else if (el) { + return $view.registerView(id, el.innerHTML, type); + } else { + var d = new can.Deferred(); + can.ajax({ + async: async, + url: url, + dataType: 'text', + error: function (jqXHR) { + checkText('', url); + d.reject(jqXHR); + }, + success: function (text) { + checkText(text, url); + $view.registerView(id, text, type, d); + } + }); + return d; + } + }; + var getDeferreds = function (data) { + var deferreds = []; + if (can.isDeferred(data)) { + return [data]; + } else { + for (var prop in data) { + if (can.isDeferred(data[prop])) { + deferreds.push(data[prop]); + } + } + } + return deferreds; + }; + var usefulPart = function (resolved) { + return can.isArray(resolved) && resolved[1] === 'success' ? resolved[0] : resolved; + }; + var $view = can.view = can.template = function (view, data, helpers, callback) { + if (isFunction(helpers)) { + callback = helpers; + helpers = undefined; + } + return $view.renderAs('fragment', view, data, helpers, callback); + }; + can.extend($view, { + frag: function (result, parentNode) { + return $view.hookup($view.fragment(result), parentNode); + }, + fragment: function (result) { + if (typeof result !== 'string' && result.nodeType === 11) { + return result; + } + var frag = can.buildFragment(result, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + }, + toId: function (src) { + return can.map(src.toString().split(/\/|\./g), function (part) { + if (part) { + return part; + } + }).join('_'); + }, + toStr: function (txt) { + return txt == null ? '' : '' + txt; + }, + hookup: function (fragment, parentNode) { + var hookupEls = [], id, func; + can.each(fragment.childNodes ? can.makeArray(fragment.childNodes) : fragment, function (node) { + if (node.nodeType === 1) { + hookupEls.push(node); + hookupEls.push.apply(hookupEls, can.makeArray(node.getElementsByTagName('*'))); + } + }); + can.each(hookupEls, function (el) { + if (el.getAttribute && (id = el.getAttribute('data-view-id')) && (func = $view.hookups[id])) { + func(el, parentNode, id); + delete $view.hookups[id]; + el.removeAttribute('data-view-id'); + } + }); + return fragment; + }, + hookups: {}, + hook: function (cb) { + $view.hookups[++hookupId] = cb; + return ' data-view-id=\'' + hookupId + '\''; + }, + cached: {}, + cachedRenderers: {}, + cache: true, + register: function (info) { + this.types['.' + info.suffix] = info; + can[info.suffix] = $view[info.suffix] = function (id, text) { + var renderer, renderFunc; + if (!text) { + renderFunc = function () { + if (!renderer) { + if (info.fragRenderer) { + renderer = info.fragRenderer(null, id); + } else { + renderer = makeRenderer(info.renderer(null, id)); + } + } + return renderer.apply(this, arguments); + }; + renderFunc.render = function () { + var textRenderer = info.renderer(null, id); + return textRenderer.apply(textRenderer, arguments); + }; + return renderFunc; + } + var registeredRenderer = function () { + if (!renderer) { + if (info.fragRenderer) { + renderer = info.fragRenderer(id, text); + } else { + renderer = info.renderer(id, text); + } + } + return renderer.apply(this, arguments); + }; + if (info.fragRenderer) { + return $view.preload(id, registeredRenderer); + } else { + return $view.preloadStringRenderer(id, registeredRenderer); + } + }; + }, + types: {}, + ext: '.ejs', + registerScript: function (type, id, src) { + return 'can.view.preloadStringRenderer(\'' + id + '\',' + $view.types['.' + type].script(id, src) + ');'; + }, + preload: function (id, renderer) { + var def = $view.cached[id] = new can.Deferred().resolve(function (data, helpers) { + return renderer.call(data, data, helpers); + }); + def.__view_id = id; + $view.cachedRenderers[id] = renderer; + return renderer; + }, + preloadStringRenderer: function (id, stringRenderer) { + return this.preload(id, makeRenderer(stringRenderer)); + }, + render: function (view, data, helpers, callback) { + return can.view.renderAs('string', view, data, helpers, callback); + }, + renderTo: function (format, renderer, data, helpers) { + return (format === 'string' && renderer.render ? renderer.render : renderer)(data, helpers); + }, + renderAs: function (format, view, data, helpers, callback) { + if (isFunction(helpers)) { + callback = helpers; + helpers = undefined; + } + var deferreds = getDeferreds(data); + var reading, deferred, dataCopy, async, response; + if (deferreds.length) { + deferred = new can.Deferred(); + dataCopy = can.extend({}, data); + deferreds.push(getRenderer(view, true)); + can.when.apply(can, deferreds).then(function (resolved) { + var objs = makeArray(arguments), renderer = objs.pop(), result; + if (can.isDeferred(data)) { + dataCopy = usefulPart(resolved); + } else { + for (var prop in data) { + if (can.isDeferred(data[prop])) { + dataCopy[prop] = usefulPart(objs.shift()); + } + } + } + result = can.view.renderTo(format, renderer, dataCopy, helpers); + deferred.resolve(result, dataCopy); + if (callback) { + callback(result, dataCopy); + } + }, function () { + deferred.reject.apply(deferred, arguments); + }); + return deferred; + } else { + reading = can.__clearReading(); + async = isFunction(callback); + deferred = getRenderer(view, async); + if (reading) { + can.__setReading(reading); + } + if (async) { + response = deferred; + deferred.then(function (renderer) { + callback(data ? can.view.renderTo(format, renderer, data, helpers) : renderer); + }); + } else { + if (deferred.state() === 'resolved' && deferred.__view_id) { + var currentRenderer = $view.cachedRenderers[deferred.__view_id]; + return data ? can.view.renderTo(format, currentRenderer, data, helpers) : currentRenderer; + } else { + deferred.then(function (renderer) { + response = data ? can.view.renderTo(format, renderer, data, helpers) : renderer; + }); + } + } + return response; + } + }, + registerView: function (id, text, type, def) { + var info = typeof type === 'object' ? type : $view.types[type || $view.ext], renderer; + if (info.fragRenderer) { + renderer = info.fragRenderer(id, text); + } else { + renderer = makeRenderer(info.renderer(id, text)); + } + def = def || new can.Deferred(); + if ($view.cache) { + $view.cached[id] = def; + def.__view_id = id; + $view.cachedRenderers[id] = renderer; + } + return def.resolve(renderer); + } + }); + return can; +}); +/*can@2.2.6#view/callbacks/callbacks*/ +define('can/view/callbacks/callbacks', [ + 'can/util/util', + 'can/view/view' +], function (can) { + var attr = can.view.attr = function (attributeName, attrHandler) { + if (attrHandler) { + if (typeof attributeName === 'string') { + attributes[attributeName] = attrHandler; + } else { + regExpAttributes.push({ + match: attributeName, + handler: attrHandler + }); + } + } else { + var cb = attributes[attributeName]; + if (!cb) { + for (var i = 0, len = regExpAttributes.length; i < len; i++) { + var attrMatcher = regExpAttributes[i]; + if (attrMatcher.match.test(attributeName)) { + cb = attrMatcher.handler; + break; + } + } + } + return cb; + } + }; + var attributes = {}, regExpAttributes = [], automaticCustomElementCharacters = /[-\:]/; + var tag = can.view.tag = function (tagName, tagHandler) { + if (tagHandler) { + if (can.global.html5) { + can.global.html5.elements += ' ' + tagName; + can.global.html5.shivDocument(); + } + tags[tagName.toLowerCase()] = tagHandler; + } else { + var cb = tags[tagName.toLowerCase()]; + if (!cb && automaticCustomElementCharacters.test(tagName)) { + cb = function () { + }; + } + return cb; + } + }; + var tags = {}; + can.view.callbacks = { + _tags: tags, + _attributes: attributes, + _regExpAttributes: regExpAttributes, + tag: tag, + attr: attr, + tagHandler: function (el, tagName, tagData) { + var helperTagCallback = tagData.options.attr('tags.' + tagName), tagCallback = helperTagCallback || tags[tagName]; + var scope = tagData.scope, res; + if (tagCallback) { + var reads = can.__clearReading(); + res = tagCallback(el, tagData); + can.__setReading(reads); + } else { + res = scope; + } + if (res && tagData.subtemplate) { + if (scope !== res) { + scope = scope.add(res); + } + var result = tagData.subtemplate(scope, tagData.options); + var frag = typeof result === 'string' ? can.view.frag(result) : result; + can.appendChild(el, frag); + } + } + }; + return can.view.callbacks; +}); +/*can@2.2.6#view/elements*/ +define('can/view/elements', [ + 'can/util/util', + 'can/view/view' +], function (can) { + var doc = typeof document !== 'undefined' ? document : null; + var selectsCommentNodes = doc && function () { + return can.$(document.createComment('~')).length === 1; + }(); + var elements = { + tagToContentPropMap: { + option: doc && 'textContent' in document.createElement('option') ? 'textContent' : 'innerText', + textarea: 'value' + }, + attrMap: can.attr.map, + attrReg: /([^\s=]+)[\s]*=[\s]*/, + defaultValue: can.attr.defaultValue, + tagMap: { + '': 'span', + colgroup: 'col', + table: 'tbody', + tr: 'td', + ol: 'li', + ul: 'li', + tbody: 'tr', + thead: 'tr', + tfoot: 'tr', + select: 'option', + optgroup: 'option' + }, + reverseTagMap: { + col: 'colgroup', + tr: 'tbody', + option: 'select', + td: 'tr', + th: 'tr', + li: 'ul' + }, + getParentNode: function (el, defaultParentNode) { + return defaultParentNode && el.parentNode.nodeType === 11 ? defaultParentNode : el.parentNode; + }, + setAttr: can.attr.set, + getAttr: can.attr.get, + removeAttr: can.attr.remove, + contentText: function (text) { + if (typeof text === 'string') { + return text; + } + if (!text && text !== 0) { + return ''; + } + return '' + text; + }, + after: function (oldElements, newFrag) { + var last = oldElements[oldElements.length - 1]; + if (last.nextSibling) { + can.insertBefore(last.parentNode, newFrag, last.nextSibling); + } else { + can.appendChild(last.parentNode, newFrag); + } + }, + replace: function (oldElements, newFrag) { + elements.after(oldElements, newFrag); + if (can.remove(can.$(oldElements)).length < oldElements.length && !selectsCommentNodes) { + can.each(oldElements, function (el) { + if (el.nodeType === 8) { + el.parentNode.removeChild(el); + } + }); + } + } + }; + can.view.elements = elements; + return elements; +}); +/*can@2.2.6#util/string/string*/ +define('can/util/string/string', ['can/util/util'], function (can) { + var strUndHash = /_|-/, strColons = /\=\=/, strWords = /([A-Z]+)([A-Z][a-z])/g, strLowUp = /([a-z\d])([A-Z])/g, strDash = /([a-z\d])([A-Z])/g, strReplacer = /\{([^\}]+)\}/g, strQuote = /"/g, strSingleQuote = /'/g, strHyphenMatch = /-+(.)?/g, strCamelMatch = /[a-z][A-Z]/g, getNext = function (obj, prop, add) { + var result = obj[prop]; + if (result === undefined && add === true) { + result = obj[prop] = {}; + } + return result; + }, isContainer = function (current) { + return /^f|^o/.test(typeof current); + }, convertBadValues = function (content) { + var isInvalid = content === null || content === undefined || isNaN(content) && '' + content === 'NaN'; + return '' + (isInvalid ? '' : content); + }; + can.extend(can, { + esc: function (content) { + return convertBadValues(content).replace(/&/g, '&').replace(//g, '>').replace(strQuote, '"').replace(strSingleQuote, '''); + }, + getObject: function (name, roots, add) { + var parts = name ? name.split('.') : [], length = parts.length, current, r = 0, i, container, rootsLength; + roots = can.isArray(roots) ? roots : [roots || window]; + rootsLength = roots.length; + if (!length) { + return roots[0]; + } + for (r; r < rootsLength; r++) { + current = roots[r]; + container = undefined; + for (i = 0; i < length && isContainer(current); i++) { + container = current; + current = getNext(container, parts[i]); + } + if (container !== undefined && current !== undefined) { + break; + } + } + if (add === false && current !== undefined) { + delete container[parts[i - 1]]; + } + if (add === true && current === undefined) { + current = roots[0]; + for (i = 0; i < length && isContainer(current); i++) { + current = getNext(current, parts[i], true); + } + } + return current; + }, + capitalize: function (s, cache) { + return s.charAt(0).toUpperCase() + s.slice(1); + }, + camelize: function (str) { + return convertBadValues(str).replace(strHyphenMatch, function (match, chr) { + return chr ? chr.toUpperCase() : ''; + }); + }, + hyphenate: function (str) { + return convertBadValues(str).replace(strCamelMatch, function (str, offset) { + return str.charAt(0) + '-' + str.charAt(1).toLowerCase(); + }); + }, + underscore: function (s) { + return s.replace(strColons, '/').replace(strWords, '$1_$2').replace(strLowUp, '$1_$2').replace(strDash, '_').toLowerCase(); + }, + sub: function (str, data, remove) { + var obs = []; + str = str || ''; + obs.push(str.replace(strReplacer, function (whole, inside) { + var ob = can.getObject(inside, data, remove === true ? false : undefined); + if (ob === undefined || ob === null) { + obs = null; + return ''; + } + if (isContainer(ob) && obs) { + obs.push(ob); + return ''; + } + return '' + ob; + })); + return obs === null ? obs : obs.length <= 1 ? obs[0] : obs; + }, + replacer: strReplacer, + undHash: strUndHash + }); + return can; +}); +/*can@2.2.6#construct/construct*/ +define('can/construct/construct', ['can/util/string/string'], function (can) { + var initializing = 0; + var canGetDescriptor; + try { + Object.getOwnPropertyDescriptor({}); + canGetDescriptor = true; + } catch (e) { + canGetDescriptor = false; + } + var getDescriptor = function (newProps, name) { + var descriptor = Object.getOwnPropertyDescriptor(newProps, name); + if (descriptor && (descriptor.get || descriptor.set)) { + return descriptor; + } + return null; + }, inheritGetterSetter = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + var descriptor; + for (var name in newProps) { + if (descriptor = getDescriptor(newProps, name)) { + this._defineProperty(addTo, oldProps, name, descriptor); + } else { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + } + }, simpleInherit = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + for (var name in newProps) { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + }; + can.Construct = function () { + if (arguments.length) { + return can.Construct.extend.apply(can.Construct, arguments); + } + }; + can.extend(can.Construct, { + constructorExtends: true, + newInstance: function () { + var inst = this.instance(), args; + if (inst.setup) { + args = inst.setup.apply(inst, arguments); + } + if (inst.init) { + inst.init.apply(inst, args || arguments); + } + return inst; + }, + _inherit: canGetDescriptor ? inheritGetterSetter : simpleInherit, + _defineProperty: function (what, oldProps, propName, descriptor) { + Object.defineProperty(what, propName, descriptor); + }, + _overwrite: function (what, oldProps, propName, val) { + what[propName] = val; + }, + setup: function (base, fullName) { + this.defaults = can.extend(true, {}, base.defaults, this.defaults); + }, + instance: function () { + initializing = 1; + var inst = new this(); + initializing = 0; + return inst; + }, + extend: function (name, staticProperties, instanceProperties) { + var fullName = name, klass = staticProperties, proto = instanceProperties; + if (typeof fullName !== 'string') { + proto = klass; + klass = fullName; + fullName = null; + } + if (!proto) { + proto = klass; + klass = null; + } + proto = proto || {}; + var _super_class = this, _super = this.prototype, Constructor, parts, current, _fullName, _shortName, propName, shortName, namespace, prototype; + prototype = this.instance(); + can.Construct._inherit(proto, _super, prototype); + if (fullName) { + parts = fullName.split('.'); + shortName = parts.pop(); + } + if (typeof constructorName === 'undefined') { + Constructor = function () { + return init.apply(this, arguments); + }; + } + function init() { + if (!initializing) { + return this.constructor !== Constructor && arguments.length && Constructor.constructorExtends ? Constructor.extend.apply(Constructor, arguments) : Constructor.newInstance.apply(Constructor, arguments); + } + } + for (propName in _super_class) { + if (_super_class.hasOwnProperty(propName)) { + Constructor[propName] = _super_class[propName]; + } + } + can.Construct._inherit(klass, _super_class, Constructor); + if (fullName) { + current = can.getObject(parts.join('.'), window, true); + namespace = current; + _fullName = can.underscore(fullName.replace(/\./g, '_')); + _shortName = can.underscore(shortName); + current[shortName] = Constructor; + } + can.extend(Constructor, { + constructor: Constructor, + prototype: prototype, + namespace: namespace, + _shortName: _shortName, + fullName: fullName, + _fullName: _fullName + }); + if (shortName !== undefined) { + Constructor.shortName = shortName; + } + Constructor.prototype.constructor = Constructor; + var t = [_super_class].concat(can.makeArray(arguments)), args = Constructor.setup.apply(Constructor, t); + if (Constructor.init) { + Constructor.init.apply(Constructor, args || t); + } + return Constructor; + } + }); + can.Construct.prototype.setup = function () { + }; + can.Construct.prototype.init = function () { + }; + return can.Construct; +}); +/*can@2.2.6#control/control*/ +define('can/control/control', [ + 'can/util/util', + 'can/construct/construct' +], function (can) { + var bind = function (el, ev, callback) { + can.bind.call(el, ev, callback); + return function () { + can.unbind.call(el, ev, callback); + }; + }, isFunction = can.isFunction, extend = can.extend, each = can.each, slice = [].slice, paramReplacer = /\{([^\}]+)\}/g, special = can.getObject('$.event.special', [can]) || {}, delegate = function (el, selector, ev, callback) { + can.delegate.call(el, selector, ev, callback); + return function () { + can.undelegate.call(el, selector, ev, callback); + }; + }, binder = function (el, ev, callback, selector) { + return selector ? delegate(el, can.trim(selector), ev, callback) : bind(el, ev, callback); + }, basicProcessor; + var Control = can.Control = can.Construct({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Control) { + var control = this, funcName; + control.actions = {}; + for (funcName in control.prototype) { + if (control._isAction(funcName)) { + control.actions[funcName] = control._action(funcName); + } + } + } + }, + _shifter: function (context, name) { + var method = typeof name === 'string' ? context[name] : name; + if (!isFunction(method)) { + method = context[method]; + } + return function () { + context.called = name; + return method.apply(context, [this.nodeName ? can.$(this) : this].concat(slice.call(arguments, 0))); + }; + }, + _isAction: function (methodName) { + var val = this.prototype[methodName], type = typeof val; + return methodName !== 'constructor' && (type === 'function' || type === 'string' && isFunction(this.prototype[val])) && !!(special[methodName] || processors[methodName] || /[^\w]/.test(methodName)); + }, + _action: function (methodName, options) { + paramReplacer.lastIndex = 0; + if (options || !paramReplacer.test(methodName)) { + var convertedName = options ? can.sub(methodName, this._lookup(options)) : methodName; + if (!convertedName) { + return null; + } + var arr = can.isArray(convertedName), name = arr ? convertedName[1] : convertedName, parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: processors[event] || basicProcessor, + parts: [ + name, + parts.join(' '), + event + ], + delegate: arr ? convertedName[0] : undefined + }; + } + }, + _lookup: function (options) { + return [ + options, + window + ]; + }, + processors: {}, + defaults: {} + }, { + setup: function (element, options) { + var cls = this.constructor, pluginname = cls.pluginName || cls._fullName, arr; + this.element = can.$(element); + if (pluginname && pluginname !== 'can_control') { + this.element.addClass(pluginname); + } + arr = can.data(this.element, 'controls'); + if (!arr) { + arr = []; + can.data(this.element, 'controls', arr); + } + arr.push(this); + this.options = extend({}, cls.defaults, options); + this.on(); + return [ + this.element, + this.options + ]; + }, + on: function (el, selector, eventName, func) { + if (!el) { + this.off(); + var cls = this.constructor, bindings = this._bindings, actions = cls.actions, element = this.element, destroyCB = can.Control._shifter(this, 'destroy'), funcName, ready; + for (funcName in actions) { + if (actions.hasOwnProperty(funcName)) { + ready = actions[funcName] || cls._action(funcName, this.options, this); + if (ready) { + bindings.control[funcName] = ready.processor(ready.delegate || element, ready.parts[2], ready.parts[1], funcName, this); + } + } + } + can.bind.call(element, 'removed', destroyCB); + bindings.user.push(function (el) { + can.unbind.call(el, 'removed', destroyCB); + }); + return bindings.user.length; + } + if (typeof el === 'string') { + func = eventName; + eventName = selector; + selector = el; + el = this.element; + } + if (func === undefined) { + func = eventName; + eventName = selector; + selector = null; + } + if (typeof func === 'string') { + func = can.Control._shifter(this, func); + } + this._bindings.user.push(binder(el, eventName, func, selector)); + return this._bindings.user.length; + }, + off: function () { + var el = this.element[0], bindings = this._bindings; + if (bindings) { + each(bindings.user || [], function (value) { + value(el); + }); + each(bindings.control || {}, function (value) { + value(el); + }); + } + this._bindings = { + user: [], + control: {} + }; + }, + destroy: function () { + if (this.element === null) { + return; + } + var Class = this.constructor, pluginName = Class.pluginName || Class._fullName, controls; + this.off(); + if (pluginName && pluginName !== 'can_control') { + this.element.removeClass(pluginName); + } + controls = can.data(this.element, 'controls'); + controls.splice(can.inArray(this, controls), 1); + can.trigger(this, 'destroyed'); + this.element = null; + } + }); + var processors = can.Control.processors; + basicProcessor = function (el, event, selector, methodName, control) { + return binder(el, event, can.Control._shifter(control, methodName), selector); + }; + each([ + 'change', + 'click', + 'contextmenu', + 'dblclick', + 'keydown', + 'keyup', + 'keypress', + 'mousedown', + 'mousemove', + 'mouseout', + 'mouseover', + 'mouseup', + 'reset', + 'resize', + 'scroll', + 'select', + 'submit', + 'focusin', + 'focusout', + 'mouseenter', + 'mouseleave', + 'touchstart', + 'touchmove', + 'touchcancel', + 'touchend', + 'touchleave', + 'inserted', + 'removed' + ], function (v) { + processors[v] = basicProcessor; + }); + return Control; +}); +/*can@2.2.6#util/bind/bind*/ +define('can/util/bind/bind', ['can/util/util'], function (can) { + can.bindAndSetup = function () { + can.addEvent.apply(this, arguments); + if (!this._init) { + if (!this._bindings) { + this._bindings = 1; + if (this._bindsetup) { + this._bindsetup(); + } + } else { + this._bindings++; + } + } + return this; + }; + can.unbindAndTeardown = function (event, handler) { + var handlers = this.__bindEvents[event] || []; + var handlerCount = handlers.length; + can.removeEvent.apply(this, arguments); + if (this._bindings === null) { + this._bindings = 0; + } else { + this._bindings = this._bindings - (handlerCount - handlers.length); + } + if (!this._bindings && this._bindteardown) { + this._bindteardown(); + } + return this; + }; + return can; +}); +/*can@2.2.6#map/bubble*/ +define('can/map/bubble', ['can/util/util'], function (can) { + var bubble = can.bubble = { + event: function (map, boundEventName) { + return map.constructor._bubbleRule(boundEventName, map); + }, + childrenOf: function (parentMap, eventName) { + parentMap._each(function (child, prop) { + if (child && child.bind) { + bubble.toParent(child, parentMap, prop, eventName); + } + }); + }, + teardownChildrenFrom: function (parentMap, eventName) { + parentMap._each(function (child) { + bubble.teardownFromParent(parentMap, child, eventName); + }); + }, + toParent: function (child, parent, prop, eventName) { + can.listenTo.call(parent, child, eventName, function () { + var args = can.makeArray(arguments), ev = args.shift(); + args[0] = (can.List && parent instanceof can.List ? parent.indexOf(child) : prop) + (args[0] ? '.' + args[0] : ''); + ev.triggeredNS = ev.triggeredNS || {}; + if (ev.triggeredNS[parent._cid]) { + return; + } + ev.triggeredNS[parent._cid] = true; + can.trigger(parent, ev, args); + }); + }, + teardownFromParent: function (parent, child, eventName) { + if (child && child.unbind) { + can.stopListening.call(parent, child, eventName); + } + }, + isBubbling: function (parent, eventName) { + return parent._bubbleBindings && parent._bubbleBindings[eventName]; + }, + bind: function (parent, eventName) { + if (!parent._init) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + if (!parent._bubbleBindings) { + parent._bubbleBindings = {}; + } + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (!parent._bubbleBindings[bubbleEvent]) { + parent._bubbleBindings[bubbleEvent] = 1; + bubble.childrenOf(parent, bubbleEvent); + } else { + parent._bubbleBindings[bubbleEvent]++; + } + } + } + }, + unbind: function (parent, eventName) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (parent._bubbleBindings) { + parent._bubbleBindings[bubbleEvent]--; + } + if (parent._bubbleBindings && !parent._bubbleBindings[bubbleEvent]) { + delete parent._bubbleBindings[bubbleEvent]; + bubble.teardownChildrenFrom(parent, bubbleEvent); + if (can.isEmptyObject(parent._bubbleBindings)) { + delete parent._bubbleBindings; + } + } + } + }, + add: function (parent, child, prop) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + bubble.toParent(child, parent, prop, eventName); + } + } + } + }, + removeMany: function (parent, children) { + for (var i = 0, len = children.length; i < len; i++) { + bubble.remove(parent, children[i]); + } + }, + remove: function (parent, child) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + } + } + } + }, + set: function (parent, prop, value, current) { + if (can.Map.helpers.isObservable(value)) { + bubble.add(parent, value, prop); + } + if (can.Map.helpers.isObservable(current)) { + bubble.remove(parent, current); + } + return value; + } + }; + return bubble; +}); +/*can@2.2.6#util/batch/batch*/ +define('can/util/batch/batch', ['can/util/can'], function (can) { + var batchNum = 1, transactions = 0, batchEvents = [], stopCallbacks = [], currentBatchEvents = null; + can.batch = { + start: function (batchStopHandler) { + transactions++; + if (batchStopHandler) { + stopCallbacks.push(batchStopHandler); + } + }, + stop: function (force, callStart) { + if (force) { + transactions = 0; + } else { + transactions--; + } + if (transactions === 0) { + if (currentBatchEvents !== null) { + return; + } + currentBatchEvents = batchEvents.slice(0); + var callbacks = stopCallbacks.slice(0), i, len; + batchEvents = []; + stopCallbacks = []; + can.batch.batchNum = batchNum; + batchNum++; + if (callStart) { + can.batch.start(); + } + for (i = 0; i < currentBatchEvents.length; i++) { + can.dispatch.apply(currentBatchEvents[i][0], currentBatchEvents[i][1]); + } + currentBatchEvents = null; + for (i = 0, len = callbacks.length; i < callbacks.length; i++) { + callbacks[i](); + } + can.batch.batchNum = undefined; + } + }, + trigger: function (item, event, args) { + if (!item._init) { + event = typeof event === 'string' ? { type: event } : event; + if (currentBatchEvents) { + currentBatchEvents.push([ + item, + [ + event, + args + ] + ]); + } else if (transactions === 0) { + return can.dispatch.call(item, event, args); + } else { + event.batchNum = batchNum; + batchEvents.push([ + item, + [ + event, + args + ] + ]); + } + } + }, + afterPreviousEvents: function (handler) { + if (currentBatchEvents) { + var obj = {}; + can.bind.call(obj, 'ready', handler); + currentBatchEvents.push([ + obj, + [ + { type: 'ready' }, + [] + ] + ]); + } else { + handler(); + } + } + }; +}); +/*can@2.2.6#map/map*/ +define('can/map/map', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/map/bubble', + 'can/construct/construct', + 'can/util/batch/batch' +], function (can, bind, bubble) { + var madeMap = null; + var teardownMap = function () { + for (var cid in madeMap) { + if (madeMap[cid].added) { + delete madeMap[cid].obj._cid; + } + } + madeMap = null; + }; + var getMapFromObject = function (obj) { + return madeMap && madeMap[obj._cid] && madeMap[obj._cid].instance; + }; + var serializeMap = null; + var Map = can.Map = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Map) { + if (!this.defaults) { + this.defaults = {}; + } + this._computes = []; + for (var prop in this.prototype) { + if (prop !== 'define' && prop !== 'constructor' && (typeof this.prototype[prop] !== 'function' || this.prototype[prop].prototype instanceof can.Construct)) { + this.defaults[prop] = this.prototype[prop]; + } else if (this.prototype[prop].isComputed) { + this._computes.push(prop); + } + } + if (this.helpers.define) { + this.helpers.define(this); + } + } + if (can.List && !(this.prototype instanceof can.List)) { + this.List = Map.List.extend({ Map: this }, {}); + } + }, + _bubble: bubble, + _bubbleRule: function (eventName) { + return eventName === 'change' || eventName.indexOf('.') >= 0 ? ['change'] : []; + }, + _computes: [], + bind: can.bindAndSetup, + on: can.bindAndSetup, + unbind: can.unbindAndTeardown, + off: can.unbindAndTeardown, + id: 'id', + helpers: { + define: null, + attrParts: function (attr, keepKey) { + if (keepKey) { + return [attr]; + } + return typeof attr === 'object' ? attr : ('' + attr).split('.'); + }, + addToMap: function (obj, instance) { + var teardown; + if (!madeMap) { + teardown = teardownMap; + madeMap = {}; + } + var hasCid = obj._cid; + var cid = can.cid(obj); + if (!madeMap[cid]) { + madeMap[cid] = { + obj: obj, + instance: instance, + added: !hasCid + }; + } + return teardown; + }, + isObservable: function (obj) { + return obj instanceof can.Map || obj && obj === can.route; + }, + canMakeObserve: function (obj) { + return obj && !can.isDeferred(obj) && (can.isArray(obj) || can.isPlainObject(obj)); + }, + serialize: function (map, how, where) { + var cid = can.cid(map), firstSerialize = false; + if (!serializeMap) { + firstSerialize = true; + serializeMap = { + attr: {}, + serialize: {} + }; + } + serializeMap[how][cid] = where; + map.each(function (val, name) { + var result, isObservable = Map.helpers.isObservable(val), serialized = isObservable && serializeMap[how][can.cid(val)]; + if (serialized) { + result = serialized; + } else { + if (how === 'serialize') { + result = Map.helpers._serialize(map, name, val); + } else { + result = Map.helpers._getValue(map, name, val, how); + } + } + if (result !== undefined) { + where[name] = result; + } + }); + can.__observe(map, '__keys'); + if (firstSerialize) { + serializeMap = null; + } + return where; + }, + _serialize: function (map, name, val) { + return Map.helpers._getValue(map, name, val, 'serialize'); + }, + _getValue: function (map, name, val, how) { + if (Map.helpers.isObservable(val)) { + return val[how](); + } else { + return val; + } + } + }, + keys: function (map) { + var keys = []; + can.__observe(map, '__keys'); + for (var keyName in map._data) { + keys.push(keyName); + } + return keys; + } + }, { + setup: function (obj) { + if (obj instanceof can.Map) { + obj = obj.serialize(); + } + this._data = {}; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + var defaultValues = this._setupDefaults(obj); + this._setupComputes(defaultValues); + var teardownMapping = obj && can.Map.helpers.addToMap(obj, this); + var data = can.extend(can.extend(true, {}, defaultValues), obj); + this.attr(data); + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + delete this._init; + }, + _setupComputes: function () { + var computes = this.constructor._computes; + for (var i = 0, len = computes.length, prop; i < len; i++) { + prop = computes[i]; + this[prop] = this[prop].clone(this); + this._computedBindings[prop] = { count: 0 }; + } + }, + _setupDefaults: function () { + return this.constructor.defaults || {}; + }, + _bindsetup: function () { + }, + _bindteardown: function () { + }, + _changes: function (ev, attr, how, newVal, oldVal) { + can.batch.trigger(this, { + type: attr, + batchNum: ev.batchNum, + target: ev.target + }, [ + newVal, + oldVal + ]); + }, + _triggerChange: function (attr, how, newVal, oldVal) { + if (bubble.isBubbling(this, 'change')) { + can.batch.trigger(this, { + type: 'change', + target: this + }, [ + attr, + how, + newVal, + oldVal + ]); + } else { + can.batch.trigger(this, attr, [ + newVal, + oldVal + ]); + } + if (how === 'remove' || how === 'add') { + can.batch.trigger(this, { + type: '__keys', + target: this + }); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var prop in data) { + if (data.hasOwnProperty(prop)) { + callback(data[prop], prop); + } + } + }, + attr: function (attr, val) { + var type = typeof attr; + if (type !== 'string' && type !== 'number') { + return this._attrs(attr, val); + } else if (arguments.length === 1) { + return this._get(attr); + } else { + this._set(attr, val); + return this; + } + }, + each: function () { + return can.each.apply(undefined, [this].concat(can.makeArray(arguments))); + }, + removeAttr: function (attr) { + var isList = can.List && this instanceof can.List, parts = can.Map.helpers.attrParts(attr), prop = parts.shift(), current = isList ? this[prop] : this._data[prop]; + if (parts.length && current) { + return current.removeAttr(parts); + } else { + if (typeof attr === 'string' && !!~attr.indexOf('.')) { + prop = attr; + } + this._remove(prop, current); + return current; + } + }, + _remove: function (prop, current) { + if (prop in this._data) { + delete this._data[prop]; + if (!(prop in this.constructor.prototype)) { + delete this[prop]; + } + this._triggerChange(prop, 'remove', undefined, current); + } + }, + _get: function (attr) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'); + if (dotIndex >= 0) { + var value = this.__get(attr); + if (value !== undefined) { + return value; + } + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + can.__observe(this, first); + var current = this.__get(first); + return current && current._get ? current._get(second) : undefined; + } else { + can.__observe(this, attr); + return this.__get(attr); + } + }, + __get: function (attr) { + if (attr) { + if (this._computedBindings[attr]) { + return this[attr](); + } else { + return this._data[attr]; + } + } else { + return this._data; + } + }, + __type: function (value, prop) { + if (!(value instanceof can.Map) && can.Map.helpers.canMakeObserve(value)) { + var cached = getMapFromObject(value); + if (cached) { + return cached; + } + if (can.isArray(value)) { + var List = can.List; + return new List(value); + } else { + var Map = this.constructor.Map || can.Map; + return new Map(value); + } + } + return value; + }, + _set: function (attr, value, keepKey) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'), current; + if (!keepKey && dotIndex >= 0) { + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + current = this._init ? undefined : this.__get(first); + if (Map.helpers.isObservable(current)) { + current._set(second, value); + } else { + throw 'can.Map: Object does not exist'; + } + } else { + if (this.__convert) { + value = this.__convert(attr, value); + } + current = this._init ? undefined : this.__get(attr); + this.__set(attr, this.__type(value, attr), current); + } + }, + __set: function (prop, value, current) { + if (value !== current) { + var changeType = current !== undefined || this.__get().hasOwnProperty(prop) ? 'set' : 'add'; + this.___set(prop, this.constructor._bubble.set(this, prop, value, current)); + if (!this._computedBindings[prop]) { + this._triggerChange(prop, changeType, value, current); + } + if (current) { + this.constructor._bubble.teardownFromParent(this, current); + } + } + }, + ___set: function (prop, val) { + if (this._computedBindings[prop]) { + this[prop](val); + } else { + this._data[prop] = val; + } + if (typeof this.constructor.prototype[prop] !== 'function' && !this._computedBindings[prop]) { + this[prop] = val; + } + }, + bind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (!computedBinding.count) { + computedBinding.count = 1; + var self = this; + computedBinding.handler = function (ev, newVal, oldVal) { + can.batch.trigger(self, { + type: eventName, + batchNum: ev.batchNum, + target: self + }, [ + newVal, + oldVal + ]); + }; + this[eventName].bind('change', computedBinding.handler); + } else { + computedBinding.count++; + } + } + this.constructor._bubble.bind(this, eventName); + return can.bindAndSetup.apply(this, arguments); + }, + unbind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (computedBinding.count === 1) { + computedBinding.count = 0; + this[eventName].unbind('change', computedBinding.handler); + delete computedBinding.handler; + } else { + computedBinding.count--; + } + } + this.constructor._bubble.unbind(this, eventName); + return can.unbindAndTeardown.apply(this, arguments); + }, + serialize: function () { + return can.Map.helpers.serialize(this, 'serialize', {}); + }, + _attrs: function (props, remove) { + if (props === undefined) { + return Map.helpers.serialize(this, 'attr', {}); + } + props = can.simpleExtend({}, props); + var prop, self = this, newVal; + can.batch.start(); + this.each(function (curVal, prop) { + if (prop === '_cid') { + return; + } + newVal = props[prop]; + if (newVal === undefined) { + if (remove) { + self.removeAttr(prop); + } + return; + } + if (self.__convert) { + newVal = self.__convert(prop, newVal); + } + if (Map.helpers.isObservable(newVal)) { + self.__set(prop, self.__type(newVal, prop), curVal); + } else if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + self.__set(prop, self.__type(newVal, prop), curVal); + } + delete props[prop]; + }); + for (prop in props) { + if (prop !== '_cid') { + newVal = props[prop]; + this._set(prop, newVal, true); + } + } + can.batch.stop(); + return this; + }, + compute: function (prop) { + if (can.isFunction(this.constructor.prototype[prop])) { + return can.compute(this[prop], this); + } else { + var reads = prop.split('.'), last = reads.length - 1, options = { args: [] }; + return can.compute(function (newVal) { + if (arguments.length) { + can.compute.read(this, reads.slice(0, last)).value.attr(reads[last], newVal); + } else { + return can.compute.read(this, reads, options).value; + } + }, this); + } + } + }); + Map.prototype.on = Map.prototype.bind; + Map.prototype.off = Map.prototype.unbind; + return Map; +}); +/*can@2.2.6#list/list*/ +define('can/list/list', [ + 'can/util/util', + 'can/map/map', + 'can/map/bubble' +], function (can, Map, bubble) { + var splice = [].splice, spliceRemovesProps = function () { + var obj = { + 0: 'a', + length: 1 + }; + splice.call(obj, 0, 1); + return !obj[0]; + }(); + var list = Map.extend({ Map: Map }, { + setup: function (instances, options) { + this.length = 0; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + this._setupComputes(); + instances = instances || []; + var teardownMapping; + if (can.isDeferred(instances)) { + this.replace(instances); + } else { + teardownMapping = instances.length && can.Map.helpers.addToMap(instances, this); + this.push.apply(this, can.makeArray(instances || [])); + } + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + can.simpleExtend(this, options); + delete this._init; + }, + _triggerChange: function (attr, how, newVal, oldVal) { + Map.prototype._triggerChange.apply(this, arguments); + var index = +attr; + if (!~('' + attr).indexOf('.') && !isNaN(index)) { + if (how === 'add') { + can.batch.trigger(this, how, [ + newVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else if (how === 'remove') { + can.batch.trigger(this, how, [ + oldVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else { + can.batch.trigger(this, how, [ + newVal, + index + ]); + } + } + }, + __get: function (attr) { + if (attr) { + if (this[attr] && this[attr].isComputed && can.isFunction(this.constructor.prototype[attr])) { + return this[attr](); + } else { + return this[attr]; + } + } else { + return this; + } + }, + __set: function (prop, value, current) { + prop = isNaN(+prop) || prop % 1 ? prop : +prop; + if (typeof prop === 'number' && prop > this.length - 1) { + var newArr = new Array(prop + 1 - this.length); + newArr[newArr.length - 1] = value; + this.push.apply(this, newArr); + return newArr; + } + return can.Map.prototype.__set.call(this, '' + prop, value, current); + }, + ___set: function (attr, val) { + this[attr] = val; + if (+attr >= this.length) { + this.length = +attr + 1; + } + }, + _remove: function (prop, current) { + if (isNaN(+prop)) { + delete this[prop]; + this._triggerChange(prop, 'remove', undefined, current); + } else { + this.splice(prop, 1); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var i = 0; i < data.length; i++) { + callback(data[i], i); + } + }, + serialize: function () { + return Map.helpers.serialize(this, 'serialize', []); + }, + splice: function (index, howMany) { + var args = can.makeArray(arguments), added = [], i, len, listIndex, allSame = args.length > 2; + index = index || 0; + for (i = 0, len = args.length - 2; i < len; i++) { + listIndex = i + 2; + args[listIndex] = this.__type(args[listIndex], listIndex); + added.push(args[listIndex]); + if (this[i + index] !== args[listIndex]) { + allSame = false; + } + } + if (allSame && this.length <= added.length) { + return added; + } + if (howMany === undefined) { + howMany = args[1] = this.length - index; + } + var removed = splice.apply(this, args); + if (!spliceRemovesProps) { + for (i = this.length; i < removed.length + this.length; i++) { + delete this[i]; + } + } + can.batch.start(); + if (howMany > 0) { + bubble.removeMany(this, removed); + this._triggerChange('' + index, 'remove', undefined, removed); + } + if (args.length > 2) { + for (i = 0, len = added.length; i < len; i++) { + bubble.set(this, i, added[i]); + } + this._triggerChange('' + index, 'add', added, removed); + } + can.batch.stop(); + return removed; + }, + _attrs: function (items, remove) { + if (items === undefined) { + return Map.helpers.serialize(this, 'attr', []); + } + items = can.makeArray(items); + can.batch.start(); + this._updateAttrs(items, remove); + can.batch.stop(); + }, + _updateAttrs: function (items, remove) { + var len = Math.min(items.length, this.length); + for (var prop = 0; prop < len; prop++) { + var curVal = this[prop], newVal = items[prop]; + if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + this._set(prop, newVal); + } else { + } + } + if (items.length > this.length) { + this.push.apply(this, items.slice(this.length)); + } else if (items.length < this.length && remove) { + this.splice(items.length); + } + } + }), getArgs = function (args) { + return args[0] && can.isArray(args[0]) ? args[0] : can.makeArray(args); + }; + can.each({ + push: 'length', + unshift: 0 + }, function (where, name) { + var orig = [][name]; + list.prototype[name] = function () { + var args = [], len = where ? this.length : 0, i = arguments.length, res, val; + while (i--) { + val = arguments[i]; + args[i] = bubble.set(this, i, this.__type(val, i)); + } + res = orig.apply(this, args); + if (!this.comparator || args.length) { + this._triggerChange('' + len, 'add', args, undefined); + } + return res; + }; + }); + can.each({ + pop: 'length', + shift: 0 + }, function (where, name) { + list.prototype[name] = function () { + if (!this.length) { + return undefined; + } + var args = getArgs(arguments), len = where && this.length ? this.length - 1 : 0; + var res = [][name].apply(this, args); + this._triggerChange('' + len, 'remove', undefined, [res]); + if (res && res.unbind) { + bubble.remove(this, res); + } + return res; + }; + }); + can.extend(list.prototype, { + indexOf: function (item, fromIndex) { + this.attr('length'); + return can.inArray(item, this, fromIndex); + }, + join: function () { + return [].join.apply(this.attr(), arguments); + }, + reverse: function () { + var list = [].reverse.call(can.makeArray(this)); + this.replace(list); + }, + slice: function () { + var temp = Array.prototype.slice.apply(this, arguments); + return new this.constructor(temp); + }, + concat: function () { + var args = []; + can.each(can.makeArray(arguments), function (arg, i) { + args[i] = arg instanceof can.List ? arg.serialize() : arg; + }); + return new this.constructor(Array.prototype.concat.apply(this.serialize(), args)); + }, + forEach: function (cb, thisarg) { + return can.each(this, cb, thisarg || this); + }, + replace: function (newList) { + if (can.isDeferred(newList)) { + newList.then(can.proxy(this.replace, this)); + } else { + this.splice.apply(this, [ + 0, + this.length + ].concat(can.makeArray(newList || []))); + } + return this; + }, + filter: function (callback, thisArg) { + var filteredList = new can.List(), self = this, filtered; + this.each(function (item, index, list) { + filtered = callback.call(thisArg | self, item, index, self); + if (filtered) { + filteredList.push(item); + } + }); + return filteredList; + } + }); + can.List = Map.List = list; + return can.List; +}); +/*can@2.2.6#compute/read*/ +define('can/compute/read', ['can/util/util'], function (can) { + var read = function (parent, reads, options) { + options = options || {}; + var state = { foundObservable: false }; + var cur = readValue(parent, 0, reads, options, state), type, prev, readLength = reads.length, i = 0; + while (i < readLength) { + prev = cur; + for (var r = 0, readersLength = read.propertyReaders.length; r < readersLength; r++) { + var reader = read.propertyReaders[r]; + if (reader.test(cur)) { + cur = reader.read(cur, reads[i], i, options, state); + break; + } + } + i = i + 1; + cur = readValue(cur, i, reads, options, state, prev); + type = typeof cur; + if (i < reads.length && (cur === null || type !== 'function' && type !== 'object')) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1, cur); + } + return { + value: undefined, + parent: prev + }; + } + } + if (cur === undefined) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1); + } + } + return { + value: cur, + parent: prev + }; + }; + var readValue = function (value, index, reads, options, state, prev) { + var usedValueReader; + do { + usedValueReader = false; + for (var i = 0, len = read.valueReaders.length; i < len; i++) { + if (read.valueReaders[i].test(value, index, reads, options)) { + value = read.valueReaders[i].read(value, index, reads, options, state, prev); + } + } + } while (usedValueReader); + return value; + }; + read.valueReaders = [ + { + name: 'compute', + test: function (value, i, reads, options) { + return value && value.isComputed; + }, + read: function (value, i, reads, options, state) { + if (options.isArgument && i === reads.length) { + return value; + } + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, i); + state.foundObservable = true; + } + return value instanceof can.Compute ? value.get() : value(); + } + }, + { + name: 'function', + test: function (value, i, reads, options) { + var type = typeof value; + return type === 'function' && !value.isComputed && (options.executeAnonymousFunctions || options.isArgument && i === reads.length) && !(can.Construct && value.prototype instanceof can.Construct) && !(can.route && value === can.route); + }, + read: function (value, i, reads, options, state, prev) { + if (options.isArgument && i === reads.length) { + return options.proxyMethods !== false ? can.proxy(value, prev) : value; + } + return value.call(prev); + } + } + ]; + read.propertyReaders = [ + { + name: 'map', + test: can.isMapLike, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + if (typeof value[prop] === 'function' && value.constructor.prototype[prop] === value[prop]) { + if (options.returnObserveMethods) { + return value[prop]; + } else if (prop === 'constructor' && value instanceof can.Construct || value[prop].prototype instanceof can.Construct) { + return value[prop]; + } else { + return value[prop].apply(value, options.args || []); + } + } else { + return value.attr(prop); + } + } + }, + { + name: 'promise', + test: function (value) { + return can.isPromise(value); + }, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + var observeData = value.__observeData; + if (!value.__observeData) { + observeData = value.__observeData = { + isPending: true, + state: 'pending', + isResolved: false, + isRejected: false, + value: undefined, + reason: undefined + }; + can.cid(observeData); + can.simpleExtend(observeData, can.event); + value.then(function (value) { + observeData.isPending = false; + observeData.isResolved = true; + observeData.value = value; + observeData.state = 'resolved'; + observeData.dispatch('state', [ + 'resolved', + 'pending' + ]); + }, function (reason) { + observeData.isPending = false; + observeData.isRejected = true; + observeData.reason = reason; + observeData.state = 'rejected'; + observeData.dispatch('state', [ + 'rejected', + 'pending' + ]); + }); + } + can.__observe(observeData, 'state'); + return prop in observeData ? observeData[prop] : value[prop]; + } + }, + { + name: 'object', + test: function () { + return true; + }, + read: function (value, prop) { + if (value == null) { + return undefined; + } else { + return value[prop]; + } + } + } + ]; + read.write = function (parent, key, value, options) { + options = options || {}; + if (can.isMapLike(parent)) { + if (!options.isArgument && parent._data && parent._data[key] && parent._data[key].isComputed) { + return parent._data[key](value); + } else { + return parent.attr(key, value); + } + } + if (parent[key] && parent[key].isComputed) { + return parent[key](value); + } + if (typeof parent === 'object') { + parent[key] = value; + } + }; + return read; +}); +/*can@2.2.6#compute/get_value_and_bind*/ +define('can/compute/get_value_and_bind', ['can/util/util'], function () { + function observe(func, context, oldInfo, onchanged) { + var info = getValueAndObserved(func, context), newObserveSet = info.observed, oldObserved = oldInfo.observed; + if (info.names !== oldInfo.names) { + bindNewSet(oldObserved, newObserveSet, onchanged); + unbindOldSet(oldObserved, onchanged); + } + can.batch.afterPreviousEvents(function () { + info.ready = true; + }); + return info; + } + var observedStack = []; + can.__isRecordingObserves = function () { + return observedStack.length; + }; + can.__observe = can.__reading = function (obj, event) { + if (observedStack.length) { + var name = obj._cid + '|' + event, top = observedStack[observedStack.length - 1]; + top.names += name; + top.observed[name] = { + obj: obj, + event: event + '' + }; + } + }; + can.__notObserve = function (fn) { + return function () { + var previousReads = can.__clearObserved(); + var res = fn.apply(this, arguments); + can.__setObserved(previousReads); + return res; + }; + }; + can.__clearObserved = can.__clearReading = function () { + if (observedStack.length) { + var ret = observedStack[observedStack.length - 1]; + observedStack[observedStack.length - 1] = { observed: {} }; + return ret; + } + }; + can.__setObserved = can.__setReading = function (o) { + if (observedStack.length) { + observedStack[observedStack.length - 1] = o; + } + }; + can.__addObserved = can.__addReading = function (o) { + if (observedStack.length) { + can.simpleExtend(observedStack[observedStack.length - 1], o); + } + }; + var getValueAndObserved = function (func, self) { + observedStack.push({ + names: '', + observed: {} + }); + var value = func.call(self); + var stackItem = observedStack.pop(); + stackItem.value = value; + return stackItem; + }; + var bindNewSet = function (oldObserved, newObserveSet, onchanged) { + for (var name in newObserveSet) { + bindOrPreventUnbinding(oldObserved, newObserveSet, name, onchanged); + } + }; + var bindOrPreventUnbinding = function (oldObserved, newObserveSet, name, onchanged) { + if (oldObserved[name]) { + delete oldObserved[name]; + } else { + var obEv = newObserveSet[name]; + obEv.obj.bind(obEv.event, onchanged); + } + }; + var unbindOldSet = function (oldObserved, onchanged) { + for (var name in oldObserved) { + var obEv = oldObserved[name]; + obEv.obj.unbind(obEv.event, onchanged); + } + }; + return observe; +}); +/*can@2.2.6#compute/proto_compute*/ +define('can/compute/proto_compute', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/compute/read', + 'can/compute/get_value_and_bind', + 'can/util/batch/batch' +], function (can, bind, read, getValueAndBind) { + var updateOnChange = function (compute, newValue, oldValue, batchNum) { + if (newValue !== oldValue) { + can.batch.trigger(compute, batchNum ? { + type: 'change', + batchNum: batchNum + } : 'change', [ + newValue, + oldValue + ]); + } + }; + var setupComputeHandlers = function (compute, func, context, singleBind) { + var readInfo, onchanged, batchNum; + singleBind = false; + return { + on: function (updater) { + var self = this; + if (!onchanged) { + onchanged = function (ev) { + if (readInfo.ready && compute.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + if (singleBind) { + newValue = func.call(context); + readInfo.value = newValue; + } else { + readInfo = getValueAndBind(func, context, readInfo, onchanged); + newValue = readInfo.value; + } + self.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }; + } + readInfo = getValueAndBind(func, context, { observed: {} }, onchanged); + if (singleBind) { + func = can.__notObserve(func); + } + compute.value = readInfo.value; + compute.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function (updater) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, onchanged); + } + } + }; + }; + var k = function () { + }; + var updater = function (newVal, oldVal, batchNum) { + this.value = newVal; + updateOnChange(this, newVal, oldVal, batchNum); + }, asyncGet = function (fn, context, lastSetValue) { + return function () { + return fn.call(context, lastSetValue.get()); + }; + }, asyncUpdater = function (context, oldUpdater) { + return function (newVal) { + if (newVal !== undefined) { + oldUpdater(newVal, context.value); + } + }; + }; + can.Compute = function (getterSetter, context, eventName, bindOnce) { + var args = []; + for (var i = 0, arglen = arguments.length; i < arglen; i++) { + args[i] = arguments[i]; + } + var contextType = typeof args[1]; + if (typeof args[0] === 'function') { + this._setupGetterSetterFn(args[0], args[1], args[2], args[3]); + } else if (args[1]) { + if (contextType === 'string') { + this._setupContextString(args[0], args[1], args[2]); + } else if (contextType === 'function') { + this._setupContextFunction(args[0], args[1], args[2]); + } else { + if (args[1] && args[1].fn) { + this._setupAsyncCompute(args[0], args[1]); + } else { + this._setupContextSettings(args[0], args[1]); + } + } + } else { + this._setupInitialValue(args[0]); + } + this._args = args; + this.isComputed = true; + can.cid(this, 'compute'); + }; + can.simpleExtend(can.Compute.prototype, { + _bindsetup: can.__notObserve(function () { + this.bound = true; + this._on(this.updater); + }), + _bindteardown: function () { + this._off(this.updater); + this.bound = false; + }, + bind: can.bindAndSetup, + unbind: can.unbindAndTeardown, + clone: function (context) { + if (context && typeof this._args[0] === 'function') { + this._args[1] = context; + } else if (context) { + this._args[2] = context; + } + return new can.Compute(this._args[0], this._args[1], this._args[2], this._args[3]); + }, + _on: k, + _off: k, + get: function () { + if (can.__isRecordingObserves() && this._canObserve !== false) { + can.__observe(this, 'change'); + if (!this.bound) { + can.Compute.temporarilyBind(this); + } + } + if (this.bound) { + return this.value; + } else { + return this._get(); + } + }, + _get: function () { + return this.value; + }, + set: function (newVal) { + var old = this.value; + var setVal = this._set(newVal, old); + if (this.hasDependencies) { + if (this._setUpdates) { + return this.value; + } + return this._get(); + } + if (setVal === undefined) { + this.value = this._get(); + } else { + this.value = setVal; + } + updateOnChange(this, this.value, old); + return this.value; + }, + _set: function (newVal) { + return this.value = newVal; + }, + updater: updater, + _computeFn: function (newVal) { + if (arguments.length) { + return this.set(newVal); + } + return this.get(); + }, + toFunction: function () { + return can.proxy(this._computeFn, this); + }, + _setupGetterSetterFn: function (getterSetter, context, eventName, bindOnce) { + this._set = can.proxy(getterSetter, context); + this._get = can.proxy(getterSetter, context); + this._canObserve = eventName === false ? false : true; + var handlers = setupComputeHandlers(this, getterSetter, context || this, bindOnce); + this._on = handlers.on; + this._off = handlers.off; + }, + _setupContextString: function (target, propertyName, eventName) { + var isObserve = can.isMapLike(target), self = this, handler = function (ev, newVal, oldVal) { + self.updater(newVal, oldVal, ev.batchNum); + }; + if (isObserve) { + this.hasDependencies = true; + this._get = function () { + return target.attr(propertyName); + }; + this._set = function (val) { + target.attr(propertyName, val); + }; + this._on = function (update) { + target.bind(eventName || propertyName, handler); + this.value = this._get(); + }; + this._off = function () { + return target.unbind(eventName || propertyName, handler); + }; + } else { + this._get = can.proxy(this._get, target); + this._set = can.proxy(this._set, target); + } + }, + _setupContextFunction: function (initialValue, setter, eventName) { + this.value = initialValue; + this._set = setter; + can.simpleExtend(this, eventName); + }, + _setupContextSettings: function (initialValue, settings) { + this.value = initialValue; + this._set = settings.set ? can.proxy(settings.set, settings) : this._set; + this._get = settings.get ? can.proxy(settings.get, settings) : this._get; + if (!settings.__selfUpdater) { + var self = this, oldUpdater = this.updater; + this.updater = function () { + oldUpdater.call(self, self._get(), self.value); + }; + } + this._on = settings.on ? settings.on : this._on; + this._off = settings.off ? settings.off : this._off; + }, + _setupAsyncCompute: function (initialValue, settings) { + this.value = initialValue; + var oldUpdater = can.proxy(this.updater, this), self = this, fn = settings.fn, data; + this.updater = oldUpdater; + var lastSetValue = new can.Compute(initialValue); + this.lastSetValue = lastSetValue; + this._setUpdates = true; + this._set = function (newVal) { + if (newVal === lastSetValue.get()) { + return this.value; + } + return lastSetValue.set(newVal); + }; + this._get = asyncGet(fn, settings.context, lastSetValue); + if (fn.length === 0) { + data = setupComputeHandlers(this, fn, settings.context); + } else if (fn.length === 1) { + data = setupComputeHandlers(this, function () { + return fn.call(settings.context, lastSetValue.get()); + }, settings); + } else { + this.updater = asyncUpdater(this, oldUpdater); + data = setupComputeHandlers(this, function () { + var res = fn.call(settings.context, lastSetValue.get(), function (newVal) { + oldUpdater(newVal, self.value); + }); + return res !== undefined ? res : this.value; + }, settings); + } + this._on = data.on; + this._off = data.off; + }, + _setupInitialValue: function (initialValue) { + this.value = initialValue; + } + }); + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.Compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.Compute.async = function (initialValue, asyncComputer, context) { + return new can.Compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.Compute.read = read; + can.Compute.set = read.write; + can.Compute.truthy = function (compute) { + return new can.Compute(function () { + var res = compute.get(); + if (typeof res === 'function') { + res = res.get(); + } + return !!res; + }); + }; + return can.Compute; +}); +/*can@2.2.6#compute/compute*/ +define('can/compute/compute', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/util/batch/batch', + 'can/compute/proto_compute' +], function (can, bind) { + can.compute = function (getterSetter, context, eventName, bindOnce) { + var internalCompute = new can.Compute(getterSetter, context, eventName, bindOnce); + var compute = function (val) { + if (arguments.length) { + return internalCompute.set(val); + } + return internalCompute.get(); + }; + compute.bind = can.proxy(internalCompute.bind, internalCompute); + compute.unbind = can.proxy(internalCompute.unbind, internalCompute); + compute.isComputed = internalCompute.isComputed; + compute.clone = function (ctx) { + if (typeof getterSetter === 'function') { + context = ctx; + } + return can.compute(getterSetter, context, ctx, bindOnce); + }; + compute.computeInstance = internalCompute; + return compute; + }; + var k = function () { + }; + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.compute.truthy = function (compute) { + return can.compute(function () { + var res = compute(); + if (typeof res === 'function') { + res = res(); + } + return !!res; + }); + }; + can.compute.async = function (initialValue, asyncComputer, context) { + return can.compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.compute.read = can.Compute.read; + can.compute.set = can.Compute.set; + return can.compute; +}); +/*can@2.2.6#observe/observe*/ +define('can/observe/observe', [ + 'can/util/util', + 'can/map/map', + 'can/list/list', + 'can/compute/compute' +], function (can) { + can.Observe = can.Map; + can.Observe.startBatch = can.batch.start; + can.Observe.stopBatch = can.batch.stop; + can.Observe.triggerBatch = can.batch.trigger; + return can; +}); +/*can@2.2.6#view/scope/compute_data*/ +define('can/view/scope/compute_data', [ + 'can/util/util', + 'can/compute/compute', + 'can/compute/get_value_and_bind' +], function (can, compute, getValueAndBind) { + var isFastPath = function (computeData) { + return computeData.reads && computeData.reads.length === 1 && computeData.root instanceof can.Map && !can.isFunction(computeData.root[computeData.reads[0]]); + }; + var getValueAndBindScopeRead = function (scopeRead, scopeReadChanged) { + return getValueAndBind(scopeRead, null, { observed: {} }, scopeReadChanged); + }; + var unbindScopeRead = function (readInfo, scopeReadChanged) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, scopeReadChanged); + } + }; + var getValueAndBindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + var target = computeData.root, prop = computeData.reads[0]; + target.bind(prop, singlePropertyReadChanged); + return { + value: computeData.initialValue, + observed: { something: true } + }; + }; + var unbindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + computeData.root.unbind(computeData.reads[0], singlePropertyReadChanged); + }; + var scopeReader = function (scope, key, options, computeData, newVal) { + if (arguments.length > 4) { + if (computeData.root.isComputed) { + computeData.root(newVal); + } else if (computeData.reads.length) { + var last = computeData.reads.length - 1; + var obj = computeData.reads.length ? can.compute.read(computeData.root, computeData.reads.slice(0, last)).value : computeData.root; + can.compute.set(obj, computeData.reads[last], newVal, options); + } + } else { + if (computeData.root) { + return can.compute.read(computeData.root, computeData.reads, options).value; + } + var data = scope.read(key, options); + computeData.scope = data.scope; + computeData.initialValue = data.value; + computeData.reads = data.reads; + computeData.root = data.rootObserve; + return data.value; + } + }; + return function (scope, key, options) { + options = options || { args: [] }; + var computeData = {}, scopeRead = function (newVal) { + if (arguments.length) { + return scopeReader(scope, key, options, computeData, newVal); + } else { + return scopeReader(scope, key, options, computeData); + } + }, batchNum, readInfo, scopeReadChanged = function (ev) { + if (readInfo.ready && compute.computeInstance.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + readInfo = getValueAndBind(scopeRead, null, readInfo, scopeReadChanged); + newValue = readInfo.value; + compute.computeInstance.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }, singlePropertyReadChanged = function (ev, newVal, oldVal) { + if (typeof newVal !== 'function') { + compute.computeInstance.updater(newVal, oldVal, ev.batchNum); + } else { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + isFastPathBound = false; + compute.computeInstance.updater(readInfo.value, oldVal, ev.batchNum); + } + }, isFastPathBound = false, compute = can.compute(undefined, { + on: function () { + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + if (isFastPath(computeData)) { + var oldReadInfo = readInfo; + readInfo = getValueAndBindSinglePropertyRead(computeData, singlePropertyReadChanged); + unbindScopeRead(oldReadInfo, scopeReadChanged); + isFastPathBound = true; + } + compute.computeInstance.value = readInfo.value; + compute.computeInstance.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function () { + if (isFastPathBound) { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + } else { + unbindScopeRead(readInfo, scopeReadChanged); + } + }, + set: scopeRead, + get: scopeRead, + __selfUpdater: true + }); + computeData.compute = compute; + return computeData; + }; +}); +/*can@2.2.6#view/scope/scope*/ +define('can/view/scope/scope', [ + 'can/util/util', + 'can/view/scope/compute_data', + 'can/construct/construct', + 'can/map/map', + 'can/list/list', + 'can/view/view', + 'can/compute/compute' +], function (can, makeComputeData) { + var escapeReg = /(\\)?\./g, escapeDotReg = /\\\./g, getNames = function (attr) { + var names = [], last = 0; + attr.replace(escapeReg, function (first, second, index) { + if (!second) { + names.push(attr.slice(last, index).replace(escapeDotReg, '.')); + last = index + first.length; + } + }); + names.push(attr.slice(last).replace(escapeDotReg, '.')); + return names; + }; + var Scope = can.Construct.extend({ read: can.compute.read }, { + init: function (context, parent) { + this._context = context; + this._parent = parent; + this.__cache = {}; + }, + attr: can.__notObserve(function (key, value) { + var options = { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }, res = this.read(key, options); + if (arguments.length === 2) { + var lastIndex = key.lastIndexOf('.'), readKey = lastIndex !== -1 ? key.substring(0, lastIndex) : '.', obj = this.read(readKey, options).value; + if (lastIndex !== -1) { + key = key.substring(lastIndex + 1, key.length); + } + can.compute.set(obj, key, value, options); + } + return res.value; + }), + add: function (context) { + if (context !== this._context) { + return new this.constructor(context, this); + } else { + return this; + } + }, + computeData: function (key, options) { + return makeComputeData(this, key, options); + }, + compute: function (key, options) { + return this.computeData(key, options).compute; + }, + read: function (attr, options) { + var stopLookup; + if (attr.substr(0, 2) === './') { + stopLookup = true; + attr = attr.substr(2); + } else if (attr.substr(0, 3) === '../') { + return this._parent.read(attr.substr(3), options); + } else if (attr === '..') { + return { value: this._parent._context }; + } else if (attr === '.' || attr === 'this') { + return { value: this._context }; + } + var names = attr.indexOf('\\.') === -1 ? attr.split('.') : getNames(attr), context, scope = this, defaultObserve, defaultReads = [], defaultPropertyDepth = -1, defaultComputeReadings, defaultScope, currentObserve, currentReads; + while (scope) { + context = scope._context; + if (context !== null && (typeof context === 'object' || typeof context === 'function')) { + var data = can.compute.read(context, names, can.simpleExtend({ + foundObservable: function (observe, nameIndex) { + currentObserve = observe; + currentReads = names.slice(nameIndex); + }, + earlyExit: function (parentValue, nameIndex) { + if (nameIndex > defaultPropertyDepth) { + defaultObserve = currentObserve; + defaultReads = currentReads; + defaultPropertyDepth = nameIndex; + defaultScope = scope; + defaultComputeReadings = can.__clearReading(); + } + }, + executeAnonymousFunctions: true + }, options)); + if (data.value !== undefined) { + return { + scope: scope, + rootObserve: currentObserve, + value: data.value, + reads: currentReads + }; + } + } + can.__clearReading(); + if (!stopLookup) { + scope = scope._parent; + } else { + scope = null; + } + } + if (defaultObserve) { + can.__setReading(defaultComputeReadings); + return { + scope: defaultScope, + rootObserve: defaultObserve, + reads: defaultReads, + value: undefined + }; + } else { + return { + names: names, + value: undefined + }; + } + } + }); + can.view.Scope = Scope; + return Scope; +}); +/*can@2.2.6#view/scanner*/ +define('can/view/scanner', [ + 'can/view/view', + 'can/view/elements', + 'can/view/callbacks/callbacks' +], function (can, elements, viewCallbacks) { + var newLine = /(\r|\n)+/g, notEndTag = /\//, clean = function (content) { + return content.split('\\').join('\\\\').split('\n').join('\\n').split('"').join('\\"').split('\t').join('\\t'); + }, getTag = function (tagName, tokens, i) { + if (tagName) { + return tagName; + } else { + while (i < tokens.length) { + if (tokens[i] === '<' && !notEndTag.test(tokens[i + 1])) { + return elements.reverseTagMap[tokens[i + 1]] || 'span'; + } + i++; + } + } + return ''; + }, bracketNum = function (content) { + return --content.split('{').length - --content.split('}').length; + }, myEval = function (script) { + eval(script); + }, attrReg = /([^\s]+)[\s]*=[\s]*$/, startTxt = 'var ___v1ew = [];', finishTxt = 'return ___v1ew.join(\'\')', put_cmd = '___v1ew.push(\n', insert_cmd = put_cmd, htmlTag = null, quote = null, beforeQuote = null, rescan = null, getAttrName = function () { + var matches = beforeQuote.match(attrReg); + return matches && matches[1]; + }, status = function () { + return quote ? '\'' + getAttrName() + '\'' : htmlTag ? 1 : 0; + }, top = function (stack) { + return stack[stack.length - 1]; + }, Scanner; + can.view.Scanner = Scanner = function (options) { + can.extend(this, { + text: {}, + tokens: [] + }, options); + this.text.options = this.text.options || ''; + this.tokenReg = []; + this.tokenSimple = { + '<': '<', + '>': '>', + '"': '"', + '\'': '\'' + }; + this.tokenComplex = []; + this.tokenMap = {}; + for (var i = 0, token; token = this.tokens[i]; i++) { + if (token[2]) { + this.tokenReg.push(token[2]); + this.tokenComplex.push({ + abbr: token[1], + re: new RegExp(token[2]), + rescan: token[3] + }); + } else { + this.tokenReg.push(token[1]); + this.tokenSimple[token[1]] = token[0]; + } + this.tokenMap[token[0]] = token[1]; + } + this.tokenReg = new RegExp('(' + this.tokenReg.slice(0).concat([ + '<', + '>', + '"', + '\'' + ]).join('|') + ')', 'g'); + }; + Scanner.prototype = { + helpers: [], + scan: function (source, name) { + var tokens = [], last = 0, simple = this.tokenSimple, complex = this.tokenComplex; + source = source.replace(newLine, '\n'); + if (this.transform) { + source = this.transform(source); + } + source.replace(this.tokenReg, function (whole, part) { + var offset = arguments[arguments.length - 2]; + if (offset > last) { + tokens.push(source.substring(last, offset)); + } + if (simple[whole]) { + tokens.push(whole); + } else { + for (var i = 0, token; token = complex[i]; i++) { + if (token.re.test(whole)) { + tokens.push(token.abbr); + if (token.rescan) { + tokens.push(token.rescan(part)); + } + break; + } + } + } + last = offset + part.length; + }); + if (last < source.length) { + tokens.push(source.substr(last)); + } + var content = '', buff = [startTxt + (this.text.start || '')], put = function (content, bonus) { + buff.push(put_cmd, '"', clean(content), '"' + (bonus || '') + ');'); + }, endStack = [], lastToken, startTag = null, magicInTag = false, specialStates = { + attributeHookups: [], + tagHookups: [], + lastTagHookup: '' + }, popTagHookup = function () { + specialStates.lastTagHookup = specialStates.tagHookups.pop() + specialStates.tagHookups.length; + }, tagName = '', tagNames = [], popTagName = false, bracketCount, specialAttribute = false, i = 0, token, tmap = this.tokenMap, attrName; + htmlTag = quote = beforeQuote = null; + for (; (token = tokens[i++]) !== undefined;) { + if (startTag === null) { + switch (token) { + case tmap.left: + case tmap.escapeLeft: + case tmap.returnLeft: + magicInTag = htmlTag && 1; + case tmap.commentLeft: + startTag = token; + if (content.length) { + put(content); + } + content = ''; + break; + case tmap.escapeFull: + magicInTag = htmlTag && 1; + rescan = 1; + startTag = tmap.escapeLeft; + if (content.length) { + put(content); + } + rescan = tokens[i++]; + content = rescan.content || rescan; + if (rescan.before) { + put(rescan.before); + } + tokens.splice(i, 0, tmap.right); + break; + case tmap.commentFull: + break; + case tmap.templateLeft: + content += tmap.left; + break; + case '<': + if (tokens[i].indexOf('!--') !== 0) { + htmlTag = 1; + magicInTag = 0; + } + content += token; + break; + case '>': + htmlTag = 0; + var emptyElement = content.substr(content.length - 1) === '/' || content.substr(content.length - 2) === '--', attrs = ''; + if (specialStates.attributeHookups.length) { + attrs = 'attrs: [\'' + specialStates.attributeHookups.join('\',\'') + '\'], '; + specialStates.attributeHookups = []; + } + if (tagName + specialStates.tagHookups.length !== specialStates.lastTagHookup && tagName === top(specialStates.tagHookups)) { + if (emptyElement) { + content = content.substr(0, content.length - 1); + } + buff.push(put_cmd, '"', clean(content), '"', ',can.view.pending({tagName:\'' + tagName + '\',' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options); + if (emptyElement) { + buff.push('}));'); + content = '/>'; + popTagHookup(); + } else if (tokens[i] === '<' && tokens[i + 1] === '/' + tagName) { + buff.push('}));'); + content = token; + popTagHookup(); + } else { + buff.push(',subtemplate: function(' + this.text.argNames + '){\n' + startTxt + (this.text.start || '')); + content = ''; + } + } else if (magicInTag || !popTagName && elements.tagToContentPropMap[tagNames[tagNames.length - 1]] || attrs) { + var pendingPart = ',can.view.pending({' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options + '}),"'; + if (emptyElement) { + put(content.substr(0, content.length - 1), pendingPart + '/>"'); + } else { + put(content, pendingPart + '>"'); + } + content = ''; + magicInTag = 0; + } else { + content += token; + } + if (emptyElement || popTagName) { + tagNames.pop(); + tagName = tagNames[tagNames.length - 1]; + popTagName = false; + } + specialStates.attributeHookups = []; + break; + case '\'': + case '"': + if (htmlTag) { + if (quote && quote === token) { + quote = null; + var attr = getAttrName(); + if (viewCallbacks.attr(attr)) { + specialStates.attributeHookups.push(attr); + } + if (specialAttribute) { + content += token; + put(content); + buff.push(finishTxt, '}));\n'); + content = ''; + specialAttribute = false; + break; + } + } else if (quote === null) { + quote = token; + beforeQuote = lastToken; + attrName = getAttrName(); + if (tagName === 'img' && attrName === 'src' || attrName === 'style') { + put(content.replace(attrReg, '')); + content = ''; + specialAttribute = true; + buff.push(insert_cmd, 'can.view.txt(2,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt); + put(attrName + '=' + token); + break; + } + } + } + default: + if (lastToken === '<') { + tagName = token.substr(0, 3) === '!--' ? '!--' : token.split(/\s/)[0]; + var isClosingTag = false, cleanedTagName; + if (tagName.indexOf('/') === 0) { + isClosingTag = true; + cleanedTagName = tagName.substr(1); + } + if (isClosingTag) { + if (top(tagNames) === cleanedTagName) { + tagName = cleanedTagName; + popTagName = true; + } + if (top(specialStates.tagHookups) === cleanedTagName) { + put(content.substr(0, content.length - 1)); + buff.push(finishTxt + '}}) );'); + content = '><'; + popTagHookup(); + } + } else { + if (tagName.lastIndexOf('/') === tagName.length - 1) { + tagName = tagName.substr(0, tagName.length - 1); + } + if (tagName !== '!--' && viewCallbacks.tag(tagName)) { + if (tagName === 'content' && elements.tagMap[top(tagNames)]) { + token = token.replace('content', elements.tagMap[top(tagNames)]); + } + specialStates.tagHookups.push(tagName); + } + tagNames.push(tagName); + } + } + content += token; + break; + } + } else { + switch (token) { + case tmap.right: + case tmap.returnRight: + switch (startTag) { + case tmap.left: + bracketCount = bracketNum(content); + if (bracketCount === 1) { + buff.push(insert_cmd, 'can.view.txt(0,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt, content); + endStack.push({ + before: '', + after: finishTxt + '}));\n' + }); + } else { + last = endStack.length && bracketCount === -1 ? endStack.pop() : { after: ';' }; + if (last.before) { + buff.push(last.before); + } + buff.push(content, ';', last.after); + } + break; + case tmap.escapeLeft: + case tmap.returnLeft: + bracketCount = bracketNum(content); + if (bracketCount) { + endStack.push({ + before: finishTxt, + after: '}));\n' + }); + } + var escaped = startTag === tmap.escapeLeft ? 1 : 0, commands = { + insert: insert_cmd, + tagName: getTag(tagName, tokens, i), + status: status(), + specialAttribute: specialAttribute + }; + for (var ii = 0; ii < this.helpers.length; ii++) { + var helper = this.helpers[ii]; + if (helper.name.test(content)) { + content = helper.fn(content, commands); + if (helper.name.source === /^>[\s]*\w*/.source) { + escaped = 0; + } + break; + } + } + if (typeof content === 'object') { + if (content.startTxt && content.end && specialAttribute) { + buff.push(insert_cmd, 'can.view.toStr( ', content.content, '() ) );'); + } else { + if (content.startTxt) { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || (content.escaped != null ? content.escaped : escaped)) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\n'); + } else if (content.startOnlyTxt) { + buff.push(insert_cmd, 'can.view.onlytxt(this,\n'); + } + buff.push(content.content); + if (content.end) { + buff.push('));'); + } + } + } else if (specialAttribute) { + buff.push(insert_cmd, content, ');'); + } else { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || escaped) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\nfunction(){ ' + (this.text.escape || '') + 'return ', content, bracketCount ? startTxt : '}));\n'); + } + if (rescan && rescan.after && rescan.after.length) { + put(rescan.after.length); + rescan = null; + } + break; + } + startTag = null; + content = ''; + break; + case tmap.templateLeft: + content += tmap.left; + break; + default: + content += token; + break; + } + } + lastToken = token; + } + if (content.length) { + put(content); + } + buff.push(';'); + var template = buff.join(''), out = { out: (this.text.outStart || '') + template + ' ' + finishTxt + (this.text.outEnd || '') }; + myEval.call(out, 'this.fn = (function(' + this.text.argNames + '){' + out.out + '});\r\n//# sourceURL=' + name + '.js'); + return out; + } + }; + can.view.pending = function (viewData) { + var hooks = can.view.getHooks(); + return can.view.hook(function (el) { + can.each(hooks, function (fn) { + fn(el); + }); + viewData.templateType = 'legacy'; + if (viewData.tagName) { + viewCallbacks.tagHandler(el, viewData.tagName, viewData); + } + can.each(viewData && viewData.attrs || [], function (attributeName) { + viewData.attributeName = attributeName; + var callback = viewCallbacks.attr(attributeName); + if (callback) { + callback(el, viewData); + } + }); + }); + }; + can.view.tag('content', function (el, tagData) { + return tagData.scope; + }); + can.view.Scanner = Scanner; + return Scanner; +}); +/*can@2.2.6#view/node_lists/node_lists*/ +define('can/view/node_lists/node_lists', [ + 'can/util/util', + 'can/view/elements' +], function (can) { + var canExpando = true; + try { + document.createTextNode('')._ = 0; + } catch (ex) { + canExpando = false; + } + var nodeMap = {}, textNodeMap = {}, expando = 'ejs_' + Math.random(), _id = 0, id = function (node, localMap) { + var _textNodeMap = localMap || textNodeMap; + var id = readId(node, _textNodeMap); + if (id) { + return id; + } else { + if (canExpando || node.nodeType !== 3) { + ++_id; + return node[expando] = (node.nodeName ? 'element_' : 'obj_') + _id; + } else { + ++_id; + _textNodeMap['text_' + _id] = node; + return 'text_' + _id; + } + } + }, readId = function (node, textNodeMap) { + if (canExpando || node.nodeType !== 3) { + return node[expando]; + } else { + for (var textNodeID in textNodeMap) { + if (textNodeMap[textNodeID] === node) { + return textNodeID; + } + } + } + }, splice = [].splice, push = [].push, itemsInChildListTree = function (list) { + var count = 0; + for (var i = 0, len = list.length; i < len; i++) { + var item = list[i]; + if (item.nodeType) { + count++; + } else { + count += itemsInChildListTree(item); + } + } + return count; + }, replacementMap = function (replacements, idMap) { + var map = {}; + for (var i = 0, len = replacements.length; i < len; i++) { + var node = nodeLists.first(replacements[i]); + map[id(node, idMap)] = replacements[i]; + } + return map; + }; + var nodeLists = { + id: id, + update: function (nodeList, newNodes) { + var oldNodes = nodeLists.unregisterChildren(nodeList); + newNodes = can.makeArray(newNodes); + var oldListLength = nodeList.length; + splice.apply(nodeList, [ + 0, + oldListLength + ].concat(newNodes)); + if (nodeList.replacements) { + nodeLists.nestReplacements(nodeList); + } else { + nodeLists.nestList(nodeList); + } + return oldNodes; + }, + nestReplacements: function (list) { + var index = 0, idMap = {}, rMap = replacementMap(list.replacements, idMap), rCount = list.replacements.length; + while (index < list.length && rCount) { + var node = list[index], replacement = rMap[readId(node, idMap)]; + if (replacement) { + list.splice(index, itemsInChildListTree(replacement), replacement); + rCount--; + } + index++; + } + list.replacements = []; + }, + nestList: function (list) { + var index = 0; + while (index < list.length) { + var node = list[index], childNodeList = nodeMap[id(node)]; + if (childNodeList) { + if (childNodeList !== list) { + list.splice(index, itemsInChildListTree(childNodeList), childNodeList); + } + } else { + nodeMap[id(node)] = list; + } + index++; + } + }, + last: function (nodeList) { + var last = nodeList[nodeList.length - 1]; + if (last.nodeType) { + return last; + } else { + return nodeLists.last(last); + } + }, + first: function (nodeList) { + var first = nodeList[0]; + if (first.nodeType) { + return first; + } else { + return nodeLists.first(first); + } + }, + flatten: function (nodeList) { + var items = []; + for (var i = 0; i < nodeList.length; i++) { + var item = nodeList[i]; + if (item.nodeType) { + items.push(item); + } else { + items.push.apply(items, nodeLists.flatten(item)); + } + } + return items; + }, + register: function (nodeList, unregistered, parent) { + nodeList.unregistered = unregistered; + nodeList.parentList = parent; + if (parent === true) { + nodeList.replacements = []; + } else if (parent) { + parent.replacements.push(nodeList); + nodeList.replacements = []; + } else { + nodeLists.nestList(nodeList); + } + return nodeList; + }, + unregisterChildren: function (nodeList) { + var nodes = []; + can.each(nodeList, function (node) { + if (node.nodeType) { + if (!nodeList.replacements) { + delete nodeMap[id(node)]; + } + nodes.push(node); + } else { + push.apply(nodes, nodeLists.unregister(node)); + } + }); + return nodes; + }, + unregister: function (nodeList) { + var nodes = nodeLists.unregisterChildren(nodeList); + if (nodeList.unregistered) { + var unregisteredCallback = nodeList.unregistered; + delete nodeList.unregistered; + delete nodeList.replacements; + unregisteredCallback(); + } + return nodes; + }, + nodeMap: nodeMap + }; + can.view.nodeLists = nodeLists; + return nodeLists; +}); +/*can@2.2.6#view/parser/parser*/ +define('can/view/parser/parser', ['can/view/view'], function (can) { + function makeMap(str) { + var obj = {}, items = str.split(','); + for (var i = 0; i < items.length; i++) { + obj[items[i]] = true; + } + return obj; + } + function handleIntermediate(intermediate, handler) { + for (var i = 0, len = intermediate.length; i < len; i++) { + var item = intermediate[i]; + handler[item.tokenType].apply(handler, item.args); + } + return intermediate; + } + var alphaNumericHU = '-:A-Za-z0-9_', attributeNames = '[a-zA-Z_:][' + alphaNumericHU + ':.]*', spaceEQspace = '\\s*=\\s*', dblQuote2dblQuote = '"((?:\\\\.|[^"])*)"', quote2quote = '\'((?:\\\\.|[^\'])*)\'', attributeEqAndValue = '(?:' + spaceEQspace + '(?:' + '(?:"[^"]*")|(?:\'[^\']*\')|[^>\\s]+))?', matchStash = '\\{\\{[^\\}]*\\}\\}\\}?', stash = '\\{\\{([^\\}]*)\\}\\}\\}?', startTag = new RegExp('^<([' + alphaNumericHU + ']+)' + '(' + '(?:\\s*' + '(?:(?:' + '(?:' + attributeNames + ')?' + attributeEqAndValue + ')|' + '(?:' + matchStash + ')+)' + ')*' + ')\\s*(\\/?)>'), endTag = new RegExp('^<\\/([' + alphaNumericHU + ']+)[^>]*>'), attr = new RegExp('(?:' + '(?:(' + attributeNames + ')|' + stash + ')' + '(?:' + spaceEQspace + '(?:' + '(?:' + dblQuote2dblQuote + ')|(?:' + quote2quote + ')|([^>\\s]+)' + ')' + ')?)', 'g'), mustache = new RegExp(stash, 'g'), txtBreak = /<|\{\{/; + var empty = makeMap('area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed'); + var block = makeMap('a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video'); + var inline = makeMap('abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var'); + var closeSelf = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr'); + var fillAttrs = makeMap('checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected'); + var special = makeMap('script,style'); + var tokenTypes = 'start,end,close,attrStart,attrEnd,attrValue,chars,comment,special,done'.split(','); + var fn = function () { + }; + var HTMLParser = function (html, handler, returnIntermediate) { + if (typeof html === 'object') { + return handleIntermediate(html, handler); + } + var intermediate = []; + handler = handler || {}; + if (returnIntermediate) { + can.each(tokenTypes, function (name) { + var callback = handler[name] || fn; + handler[name] = function () { + if (callback.apply(this, arguments) !== false) { + intermediate.push({ + tokenType: name, + args: can.makeArray(arguments) + }); + } + }; + }); + } + function parseStartTag(tag, tagName, rest, unary) { + tagName = tagName.toLowerCase(); + if (block[tagName]) { + while (stack.last() && inline[stack.last()]) { + parseEndTag('', stack.last()); + } + } + if (closeSelf[tagName] && stack.last() === tagName) { + parseEndTag('', tagName); + } + unary = empty[tagName] || !!unary; + handler.start(tagName, unary); + if (!unary) { + stack.push(tagName); + } + HTMLParser.parseAttrs(rest, handler); + handler.end(tagName, unary); + } + function parseEndTag(tag, tagName) { + var pos; + if (!tagName) { + pos = 0; + } else { + for (pos = stack.length - 1; pos >= 0; pos--) { + if (stack[pos] === tagName) { + break; + } + } + } + if (pos >= 0) { + for (var i = stack.length - 1; i >= pos; i--) { + if (handler.close) { + handler.close(stack[i]); + } + } + stack.length = pos; + } + } + function parseMustache(mustache, inside) { + if (handler.special) { + handler.special(inside); + } + } + var index, chars, match, stack = [], last = html; + stack.last = function () { + return this[this.length - 1]; + }; + while (html) { + chars = true; + if (!stack.last() || !special[stack.last()]) { + if (html.indexOf(''); + if (index >= 0) { + if (handler.comment) { + handler.comment(html.substring(4, index)); + } + html = html.substring(index + 3); + chars = false; + } + } else if (html.indexOf(']*>'), function (all, text) { + text = text.replace(/|/g, '$1$2'); + if (handler.chars) { + handler.chars(text); + } + return ''; + }); + parseEndTag('', stack.last()); + } + if (html === last) { + throw 'Parse Error: ' + html; + } + last = html; + } + parseEndTag(); + handler.done(); + return intermediate; + }; + HTMLParser.parseAttrs = function (rest, handler) { + (rest != null ? rest : '').replace(attr, function (text, name, special, dblQuote, singleQuote, val) { + if (special) { + handler.special(special); + } + if (name || dblQuote || singleQuote || val) { + var value = arguments[3] ? arguments[3] : arguments[4] ? arguments[4] : arguments[5] ? arguments[5] : fillAttrs[name.toLowerCase()] ? name : ''; + handler.attrStart(name || ''); + var last = mustache.lastIndex = 0, res = mustache.exec(value), chars; + while (res) { + chars = value.substring(last, mustache.lastIndex - res[0].length); + if (chars.length) { + handler.attrValue(chars); + } + handler.special(res[1]); + last = mustache.lastIndex; + res = mustache.exec(value); + } + chars = value.substr(last, value.length); + if (chars) { + handler.attrValue(chars); + } + handler.attrEnd(name || ''); + } + }); + }; + can.view.parser = HTMLParser; + return HTMLParser; +}); +/*can@2.2.6#view/live/live*/ +define('can/view/live/live', [ + 'can/util/util', + 'can/view/elements', + 'can/view/view', + 'can/view/node_lists/node_lists', + 'can/view/parser/parser' +], function (can, elements, view, nodeLists, parser) { + elements = elements || can.view.elements; + nodeLists = nodeLists || can.view.NodeLists; + parser = parser || can.view.parser; + var setup = function (el, bind, unbind) { + var tornDown = false, teardown = function () { + if (!tornDown) { + tornDown = true; + unbind(data); + can.unbind.call(el, 'removed', teardown); + } + return true; + }, data = { + teardownCheck: function (parent) { + return parent ? false : teardown(); + } + }; + can.bind.call(el, 'removed', teardown); + bind(data); + return data; + }, listen = function (el, compute, change) { + return setup(el, function () { + compute.bind('change', change); + }, function (data) { + compute.unbind('change', change); + if (data.nodeList) { + nodeLists.unregister(data.nodeList); + } + }); + }, getAttributeParts = function (newVal) { + var attrs = {}, attr; + parser.parseAttrs(newVal, { + attrStart: function (name) { + attrs[name] = ''; + attr = name; + }, + attrValue: function (value) { + attrs[attr] += value; + }, + attrEnd: function () { + } + }); + return attrs; + }, splice = [].splice, isNode = function (obj) { + return obj && obj.nodeType; + }, addTextNodeIfNoChildren = function (frag) { + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + }; + var live = { + list: function (el, compute, render, context, parentNode, nodeList) { + var masterNodeList = nodeList || [el], indexMap = [], afterPreviousEvents = false, isTornDown = false, add = function (ev, items, index) { + if (!afterPreviousEvents) { + return; + } + var frag = document.createDocumentFragment(), newNodeLists = [], newIndicies = []; + can.each(items, function (item, key) { + var itemNodeList = []; + if (nodeList) { + nodeLists.register(itemNodeList, null, true); + } + var itemIndex = can.compute(key + index), itemHTML = render.call(context, item, itemIndex, itemNodeList), gotText = typeof itemHTML === 'string', itemFrag = can.frag(itemHTML); + itemFrag = gotText ? can.view.hookup(itemFrag) : itemFrag; + var childNodes = can.makeArray(itemFrag.childNodes); + if (nodeList) { + nodeLists.update(itemNodeList, childNodes); + newNodeLists.push(itemNodeList); + } else { + newNodeLists.push(nodeLists.register(childNodes)); + } + frag.appendChild(itemFrag); + newIndicies.push(itemIndex); + }); + var masterListIndex = index + 1; + if (!masterNodeList[masterListIndex]) { + elements.after(masterListIndex === 1 ? [text] : [nodeLists.last(masterNodeList[masterListIndex - 1])], frag); + } else { + var el = nodeLists.first(masterNodeList[masterListIndex]); + can.insertBefore(el.parentNode, frag, el); + } + splice.apply(masterNodeList, [ + masterListIndex, + 0 + ].concat(newNodeLists)); + splice.apply(indexMap, [ + index, + 0 + ].concat(newIndicies)); + for (var i = index + newIndicies.length, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + }, remove = function (ev, items, index, duringTeardown, fullTeardown) { + if (!afterPreviousEvents) { + return; + } + if (!duringTeardown && data.teardownCheck(text.parentNode)) { + return; + } + if (index < 0) { + index = indexMap.length + index; + } + var removedMappings = masterNodeList.splice(index + 1, items.length), itemsToRemove = []; + can.each(removedMappings, function (nodeList) { + var nodesToRemove = nodeLists.unregister(nodeList); + [].push.apply(itemsToRemove, nodesToRemove); + }); + indexMap.splice(index, items.length); + for (var i = index, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + if (!fullTeardown) { + can.remove(can.$(itemsToRemove)); + } else { + nodeLists.unregister(masterNodeList); + } + }, move = function (ev, item, newIndex, currentIndex) { + if (!afterPreviousEvents) { + return; + } + newIndex = newIndex + 1; + currentIndex = currentIndex + 1; + var referenceNodeList = masterNodeList[newIndex]; + var movedElements = can.frag(nodeLists.flatten(masterNodeList[currentIndex])); + var referenceElement; + if (currentIndex < newIndex) { + referenceElement = nodeLists.last(referenceNodeList).nextSibling; + } else { + referenceElement = nodeLists.first(referenceNodeList); + } + var parentNode = masterNodeList[0].parentNode; + parentNode.insertBefore(movedElements, referenceElement); + var temp = masterNodeList[currentIndex]; + [].splice.apply(masterNodeList, [ + currentIndex, + 1 + ]); + [].splice.apply(masterNodeList, [ + newIndex, + 0, + temp + ]); + }, text = document.createTextNode(''), list, teardownList = function (fullTeardown) { + if (list && list.unbind) { + list.unbind('add', add).unbind('remove', remove).unbind('move', move); + } + remove({}, { length: masterNodeList.length - 1 }, 0, true, fullTeardown); + }, updateList = function (ev, newList, oldList) { + if (isTornDown) { + return; + } + teardownList(); + list = newList || []; + if (list.bind) { + list.bind('add', add).bind('remove', remove).bind('move', move); + } + afterPreviousEvents = true; + add({}, list, 0); + afterPreviousEvents = false; + can.batch.afterPreviousEvents(function () { + afterPreviousEvents = true; + }); + }; + parentNode = elements.getParentNode(el, parentNode); + var data = setup(parentNode, function () { + if (can.isFunction(compute)) { + compute.bind('change', updateList); + } + }, function () { + if (can.isFunction(compute)) { + compute.unbind('change', updateList); + } + teardownList(true); + }); + if (!nodeList) { + live.replace(masterNodeList, text, data.teardownCheck); + } else { + elements.replace(masterNodeList, text); + nodeLists.update(masterNodeList, [text]); + nodeList.unregistered = function () { + data.teardownCheck(); + isTornDown = true; + }; + } + updateList({}, can.isFunction(compute) ? compute() : compute); + }, + html: function (el, compute, parentNode, nodeList) { + var data; + parentNode = elements.getParentNode(el, parentNode); + data = listen(parentNode, compute, function (ev, newVal, oldVal) { + var attached = nodeLists.first(nodes).parentNode; + if (attached) { + makeAndPut(newVal); + } + data.teardownCheck(nodeLists.first(nodes).parentNode); + }); + var nodes = nodeList || [el], makeAndPut = function (val) { + var isFunction = typeof val === 'function', aNode = isNode(val), frag = can.frag(isFunction ? '' : val), oldNodes = can.makeArray(nodes); + addTextNodeIfNoChildren(frag); + if (!aNode && !isFunction) { + frag = can.view.hookup(frag, parentNode); + } + oldNodes = nodeLists.update(nodes, frag.childNodes); + if (isFunction) { + val(frag.childNodes[0]); + } + elements.replace(oldNodes, frag); + }; + data.nodeList = nodes; + if (!nodeList) { + nodeLists.register(nodes, data.teardownCheck); + } else { + nodeList.unregistered = data.teardownCheck; + } + makeAndPut(compute()); + }, + replace: function (nodes, val, teardown) { + var oldNodes = nodes.slice(0), frag = can.frag(val); + nodeLists.register(nodes, teardown); + if (typeof val === 'string') { + frag = can.view.hookup(frag, nodes[0].parentNode); + } + nodeLists.update(nodes, frag.childNodes); + elements.replace(oldNodes, frag); + return nodes; + }, + text: function (el, compute, parentNode, nodeList) { + var parent = elements.getParentNode(el, parentNode); + var data = listen(parent, compute, function (ev, newVal, oldVal) { + if (typeof node.nodeValue !== 'unknown') { + node.nodeValue = can.view.toStr(newVal); + } + data.teardownCheck(node.parentNode); + }); + var node = document.createTextNode(can.view.toStr(compute())); + if (nodeList) { + nodeList.unregistered = data.teardownCheck; + data.nodeList = nodeList; + nodeLists.update(nodeList, [node]); + elements.replace([el], node); + } else { + data.nodeList = live.replace([el], node, data.teardownCheck); + } + }, + setAttributes: function (el, newVal) { + var attrs = getAttributeParts(newVal); + for (var name in attrs) { + can.attr.set(el, name, attrs[name]); + } + }, + attributes: function (el, compute, currentValue) { + var oldAttrs = {}; + var setAttrs = function (newVal) { + var newAttrs = getAttributeParts(newVal), name; + for (name in newAttrs) { + var newValue = newAttrs[name], oldValue = oldAttrs[name]; + if (newValue !== oldValue) { + can.attr.set(el, name, newValue); + } + delete oldAttrs[name]; + } + for (name in oldAttrs) { + elements.removeAttr(el, name); + } + oldAttrs = newAttrs; + }; + listen(el, compute, function (ev, newVal) { + setAttrs(newVal); + }); + if (arguments.length >= 3) { + oldAttrs = getAttributeParts(currentValue); + } else { + setAttrs(compute()); + } + }, + attributePlaceholder: '__!!__', + attributeReplace: /__!!__/g, + attribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, hook.render()); + }); + var wrapped = can.$(el), hooks; + hooks = can.data(wrapped, 'hooks'); + if (!hooks) { + can.data(wrapped, 'hooks', hooks = {}); + } + var attr = elements.getAttr(el, attributeName), parts = attr.split(live.attributePlaceholder), goodParts = [], hook; + goodParts.push(parts.shift(), parts.join(live.attributePlaceholder)); + if (hooks[attributeName]) { + hooks[attributeName].computes.push(compute); + } else { + hooks[attributeName] = { + render: function () { + var i = 0, newAttr = attr ? attr.replace(live.attributeReplace, function () { + return elements.contentText(hook.computes[i++]()); + }) : elements.contentText(hook.computes[i++]()); + return newAttr; + }, + computes: [compute], + batchNum: undefined + }; + } + hook = hooks[attributeName]; + goodParts.splice(1, 0, compute()); + elements.setAttr(el, attributeName, goodParts.join('')); + }, + specialAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, getValue(newVal)); + }); + elements.setAttr(el, attributeName, getValue(compute())); + }, + simpleAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, newVal); + }); + elements.setAttr(el, attributeName, compute()); + } + }; + live.attr = live.simpleAttribute; + live.attrs = live.attributes; + var newLine = /(\r|\n)+/g; + var getValue = function (val) { + var regexp = /^["'].*["']$/; + val = val.replace(elements.attrReg, '').replace(newLine, ''); + return regexp.test(val) ? val.substr(1, val.length - 2) : val; + }; + can.view.live = live; + return live; +}); +/*can@2.2.6#view/render*/ +define('can/view/render', [ + 'can/view/view', + 'can/view/elements', + 'can/view/live/live', + 'can/util/string/string' +], function (can, elements, live) { + var pendingHookups = [], tagChildren = function (tagName) { + var newTag = elements.tagMap[tagName] || 'span'; + if (newTag === 'span') { + return '@@!!@@'; + } + return '<' + newTag + '>' + tagChildren(newTag) + ''; + }, contentText = function (input, tag) { + if (typeof input === 'string') { + return input; + } + if (!input && input !== 0) { + return ''; + } + var hook = input.hookup && function (el, id) { + input.hookup.call(input, el, id); + } || typeof input === 'function' && input; + if (hook) { + if (tag) { + return '<' + tag + ' ' + can.view.hook(hook) + '>'; + } else { + pendingHookups.push(hook); + } + return ''; + } + return '' + input; + }, contentEscape = function (txt, tag) { + return typeof txt === 'string' || typeof txt === 'number' ? can.esc(txt) : contentText(txt, tag); + }, withinTemplatedSectionWithinAnElement = false, emptyHandler = function () { + }; + var lastHookups; + can.extend(can.view, { + live: live, + setupLists: function () { + var old = can.view.lists, data; + can.view.lists = function (list, renderer) { + data = { + list: list, + renderer: renderer + }; + return Math.random(); + }; + return function () { + can.view.lists = old; + return data; + }; + }, + getHooks: function () { + var hooks = pendingHookups.slice(0); + lastHookups = hooks; + pendingHookups = []; + return hooks; + }, + onlytxt: function (self, func) { + return contentEscape(func.call(self)); + }, + txt: function (escape, tagName, status, self, func) { + var tag = elements.tagMap[tagName] || 'span', setupLiveBinding = false, value, listData, compute, unbind = emptyHandler, attributeName; + if (withinTemplatedSectionWithinAnElement) { + value = func.call(self); + } else { + if (typeof status === 'string' || status === 1) { + withinTemplatedSectionWithinAnElement = true; + } + var listTeardown = can.view.setupLists(); + unbind = function () { + compute.unbind('change', emptyHandler); + }; + compute = can.compute(func, self, false); + compute.bind('change', emptyHandler); + listData = listTeardown(); + value = compute(); + withinTemplatedSectionWithinAnElement = false; + setupLiveBinding = compute.computeInstance.hasDependencies; + } + if (listData) { + unbind(); + return '<' + tag + can.view.hook(function (el, parentNode) { + live.list(el, listData.list, listData.renderer, self, parentNode); + }) + '>'; + } + if (!setupLiveBinding || typeof value === 'function') { + unbind(); + return (withinTemplatedSectionWithinAnElement || escape === 2 || !escape ? contentText : contentEscape)(value, status === 0 && tag); + } + var contentProp = elements.tagToContentPropMap[tagName]; + if (status === 0 && !contentProp) { + return '<' + tag + can.view.hook(escape && typeof value !== 'object' ? function (el, parentNode) { + live.text(el, compute, parentNode); + unbind(); + } : function (el, parentNode) { + live.html(el, compute, parentNode); + unbind(); + }) + '>' + tagChildren(tag) + ''; + } else if (status === 1) { + pendingHookups.push(function (el) { + live.attributes(el, compute, compute()); + unbind(); + }); + return compute(); + } else if (escape === 2) { + attributeName = status; + pendingHookups.push(function (el) { + live.specialAttribute(el, attributeName, compute); + unbind(); + }); + return compute(); + } else { + attributeName = status === 0 ? contentProp : status; + (status === 0 ? lastHookups : pendingHookups).push(function (el) { + live.attribute(el, attributeName, compute); + unbind(); + }); + return live.attributePlaceholder; + } + } + }); + return can; +}); +/*can@2.2.6#view/stache/utils*/ +define('can/view/stache/utils', ['can/util/util'], function () { + return { + isArrayLike: function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, + isObserveLike: function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, + emptyHandler: function () { + }, + jsonParse: function (str) { + if (str[0] === '\'') { + return str.substr(1, str.length - 2); + } else if (str === 'undefined') { + return undefined; + } else if (can.global.JSON) { + return JSON.parse(str); + } else { + return eval('(' + str + ')'); + } + }, + mixins: { + last: function () { + return this.stack[this.stack.length - 1]; + }, + add: function (chars) { + this.last().add(chars); + }, + subSectionDepth: function () { + return this.stack.length - 1; + } + } + }; +}); +/*can@2.2.6#view/stache/mustache_helpers*/ +define('can/view/stache/mustache_helpers', [ + 'can/util/util', + 'can/view/stache/utils', + 'can/view/live/live' +], function (can, utils, live) { + live = live || can.view.live; + var resolve = function (value) { + if (utils.isObserveLike(value) && utils.isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + var helpers = { + 'each': function (items, options) { + var resolved = resolve(items), result = [], keys, key, i; + if (resolved instanceof can.List) { + return function (el) { + var nodeList = [el]; + nodeList.expression = 'live.list'; + can.view.nodeLists.register(nodeList, null, options.nodeList); + can.view.nodeLists.update(options.nodeList, [el]); + var cb = function (item, index, parentNodeList) { + return options.fn(options.scope.add({ '@index': index }).add(item), options.options, parentNodeList); + }; + live.list(el, items, cb, options.context, el.parentNode, nodeList); + }; + } + var expr = resolved; + if (!!expr && utils.isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + } else if (utils.isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } + return result; + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + }, + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!resolve(expr); + } + if (value) { + return options.fn(options.scope || this); + } else { + return options.inverse(options.scope || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return helpers.is.apply(this, arguments); + }, + 'unless': function (expr, options) { + return helpers['if'].apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'with': function (expr, options) { + var ctx = expr; + expr = resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + 'data': function (attr) { + var data = arguments.length === 2 ? this : arguments[1]; + return function (el) { + can.data(can.$(el), attr, data || this.context); + }; + } + }; + return { + registerHelper: function (name, callback) { + helpers[name] = callback; + }, + getHelper: function (name, options) { + var helper = options.attr('helpers.' + name); + if (!helper) { + helper = helpers[name]; + } + if (helper) { + return { fn: helper }; + } + } + }; +}); +/*can@2.2.6#view/stache/mustache_core*/ +define('can/view/stache/mustache_core', [ + 'can/util/util', + 'can/view/stache/utils', + 'can/view/stache/mustache_helpers', + 'can/view/live/live', + 'can/view/elements', + 'can/view/scope/scope', + 'can/view/node_lists/node_lists' +], function (can, utils, mustacheHelpers, live, elements, Scope, nodeLists) { + live = live || can.view.live; + elements = elements || can.view.elements; + Scope = Scope || can.view.Scope; + nodeLists = nodeLists || can.view.nodeLists; + var argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(?:(.+?)=(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(.+))))$/, mustacheLineBreakRegExp = /(?:(?:^|(\r?)\n)(\s*)(\{\{([^\}]*)\}\}\}?)([^\S\n\r]*)($|\r?\n))|(\{\{([^\}]*)\}\}\}?)/g, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, getItemsFragContent = function (items, isObserveList, helperOptions, options) { + var frag = document.createDocumentFragment(); + for (var i = 0, len = items.length; i < len; i++) { + append(frag, helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options)); + } + return frag; + }, append = function (frag, content) { + if (content) { + frag.appendChild(typeof content === 'string' ? document.createTextNode(content) : content); + } + }, getItemsStringContent = function (items, isObserveList, helperOptions, options) { + var txt = ''; + for (var i = 0, len = items.length; i < len; i++) { + txt += helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options); + } + return txt; + }, getKeyComputeData = function (key, scope, isArgument) { + var data = scope.computeData(key, { + isArgument: isArgument, + args: [ + scope.attr('.'), + scope + ] + }); + can.compute.temporarilyBind(data.compute); + return data; + }, getKeyArgValue = function (key, scope) { + var data = getKeyComputeData(key, scope, true); + if (!data.compute.computeInstance.hasDependencies) { + return data.initialValue; + } else { + return data.compute; + } + }, convertToScopes = function (helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer) { + if (truthyRenderer) { + helperOptions.fn = makeRendererConvertScopes(truthyRenderer, scope, options, nodeList); + } + if (falseyRenderer) { + helperOptions.inverse = makeRendererConvertScopes(falseyRenderer, scope, options, nodeList); + } + }, makeRendererConvertScopes = function (renderer, parentScope, parentOptions, nodeList) { + var rendererWithScope = function (ctx, opts, parentNodeList) { + return renderer(ctx || parentScope, opts, parentNodeList); + }; + return can.__notObserve(function (newScope, newOptions, parentNodeList) { + if (newScope !== undefined && !(newScope instanceof can.view.Scope)) { + newScope = parentScope.add(newScope); + } + if (newOptions !== undefined && !(newOptions instanceof core.Options)) { + newOptions = parentOptions.add(newOptions); + } + var result = rendererWithScope(newScope, newOptions || parentOptions, parentNodeList || nodeList); + return result; + }); + }; + var core = { + expressionData: function (expression) { + var args = [], hashes = {}, i = 0; + (can.trim(expression) + ' ').replace(argumentsRegExp, function (whole, arg) { + var m; + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[1] || m[2]) { + args.push(utils.jsonParse(m[1] || m[2])); + } else { + hashes[m[3]] = m[6] ? { get: m[6] } : utils.jsonParse(m[4] || m[5]); + } + } else { + args.push({ get: arg }); + } + i++; + }); + return { + name: args.shift(), + args: args, + hash: hashes + }; + }, + makeEvaluator: function (scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, stringOnly) { + var args = [], hash = {}, helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, context = scope.attr('.'), name = exprData.name, helper, looksLikeAHelper = exprData.args.length || !can.isEmptyObject(exprData.hash), initialValue, helperEvaluator; + for (var i = 0, len = exprData.args.length; i < len; i++) { + var arg = exprData.args[i]; + if (arg && isLookup(arg)) { + args.push(getKeyArgValue(arg.get, scope, true)); + } else { + args.push(arg); + } + } + for (var prop in exprData.hash) { + if (isLookup(exprData.hash[prop])) { + hash[prop] = getKeyArgValue(exprData.hash[prop].get, scope); + } else { + hash[prop] = exprData.hash[prop]; + } + } + if (isLookup(name)) { + if (looksLikeAHelper) { + helper = mustacheHelpers.getHelper(name.get, options); + if (!helper && typeof context[name.get] === 'function') { + helper = { fn: context[name.get] }; + } + } + if (!helper) { + var get = name.get; + var computeData = getKeyComputeData(name.get, scope, false), compute = computeData.compute; + initialValue = computeData.initialValue; + if (computeData.compute.computeInstance.hasDependencies) { + name = compute; + } else { + name = initialValue; + } + if (!looksLikeAHelper && initialValue === undefined) { + helper = mustacheHelpers.getHelper(get, options); + } else if (typeof initialValue === 'function') { + helper = { fn: initialValue }; + } + } + } + if (mode === '^') { + var temp = truthyRenderer; + truthyRenderer = falseyRenderer; + falseyRenderer = temp; + } + if (helper) { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + can.simpleExtend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash, + nodeList: nodeList, + exprData: exprData + }); + args.push(helperOptions); + helperEvaluator = function () { + return helper.fn.apply(context, args) || ''; + }; + helperEvaluator.bindOnce = false; + return helperEvaluator; + } + if (!mode) { + if (name && name.isComputed) { + return name; + } else { + return function () { + return '' + (name != null ? name : ''); + }; + } + } else if (mode === '#' || mode === '^') { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + var evaluator = function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + if (utils.isArrayLike(value)) { + var isObserveList = utils.isObserveLike(value); + if (isObserveList ? value.attr('length') : value.length) { + return (stringOnly ? getItemsStringContent : getItemsFragContent)(value, isObserveList, helperOptions, options); + } else { + return helperOptions.inverse(scope, options); + } + } else { + return value ? helperOptions.fn(value || scope, options) : helperOptions.inverse(scope, options); + } + }; + evaluator.bindOnce = false; + return evaluator; + } else { + } + }, + makeLiveBindingPartialRenderer: function (partialName, state) { + partialName = can.trim(partialName); + return function (scope, options, parentSectionNodeList) { + var nodeList = [this]; + nodeList.expression = '>' + partialName; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var partialFrag = can.compute(function () { + var localPartialName = partialName; + var partial = options.attr('partials.' + localPartialName), res; + if (partial) { + res = partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + var scopePartialName = scope.read(localPartialName, { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }).value; + if (scopePartialName) { + localPartialName = scopePartialName; + } + res = can.view.render(localPartialName, scope, options); + } + return can.frag(res); + }); + live.html(this, partialFrag, this.parentNode, nodeList); + }; + }, + makeStringBranchRenderer: function (mode, expression) { + var exprData = expressionData(expression), fullExpression = mode + expression; + return function branchRenderer(scope, options, truthyRenderer, falseyRenderer) { + var evaluator = scope.__cache[fullExpression]; + if (mode || !evaluator) { + evaluator = makeEvaluator(scope, options, null, mode, exprData, truthyRenderer, falseyRenderer, true); + if (!mode) { + scope.__cache[fullExpression] = evaluator; + } + } + var res = evaluator(); + return res == null ? '' : '' + res; + }; + }, + makeLiveBindingBranchRenderer: function (mode, expression, state) { + var exprData = expressionData(expression); + return function branchRenderer(scope, options, parentSectionNodeList, truthyRenderer, falseyRenderer) { + var nodeList = [this]; + nodeList.expression = expression; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var evaluator = makeEvaluator(scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, state.tag); + var compute = can.compute(evaluator, null, false, evaluator.bindOnce === false ? false : true); + compute.bind('change', can.k); + var value = compute(); + if (typeof value === 'function') { + var old = can.__clearReading(); + value(this); + can.__setReading(old); + } else if (compute.computeInstance.hasDependencies) { + if (state.attr) { + live.simpleAttribute(this, state.attr, compute); + } else if (state.tag) { + live.attributes(this, compute); + } else if (state.text && typeof value !== 'object') { + live.text(this, compute, this.parentNode, nodeList); + } else { + live.html(this, compute, this.parentNode, nodeList); + } + } else { + if (state.attr) { + can.attr.set(this, state.attr, value); + } else if (state.tag) { + live.setAttributes(this, value); + } else if (state.text && typeof value === 'string') { + this.nodeValue = value; + } else if (value) { + elements.replace([this], can.frag(value)); + } + } + compute.unbind('change', can.k); + }; + }, + splitModeFromExpression: function (expression, state) { + expression = can.trim(expression); + var mode = expression.charAt(0); + if ('#/{&^>!'.indexOf(mode) >= 0) { + expression = can.trim(expression.substr(1)); + } else { + mode = null; + } + if (mode === '{' && state.node) { + mode = null; + } + return { + mode: mode, + expression: expression + }; + }, + cleanLineEndings: function (template) { + return template.replace(mustacheLineBreakRegExp, function (whole, returnBefore, spaceBefore, special, expression, spaceAfter, returnAfter, spaceLessSpecial, spaceLessExpression, matchIndex) { + spaceAfter = spaceAfter || ''; + returnBefore = returnBefore || ''; + spaceBefore = spaceBefore || ''; + var modeAndExpression = splitModeFromExpression(expression || spaceLessExpression, {}); + if (spaceLessSpecial || '>{'.indexOf(modeAndExpression.mode) >= 0) { + return whole; + } else if ('^#!/'.indexOf(modeAndExpression.mode) >= 0) { + return special + (matchIndex !== 0 && returnAfter.length ? returnBefore + '\n' : ''); + } else { + return spaceBefore + special + spaceAfter + (spaceBefore.length || matchIndex !== 0 ? returnBefore + '\n' : ''); + } + }); + }, + Options: can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }) + }; + var makeEvaluator = core.makeEvaluator, expressionData = core.expressionData, splitModeFromExpression = core.splitModeFromExpression; + return core; +}); +/*can@2.2.6#view/bindings/bindings*/ +define('can/view/bindings/bindings', [ + 'can/util/util', + 'can/view/stache/mustache_core', + 'can/view/callbacks/callbacks', + 'can/control/control', + 'can/view/scope/scope' +], function (can, mustacheCore) { + var isContentEditable = function () { + var values = { + '': true, + 'true': true, + 'false': false + }; + var editable = function (el) { + if (!el || !el.getAttribute) { + return; + } + var attr = el.getAttribute('contenteditable'); + return values[attr]; + }; + return function (el) { + var val = editable(el); + if (typeof val === 'boolean') { + return val; + } else { + return !!editable(el.parentNode); + } + }; + }(), removeCurly = function (value) { + if (value[0] === '{' && value[value.length - 1] === '}') { + return value.substr(1, value.length - 2); + } + return value; + }; + can.view.attr('can-value', function (el, data) { + var attr = can.trim(removeCurly(el.getAttribute('can-value'))), value = data.scope.computeData(attr, { args: [] }).compute, trueValue, falseValue; + if (el.nodeName.toLowerCase() === 'input') { + if (el.type === 'checkbox') { + if (can.attr.has(el, 'can-true-value')) { + trueValue = el.getAttribute('can-true-value'); + } else { + trueValue = true; + } + if (can.attr.has(el, 'can-false-value')) { + falseValue = el.getAttribute('can-false-value'); + } else { + falseValue = false; + } + } + if (el.type === 'checkbox' || el.type === 'radio') { + new Checked(el, { + value: value, + trueValue: trueValue, + falseValue: falseValue + }); + return; + } + } + if (el.nodeName.toLowerCase() === 'select' && el.multiple) { + new Multiselect(el, { value: value }); + return; + } + if (isContentEditable(el)) { + new Content(el, { value: value }); + return; + } + new Value(el, { value: value }); + }); + var special = { + enter: function (data, el, original) { + return { + event: 'keyup', + handler: function (ev) { + if (ev.keyCode === 13) { + return original.call(this, ev); + } + } + }; + } + }; + can.view.attr(/can-[\w\.]+/, function (el, data) { + var attributeName = data.attributeName, event = attributeName.substr('can-'.length), handler = function (ev) { + var attrVal = el.getAttribute(attributeName); + if (!attrVal) { + return; + } + var attrInfo = mustacheCore.expressionData(removeCurly(attrVal)); + var scopeData = data.scope.read(attrInfo.name.get, { + returnObserveMethods: true, + isArgument: true, + executeAnonymousFunctions: true + }); + var args = []; + var $el = can.$(this); + var viewModel = can.viewModel($el[0]); + var localScope = data.scope.add({ + '@element': $el, + '@event': ev, + '@viewModel': viewModel, + '@scope': data.scope, + '@context': data.scope._context + }); + if (!can.isEmptyObject(attrInfo.hash)) { + var hash = {}; + can.each(attrInfo.hash, function (val, key) { + if (val && val.hasOwnProperty('get')) { + var s = !val.get.indexOf('@') ? localScope : data.scope; + hash[key] = s.read(val.get, {}).value; + } else { + hash[key] = val; + } + }); + args.unshift(hash); + } + if (attrInfo.args.length) { + var arg; + for (var i = attrInfo.args.length - 1; i >= 0; i--) { + arg = attrInfo.args[i]; + if (arg && arg.hasOwnProperty('get')) { + var s = !arg.get.indexOf('@') ? localScope : data.scope; + args.unshift(s.read(arg.get, {}).value); + } else { + args.unshift(arg); + } + } + } + if (!args.length) { + args = [ + data.scope._context, + $el + ].concat(can.makeArray(arguments)); + } + return scopeData.value.apply(scopeData.parent, args); + }; + if (special[event]) { + var specialData = special[event](data, el, handler); + handler = specialData.handler; + event = specialData.event; + } + can.bind.call(el, event, handler); + }); + var Value = can.Control.extend({ + init: function () { + if (this.element[0].nodeName.toUpperCase() === 'SELECT') { + setTimeout(can.proxy(this.set, this), 1); + } else { + this.set(); + } + }, + '{value} change': 'set', + set: function () { + if (!this.element) { + return; + } + var val = this.options.value(); + this.element[0].value = val == null ? '' : val; + }, + 'change': function () { + if (!this.element) { + return; + } + var el = this.element[0]; + this.options.value(el.value); + var newVal = this.options.value(); + if (el.value !== newVal) { + el.value = newVal; + } + } + }), Checked = can.Control.extend({ + init: function () { + this.isCheckbox = this.element[0].type.toLowerCase() === 'checkbox'; + this.check(); + }, + '{value} change': 'check', + check: function () { + if (this.isCheckbox) { + var value = this.options.value(), trueValue = this.options.trueValue || true; + this.element[0].checked = value == trueValue; + } else { + var setOrRemove = this.options.value() == this.element[0].value ? 'set' : 'remove'; + can.attr[setOrRemove](this.element[0], 'checked', true); + } + }, + 'change': function () { + if (this.isCheckbox) { + this.options.value(this.element[0].checked ? this.options.trueValue : this.options.falseValue); + } else { + if (this.element[0].checked) { + this.options.value(this.element[0].value); + } + } + } + }), Multiselect = Value.extend({ + init: function () { + this.delimiter = ';'; + setTimeout(can.proxy(this.set, this), 1); + }, + set: function () { + var newVal = this.options.value(); + if (typeof newVal === 'string') { + newVal = newVal.split(this.delimiter); + this.isString = true; + } else if (newVal) { + newVal = can.makeArray(newVal); + } + var isSelected = {}; + can.each(newVal, function (val) { + isSelected[val] = true; + }); + can.each(this.element[0].childNodes, function (option) { + if (option.value) { + option.selected = !!isSelected[option.value]; + } + }); + }, + get: function () { + var values = [], children = this.element[0].childNodes; + can.each(children, function (child) { + if (child.selected && child.value) { + values.push(child.value); + } + }); + return values; + }, + 'change': function () { + var value = this.get(), currentValue = this.options.value(); + if (this.isString || typeof currentValue === 'string') { + this.isString = true; + this.options.value(value.join(this.delimiter)); + } else if (currentValue instanceof can.List) { + currentValue.attr(value, true); + } else { + this.options.value(value); + } + } + }), Content = can.Control.extend({ + init: function () { + this.set(); + this.on('blur', 'setValue'); + }, + '{value} change': 'set', + set: function () { + var val = this.options.value(); + this.element[0].innerHTML = typeof val === 'undefined' ? '' : val; + }, + setValue: function () { + this.options.value(this.element[0].innerHTML); + } + }); +}); +/*can@2.2.6#view/mustache/mustache*/ +define('can/view/mustache/mustache', [ + 'can/util/util', + 'can/view/scope/scope', + 'can/view/view', + 'can/view/scanner', + 'can/compute/compute', + 'can/view/render', + 'can/view/bindings/bindings' +], function (can) { + can.view.ext = '.mustache'; + var SCOPE = 'scope', HASH = '___h4sh', CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options}', SPECIAL_CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options, special: true}', ARG_NAMES = SCOPE + ',options', argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false|null|undefined)|((.+?)=(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false)|(.+))))$/, makeLookupLiteral = function (type) { + return '{get:"' + type.replace(/"/g, '\\"') + '"}'; + }, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, isObserveLike = function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, isArrayLike = function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, makeConvertToScopes = function (original, scope, options) { + var originalWithScope = function (ctx, opts) { + return original(ctx || scope, opts); + }; + return function (updatedScope, updatedOptions) { + if (updatedScope !== undefined && !(updatedScope instanceof can.view.Scope)) { + updatedScope = scope.add(updatedScope); + } + if (updatedOptions !== undefined && !(updatedOptions instanceof can.view.Options)) { + updatedOptions = options.add(updatedOptions); + } + return originalWithScope(updatedScope, updatedOptions || options); + }; + }; + var Mustache = function (options, helpers) { + if (this.constructor !== Mustache) { + var mustache = new Mustache(options); + return function (data, options) { + return mustache.render(data, options); + }; + } + if (typeof options === 'function') { + this.template = { fn: options }; + return; + } + can.extend(this, options); + this.template = this.scanner.scan(this.text, this.name); + }; + can.Mustache = can.global.Mustache = Mustache; + Mustache.prototype.render = function (data, options) { + if (!(data instanceof can.view.Scope)) { + data = new can.view.Scope(data || {}); + } + if (!(options instanceof can.view.Options)) { + options = new can.view.Options(options || {}); + } + options = options || {}; + return this.template.fn.call(data, data, options); + }; + can.extend(Mustache.prototype, { + scanner: new can.view.Scanner({ + text: { + start: '', + scope: SCOPE, + options: ',options: options', + argNames: ARG_NAMES + }, + tokens: [ + [ + 'returnLeft', + '{{{', + '{{[{&]' + ], + [ + 'commentFull', + '{{!}}', + '^[\\s\\t]*{{!.+?}}\\n' + ], + [ + 'commentLeft', + '{{!', + '(\\n[\\s\\t]*{{!|{{!)' + ], + [ + 'escapeFull', + '{{}}', + '(^[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}$)', + function (content) { + return { + before: /^\n.+?\n$/.test(content) ? '\n' : '', + content: content.match(/\{\{(.+?)\}\}/)[1] || '' + }; + } + ], + [ + 'escapeLeft', + '{{' + ], + [ + 'returnRight', + '}}}' + ], + [ + 'right', + '}}' + ] + ], + helpers: [ + { + name: /^>[\s]*\w*/, + fn: function (content, cmd) { + var templateName = can.trim(content.replace(/^>\s?/, '')).replace(/["|']/g, ''); + return 'can.Mustache.renderPartial(\'' + templateName + '\',' + ARG_NAMES + ')'; + } + }, + { + name: /^\s*data\s/, + fn: function (content, cmd) { + var attr = content.match(/["|'](.*)["|']/)[1]; + return 'can.proxy(function(__){' + 'can.data(can.$(__),\'' + attr + '\', this.attr(\'.\')); }, ' + SCOPE + ')'; + } + }, + { + name: /\s*\(([\$\w]+)\)\s*->([^\n]*)/, + fn: function (content) { + var quickFunc = /\s*\(([\$\w]+)\)\s*->([^\n]*)/, parts = content.match(quickFunc); + return 'can.proxy(function(__){var ' + parts[1] + '=can.$(__);with(' + SCOPE + '.attr(\'.\')){' + parts[2] + '}}, this);'; + } + }, + { + name: /^.*$/, + fn: function (content, cmd) { + var mode = false, result = { + content: '', + startTxt: false, + startOnlyTxt: false, + end: false + }; + content = can.trim(content); + if (content.length && (mode = content.match(/^([#^\/]|else$)/))) { + mode = mode[0]; + switch (mode) { + case '#': + case '^': + if (cmd.specialAttribute) { + result.startOnlyTxt = true; + } else { + result.startTxt = true; + result.escaped = 0; + } + break; + case '/': + result.end = true; + result.content += 'return ___v1ew.join("");}}])'; + return result; + } + content = content.substring(1); + } + if (mode !== 'else') { + var args = [], hashes = [], i = 0, m; + result.content += 'can.Mustache.txt(\n' + (cmd.specialAttribute ? SPECIAL_CONTEXT_OBJ : CONTEXT_OBJ) + ',\n' + (mode ? '"' + mode + '"' : 'null') + ','; + (can.trim(content) + ' ').replace(argumentsRegExp, function (whole, arg) { + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[2]) { + args.push(m[0]); + } else { + hashes.push(m[4] + ':' + (m[6] ? m[6] : makeLookupLiteral(m[5]))); + } + } else { + args.push(makeLookupLiteral(arg)); + } + i++; + }); + result.content += args.join(','); + if (hashes.length) { + result.content += ',{' + HASH + ':{' + hashes.join(',') + '}}'; + } + } + if (mode && mode !== 'else') { + result.content += ',[\n\n'; + } + switch (mode) { + case '^': + case '#': + result.content += '{fn:function(' + ARG_NAMES + '){var ___v1ew = [];'; + break; + case 'else': + result.content += 'return ___v1ew.join("");}},\n{inverse:function(' + ARG_NAMES + '){\nvar ___v1ew = [];'; + break; + default: + result.content += ')'; + break; + } + if (!mode) { + result.startTxt = true; + result.end = true; + } + return result; + } + } + ] + }) + }); + var helpers = can.view.Scanner.prototype.helpers; + for (var i = 0; i < helpers.length; i++) { + Mustache.prototype.scanner.helpers.unshift(helpers[i]); + } + Mustache.txt = function (scopeAndOptions, mode, name) { + var scope = scopeAndOptions.scope, options = scopeAndOptions.options, args = [], helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, hash, context = scope.attr('.'), getHelper = true, helper; + for (var i = 3; i < arguments.length; i++) { + var arg = arguments[i]; + if (mode && can.isArray(arg)) { + helperOptions = can.extend.apply(can, [helperOptions].concat(arg)); + } else if (arg && arg[HASH]) { + hash = arg[HASH]; + for (var prop in hash) { + if (isLookup(hash[prop])) { + hash[prop] = Mustache.get(hash[prop].get, scopeAndOptions, false, true); + } + } + } else if (arg && isLookup(arg)) { + args.push(Mustache.get(arg.get, scopeAndOptions, false, true, true)); + } else { + args.push(arg); + } + } + if (isLookup(name)) { + var get = name.get; + name = Mustache.get(name.get, scopeAndOptions, args.length, false); + getHelper = get === name; + } + helperOptions.fn = makeConvertToScopes(helperOptions.fn, scope, options); + helperOptions.inverse = makeConvertToScopes(helperOptions.inverse, scope, options); + if (mode === '^') { + var tmp = helperOptions.fn; + helperOptions.fn = helperOptions.inverse; + helperOptions.inverse = tmp; + } + if (helper = getHelper && (typeof name === 'string' && Mustache.getHelper(name, options)) || can.isFunction(name) && !name.isComputed && { fn: name }) { + can.extend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash + }); + args.push(helperOptions); + return function () { + return helper.fn.apply(context, args) || ''; + }; + } + return function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + var validArgs = args.length ? args : [value], valid = true, result = [], i, argIsObserve, arg; + if (mode) { + for (i = 0; i < validArgs.length; i++) { + arg = validArgs[i]; + argIsObserve = typeof arg !== 'undefined' && isObserveLike(arg); + if (isArrayLike(arg)) { + if (mode === '#') { + valid = valid && !!(argIsObserve ? arg.attr('length') : arg.length); + } else if (mode === '^') { + valid = valid && !(argIsObserve ? arg.attr('length') : arg.length); + } + } else { + valid = mode === '#' ? valid && !!arg : mode === '^' ? valid && !arg : valid; + } + } + } + if (valid) { + if (mode === '#') { + if (isArrayLike(value)) { + var isObserveList = isObserveLike(value); + for (i = 0; i < value.length; i++) { + result.push(helperOptions.fn(isObserveList ? value.attr('' + i) : value[i])); + } + return result.join(''); + } else { + return helperOptions.fn(value || {}) || ''; + } + } else if (mode === '^') { + return helperOptions.inverse(value || {}) || ''; + } else { + return '' + (value != null ? value : ''); + } + } + return ''; + }; + }; + Mustache.get = function (key, scopeAndOptions, isHelper, isArgument, isLookup) { + var context = scopeAndOptions.scope.attr('.'), options = scopeAndOptions.options || {}; + if (isHelper) { + if (Mustache.getHelper(key, options)) { + return key; + } + if (scopeAndOptions.scope && can.isFunction(context[key])) { + return context[key]; + } + } + var computeData = scopeAndOptions.scope.computeData(key, { + isArgument: isArgument, + args: [ + context, + scopeAndOptions.scope + ] + }), compute = computeData.compute; + can.compute.temporarilyBind(compute); + var initialValue = computeData.initialValue, helperObj = Mustache.getHelper(key, options); + if (!isLookup && (initialValue === undefined || computeData.scope !== scopeAndOptions.scope) && Mustache.getHelper(key, options)) { + return key; + } + if (!compute.computeInstance.hasDependencies) { + return initialValue; + } else { + return compute; + } + }; + Mustache.resolve = function (value) { + if (isObserveLike(value) && isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + can.view.Options = can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }); + Mustache._helpers = {}; + Mustache.registerHelper = function (name, fn) { + this._helpers[name] = { + name: name, + fn: fn + }; + }; + Mustache.getHelper = function (name, options) { + var helper; + if (options) { + helper = options.attr('helpers.' + name); + } + return helper ? { fn: helper } : this._helpers[name]; + }; + Mustache.render = function (partial, scope, options) { + if (!can.view.cached[partial]) { + var reads = can.__clearReading(); + var scopePartialName = scope.attr(partial); + if (scopePartialName) { + partial = scopePartialName; + } + can.__setReading(reads); + } + return can.view.render(partial, scope, options); + }; + Mustache.safeString = function (str) { + return { + toString: function () { + return str; + } + }; + }; + Mustache.renderPartial = function (partialName, scope, options) { + var partial = options.attr('partials.' + partialName); + if (partial) { + return partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + return can.Mustache.render(partialName, scope, options); + } + }; + can.each({ + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!Mustache.resolve(expr); + } + if (value) { + return options.fn(options.contexts || this); + } else { + return options.inverse(options.contexts || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = Mustache.resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return Mustache._helpers.is.fn.apply(this, arguments); + }, + 'unless': function (expr, options) { + return Mustache._helpers['if'].fn.apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'each': function (expr, options) { + var resolved = Mustache.resolve(expr), result = [], keys, key, i; + if (can.view.lists && (resolved instanceof can.List || expr && expr.isComputed && resolved === undefined)) { + return can.view.lists(expr, function (item, index) { + return options.fn(options.scope.add({ '@index': index }).add(item)); + }); + } + expr = resolved; + if (!!expr && isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + return result.join(''); + } else if (isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } + }, + 'with': function (expr, options) { + var ctx = expr; + expr = Mustache.resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + } + }, function (fn, name) { + Mustache.registerHelper(name, fn); + }); + can.view.register({ + suffix: 'mustache', + contentType: 'x-mustache-template', + script: function (id, src) { + return 'can.Mustache(function(' + ARG_NAMES + ') { ' + new Mustache({ + text: src, + name: id + }).template.out + ' })'; + }, + renderer: function (id, text) { + return Mustache({ + text: text, + name: id + }); + } + }); + can.mustache.registerHelper = can.proxy(can.Mustache.registerHelper, can.Mustache); + can.mustache.safeString = can.Mustache.safeString; + return can; +}); +/*can@2.2.6#component/component*/ +define('can/component/component', [ + 'can/util/util', + 'can/view/callbacks/callbacks', + 'can/view/elements', + 'can/control/control', + 'can/observe/observe', + 'can/view/mustache/mustache', + 'can/view/bindings/bindings' +], function (can, viewCallbacks, elements) { + var ignoreAttributesRegExp = /^(dataViewId|class|id)$/i, paramReplacer = /\{([^\}]+)\}/g; + var Component = can.Component = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Component) { + var self = this, scope = this.prototype.scope || this.prototype.viewModel; + this.Control = ComponentControl.extend(this.prototype.events); + if (!scope || typeof scope === 'object' && !(scope instanceof can.Map)) { + this.Map = can.Map.extend(scope || {}); + } else if (scope.prototype instanceof can.Map) { + this.Map = scope; + } + this.attributeScopeMappings = {}; + can.each(this.Map ? this.Map.defaults : {}, function (val, prop) { + if (val === '@') { + self.attributeScopeMappings[prop] = prop; + } + }); + if (this.prototype.template) { + if (typeof this.prototype.template === 'function') { + var temp = this.prototype.template; + this.renderer = function () { + return can.view.frag(temp.apply(null, arguments)); + }; + } else { + this.renderer = can.view.mustache(this.prototype.template); + } + } + can.view.tag(this.prototype.tag, function (el, options) { + new self(el, options); + }); + } + } + }, { + setup: function (el, hookupOptions) { + var initialScopeData = {}, component = this, lexicalContent = (typeof this.leakScope === 'undefined' ? false : !this.leakScope) && this.template, twoWayBindings = {}, scope = this.scope || this.viewModel, viewModelPropertyUpdates = {}, componentScope, frag, teardownFunctions = [], callTeardownFunctions = function () { + for (var i = 0, len = teardownFunctions.length; i < len; i++) { + teardownFunctions[i](); + } + }; + can.each(this.constructor.attributeScopeMappings, function (val, prop) { + initialScopeData[prop] = el.getAttribute(can.hyphenate(val)); + }); + can.each(can.makeArray(el.attributes), function (node, index) { + var name = can.camelize(node.nodeName.toLowerCase()), value = node.value; + if (component.constructor.attributeScopeMappings[name] || ignoreAttributesRegExp.test(name) || viewCallbacks.attr(node.nodeName)) { + return; + } + if (value[0] === '{' && value[value.length - 1] === '}') { + value = value.substr(1, value.length - 2); + } else { + if (hookupOptions.templateType !== 'legacy') { + initialScopeData[name] = value; + return; + } + } + var computeData = hookupOptions.scope.computeData(value, { args: [] }), compute = computeData.compute; + var handler = function (ev, newVal) { + viewModelPropertyUpdates[name] = (viewModelPropertyUpdates[name] || 0) + 1; + componentScope.attr(name, newVal); + can.batch.afterPreviousEvents(function () { + --viewModelPropertyUpdates[name]; + }); + }; + compute.bind('change', handler); + initialScopeData[name] = compute(); + if (!compute.computeInstance.hasDependencies) { + compute.unbind('change', handler); + } else { + teardownFunctions.push(function () { + compute.unbind('change', handler); + }); + twoWayBindings[name] = computeData; + } + }); + if (this.constructor.Map) { + componentScope = new this.constructor.Map(initialScopeData); + } else if (scope instanceof can.Map) { + componentScope = scope; + } else if (can.isFunction(scope)) { + var scopeResult = scope.call(this, initialScopeData, hookupOptions.scope, el); + if (scopeResult instanceof can.Map) { + componentScope = scopeResult; + } else if (scopeResult.prototype instanceof can.Map) { + componentScope = new scopeResult(initialScopeData); + } else { + componentScope = new (can.Map.extend(scopeResult))(initialScopeData); + } + } + var handlers = {}; + can.each(twoWayBindings, function (computeData, prop) { + handlers[prop] = function (ev, newVal) { + if (!viewModelPropertyUpdates[prop]) { + computeData.compute(newVal); + } + }; + componentScope.bind(prop, handlers[prop]); + }); + if (!can.isEmptyObject(this.constructor.attributeScopeMappings) || hookupOptions.templateType !== 'legacy') { + can.bind.call(el, 'attributes', function (ev) { + var camelized = can.camelize(ev.attributeName); + if (!twoWayBindings[camelized] && !ignoreAttributesRegExp.test(camelized)) { + componentScope.attr(camelized, el.getAttribute(ev.attributeName)); + } + }); + } + this.scope = this.viewModel = componentScope; + can.data(can.$(el), 'scope', this.scope); + can.data(can.$(el), 'viewModel', this.scope); + var renderedScope = lexicalContent ? this.scope : hookupOptions.scope.add(this.scope), options = { helpers: {} }; + can.each(this.helpers || {}, function (val, prop) { + if (can.isFunction(val)) { + options.helpers[prop] = function () { + return val.apply(componentScope, arguments); + }; + } + }); + teardownFunctions.push(function () { + can.each(handlers, function (handler, prop) { + componentScope.unbind(prop, handlers[prop]); + }); + }); + this._control = new this.constructor.Control(el, { + scope: this.scope, + viewModel: this.scope + }); + if (this._control && this._control.destroy) { + var oldDestroy = this._control.destroy; + this._control.destroy = function () { + oldDestroy.apply(this, arguments); + callTeardownFunctions(); + }; + this._control.on(); + } else { + can.bind.call(el, 'removed', function () { + callTeardownFunctions(); + }); + } + var nodeList = can.view.nodeLists.register([], undefined, true); + teardownFunctions.push(function () { + can.view.nodeLists.unregister(nodeList); + }); + if (this.constructor.renderer) { + if (!options.tags) { + options.tags = {}; + } + options.tags.content = function contentHookup(el, rendererOptions) { + var subtemplate = hookupOptions.subtemplate || rendererOptions.subtemplate; + if (subtemplate) { + delete options.tags.content; + var opts = !lexicalContent || subtemplate !== hookupOptions.subtemplate ? rendererOptions : hookupOptions; + if (rendererOptions.parentNodeList) { + var frag = subtemplate(opts.scope, opts.options, rendererOptions.parentNodeList); + elements.replace([el], frag); + } else { + can.view.live.replace([el], subtemplate(opts.scope, opts.options)); + } + options.tags.content = contentHookup; + } + }; + frag = this.constructor.renderer(renderedScope, hookupOptions.options.add(options), nodeList); + } else { + if (hookupOptions.templateType === 'legacy') { + frag = can.view.frag(hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options)) : ''); + } else { + frag = hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options), nodeList) : document.createDocumentFragment(); + } + } + can.appendChild(el, frag); + can.view.nodeLists.update(nodeList, el.childNodes); + } + }); + var ComponentControl = can.Control.extend({ + _lookup: function (options) { + return [ + options.scope, + options, + window + ]; + }, + _action: function (methodName, options, controlInstance) { + var hasObjectLookup, readyCompute; + paramReplacer.lastIndex = 0; + hasObjectLookup = paramReplacer.test(methodName); + if (!controlInstance && hasObjectLookup) { + return; + } else if (!hasObjectLookup) { + return can.Control._action.apply(this, arguments); + } else { + readyCompute = can.compute(function () { + var delegate; + var name = methodName.replace(paramReplacer, function (matched, key) { + var value; + if (key === 'scope' || key === 'viewModel') { + delegate = options.scope; + return ''; + } + key = key.replace(/^(scope|^viewModel)\./, ''); + value = can.compute.read(options.scope, key.split('.'), { isArgument: true }).value; + if (value === undefined) { + value = can.getObject(key); + } + if (typeof value === 'string') { + return value; + } else { + delegate = value; + return ''; + } + }); + var parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: this.processors[event] || this.processors.click, + parts: [ + name, + parts.join(' '), + event + ], + delegate: delegate || undefined + }; + }, this); + var handler = function (ev, ready) { + controlInstance._bindings.control[methodName](controlInstance.element); + controlInstance._bindings.control[methodName] = ready.processor(ready.delegate || controlInstance.element, ready.parts[2], ready.parts[1], methodName, controlInstance); + }; + readyCompute.bind('change', handler); + controlInstance._bindings.readyComputes[methodName] = { + compute: readyCompute, + handler: handler + }; + return readyCompute(); + } + } + }, { + setup: function (el, options) { + this.scope = options.scope; + this.viewModel = options.viewModel; + return can.Control.prototype.setup.call(this, el, options); + }, + off: function () { + if (this._bindings) { + can.each(this._bindings.readyComputes || {}, function (value) { + value.compute.unbind('change', value.handler); + }); + } + can.Control.prototype.off.apply(this, arguments); + this._bindings.readyComputes = {}; + } + }); + var $ = can.$; + if ($.fn) { + $.fn.scope = $.fn.viewModel = function () { + return can.viewModel.apply(can, [this].concat(can.makeArray(arguments))); + }; + } + return Component; +}); +/*can@2.2.6#model/model*/ +define('can/model/model', [ + 'can/util/util', + 'can/map/map', + 'can/list/list' +], function (can) { + var pipe = function (def, thisArg, func) { + var d = new can.Deferred(); + def.then(function () { + var args = can.makeArray(arguments), success = true; + try { + args[0] = func.apply(thisArg, args); + } catch (e) { + success = false; + d.rejectWith(d, [e].concat(args)); + } + if (success) { + d.resolveWith(d, args); + } + }, function () { + d.rejectWith(this, arguments); + }); + if (typeof def.abort === 'function') { + d.abort = function () { + return def.abort(); + }; + } + return d; + }, modelNum = 0, getId = function (inst) { + can.__observe(inst, inst.constructor.id); + return inst.__get(inst.constructor.id); + }, ajax = function (ajaxOb, data, type, dataType, success, error) { + var params = {}; + if (typeof ajaxOb === 'string') { + var parts = ajaxOb.split(/\s+/); + params.url = parts.pop(); + if (parts.length) { + params.type = parts.pop(); + } + } else { + can.extend(params, ajaxOb); + } + params.data = typeof data === 'object' && !can.isArray(data) ? can.extend(params.data || {}, data) : data; + params.url = can.sub(params.url, params.data, true); + return can.ajax(can.extend({ + type: type || 'post', + dataType: dataType || 'json', + success: success, + error: error + }, params)); + }, makeRequest = function (modelObj, type, success, error, method) { + var args; + if (can.isArray(modelObj)) { + args = modelObj[1]; + modelObj = modelObj[0]; + } else { + args = modelObj.serialize(); + } + args = [args]; + var deferred, model = modelObj.constructor, jqXHR; + if (type === 'update' || type === 'destroy') { + args.unshift(getId(modelObj)); + } + jqXHR = model[type].apply(model, args); + deferred = pipe(jqXHR, modelObj, function (data) { + modelObj[method || type + 'd'](data, jqXHR); + return modelObj; + }); + if (jqXHR.abort) { + deferred.abort = function () { + jqXHR.abort(); + }; + } + deferred.then(success, error); + return deferred; + }, converters = { + models: function (instancesRawData, oldList, xhr) { + can.Model._reqs++; + if (!instancesRawData) { + return; + } + if (instancesRawData instanceof this.List) { + return instancesRawData; + } + var self = this, tmp = [], ListClass = self.List || ML, modelList = oldList instanceof can.List ? oldList : new ListClass(), rawDataIsList = instancesRawData instanceof ML, raw = rawDataIsList ? instancesRawData.serialize() : instancesRawData; + raw = self.parseModels(raw, xhr); + if (raw.data) { + instancesRawData = raw; + raw = raw.data; + } + if (typeof raw === 'undefined' || !can.isArray(raw)) { + throw new Error('Could not get any raw data while converting using .models'); + } + if (modelList.length) { + modelList.splice(0); + } + can.each(raw, function (rawPart) { + tmp.push(self.model(rawPart, xhr)); + }); + modelList.push.apply(modelList, tmp); + if (!can.isArray(instancesRawData)) { + can.each(instancesRawData, function (val, prop) { + if (prop !== 'data') { + modelList.attr(prop, val); + } + }); + } + setTimeout(can.proxy(this._clean, this), 1); + return modelList; + }, + model: function (attributes, oldModel, xhr) { + if (!attributes) { + return; + } + if (typeof attributes.serialize === 'function') { + attributes = attributes.serialize(); + } else { + attributes = this.parseModel(attributes, xhr); + } + var id = attributes[this.id]; + if ((id || id === 0) && this.store[id]) { + oldModel = this.store[id]; + } + var model = oldModel && can.isFunction(oldModel.attr) ? oldModel.attr(attributes, this.removeAttr || false) : new this(attributes); + return model; + } + }, makeParser = { + parseModel: function (prop) { + return function (attributes) { + return prop ? can.getObject(prop, attributes) : attributes; + }; + }, + parseModels: function (prop) { + return function (attributes) { + if (can.isArray(attributes)) { + return attributes; + } + prop = prop || 'data'; + var result = can.getObject(prop, attributes); + if (!can.isArray(result)) { + throw new Error('Could not get any raw data while converting using .models'); + } + return result; + }; + } + }, ajaxMethods = { + create: { + url: '_shortName', + type: 'post' + }, + update: { + data: function (id, attrs) { + attrs = attrs || {}; + var identity = this.id; + if (attrs[identity] && attrs[identity] !== id) { + attrs['new' + can.capitalize(id)] = attrs[identity]; + delete attrs[identity]; + } + attrs[identity] = id; + return attrs; + }, + type: 'put' + }, + destroy: { + type: 'delete', + data: function (id, attrs) { + attrs = attrs || {}; + attrs.id = attrs[this.id] = id; + return attrs; + } + }, + findAll: { url: '_shortName' }, + findOne: {} + }, ajaxMaker = function (ajaxMethod, str) { + return function (data) { + data = ajaxMethod.data ? ajaxMethod.data.apply(this, arguments) : data; + return ajax(str || this[ajaxMethod.url || '_url'], data, ajaxMethod.type || 'get'); + }; + }, createURLFromResource = function (model, name) { + if (!model.resource) { + return; + } + var resource = model.resource.replace(/\/+$/, ''); + if (name === 'findAll' || name === 'create') { + return resource; + } else { + return resource + '/{' + model.id + '}'; + } + }; + can.Model = can.Map.extend({ + fullName: 'can.Model', + _reqs: 0, + setup: function (base, fullName, staticProps, protoProps) { + if (typeof fullName !== 'string') { + protoProps = staticProps; + staticProps = fullName; + } + if (!protoProps) { + protoProps = staticProps; + } + this.store = {}; + can.Map.setup.apply(this, arguments); + if (!can.Model) { + return; + } + if (staticProps && staticProps.List) { + this.List = staticProps.List; + this.List.Map = this; + } else { + this.List = base.List.extend({ Map: this }, {}); + } + var self = this, clean = can.proxy(this._clean, self); + can.each(ajaxMethods, function (method, name) { + if (staticProps && staticProps[name] && (typeof staticProps[name] === 'string' || typeof staticProps[name] === 'object')) { + self[name] = ajaxMaker(method, staticProps[name]); + } else if (staticProps && staticProps.resource && !can.isFunction(staticProps[name])) { + self[name] = ajaxMaker(method, createURLFromResource(self, name)); + } + if (self['make' + can.capitalize(name)]) { + var newMethod = self['make' + can.capitalize(name)](self[name]); + can.Construct._overwrite(self, base, name, function () { + can.Model._reqs++; + var def = newMethod.apply(this, arguments); + var then = def.then(clean, clean); + then.abort = def.abort; + return then; + }); + } + }); + var hasCustomConverter = {}; + can.each(converters, function (converter, name) { + var parseName = 'parse' + can.capitalize(name), dataProperty = staticProps && staticProps[name] || self[name]; + if (typeof dataProperty === 'string') { + self[parseName] = dataProperty; + can.Construct._overwrite(self, base, name, converter); + } else if (staticProps && staticProps[name]) { + hasCustomConverter[parseName] = true; + } + }); + can.each(makeParser, function (maker, parseName) { + var prop = staticProps && staticProps[parseName] || self[parseName]; + if (typeof prop === 'string') { + can.Construct._overwrite(self, base, parseName, maker(prop)); + } else if ((!staticProps || !can.isFunction(staticProps[parseName])) && !self[parseName]) { + var madeParser = maker(); + madeParser.useModelConverter = hasCustomConverter[parseName]; + can.Construct._overwrite(self, base, parseName, madeParser); + } + }); + if (self.fullName === 'can.Model' || !self.fullName) { + self.fullName = 'Model' + ++modelNum; + } + can.Model._reqs = 0; + this._url = this._shortName + '/{' + this.id + '}'; + }, + _ajax: ajaxMaker, + _makeRequest: makeRequest, + _clean: function () { + can.Model._reqs--; + if (!can.Model._reqs) { + for (var id in this.store) { + if (!this.store[id]._bindings) { + delete this.store[id]; + } + } + } + return arguments[0]; + }, + models: converters.models, + model: converters.model + }, { + setup: function (attrs) { + var id = attrs && attrs[this.constructor.id]; + if (can.Model._reqs && id != null) { + this.constructor.store[id] = this; + } + can.Map.prototype.setup.apply(this, arguments); + }, + isNew: function () { + var id = getId(this); + return !(id || id === 0); + }, + save: function (success, error) { + return makeRequest(this, this.isNew() ? 'create' : 'update', success, error); + }, + destroy: function (success, error) { + if (this.isNew()) { + var self = this; + var def = can.Deferred(); + def.then(success, error); + return def.done(function (data) { + self.destroyed(data); + }).resolve(self); + } + return makeRequest(this, 'destroy', success, error, 'destroyed'); + }, + _bindsetup: function () { + var modelInstance = this.__get(this.constructor.id); + if (modelInstance != null) { + this.constructor.store[modelInstance] = this; + } + return can.Map.prototype._bindsetup.apply(this, arguments); + }, + _bindteardown: function () { + delete this.constructor.store[getId(this)]; + return can.Map.prototype._bindteardown.apply(this, arguments); + }, + ___set: function (prop, val) { + can.Map.prototype.___set.call(this, prop, val); + if (prop === this.constructor.id && this._bindings) { + this.constructor.store[getId(this)] = this; + } + } + }); + var makeGetterHandler = function (name) { + return function (data, readyState, xhr) { + return this[name](data, null, xhr); + }; + }, createUpdateDestroyHandler = function (data) { + if (this.parseModel.useModelConverter) { + return this.model(data); + } + return this.parseModel(data); + }; + var responseHandlers = { + makeFindAll: makeGetterHandler('models'), + makeFindOne: makeGetterHandler('model'), + makeCreate: createUpdateDestroyHandler, + makeUpdate: createUpdateDestroyHandler, + makeDestroy: createUpdateDestroyHandler + }; + can.each(responseHandlers, function (method, name) { + can.Model[name] = function (oldMethod) { + return function () { + var args = can.makeArray(arguments), oldArgs = can.isFunction(args[1]) ? args.splice(0, 1) : args.splice(0, 2), def = pipe(oldMethod.apply(this, oldArgs), this, method); + def.then(args[0], args[1]); + return def; + }; + }; + }); + can.each([ + 'created', + 'updated', + 'destroyed' + ], function (funcName) { + can.Model.prototype[funcName] = function (attrs) { + var self = this, constructor = self.constructor; + if (attrs && typeof attrs === 'object') { + this.attr(can.isFunction(attrs.attr) ? attrs.attr() : attrs); + } + can.dispatch.call(this, { + type: 'change', + target: this + }, [funcName]); + can.dispatch.call(constructor, funcName, [this]); + }; + }); + var ML = can.Model.List = can.List.extend({ + _bubbleRule: function (eventName, list) { + var bubbleRules = can.List._bubbleRule(eventName, list); + bubbleRules.push('destroyed'); + return bubbleRules; + } + }, { + setup: function (params) { + if (can.isPlainObject(params) && !can.isArray(params)) { + can.List.prototype.setup.apply(this); + this.replace(can.isDeferred(params) ? params : this.constructor.Map.findAll(params)); + } else { + can.List.prototype.setup.apply(this, arguments); + } + this._init = 1; + this.bind('destroyed', can.proxy(this._destroyed, this)); + delete this._init; + }, + _destroyed: function (ev, attr) { + if (/\w+/.test(attr)) { + var index; + while ((index = this.indexOf(ev.target)) > -1) { + this.splice(index, 1); + } + } + } + }); + return can.Model; +}); +/*can@2.2.6#util/string/deparam/deparam*/ +define('can/util/string/deparam/deparam', [ + 'can/util/util', + 'can/util/string/string' +], function (can) { + var digitTest = /^\d+$/, keyBreaker = /([^\[\]]+)|(\[\])/g, paramTest = /([^?#]*)(#.*)?$/, prep = function (str) { + return decodeURIComponent(str.replace(/\+/g, ' ')); + }; + can.extend(can, { + deparam: function (params) { + var data = {}, pairs, lastPart; + if (params && paramTest.test(params)) { + pairs = params.split('&'); + can.each(pairs, function (pair) { + var parts = pair.split('='), key = prep(parts.shift()), value = prep(parts.join('=')), current = data; + if (key) { + parts = key.match(keyBreaker); + for (var j = 0, l = parts.length - 1; j < l; j++) { + if (!current[parts[j]]) { + current[parts[j]] = digitTest.test(parts[j + 1]) || parts[j + 1] === '[]' ? [] : {}; + } + current = current[parts[j]]; + } + lastPart = parts.pop(); + if (lastPart === '[]') { + current.push(value); + } else { + current[lastPart] = value; + } + } + }); + } + return data; + } + }); + return can; +}); +/*can@2.2.6#route/route*/ +define('can/route/route', [ + 'can/util/util', + 'can/map/map', + 'can/list/list', + 'can/util/string/deparam/deparam' +], function (can) { + var matcher = /\:([\w\.]+)/g, paramsMatcher = /^(?:&[^=]+=[^&]*)+/, makeProps = function (props) { + var tags = []; + can.each(props, function (val, name) { + tags.push((name === 'className' ? 'class' : name) + '="' + (name === 'href' ? val : can.esc(val)) + '"'); + }); + return tags.join(' '); + }, matchesData = function (route, data) { + var count = 0, i = 0, defaults = {}; + for (var name in route.defaults) { + if (route.defaults[name] === data[name]) { + defaults[name] = 1; + count++; + } + } + for (; i < route.names.length; i++) { + if (!data.hasOwnProperty(route.names[i])) { + return -1; + } + if (!defaults[route.names[i]]) { + count++; + } + } + return count; + }, location = window.location, wrapQuote = function (str) { + return (str + '').replace(/([.?*+\^$\[\]\\(){}|\-])/g, '\\$1'); + }, each = can.each, extend = can.extend, stringify = function (obj) { + if (obj && typeof obj === 'object') { + if (obj instanceof can.Map) { + obj = obj.attr(); + } else { + obj = can.isFunction(obj.slice) ? obj.slice() : can.extend({}, obj); + } + can.each(obj, function (val, prop) { + obj[prop] = stringify(val); + }); + } else if (obj !== undefined && obj !== null && can.isFunction(obj.toString)) { + obj = obj.toString(); + } + return obj; + }, removeBackslash = function (str) { + return str.replace(/\\/g, ''); + }, timer, curParams, lastHash, changingData, changedAttrs = [], onRouteDataChange = function (ev, attr, how, newval) { + changingData = 1; + changedAttrs.push(attr); + clearTimeout(timer); + timer = setTimeout(function () { + changingData = 0; + var serialized = can.route.data.serialize(), path = can.route.param(serialized, true); + can.route._call('setURL', path, changedAttrs); + can.batch.trigger(eventsObject, '__url', [ + path, + lastHash + ]); + lastHash = path; + changedAttrs = []; + }, 10); + }, eventsObject = can.extend({}, can.event); + can.route = function (url, defaults) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + defaults = defaults || {}; + var names = [], res, test = '', lastIndex = matcher.lastIndex = 0, next, querySeparator = can.route._call('querySeparator'), matchSlashes = can.route._call('matchSlashes'); + while (res = matcher.exec(url)) { + names.push(res[1]); + test += removeBackslash(url.substring(lastIndex, matcher.lastIndex - res[0].length)); + next = '\\' + (removeBackslash(url.substr(matcher.lastIndex, 1)) || querySeparator + (matchSlashes ? '' : '|/')); + test += '([^' + next + ']' + (defaults[res[1]] ? '*' : '+') + ')'; + lastIndex = matcher.lastIndex; + } + test += url.substr(lastIndex).replace('\\', ''); + can.route.routes[url] = { + test: new RegExp('^' + test + '($|' + wrapQuote(querySeparator) + ')'), + route: url, + names: names, + defaults: defaults, + length: url.split('/').length + }; + return can.route; + }; + extend(can.route, { + param: function (data, _setRoute) { + var route, matches = 0, matchCount, routeName = data.route, propCount = 0; + delete data.route; + each(data, function () { + propCount++; + }); + each(can.route.routes, function (temp, name) { + matchCount = matchesData(temp, data); + if (matchCount > matches) { + route = temp; + matches = matchCount; + } + if (matchCount >= propCount) { + return false; + } + }); + if (can.route.routes[routeName] && matchesData(can.route.routes[routeName], data) === matches) { + route = can.route.routes[routeName]; + } + if (route) { + var cpy = extend({}, data), res = route.route.replace(matcher, function (whole, name) { + delete cpy[name]; + return data[name] === route.defaults[name] ? '' : encodeURIComponent(data[name]); + }).replace('\\', ''), after; + each(route.defaults, function (val, name) { + if (cpy[name] === val) { + delete cpy[name]; + } + }); + after = can.param(cpy); + if (_setRoute) { + can.route.attr('route', route.route); + } + return res + (after ? can.route._call('querySeparator') + after : ''); + } + return can.isEmptyObject(data) ? '' : can.route._call('querySeparator') + can.param(data); + }, + deparam: function (url) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + var route = { length: -1 }, querySeparator = can.route._call('querySeparator'), paramsMatcher = can.route._call('paramsMatcher'); + each(can.route.routes, function (temp, name) { + if (temp.test.test(url) && temp.length > route.length) { + route = temp; + } + }); + if (route.length > -1) { + var parts = url.match(route.test), start = parts.shift(), remainder = url.substr(start.length - (parts[parts.length - 1] === querySeparator ? 1 : 0)), obj = remainder && paramsMatcher.test(remainder) ? can.deparam(remainder.slice(1)) : {}; + obj = extend(true, {}, route.defaults, obj); + each(parts, function (part, i) { + if (part && part !== querySeparator) { + obj[route.names[i]] = decodeURIComponent(part); + } + }); + obj.route = route.route; + return obj; + } + if (url.charAt(0) !== querySeparator) { + url = querySeparator + url; + } + return paramsMatcher.test(url) ? can.deparam(url.slice(1)) : {}; + }, + data: new can.Map({}), + map: function (data) { + var appState; + if (data.prototype instanceof can.Map) { + appState = new data(); + } else { + appState = data; + } + can.route.data = appState; + }, + routes: {}, + ready: function (val) { + if (val !== true) { + can.route._setup(); + can.route.setState(); + } + return can.route; + }, + url: function (options, merge) { + if (merge) { + options = can.extend({}, can.route.deparam(can.route._call('matchingPartOfURL')), options); + } + return can.route._call('root') + can.route.param(options); + }, + link: function (name, options, props, merge) { + return '' + name + ''; + }, + current: function (options) { + can.__observe(eventsObject, '__url'); + return this._call('matchingPartOfURL') === can.route.param(options); + }, + bindings: { + hashchange: { + paramsMatcher: paramsMatcher, + querySeparator: '&', + matchSlashes: false, + bind: function () { + can.bind.call(window, 'hashchange', setState); + }, + unbind: function () { + can.unbind.call(window, 'hashchange', setState); + }, + matchingPartOfURL: function () { + return location.href.split(/#!?/)[1] || ''; + }, + setURL: function (path) { + if (location.hash !== '#' + path) { + location.hash = '!' + path; + } + return path; + }, + root: '#!' + } + }, + defaultBinding: 'hashchange', + currentBinding: null, + _setup: function () { + if (!can.route.currentBinding) { + can.route._call('bind'); + can.route.bind('change', onRouteDataChange); + can.route.currentBinding = can.route.defaultBinding; + } + }, + _teardown: function () { + if (can.route.currentBinding) { + can.route._call('unbind'); + can.route.unbind('change', onRouteDataChange); + can.route.currentBinding = null; + } + clearTimeout(timer); + changingData = 0; + }, + _call: function () { + var args = can.makeArray(arguments), prop = args.shift(), binding = can.route.bindings[can.route.currentBinding || can.route.defaultBinding], method = binding[prop]; + if (method.apply) { + return method.apply(binding, args); + } else { + return method; + } + } + }); + each([ + 'bind', + 'unbind', + 'on', + 'off', + 'delegate', + 'undelegate', + 'removeAttr', + 'compute', + '_get', + '__get', + 'each' + ], function (name) { + can.route[name] = function () { + if (!can.route.data[name]) { + return; + } + return can.route.data[name].apply(can.route.data, arguments); + }; + }); + can.route.attr = function (attr, val) { + var type = typeof attr, newArguments; + if (val === undefined) { + newArguments = arguments; + } else if (type !== 'string' && type !== 'number') { + newArguments = [ + stringify(attr), + val + ]; + } else { + newArguments = [ + attr, + stringify(val) + ]; + } + return can.route.data.attr.apply(can.route.data, newArguments); + }; + var setState = can.route.setState = function () { + var hash = can.route._call('matchingPartOfURL'); + var oldParams = curParams; + curParams = can.route.deparam(hash); + if (!changingData || hash !== lastHash) { + can.batch.start(); + recursiveClean(oldParams, curParams, can.route.data); + can.route.attr(curParams); + can.batch.trigger(eventsObject, '__url', [ + hash, + lastHash + ]); + can.batch.stop(); + } + }; + var recursiveClean = function (old, cur, data) { + for (var attr in old) { + if (cur[attr] === undefined) { + data.removeAttr(attr); + } else if (Object.prototype.toString.call(old[attr]) === '[object Object]') { + recursiveClean(old[attr], cur[attr], data.attr(attr)); + } + } + }; + return can.route; +}); +/*can@2.2.6#control/route/route*/ +define('can/control/route/route', [ + 'can/util/util', + 'can/route/route', + 'can/control/control' +], function (can) { + can.Control.processors.route = function (el, event, selector, funcName, controller) { + selector = selector || ''; + if (!can.route.routes[selector]) { + if (selector[0] === '/') { + selector = selector.substring(1); + } + can.route(selector); + } + var batchNum, check = function (ev, attr, how) { + if (can.route.attr('route') === selector && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + batchNum = ev.batchNum; + var d = can.route.attr(); + delete d.route; + if (can.isFunction(controller[funcName])) { + controller[funcName](d); + } else { + controller[controller[funcName]](d); + } + } + }; + can.route.bind('change', check); + return function () { + can.route.unbind('change', check); + }; + }; + return can; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.yui.min.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.yui.min.js new file mode 100644 index 0000000000..afeac4f1d2 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.yui.min.js @@ -0,0 +1,98 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +!function(exports,global){var origDefine=global.define,get=function(e){var o,l=e.split("."),n=global;for(o=0;o=0&&(e.defaultChecked=!0)):l?(i=a,e[l]!==a&&(e[l]=a),"value"===l&&t.inArray(o,r.defaultValue)>=0&&(e.defaultValue=a)):(e.setAttribute(n,a),i=a),r.MutationObserver||i===u||r.trigger(e,n,u)},trigger:function(r,n,a){return t.data(t.$(r),"canHasAttributesBindings")?(n=n.toLowerCase(),e(function(){t.trigger(r,{type:"attributes",attributeName:n,target:r,oldValue:a,bubbles:!1},[])})):void 0},get:function(t,e){e=e.toLowerCase();var n=r.map[e];return"string"==typeof n&&t[n]?t[n]:t.getAttribute(e)},remove:function(t,e){e=e.toLowerCase();var n;r.MutationObserver||(n=r.get(t,e));var a=r.map[e];"function"==typeof a&&a(t,void 0),a===!0?t[e]=!1:"string"==typeof a?t[a]="":t.removeAttribute(e),r.MutationObserver||null==n||r.trigger(t,e,n)},has:function(){var e=t.global.document&&document.createElement("div");return e&&e.hasAttribute?function(t,e){return t.hasAttribute(e)}:function(t,e){return null!==t.getAttribute(e)}}()};return r}); +/*can@2.2.6#event/event*/ +define("can/event/event",["can/util/can"],function(t){return t.addEvent=function(t,n){var e=this.__bindEvents||(this.__bindEvents={}),i=e[t]||(e[t]=[]);return i.push({handler:n,name:t}),this},t.listenTo=function(n,e,i){var r=this.__listenToEvents;r||(r=this.__listenToEvents={});var s=t.cid(n),o=r[s];o||(o=r[s]={obj:n,events:{}});var a=o.events[e];a||(a=o.events[e]=[]),a.push(i),t.bind.call(n,e,i)},t.stopListening=function(n,e,i){var r=this.__listenToEvents,s=r,o=0;if(!r)return this;if(n){var a=t.cid(n);if((s={})[a]=r[a],!r[a])return this}for(var v in s){var l,h=s[v];n=r[v].obj,e?(l={})[e]=h.events[e]:l=h.events;for(var u in l){var d=l[u]||[];for(o=0;oo;o++)r[o].handler.apply(this,s);return t}},t.one=function(n,e){var i=function(){return t.unbind.call(this,n,i),e.apply(this,arguments)};return t.bind.call(this,n,i),this},t.event={on:function(){return 0===arguments.length&&t.Control&&this instanceof t.Control?t.Control.prototype.on.call(this):t.addEvent.apply(this,arguments)},off:function(){return 0===arguments.length&&t.Control&&this instanceof t.Control?t.Control.prototype.off.call(this):t.removeEvent.apply(this,arguments)},bind:t.addEvent,unbind:t.removeEvent,delegate:function(n,e,i){return t.addEvent.call(this,e,i)},undelegate:function(n,e,i){return t.removeEvent.call(this,e,i)},trigger:t.dispatch,one:t.one,addEvent:t.addEvent,removeEvent:t.removeEvent,listenTo:t.listenTo,stopListening:t.stopListening,dispatch:t.dispatch},t.event}); +/*can@2.2.6#util/fragment*/ +define("can/util/fragment",["can/util/can"],function(e){var t=/^\s*<(\w+)[^>]*>/,n={}.toString,i=function(e,i){void 0===i&&(i=t.test(e)&&RegExp.$1),e&&"[object Function]"===n.call(e.replace)&&(e=e.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,"<$1>"));var l=document.createElement("div"),d=document.createElement("div");"tbody"===i||"tfoot"===i||"thead"===i?(d.innerHTML=""+e+"
            ",l=3===d.firstChild.nodeType?d.lastChild:d.firstChild):"tr"===i?(d.innerHTML=""+e+"
            ",l=3===d.firstChild.nodeType?d.lastChild:d.firstChild.firstChild):"td"===i||"th"===i?(d.innerHTML=""+e+"
            ",l=3===d.firstChild.nodeType?d.lastChild:d.firstChild.firstChild.firstChild):"option"===i?(d.innerHTML="",l=3===d.firstChild.nodeType?d.lastChild:d.firstChild):l.innerHTML=""+e;var r={},a=l.childNodes;r.length=a.length;for(var o=0;od;d++)l.appendChild(n[d]);return l},function(){var t="<-\n>",n=e.buildFragment(t,document);if(t!==n.childNodes[0].nodeValue){var i=e.buildFragment;e.buildFragment=function(e,t){var n=i(e,t);return 1===n.childNodes.length&&3===n.childNodes[0].nodeType&&(n.childNodes[0].nodeValue=e),n}}}(),e}); +/*can@2.2.6#util/array/each*/ +define("can/util/array/each",["can/util/can"],function(t){var e=function(t){var e="length"in t&&t.length;return"function"!=typeof arr&&(0===e||"number"==typeof e&&e>0&&e-1 in t)};return t.each=function(n,a,r){var f,i,l,c=0;if(n)if(e(n))if(t.List&&n instanceof t.List)for(i=n.attr("length");i>c&&(l=n.attr(c),a.call(r||l,l,c,n)!==!1);c++);else for(i=n.length;i>c&&(l=n[c],a.call(r||l,l,c,n)!==!1);c++);else if("object"==typeof n)if(t.Map&&n instanceof t.Map||n===t.route){var o=t.Map.keys(n);for(c=0,i=o.length;i>c&&(f=o[c],l=n.attr(f),a.call(r||l,l,f,n)!==!1);c++);}else for(f in n)if(n.hasOwnProperty(f)&&a.call(r||n[f],n[f],f,n)===!1)break;return n},t}); +/*can@2.2.6#util/object/isplain/isplain*/ +define("can/util/object/isplain/isplain",["can/util/can"],function(){var t=Object.prototype.hasOwnProperty,n=function(t){return null!==t&&t==t.window},r=function(r){if(!r||"object"!=typeof r||r.nodeType||n(r))return!1;try{if(r.constructor&&!t.call(r,"constructor")&&!t.call(r.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var o;for(o in r);return void 0===o||t.call(r,o)};return can.isPlainObject=r,can}); +/*can@2.2.6#util/deferred*/ +define("can/util/deferred",["can/util/can"],function(t){var e=function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},n=function(t){return this instanceof n?(this._doneFuncs=[],this._failFuncs=[],this._resultArgs=null,this._status="",void(t&&t.call(this,this))):new n};t.Deferred=n,t.when=n.when=function(){var e=t.makeArray(arguments);if(e.length<2){var r=e[0];return r&&t.isFunction(r.isResolved)&&t.isFunction(r.isRejected)?r:n().resolve(r)}var s=n(),i=0,u=[];return t.each(e,function(t,n){t.done(function(){u[n]=arguments.length<2?arguments[0]:arguments,++i===e.length&&s.resolve.apply(s,u)}).fail(function(){s.reject(1===arguments.length?arguments[0]:arguments)})}),s};var r=function(t,e){return function(n){var r=this._resultArgs=arguments.length>1?arguments[1]:[];return this.exec(n,this[t],r,e)}},s=function a(e,n){return function(){var r=this;return t.each(Array.prototype.slice.call(arguments),function(t,s,i){t&&(t.constructor===Array?a.apply(r,t):(r._status===n&&t.apply(r,r._resultArgs||[]),r[e].push(t)))}),this}},i=function(t){return t&&t.then&&t.fail&&t.done},u=function(e,n,r,s){i(n)?n.done(t.proxy(e.resolve,e)).fail(t.proxy(e.reject,e)):r.call(e,void 0!==n?n:s)};return e(n.prototype,{then:function(e,n){var r=t.Deferred(),s=r.resolve,i=r.reject;return this.done(function(t){"function"==typeof e?u(r,e.apply(this,arguments),s,t):s.apply(r,arguments)}),this.fail(function(t){"function"==typeof n?u(r,n.apply(this,arguments),i,t):i.apply(r,arguments)}),r},resolveWith:r("_doneFuncs","rs"),rejectWith:r("_failFuncs","rj"),done:s("_doneFuncs","rs"),fail:s("_failFuncs","rj"),always:function(){var e=t.makeArray(arguments);return e.length&&e[0]&&this.done(e[0]).fail(e[0]),this},state:function(){switch(this._status){case"rs":return"resolved";case"rj":return"rejected";default:return"pending"}},isResolved:function(){return"rs"===this._status},isRejected:function(){return"rj"===this._status},reject:function(){return this.rejectWith(this,arguments)},resolve:function(){return this.resolveWith(this,arguments)},exec:function(e,n,r,s){return""!==this._status?this:(this._status=s,t.each(n,function(t){"function"==typeof t.apply&&t.apply(e,r)}),this)},promise:function(){var t=this.then();return t.reject=t.resolve=void 0,t}}),n.prototype.pipe=n.prototype.then,t}); +/*can@2.2.6#util/hashchange*/ +define("can/util/hashchange",["can/util/can"],function(n){!function(){var t=function(n,t,a){n.addEventListener?n.addEventListener(t,a,!1):n.attachEvent?n.attachEvent("on"+t,a):n["on"+t]=a},a=function(){n.trigger(window,"hashchange")};t(window,"hashchange",a)}()}); +/*can@2.2.6#util/inserted/inserted*/ +define("can/util/inserted/inserted",["can/util/can"],function(e){e.inserted=function(n){n=e.makeArray(n);for(var r,i,t=!1,a=e.$(document.contains?document:document.body),d=0;void 0!==(i=n[d]);d++){if(!t){if(!i.getElementsByTagName)continue;if(!e.has(a,i).length)return;t=!0}if(t&&i.getElementsByTagName){r=e.makeArray(i.getElementsByTagName("*")),e.trigger(i,"inserted",[],!1);for(var o,s=0;void 0!==(o=r[s]);s++)e.trigger(o,"inserted",[],!1)}}},e.appendChild=function(n,r){var i;i=11===r.nodeType?e.makeArray(r.childNodes):[r],n.appendChild(r),e.inserted(i)},e.insertBefore=function(n,r,i){var t;t=11===r.nodeType?e.makeArray(r.childNodes):[r],n.insertBefore(r,i),e.inserted(t)}}); +/*can@2.2.6#util/util*/ +define("can/util/util",["can/util/can","can/util/attr/attr","can/yui/yui","can/event/event","can/util/fragment","can/util/array/each","can/util/object/isplain/isplain","can/util/deferred","can/util/hashchange","can/util/inserted/inserted"],function(can,attr,YUI){YUI=YUI||window.YUI,YUI.add("can-modifications",function(e,n){var t=e.DOM.addHTML;e.DOM.addHTML=function(e,n,a){("string"==typeof n||"number"==typeof n)&&(n=can.buildFragment(n));var i;i=11===n.nodeType?can.makeArray(n.childNodes):[n];var r=t.call(this,e,n,a);return can.inserted(i),r};var a=e.Node.prototype.on;e.Node.prototype.on=function(e,n){if("attributes"===e){var t=can.$(this);can.data(t,"canHasAttributesBindings",(can.data(t,"canHasAttributesBindings")||0)+1);var i=a.apply(this,arguments),r=i.detach;return i.detach=function(){var e=can.data(t,"canHasAttributesBindings")||0;return 0>=e?can.cleanData(t,"canHasAttributesBindings"):can.data(t,"canHasAttributesBindings",e-1),r.apply(this,arguments)},i}return a.apply(this,arguments)}},"3.7.3",{requires:["node-base"]});var Y=can.Y=can.Y||YUI().use("*");can.trim=function(e){return Y.Lang.trim(e)},can.makeArray=function(e){return e?Y.Array(e):[]},can.isArray=Y.Lang.isArray,can.inArray=function(e,n,t){return n?Y.Array.indexOf(n,e,t):-1},can.map=function(e,n){return Y.Array.map(can.makeArray(e||[]),n)},can.extend=function(e){for(var n,t=e===!0?1:0,a=arguments[t],i=t+1;n=arguments[i];i++)Y.mix(a,n,!0,null,null,!!t);return a},can.param=function(e){return Y.QueryString.stringify(e,{arrayKey:!0})},can.isEmptyObject=function(e){return Y.Object.isEmpty(e)},can.proxy=function(e,n){return Y.bind.apply(Y,arguments)},can.isFunction=function(e){return Y.Lang.isFunction(e)};var prepareNodeList=function(e){return e.each(function(n,t){e[t]=n.getDOMNode()}),e.length=e.size(),e};can.$=function(e){return e===window?window:e instanceof Y.NodeList?prepareNodeList(e):"object"!=typeof e||can.isArray(e)||"undefined"!=typeof e.nodeType||e.getDOMNode?prepareNodeList(Y.all(e)):new Y.NodeList(e)},can.get=function(e,n){return e._nodes[n]},can.append=function(e,n){e.each(function(e){"string"==typeof n&&(n=can.buildFragment(n,e)),e.append(n)})},can.addClass=function(e,n){return e.addClass(n)},can.data=function(e,n,t){return e.item(0)?void 0===t?e.item(0).getData(n):e.item(0).setData(n,t):void 0},can.remove=function(e){return e.remove()&&e.destroy()},can.has=function(e,n){return Y.DOM.contains(e[0],n)?e:[]},can._yNodeRemove=can._yNodeRemove||Y.Node.prototype.remove,Y.Node.prototype.remove=function(){var e=this.getDOMNode();if(1===e.nodeType){can.trigger(this,"removed",[],!1);for(var n,t=e.getElementsByTagName("*"),a=0;void 0!==(n=t[a]);a++)can.trigger(n,"removed",[],!1)}can._yNodeRemove.apply(this,arguments)},Y.NodeList.addMethod("remove",Y.Node.prototype.remove);var optionsMap={type:"method",success:void 0,error:void 0},updateDeferred=function(e,n){if(e&&e.io){var t=e.io;for(var a in t)"function"==typeof n[a]?n[a]=function(){t[a].apply(t,arguments)}:n[a]=a[t]}};can.ajax=function(options){var d=can.Deferred(),requestOptions=can.extend({},options);for(var option in optionsMap)void 0!==requestOptions[option]&&(requestOptions[optionsMap[option]]=requestOptions[option],delete requestOptions[option]);requestOptions.sync=!options.async;var success=options.success,error=options.error;requestOptions.on={success:function(transactionid,response){var data=response.responseText;"json"===options.dataType&&(data=eval("("+data+")")),updateDeferred(request,d),d.resolve(data),success&&success(data,"success",request)},failure:function(e,n){updateDeferred(request,d),d.reject(request,"error"),error&&error(request,"error")}};var request=Y.io(requestOptions.url,requestOptions);return updateDeferred(request,d),d};var yuiEventId=0,addBinding=function(e,n,t,a){if(e instanceof Y.NodeList||!e.on||e.getDOMNode)e.each(function(e){e=can.$(e);var i=can.data(e,"events"),r=t+":"+n;i||can.data(e,"events",i={}),i[r]||(i[r]={}),void 0===a.__bindingsIds&&(a.__bindingsIds=yuiEventId++),i[r][a.__bindingsIds]=n?e.item(0).delegate(t,a,n):e.item(0).on(t,a)});else{var i=e,r=i.__canEvents=i.__canEvents||{};r[t]||(r[t]={}),void 0===a.__bindingsIds&&(a.__bindingsIds=yuiEventId++),r[t][a.__bindingsIds]=i.on(t,a)}},removeBinding=function(e,n,t,a){if(e instanceof Y.NodeList||!e.on||e.getDOMNode)e.each(function(e){e=can.$(e);var i=can.data(e,"events");if(i){var r=t+":"+n,o=i[r],s=o[a.__bindingsIds];s.detach(),delete o[a.__bindingsIds],can.isEmptyObject(o)&&delete i[t],can.isEmptyObject(i)}});else{var i=e,r=i.__canEvents||{},o=r[t],s=o[a.__bindingsIds];s.detach(),delete o[a.__bindingsIds],can.isEmptyObject(o)&&delete r[t],can.isEmptyObject(r)}};can.bind=function(e,n){return this.bind&&this.bind!==can.bind?this.bind(e,n):this.on||this.nodeType?addBinding(can.$(this),void 0,e,n):this.addEvent?this.addEvent(e,n):can.addEvent.call(this,e,n),this},can.unbind=function(e,n){return this.unbind&&this.unbind!==can.unbind?this.unbind(e,n):this.on||this.nodeType?removeBinding(can.$(this),void 0,e,n):can.removeEvent.call(this,e,n),this},can.on=can.bind,can.off=can.unbind,can.trigger=function(e,n,t,a){e instanceof Y.NodeList&&(e=e.item(0)),e.getDOMNode&&(e=e.getDOMNode()),e.nodeName?(e=Y.Node(e),a===!1&&e.once(n,function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,e._stopper&&e._stopper()}),"string"!=typeof n&&(t=n,n=t.type,delete t.type),realTrigger(e.getDOMNode(),n,t||{})):("string"==typeof n&&(n={type:n}),n.target=n.target||e,can.dispatch.call(e,n,can.makeArray(t)))},Y.mix(Y.Node.DOM_EVENTS,{removed:!0,inserted:!0,attributes:!0,foo:!0}),Y.Env.evt.plugins.attributes={on:function(){var e=can.makeArray(arguments);return Y.Event._attach(e,{facade:!1})}},can.delegate=function(e,n,t){return this.on||this.nodeType?addBinding(can.$(this),e,n,t):this.delegate?this.delegate(e,n,t):can.bind.call(this,n,t),this},can.undelegate=function(e,n,t){return this.on||this.nodeType?removeBinding(can.$(this),e,n,t):this.undelegate?this.undelegate(e,n,t):can.unbind.call(this,n,t),this};var realTrigger,realTriggerHandler=function(e,n,t){var a,i=Y.Node(e),r=can.Y.Event.getListeners(i._yuid,n);if(r)for(a=0;an;n++){var s=i[n];if(s.match.test(t)){r=s.handler;break}}return r}"string"==typeof t?e[t]=a:i.push({match:t,handler:a})},e={},i=[],r=/[-\:]/,n=t.view.tag=function(a,e){if(!e){var i=l[a.toLowerCase()];return!i&&r.test(a)&&(i=function(){}),i}t.global.html5&&(t.global.html5.elements+=" "+a,t.global.html5.shivDocument()),l[a.toLowerCase()]=e},l={};return t.view.callbacks={_tags:l,_attributes:e,_regExpAttributes:i,tag:n,attr:a,tagHandler:function(a,e,i){var r,n=i.options.attr("tags."+e),s=n||l[e],c=i.scope;if(s){var o=t.__clearReading();r=s(a,i),t.__setReading(o)}else r=c;if(r&&i.subtemplate){c!==r&&(c=c.add(r));var v=i.subtemplate(c,i.options),f="string"==typeof v?t.view.frag(v):v;t.appendChild(a,f)}}},t.view.callbacks}); +/*can@2.2.6#view/elements*/ +define("can/view/elements",["can/util/util","can/view/view"],function(t){var e="undefined"!=typeof document?document:null,n=e&&function(){return 1===t.$(document.createComment("~")).length}(),o={tagToContentPropMap:{option:e&&"textContent"in document.createElement("option")?"textContent":"innerText",textarea:"value"},attrMap:t.attr.map,attrReg:/([^\s=]+)[\s]*=[\s]*/,defaultValue:t.attr.defaultValue,tagMap:{"":"span",colgroup:"col",table:"tbody",tr:"td",ol:"li",ul:"li",tbody:"tr",thead:"tr",tfoot:"tr",select:"option",optgroup:"option"},reverseTagMap:{col:"colgroup",tr:"tbody",option:"select",td:"tr",th:"tr",li:"ul"},getParentNode:function(t,e){return e&&11===t.parentNode.nodeType?e:t.parentNode},setAttr:t.attr.set,getAttr:t.attr.get,removeAttr:t.attr.remove,contentText:function(t){return"string"==typeof t?t:t||0===t?""+t:""},after:function(e,n){var o=e[e.length-1];o.nextSibling?t.insertBefore(o.parentNode,n,o.nextSibling):t.appendChild(o.parentNode,n)},replace:function(e,r){o.after(e,r),t.remove(t.$(e)).length/g,">").replace(c,""").replace(o,"'")},getObject:function(r,n,t){var a,u,i,c,o=r?r.split("."):[],l=o.length,p=0;if(n=e.isArray(n)?n:[n||window],c=n.length,!l)return n[0];for(p;c>p;p++){for(a=n[p],i=void 0,u=0;l>u&&g(a);u++)i=a,a=f(i,o[u]);if(void 0!==i&&void 0!==a)break}if(t===!1&&void 0!==a&&delete i[o[u-1]],t===!0&&void 0===a)for(a=n[0],u=0;l>u&&g(a);u++)a=f(a,o[u],!0);return a},capitalize:function(e,r){return e.charAt(0).toUpperCase()+e.slice(1)},camelize:function(e){return d(e).replace(l,function(e,r){return r?r.toUpperCase():""})},hyphenate:function(e){return d(e).replace(p,function(e,r){return e.charAt(0)+"-"+e.charAt(1).toLowerCase()})},underscore:function(e){return e.replace(n,"/").replace(t,"$1_$2").replace(a,"$1_$2").replace(u,"_").toLowerCase()},sub:function(r,n,t){var a=[];return r=r||"",a.push(r.replace(i,function(r,u){var i=e.getObject(u,n,t===!0?!1:void 0);return void 0===i||null===i?(a=null,""):g(i)&&a?(a.push(i),""):""+i})),null===a?a:a.length<=1?a[0]:a},replacer:i,undHash:r}),e}); +/*can@2.2.6#construct/construct*/ +define("can/construct/construct",["can/util/string/string"],function(t){var n,r=0;try{Object.getOwnPropertyDescriptor({}),n=!0}catch(e){n=!1}var o=function(t,n){var r=Object.getOwnPropertyDescriptor(t,n);return r&&(r.get||r.set)?r:null},u=function(n,r,e){e=e||n;var u;for(var i in n)(u=o(n,i))?this._defineProperty(e,r,i,u):t.Construct._overwrite(e,r,i,n[i])},i=function(n,r,e){e=e||n;for(var o in n)t.Construct._overwrite(e,r,o,n[o])};return t.Construct=function(){return arguments.length?t.Construct.extend.apply(t.Construct,arguments):void 0},t.extend(t.Construct,{constructorExtends:!0,newInstance:function(){var t,n=this.instance();return n.setup&&(t=n.setup.apply(n,arguments)),n.init&&n.init.apply(n,t||arguments),n},_inherit:n?u:i,_defineProperty:function(t,n,r,e){Object.defineProperty(t,r,e)},_overwrite:function(t,n,r,e){t[r]=e},setup:function(n,r){this.defaults=t.extend(!0,{},n.defaults,this.defaults)},instance:function(){r=1;var t=new this;return r=0,t},extend:function(n,e,o){function u(){return r?void 0:this.constructor!==a&&arguments.length&&a.constructorExtends?a.extend.apply(a,arguments):a.newInstance.apply(a,arguments)}var i=n,s=e,c=o;"string"!=typeof i&&(c=s,s=i,i=null),c||(c=s,s=null),c=c||{};var a,p,f,l,d,y,g,h,v,m=this,w=this.prototype;v=this.instance(),t.Construct._inherit(c,w,v),i&&(p=i.split("."),g=p.pop()),"undefined"==typeof constructorName&&(a=function(){return u.apply(this,arguments)});for(y in m)m.hasOwnProperty(y)&&(a[y]=m[y]);t.Construct._inherit(s,m,a),i&&(f=t.getObject(p.join("."),window,!0),h=f,l=t.underscore(i.replace(/\./g,"_")),d=t.underscore(g),f[g]=a),t.extend(a,{constructor:a,prototype:v,namespace:h,_shortName:d,fullName:i,_fullName:l}),void 0!==g&&(a.shortName=g),a.prototype.constructor=a;var C=[m].concat(t.makeArray(arguments)),_=a.setup.apply(a,C);return a.init&&a.init.apply(a,_||C),a}}),t.Construct.prototype.setup=function(){},t.Construct.prototype.init=function(){},t.Construct}); +/*can@2.2.6#control/control*/ +define("can/control/control",["can/util/util","can/construct/construct"],function(t){var n,e=function(n,e,o){return t.bind.call(n,e,o),function(){t.unbind.call(n,e,o)}},o=t.isFunction,s=t.extend,i=t.each,r=[].slice,u=/\{([^\}]+)\}/g,c=t.getObject("$.event.special",[t])||{},l=function(n,e,o,s){return t.delegate.call(n,e,o,s),function(){t.undelegate.call(n,e,o,s)}},a=function(n,o,s,i){return i?l(n,t.trim(i),o,s):e(n,o,s)},h=t.Control=t.Construct({setup:function(){if(t.Construct.setup.apply(this,arguments),t.Control){var n,e=this;e.actions={};for(n in e.prototype)e._isAction(n)&&(e.actions[n]=e._action(n))}},_shifter:function(n,e){var s="string"==typeof e?n[e]:e;return o(s)||(s=n[s]),function(){return n.called=e,s.apply(n,[this.nodeName?t.$(this):this].concat(r.call(arguments,0)))}},_isAction:function(t){var n=this.prototype[t],e=typeof n;return"constructor"!==t&&("function"===e||"string"===e&&o(this.prototype[n]))&&!!(c[t]||f[t]||/[^\w]/.test(t))},_action:function(e,o){if(u.lastIndex=0,o||!u.test(e)){var s=o?t.sub(e,this._lookup(o)):e;if(!s)return null;var i=t.isArray(s),r=i?s[1]:s,c=r.split(/\s+/g),l=c.pop();return{processor:f[l]||n,parts:[r,c.join(" "),l],delegate:i?s[0]:void 0}}},_lookup:function(t){return[t,window]},processors:{},defaults:{}},{setup:function(n,e){var o,i=this.constructor,r=i.pluginName||i._fullName;return this.element=t.$(n),r&&"can_control"!==r&&this.element.addClass(r),o=t.data(this.element,"controls"),o||(o=[],t.data(this.element,"controls",o)),o.push(this),this.options=s({},i.defaults,e),this.on(),[this.element,this.options]},on:function(n,e,o,s){if(!n){this.off();var i,r,u=this.constructor,c=this._bindings,l=u.actions,h=this.element,f=t.Control._shifter(this,"destroy");for(i in l)l.hasOwnProperty(i)&&(r=l[i]||u._action(i,this.options,this),r&&(c.control[i]=r.processor(r.delegate||h,r.parts[2],r.parts[1],i,this)));return t.bind.call(h,"removed",f),c.user.push(function(n){t.unbind.call(n,"removed",f)}),c.user.length}return"string"==typeof n&&(s=o,o=e,e=n,n=this.element),void 0===s&&(s=o,o=e,e=null),"string"==typeof s&&(s=t.Control._shifter(this,s)),this._bindings.user.push(a(n,o,s,e)),this._bindings.user.length},off:function(){var t=this.element[0],n=this._bindings;n&&(i(n.user||[],function(n){n(t)}),i(n.control||{},function(n){n(t)})),this._bindings={user:[],control:{}}},destroy:function(){if(null!==this.element){var n,e=this.constructor,o=e.pluginName||e._fullName;this.off(),o&&"can_control"!==o&&this.element.removeClass(o),n=t.data(this.element,"controls"),n.splice(t.inArray(this,n),1),t.trigger(this,"destroyed"),this.element=null}}}),f=t.Control.processors;return n=function(n,e,o,s,i){return a(n,e,t.Control._shifter(i,s),o)},i(["change","click","contextmenu","dblclick","keydown","keyup","keypress","mousedown","mousemove","mouseout","mouseover","mouseup","reset","resize","scroll","select","submit","focusin","focusout","mouseenter","mouseleave","touchstart","touchmove","touchcancel","touchend","touchleave","inserted","removed"],function(t){f[t]=n}),h}); +/*can@2.2.6#util/bind/bind*/ +define("can/util/bind/bind",["can/util/util"],function(i){return i.bindAndSetup=function(){return i.addEvent.apply(this,arguments),this._init||(this._bindings?this._bindings++:(this._bindings=1,this._bindsetup&&this._bindsetup())),this},i.unbindAndTeardown=function(n,t){var s=this.__bindEvents[n]||[],d=s.length;return i.removeEvent.apply(this,arguments),null===this._bindings?this._bindings=0:this._bindings=this._bindings-(d-s.length),!this._bindings&&this._bindteardown&&this._bindteardown(),this},i}); +/*can@2.2.6#map/bubble*/ +define("can/map/bubble",["can/util/util"],function(n){var e=n.bubble={event:function(n,e){return n.constructor._bubbleRule(e,n)},childrenOf:function(n,i){n._each(function(b,r){b&&b.bind&&e.toParent(b,n,r,i)})},teardownChildrenFrom:function(n,i){n._each(function(b){e.teardownFromParent(n,b,i)})},toParent:function(e,i,b,r){n.listenTo.call(i,e,r,function(){var r=n.makeArray(arguments),t=r.shift();r[0]=(n.List&&i instanceof n.List?i.indexOf(e):b)+(r[0]?"."+r[0]:""),t.triggeredNS=t.triggeredNS||{},t.triggeredNS[i._cid]||(t.triggeredNS[i._cid]=!0,n.trigger(i,t,r))})},teardownFromParent:function(e,i,b){i&&i.unbind&&n.stopListening.call(e,i,b)},isBubbling:function(n,e){return n._bubbleBindings&&n._bubbleBindings[e]},bind:function(n,i){if(!n._init){var b,r=e.event(n,i),t=r.length;n._bubbleBindings||(n._bubbleBindings={});for(var u=0;t>u;u++)b=r[u],n._bubbleBindings[b]?n._bubbleBindings[b]++:(n._bubbleBindings[b]=1,e.childrenOf(n,b))}},unbind:function(i,b){for(var r,t=e.event(i,b),u=t.length,d=0;u>d;d++)r=t[d],i._bubbleBindings&&i._bubbleBindings[r]--,i._bubbleBindings&&!i._bubbleBindings[r]&&(delete i._bubbleBindings[r],e.teardownChildrenFrom(i,r),n.isEmptyObject(i._bubbleBindings)&&delete i._bubbleBindings)},add:function(i,b,r){if(b instanceof n.Map&&i._bubbleBindings)for(var t in i._bubbleBindings)i._bubbleBindings[t]&&(e.teardownFromParent(i,b,t),e.toParent(b,i,r,t))},removeMany:function(n,i){for(var b=0,r=i.length;r>b;b++)e.remove(n,i[b])},remove:function(i,b){if(b instanceof n.Map&&i._bubbleBindings)for(var r in i._bubbleBindings)i._bubbleBindings[r]&&e.teardownFromParent(i,b,r)},set:function(i,b,r,t){return n.Map.helpers.isObservable(r)&&e.add(i,r,b),n.Map.helpers.isObservable(t)&&e.remove(i,t),r}};return e}); +/*can@2.2.6#util/batch/batch*/ +define("can/util/batch/batch",["can/util/can"],function(t){var n=1,a=0,i=[],c=[],e=null;t.batch={start:function(t){a++,t&&c.push(t)},stop:function(l,u){if(l?a=0:a--,0===a){if(null!==e)return;e=i.slice(0);var h,r,f=c.slice(0);for(i=[],c=[],t.batch.batchNum=n,n++,u&&t.batch.start(),h=0;h=0?["change"]:[]},_computes:[],bind:t.bindAndSetup,on:t.bindAndSetup,unbind:t.unbindAndTeardown,off:t.unbindAndTeardown,id:"id",helpers:{define:null,attrParts:function(t,e){return e?[t]:"object"==typeof t?t:(""+t).split(".")},addToMap:function(e,i){var r;n||(r=s,n={});var a=e._cid,o=t.cid(e);return n[o]||(n[o]={obj:e,instance:i,added:!a}),r},isObservable:function(e){return e instanceof t.Map||e&&e===t.route},canMakeObserve:function(e){return e&&!t.isDeferred(e)&&(t.isArray(e)||t.isPlainObject(e))},serialize:function(e,i,n){var s=t.cid(e),r=!1;return a||(r=!0,a={attr:{},serialize:{}}),a[i][s]=n,e.each(function(s,r){var u,h=o.helpers.isObservable(s),c=h&&a[i][t.cid(s)];u=c?c:"serialize"===i?o.helpers._serialize(e,r,s):o.helpers._getValue(e,r,s,i),void 0!==u&&(n[r]=u)}),t.__observe(e,"__keys"),r&&(a=null),n},_serialize:function(t,e,i){return o.helpers._getValue(t,e,i,"serialize")},_getValue:function(t,e,i,n){return o.helpers.isObservable(i)?i[n]():i}},keys:function(e){var i=[];t.__observe(e,"__keys");for(var n in e._data)i.push(n);return i}},{setup:function(e){e instanceof t.Map&&(e=e.serialize()),this._data={},t.cid(this,".map"),this._init=1,this._computedBindings={};var i=this._setupDefaults(e);this._setupComputes(i);var n=e&&t.Map.helpers.addToMap(e,this),s=t.extend(t.extend(!0,{},i),e);this.attr(s),n&&n(),this.bind("change",t.proxy(this._changes,this)),delete this._init},_setupComputes:function(){for(var t,e=this.constructor._computes,i=0,n=e.length;n>i;i++)t=e[i],this[t]=this[t].clone(this),this._computedBindings[t]={count:0}},_setupDefaults:function(){return this.constructor.defaults||{}},_bindsetup:function(){},_bindteardown:function(){},_changes:function(e,i,n,s,r){t.batch.trigger(this,{type:i,batchNum:e.batchNum,target:e.target},[s,r])},_triggerChange:function(e,n,s,r){i.isBubbling(this,"change")?t.batch.trigger(this,{type:"change",target:this},[e,n,s,r]):t.batch.trigger(this,e,[s,r]),("remove"===n||"add"===n)&&t.batch.trigger(this,{type:"__keys",target:this})},_each:function(t){var e=this.__get();for(var i in e)e.hasOwnProperty(i)&&t(e[i],i)},attr:function(t,e){var i=typeof t;return"string"!==i&&"number"!==i?this._attrs(t,e):1===arguments.length?this._get(t):(this._set(t,e),this)},each:function(){return t.each.apply(void 0,[this].concat(t.makeArray(arguments)))},removeAttr:function(e){var i=t.List&&this instanceof t.List,n=t.Map.helpers.attrParts(e),s=n.shift(),r=i?this[s]:this._data[s];return n.length&&r?r.removeAttr(n):("string"==typeof e&&~e.indexOf(".")&&(s=e),this._remove(s,r),r)},_remove:function(t,e){t in this._data&&(delete this._data[t],t in this.constructor.prototype||delete this[t],this._triggerChange(t,"remove",void 0,e))},_get:function(e){e=""+e;var i=e.indexOf(".");if(i>=0){var n=this.__get(e);if(void 0!==n)return n;var s=e.substr(0,i),r=e.substr(i+1);t.__observe(this,s);var a=this.__get(s);return a&&a._get?a._get(r):void 0}return t.__observe(this,e),this.__get(e)},__get:function(t){return t?this._computedBindings[t]?this[t]():this._data[t]:this._data},__type:function(e,i){if(!(e instanceof t.Map)&&t.Map.helpers.canMakeObserve(e)){var n=r(e);if(n)return n;if(t.isArray(e)){var s=t.List;return new s(e)}var a=this.constructor.Map||t.Map;return new a(e)}return e},_set:function(t,e,i){t=""+t;var n,s=t.indexOf(".");if(!i&&s>=0){var r=t.substr(0,s),a=t.substr(s+1);if(n=this._init?void 0:this.__get(r),!o.helpers.isObservable(n))throw"can.Map: Object does not exist";n._set(a,e)}else this.__convert&&(e=this.__convert(t,e)),n=this._init?void 0:this.__get(t),this.__set(t,this.__type(e,t),n)},__set:function(t,e,i){if(e!==i){var n=void 0!==i||this.__get().hasOwnProperty(t)?"set":"add";this.___set(t,this.constructor._bubble.set(this,t,e,i)),this._computedBindings[t]||this._triggerChange(t,n,e,i),i&&this.constructor._bubble.teardownFromParent(this,i)}},___set:function(t,e){this._computedBindings[t]?this[t](e):this._data[t]=e,"function"==typeof this.constructor.prototype[t]||this._computedBindings[t]||(this[t]=e)},bind:function(e,i){var n=this._computedBindings&&this._computedBindings[e];if(n)if(n.count)n.count++;else{n.count=1;var s=this;n.handler=function(i,n,r){t.batch.trigger(s,{type:e,batchNum:i.batchNum,target:s},[n,r])},this[e].bind("change",n.handler)}return this.constructor._bubble.bind(this,e),t.bindAndSetup.apply(this,arguments)},unbind:function(e,i){var n=this._computedBindings&&this._computedBindings[e];return n&&(1===n.count?(n.count=0,this[e].unbind("change",n.handler),delete n.handler):n.count--),this.constructor._bubble.unbind(this,e),t.unbindAndTeardown.apply(this,arguments)},serialize:function(){return t.Map.helpers.serialize(this,"serialize",{})},_attrs:function(e,i){if(void 0===e)return o.helpers.serialize(this,"attr",{});e=t.simpleExtend({},e);var n,s,r=this;t.batch.start(),this.each(function(t,n){if("_cid"!==n){if(s=e[n],void 0===s)return void(i&&r.removeAttr(n));r.__convert&&(s=r.__convert(n,s)),o.helpers.isObservable(s)?r.__set(n,r.__type(s,n),t):o.helpers.isObservable(t)&&o.helpers.canMakeObserve(s)?t.attr(s,i):t!==s&&r.__set(n,r.__type(s,n),t),delete e[n]}});for(n in e)"_cid"!==n&&(s=e[n],this._set(n,s,!0));return t.batch.stop(),this},compute:function(e){if(t.isFunction(this.constructor.prototype[e]))return t.compute(this[e],this);var i=e.split("."),n=i.length-1,s={args:[]};return t.compute(function(e){return arguments.length?void t.compute.read(this,i.slice(0,n)).value.attr(i[n],e):t.compute.read(this,i,s).value},this)}});return o.prototype.on=o.prototype.bind,o.prototype.off=o.prototype.unbind,o}); +/*can@2.2.6#list/list*/ +define("can/list/list",["can/util/util","can/map/map","can/map/bubble"],function(t,e,i){var r=[].splice,h=function(){var t={0:"a",length:1};return r.call(t,0,1),!t[0]}(),n=e.extend({Map:e},{setup:function(e,i){this.length=0,t.cid(this,".map"),this._init=1,this._computedBindings={},this._setupComputes(),e=e||[];var r;t.isDeferred(e)?this.replace(e):(r=e.length&&t.Map.helpers.addToMap(e,this),this.push.apply(this,t.makeArray(e||[]))),r&&r(),this.bind("change",t.proxy(this._changes,this)),t.simpleExtend(this,i),delete this._init},_triggerChange:function(i,r,h,n){e.prototype._triggerChange.apply(this,arguments);var s=+i;~(""+i).indexOf(".")||isNaN(s)||("add"===r?(t.batch.trigger(this,r,[h,s]),t.batch.trigger(this,"length",[this.length])):"remove"===r?(t.batch.trigger(this,r,[n,s]),t.batch.trigger(this,"length",[this.length])):t.batch.trigger(this,r,[h,s]))},__get:function(e){return e?this[e]&&this[e].isComputed&&t.isFunction(this.constructor.prototype[e])?this[e]():this[e]:this},__set:function(e,i,r){if(e=isNaN(+e)||e%1?e:+e,"number"==typeof e&&e>this.length-1){var h=new Array(e+1-this.length);return h[h.length-1]=i,this.push.apply(this,h),h}return t.Map.prototype.__set.call(this,""+e,i,r)},___set:function(t,e){this[t]=e,+t>=this.length&&(this.length=+t+1)},_remove:function(t,e){isNaN(+t)?(delete this[t],this._triggerChange(t,"remove",void 0,e)):this.splice(t,1)},_each:function(t){for(var e=this.__get(),i=0;i2;for(e=e||0,s=0,a=o.length-2;a>s;s++)l=s+2,o[l]=this.__type(o[l],l),g.push(o[l]),this[s+e]!==o[l]&&(c=!1);if(c&&this.length<=g.length)return g;void 0===n&&(n=o[1]=this.length-e);var p=r.apply(this,o);if(!h)for(s=this.length;s0&&(i.removeMany(this,p),this._triggerChange(""+e,"remove",void 0,p)),o.length>2){for(s=0,a=g.length;a>s;s++)i.set(this,s,g[s]);this._triggerChange(""+e,"add",g,p)}return t.batch.stop(),p},_attrs:function(i,r){return void 0===i?e.helpers.serialize(this,"attr",[]):(i=t.makeArray(i),t.batch.start(),this._updateAttrs(i,r),void t.batch.stop())},_updateAttrs:function(t,i){for(var r=Math.min(t.length,this.length),h=0;r>h;h++){var n=this[h],s=t[h];e.helpers.isObservable(n)&&e.helpers.canMakeObserve(s)?n.attr(s,i):n!==s&&this._set(h,s)}t.length>this.length?this.push.apply(this,t.slice(this.length)):t.lengthc;){s=i;for(var l=0,f=t.propertyReaders.length;f>l;l++){var v=t.propertyReaders[l];if(v.test(i)){i=v.read(i,r[c],c,o,u);break}}if(c+=1,i=n(i,c,r,o,u,s),a=typeof i,ci;i++)t.valueReaders[i].test(e,n,r,o)&&(e=t.valueReaders[i].read(e,n,r,o,a,s))}while(u);return e};return t.valueReaders=[{name:"compute",test:function(e,t,n,r){return e&&e.isComputed},read:function(t,n,r,o,a){return o.isArgument&&n===r.length?t:(!a.foundObservable&&o.foundObservable&&(o.foundObservable(t,n),a.foundObservable=!0),t instanceof e.Compute?t.get():t())}},{name:"function",test:function(t,n,r,o){var a=typeof t;return!("function"!==a||t.isComputed||!(o.executeAnonymousFunctions||o.isArgument&&n===r.length)||e.Construct&&t.prototype instanceof e.Construct||e.route&&t===e.route)},read:function(t,n,r,o,a,s){return o.isArgument&&n===r.length?o.proxyMethods!==!1?e.proxy(t,s):t:t.call(s)}}],t.propertyReaders=[{name:"map",test:e.isMapLike,read:function(t,n,r,o,a){return!a.foundObservable&&o.foundObservable&&(o.foundObservable(t,r),a.foundObservable=!0),"function"==typeof t[n]&&t.constructor.prototype[n]===t[n]?o.returnObserveMethods?t[n]:"constructor"===n&&t instanceof e.Construct||t[n].prototype instanceof e.Construct?t[n]:t[n].apply(t,o.args||[]):t.attr(n)}},{name:"promise",test:function(t){return e.isPromise(t)},read:function(t,n,r,o,a){!a.foundObservable&&o.foundObservable&&(o.foundObservable(t,r),a.foundObservable=!0);var s=t.__observeData;return t.__observeData||(s=t.__observeData={isPending:!0,state:"pending",isResolved:!1,isRejected:!1,value:void 0,reason:void 0},e.cid(s),e.simpleExtend(s,e.event),t.then(function(e){s.isPending=!1,s.isResolved=!0,s.value=e,s.state="resolved",s.dispatch("state",["resolved","pending"])},function(e){s.isPending=!1,s.isRejected=!0,s.reason=e,s.state="rejected",s.dispatch("state",["rejected","pending"])})),e.__observe(s,"state"),n in s?s[n]:t[n]}},{name:"object",test:function(){return!0},read:function(e,t){return null==e?void 0:e[t]}}],t.write=function(t,n,r,o){return o=o||{},e.isMapLike(t)?!o.isArgument&&t._data&&t._data[n]&&t._data[n].isComputed?t._data[n](r):t.attr(n,r):t[n]&&t[n].isComputed?t[n](r):void("object"==typeof t&&(t[n]=r))},t}); +/*can@2.2.6#compute/get_value_and_bind*/ +define("can/compute/get_value_and_bind",["can/util/util"],function(){function n(n,e,t,i){var v=a(n,e),o=v.observed,u=t.observed;return v.names!==t.names&&(r(u,o,i),c(u,i)),can.batch.afterPreviousEvents(function(){v.ready=!0}),v}var e=[];can.__isRecordingObserves=function(){return e.length},can.__observe=can.__reading=function(n,a){if(e.length){var r=n._cid+"|"+a,t=e[e.length-1];t.names+=r,t.observed[r]={obj:n,event:a+""}}},can.__notObserve=function(n){return function(){var e=can.__clearObserved(),a=n.apply(this,arguments);return can.__setObserved(e),a}},can.__clearObserved=can.__clearReading=function(){if(e.length){var n=e[e.length-1];return e[e.length-1]={observed:{}},n}},can.__setObserved=can.__setReading=function(n){e.length&&(e[e.length-1]=n)},can.__addObserved=can.__addReading=function(n){e.length&&can.simpleExtend(e[e.length-1],n)};var a=function(n,a){e.push({names:"",observed:{}});var r=n.call(a),t=e.pop();return t.value=r,t},r=function(n,e,a){for(var r in e)t(n,e,r,a)},t=function(n,e,a,r){if(n[a])delete n[a];else{var t=e[a];t.obj.bind(t.event,r)}},c=function(n,e){for(var a in n){var r=n[a];r.obj.unbind(r.event,e)}};return n}); +/*can@2.2.6#compute/proto_compute*/ +define("can/compute/proto_compute",["can/util/util","can/util/bind/bind","can/compute/read","can/compute/get_value_and_bind","can/util/batch/batch"],function(t,e,n,i){var s=function(e,n,i,s){n!==i&&t.batch.trigger(e,s?{type:"change",batchNum:s}:"change",[n,i])},u=function(e,n,s,u){var o,h,r;return u=!1,{on:function(a){var c=this;h||(h=function(t){if(o.ready&&e.bound&&(void 0===t.batchNum||t.batchNum!==r)){var a,f=o.value;u?(a=n.call(s),o.value=a):(o=i(n,s,o,h),a=o.value),c.updater(a,f,t.batchNum),r=r=t.batchNum}}),o=i(n,s,{observed:{}},h),u&&(n=t.__notObserve(n)),e.value=o.value,e.hasDependencies=!t.isEmptyObject(o.observed)},off:function(t){for(var e in o.observed){var n=o.observed[e];n.obj.unbind(n.event,h)}}}},o=function(){},h=function(t,e,n){this.value=t,s(this,t,e,n)},r=function(t,e,n){return function(){return t.call(e,n.get())}},a=function(t,e){return function(n){void 0!==n&&e(n,t.value)}};t.Compute=function(e,n,i,s){for(var u=[],o=0,h=arguments.length;h>o;o++)u[o]=arguments[o];var r=typeof u[1];"function"==typeof u[0]?this._setupGetterSetterFn(u[0],u[1],u[2],u[3]):u[1]?"string"===r?this._setupContextString(u[0],u[1],u[2]):"function"===r?this._setupContextFunction(u[0],u[1],u[2]):u[1]&&u[1].fn?this._setupAsyncCompute(u[0],u[1]):this._setupContextSettings(u[0],u[1]):this._setupInitialValue(u[0]),this._args=u,this.isComputed=!0,t.cid(this,"compute")},t.simpleExtend(t.Compute.prototype,{_bindsetup:t.__notObserve(function(){this.bound=!0,this._on(this.updater)}),_bindteardown:function(){this._off(this.updater),this.bound=!1},bind:t.bindAndSetup,unbind:t.unbindAndTeardown,clone:function(e){return e&&"function"==typeof this._args[0]?this._args[1]=e:e&&(this._args[2]=e),new t.Compute(this._args[0],this._args[1],this._args[2],this._args[3])},_on:o,_off:o,get:function(){return t.__isRecordingObserves()&&this._canObserve!==!1&&(t.__observe(this,"change"),this.bound||t.Compute.temporarilyBind(this)),this.bound?this.value:this._get()},_get:function(){return this.value},set:function(t){var e=this.value,n=this._set(t,e);return this.hasDependencies?this._setUpdates?this.value:this._get():(void 0===n?this.value=this._get():this.value=n,s(this,this.value,e),this.value)},_set:function(t){return this.value=t},updater:h,_computeFn:function(t){return arguments.length?this.set(t):this.get()},toFunction:function(){return t.proxy(this._computeFn,this)},_setupGetterSetterFn:function(e,n,i,s){this._set=t.proxy(e,n),this._get=t.proxy(e,n),this._canObserve=i===!1?!1:!0;var o=u(this,e,n||this,s);this._on=o.on,this._off=o.off},_setupContextString:function(e,n,i){var s=t.isMapLike(e),u=this,o=function(t,e,n){u.updater(e,n,t.batchNum)};s?(this.hasDependencies=!0,this._get=function(){return e.attr(n)},this._set=function(t){e.attr(n,t)},this._on=function(t){e.bind(i||n,o),this.value=this._get()},this._off=function(){return e.unbind(i||n,o)}):(this._get=t.proxy(this._get,e),this._set=t.proxy(this._set,e))},_setupContextFunction:function(e,n,i){this.value=e,this._set=n,t.simpleExtend(this,i)},_setupContextSettings:function(e,n){if(this.value=e,this._set=n.set?t.proxy(n.set,n):this._set,this._get=n.get?t.proxy(n.get,n):this._get,!n.__selfUpdater){var i=this,s=this.updater;this.updater=function(){s.call(i,i._get(),i.value)}}this._on=n.on?n.on:this._on,this._off=n.off?n.off:this._off},_setupAsyncCompute:function(e,n){this.value=e;var i,s=t.proxy(this.updater,this),o=this,h=n.fn;this.updater=s;var c=new t.Compute(e);this.lastSetValue=c,this._setUpdates=!0,this._set=function(t){return t===c.get()?this.value:c.set(t)},this._get=r(h,n.context,c),0===h.length?i=u(this,h,n.context):1===h.length?i=u(this,function(){return h.call(n.context,c.get())},n):(this.updater=a(this,s),i=u(this,function(){var t=h.call(n.context,c.get(),function(t){s(t,o.value)});return void 0!==t?t:this.value},n)),this._on=i.on,this._off=i.off},_setupInitialValue:function(t){this.value=t}});var c,f=function(){for(var t=0,e=c.length;e>t;t++)c[t].unbind("change",o);c=null};return t.Compute.temporarilyBind=function(t){t.bind("change",o),c||(c=[],setTimeout(f,10)),c.push(t)},t.Compute.async=function(e,n,i){return new t.Compute(e,{fn:n,context:i})},t.Compute.read=n,t.Compute.set=n.write,t.Compute.truthy=function(e){return new t.Compute(function(){var t=e.get();return"function"==typeof t&&(t=t.get()),!!t})},t.Compute}); +/*can@2.2.6#compute/compute*/ +define("can/compute/compute",["can/util/util","can/util/bind/bind","can/util/batch/batch","can/compute/proto_compute"],function(t,n){t.compute=function(n,u,e,o){var c=new t.Compute(n,u,e,o),i=function(t){return arguments.length?c.set(t):c.get()};return i.bind=t.proxy(c.bind,c),i.unbind=t.proxy(c.unbind,c),i.isComputed=c.isComputed,i.clone=function(e){return"function"==typeof n&&(u=e),t.compute(n,u,e,o)},i.computeInstance=c,i};var u,e=function(){},o=function(){for(var t=0,n=u.length;n>t;t++)u[t].unbind("change",e);u=null};return t.compute.temporarilyBind=function(t){t.bind("change",e),u||(u=[],setTimeout(o,10)),u.push(t)},t.compute.truthy=function(n){return t.compute(function(){var t=n();return"function"==typeof t&&(t=t()),!!t})},t.compute.async=function(n,u,e){return t.compute(n,{fn:u,context:e})},t.compute.read=t.Compute.read,t.compute.set=t.Compute.set,t.compute}); +/*can@2.2.6#observe/observe*/ +define("can/observe/observe",["can/util/util","can/map/map","can/list/list","can/compute/compute"],function(t){return t.Observe=t.Map,t.Observe.startBatch=t.batch.start,t.Observe.stopBatch=t.batch.stop,t.Observe.triggerBatch=t.batch.trigger,t}); +/*can@2.2.6#view/scope/compute_data*/ +define("can/view/scope/compute_data",["can/util/util","can/compute/compute","can/compute/get_value_and_bind"],function(e,t,n){var o=function(t){return t.reads&&1===t.reads.length&&t.root instanceof e.Map&&!e.isFunction(t.root[t.reads[0]])},a=function(e,t){return n(e,null,{observed:{}},t)},u=function(e,t){for(var n in e.observed){var o=e.observed[n];o.obj.unbind(o.event,t)}},r=function(e,t){var n=e.root,o=e.reads[0];return n.bind(o,t),{value:e.initialValue,observed:{something:!0}}},c=function(e,t){e.root.unbind(e.reads[0],t)},i=function(t,n,o,a,u){if(!(arguments.length>4)){if(a.root)return e.compute.read(a.root,a.reads,o).value;var r=t.read(n,o);return a.scope=r.scope,a.initialValue=r.value,a.reads=r.reads,a.root=r.rootObserve,r.value}if(a.root.isComputed)a.root(u);else if(a.reads.length){var c=a.reads.length-1,i=a.reads.length?e.compute.read(a.root,a.reads.slice(0,c)).value:a.root;e.compute.set(i,a.reads[c],u,o)}};return function(t,s,d){d=d||{args:[]};var l,v,f={},p=function(e){return arguments.length?i(t,s,d,f,e):i(t,s,d,f)},m=function(e){if(v.ready&&g.computeInstance.bound&&(void 0===e.batchNum||e.batchNum!==l)){var t,o=v.value;v=n(p,null,v,m),t=v.value,g.computeInstance.updater(t,o,e.batchNum),l=l=e.batchNum}},b=function(e,t,n){"function"!=typeof t?g.computeInstance.updater(t,n,e.batchNum):(c(f,b),v=a(p,m),h=!1,g.computeInstance.updater(v.value,n,e.batchNum))},h=!1,g=e.compute(void 0,{on:function(){if(v=a(p,m),o(f)){var t=v;v=r(f,b),u(t,m),h=!0}g.computeInstance.value=v.value,g.computeInstance.hasDependencies=!e.isEmptyObject(v.observed)},off:function(){h?c(f,b):u(v,m)},set:p,get:p,__selfUpdater:!0});return f.compute=g,f}}); +/*can@2.2.6#view/scope/scope*/ +define("can/view/scope/scope",["can/util/util","can/view/scope/compute_data","can/construct/construct","can/map/map","can/list/list","can/view/view","can/compute/compute"],function(e,t){var n=/(\\)?\./g,r=/\\\./g,u=function(e){var t=[],u=0;return e.replace(n,function(n,i,s){i||(t.push(e.slice(u,s).replace(r,".")),u=s+n.length)}),t.push(e.slice(u).replace(r,".")),t},i=e.Construct.extend({read:e.compute.read},{init:function(e,t){this._context=e,this._parent=t,this.__cache={}},attr:e.__notObserve(function(t,n){var r={isArgument:!0,returnObserveMethods:!0,proxyMethods:!1},u=this.read(t,r);if(2===arguments.length){var i=t.lastIndexOf("."),s=-1!==i?t.substring(0,i):".",a=this.read(s,r).value;-1!==i&&(t=t.substring(i+1,t.length)),e.compute.set(a,t,n,r)}return u.value}),add:function(e){return e!==this._context?new this.constructor(e,this):this},computeData:function(e,n){return t(this,e,n)},compute:function(e,t){return this.computeData(e,t).compute},read:function(t,n){var r;if("./"===t.substr(0,2))r=!0,t=t.substr(2);else{if("../"===t.substr(0,3))return this._parent.read(t.substr(3),n);if(".."===t)return{value:this._parent._context};if("."===t||"this"===t)return{value:this._context}}for(var i,s,a,c,o,l,p=-1===t.indexOf("\\.")?t.split("."):u(t),v=this,d=[],f=-1;v;){if(i=v._context,null!==i&&("object"==typeof i||"function"==typeof i)){var h=e.compute.read(i,p,e.simpleExtend({foundObservable:function(e,t){o=e,l=p.slice(t)},earlyExit:function(t,n){n>f&&(s=o,d=l,f=n,c=v,a=e.__clearReading())},executeAnonymousFunctions:!0},n));if(void 0!==h.value)return{scope:v,rootObserve:o,value:h.value,reads:l}}e.__clearReading(),v=r?null:v._parent}return s?(e.__setReading(a),{scope:c,rootObserve:s,reads:d,value:void 0}):{names:p,value:void 0}}});return e.view.Scope=i,i}); +/*can@2.2.6#view/scanner*/ +define("can/view/scanner",["can/view/view","can/view/elements","can/view/callbacks/callbacks"],function(can,elements,viewCallbacks){var newLine=/(\r|\n)+/g,notEndTag=/\//,clean=function(t){return t.split("\\").join("\\\\").split("\n").join("\\n").split('"').join('\\"').split(" ").join("\\t")},getTag=function(t,e,n){if(t)return t;for(;n":">",'"':'"',"'":"'"},this.tokenComplex=[],this.tokenMap={};for(var e,n=0;e=this.tokens[n];n++)e[2]?(this.tokenReg.push(e[2]),this.tokenComplex.push({abbr:e[1],re:new RegExp(e[2]),rescan:e[3]})):(this.tokenReg.push(e[1]),this.tokenSimple[e[1]]=e[0]),this.tokenMap[e[0]]=e[1];this.tokenReg=new RegExp("("+this.tokenReg.slice(0).concat(["<",">",'"',"'"]).join("|")+")","g")},Scanner.prototype={helpers:[],scan:function(t,e){var n=[],s=0,a=this.tokenSimple,r=this.tokenComplex;t=t.replace(newLine,"\n"),this.transform&&(t=this.transform(t)),t.replace(this.tokenReg,function(e,i){var o=arguments[arguments.length-2];if(o>s&&n.push(t.substring(s,o)),a[e])n.push(e);else for(var u,c=0;u=r[c];c++)if(u.re.test(e)){n.push(u.abbr),u.rescan&&n.push(u.rescan(i));break}s=o+i.length}),s":htmlTag=0;var H="/"===l.substr(l.length-1)||"--"===l.substr(l.length-2),N="";if(k.attributeHookups.length&&(N="attrs: ['"+k.attributeHookups.join("','")+"'], ",k.attributeHookups=[]),v+k.tagHookups.length!==k.lastTagHookup&&v===top(k.tagHookups))H&&(l=l.substr(0,l.length-1)),p.push(put_cmd,'"',clean(l),'"',",can.view.pending({tagName:'"+v+"',"+N+"scope: "+(this.text.scope||"this")+this.text.options),H?(p.push("}));"),l="/>",b()):"<"===n[d]&&n[d+1]==="/"+v?(p.push("}));"),l=u,b()):(p.push(",subtemplate: function("+this.text.argNames+"){\n"+startTxt+(this.text.start||"")),l="");else if(m||!w&&elements.tagToContentPropMap[x[x.length-1]]||N){var R=",can.view.pending({"+N+"scope: "+(this.text.scope||"this")+this.text.options+'}),"';H?h(l.substr(0,l.length-1),R+'/>"'):h(l,R+'>"'),l="",m=0}else l+=u;(H||w)&&(x.pop(),v=x[x.length-1],w=!1),k.attributeHookups=[];break;case"'":case'"':if(htmlTag)if(quote&"e===u){quote=null;var L=getAttrName();if(viewCallbacks.attr(L)&&k.attributeHookups.push(L),T){l+=u,h(l),p.push(finishTxt,"}));\n"),l="",T=!1;break}}else if(null===quote&&(quote=u,beforeQuote=i,c=getAttrName(),"img"===v&&"src"===c||"style"===c)){h(l.replace(attrReg,"")),l="",T=!0,p.push(insert_cmd,"can.view.txt(2,'"+getTag(v,n,d)+"',"+status()+",this,function(){",startTxt),h(c+"="+u);break}default:if("<"===i){v="!--"===u.substr(0,3)?"!--":u.split(/\s/)[0];var S,y=!1;0===v.indexOf("/")&&(y=!0,S=v.substr(1)),y?(top(x)===S&&(v=S,w=!0),top(k.tagHookups)===S&&(h(l.substr(0,l.length-1)),p.push(finishTxt+"}}) );"),l="><",b())):(v.lastIndexOf("/")===v.length-1&&(v=v.substr(0,v.length-1)),"!--"!==v&&viewCallbacks.tag(v)&&("content"===v&&elements.tagMap[top(x)]&&(u=u.replace("content",elements.tagMap[top(x)])),k.tagHookups.push(v)),x.push(v))}l+=u}else switch(u){case _.right:case _.returnRight:switch(f){case _.left:o=bracketNum(l),1===o?(p.push(insert_cmd,"can.view.txt(0,'"+getTag(v,n,d)+"',"+status()+",this,function(){",startTxt,l),g.push({before:"",after:finishTxt+"}));\n"})):(s=g.length&&-1===o?g.pop():{after:";"},s.before&&p.push(s.before),p.push(l,";",s.after));break;case _.escapeLeft:case _.returnLeft:o=bracketNum(l),o&&g.push({before:finishTxt,after:"}));\n"});for(var j=f===_.escapeLeft?1:0,C={insert:insert_cmd,tagName:getTag(v,n,d),status:status(),specialAttribute:T},q=0;q[\s]*\w*/.source&&(j=0);break}}"object"==typeof l?l.startTxt&&l.end&&T?p.push(insert_cmd,"can.view.toStr( ",l.content,"() ) );"):(l.startTxt?p.push(insert_cmd,"can.view.txt(\n"+("string"==typeof status()||(null!=l.escaped?l.escaped:j))+",\n'"+v+"',\n"+status()+",\nthis,\n"):l.startOnlyTxt&&p.push(insert_cmd,"can.view.onlytxt(this,\n"),p.push(l.content),l.end&&p.push("));")):T?p.push(insert_cmd,l,");"):p.push(insert_cmd,"can.view.txt(\n"+("string"==typeof status()||j)+",\n'"+v+"',\n"+status()+",\nthis,\nfunction(){ "+(this.text.escape||"")+"return ",l,o?startTxt:"}));\n"),rescan&&rescan.after&&rescan.after.length&&(h(rescan.after.length),rescan=null)}f=null,l="";break;case _.templateLeft:l+=_.left;break;default:l+=u}i=u}l.length&&h(l),p.push(";");var M=p.join(""),A={out:(this.text.outStart||"")+M+" "+finishTxt+(this.text.outEnd||"")};return myEval.call(A,"this.fn = (function("+this.text.argNames+"){"+A.out+"});\r\n//# sourceURL="+e+".js"),A}},can.view.pending=function(t){var e=can.view.getHooks();return can.view.hook(function(n){can.each(e,function(t){t(n)}),t.templateType="legacy",t.tagName&&viewCallbacks.tagHandler(n,t.tagName,t),can.each(t&&t.attrs||[],function(e){t.attributeName=e;var s=viewCallbacks.attr(e);s&&s(n,t)})})},can.view.tag("content",function(t,e){return e.scope}),can.view.Scanner=Scanner,Scanner}); +/*can@2.2.6#view/node_lists/node_lists*/ +define("can/view/node_lists/node_lists",["can/util/util","can/view/elements"],function(e){var n=!0;try{document.createTextNode("")._=0}catch(t){n=!1}var r={},a={},i="ejs_"+Math.random(),s=0,u=function(e,t){var r=t||a,u=l(e,r);return u?u:n||3!==e.nodeType?(++s,e[i]=(e.nodeName?"element_":"obj_")+s):(++s,r["text_"+s]=e,"text_"+s)},l=function(e,t){if(n||3!==e.nodeType)return e[i];for(var r in t)if(t[r]===e)return r},c=[].splice,o=[].push,p=function(e){for(var n=0,t=0,r=e.length;r>t;t++){var a=e[t];a.nodeType?n++:n+=p(a)}return n},f=function(e,n){for(var t={},r=0,a=e.length;a>r;r++){var i=d.first(e[r]);t[u(i,n)]=e[r]}return t},d={id:u,update:function(n,t){var r=d.unregisterChildren(n);t=e.makeArray(t);var a=n.length;return c.apply(n,[0,a].concat(t)),n.replacements?d.nestReplacements(n):d.nestList(n),r},nestReplacements:function(e){for(var n=0,t={},r=f(e.replacements,t),a=e.replacements.length;nr;r++){var n=e[r];t[n.tokenType].apply(t,n.args)}return e}var a="-:A-Za-z0-9_",n="[a-zA-Z_:]["+a+":.]*",s="\\s*=\\s*",i='"((?:\\\\.|[^"])*)"',o="'((?:\\\\.|[^'])*)'",l="(?:"+s+"(?:(?:\"[^\"]*\")|(?:'[^']*')|[^>\\s]+))?",c="\\{\\{[^\\}]*\\}\\}\\}?",u="\\{\\{([^\\}]*)\\}\\}\\}?",p=new RegExp("^<(["+a+"]+)((?:\\s*(?:(?:(?:"+n+")?"+l+")|(?:"+c+")+))*)\\s*(\\/?)>"),f=new RegExp("^<\\/(["+a+"]+)[^>]*>"),d=new RegExp("(?:(?:("+n+")|"+u+")(?:"+s+"(?:(?:"+i+")|(?:"+o+")|([^>\\s]+)))?)","g"),g=new RegExp(u,"g"),h=/<|\{\{/,m=t("area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed"),b=t("a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video"),v=t("abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var"),x=t("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr"),w=t("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"),y=t("script,style"),k="start,end,close,attrStart,attrEnd,attrValue,chars,comment,special,done".split(","),E=function(){},A=function(t,a,n){function s(e,t,r,n){if(t=t.toLowerCase(),b[t])for(;w.last()&&v[w.last()];)i("",w.last());x[t]&&w.last()===t&&i("",t),n=m[t]||!!n,a.start(t,n),n||w.push(t),A.parseAttrs(r,a),a.end(t,n)}function i(e,t){var r;if(t)for(r=w.length-1;r>=0&&w[r]!==t;r--);else r=0;if(r>=0){for(var n=w.length-1;n>=r;n--)a.close&&a.close(w[n]);w.length=r}}function o(e,t){a.special&&a.special(t)}if("object"==typeof t)return r(t,a);var l=[];a=a||{},n&&e.each(k,function(t){var r=a[t]||E;a[t]=function(){r.apply(this,arguments)!==!1&&l.push({tokenType:t,args:e.makeArray(arguments)})}});var c,u,d,w=[],O=t;for(w.last=function(){return this[this.length-1]};t;){if(u=!0,w.last()&&y[w.last()])t=t.replace(new RegExp("([\\s\\S]*?)]*>"),function(e,t){return t=t.replace(/|/g,"$1$2"),a.chars&&a.chars(t),""}),i("",w.last());else if(0===t.indexOf(""),c>=0&&(a.comment&&a.comment(t.substring(4,c)),t=t.substring(c+3),u=!1)):0===t.indexOf("c?t:t.substring(0,c);t=0>c?"":t.substring(c),a.chars&&R&&a.chars(R)}if(t===O)throw"Parse Error: "+t;O=t}return i(),a.done(),l};return A.parseAttrs=function(e,t){(null!=e?e:"").replace(d,function(e,r,a,n,s,i){if(a&&t.special(a),r||n||s||i){var o=arguments[3]?arguments[3]:arguments[4]?arguments[4]:arguments[5]?arguments[5]:w[r.toLowerCase()]?r:"";t.attrStart(r||"");for(var l,c=g.lastIndex=0,u=g.exec(o);u;)l=o.substring(c,g.lastIndex-u[0].length),l.length&&t.attrValue(l),t.special(u[1]),c=g.lastIndex,u=g.exec(o);l=o.substr(c,o.length),l&&t.attrValue(l),t.attrEnd(r||"")}})},e.view.parser=A,A}); +/*can@2.2.6#view/live/live*/ +define("can/view/live/live",["can/util/util","can/view/elements","can/view/view","can/view/node_lists/node_lists","can/view/parser/parser"],function(e,t,n,r,i){t=t||e.view.elements,r=r||e.view.NodeLists,i=i||e.view.parser;var a=function(t,n,r){var i=!1,a=function(){return i||(i=!0,r(o),e.unbind.call(t,"removed",a)),!0},o={teardownCheck:function(e){return e?!1:a()}};return e.bind.call(t,"removed",a),n(o),o},o=function(e,t,n){return a(e,function(){t.bind("change",n)},function(e){t.unbind("change",n),e.nodeList&&r.unregister(e.nodeList)})},c=function(e){var t,n={};return i.parseAttrs(e,{attrStart:function(e){n[e]="",t=e},attrValue:function(e){n[t]+=e},attrEnd:function(){}}),n},u=[].splice,d=function(e){return e&&e.nodeType},s=function(e){e.childNodes.length||e.appendChild(document.createTextNode(""))},l={list:function(n,i,o,c,d,s){var f,p=s||[n],v=[],h=!1,g=!1,b=function(n,i,a){if(h){var d=document.createDocumentFragment(),l=[],f=[];e.each(i,function(t,n){var i=[];s&&r.register(i,null,!0);var u=e.compute(n+a),p=o.call(c,t,u,i),v="string"==typeof p,h=e.frag(p);h=v?e.view.hookup(h):h;var g=e.makeArray(h.childNodes);s?(r.update(i,g),l.push(i)):l.push(r.register(g)),d.appendChild(h),f.push(u)});var g=a+1;if(p[g]){var b=r.first(p[g]);e.insertBefore(b.parentNode,d,b)}else t.after(1===g?[N]:[r.last(p[g-1])],d);u.apply(p,[g,0].concat(l)),u.apply(v,[a,0].concat(f));for(var m=a+f.length,w=v.length;w>m;m++)v[m](m)}},m=function(t,n,i,a,o){if(h&&(a||!y.teardownCheck(N.parentNode))){0>i&&(i=v.length+i);var c=p.splice(i+1,n.length),u=[];e.each(c,function(e){var t=r.unregister(e);[].push.apply(u,t)}),v.splice(i,n.length);for(var d=i,s=v.length;s>d;d++)v[d](d);o?r.unregister(p):e.remove(e.$(u))}},w=function(t,n,i,a){if(h){i+=1,a+=1;var o,c=p[i],u=e.frag(r.flatten(p[a]));o=i>a?r.last(c).nextSibling:r.first(c);var d=p[0].parentNode;d.insertBefore(u,o);var s=p[a];[].splice.apply(p,[a,1]),[].splice.apply(p,[i,0,s])}},N=document.createTextNode(""),k=function(e){f&&f.unbind&&f.unbind("add",b).unbind("remove",m).unbind("move",w),m({},{length:p.length-1},0,!0,e)},A=function(t,n,r){g||(k(),f=n||[],f.bind&&f.bind("add",b).bind("remove",m).bind("move",w),h=!0,b({},f,0),h=!1,e.batch.afterPreviousEvents(function(){h=!0}))};d=t.getParentNode(n,d);var y=a(d,function(){e.isFunction(i)&&i.bind("change",A)},function(){e.isFunction(i)&&i.unbind("change",A),k(!0)});s?(t.replace(p,N),r.update(p,[N]),s.unregistered=function(){y.teardownCheck(),g=!0}):l.replace(p,N,y.teardownCheck),A({},e.isFunction(i)?i():i)},html:function(n,i,a,c){var u;a=t.getParentNode(n,a),u=o(a,i,function(e,t,n){var i=r.first(l).parentNode;i&&f(t),u.teardownCheck(r.first(l).parentNode)});var l=c||[n],f=function(n){var i="function"==typeof n,o=d(n),c=e.frag(i?"":n),u=e.makeArray(l);s(c),o||i||(c=e.view.hookup(c,a)),u=r.update(l,c.childNodes),i&&n(c.childNodes[0]),t.replace(u,c)};u.nodeList=l,c?c.unregistered=u.teardownCheck:r.register(l,u.teardownCheck),f(i())},replace:function(n,i,a){var o=n.slice(0),c=e.frag(i);return r.register(n,a),"string"==typeof i&&(c=e.view.hookup(c,n[0].parentNode)),r.update(n,c.childNodes),t.replace(o,c),n},text:function(n,i,a,c){var u=t.getParentNode(n,a),d=o(u,i,function(t,n,r){"unknown"!=typeof s.nodeValue&&(s.nodeValue=e.view.toStr(n)),d.teardownCheck(s.parentNode)}),s=document.createTextNode(e.view.toStr(i()));c?(c.unregistered=d.teardownCheck,d.nodeList=c,r.update(c,[s]),t.replace([n],s)):d.nodeList=l.replace([n],s,d.teardownCheck)},setAttributes:function(t,n){var r=c(n);for(var i in r)e.attr.set(t,i,r[i])},attributes:function(n,r,i){var a={},u=function(r){var i,o=c(r);for(i in o){var u=o[i],d=a[i];u!==d&&e.attr.set(n,i,u),delete a[i]}for(i in a)t.removeAttr(n,i);a=o};o(n,r,function(e,t){u(t)}),arguments.length>=3?a=c(i):u(r())},attributePlaceholder:"__!!__",attributeReplace:/__!!__/g,attribute:function(n,r,i){o(n,i,function(e,i){t.setAttr(n,r,u.render())});var a,c=e.$(n);a=e.data(c,"hooks"),a||e.data(c,"hooks",a={});var u,d=t.getAttr(n,r),s=d.split(l.attributePlaceholder),f=[];f.push(s.shift(),s.join(l.attributePlaceholder)),a[r]?a[r].computes.push(i):a[r]={render:function(){var e=0,n=d?d.replace(l.attributeReplace,function(){return t.contentText(u.computes[e++]())}):t.contentText(u.computes[e++]());return n},computes:[i],batchNum:void 0},u=a[r],f.splice(1,0,i()),t.setAttr(n,r,f.join(""))},specialAttribute:function(e,n,r){o(e,r,function(r,i){t.setAttr(e,n,p(i))}),t.setAttr(e,n,p(r()))},simpleAttribute:function(e,n,r){o(e,r,function(r,i){t.setAttr(e,n,i)}),t.setAttr(e,n,r())}};l.attr=l.simpleAttribute,l.attrs=l.attributes;var f=/(\r|\n)+/g,p=function(e){var n=/^["'].*["']$/;return e=e.replace(t.attrReg,"").replace(f,""),n.test(e)?e.substr(1,e.length-2):e};return e.view.live=l,l}); +/*can@2.2.6#view/render*/ +define("can/view/render",["can/view/view","can/view/elements","can/view/live/live","can/util/string/string"],function(t,n,e){var i,r=[],u=function(t){var e=n.tagMap[t]||"span";return"span"===e?"@@!!@@":"<"+e+">"+u(e)+""},o=function(n,e){if("string"==typeof n)return n;if(!n&&0!==n)return"";var i=n.hookup&&function(t,e){n.hookup.call(n,t,e)}||"function"==typeof n&&n;return i?e?"<"+e+" "+t.view.hook(i)+">":(r.push(i),""):""+n},c=function(n,e){return"string"==typeof n||"number"==typeof n?t.esc(n):o(n,e)},s=!1,a=function(){};return t.extend(t.view,{live:e,setupLists:function(){var n,e=t.view.lists;return t.view.lists=function(t,e){return n={list:t,renderer:e},Math.random()},function(){return t.view.lists=e,n}},getHooks:function(){var t=r.slice(0);return i=t,r=[],t},onlytxt:function(t,n){return c(n.call(t))},txt:function(f,p,l,v,h){var w,g,d,b,y=n.tagMap[p]||"span",k=!1,m=a;if(s)w=h.call(v);else{("string"==typeof l||1===l)&&(s=!0);var x=t.view.setupLists();m=function(){d.unbind("change",a)},d=t.compute(h,v,!1),d.bind("change",a),g=x(),w=d(),s=!1,k=d.computeInstance.hasDependencies}if(g)return m(),"<"+y+t.view.hook(function(t,n){e.list(t,g.list,g.renderer,v,n)})+">";if(!k||"function"==typeof w)return m(),(s||2===f||!f?o:c)(w,0===l&&y);var M=n.tagToContentPropMap[p];return 0!==l||M?1===l?(r.push(function(t){e.attributes(t,d,d()),m()}),d()):2===f?(b=l,r.push(function(t){e.specialAttribute(t,b,d),m()}),d()):(b=0===l?M:l,(0===l?i:r).push(function(t){e.attribute(t,b,d),m()}),e.attributePlaceholder):"<"+y+t.view.hook(f&&"object"!=typeof w?function(t,n){e.text(t,d,n),m()}:function(t,n){e.html(t,d,n),m()})+">"+u(y)+""}}),t}); +/*can@2.2.6#view/stache/utils*/ +define("can/view/stache/utils",["can/util/util"],function(){return{isArrayLike:function(t){return t&&t.splice&&"number"==typeof t.length},isObserveLike:function(t){return t instanceof can.Map||t&&!!t._get},emptyHandler:function(){},jsonParse:function(str){return"'"===str[0]?str.substr(1,str.length-2):"undefined"===str?void 0:can.global.JSON?JSON.parse(str):eval("("+str+")")},mixins:{last:function(){return this.stack[this.stack.length-1]},add:function(t){this.last().add(t)},subSectionDepth:function(){return this.stack.length-1}}}}); +/*can@2.2.6#view/stache/mustache_helpers*/ +define("can/view/stache/mustache_helpers",["can/util/util","can/view/stache/utils","can/view/live/live"],function(e,n,t){t=t||e.view.live;var i=function(t){return n.isObserveLike(t)&&n.isArrayLike(t)&&t.attr("length")?t:e.isFunction(t)?t():t},r={each:function(r,s){var o,u,a,c=i(r),f=[];if(c instanceof e.List)return function(n){var i=[n];i.expression="live.list",e.view.nodeLists.register(i,null,s.nodeList),e.view.nodeLists.update(s.nodeList,[n]);var o=function(e,n,t){return s.fn(s.scope.add({"@index":n}).add(e),s.options,t)};t.list(n,r,o,s.context,n.parentNode,i)};var l=c;if(l&&n.isArrayLike(l))for(a=0;a0&&t!==n)return r.inverse();n=t}return r.fn()},eq:function(){return r.is.apply(this,arguments)},unless:function(n,t){return r["if"].apply(this,[e.isFunction(n)?e.compute(function(){return!n()}):!n,t])},"with":function(e,n){var t=e;return e=i(e),e?n.fn(t):void 0},log:function(e,n){"undefined"!=typeof console&&console.log&&(n?console.log(e,n.context):console.log(e.context))},data:function(n){var t=2===arguments.length?this:arguments[1];return function(i){e.data(e.$(i),n,t||this.context)}}};return{registerHelper:function(e,n){r[e]=n},getHelper:function(e,n){var t=n.attr("helpers."+e);return t||(t=r[e]),t?{fn:t}:void 0}}}); +/*can@2.2.6#view/stache/mustache_core*/ +define("can/view/stache/mustache_core",["can/util/util","can/view/stache/utils","can/view/stache/mustache_helpers","can/view/live/live","can/view/elements","can/view/scope/scope","can/view/node_lists/node_lists"],function(e,t,n,r,i,a,s){r=r||e.view.live,i=i||e.view.elements,a=a||e.view.Scope,s=s||e.view.nodeLists;var o=/((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g,u=/^(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(?:(.+?)=(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(.+))))$/,c=/(?:(?:^|(\r?)\n)(\s*)(\{\{([^\}]*)\}\}\}?)([^\S\n\r]*)($|\r?\n))|(\{\{([^\}]*)\}\}\}?)/g,l=function(e){return e&&"string"==typeof e.get},f=function(e,t,n,r){for(var i=document.createDocumentFragment(),a=0,s=e.length;s>a;a++)p(i,n.fn(t?e.attr(""+a):e[a],r));return i},p=function(e,t){t&&e.appendChild("string"==typeof t?document.createTextNode(t):t)},h=function(e,t,n,r){for(var i="",a=0,s=e.length;s>a;a++)i+=n.fn(t?e.attr(""+a):e[a],r);return i},d=function(t,n,r){var i=n.computeData(t,{isArgument:r,args:[n.attr("."),n]});return e.compute.temporarilyBind(i.compute),i},v=function(e,t){var n=d(e,t,!0);return n.compute.computeInstance.hasDependencies?n.compute:n.initialValue},g=function(e,t,n,r,i,a){i&&(e.fn=m(i,t,n,r)),a&&(e.inverse=m(a,t,n,r))},m=function(t,n,r,i){var a=function(e,r,i){return t(e||n,r,i)};return e.__notObserve(function(t,s,o){void 0===t||t instanceof e.view.Scope||(t=n.add(t)),void 0===s||s instanceof x.Options||(s=r.add(s));var u=a(t,s||r,o||i);return u})},x={expressionData:function(n){var r=[],i={},a=0;return(e.trim(n)+" ").replace(o,function(e,n){var s;a&&(s=n.match(u))?s[1]||s[2]?r.push(t.jsonParse(s[1]||s[2])):i[s[3]]=s[6]?{get:s[6]}:t.jsonParse(s[4]||s[5]):r.push({get:n}),a++}),{name:r.shift(),args:r,hash:i}},makeEvaluator:function(r,i,a,s,o,u,c,p){for(var m,x,y,w=[],b={},_={fn:function(){},inverse:function(){}},O=r.attr("."),k=o.name,D=o.args.length||!e.isEmptyObject(o.hash),E=0,L=o.args.length;L>E;E++){var A=o.args[E];w.push(A&&l(A)?v(A.get,r,!0):A)}for(var N in o.hash)l(o.hash[N])?b[N]=v(o.hash[N].get,r):b[N]=o.hash[N];if(l(k)&&(D&&(m=n.getHelper(k.get,i),m||"function"!=typeof O[k.get]||(m={fn:O[k.get]})),!m)){var S=k.get,B=d(k.get,r,!1),R=B.compute;x=B.initialValue,k=B.compute.computeInstance.hasDependencies?R:x,D||void 0!==x?"function"==typeof x&&(m={fn:x}):m=n.getHelper(S,i)}if("^"===s){var j=u;u=c,c=j}if(m)return g(_,r,i,a,u,c),e.simpleExtend(_,{context:O,scope:r,contexts:r,hash:b,nodeList:a,exprData:o}),w.push(_),y=function(){return m.fn.apply(O,w)||""},y.bindOnce=!1,y;if(!s)return k&&k.isComputed?k:function(){return""+(null!=k?k:"")};if("#"===s||"^"===s){g(_,r,i,a,u,c);var F=function(){var n;if(n=e.isFunction(k)&&k.isComputed?k():k,t.isArrayLike(n)){var a=t.isObserveLike(n);return(a?n.attr("length"):n.length)?(p?h:f)(n,a,_,i):_.inverse(r,i)}return n?_.fn(n||r,i):_.inverse(r,i)};return F.bindOnce=!1,F}},makeLiveBindingPartialRenderer:function(t,n){return t=e.trim(t),function(i,a,o){var u=[this];u.expression=">"+t,s.register(u,null,n.directlyNested?o||!0:!0);var c=e.compute(function(){var n,r=t,s=a.attr("partials."+r);if(s)n=s.render?s.render(i,a):s(i,a);else{var o=i.read(r,{isArgument:!0,returnObserveMethods:!0,proxyMethods:!1}).value;o&&(r=o),n=e.view.render(r,i,a)}return e.frag(n)});r.html(this,c,this.parentNode,u)}},makeStringBranchRenderer:function(e,t){var n=w(t),r=e+t;return function(t,i,a,s){var o=t.__cache[r];(e||!o)&&(o=y(t,i,null,e,n,a,s,!0),e||(t.__cache[r]=o));var u=o();return null==u?"":""+u}},makeLiveBindingBranchRenderer:function(t,n,a){var o=w(n);return function(u,c,l,f,p){var h=[this];h.expression=n,s.register(h,null,a.directlyNested?l||!0:!0);var d=y(u,c,h,t,o,f,p,a.tag),v=e.compute(d,null,!1,d.bindOnce===!1?!1:!0);v.bind("change",e.k);var g=v();if("function"==typeof g){var m=e.__clearReading();g(this),e.__setReading(m)}else v.computeInstance.hasDependencies?a.attr?r.simpleAttribute(this,a.attr,v):a.tag?r.attributes(this,v):a.text&&"object"!=typeof g?r.text(this,v,this.parentNode,h):r.html(this,v,this.parentNode,h):a.attr?e.attr.set(this,a.attr,g):a.tag?r.setAttributes(this,g):a.text&&"string"==typeof g?this.nodeValue=g:g&&i.replace([this],e.frag(g));v.unbind("change",e.k)}},splitModeFromExpression:function(t,n){t=e.trim(t);var r=t.charAt(0);return"#/{&^>!".indexOf(r)>=0?t=e.trim(t.substr(1)):r=null,"{"===r&&n.node&&(r=null),{mode:r,expression:t}},cleanLineEndings:function(e){return e.replace(c,function(e,t,n,r,i,a,s,o,u,c){a=a||"",t=t||"",n=n||"";var l=b(i||u,{});return o||">{".indexOf(l.mode)>=0?e:"^#!/".indexOf(l.mode)>=0?r+(0!==c&&s.length?t+"\n":""):n+r+a+(n.length||0!==c?t+"\n":"")})},Options:e.view.Scope.extend({init:function(t,n){t.helpers||t.partials||t.tags||(t={helpers:t}),e.view.Scope.prototype.init.apply(this,arguments)}})},y=x.makeEvaluator,w=x.expressionData,b=x.splitModeFromExpression;return x}); +/*can@2.2.6#view/bindings/bindings*/ +define("can/view/bindings/bindings",["can/util/util","can/view/stache/mustache_core","can/view/callbacks/callbacks","can/control/control","can/view/scope/scope"],function(e,t){var n=function(){var e={"":!0,"true":!0,"false":!1},t=function(t){if(t&&t.getAttribute){var n=t.getAttribute("contenteditable");return e[n]}};return function(e){var n=t(e);return"boolean"==typeof n?n:!!t(e.parentNode)}}(),i=function(e){return"{"===e[0]&&"}"===e[e.length-1]?e.substr(1,e.length-2):e};e.view.attr("can-value",function(t,a){var c,l,h=e.trim(i(t.getAttribute("can-value"))),v=a.scope.computeData(h,{args:[]}).compute;return"input"===t.nodeName.toLowerCase()&&("checkbox"===t.type&&(c=e.attr.has(t,"can-true-value")?t.getAttribute("can-true-value"):!0,l=e.attr.has(t,"can-false-value")?t.getAttribute("can-false-value"):!1),"checkbox"===t.type||"radio"===t.type)?void new o(t,{value:v,trueValue:c,falseValue:l}):"select"===t.nodeName.toLowerCase()&&t.multiple?void new u(t,{value:v}):n(t)?void new r(t,{value:v}):void new s(t,{value:v})});var a={enter:function(e,t,n){return{event:"keyup",handler:function(e){return 13===e.keyCode?n.call(this,e):void 0}}}};e.view.attr(/can-[\w\.]+/,function(n,s){var o=s.attributeName,u=o.substr("can-".length),r=function(a){var u=n.getAttribute(o);if(u){var r=t.expressionData(i(u)),c=s.scope.read(r.name.get,{returnObserveMethods:!0,isArgument:!0,executeAnonymousFunctions:!0}),l=[],h=e.$(this),v=e.viewModel(h[0]),f=s.scope.add({"@element":h,"@event":a,"@viewModel":v,"@scope":s.scope,"@context":s.scope._context});if(!e.isEmptyObject(r.hash)){var p={};e.each(r.hash,function(e,t){if(e&&e.hasOwnProperty("get")){var n=e.get.indexOf("@")?s.scope:f;p[t]=n.read(e.get,{}).value}else p[t]=e}),l.unshift(p)}if(r.args.length)for(var d,g=r.args.length-1;g>=0;g--)if(d=r.args[g],d&&d.hasOwnProperty("get")){var m=d.get.indexOf("@")?s.scope:f;l.unshift(m.read(d.get,{}).value)}else l.unshift(d);return l.length||(l=[s.scope._context,h].concat(e.makeArray(arguments))),c.value.apply(c.parent,l)}};if(a[u]){var c=a[u](s,n,r);r=c.handler,u=c.event}e.bind.call(n,u,r)});var s=e.Control.extend({init:function(){"SELECT"===this.element[0].nodeName.toUpperCase()?setTimeout(e.proxy(this.set,this),1):this.set()},"{value} change":"set",set:function(){if(this.element){var e=this.options.value();this.element[0].value=null==e?"":e}},change:function(){if(this.element){var e=this.element[0];this.options.value(e.value);var t=this.options.value();e.value!==t&&(e.value=t)}}}),o=e.Control.extend({init:function(){this.isCheckbox="checkbox"===this.element[0].type.toLowerCase(),this.check()},"{value} change":"check",check:function(){if(this.isCheckbox){var t=this.options.value(),n=this.options.trueValue||!0;this.element[0].checked=t==n}else{var i=this.options.value()==this.element[0].value?"set":"remove";e.attr[i](this.element[0],"checked",!0)}},change:function(){this.isCheckbox?this.options.value(this.element[0].checked?this.options.trueValue:this.options.falseValue):this.element[0].checked&&this.options.value(this.element[0].value)}}),u=s.extend({init:function(){this.delimiter=";",setTimeout(e.proxy(this.set,this),1)},set:function(){var t=this.options.value();"string"==typeof t?(t=t.split(this.delimiter),this.isString=!0):t&&(t=e.makeArray(t));var n={};e.each(t,function(e){n[e]=!0}),e.each(this.element[0].childNodes,function(e){e.value&&(e.selected=!!n[e.value])})},get:function(){var t=[],n=this.element[0].childNodes;return e.each(n,function(e){e.selected&&e.value&&t.push(e.value)}),t},change:function(){var t=this.get(),n=this.options.value();this.isString||"string"==typeof n?(this.isString=!0,this.options.value(t.join(this.delimiter))):n instanceof e.List?n.attr(t,!0):this.options.value(t)}}),r=e.Control.extend({init:function(){this.set(),this.on("blur","setValue")},"{value} change":"set",set:function(){var e=this.options.value();this.element[0].innerHTML="undefined"==typeof e?"":e},setValue:function(){this.options.value(this.element[0].innerHTML)}})}); +/*can@2.2.6#view/mustache/mustache*/ +define("can/view/mustache/mustache",["can/util/util","can/view/scope/scope","can/view/view","can/view/scanner","can/compute/compute","can/view/render","can/view/bindings/bindings"],function(e){e.view.ext=".mustache";var n="scope",t="___h4sh",r="{scope:"+n+",options:options}",i="{scope:"+n+",options:options, special: true}",s=n+",options",o=/((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g,a=/^(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false|null|undefined)|((.+?)=(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false)|(.+))))$/,c=function(e){return'{get:"'+e.replace(/"/g,'\\"')+'"}'},u=function(e){return e&&"string"==typeof e.get},f=function(n){return n instanceof e.Map||n&&!!n._get},p=function(e){return e&&e.splice&&"number"==typeof e.length},l=function(n,t,r){var i=function(e,r){return n(e||t,r)};return function(n,s){return void 0===n||n instanceof e.view.Scope||(n=t.add(n)),void 0===s||s instanceof e.view.Options||(s=r.add(s)),i(n,s||r)}},h=function(n,t){if(this.constructor!==h){var r=new h(n);return function(e,n){return r.render(e,n)}}return"function"==typeof n?void(this.template={fn:n}):(e.extend(this,n),void(this.template=this.scanner.scan(this.text,this.name)))};e.Mustache=e.global.Mustache=h,h.prototype.render=function(n,t){return n instanceof e.view.Scope||(n=new e.view.Scope(n||{})),t instanceof e.view.Options||(t=new e.view.Options(t||{})),t=t||{},this.template.fn.call(n,n,t)},e.extend(h.prototype,{scanner:new e.view.Scanner({text:{start:"",scope:n,options:",options: options",argNames:s},tokens:[["returnLeft","{{{","{{[{&]"],["commentFull","{{!}}","^[\\s\\t]*{{!.+?}}\\n"],["commentLeft","{{!","(\\n[\\s\\t]*{{!|{{!)"],["escapeFull","{{}}","(^[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}$)",function(e){return{before:/^\n.+?\n$/.test(e)?"\n":"",content:e.match(/\{\{(.+?)\}\}/)[1]||""}}],["escapeLeft","{{"],["returnRight","}}}"],["right","}}"]],helpers:[{name:/^>[\s]*\w*/,fn:function(n,t){var r=e.trim(n.replace(/^>\s?/,"")).replace(/["|']/g,"");return"can.Mustache.renderPartial('"+r+"',"+s+")"}},{name:/^\s*data\s/,fn:function(e,t){var r=e.match(/["|'](.*)["|']/)[1];return"can.proxy(function(__){can.data(can.$(__),'"+r+"', this.attr('.')); }, "+n+")"}},{name:/\s*\(([\$\w]+)\)\s*->([^\n]*)/,fn:function(e){var t=/\s*\(([\$\w]+)\)\s*->([^\n]*)/,r=e.match(t);return"can.proxy(function(__){var "+r[1]+"=can.$(__);with("+n+".attr('.')){"+r[2]+"}}, this);"}},{name:/^.*$/,fn:function(n,u){var f=!1,p={content:"",startTxt:!1,startOnlyTxt:!1,end:!1};if(n=e.trim(n),n.length&&(f=n.match(/^([#^\/]|else$)/))){switch(f=f[0]){case"#":case"^":u.specialAttribute?p.startOnlyTxt=!0:(p.startTxt=!0,p.escaped=0);break;case"/":return p.end=!0,p.content+='return ___v1ew.join("");}}])',p}n=n.substring(1)}if("else"!==f){var l,h=[],v=[],g=0;p.content+="can.Mustache.txt(\n"+(u.specialAttribute?i:r)+",\n"+(f?'"'+f+'"':"null")+",",(e.trim(n)+" ").replace(o,function(e,n){g&&(l=n.match(a))?l[2]?h.push(l[0]):v.push(l[4]+":"+(l[6]?l[6]:c(l[5]))):h.push(c(n)),g++}),p.content+=h.join(","),v.length&&(p.content+=",{"+t+":{"+v.join(",")+"}}")}switch(f&&"else"!==f&&(p.content+=",[\n\n"),f){case"^":case"#":p.content+="{fn:function("+s+"){var ___v1ew = [];";break;case"else":p.content+='return ___v1ew.join("");}},\n{inverse:function('+s+"){\nvar ___v1ew = [];";break;default:p.content+=")"}return f||(p.startTxt=!0,p.end=!0),p}}]})});for(var v=e.view.Scanner.prototype.helpers,g=0;g0&&t!==n)return r.inverse();n=t}return r.fn()},eq:function(){return h._helpers.is.fn.apply(this,arguments)},unless:function(n,t){return h._helpers["if"].fn.apply(this,[e.isFunction(n)?e.compute(function(){return!n()}):!n,t])},each:function(n,t){var r,i,s,o=h.resolve(n),a=[];if(e.view.lists&&(o instanceof e.List||n&&n.isComputed&&void 0===o))return e.view.lists(n,function(e,n){return t.fn(t.scope.add({"@index":n}).add(e))});if(n=o,n&&p(n)){for(s=0;st;t++)f[t]()};if(t.each(this.constructor.attributeScopeMappings,function(e,n){r[n]=i.getAttribute(t.hyphenate(e))}),t.each(t.makeArray(i.attributes),function(n,i){var c=t.camelize(n.nodeName.toLowerCase()),u=n.value;if(!(p.constructor.attributeScopeMappings[c]||o.test(c)||e.attr(n.nodeName))){if("{"===u[0]&&"}"===u[u.length-1])u=u.substr(1,u.length-2);else if("legacy"!==s.templateType)return void(r[c]=u);var h=s.scope.computeData(u,{args:[]}),m=h.compute,v=function(e,n){d[c]=(d[c]||0)+1,a.attr(c,n),t.batch.afterPreviousEvents(function(){--d[c]})};m.bind("change",v),r[c]=m(),m.computeInstance.hasDependencies?(f.push(function(){m.unbind("change",v)}),l[c]=h):m.unbind("change",v)}}),this.constructor.Map)a=new this.constructor.Map(r);else if(h instanceof t.Map)a=h;else if(t.isFunction(h)){var v=h.call(this,r,s.scope,i);a=v instanceof t.Map?v:v.prototype instanceof t.Map?new v(r):new(t.Map.extend(v))(r)}var g={};t.each(l,function(t,e){g[e]=function(n,o){d[e]||t.compute(o)},a.bind(e,g[e])}),t.isEmptyObject(this.constructor.attributeScopeMappings)&&"legacy"===s.templateType||t.bind.call(i,"attributes",function(e){var n=t.camelize(e.attributeName);l[n]||o.test(n)||a.attr(n,i.getAttribute(e.attributeName))}),this.scope=this.viewModel=a,t.data(t.$(i),"scope",this.scope),t.data(t.$(i),"viewModel",this.scope);var b=u?this.scope:s.scope.add(this.scope),y={helpers:{}};if(t.each(this.helpers||{},function(e,n){t.isFunction(e)&&(y.helpers[n]=function(){return e.apply(a,arguments)})}),f.push(function(){t.each(g,function(t,e){a.unbind(e,g[e])})}),this._control=new this.constructor.Control(i,{scope:this.scope,viewModel:this.scope}),this._control&&this._control.destroy){var w=this._control.destroy;this._control.destroy=function(){w.apply(this,arguments),m()},this._control.on()}else t.bind.call(i,"removed",function(){m()});var M=t.view.nodeLists.register([],void 0,!0);f.push(function(){t.view.nodeLists.unregister(M)}),this.constructor.renderer?(y.tags||(y.tags={}),y.tags.content=function C(e,o){var i=s.subtemplate||o.subtemplate;if(i){delete y.tags.content;var a=u&&i===s.subtemplate?s:o;if(o.parentNodeList){var c=i(a.scope,a.options,o.parentNodeList);n.replace([e],c)}else t.view.live.replace([e],i(a.scope,a.options));y.tags.content=C}},c=this.constructor.renderer(b,s.options.add(y),M)):c="legacy"===s.templateType?t.view.frag(s.subtemplate?s.subtemplate(b,s.options.add(y)):""):s.subtemplate?s.subtemplate(b,s.options.add(y),M):document.createDocumentFragment(),t.appendChild(i,c),t.view.nodeLists.update(M,i.childNodes)}}),a=t.Control.extend({_lookup:function(t){return[t.scope,t,window]},_action:function(e,n,o){var s,a;if(i.lastIndex=0,s=i.test(e),o||!s){if(s){a=t.compute(function(){var o,s=e.replace(i,function(e,i){var s;return"scope"===i||"viewModel"===i?(o=n.scope,""):(i=i.replace(/^(scope|^viewModel)\./,""),s=t.compute.read(n.scope,i.split("."),{isArgument:!0}).value,void 0===s&&(s=t.getObject(i)),"string"==typeof s?s:(o=s,""))}),a=s.split(/\s+/g),c=a.pop();return{processor:this.processors[c]||this.processors.click,parts:[s,a.join(" "),c],delegate:o||void 0}},this);var c=function(t,n){o._bindings.control[e](o.element),o._bindings.control[e]=n.processor(n.delegate||o.element,n.parts[2],n.parts[1],e,o)};return a.bind("change",c),o._bindings.readyComputes[e]={compute:a,handler:c},a()}return t.Control._action.apply(this,arguments)}}},{setup:function(e,n){return this.scope=n.scope,this.viewModel=n.viewModel,t.Control.prototype.setup.call(this,e,n)},off:function(){this._bindings&&t.each(this._bindings.readyComputes||{},function(t){t.compute.unbind("change",t.handler)}),t.Control.prototype.off.apply(this,arguments),this._bindings.readyComputes={}}}),c=t.$;return c.fn&&(c.fn.scope=c.fn.viewModel=function(){return t.viewModel.apply(t,[this].concat(t.makeArray(arguments)))}),s}); +/*can@2.2.6#model/model*/ +define("can/model/model",["can/util/util","can/map/map","can/list/list"],function(t){var e=function(e,r,i){var n=new t.Deferred;return e.then(function(){var e=t.makeArray(arguments),s=!0;try{e[0]=i.apply(r,e)}catch(o){s=!1,n.rejectWith(n,[o].concat(e))}s&&n.resolveWith(n,e)},function(){n.rejectWith(this,arguments)}),"function"==typeof e.abort&&(n.abort=function(){return e.abort()}),n},r=0,i=function(e){return t.__observe(e,e.constructor.id),e.__get(e.constructor.id)},n=function(e,r,i,n,s,o){var a={};if("string"==typeof e){var u=e.split(/\s+/);a.url=u.pop(),u.length&&(a.type=u.pop())}else t.extend(a,e);return a.data="object"!=typeof r||t.isArray(r)?r:t.extend(a.data||{},r),a.url=t.sub(a.url,a.data,!0),t.ajax(t.extend({type:i||"post",dataType:n||"json",success:s,error:o},a))},s=function(r,n,s,o,a){var u;t.isArray(r)?(u=r[1],r=r[0]):u=r.serialize(),u=[u];var c,l,d=r.constructor;return("update"===n||"destroy"===n)&&u.unshift(i(r)),l=d[n].apply(d,u),c=e(l,r,function(t){return r[a||n+"d"](t,l),r}),l.abort&&(c.abort=function(){l.abort()}),c.then(s,o),c},o={models:function(e,r,i){if(t.Model._reqs++,e){if(e instanceof this.List)return e;var n=this,s=[],o=n.List||f,a=r instanceof t.List?r:new o,u=e instanceof f,c=u?e.serialize():e;if(c=n.parseModels(c,i),c.data&&(e=c,c=c.data),"undefined"==typeof c||!t.isArray(c))throw new Error("Could not get any raw data while converting using .models");return a.length&&a.splice(0),t.each(c,function(t){s.push(n.model(t,i))}),a.push.apply(a,s),t.isArray(e)||t.each(e,function(t,e){"data"!==e&&a.attr(e,t)}),setTimeout(t.proxy(this._clean,this),1),a}},model:function(e,r,i){if(e){e="function"==typeof e.serialize?e.serialize():this.parseModel(e,i);var n=e[this.id];(n||0===n)&&this.store[n]&&(r=this.store[n]);var s=r&&t.isFunction(r.attr)?r.attr(e,this.removeAttr||!1):new this(e);return s}}},a={parseModel:function(e){return function(r){return e?t.getObject(e,r):r}},parseModels:function(e){return function(r){if(t.isArray(r))return r;e=e||"data";var i=t.getObject(e,r);if(!t.isArray(i))throw new Error("Could not get any raw data while converting using .models");return i}}},u={create:{url:"_shortName",type:"post"},update:{data:function(e,r){r=r||{};var i=this.id;return r[i]&&r[i]!==e&&(r["new"+t.capitalize(e)]=r[i],delete r[i]),r[i]=e,r},type:"put"},destroy:{type:"delete",data:function(t,e){return e=e||{},e.id=e[this.id]=t,e}},findAll:{url:"_shortName"},findOne:{}},c=function(t,e){return function(r){return r=t.data?t.data.apply(this,arguments):r,n(e||this[t.url||"_url"],r,t.type||"get")}},l=function(t,e){if(t.resource){var r=t.resource.replace(/\/+$/,"");return"findAll"===e||"create"===e?r:r+"/{"+t.id+"}"}};t.Model=t.Map.extend({fullName:"can.Model",_reqs:0,setup:function(e,i,n,s){if("string"!=typeof i&&(s=n,n=i),s||(s=n),this.store={},t.Map.setup.apply(this,arguments),t.Model){n&&n.List?(this.List=n.List,this.List.Map=this):this.List=e.List.extend({Map:this},{});var d=this,p=t.proxy(this._clean,d);t.each(u,function(r,i){if(n&&n[i]&&("string"==typeof n[i]||"object"==typeof n[i])?d[i]=c(r,n[i]):n&&n.resource&&!t.isFunction(n[i])&&(d[i]=c(r,l(d,i))),d["make"+t.capitalize(i)]){var s=d["make"+t.capitalize(i)](d[i]);t.Construct._overwrite(d,e,i,function(){t.Model._reqs++;var e=s.apply(this,arguments),r=e.then(p,p);return r.abort=e.abort,r})}});var h={};t.each(o,function(r,i){var s="parse"+t.capitalize(i),o=n&&n[i]||d[i];"string"==typeof o?(d[s]=o,t.Construct._overwrite(d,e,i,r)):n&&n[i]&&(h[s]=!0)}),t.each(a,function(r,i){var s=n&&n[i]||d[i];if("string"==typeof s)t.Construct._overwrite(d,e,i,r(s));else if(!(n&&t.isFunction(n[i])||d[i])){var o=r();o.useModelConverter=h[i],t.Construct._overwrite(d,e,i,o)}}),"can.Model"!==d.fullName&&d.fullName||(d.fullName="Model"+ ++r),t.Model._reqs=0,this._url=this._shortName+"/{"+this.id+"}"}},_ajax:c,_makeRequest:s,_clean:function(){if(t.Model._reqs--,!t.Model._reqs)for(var e in this.store)this.store[e]._bindings||delete this.store[e];return arguments[0]},models:o.models,model:o.model},{setup:function(e){var r=e&&e[this.constructor.id];t.Model._reqs&&null!=r&&(this.constructor.store[r]=this),t.Map.prototype.setup.apply(this,arguments)},isNew:function(){var t=i(this);return!(t||0===t)},save:function(t,e){return s(this,this.isNew()?"create":"update",t,e)},destroy:function(e,r){if(this.isNew()){var i=this,n=t.Deferred();return n.then(e,r),n.done(function(t){i.destroyed(t)}).resolve(i)}return s(this,"destroy",e,r,"destroyed")},_bindsetup:function(){var e=this.__get(this.constructor.id);return null!=e&&(this.constructor.store[e]=this),t.Map.prototype._bindsetup.apply(this,arguments)},_bindteardown:function(){return delete this.constructor.store[i(this)],t.Map.prototype._bindteardown.apply(this,arguments)},___set:function(e,r){t.Map.prototype.___set.call(this,e,r),e===this.constructor.id&&this._bindings&&(this.constructor.store[i(this)]=this)}});var d=function(t){return function(e,r,i){return this[t](e,null,i)}},p=function(t){return this.parseModel.useModelConverter?this.model(t):this.parseModel(t)},h={makeFindAll:d("models"),makeFindOne:d("model"),makeCreate:p,makeUpdate:p,makeDestroy:p};t.each(h,function(r,i){t.Model[i]=function(i){return function(){var n=t.makeArray(arguments),s=t.isFunction(n[1])?n.splice(0,1):n.splice(0,2),o=e(i.apply(this,s),this,r);return o.then(n[0],n[1]),o}}}),t.each(["created","updated","destroyed"],function(e){t.Model.prototype[e]=function(r){var i=this,n=i.constructor;r&&"object"==typeof r&&this.attr(t.isFunction(r.attr)?r.attr():r),t.dispatch.call(this,{type:"change",target:this},[e]),t.dispatch.call(n,e,[this])}});var f=t.Model.List=t.List.extend({_bubbleRule:function(e,r){var i=t.List._bubbleRule(e,r);return i.push("destroyed"),i}},{setup:function(e){t.isPlainObject(e)&&!t.isArray(e)?(t.List.prototype.setup.apply(this),this.replace(t.isDeferred(e)?e:this.constructor.Map.findAll(e))):t.List.prototype.setup.apply(this,arguments),this._init=1,this.bind("destroyed",t.proxy(this._destroyed,this)),delete this._init},_destroyed:function(t,e){if(/\w+/.test(e))for(var r;(r=this.indexOf(t.target))>-1;)this.splice(r,1)}});return t.Model}); +/*can@2.2.6#util/string/deparam/deparam*/ +define("can/util/string/deparam/deparam",["can/util/util","can/util/string/string"],function(t){var n=/^\d+$/,e=/([^\[\]]+)|(\[\])/g,r=/([^?#]*)(#.*)?$/,i=function(t){return decodeURIComponent(t.replace(/\+/g," "))};return t.extend(t,{deparam:function(a){var u,c,o={};return a&&r.test(a)&&(u=a.split("&"),t.each(u,function(t){var r=t.split("="),a=i(r.shift()),u=i(r.join("=")),p=o;if(a){r=a.match(e);for(var s=0,d=r.length-1;d>s;s++)p[r[s]]||(p[r[s]]=n.test(r[s+1])||"[]"===r[s+1]?[]:{}),p=p[r[s]];c=r.pop(),"[]"===c?p.push(u):p[c]=u}})),o}}),t}); +/*can@2.2.6#route/route*/ +define("can/route/route",["can/util/util","can/map/map","can/list/list","can/util/string/deparam/deparam"],function(t){var e,r,n,a,u=/\:([\w\.]+)/g,o=/^(?:&[^=]+=[^&]*)+/,i=function(e){var r=[];return t.each(e,function(e,n){r.push(("className"===n?"class":n)+'="'+("href"===n?e:t.esc(e))+'"')}),r.join(" ")},c=function(t,e){var r=0,n=0,a={};for(var u in t.defaults)t.defaults[u]===e[u]&&(a[u]=1,r++);for(;no&&(n=t,o=a),a>=l?!1:void 0}),t.route.routes[i]&&c(t.route.routes[i],e)===o&&(n=t.route.routes[i]),n){var s,h=f({},e),p=n.route.replace(u,function(t,r){return delete h[r],e[r]===n.defaults[r]?"":encodeURIComponent(e[r])}).replace("\\","");return d(n.defaults,function(t,e){h[e]===t&&delete h[e]}),s=t.param(h),r&&t.route.attr("route",n.route),p+(s?t.route._call("querySeparator")+s:"")}return t.isEmptyObject(e)?"":t.route._call("querySeparator")+t.param(e)},deparam:function(e){var r=t.route._call("root");r.lastIndexOf("/")===r.length-1&&0===e.indexOf("/")&&(e=e.substr(1));var n={length:-1},a=t.route._call("querySeparator"),u=t.route._call("paramsMatcher");if(d(t.route.routes,function(t,r){t.test.test(e)&&t.length>n.length&&(n=t)}),n.length>-1){var o=e.match(n.test),i=o.shift(),c=e.substr(i.length-(o[o.length-1]===a?1:0)),l=c&&u.test(c)?t.deparam(c.slice(1)):{};return l=f(!0,{},n.defaults,l),d(o,function(t,e){t&&t!==a&&(l[n.names[e]]=decodeURIComponent(t))}),l.route=n.route,l}return e.charAt(0)!==a&&(e=a+e),u.test(e)?t.deparam(e.slice(1)):{}},data:new t.Map({}),map:function(e){var r;r=e.prototype instanceof t.Map?new e:e,t.route.data=r},routes:{},ready:function(e){return e!==!0&&(t.route._setup(),t.route.setState()),t.route},url:function(e,r){return r&&(e=t.extend({},t.route.deparam(t.route._call("matchingPartOfURL")),e)),t.route._call("root")+t.route.param(e)},link:function(e,r,n,a){return""+e+""},current:function(e){return t.__observe(_,"__url"),this._call("matchingPartOfURL")===t.route.param(e)},bindings:{hashchange:{paramsMatcher:o,querySeparator:"&",matchSlashes:!1,bind:function(){t.bind.call(window,"hashchange",b)},unbind:function(){t.unbind.call(window,"hashchange",b)},matchingPartOfURL:function(){return l.href.split(/#!?/)[1]||""},setURL:function(t){return l.hash!=="#"+t&&(l.hash="!"+t),t},root:"#!"}},defaultBinding:"hashchange",currentBinding:null,_setup:function(){t.route.currentBinding||(t.route._call("bind"),t.route.bind("change",m),t.route.currentBinding=t.route.defaultBinding)},_teardown:function(){t.route.currentBinding&&(t.route._call("unbind"),t.route.unbind("change",m),t.route.currentBinding=null),clearTimeout(e),a=0},_call:function(){var e=t.makeArray(arguments),r=e.shift(),n=t.route.bindings[t.route.currentBinding||t.route.defaultBinding],a=n[r];return a.apply?a.apply(n,e):a}}),d(["bind","unbind","on","off","delegate","undelegate","removeAttr","compute","_get","__get","each"],function(e){t.route[e]=function(){return t.route.data[e]?t.route.data[e].apply(t.route.data,arguments):void 0}}),t.route.attr=function(e,r){var n,a=typeof e;return n=void 0===r?arguments:"string"!==a&&"number"!==a?[h(e),r]:[e,h(r)],t.route.data.attr.apply(t.route.data,n)};var b=t.route.setState=function(){var e=t.route._call("matchingPartOfURL"),u=r;r=t.route.deparam(e),a&&e===n||(t.batch.start(),v(u,r,t.route.data),t.route.attr(r),t.batch.trigger(_,"__url",[e,n]),t.batch.stop())},v=function(t,e,r){for(var n in t)void 0===e[n]?r.removeAttr(n):"[object Object]"===Object.prototype.toString.call(t[n])&&v(t[n],e[n],r.attr(n))};return t.route}); +/*can@2.2.6#control/route/route*/ +define("can/control/route/route",["can/util/util","can/route/route","can/control/control"],function(t){return t.Control.processors.route=function(o,r,u,n,e){u=u||"",t.route.routes[u]||("/"===u[0]&&(u=u.substring(1)),t.route(u));var c,i=function(o,r,i){if(t.route.attr("route")===u&&(void 0===o.batchNum||o.batchNum!==c)){c=o.batchNum;var a=t.route.attr();delete a.route,t.isFunction(e[n])?e[n](a):e[e[n]](a)}};return t.route.bind("change",i),function(){t.route.unbind("change",i)}},t}); +/*[global-shim-end]*/ +!function(){window._define=window.define,window.define=window.define.orig}(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.zepto.dev.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.zepto.dev.js new file mode 100644 index 0000000000..e46d99ac67 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.zepto.dev.js @@ -0,0 +1,7212 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#util/can*/ +define('can/util/can', [], function () { + var glbl = typeof window !== 'undefined' ? window : global; + var can = {}; + if (typeof GLOBALCAN === 'undefined' || GLOBALCAN !== false) { + glbl.can = can; + } + can.global = glbl; + can.k = function () { + }; + can.isDeferred = can.isPromise = function (obj) { + return obj && typeof obj.then === 'function' && typeof obj.pipe === 'function'; + }; + can.isMapLike = function (obj) { + return can.Map && (obj instanceof can.Map || obj && obj.__get); + }; + var cid = 0; + can.cid = function (object, name) { + if (!object._cid) { + cid++; + object._cid = (name || '') + cid; + } + return object._cid; + }; + can.VERSION = '2.2.6'; + can.simpleExtend = function (d, s) { + for (var prop in s) { + d[prop] = s[prop]; + } + return d; + }; + can.last = function (arr) { + return arr && arr[arr.length - 1]; + }; + var protoBind = Function.prototype.bind; + if (protoBind) { + can.proxy = function (fn, context) { + return protoBind.call(fn, context); + }; + } else { + can.proxy = function (fn, context) { + return function () { + return fn.apply(context, arguments); + }; + }; + } + can.frag = function (item) { + var frag; + if (!item || typeof item === 'string') { + frag = can.buildFragment(item == null ? '' : '' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } else if (item.nodeType === 11) { + return item; + } else if (typeof item.nodeType === 'number') { + frag = document.createDocumentFragment(); + frag.appendChild(item); + return frag; + } else if (typeof item.length === 'number') { + frag = document.createDocumentFragment(); + can.each(item, function (item) { + frag.appendChild(can.frag(item)); + }); + return frag; + } else { + frag = can.buildFragment('' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } + }; + can.scope = can.viewModel = function (el, attr, val) { + el = can.$(el); + var scope = can.data(el, 'scope') || can.data(el, 'viewModel'); + if (!scope) { + scope = new can.Map(); + can.data(el, 'scope', scope); + can.data(el, 'viewModel', scope); + } + switch (arguments.length) { + case 0: + case 1: + return scope; + case 2: + return scope.attr(attr); + default: + scope.attr(attr, val); + return el; + } + }; + can['import'] = function (moduleName) { + var deferred = new can.Deferred(); + if (typeof window.System === 'object' && can.isFunction(window.System['import'])) { + window.System['import'](moduleName).then(can.proxy(deferred.resolve, deferred), can.proxy(deferred.reject, deferred)); + } else if (window.define && window.define.amd) { + window.require([moduleName], function (value) { + deferred.resolve(value); + }); + } else if (window.steal) { + steal.steal(moduleName, function (value) { + deferred.resolve(value); + }); + } else if (window.require) { + deferred.resolve(window.require(moduleName)); + } else { + deferred.resolve(); + } + return deferred.promise(); + }; + can.__observe = function () { + }; + can.dev = { + warnTimeout: 5000, + logLevel: 0, + warn: function (out) { + var ll = this.logLevel; + if (ll < 2) { + Array.prototype.unshift.call(arguments, 'WARN:'); + if (typeof window !== undefined && window.console && console.warn) { + this._logger('warn', Array.prototype.slice.call(arguments)); + } else if (window.console && console.log) { + this._logger('log', Array.prototype.slice.call(arguments)); + } else if (window.opera && window.opera.postError) { + window.opera.postError('steal.js WARNING: ' + out); + } + } + }, + log: function (out) { + var ll = this.logLevel; + if (ll < 1) { + if (window.console && console.log) { + Array.prototype.unshift.call(arguments, 'Info:'); + this._logger('log', Array.prototype.slice.call(arguments)); + } else if (window.opera && window.opera.postError) { + window.opera.postError('steal.js INFO: ' + out); + } + } + }, + _logger: function (type, arr) { + if (console.log.apply) { + console[type].apply(console, arr); + } else { + console[type](arr); + } + } + }; + return can; +}); +/*can@2.2.6#util/attr/attr*/ +define('can/util/attr/attr', ['can/util/can'], function (can) { + var setImmediate = can.global.setImmediate || function (cb) { + return setTimeout(cb, 0); + }, attr = { + MutationObserver: can.global.MutationObserver || can.global.WebKitMutationObserver || can.global.MozMutationObserver, + map: { + 'class': 'className', + 'value': 'value', + 'innertext': 'innerText', + 'textcontent': 'textContent', + 'checked': true, + 'disabled': true, + 'readonly': true, + 'required': true, + src: function (el, val) { + if (val == null || val === '') { + el.removeAttribute('src'); + return null; + } else { + el.setAttribute('src', val); + return val; + } + }, + style: function (el, val) { + return el.style.cssText = val || ''; + } + }, + defaultValue: [ + 'input', + 'textarea' + ], + set: function (el, attrName, val) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var tagName = el.nodeName.toString().toLowerCase(), prop = attr.map[attrName], newValue; + if (typeof prop === 'function') { + newValue = prop(el, val); + } else if (prop === true) { + newValue = el[attrName] = true; + if (attrName === 'checked' && el.type === 'radio') { + if (can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultChecked = true; + } + } + } else if (prop) { + newValue = val; + if (el[prop] !== val) { + el[prop] = val; + } + if (prop === 'value' && can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultValue = val; + } + } else { + el.setAttribute(attrName, val); + newValue = val; + } + if (!attr.MutationObserver && newValue !== oldValue) { + attr.trigger(el, attrName, oldValue); + } + }, + trigger: function (el, attrName, oldValue) { + if (can.data(can.$(el), 'canHasAttributesBindings')) { + attrName = attrName.toLowerCase(); + return setImmediate(function () { + can.trigger(el, { + type: 'attributes', + attributeName: attrName, + target: el, + oldValue: oldValue, + bubbles: false + }, []); + }); + } + }, + get: function (el, attrName) { + attrName = attrName.toLowerCase(); + var prop = attr.map[attrName]; + if (typeof prop === 'string' && el[prop]) { + return el[prop]; + } + return el.getAttribute(attrName); + }, + remove: function (el, attrName) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var setter = attr.map[attrName]; + if (typeof setter === 'function') { + setter(el, undefined); + } + if (setter === true) { + el[attrName] = false; + } else if (typeof setter === 'string') { + el[setter] = ''; + } else { + el.removeAttribute(attrName); + } + if (!attr.MutationObserver && oldValue != null) { + attr.trigger(el, attrName, oldValue); + } + }, + has: function () { + var el = can.global.document && document.createElement('div'); + if (el && el.hasAttribute) { + return function (el, name) { + return el.hasAttribute(name); + }; + } else { + return function (el, name) { + return el.getAttribute(name) !== null; + }; + } + }() + }; + return attr; +}); +/*can@2.2.6#event/event*/ +define('can/event/event', ['can/util/can'], function (can) { + can.addEvent = function (event, handler) { + var allEvents = this.__bindEvents || (this.__bindEvents = {}), eventList = allEvents[event] || (allEvents[event] = []); + eventList.push({ + handler: handler, + name: event + }); + return this; + }; + can.listenTo = function (other, event, handler) { + var idedEvents = this.__listenToEvents; + if (!idedEvents) { + idedEvents = this.__listenToEvents = {}; + } + var otherId = can.cid(other); + var othersEvents = idedEvents[otherId]; + if (!othersEvents) { + othersEvents = idedEvents[otherId] = { + obj: other, + events: {} + }; + } + var eventsEvents = othersEvents.events[event]; + if (!eventsEvents) { + eventsEvents = othersEvents.events[event] = []; + } + eventsEvents.push(handler); + can.bind.call(other, event, handler); + }; + can.stopListening = function (other, event, handler) { + var idedEvents = this.__listenToEvents, iterIdedEvents = idedEvents, i = 0; + if (!idedEvents) { + return this; + } + if (other) { + var othercid = can.cid(other); + (iterIdedEvents = {})[othercid] = idedEvents[othercid]; + if (!idedEvents[othercid]) { + return this; + } + } + for (var cid in iterIdedEvents) { + var othersEvents = iterIdedEvents[cid], eventsEvents; + other = idedEvents[cid].obj; + if (!event) { + eventsEvents = othersEvents.events; + } else { + (eventsEvents = {})[event] = othersEvents.events[event]; + } + for (var eventName in eventsEvents) { + var handlers = eventsEvents[eventName] || []; + i = 0; + while (i < handlers.length) { + if (handler && handler === handlers[i] || !handler) { + can.unbind.call(other, eventName, handlers[i]); + handlers.splice(i, 1); + } else { + i++; + } + } + if (!handlers.length) { + delete othersEvents.events[eventName]; + } + } + if (can.isEmptyObject(othersEvents.events)) { + delete idedEvents[cid]; + } + } + return this; + }; + can.removeEvent = function (event, fn, __validate) { + if (!this.__bindEvents) { + return this; + } + var events = this.__bindEvents[event] || [], i = 0, ev, isFunction = typeof fn === 'function'; + while (i < events.length) { + ev = events[i]; + if (__validate ? __validate(ev, event, fn) : isFunction && ev.handler === fn || !isFunction && (ev.cid === fn || !fn)) { + events.splice(i, 1); + } else { + i++; + } + } + return this; + }; + can.dispatch = function (event, args) { + var events = this.__bindEvents; + if (!events) { + return; + } + if (typeof event === 'string') { + event = { type: event }; + } + var eventName = event.type, handlers = (events[eventName] || []).slice(0), passed = [event]; + if (args) { + passed.push.apply(passed, args); + } + for (var i = 0, len = handlers.length; i < len; i++) { + handlers[i].handler.apply(this, passed); + } + return event; + }; + can.one = function (event, handler) { + var one = function () { + can.unbind.call(this, event, one); + return handler.apply(this, arguments); + }; + can.bind.call(this, event, one); + return this; + }; + can.event = { + on: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.on.call(this); + } else { + return can.addEvent.apply(this, arguments); + } + }, + off: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.off.call(this); + } else { + return can.removeEvent.apply(this, arguments); + } + }, + bind: can.addEvent, + unbind: can.removeEvent, + delegate: function (selector, event, handler) { + return can.addEvent.call(this, event, handler); + }, + undelegate: function (selector, event, handler) { + return can.removeEvent.call(this, event, handler); + }, + trigger: can.dispatch, + one: can.one, + addEvent: can.addEvent, + removeEvent: can.removeEvent, + listenTo: can.listenTo, + stopListening: can.stopListening, + dispatch: can.dispatch + }; + return can.event; +}); +/*can@2.2.6#util/object/isplain/isplain*/ +define('can/util/object/isplain/isplain', ['can/util/can'], function () { + var core_hasOwn = Object.prototype.hasOwnProperty, isWindow = function (obj) { + return obj !== null && obj == obj.window; + }, isPlainObject = function (obj) { + if (!obj || typeof obj !== 'object' || obj.nodeType || isWindow(obj)) { + return false; + } + try { + if (obj.constructor && !core_hasOwn.call(obj, 'constructor') && !core_hasOwn.call(obj.constructor.prototype, 'isPrototypeOf')) { + return false; + } + } catch (e) { + return false; + } + var key; + for (key in obj) { + } + return key === undefined || core_hasOwn.call(obj, key); + }; + can.isPlainObject = isPlainObject; + return can; +}); +/*can@2.2.6#util/fragment*/ +define('can/util/fragment', ['can/util/can'], function (can) { + var fragmentRE = /^\s*<(\w+)[^>]*>/, toString = {}.toString, fragment = function (html, name) { + if (name === undefined) { + name = fragmentRE.test(html) && RegExp.$1; + } + if (html && toString.call(html.replace) === '[object Function]') { + html = html.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, '<$1>'); + } + var container = document.createElement('div'), temp = document.createElement('div'); + if (name === 'tbody' || name === 'tfoot' || name === 'thead') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; + } else if (name === 'tr') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild; + } else if (name === 'td' || name === 'th') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild.firstChild; + } else if (name === 'option') { + temp.innerHTML = ''; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; + } else { + container.innerHTML = '' + html; + } + var tmp = {}, children = container.childNodes; + tmp.length = children.length; + for (var i = 0; i < children.length; i++) { + tmp[i] = children[i]; + } + return [].slice.call(tmp); + }; + can.buildFragment = function (html, nodes) { + if (html && html.nodeType === 11) { + return html; + } + var parts = fragment(html), frag = document.createDocumentFragment(); + for (var i = 0, length = parts.length; i < length; i++) { + frag.appendChild(parts[i]); + } + return frag; + }; + (function () { + var text = '<-\n>', frag = can.buildFragment(text, document); + if (text !== frag.childNodes[0].nodeValue) { + var oldBuildFragment = can.buildFragment; + can.buildFragment = function (html, nodes) { + var res = oldBuildFragment(html, nodes); + if (res.childNodes.length === 1 && res.childNodes[0].nodeType === 3) { + res.childNodes[0].nodeValue = html; + } + return res; + }; + } + }()); + return can; +}); +/*can@2.2.6#util/deferred*/ +define('can/util/deferred', ['can/util/can'], function (can) { + var extend = function (target, src) { + for (var key in src) { + if (src.hasOwnProperty(key)) { + target[key] = src[key]; + } + } + }, Deferred = function (func) { + if (!(this instanceof Deferred)) { + return new Deferred(); + } + this._doneFuncs = []; + this._failFuncs = []; + this._resultArgs = null; + this._status = ''; + if (func) { + func.call(this, this); + } + }; + can.Deferred = Deferred; + can.when = Deferred.when = function () { + var args = can.makeArray(arguments); + if (args.length < 2) { + var obj = args[0]; + if (obj && (can.isFunction(obj.isResolved) && can.isFunction(obj.isRejected))) { + return obj; + } else { + return Deferred().resolve(obj); + } + } else { + var df = Deferred(), done = 0, rp = []; + can.each(args, function (arg, j) { + arg.done(function () { + rp[j] = arguments.length < 2 ? arguments[0] : arguments; + if (++done === args.length) { + df.resolve.apply(df, rp); + } + }).fail(function () { + df.reject(arguments.length === 1 ? arguments[0] : arguments); + }); + }); + return df; + } + }; + var resolveFunc = function (type, _status) { + return function (context) { + var args = this._resultArgs = arguments.length > 1 ? arguments[1] : []; + return this.exec(context, this[type], args, _status); + }; + }, doneFunc = function doneFunc(type, _status) { + return function () { + var self = this; + can.each(Array.prototype.slice.call(arguments), function (v, i, args) { + if (!v) { + return; + } + if (v.constructor === Array) { + doneFunc.apply(self, v); + } else { + if (self._status === _status) { + v.apply(self, self._resultArgs || []); + } + self[type].push(v); + } + }); + return this; + }; + }; + var isDeferred = function (obj) { + return obj && obj.then && obj.fail && obj.done; + }; + var wire = function (parentDeferred, result, setter, value) { + if (isDeferred(result)) { + result.done(can.proxy(parentDeferred.resolve, parentDeferred)).fail(can.proxy(parentDeferred.reject, parentDeferred)); + } else { + setter.call(parentDeferred, result !== undefined ? result : value); + } + }; + extend(Deferred.prototype, { + then: function (done, fail) { + var d = can.Deferred(), resolve = d.resolve, reject = d.reject; + this.done(function (value) { + if (typeof done === 'function') { + wire(d, done.apply(this, arguments), resolve, value); + } else { + resolve.apply(d, arguments); + } + }); + this.fail(function (value) { + if (typeof fail === 'function') { + wire(d, fail.apply(this, arguments), reject, value); + } else { + reject.apply(d, arguments); + } + }); + return d; + }, + resolveWith: resolveFunc('_doneFuncs', 'rs'), + rejectWith: resolveFunc('_failFuncs', 'rj'), + done: doneFunc('_doneFuncs', 'rs'), + fail: doneFunc('_failFuncs', 'rj'), + always: function () { + var args = can.makeArray(arguments); + if (args.length && args[0]) { + this.done(args[0]).fail(args[0]); + } + return this; + }, + state: function () { + switch (this._status) { + case 'rs': + return 'resolved'; + case 'rj': + return 'rejected'; + default: + return 'pending'; + } + }, + isResolved: function () { + return this._status === 'rs'; + }, + isRejected: function () { + return this._status === 'rj'; + }, + reject: function () { + return this.rejectWith(this, arguments); + }, + resolve: function () { + return this.resolveWith(this, arguments); + }, + exec: function (context, dst, args, st) { + if (this._status !== '') { + return this; + } + this._status = st; + can.each(dst, function (d) { + if (typeof d.apply === 'function') { + d.apply(context, args); + } + }); + return this; + }, + promise: function () { + var promise = this.then(); + promise.reject = promise.resolve = undefined; + return promise; + } + }); + Deferred.prototype.pipe = Deferred.prototype.then; + return can; +}); +/*can@2.2.6#util/array/each*/ +define('can/util/array/each', ['can/util/can'], function (can) { + var isArrayLike = function (obj) { + var length = 'length' in obj && obj.length; + return typeof arr !== 'function' && (length === 0 || typeof length === 'number' && length > 0 && length - 1 in obj); + }; + can.each = function (elements, callback, context) { + var i = 0, key, len, item; + if (elements) { + if (isArrayLike(elements)) { + if (can.List && elements instanceof can.List) { + for (len = elements.attr('length'); i < len; i++) { + item = elements.attr(i); + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } else { + for (len = elements.length; i < len; i++) { + item = elements[i]; + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } + } else if (typeof elements === 'object') { + if (can.Map && elements instanceof can.Map || elements === can.route) { + var keys = can.Map.keys(elements); + for (i = 0, len = keys.length; i < len; i++) { + key = keys[i]; + item = elements.attr(key); + if (callback.call(context || item, item, key, elements) === false) { + break; + } + } + } else { + for (key in elements) { + if (elements.hasOwnProperty(key) && callback.call(context || elements[key], elements[key], key, elements) === false) { + break; + } + } + } + } + } + return elements; + }; + return can; +}); +/*can@2.2.6#util/inserted/inserted*/ +define('can/util/inserted/inserted', ['can/util/can'], function (can) { + can.inserted = function (elems) { + elems = can.makeArray(elems); + var inDocument = false, doc = can.$(document.contains ? document : document.body), children; + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + if (!inDocument) { + if (elem.getElementsByTagName) { + if (can.has(doc, elem).length) { + inDocument = true; + } else { + return; + } + } else { + continue; + } + } + if (inDocument && elem.getElementsByTagName) { + children = can.makeArray(elem.getElementsByTagName('*')); + can.trigger(elem, 'inserted', [], false); + for (var j = 0, child; (child = children[j]) !== undefined; j++) { + can.trigger(child, 'inserted', [], false); + } + } + } + }; + can.appendChild = function (el, child) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.appendChild(child); + can.inserted(children); + }; + can.insertBefore = function (el, child, ref) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.insertBefore(child, ref); + can.inserted(children); + }; +}); +/*can@2.2.6#util/util*/ +define('can/util/util', [ + 'can/util/can', + 'can/util/attr/attr', + 'can/event/event', + 'can/zepto/zepto', + 'can/util/object/isplain/isplain', + 'can/util/fragment', + 'can/util/deferred', + 'can/util/array/each', + 'can/util/inserted/inserted' +], function (can, attr, event) { + var $ = Zepto; + var data = {}, dataAttr = $.fn.data, uuid = $.uuid = +new Date(), exp = $.expando = 'Zepto' + uuid; + function getData(node, name) { + var id = node[exp], store = id && data[id]; + return name === undefined ? store || setData(node) : store && store[name] || dataAttr.call($(node), name); + } + function setData(node, name, value) { + var id = node[exp] || (node[exp] = ++uuid), store = data[id] || (data[id] = {}); + if (name !== undefined) { + store[name] = value; + } + return store; + } + $.fn.data = function (name, value) { + return value === undefined ? this.length === 0 ? undefined : getData(this[0], name) : this.each(function (idx) { + setData(this, name, $.isFunction(value) ? value.call(this, idx, getData(this, name)) : value); + }); + }; + $.cleanData = function (elems) { + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + can.trigger(elem, 'removed', [], false); + } + for (i = 0; (elem = elems[i]) !== undefined; i++) { + var id = elem[exp]; + delete data[id]; + } + }; + var oldEach = can.each; + var oldPlain = can.isPlainObject; + $.extend(can, Zepto); + can.inArray = function (el, arr) { + return !arr ? -1 : $.inArray.apply($, arguments); + }; + can.isPlainObject = oldPlain; + can.each = oldEach; + can.attr = attr; + can.event = event; + var arrHas = function (obj, name) { + return obj[0] && obj[0][name] || obj[name]; + }; + can.trigger = function (obj, event, args, bubble) { + if (obj.trigger) { + obj.trigger(event, args); + } else if (arrHas(obj, 'dispatchEvent')) { + if (bubble === false) { + $([obj]).triggerHandler(event, args); + } else { + $([obj]).trigger(event, args); + } + } else { + if (typeof event === 'string') { + event = { type: event }; + } + event.target = event.target || obj; + can.dispatch.call(obj, event, can.makeArray(args)); + } + }; + can.$ = Zepto; + can.bind = function (ev, cb) { + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (arrHas(this, 'addEventListener')) { + $([this]).bind(ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + return this; + }; + can.unbind = function (ev, cb) { + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (arrHas(this, 'addEventListener')) { + $([this]).unbind(ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + return this; + }; + can.on = can.bind; + can.off = can.unbind; + can.delegate = function (selector, ev, cb) { + if (!selector) { + can.bind.call(this, ev, cb); + } else if (this.delegate) { + this.delegate(selector, ev, cb); + } else if (arrHas(this, 'addEventListener')) { + $([this]).delegate(selector, ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + }; + can.undelegate = function (selector, ev, cb) { + if (!selector) { + can.unbind.call(this, ev, cb); + } else if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else if (arrHas(this, 'addEventListener')) { + $([this]).undelegate(selector, ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + }; + $.each([ + 'append', + 'filter', + 'addClass', + 'remove', + 'data', + 'has' + ], function (i, name) { + can[name] = function (wrapped) { + return wrapped[name].apply(wrapped, can.makeArray(arguments).slice(1)); + }; + }); + can.makeArray = function (arr) { + var ret = []; + if (arr == null) { + return []; + } + if (arr.length === undefined || typeof arr === 'string') { + return [arr]; + } + can.each(arr, function (a, i) { + ret[i] = a; + }); + return ret; + }; + var XHR = $.ajaxSettings.xhr; + $.ajaxSettings.xhr = function () { + var xhr = XHR(); + var open = xhr.open; + xhr.open = function (type, url, async) { + open.call(this, type, url, ASYNC === undefined ? true : ASYNC); + }; + return xhr; + }; + var ASYNC; + var AJAX = $.ajax; + var updateDeferred = function (xhr, d) { + for (var prop in xhr) { + if (typeof d[prop] === 'function') { + d[prop] = function () { + xhr[prop].apply(xhr, arguments); + }; + } else { + d[prop] = prop[xhr]; + } + } + }; + can.ajax = function (options) { + var success = options.success, error = options.error; + var d = can.Deferred(); + options.success = function (data) { + updateDeferred(xhr, d); + d.resolve.call(d, data); + if (success) { + success.apply(this, arguments); + } + }; + options.error = function () { + updateDeferred(xhr, d); + d.reject.apply(d, arguments); + if (error) { + error.apply(this, arguments); + } + }; + if (options.async === false) { + ASYNC = false; + } + var xhr = AJAX(options); + ASYNC = undefined; + updateDeferred(xhr, d); + return d; + }; + var $_empty = $.fn.empty; + $.fn.empty = function () { + this.each(function () { + $.cleanData(this.getElementsByTagName('*')); + this.innerHTML = ''; + }); + return $_empty.call(this); + }; + var $_remove = $.fn.remove; + $.fn.remove = function () { + this.each(function () { + if (this.getElementsByTagName) { + $.cleanData([this].concat(can.makeArray(this.getElementsByTagName('*')))); + } + }); + return $_remove.call(this); + }; + can.trim = function (str) { + return str.trim(); + }; + can.isEmptyObject = function (object) { + var name; + for (name in object) { + } + return name === undefined; + }; + can.extend = function (first) { + if (first === true) { + var args = can.makeArray(arguments); + args.shift(); + return $.extend.apply($, args); + } + return $.extend.apply($, arguments); + }; + can.get = function (wrapped, index) { + return wrapped[index]; + }; + can.each([ + 'after', + 'prepend', + 'before', + 'append' + ], function (name) { + var original = Zepto.fn[name]; + Zepto.fn[name] = function () { + var elems, args = can.makeArray(arguments); + if (args[0] != null) { + if (typeof args[0] === 'string') { + args[0] = $.zepto.fragment(args[0]); + } + if (args[0].nodeType === 11) { + elems = can.makeArray(args[0].childNodes); + } else if (args[0] instanceof Zepto.fn.constructor) { + elems = can.makeArray(args[0]); + } else { + elems = [args[0]]; + } + } + var ret = original.apply(this, args); + can.inserted(elems); + return ret; + }; + }); + delete attr.MutationObserver; + var oldAttr = $.fn.attr; + $.fn.attr = function (attrName, value) { + var isString = typeof attrName === 'string', oldValue, newValue; + if (value !== undefined && isString) { + oldValue = oldAttr.call(this, attrName); + } + var res = oldAttr.apply(this, arguments); + if (value !== undefined && isString) { + newValue = oldAttr.call(this, attrName); + } + if (newValue !== oldValue) { + can.attr.trigger(this[0], attrName, oldValue); + } + return res; + }; + var oldRemove = $.fn.removeAttr; + $.fn.removeAttr = function (attrName) { + var oldValue = oldAttr.call(this, attrName), res = oldRemove.apply(this, arguments); + if (oldValue != null) { + can.attr.trigger(this[0], attrName, oldValue); + } + return res; + }; + var oldBind = $.fn.bind, oldUnbind = $.fn.unbind; + $.fn.bind = function (event) { + if (event === 'attributes') { + this.each(function () { + var el = can.$(this); + can.data(el, 'canHasAttributesBindings', (can.data(el, 'canHasAttributesBindings') || 0) + 1); + }); + } + return oldBind.apply(this, arguments); + }; + $.fn.unbind = function (event) { + if (event === 'attributes') { + this.each(function () { + var el = can.$(this), cur = can.data(el, 'canHasAttributesBindings') || 0; + if (cur <= 0) { + can.data(el, 'canHasAttributesBindings', 0); + } else { + can.data(el, 'canHasAttributesBindings', cur - 1); + } + }); + } + return oldUnbind.apply(this, arguments); + }; + return can; +}); +/*can@2.2.6#view/view*/ +define('can/view/view', ['can/util/util'], function (can) { + var isFunction = can.isFunction, makeArray = can.makeArray, hookupId = 1; + var makeRenderer = function (textRenderer) { + var renderer = function () { + return $view.frag(textRenderer.apply(this, arguments)); + }; + renderer.render = function () { + return textRenderer.apply(textRenderer, arguments); + }; + return renderer; + }; + var checkText = function (text, url) { + if (!text.length) { + can.dev.log('can/view/view.js: There is no template or an empty template at ' + url); + throw 'can.view: No template or empty template:' + url; + } + }; + var getRenderer = function (obj, async) { + if (isFunction(obj)) { + var def = can.Deferred(); + return def.resolve(obj); + } + var url = typeof obj === 'string' ? obj : obj.url, suffix = obj.engine && '.' + obj.engine || url.match(/\.[\w\d]+$/), type, el, id; + if (url.match(/^#/)) { + url = url.substr(1); + } + if (el = document.getElementById(url)) { + suffix = '.' + el.type.match(/\/(x\-)?(.+)/)[2]; + } + if (!suffix && !$view.cached[url]) { + url += suffix = $view.ext; + } + if (can.isArray(suffix)) { + suffix = suffix[0]; + } + id = $view.toId(url); + if (url.match(/^\/\//)) { + url = url.substr(2); + url = !window.steal ? url : steal.config().root.mapJoin('' + steal.id(url)); + } + if (window.require) { + if (require.toUrl) { + url = require.toUrl(url); + } + } + type = $view.types[suffix]; + if ($view.cached[id]) { + return $view.cached[id]; + } else if (el) { + return $view.registerView(id, el.innerHTML, type); + } else { + var d = new can.Deferred(); + can.ajax({ + async: async, + url: url, + dataType: 'text', + error: function (jqXHR) { + checkText('', url); + d.reject(jqXHR); + }, + success: function (text) { + checkText(text, url); + $view.registerView(id, text, type, d); + } + }); + return d; + } + }; + var getDeferreds = function (data) { + var deferreds = []; + if (can.isDeferred(data)) { + return [data]; + } else { + for (var prop in data) { + if (can.isDeferred(data[prop])) { + deferreds.push(data[prop]); + } + } + } + return deferreds; + }; + var usefulPart = function (resolved) { + return can.isArray(resolved) && resolved[1] === 'success' ? resolved[0] : resolved; + }; + var $view = can.view = can.template = function (view, data, helpers, callback) { + if (isFunction(helpers)) { + callback = helpers; + helpers = undefined; + } + return $view.renderAs('fragment', view, data, helpers, callback); + }; + can.extend($view, { + frag: function (result, parentNode) { + return $view.hookup($view.fragment(result), parentNode); + }, + fragment: function (result) { + if (typeof result !== 'string' && result.nodeType === 11) { + return result; + } + var frag = can.buildFragment(result, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + }, + toId: function (src) { + return can.map(src.toString().split(/\/|\./g), function (part) { + if (part) { + return part; + } + }).join('_'); + }, + toStr: function (txt) { + return txt == null ? '' : '' + txt; + }, + hookup: function (fragment, parentNode) { + var hookupEls = [], id, func; + can.each(fragment.childNodes ? can.makeArray(fragment.childNodes) : fragment, function (node) { + if (node.nodeType === 1) { + hookupEls.push(node); + hookupEls.push.apply(hookupEls, can.makeArray(node.getElementsByTagName('*'))); + } + }); + can.each(hookupEls, function (el) { + if (el.getAttribute && (id = el.getAttribute('data-view-id')) && (func = $view.hookups[id])) { + func(el, parentNode, id); + delete $view.hookups[id]; + el.removeAttribute('data-view-id'); + } + }); + return fragment; + }, + hookups: {}, + hook: function (cb) { + $view.hookups[++hookupId] = cb; + return ' data-view-id=\'' + hookupId + '\''; + }, + cached: {}, + cachedRenderers: {}, + cache: true, + register: function (info) { + this.types['.' + info.suffix] = info; + if (typeof window !== 'undefined' && window.steal && steal.type) { + steal.type(info.suffix + ' view js', function (options, success, error) { + var type = $view.types['.' + options.type], id = $view.toId(options.id + ''); + options.text = type.script(id, options.text); + success(); + }); + } + can[info.suffix] = $view[info.suffix] = function (id, text) { + var renderer, renderFunc; + if (!text) { + renderFunc = function () { + if (!renderer) { + if (info.fragRenderer) { + renderer = info.fragRenderer(null, id); + } else { + renderer = makeRenderer(info.renderer(null, id)); + } + } + return renderer.apply(this, arguments); + }; + renderFunc.render = function () { + var textRenderer = info.renderer(null, id); + return textRenderer.apply(textRenderer, arguments); + }; + return renderFunc; + } + var registeredRenderer = function () { + if (!renderer) { + if (info.fragRenderer) { + renderer = info.fragRenderer(id, text); + } else { + renderer = info.renderer(id, text); + } + } + return renderer.apply(this, arguments); + }; + if (info.fragRenderer) { + return $view.preload(id, registeredRenderer); + } else { + return $view.preloadStringRenderer(id, registeredRenderer); + } + }; + }, + types: {}, + ext: '.ejs', + registerScript: function (type, id, src) { + return 'can.view.preloadStringRenderer(\'' + id + '\',' + $view.types['.' + type].script(id, src) + ');'; + }, + preload: function (id, renderer) { + var def = $view.cached[id] = new can.Deferred().resolve(function (data, helpers) { + return renderer.call(data, data, helpers); + }); + def.__view_id = id; + $view.cachedRenderers[id] = renderer; + return renderer; + }, + preloadStringRenderer: function (id, stringRenderer) { + return this.preload(id, makeRenderer(stringRenderer)); + }, + render: function (view, data, helpers, callback) { + return can.view.renderAs('string', view, data, helpers, callback); + }, + renderTo: function (format, renderer, data, helpers) { + return (format === 'string' && renderer.render ? renderer.render : renderer)(data, helpers); + }, + renderAs: function (format, view, data, helpers, callback) { + if (isFunction(helpers)) { + callback = helpers; + helpers = undefined; + } + var deferreds = getDeferreds(data); + var reading, deferred, dataCopy, async, response; + if (deferreds.length) { + deferred = new can.Deferred(); + dataCopy = can.extend({}, data); + deferreds.push(getRenderer(view, true)); + can.when.apply(can, deferreds).then(function (resolved) { + var objs = makeArray(arguments), renderer = objs.pop(), result; + if (can.isDeferred(data)) { + dataCopy = usefulPart(resolved); + } else { + for (var prop in data) { + if (can.isDeferred(data[prop])) { + dataCopy[prop] = usefulPart(objs.shift()); + } + } + } + result = can.view.renderTo(format, renderer, dataCopy, helpers); + deferred.resolve(result, dataCopy); + if (callback) { + callback(result, dataCopy); + } + }, function () { + deferred.reject.apply(deferred, arguments); + }); + return deferred; + } else { + reading = can.__clearReading(); + async = isFunction(callback); + deferred = getRenderer(view, async); + if (reading) { + can.__setReading(reading); + } + if (async) { + response = deferred; + deferred.then(function (renderer) { + callback(data ? can.view.renderTo(format, renderer, data, helpers) : renderer); + }); + } else { + if (deferred.state() === 'resolved' && deferred.__view_id) { + var currentRenderer = $view.cachedRenderers[deferred.__view_id]; + return data ? can.view.renderTo(format, currentRenderer, data, helpers) : currentRenderer; + } else { + deferred.then(function (renderer) { + response = data ? can.view.renderTo(format, renderer, data, helpers) : renderer; + }); + } + } + return response; + } + }, + registerView: function (id, text, type, def) { + var info = typeof type === 'object' ? type : $view.types[type || $view.ext], renderer; + if (info.fragRenderer) { + renderer = info.fragRenderer(id, text); + } else { + renderer = makeRenderer(info.renderer(id, text)); + } + def = def || new can.Deferred(); + if ($view.cache) { + $view.cached[id] = def; + def.__view_id = id; + $view.cachedRenderers[id] = renderer; + } + return def.resolve(renderer); + } + }); + if (typeof window !== 'undefined' && window.steal && steal.type) { + steal.type('view js', function (options, success, error) { + var type = $view.types['.' + options.type], id = $view.toId(options.id); + var dependency = type.plugin || 'can/view/' + options.type, preload = type.fragRenderer ? 'preload' : 'preloadStringRenderer'; + options.text = 'steal(\'can/view\',\'' + dependency + '\',function(can){return ' + 'can.view.' + preload + '(\'' + id + '\',' + options.text + ');\n})'; + success(); + }); + } + return can; +}); +/*can@2.2.6#view/callbacks/callbacks*/ +define('can/view/callbacks/callbacks', [ + 'can/util/util', + 'can/view/view' +], function (can) { + var attr = can.view.attr = function (attributeName, attrHandler) { + if (attrHandler) { + if (typeof attributeName === 'string') { + attributes[attributeName] = attrHandler; + } else { + regExpAttributes.push({ + match: attributeName, + handler: attrHandler + }); + } + } else { + var cb = attributes[attributeName]; + if (!cb) { + for (var i = 0, len = regExpAttributes.length; i < len; i++) { + var attrMatcher = regExpAttributes[i]; + if (attrMatcher.match.test(attributeName)) { + cb = attrMatcher.handler; + break; + } + } + } + return cb; + } + }; + var attributes = {}, regExpAttributes = [], automaticCustomElementCharacters = /[-\:]/; + var tag = can.view.tag = function (tagName, tagHandler) { + if (tagHandler) { + if (typeof tags[tagName.toLowerCase()] !== 'undefined') { + can.dev.warn('Custom tag: ' + tagName.toLowerCase() + ' is already defined'); + } + if (can.global.html5) { + can.global.html5.elements += ' ' + tagName; + can.global.html5.shivDocument(); + } + tags[tagName.toLowerCase()] = tagHandler; + } else { + var cb = tags[tagName.toLowerCase()]; + if (!cb && automaticCustomElementCharacters.test(tagName)) { + cb = function () { + }; + } + return cb; + } + }; + var tags = {}; + can.view.callbacks = { + _tags: tags, + _attributes: attributes, + _regExpAttributes: regExpAttributes, + tag: tag, + attr: attr, + tagHandler: function (el, tagName, tagData) { + var helperTagCallback = tagData.options.attr('tags.' + tagName), tagCallback = helperTagCallback || tags[tagName]; + var scope = tagData.scope, res; + if (tagCallback) { + var reads = can.__clearReading(); + res = tagCallback(el, tagData); + can.__setReading(reads); + } else { + res = scope; + } + if (!tagCallback) { + can.dev.warn('can/view/scanner.js: No custom element found for ' + tagName); + } + if (res && tagData.subtemplate) { + if (scope !== res) { + scope = scope.add(res); + } + var result = tagData.subtemplate(scope, tagData.options); + var frag = typeof result === 'string' ? can.view.frag(result) : result; + can.appendChild(el, frag); + } + } + }; + return can.view.callbacks; +}); +/*can@2.2.6#view/elements*/ +define('can/view/elements', [ + 'can/util/util', + 'can/view/view' +], function (can) { + var doc = typeof document !== 'undefined' ? document : null; + var selectsCommentNodes = doc && function () { + return can.$(document.createComment('~')).length === 1; + }(); + var elements = { + tagToContentPropMap: { + option: doc && 'textContent' in document.createElement('option') ? 'textContent' : 'innerText', + textarea: 'value' + }, + attrMap: can.attr.map, + attrReg: /([^\s=]+)[\s]*=[\s]*/, + defaultValue: can.attr.defaultValue, + tagMap: { + '': 'span', + colgroup: 'col', + table: 'tbody', + tr: 'td', + ol: 'li', + ul: 'li', + tbody: 'tr', + thead: 'tr', + tfoot: 'tr', + select: 'option', + optgroup: 'option' + }, + reverseTagMap: { + col: 'colgroup', + tr: 'tbody', + option: 'select', + td: 'tr', + th: 'tr', + li: 'ul' + }, + getParentNode: function (el, defaultParentNode) { + return defaultParentNode && el.parentNode.nodeType === 11 ? defaultParentNode : el.parentNode; + }, + setAttr: can.attr.set, + getAttr: can.attr.get, + removeAttr: can.attr.remove, + contentText: function (text) { + if (typeof text === 'string') { + return text; + } + if (!text && text !== 0) { + return ''; + } + return '' + text; + }, + after: function (oldElements, newFrag) { + var last = oldElements[oldElements.length - 1]; + if (last.nextSibling) { + can.insertBefore(last.parentNode, newFrag, last.nextSibling); + } else { + can.appendChild(last.parentNode, newFrag); + } + }, + replace: function (oldElements, newFrag) { + elements.after(oldElements, newFrag); + if (can.remove(can.$(oldElements)).length < oldElements.length && !selectsCommentNodes) { + can.each(oldElements, function (el) { + if (el.nodeType === 8) { + el.parentNode.removeChild(el); + } + }); + } + } + }; + can.view.elements = elements; + return elements; +}); +/*can@2.2.6#util/string/string*/ +define('can/util/string/string', ['can/util/util'], function (can) { + var strUndHash = /_|-/, strColons = /\=\=/, strWords = /([A-Z]+)([A-Z][a-z])/g, strLowUp = /([a-z\d])([A-Z])/g, strDash = /([a-z\d])([A-Z])/g, strReplacer = /\{([^\}]+)\}/g, strQuote = /"/g, strSingleQuote = /'/g, strHyphenMatch = /-+(.)?/g, strCamelMatch = /[a-z][A-Z]/g, getNext = function (obj, prop, add) { + var result = obj[prop]; + if (result === undefined && add === true) { + result = obj[prop] = {}; + } + return result; + }, isContainer = function (current) { + return /^f|^o/.test(typeof current); + }, convertBadValues = function (content) { + var isInvalid = content === null || content === undefined || isNaN(content) && '' + content === 'NaN'; + return '' + (isInvalid ? '' : content); + }; + can.extend(can, { + esc: function (content) { + return convertBadValues(content).replace(/&/g, '&').replace(//g, '>').replace(strQuote, '"').replace(strSingleQuote, '''); + }, + getObject: function (name, roots, add) { + var parts = name ? name.split('.') : [], length = parts.length, current, r = 0, i, container, rootsLength; + roots = can.isArray(roots) ? roots : [roots || window]; + rootsLength = roots.length; + if (!length) { + return roots[0]; + } + for (r; r < rootsLength; r++) { + current = roots[r]; + container = undefined; + for (i = 0; i < length && isContainer(current); i++) { + container = current; + current = getNext(container, parts[i]); + } + if (container !== undefined && current !== undefined) { + break; + } + } + if (add === false && current !== undefined) { + delete container[parts[i - 1]]; + } + if (add === true && current === undefined) { + current = roots[0]; + for (i = 0; i < length && isContainer(current); i++) { + current = getNext(current, parts[i], true); + } + } + return current; + }, + capitalize: function (s, cache) { + return s.charAt(0).toUpperCase() + s.slice(1); + }, + camelize: function (str) { + return convertBadValues(str).replace(strHyphenMatch, function (match, chr) { + return chr ? chr.toUpperCase() : ''; + }); + }, + hyphenate: function (str) { + return convertBadValues(str).replace(strCamelMatch, function (str, offset) { + return str.charAt(0) + '-' + str.charAt(1).toLowerCase(); + }); + }, + underscore: function (s) { + return s.replace(strColons, '/').replace(strWords, '$1_$2').replace(strLowUp, '$1_$2').replace(strDash, '_').toLowerCase(); + }, + sub: function (str, data, remove) { + var obs = []; + str = str || ''; + obs.push(str.replace(strReplacer, function (whole, inside) { + var ob = can.getObject(inside, data, remove === true ? false : undefined); + if (ob === undefined || ob === null) { + obs = null; + return ''; + } + if (isContainer(ob) && obs) { + obs.push(ob); + return ''; + } + return '' + ob; + })); + return obs === null ? obs : obs.length <= 1 ? obs[0] : obs; + }, + replacer: strReplacer, + undHash: strUndHash + }); + return can; +}); +/*can@2.2.6#construct/construct*/ +define('can/construct/construct', ['can/util/string/string'], function (can) { + var initializing = 0; + var canGetDescriptor; + try { + Object.getOwnPropertyDescriptor({}); + canGetDescriptor = true; + } catch (e) { + canGetDescriptor = false; + } + var getDescriptor = function (newProps, name) { + var descriptor = Object.getOwnPropertyDescriptor(newProps, name); + if (descriptor && (descriptor.get || descriptor.set)) { + return descriptor; + } + return null; + }, inheritGetterSetter = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + var descriptor; + for (var name in newProps) { + if (descriptor = getDescriptor(newProps, name)) { + this._defineProperty(addTo, oldProps, name, descriptor); + } else { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + } + }, simpleInherit = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + for (var name in newProps) { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + }; + can.Construct = function () { + if (arguments.length) { + return can.Construct.extend.apply(can.Construct, arguments); + } + }; + can.extend(can.Construct, { + constructorExtends: true, + newInstance: function () { + var inst = this.instance(), args; + if (inst.setup) { + args = inst.setup.apply(inst, arguments); + } + if (inst.init) { + inst.init.apply(inst, args || arguments); + } + return inst; + }, + _inherit: canGetDescriptor ? inheritGetterSetter : simpleInherit, + _defineProperty: function (what, oldProps, propName, descriptor) { + Object.defineProperty(what, propName, descriptor); + }, + _overwrite: function (what, oldProps, propName, val) { + what[propName] = val; + }, + setup: function (base, fullName) { + this.defaults = can.extend(true, {}, base.defaults, this.defaults); + }, + instance: function () { + initializing = 1; + var inst = new this(); + initializing = 0; + return inst; + }, + extend: function (name, staticProperties, instanceProperties) { + var fullName = name, klass = staticProperties, proto = instanceProperties; + if (typeof fullName !== 'string') { + proto = klass; + klass = fullName; + fullName = null; + } + if (!proto) { + proto = klass; + klass = null; + } + proto = proto || {}; + var _super_class = this, _super = this.prototype, Constructor, parts, current, _fullName, _shortName, propName, shortName, namespace, prototype; + prototype = this.instance(); + can.Construct._inherit(proto, _super, prototype); + if (fullName) { + parts = fullName.split('.'); + shortName = parts.pop(); + } + var constructorName = shortName ? shortName.replace(/;/g, '') : 'Constructor'; + eval('Constructor = function ' + constructorName + '() { return init.apply(this, arguments); }'); + if (typeof constructorName === 'undefined') { + Constructor = function () { + return init.apply(this, arguments); + }; + } + function init() { + if (!initializing) { + if (this.constructor !== Constructor && arguments.length && Constructor.constructorExtends) { + can.dev.warn('can/construct/construct.js: extending a can.Construct without calling extend'); + } + return this.constructor !== Constructor && arguments.length && Constructor.constructorExtends ? Constructor.extend.apply(Constructor, arguments) : Constructor.newInstance.apply(Constructor, arguments); + } + } + for (propName in _super_class) { + if (_super_class.hasOwnProperty(propName)) { + Constructor[propName] = _super_class[propName]; + } + } + can.Construct._inherit(klass, _super_class, Constructor); + if (fullName) { + current = can.getObject(parts.join('.'), window, true); + namespace = current; + _fullName = can.underscore(fullName.replace(/\./g, '_')); + _shortName = can.underscore(shortName); + if (current[shortName]) { + can.dev.warn('can/construct/construct.js: There\'s already something called ' + fullName); + } + current[shortName] = Constructor; + } + can.extend(Constructor, { + constructor: Constructor, + prototype: prototype, + namespace: namespace, + _shortName: _shortName, + fullName: fullName, + _fullName: _fullName + }); + if (shortName !== undefined) { + Constructor.shortName = shortName; + } + Constructor.prototype.constructor = Constructor; + var t = [_super_class].concat(can.makeArray(arguments)), args = Constructor.setup.apply(Constructor, t); + if (Constructor.init) { + Constructor.init.apply(Constructor, args || t); + } + return Constructor; + } + }); + can.Construct.prototype.setup = function () { + }; + can.Construct.prototype.init = function () { + }; + return can.Construct; +}); +/*can@2.2.6#control/control*/ +define('can/control/control', [ + 'can/util/util', + 'can/construct/construct' +], function (can) { + var bind = function (el, ev, callback) { + can.bind.call(el, ev, callback); + return function () { + can.unbind.call(el, ev, callback); + }; + }, isFunction = can.isFunction, extend = can.extend, each = can.each, slice = [].slice, paramReplacer = /\{([^\}]+)\}/g, special = can.getObject('$.event.special', [can]) || {}, delegate = function (el, selector, ev, callback) { + can.delegate.call(el, selector, ev, callback); + return function () { + can.undelegate.call(el, selector, ev, callback); + }; + }, binder = function (el, ev, callback, selector) { + return selector ? delegate(el, can.trim(selector), ev, callback) : bind(el, ev, callback); + }, basicProcessor; + var Control = can.Control = can.Construct({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Control) { + var control = this, funcName; + control.actions = {}; + for (funcName in control.prototype) { + if (control._isAction(funcName)) { + control.actions[funcName] = control._action(funcName); + } + } + } + }, + _shifter: function (context, name) { + var method = typeof name === 'string' ? context[name] : name; + if (!isFunction(method)) { + method = context[method]; + } + return function () { + context.called = name; + return method.apply(context, [this.nodeName ? can.$(this) : this].concat(slice.call(arguments, 0))); + }; + }, + _isAction: function (methodName) { + var val = this.prototype[methodName], type = typeof val; + return methodName !== 'constructor' && (type === 'function' || type === 'string' && isFunction(this.prototype[val])) && !!(special[methodName] || processors[methodName] || /[^\w]/.test(methodName)); + }, + _action: function (methodName, options) { + paramReplacer.lastIndex = 0; + if (options || !paramReplacer.test(methodName)) { + var convertedName = options ? can.sub(methodName, this._lookup(options)) : methodName; + if (!convertedName) { + can.dev.log('can/control/control.js: No property found for handling ' + methodName); + return null; + } + var arr = can.isArray(convertedName), name = arr ? convertedName[1] : convertedName, parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: processors[event] || basicProcessor, + parts: [ + name, + parts.join(' '), + event + ], + delegate: arr ? convertedName[0] : undefined + }; + } + }, + _lookup: function (options) { + return [ + options, + window + ]; + }, + processors: {}, + defaults: {} + }, { + setup: function (element, options) { + var cls = this.constructor, pluginname = cls.pluginName || cls._fullName, arr; + this.element = can.$(element); + if (pluginname && pluginname !== 'can_control') { + this.element.addClass(pluginname); + } + arr = can.data(this.element, 'controls'); + if (!arr) { + arr = []; + can.data(this.element, 'controls', arr); + } + arr.push(this); + this.options = extend({}, cls.defaults, options); + this.on(); + return [ + this.element, + this.options + ]; + }, + on: function (el, selector, eventName, func) { + if (!el) { + this.off(); + var cls = this.constructor, bindings = this._bindings, actions = cls.actions, element = this.element, destroyCB = can.Control._shifter(this, 'destroy'), funcName, ready; + for (funcName in actions) { + if (actions.hasOwnProperty(funcName)) { + ready = actions[funcName] || cls._action(funcName, this.options, this); + if (ready) { + bindings.control[funcName] = ready.processor(ready.delegate || element, ready.parts[2], ready.parts[1], funcName, this); + } + } + } + can.bind.call(element, 'removed', destroyCB); + bindings.user.push(function (el) { + can.unbind.call(el, 'removed', destroyCB); + }); + return bindings.user.length; + } + if (typeof el === 'string') { + func = eventName; + eventName = selector; + selector = el; + el = this.element; + } + if (func === undefined) { + func = eventName; + eventName = selector; + selector = null; + } + if (typeof func === 'string') { + func = can.Control._shifter(this, func); + } + this._bindings.user.push(binder(el, eventName, func, selector)); + return this._bindings.user.length; + }, + off: function () { + var el = this.element[0], bindings = this._bindings; + if (bindings) { + each(bindings.user || [], function (value) { + value(el); + }); + each(bindings.control || {}, function (value) { + value(el); + }); + } + this._bindings = { + user: [], + control: {} + }; + }, + destroy: function () { + if (this.element === null) { + can.dev.warn('can/control/control.js: Control already destroyed'); + return; + } + var Class = this.constructor, pluginName = Class.pluginName || Class._fullName, controls; + this.off(); + if (pluginName && pluginName !== 'can_control') { + this.element.removeClass(pluginName); + } + controls = can.data(this.element, 'controls'); + controls.splice(can.inArray(this, controls), 1); + can.trigger(this, 'destroyed'); + this.element = null; + } + }); + var processors = can.Control.processors; + basicProcessor = function (el, event, selector, methodName, control) { + return binder(el, event, can.Control._shifter(control, methodName), selector); + }; + each([ + 'change', + 'click', + 'contextmenu', + 'dblclick', + 'keydown', + 'keyup', + 'keypress', + 'mousedown', + 'mousemove', + 'mouseout', + 'mouseover', + 'mouseup', + 'reset', + 'resize', + 'scroll', + 'select', + 'submit', + 'focusin', + 'focusout', + 'mouseenter', + 'mouseleave', + 'touchstart', + 'touchmove', + 'touchcancel', + 'touchend', + 'touchleave', + 'inserted', + 'removed' + ], function (v) { + processors[v] = basicProcessor; + }); + return Control; +}); +/*can@2.2.6#util/bind/bind*/ +define('can/util/bind/bind', ['can/util/util'], function (can) { + can.bindAndSetup = function () { + can.addEvent.apply(this, arguments); + if (!this._init) { + if (!this._bindings) { + this._bindings = 1; + if (this._bindsetup) { + this._bindsetup(); + } + } else { + this._bindings++; + } + } + return this; + }; + can.unbindAndTeardown = function (event, handler) { + var handlers = this.__bindEvents[event] || []; + var handlerCount = handlers.length; + can.removeEvent.apply(this, arguments); + if (this._bindings === null) { + this._bindings = 0; + } else { + this._bindings = this._bindings - (handlerCount - handlers.length); + } + if (!this._bindings && this._bindteardown) { + this._bindteardown(); + } + return this; + }; + return can; +}); +/*can@2.2.6#map/bubble*/ +define('can/map/bubble', ['can/util/util'], function (can) { + var bubble = can.bubble = { + event: function (map, boundEventName) { + return map.constructor._bubbleRule(boundEventName, map); + }, + childrenOf: function (parentMap, eventName) { + parentMap._each(function (child, prop) { + if (child && child.bind) { + bubble.toParent(child, parentMap, prop, eventName); + } + }); + }, + teardownChildrenFrom: function (parentMap, eventName) { + parentMap._each(function (child) { + bubble.teardownFromParent(parentMap, child, eventName); + }); + }, + toParent: function (child, parent, prop, eventName) { + can.listenTo.call(parent, child, eventName, function () { + var args = can.makeArray(arguments), ev = args.shift(); + args[0] = (can.List && parent instanceof can.List ? parent.indexOf(child) : prop) + (args[0] ? '.' + args[0] : ''); + ev.triggeredNS = ev.triggeredNS || {}; + if (ev.triggeredNS[parent._cid]) { + return; + } + ev.triggeredNS[parent._cid] = true; + can.trigger(parent, ev, args); + }); + }, + teardownFromParent: function (parent, child, eventName) { + if (child && child.unbind) { + can.stopListening.call(parent, child, eventName); + } + }, + isBubbling: function (parent, eventName) { + return parent._bubbleBindings && parent._bubbleBindings[eventName]; + }, + bind: function (parent, eventName) { + if (!parent._init) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + if (!parent._bubbleBindings) { + parent._bubbleBindings = {}; + } + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (!parent._bubbleBindings[bubbleEvent]) { + parent._bubbleBindings[bubbleEvent] = 1; + bubble.childrenOf(parent, bubbleEvent); + } else { + parent._bubbleBindings[bubbleEvent]++; + } + } + } + }, + unbind: function (parent, eventName) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (parent._bubbleBindings) { + parent._bubbleBindings[bubbleEvent]--; + } + if (parent._bubbleBindings && !parent._bubbleBindings[bubbleEvent]) { + delete parent._bubbleBindings[bubbleEvent]; + bubble.teardownChildrenFrom(parent, bubbleEvent); + if (can.isEmptyObject(parent._bubbleBindings)) { + delete parent._bubbleBindings; + } + } + } + }, + add: function (parent, child, prop) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + bubble.toParent(child, parent, prop, eventName); + } + } + } + }, + removeMany: function (parent, children) { + for (var i = 0, len = children.length; i < len; i++) { + bubble.remove(parent, children[i]); + } + }, + remove: function (parent, child) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + } + } + } + }, + set: function (parent, prop, value, current) { + if (can.Map.helpers.isObservable(value)) { + bubble.add(parent, value, prop); + } + if (can.Map.helpers.isObservable(current)) { + bubble.remove(parent, current); + } + return value; + } + }; + return bubble; +}); +/*can@2.2.6#util/batch/batch*/ +define('can/util/batch/batch', ['can/util/can'], function (can) { + var batchNum = 1, transactions = 0, batchEvents = [], stopCallbacks = [], currentBatchEvents = null; + can.batch = { + start: function (batchStopHandler) { + transactions++; + if (batchStopHandler) { + stopCallbacks.push(batchStopHandler); + } + }, + stop: function (force, callStart) { + if (force) { + transactions = 0; + } else { + transactions--; + } + if (transactions === 0) { + if (currentBatchEvents !== null) { + return; + } + currentBatchEvents = batchEvents.slice(0); + var callbacks = stopCallbacks.slice(0), i, len; + batchEvents = []; + stopCallbacks = []; + can.batch.batchNum = batchNum; + batchNum++; + if (callStart) { + can.batch.start(); + } + for (i = 0; i < currentBatchEvents.length; i++) { + can.dispatch.apply(currentBatchEvents[i][0], currentBatchEvents[i][1]); + } + currentBatchEvents = null; + for (i = 0, len = callbacks.length; i < callbacks.length; i++) { + callbacks[i](); + } + can.batch.batchNum = undefined; + } + }, + trigger: function (item, event, args) { + if (!item._init) { + event = typeof event === 'string' ? { type: event } : event; + if (currentBatchEvents) { + currentBatchEvents.push([ + item, + [ + event, + args + ] + ]); + } else if (transactions === 0) { + return can.dispatch.call(item, event, args); + } else { + event.batchNum = batchNum; + batchEvents.push([ + item, + [ + event, + args + ] + ]); + } + } + }, + afterPreviousEvents: function (handler) { + if (currentBatchEvents) { + var obj = {}; + can.bind.call(obj, 'ready', handler); + currentBatchEvents.push([ + obj, + [ + { type: 'ready' }, + [] + ] + ]); + } else { + handler(); + } + } + }; +}); +/*can@2.2.6#map/map*/ +define('can/map/map', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/map/bubble', + 'can/construct/construct', + 'can/util/batch/batch' +], function (can, bind, bubble) { + var madeMap = null; + var teardownMap = function () { + for (var cid in madeMap) { + if (madeMap[cid].added) { + delete madeMap[cid].obj._cid; + } + } + madeMap = null; + }; + var getMapFromObject = function (obj) { + return madeMap && madeMap[obj._cid] && madeMap[obj._cid].instance; + }; + var serializeMap = null; + var Map = can.Map = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Map) { + if (!this.defaults) { + this.defaults = {}; + } + this._computes = []; + if (this.prototype.define && !this.helpers.define) { + can.dev.warn('can/map/define is not included, yet there is a define property ' + 'used. You may want to add this plugin.'); + } + if (this.define && !this.helpers.define) { + can.dev.warn('The define property should be on the map\'s prototype properties, ' + 'not the static properies. Also, can/map/define is not included.'); + } + for (var prop in this.prototype) { + if (prop !== 'define' && prop !== 'constructor' && (typeof this.prototype[prop] !== 'function' || this.prototype[prop].prototype instanceof can.Construct)) { + this.defaults[prop] = this.prototype[prop]; + } else if (this.prototype[prop].isComputed) { + this._computes.push(prop); + } + } + if (this.helpers.define) { + this.helpers.define(this); + } + } + if (can.List && !(this.prototype instanceof can.List)) { + this.List = Map.List.extend({ Map: this }, {}); + } + }, + _bubble: bubble, + _bubbleRule: function (eventName) { + return eventName === 'change' || eventName.indexOf('.') >= 0 ? ['change'] : []; + }, + _computes: [], + bind: can.bindAndSetup, + on: can.bindAndSetup, + unbind: can.unbindAndTeardown, + off: can.unbindAndTeardown, + id: 'id', + helpers: { + define: null, + attrParts: function (attr, keepKey) { + if (keepKey) { + return [attr]; + } + return typeof attr === 'object' ? attr : ('' + attr).split('.'); + }, + addToMap: function (obj, instance) { + var teardown; + if (!madeMap) { + teardown = teardownMap; + madeMap = {}; + } + var hasCid = obj._cid; + var cid = can.cid(obj); + if (!madeMap[cid]) { + madeMap[cid] = { + obj: obj, + instance: instance, + added: !hasCid + }; + } + return teardown; + }, + isObservable: function (obj) { + return obj instanceof can.Map || obj && obj === can.route; + }, + canMakeObserve: function (obj) { + return obj && !can.isDeferred(obj) && (can.isArray(obj) || can.isPlainObject(obj)); + }, + serialize: function (map, how, where) { + var cid = can.cid(map), firstSerialize = false; + if (!serializeMap) { + firstSerialize = true; + serializeMap = { + attr: {}, + serialize: {} + }; + } + serializeMap[how][cid] = where; + map.each(function (val, name) { + var result, isObservable = Map.helpers.isObservable(val), serialized = isObservable && serializeMap[how][can.cid(val)]; + if (serialized) { + result = serialized; + } else { + if (how === 'serialize') { + result = Map.helpers._serialize(map, name, val); + } else { + result = Map.helpers._getValue(map, name, val, how); + } + } + if (result !== undefined) { + where[name] = result; + } + }); + can.__observe(map, '__keys'); + if (firstSerialize) { + serializeMap = null; + } + return where; + }, + _serialize: function (map, name, val) { + return Map.helpers._getValue(map, name, val, 'serialize'); + }, + _getValue: function (map, name, val, how) { + if (Map.helpers.isObservable(val)) { + return val[how](); + } else { + return val; + } + } + }, + keys: function (map) { + var keys = []; + can.__observe(map, '__keys'); + for (var keyName in map._data) { + keys.push(keyName); + } + return keys; + } + }, { + setup: function (obj) { + if (obj instanceof can.Map) { + obj = obj.serialize(); + } + this._data = {}; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + var defaultValues = this._setupDefaults(obj); + this._setupComputes(defaultValues); + var teardownMapping = obj && can.Map.helpers.addToMap(obj, this); + var data = can.extend(can.extend(true, {}, defaultValues), obj); + this.attr(data); + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + delete this._init; + }, + _setupComputes: function () { + var computes = this.constructor._computes; + for (var i = 0, len = computes.length, prop; i < len; i++) { + prop = computes[i]; + this[prop] = this[prop].clone(this); + this._computedBindings[prop] = { count: 0 }; + } + }, + _setupDefaults: function () { + return this.constructor.defaults || {}; + }, + _bindsetup: function () { + }, + _bindteardown: function () { + }, + _changes: function (ev, attr, how, newVal, oldVal) { + can.batch.trigger(this, { + type: attr, + batchNum: ev.batchNum, + target: ev.target + }, [ + newVal, + oldVal + ]); + }, + _triggerChange: function (attr, how, newVal, oldVal) { + if (bubble.isBubbling(this, 'change')) { + can.batch.trigger(this, { + type: 'change', + target: this + }, [ + attr, + how, + newVal, + oldVal + ]); + } else { + can.batch.trigger(this, attr, [ + newVal, + oldVal + ]); + } + if (how === 'remove' || how === 'add') { + can.batch.trigger(this, { + type: '__keys', + target: this + }); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var prop in data) { + if (data.hasOwnProperty(prop)) { + callback(data[prop], prop); + } + } + }, + attr: function (attr, val) { + var type = typeof attr; + if (type !== 'string' && type !== 'number') { + return this._attrs(attr, val); + } else if (arguments.length === 1) { + return this._get(attr); + } else { + this._set(attr, val); + return this; + } + }, + each: function () { + return can.each.apply(undefined, [this].concat(can.makeArray(arguments))); + }, + removeAttr: function (attr) { + var isList = can.List && this instanceof can.List, parts = can.Map.helpers.attrParts(attr), prop = parts.shift(), current = isList ? this[prop] : this._data[prop]; + if (parts.length && current) { + return current.removeAttr(parts); + } else { + if (typeof attr === 'string' && !!~attr.indexOf('.')) { + prop = attr; + } + this._remove(prop, current); + return current; + } + }, + _remove: function (prop, current) { + if (prop in this._data) { + delete this._data[prop]; + if (!(prop in this.constructor.prototype)) { + delete this[prop]; + } + this._triggerChange(prop, 'remove', undefined, current); + } + }, + _get: function (attr) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'); + if (dotIndex >= 0) { + var value = this.__get(attr); + if (value !== undefined) { + return value; + } + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + can.__observe(this, first); + var current = this.__get(first); + return current && current._get ? current._get(second) : undefined; + } else { + can.__observe(this, attr); + return this.__get(attr); + } + }, + __get: function (attr) { + if (attr) { + if (this._computedBindings[attr]) { + return this[attr](); + } else { + return this._data[attr]; + } + } else { + return this._data; + } + }, + __type: function (value, prop) { + if (!(value instanceof can.Map) && can.Map.helpers.canMakeObserve(value)) { + var cached = getMapFromObject(value); + if (cached) { + return cached; + } + if (can.isArray(value)) { + var List = can.List; + return new List(value); + } else { + var Map = this.constructor.Map || can.Map; + return new Map(value); + } + } + return value; + }, + _set: function (attr, value, keepKey) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'), current; + if (!keepKey && dotIndex >= 0) { + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + current = this._init ? undefined : this.__get(first); + if (Map.helpers.isObservable(current)) { + current._set(second, value); + } else { + throw 'can.Map: Object does not exist'; + } + } else { + if (this.__convert) { + value = this.__convert(attr, value); + } + current = this._init ? undefined : this.__get(attr); + this.__set(attr, this.__type(value, attr), current); + } + }, + __set: function (prop, value, current) { + if (value !== current) { + var changeType = current !== undefined || this.__get().hasOwnProperty(prop) ? 'set' : 'add'; + this.___set(prop, this.constructor._bubble.set(this, prop, value, current)); + if (!this._computedBindings[prop]) { + this._triggerChange(prop, changeType, value, current); + } + if (current) { + this.constructor._bubble.teardownFromParent(this, current); + } + } + }, + ___set: function (prop, val) { + if (this._computedBindings[prop]) { + this[prop](val); + } else { + this._data[prop] = val; + } + if (typeof this.constructor.prototype[prop] !== 'function' && !this._computedBindings[prop]) { + this[prop] = val; + } + }, + bind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (!computedBinding.count) { + computedBinding.count = 1; + var self = this; + computedBinding.handler = function (ev, newVal, oldVal) { + can.batch.trigger(self, { + type: eventName, + batchNum: ev.batchNum, + target: self + }, [ + newVal, + oldVal + ]); + }; + this[eventName].bind('change', computedBinding.handler); + } else { + computedBinding.count++; + } + } + this.constructor._bubble.bind(this, eventName); + return can.bindAndSetup.apply(this, arguments); + }, + unbind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (computedBinding.count === 1) { + computedBinding.count = 0; + this[eventName].unbind('change', computedBinding.handler); + delete computedBinding.handler; + } else { + computedBinding.count--; + } + } + this.constructor._bubble.unbind(this, eventName); + return can.unbindAndTeardown.apply(this, arguments); + }, + serialize: function () { + return can.Map.helpers.serialize(this, 'serialize', {}); + }, + _attrs: function (props, remove) { + if (props === undefined) { + return Map.helpers.serialize(this, 'attr', {}); + } + props = can.simpleExtend({}, props); + var prop, self = this, newVal; + can.batch.start(); + this.each(function (curVal, prop) { + if (prop === '_cid') { + return; + } + newVal = props[prop]; + if (newVal === undefined) { + if (remove) { + self.removeAttr(prop); + } + return; + } + if (self.__convert) { + newVal = self.__convert(prop, newVal); + } + if (Map.helpers.isObservable(newVal)) { + self.__set(prop, self.__type(newVal, prop), curVal); + } else if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + self.__set(prop, self.__type(newVal, prop), curVal); + } + delete props[prop]; + }); + for (prop in props) { + if (prop !== '_cid') { + newVal = props[prop]; + this._set(prop, newVal, true); + } + } + can.batch.stop(); + return this; + }, + compute: function (prop) { + if (can.isFunction(this.constructor.prototype[prop])) { + return can.compute(this[prop], this); + } else { + var reads = prop.split('.'), last = reads.length - 1, options = { args: [] }; + return can.compute(function (newVal) { + if (arguments.length) { + can.compute.read(this, reads.slice(0, last)).value.attr(reads[last], newVal); + } else { + return can.compute.read(this, reads, options).value; + } + }, this); + } + } + }); + Map.prototype.on = Map.prototype.bind; + Map.prototype.off = Map.prototype.unbind; + return Map; +}); +/*can@2.2.6#list/list*/ +define('can/list/list', [ + 'can/util/util', + 'can/map/map', + 'can/map/bubble' +], function (can, Map, bubble) { + var splice = [].splice, spliceRemovesProps = function () { + var obj = { + 0: 'a', + length: 1 + }; + splice.call(obj, 0, 1); + return !obj[0]; + }(); + var list = Map.extend({ Map: Map }, { + setup: function (instances, options) { + this.length = 0; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + this._setupComputes(); + instances = instances || []; + var teardownMapping; + if (can.isDeferred(instances)) { + this.replace(instances); + } else { + teardownMapping = instances.length && can.Map.helpers.addToMap(instances, this); + this.push.apply(this, can.makeArray(instances || [])); + } + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + can.simpleExtend(this, options); + delete this._init; + }, + _triggerChange: function (attr, how, newVal, oldVal) { + Map.prototype._triggerChange.apply(this, arguments); + var index = +attr; + if (!~('' + attr).indexOf('.') && !isNaN(index)) { + if (how === 'add') { + can.batch.trigger(this, how, [ + newVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else if (how === 'remove') { + can.batch.trigger(this, how, [ + oldVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else { + can.batch.trigger(this, how, [ + newVal, + index + ]); + } + } + }, + __get: function (attr) { + if (attr) { + if (this[attr] && this[attr].isComputed && can.isFunction(this.constructor.prototype[attr])) { + return this[attr](); + } else { + return this[attr]; + } + } else { + return this; + } + }, + __set: function (prop, value, current) { + prop = isNaN(+prop) || prop % 1 ? prop : +prop; + if (typeof prop === 'number' && prop > this.length - 1) { + var newArr = new Array(prop + 1 - this.length); + newArr[newArr.length - 1] = value; + this.push.apply(this, newArr); + return newArr; + } + return can.Map.prototype.__set.call(this, '' + prop, value, current); + }, + ___set: function (attr, val) { + this[attr] = val; + if (+attr >= this.length) { + this.length = +attr + 1; + } + }, + _remove: function (prop, current) { + if (isNaN(+prop)) { + delete this[prop]; + this._triggerChange(prop, 'remove', undefined, current); + } else { + this.splice(prop, 1); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var i = 0; i < data.length; i++) { + callback(data[i], i); + } + }, + serialize: function () { + return Map.helpers.serialize(this, 'serialize', []); + }, + splice: function (index, howMany) { + var args = can.makeArray(arguments), added = [], i, len, listIndex, allSame = args.length > 2; + index = index || 0; + for (i = 0, len = args.length - 2; i < len; i++) { + listIndex = i + 2; + args[listIndex] = this.__type(args[listIndex], listIndex); + added.push(args[listIndex]); + if (this[i + index] !== args[listIndex]) { + allSame = false; + } + } + if (allSame && this.length <= added.length) { + return added; + } + if (howMany === undefined) { + howMany = args[1] = this.length - index; + } + var removed = splice.apply(this, args); + if (!spliceRemovesProps) { + for (i = this.length; i < removed.length + this.length; i++) { + delete this[i]; + } + } + can.batch.start(); + if (howMany > 0) { + bubble.removeMany(this, removed); + this._triggerChange('' + index, 'remove', undefined, removed); + } + if (args.length > 2) { + for (i = 0, len = added.length; i < len; i++) { + bubble.set(this, i, added[i]); + } + this._triggerChange('' + index, 'add', added, removed); + } + can.batch.stop(); + return removed; + }, + _attrs: function (items, remove) { + if (items === undefined) { + return Map.helpers.serialize(this, 'attr', []); + } + items = can.makeArray(items); + can.batch.start(); + this._updateAttrs(items, remove); + can.batch.stop(); + }, + _updateAttrs: function (items, remove) { + var len = Math.min(items.length, this.length); + for (var prop = 0; prop < len; prop++) { + var curVal = this[prop], newVal = items[prop]; + if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + this._set(prop, newVal); + } else { + } + } + if (items.length > this.length) { + this.push.apply(this, items.slice(this.length)); + } else if (items.length < this.length && remove) { + this.splice(items.length); + } + } + }), getArgs = function (args) { + return args[0] && can.isArray(args[0]) ? args[0] : can.makeArray(args); + }; + can.each({ + push: 'length', + unshift: 0 + }, function (where, name) { + var orig = [][name]; + list.prototype[name] = function () { + var args = [], len = where ? this.length : 0, i = arguments.length, res, val; + while (i--) { + val = arguments[i]; + args[i] = bubble.set(this, i, this.__type(val, i)); + } + res = orig.apply(this, args); + if (!this.comparator || args.length) { + this._triggerChange('' + len, 'add', args, undefined); + } + return res; + }; + }); + can.each({ + pop: 'length', + shift: 0 + }, function (where, name) { + list.prototype[name] = function () { + if (!this.length) { + return undefined; + } + var args = getArgs(arguments), len = where && this.length ? this.length - 1 : 0; + var res = [][name].apply(this, args); + this._triggerChange('' + len, 'remove', undefined, [res]); + if (res && res.unbind) { + bubble.remove(this, res); + } + return res; + }; + }); + can.extend(list.prototype, { + indexOf: function (item, fromIndex) { + this.attr('length'); + return can.inArray(item, this, fromIndex); + }, + join: function () { + return [].join.apply(this.attr(), arguments); + }, + reverse: function () { + var list = [].reverse.call(can.makeArray(this)); + this.replace(list); + }, + slice: function () { + var temp = Array.prototype.slice.apply(this, arguments); + return new this.constructor(temp); + }, + concat: function () { + var args = []; + can.each(can.makeArray(arguments), function (arg, i) { + args[i] = arg instanceof can.List ? arg.serialize() : arg; + }); + return new this.constructor(Array.prototype.concat.apply(this.serialize(), args)); + }, + forEach: function (cb, thisarg) { + return can.each(this, cb, thisarg || this); + }, + replace: function (newList) { + if (can.isDeferred(newList)) { + newList.then(can.proxy(this.replace, this)); + } else { + this.splice.apply(this, [ + 0, + this.length + ].concat(can.makeArray(newList || []))); + } + return this; + }, + filter: function (callback, thisArg) { + var filteredList = new can.List(), self = this, filtered; + this.each(function (item, index, list) { + filtered = callback.call(thisArg | self, item, index, self); + if (filtered) { + filteredList.push(item); + } + }); + return filteredList; + } + }); + can.List = Map.List = list; + return can.List; +}); +/*can@2.2.6#compute/read*/ +define('can/compute/read', ['can/util/util'], function (can) { + var read = function (parent, reads, options) { + options = options || {}; + var state = { foundObservable: false }; + var cur = readValue(parent, 0, reads, options, state), type, prev, readLength = reads.length, i = 0; + while (i < readLength) { + prev = cur; + for (var r = 0, readersLength = read.propertyReaders.length; r < readersLength; r++) { + var reader = read.propertyReaders[r]; + if (reader.test(cur)) { + cur = reader.read(cur, reads[i], i, options, state); + break; + } + } + i = i + 1; + cur = readValue(cur, i, reads, options, state, prev); + type = typeof cur; + if (i < reads.length && (cur === null || type !== 'function' && type !== 'object')) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1, cur); + } + return { + value: undefined, + parent: prev + }; + } + } + if (cur === undefined) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1); + } + } + return { + value: cur, + parent: prev + }; + }; + var readValue = function (value, index, reads, options, state, prev) { + var usedValueReader; + do { + usedValueReader = false; + for (var i = 0, len = read.valueReaders.length; i < len; i++) { + if (read.valueReaders[i].test(value, index, reads, options)) { + value = read.valueReaders[i].read(value, index, reads, options, state, prev); + } + } + } while (usedValueReader); + return value; + }; + read.valueReaders = [ + { + name: 'compute', + test: function (value, i, reads, options) { + return value && value.isComputed; + }, + read: function (value, i, reads, options, state) { + if (options.isArgument && i === reads.length) { + return value; + } + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, i); + state.foundObservable = true; + } + return value instanceof can.Compute ? value.get() : value(); + } + }, + { + name: 'function', + test: function (value, i, reads, options) { + var type = typeof value; + return type === 'function' && !value.isComputed && (options.executeAnonymousFunctions || options.isArgument && i === reads.length) && !(can.Construct && value.prototype instanceof can.Construct) && !(can.route && value === can.route); + }, + read: function (value, i, reads, options, state, prev) { + if (options.isArgument && i === reads.length) { + return options.proxyMethods !== false ? can.proxy(value, prev) : value; + } + return value.call(prev); + } + } + ]; + read.propertyReaders = [ + { + name: 'map', + test: can.isMapLike, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + if (typeof value[prop] === 'function' && value.constructor.prototype[prop] === value[prop]) { + if (options.returnObserveMethods) { + return value[prop]; + } else if (prop === 'constructor' && value instanceof can.Construct || value[prop].prototype instanceof can.Construct) { + return value[prop]; + } else { + return value[prop].apply(value, options.args || []); + } + } else { + return value.attr(prop); + } + } + }, + { + name: 'promise', + test: function (value) { + return can.isPromise(value); + }, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + var observeData = value.__observeData; + if (!value.__observeData) { + observeData = value.__observeData = { + isPending: true, + state: 'pending', + isResolved: false, + isRejected: false, + value: undefined, + reason: undefined + }; + can.cid(observeData); + can.simpleExtend(observeData, can.event); + value.then(function (value) { + observeData.isPending = false; + observeData.isResolved = true; + observeData.value = value; + observeData.state = 'resolved'; + observeData.dispatch('state', [ + 'resolved', + 'pending' + ]); + }, function (reason) { + observeData.isPending = false; + observeData.isRejected = true; + observeData.reason = reason; + observeData.state = 'rejected'; + observeData.dispatch('state', [ + 'rejected', + 'pending' + ]); + }); + } + can.__observe(observeData, 'state'); + return prop in observeData ? observeData[prop] : value[prop]; + } + }, + { + name: 'object', + test: function () { + return true; + }, + read: function (value, prop) { + if (value == null) { + return undefined; + } else { + return value[prop]; + } + } + } + ]; + read.write = function (parent, key, value, options) { + options = options || {}; + if (can.isMapLike(parent)) { + if (!options.isArgument && parent._data && parent._data[key] && parent._data[key].isComputed) { + return parent._data[key](value); + } else { + return parent.attr(key, value); + } + } + if (parent[key] && parent[key].isComputed) { + return parent[key](value); + } + if (typeof parent === 'object') { + parent[key] = value; + } + }; + return read; +}); +/*can@2.2.6#compute/get_value_and_bind*/ +define('can/compute/get_value_and_bind', ['can/util/util'], function () { + function observe(func, context, oldInfo, onchanged) { + var info = getValueAndObserved(func, context), newObserveSet = info.observed, oldObserved = oldInfo.observed; + if (info.names !== oldInfo.names) { + bindNewSet(oldObserved, newObserveSet, onchanged); + unbindOldSet(oldObserved, onchanged); + } + can.batch.afterPreviousEvents(function () { + info.ready = true; + }); + return info; + } + var observedStack = []; + can.__isRecordingObserves = function () { + return observedStack.length; + }; + can.__observe = can.__reading = function (obj, event) { + if (observedStack.length) { + var name = obj._cid + '|' + event, top = observedStack[observedStack.length - 1]; + top.names += name; + top.observed[name] = { + obj: obj, + event: event + '' + }; + } + }; + can.__notObserve = function (fn) { + return function () { + var previousReads = can.__clearObserved(); + var res = fn.apply(this, arguments); + can.__setObserved(previousReads); + return res; + }; + }; + can.__clearObserved = can.__clearReading = function () { + if (observedStack.length) { + var ret = observedStack[observedStack.length - 1]; + observedStack[observedStack.length - 1] = { observed: {} }; + return ret; + } + }; + can.__setObserved = can.__setReading = function (o) { + if (observedStack.length) { + observedStack[observedStack.length - 1] = o; + } + }; + can.__addObserved = can.__addReading = function (o) { + if (observedStack.length) { + can.simpleExtend(observedStack[observedStack.length - 1], o); + } + }; + var getValueAndObserved = function (func, self) { + observedStack.push({ + names: '', + observed: {} + }); + var value = func.call(self); + var stackItem = observedStack.pop(); + stackItem.value = value; + return stackItem; + }; + var bindNewSet = function (oldObserved, newObserveSet, onchanged) { + for (var name in newObserveSet) { + bindOrPreventUnbinding(oldObserved, newObserveSet, name, onchanged); + } + }; + var bindOrPreventUnbinding = function (oldObserved, newObserveSet, name, onchanged) { + if (oldObserved[name]) { + delete oldObserved[name]; + } else { + var obEv = newObserveSet[name]; + obEv.obj.bind(obEv.event, onchanged); + } + }; + var unbindOldSet = function (oldObserved, onchanged) { + for (var name in oldObserved) { + var obEv = oldObserved[name]; + obEv.obj.unbind(obEv.event, onchanged); + } + }; + return observe; +}); +/*can@2.2.6#compute/proto_compute*/ +define('can/compute/proto_compute', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/compute/read', + 'can/compute/get_value_and_bind', + 'can/util/batch/batch' +], function (can, bind, read, getValueAndBind) { + var updateOnChange = function (compute, newValue, oldValue, batchNum) { + if (newValue !== oldValue) { + can.batch.trigger(compute, batchNum ? { + type: 'change', + batchNum: batchNum + } : 'change', [ + newValue, + oldValue + ]); + } + }; + var setupComputeHandlers = function (compute, func, context, singleBind) { + var readInfo, onchanged, batchNum; + singleBind = false; + return { + on: function (updater) { + var self = this; + if (!onchanged) { + onchanged = function (ev) { + if (readInfo.ready && compute.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + if (singleBind) { + newValue = func.call(context); + readInfo.value = newValue; + } else { + readInfo = getValueAndBind(func, context, readInfo, onchanged); + newValue = readInfo.value; + } + self.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }; + } + readInfo = getValueAndBind(func, context, { observed: {} }, onchanged); + if (singleBind) { + func = can.__notObserve(func); + } + compute.value = readInfo.value; + compute.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function (updater) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, onchanged); + } + } + }; + }; + var k = function () { + }; + var updater = function (newVal, oldVal, batchNum) { + this.value = newVal; + updateOnChange(this, newVal, oldVal, batchNum); + }, asyncGet = function (fn, context, lastSetValue) { + return function () { + return fn.call(context, lastSetValue.get()); + }; + }, asyncUpdater = function (context, oldUpdater) { + return function (newVal) { + if (newVal !== undefined) { + oldUpdater(newVal, context.value); + } + }; + }; + can.Compute = function (getterSetter, context, eventName, bindOnce) { + var args = []; + for (var i = 0, arglen = arguments.length; i < arglen; i++) { + args[i] = arguments[i]; + } + var contextType = typeof args[1]; + if (typeof args[0] === 'function') { + this._setupGetterSetterFn(args[0], args[1], args[2], args[3]); + } else if (args[1]) { + if (contextType === 'string') { + this._setupContextString(args[0], args[1], args[2]); + } else if (contextType === 'function') { + this._setupContextFunction(args[0], args[1], args[2]); + } else { + if (args[1] && args[1].fn) { + this._setupAsyncCompute(args[0], args[1]); + } else { + this._setupContextSettings(args[0], args[1]); + } + } + } else { + this._setupInitialValue(args[0]); + } + this._args = args; + this.isComputed = true; + can.cid(this, 'compute'); + }; + can.simpleExtend(can.Compute.prototype, { + _bindsetup: can.__notObserve(function () { + this.bound = true; + this._on(this.updater); + }), + _bindteardown: function () { + this._off(this.updater); + this.bound = false; + }, + bind: can.bindAndSetup, + unbind: can.unbindAndTeardown, + clone: function (context) { + if (context && typeof this._args[0] === 'function') { + this._args[1] = context; + } else if (context) { + this._args[2] = context; + } + return new can.Compute(this._args[0], this._args[1], this._args[2], this._args[3]); + }, + _on: k, + _off: k, + get: function () { + if (can.__isRecordingObserves() && this._canObserve !== false) { + can.__observe(this, 'change'); + if (!this.bound) { + can.Compute.temporarilyBind(this); + } + } + if (this.bound) { + return this.value; + } else { + return this._get(); + } + }, + _get: function () { + return this.value; + }, + set: function (newVal) { + var old = this.value; + var setVal = this._set(newVal, old); + if (this.hasDependencies) { + if (this._setUpdates) { + return this.value; + } + return this._get(); + } + if (setVal === undefined) { + this.value = this._get(); + } else { + this.value = setVal; + } + updateOnChange(this, this.value, old); + return this.value; + }, + _set: function (newVal) { + return this.value = newVal; + }, + updater: updater, + _computeFn: function (newVal) { + if (arguments.length) { + return this.set(newVal); + } + return this.get(); + }, + toFunction: function () { + return can.proxy(this._computeFn, this); + }, + _setupGetterSetterFn: function (getterSetter, context, eventName, bindOnce) { + this._set = can.proxy(getterSetter, context); + this._get = can.proxy(getterSetter, context); + this._canObserve = eventName === false ? false : true; + var handlers = setupComputeHandlers(this, getterSetter, context || this, bindOnce); + this._on = handlers.on; + this._off = handlers.off; + }, + _setupContextString: function (target, propertyName, eventName) { + var isObserve = can.isMapLike(target), self = this, handler = function (ev, newVal, oldVal) { + self.updater(newVal, oldVal, ev.batchNum); + }; + if (isObserve) { + this.hasDependencies = true; + this._get = function () { + return target.attr(propertyName); + }; + this._set = function (val) { + target.attr(propertyName, val); + }; + this._on = function (update) { + target.bind(eventName || propertyName, handler); + this.value = this._get(); + }; + this._off = function () { + return target.unbind(eventName || propertyName, handler); + }; + } else { + this._get = can.proxy(this._get, target); + this._set = can.proxy(this._set, target); + } + }, + _setupContextFunction: function (initialValue, setter, eventName) { + this.value = initialValue; + this._set = setter; + can.simpleExtend(this, eventName); + }, + _setupContextSettings: function (initialValue, settings) { + this.value = initialValue; + this._set = settings.set ? can.proxy(settings.set, settings) : this._set; + this._get = settings.get ? can.proxy(settings.get, settings) : this._get; + if (!settings.__selfUpdater) { + var self = this, oldUpdater = this.updater; + this.updater = function () { + oldUpdater.call(self, self._get(), self.value); + }; + } + this._on = settings.on ? settings.on : this._on; + this._off = settings.off ? settings.off : this._off; + }, + _setupAsyncCompute: function (initialValue, settings) { + this.value = initialValue; + var oldUpdater = can.proxy(this.updater, this), self = this, fn = settings.fn, data; + this.updater = oldUpdater; + var lastSetValue = new can.Compute(initialValue); + this.lastSetValue = lastSetValue; + this._setUpdates = true; + this._set = function (newVal) { + if (newVal === lastSetValue.get()) { + return this.value; + } + return lastSetValue.set(newVal); + }; + this._get = asyncGet(fn, settings.context, lastSetValue); + if (fn.length === 0) { + data = setupComputeHandlers(this, fn, settings.context); + } else if (fn.length === 1) { + data = setupComputeHandlers(this, function () { + return fn.call(settings.context, lastSetValue.get()); + }, settings); + } else { + this.updater = asyncUpdater(this, oldUpdater); + data = setupComputeHandlers(this, function () { + var res = fn.call(settings.context, lastSetValue.get(), function (newVal) { + oldUpdater(newVal, self.value); + }); + return res !== undefined ? res : this.value; + }, settings); + } + this._on = data.on; + this._off = data.off; + }, + _setupInitialValue: function (initialValue) { + this.value = initialValue; + } + }); + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.Compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.Compute.async = function (initialValue, asyncComputer, context) { + return new can.Compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.Compute.read = read; + can.Compute.set = read.write; + can.Compute.truthy = function (compute) { + return new can.Compute(function () { + var res = compute.get(); + if (typeof res === 'function') { + res = res.get(); + } + return !!res; + }); + }; + return can.Compute; +}); +/*can@2.2.6#compute/compute*/ +define('can/compute/compute', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/util/batch/batch', + 'can/compute/proto_compute' +], function (can, bind) { + can.compute = function (getterSetter, context, eventName, bindOnce) { + var internalCompute = new can.Compute(getterSetter, context, eventName, bindOnce); + var compute = function (val) { + if (arguments.length) { + return internalCompute.set(val); + } + return internalCompute.get(); + }; + compute.bind = can.proxy(internalCompute.bind, internalCompute); + compute.unbind = can.proxy(internalCompute.unbind, internalCompute); + compute.isComputed = internalCompute.isComputed; + compute.clone = function (ctx) { + if (typeof getterSetter === 'function') { + context = ctx; + } + return can.compute(getterSetter, context, ctx, bindOnce); + }; + compute.computeInstance = internalCompute; + return compute; + }; + var k = function () { + }; + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.compute.truthy = function (compute) { + return can.compute(function () { + var res = compute(); + if (typeof res === 'function') { + res = res(); + } + return !!res; + }); + }; + can.compute.async = function (initialValue, asyncComputer, context) { + return can.compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.compute.read = can.Compute.read; + can.compute.set = can.Compute.set; + return can.compute; +}); +/*can@2.2.6#observe/observe*/ +define('can/observe/observe', [ + 'can/util/util', + 'can/map/map', + 'can/list/list', + 'can/compute/compute' +], function (can) { + can.Observe = can.Map; + can.Observe.startBatch = can.batch.start; + can.Observe.stopBatch = can.batch.stop; + can.Observe.triggerBatch = can.batch.trigger; + return can; +}); +/*can@2.2.6#view/scope/compute_data*/ +define('can/view/scope/compute_data', [ + 'can/util/util', + 'can/compute/compute', + 'can/compute/get_value_and_bind' +], function (can, compute, getValueAndBind) { + var isFastPath = function (computeData) { + return computeData.reads && computeData.reads.length === 1 && computeData.root instanceof can.Map && !can.isFunction(computeData.root[computeData.reads[0]]); + }; + var getValueAndBindScopeRead = function (scopeRead, scopeReadChanged) { + return getValueAndBind(scopeRead, null, { observed: {} }, scopeReadChanged); + }; + var unbindScopeRead = function (readInfo, scopeReadChanged) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, scopeReadChanged); + } + }; + var getValueAndBindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + var target = computeData.root, prop = computeData.reads[0]; + target.bind(prop, singlePropertyReadChanged); + return { + value: computeData.initialValue, + observed: { something: true } + }; + }; + var unbindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + computeData.root.unbind(computeData.reads[0], singlePropertyReadChanged); + }; + var scopeReader = function (scope, key, options, computeData, newVal) { + if (arguments.length > 4) { + if (computeData.root.isComputed) { + computeData.root(newVal); + } else if (computeData.reads.length) { + var last = computeData.reads.length - 1; + var obj = computeData.reads.length ? can.compute.read(computeData.root, computeData.reads.slice(0, last)).value : computeData.root; + can.compute.set(obj, computeData.reads[last], newVal, options); + } + } else { + if (computeData.root) { + return can.compute.read(computeData.root, computeData.reads, options).value; + } + var data = scope.read(key, options); + computeData.scope = data.scope; + computeData.initialValue = data.value; + computeData.reads = data.reads; + computeData.root = data.rootObserve; + return data.value; + } + }; + return function (scope, key, options) { + options = options || { args: [] }; + var computeData = {}, scopeRead = function (newVal) { + if (arguments.length) { + return scopeReader(scope, key, options, computeData, newVal); + } else { + return scopeReader(scope, key, options, computeData); + } + }, batchNum, readInfo, scopeReadChanged = function (ev) { + if (readInfo.ready && compute.computeInstance.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + readInfo = getValueAndBind(scopeRead, null, readInfo, scopeReadChanged); + newValue = readInfo.value; + compute.computeInstance.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }, singlePropertyReadChanged = function (ev, newVal, oldVal) { + if (typeof newVal !== 'function') { + compute.computeInstance.updater(newVal, oldVal, ev.batchNum); + } else { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + isFastPathBound = false; + compute.computeInstance.updater(readInfo.value, oldVal, ev.batchNum); + } + }, isFastPathBound = false, compute = can.compute(undefined, { + on: function () { + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + if (isFastPath(computeData)) { + var oldReadInfo = readInfo; + readInfo = getValueAndBindSinglePropertyRead(computeData, singlePropertyReadChanged); + unbindScopeRead(oldReadInfo, scopeReadChanged); + isFastPathBound = true; + } + compute.computeInstance.value = readInfo.value; + compute.computeInstance.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function () { + if (isFastPathBound) { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + } else { + unbindScopeRead(readInfo, scopeReadChanged); + } + }, + set: scopeRead, + get: scopeRead, + __selfUpdater: true + }); + computeData.compute = compute; + return computeData; + }; +}); +/*can@2.2.6#view/scope/scope*/ +define('can/view/scope/scope', [ + 'can/util/util', + 'can/view/scope/compute_data', + 'can/construct/construct', + 'can/map/map', + 'can/list/list', + 'can/view/view', + 'can/compute/compute' +], function (can, makeComputeData) { + var escapeReg = /(\\)?\./g, escapeDotReg = /\\\./g, getNames = function (attr) { + var names = [], last = 0; + attr.replace(escapeReg, function (first, second, index) { + if (!second) { + names.push(attr.slice(last, index).replace(escapeDotReg, '.')); + last = index + first.length; + } + }); + names.push(attr.slice(last).replace(escapeDotReg, '.')); + return names; + }; + var Scope = can.Construct.extend({ read: can.compute.read }, { + init: function (context, parent) { + this._context = context; + this._parent = parent; + this.__cache = {}; + }, + attr: can.__notObserve(function (key, value) { + var options = { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }, res = this.read(key, options); + if (arguments.length === 2) { + var lastIndex = key.lastIndexOf('.'), readKey = lastIndex !== -1 ? key.substring(0, lastIndex) : '.', obj = this.read(readKey, options).value; + if (lastIndex !== -1) { + key = key.substring(lastIndex + 1, key.length); + } + can.compute.set(obj, key, value, options); + } + return res.value; + }), + add: function (context) { + if (context !== this._context) { + return new this.constructor(context, this); + } else { + return this; + } + }, + computeData: function (key, options) { + return makeComputeData(this, key, options); + }, + compute: function (key, options) { + return this.computeData(key, options).compute; + }, + read: function (attr, options) { + var stopLookup; + if (attr.substr(0, 2) === './') { + stopLookup = true; + attr = attr.substr(2); + } else if (attr.substr(0, 3) === '../') { + return this._parent.read(attr.substr(3), options); + } else if (attr === '..') { + return { value: this._parent._context }; + } else if (attr === '.' || attr === 'this') { + return { value: this._context }; + } + var names = attr.indexOf('\\.') === -1 ? attr.split('.') : getNames(attr), context, scope = this, defaultObserve, defaultReads = [], defaultPropertyDepth = -1, defaultComputeReadings, defaultScope, currentObserve, currentReads; + while (scope) { + context = scope._context; + if (context !== null && (typeof context === 'object' || typeof context === 'function')) { + var data = can.compute.read(context, names, can.simpleExtend({ + foundObservable: function (observe, nameIndex) { + currentObserve = observe; + currentReads = names.slice(nameIndex); + }, + earlyExit: function (parentValue, nameIndex) { + if (nameIndex > defaultPropertyDepth) { + defaultObserve = currentObserve; + defaultReads = currentReads; + defaultPropertyDepth = nameIndex; + defaultScope = scope; + defaultComputeReadings = can.__clearReading(); + } + }, + executeAnonymousFunctions: true + }, options)); + if (data.value !== undefined) { + return { + scope: scope, + rootObserve: currentObserve, + value: data.value, + reads: currentReads + }; + } + } + can.__clearReading(); + if (!stopLookup) { + scope = scope._parent; + } else { + scope = null; + } + } + if (defaultObserve) { + can.__setReading(defaultComputeReadings); + return { + scope: defaultScope, + rootObserve: defaultObserve, + reads: defaultReads, + value: undefined + }; + } else { + return { + names: names, + value: undefined + }; + } + } + }); + can.view.Scope = Scope; + return Scope; +}); +/*can@2.2.6#view/scanner*/ +define('can/view/scanner', [ + 'can/view/view', + 'can/view/elements', + 'can/view/callbacks/callbacks' +], function (can, elements, viewCallbacks) { + var newLine = /(\r|\n)+/g, notEndTag = /\//, clean = function (content) { + return content.split('\\').join('\\\\').split('\n').join('\\n').split('"').join('\\"').split('\t').join('\\t'); + }, getTag = function (tagName, tokens, i) { + if (tagName) { + return tagName; + } else { + while (i < tokens.length) { + if (tokens[i] === '<' && !notEndTag.test(tokens[i + 1])) { + return elements.reverseTagMap[tokens[i + 1]] || 'span'; + } + i++; + } + } + return ''; + }, bracketNum = function (content) { + return --content.split('{').length - --content.split('}').length; + }, myEval = function (script) { + eval(script); + }, attrReg = /([^\s]+)[\s]*=[\s]*$/, startTxt = 'var ___v1ew = [];', finishTxt = 'return ___v1ew.join(\'\')', put_cmd = '___v1ew.push(\n', insert_cmd = put_cmd, htmlTag = null, quote = null, beforeQuote = null, rescan = null, getAttrName = function () { + var matches = beforeQuote.match(attrReg); + return matches && matches[1]; + }, status = function () { + return quote ? '\'' + getAttrName() + '\'' : htmlTag ? 1 : 0; + }, top = function (stack) { + return stack[stack.length - 1]; + }, Scanner; + can.view.Scanner = Scanner = function (options) { + can.extend(this, { + text: {}, + tokens: [] + }, options); + this.text.options = this.text.options || ''; + this.tokenReg = []; + this.tokenSimple = { + '<': '<', + '>': '>', + '"': '"', + '\'': '\'' + }; + this.tokenComplex = []; + this.tokenMap = {}; + for (var i = 0, token; token = this.tokens[i]; i++) { + if (token[2]) { + this.tokenReg.push(token[2]); + this.tokenComplex.push({ + abbr: token[1], + re: new RegExp(token[2]), + rescan: token[3] + }); + } else { + this.tokenReg.push(token[1]); + this.tokenSimple[token[1]] = token[0]; + } + this.tokenMap[token[0]] = token[1]; + } + this.tokenReg = new RegExp('(' + this.tokenReg.slice(0).concat([ + '<', + '>', + '"', + '\'' + ]).join('|') + ')', 'g'); + }; + Scanner.prototype = { + helpers: [], + scan: function (source, name) { + var tokens = [], last = 0, simple = this.tokenSimple, complex = this.tokenComplex; + source = source.replace(newLine, '\n'); + if (this.transform) { + source = this.transform(source); + } + source.replace(this.tokenReg, function (whole, part) { + var offset = arguments[arguments.length - 2]; + if (offset > last) { + tokens.push(source.substring(last, offset)); + } + if (simple[whole]) { + tokens.push(whole); + } else { + for (var i = 0, token; token = complex[i]; i++) { + if (token.re.test(whole)) { + tokens.push(token.abbr); + if (token.rescan) { + tokens.push(token.rescan(part)); + } + break; + } + } + } + last = offset + part.length; + }); + if (last < source.length) { + tokens.push(source.substr(last)); + } + var content = '', buff = [startTxt + (this.text.start || '')], put = function (content, bonus) { + buff.push(put_cmd, '"', clean(content), '"' + (bonus || '') + ');'); + }, endStack = [], lastToken, startTag = null, magicInTag = false, specialStates = { + attributeHookups: [], + tagHookups: [], + lastTagHookup: '' + }, popTagHookup = function () { + specialStates.lastTagHookup = specialStates.tagHookups.pop() + specialStates.tagHookups.length; + }, tagName = '', tagNames = [], popTagName = false, bracketCount, specialAttribute = false, i = 0, token, tmap = this.tokenMap, attrName; + htmlTag = quote = beforeQuote = null; + for (; (token = tokens[i++]) !== undefined;) { + if (startTag === null) { + switch (token) { + case tmap.left: + case tmap.escapeLeft: + case tmap.returnLeft: + magicInTag = htmlTag && 1; + case tmap.commentLeft: + startTag = token; + if (content.length) { + put(content); + } + content = ''; + break; + case tmap.escapeFull: + magicInTag = htmlTag && 1; + rescan = 1; + startTag = tmap.escapeLeft; + if (content.length) { + put(content); + } + rescan = tokens[i++]; + content = rescan.content || rescan; + if (rescan.before) { + put(rescan.before); + } + tokens.splice(i, 0, tmap.right); + break; + case tmap.commentFull: + break; + case tmap.templateLeft: + content += tmap.left; + break; + case '<': + if (tokens[i].indexOf('!--') !== 0) { + htmlTag = 1; + magicInTag = 0; + } + content += token; + break; + case '>': + htmlTag = 0; + var emptyElement = content.substr(content.length - 1) === '/' || content.substr(content.length - 2) === '--', attrs = ''; + if (specialStates.attributeHookups.length) { + attrs = 'attrs: [\'' + specialStates.attributeHookups.join('\',\'') + '\'], '; + specialStates.attributeHookups = []; + } + if (tagName + specialStates.tagHookups.length !== specialStates.lastTagHookup && tagName === top(specialStates.tagHookups)) { + if (emptyElement) { + content = content.substr(0, content.length - 1); + } + buff.push(put_cmd, '"', clean(content), '"', ',can.view.pending({tagName:\'' + tagName + '\',' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options); + if (emptyElement) { + buff.push('}));'); + content = '/>'; + popTagHookup(); + } else if (tokens[i] === '<' && tokens[i + 1] === '/' + tagName) { + buff.push('}));'); + content = token; + popTagHookup(); + } else { + buff.push(',subtemplate: function(' + this.text.argNames + '){\n' + startTxt + (this.text.start || '')); + content = ''; + } + } else if (magicInTag || !popTagName && elements.tagToContentPropMap[tagNames[tagNames.length - 1]] || attrs) { + var pendingPart = ',can.view.pending({' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options + '}),"'; + if (emptyElement) { + put(content.substr(0, content.length - 1), pendingPart + '/>"'); + } else { + put(content, pendingPart + '>"'); + } + content = ''; + magicInTag = 0; + } else { + content += token; + } + if (emptyElement || popTagName) { + tagNames.pop(); + tagName = tagNames[tagNames.length - 1]; + popTagName = false; + } + specialStates.attributeHookups = []; + break; + case '\'': + case '"': + if (htmlTag) { + if (quote && quote === token) { + quote = null; + var attr = getAttrName(); + if (viewCallbacks.attr(attr)) { + specialStates.attributeHookups.push(attr); + } + if (specialAttribute) { + content += token; + put(content); + buff.push(finishTxt, '}));\n'); + content = ''; + specialAttribute = false; + break; + } + } else if (quote === null) { + quote = token; + beforeQuote = lastToken; + attrName = getAttrName(); + if (tagName === 'img' && attrName === 'src' || attrName === 'style') { + put(content.replace(attrReg, '')); + content = ''; + specialAttribute = true; + buff.push(insert_cmd, 'can.view.txt(2,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt); + put(attrName + '=' + token); + break; + } + } + } + default: + if (lastToken === '<') { + tagName = token.substr(0, 3) === '!--' ? '!--' : token.split(/\s/)[0]; + var isClosingTag = false, cleanedTagName; + if (tagName.indexOf('/') === 0) { + isClosingTag = true; + cleanedTagName = tagName.substr(1); + } + if (isClosingTag) { + if (top(tagNames) === cleanedTagName) { + tagName = cleanedTagName; + popTagName = true; + } + if (top(specialStates.tagHookups) === cleanedTagName) { + put(content.substr(0, content.length - 1)); + buff.push(finishTxt + '}}) );'); + content = '><'; + popTagHookup(); + } + } else { + if (tagName.lastIndexOf('/') === tagName.length - 1) { + tagName = tagName.substr(0, tagName.length - 1); + } + if (tagName !== '!--' && viewCallbacks.tag(tagName)) { + if (tagName === 'content' && elements.tagMap[top(tagNames)]) { + token = token.replace('content', elements.tagMap[top(tagNames)]); + } + specialStates.tagHookups.push(tagName); + } + tagNames.push(tagName); + } + } + content += token; + break; + } + } else { + switch (token) { + case tmap.right: + case tmap.returnRight: + switch (startTag) { + case tmap.left: + bracketCount = bracketNum(content); + if (bracketCount === 1) { + buff.push(insert_cmd, 'can.view.txt(0,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt, content); + endStack.push({ + before: '', + after: finishTxt + '}));\n' + }); + } else { + last = endStack.length && bracketCount === -1 ? endStack.pop() : { after: ';' }; + if (last.before) { + buff.push(last.before); + } + buff.push(content, ';', last.after); + } + break; + case tmap.escapeLeft: + case tmap.returnLeft: + bracketCount = bracketNum(content); + if (bracketCount) { + endStack.push({ + before: finishTxt, + after: '}));\n' + }); + } + var escaped = startTag === tmap.escapeLeft ? 1 : 0, commands = { + insert: insert_cmd, + tagName: getTag(tagName, tokens, i), + status: status(), + specialAttribute: specialAttribute + }; + for (var ii = 0; ii < this.helpers.length; ii++) { + var helper = this.helpers[ii]; + if (helper.name.test(content)) { + content = helper.fn(content, commands); + if (helper.name.source === /^>[\s]*\w*/.source) { + escaped = 0; + } + break; + } + } + if (typeof content === 'object') { + if (content.startTxt && content.end && specialAttribute) { + buff.push(insert_cmd, 'can.view.toStr( ', content.content, '() ) );'); + } else { + if (content.startTxt) { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || (content.escaped != null ? content.escaped : escaped)) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\n'); + } else if (content.startOnlyTxt) { + buff.push(insert_cmd, 'can.view.onlytxt(this,\n'); + } + buff.push(content.content); + if (content.end) { + buff.push('));'); + } + } + } else if (specialAttribute) { + buff.push(insert_cmd, content, ');'); + } else { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || escaped) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\nfunction(){ ' + (this.text.escape || '') + 'return ', content, bracketCount ? startTxt : '}));\n'); + } + if (rescan && rescan.after && rescan.after.length) { + put(rescan.after.length); + rescan = null; + } + break; + } + startTag = null; + content = ''; + break; + case tmap.templateLeft: + content += tmap.left; + break; + default: + content += token; + break; + } + } + lastToken = token; + } + if (content.length) { + put(content); + } + buff.push(';'); + var template = buff.join(''), out = { out: (this.text.outStart || '') + template + ' ' + finishTxt + (this.text.outEnd || '') }; + myEval.call(out, 'this.fn = (function(' + this.text.argNames + '){' + out.out + '});\r\n//# sourceURL=' + name + '.js'); + return out; + } + }; + can.view.pending = function (viewData) { + var hooks = can.view.getHooks(); + return can.view.hook(function (el) { + can.each(hooks, function (fn) { + fn(el); + }); + viewData.templateType = 'legacy'; + if (viewData.tagName) { + viewCallbacks.tagHandler(el, viewData.tagName, viewData); + } + can.each(viewData && viewData.attrs || [], function (attributeName) { + viewData.attributeName = attributeName; + var callback = viewCallbacks.attr(attributeName); + if (callback) { + callback(el, viewData); + } + }); + }); + }; + can.view.tag('content', function (el, tagData) { + return tagData.scope; + }); + can.view.Scanner = Scanner; + return Scanner; +}); +/*can@2.2.6#view/node_lists/node_lists*/ +define('can/view/node_lists/node_lists', [ + 'can/util/util', + 'can/view/elements' +], function (can) { + var canExpando = true; + try { + document.createTextNode('')._ = 0; + } catch (ex) { + canExpando = false; + } + var nodeMap = {}, textNodeMap = {}, expando = 'ejs_' + Math.random(), _id = 0, id = function (node, localMap) { + var _textNodeMap = localMap || textNodeMap; + var id = readId(node, _textNodeMap); + if (id) { + return id; + } else { + if (canExpando || node.nodeType !== 3) { + ++_id; + return node[expando] = (node.nodeName ? 'element_' : 'obj_') + _id; + } else { + ++_id; + _textNodeMap['text_' + _id] = node; + return 'text_' + _id; + } + } + }, readId = function (node, textNodeMap) { + if (canExpando || node.nodeType !== 3) { + return node[expando]; + } else { + for (var textNodeID in textNodeMap) { + if (textNodeMap[textNodeID] === node) { + return textNodeID; + } + } + } + }, splice = [].splice, push = [].push, itemsInChildListTree = function (list) { + var count = 0; + for (var i = 0, len = list.length; i < len; i++) { + var item = list[i]; + if (item.nodeType) { + count++; + } else { + count += itemsInChildListTree(item); + } + } + return count; + }, replacementMap = function (replacements, idMap) { + var map = {}; + for (var i = 0, len = replacements.length; i < len; i++) { + var node = nodeLists.first(replacements[i]); + map[id(node, idMap)] = replacements[i]; + } + return map; + }; + var nodeLists = { + id: id, + update: function (nodeList, newNodes) { + var oldNodes = nodeLists.unregisterChildren(nodeList); + newNodes = can.makeArray(newNodes); + var oldListLength = nodeList.length; + splice.apply(nodeList, [ + 0, + oldListLength + ].concat(newNodes)); + if (nodeList.replacements) { + nodeLists.nestReplacements(nodeList); + } else { + nodeLists.nestList(nodeList); + } + return oldNodes; + }, + nestReplacements: function (list) { + var index = 0, idMap = {}, rMap = replacementMap(list.replacements, idMap), rCount = list.replacements.length; + while (index < list.length && rCount) { + var node = list[index], replacement = rMap[readId(node, idMap)]; + if (replacement) { + list.splice(index, itemsInChildListTree(replacement), replacement); + rCount--; + } + index++; + } + list.replacements = []; + }, + nestList: function (list) { + var index = 0; + while (index < list.length) { + var node = list[index], childNodeList = nodeMap[id(node)]; + if (childNodeList) { + if (childNodeList !== list) { + list.splice(index, itemsInChildListTree(childNodeList), childNodeList); + } + } else { + nodeMap[id(node)] = list; + } + index++; + } + }, + last: function (nodeList) { + var last = nodeList[nodeList.length - 1]; + if (last.nodeType) { + return last; + } else { + return nodeLists.last(last); + } + }, + first: function (nodeList) { + var first = nodeList[0]; + if (first.nodeType) { + return first; + } else { + return nodeLists.first(first); + } + }, + flatten: function (nodeList) { + var items = []; + for (var i = 0; i < nodeList.length; i++) { + var item = nodeList[i]; + if (item.nodeType) { + items.push(item); + } else { + items.push.apply(items, nodeLists.flatten(item)); + } + } + return items; + }, + register: function (nodeList, unregistered, parent) { + nodeList.unregistered = unregistered; + nodeList.parentList = parent; + if (parent === true) { + nodeList.replacements = []; + } else if (parent) { + parent.replacements.push(nodeList); + nodeList.replacements = []; + } else { + nodeLists.nestList(nodeList); + } + return nodeList; + }, + unregisterChildren: function (nodeList) { + var nodes = []; + can.each(nodeList, function (node) { + if (node.nodeType) { + if (!nodeList.replacements) { + delete nodeMap[id(node)]; + } + nodes.push(node); + } else { + push.apply(nodes, nodeLists.unregister(node)); + } + }); + return nodes; + }, + unregister: function (nodeList) { + var nodes = nodeLists.unregisterChildren(nodeList); + if (nodeList.unregistered) { + var unregisteredCallback = nodeList.unregistered; + delete nodeList.unregistered; + delete nodeList.replacements; + unregisteredCallback(); + } + return nodes; + }, + nodeMap: nodeMap + }; + can.view.nodeLists = nodeLists; + return nodeLists; +}); +/*can@2.2.6#view/parser/parser*/ +define('can/view/parser/parser', ['can/view/view'], function (can) { + function makeMap(str) { + var obj = {}, items = str.split(','); + for (var i = 0; i < items.length; i++) { + obj[items[i]] = true; + } + return obj; + } + function handleIntermediate(intermediate, handler) { + for (var i = 0, len = intermediate.length; i < len; i++) { + var item = intermediate[i]; + handler[item.tokenType].apply(handler, item.args); + } + return intermediate; + } + var alphaNumericHU = '-:A-Za-z0-9_', attributeNames = '[a-zA-Z_:][' + alphaNumericHU + ':.]*', spaceEQspace = '\\s*=\\s*', dblQuote2dblQuote = '"((?:\\\\.|[^"])*)"', quote2quote = '\'((?:\\\\.|[^\'])*)\'', attributeEqAndValue = '(?:' + spaceEQspace + '(?:' + '(?:"[^"]*")|(?:\'[^\']*\')|[^>\\s]+))?', matchStash = '\\{\\{[^\\}]*\\}\\}\\}?', stash = '\\{\\{([^\\}]*)\\}\\}\\}?', startTag = new RegExp('^<([' + alphaNumericHU + ']+)' + '(' + '(?:\\s*' + '(?:(?:' + '(?:' + attributeNames + ')?' + attributeEqAndValue + ')|' + '(?:' + matchStash + ')+)' + ')*' + ')\\s*(\\/?)>'), endTag = new RegExp('^<\\/([' + alphaNumericHU + ']+)[^>]*>'), attr = new RegExp('(?:' + '(?:(' + attributeNames + ')|' + stash + ')' + '(?:' + spaceEQspace + '(?:' + '(?:' + dblQuote2dblQuote + ')|(?:' + quote2quote + ')|([^>\\s]+)' + ')' + ')?)', 'g'), mustache = new RegExp(stash, 'g'), txtBreak = /<|\{\{/; + var empty = makeMap('area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed'); + var block = makeMap('a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video'); + var inline = makeMap('abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var'); + var closeSelf = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr'); + var fillAttrs = makeMap('checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected'); + var special = makeMap('script,style'); + var tokenTypes = 'start,end,close,attrStart,attrEnd,attrValue,chars,comment,special,done'.split(','); + var fn = function () { + }; + var HTMLParser = function (html, handler, returnIntermediate) { + if (typeof html === 'object') { + return handleIntermediate(html, handler); + } + var intermediate = []; + handler = handler || {}; + if (returnIntermediate) { + can.each(tokenTypes, function (name) { + var callback = handler[name] || fn; + handler[name] = function () { + if (callback.apply(this, arguments) !== false) { + intermediate.push({ + tokenType: name, + args: can.makeArray(arguments) + }); + } + }; + }); + } + function parseStartTag(tag, tagName, rest, unary) { + tagName = tagName.toLowerCase(); + if (block[tagName]) { + while (stack.last() && inline[stack.last()]) { + parseEndTag('', stack.last()); + } + } + if (closeSelf[tagName] && stack.last() === tagName) { + parseEndTag('', tagName); + } + unary = empty[tagName] || !!unary; + handler.start(tagName, unary); + if (!unary) { + stack.push(tagName); + } + HTMLParser.parseAttrs(rest, handler); + handler.end(tagName, unary); + } + function parseEndTag(tag, tagName) { + var pos; + if (!tagName) { + pos = 0; + } else { + for (pos = stack.length - 1; pos >= 0; pos--) { + if (stack[pos] === tagName) { + break; + } + } + } + if (pos >= 0) { + for (var i = stack.length - 1; i >= pos; i--) { + if (handler.close) { + handler.close(stack[i]); + } + } + stack.length = pos; + } + } + function parseMustache(mustache, inside) { + if (handler.special) { + handler.special(inside); + } + } + var index, chars, match, stack = [], last = html; + stack.last = function () { + return this[this.length - 1]; + }; + while (html) { + chars = true; + if (!stack.last() || !special[stack.last()]) { + if (html.indexOf(''); + if (index >= 0) { + if (handler.comment) { + handler.comment(html.substring(4, index)); + } + html = html.substring(index + 3); + chars = false; + } + } else if (html.indexOf(']*>'), function (all, text) { + text = text.replace(/|/g, '$1$2'); + if (handler.chars) { + handler.chars(text); + } + return ''; + }); + parseEndTag('', stack.last()); + } + if (html === last) { + throw 'Parse Error: ' + html; + } + last = html; + } + parseEndTag(); + handler.done(); + return intermediate; + }; + HTMLParser.parseAttrs = function (rest, handler) { + (rest != null ? rest : '').replace(attr, function (text, name, special, dblQuote, singleQuote, val) { + if (special) { + handler.special(special); + } + if (name || dblQuote || singleQuote || val) { + var value = arguments[3] ? arguments[3] : arguments[4] ? arguments[4] : arguments[5] ? arguments[5] : fillAttrs[name.toLowerCase()] ? name : ''; + handler.attrStart(name || ''); + var last = mustache.lastIndex = 0, res = mustache.exec(value), chars; + while (res) { + chars = value.substring(last, mustache.lastIndex - res[0].length); + if (chars.length) { + handler.attrValue(chars); + } + handler.special(res[1]); + last = mustache.lastIndex; + res = mustache.exec(value); + } + chars = value.substr(last, value.length); + if (chars) { + handler.attrValue(chars); + } + handler.attrEnd(name || ''); + } + }); + }; + can.view.parser = HTMLParser; + return HTMLParser; +}); +/*can@2.2.6#view/live/live*/ +define('can/view/live/live', [ + 'can/util/util', + 'can/view/elements', + 'can/view/view', + 'can/view/node_lists/node_lists', + 'can/view/parser/parser' +], function (can, elements, view, nodeLists, parser) { + elements = elements || can.view.elements; + nodeLists = nodeLists || can.view.NodeLists; + parser = parser || can.view.parser; + var setup = function (el, bind, unbind) { + var tornDown = false, teardown = function () { + if (!tornDown) { + tornDown = true; + unbind(data); + can.unbind.call(el, 'removed', teardown); + } + return true; + }, data = { + teardownCheck: function (parent) { + return parent ? false : teardown(); + } + }; + can.bind.call(el, 'removed', teardown); + bind(data); + return data; + }, listen = function (el, compute, change) { + return setup(el, function () { + compute.bind('change', change); + }, function (data) { + compute.unbind('change', change); + if (data.nodeList) { + nodeLists.unregister(data.nodeList); + } + }); + }, getAttributeParts = function (newVal) { + var attrs = {}, attr; + parser.parseAttrs(newVal, { + attrStart: function (name) { + attrs[name] = ''; + attr = name; + }, + attrValue: function (value) { + attrs[attr] += value; + }, + attrEnd: function () { + } + }); + return attrs; + }, splice = [].splice, isNode = function (obj) { + return obj && obj.nodeType; + }, addTextNodeIfNoChildren = function (frag) { + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + }; + var live = { + list: function (el, compute, render, context, parentNode, nodeList) { + var masterNodeList = nodeList || [el], indexMap = [], afterPreviousEvents = false, isTornDown = false, add = function (ev, items, index) { + if (!afterPreviousEvents) { + return; + } + var frag = document.createDocumentFragment(), newNodeLists = [], newIndicies = []; + can.each(items, function (item, key) { + var itemNodeList = []; + if (nodeList) { + nodeLists.register(itemNodeList, null, true); + } + var itemIndex = can.compute(key + index), itemHTML = render.call(context, item, itemIndex, itemNodeList), gotText = typeof itemHTML === 'string', itemFrag = can.frag(itemHTML); + itemFrag = gotText ? can.view.hookup(itemFrag) : itemFrag; + var childNodes = can.makeArray(itemFrag.childNodes); + if (nodeList) { + nodeLists.update(itemNodeList, childNodes); + newNodeLists.push(itemNodeList); + } else { + newNodeLists.push(nodeLists.register(childNodes)); + } + frag.appendChild(itemFrag); + newIndicies.push(itemIndex); + }); + var masterListIndex = index + 1; + if (!masterNodeList[masterListIndex]) { + elements.after(masterListIndex === 1 ? [text] : [nodeLists.last(masterNodeList[masterListIndex - 1])], frag); + } else { + var el = nodeLists.first(masterNodeList[masterListIndex]); + can.insertBefore(el.parentNode, frag, el); + } + splice.apply(masterNodeList, [ + masterListIndex, + 0 + ].concat(newNodeLists)); + splice.apply(indexMap, [ + index, + 0 + ].concat(newIndicies)); + for (var i = index + newIndicies.length, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + }, remove = function (ev, items, index, duringTeardown, fullTeardown) { + if (!afterPreviousEvents) { + return; + } + if (!duringTeardown && data.teardownCheck(text.parentNode)) { + return; + } + if (index < 0) { + index = indexMap.length + index; + } + var removedMappings = masterNodeList.splice(index + 1, items.length), itemsToRemove = []; + can.each(removedMappings, function (nodeList) { + var nodesToRemove = nodeLists.unregister(nodeList); + [].push.apply(itemsToRemove, nodesToRemove); + }); + indexMap.splice(index, items.length); + for (var i = index, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + if (!fullTeardown) { + can.remove(can.$(itemsToRemove)); + } else { + nodeLists.unregister(masterNodeList); + } + }, move = function (ev, item, newIndex, currentIndex) { + if (!afterPreviousEvents) { + return; + } + newIndex = newIndex + 1; + currentIndex = currentIndex + 1; + var referenceNodeList = masterNodeList[newIndex]; + var movedElements = can.frag(nodeLists.flatten(masterNodeList[currentIndex])); + var referenceElement; + if (currentIndex < newIndex) { + referenceElement = nodeLists.last(referenceNodeList).nextSibling; + } else { + referenceElement = nodeLists.first(referenceNodeList); + } + var parentNode = masterNodeList[0].parentNode; + parentNode.insertBefore(movedElements, referenceElement); + var temp = masterNodeList[currentIndex]; + [].splice.apply(masterNodeList, [ + currentIndex, + 1 + ]); + [].splice.apply(masterNodeList, [ + newIndex, + 0, + temp + ]); + }, text = document.createTextNode(''), list, teardownList = function (fullTeardown) { + if (list && list.unbind) { + list.unbind('add', add).unbind('remove', remove).unbind('move', move); + } + remove({}, { length: masterNodeList.length - 1 }, 0, true, fullTeardown); + }, updateList = function (ev, newList, oldList) { + if (isTornDown) { + return; + } + teardownList(); + list = newList || []; + if (list.bind) { + list.bind('add', add).bind('remove', remove).bind('move', move); + } + afterPreviousEvents = true; + add({}, list, 0); + afterPreviousEvents = false; + can.batch.afterPreviousEvents(function () { + afterPreviousEvents = true; + }); + }; + parentNode = elements.getParentNode(el, parentNode); + var data = setup(parentNode, function () { + if (can.isFunction(compute)) { + compute.bind('change', updateList); + } + }, function () { + if (can.isFunction(compute)) { + compute.unbind('change', updateList); + } + teardownList(true); + }); + if (!nodeList) { + live.replace(masterNodeList, text, data.teardownCheck); + } else { + elements.replace(masterNodeList, text); + nodeLists.update(masterNodeList, [text]); + nodeList.unregistered = function () { + data.teardownCheck(); + isTornDown = true; + }; + } + updateList({}, can.isFunction(compute) ? compute() : compute); + }, + html: function (el, compute, parentNode, nodeList) { + var data; + parentNode = elements.getParentNode(el, parentNode); + data = listen(parentNode, compute, function (ev, newVal, oldVal) { + var attached = nodeLists.first(nodes).parentNode; + if (attached) { + makeAndPut(newVal); + } + data.teardownCheck(nodeLists.first(nodes).parentNode); + }); + var nodes = nodeList || [el], makeAndPut = function (val) { + var isFunction = typeof val === 'function', aNode = isNode(val), frag = can.frag(isFunction ? '' : val), oldNodes = can.makeArray(nodes); + addTextNodeIfNoChildren(frag); + if (!aNode && !isFunction) { + frag = can.view.hookup(frag, parentNode); + } + oldNodes = nodeLists.update(nodes, frag.childNodes); + if (isFunction) { + val(frag.childNodes[0]); + } + elements.replace(oldNodes, frag); + }; + data.nodeList = nodes; + if (!nodeList) { + nodeLists.register(nodes, data.teardownCheck); + } else { + nodeList.unregistered = data.teardownCheck; + } + makeAndPut(compute()); + }, + replace: function (nodes, val, teardown) { + var oldNodes = nodes.slice(0), frag = can.frag(val); + nodeLists.register(nodes, teardown); + if (typeof val === 'string') { + frag = can.view.hookup(frag, nodes[0].parentNode); + } + nodeLists.update(nodes, frag.childNodes); + elements.replace(oldNodes, frag); + return nodes; + }, + text: function (el, compute, parentNode, nodeList) { + var parent = elements.getParentNode(el, parentNode); + var data = listen(parent, compute, function (ev, newVal, oldVal) { + if (typeof node.nodeValue !== 'unknown') { + node.nodeValue = can.view.toStr(newVal); + } + data.teardownCheck(node.parentNode); + }); + var node = document.createTextNode(can.view.toStr(compute())); + if (nodeList) { + nodeList.unregistered = data.teardownCheck; + data.nodeList = nodeList; + nodeLists.update(nodeList, [node]); + elements.replace([el], node); + } else { + data.nodeList = live.replace([el], node, data.teardownCheck); + } + }, + setAttributes: function (el, newVal) { + var attrs = getAttributeParts(newVal); + for (var name in attrs) { + can.attr.set(el, name, attrs[name]); + } + }, + attributes: function (el, compute, currentValue) { + var oldAttrs = {}; + var setAttrs = function (newVal) { + var newAttrs = getAttributeParts(newVal), name; + for (name in newAttrs) { + var newValue = newAttrs[name], oldValue = oldAttrs[name]; + if (newValue !== oldValue) { + can.attr.set(el, name, newValue); + } + delete oldAttrs[name]; + } + for (name in oldAttrs) { + elements.removeAttr(el, name); + } + oldAttrs = newAttrs; + }; + listen(el, compute, function (ev, newVal) { + setAttrs(newVal); + }); + if (arguments.length >= 3) { + oldAttrs = getAttributeParts(currentValue); + } else { + setAttrs(compute()); + } + }, + attributePlaceholder: '__!!__', + attributeReplace: /__!!__/g, + attribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, hook.render()); + }); + var wrapped = can.$(el), hooks; + hooks = can.data(wrapped, 'hooks'); + if (!hooks) { + can.data(wrapped, 'hooks', hooks = {}); + } + var attr = elements.getAttr(el, attributeName), parts = attr.split(live.attributePlaceholder), goodParts = [], hook; + goodParts.push(parts.shift(), parts.join(live.attributePlaceholder)); + if (hooks[attributeName]) { + hooks[attributeName].computes.push(compute); + } else { + hooks[attributeName] = { + render: function () { + var i = 0, newAttr = attr ? attr.replace(live.attributeReplace, function () { + return elements.contentText(hook.computes[i++]()); + }) : elements.contentText(hook.computes[i++]()); + return newAttr; + }, + computes: [compute], + batchNum: undefined + }; + } + hook = hooks[attributeName]; + goodParts.splice(1, 0, compute()); + elements.setAttr(el, attributeName, goodParts.join('')); + }, + specialAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, getValue(newVal)); + }); + elements.setAttr(el, attributeName, getValue(compute())); + }, + simpleAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, newVal); + }); + elements.setAttr(el, attributeName, compute()); + } + }; + live.attr = live.simpleAttribute; + live.attrs = live.attributes; + var newLine = /(\r|\n)+/g; + var getValue = function (val) { + var regexp = /^["'].*["']$/; + val = val.replace(elements.attrReg, '').replace(newLine, ''); + return regexp.test(val) ? val.substr(1, val.length - 2) : val; + }; + can.view.live = live; + return live; +}); +/*can@2.2.6#view/render*/ +define('can/view/render', [ + 'can/view/view', + 'can/view/elements', + 'can/view/live/live', + 'can/util/string/string' +], function (can, elements, live) { + var pendingHookups = [], tagChildren = function (tagName) { + var newTag = elements.tagMap[tagName] || 'span'; + if (newTag === 'span') { + return '@@!!@@'; + } + return '<' + newTag + '>' + tagChildren(newTag) + ''; + }, contentText = function (input, tag) { + if (typeof input === 'string') { + return input; + } + if (!input && input !== 0) { + return ''; + } + var hook = input.hookup && function (el, id) { + input.hookup.call(input, el, id); + } || typeof input === 'function' && input; + if (hook) { + if (tag) { + return '<' + tag + ' ' + can.view.hook(hook) + '>'; + } else { + pendingHookups.push(hook); + } + return ''; + } + return '' + input; + }, contentEscape = function (txt, tag) { + return typeof txt === 'string' || typeof txt === 'number' ? can.esc(txt) : contentText(txt, tag); + }, withinTemplatedSectionWithinAnElement = false, emptyHandler = function () { + }; + var lastHookups; + can.extend(can.view, { + live: live, + setupLists: function () { + var old = can.view.lists, data; + can.view.lists = function (list, renderer) { + data = { + list: list, + renderer: renderer + }; + return Math.random(); + }; + return function () { + can.view.lists = old; + return data; + }; + }, + getHooks: function () { + var hooks = pendingHookups.slice(0); + lastHookups = hooks; + pendingHookups = []; + return hooks; + }, + onlytxt: function (self, func) { + return contentEscape(func.call(self)); + }, + txt: function (escape, tagName, status, self, func) { + var tag = elements.tagMap[tagName] || 'span', setupLiveBinding = false, value, listData, compute, unbind = emptyHandler, attributeName; + if (withinTemplatedSectionWithinAnElement) { + value = func.call(self); + } else { + if (typeof status === 'string' || status === 1) { + withinTemplatedSectionWithinAnElement = true; + } + var listTeardown = can.view.setupLists(); + unbind = function () { + compute.unbind('change', emptyHandler); + }; + compute = can.compute(func, self, false); + compute.bind('change', emptyHandler); + listData = listTeardown(); + value = compute(); + withinTemplatedSectionWithinAnElement = false; + setupLiveBinding = compute.computeInstance.hasDependencies; + } + if (listData) { + unbind(); + return '<' + tag + can.view.hook(function (el, parentNode) { + live.list(el, listData.list, listData.renderer, self, parentNode); + }) + '>'; + } + if (!setupLiveBinding || typeof value === 'function') { + unbind(); + return (withinTemplatedSectionWithinAnElement || escape === 2 || !escape ? contentText : contentEscape)(value, status === 0 && tag); + } + var contentProp = elements.tagToContentPropMap[tagName]; + if (status === 0 && !contentProp) { + return '<' + tag + can.view.hook(escape && typeof value !== 'object' ? function (el, parentNode) { + live.text(el, compute, parentNode); + unbind(); + } : function (el, parentNode) { + live.html(el, compute, parentNode); + unbind(); + }) + '>' + tagChildren(tag) + ''; + } else if (status === 1) { + pendingHookups.push(function (el) { + live.attributes(el, compute, compute()); + unbind(); + }); + return compute(); + } else if (escape === 2) { + attributeName = status; + pendingHookups.push(function (el) { + live.specialAttribute(el, attributeName, compute); + unbind(); + }); + return compute(); + } else { + attributeName = status === 0 ? contentProp : status; + (status === 0 ? lastHookups : pendingHookups).push(function (el) { + live.attribute(el, attributeName, compute); + unbind(); + }); + return live.attributePlaceholder; + } + } + }); + return can; +}); +/*can@2.2.6#view/stache/utils*/ +define('can/view/stache/utils', ['can/util/util'], function () { + return { + isArrayLike: function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, + isObserveLike: function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, + emptyHandler: function () { + }, + jsonParse: function (str) { + if (str[0] === '\'') { + return str.substr(1, str.length - 2); + } else if (str === 'undefined') { + return undefined; + } else if (can.global.JSON) { + return JSON.parse(str); + } else { + return eval('(' + str + ')'); + } + }, + mixins: { + last: function () { + return this.stack[this.stack.length - 1]; + }, + add: function (chars) { + this.last().add(chars); + }, + subSectionDepth: function () { + return this.stack.length - 1; + } + } + }; +}); +/*can@2.2.6#view/stache/mustache_helpers*/ +define('can/view/stache/mustache_helpers', [ + 'can/util/util', + 'can/view/stache/utils', + 'can/view/live/live' +], function (can, utils, live) { + live = live || can.view.live; + var resolve = function (value) { + if (utils.isObserveLike(value) && utils.isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + var helpers = { + 'each': function (items, options) { + var resolved = resolve(items), result = [], keys, key, i; + if (resolved instanceof can.List) { + return function (el) { + var nodeList = [el]; + nodeList.expression = 'live.list'; + can.view.nodeLists.register(nodeList, null, options.nodeList); + can.view.nodeLists.update(options.nodeList, [el]); + var cb = function (item, index, parentNodeList) { + return options.fn(options.scope.add({ '@index': index }).add(item), options.options, parentNodeList); + }; + live.list(el, items, cb, options.context, el.parentNode, nodeList); + }; + } + var expr = resolved; + if (!!expr && utils.isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + } else if (utils.isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } + return result; + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + }, + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!resolve(expr); + } + if (value) { + return options.fn(options.scope || this); + } else { + return options.inverse(options.scope || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return helpers.is.apply(this, arguments); + }, + 'unless': function (expr, options) { + return helpers['if'].apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'with': function (expr, options) { + var ctx = expr; + expr = resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + 'data': function (attr) { + var data = arguments.length === 2 ? this : arguments[1]; + return function (el) { + can.data(can.$(el), attr, data || this.context); + }; + } + }; + return { + registerHelper: function (name, callback) { + helpers[name] = callback; + }, + getHelper: function (name, options) { + var helper = options.attr('helpers.' + name); + if (!helper) { + helper = helpers[name]; + } + if (helper) { + return { fn: helper }; + } + } + }; +}); +/*can@2.2.6#view/stache/mustache_core*/ +define('can/view/stache/mustache_core', [ + 'can/util/util', + 'can/view/stache/utils', + 'can/view/stache/mustache_helpers', + 'can/view/live/live', + 'can/view/elements', + 'can/view/scope/scope', + 'can/view/node_lists/node_lists' +], function (can, utils, mustacheHelpers, live, elements, Scope, nodeLists) { + live = live || can.view.live; + elements = elements || can.view.elements; + Scope = Scope || can.view.Scope; + nodeLists = nodeLists || can.view.nodeLists; + var argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(?:(.+?)=(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(.+))))$/, mustacheLineBreakRegExp = /(?:(?:^|(\r?)\n)(\s*)(\{\{([^\}]*)\}\}\}?)([^\S\n\r]*)($|\r?\n))|(\{\{([^\}]*)\}\}\}?)/g, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, getItemsFragContent = function (items, isObserveList, helperOptions, options) { + var frag = document.createDocumentFragment(); + for (var i = 0, len = items.length; i < len; i++) { + append(frag, helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options)); + } + return frag; + }, append = function (frag, content) { + if (content) { + frag.appendChild(typeof content === 'string' ? document.createTextNode(content) : content); + } + }, getItemsStringContent = function (items, isObserveList, helperOptions, options) { + var txt = ''; + for (var i = 0, len = items.length; i < len; i++) { + txt += helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options); + } + return txt; + }, getKeyComputeData = function (key, scope, isArgument) { + var data = scope.computeData(key, { + isArgument: isArgument, + args: [ + scope.attr('.'), + scope + ] + }); + can.compute.temporarilyBind(data.compute); + return data; + }, getKeyArgValue = function (key, scope) { + var data = getKeyComputeData(key, scope, true); + if (!data.compute.computeInstance.hasDependencies) { + return data.initialValue; + } else { + return data.compute; + } + }, convertToScopes = function (helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer) { + if (truthyRenderer) { + helperOptions.fn = makeRendererConvertScopes(truthyRenderer, scope, options, nodeList); + } + if (falseyRenderer) { + helperOptions.inverse = makeRendererConvertScopes(falseyRenderer, scope, options, nodeList); + } + }, makeRendererConvertScopes = function (renderer, parentScope, parentOptions, nodeList) { + var rendererWithScope = function (ctx, opts, parentNodeList) { + return renderer(ctx || parentScope, opts, parentNodeList); + }; + return can.__notObserve(function (newScope, newOptions, parentNodeList) { + if (newScope !== undefined && !(newScope instanceof can.view.Scope)) { + newScope = parentScope.add(newScope); + } + if (newOptions !== undefined && !(newOptions instanceof core.Options)) { + newOptions = parentOptions.add(newOptions); + } + var result = rendererWithScope(newScope, newOptions || parentOptions, parentNodeList || nodeList); + return result; + }); + }; + var core = { + expressionData: function (expression) { + var args = [], hashes = {}, i = 0; + (can.trim(expression) + ' ').replace(argumentsRegExp, function (whole, arg) { + var m; + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[1] || m[2]) { + args.push(utils.jsonParse(m[1] || m[2])); + } else { + hashes[m[3]] = m[6] ? { get: m[6] } : utils.jsonParse(m[4] || m[5]); + } + } else { + args.push({ get: arg }); + } + i++; + }); + return { + name: args.shift(), + args: args, + hash: hashes + }; + }, + makeEvaluator: function (scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, stringOnly) { + var args = [], hash = {}, helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, context = scope.attr('.'), name = exprData.name, helper, looksLikeAHelper = exprData.args.length || !can.isEmptyObject(exprData.hash), initialValue, helperEvaluator; + for (var i = 0, len = exprData.args.length; i < len; i++) { + var arg = exprData.args[i]; + if (arg && isLookup(arg)) { + args.push(getKeyArgValue(arg.get, scope, true)); + } else { + args.push(arg); + } + } + for (var prop in exprData.hash) { + if (isLookup(exprData.hash[prop])) { + hash[prop] = getKeyArgValue(exprData.hash[prop].get, scope); + } else { + hash[prop] = exprData.hash[prop]; + } + } + if (isLookup(name)) { + if (looksLikeAHelper) { + helper = mustacheHelpers.getHelper(name.get, options); + if (!helper && typeof context[name.get] === 'function') { + helper = { fn: context[name.get] }; + } + } + if (!helper) { + var get = name.get; + var computeData = getKeyComputeData(name.get, scope, false), compute = computeData.compute; + initialValue = computeData.initialValue; + if (computeData.compute.computeInstance.hasDependencies) { + name = compute; + } else { + name = initialValue; + } + if (!looksLikeAHelper && initialValue === undefined) { + helper = mustacheHelpers.getHelper(get, options); + } else if (typeof initialValue === 'function') { + helper = { fn: initialValue }; + } + } + if (!helper && initialValue === undefined) { + if (looksLikeAHelper) { + can.dev.warn('can/view/stache/mustache_core.js: Unable to find helper "' + exprData.name.get + '".'); + } else { + can.dev.warn('can/view/stache/mustache_core.js: Unable to find key or helper "' + exprData.name.get + '".'); + } + } + } + if (mode === '^') { + var temp = truthyRenderer; + truthyRenderer = falseyRenderer; + falseyRenderer = temp; + } + if (helper) { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + can.simpleExtend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash, + nodeList: nodeList, + exprData: exprData + }); + args.push(helperOptions); + helperEvaluator = function () { + return helper.fn.apply(context, args) || ''; + }; + helperEvaluator.bindOnce = false; + return helperEvaluator; + } + if (!mode) { + if (name && name.isComputed) { + return name; + } else { + return function () { + return '' + (name != null ? name : ''); + }; + } + } else if (mode === '#' || mode === '^') { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + var evaluator = function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + if (utils.isArrayLike(value)) { + var isObserveList = utils.isObserveLike(value); + if (isObserveList ? value.attr('length') : value.length) { + return (stringOnly ? getItemsStringContent : getItemsFragContent)(value, isObserveList, helperOptions, options); + } else { + return helperOptions.inverse(scope, options); + } + } else { + return value ? helperOptions.fn(value || scope, options) : helperOptions.inverse(scope, options); + } + }; + evaluator.bindOnce = false; + return evaluator; + } else { + } + }, + makeLiveBindingPartialRenderer: function (partialName, state) { + partialName = can.trim(partialName); + return function (scope, options, parentSectionNodeList) { + var nodeList = [this]; + nodeList.expression = '>' + partialName; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var partialFrag = can.compute(function () { + var localPartialName = partialName; + var partial = options.attr('partials.' + localPartialName), res; + if (partial) { + res = partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + var scopePartialName = scope.read(localPartialName, { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }).value; + if (scopePartialName) { + localPartialName = scopePartialName; + } + res = can.view.render(localPartialName, scope, options); + } + return can.frag(res); + }); + live.html(this, partialFrag, this.parentNode, nodeList); + }; + }, + makeStringBranchRenderer: function (mode, expression) { + var exprData = expressionData(expression), fullExpression = mode + expression; + return function branchRenderer(scope, options, truthyRenderer, falseyRenderer) { + var evaluator = scope.__cache[fullExpression]; + if (mode || !evaluator) { + evaluator = makeEvaluator(scope, options, null, mode, exprData, truthyRenderer, falseyRenderer, true); + if (!mode) { + scope.__cache[fullExpression] = evaluator; + } + } + var res = evaluator(); + return res == null ? '' : '' + res; + }; + }, + makeLiveBindingBranchRenderer: function (mode, expression, state) { + var exprData = expressionData(expression); + return function branchRenderer(scope, options, parentSectionNodeList, truthyRenderer, falseyRenderer) { + var nodeList = [this]; + nodeList.expression = expression; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var evaluator = makeEvaluator(scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, state.tag); + var compute = can.compute(evaluator, null, false, evaluator.bindOnce === false ? false : true); + compute.bind('change', can.k); + var value = compute(); + if (typeof value === 'function') { + var old = can.__clearReading(); + value(this); + can.__setReading(old); + } else if (compute.computeInstance.hasDependencies) { + if (state.attr) { + live.simpleAttribute(this, state.attr, compute); + } else if (state.tag) { + live.attributes(this, compute); + } else if (state.text && typeof value !== 'object') { + live.text(this, compute, this.parentNode, nodeList); + } else { + live.html(this, compute, this.parentNode, nodeList); + } + } else { + if (state.attr) { + can.attr.set(this, state.attr, value); + } else if (state.tag) { + live.setAttributes(this, value); + } else if (state.text && typeof value === 'string') { + this.nodeValue = value; + } else if (value) { + elements.replace([this], can.frag(value)); + } + } + compute.unbind('change', can.k); + }; + }, + splitModeFromExpression: function (expression, state) { + expression = can.trim(expression); + var mode = expression.charAt(0); + if ('#/{&^>!'.indexOf(mode) >= 0) { + expression = can.trim(expression.substr(1)); + } else { + mode = null; + } + if (mode === '{' && state.node) { + mode = null; + } + return { + mode: mode, + expression: expression + }; + }, + cleanLineEndings: function (template) { + return template.replace(mustacheLineBreakRegExp, function (whole, returnBefore, spaceBefore, special, expression, spaceAfter, returnAfter, spaceLessSpecial, spaceLessExpression, matchIndex) { + spaceAfter = spaceAfter || ''; + returnBefore = returnBefore || ''; + spaceBefore = spaceBefore || ''; + var modeAndExpression = splitModeFromExpression(expression || spaceLessExpression, {}); + if (spaceLessSpecial || '>{'.indexOf(modeAndExpression.mode) >= 0) { + return whole; + } else if ('^#!/'.indexOf(modeAndExpression.mode) >= 0) { + return special + (matchIndex !== 0 && returnAfter.length ? returnBefore + '\n' : ''); + } else { + return spaceBefore + special + spaceAfter + (spaceBefore.length || matchIndex !== 0 ? returnBefore + '\n' : ''); + } + }); + }, + Options: can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }) + }; + var makeEvaluator = core.makeEvaluator, expressionData = core.expressionData, splitModeFromExpression = core.splitModeFromExpression; + return core; +}); +/*can@2.2.6#view/bindings/bindings*/ +define('can/view/bindings/bindings', [ + 'can/util/util', + 'can/view/stache/mustache_core', + 'can/view/callbacks/callbacks', + 'can/control/control', + 'can/view/scope/scope' +], function (can, mustacheCore) { + var isContentEditable = function () { + var values = { + '': true, + 'true': true, + 'false': false + }; + var editable = function (el) { + if (!el || !el.getAttribute) { + return; + } + var attr = el.getAttribute('contenteditable'); + return values[attr]; + }; + return function (el) { + var val = editable(el); + if (typeof val === 'boolean') { + return val; + } else { + return !!editable(el.parentNode); + } + }; + }(), removeCurly = function (value) { + if (value[0] === '{' && value[value.length - 1] === '}') { + return value.substr(1, value.length - 2); + } + return value; + }; + can.view.attr('can-value', function (el, data) { + var attr = can.trim(removeCurly(el.getAttribute('can-value'))), value = data.scope.computeData(attr, { args: [] }).compute, trueValue, falseValue; + if (el.nodeName.toLowerCase() === 'input') { + if (el.type === 'checkbox') { + if (can.attr.has(el, 'can-true-value')) { + trueValue = el.getAttribute('can-true-value'); + } else { + trueValue = true; + } + if (can.attr.has(el, 'can-false-value')) { + falseValue = el.getAttribute('can-false-value'); + } else { + falseValue = false; + } + } + if (el.type === 'checkbox' || el.type === 'radio') { + new Checked(el, { + value: value, + trueValue: trueValue, + falseValue: falseValue + }); + return; + } + } + if (el.nodeName.toLowerCase() === 'select' && el.multiple) { + new Multiselect(el, { value: value }); + return; + } + if (isContentEditable(el)) { + new Content(el, { value: value }); + return; + } + new Value(el, { value: value }); + }); + var special = { + enter: function (data, el, original) { + return { + event: 'keyup', + handler: function (ev) { + if (ev.keyCode === 13) { + return original.call(this, ev); + } + } + }; + } + }; + can.view.attr(/can-[\w\.]+/, function (el, data) { + var attributeName = data.attributeName, event = attributeName.substr('can-'.length), handler = function (ev) { + var attrVal = el.getAttribute(attributeName); + if (!attrVal) { + return; + } + var attrInfo = mustacheCore.expressionData(removeCurly(attrVal)); + var scopeData = data.scope.read(attrInfo.name.get, { + returnObserveMethods: true, + isArgument: true, + executeAnonymousFunctions: true + }); + if (!scopeData.value) { + can.dev.warn('can/view/bindings: ' + attributeName + ' couldn\'t find method named ' + attrInfo.name.get, { + element: el, + scope: data.scope + }); + return null; + } + var args = []; + var $el = can.$(this); + var viewModel = can.viewModel($el[0]); + var localScope = data.scope.add({ + '@element': $el, + '@event': ev, + '@viewModel': viewModel, + '@scope': data.scope, + '@context': data.scope._context + }); + if (!can.isEmptyObject(attrInfo.hash)) { + var hash = {}; + can.each(attrInfo.hash, function (val, key) { + if (val && val.hasOwnProperty('get')) { + var s = !val.get.indexOf('@') ? localScope : data.scope; + hash[key] = s.read(val.get, {}).value; + } else { + hash[key] = val; + } + }); + args.unshift(hash); + } + if (attrInfo.args.length) { + var arg; + for (var i = attrInfo.args.length - 1; i >= 0; i--) { + arg = attrInfo.args[i]; + if (arg && arg.hasOwnProperty('get')) { + var s = !arg.get.indexOf('@') ? localScope : data.scope; + args.unshift(s.read(arg.get, {}).value); + } else { + args.unshift(arg); + } + } + } + if (!args.length) { + args = [ + data.scope._context, + $el + ].concat(can.makeArray(arguments)); + } + return scopeData.value.apply(scopeData.parent, args); + }; + if (special[event]) { + var specialData = special[event](data, el, handler); + handler = specialData.handler; + event = specialData.event; + } + can.bind.call(el, event, handler); + }); + var Value = can.Control.extend({ + init: function () { + if (this.element[0].nodeName.toUpperCase() === 'SELECT') { + setTimeout(can.proxy(this.set, this), 1); + } else { + this.set(); + } + }, + '{value} change': 'set', + set: function () { + if (!this.element) { + return; + } + var val = this.options.value(); + this.element[0].value = val == null ? '' : val; + }, + 'change': function () { + if (!this.element) { + return; + } + var el = this.element[0]; + this.options.value(el.value); + var newVal = this.options.value(); + if (el.value !== newVal) { + el.value = newVal; + } + } + }), Checked = can.Control.extend({ + init: function () { + this.isCheckbox = this.element[0].type.toLowerCase() === 'checkbox'; + this.check(); + }, + '{value} change': 'check', + check: function () { + if (this.isCheckbox) { + var value = this.options.value(), trueValue = this.options.trueValue || true; + this.element[0].checked = value == trueValue; + } else { + var setOrRemove = this.options.value() == this.element[0].value ? 'set' : 'remove'; + can.attr[setOrRemove](this.element[0], 'checked', true); + } + }, + 'change': function () { + if (this.isCheckbox) { + this.options.value(this.element[0].checked ? this.options.trueValue : this.options.falseValue); + } else { + if (this.element[0].checked) { + this.options.value(this.element[0].value); + } + } + } + }), Multiselect = Value.extend({ + init: function () { + this.delimiter = ';'; + setTimeout(can.proxy(this.set, this), 1); + }, + set: function () { + var newVal = this.options.value(); + if (typeof newVal === 'string') { + newVal = newVal.split(this.delimiter); + this.isString = true; + } else if (newVal) { + newVal = can.makeArray(newVal); + } + var isSelected = {}; + can.each(newVal, function (val) { + isSelected[val] = true; + }); + can.each(this.element[0].childNodes, function (option) { + if (option.value) { + option.selected = !!isSelected[option.value]; + } + }); + }, + get: function () { + var values = [], children = this.element[0].childNodes; + can.each(children, function (child) { + if (child.selected && child.value) { + values.push(child.value); + } + }); + return values; + }, + 'change': function () { + var value = this.get(), currentValue = this.options.value(); + if (this.isString || typeof currentValue === 'string') { + this.isString = true; + this.options.value(value.join(this.delimiter)); + } else if (currentValue instanceof can.List) { + currentValue.attr(value, true); + } else { + this.options.value(value); + } + } + }), Content = can.Control.extend({ + init: function () { + this.set(); + this.on('blur', 'setValue'); + }, + '{value} change': 'set', + set: function () { + var val = this.options.value(); + this.element[0].innerHTML = typeof val === 'undefined' ? '' : val; + }, + setValue: function () { + this.options.value(this.element[0].innerHTML); + } + }); +}); +/*can@2.2.6#view/mustache/mustache*/ +define('can/view/mustache/mustache', [ + 'can/util/util', + 'can/view/scope/scope', + 'can/view/view', + 'can/view/scanner', + 'can/compute/compute', + 'can/view/render', + 'can/view/bindings/bindings' +], function (can) { + can.view.ext = '.mustache'; + var SCOPE = 'scope', HASH = '___h4sh', CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options}', SPECIAL_CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options, special: true}', ARG_NAMES = SCOPE + ',options', argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false|null|undefined)|((.+?)=(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false)|(.+))))$/, makeLookupLiteral = function (type) { + return '{get:"' + type.replace(/"/g, '\\"') + '"}'; + }, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, isObserveLike = function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, isArrayLike = function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, makeConvertToScopes = function (original, scope, options) { + var originalWithScope = function (ctx, opts) { + return original(ctx || scope, opts); + }; + return function (updatedScope, updatedOptions) { + if (updatedScope !== undefined && !(updatedScope instanceof can.view.Scope)) { + updatedScope = scope.add(updatedScope); + } + if (updatedOptions !== undefined && !(updatedOptions instanceof can.view.Options)) { + updatedOptions = options.add(updatedOptions); + } + return originalWithScope(updatedScope, updatedOptions || options); + }; + }; + var Mustache = function (options, helpers) { + if (this.constructor !== Mustache) { + var mustache = new Mustache(options); + return function (data, options) { + return mustache.render(data, options); + }; + } + if (typeof options === 'function') { + this.template = { fn: options }; + return; + } + can.extend(this, options); + this.template = this.scanner.scan(this.text, this.name); + }; + can.Mustache = can.global.Mustache = Mustache; + Mustache.prototype.render = function (data, options) { + if (!(data instanceof can.view.Scope)) { + data = new can.view.Scope(data || {}); + } + if (!(options instanceof can.view.Options)) { + options = new can.view.Options(options || {}); + } + options = options || {}; + return this.template.fn.call(data, data, options); + }; + can.extend(Mustache.prototype, { + scanner: new can.view.Scanner({ + text: { + start: '', + scope: SCOPE, + options: ',options: options', + argNames: ARG_NAMES + }, + tokens: [ + [ + 'returnLeft', + '{{{', + '{{[{&]' + ], + [ + 'commentFull', + '{{!}}', + '^[\\s\\t]*{{!.+?}}\\n' + ], + [ + 'commentLeft', + '{{!', + '(\\n[\\s\\t]*{{!|{{!)' + ], + [ + 'escapeFull', + '{{}}', + '(^[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}$)', + function (content) { + return { + before: /^\n.+?\n$/.test(content) ? '\n' : '', + content: content.match(/\{\{(.+?)\}\}/)[1] || '' + }; + } + ], + [ + 'escapeLeft', + '{{' + ], + [ + 'returnRight', + '}}}' + ], + [ + 'right', + '}}' + ] + ], + helpers: [ + { + name: /^>[\s]*\w*/, + fn: function (content, cmd) { + var templateName = can.trim(content.replace(/^>\s?/, '')).replace(/["|']/g, ''); + return 'can.Mustache.renderPartial(\'' + templateName + '\',' + ARG_NAMES + ')'; + } + }, + { + name: /^\s*data\s/, + fn: function (content, cmd) { + var attr = content.match(/["|'](.*)["|']/)[1]; + return 'can.proxy(function(__){' + 'can.data(can.$(__),\'' + attr + '\', this.attr(\'.\')); }, ' + SCOPE + ')'; + } + }, + { + name: /\s*\(([\$\w]+)\)\s*->([^\n]*)/, + fn: function (content) { + var quickFunc = /\s*\(([\$\w]+)\)\s*->([^\n]*)/, parts = content.match(quickFunc); + return 'can.proxy(function(__){var ' + parts[1] + '=can.$(__);with(' + SCOPE + '.attr(\'.\')){' + parts[2] + '}}, this);'; + } + }, + { + name: /^.*$/, + fn: function (content, cmd) { + var mode = false, result = { + content: '', + startTxt: false, + startOnlyTxt: false, + end: false + }; + content = can.trim(content); + if (content.length && (mode = content.match(/^([#^\/]|else$)/))) { + mode = mode[0]; + switch (mode) { + case '#': + case '^': + if (cmd.specialAttribute) { + result.startOnlyTxt = true; + } else { + result.startTxt = true; + result.escaped = 0; + } + break; + case '/': + result.end = true; + result.content += 'return ___v1ew.join("");}}])'; + return result; + } + content = content.substring(1); + } + if (mode !== 'else') { + var args = [], hashes = [], i = 0, m; + result.content += 'can.Mustache.txt(\n' + (cmd.specialAttribute ? SPECIAL_CONTEXT_OBJ : CONTEXT_OBJ) + ',\n' + (mode ? '"' + mode + '"' : 'null') + ','; + (can.trim(content) + ' ').replace(argumentsRegExp, function (whole, arg) { + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[2]) { + args.push(m[0]); + } else { + hashes.push(m[4] + ':' + (m[6] ? m[6] : makeLookupLiteral(m[5]))); + } + } else { + args.push(makeLookupLiteral(arg)); + } + i++; + }); + result.content += args.join(','); + if (hashes.length) { + result.content += ',{' + HASH + ':{' + hashes.join(',') + '}}'; + } + } + if (mode && mode !== 'else') { + result.content += ',[\n\n'; + } + switch (mode) { + case '^': + case '#': + result.content += '{fn:function(' + ARG_NAMES + '){var ___v1ew = [];'; + break; + case 'else': + result.content += 'return ___v1ew.join("");}},\n{inverse:function(' + ARG_NAMES + '){\nvar ___v1ew = [];'; + break; + default: + result.content += ')'; + break; + } + if (!mode) { + result.startTxt = true; + result.end = true; + } + return result; + } + } + ] + }) + }); + var helpers = can.view.Scanner.prototype.helpers; + for (var i = 0; i < helpers.length; i++) { + Mustache.prototype.scanner.helpers.unshift(helpers[i]); + } + Mustache.txt = function (scopeAndOptions, mode, name) { + var scope = scopeAndOptions.scope, options = scopeAndOptions.options, args = [], helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, hash, context = scope.attr('.'), getHelper = true, helper; + for (var i = 3; i < arguments.length; i++) { + var arg = arguments[i]; + if (mode && can.isArray(arg)) { + helperOptions = can.extend.apply(can, [helperOptions].concat(arg)); + } else if (arg && arg[HASH]) { + hash = arg[HASH]; + for (var prop in hash) { + if (isLookup(hash[prop])) { + hash[prop] = Mustache.get(hash[prop].get, scopeAndOptions, false, true); + } + } + } else if (arg && isLookup(arg)) { + args.push(Mustache.get(arg.get, scopeAndOptions, false, true, true)); + } else { + args.push(arg); + } + } + if (isLookup(name)) { + var get = name.get; + name = Mustache.get(name.get, scopeAndOptions, args.length, false); + getHelper = get === name; + } + helperOptions.fn = makeConvertToScopes(helperOptions.fn, scope, options); + helperOptions.inverse = makeConvertToScopes(helperOptions.inverse, scope, options); + if (mode === '^') { + var tmp = helperOptions.fn; + helperOptions.fn = helperOptions.inverse; + helperOptions.inverse = tmp; + } + if (helper = getHelper && (typeof name === 'string' && Mustache.getHelper(name, options)) || can.isFunction(name) && !name.isComputed && { fn: name }) { + can.extend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash + }); + args.push(helperOptions); + return function () { + return helper.fn.apply(context, args) || ''; + }; + } + return function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + var validArgs = args.length ? args : [value], valid = true, result = [], i, argIsObserve, arg; + if (mode) { + for (i = 0; i < validArgs.length; i++) { + arg = validArgs[i]; + argIsObserve = typeof arg !== 'undefined' && isObserveLike(arg); + if (isArrayLike(arg)) { + if (mode === '#') { + valid = valid && !!(argIsObserve ? arg.attr('length') : arg.length); + } else if (mode === '^') { + valid = valid && !(argIsObserve ? arg.attr('length') : arg.length); + } + } else { + valid = mode === '#' ? valid && !!arg : mode === '^' ? valid && !arg : valid; + } + } + } + if (valid) { + if (mode === '#') { + if (isArrayLike(value)) { + var isObserveList = isObserveLike(value); + for (i = 0; i < value.length; i++) { + result.push(helperOptions.fn(isObserveList ? value.attr('' + i) : value[i])); + } + return result.join(''); + } else { + return helperOptions.fn(value || {}) || ''; + } + } else if (mode === '^') { + return helperOptions.inverse(value || {}) || ''; + } else { + return '' + (value != null ? value : ''); + } + } + return ''; + }; + }; + Mustache.get = function (key, scopeAndOptions, isHelper, isArgument, isLookup) { + var context = scopeAndOptions.scope.attr('.'), options = scopeAndOptions.options || {}; + if (isHelper) { + if (Mustache.getHelper(key, options)) { + return key; + } + if (scopeAndOptions.scope && can.isFunction(context[key])) { + return context[key]; + } + can.dev.warn('can/view/mustache/mustache.js: Unable to find helper "' + key + '".'); + } + var computeData = scopeAndOptions.scope.computeData(key, { + isArgument: isArgument, + args: [ + context, + scopeAndOptions.scope + ] + }), compute = computeData.compute; + can.compute.temporarilyBind(compute); + var initialValue = computeData.initialValue, helperObj = Mustache.getHelper(key, options); + if (initialValue === undefined && !isHelper && !helperObj) { + can.dev.warn('can/view/mustache/mustache.js: Unable to find key "' + key + '".'); + } + if (!isLookup && (initialValue === undefined || computeData.scope !== scopeAndOptions.scope) && Mustache.getHelper(key, options)) { + return key; + } + if (!compute.computeInstance.hasDependencies) { + return initialValue; + } else { + return compute; + } + }; + Mustache.resolve = function (value) { + if (isObserveLike(value) && isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + can.view.Options = can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }); + Mustache._helpers = {}; + Mustache.registerHelper = function (name, fn) { + this._helpers[name] = { + name: name, + fn: fn + }; + }; + Mustache.getHelper = function (name, options) { + var helper; + if (options) { + helper = options.attr('helpers.' + name); + } + return helper ? { fn: helper } : this._helpers[name]; + }; + Mustache.render = function (partial, scope, options) { + if (!can.view.cached[partial]) { + var reads = can.__clearReading(); + var scopePartialName = scope.attr(partial); + if (scopePartialName) { + partial = scopePartialName; + } + can.__setReading(reads); + } + return can.view.render(partial, scope, options); + }; + Mustache.safeString = function (str) { + return { + toString: function () { + return str; + } + }; + }; + Mustache.renderPartial = function (partialName, scope, options) { + var partial = options.attr('partials.' + partialName); + if (partial) { + return partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + return can.Mustache.render(partialName, scope, options); + } + }; + can.each({ + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!Mustache.resolve(expr); + } + if (value) { + return options.fn(options.contexts || this); + } else { + return options.inverse(options.contexts || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = Mustache.resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return Mustache._helpers.is.fn.apply(this, arguments); + }, + 'unless': function (expr, options) { + return Mustache._helpers['if'].fn.apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'each': function (expr, options) { + var resolved = Mustache.resolve(expr), result = [], keys, key, i; + if (can.view.lists && (resolved instanceof can.List || expr && expr.isComputed && resolved === undefined)) { + return can.view.lists(expr, function (item, index) { + return options.fn(options.scope.add({ '@index': index }).add(item)); + }); + } + expr = resolved; + if (!!expr && isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + return result.join(''); + } else if (isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } + }, + 'with': function (expr, options) { + var ctx = expr; + expr = Mustache.resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + } + }, function (fn, name) { + Mustache.registerHelper(name, fn); + }); + can.view.register({ + suffix: 'mustache', + contentType: 'x-mustache-template', + script: function (id, src) { + return 'can.Mustache(function(' + ARG_NAMES + ') { ' + new Mustache({ + text: src, + name: id + }).template.out + ' })'; + }, + renderer: function (id, text) { + return Mustache({ + text: text, + name: id + }); + } + }); + can.mustache.registerHelper = can.proxy(can.Mustache.registerHelper, can.Mustache); + can.mustache.safeString = can.Mustache.safeString; + return can; +}); +/*can@2.2.6#component/component*/ +define('can/component/component', [ + 'can/util/util', + 'can/view/callbacks/callbacks', + 'can/view/elements', + 'can/control/control', + 'can/observe/observe', + 'can/view/mustache/mustache', + 'can/view/bindings/bindings' +], function (can, viewCallbacks, elements) { + var ignoreAttributesRegExp = /^(dataViewId|class|id)$/i, paramReplacer = /\{([^\}]+)\}/g; + var Component = can.Component = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Component) { + var self = this, scope = this.prototype.scope || this.prototype.viewModel; + this.Control = ComponentControl.extend(this.prototype.events); + if (!scope || typeof scope === 'object' && !(scope instanceof can.Map)) { + this.Map = can.Map.extend(scope || {}); + } else if (scope.prototype instanceof can.Map) { + this.Map = scope; + } + this.attributeScopeMappings = {}; + can.each(this.Map ? this.Map.defaults : {}, function (val, prop) { + if (val === '@') { + self.attributeScopeMappings[prop] = prop; + } + }); + if (this.prototype.template) { + if (typeof this.prototype.template === 'function') { + var temp = this.prototype.template; + this.renderer = function () { + return can.view.frag(temp.apply(null, arguments)); + }; + } else { + this.renderer = can.view.mustache(this.prototype.template); + } + } + can.view.tag(this.prototype.tag, function (el, options) { + new self(el, options); + }); + } + } + }, { + setup: function (el, hookupOptions) { + var initialScopeData = {}, component = this, lexicalContent = (typeof this.leakScope === 'undefined' ? false : !this.leakScope) && this.template, twoWayBindings = {}, scope = this.scope || this.viewModel, viewModelPropertyUpdates = {}, componentScope, frag, teardownFunctions = [], callTeardownFunctions = function () { + for (var i = 0, len = teardownFunctions.length; i < len; i++) { + teardownFunctions[i](); + } + }; + can.each(this.constructor.attributeScopeMappings, function (val, prop) { + initialScopeData[prop] = el.getAttribute(can.hyphenate(val)); + }); + can.each(can.makeArray(el.attributes), function (node, index) { + var name = can.camelize(node.nodeName.toLowerCase()), value = node.value; + if (ignoreAttributesRegExp.test(name) && value[0] === '{' && value[value.length - 1] === '}') { + can.dev.warn('can/component: looks like you\'re trying to pass ' + name + ' as an attribute into a component, ' + 'but it is not a supported attribute'); + } + if (component.constructor.attributeScopeMappings[name] || ignoreAttributesRegExp.test(name) || viewCallbacks.attr(node.nodeName)) { + return; + } + if (value[0] === '{' && value[value.length - 1] === '}') { + value = value.substr(1, value.length - 2); + } else { + if (hookupOptions.templateType !== 'legacy') { + initialScopeData[name] = value; + return; + } + } + var computeData = hookupOptions.scope.computeData(value, { args: [] }), compute = computeData.compute; + var handler = function (ev, newVal) { + viewModelPropertyUpdates[name] = (viewModelPropertyUpdates[name] || 0) + 1; + componentScope.attr(name, newVal); + can.batch.afterPreviousEvents(function () { + --viewModelPropertyUpdates[name]; + }); + }; + compute.bind('change', handler); + initialScopeData[name] = compute(); + if (!compute.computeInstance.hasDependencies) { + compute.unbind('change', handler); + } else { + teardownFunctions.push(function () { + compute.unbind('change', handler); + }); + twoWayBindings[name] = computeData; + } + }); + if (this.constructor.Map) { + componentScope = new this.constructor.Map(initialScopeData); + } else if (scope instanceof can.Map) { + componentScope = scope; + } else if (can.isFunction(scope)) { + var scopeResult = scope.call(this, initialScopeData, hookupOptions.scope, el); + if (scopeResult instanceof can.Map) { + componentScope = scopeResult; + } else if (scopeResult.prototype instanceof can.Map) { + componentScope = new scopeResult(initialScopeData); + } else { + componentScope = new (can.Map.extend(scopeResult))(initialScopeData); + } + } + var handlers = {}; + can.each(twoWayBindings, function (computeData, prop) { + handlers[prop] = function (ev, newVal) { + if (!viewModelPropertyUpdates[prop]) { + computeData.compute(newVal); + } + }; + componentScope.bind(prop, handlers[prop]); + }); + if (!can.isEmptyObject(this.constructor.attributeScopeMappings) || hookupOptions.templateType !== 'legacy') { + can.bind.call(el, 'attributes', function (ev) { + var camelized = can.camelize(ev.attributeName); + if (!twoWayBindings[camelized] && !ignoreAttributesRegExp.test(camelized)) { + componentScope.attr(camelized, el.getAttribute(ev.attributeName)); + } + }); + } + this.scope = this.viewModel = componentScope; + can.data(can.$(el), 'scope', this.scope); + can.data(can.$(el), 'viewModel', this.scope); + var renderedScope = lexicalContent ? this.scope : hookupOptions.scope.add(this.scope), options = { helpers: {} }; + can.each(this.helpers || {}, function (val, prop) { + if (can.isFunction(val)) { + options.helpers[prop] = function () { + return val.apply(componentScope, arguments); + }; + } + }); + teardownFunctions.push(function () { + can.each(handlers, function (handler, prop) { + componentScope.unbind(prop, handlers[prop]); + }); + }); + this._control = new this.constructor.Control(el, { + scope: this.scope, + viewModel: this.scope + }); + if (this._control && this._control.destroy) { + var oldDestroy = this._control.destroy; + this._control.destroy = function () { + oldDestroy.apply(this, arguments); + callTeardownFunctions(); + }; + this._control.on(); + } else { + can.bind.call(el, 'removed', function () { + callTeardownFunctions(); + }); + } + var nodeList = can.view.nodeLists.register([], undefined, true); + teardownFunctions.push(function () { + can.view.nodeLists.unregister(nodeList); + }); + if (this.constructor.renderer) { + if (!options.tags) { + options.tags = {}; + } + options.tags.content = function contentHookup(el, rendererOptions) { + var subtemplate = hookupOptions.subtemplate || rendererOptions.subtemplate; + if (subtemplate) { + delete options.tags.content; + var opts = !lexicalContent || subtemplate !== hookupOptions.subtemplate ? rendererOptions : hookupOptions; + if (rendererOptions.parentNodeList) { + var frag = subtemplate(opts.scope, opts.options, rendererOptions.parentNodeList); + elements.replace([el], frag); + } else { + can.view.live.replace([el], subtemplate(opts.scope, opts.options)); + } + options.tags.content = contentHookup; + } + }; + frag = this.constructor.renderer(renderedScope, hookupOptions.options.add(options), nodeList); + } else { + if (hookupOptions.templateType === 'legacy') { + frag = can.view.frag(hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options)) : ''); + } else { + frag = hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options), nodeList) : document.createDocumentFragment(); + } + } + can.appendChild(el, frag); + can.view.nodeLists.update(nodeList, el.childNodes); + } + }); + var ComponentControl = can.Control.extend({ + _lookup: function (options) { + return [ + options.scope, + options, + window + ]; + }, + _action: function (methodName, options, controlInstance) { + var hasObjectLookup, readyCompute; + paramReplacer.lastIndex = 0; + hasObjectLookup = paramReplacer.test(methodName); + if (!controlInstance && hasObjectLookup) { + return; + } else if (!hasObjectLookup) { + return can.Control._action.apply(this, arguments); + } else { + readyCompute = can.compute(function () { + var delegate; + var name = methodName.replace(paramReplacer, function (matched, key) { + var value; + if (key === 'scope' || key === 'viewModel') { + delegate = options.scope; + return ''; + } + key = key.replace(/^(scope|^viewModel)\./, ''); + value = can.compute.read(options.scope, key.split('.'), { isArgument: true }).value; + if (value === undefined) { + value = can.getObject(key); + } + if (typeof value === 'string') { + return value; + } else { + delegate = value; + return ''; + } + }); + var parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: this.processors[event] || this.processors.click, + parts: [ + name, + parts.join(' '), + event + ], + delegate: delegate || undefined + }; + }, this); + var handler = function (ev, ready) { + controlInstance._bindings.control[methodName](controlInstance.element); + controlInstance._bindings.control[methodName] = ready.processor(ready.delegate || controlInstance.element, ready.parts[2], ready.parts[1], methodName, controlInstance); + }; + readyCompute.bind('change', handler); + controlInstance._bindings.readyComputes[methodName] = { + compute: readyCompute, + handler: handler + }; + return readyCompute(); + } + } + }, { + setup: function (el, options) { + this.scope = options.scope; + this.viewModel = options.viewModel; + return can.Control.prototype.setup.call(this, el, options); + }, + off: function () { + if (this._bindings) { + can.each(this._bindings.readyComputes || {}, function (value) { + value.compute.unbind('change', value.handler); + }); + } + can.Control.prototype.off.apply(this, arguments); + this._bindings.readyComputes = {}; + } + }); + var $ = can.$; + if ($.fn) { + $.fn.scope = $.fn.viewModel = function () { + return can.viewModel.apply(can, [this].concat(can.makeArray(arguments))); + }; + } + return Component; +}); +/*can@2.2.6#model/model*/ +define('can/model/model', [ + 'can/util/util', + 'can/map/map', + 'can/list/list' +], function (can) { + var pipe = function (def, thisArg, func) { + var d = new can.Deferred(); + def.then(function () { + var args = can.makeArray(arguments), success = true; + try { + args[0] = func.apply(thisArg, args); + } catch (e) { + success = false; + d.rejectWith(d, [e].concat(args)); + } + if (success) { + d.resolveWith(d, args); + } + }, function () { + d.rejectWith(this, arguments); + }); + if (typeof def.abort === 'function') { + d.abort = function () { + return def.abort(); + }; + } + return d; + }, modelNum = 0, getId = function (inst) { + can.__observe(inst, inst.constructor.id); + return inst.__get(inst.constructor.id); + }, ajax = function (ajaxOb, data, type, dataType, success, error) { + var params = {}; + if (typeof ajaxOb === 'string') { + var parts = ajaxOb.split(/\s+/); + params.url = parts.pop(); + if (parts.length) { + params.type = parts.pop(); + } + } else { + can.extend(params, ajaxOb); + } + params.data = typeof data === 'object' && !can.isArray(data) ? can.extend(params.data || {}, data) : data; + params.url = can.sub(params.url, params.data, true); + return can.ajax(can.extend({ + type: type || 'post', + dataType: dataType || 'json', + success: success, + error: error + }, params)); + }, makeRequest = function (modelObj, type, success, error, method) { + var args; + if (can.isArray(modelObj)) { + args = modelObj[1]; + modelObj = modelObj[0]; + } else { + args = modelObj.serialize(); + } + args = [args]; + var deferred, model = modelObj.constructor, jqXHR; + if (type === 'update' || type === 'destroy') { + args.unshift(getId(modelObj)); + } + jqXHR = model[type].apply(model, args); + deferred = pipe(jqXHR, modelObj, function (data) { + modelObj[method || type + 'd'](data, jqXHR); + return modelObj; + }); + if (jqXHR.abort) { + deferred.abort = function () { + jqXHR.abort(); + }; + } + deferred.then(success, error); + return deferred; + }, converters = { + models: function (instancesRawData, oldList, xhr) { + can.Model._reqs++; + if (!instancesRawData) { + return; + } + if (instancesRawData instanceof this.List) { + return instancesRawData; + } + var self = this, tmp = [], ListClass = self.List || ML, modelList = oldList instanceof can.List ? oldList : new ListClass(), rawDataIsList = instancesRawData instanceof ML, raw = rawDataIsList ? instancesRawData.serialize() : instancesRawData; + raw = self.parseModels(raw, xhr); + if (raw.data) { + instancesRawData = raw; + raw = raw.data; + } + if (typeof raw === 'undefined' || !can.isArray(raw)) { + throw new Error('Could not get any raw data while converting using .models'); + } + if (!raw.length) { + can.dev.warn('model.js models has no data.'); + } + if (modelList.length) { + modelList.splice(0); + } + can.each(raw, function (rawPart) { + tmp.push(self.model(rawPart, xhr)); + }); + modelList.push.apply(modelList, tmp); + if (!can.isArray(instancesRawData)) { + can.each(instancesRawData, function (val, prop) { + if (prop !== 'data') { + modelList.attr(prop, val); + } + }); + } + setTimeout(can.proxy(this._clean, this), 1); + return modelList; + }, + model: function (attributes, oldModel, xhr) { + if (!attributes) { + return; + } + if (typeof attributes.serialize === 'function') { + attributes = attributes.serialize(); + } else { + attributes = this.parseModel(attributes, xhr); + } + var id = attributes[this.id]; + if ((id || id === 0) && this.store[id]) { + oldModel = this.store[id]; + } + var model = oldModel && can.isFunction(oldModel.attr) ? oldModel.attr(attributes, this.removeAttr || false) : new this(attributes); + return model; + } + }, makeParser = { + parseModel: function (prop) { + return function (attributes) { + return prop ? can.getObject(prop, attributes) : attributes; + }; + }, + parseModels: function (prop) { + return function (attributes) { + if (can.isArray(attributes)) { + return attributes; + } + prop = prop || 'data'; + var result = can.getObject(prop, attributes); + if (!can.isArray(result)) { + throw new Error('Could not get any raw data while converting using .models'); + } + return result; + }; + } + }, ajaxMethods = { + create: { + url: '_shortName', + type: 'post' + }, + update: { + data: function (id, attrs) { + attrs = attrs || {}; + var identity = this.id; + if (attrs[identity] && attrs[identity] !== id) { + attrs['new' + can.capitalize(id)] = attrs[identity]; + delete attrs[identity]; + } + attrs[identity] = id; + return attrs; + }, + type: 'put' + }, + destroy: { + type: 'delete', + data: function (id, attrs) { + attrs = attrs || {}; + attrs.id = attrs[this.id] = id; + return attrs; + } + }, + findAll: { url: '_shortName' }, + findOne: {} + }, ajaxMaker = function (ajaxMethod, str) { + return function (data) { + data = ajaxMethod.data ? ajaxMethod.data.apply(this, arguments) : data; + return ajax(str || this[ajaxMethod.url || '_url'], data, ajaxMethod.type || 'get'); + }; + }, createURLFromResource = function (model, name) { + if (!model.resource) { + return; + } + var resource = model.resource.replace(/\/+$/, ''); + if (name === 'findAll' || name === 'create') { + return resource; + } else { + return resource + '/{' + model.id + '}'; + } + }; + can.Model = can.Map.extend({ + fullName: 'can.Model', + _reqs: 0, + setup: function (base, fullName, staticProps, protoProps) { + if (typeof fullName !== 'string') { + protoProps = staticProps; + staticProps = fullName; + } + if (!protoProps) { + can.dev.warn('can/model/model.js: can.Model extended without static properties.'); + protoProps = staticProps; + } + this.store = {}; + can.Map.setup.apply(this, arguments); + if (!can.Model) { + return; + } + if (staticProps && staticProps.List) { + this.List = staticProps.List; + this.List.Map = this; + } else { + this.List = base.List.extend({ Map: this }, {}); + } + var self = this, clean = can.proxy(this._clean, self); + can.each(ajaxMethods, function (method, name) { + if (staticProps && staticProps[name] && (typeof staticProps[name] === 'string' || typeof staticProps[name] === 'object')) { + self[name] = ajaxMaker(method, staticProps[name]); + } else if (staticProps && staticProps.resource && !can.isFunction(staticProps[name])) { + self[name] = ajaxMaker(method, createURLFromResource(self, name)); + } + if (self['make' + can.capitalize(name)]) { + var newMethod = self['make' + can.capitalize(name)](self[name]); + can.Construct._overwrite(self, base, name, function () { + can.Model._reqs++; + var def = newMethod.apply(this, arguments); + var then = def.then(clean, clean); + then.abort = def.abort; + return then; + }); + } + }); + var hasCustomConverter = {}; + can.each(converters, function (converter, name) { + var parseName = 'parse' + can.capitalize(name), dataProperty = staticProps && staticProps[name] || self[name]; + if (typeof dataProperty === 'string') { + self[parseName] = dataProperty; + can.Construct._overwrite(self, base, name, converter); + } else if (staticProps && staticProps[name]) { + hasCustomConverter[parseName] = true; + } + }); + can.each(makeParser, function (maker, parseName) { + var prop = staticProps && staticProps[parseName] || self[parseName]; + if (typeof prop === 'string') { + can.Construct._overwrite(self, base, parseName, maker(prop)); + } else if ((!staticProps || !can.isFunction(staticProps[parseName])) && !self[parseName]) { + var madeParser = maker(); + madeParser.useModelConverter = hasCustomConverter[parseName]; + can.Construct._overwrite(self, base, parseName, madeParser); + } + }); + if (self.fullName === 'can.Model' || !self.fullName) { + self.fullName = 'Model' + ++modelNum; + } + can.Model._reqs = 0; + this._url = this._shortName + '/{' + this.id + '}'; + }, + _ajax: ajaxMaker, + _makeRequest: makeRequest, + _clean: function () { + can.Model._reqs--; + if (!can.Model._reqs) { + for (var id in this.store) { + if (!this.store[id]._bindings) { + delete this.store[id]; + } + } + } + return arguments[0]; + }, + models: converters.models, + model: converters.model + }, { + setup: function (attrs) { + var id = attrs && attrs[this.constructor.id]; + if (can.Model._reqs && id != null) { + this.constructor.store[id] = this; + } + can.Map.prototype.setup.apply(this, arguments); + }, + isNew: function () { + var id = getId(this); + return !(id || id === 0); + }, + save: function (success, error) { + return makeRequest(this, this.isNew() ? 'create' : 'update', success, error); + }, + destroy: function (success, error) { + if (this.isNew()) { + var self = this; + var def = can.Deferred(); + def.then(success, error); + return def.done(function (data) { + self.destroyed(data); + }).resolve(self); + } + return makeRequest(this, 'destroy', success, error, 'destroyed'); + }, + _bindsetup: function () { + var modelInstance = this.__get(this.constructor.id); + if (modelInstance != null) { + this.constructor.store[modelInstance] = this; + } + return can.Map.prototype._bindsetup.apply(this, arguments); + }, + _bindteardown: function () { + delete this.constructor.store[getId(this)]; + return can.Map.prototype._bindteardown.apply(this, arguments); + }, + ___set: function (prop, val) { + can.Map.prototype.___set.call(this, prop, val); + if (prop === this.constructor.id && this._bindings) { + this.constructor.store[getId(this)] = this; + } + } + }); + var makeGetterHandler = function (name) { + return function (data, readyState, xhr) { + return this[name](data, null, xhr); + }; + }, createUpdateDestroyHandler = function (data) { + if (this.parseModel.useModelConverter) { + return this.model(data); + } + return this.parseModel(data); + }; + var responseHandlers = { + makeFindAll: makeGetterHandler('models'), + makeFindOne: makeGetterHandler('model'), + makeCreate: createUpdateDestroyHandler, + makeUpdate: createUpdateDestroyHandler, + makeDestroy: createUpdateDestroyHandler + }; + can.each(responseHandlers, function (method, name) { + can.Model[name] = function (oldMethod) { + return function () { + var args = can.makeArray(arguments), oldArgs = can.isFunction(args[1]) ? args.splice(0, 1) : args.splice(0, 2), def = pipe(oldMethod.apply(this, oldArgs), this, method); + def.then(args[0], args[1]); + return def; + }; + }; + }); + can.each([ + 'created', + 'updated', + 'destroyed' + ], function (funcName) { + can.Model.prototype[funcName] = function (attrs) { + var self = this, constructor = self.constructor; + if (attrs && typeof attrs === 'object') { + this.attr(can.isFunction(attrs.attr) ? attrs.attr() : attrs); + } + can.dispatch.call(this, { + type: 'change', + target: this + }, [funcName]); + can.dev.log('Model.js - ' + constructor.shortName + ' ' + funcName); + can.dispatch.call(constructor, funcName, [this]); + }; + }); + var ML = can.Model.List = can.List.extend({ + _bubbleRule: function (eventName, list) { + var bubbleRules = can.List._bubbleRule(eventName, list); + bubbleRules.push('destroyed'); + return bubbleRules; + } + }, { + setup: function (params) { + if (can.isPlainObject(params) && !can.isArray(params)) { + can.List.prototype.setup.apply(this); + this.replace(can.isDeferred(params) ? params : this.constructor.Map.findAll(params)); + } else { + can.List.prototype.setup.apply(this, arguments); + } + this._init = 1; + this.bind('destroyed', can.proxy(this._destroyed, this)); + delete this._init; + }, + _destroyed: function (ev, attr) { + if (/\w+/.test(attr)) { + var index; + while ((index = this.indexOf(ev.target)) > -1) { + this.splice(index, 1); + } + } + } + }); + return can.Model; +}); +/*can@2.2.6#util/string/deparam/deparam*/ +define('can/util/string/deparam/deparam', [ + 'can/util/util', + 'can/util/string/string' +], function (can) { + var digitTest = /^\d+$/, keyBreaker = /([^\[\]]+)|(\[\])/g, paramTest = /([^?#]*)(#.*)?$/, prep = function (str) { + return decodeURIComponent(str.replace(/\+/g, ' ')); + }; + can.extend(can, { + deparam: function (params) { + var data = {}, pairs, lastPart; + if (params && paramTest.test(params)) { + pairs = params.split('&'); + can.each(pairs, function (pair) { + var parts = pair.split('='), key = prep(parts.shift()), value = prep(parts.join('=')), current = data; + if (key) { + parts = key.match(keyBreaker); + for (var j = 0, l = parts.length - 1; j < l; j++) { + if (!current[parts[j]]) { + current[parts[j]] = digitTest.test(parts[j + 1]) || parts[j + 1] === '[]' ? [] : {}; + } + current = current[parts[j]]; + } + lastPart = parts.pop(); + if (lastPart === '[]') { + current.push(value); + } else { + current[lastPart] = value; + } + } + }); + } + return data; + } + }); + return can; +}); +/*can@2.2.6#route/route*/ +define('can/route/route', [ + 'can/util/util', + 'can/map/map', + 'can/list/list', + 'can/util/string/deparam/deparam' +], function (can) { + var matcher = /\:([\w\.]+)/g, paramsMatcher = /^(?:&[^=]+=[^&]*)+/, makeProps = function (props) { + var tags = []; + can.each(props, function (val, name) { + tags.push((name === 'className' ? 'class' : name) + '="' + (name === 'href' ? val : can.esc(val)) + '"'); + }); + return tags.join(' '); + }, matchesData = function (route, data) { + var count = 0, i = 0, defaults = {}; + for (var name in route.defaults) { + if (route.defaults[name] === data[name]) { + defaults[name] = 1; + count++; + } + } + for (; i < route.names.length; i++) { + if (!data.hasOwnProperty(route.names[i])) { + return -1; + } + if (!defaults[route.names[i]]) { + count++; + } + } + return count; + }, location = window.location, wrapQuote = function (str) { + return (str + '').replace(/([.?*+\^$\[\]\\(){}|\-])/g, '\\$1'); + }, each = can.each, extend = can.extend, stringify = function (obj) { + if (obj && typeof obj === 'object') { + if (obj instanceof can.Map) { + obj = obj.attr(); + } else { + obj = can.isFunction(obj.slice) ? obj.slice() : can.extend({}, obj); + } + can.each(obj, function (val, prop) { + obj[prop] = stringify(val); + }); + } else if (obj !== undefined && obj !== null && can.isFunction(obj.toString)) { + obj = obj.toString(); + } + return obj; + }, removeBackslash = function (str) { + return str.replace(/\\/g, ''); + }, timer, curParams, lastHash, changingData, changedAttrs = [], onRouteDataChange = function (ev, attr, how, newval) { + changingData = 1; + changedAttrs.push(attr); + clearTimeout(timer); + timer = setTimeout(function () { + changingData = 0; + var serialized = can.route.data.serialize(), path = can.route.param(serialized, true); + can.route._call('setURL', path, changedAttrs); + can.batch.trigger(eventsObject, '__url', [ + path, + lastHash + ]); + lastHash = path; + changedAttrs = []; + }, 10); + }, eventsObject = can.extend({}, can.event); + can.route = function (url, defaults) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + defaults = defaults || {}; + var names = [], res, test = '', lastIndex = matcher.lastIndex = 0, next, querySeparator = can.route._call('querySeparator'), matchSlashes = can.route._call('matchSlashes'); + while (res = matcher.exec(url)) { + names.push(res[1]); + test += removeBackslash(url.substring(lastIndex, matcher.lastIndex - res[0].length)); + next = '\\' + (removeBackslash(url.substr(matcher.lastIndex, 1)) || querySeparator + (matchSlashes ? '' : '|/')); + test += '([^' + next + ']' + (defaults[res[1]] ? '*' : '+') + ')'; + lastIndex = matcher.lastIndex; + } + test += url.substr(lastIndex).replace('\\', ''); + can.route.routes[url] = { + test: new RegExp('^' + test + '($|' + wrapQuote(querySeparator) + ')'), + route: url, + names: names, + defaults: defaults, + length: url.split('/').length + }; + return can.route; + }; + extend(can.route, { + param: function (data, _setRoute) { + var route, matches = 0, matchCount, routeName = data.route, propCount = 0; + delete data.route; + each(data, function () { + propCount++; + }); + each(can.route.routes, function (temp, name) { + matchCount = matchesData(temp, data); + if (matchCount > matches) { + route = temp; + matches = matchCount; + } + if (matchCount >= propCount) { + return false; + } + }); + if (can.route.routes[routeName] && matchesData(can.route.routes[routeName], data) === matches) { + route = can.route.routes[routeName]; + } + if (route) { + var cpy = extend({}, data), res = route.route.replace(matcher, function (whole, name) { + delete cpy[name]; + return data[name] === route.defaults[name] ? '' : encodeURIComponent(data[name]); + }).replace('\\', ''), after; + each(route.defaults, function (val, name) { + if (cpy[name] === val) { + delete cpy[name]; + } + }); + after = can.param(cpy); + if (_setRoute) { + can.route.attr('route', route.route); + } + return res + (after ? can.route._call('querySeparator') + after : ''); + } + return can.isEmptyObject(data) ? '' : can.route._call('querySeparator') + can.param(data); + }, + deparam: function (url) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + var route = { length: -1 }, querySeparator = can.route._call('querySeparator'), paramsMatcher = can.route._call('paramsMatcher'); + each(can.route.routes, function (temp, name) { + if (temp.test.test(url) && temp.length > route.length) { + route = temp; + } + }); + if (route.length > -1) { + var parts = url.match(route.test), start = parts.shift(), remainder = url.substr(start.length - (parts[parts.length - 1] === querySeparator ? 1 : 0)), obj = remainder && paramsMatcher.test(remainder) ? can.deparam(remainder.slice(1)) : {}; + obj = extend(true, {}, route.defaults, obj); + each(parts, function (part, i) { + if (part && part !== querySeparator) { + obj[route.names[i]] = decodeURIComponent(part); + } + }); + obj.route = route.route; + return obj; + } + if (url.charAt(0) !== querySeparator) { + url = querySeparator + url; + } + return paramsMatcher.test(url) ? can.deparam(url.slice(1)) : {}; + }, + data: new can.Map({}), + map: function (data) { + var appState; + if (data.prototype instanceof can.Map) { + appState = new data(); + } else { + appState = data; + } + can.route.data = appState; + }, + routes: {}, + ready: function (val) { + if (val !== true) { + can.route._setup(); + can.route.setState(); + } + return can.route; + }, + url: function (options, merge) { + if (merge) { + options = can.extend({}, can.route.deparam(can.route._call('matchingPartOfURL')), options); + } + return can.route._call('root') + can.route.param(options); + }, + link: function (name, options, props, merge) { + return '' + name + ''; + }, + current: function (options) { + can.__observe(eventsObject, '__url'); + return this._call('matchingPartOfURL') === can.route.param(options); + }, + bindings: { + hashchange: { + paramsMatcher: paramsMatcher, + querySeparator: '&', + matchSlashes: false, + bind: function () { + can.bind.call(window, 'hashchange', setState); + }, + unbind: function () { + can.unbind.call(window, 'hashchange', setState); + }, + matchingPartOfURL: function () { + return location.href.split(/#!?/)[1] || ''; + }, + setURL: function (path) { + if (location.hash !== '#' + path) { + location.hash = '!' + path; + } + return path; + }, + root: '#!' + } + }, + defaultBinding: 'hashchange', + currentBinding: null, + _setup: function () { + if (!can.route.currentBinding) { + can.route._call('bind'); + can.route.bind('change', onRouteDataChange); + can.route.currentBinding = can.route.defaultBinding; + } + }, + _teardown: function () { + if (can.route.currentBinding) { + can.route._call('unbind'); + can.route.unbind('change', onRouteDataChange); + can.route.currentBinding = null; + } + clearTimeout(timer); + changingData = 0; + }, + _call: function () { + var args = can.makeArray(arguments), prop = args.shift(), binding = can.route.bindings[can.route.currentBinding || can.route.defaultBinding], method = binding[prop]; + if (method.apply) { + return method.apply(binding, args); + } else { + return method; + } + } + }); + each([ + 'bind', + 'unbind', + 'on', + 'off', + 'delegate', + 'undelegate', + 'removeAttr', + 'compute', + '_get', + '__get', + 'each' + ], function (name) { + can.route[name] = function () { + if (!can.route.data[name]) { + return; + } + return can.route.data[name].apply(can.route.data, arguments); + }; + }); + can.route.attr = function (attr, val) { + var type = typeof attr, newArguments; + if (val === undefined) { + newArguments = arguments; + } else if (type !== 'string' && type !== 'number') { + newArguments = [ + stringify(attr), + val + ]; + } else { + newArguments = [ + attr, + stringify(val) + ]; + } + return can.route.data.attr.apply(can.route.data, newArguments); + }; + var setState = can.route.setState = function () { + var hash = can.route._call('matchingPartOfURL'); + var oldParams = curParams; + curParams = can.route.deparam(hash); + if (!changingData || hash !== lastHash) { + can.batch.start(); + recursiveClean(oldParams, curParams, can.route.data); + can.route.attr(curParams); + can.batch.trigger(eventsObject, '__url', [ + hash, + lastHash + ]); + can.batch.stop(); + } + }; + var recursiveClean = function (old, cur, data) { + for (var attr in old) { + if (cur[attr] === undefined) { + data.removeAttr(attr); + } else if (Object.prototype.toString.call(old[attr]) === '[object Object]') { + recursiveClean(old[attr], cur[attr], data.attr(attr)); + } + } + }; + return can.route; +}); +/*can@2.2.6#control/route/route*/ +define('can/control/route/route', [ + 'can/util/util', + 'can/route/route', + 'can/control/control' +], function (can) { + can.Control.processors.route = function (el, event, selector, funcName, controller) { + selector = selector || ''; + if (!can.route.routes[selector]) { + if (selector[0] === '/') { + selector = selector.substring(1); + } + can.route(selector); + } + var batchNum, check = function (ev, attr, how) { + if (can.route.attr('route') === selector && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + batchNum = ev.batchNum; + var d = can.route.attr(); + delete d.route; + if (can.isFunction(controller[funcName])) { + controller[funcName](d); + } else { + controller[controller[funcName]](d); + } + } + }; + can.route.bind('change', check); + return function () { + can.route.unbind('change', check); + }; + }; + return can; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.zepto.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.zepto.js new file mode 100644 index 0000000000..a4341a7afd --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.zepto.js @@ -0,0 +1,7113 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +(function (exports, global){ + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses only the exports objet + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + modules[moduleName] = module && module.exports ? module.exports : result; + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + global.System = { + define: function(__name, __code){ + global.define = origDefine; + eval("(function() { " + __code + " \n }).call(global);"); + global.define = ourDefine; + } + }; +})({},window) +/*can@2.2.6#util/can*/ +define('can/util/can', [], function () { + var glbl = typeof window !== 'undefined' ? window : global; + var can = {}; + if (typeof GLOBALCAN === 'undefined' || GLOBALCAN !== false) { + glbl.can = can; + } + can.global = glbl; + can.k = function () { + }; + can.isDeferred = can.isPromise = function (obj) { + return obj && typeof obj.then === 'function' && typeof obj.pipe === 'function'; + }; + can.isMapLike = function (obj) { + return can.Map && (obj instanceof can.Map || obj && obj.__get); + }; + var cid = 0; + can.cid = function (object, name) { + if (!object._cid) { + cid++; + object._cid = (name || '') + cid; + } + return object._cid; + }; + can.VERSION = '2.2.6'; + can.simpleExtend = function (d, s) { + for (var prop in s) { + d[prop] = s[prop]; + } + return d; + }; + can.last = function (arr) { + return arr && arr[arr.length - 1]; + }; + var protoBind = Function.prototype.bind; + if (protoBind) { + can.proxy = function (fn, context) { + return protoBind.call(fn, context); + }; + } else { + can.proxy = function (fn, context) { + return function () { + return fn.apply(context, arguments); + }; + }; + } + can.frag = function (item) { + var frag; + if (!item || typeof item === 'string') { + frag = can.buildFragment(item == null ? '' : '' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } else if (item.nodeType === 11) { + return item; + } else if (typeof item.nodeType === 'number') { + frag = document.createDocumentFragment(); + frag.appendChild(item); + return frag; + } else if (typeof item.length === 'number') { + frag = document.createDocumentFragment(); + can.each(item, function (item) { + frag.appendChild(can.frag(item)); + }); + return frag; + } else { + frag = can.buildFragment('' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } + }; + can.scope = can.viewModel = function (el, attr, val) { + el = can.$(el); + var scope = can.data(el, 'scope') || can.data(el, 'viewModel'); + if (!scope) { + scope = new can.Map(); + can.data(el, 'scope', scope); + can.data(el, 'viewModel', scope); + } + switch (arguments.length) { + case 0: + case 1: + return scope; + case 2: + return scope.attr(attr); + default: + scope.attr(attr, val); + return el; + } + }; + can['import'] = function (moduleName) { + var deferred = new can.Deferred(); + if (typeof window.System === 'object' && can.isFunction(window.System['import'])) { + window.System['import'](moduleName).then(can.proxy(deferred.resolve, deferred), can.proxy(deferred.reject, deferred)); + } else if (window.define && window.define.amd) { + window.require([moduleName], function (value) { + deferred.resolve(value); + }); + } else if (window.steal) { + steal.steal(moduleName, function (value) { + deferred.resolve(value); + }); + } else if (window.require) { + deferred.resolve(window.require(moduleName)); + } else { + deferred.resolve(); + } + return deferred.promise(); + }; + can.__observe = function () { + }; + return can; +}); +/*can@2.2.6#util/attr/attr*/ +define('can/util/attr/attr', ['can/util/can'], function (can) { + var setImmediate = can.global.setImmediate || function (cb) { + return setTimeout(cb, 0); + }, attr = { + MutationObserver: can.global.MutationObserver || can.global.WebKitMutationObserver || can.global.MozMutationObserver, + map: { + 'class': 'className', + 'value': 'value', + 'innertext': 'innerText', + 'textcontent': 'textContent', + 'checked': true, + 'disabled': true, + 'readonly': true, + 'required': true, + src: function (el, val) { + if (val == null || val === '') { + el.removeAttribute('src'); + return null; + } else { + el.setAttribute('src', val); + return val; + } + }, + style: function (el, val) { + return el.style.cssText = val || ''; + } + }, + defaultValue: [ + 'input', + 'textarea' + ], + set: function (el, attrName, val) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var tagName = el.nodeName.toString().toLowerCase(), prop = attr.map[attrName], newValue; + if (typeof prop === 'function') { + newValue = prop(el, val); + } else if (prop === true) { + newValue = el[attrName] = true; + if (attrName === 'checked' && el.type === 'radio') { + if (can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultChecked = true; + } + } + } else if (prop) { + newValue = val; + if (el[prop] !== val) { + el[prop] = val; + } + if (prop === 'value' && can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultValue = val; + } + } else { + el.setAttribute(attrName, val); + newValue = val; + } + if (!attr.MutationObserver && newValue !== oldValue) { + attr.trigger(el, attrName, oldValue); + } + }, + trigger: function (el, attrName, oldValue) { + if (can.data(can.$(el), 'canHasAttributesBindings')) { + attrName = attrName.toLowerCase(); + return setImmediate(function () { + can.trigger(el, { + type: 'attributes', + attributeName: attrName, + target: el, + oldValue: oldValue, + bubbles: false + }, []); + }); + } + }, + get: function (el, attrName) { + attrName = attrName.toLowerCase(); + var prop = attr.map[attrName]; + if (typeof prop === 'string' && el[prop]) { + return el[prop]; + } + return el.getAttribute(attrName); + }, + remove: function (el, attrName) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var setter = attr.map[attrName]; + if (typeof setter === 'function') { + setter(el, undefined); + } + if (setter === true) { + el[attrName] = false; + } else if (typeof setter === 'string') { + el[setter] = ''; + } else { + el.removeAttribute(attrName); + } + if (!attr.MutationObserver && oldValue != null) { + attr.trigger(el, attrName, oldValue); + } + }, + has: function () { + var el = can.global.document && document.createElement('div'); + if (el && el.hasAttribute) { + return function (el, name) { + return el.hasAttribute(name); + }; + } else { + return function (el, name) { + return el.getAttribute(name) !== null; + }; + } + }() + }; + return attr; +}); +/*can@2.2.6#event/event*/ +define('can/event/event', ['can/util/can'], function (can) { + can.addEvent = function (event, handler) { + var allEvents = this.__bindEvents || (this.__bindEvents = {}), eventList = allEvents[event] || (allEvents[event] = []); + eventList.push({ + handler: handler, + name: event + }); + return this; + }; + can.listenTo = function (other, event, handler) { + var idedEvents = this.__listenToEvents; + if (!idedEvents) { + idedEvents = this.__listenToEvents = {}; + } + var otherId = can.cid(other); + var othersEvents = idedEvents[otherId]; + if (!othersEvents) { + othersEvents = idedEvents[otherId] = { + obj: other, + events: {} + }; + } + var eventsEvents = othersEvents.events[event]; + if (!eventsEvents) { + eventsEvents = othersEvents.events[event] = []; + } + eventsEvents.push(handler); + can.bind.call(other, event, handler); + }; + can.stopListening = function (other, event, handler) { + var idedEvents = this.__listenToEvents, iterIdedEvents = idedEvents, i = 0; + if (!idedEvents) { + return this; + } + if (other) { + var othercid = can.cid(other); + (iterIdedEvents = {})[othercid] = idedEvents[othercid]; + if (!idedEvents[othercid]) { + return this; + } + } + for (var cid in iterIdedEvents) { + var othersEvents = iterIdedEvents[cid], eventsEvents; + other = idedEvents[cid].obj; + if (!event) { + eventsEvents = othersEvents.events; + } else { + (eventsEvents = {})[event] = othersEvents.events[event]; + } + for (var eventName in eventsEvents) { + var handlers = eventsEvents[eventName] || []; + i = 0; + while (i < handlers.length) { + if (handler && handler === handlers[i] || !handler) { + can.unbind.call(other, eventName, handlers[i]); + handlers.splice(i, 1); + } else { + i++; + } + } + if (!handlers.length) { + delete othersEvents.events[eventName]; + } + } + if (can.isEmptyObject(othersEvents.events)) { + delete idedEvents[cid]; + } + } + return this; + }; + can.removeEvent = function (event, fn, __validate) { + if (!this.__bindEvents) { + return this; + } + var events = this.__bindEvents[event] || [], i = 0, ev, isFunction = typeof fn === 'function'; + while (i < events.length) { + ev = events[i]; + if (__validate ? __validate(ev, event, fn) : isFunction && ev.handler === fn || !isFunction && (ev.cid === fn || !fn)) { + events.splice(i, 1); + } else { + i++; + } + } + return this; + }; + can.dispatch = function (event, args) { + var events = this.__bindEvents; + if (!events) { + return; + } + if (typeof event === 'string') { + event = { type: event }; + } + var eventName = event.type, handlers = (events[eventName] || []).slice(0), passed = [event]; + if (args) { + passed.push.apply(passed, args); + } + for (var i = 0, len = handlers.length; i < len; i++) { + handlers[i].handler.apply(this, passed); + } + return event; + }; + can.one = function (event, handler) { + var one = function () { + can.unbind.call(this, event, one); + return handler.apply(this, arguments); + }; + can.bind.call(this, event, one); + return this; + }; + can.event = { + on: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.on.call(this); + } else { + return can.addEvent.apply(this, arguments); + } + }, + off: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.off.call(this); + } else { + return can.removeEvent.apply(this, arguments); + } + }, + bind: can.addEvent, + unbind: can.removeEvent, + delegate: function (selector, event, handler) { + return can.addEvent.call(this, event, handler); + }, + undelegate: function (selector, event, handler) { + return can.removeEvent.call(this, event, handler); + }, + trigger: can.dispatch, + one: can.one, + addEvent: can.addEvent, + removeEvent: can.removeEvent, + listenTo: can.listenTo, + stopListening: can.stopListening, + dispatch: can.dispatch + }; + return can.event; +}); +/*can@2.2.6#util/object/isplain/isplain*/ +define('can/util/object/isplain/isplain', ['can/util/can'], function () { + var core_hasOwn = Object.prototype.hasOwnProperty, isWindow = function (obj) { + return obj !== null && obj == obj.window; + }, isPlainObject = function (obj) { + if (!obj || typeof obj !== 'object' || obj.nodeType || isWindow(obj)) { + return false; + } + try { + if (obj.constructor && !core_hasOwn.call(obj, 'constructor') && !core_hasOwn.call(obj.constructor.prototype, 'isPrototypeOf')) { + return false; + } + } catch (e) { + return false; + } + var key; + for (key in obj) { + } + return key === undefined || core_hasOwn.call(obj, key); + }; + can.isPlainObject = isPlainObject; + return can; +}); +/*can@2.2.6#util/fragment*/ +define('can/util/fragment', ['can/util/can'], function (can) { + var fragmentRE = /^\s*<(\w+)[^>]*>/, toString = {}.toString, fragment = function (html, name) { + if (name === undefined) { + name = fragmentRE.test(html) && RegExp.$1; + } + if (html && toString.call(html.replace) === '[object Function]') { + html = html.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, '<$1>'); + } + var container = document.createElement('div'), temp = document.createElement('div'); + if (name === 'tbody' || name === 'tfoot' || name === 'thead') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; + } else if (name === 'tr') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild; + } else if (name === 'td' || name === 'th') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild.firstChild; + } else if (name === 'option') { + temp.innerHTML = ''; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; + } else { + container.innerHTML = '' + html; + } + var tmp = {}, children = container.childNodes; + tmp.length = children.length; + for (var i = 0; i < children.length; i++) { + tmp[i] = children[i]; + } + return [].slice.call(tmp); + }; + can.buildFragment = function (html, nodes) { + if (html && html.nodeType === 11) { + return html; + } + var parts = fragment(html), frag = document.createDocumentFragment(); + for (var i = 0, length = parts.length; i < length; i++) { + frag.appendChild(parts[i]); + } + return frag; + }; + (function () { + var text = '<-\n>', frag = can.buildFragment(text, document); + if (text !== frag.childNodes[0].nodeValue) { + var oldBuildFragment = can.buildFragment; + can.buildFragment = function (html, nodes) { + var res = oldBuildFragment(html, nodes); + if (res.childNodes.length === 1 && res.childNodes[0].nodeType === 3) { + res.childNodes[0].nodeValue = html; + } + return res; + }; + } + }()); + return can; +}); +/*can@2.2.6#util/deferred*/ +define('can/util/deferred', ['can/util/can'], function (can) { + var extend = function (target, src) { + for (var key in src) { + if (src.hasOwnProperty(key)) { + target[key] = src[key]; + } + } + }, Deferred = function (func) { + if (!(this instanceof Deferred)) { + return new Deferred(); + } + this._doneFuncs = []; + this._failFuncs = []; + this._resultArgs = null; + this._status = ''; + if (func) { + func.call(this, this); + } + }; + can.Deferred = Deferred; + can.when = Deferred.when = function () { + var args = can.makeArray(arguments); + if (args.length < 2) { + var obj = args[0]; + if (obj && (can.isFunction(obj.isResolved) && can.isFunction(obj.isRejected))) { + return obj; + } else { + return Deferred().resolve(obj); + } + } else { + var df = Deferred(), done = 0, rp = []; + can.each(args, function (arg, j) { + arg.done(function () { + rp[j] = arguments.length < 2 ? arguments[0] : arguments; + if (++done === args.length) { + df.resolve.apply(df, rp); + } + }).fail(function () { + df.reject(arguments.length === 1 ? arguments[0] : arguments); + }); + }); + return df; + } + }; + var resolveFunc = function (type, _status) { + return function (context) { + var args = this._resultArgs = arguments.length > 1 ? arguments[1] : []; + return this.exec(context, this[type], args, _status); + }; + }, doneFunc = function doneFunc(type, _status) { + return function () { + var self = this; + can.each(Array.prototype.slice.call(arguments), function (v, i, args) { + if (!v) { + return; + } + if (v.constructor === Array) { + doneFunc.apply(self, v); + } else { + if (self._status === _status) { + v.apply(self, self._resultArgs || []); + } + self[type].push(v); + } + }); + return this; + }; + }; + var isDeferred = function (obj) { + return obj && obj.then && obj.fail && obj.done; + }; + var wire = function (parentDeferred, result, setter, value) { + if (isDeferred(result)) { + result.done(can.proxy(parentDeferred.resolve, parentDeferred)).fail(can.proxy(parentDeferred.reject, parentDeferred)); + } else { + setter.call(parentDeferred, result !== undefined ? result : value); + } + }; + extend(Deferred.prototype, { + then: function (done, fail) { + var d = can.Deferred(), resolve = d.resolve, reject = d.reject; + this.done(function (value) { + if (typeof done === 'function') { + wire(d, done.apply(this, arguments), resolve, value); + } else { + resolve.apply(d, arguments); + } + }); + this.fail(function (value) { + if (typeof fail === 'function') { + wire(d, fail.apply(this, arguments), reject, value); + } else { + reject.apply(d, arguments); + } + }); + return d; + }, + resolveWith: resolveFunc('_doneFuncs', 'rs'), + rejectWith: resolveFunc('_failFuncs', 'rj'), + done: doneFunc('_doneFuncs', 'rs'), + fail: doneFunc('_failFuncs', 'rj'), + always: function () { + var args = can.makeArray(arguments); + if (args.length && args[0]) { + this.done(args[0]).fail(args[0]); + } + return this; + }, + state: function () { + switch (this._status) { + case 'rs': + return 'resolved'; + case 'rj': + return 'rejected'; + default: + return 'pending'; + } + }, + isResolved: function () { + return this._status === 'rs'; + }, + isRejected: function () { + return this._status === 'rj'; + }, + reject: function () { + return this.rejectWith(this, arguments); + }, + resolve: function () { + return this.resolveWith(this, arguments); + }, + exec: function (context, dst, args, st) { + if (this._status !== '') { + return this; + } + this._status = st; + can.each(dst, function (d) { + if (typeof d.apply === 'function') { + d.apply(context, args); + } + }); + return this; + }, + promise: function () { + var promise = this.then(); + promise.reject = promise.resolve = undefined; + return promise; + } + }); + Deferred.prototype.pipe = Deferred.prototype.then; + return can; +}); +/*can@2.2.6#util/array/each*/ +define('can/util/array/each', ['can/util/can'], function (can) { + var isArrayLike = function (obj) { + var length = 'length' in obj && obj.length; + return typeof arr !== 'function' && (length === 0 || typeof length === 'number' && length > 0 && length - 1 in obj); + }; + can.each = function (elements, callback, context) { + var i = 0, key, len, item; + if (elements) { + if (isArrayLike(elements)) { + if (can.List && elements instanceof can.List) { + for (len = elements.attr('length'); i < len; i++) { + item = elements.attr(i); + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } else { + for (len = elements.length; i < len; i++) { + item = elements[i]; + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } + } else if (typeof elements === 'object') { + if (can.Map && elements instanceof can.Map || elements === can.route) { + var keys = can.Map.keys(elements); + for (i = 0, len = keys.length; i < len; i++) { + key = keys[i]; + item = elements.attr(key); + if (callback.call(context || item, item, key, elements) === false) { + break; + } + } + } else { + for (key in elements) { + if (elements.hasOwnProperty(key) && callback.call(context || elements[key], elements[key], key, elements) === false) { + break; + } + } + } + } + } + return elements; + }; + return can; +}); +/*can@2.2.6#util/inserted/inserted*/ +define('can/util/inserted/inserted', ['can/util/can'], function (can) { + can.inserted = function (elems) { + elems = can.makeArray(elems); + var inDocument = false, doc = can.$(document.contains ? document : document.body), children; + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + if (!inDocument) { + if (elem.getElementsByTagName) { + if (can.has(doc, elem).length) { + inDocument = true; + } else { + return; + } + } else { + continue; + } + } + if (inDocument && elem.getElementsByTagName) { + children = can.makeArray(elem.getElementsByTagName('*')); + can.trigger(elem, 'inserted', [], false); + for (var j = 0, child; (child = children[j]) !== undefined; j++) { + can.trigger(child, 'inserted', [], false); + } + } + } + }; + can.appendChild = function (el, child) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.appendChild(child); + can.inserted(children); + }; + can.insertBefore = function (el, child, ref) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.insertBefore(child, ref); + can.inserted(children); + }; +}); +/*can@2.2.6#util/util*/ +define('can/util/util', [ + 'can/util/can', + 'can/util/attr/attr', + 'can/event/event', + 'can/zepto/zepto', + 'can/util/object/isplain/isplain', + 'can/util/fragment', + 'can/util/deferred', + 'can/util/array/each', + 'can/util/inserted/inserted' +], function (can, attr, event) { + var $ = Zepto; + var data = {}, dataAttr = $.fn.data, uuid = $.uuid = +new Date(), exp = $.expando = 'Zepto' + uuid; + function getData(node, name) { + var id = node[exp], store = id && data[id]; + return name === undefined ? store || setData(node) : store && store[name] || dataAttr.call($(node), name); + } + function setData(node, name, value) { + var id = node[exp] || (node[exp] = ++uuid), store = data[id] || (data[id] = {}); + if (name !== undefined) { + store[name] = value; + } + return store; + } + $.fn.data = function (name, value) { + return value === undefined ? this.length === 0 ? undefined : getData(this[0], name) : this.each(function (idx) { + setData(this, name, $.isFunction(value) ? value.call(this, idx, getData(this, name)) : value); + }); + }; + $.cleanData = function (elems) { + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + can.trigger(elem, 'removed', [], false); + } + for (i = 0; (elem = elems[i]) !== undefined; i++) { + var id = elem[exp]; + delete data[id]; + } + }; + var oldEach = can.each; + var oldPlain = can.isPlainObject; + $.extend(can, Zepto); + can.inArray = function (el, arr) { + return !arr ? -1 : $.inArray.apply($, arguments); + }; + can.isPlainObject = oldPlain; + can.each = oldEach; + can.attr = attr; + can.event = event; + var arrHas = function (obj, name) { + return obj[0] && obj[0][name] || obj[name]; + }; + can.trigger = function (obj, event, args, bubble) { + if (obj.trigger) { + obj.trigger(event, args); + } else if (arrHas(obj, 'dispatchEvent')) { + if (bubble === false) { + $([obj]).triggerHandler(event, args); + } else { + $([obj]).trigger(event, args); + } + } else { + if (typeof event === 'string') { + event = { type: event }; + } + event.target = event.target || obj; + can.dispatch.call(obj, event, can.makeArray(args)); + } + }; + can.$ = Zepto; + can.bind = function (ev, cb) { + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (arrHas(this, 'addEventListener')) { + $([this]).bind(ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + return this; + }; + can.unbind = function (ev, cb) { + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (arrHas(this, 'addEventListener')) { + $([this]).unbind(ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + return this; + }; + can.on = can.bind; + can.off = can.unbind; + can.delegate = function (selector, ev, cb) { + if (!selector) { + can.bind.call(this, ev, cb); + } else if (this.delegate) { + this.delegate(selector, ev, cb); + } else if (arrHas(this, 'addEventListener')) { + $([this]).delegate(selector, ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + }; + can.undelegate = function (selector, ev, cb) { + if (!selector) { + can.unbind.call(this, ev, cb); + } else if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else if (arrHas(this, 'addEventListener')) { + $([this]).undelegate(selector, ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + }; + $.each([ + 'append', + 'filter', + 'addClass', + 'remove', + 'data', + 'has' + ], function (i, name) { + can[name] = function (wrapped) { + return wrapped[name].apply(wrapped, can.makeArray(arguments).slice(1)); + }; + }); + can.makeArray = function (arr) { + var ret = []; + if (arr == null) { + return []; + } + if (arr.length === undefined || typeof arr === 'string') { + return [arr]; + } + can.each(arr, function (a, i) { + ret[i] = a; + }); + return ret; + }; + var XHR = $.ajaxSettings.xhr; + $.ajaxSettings.xhr = function () { + var xhr = XHR(); + var open = xhr.open; + xhr.open = function (type, url, async) { + open.call(this, type, url, ASYNC === undefined ? true : ASYNC); + }; + return xhr; + }; + var ASYNC; + var AJAX = $.ajax; + var updateDeferred = function (xhr, d) { + for (var prop in xhr) { + if (typeof d[prop] === 'function') { + d[prop] = function () { + xhr[prop].apply(xhr, arguments); + }; + } else { + d[prop] = prop[xhr]; + } + } + }; + can.ajax = function (options) { + var success = options.success, error = options.error; + var d = can.Deferred(); + options.success = function (data) { + updateDeferred(xhr, d); + d.resolve.call(d, data); + if (success) { + success.apply(this, arguments); + } + }; + options.error = function () { + updateDeferred(xhr, d); + d.reject.apply(d, arguments); + if (error) { + error.apply(this, arguments); + } + }; + if (options.async === false) { + ASYNC = false; + } + var xhr = AJAX(options); + ASYNC = undefined; + updateDeferred(xhr, d); + return d; + }; + var $_empty = $.fn.empty; + $.fn.empty = function () { + this.each(function () { + $.cleanData(this.getElementsByTagName('*')); + this.innerHTML = ''; + }); + return $_empty.call(this); + }; + var $_remove = $.fn.remove; + $.fn.remove = function () { + this.each(function () { + if (this.getElementsByTagName) { + $.cleanData([this].concat(can.makeArray(this.getElementsByTagName('*')))); + } + }); + return $_remove.call(this); + }; + can.trim = function (str) { + return str.trim(); + }; + can.isEmptyObject = function (object) { + var name; + for (name in object) { + } + return name === undefined; + }; + can.extend = function (first) { + if (first === true) { + var args = can.makeArray(arguments); + args.shift(); + return $.extend.apply($, args); + } + return $.extend.apply($, arguments); + }; + can.get = function (wrapped, index) { + return wrapped[index]; + }; + can.each([ + 'after', + 'prepend', + 'before', + 'append' + ], function (name) { + var original = Zepto.fn[name]; + Zepto.fn[name] = function () { + var elems, args = can.makeArray(arguments); + if (args[0] != null) { + if (typeof args[0] === 'string') { + args[0] = $.zepto.fragment(args[0]); + } + if (args[0].nodeType === 11) { + elems = can.makeArray(args[0].childNodes); + } else if (args[0] instanceof Zepto.fn.constructor) { + elems = can.makeArray(args[0]); + } else { + elems = [args[0]]; + } + } + var ret = original.apply(this, args); + can.inserted(elems); + return ret; + }; + }); + delete attr.MutationObserver; + var oldAttr = $.fn.attr; + $.fn.attr = function (attrName, value) { + var isString = typeof attrName === 'string', oldValue, newValue; + if (value !== undefined && isString) { + oldValue = oldAttr.call(this, attrName); + } + var res = oldAttr.apply(this, arguments); + if (value !== undefined && isString) { + newValue = oldAttr.call(this, attrName); + } + if (newValue !== oldValue) { + can.attr.trigger(this[0], attrName, oldValue); + } + return res; + }; + var oldRemove = $.fn.removeAttr; + $.fn.removeAttr = function (attrName) { + var oldValue = oldAttr.call(this, attrName), res = oldRemove.apply(this, arguments); + if (oldValue != null) { + can.attr.trigger(this[0], attrName, oldValue); + } + return res; + }; + var oldBind = $.fn.bind, oldUnbind = $.fn.unbind; + $.fn.bind = function (event) { + if (event === 'attributes') { + this.each(function () { + var el = can.$(this); + can.data(el, 'canHasAttributesBindings', (can.data(el, 'canHasAttributesBindings') || 0) + 1); + }); + } + return oldBind.apply(this, arguments); + }; + $.fn.unbind = function (event) { + if (event === 'attributes') { + this.each(function () { + var el = can.$(this), cur = can.data(el, 'canHasAttributesBindings') || 0; + if (cur <= 0) { + can.data(el, 'canHasAttributesBindings', 0); + } else { + can.data(el, 'canHasAttributesBindings', cur - 1); + } + }); + } + return oldUnbind.apply(this, arguments); + }; + return can; +}); +/*can@2.2.6#view/view*/ +define('can/view/view', ['can/util/util'], function (can) { + var isFunction = can.isFunction, makeArray = can.makeArray, hookupId = 1; + var makeRenderer = function (textRenderer) { + var renderer = function () { + return $view.frag(textRenderer.apply(this, arguments)); + }; + renderer.render = function () { + return textRenderer.apply(textRenderer, arguments); + }; + return renderer; + }; + var checkText = function (text, url) { + if (!text.length) { + throw 'can.view: No template or empty template:' + url; + } + }; + var getRenderer = function (obj, async) { + if (isFunction(obj)) { + var def = can.Deferred(); + return def.resolve(obj); + } + var url = typeof obj === 'string' ? obj : obj.url, suffix = obj.engine && '.' + obj.engine || url.match(/\.[\w\d]+$/), type, el, id; + if (url.match(/^#/)) { + url = url.substr(1); + } + if (el = document.getElementById(url)) { + suffix = '.' + el.type.match(/\/(x\-)?(.+)/)[2]; + } + if (!suffix && !$view.cached[url]) { + url += suffix = $view.ext; + } + if (can.isArray(suffix)) { + suffix = suffix[0]; + } + id = $view.toId(url); + if (url.match(/^\/\//)) { + url = url.substr(2); + url = !window.steal ? url : steal.config().root.mapJoin('' + steal.id(url)); + } + if (window.require) { + if (require.toUrl) { + url = require.toUrl(url); + } + } + type = $view.types[suffix]; + if ($view.cached[id]) { + return $view.cached[id]; + } else if (el) { + return $view.registerView(id, el.innerHTML, type); + } else { + var d = new can.Deferred(); + can.ajax({ + async: async, + url: url, + dataType: 'text', + error: function (jqXHR) { + checkText('', url); + d.reject(jqXHR); + }, + success: function (text) { + checkText(text, url); + $view.registerView(id, text, type, d); + } + }); + return d; + } + }; + var getDeferreds = function (data) { + var deferreds = []; + if (can.isDeferred(data)) { + return [data]; + } else { + for (var prop in data) { + if (can.isDeferred(data[prop])) { + deferreds.push(data[prop]); + } + } + } + return deferreds; + }; + var usefulPart = function (resolved) { + return can.isArray(resolved) && resolved[1] === 'success' ? resolved[0] : resolved; + }; + var $view = can.view = can.template = function (view, data, helpers, callback) { + if (isFunction(helpers)) { + callback = helpers; + helpers = undefined; + } + return $view.renderAs('fragment', view, data, helpers, callback); + }; + can.extend($view, { + frag: function (result, parentNode) { + return $view.hookup($view.fragment(result), parentNode); + }, + fragment: function (result) { + if (typeof result !== 'string' && result.nodeType === 11) { + return result; + } + var frag = can.buildFragment(result, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + }, + toId: function (src) { + return can.map(src.toString().split(/\/|\./g), function (part) { + if (part) { + return part; + } + }).join('_'); + }, + toStr: function (txt) { + return txt == null ? '' : '' + txt; + }, + hookup: function (fragment, parentNode) { + var hookupEls = [], id, func; + can.each(fragment.childNodes ? can.makeArray(fragment.childNodes) : fragment, function (node) { + if (node.nodeType === 1) { + hookupEls.push(node); + hookupEls.push.apply(hookupEls, can.makeArray(node.getElementsByTagName('*'))); + } + }); + can.each(hookupEls, function (el) { + if (el.getAttribute && (id = el.getAttribute('data-view-id')) && (func = $view.hookups[id])) { + func(el, parentNode, id); + delete $view.hookups[id]; + el.removeAttribute('data-view-id'); + } + }); + return fragment; + }, + hookups: {}, + hook: function (cb) { + $view.hookups[++hookupId] = cb; + return ' data-view-id=\'' + hookupId + '\''; + }, + cached: {}, + cachedRenderers: {}, + cache: true, + register: function (info) { + this.types['.' + info.suffix] = info; + can[info.suffix] = $view[info.suffix] = function (id, text) { + var renderer, renderFunc; + if (!text) { + renderFunc = function () { + if (!renderer) { + if (info.fragRenderer) { + renderer = info.fragRenderer(null, id); + } else { + renderer = makeRenderer(info.renderer(null, id)); + } + } + return renderer.apply(this, arguments); + }; + renderFunc.render = function () { + var textRenderer = info.renderer(null, id); + return textRenderer.apply(textRenderer, arguments); + }; + return renderFunc; + } + var registeredRenderer = function () { + if (!renderer) { + if (info.fragRenderer) { + renderer = info.fragRenderer(id, text); + } else { + renderer = info.renderer(id, text); + } + } + return renderer.apply(this, arguments); + }; + if (info.fragRenderer) { + return $view.preload(id, registeredRenderer); + } else { + return $view.preloadStringRenderer(id, registeredRenderer); + } + }; + }, + types: {}, + ext: '.ejs', + registerScript: function (type, id, src) { + return 'can.view.preloadStringRenderer(\'' + id + '\',' + $view.types['.' + type].script(id, src) + ');'; + }, + preload: function (id, renderer) { + var def = $view.cached[id] = new can.Deferred().resolve(function (data, helpers) { + return renderer.call(data, data, helpers); + }); + def.__view_id = id; + $view.cachedRenderers[id] = renderer; + return renderer; + }, + preloadStringRenderer: function (id, stringRenderer) { + return this.preload(id, makeRenderer(stringRenderer)); + }, + render: function (view, data, helpers, callback) { + return can.view.renderAs('string', view, data, helpers, callback); + }, + renderTo: function (format, renderer, data, helpers) { + return (format === 'string' && renderer.render ? renderer.render : renderer)(data, helpers); + }, + renderAs: function (format, view, data, helpers, callback) { + if (isFunction(helpers)) { + callback = helpers; + helpers = undefined; + } + var deferreds = getDeferreds(data); + var reading, deferred, dataCopy, async, response; + if (deferreds.length) { + deferred = new can.Deferred(); + dataCopy = can.extend({}, data); + deferreds.push(getRenderer(view, true)); + can.when.apply(can, deferreds).then(function (resolved) { + var objs = makeArray(arguments), renderer = objs.pop(), result; + if (can.isDeferred(data)) { + dataCopy = usefulPart(resolved); + } else { + for (var prop in data) { + if (can.isDeferred(data[prop])) { + dataCopy[prop] = usefulPart(objs.shift()); + } + } + } + result = can.view.renderTo(format, renderer, dataCopy, helpers); + deferred.resolve(result, dataCopy); + if (callback) { + callback(result, dataCopy); + } + }, function () { + deferred.reject.apply(deferred, arguments); + }); + return deferred; + } else { + reading = can.__clearReading(); + async = isFunction(callback); + deferred = getRenderer(view, async); + if (reading) { + can.__setReading(reading); + } + if (async) { + response = deferred; + deferred.then(function (renderer) { + callback(data ? can.view.renderTo(format, renderer, data, helpers) : renderer); + }); + } else { + if (deferred.state() === 'resolved' && deferred.__view_id) { + var currentRenderer = $view.cachedRenderers[deferred.__view_id]; + return data ? can.view.renderTo(format, currentRenderer, data, helpers) : currentRenderer; + } else { + deferred.then(function (renderer) { + response = data ? can.view.renderTo(format, renderer, data, helpers) : renderer; + }); + } + } + return response; + } + }, + registerView: function (id, text, type, def) { + var info = typeof type === 'object' ? type : $view.types[type || $view.ext], renderer; + if (info.fragRenderer) { + renderer = info.fragRenderer(id, text); + } else { + renderer = makeRenderer(info.renderer(id, text)); + } + def = def || new can.Deferred(); + if ($view.cache) { + $view.cached[id] = def; + def.__view_id = id; + $view.cachedRenderers[id] = renderer; + } + return def.resolve(renderer); + } + }); + return can; +}); +/*can@2.2.6#view/callbacks/callbacks*/ +define('can/view/callbacks/callbacks', [ + 'can/util/util', + 'can/view/view' +], function (can) { + var attr = can.view.attr = function (attributeName, attrHandler) { + if (attrHandler) { + if (typeof attributeName === 'string') { + attributes[attributeName] = attrHandler; + } else { + regExpAttributes.push({ + match: attributeName, + handler: attrHandler + }); + } + } else { + var cb = attributes[attributeName]; + if (!cb) { + for (var i = 0, len = regExpAttributes.length; i < len; i++) { + var attrMatcher = regExpAttributes[i]; + if (attrMatcher.match.test(attributeName)) { + cb = attrMatcher.handler; + break; + } + } + } + return cb; + } + }; + var attributes = {}, regExpAttributes = [], automaticCustomElementCharacters = /[-\:]/; + var tag = can.view.tag = function (tagName, tagHandler) { + if (tagHandler) { + if (can.global.html5) { + can.global.html5.elements += ' ' + tagName; + can.global.html5.shivDocument(); + } + tags[tagName.toLowerCase()] = tagHandler; + } else { + var cb = tags[tagName.toLowerCase()]; + if (!cb && automaticCustomElementCharacters.test(tagName)) { + cb = function () { + }; + } + return cb; + } + }; + var tags = {}; + can.view.callbacks = { + _tags: tags, + _attributes: attributes, + _regExpAttributes: regExpAttributes, + tag: tag, + attr: attr, + tagHandler: function (el, tagName, tagData) { + var helperTagCallback = tagData.options.attr('tags.' + tagName), tagCallback = helperTagCallback || tags[tagName]; + var scope = tagData.scope, res; + if (tagCallback) { + var reads = can.__clearReading(); + res = tagCallback(el, tagData); + can.__setReading(reads); + } else { + res = scope; + } + if (res && tagData.subtemplate) { + if (scope !== res) { + scope = scope.add(res); + } + var result = tagData.subtemplate(scope, tagData.options); + var frag = typeof result === 'string' ? can.view.frag(result) : result; + can.appendChild(el, frag); + } + } + }; + return can.view.callbacks; +}); +/*can@2.2.6#view/elements*/ +define('can/view/elements', [ + 'can/util/util', + 'can/view/view' +], function (can) { + var doc = typeof document !== 'undefined' ? document : null; + var selectsCommentNodes = doc && function () { + return can.$(document.createComment('~')).length === 1; + }(); + var elements = { + tagToContentPropMap: { + option: doc && 'textContent' in document.createElement('option') ? 'textContent' : 'innerText', + textarea: 'value' + }, + attrMap: can.attr.map, + attrReg: /([^\s=]+)[\s]*=[\s]*/, + defaultValue: can.attr.defaultValue, + tagMap: { + '': 'span', + colgroup: 'col', + table: 'tbody', + tr: 'td', + ol: 'li', + ul: 'li', + tbody: 'tr', + thead: 'tr', + tfoot: 'tr', + select: 'option', + optgroup: 'option' + }, + reverseTagMap: { + col: 'colgroup', + tr: 'tbody', + option: 'select', + td: 'tr', + th: 'tr', + li: 'ul' + }, + getParentNode: function (el, defaultParentNode) { + return defaultParentNode && el.parentNode.nodeType === 11 ? defaultParentNode : el.parentNode; + }, + setAttr: can.attr.set, + getAttr: can.attr.get, + removeAttr: can.attr.remove, + contentText: function (text) { + if (typeof text === 'string') { + return text; + } + if (!text && text !== 0) { + return ''; + } + return '' + text; + }, + after: function (oldElements, newFrag) { + var last = oldElements[oldElements.length - 1]; + if (last.nextSibling) { + can.insertBefore(last.parentNode, newFrag, last.nextSibling); + } else { + can.appendChild(last.parentNode, newFrag); + } + }, + replace: function (oldElements, newFrag) { + elements.after(oldElements, newFrag); + if (can.remove(can.$(oldElements)).length < oldElements.length && !selectsCommentNodes) { + can.each(oldElements, function (el) { + if (el.nodeType === 8) { + el.parentNode.removeChild(el); + } + }); + } + } + }; + can.view.elements = elements; + return elements; +}); +/*can@2.2.6#util/string/string*/ +define('can/util/string/string', ['can/util/util'], function (can) { + var strUndHash = /_|-/, strColons = /\=\=/, strWords = /([A-Z]+)([A-Z][a-z])/g, strLowUp = /([a-z\d])([A-Z])/g, strDash = /([a-z\d])([A-Z])/g, strReplacer = /\{([^\}]+)\}/g, strQuote = /"/g, strSingleQuote = /'/g, strHyphenMatch = /-+(.)?/g, strCamelMatch = /[a-z][A-Z]/g, getNext = function (obj, prop, add) { + var result = obj[prop]; + if (result === undefined && add === true) { + result = obj[prop] = {}; + } + return result; + }, isContainer = function (current) { + return /^f|^o/.test(typeof current); + }, convertBadValues = function (content) { + var isInvalid = content === null || content === undefined || isNaN(content) && '' + content === 'NaN'; + return '' + (isInvalid ? '' : content); + }; + can.extend(can, { + esc: function (content) { + return convertBadValues(content).replace(/&/g, '&').replace(//g, '>').replace(strQuote, '"').replace(strSingleQuote, '''); + }, + getObject: function (name, roots, add) { + var parts = name ? name.split('.') : [], length = parts.length, current, r = 0, i, container, rootsLength; + roots = can.isArray(roots) ? roots : [roots || window]; + rootsLength = roots.length; + if (!length) { + return roots[0]; + } + for (r; r < rootsLength; r++) { + current = roots[r]; + container = undefined; + for (i = 0; i < length && isContainer(current); i++) { + container = current; + current = getNext(container, parts[i]); + } + if (container !== undefined && current !== undefined) { + break; + } + } + if (add === false && current !== undefined) { + delete container[parts[i - 1]]; + } + if (add === true && current === undefined) { + current = roots[0]; + for (i = 0; i < length && isContainer(current); i++) { + current = getNext(current, parts[i], true); + } + } + return current; + }, + capitalize: function (s, cache) { + return s.charAt(0).toUpperCase() + s.slice(1); + }, + camelize: function (str) { + return convertBadValues(str).replace(strHyphenMatch, function (match, chr) { + return chr ? chr.toUpperCase() : ''; + }); + }, + hyphenate: function (str) { + return convertBadValues(str).replace(strCamelMatch, function (str, offset) { + return str.charAt(0) + '-' + str.charAt(1).toLowerCase(); + }); + }, + underscore: function (s) { + return s.replace(strColons, '/').replace(strWords, '$1_$2').replace(strLowUp, '$1_$2').replace(strDash, '_').toLowerCase(); + }, + sub: function (str, data, remove) { + var obs = []; + str = str || ''; + obs.push(str.replace(strReplacer, function (whole, inside) { + var ob = can.getObject(inside, data, remove === true ? false : undefined); + if (ob === undefined || ob === null) { + obs = null; + return ''; + } + if (isContainer(ob) && obs) { + obs.push(ob); + return ''; + } + return '' + ob; + })); + return obs === null ? obs : obs.length <= 1 ? obs[0] : obs; + }, + replacer: strReplacer, + undHash: strUndHash + }); + return can; +}); +/*can@2.2.6#construct/construct*/ +define('can/construct/construct', ['can/util/string/string'], function (can) { + var initializing = 0; + var canGetDescriptor; + try { + Object.getOwnPropertyDescriptor({}); + canGetDescriptor = true; + } catch (e) { + canGetDescriptor = false; + } + var getDescriptor = function (newProps, name) { + var descriptor = Object.getOwnPropertyDescriptor(newProps, name); + if (descriptor && (descriptor.get || descriptor.set)) { + return descriptor; + } + return null; + }, inheritGetterSetter = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + var descriptor; + for (var name in newProps) { + if (descriptor = getDescriptor(newProps, name)) { + this._defineProperty(addTo, oldProps, name, descriptor); + } else { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + } + }, simpleInherit = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + for (var name in newProps) { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + }; + can.Construct = function () { + if (arguments.length) { + return can.Construct.extend.apply(can.Construct, arguments); + } + }; + can.extend(can.Construct, { + constructorExtends: true, + newInstance: function () { + var inst = this.instance(), args; + if (inst.setup) { + args = inst.setup.apply(inst, arguments); + } + if (inst.init) { + inst.init.apply(inst, args || arguments); + } + return inst; + }, + _inherit: canGetDescriptor ? inheritGetterSetter : simpleInherit, + _defineProperty: function (what, oldProps, propName, descriptor) { + Object.defineProperty(what, propName, descriptor); + }, + _overwrite: function (what, oldProps, propName, val) { + what[propName] = val; + }, + setup: function (base, fullName) { + this.defaults = can.extend(true, {}, base.defaults, this.defaults); + }, + instance: function () { + initializing = 1; + var inst = new this(); + initializing = 0; + return inst; + }, + extend: function (name, staticProperties, instanceProperties) { + var fullName = name, klass = staticProperties, proto = instanceProperties; + if (typeof fullName !== 'string') { + proto = klass; + klass = fullName; + fullName = null; + } + if (!proto) { + proto = klass; + klass = null; + } + proto = proto || {}; + var _super_class = this, _super = this.prototype, Constructor, parts, current, _fullName, _shortName, propName, shortName, namespace, prototype; + prototype = this.instance(); + can.Construct._inherit(proto, _super, prototype); + if (fullName) { + parts = fullName.split('.'); + shortName = parts.pop(); + } + if (typeof constructorName === 'undefined') { + Constructor = function () { + return init.apply(this, arguments); + }; + } + function init() { + if (!initializing) { + return this.constructor !== Constructor && arguments.length && Constructor.constructorExtends ? Constructor.extend.apply(Constructor, arguments) : Constructor.newInstance.apply(Constructor, arguments); + } + } + for (propName in _super_class) { + if (_super_class.hasOwnProperty(propName)) { + Constructor[propName] = _super_class[propName]; + } + } + can.Construct._inherit(klass, _super_class, Constructor); + if (fullName) { + current = can.getObject(parts.join('.'), window, true); + namespace = current; + _fullName = can.underscore(fullName.replace(/\./g, '_')); + _shortName = can.underscore(shortName); + current[shortName] = Constructor; + } + can.extend(Constructor, { + constructor: Constructor, + prototype: prototype, + namespace: namespace, + _shortName: _shortName, + fullName: fullName, + _fullName: _fullName + }); + if (shortName !== undefined) { + Constructor.shortName = shortName; + } + Constructor.prototype.constructor = Constructor; + var t = [_super_class].concat(can.makeArray(arguments)), args = Constructor.setup.apply(Constructor, t); + if (Constructor.init) { + Constructor.init.apply(Constructor, args || t); + } + return Constructor; + } + }); + can.Construct.prototype.setup = function () { + }; + can.Construct.prototype.init = function () { + }; + return can.Construct; +}); +/*can@2.2.6#control/control*/ +define('can/control/control', [ + 'can/util/util', + 'can/construct/construct' +], function (can) { + var bind = function (el, ev, callback) { + can.bind.call(el, ev, callback); + return function () { + can.unbind.call(el, ev, callback); + }; + }, isFunction = can.isFunction, extend = can.extend, each = can.each, slice = [].slice, paramReplacer = /\{([^\}]+)\}/g, special = can.getObject('$.event.special', [can]) || {}, delegate = function (el, selector, ev, callback) { + can.delegate.call(el, selector, ev, callback); + return function () { + can.undelegate.call(el, selector, ev, callback); + }; + }, binder = function (el, ev, callback, selector) { + return selector ? delegate(el, can.trim(selector), ev, callback) : bind(el, ev, callback); + }, basicProcessor; + var Control = can.Control = can.Construct({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Control) { + var control = this, funcName; + control.actions = {}; + for (funcName in control.prototype) { + if (control._isAction(funcName)) { + control.actions[funcName] = control._action(funcName); + } + } + } + }, + _shifter: function (context, name) { + var method = typeof name === 'string' ? context[name] : name; + if (!isFunction(method)) { + method = context[method]; + } + return function () { + context.called = name; + return method.apply(context, [this.nodeName ? can.$(this) : this].concat(slice.call(arguments, 0))); + }; + }, + _isAction: function (methodName) { + var val = this.prototype[methodName], type = typeof val; + return methodName !== 'constructor' && (type === 'function' || type === 'string' && isFunction(this.prototype[val])) && !!(special[methodName] || processors[methodName] || /[^\w]/.test(methodName)); + }, + _action: function (methodName, options) { + paramReplacer.lastIndex = 0; + if (options || !paramReplacer.test(methodName)) { + var convertedName = options ? can.sub(methodName, this._lookup(options)) : methodName; + if (!convertedName) { + return null; + } + var arr = can.isArray(convertedName), name = arr ? convertedName[1] : convertedName, parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: processors[event] || basicProcessor, + parts: [ + name, + parts.join(' '), + event + ], + delegate: arr ? convertedName[0] : undefined + }; + } + }, + _lookup: function (options) { + return [ + options, + window + ]; + }, + processors: {}, + defaults: {} + }, { + setup: function (element, options) { + var cls = this.constructor, pluginname = cls.pluginName || cls._fullName, arr; + this.element = can.$(element); + if (pluginname && pluginname !== 'can_control') { + this.element.addClass(pluginname); + } + arr = can.data(this.element, 'controls'); + if (!arr) { + arr = []; + can.data(this.element, 'controls', arr); + } + arr.push(this); + this.options = extend({}, cls.defaults, options); + this.on(); + return [ + this.element, + this.options + ]; + }, + on: function (el, selector, eventName, func) { + if (!el) { + this.off(); + var cls = this.constructor, bindings = this._bindings, actions = cls.actions, element = this.element, destroyCB = can.Control._shifter(this, 'destroy'), funcName, ready; + for (funcName in actions) { + if (actions.hasOwnProperty(funcName)) { + ready = actions[funcName] || cls._action(funcName, this.options, this); + if (ready) { + bindings.control[funcName] = ready.processor(ready.delegate || element, ready.parts[2], ready.parts[1], funcName, this); + } + } + } + can.bind.call(element, 'removed', destroyCB); + bindings.user.push(function (el) { + can.unbind.call(el, 'removed', destroyCB); + }); + return bindings.user.length; + } + if (typeof el === 'string') { + func = eventName; + eventName = selector; + selector = el; + el = this.element; + } + if (func === undefined) { + func = eventName; + eventName = selector; + selector = null; + } + if (typeof func === 'string') { + func = can.Control._shifter(this, func); + } + this._bindings.user.push(binder(el, eventName, func, selector)); + return this._bindings.user.length; + }, + off: function () { + var el = this.element[0], bindings = this._bindings; + if (bindings) { + each(bindings.user || [], function (value) { + value(el); + }); + each(bindings.control || {}, function (value) { + value(el); + }); + } + this._bindings = { + user: [], + control: {} + }; + }, + destroy: function () { + if (this.element === null) { + return; + } + var Class = this.constructor, pluginName = Class.pluginName || Class._fullName, controls; + this.off(); + if (pluginName && pluginName !== 'can_control') { + this.element.removeClass(pluginName); + } + controls = can.data(this.element, 'controls'); + controls.splice(can.inArray(this, controls), 1); + can.trigger(this, 'destroyed'); + this.element = null; + } + }); + var processors = can.Control.processors; + basicProcessor = function (el, event, selector, methodName, control) { + return binder(el, event, can.Control._shifter(control, methodName), selector); + }; + each([ + 'change', + 'click', + 'contextmenu', + 'dblclick', + 'keydown', + 'keyup', + 'keypress', + 'mousedown', + 'mousemove', + 'mouseout', + 'mouseover', + 'mouseup', + 'reset', + 'resize', + 'scroll', + 'select', + 'submit', + 'focusin', + 'focusout', + 'mouseenter', + 'mouseleave', + 'touchstart', + 'touchmove', + 'touchcancel', + 'touchend', + 'touchleave', + 'inserted', + 'removed' + ], function (v) { + processors[v] = basicProcessor; + }); + return Control; +}); +/*can@2.2.6#util/bind/bind*/ +define('can/util/bind/bind', ['can/util/util'], function (can) { + can.bindAndSetup = function () { + can.addEvent.apply(this, arguments); + if (!this._init) { + if (!this._bindings) { + this._bindings = 1; + if (this._bindsetup) { + this._bindsetup(); + } + } else { + this._bindings++; + } + } + return this; + }; + can.unbindAndTeardown = function (event, handler) { + var handlers = this.__bindEvents[event] || []; + var handlerCount = handlers.length; + can.removeEvent.apply(this, arguments); + if (this._bindings === null) { + this._bindings = 0; + } else { + this._bindings = this._bindings - (handlerCount - handlers.length); + } + if (!this._bindings && this._bindteardown) { + this._bindteardown(); + } + return this; + }; + return can; +}); +/*can@2.2.6#map/bubble*/ +define('can/map/bubble', ['can/util/util'], function (can) { + var bubble = can.bubble = { + event: function (map, boundEventName) { + return map.constructor._bubbleRule(boundEventName, map); + }, + childrenOf: function (parentMap, eventName) { + parentMap._each(function (child, prop) { + if (child && child.bind) { + bubble.toParent(child, parentMap, prop, eventName); + } + }); + }, + teardownChildrenFrom: function (parentMap, eventName) { + parentMap._each(function (child) { + bubble.teardownFromParent(parentMap, child, eventName); + }); + }, + toParent: function (child, parent, prop, eventName) { + can.listenTo.call(parent, child, eventName, function () { + var args = can.makeArray(arguments), ev = args.shift(); + args[0] = (can.List && parent instanceof can.List ? parent.indexOf(child) : prop) + (args[0] ? '.' + args[0] : ''); + ev.triggeredNS = ev.triggeredNS || {}; + if (ev.triggeredNS[parent._cid]) { + return; + } + ev.triggeredNS[parent._cid] = true; + can.trigger(parent, ev, args); + }); + }, + teardownFromParent: function (parent, child, eventName) { + if (child && child.unbind) { + can.stopListening.call(parent, child, eventName); + } + }, + isBubbling: function (parent, eventName) { + return parent._bubbleBindings && parent._bubbleBindings[eventName]; + }, + bind: function (parent, eventName) { + if (!parent._init) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + if (!parent._bubbleBindings) { + parent._bubbleBindings = {}; + } + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (!parent._bubbleBindings[bubbleEvent]) { + parent._bubbleBindings[bubbleEvent] = 1; + bubble.childrenOf(parent, bubbleEvent); + } else { + parent._bubbleBindings[bubbleEvent]++; + } + } + } + }, + unbind: function (parent, eventName) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (parent._bubbleBindings) { + parent._bubbleBindings[bubbleEvent]--; + } + if (parent._bubbleBindings && !parent._bubbleBindings[bubbleEvent]) { + delete parent._bubbleBindings[bubbleEvent]; + bubble.teardownChildrenFrom(parent, bubbleEvent); + if (can.isEmptyObject(parent._bubbleBindings)) { + delete parent._bubbleBindings; + } + } + } + }, + add: function (parent, child, prop) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + bubble.toParent(child, parent, prop, eventName); + } + } + } + }, + removeMany: function (parent, children) { + for (var i = 0, len = children.length; i < len; i++) { + bubble.remove(parent, children[i]); + } + }, + remove: function (parent, child) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + } + } + } + }, + set: function (parent, prop, value, current) { + if (can.Map.helpers.isObservable(value)) { + bubble.add(parent, value, prop); + } + if (can.Map.helpers.isObservable(current)) { + bubble.remove(parent, current); + } + return value; + } + }; + return bubble; +}); +/*can@2.2.6#util/batch/batch*/ +define('can/util/batch/batch', ['can/util/can'], function (can) { + var batchNum = 1, transactions = 0, batchEvents = [], stopCallbacks = [], currentBatchEvents = null; + can.batch = { + start: function (batchStopHandler) { + transactions++; + if (batchStopHandler) { + stopCallbacks.push(batchStopHandler); + } + }, + stop: function (force, callStart) { + if (force) { + transactions = 0; + } else { + transactions--; + } + if (transactions === 0) { + if (currentBatchEvents !== null) { + return; + } + currentBatchEvents = batchEvents.slice(0); + var callbacks = stopCallbacks.slice(0), i, len; + batchEvents = []; + stopCallbacks = []; + can.batch.batchNum = batchNum; + batchNum++; + if (callStart) { + can.batch.start(); + } + for (i = 0; i < currentBatchEvents.length; i++) { + can.dispatch.apply(currentBatchEvents[i][0], currentBatchEvents[i][1]); + } + currentBatchEvents = null; + for (i = 0, len = callbacks.length; i < callbacks.length; i++) { + callbacks[i](); + } + can.batch.batchNum = undefined; + } + }, + trigger: function (item, event, args) { + if (!item._init) { + event = typeof event === 'string' ? { type: event } : event; + if (currentBatchEvents) { + currentBatchEvents.push([ + item, + [ + event, + args + ] + ]); + } else if (transactions === 0) { + return can.dispatch.call(item, event, args); + } else { + event.batchNum = batchNum; + batchEvents.push([ + item, + [ + event, + args + ] + ]); + } + } + }, + afterPreviousEvents: function (handler) { + if (currentBatchEvents) { + var obj = {}; + can.bind.call(obj, 'ready', handler); + currentBatchEvents.push([ + obj, + [ + { type: 'ready' }, + [] + ] + ]); + } else { + handler(); + } + } + }; +}); +/*can@2.2.6#map/map*/ +define('can/map/map', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/map/bubble', + 'can/construct/construct', + 'can/util/batch/batch' +], function (can, bind, bubble) { + var madeMap = null; + var teardownMap = function () { + for (var cid in madeMap) { + if (madeMap[cid].added) { + delete madeMap[cid].obj._cid; + } + } + madeMap = null; + }; + var getMapFromObject = function (obj) { + return madeMap && madeMap[obj._cid] && madeMap[obj._cid].instance; + }; + var serializeMap = null; + var Map = can.Map = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Map) { + if (!this.defaults) { + this.defaults = {}; + } + this._computes = []; + for (var prop in this.prototype) { + if (prop !== 'define' && prop !== 'constructor' && (typeof this.prototype[prop] !== 'function' || this.prototype[prop].prototype instanceof can.Construct)) { + this.defaults[prop] = this.prototype[prop]; + } else if (this.prototype[prop].isComputed) { + this._computes.push(prop); + } + } + if (this.helpers.define) { + this.helpers.define(this); + } + } + if (can.List && !(this.prototype instanceof can.List)) { + this.List = Map.List.extend({ Map: this }, {}); + } + }, + _bubble: bubble, + _bubbleRule: function (eventName) { + return eventName === 'change' || eventName.indexOf('.') >= 0 ? ['change'] : []; + }, + _computes: [], + bind: can.bindAndSetup, + on: can.bindAndSetup, + unbind: can.unbindAndTeardown, + off: can.unbindAndTeardown, + id: 'id', + helpers: { + define: null, + attrParts: function (attr, keepKey) { + if (keepKey) { + return [attr]; + } + return typeof attr === 'object' ? attr : ('' + attr).split('.'); + }, + addToMap: function (obj, instance) { + var teardown; + if (!madeMap) { + teardown = teardownMap; + madeMap = {}; + } + var hasCid = obj._cid; + var cid = can.cid(obj); + if (!madeMap[cid]) { + madeMap[cid] = { + obj: obj, + instance: instance, + added: !hasCid + }; + } + return teardown; + }, + isObservable: function (obj) { + return obj instanceof can.Map || obj && obj === can.route; + }, + canMakeObserve: function (obj) { + return obj && !can.isDeferred(obj) && (can.isArray(obj) || can.isPlainObject(obj)); + }, + serialize: function (map, how, where) { + var cid = can.cid(map), firstSerialize = false; + if (!serializeMap) { + firstSerialize = true; + serializeMap = { + attr: {}, + serialize: {} + }; + } + serializeMap[how][cid] = where; + map.each(function (val, name) { + var result, isObservable = Map.helpers.isObservable(val), serialized = isObservable && serializeMap[how][can.cid(val)]; + if (serialized) { + result = serialized; + } else { + if (how === 'serialize') { + result = Map.helpers._serialize(map, name, val); + } else { + result = Map.helpers._getValue(map, name, val, how); + } + } + if (result !== undefined) { + where[name] = result; + } + }); + can.__observe(map, '__keys'); + if (firstSerialize) { + serializeMap = null; + } + return where; + }, + _serialize: function (map, name, val) { + return Map.helpers._getValue(map, name, val, 'serialize'); + }, + _getValue: function (map, name, val, how) { + if (Map.helpers.isObservable(val)) { + return val[how](); + } else { + return val; + } + } + }, + keys: function (map) { + var keys = []; + can.__observe(map, '__keys'); + for (var keyName in map._data) { + keys.push(keyName); + } + return keys; + } + }, { + setup: function (obj) { + if (obj instanceof can.Map) { + obj = obj.serialize(); + } + this._data = {}; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + var defaultValues = this._setupDefaults(obj); + this._setupComputes(defaultValues); + var teardownMapping = obj && can.Map.helpers.addToMap(obj, this); + var data = can.extend(can.extend(true, {}, defaultValues), obj); + this.attr(data); + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + delete this._init; + }, + _setupComputes: function () { + var computes = this.constructor._computes; + for (var i = 0, len = computes.length, prop; i < len; i++) { + prop = computes[i]; + this[prop] = this[prop].clone(this); + this._computedBindings[prop] = { count: 0 }; + } + }, + _setupDefaults: function () { + return this.constructor.defaults || {}; + }, + _bindsetup: function () { + }, + _bindteardown: function () { + }, + _changes: function (ev, attr, how, newVal, oldVal) { + can.batch.trigger(this, { + type: attr, + batchNum: ev.batchNum, + target: ev.target + }, [ + newVal, + oldVal + ]); + }, + _triggerChange: function (attr, how, newVal, oldVal) { + if (bubble.isBubbling(this, 'change')) { + can.batch.trigger(this, { + type: 'change', + target: this + }, [ + attr, + how, + newVal, + oldVal + ]); + } else { + can.batch.trigger(this, attr, [ + newVal, + oldVal + ]); + } + if (how === 'remove' || how === 'add') { + can.batch.trigger(this, { + type: '__keys', + target: this + }); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var prop in data) { + if (data.hasOwnProperty(prop)) { + callback(data[prop], prop); + } + } + }, + attr: function (attr, val) { + var type = typeof attr; + if (type !== 'string' && type !== 'number') { + return this._attrs(attr, val); + } else if (arguments.length === 1) { + return this._get(attr); + } else { + this._set(attr, val); + return this; + } + }, + each: function () { + return can.each.apply(undefined, [this].concat(can.makeArray(arguments))); + }, + removeAttr: function (attr) { + var isList = can.List && this instanceof can.List, parts = can.Map.helpers.attrParts(attr), prop = parts.shift(), current = isList ? this[prop] : this._data[prop]; + if (parts.length && current) { + return current.removeAttr(parts); + } else { + if (typeof attr === 'string' && !!~attr.indexOf('.')) { + prop = attr; + } + this._remove(prop, current); + return current; + } + }, + _remove: function (prop, current) { + if (prop in this._data) { + delete this._data[prop]; + if (!(prop in this.constructor.prototype)) { + delete this[prop]; + } + this._triggerChange(prop, 'remove', undefined, current); + } + }, + _get: function (attr) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'); + if (dotIndex >= 0) { + var value = this.__get(attr); + if (value !== undefined) { + return value; + } + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + can.__observe(this, first); + var current = this.__get(first); + return current && current._get ? current._get(second) : undefined; + } else { + can.__observe(this, attr); + return this.__get(attr); + } + }, + __get: function (attr) { + if (attr) { + if (this._computedBindings[attr]) { + return this[attr](); + } else { + return this._data[attr]; + } + } else { + return this._data; + } + }, + __type: function (value, prop) { + if (!(value instanceof can.Map) && can.Map.helpers.canMakeObserve(value)) { + var cached = getMapFromObject(value); + if (cached) { + return cached; + } + if (can.isArray(value)) { + var List = can.List; + return new List(value); + } else { + var Map = this.constructor.Map || can.Map; + return new Map(value); + } + } + return value; + }, + _set: function (attr, value, keepKey) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'), current; + if (!keepKey && dotIndex >= 0) { + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + current = this._init ? undefined : this.__get(first); + if (Map.helpers.isObservable(current)) { + current._set(second, value); + } else { + throw 'can.Map: Object does not exist'; + } + } else { + if (this.__convert) { + value = this.__convert(attr, value); + } + current = this._init ? undefined : this.__get(attr); + this.__set(attr, this.__type(value, attr), current); + } + }, + __set: function (prop, value, current) { + if (value !== current) { + var changeType = current !== undefined || this.__get().hasOwnProperty(prop) ? 'set' : 'add'; + this.___set(prop, this.constructor._bubble.set(this, prop, value, current)); + if (!this._computedBindings[prop]) { + this._triggerChange(prop, changeType, value, current); + } + if (current) { + this.constructor._bubble.teardownFromParent(this, current); + } + } + }, + ___set: function (prop, val) { + if (this._computedBindings[prop]) { + this[prop](val); + } else { + this._data[prop] = val; + } + if (typeof this.constructor.prototype[prop] !== 'function' && !this._computedBindings[prop]) { + this[prop] = val; + } + }, + bind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (!computedBinding.count) { + computedBinding.count = 1; + var self = this; + computedBinding.handler = function (ev, newVal, oldVal) { + can.batch.trigger(self, { + type: eventName, + batchNum: ev.batchNum, + target: self + }, [ + newVal, + oldVal + ]); + }; + this[eventName].bind('change', computedBinding.handler); + } else { + computedBinding.count++; + } + } + this.constructor._bubble.bind(this, eventName); + return can.bindAndSetup.apply(this, arguments); + }, + unbind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (computedBinding.count === 1) { + computedBinding.count = 0; + this[eventName].unbind('change', computedBinding.handler); + delete computedBinding.handler; + } else { + computedBinding.count--; + } + } + this.constructor._bubble.unbind(this, eventName); + return can.unbindAndTeardown.apply(this, arguments); + }, + serialize: function () { + return can.Map.helpers.serialize(this, 'serialize', {}); + }, + _attrs: function (props, remove) { + if (props === undefined) { + return Map.helpers.serialize(this, 'attr', {}); + } + props = can.simpleExtend({}, props); + var prop, self = this, newVal; + can.batch.start(); + this.each(function (curVal, prop) { + if (prop === '_cid') { + return; + } + newVal = props[prop]; + if (newVal === undefined) { + if (remove) { + self.removeAttr(prop); + } + return; + } + if (self.__convert) { + newVal = self.__convert(prop, newVal); + } + if (Map.helpers.isObservable(newVal)) { + self.__set(prop, self.__type(newVal, prop), curVal); + } else if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + self.__set(prop, self.__type(newVal, prop), curVal); + } + delete props[prop]; + }); + for (prop in props) { + if (prop !== '_cid') { + newVal = props[prop]; + this._set(prop, newVal, true); + } + } + can.batch.stop(); + return this; + }, + compute: function (prop) { + if (can.isFunction(this.constructor.prototype[prop])) { + return can.compute(this[prop], this); + } else { + var reads = prop.split('.'), last = reads.length - 1, options = { args: [] }; + return can.compute(function (newVal) { + if (arguments.length) { + can.compute.read(this, reads.slice(0, last)).value.attr(reads[last], newVal); + } else { + return can.compute.read(this, reads, options).value; + } + }, this); + } + } + }); + Map.prototype.on = Map.prototype.bind; + Map.prototype.off = Map.prototype.unbind; + return Map; +}); +/*can@2.2.6#list/list*/ +define('can/list/list', [ + 'can/util/util', + 'can/map/map', + 'can/map/bubble' +], function (can, Map, bubble) { + var splice = [].splice, spliceRemovesProps = function () { + var obj = { + 0: 'a', + length: 1 + }; + splice.call(obj, 0, 1); + return !obj[0]; + }(); + var list = Map.extend({ Map: Map }, { + setup: function (instances, options) { + this.length = 0; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + this._setupComputes(); + instances = instances || []; + var teardownMapping; + if (can.isDeferred(instances)) { + this.replace(instances); + } else { + teardownMapping = instances.length && can.Map.helpers.addToMap(instances, this); + this.push.apply(this, can.makeArray(instances || [])); + } + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + can.simpleExtend(this, options); + delete this._init; + }, + _triggerChange: function (attr, how, newVal, oldVal) { + Map.prototype._triggerChange.apply(this, arguments); + var index = +attr; + if (!~('' + attr).indexOf('.') && !isNaN(index)) { + if (how === 'add') { + can.batch.trigger(this, how, [ + newVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else if (how === 'remove') { + can.batch.trigger(this, how, [ + oldVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else { + can.batch.trigger(this, how, [ + newVal, + index + ]); + } + } + }, + __get: function (attr) { + if (attr) { + if (this[attr] && this[attr].isComputed && can.isFunction(this.constructor.prototype[attr])) { + return this[attr](); + } else { + return this[attr]; + } + } else { + return this; + } + }, + __set: function (prop, value, current) { + prop = isNaN(+prop) || prop % 1 ? prop : +prop; + if (typeof prop === 'number' && prop > this.length - 1) { + var newArr = new Array(prop + 1 - this.length); + newArr[newArr.length - 1] = value; + this.push.apply(this, newArr); + return newArr; + } + return can.Map.prototype.__set.call(this, '' + prop, value, current); + }, + ___set: function (attr, val) { + this[attr] = val; + if (+attr >= this.length) { + this.length = +attr + 1; + } + }, + _remove: function (prop, current) { + if (isNaN(+prop)) { + delete this[prop]; + this._triggerChange(prop, 'remove', undefined, current); + } else { + this.splice(prop, 1); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var i = 0; i < data.length; i++) { + callback(data[i], i); + } + }, + serialize: function () { + return Map.helpers.serialize(this, 'serialize', []); + }, + splice: function (index, howMany) { + var args = can.makeArray(arguments), added = [], i, len, listIndex, allSame = args.length > 2; + index = index || 0; + for (i = 0, len = args.length - 2; i < len; i++) { + listIndex = i + 2; + args[listIndex] = this.__type(args[listIndex], listIndex); + added.push(args[listIndex]); + if (this[i + index] !== args[listIndex]) { + allSame = false; + } + } + if (allSame && this.length <= added.length) { + return added; + } + if (howMany === undefined) { + howMany = args[1] = this.length - index; + } + var removed = splice.apply(this, args); + if (!spliceRemovesProps) { + for (i = this.length; i < removed.length + this.length; i++) { + delete this[i]; + } + } + can.batch.start(); + if (howMany > 0) { + bubble.removeMany(this, removed); + this._triggerChange('' + index, 'remove', undefined, removed); + } + if (args.length > 2) { + for (i = 0, len = added.length; i < len; i++) { + bubble.set(this, i, added[i]); + } + this._triggerChange('' + index, 'add', added, removed); + } + can.batch.stop(); + return removed; + }, + _attrs: function (items, remove) { + if (items === undefined) { + return Map.helpers.serialize(this, 'attr', []); + } + items = can.makeArray(items); + can.batch.start(); + this._updateAttrs(items, remove); + can.batch.stop(); + }, + _updateAttrs: function (items, remove) { + var len = Math.min(items.length, this.length); + for (var prop = 0; prop < len; prop++) { + var curVal = this[prop], newVal = items[prop]; + if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + this._set(prop, newVal); + } else { + } + } + if (items.length > this.length) { + this.push.apply(this, items.slice(this.length)); + } else if (items.length < this.length && remove) { + this.splice(items.length); + } + } + }), getArgs = function (args) { + return args[0] && can.isArray(args[0]) ? args[0] : can.makeArray(args); + }; + can.each({ + push: 'length', + unshift: 0 + }, function (where, name) { + var orig = [][name]; + list.prototype[name] = function () { + var args = [], len = where ? this.length : 0, i = arguments.length, res, val; + while (i--) { + val = arguments[i]; + args[i] = bubble.set(this, i, this.__type(val, i)); + } + res = orig.apply(this, args); + if (!this.comparator || args.length) { + this._triggerChange('' + len, 'add', args, undefined); + } + return res; + }; + }); + can.each({ + pop: 'length', + shift: 0 + }, function (where, name) { + list.prototype[name] = function () { + if (!this.length) { + return undefined; + } + var args = getArgs(arguments), len = where && this.length ? this.length - 1 : 0; + var res = [][name].apply(this, args); + this._triggerChange('' + len, 'remove', undefined, [res]); + if (res && res.unbind) { + bubble.remove(this, res); + } + return res; + }; + }); + can.extend(list.prototype, { + indexOf: function (item, fromIndex) { + this.attr('length'); + return can.inArray(item, this, fromIndex); + }, + join: function () { + return [].join.apply(this.attr(), arguments); + }, + reverse: function () { + var list = [].reverse.call(can.makeArray(this)); + this.replace(list); + }, + slice: function () { + var temp = Array.prototype.slice.apply(this, arguments); + return new this.constructor(temp); + }, + concat: function () { + var args = []; + can.each(can.makeArray(arguments), function (arg, i) { + args[i] = arg instanceof can.List ? arg.serialize() : arg; + }); + return new this.constructor(Array.prototype.concat.apply(this.serialize(), args)); + }, + forEach: function (cb, thisarg) { + return can.each(this, cb, thisarg || this); + }, + replace: function (newList) { + if (can.isDeferred(newList)) { + newList.then(can.proxy(this.replace, this)); + } else { + this.splice.apply(this, [ + 0, + this.length + ].concat(can.makeArray(newList || []))); + } + return this; + }, + filter: function (callback, thisArg) { + var filteredList = new can.List(), self = this, filtered; + this.each(function (item, index, list) { + filtered = callback.call(thisArg | self, item, index, self); + if (filtered) { + filteredList.push(item); + } + }); + return filteredList; + } + }); + can.List = Map.List = list; + return can.List; +}); +/*can@2.2.6#compute/read*/ +define('can/compute/read', ['can/util/util'], function (can) { + var read = function (parent, reads, options) { + options = options || {}; + var state = { foundObservable: false }; + var cur = readValue(parent, 0, reads, options, state), type, prev, readLength = reads.length, i = 0; + while (i < readLength) { + prev = cur; + for (var r = 0, readersLength = read.propertyReaders.length; r < readersLength; r++) { + var reader = read.propertyReaders[r]; + if (reader.test(cur)) { + cur = reader.read(cur, reads[i], i, options, state); + break; + } + } + i = i + 1; + cur = readValue(cur, i, reads, options, state, prev); + type = typeof cur; + if (i < reads.length && (cur === null || type !== 'function' && type !== 'object')) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1, cur); + } + return { + value: undefined, + parent: prev + }; + } + } + if (cur === undefined) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1); + } + } + return { + value: cur, + parent: prev + }; + }; + var readValue = function (value, index, reads, options, state, prev) { + var usedValueReader; + do { + usedValueReader = false; + for (var i = 0, len = read.valueReaders.length; i < len; i++) { + if (read.valueReaders[i].test(value, index, reads, options)) { + value = read.valueReaders[i].read(value, index, reads, options, state, prev); + } + } + } while (usedValueReader); + return value; + }; + read.valueReaders = [ + { + name: 'compute', + test: function (value, i, reads, options) { + return value && value.isComputed; + }, + read: function (value, i, reads, options, state) { + if (options.isArgument && i === reads.length) { + return value; + } + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, i); + state.foundObservable = true; + } + return value instanceof can.Compute ? value.get() : value(); + } + }, + { + name: 'function', + test: function (value, i, reads, options) { + var type = typeof value; + return type === 'function' && !value.isComputed && (options.executeAnonymousFunctions || options.isArgument && i === reads.length) && !(can.Construct && value.prototype instanceof can.Construct) && !(can.route && value === can.route); + }, + read: function (value, i, reads, options, state, prev) { + if (options.isArgument && i === reads.length) { + return options.proxyMethods !== false ? can.proxy(value, prev) : value; + } + return value.call(prev); + } + } + ]; + read.propertyReaders = [ + { + name: 'map', + test: can.isMapLike, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + if (typeof value[prop] === 'function' && value.constructor.prototype[prop] === value[prop]) { + if (options.returnObserveMethods) { + return value[prop]; + } else if (prop === 'constructor' && value instanceof can.Construct || value[prop].prototype instanceof can.Construct) { + return value[prop]; + } else { + return value[prop].apply(value, options.args || []); + } + } else { + return value.attr(prop); + } + } + }, + { + name: 'promise', + test: function (value) { + return can.isPromise(value); + }, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + var observeData = value.__observeData; + if (!value.__observeData) { + observeData = value.__observeData = { + isPending: true, + state: 'pending', + isResolved: false, + isRejected: false, + value: undefined, + reason: undefined + }; + can.cid(observeData); + can.simpleExtend(observeData, can.event); + value.then(function (value) { + observeData.isPending = false; + observeData.isResolved = true; + observeData.value = value; + observeData.state = 'resolved'; + observeData.dispatch('state', [ + 'resolved', + 'pending' + ]); + }, function (reason) { + observeData.isPending = false; + observeData.isRejected = true; + observeData.reason = reason; + observeData.state = 'rejected'; + observeData.dispatch('state', [ + 'rejected', + 'pending' + ]); + }); + } + can.__observe(observeData, 'state'); + return prop in observeData ? observeData[prop] : value[prop]; + } + }, + { + name: 'object', + test: function () { + return true; + }, + read: function (value, prop) { + if (value == null) { + return undefined; + } else { + return value[prop]; + } + } + } + ]; + read.write = function (parent, key, value, options) { + options = options || {}; + if (can.isMapLike(parent)) { + if (!options.isArgument && parent._data && parent._data[key] && parent._data[key].isComputed) { + return parent._data[key](value); + } else { + return parent.attr(key, value); + } + } + if (parent[key] && parent[key].isComputed) { + return parent[key](value); + } + if (typeof parent === 'object') { + parent[key] = value; + } + }; + return read; +}); +/*can@2.2.6#compute/get_value_and_bind*/ +define('can/compute/get_value_and_bind', ['can/util/util'], function () { + function observe(func, context, oldInfo, onchanged) { + var info = getValueAndObserved(func, context), newObserveSet = info.observed, oldObserved = oldInfo.observed; + if (info.names !== oldInfo.names) { + bindNewSet(oldObserved, newObserveSet, onchanged); + unbindOldSet(oldObserved, onchanged); + } + can.batch.afterPreviousEvents(function () { + info.ready = true; + }); + return info; + } + var observedStack = []; + can.__isRecordingObserves = function () { + return observedStack.length; + }; + can.__observe = can.__reading = function (obj, event) { + if (observedStack.length) { + var name = obj._cid + '|' + event, top = observedStack[observedStack.length - 1]; + top.names += name; + top.observed[name] = { + obj: obj, + event: event + '' + }; + } + }; + can.__notObserve = function (fn) { + return function () { + var previousReads = can.__clearObserved(); + var res = fn.apply(this, arguments); + can.__setObserved(previousReads); + return res; + }; + }; + can.__clearObserved = can.__clearReading = function () { + if (observedStack.length) { + var ret = observedStack[observedStack.length - 1]; + observedStack[observedStack.length - 1] = { observed: {} }; + return ret; + } + }; + can.__setObserved = can.__setReading = function (o) { + if (observedStack.length) { + observedStack[observedStack.length - 1] = o; + } + }; + can.__addObserved = can.__addReading = function (o) { + if (observedStack.length) { + can.simpleExtend(observedStack[observedStack.length - 1], o); + } + }; + var getValueAndObserved = function (func, self) { + observedStack.push({ + names: '', + observed: {} + }); + var value = func.call(self); + var stackItem = observedStack.pop(); + stackItem.value = value; + return stackItem; + }; + var bindNewSet = function (oldObserved, newObserveSet, onchanged) { + for (var name in newObserveSet) { + bindOrPreventUnbinding(oldObserved, newObserveSet, name, onchanged); + } + }; + var bindOrPreventUnbinding = function (oldObserved, newObserveSet, name, onchanged) { + if (oldObserved[name]) { + delete oldObserved[name]; + } else { + var obEv = newObserveSet[name]; + obEv.obj.bind(obEv.event, onchanged); + } + }; + var unbindOldSet = function (oldObserved, onchanged) { + for (var name in oldObserved) { + var obEv = oldObserved[name]; + obEv.obj.unbind(obEv.event, onchanged); + } + }; + return observe; +}); +/*can@2.2.6#compute/proto_compute*/ +define('can/compute/proto_compute', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/compute/read', + 'can/compute/get_value_and_bind', + 'can/util/batch/batch' +], function (can, bind, read, getValueAndBind) { + var updateOnChange = function (compute, newValue, oldValue, batchNum) { + if (newValue !== oldValue) { + can.batch.trigger(compute, batchNum ? { + type: 'change', + batchNum: batchNum + } : 'change', [ + newValue, + oldValue + ]); + } + }; + var setupComputeHandlers = function (compute, func, context, singleBind) { + var readInfo, onchanged, batchNum; + singleBind = false; + return { + on: function (updater) { + var self = this; + if (!onchanged) { + onchanged = function (ev) { + if (readInfo.ready && compute.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + if (singleBind) { + newValue = func.call(context); + readInfo.value = newValue; + } else { + readInfo = getValueAndBind(func, context, readInfo, onchanged); + newValue = readInfo.value; + } + self.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }; + } + readInfo = getValueAndBind(func, context, { observed: {} }, onchanged); + if (singleBind) { + func = can.__notObserve(func); + } + compute.value = readInfo.value; + compute.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function (updater) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, onchanged); + } + } + }; + }; + var k = function () { + }; + var updater = function (newVal, oldVal, batchNum) { + this.value = newVal; + updateOnChange(this, newVal, oldVal, batchNum); + }, asyncGet = function (fn, context, lastSetValue) { + return function () { + return fn.call(context, lastSetValue.get()); + }; + }, asyncUpdater = function (context, oldUpdater) { + return function (newVal) { + if (newVal !== undefined) { + oldUpdater(newVal, context.value); + } + }; + }; + can.Compute = function (getterSetter, context, eventName, bindOnce) { + var args = []; + for (var i = 0, arglen = arguments.length; i < arglen; i++) { + args[i] = arguments[i]; + } + var contextType = typeof args[1]; + if (typeof args[0] === 'function') { + this._setupGetterSetterFn(args[0], args[1], args[2], args[3]); + } else if (args[1]) { + if (contextType === 'string') { + this._setupContextString(args[0], args[1], args[2]); + } else if (contextType === 'function') { + this._setupContextFunction(args[0], args[1], args[2]); + } else { + if (args[1] && args[1].fn) { + this._setupAsyncCompute(args[0], args[1]); + } else { + this._setupContextSettings(args[0], args[1]); + } + } + } else { + this._setupInitialValue(args[0]); + } + this._args = args; + this.isComputed = true; + can.cid(this, 'compute'); + }; + can.simpleExtend(can.Compute.prototype, { + _bindsetup: can.__notObserve(function () { + this.bound = true; + this._on(this.updater); + }), + _bindteardown: function () { + this._off(this.updater); + this.bound = false; + }, + bind: can.bindAndSetup, + unbind: can.unbindAndTeardown, + clone: function (context) { + if (context && typeof this._args[0] === 'function') { + this._args[1] = context; + } else if (context) { + this._args[2] = context; + } + return new can.Compute(this._args[0], this._args[1], this._args[2], this._args[3]); + }, + _on: k, + _off: k, + get: function () { + if (can.__isRecordingObserves() && this._canObserve !== false) { + can.__observe(this, 'change'); + if (!this.bound) { + can.Compute.temporarilyBind(this); + } + } + if (this.bound) { + return this.value; + } else { + return this._get(); + } + }, + _get: function () { + return this.value; + }, + set: function (newVal) { + var old = this.value; + var setVal = this._set(newVal, old); + if (this.hasDependencies) { + if (this._setUpdates) { + return this.value; + } + return this._get(); + } + if (setVal === undefined) { + this.value = this._get(); + } else { + this.value = setVal; + } + updateOnChange(this, this.value, old); + return this.value; + }, + _set: function (newVal) { + return this.value = newVal; + }, + updater: updater, + _computeFn: function (newVal) { + if (arguments.length) { + return this.set(newVal); + } + return this.get(); + }, + toFunction: function () { + return can.proxy(this._computeFn, this); + }, + _setupGetterSetterFn: function (getterSetter, context, eventName, bindOnce) { + this._set = can.proxy(getterSetter, context); + this._get = can.proxy(getterSetter, context); + this._canObserve = eventName === false ? false : true; + var handlers = setupComputeHandlers(this, getterSetter, context || this, bindOnce); + this._on = handlers.on; + this._off = handlers.off; + }, + _setupContextString: function (target, propertyName, eventName) { + var isObserve = can.isMapLike(target), self = this, handler = function (ev, newVal, oldVal) { + self.updater(newVal, oldVal, ev.batchNum); + }; + if (isObserve) { + this.hasDependencies = true; + this._get = function () { + return target.attr(propertyName); + }; + this._set = function (val) { + target.attr(propertyName, val); + }; + this._on = function (update) { + target.bind(eventName || propertyName, handler); + this.value = this._get(); + }; + this._off = function () { + return target.unbind(eventName || propertyName, handler); + }; + } else { + this._get = can.proxy(this._get, target); + this._set = can.proxy(this._set, target); + } + }, + _setupContextFunction: function (initialValue, setter, eventName) { + this.value = initialValue; + this._set = setter; + can.simpleExtend(this, eventName); + }, + _setupContextSettings: function (initialValue, settings) { + this.value = initialValue; + this._set = settings.set ? can.proxy(settings.set, settings) : this._set; + this._get = settings.get ? can.proxy(settings.get, settings) : this._get; + if (!settings.__selfUpdater) { + var self = this, oldUpdater = this.updater; + this.updater = function () { + oldUpdater.call(self, self._get(), self.value); + }; + } + this._on = settings.on ? settings.on : this._on; + this._off = settings.off ? settings.off : this._off; + }, + _setupAsyncCompute: function (initialValue, settings) { + this.value = initialValue; + var oldUpdater = can.proxy(this.updater, this), self = this, fn = settings.fn, data; + this.updater = oldUpdater; + var lastSetValue = new can.Compute(initialValue); + this.lastSetValue = lastSetValue; + this._setUpdates = true; + this._set = function (newVal) { + if (newVal === lastSetValue.get()) { + return this.value; + } + return lastSetValue.set(newVal); + }; + this._get = asyncGet(fn, settings.context, lastSetValue); + if (fn.length === 0) { + data = setupComputeHandlers(this, fn, settings.context); + } else if (fn.length === 1) { + data = setupComputeHandlers(this, function () { + return fn.call(settings.context, lastSetValue.get()); + }, settings); + } else { + this.updater = asyncUpdater(this, oldUpdater); + data = setupComputeHandlers(this, function () { + var res = fn.call(settings.context, lastSetValue.get(), function (newVal) { + oldUpdater(newVal, self.value); + }); + return res !== undefined ? res : this.value; + }, settings); + } + this._on = data.on; + this._off = data.off; + }, + _setupInitialValue: function (initialValue) { + this.value = initialValue; + } + }); + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.Compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.Compute.async = function (initialValue, asyncComputer, context) { + return new can.Compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.Compute.read = read; + can.Compute.set = read.write; + can.Compute.truthy = function (compute) { + return new can.Compute(function () { + var res = compute.get(); + if (typeof res === 'function') { + res = res.get(); + } + return !!res; + }); + }; + return can.Compute; +}); +/*can@2.2.6#compute/compute*/ +define('can/compute/compute', [ + 'can/util/util', + 'can/util/bind/bind', + 'can/util/batch/batch', + 'can/compute/proto_compute' +], function (can, bind) { + can.compute = function (getterSetter, context, eventName, bindOnce) { + var internalCompute = new can.Compute(getterSetter, context, eventName, bindOnce); + var compute = function (val) { + if (arguments.length) { + return internalCompute.set(val); + } + return internalCompute.get(); + }; + compute.bind = can.proxy(internalCompute.bind, internalCompute); + compute.unbind = can.proxy(internalCompute.unbind, internalCompute); + compute.isComputed = internalCompute.isComputed; + compute.clone = function (ctx) { + if (typeof getterSetter === 'function') { + context = ctx; + } + return can.compute(getterSetter, context, ctx, bindOnce); + }; + compute.computeInstance = internalCompute; + return compute; + }; + var k = function () { + }; + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + can.compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + can.compute.truthy = function (compute) { + return can.compute(function () { + var res = compute(); + if (typeof res === 'function') { + res = res(); + } + return !!res; + }); + }; + can.compute.async = function (initialValue, asyncComputer, context) { + return can.compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + can.compute.read = can.Compute.read; + can.compute.set = can.Compute.set; + return can.compute; +}); +/*can@2.2.6#observe/observe*/ +define('can/observe/observe', [ + 'can/util/util', + 'can/map/map', + 'can/list/list', + 'can/compute/compute' +], function (can) { + can.Observe = can.Map; + can.Observe.startBatch = can.batch.start; + can.Observe.stopBatch = can.batch.stop; + can.Observe.triggerBatch = can.batch.trigger; + return can; +}); +/*can@2.2.6#view/scope/compute_data*/ +define('can/view/scope/compute_data', [ + 'can/util/util', + 'can/compute/compute', + 'can/compute/get_value_and_bind' +], function (can, compute, getValueAndBind) { + var isFastPath = function (computeData) { + return computeData.reads && computeData.reads.length === 1 && computeData.root instanceof can.Map && !can.isFunction(computeData.root[computeData.reads[0]]); + }; + var getValueAndBindScopeRead = function (scopeRead, scopeReadChanged) { + return getValueAndBind(scopeRead, null, { observed: {} }, scopeReadChanged); + }; + var unbindScopeRead = function (readInfo, scopeReadChanged) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, scopeReadChanged); + } + }; + var getValueAndBindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + var target = computeData.root, prop = computeData.reads[0]; + target.bind(prop, singlePropertyReadChanged); + return { + value: computeData.initialValue, + observed: { something: true } + }; + }; + var unbindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + computeData.root.unbind(computeData.reads[0], singlePropertyReadChanged); + }; + var scopeReader = function (scope, key, options, computeData, newVal) { + if (arguments.length > 4) { + if (computeData.root.isComputed) { + computeData.root(newVal); + } else if (computeData.reads.length) { + var last = computeData.reads.length - 1; + var obj = computeData.reads.length ? can.compute.read(computeData.root, computeData.reads.slice(0, last)).value : computeData.root; + can.compute.set(obj, computeData.reads[last], newVal, options); + } + } else { + if (computeData.root) { + return can.compute.read(computeData.root, computeData.reads, options).value; + } + var data = scope.read(key, options); + computeData.scope = data.scope; + computeData.initialValue = data.value; + computeData.reads = data.reads; + computeData.root = data.rootObserve; + return data.value; + } + }; + return function (scope, key, options) { + options = options || { args: [] }; + var computeData = {}, scopeRead = function (newVal) { + if (arguments.length) { + return scopeReader(scope, key, options, computeData, newVal); + } else { + return scopeReader(scope, key, options, computeData); + } + }, batchNum, readInfo, scopeReadChanged = function (ev) { + if (readInfo.ready && compute.computeInstance.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + readInfo = getValueAndBind(scopeRead, null, readInfo, scopeReadChanged); + newValue = readInfo.value; + compute.computeInstance.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }, singlePropertyReadChanged = function (ev, newVal, oldVal) { + if (typeof newVal !== 'function') { + compute.computeInstance.updater(newVal, oldVal, ev.batchNum); + } else { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + isFastPathBound = false; + compute.computeInstance.updater(readInfo.value, oldVal, ev.batchNum); + } + }, isFastPathBound = false, compute = can.compute(undefined, { + on: function () { + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + if (isFastPath(computeData)) { + var oldReadInfo = readInfo; + readInfo = getValueAndBindSinglePropertyRead(computeData, singlePropertyReadChanged); + unbindScopeRead(oldReadInfo, scopeReadChanged); + isFastPathBound = true; + } + compute.computeInstance.value = readInfo.value; + compute.computeInstance.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function () { + if (isFastPathBound) { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + } else { + unbindScopeRead(readInfo, scopeReadChanged); + } + }, + set: scopeRead, + get: scopeRead, + __selfUpdater: true + }); + computeData.compute = compute; + return computeData; + }; +}); +/*can@2.2.6#view/scope/scope*/ +define('can/view/scope/scope', [ + 'can/util/util', + 'can/view/scope/compute_data', + 'can/construct/construct', + 'can/map/map', + 'can/list/list', + 'can/view/view', + 'can/compute/compute' +], function (can, makeComputeData) { + var escapeReg = /(\\)?\./g, escapeDotReg = /\\\./g, getNames = function (attr) { + var names = [], last = 0; + attr.replace(escapeReg, function (first, second, index) { + if (!second) { + names.push(attr.slice(last, index).replace(escapeDotReg, '.')); + last = index + first.length; + } + }); + names.push(attr.slice(last).replace(escapeDotReg, '.')); + return names; + }; + var Scope = can.Construct.extend({ read: can.compute.read }, { + init: function (context, parent) { + this._context = context; + this._parent = parent; + this.__cache = {}; + }, + attr: can.__notObserve(function (key, value) { + var options = { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }, res = this.read(key, options); + if (arguments.length === 2) { + var lastIndex = key.lastIndexOf('.'), readKey = lastIndex !== -1 ? key.substring(0, lastIndex) : '.', obj = this.read(readKey, options).value; + if (lastIndex !== -1) { + key = key.substring(lastIndex + 1, key.length); + } + can.compute.set(obj, key, value, options); + } + return res.value; + }), + add: function (context) { + if (context !== this._context) { + return new this.constructor(context, this); + } else { + return this; + } + }, + computeData: function (key, options) { + return makeComputeData(this, key, options); + }, + compute: function (key, options) { + return this.computeData(key, options).compute; + }, + read: function (attr, options) { + var stopLookup; + if (attr.substr(0, 2) === './') { + stopLookup = true; + attr = attr.substr(2); + } else if (attr.substr(0, 3) === '../') { + return this._parent.read(attr.substr(3), options); + } else if (attr === '..') { + return { value: this._parent._context }; + } else if (attr === '.' || attr === 'this') { + return { value: this._context }; + } + var names = attr.indexOf('\\.') === -1 ? attr.split('.') : getNames(attr), context, scope = this, defaultObserve, defaultReads = [], defaultPropertyDepth = -1, defaultComputeReadings, defaultScope, currentObserve, currentReads; + while (scope) { + context = scope._context; + if (context !== null && (typeof context === 'object' || typeof context === 'function')) { + var data = can.compute.read(context, names, can.simpleExtend({ + foundObservable: function (observe, nameIndex) { + currentObserve = observe; + currentReads = names.slice(nameIndex); + }, + earlyExit: function (parentValue, nameIndex) { + if (nameIndex > defaultPropertyDepth) { + defaultObserve = currentObserve; + defaultReads = currentReads; + defaultPropertyDepth = nameIndex; + defaultScope = scope; + defaultComputeReadings = can.__clearReading(); + } + }, + executeAnonymousFunctions: true + }, options)); + if (data.value !== undefined) { + return { + scope: scope, + rootObserve: currentObserve, + value: data.value, + reads: currentReads + }; + } + } + can.__clearReading(); + if (!stopLookup) { + scope = scope._parent; + } else { + scope = null; + } + } + if (defaultObserve) { + can.__setReading(defaultComputeReadings); + return { + scope: defaultScope, + rootObserve: defaultObserve, + reads: defaultReads, + value: undefined + }; + } else { + return { + names: names, + value: undefined + }; + } + } + }); + can.view.Scope = Scope; + return Scope; +}); +/*can@2.2.6#view/scanner*/ +define('can/view/scanner', [ + 'can/view/view', + 'can/view/elements', + 'can/view/callbacks/callbacks' +], function (can, elements, viewCallbacks) { + var newLine = /(\r|\n)+/g, notEndTag = /\//, clean = function (content) { + return content.split('\\').join('\\\\').split('\n').join('\\n').split('"').join('\\"').split('\t').join('\\t'); + }, getTag = function (tagName, tokens, i) { + if (tagName) { + return tagName; + } else { + while (i < tokens.length) { + if (tokens[i] === '<' && !notEndTag.test(tokens[i + 1])) { + return elements.reverseTagMap[tokens[i + 1]] || 'span'; + } + i++; + } + } + return ''; + }, bracketNum = function (content) { + return --content.split('{').length - --content.split('}').length; + }, myEval = function (script) { + eval(script); + }, attrReg = /([^\s]+)[\s]*=[\s]*$/, startTxt = 'var ___v1ew = [];', finishTxt = 'return ___v1ew.join(\'\')', put_cmd = '___v1ew.push(\n', insert_cmd = put_cmd, htmlTag = null, quote = null, beforeQuote = null, rescan = null, getAttrName = function () { + var matches = beforeQuote.match(attrReg); + return matches && matches[1]; + }, status = function () { + return quote ? '\'' + getAttrName() + '\'' : htmlTag ? 1 : 0; + }, top = function (stack) { + return stack[stack.length - 1]; + }, Scanner; + can.view.Scanner = Scanner = function (options) { + can.extend(this, { + text: {}, + tokens: [] + }, options); + this.text.options = this.text.options || ''; + this.tokenReg = []; + this.tokenSimple = { + '<': '<', + '>': '>', + '"': '"', + '\'': '\'' + }; + this.tokenComplex = []; + this.tokenMap = {}; + for (var i = 0, token; token = this.tokens[i]; i++) { + if (token[2]) { + this.tokenReg.push(token[2]); + this.tokenComplex.push({ + abbr: token[1], + re: new RegExp(token[2]), + rescan: token[3] + }); + } else { + this.tokenReg.push(token[1]); + this.tokenSimple[token[1]] = token[0]; + } + this.tokenMap[token[0]] = token[1]; + } + this.tokenReg = new RegExp('(' + this.tokenReg.slice(0).concat([ + '<', + '>', + '"', + '\'' + ]).join('|') + ')', 'g'); + }; + Scanner.prototype = { + helpers: [], + scan: function (source, name) { + var tokens = [], last = 0, simple = this.tokenSimple, complex = this.tokenComplex; + source = source.replace(newLine, '\n'); + if (this.transform) { + source = this.transform(source); + } + source.replace(this.tokenReg, function (whole, part) { + var offset = arguments[arguments.length - 2]; + if (offset > last) { + tokens.push(source.substring(last, offset)); + } + if (simple[whole]) { + tokens.push(whole); + } else { + for (var i = 0, token; token = complex[i]; i++) { + if (token.re.test(whole)) { + tokens.push(token.abbr); + if (token.rescan) { + tokens.push(token.rescan(part)); + } + break; + } + } + } + last = offset + part.length; + }); + if (last < source.length) { + tokens.push(source.substr(last)); + } + var content = '', buff = [startTxt + (this.text.start || '')], put = function (content, bonus) { + buff.push(put_cmd, '"', clean(content), '"' + (bonus || '') + ');'); + }, endStack = [], lastToken, startTag = null, magicInTag = false, specialStates = { + attributeHookups: [], + tagHookups: [], + lastTagHookup: '' + }, popTagHookup = function () { + specialStates.lastTagHookup = specialStates.tagHookups.pop() + specialStates.tagHookups.length; + }, tagName = '', tagNames = [], popTagName = false, bracketCount, specialAttribute = false, i = 0, token, tmap = this.tokenMap, attrName; + htmlTag = quote = beforeQuote = null; + for (; (token = tokens[i++]) !== undefined;) { + if (startTag === null) { + switch (token) { + case tmap.left: + case tmap.escapeLeft: + case tmap.returnLeft: + magicInTag = htmlTag && 1; + case tmap.commentLeft: + startTag = token; + if (content.length) { + put(content); + } + content = ''; + break; + case tmap.escapeFull: + magicInTag = htmlTag && 1; + rescan = 1; + startTag = tmap.escapeLeft; + if (content.length) { + put(content); + } + rescan = tokens[i++]; + content = rescan.content || rescan; + if (rescan.before) { + put(rescan.before); + } + tokens.splice(i, 0, tmap.right); + break; + case tmap.commentFull: + break; + case tmap.templateLeft: + content += tmap.left; + break; + case '<': + if (tokens[i].indexOf('!--') !== 0) { + htmlTag = 1; + magicInTag = 0; + } + content += token; + break; + case '>': + htmlTag = 0; + var emptyElement = content.substr(content.length - 1) === '/' || content.substr(content.length - 2) === '--', attrs = ''; + if (specialStates.attributeHookups.length) { + attrs = 'attrs: [\'' + specialStates.attributeHookups.join('\',\'') + '\'], '; + specialStates.attributeHookups = []; + } + if (tagName + specialStates.tagHookups.length !== specialStates.lastTagHookup && tagName === top(specialStates.tagHookups)) { + if (emptyElement) { + content = content.substr(0, content.length - 1); + } + buff.push(put_cmd, '"', clean(content), '"', ',can.view.pending({tagName:\'' + tagName + '\',' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options); + if (emptyElement) { + buff.push('}));'); + content = '/>'; + popTagHookup(); + } else if (tokens[i] === '<' && tokens[i + 1] === '/' + tagName) { + buff.push('}));'); + content = token; + popTagHookup(); + } else { + buff.push(',subtemplate: function(' + this.text.argNames + '){\n' + startTxt + (this.text.start || '')); + content = ''; + } + } else if (magicInTag || !popTagName && elements.tagToContentPropMap[tagNames[tagNames.length - 1]] || attrs) { + var pendingPart = ',can.view.pending({' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options + '}),"'; + if (emptyElement) { + put(content.substr(0, content.length - 1), pendingPart + '/>"'); + } else { + put(content, pendingPart + '>"'); + } + content = ''; + magicInTag = 0; + } else { + content += token; + } + if (emptyElement || popTagName) { + tagNames.pop(); + tagName = tagNames[tagNames.length - 1]; + popTagName = false; + } + specialStates.attributeHookups = []; + break; + case '\'': + case '"': + if (htmlTag) { + if (quote && quote === token) { + quote = null; + var attr = getAttrName(); + if (viewCallbacks.attr(attr)) { + specialStates.attributeHookups.push(attr); + } + if (specialAttribute) { + content += token; + put(content); + buff.push(finishTxt, '}));\n'); + content = ''; + specialAttribute = false; + break; + } + } else if (quote === null) { + quote = token; + beforeQuote = lastToken; + attrName = getAttrName(); + if (tagName === 'img' && attrName === 'src' || attrName === 'style') { + put(content.replace(attrReg, '')); + content = ''; + specialAttribute = true; + buff.push(insert_cmd, 'can.view.txt(2,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt); + put(attrName + '=' + token); + break; + } + } + } + default: + if (lastToken === '<') { + tagName = token.substr(0, 3) === '!--' ? '!--' : token.split(/\s/)[0]; + var isClosingTag = false, cleanedTagName; + if (tagName.indexOf('/') === 0) { + isClosingTag = true; + cleanedTagName = tagName.substr(1); + } + if (isClosingTag) { + if (top(tagNames) === cleanedTagName) { + tagName = cleanedTagName; + popTagName = true; + } + if (top(specialStates.tagHookups) === cleanedTagName) { + put(content.substr(0, content.length - 1)); + buff.push(finishTxt + '}}) );'); + content = '><'; + popTagHookup(); + } + } else { + if (tagName.lastIndexOf('/') === tagName.length - 1) { + tagName = tagName.substr(0, tagName.length - 1); + } + if (tagName !== '!--' && viewCallbacks.tag(tagName)) { + if (tagName === 'content' && elements.tagMap[top(tagNames)]) { + token = token.replace('content', elements.tagMap[top(tagNames)]); + } + specialStates.tagHookups.push(tagName); + } + tagNames.push(tagName); + } + } + content += token; + break; + } + } else { + switch (token) { + case tmap.right: + case tmap.returnRight: + switch (startTag) { + case tmap.left: + bracketCount = bracketNum(content); + if (bracketCount === 1) { + buff.push(insert_cmd, 'can.view.txt(0,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt, content); + endStack.push({ + before: '', + after: finishTxt + '}));\n' + }); + } else { + last = endStack.length && bracketCount === -1 ? endStack.pop() : { after: ';' }; + if (last.before) { + buff.push(last.before); + } + buff.push(content, ';', last.after); + } + break; + case tmap.escapeLeft: + case tmap.returnLeft: + bracketCount = bracketNum(content); + if (bracketCount) { + endStack.push({ + before: finishTxt, + after: '}));\n' + }); + } + var escaped = startTag === tmap.escapeLeft ? 1 : 0, commands = { + insert: insert_cmd, + tagName: getTag(tagName, tokens, i), + status: status(), + specialAttribute: specialAttribute + }; + for (var ii = 0; ii < this.helpers.length; ii++) { + var helper = this.helpers[ii]; + if (helper.name.test(content)) { + content = helper.fn(content, commands); + if (helper.name.source === /^>[\s]*\w*/.source) { + escaped = 0; + } + break; + } + } + if (typeof content === 'object') { + if (content.startTxt && content.end && specialAttribute) { + buff.push(insert_cmd, 'can.view.toStr( ', content.content, '() ) );'); + } else { + if (content.startTxt) { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || (content.escaped != null ? content.escaped : escaped)) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\n'); + } else if (content.startOnlyTxt) { + buff.push(insert_cmd, 'can.view.onlytxt(this,\n'); + } + buff.push(content.content); + if (content.end) { + buff.push('));'); + } + } + } else if (specialAttribute) { + buff.push(insert_cmd, content, ');'); + } else { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || escaped) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\nfunction(){ ' + (this.text.escape || '') + 'return ', content, bracketCount ? startTxt : '}));\n'); + } + if (rescan && rescan.after && rescan.after.length) { + put(rescan.after.length); + rescan = null; + } + break; + } + startTag = null; + content = ''; + break; + case tmap.templateLeft: + content += tmap.left; + break; + default: + content += token; + break; + } + } + lastToken = token; + } + if (content.length) { + put(content); + } + buff.push(';'); + var template = buff.join(''), out = { out: (this.text.outStart || '') + template + ' ' + finishTxt + (this.text.outEnd || '') }; + myEval.call(out, 'this.fn = (function(' + this.text.argNames + '){' + out.out + '});\r\n//# sourceURL=' + name + '.js'); + return out; + } + }; + can.view.pending = function (viewData) { + var hooks = can.view.getHooks(); + return can.view.hook(function (el) { + can.each(hooks, function (fn) { + fn(el); + }); + viewData.templateType = 'legacy'; + if (viewData.tagName) { + viewCallbacks.tagHandler(el, viewData.tagName, viewData); + } + can.each(viewData && viewData.attrs || [], function (attributeName) { + viewData.attributeName = attributeName; + var callback = viewCallbacks.attr(attributeName); + if (callback) { + callback(el, viewData); + } + }); + }); + }; + can.view.tag('content', function (el, tagData) { + return tagData.scope; + }); + can.view.Scanner = Scanner; + return Scanner; +}); +/*can@2.2.6#view/node_lists/node_lists*/ +define('can/view/node_lists/node_lists', [ + 'can/util/util', + 'can/view/elements' +], function (can) { + var canExpando = true; + try { + document.createTextNode('')._ = 0; + } catch (ex) { + canExpando = false; + } + var nodeMap = {}, textNodeMap = {}, expando = 'ejs_' + Math.random(), _id = 0, id = function (node, localMap) { + var _textNodeMap = localMap || textNodeMap; + var id = readId(node, _textNodeMap); + if (id) { + return id; + } else { + if (canExpando || node.nodeType !== 3) { + ++_id; + return node[expando] = (node.nodeName ? 'element_' : 'obj_') + _id; + } else { + ++_id; + _textNodeMap['text_' + _id] = node; + return 'text_' + _id; + } + } + }, readId = function (node, textNodeMap) { + if (canExpando || node.nodeType !== 3) { + return node[expando]; + } else { + for (var textNodeID in textNodeMap) { + if (textNodeMap[textNodeID] === node) { + return textNodeID; + } + } + } + }, splice = [].splice, push = [].push, itemsInChildListTree = function (list) { + var count = 0; + for (var i = 0, len = list.length; i < len; i++) { + var item = list[i]; + if (item.nodeType) { + count++; + } else { + count += itemsInChildListTree(item); + } + } + return count; + }, replacementMap = function (replacements, idMap) { + var map = {}; + for (var i = 0, len = replacements.length; i < len; i++) { + var node = nodeLists.first(replacements[i]); + map[id(node, idMap)] = replacements[i]; + } + return map; + }; + var nodeLists = { + id: id, + update: function (nodeList, newNodes) { + var oldNodes = nodeLists.unregisterChildren(nodeList); + newNodes = can.makeArray(newNodes); + var oldListLength = nodeList.length; + splice.apply(nodeList, [ + 0, + oldListLength + ].concat(newNodes)); + if (nodeList.replacements) { + nodeLists.nestReplacements(nodeList); + } else { + nodeLists.nestList(nodeList); + } + return oldNodes; + }, + nestReplacements: function (list) { + var index = 0, idMap = {}, rMap = replacementMap(list.replacements, idMap), rCount = list.replacements.length; + while (index < list.length && rCount) { + var node = list[index], replacement = rMap[readId(node, idMap)]; + if (replacement) { + list.splice(index, itemsInChildListTree(replacement), replacement); + rCount--; + } + index++; + } + list.replacements = []; + }, + nestList: function (list) { + var index = 0; + while (index < list.length) { + var node = list[index], childNodeList = nodeMap[id(node)]; + if (childNodeList) { + if (childNodeList !== list) { + list.splice(index, itemsInChildListTree(childNodeList), childNodeList); + } + } else { + nodeMap[id(node)] = list; + } + index++; + } + }, + last: function (nodeList) { + var last = nodeList[nodeList.length - 1]; + if (last.nodeType) { + return last; + } else { + return nodeLists.last(last); + } + }, + first: function (nodeList) { + var first = nodeList[0]; + if (first.nodeType) { + return first; + } else { + return nodeLists.first(first); + } + }, + flatten: function (nodeList) { + var items = []; + for (var i = 0; i < nodeList.length; i++) { + var item = nodeList[i]; + if (item.nodeType) { + items.push(item); + } else { + items.push.apply(items, nodeLists.flatten(item)); + } + } + return items; + }, + register: function (nodeList, unregistered, parent) { + nodeList.unregistered = unregistered; + nodeList.parentList = parent; + if (parent === true) { + nodeList.replacements = []; + } else if (parent) { + parent.replacements.push(nodeList); + nodeList.replacements = []; + } else { + nodeLists.nestList(nodeList); + } + return nodeList; + }, + unregisterChildren: function (nodeList) { + var nodes = []; + can.each(nodeList, function (node) { + if (node.nodeType) { + if (!nodeList.replacements) { + delete nodeMap[id(node)]; + } + nodes.push(node); + } else { + push.apply(nodes, nodeLists.unregister(node)); + } + }); + return nodes; + }, + unregister: function (nodeList) { + var nodes = nodeLists.unregisterChildren(nodeList); + if (nodeList.unregistered) { + var unregisteredCallback = nodeList.unregistered; + delete nodeList.unregistered; + delete nodeList.replacements; + unregisteredCallback(); + } + return nodes; + }, + nodeMap: nodeMap + }; + can.view.nodeLists = nodeLists; + return nodeLists; +}); +/*can@2.2.6#view/parser/parser*/ +define('can/view/parser/parser', ['can/view/view'], function (can) { + function makeMap(str) { + var obj = {}, items = str.split(','); + for (var i = 0; i < items.length; i++) { + obj[items[i]] = true; + } + return obj; + } + function handleIntermediate(intermediate, handler) { + for (var i = 0, len = intermediate.length; i < len; i++) { + var item = intermediate[i]; + handler[item.tokenType].apply(handler, item.args); + } + return intermediate; + } + var alphaNumericHU = '-:A-Za-z0-9_', attributeNames = '[a-zA-Z_:][' + alphaNumericHU + ':.]*', spaceEQspace = '\\s*=\\s*', dblQuote2dblQuote = '"((?:\\\\.|[^"])*)"', quote2quote = '\'((?:\\\\.|[^\'])*)\'', attributeEqAndValue = '(?:' + spaceEQspace + '(?:' + '(?:"[^"]*")|(?:\'[^\']*\')|[^>\\s]+))?', matchStash = '\\{\\{[^\\}]*\\}\\}\\}?', stash = '\\{\\{([^\\}]*)\\}\\}\\}?', startTag = new RegExp('^<([' + alphaNumericHU + ']+)' + '(' + '(?:\\s*' + '(?:(?:' + '(?:' + attributeNames + ')?' + attributeEqAndValue + ')|' + '(?:' + matchStash + ')+)' + ')*' + ')\\s*(\\/?)>'), endTag = new RegExp('^<\\/([' + alphaNumericHU + ']+)[^>]*>'), attr = new RegExp('(?:' + '(?:(' + attributeNames + ')|' + stash + ')' + '(?:' + spaceEQspace + '(?:' + '(?:' + dblQuote2dblQuote + ')|(?:' + quote2quote + ')|([^>\\s]+)' + ')' + ')?)', 'g'), mustache = new RegExp(stash, 'g'), txtBreak = /<|\{\{/; + var empty = makeMap('area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed'); + var block = makeMap('a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video'); + var inline = makeMap('abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var'); + var closeSelf = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr'); + var fillAttrs = makeMap('checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected'); + var special = makeMap('script,style'); + var tokenTypes = 'start,end,close,attrStart,attrEnd,attrValue,chars,comment,special,done'.split(','); + var fn = function () { + }; + var HTMLParser = function (html, handler, returnIntermediate) { + if (typeof html === 'object') { + return handleIntermediate(html, handler); + } + var intermediate = []; + handler = handler || {}; + if (returnIntermediate) { + can.each(tokenTypes, function (name) { + var callback = handler[name] || fn; + handler[name] = function () { + if (callback.apply(this, arguments) !== false) { + intermediate.push({ + tokenType: name, + args: can.makeArray(arguments) + }); + } + }; + }); + } + function parseStartTag(tag, tagName, rest, unary) { + tagName = tagName.toLowerCase(); + if (block[tagName]) { + while (stack.last() && inline[stack.last()]) { + parseEndTag('', stack.last()); + } + } + if (closeSelf[tagName] && stack.last() === tagName) { + parseEndTag('', tagName); + } + unary = empty[tagName] || !!unary; + handler.start(tagName, unary); + if (!unary) { + stack.push(tagName); + } + HTMLParser.parseAttrs(rest, handler); + handler.end(tagName, unary); + } + function parseEndTag(tag, tagName) { + var pos; + if (!tagName) { + pos = 0; + } else { + for (pos = stack.length - 1; pos >= 0; pos--) { + if (stack[pos] === tagName) { + break; + } + } + } + if (pos >= 0) { + for (var i = stack.length - 1; i >= pos; i--) { + if (handler.close) { + handler.close(stack[i]); + } + } + stack.length = pos; + } + } + function parseMustache(mustache, inside) { + if (handler.special) { + handler.special(inside); + } + } + var index, chars, match, stack = [], last = html; + stack.last = function () { + return this[this.length - 1]; + }; + while (html) { + chars = true; + if (!stack.last() || !special[stack.last()]) { + if (html.indexOf(''); + if (index >= 0) { + if (handler.comment) { + handler.comment(html.substring(4, index)); + } + html = html.substring(index + 3); + chars = false; + } + } else if (html.indexOf(']*>'), function (all, text) { + text = text.replace(/|/g, '$1$2'); + if (handler.chars) { + handler.chars(text); + } + return ''; + }); + parseEndTag('', stack.last()); + } + if (html === last) { + throw 'Parse Error: ' + html; + } + last = html; + } + parseEndTag(); + handler.done(); + return intermediate; + }; + HTMLParser.parseAttrs = function (rest, handler) { + (rest != null ? rest : '').replace(attr, function (text, name, special, dblQuote, singleQuote, val) { + if (special) { + handler.special(special); + } + if (name || dblQuote || singleQuote || val) { + var value = arguments[3] ? arguments[3] : arguments[4] ? arguments[4] : arguments[5] ? arguments[5] : fillAttrs[name.toLowerCase()] ? name : ''; + handler.attrStart(name || ''); + var last = mustache.lastIndex = 0, res = mustache.exec(value), chars; + while (res) { + chars = value.substring(last, mustache.lastIndex - res[0].length); + if (chars.length) { + handler.attrValue(chars); + } + handler.special(res[1]); + last = mustache.lastIndex; + res = mustache.exec(value); + } + chars = value.substr(last, value.length); + if (chars) { + handler.attrValue(chars); + } + handler.attrEnd(name || ''); + } + }); + }; + can.view.parser = HTMLParser; + return HTMLParser; +}); +/*can@2.2.6#view/live/live*/ +define('can/view/live/live', [ + 'can/util/util', + 'can/view/elements', + 'can/view/view', + 'can/view/node_lists/node_lists', + 'can/view/parser/parser' +], function (can, elements, view, nodeLists, parser) { + elements = elements || can.view.elements; + nodeLists = nodeLists || can.view.NodeLists; + parser = parser || can.view.parser; + var setup = function (el, bind, unbind) { + var tornDown = false, teardown = function () { + if (!tornDown) { + tornDown = true; + unbind(data); + can.unbind.call(el, 'removed', teardown); + } + return true; + }, data = { + teardownCheck: function (parent) { + return parent ? false : teardown(); + } + }; + can.bind.call(el, 'removed', teardown); + bind(data); + return data; + }, listen = function (el, compute, change) { + return setup(el, function () { + compute.bind('change', change); + }, function (data) { + compute.unbind('change', change); + if (data.nodeList) { + nodeLists.unregister(data.nodeList); + } + }); + }, getAttributeParts = function (newVal) { + var attrs = {}, attr; + parser.parseAttrs(newVal, { + attrStart: function (name) { + attrs[name] = ''; + attr = name; + }, + attrValue: function (value) { + attrs[attr] += value; + }, + attrEnd: function () { + } + }); + return attrs; + }, splice = [].splice, isNode = function (obj) { + return obj && obj.nodeType; + }, addTextNodeIfNoChildren = function (frag) { + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + }; + var live = { + list: function (el, compute, render, context, parentNode, nodeList) { + var masterNodeList = nodeList || [el], indexMap = [], afterPreviousEvents = false, isTornDown = false, add = function (ev, items, index) { + if (!afterPreviousEvents) { + return; + } + var frag = document.createDocumentFragment(), newNodeLists = [], newIndicies = []; + can.each(items, function (item, key) { + var itemNodeList = []; + if (nodeList) { + nodeLists.register(itemNodeList, null, true); + } + var itemIndex = can.compute(key + index), itemHTML = render.call(context, item, itemIndex, itemNodeList), gotText = typeof itemHTML === 'string', itemFrag = can.frag(itemHTML); + itemFrag = gotText ? can.view.hookup(itemFrag) : itemFrag; + var childNodes = can.makeArray(itemFrag.childNodes); + if (nodeList) { + nodeLists.update(itemNodeList, childNodes); + newNodeLists.push(itemNodeList); + } else { + newNodeLists.push(nodeLists.register(childNodes)); + } + frag.appendChild(itemFrag); + newIndicies.push(itemIndex); + }); + var masterListIndex = index + 1; + if (!masterNodeList[masterListIndex]) { + elements.after(masterListIndex === 1 ? [text] : [nodeLists.last(masterNodeList[masterListIndex - 1])], frag); + } else { + var el = nodeLists.first(masterNodeList[masterListIndex]); + can.insertBefore(el.parentNode, frag, el); + } + splice.apply(masterNodeList, [ + masterListIndex, + 0 + ].concat(newNodeLists)); + splice.apply(indexMap, [ + index, + 0 + ].concat(newIndicies)); + for (var i = index + newIndicies.length, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + }, remove = function (ev, items, index, duringTeardown, fullTeardown) { + if (!afterPreviousEvents) { + return; + } + if (!duringTeardown && data.teardownCheck(text.parentNode)) { + return; + } + if (index < 0) { + index = indexMap.length + index; + } + var removedMappings = masterNodeList.splice(index + 1, items.length), itemsToRemove = []; + can.each(removedMappings, function (nodeList) { + var nodesToRemove = nodeLists.unregister(nodeList); + [].push.apply(itemsToRemove, nodesToRemove); + }); + indexMap.splice(index, items.length); + for (var i = index, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + if (!fullTeardown) { + can.remove(can.$(itemsToRemove)); + } else { + nodeLists.unregister(masterNodeList); + } + }, move = function (ev, item, newIndex, currentIndex) { + if (!afterPreviousEvents) { + return; + } + newIndex = newIndex + 1; + currentIndex = currentIndex + 1; + var referenceNodeList = masterNodeList[newIndex]; + var movedElements = can.frag(nodeLists.flatten(masterNodeList[currentIndex])); + var referenceElement; + if (currentIndex < newIndex) { + referenceElement = nodeLists.last(referenceNodeList).nextSibling; + } else { + referenceElement = nodeLists.first(referenceNodeList); + } + var parentNode = masterNodeList[0].parentNode; + parentNode.insertBefore(movedElements, referenceElement); + var temp = masterNodeList[currentIndex]; + [].splice.apply(masterNodeList, [ + currentIndex, + 1 + ]); + [].splice.apply(masterNodeList, [ + newIndex, + 0, + temp + ]); + }, text = document.createTextNode(''), list, teardownList = function (fullTeardown) { + if (list && list.unbind) { + list.unbind('add', add).unbind('remove', remove).unbind('move', move); + } + remove({}, { length: masterNodeList.length - 1 }, 0, true, fullTeardown); + }, updateList = function (ev, newList, oldList) { + if (isTornDown) { + return; + } + teardownList(); + list = newList || []; + if (list.bind) { + list.bind('add', add).bind('remove', remove).bind('move', move); + } + afterPreviousEvents = true; + add({}, list, 0); + afterPreviousEvents = false; + can.batch.afterPreviousEvents(function () { + afterPreviousEvents = true; + }); + }; + parentNode = elements.getParentNode(el, parentNode); + var data = setup(parentNode, function () { + if (can.isFunction(compute)) { + compute.bind('change', updateList); + } + }, function () { + if (can.isFunction(compute)) { + compute.unbind('change', updateList); + } + teardownList(true); + }); + if (!nodeList) { + live.replace(masterNodeList, text, data.teardownCheck); + } else { + elements.replace(masterNodeList, text); + nodeLists.update(masterNodeList, [text]); + nodeList.unregistered = function () { + data.teardownCheck(); + isTornDown = true; + }; + } + updateList({}, can.isFunction(compute) ? compute() : compute); + }, + html: function (el, compute, parentNode, nodeList) { + var data; + parentNode = elements.getParentNode(el, parentNode); + data = listen(parentNode, compute, function (ev, newVal, oldVal) { + var attached = nodeLists.first(nodes).parentNode; + if (attached) { + makeAndPut(newVal); + } + data.teardownCheck(nodeLists.first(nodes).parentNode); + }); + var nodes = nodeList || [el], makeAndPut = function (val) { + var isFunction = typeof val === 'function', aNode = isNode(val), frag = can.frag(isFunction ? '' : val), oldNodes = can.makeArray(nodes); + addTextNodeIfNoChildren(frag); + if (!aNode && !isFunction) { + frag = can.view.hookup(frag, parentNode); + } + oldNodes = nodeLists.update(nodes, frag.childNodes); + if (isFunction) { + val(frag.childNodes[0]); + } + elements.replace(oldNodes, frag); + }; + data.nodeList = nodes; + if (!nodeList) { + nodeLists.register(nodes, data.teardownCheck); + } else { + nodeList.unregistered = data.teardownCheck; + } + makeAndPut(compute()); + }, + replace: function (nodes, val, teardown) { + var oldNodes = nodes.slice(0), frag = can.frag(val); + nodeLists.register(nodes, teardown); + if (typeof val === 'string') { + frag = can.view.hookup(frag, nodes[0].parentNode); + } + nodeLists.update(nodes, frag.childNodes); + elements.replace(oldNodes, frag); + return nodes; + }, + text: function (el, compute, parentNode, nodeList) { + var parent = elements.getParentNode(el, parentNode); + var data = listen(parent, compute, function (ev, newVal, oldVal) { + if (typeof node.nodeValue !== 'unknown') { + node.nodeValue = can.view.toStr(newVal); + } + data.teardownCheck(node.parentNode); + }); + var node = document.createTextNode(can.view.toStr(compute())); + if (nodeList) { + nodeList.unregistered = data.teardownCheck; + data.nodeList = nodeList; + nodeLists.update(nodeList, [node]); + elements.replace([el], node); + } else { + data.nodeList = live.replace([el], node, data.teardownCheck); + } + }, + setAttributes: function (el, newVal) { + var attrs = getAttributeParts(newVal); + for (var name in attrs) { + can.attr.set(el, name, attrs[name]); + } + }, + attributes: function (el, compute, currentValue) { + var oldAttrs = {}; + var setAttrs = function (newVal) { + var newAttrs = getAttributeParts(newVal), name; + for (name in newAttrs) { + var newValue = newAttrs[name], oldValue = oldAttrs[name]; + if (newValue !== oldValue) { + can.attr.set(el, name, newValue); + } + delete oldAttrs[name]; + } + for (name in oldAttrs) { + elements.removeAttr(el, name); + } + oldAttrs = newAttrs; + }; + listen(el, compute, function (ev, newVal) { + setAttrs(newVal); + }); + if (arguments.length >= 3) { + oldAttrs = getAttributeParts(currentValue); + } else { + setAttrs(compute()); + } + }, + attributePlaceholder: '__!!__', + attributeReplace: /__!!__/g, + attribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, hook.render()); + }); + var wrapped = can.$(el), hooks; + hooks = can.data(wrapped, 'hooks'); + if (!hooks) { + can.data(wrapped, 'hooks', hooks = {}); + } + var attr = elements.getAttr(el, attributeName), parts = attr.split(live.attributePlaceholder), goodParts = [], hook; + goodParts.push(parts.shift(), parts.join(live.attributePlaceholder)); + if (hooks[attributeName]) { + hooks[attributeName].computes.push(compute); + } else { + hooks[attributeName] = { + render: function () { + var i = 0, newAttr = attr ? attr.replace(live.attributeReplace, function () { + return elements.contentText(hook.computes[i++]()); + }) : elements.contentText(hook.computes[i++]()); + return newAttr; + }, + computes: [compute], + batchNum: undefined + }; + } + hook = hooks[attributeName]; + goodParts.splice(1, 0, compute()); + elements.setAttr(el, attributeName, goodParts.join('')); + }, + specialAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, getValue(newVal)); + }); + elements.setAttr(el, attributeName, getValue(compute())); + }, + simpleAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, newVal); + }); + elements.setAttr(el, attributeName, compute()); + } + }; + live.attr = live.simpleAttribute; + live.attrs = live.attributes; + var newLine = /(\r|\n)+/g; + var getValue = function (val) { + var regexp = /^["'].*["']$/; + val = val.replace(elements.attrReg, '').replace(newLine, ''); + return regexp.test(val) ? val.substr(1, val.length - 2) : val; + }; + can.view.live = live; + return live; +}); +/*can@2.2.6#view/render*/ +define('can/view/render', [ + 'can/view/view', + 'can/view/elements', + 'can/view/live/live', + 'can/util/string/string' +], function (can, elements, live) { + var pendingHookups = [], tagChildren = function (tagName) { + var newTag = elements.tagMap[tagName] || 'span'; + if (newTag === 'span') { + return '@@!!@@'; + } + return '<' + newTag + '>' + tagChildren(newTag) + ''; + }, contentText = function (input, tag) { + if (typeof input === 'string') { + return input; + } + if (!input && input !== 0) { + return ''; + } + var hook = input.hookup && function (el, id) { + input.hookup.call(input, el, id); + } || typeof input === 'function' && input; + if (hook) { + if (tag) { + return '<' + tag + ' ' + can.view.hook(hook) + '>'; + } else { + pendingHookups.push(hook); + } + return ''; + } + return '' + input; + }, contentEscape = function (txt, tag) { + return typeof txt === 'string' || typeof txt === 'number' ? can.esc(txt) : contentText(txt, tag); + }, withinTemplatedSectionWithinAnElement = false, emptyHandler = function () { + }; + var lastHookups; + can.extend(can.view, { + live: live, + setupLists: function () { + var old = can.view.lists, data; + can.view.lists = function (list, renderer) { + data = { + list: list, + renderer: renderer + }; + return Math.random(); + }; + return function () { + can.view.lists = old; + return data; + }; + }, + getHooks: function () { + var hooks = pendingHookups.slice(0); + lastHookups = hooks; + pendingHookups = []; + return hooks; + }, + onlytxt: function (self, func) { + return contentEscape(func.call(self)); + }, + txt: function (escape, tagName, status, self, func) { + var tag = elements.tagMap[tagName] || 'span', setupLiveBinding = false, value, listData, compute, unbind = emptyHandler, attributeName; + if (withinTemplatedSectionWithinAnElement) { + value = func.call(self); + } else { + if (typeof status === 'string' || status === 1) { + withinTemplatedSectionWithinAnElement = true; + } + var listTeardown = can.view.setupLists(); + unbind = function () { + compute.unbind('change', emptyHandler); + }; + compute = can.compute(func, self, false); + compute.bind('change', emptyHandler); + listData = listTeardown(); + value = compute(); + withinTemplatedSectionWithinAnElement = false; + setupLiveBinding = compute.computeInstance.hasDependencies; + } + if (listData) { + unbind(); + return '<' + tag + can.view.hook(function (el, parentNode) { + live.list(el, listData.list, listData.renderer, self, parentNode); + }) + '>'; + } + if (!setupLiveBinding || typeof value === 'function') { + unbind(); + return (withinTemplatedSectionWithinAnElement || escape === 2 || !escape ? contentText : contentEscape)(value, status === 0 && tag); + } + var contentProp = elements.tagToContentPropMap[tagName]; + if (status === 0 && !contentProp) { + return '<' + tag + can.view.hook(escape && typeof value !== 'object' ? function (el, parentNode) { + live.text(el, compute, parentNode); + unbind(); + } : function (el, parentNode) { + live.html(el, compute, parentNode); + unbind(); + }) + '>' + tagChildren(tag) + ''; + } else if (status === 1) { + pendingHookups.push(function (el) { + live.attributes(el, compute, compute()); + unbind(); + }); + return compute(); + } else if (escape === 2) { + attributeName = status; + pendingHookups.push(function (el) { + live.specialAttribute(el, attributeName, compute); + unbind(); + }); + return compute(); + } else { + attributeName = status === 0 ? contentProp : status; + (status === 0 ? lastHookups : pendingHookups).push(function (el) { + live.attribute(el, attributeName, compute); + unbind(); + }); + return live.attributePlaceholder; + } + } + }); + return can; +}); +/*can@2.2.6#view/stache/utils*/ +define('can/view/stache/utils', ['can/util/util'], function () { + return { + isArrayLike: function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, + isObserveLike: function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, + emptyHandler: function () { + }, + jsonParse: function (str) { + if (str[0] === '\'') { + return str.substr(1, str.length - 2); + } else if (str === 'undefined') { + return undefined; + } else if (can.global.JSON) { + return JSON.parse(str); + } else { + return eval('(' + str + ')'); + } + }, + mixins: { + last: function () { + return this.stack[this.stack.length - 1]; + }, + add: function (chars) { + this.last().add(chars); + }, + subSectionDepth: function () { + return this.stack.length - 1; + } + } + }; +}); +/*can@2.2.6#view/stache/mustache_helpers*/ +define('can/view/stache/mustache_helpers', [ + 'can/util/util', + 'can/view/stache/utils', + 'can/view/live/live' +], function (can, utils, live) { + live = live || can.view.live; + var resolve = function (value) { + if (utils.isObserveLike(value) && utils.isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + var helpers = { + 'each': function (items, options) { + var resolved = resolve(items), result = [], keys, key, i; + if (resolved instanceof can.List) { + return function (el) { + var nodeList = [el]; + nodeList.expression = 'live.list'; + can.view.nodeLists.register(nodeList, null, options.nodeList); + can.view.nodeLists.update(options.nodeList, [el]); + var cb = function (item, index, parentNodeList) { + return options.fn(options.scope.add({ '@index': index }).add(item), options.options, parentNodeList); + }; + live.list(el, items, cb, options.context, el.parentNode, nodeList); + }; + } + var expr = resolved; + if (!!expr && utils.isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + } else if (utils.isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } + return result; + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + }, + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!resolve(expr); + } + if (value) { + return options.fn(options.scope || this); + } else { + return options.inverse(options.scope || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return helpers.is.apply(this, arguments); + }, + 'unless': function (expr, options) { + return helpers['if'].apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'with': function (expr, options) { + var ctx = expr; + expr = resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + 'data': function (attr) { + var data = arguments.length === 2 ? this : arguments[1]; + return function (el) { + can.data(can.$(el), attr, data || this.context); + }; + } + }; + return { + registerHelper: function (name, callback) { + helpers[name] = callback; + }, + getHelper: function (name, options) { + var helper = options.attr('helpers.' + name); + if (!helper) { + helper = helpers[name]; + } + if (helper) { + return { fn: helper }; + } + } + }; +}); +/*can@2.2.6#view/stache/mustache_core*/ +define('can/view/stache/mustache_core', [ + 'can/util/util', + 'can/view/stache/utils', + 'can/view/stache/mustache_helpers', + 'can/view/live/live', + 'can/view/elements', + 'can/view/scope/scope', + 'can/view/node_lists/node_lists' +], function (can, utils, mustacheHelpers, live, elements, Scope, nodeLists) { + live = live || can.view.live; + elements = elements || can.view.elements; + Scope = Scope || can.view.Scope; + nodeLists = nodeLists || can.view.nodeLists; + var argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(?:(.+?)=(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(.+))))$/, mustacheLineBreakRegExp = /(?:(?:^|(\r?)\n)(\s*)(\{\{([^\}]*)\}\}\}?)([^\S\n\r]*)($|\r?\n))|(\{\{([^\}]*)\}\}\}?)/g, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, getItemsFragContent = function (items, isObserveList, helperOptions, options) { + var frag = document.createDocumentFragment(); + for (var i = 0, len = items.length; i < len; i++) { + append(frag, helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options)); + } + return frag; + }, append = function (frag, content) { + if (content) { + frag.appendChild(typeof content === 'string' ? document.createTextNode(content) : content); + } + }, getItemsStringContent = function (items, isObserveList, helperOptions, options) { + var txt = ''; + for (var i = 0, len = items.length; i < len; i++) { + txt += helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options); + } + return txt; + }, getKeyComputeData = function (key, scope, isArgument) { + var data = scope.computeData(key, { + isArgument: isArgument, + args: [ + scope.attr('.'), + scope + ] + }); + can.compute.temporarilyBind(data.compute); + return data; + }, getKeyArgValue = function (key, scope) { + var data = getKeyComputeData(key, scope, true); + if (!data.compute.computeInstance.hasDependencies) { + return data.initialValue; + } else { + return data.compute; + } + }, convertToScopes = function (helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer) { + if (truthyRenderer) { + helperOptions.fn = makeRendererConvertScopes(truthyRenderer, scope, options, nodeList); + } + if (falseyRenderer) { + helperOptions.inverse = makeRendererConvertScopes(falseyRenderer, scope, options, nodeList); + } + }, makeRendererConvertScopes = function (renderer, parentScope, parentOptions, nodeList) { + var rendererWithScope = function (ctx, opts, parentNodeList) { + return renderer(ctx || parentScope, opts, parentNodeList); + }; + return can.__notObserve(function (newScope, newOptions, parentNodeList) { + if (newScope !== undefined && !(newScope instanceof can.view.Scope)) { + newScope = parentScope.add(newScope); + } + if (newOptions !== undefined && !(newOptions instanceof core.Options)) { + newOptions = parentOptions.add(newOptions); + } + var result = rendererWithScope(newScope, newOptions || parentOptions, parentNodeList || nodeList); + return result; + }); + }; + var core = { + expressionData: function (expression) { + var args = [], hashes = {}, i = 0; + (can.trim(expression) + ' ').replace(argumentsRegExp, function (whole, arg) { + var m; + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[1] || m[2]) { + args.push(utils.jsonParse(m[1] || m[2])); + } else { + hashes[m[3]] = m[6] ? { get: m[6] } : utils.jsonParse(m[4] || m[5]); + } + } else { + args.push({ get: arg }); + } + i++; + }); + return { + name: args.shift(), + args: args, + hash: hashes + }; + }, + makeEvaluator: function (scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, stringOnly) { + var args = [], hash = {}, helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, context = scope.attr('.'), name = exprData.name, helper, looksLikeAHelper = exprData.args.length || !can.isEmptyObject(exprData.hash), initialValue, helperEvaluator; + for (var i = 0, len = exprData.args.length; i < len; i++) { + var arg = exprData.args[i]; + if (arg && isLookup(arg)) { + args.push(getKeyArgValue(arg.get, scope, true)); + } else { + args.push(arg); + } + } + for (var prop in exprData.hash) { + if (isLookup(exprData.hash[prop])) { + hash[prop] = getKeyArgValue(exprData.hash[prop].get, scope); + } else { + hash[prop] = exprData.hash[prop]; + } + } + if (isLookup(name)) { + if (looksLikeAHelper) { + helper = mustacheHelpers.getHelper(name.get, options); + if (!helper && typeof context[name.get] === 'function') { + helper = { fn: context[name.get] }; + } + } + if (!helper) { + var get = name.get; + var computeData = getKeyComputeData(name.get, scope, false), compute = computeData.compute; + initialValue = computeData.initialValue; + if (computeData.compute.computeInstance.hasDependencies) { + name = compute; + } else { + name = initialValue; + } + if (!looksLikeAHelper && initialValue === undefined) { + helper = mustacheHelpers.getHelper(get, options); + } else if (typeof initialValue === 'function') { + helper = { fn: initialValue }; + } + } + } + if (mode === '^') { + var temp = truthyRenderer; + truthyRenderer = falseyRenderer; + falseyRenderer = temp; + } + if (helper) { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + can.simpleExtend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash, + nodeList: nodeList, + exprData: exprData + }); + args.push(helperOptions); + helperEvaluator = function () { + return helper.fn.apply(context, args) || ''; + }; + helperEvaluator.bindOnce = false; + return helperEvaluator; + } + if (!mode) { + if (name && name.isComputed) { + return name; + } else { + return function () { + return '' + (name != null ? name : ''); + }; + } + } else if (mode === '#' || mode === '^') { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + var evaluator = function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + if (utils.isArrayLike(value)) { + var isObserveList = utils.isObserveLike(value); + if (isObserveList ? value.attr('length') : value.length) { + return (stringOnly ? getItemsStringContent : getItemsFragContent)(value, isObserveList, helperOptions, options); + } else { + return helperOptions.inverse(scope, options); + } + } else { + return value ? helperOptions.fn(value || scope, options) : helperOptions.inverse(scope, options); + } + }; + evaluator.bindOnce = false; + return evaluator; + } else { + } + }, + makeLiveBindingPartialRenderer: function (partialName, state) { + partialName = can.trim(partialName); + return function (scope, options, parentSectionNodeList) { + var nodeList = [this]; + nodeList.expression = '>' + partialName; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var partialFrag = can.compute(function () { + var localPartialName = partialName; + var partial = options.attr('partials.' + localPartialName), res; + if (partial) { + res = partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + var scopePartialName = scope.read(localPartialName, { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }).value; + if (scopePartialName) { + localPartialName = scopePartialName; + } + res = can.view.render(localPartialName, scope, options); + } + return can.frag(res); + }); + live.html(this, partialFrag, this.parentNode, nodeList); + }; + }, + makeStringBranchRenderer: function (mode, expression) { + var exprData = expressionData(expression), fullExpression = mode + expression; + return function branchRenderer(scope, options, truthyRenderer, falseyRenderer) { + var evaluator = scope.__cache[fullExpression]; + if (mode || !evaluator) { + evaluator = makeEvaluator(scope, options, null, mode, exprData, truthyRenderer, falseyRenderer, true); + if (!mode) { + scope.__cache[fullExpression] = evaluator; + } + } + var res = evaluator(); + return res == null ? '' : '' + res; + }; + }, + makeLiveBindingBranchRenderer: function (mode, expression, state) { + var exprData = expressionData(expression); + return function branchRenderer(scope, options, parentSectionNodeList, truthyRenderer, falseyRenderer) { + var nodeList = [this]; + nodeList.expression = expression; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var evaluator = makeEvaluator(scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, state.tag); + var compute = can.compute(evaluator, null, false, evaluator.bindOnce === false ? false : true); + compute.bind('change', can.k); + var value = compute(); + if (typeof value === 'function') { + var old = can.__clearReading(); + value(this); + can.__setReading(old); + } else if (compute.computeInstance.hasDependencies) { + if (state.attr) { + live.simpleAttribute(this, state.attr, compute); + } else if (state.tag) { + live.attributes(this, compute); + } else if (state.text && typeof value !== 'object') { + live.text(this, compute, this.parentNode, nodeList); + } else { + live.html(this, compute, this.parentNode, nodeList); + } + } else { + if (state.attr) { + can.attr.set(this, state.attr, value); + } else if (state.tag) { + live.setAttributes(this, value); + } else if (state.text && typeof value === 'string') { + this.nodeValue = value; + } else if (value) { + elements.replace([this], can.frag(value)); + } + } + compute.unbind('change', can.k); + }; + }, + splitModeFromExpression: function (expression, state) { + expression = can.trim(expression); + var mode = expression.charAt(0); + if ('#/{&^>!'.indexOf(mode) >= 0) { + expression = can.trim(expression.substr(1)); + } else { + mode = null; + } + if (mode === '{' && state.node) { + mode = null; + } + return { + mode: mode, + expression: expression + }; + }, + cleanLineEndings: function (template) { + return template.replace(mustacheLineBreakRegExp, function (whole, returnBefore, spaceBefore, special, expression, spaceAfter, returnAfter, spaceLessSpecial, spaceLessExpression, matchIndex) { + spaceAfter = spaceAfter || ''; + returnBefore = returnBefore || ''; + spaceBefore = spaceBefore || ''; + var modeAndExpression = splitModeFromExpression(expression || spaceLessExpression, {}); + if (spaceLessSpecial || '>{'.indexOf(modeAndExpression.mode) >= 0) { + return whole; + } else if ('^#!/'.indexOf(modeAndExpression.mode) >= 0) { + return special + (matchIndex !== 0 && returnAfter.length ? returnBefore + '\n' : ''); + } else { + return spaceBefore + special + spaceAfter + (spaceBefore.length || matchIndex !== 0 ? returnBefore + '\n' : ''); + } + }); + }, + Options: can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }) + }; + var makeEvaluator = core.makeEvaluator, expressionData = core.expressionData, splitModeFromExpression = core.splitModeFromExpression; + return core; +}); +/*can@2.2.6#view/bindings/bindings*/ +define('can/view/bindings/bindings', [ + 'can/util/util', + 'can/view/stache/mustache_core', + 'can/view/callbacks/callbacks', + 'can/control/control', + 'can/view/scope/scope' +], function (can, mustacheCore) { + var isContentEditable = function () { + var values = { + '': true, + 'true': true, + 'false': false + }; + var editable = function (el) { + if (!el || !el.getAttribute) { + return; + } + var attr = el.getAttribute('contenteditable'); + return values[attr]; + }; + return function (el) { + var val = editable(el); + if (typeof val === 'boolean') { + return val; + } else { + return !!editable(el.parentNode); + } + }; + }(), removeCurly = function (value) { + if (value[0] === '{' && value[value.length - 1] === '}') { + return value.substr(1, value.length - 2); + } + return value; + }; + can.view.attr('can-value', function (el, data) { + var attr = can.trim(removeCurly(el.getAttribute('can-value'))), value = data.scope.computeData(attr, { args: [] }).compute, trueValue, falseValue; + if (el.nodeName.toLowerCase() === 'input') { + if (el.type === 'checkbox') { + if (can.attr.has(el, 'can-true-value')) { + trueValue = el.getAttribute('can-true-value'); + } else { + trueValue = true; + } + if (can.attr.has(el, 'can-false-value')) { + falseValue = el.getAttribute('can-false-value'); + } else { + falseValue = false; + } + } + if (el.type === 'checkbox' || el.type === 'radio') { + new Checked(el, { + value: value, + trueValue: trueValue, + falseValue: falseValue + }); + return; + } + } + if (el.nodeName.toLowerCase() === 'select' && el.multiple) { + new Multiselect(el, { value: value }); + return; + } + if (isContentEditable(el)) { + new Content(el, { value: value }); + return; + } + new Value(el, { value: value }); + }); + var special = { + enter: function (data, el, original) { + return { + event: 'keyup', + handler: function (ev) { + if (ev.keyCode === 13) { + return original.call(this, ev); + } + } + }; + } + }; + can.view.attr(/can-[\w\.]+/, function (el, data) { + var attributeName = data.attributeName, event = attributeName.substr('can-'.length), handler = function (ev) { + var attrVal = el.getAttribute(attributeName); + if (!attrVal) { + return; + } + var attrInfo = mustacheCore.expressionData(removeCurly(attrVal)); + var scopeData = data.scope.read(attrInfo.name.get, { + returnObserveMethods: true, + isArgument: true, + executeAnonymousFunctions: true + }); + var args = []; + var $el = can.$(this); + var viewModel = can.viewModel($el[0]); + var localScope = data.scope.add({ + '@element': $el, + '@event': ev, + '@viewModel': viewModel, + '@scope': data.scope, + '@context': data.scope._context + }); + if (!can.isEmptyObject(attrInfo.hash)) { + var hash = {}; + can.each(attrInfo.hash, function (val, key) { + if (val && val.hasOwnProperty('get')) { + var s = !val.get.indexOf('@') ? localScope : data.scope; + hash[key] = s.read(val.get, {}).value; + } else { + hash[key] = val; + } + }); + args.unshift(hash); + } + if (attrInfo.args.length) { + var arg; + for (var i = attrInfo.args.length - 1; i >= 0; i--) { + arg = attrInfo.args[i]; + if (arg && arg.hasOwnProperty('get')) { + var s = !arg.get.indexOf('@') ? localScope : data.scope; + args.unshift(s.read(arg.get, {}).value); + } else { + args.unshift(arg); + } + } + } + if (!args.length) { + args = [ + data.scope._context, + $el + ].concat(can.makeArray(arguments)); + } + return scopeData.value.apply(scopeData.parent, args); + }; + if (special[event]) { + var specialData = special[event](data, el, handler); + handler = specialData.handler; + event = specialData.event; + } + can.bind.call(el, event, handler); + }); + var Value = can.Control.extend({ + init: function () { + if (this.element[0].nodeName.toUpperCase() === 'SELECT') { + setTimeout(can.proxy(this.set, this), 1); + } else { + this.set(); + } + }, + '{value} change': 'set', + set: function () { + if (!this.element) { + return; + } + var val = this.options.value(); + this.element[0].value = val == null ? '' : val; + }, + 'change': function () { + if (!this.element) { + return; + } + var el = this.element[0]; + this.options.value(el.value); + var newVal = this.options.value(); + if (el.value !== newVal) { + el.value = newVal; + } + } + }), Checked = can.Control.extend({ + init: function () { + this.isCheckbox = this.element[0].type.toLowerCase() === 'checkbox'; + this.check(); + }, + '{value} change': 'check', + check: function () { + if (this.isCheckbox) { + var value = this.options.value(), trueValue = this.options.trueValue || true; + this.element[0].checked = value == trueValue; + } else { + var setOrRemove = this.options.value() == this.element[0].value ? 'set' : 'remove'; + can.attr[setOrRemove](this.element[0], 'checked', true); + } + }, + 'change': function () { + if (this.isCheckbox) { + this.options.value(this.element[0].checked ? this.options.trueValue : this.options.falseValue); + } else { + if (this.element[0].checked) { + this.options.value(this.element[0].value); + } + } + } + }), Multiselect = Value.extend({ + init: function () { + this.delimiter = ';'; + setTimeout(can.proxy(this.set, this), 1); + }, + set: function () { + var newVal = this.options.value(); + if (typeof newVal === 'string') { + newVal = newVal.split(this.delimiter); + this.isString = true; + } else if (newVal) { + newVal = can.makeArray(newVal); + } + var isSelected = {}; + can.each(newVal, function (val) { + isSelected[val] = true; + }); + can.each(this.element[0].childNodes, function (option) { + if (option.value) { + option.selected = !!isSelected[option.value]; + } + }); + }, + get: function () { + var values = [], children = this.element[0].childNodes; + can.each(children, function (child) { + if (child.selected && child.value) { + values.push(child.value); + } + }); + return values; + }, + 'change': function () { + var value = this.get(), currentValue = this.options.value(); + if (this.isString || typeof currentValue === 'string') { + this.isString = true; + this.options.value(value.join(this.delimiter)); + } else if (currentValue instanceof can.List) { + currentValue.attr(value, true); + } else { + this.options.value(value); + } + } + }), Content = can.Control.extend({ + init: function () { + this.set(); + this.on('blur', 'setValue'); + }, + '{value} change': 'set', + set: function () { + var val = this.options.value(); + this.element[0].innerHTML = typeof val === 'undefined' ? '' : val; + }, + setValue: function () { + this.options.value(this.element[0].innerHTML); + } + }); +}); +/*can@2.2.6#view/mustache/mustache*/ +define('can/view/mustache/mustache', [ + 'can/util/util', + 'can/view/scope/scope', + 'can/view/view', + 'can/view/scanner', + 'can/compute/compute', + 'can/view/render', + 'can/view/bindings/bindings' +], function (can) { + can.view.ext = '.mustache'; + var SCOPE = 'scope', HASH = '___h4sh', CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options}', SPECIAL_CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options, special: true}', ARG_NAMES = SCOPE + ',options', argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false|null|undefined)|((.+?)=(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false)|(.+))))$/, makeLookupLiteral = function (type) { + return '{get:"' + type.replace(/"/g, '\\"') + '"}'; + }, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, isObserveLike = function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, isArrayLike = function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, makeConvertToScopes = function (original, scope, options) { + var originalWithScope = function (ctx, opts) { + return original(ctx || scope, opts); + }; + return function (updatedScope, updatedOptions) { + if (updatedScope !== undefined && !(updatedScope instanceof can.view.Scope)) { + updatedScope = scope.add(updatedScope); + } + if (updatedOptions !== undefined && !(updatedOptions instanceof can.view.Options)) { + updatedOptions = options.add(updatedOptions); + } + return originalWithScope(updatedScope, updatedOptions || options); + }; + }; + var Mustache = function (options, helpers) { + if (this.constructor !== Mustache) { + var mustache = new Mustache(options); + return function (data, options) { + return mustache.render(data, options); + }; + } + if (typeof options === 'function') { + this.template = { fn: options }; + return; + } + can.extend(this, options); + this.template = this.scanner.scan(this.text, this.name); + }; + can.Mustache = can.global.Mustache = Mustache; + Mustache.prototype.render = function (data, options) { + if (!(data instanceof can.view.Scope)) { + data = new can.view.Scope(data || {}); + } + if (!(options instanceof can.view.Options)) { + options = new can.view.Options(options || {}); + } + options = options || {}; + return this.template.fn.call(data, data, options); + }; + can.extend(Mustache.prototype, { + scanner: new can.view.Scanner({ + text: { + start: '', + scope: SCOPE, + options: ',options: options', + argNames: ARG_NAMES + }, + tokens: [ + [ + 'returnLeft', + '{{{', + '{{[{&]' + ], + [ + 'commentFull', + '{{!}}', + '^[\\s\\t]*{{!.+?}}\\n' + ], + [ + 'commentLeft', + '{{!', + '(\\n[\\s\\t]*{{!|{{!)' + ], + [ + 'escapeFull', + '{{}}', + '(^[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}$)', + function (content) { + return { + before: /^\n.+?\n$/.test(content) ? '\n' : '', + content: content.match(/\{\{(.+?)\}\}/)[1] || '' + }; + } + ], + [ + 'escapeLeft', + '{{' + ], + [ + 'returnRight', + '}}}' + ], + [ + 'right', + '}}' + ] + ], + helpers: [ + { + name: /^>[\s]*\w*/, + fn: function (content, cmd) { + var templateName = can.trim(content.replace(/^>\s?/, '')).replace(/["|']/g, ''); + return 'can.Mustache.renderPartial(\'' + templateName + '\',' + ARG_NAMES + ')'; + } + }, + { + name: /^\s*data\s/, + fn: function (content, cmd) { + var attr = content.match(/["|'](.*)["|']/)[1]; + return 'can.proxy(function(__){' + 'can.data(can.$(__),\'' + attr + '\', this.attr(\'.\')); }, ' + SCOPE + ')'; + } + }, + { + name: /\s*\(([\$\w]+)\)\s*->([^\n]*)/, + fn: function (content) { + var quickFunc = /\s*\(([\$\w]+)\)\s*->([^\n]*)/, parts = content.match(quickFunc); + return 'can.proxy(function(__){var ' + parts[1] + '=can.$(__);with(' + SCOPE + '.attr(\'.\')){' + parts[2] + '}}, this);'; + } + }, + { + name: /^.*$/, + fn: function (content, cmd) { + var mode = false, result = { + content: '', + startTxt: false, + startOnlyTxt: false, + end: false + }; + content = can.trim(content); + if (content.length && (mode = content.match(/^([#^\/]|else$)/))) { + mode = mode[0]; + switch (mode) { + case '#': + case '^': + if (cmd.specialAttribute) { + result.startOnlyTxt = true; + } else { + result.startTxt = true; + result.escaped = 0; + } + break; + case '/': + result.end = true; + result.content += 'return ___v1ew.join("");}}])'; + return result; + } + content = content.substring(1); + } + if (mode !== 'else') { + var args = [], hashes = [], i = 0, m; + result.content += 'can.Mustache.txt(\n' + (cmd.specialAttribute ? SPECIAL_CONTEXT_OBJ : CONTEXT_OBJ) + ',\n' + (mode ? '"' + mode + '"' : 'null') + ','; + (can.trim(content) + ' ').replace(argumentsRegExp, function (whole, arg) { + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[2]) { + args.push(m[0]); + } else { + hashes.push(m[4] + ':' + (m[6] ? m[6] : makeLookupLiteral(m[5]))); + } + } else { + args.push(makeLookupLiteral(arg)); + } + i++; + }); + result.content += args.join(','); + if (hashes.length) { + result.content += ',{' + HASH + ':{' + hashes.join(',') + '}}'; + } + } + if (mode && mode !== 'else') { + result.content += ',[\n\n'; + } + switch (mode) { + case '^': + case '#': + result.content += '{fn:function(' + ARG_NAMES + '){var ___v1ew = [];'; + break; + case 'else': + result.content += 'return ___v1ew.join("");}},\n{inverse:function(' + ARG_NAMES + '){\nvar ___v1ew = [];'; + break; + default: + result.content += ')'; + break; + } + if (!mode) { + result.startTxt = true; + result.end = true; + } + return result; + } + } + ] + }) + }); + var helpers = can.view.Scanner.prototype.helpers; + for (var i = 0; i < helpers.length; i++) { + Mustache.prototype.scanner.helpers.unshift(helpers[i]); + } + Mustache.txt = function (scopeAndOptions, mode, name) { + var scope = scopeAndOptions.scope, options = scopeAndOptions.options, args = [], helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, hash, context = scope.attr('.'), getHelper = true, helper; + for (var i = 3; i < arguments.length; i++) { + var arg = arguments[i]; + if (mode && can.isArray(arg)) { + helperOptions = can.extend.apply(can, [helperOptions].concat(arg)); + } else if (arg && arg[HASH]) { + hash = arg[HASH]; + for (var prop in hash) { + if (isLookup(hash[prop])) { + hash[prop] = Mustache.get(hash[prop].get, scopeAndOptions, false, true); + } + } + } else if (arg && isLookup(arg)) { + args.push(Mustache.get(arg.get, scopeAndOptions, false, true, true)); + } else { + args.push(arg); + } + } + if (isLookup(name)) { + var get = name.get; + name = Mustache.get(name.get, scopeAndOptions, args.length, false); + getHelper = get === name; + } + helperOptions.fn = makeConvertToScopes(helperOptions.fn, scope, options); + helperOptions.inverse = makeConvertToScopes(helperOptions.inverse, scope, options); + if (mode === '^') { + var tmp = helperOptions.fn; + helperOptions.fn = helperOptions.inverse; + helperOptions.inverse = tmp; + } + if (helper = getHelper && (typeof name === 'string' && Mustache.getHelper(name, options)) || can.isFunction(name) && !name.isComputed && { fn: name }) { + can.extend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash + }); + args.push(helperOptions); + return function () { + return helper.fn.apply(context, args) || ''; + }; + } + return function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + var validArgs = args.length ? args : [value], valid = true, result = [], i, argIsObserve, arg; + if (mode) { + for (i = 0; i < validArgs.length; i++) { + arg = validArgs[i]; + argIsObserve = typeof arg !== 'undefined' && isObserveLike(arg); + if (isArrayLike(arg)) { + if (mode === '#') { + valid = valid && !!(argIsObserve ? arg.attr('length') : arg.length); + } else if (mode === '^') { + valid = valid && !(argIsObserve ? arg.attr('length') : arg.length); + } + } else { + valid = mode === '#' ? valid && !!arg : mode === '^' ? valid && !arg : valid; + } + } + } + if (valid) { + if (mode === '#') { + if (isArrayLike(value)) { + var isObserveList = isObserveLike(value); + for (i = 0; i < value.length; i++) { + result.push(helperOptions.fn(isObserveList ? value.attr('' + i) : value[i])); + } + return result.join(''); + } else { + return helperOptions.fn(value || {}) || ''; + } + } else if (mode === '^') { + return helperOptions.inverse(value || {}) || ''; + } else { + return '' + (value != null ? value : ''); + } + } + return ''; + }; + }; + Mustache.get = function (key, scopeAndOptions, isHelper, isArgument, isLookup) { + var context = scopeAndOptions.scope.attr('.'), options = scopeAndOptions.options || {}; + if (isHelper) { + if (Mustache.getHelper(key, options)) { + return key; + } + if (scopeAndOptions.scope && can.isFunction(context[key])) { + return context[key]; + } + } + var computeData = scopeAndOptions.scope.computeData(key, { + isArgument: isArgument, + args: [ + context, + scopeAndOptions.scope + ] + }), compute = computeData.compute; + can.compute.temporarilyBind(compute); + var initialValue = computeData.initialValue, helperObj = Mustache.getHelper(key, options); + if (!isLookup && (initialValue === undefined || computeData.scope !== scopeAndOptions.scope) && Mustache.getHelper(key, options)) { + return key; + } + if (!compute.computeInstance.hasDependencies) { + return initialValue; + } else { + return compute; + } + }; + Mustache.resolve = function (value) { + if (isObserveLike(value) && isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + can.view.Options = can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }); + Mustache._helpers = {}; + Mustache.registerHelper = function (name, fn) { + this._helpers[name] = { + name: name, + fn: fn + }; + }; + Mustache.getHelper = function (name, options) { + var helper; + if (options) { + helper = options.attr('helpers.' + name); + } + return helper ? { fn: helper } : this._helpers[name]; + }; + Mustache.render = function (partial, scope, options) { + if (!can.view.cached[partial]) { + var reads = can.__clearReading(); + var scopePartialName = scope.attr(partial); + if (scopePartialName) { + partial = scopePartialName; + } + can.__setReading(reads); + } + return can.view.render(partial, scope, options); + }; + Mustache.safeString = function (str) { + return { + toString: function () { + return str; + } + }; + }; + Mustache.renderPartial = function (partialName, scope, options) { + var partial = options.attr('partials.' + partialName); + if (partial) { + return partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + return can.Mustache.render(partialName, scope, options); + } + }; + can.each({ + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!Mustache.resolve(expr); + } + if (value) { + return options.fn(options.contexts || this); + } else { + return options.inverse(options.contexts || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = Mustache.resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return Mustache._helpers.is.fn.apply(this, arguments); + }, + 'unless': function (expr, options) { + return Mustache._helpers['if'].fn.apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'each': function (expr, options) { + var resolved = Mustache.resolve(expr), result = [], keys, key, i; + if (can.view.lists && (resolved instanceof can.List || expr && expr.isComputed && resolved === undefined)) { + return can.view.lists(expr, function (item, index) { + return options.fn(options.scope.add({ '@index': index }).add(item)); + }); + } + expr = resolved; + if (!!expr && isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + return result.join(''); + } else if (isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } + }, + 'with': function (expr, options) { + var ctx = expr; + expr = Mustache.resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + } + }, function (fn, name) { + Mustache.registerHelper(name, fn); + }); + can.view.register({ + suffix: 'mustache', + contentType: 'x-mustache-template', + script: function (id, src) { + return 'can.Mustache(function(' + ARG_NAMES + ') { ' + new Mustache({ + text: src, + name: id + }).template.out + ' })'; + }, + renderer: function (id, text) { + return Mustache({ + text: text, + name: id + }); + } + }); + can.mustache.registerHelper = can.proxy(can.Mustache.registerHelper, can.Mustache); + can.mustache.safeString = can.Mustache.safeString; + return can; +}); +/*can@2.2.6#component/component*/ +define('can/component/component', [ + 'can/util/util', + 'can/view/callbacks/callbacks', + 'can/view/elements', + 'can/control/control', + 'can/observe/observe', + 'can/view/mustache/mustache', + 'can/view/bindings/bindings' +], function (can, viewCallbacks, elements) { + var ignoreAttributesRegExp = /^(dataViewId|class|id)$/i, paramReplacer = /\{([^\}]+)\}/g; + var Component = can.Component = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Component) { + var self = this, scope = this.prototype.scope || this.prototype.viewModel; + this.Control = ComponentControl.extend(this.prototype.events); + if (!scope || typeof scope === 'object' && !(scope instanceof can.Map)) { + this.Map = can.Map.extend(scope || {}); + } else if (scope.prototype instanceof can.Map) { + this.Map = scope; + } + this.attributeScopeMappings = {}; + can.each(this.Map ? this.Map.defaults : {}, function (val, prop) { + if (val === '@') { + self.attributeScopeMappings[prop] = prop; + } + }); + if (this.prototype.template) { + if (typeof this.prototype.template === 'function') { + var temp = this.prototype.template; + this.renderer = function () { + return can.view.frag(temp.apply(null, arguments)); + }; + } else { + this.renderer = can.view.mustache(this.prototype.template); + } + } + can.view.tag(this.prototype.tag, function (el, options) { + new self(el, options); + }); + } + } + }, { + setup: function (el, hookupOptions) { + var initialScopeData = {}, component = this, lexicalContent = (typeof this.leakScope === 'undefined' ? false : !this.leakScope) && this.template, twoWayBindings = {}, scope = this.scope || this.viewModel, viewModelPropertyUpdates = {}, componentScope, frag, teardownFunctions = [], callTeardownFunctions = function () { + for (var i = 0, len = teardownFunctions.length; i < len; i++) { + teardownFunctions[i](); + } + }; + can.each(this.constructor.attributeScopeMappings, function (val, prop) { + initialScopeData[prop] = el.getAttribute(can.hyphenate(val)); + }); + can.each(can.makeArray(el.attributes), function (node, index) { + var name = can.camelize(node.nodeName.toLowerCase()), value = node.value; + if (component.constructor.attributeScopeMappings[name] || ignoreAttributesRegExp.test(name) || viewCallbacks.attr(node.nodeName)) { + return; + } + if (value[0] === '{' && value[value.length - 1] === '}') { + value = value.substr(1, value.length - 2); + } else { + if (hookupOptions.templateType !== 'legacy') { + initialScopeData[name] = value; + return; + } + } + var computeData = hookupOptions.scope.computeData(value, { args: [] }), compute = computeData.compute; + var handler = function (ev, newVal) { + viewModelPropertyUpdates[name] = (viewModelPropertyUpdates[name] || 0) + 1; + componentScope.attr(name, newVal); + can.batch.afterPreviousEvents(function () { + --viewModelPropertyUpdates[name]; + }); + }; + compute.bind('change', handler); + initialScopeData[name] = compute(); + if (!compute.computeInstance.hasDependencies) { + compute.unbind('change', handler); + } else { + teardownFunctions.push(function () { + compute.unbind('change', handler); + }); + twoWayBindings[name] = computeData; + } + }); + if (this.constructor.Map) { + componentScope = new this.constructor.Map(initialScopeData); + } else if (scope instanceof can.Map) { + componentScope = scope; + } else if (can.isFunction(scope)) { + var scopeResult = scope.call(this, initialScopeData, hookupOptions.scope, el); + if (scopeResult instanceof can.Map) { + componentScope = scopeResult; + } else if (scopeResult.prototype instanceof can.Map) { + componentScope = new scopeResult(initialScopeData); + } else { + componentScope = new (can.Map.extend(scopeResult))(initialScopeData); + } + } + var handlers = {}; + can.each(twoWayBindings, function (computeData, prop) { + handlers[prop] = function (ev, newVal) { + if (!viewModelPropertyUpdates[prop]) { + computeData.compute(newVal); + } + }; + componentScope.bind(prop, handlers[prop]); + }); + if (!can.isEmptyObject(this.constructor.attributeScopeMappings) || hookupOptions.templateType !== 'legacy') { + can.bind.call(el, 'attributes', function (ev) { + var camelized = can.camelize(ev.attributeName); + if (!twoWayBindings[camelized] && !ignoreAttributesRegExp.test(camelized)) { + componentScope.attr(camelized, el.getAttribute(ev.attributeName)); + } + }); + } + this.scope = this.viewModel = componentScope; + can.data(can.$(el), 'scope', this.scope); + can.data(can.$(el), 'viewModel', this.scope); + var renderedScope = lexicalContent ? this.scope : hookupOptions.scope.add(this.scope), options = { helpers: {} }; + can.each(this.helpers || {}, function (val, prop) { + if (can.isFunction(val)) { + options.helpers[prop] = function () { + return val.apply(componentScope, arguments); + }; + } + }); + teardownFunctions.push(function () { + can.each(handlers, function (handler, prop) { + componentScope.unbind(prop, handlers[prop]); + }); + }); + this._control = new this.constructor.Control(el, { + scope: this.scope, + viewModel: this.scope + }); + if (this._control && this._control.destroy) { + var oldDestroy = this._control.destroy; + this._control.destroy = function () { + oldDestroy.apply(this, arguments); + callTeardownFunctions(); + }; + this._control.on(); + } else { + can.bind.call(el, 'removed', function () { + callTeardownFunctions(); + }); + } + var nodeList = can.view.nodeLists.register([], undefined, true); + teardownFunctions.push(function () { + can.view.nodeLists.unregister(nodeList); + }); + if (this.constructor.renderer) { + if (!options.tags) { + options.tags = {}; + } + options.tags.content = function contentHookup(el, rendererOptions) { + var subtemplate = hookupOptions.subtemplate || rendererOptions.subtemplate; + if (subtemplate) { + delete options.tags.content; + var opts = !lexicalContent || subtemplate !== hookupOptions.subtemplate ? rendererOptions : hookupOptions; + if (rendererOptions.parentNodeList) { + var frag = subtemplate(opts.scope, opts.options, rendererOptions.parentNodeList); + elements.replace([el], frag); + } else { + can.view.live.replace([el], subtemplate(opts.scope, opts.options)); + } + options.tags.content = contentHookup; + } + }; + frag = this.constructor.renderer(renderedScope, hookupOptions.options.add(options), nodeList); + } else { + if (hookupOptions.templateType === 'legacy') { + frag = can.view.frag(hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options)) : ''); + } else { + frag = hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options), nodeList) : document.createDocumentFragment(); + } + } + can.appendChild(el, frag); + can.view.nodeLists.update(nodeList, el.childNodes); + } + }); + var ComponentControl = can.Control.extend({ + _lookup: function (options) { + return [ + options.scope, + options, + window + ]; + }, + _action: function (methodName, options, controlInstance) { + var hasObjectLookup, readyCompute; + paramReplacer.lastIndex = 0; + hasObjectLookup = paramReplacer.test(methodName); + if (!controlInstance && hasObjectLookup) { + return; + } else if (!hasObjectLookup) { + return can.Control._action.apply(this, arguments); + } else { + readyCompute = can.compute(function () { + var delegate; + var name = methodName.replace(paramReplacer, function (matched, key) { + var value; + if (key === 'scope' || key === 'viewModel') { + delegate = options.scope; + return ''; + } + key = key.replace(/^(scope|^viewModel)\./, ''); + value = can.compute.read(options.scope, key.split('.'), { isArgument: true }).value; + if (value === undefined) { + value = can.getObject(key); + } + if (typeof value === 'string') { + return value; + } else { + delegate = value; + return ''; + } + }); + var parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: this.processors[event] || this.processors.click, + parts: [ + name, + parts.join(' '), + event + ], + delegate: delegate || undefined + }; + }, this); + var handler = function (ev, ready) { + controlInstance._bindings.control[methodName](controlInstance.element); + controlInstance._bindings.control[methodName] = ready.processor(ready.delegate || controlInstance.element, ready.parts[2], ready.parts[1], methodName, controlInstance); + }; + readyCompute.bind('change', handler); + controlInstance._bindings.readyComputes[methodName] = { + compute: readyCompute, + handler: handler + }; + return readyCompute(); + } + } + }, { + setup: function (el, options) { + this.scope = options.scope; + this.viewModel = options.viewModel; + return can.Control.prototype.setup.call(this, el, options); + }, + off: function () { + if (this._bindings) { + can.each(this._bindings.readyComputes || {}, function (value) { + value.compute.unbind('change', value.handler); + }); + } + can.Control.prototype.off.apply(this, arguments); + this._bindings.readyComputes = {}; + } + }); + var $ = can.$; + if ($.fn) { + $.fn.scope = $.fn.viewModel = function () { + return can.viewModel.apply(can, [this].concat(can.makeArray(arguments))); + }; + } + return Component; +}); +/*can@2.2.6#model/model*/ +define('can/model/model', [ + 'can/util/util', + 'can/map/map', + 'can/list/list' +], function (can) { + var pipe = function (def, thisArg, func) { + var d = new can.Deferred(); + def.then(function () { + var args = can.makeArray(arguments), success = true; + try { + args[0] = func.apply(thisArg, args); + } catch (e) { + success = false; + d.rejectWith(d, [e].concat(args)); + } + if (success) { + d.resolveWith(d, args); + } + }, function () { + d.rejectWith(this, arguments); + }); + if (typeof def.abort === 'function') { + d.abort = function () { + return def.abort(); + }; + } + return d; + }, modelNum = 0, getId = function (inst) { + can.__observe(inst, inst.constructor.id); + return inst.__get(inst.constructor.id); + }, ajax = function (ajaxOb, data, type, dataType, success, error) { + var params = {}; + if (typeof ajaxOb === 'string') { + var parts = ajaxOb.split(/\s+/); + params.url = parts.pop(); + if (parts.length) { + params.type = parts.pop(); + } + } else { + can.extend(params, ajaxOb); + } + params.data = typeof data === 'object' && !can.isArray(data) ? can.extend(params.data || {}, data) : data; + params.url = can.sub(params.url, params.data, true); + return can.ajax(can.extend({ + type: type || 'post', + dataType: dataType || 'json', + success: success, + error: error + }, params)); + }, makeRequest = function (modelObj, type, success, error, method) { + var args; + if (can.isArray(modelObj)) { + args = modelObj[1]; + modelObj = modelObj[0]; + } else { + args = modelObj.serialize(); + } + args = [args]; + var deferred, model = modelObj.constructor, jqXHR; + if (type === 'update' || type === 'destroy') { + args.unshift(getId(modelObj)); + } + jqXHR = model[type].apply(model, args); + deferred = pipe(jqXHR, modelObj, function (data) { + modelObj[method || type + 'd'](data, jqXHR); + return modelObj; + }); + if (jqXHR.abort) { + deferred.abort = function () { + jqXHR.abort(); + }; + } + deferred.then(success, error); + return deferred; + }, converters = { + models: function (instancesRawData, oldList, xhr) { + can.Model._reqs++; + if (!instancesRawData) { + return; + } + if (instancesRawData instanceof this.List) { + return instancesRawData; + } + var self = this, tmp = [], ListClass = self.List || ML, modelList = oldList instanceof can.List ? oldList : new ListClass(), rawDataIsList = instancesRawData instanceof ML, raw = rawDataIsList ? instancesRawData.serialize() : instancesRawData; + raw = self.parseModels(raw, xhr); + if (raw.data) { + instancesRawData = raw; + raw = raw.data; + } + if (typeof raw === 'undefined' || !can.isArray(raw)) { + throw new Error('Could not get any raw data while converting using .models'); + } + if (modelList.length) { + modelList.splice(0); + } + can.each(raw, function (rawPart) { + tmp.push(self.model(rawPart, xhr)); + }); + modelList.push.apply(modelList, tmp); + if (!can.isArray(instancesRawData)) { + can.each(instancesRawData, function (val, prop) { + if (prop !== 'data') { + modelList.attr(prop, val); + } + }); + } + setTimeout(can.proxy(this._clean, this), 1); + return modelList; + }, + model: function (attributes, oldModel, xhr) { + if (!attributes) { + return; + } + if (typeof attributes.serialize === 'function') { + attributes = attributes.serialize(); + } else { + attributes = this.parseModel(attributes, xhr); + } + var id = attributes[this.id]; + if ((id || id === 0) && this.store[id]) { + oldModel = this.store[id]; + } + var model = oldModel && can.isFunction(oldModel.attr) ? oldModel.attr(attributes, this.removeAttr || false) : new this(attributes); + return model; + } + }, makeParser = { + parseModel: function (prop) { + return function (attributes) { + return prop ? can.getObject(prop, attributes) : attributes; + }; + }, + parseModels: function (prop) { + return function (attributes) { + if (can.isArray(attributes)) { + return attributes; + } + prop = prop || 'data'; + var result = can.getObject(prop, attributes); + if (!can.isArray(result)) { + throw new Error('Could not get any raw data while converting using .models'); + } + return result; + }; + } + }, ajaxMethods = { + create: { + url: '_shortName', + type: 'post' + }, + update: { + data: function (id, attrs) { + attrs = attrs || {}; + var identity = this.id; + if (attrs[identity] && attrs[identity] !== id) { + attrs['new' + can.capitalize(id)] = attrs[identity]; + delete attrs[identity]; + } + attrs[identity] = id; + return attrs; + }, + type: 'put' + }, + destroy: { + type: 'delete', + data: function (id, attrs) { + attrs = attrs || {}; + attrs.id = attrs[this.id] = id; + return attrs; + } + }, + findAll: { url: '_shortName' }, + findOne: {} + }, ajaxMaker = function (ajaxMethod, str) { + return function (data) { + data = ajaxMethod.data ? ajaxMethod.data.apply(this, arguments) : data; + return ajax(str || this[ajaxMethod.url || '_url'], data, ajaxMethod.type || 'get'); + }; + }, createURLFromResource = function (model, name) { + if (!model.resource) { + return; + } + var resource = model.resource.replace(/\/+$/, ''); + if (name === 'findAll' || name === 'create') { + return resource; + } else { + return resource + '/{' + model.id + '}'; + } + }; + can.Model = can.Map.extend({ + fullName: 'can.Model', + _reqs: 0, + setup: function (base, fullName, staticProps, protoProps) { + if (typeof fullName !== 'string') { + protoProps = staticProps; + staticProps = fullName; + } + if (!protoProps) { + protoProps = staticProps; + } + this.store = {}; + can.Map.setup.apply(this, arguments); + if (!can.Model) { + return; + } + if (staticProps && staticProps.List) { + this.List = staticProps.List; + this.List.Map = this; + } else { + this.List = base.List.extend({ Map: this }, {}); + } + var self = this, clean = can.proxy(this._clean, self); + can.each(ajaxMethods, function (method, name) { + if (staticProps && staticProps[name] && (typeof staticProps[name] === 'string' || typeof staticProps[name] === 'object')) { + self[name] = ajaxMaker(method, staticProps[name]); + } else if (staticProps && staticProps.resource && !can.isFunction(staticProps[name])) { + self[name] = ajaxMaker(method, createURLFromResource(self, name)); + } + if (self['make' + can.capitalize(name)]) { + var newMethod = self['make' + can.capitalize(name)](self[name]); + can.Construct._overwrite(self, base, name, function () { + can.Model._reqs++; + var def = newMethod.apply(this, arguments); + var then = def.then(clean, clean); + then.abort = def.abort; + return then; + }); + } + }); + var hasCustomConverter = {}; + can.each(converters, function (converter, name) { + var parseName = 'parse' + can.capitalize(name), dataProperty = staticProps && staticProps[name] || self[name]; + if (typeof dataProperty === 'string') { + self[parseName] = dataProperty; + can.Construct._overwrite(self, base, name, converter); + } else if (staticProps && staticProps[name]) { + hasCustomConverter[parseName] = true; + } + }); + can.each(makeParser, function (maker, parseName) { + var prop = staticProps && staticProps[parseName] || self[parseName]; + if (typeof prop === 'string') { + can.Construct._overwrite(self, base, parseName, maker(prop)); + } else if ((!staticProps || !can.isFunction(staticProps[parseName])) && !self[parseName]) { + var madeParser = maker(); + madeParser.useModelConverter = hasCustomConverter[parseName]; + can.Construct._overwrite(self, base, parseName, madeParser); + } + }); + if (self.fullName === 'can.Model' || !self.fullName) { + self.fullName = 'Model' + ++modelNum; + } + can.Model._reqs = 0; + this._url = this._shortName + '/{' + this.id + '}'; + }, + _ajax: ajaxMaker, + _makeRequest: makeRequest, + _clean: function () { + can.Model._reqs--; + if (!can.Model._reqs) { + for (var id in this.store) { + if (!this.store[id]._bindings) { + delete this.store[id]; + } + } + } + return arguments[0]; + }, + models: converters.models, + model: converters.model + }, { + setup: function (attrs) { + var id = attrs && attrs[this.constructor.id]; + if (can.Model._reqs && id != null) { + this.constructor.store[id] = this; + } + can.Map.prototype.setup.apply(this, arguments); + }, + isNew: function () { + var id = getId(this); + return !(id || id === 0); + }, + save: function (success, error) { + return makeRequest(this, this.isNew() ? 'create' : 'update', success, error); + }, + destroy: function (success, error) { + if (this.isNew()) { + var self = this; + var def = can.Deferred(); + def.then(success, error); + return def.done(function (data) { + self.destroyed(data); + }).resolve(self); + } + return makeRequest(this, 'destroy', success, error, 'destroyed'); + }, + _bindsetup: function () { + var modelInstance = this.__get(this.constructor.id); + if (modelInstance != null) { + this.constructor.store[modelInstance] = this; + } + return can.Map.prototype._bindsetup.apply(this, arguments); + }, + _bindteardown: function () { + delete this.constructor.store[getId(this)]; + return can.Map.prototype._bindteardown.apply(this, arguments); + }, + ___set: function (prop, val) { + can.Map.prototype.___set.call(this, prop, val); + if (prop === this.constructor.id && this._bindings) { + this.constructor.store[getId(this)] = this; + } + } + }); + var makeGetterHandler = function (name) { + return function (data, readyState, xhr) { + return this[name](data, null, xhr); + }; + }, createUpdateDestroyHandler = function (data) { + if (this.parseModel.useModelConverter) { + return this.model(data); + } + return this.parseModel(data); + }; + var responseHandlers = { + makeFindAll: makeGetterHandler('models'), + makeFindOne: makeGetterHandler('model'), + makeCreate: createUpdateDestroyHandler, + makeUpdate: createUpdateDestroyHandler, + makeDestroy: createUpdateDestroyHandler + }; + can.each(responseHandlers, function (method, name) { + can.Model[name] = function (oldMethod) { + return function () { + var args = can.makeArray(arguments), oldArgs = can.isFunction(args[1]) ? args.splice(0, 1) : args.splice(0, 2), def = pipe(oldMethod.apply(this, oldArgs), this, method); + def.then(args[0], args[1]); + return def; + }; + }; + }); + can.each([ + 'created', + 'updated', + 'destroyed' + ], function (funcName) { + can.Model.prototype[funcName] = function (attrs) { + var self = this, constructor = self.constructor; + if (attrs && typeof attrs === 'object') { + this.attr(can.isFunction(attrs.attr) ? attrs.attr() : attrs); + } + can.dispatch.call(this, { + type: 'change', + target: this + }, [funcName]); + can.dispatch.call(constructor, funcName, [this]); + }; + }); + var ML = can.Model.List = can.List.extend({ + _bubbleRule: function (eventName, list) { + var bubbleRules = can.List._bubbleRule(eventName, list); + bubbleRules.push('destroyed'); + return bubbleRules; + } + }, { + setup: function (params) { + if (can.isPlainObject(params) && !can.isArray(params)) { + can.List.prototype.setup.apply(this); + this.replace(can.isDeferred(params) ? params : this.constructor.Map.findAll(params)); + } else { + can.List.prototype.setup.apply(this, arguments); + } + this._init = 1; + this.bind('destroyed', can.proxy(this._destroyed, this)); + delete this._init; + }, + _destroyed: function (ev, attr) { + if (/\w+/.test(attr)) { + var index; + while ((index = this.indexOf(ev.target)) > -1) { + this.splice(index, 1); + } + } + } + }); + return can.Model; +}); +/*can@2.2.6#util/string/deparam/deparam*/ +define('can/util/string/deparam/deparam', [ + 'can/util/util', + 'can/util/string/string' +], function (can) { + var digitTest = /^\d+$/, keyBreaker = /([^\[\]]+)|(\[\])/g, paramTest = /([^?#]*)(#.*)?$/, prep = function (str) { + return decodeURIComponent(str.replace(/\+/g, ' ')); + }; + can.extend(can, { + deparam: function (params) { + var data = {}, pairs, lastPart; + if (params && paramTest.test(params)) { + pairs = params.split('&'); + can.each(pairs, function (pair) { + var parts = pair.split('='), key = prep(parts.shift()), value = prep(parts.join('=')), current = data; + if (key) { + parts = key.match(keyBreaker); + for (var j = 0, l = parts.length - 1; j < l; j++) { + if (!current[parts[j]]) { + current[parts[j]] = digitTest.test(parts[j + 1]) || parts[j + 1] === '[]' ? [] : {}; + } + current = current[parts[j]]; + } + lastPart = parts.pop(); + if (lastPart === '[]') { + current.push(value); + } else { + current[lastPart] = value; + } + } + }); + } + return data; + } + }); + return can; +}); +/*can@2.2.6#route/route*/ +define('can/route/route', [ + 'can/util/util', + 'can/map/map', + 'can/list/list', + 'can/util/string/deparam/deparam' +], function (can) { + var matcher = /\:([\w\.]+)/g, paramsMatcher = /^(?:&[^=]+=[^&]*)+/, makeProps = function (props) { + var tags = []; + can.each(props, function (val, name) { + tags.push((name === 'className' ? 'class' : name) + '="' + (name === 'href' ? val : can.esc(val)) + '"'); + }); + return tags.join(' '); + }, matchesData = function (route, data) { + var count = 0, i = 0, defaults = {}; + for (var name in route.defaults) { + if (route.defaults[name] === data[name]) { + defaults[name] = 1; + count++; + } + } + for (; i < route.names.length; i++) { + if (!data.hasOwnProperty(route.names[i])) { + return -1; + } + if (!defaults[route.names[i]]) { + count++; + } + } + return count; + }, location = window.location, wrapQuote = function (str) { + return (str + '').replace(/([.?*+\^$\[\]\\(){}|\-])/g, '\\$1'); + }, each = can.each, extend = can.extend, stringify = function (obj) { + if (obj && typeof obj === 'object') { + if (obj instanceof can.Map) { + obj = obj.attr(); + } else { + obj = can.isFunction(obj.slice) ? obj.slice() : can.extend({}, obj); + } + can.each(obj, function (val, prop) { + obj[prop] = stringify(val); + }); + } else if (obj !== undefined && obj !== null && can.isFunction(obj.toString)) { + obj = obj.toString(); + } + return obj; + }, removeBackslash = function (str) { + return str.replace(/\\/g, ''); + }, timer, curParams, lastHash, changingData, changedAttrs = [], onRouteDataChange = function (ev, attr, how, newval) { + changingData = 1; + changedAttrs.push(attr); + clearTimeout(timer); + timer = setTimeout(function () { + changingData = 0; + var serialized = can.route.data.serialize(), path = can.route.param(serialized, true); + can.route._call('setURL', path, changedAttrs); + can.batch.trigger(eventsObject, '__url', [ + path, + lastHash + ]); + lastHash = path; + changedAttrs = []; + }, 10); + }, eventsObject = can.extend({}, can.event); + can.route = function (url, defaults) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + defaults = defaults || {}; + var names = [], res, test = '', lastIndex = matcher.lastIndex = 0, next, querySeparator = can.route._call('querySeparator'), matchSlashes = can.route._call('matchSlashes'); + while (res = matcher.exec(url)) { + names.push(res[1]); + test += removeBackslash(url.substring(lastIndex, matcher.lastIndex - res[0].length)); + next = '\\' + (removeBackslash(url.substr(matcher.lastIndex, 1)) || querySeparator + (matchSlashes ? '' : '|/')); + test += '([^' + next + ']' + (defaults[res[1]] ? '*' : '+') + ')'; + lastIndex = matcher.lastIndex; + } + test += url.substr(lastIndex).replace('\\', ''); + can.route.routes[url] = { + test: new RegExp('^' + test + '($|' + wrapQuote(querySeparator) + ')'), + route: url, + names: names, + defaults: defaults, + length: url.split('/').length + }; + return can.route; + }; + extend(can.route, { + param: function (data, _setRoute) { + var route, matches = 0, matchCount, routeName = data.route, propCount = 0; + delete data.route; + each(data, function () { + propCount++; + }); + each(can.route.routes, function (temp, name) { + matchCount = matchesData(temp, data); + if (matchCount > matches) { + route = temp; + matches = matchCount; + } + if (matchCount >= propCount) { + return false; + } + }); + if (can.route.routes[routeName] && matchesData(can.route.routes[routeName], data) === matches) { + route = can.route.routes[routeName]; + } + if (route) { + var cpy = extend({}, data), res = route.route.replace(matcher, function (whole, name) { + delete cpy[name]; + return data[name] === route.defaults[name] ? '' : encodeURIComponent(data[name]); + }).replace('\\', ''), after; + each(route.defaults, function (val, name) { + if (cpy[name] === val) { + delete cpy[name]; + } + }); + after = can.param(cpy); + if (_setRoute) { + can.route.attr('route', route.route); + } + return res + (after ? can.route._call('querySeparator') + after : ''); + } + return can.isEmptyObject(data) ? '' : can.route._call('querySeparator') + can.param(data); + }, + deparam: function (url) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + var route = { length: -1 }, querySeparator = can.route._call('querySeparator'), paramsMatcher = can.route._call('paramsMatcher'); + each(can.route.routes, function (temp, name) { + if (temp.test.test(url) && temp.length > route.length) { + route = temp; + } + }); + if (route.length > -1) { + var parts = url.match(route.test), start = parts.shift(), remainder = url.substr(start.length - (parts[parts.length - 1] === querySeparator ? 1 : 0)), obj = remainder && paramsMatcher.test(remainder) ? can.deparam(remainder.slice(1)) : {}; + obj = extend(true, {}, route.defaults, obj); + each(parts, function (part, i) { + if (part && part !== querySeparator) { + obj[route.names[i]] = decodeURIComponent(part); + } + }); + obj.route = route.route; + return obj; + } + if (url.charAt(0) !== querySeparator) { + url = querySeparator + url; + } + return paramsMatcher.test(url) ? can.deparam(url.slice(1)) : {}; + }, + data: new can.Map({}), + map: function (data) { + var appState; + if (data.prototype instanceof can.Map) { + appState = new data(); + } else { + appState = data; + } + can.route.data = appState; + }, + routes: {}, + ready: function (val) { + if (val !== true) { + can.route._setup(); + can.route.setState(); + } + return can.route; + }, + url: function (options, merge) { + if (merge) { + options = can.extend({}, can.route.deparam(can.route._call('matchingPartOfURL')), options); + } + return can.route._call('root') + can.route.param(options); + }, + link: function (name, options, props, merge) { + return '' + name + ''; + }, + current: function (options) { + can.__observe(eventsObject, '__url'); + return this._call('matchingPartOfURL') === can.route.param(options); + }, + bindings: { + hashchange: { + paramsMatcher: paramsMatcher, + querySeparator: '&', + matchSlashes: false, + bind: function () { + can.bind.call(window, 'hashchange', setState); + }, + unbind: function () { + can.unbind.call(window, 'hashchange', setState); + }, + matchingPartOfURL: function () { + return location.href.split(/#!?/)[1] || ''; + }, + setURL: function (path) { + if (location.hash !== '#' + path) { + location.hash = '!' + path; + } + return path; + }, + root: '#!' + } + }, + defaultBinding: 'hashchange', + currentBinding: null, + _setup: function () { + if (!can.route.currentBinding) { + can.route._call('bind'); + can.route.bind('change', onRouteDataChange); + can.route.currentBinding = can.route.defaultBinding; + } + }, + _teardown: function () { + if (can.route.currentBinding) { + can.route._call('unbind'); + can.route.unbind('change', onRouteDataChange); + can.route.currentBinding = null; + } + clearTimeout(timer); + changingData = 0; + }, + _call: function () { + var args = can.makeArray(arguments), prop = args.shift(), binding = can.route.bindings[can.route.currentBinding || can.route.defaultBinding], method = binding[prop]; + if (method.apply) { + return method.apply(binding, args); + } else { + return method; + } + } + }); + each([ + 'bind', + 'unbind', + 'on', + 'off', + 'delegate', + 'undelegate', + 'removeAttr', + 'compute', + '_get', + '__get', + 'each' + ], function (name) { + can.route[name] = function () { + if (!can.route.data[name]) { + return; + } + return can.route.data[name].apply(can.route.data, arguments); + }; + }); + can.route.attr = function (attr, val) { + var type = typeof attr, newArguments; + if (val === undefined) { + newArguments = arguments; + } else if (type !== 'string' && type !== 'number') { + newArguments = [ + stringify(attr), + val + ]; + } else { + newArguments = [ + attr, + stringify(val) + ]; + } + return can.route.data.attr.apply(can.route.data, newArguments); + }; + var setState = can.route.setState = function () { + var hash = can.route._call('matchingPartOfURL'); + var oldParams = curParams; + curParams = can.route.deparam(hash); + if (!changingData || hash !== lastHash) { + can.batch.start(); + recursiveClean(oldParams, curParams, can.route.data); + can.route.attr(curParams); + can.batch.trigger(eventsObject, '__url', [ + hash, + lastHash + ]); + can.batch.stop(); + } + }; + var recursiveClean = function (old, cur, data) { + for (var attr in old) { + if (cur[attr] === undefined) { + data.removeAttr(attr); + } else if (Object.prototype.toString.call(old[attr]) === '[object Object]') { + recursiveClean(old[attr], cur[attr], data.attr(attr)); + } + } + }; + return can.route; +}); +/*can@2.2.6#control/route/route*/ +define('can/control/route/route', [ + 'can/util/util', + 'can/route/route', + 'can/control/control' +], function (can) { + can.Control.processors.route = function (el, event, selector, funcName, controller) { + selector = selector || ''; + if (!can.route.routes[selector]) { + if (selector[0] === '/') { + selector = selector.substring(1); + } + can.route(selector); + } + var batchNum, check = function (ev, attr, how) { + if (can.route.attr('route') === selector && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + batchNum = ev.batchNum; + var d = can.route.attr(); + delete d.route; + if (can.isFunction(controller[funcName])) { + controller[funcName](d); + } else { + controller[controller[funcName]](d); + } + } + }; + can.route.bind('change', check); + return function () { + can.route.unbind('change', check); + }; + }; + return can; +}); +/*[global-shim-end]*/ +(function (){ + window._define = window.define; + window.define = window.define.orig; +})(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.zepto.min.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.zepto.min.js new file mode 100644 index 0000000000..ed935027bf --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/can.zepto.min.js @@ -0,0 +1,96 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*[global-shim-start]*/ +!function(exports,global){var origDefine=global.define,get=function(e){var o,l=e.split("."),n=global;for(o=0;o=0&&(e.defaultChecked=!0)):l?(i=a,e[l]!==a&&(e[l]=a),"value"===l&&t.inArray(o,r.defaultValue)>=0&&(e.defaultValue=a)):(e.setAttribute(n,a),i=a),r.MutationObserver||i===u||r.trigger(e,n,u)},trigger:function(r,n,a){return t.data(t.$(r),"canHasAttributesBindings")?(n=n.toLowerCase(),e(function(){t.trigger(r,{type:"attributes",attributeName:n,target:r,oldValue:a,bubbles:!1},[])})):void 0},get:function(t,e){e=e.toLowerCase();var n=r.map[e];return"string"==typeof n&&t[n]?t[n]:t.getAttribute(e)},remove:function(t,e){e=e.toLowerCase();var n;r.MutationObserver||(n=r.get(t,e));var a=r.map[e];"function"==typeof a&&a(t,void 0),a===!0?t[e]=!1:"string"==typeof a?t[a]="":t.removeAttribute(e),r.MutationObserver||null==n||r.trigger(t,e,n)},has:function(){var e=t.global.document&&document.createElement("div");return e&&e.hasAttribute?function(t,e){return t.hasAttribute(e)}:function(t,e){return null!==t.getAttribute(e)}}()};return r}); +/*can@2.2.6#event/event*/ +define("can/event/event",["can/util/can"],function(t){return t.addEvent=function(t,n){var e=this.__bindEvents||(this.__bindEvents={}),i=e[t]||(e[t]=[]);return i.push({handler:n,name:t}),this},t.listenTo=function(n,e,i){var r=this.__listenToEvents;r||(r=this.__listenToEvents={});var s=t.cid(n),o=r[s];o||(o=r[s]={obj:n,events:{}});var a=o.events[e];a||(a=o.events[e]=[]),a.push(i),t.bind.call(n,e,i)},t.stopListening=function(n,e,i){var r=this.__listenToEvents,s=r,o=0;if(!r)return this;if(n){var a=t.cid(n);if((s={})[a]=r[a],!r[a])return this}for(var v in s){var l,h=s[v];n=r[v].obj,e?(l={})[e]=h.events[e]:l=h.events;for(var u in l){var d=l[u]||[];for(o=0;oo;o++)r[o].handler.apply(this,s);return t}},t.one=function(n,e){var i=function(){return t.unbind.call(this,n,i),e.apply(this,arguments)};return t.bind.call(this,n,i),this},t.event={on:function(){return 0===arguments.length&&t.Control&&this instanceof t.Control?t.Control.prototype.on.call(this):t.addEvent.apply(this,arguments)},off:function(){return 0===arguments.length&&t.Control&&this instanceof t.Control?t.Control.prototype.off.call(this):t.removeEvent.apply(this,arguments)},bind:t.addEvent,unbind:t.removeEvent,delegate:function(n,e,i){return t.addEvent.call(this,e,i)},undelegate:function(n,e,i){return t.removeEvent.call(this,e,i)},trigger:t.dispatch,one:t.one,addEvent:t.addEvent,removeEvent:t.removeEvent,listenTo:t.listenTo,stopListening:t.stopListening,dispatch:t.dispatch},t.event}); +/*can@2.2.6#util/object/isplain/isplain*/ +define("can/util/object/isplain/isplain",["can/util/can"],function(){var t=Object.prototype.hasOwnProperty,n=function(t){return null!==t&&t==t.window},r=function(r){if(!r||"object"!=typeof r||r.nodeType||n(r))return!1;try{if(r.constructor&&!t.call(r,"constructor")&&!t.call(r.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var o;for(o in r);return void 0===o||t.call(r,o)};return can.isPlainObject=r,can}); +/*can@2.2.6#util/fragment*/ +define("can/util/fragment",["can/util/can"],function(e){var t=/^\s*<(\w+)[^>]*>/,n={}.toString,i=function(e,i){void 0===i&&(i=t.test(e)&&RegExp.$1),e&&"[object Function]"===n.call(e.replace)&&(e=e.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,"<$1>"));var l=document.createElement("div"),d=document.createElement("div");"tbody"===i||"tfoot"===i||"thead"===i?(d.innerHTML=""+e+"
            ",l=3===d.firstChild.nodeType?d.lastChild:d.firstChild):"tr"===i?(d.innerHTML=""+e+"
            ",l=3===d.firstChild.nodeType?d.lastChild:d.firstChild.firstChild):"td"===i||"th"===i?(d.innerHTML=""+e+"
            ",l=3===d.firstChild.nodeType?d.lastChild:d.firstChild.firstChild.firstChild):"option"===i?(d.innerHTML="",l=3===d.firstChild.nodeType?d.lastChild:d.firstChild):l.innerHTML=""+e;var r={},a=l.childNodes;r.length=a.length;for(var o=0;od;d++)l.appendChild(n[d]);return l},function(){var t="<-\n>",n=e.buildFragment(t,document);if(t!==n.childNodes[0].nodeValue){var i=e.buildFragment;e.buildFragment=function(e,t){var n=i(e,t);return 1===n.childNodes.length&&3===n.childNodes[0].nodeType&&(n.childNodes[0].nodeValue=e),n}}}(),e}); +/*can@2.2.6#util/deferred*/ +define("can/util/deferred",["can/util/can"],function(t){var e=function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},n=function(t){return this instanceof n?(this._doneFuncs=[],this._failFuncs=[],this._resultArgs=null,this._status="",void(t&&t.call(this,this))):new n};t.Deferred=n,t.when=n.when=function(){var e=t.makeArray(arguments);if(e.length<2){var r=e[0];return r&&t.isFunction(r.isResolved)&&t.isFunction(r.isRejected)?r:n().resolve(r)}var s=n(),i=0,u=[];return t.each(e,function(t,n){t.done(function(){u[n]=arguments.length<2?arguments[0]:arguments,++i===e.length&&s.resolve.apply(s,u)}).fail(function(){s.reject(1===arguments.length?arguments[0]:arguments)})}),s};var r=function(t,e){return function(n){var r=this._resultArgs=arguments.length>1?arguments[1]:[];return this.exec(n,this[t],r,e)}},s=function a(e,n){return function(){var r=this;return t.each(Array.prototype.slice.call(arguments),function(t,s,i){t&&(t.constructor===Array?a.apply(r,t):(r._status===n&&t.apply(r,r._resultArgs||[]),r[e].push(t)))}),this}},i=function(t){return t&&t.then&&t.fail&&t.done},u=function(e,n,r,s){i(n)?n.done(t.proxy(e.resolve,e)).fail(t.proxy(e.reject,e)):r.call(e,void 0!==n?n:s)};return e(n.prototype,{then:function(e,n){var r=t.Deferred(),s=r.resolve,i=r.reject;return this.done(function(t){"function"==typeof e?u(r,e.apply(this,arguments),s,t):s.apply(r,arguments)}),this.fail(function(t){"function"==typeof n?u(r,n.apply(this,arguments),i,t):i.apply(r,arguments)}),r},resolveWith:r("_doneFuncs","rs"),rejectWith:r("_failFuncs","rj"),done:s("_doneFuncs","rs"),fail:s("_failFuncs","rj"),always:function(){var e=t.makeArray(arguments);return e.length&&e[0]&&this.done(e[0]).fail(e[0]),this},state:function(){switch(this._status){case"rs":return"resolved";case"rj":return"rejected";default:return"pending"}},isResolved:function(){return"rs"===this._status},isRejected:function(){return"rj"===this._status},reject:function(){return this.rejectWith(this,arguments)},resolve:function(){return this.resolveWith(this,arguments)},exec:function(e,n,r,s){return""!==this._status?this:(this._status=s,t.each(n,function(t){"function"==typeof t.apply&&t.apply(e,r)}),this)},promise:function(){var t=this.then();return t.reject=t.resolve=void 0,t}}),n.prototype.pipe=n.prototype.then,t}); +/*can@2.2.6#util/array/each*/ +define("can/util/array/each",["can/util/can"],function(t){var e=function(t){var e="length"in t&&t.length;return"function"!=typeof arr&&(0===e||"number"==typeof e&&e>0&&e-1 in t)};return t.each=function(n,a,r){var f,i,l,c=0;if(n)if(e(n))if(t.List&&n instanceof t.List)for(i=n.attr("length");i>c&&(l=n.attr(c),a.call(r||l,l,c,n)!==!1);c++);else for(i=n.length;i>c&&(l=n[c],a.call(r||l,l,c,n)!==!1);c++);else if("object"==typeof n)if(t.Map&&n instanceof t.Map||n===t.route){var o=t.Map.keys(n);for(c=0,i=o.length;i>c&&(f=o[c],l=n.attr(f),a.call(r||l,l,f,n)!==!1);c++);}else for(f in n)if(n.hasOwnProperty(f)&&a.call(r||n[f],n[f],f,n)===!1)break;return n},t}); +/*can@2.2.6#util/inserted/inserted*/ +define("can/util/inserted/inserted",["can/util/can"],function(e){e.inserted=function(n){n=e.makeArray(n);for(var r,i,t=!1,a=e.$(document.contains?document:document.body),d=0;void 0!==(i=n[d]);d++){if(!t){if(!i.getElementsByTagName)continue;if(!e.has(a,i).length)return;t=!0}if(t&&i.getElementsByTagName){r=e.makeArray(i.getElementsByTagName("*")),e.trigger(i,"inserted",[],!1);for(var o,s=0;void 0!==(o=r[s]);s++)e.trigger(o,"inserted",[],!1)}}},e.appendChild=function(n,r){var i;i=11===r.nodeType?e.makeArray(r.childNodes):[r],n.appendChild(r),e.inserted(i)},e.insertBefore=function(n,r,i){var t;t=11===r.nodeType?e.makeArray(r.childNodes):[r],n.insertBefore(r,i),e.inserted(t)}}); +/*can@2.2.6#util/util*/ +define("can/util/util",["can/util/can","can/util/attr/attr","can/event/event","can/zepto/zepto","can/util/object/isplain/isplain","can/util/fragment","can/util/deferred","can/util/array/each","can/util/inserted/inserted"],function(t,n,e){function a(t,n){var e=t[o],a=e&&s[e];return void 0===n?a||i(t):a&&a[n]||u.call(r(t),n)}function i(t,n,e){var a=t[o]||(t[o]=++c),i=s[a]||(s[a]={});return void 0!==n&&(i[n]=e),i}var r=Zepto,s={},u=r.fn.data,c=r.uuid=+new Date,o=r.expando="Zepto"+c;r.fn.data=function(t,n){return void 0===n?0===this.length?void 0:a(this[0],t):this.each(function(e){i(this,t,r.isFunction(n)?n.call(this,e,a(this,t)):n)})},r.cleanData=function(n){for(var e,a=0;void 0!==(e=n[a]);a++)t.trigger(e,"removed",[],!1);for(a=0;void 0!==(e=n[a]);a++){var i=e[o];delete s[i]}};var d=t.each,l=t.isPlainObject;r.extend(t,Zepto),t.inArray=function(t,n){return n?r.inArray.apply(r,arguments):-1},t.isPlainObject=l,t.each=d,t.attr=n,t.event=e;var f=function(t,n){return t[0]&&t[0][n]||t[n]};t.trigger=function(n,e,a,i){n.trigger?n.trigger(e,a):f(n,"dispatchEvent")?i===!1?r([n]).triggerHandler(e,a):r([n]).trigger(e,a):("string"==typeof e&&(e={type:e}),e.target=e.target||n,t.dispatch.call(n,e,t.makeArray(a)))},t.$=Zepto,t.bind=function(n,e){return this.bind&&this.bind!==t.bind?this.bind(n,e):f(this,"addEventListener")?r([this]).bind(n,e):t.addEvent.call(this,n,e),this},t.unbind=function(n,e){return this.unbind&&this.unbind!==t.unbind?this.unbind(n,e):f(this,"addEventListener")?r([this]).unbind(n,e):t.removeEvent.call(this,n,e),this},t.on=t.bind,t.off=t.unbind,t.delegate=function(n,e,a){n?this.delegate?this.delegate(n,e,a):f(this,"addEventListener")?r([this]).delegate(n,e,a):t.addEvent.call(this,e,a):t.bind.call(this,e,a)},t.undelegate=function(n,e,a){n?this.undelegate?this.undelegate(n,e,a):f(this,"addEventListener")?r([this]).undelegate(n,e,a):t.removeEvent.call(this,e,a):t.unbind.call(this,e,a)},r.each(["append","filter","addClass","remove","data","has"],function(n,e){t[e]=function(n){return n[e].apply(n,t.makeArray(arguments).slice(1))}}),t.makeArray=function(n){var e=[];return null==n?[]:void 0===n.length||"string"==typeof n?[n]:(t.each(n,function(t,n){e[n]=t}),e)};var h=r.ajaxSettings.xhr;r.ajaxSettings.xhr=function(){var t=h(),n=t.open;return t.open=function(t,e,a){n.call(this,t,e,void 0===v?!0:v)},t};var v,g=r.ajax,p=function(t,n){for(var e in t)"function"==typeof n[e]?n[e]=function(){t[e].apply(t,arguments)}:n[e]=e[t]};t.ajax=function(n){var e=n.success,a=n.error,i=t.Deferred();n.success=function(t){p(r,i),i.resolve.call(i,t),e&&e.apply(this,arguments)},n.error=function(){p(r,i),i.reject.apply(i,arguments),a&&a.apply(this,arguments)},n.async===!1&&(v=!1);var r=g(n);return v=void 0,p(r,i),i};var m=r.fn.empty;r.fn.empty=function(){return this.each(function(){r.cleanData(this.getElementsByTagName("*")),this.innerHTML=""}),m.call(this)};var y=r.fn.remove;r.fn.remove=function(){return this.each(function(){this.getElementsByTagName&&r.cleanData([this].concat(t.makeArray(this.getElementsByTagName("*"))))}),y.call(this)},t.trim=function(t){return t.trim()},t.isEmptyObject=function(t){var n;for(n in t);return void 0===n},t.extend=function(n){if(n===!0){var e=t.makeArray(arguments);return e.shift(),r.extend.apply(r,e)}return r.extend.apply(r,arguments)},t.get=function(t,n){return t[n]},t.each(["after","prepend","before","append"],function(n){var e=Zepto.fn[n];Zepto.fn[n]=function(){var n,a=t.makeArray(arguments);null!=a[0]&&("string"==typeof a[0]&&(a[0]=r.zepto.fragment(a[0])),n=11===a[0].nodeType?t.makeArray(a[0].childNodes):a[0]instanceof Zepto.fn.constructor?t.makeArray(a[0]):[a[0]]);var i=e.apply(this,a);return t.inserted(n),i}}),delete n.MutationObserver;var b=r.fn.attr;r.fn.attr=function(n,e){var a,i,r="string"==typeof n;void 0!==e&&r&&(a=b.call(this,n));var s=b.apply(this,arguments);return void 0!==e&&r&&(i=b.call(this,n)),i!==a&&t.attr.trigger(this[0],n,a),s};var A=r.fn.removeAttr;r.fn.removeAttr=function(n){var e=b.call(this,n),a=A.apply(this,arguments);return null!=e&&t.attr.trigger(this[0],n,e),a};var E=r.fn.bind,x=r.fn.unbind;return r.fn.bind=function(n){return"attributes"===n&&this.each(function(){var n=t.$(this);t.data(n,"canHasAttributesBindings",(t.data(n,"canHasAttributesBindings")||0)+1)}),E.apply(this,arguments)},r.fn.unbind=function(n){return"attributes"===n&&this.each(function(){var n=t.$(this),e=t.data(n,"canHasAttributesBindings")||0;0>=e?t.data(n,"canHasAttributesBindings",0):t.data(n,"canHasAttributesBindings",e-1)}),x.apply(this,arguments)},t}); +/*can@2.2.6#view/view*/ +define("can/view/view",["can/util/util"],function(e){var r=e.isFunction,n=e.makeArray,t=1,i=function(e){var r=function(){return c.frag(e.apply(this,arguments))};return r.render=function(){return e.apply(e,arguments)},r},u=function(e,r){if(!e.length)throw"can.view: No template or empty template:"+r},a=function(n,t){if(r(n)){var i=e.Deferred();return i.resolve(n)}var a,o,d,f="string"==typeof n?n:n.url,s=n.engine&&"."+n.engine||f.match(/\.[\w\d]+$/);if(f.match(/^#/)&&(f=f.substr(1)),(o=document.getElementById(f))&&(s="."+o.type.match(/\/(x\-)?(.+)/)[2]),s||c.cached[f]||(f+=s=c.ext),e.isArray(s)&&(s=s[0]),d=c.toId(f),f.match(/^\/\//)&&(f=f.substr(2),f=window.steal?steal.config().root.mapJoin(""+steal.id(f)):f),window.require&&require.toUrl&&(f=require.toUrl(f)),a=c.types[s],c.cached[d])return c.cached[d];if(o)return c.registerView(d,o.innerHTML,a);var p=new e.Deferred;return e.ajax({async:t,url:f,dataType:"text",error:function(e){u("",f),p.reject(e)},success:function(e){u(e,f),c.registerView(d,e,a,p)}}),p},o=function(r){var n=[];if(e.isDeferred(r))return[r];for(var t in r)e.isDeferred(r[t])&&n.push(r[t]);return n},d=function(r){return e.isArray(r)&&"success"===r[1]?r[0]:r},c=e.view=e.template=function(e,n,t,i){return r(t)&&(i=t,t=void 0),c.renderAs("fragment",e,n,t,i)};return e.extend(c,{frag:function(e,r){return c.hookup(c.fragment(e),r)},fragment:function(r){if("string"!=typeof r&&11===r.nodeType)return r;var n=e.buildFragment(r,document.body);return n.childNodes.length||n.appendChild(document.createTextNode("")),n},toId:function(r){return e.map(r.toString().split(/\/|\./g),function(e){return e?e:void 0}).join("_")},toStr:function(e){return null==e?"":""+e},hookup:function(r,n){var t,i,u=[];return e.each(r.childNodes?e.makeArray(r.childNodes):r,function(r){1===r.nodeType&&(u.push(r),u.push.apply(u,e.makeArray(r.getElementsByTagName("*"))))}),e.each(u,function(e){e.getAttribute&&(t=e.getAttribute("data-view-id"))&&(i=c.hookups[t])&&(i(e,n,t),delete c.hookups[t],e.removeAttribute("data-view-id"))}),r},hookups:{},hook:function(e){return c.hookups[++t]=e," data-view-id='"+t+"'"},cached:{},cachedRenderers:{},cache:!0,register:function(r){this.types["."+r.suffix]=r,e[r.suffix]=c[r.suffix]=function(e,n){var t,u;if(!n)return u=function(){return t||(t=r.fragRenderer?r.fragRenderer(null,e):i(r.renderer(null,e))),t.apply(this,arguments)},u.render=function(){var n=r.renderer(null,e);return n.apply(n,arguments)},u;var a=function(){return t||(t=r.fragRenderer?r.fragRenderer(e,n):r.renderer(e,n)),t.apply(this,arguments)};return r.fragRenderer?c.preload(e,a):c.preloadStringRenderer(e,a)}},types:{},ext:".ejs",registerScript:function(e,r,n){return"can.view.preloadStringRenderer('"+r+"',"+c.types["."+e].script(r,n)+");"},preload:function(r,n){var t=c.cached[r]=(new e.Deferred).resolve(function(e,r){return n.call(e,e,r)});return t.__view_id=r,c.cachedRenderers[r]=n,n},preloadStringRenderer:function(e,r){return this.preload(e,i(r))},render:function(r,n,t,i){return e.view.renderAs("string",r,n,t,i)},renderTo:function(e,r,n,t){return("string"===e&&r.render?r.render:r)(n,t)},renderAs:function(t,i,u,f,s){r(f)&&(s=f,f=void 0);var p,l,g,h,v,m=o(u);if(m.length)return l=new e.Deferred,g=e.extend({},u),m.push(a(i,!0)),e.when.apply(e,m).then(function(r){var i,a=n(arguments),o=a.pop();if(e.isDeferred(u))g=d(r);else for(var c in u)e.isDeferred(u[c])&&(g[c]=d(a.shift()));i=e.view.renderTo(t,o,g,f),l.resolve(i,g),s&&s(i,g)},function(){l.reject.apply(l,arguments)}),l;if(p=e.__clearReading(),h=r(s),l=a(i,h),p&&e.__setReading(p),h)v=l,l.then(function(r){s(u?e.view.renderTo(t,r,u,f):r)});else{if("resolved"===l.state()&&l.__view_id){var w=c.cachedRenderers[l.__view_id];return u?e.view.renderTo(t,w,u,f):w}l.then(function(r){v=u?e.view.renderTo(t,r,u,f):r})}return v},registerView:function(r,n,t,u){var a,o="object"==typeof t?t:c.types[t||c.ext];return a=o.fragRenderer?o.fragRenderer(r,n):i(o.renderer(r,n)),u=u||new e.Deferred,c.cache&&(c.cached[r]=u,u.__view_id=r,c.cachedRenderers[r]=a),u.resolve(a)}}),e}); +/*can@2.2.6#view/callbacks/callbacks*/ +define("can/view/callbacks/callbacks",["can/util/util","can/view/view"],function(t){var a=t.view.attr=function(t,a){if(!a){var r=e[t];if(!r)for(var n=0,l=i.length;l>n;n++){var s=i[n];if(s.match.test(t)){r=s.handler;break}}return r}"string"==typeof t?e[t]=a:i.push({match:t,handler:a})},e={},i=[],r=/[-\:]/,n=t.view.tag=function(a,e){if(!e){var i=l[a.toLowerCase()];return!i&&r.test(a)&&(i=function(){}),i}t.global.html5&&(t.global.html5.elements+=" "+a,t.global.html5.shivDocument()),l[a.toLowerCase()]=e},l={};return t.view.callbacks={_tags:l,_attributes:e,_regExpAttributes:i,tag:n,attr:a,tagHandler:function(a,e,i){var r,n=i.options.attr("tags."+e),s=n||l[e],c=i.scope;if(s){var o=t.__clearReading();r=s(a,i),t.__setReading(o)}else r=c;if(r&&i.subtemplate){c!==r&&(c=c.add(r));var v=i.subtemplate(c,i.options),f="string"==typeof v?t.view.frag(v):v;t.appendChild(a,f)}}},t.view.callbacks}); +/*can@2.2.6#view/elements*/ +define("can/view/elements",["can/util/util","can/view/view"],function(t){var e="undefined"!=typeof document?document:null,n=e&&function(){return 1===t.$(document.createComment("~")).length}(),o={tagToContentPropMap:{option:e&&"textContent"in document.createElement("option")?"textContent":"innerText",textarea:"value"},attrMap:t.attr.map,attrReg:/([^\s=]+)[\s]*=[\s]*/,defaultValue:t.attr.defaultValue,tagMap:{"":"span",colgroup:"col",table:"tbody",tr:"td",ol:"li",ul:"li",tbody:"tr",thead:"tr",tfoot:"tr",select:"option",optgroup:"option"},reverseTagMap:{col:"colgroup",tr:"tbody",option:"select",td:"tr",th:"tr",li:"ul"},getParentNode:function(t,e){return e&&11===t.parentNode.nodeType?e:t.parentNode},setAttr:t.attr.set,getAttr:t.attr.get,removeAttr:t.attr.remove,contentText:function(t){return"string"==typeof t?t:t||0===t?""+t:""},after:function(e,n){var o=e[e.length-1];o.nextSibling?t.insertBefore(o.parentNode,n,o.nextSibling):t.appendChild(o.parentNode,n)},replace:function(e,r){o.after(e,r),t.remove(t.$(e)).length/g,">").replace(c,""").replace(o,"'")},getObject:function(r,n,t){var a,u,i,c,o=r?r.split("."):[],l=o.length,p=0;if(n=e.isArray(n)?n:[n||window],c=n.length,!l)return n[0];for(p;c>p;p++){for(a=n[p],i=void 0,u=0;l>u&&g(a);u++)i=a,a=f(i,o[u]);if(void 0!==i&&void 0!==a)break}if(t===!1&&void 0!==a&&delete i[o[u-1]],t===!0&&void 0===a)for(a=n[0],u=0;l>u&&g(a);u++)a=f(a,o[u],!0);return a},capitalize:function(e,r){return e.charAt(0).toUpperCase()+e.slice(1)},camelize:function(e){return d(e).replace(l,function(e,r){return r?r.toUpperCase():""})},hyphenate:function(e){return d(e).replace(p,function(e,r){return e.charAt(0)+"-"+e.charAt(1).toLowerCase()})},underscore:function(e){return e.replace(n,"/").replace(t,"$1_$2").replace(a,"$1_$2").replace(u,"_").toLowerCase()},sub:function(r,n,t){var a=[];return r=r||"",a.push(r.replace(i,function(r,u){var i=e.getObject(u,n,t===!0?!1:void 0);return void 0===i||null===i?(a=null,""):g(i)&&a?(a.push(i),""):""+i})),null===a?a:a.length<=1?a[0]:a},replacer:i,undHash:r}),e}); +/*can@2.2.6#construct/construct*/ +define("can/construct/construct",["can/util/string/string"],function(t){var n,r=0;try{Object.getOwnPropertyDescriptor({}),n=!0}catch(e){n=!1}var o=function(t,n){var r=Object.getOwnPropertyDescriptor(t,n);return r&&(r.get||r.set)?r:null},u=function(n,r,e){e=e||n;var u;for(var i in n)(u=o(n,i))?this._defineProperty(e,r,i,u):t.Construct._overwrite(e,r,i,n[i])},i=function(n,r,e){e=e||n;for(var o in n)t.Construct._overwrite(e,r,o,n[o])};return t.Construct=function(){return arguments.length?t.Construct.extend.apply(t.Construct,arguments):void 0},t.extend(t.Construct,{constructorExtends:!0,newInstance:function(){var t,n=this.instance();return n.setup&&(t=n.setup.apply(n,arguments)),n.init&&n.init.apply(n,t||arguments),n},_inherit:n?u:i,_defineProperty:function(t,n,r,e){Object.defineProperty(t,r,e)},_overwrite:function(t,n,r,e){t[r]=e},setup:function(n,r){this.defaults=t.extend(!0,{},n.defaults,this.defaults)},instance:function(){r=1;var t=new this;return r=0,t},extend:function(n,e,o){function u(){return r?void 0:this.constructor!==a&&arguments.length&&a.constructorExtends?a.extend.apply(a,arguments):a.newInstance.apply(a,arguments)}var i=n,s=e,c=o;"string"!=typeof i&&(c=s,s=i,i=null),c||(c=s,s=null),c=c||{};var a,p,f,l,d,y,g,h,v,m=this,w=this.prototype;v=this.instance(),t.Construct._inherit(c,w,v),i&&(p=i.split("."),g=p.pop()),"undefined"==typeof constructorName&&(a=function(){return u.apply(this,arguments)});for(y in m)m.hasOwnProperty(y)&&(a[y]=m[y]);t.Construct._inherit(s,m,a),i&&(f=t.getObject(p.join("."),window,!0),h=f,l=t.underscore(i.replace(/\./g,"_")),d=t.underscore(g),f[g]=a),t.extend(a,{constructor:a,prototype:v,namespace:h,_shortName:d,fullName:i,_fullName:l}),void 0!==g&&(a.shortName=g),a.prototype.constructor=a;var C=[m].concat(t.makeArray(arguments)),_=a.setup.apply(a,C);return a.init&&a.init.apply(a,_||C),a}}),t.Construct.prototype.setup=function(){},t.Construct.prototype.init=function(){},t.Construct}); +/*can@2.2.6#control/control*/ +define("can/control/control",["can/util/util","can/construct/construct"],function(t){var n,e=function(n,e,o){return t.bind.call(n,e,o),function(){t.unbind.call(n,e,o)}},o=t.isFunction,s=t.extend,i=t.each,r=[].slice,u=/\{([^\}]+)\}/g,c=t.getObject("$.event.special",[t])||{},l=function(n,e,o,s){return t.delegate.call(n,e,o,s),function(){t.undelegate.call(n,e,o,s)}},a=function(n,o,s,i){return i?l(n,t.trim(i),o,s):e(n,o,s)},h=t.Control=t.Construct({setup:function(){if(t.Construct.setup.apply(this,arguments),t.Control){var n,e=this;e.actions={};for(n in e.prototype)e._isAction(n)&&(e.actions[n]=e._action(n))}},_shifter:function(n,e){var s="string"==typeof e?n[e]:e;return o(s)||(s=n[s]),function(){return n.called=e,s.apply(n,[this.nodeName?t.$(this):this].concat(r.call(arguments,0)))}},_isAction:function(t){var n=this.prototype[t],e=typeof n;return"constructor"!==t&&("function"===e||"string"===e&&o(this.prototype[n]))&&!!(c[t]||f[t]||/[^\w]/.test(t))},_action:function(e,o){if(u.lastIndex=0,o||!u.test(e)){var s=o?t.sub(e,this._lookup(o)):e;if(!s)return null;var i=t.isArray(s),r=i?s[1]:s,c=r.split(/\s+/g),l=c.pop();return{processor:f[l]||n,parts:[r,c.join(" "),l],delegate:i?s[0]:void 0}}},_lookup:function(t){return[t,window]},processors:{},defaults:{}},{setup:function(n,e){var o,i=this.constructor,r=i.pluginName||i._fullName;return this.element=t.$(n),r&&"can_control"!==r&&this.element.addClass(r),o=t.data(this.element,"controls"),o||(o=[],t.data(this.element,"controls",o)),o.push(this),this.options=s({},i.defaults,e),this.on(),[this.element,this.options]},on:function(n,e,o,s){if(!n){this.off();var i,r,u=this.constructor,c=this._bindings,l=u.actions,h=this.element,f=t.Control._shifter(this,"destroy");for(i in l)l.hasOwnProperty(i)&&(r=l[i]||u._action(i,this.options,this),r&&(c.control[i]=r.processor(r.delegate||h,r.parts[2],r.parts[1],i,this)));return t.bind.call(h,"removed",f),c.user.push(function(n){t.unbind.call(n,"removed",f)}),c.user.length}return"string"==typeof n&&(s=o,o=e,e=n,n=this.element),void 0===s&&(s=o,o=e,e=null),"string"==typeof s&&(s=t.Control._shifter(this,s)),this._bindings.user.push(a(n,o,s,e)),this._bindings.user.length},off:function(){var t=this.element[0],n=this._bindings;n&&(i(n.user||[],function(n){n(t)}),i(n.control||{},function(n){n(t)})),this._bindings={user:[],control:{}}},destroy:function(){if(null!==this.element){var n,e=this.constructor,o=e.pluginName||e._fullName;this.off(),o&&"can_control"!==o&&this.element.removeClass(o),n=t.data(this.element,"controls"),n.splice(t.inArray(this,n),1),t.trigger(this,"destroyed"),this.element=null}}}),f=t.Control.processors;return n=function(n,e,o,s,i){return a(n,e,t.Control._shifter(i,s),o)},i(["change","click","contextmenu","dblclick","keydown","keyup","keypress","mousedown","mousemove","mouseout","mouseover","mouseup","reset","resize","scroll","select","submit","focusin","focusout","mouseenter","mouseleave","touchstart","touchmove","touchcancel","touchend","touchleave","inserted","removed"],function(t){f[t]=n}),h}); +/*can@2.2.6#util/bind/bind*/ +define("can/util/bind/bind",["can/util/util"],function(i){return i.bindAndSetup=function(){return i.addEvent.apply(this,arguments),this._init||(this._bindings?this._bindings++:(this._bindings=1,this._bindsetup&&this._bindsetup())),this},i.unbindAndTeardown=function(n,t){var s=this.__bindEvents[n]||[],d=s.length;return i.removeEvent.apply(this,arguments),null===this._bindings?this._bindings=0:this._bindings=this._bindings-(d-s.length),!this._bindings&&this._bindteardown&&this._bindteardown(),this},i}); +/*can@2.2.6#map/bubble*/ +define("can/map/bubble",["can/util/util"],function(n){var e=n.bubble={event:function(n,e){return n.constructor._bubbleRule(e,n)},childrenOf:function(n,i){n._each(function(b,r){b&&b.bind&&e.toParent(b,n,r,i)})},teardownChildrenFrom:function(n,i){n._each(function(b){e.teardownFromParent(n,b,i)})},toParent:function(e,i,b,r){n.listenTo.call(i,e,r,function(){var r=n.makeArray(arguments),t=r.shift();r[0]=(n.List&&i instanceof n.List?i.indexOf(e):b)+(r[0]?"."+r[0]:""),t.triggeredNS=t.triggeredNS||{},t.triggeredNS[i._cid]||(t.triggeredNS[i._cid]=!0,n.trigger(i,t,r))})},teardownFromParent:function(e,i,b){i&&i.unbind&&n.stopListening.call(e,i,b)},isBubbling:function(n,e){return n._bubbleBindings&&n._bubbleBindings[e]},bind:function(n,i){if(!n._init){var b,r=e.event(n,i),t=r.length;n._bubbleBindings||(n._bubbleBindings={});for(var u=0;t>u;u++)b=r[u],n._bubbleBindings[b]?n._bubbleBindings[b]++:(n._bubbleBindings[b]=1,e.childrenOf(n,b))}},unbind:function(i,b){for(var r,t=e.event(i,b),u=t.length,d=0;u>d;d++)r=t[d],i._bubbleBindings&&i._bubbleBindings[r]--,i._bubbleBindings&&!i._bubbleBindings[r]&&(delete i._bubbleBindings[r],e.teardownChildrenFrom(i,r),n.isEmptyObject(i._bubbleBindings)&&delete i._bubbleBindings)},add:function(i,b,r){if(b instanceof n.Map&&i._bubbleBindings)for(var t in i._bubbleBindings)i._bubbleBindings[t]&&(e.teardownFromParent(i,b,t),e.toParent(b,i,r,t))},removeMany:function(n,i){for(var b=0,r=i.length;r>b;b++)e.remove(n,i[b])},remove:function(i,b){if(b instanceof n.Map&&i._bubbleBindings)for(var r in i._bubbleBindings)i._bubbleBindings[r]&&e.teardownFromParent(i,b,r)},set:function(i,b,r,t){return n.Map.helpers.isObservable(r)&&e.add(i,r,b),n.Map.helpers.isObservable(t)&&e.remove(i,t),r}};return e}); +/*can@2.2.6#util/batch/batch*/ +define("can/util/batch/batch",["can/util/can"],function(t){var n=1,a=0,i=[],c=[],e=null;t.batch={start:function(t){a++,t&&c.push(t)},stop:function(l,u){if(l?a=0:a--,0===a){if(null!==e)return;e=i.slice(0);var h,r,f=c.slice(0);for(i=[],c=[],t.batch.batchNum=n,n++,u&&t.batch.start(),h=0;h=0?["change"]:[]},_computes:[],bind:t.bindAndSetup,on:t.bindAndSetup,unbind:t.unbindAndTeardown,off:t.unbindAndTeardown,id:"id",helpers:{define:null,attrParts:function(t,e){return e?[t]:"object"==typeof t?t:(""+t).split(".")},addToMap:function(e,i){var r;n||(r=s,n={});var a=e._cid,o=t.cid(e);return n[o]||(n[o]={obj:e,instance:i,added:!a}),r},isObservable:function(e){return e instanceof t.Map||e&&e===t.route},canMakeObserve:function(e){return e&&!t.isDeferred(e)&&(t.isArray(e)||t.isPlainObject(e))},serialize:function(e,i,n){var s=t.cid(e),r=!1;return a||(r=!0,a={attr:{},serialize:{}}),a[i][s]=n,e.each(function(s,r){var u,h=o.helpers.isObservable(s),c=h&&a[i][t.cid(s)];u=c?c:"serialize"===i?o.helpers._serialize(e,r,s):o.helpers._getValue(e,r,s,i),void 0!==u&&(n[r]=u)}),t.__observe(e,"__keys"),r&&(a=null),n},_serialize:function(t,e,i){return o.helpers._getValue(t,e,i,"serialize")},_getValue:function(t,e,i,n){return o.helpers.isObservable(i)?i[n]():i}},keys:function(e){var i=[];t.__observe(e,"__keys");for(var n in e._data)i.push(n);return i}},{setup:function(e){e instanceof t.Map&&(e=e.serialize()),this._data={},t.cid(this,".map"),this._init=1,this._computedBindings={};var i=this._setupDefaults(e);this._setupComputes(i);var n=e&&t.Map.helpers.addToMap(e,this),s=t.extend(t.extend(!0,{},i),e);this.attr(s),n&&n(),this.bind("change",t.proxy(this._changes,this)),delete this._init},_setupComputes:function(){for(var t,e=this.constructor._computes,i=0,n=e.length;n>i;i++)t=e[i],this[t]=this[t].clone(this),this._computedBindings[t]={count:0}},_setupDefaults:function(){return this.constructor.defaults||{}},_bindsetup:function(){},_bindteardown:function(){},_changes:function(e,i,n,s,r){t.batch.trigger(this,{type:i,batchNum:e.batchNum,target:e.target},[s,r])},_triggerChange:function(e,n,s,r){i.isBubbling(this,"change")?t.batch.trigger(this,{type:"change",target:this},[e,n,s,r]):t.batch.trigger(this,e,[s,r]),("remove"===n||"add"===n)&&t.batch.trigger(this,{type:"__keys",target:this})},_each:function(t){var e=this.__get();for(var i in e)e.hasOwnProperty(i)&&t(e[i],i)},attr:function(t,e){var i=typeof t;return"string"!==i&&"number"!==i?this._attrs(t,e):1===arguments.length?this._get(t):(this._set(t,e),this)},each:function(){return t.each.apply(void 0,[this].concat(t.makeArray(arguments)))},removeAttr:function(e){var i=t.List&&this instanceof t.List,n=t.Map.helpers.attrParts(e),s=n.shift(),r=i?this[s]:this._data[s];return n.length&&r?r.removeAttr(n):("string"==typeof e&&~e.indexOf(".")&&(s=e),this._remove(s,r),r)},_remove:function(t,e){t in this._data&&(delete this._data[t],t in this.constructor.prototype||delete this[t],this._triggerChange(t,"remove",void 0,e))},_get:function(e){e=""+e;var i=e.indexOf(".");if(i>=0){var n=this.__get(e);if(void 0!==n)return n;var s=e.substr(0,i),r=e.substr(i+1);t.__observe(this,s);var a=this.__get(s);return a&&a._get?a._get(r):void 0}return t.__observe(this,e),this.__get(e)},__get:function(t){return t?this._computedBindings[t]?this[t]():this._data[t]:this._data},__type:function(e,i){if(!(e instanceof t.Map)&&t.Map.helpers.canMakeObserve(e)){var n=r(e);if(n)return n;if(t.isArray(e)){var s=t.List;return new s(e)}var a=this.constructor.Map||t.Map;return new a(e)}return e},_set:function(t,e,i){t=""+t;var n,s=t.indexOf(".");if(!i&&s>=0){var r=t.substr(0,s),a=t.substr(s+1);if(n=this._init?void 0:this.__get(r),!o.helpers.isObservable(n))throw"can.Map: Object does not exist";n._set(a,e)}else this.__convert&&(e=this.__convert(t,e)),n=this._init?void 0:this.__get(t),this.__set(t,this.__type(e,t),n)},__set:function(t,e,i){if(e!==i){var n=void 0!==i||this.__get().hasOwnProperty(t)?"set":"add";this.___set(t,this.constructor._bubble.set(this,t,e,i)),this._computedBindings[t]||this._triggerChange(t,n,e,i),i&&this.constructor._bubble.teardownFromParent(this,i)}},___set:function(t,e){this._computedBindings[t]?this[t](e):this._data[t]=e,"function"==typeof this.constructor.prototype[t]||this._computedBindings[t]||(this[t]=e)},bind:function(e,i){var n=this._computedBindings&&this._computedBindings[e];if(n)if(n.count)n.count++;else{n.count=1;var s=this;n.handler=function(i,n,r){t.batch.trigger(s,{type:e,batchNum:i.batchNum,target:s},[n,r])},this[e].bind("change",n.handler)}return this.constructor._bubble.bind(this,e),t.bindAndSetup.apply(this,arguments)},unbind:function(e,i){var n=this._computedBindings&&this._computedBindings[e];return n&&(1===n.count?(n.count=0,this[e].unbind("change",n.handler),delete n.handler):n.count--),this.constructor._bubble.unbind(this,e),t.unbindAndTeardown.apply(this,arguments)},serialize:function(){return t.Map.helpers.serialize(this,"serialize",{})},_attrs:function(e,i){if(void 0===e)return o.helpers.serialize(this,"attr",{});e=t.simpleExtend({},e);var n,s,r=this;t.batch.start(),this.each(function(t,n){if("_cid"!==n){if(s=e[n],void 0===s)return void(i&&r.removeAttr(n));r.__convert&&(s=r.__convert(n,s)),o.helpers.isObservable(s)?r.__set(n,r.__type(s,n),t):o.helpers.isObservable(t)&&o.helpers.canMakeObserve(s)?t.attr(s,i):t!==s&&r.__set(n,r.__type(s,n),t),delete e[n]}});for(n in e)"_cid"!==n&&(s=e[n],this._set(n,s,!0));return t.batch.stop(),this},compute:function(e){if(t.isFunction(this.constructor.prototype[e]))return t.compute(this[e],this);var i=e.split("."),n=i.length-1,s={args:[]};return t.compute(function(e){return arguments.length?void t.compute.read(this,i.slice(0,n)).value.attr(i[n],e):t.compute.read(this,i,s).value},this)}});return o.prototype.on=o.prototype.bind,o.prototype.off=o.prototype.unbind,o}); +/*can@2.2.6#list/list*/ +define("can/list/list",["can/util/util","can/map/map","can/map/bubble"],function(t,e,i){var r=[].splice,h=function(){var t={0:"a",length:1};return r.call(t,0,1),!t[0]}(),n=e.extend({Map:e},{setup:function(e,i){this.length=0,t.cid(this,".map"),this._init=1,this._computedBindings={},this._setupComputes(),e=e||[];var r;t.isDeferred(e)?this.replace(e):(r=e.length&&t.Map.helpers.addToMap(e,this),this.push.apply(this,t.makeArray(e||[]))),r&&r(),this.bind("change",t.proxy(this._changes,this)),t.simpleExtend(this,i),delete this._init},_triggerChange:function(i,r,h,n){e.prototype._triggerChange.apply(this,arguments);var s=+i;~(""+i).indexOf(".")||isNaN(s)||("add"===r?(t.batch.trigger(this,r,[h,s]),t.batch.trigger(this,"length",[this.length])):"remove"===r?(t.batch.trigger(this,r,[n,s]),t.batch.trigger(this,"length",[this.length])):t.batch.trigger(this,r,[h,s]))},__get:function(e){return e?this[e]&&this[e].isComputed&&t.isFunction(this.constructor.prototype[e])?this[e]():this[e]:this},__set:function(e,i,r){if(e=isNaN(+e)||e%1?e:+e,"number"==typeof e&&e>this.length-1){var h=new Array(e+1-this.length);return h[h.length-1]=i,this.push.apply(this,h),h}return t.Map.prototype.__set.call(this,""+e,i,r)},___set:function(t,e){this[t]=e,+t>=this.length&&(this.length=+t+1)},_remove:function(t,e){isNaN(+t)?(delete this[t],this._triggerChange(t,"remove",void 0,e)):this.splice(t,1)},_each:function(t){for(var e=this.__get(),i=0;i2;for(e=e||0,s=0,a=o.length-2;a>s;s++)l=s+2,o[l]=this.__type(o[l],l),g.push(o[l]),this[s+e]!==o[l]&&(c=!1);if(c&&this.length<=g.length)return g;void 0===n&&(n=o[1]=this.length-e);var p=r.apply(this,o);if(!h)for(s=this.length;s0&&(i.removeMany(this,p),this._triggerChange(""+e,"remove",void 0,p)),o.length>2){for(s=0,a=g.length;a>s;s++)i.set(this,s,g[s]);this._triggerChange(""+e,"add",g,p)}return t.batch.stop(),p},_attrs:function(i,r){return void 0===i?e.helpers.serialize(this,"attr",[]):(i=t.makeArray(i),t.batch.start(),this._updateAttrs(i,r),void t.batch.stop())},_updateAttrs:function(t,i){for(var r=Math.min(t.length,this.length),h=0;r>h;h++){var n=this[h],s=t[h];e.helpers.isObservable(n)&&e.helpers.canMakeObserve(s)?n.attr(s,i):n!==s&&this._set(h,s)}t.length>this.length?this.push.apply(this,t.slice(this.length)):t.lengthc;){s=i;for(var l=0,f=t.propertyReaders.length;f>l;l++){var v=t.propertyReaders[l];if(v.test(i)){i=v.read(i,r[c],c,o,u);break}}if(c+=1,i=n(i,c,r,o,u,s),a=typeof i,ci;i++)t.valueReaders[i].test(e,n,r,o)&&(e=t.valueReaders[i].read(e,n,r,o,a,s))}while(u);return e};return t.valueReaders=[{name:"compute",test:function(e,t,n,r){return e&&e.isComputed},read:function(t,n,r,o,a){return o.isArgument&&n===r.length?t:(!a.foundObservable&&o.foundObservable&&(o.foundObservable(t,n),a.foundObservable=!0),t instanceof e.Compute?t.get():t())}},{name:"function",test:function(t,n,r,o){var a=typeof t;return!("function"!==a||t.isComputed||!(o.executeAnonymousFunctions||o.isArgument&&n===r.length)||e.Construct&&t.prototype instanceof e.Construct||e.route&&t===e.route)},read:function(t,n,r,o,a,s){return o.isArgument&&n===r.length?o.proxyMethods!==!1?e.proxy(t,s):t:t.call(s)}}],t.propertyReaders=[{name:"map",test:e.isMapLike,read:function(t,n,r,o,a){return!a.foundObservable&&o.foundObservable&&(o.foundObservable(t,r),a.foundObservable=!0),"function"==typeof t[n]&&t.constructor.prototype[n]===t[n]?o.returnObserveMethods?t[n]:"constructor"===n&&t instanceof e.Construct||t[n].prototype instanceof e.Construct?t[n]:t[n].apply(t,o.args||[]):t.attr(n)}},{name:"promise",test:function(t){return e.isPromise(t)},read:function(t,n,r,o,a){!a.foundObservable&&o.foundObservable&&(o.foundObservable(t,r),a.foundObservable=!0);var s=t.__observeData;return t.__observeData||(s=t.__observeData={isPending:!0,state:"pending",isResolved:!1,isRejected:!1,value:void 0,reason:void 0},e.cid(s),e.simpleExtend(s,e.event),t.then(function(e){s.isPending=!1,s.isResolved=!0,s.value=e,s.state="resolved",s.dispatch("state",["resolved","pending"])},function(e){s.isPending=!1,s.isRejected=!0,s.reason=e,s.state="rejected",s.dispatch("state",["rejected","pending"])})),e.__observe(s,"state"),n in s?s[n]:t[n]}},{name:"object",test:function(){return!0},read:function(e,t){return null==e?void 0:e[t]}}],t.write=function(t,n,r,o){return o=o||{},e.isMapLike(t)?!o.isArgument&&t._data&&t._data[n]&&t._data[n].isComputed?t._data[n](r):t.attr(n,r):t[n]&&t[n].isComputed?t[n](r):void("object"==typeof t&&(t[n]=r))},t}); +/*can@2.2.6#compute/get_value_and_bind*/ +define("can/compute/get_value_and_bind",["can/util/util"],function(){function n(n,e,t,i){var v=a(n,e),o=v.observed,u=t.observed;return v.names!==t.names&&(r(u,o,i),c(u,i)),can.batch.afterPreviousEvents(function(){v.ready=!0}),v}var e=[];can.__isRecordingObserves=function(){return e.length},can.__observe=can.__reading=function(n,a){if(e.length){var r=n._cid+"|"+a,t=e[e.length-1];t.names+=r,t.observed[r]={obj:n,event:a+""}}},can.__notObserve=function(n){return function(){var e=can.__clearObserved(),a=n.apply(this,arguments);return can.__setObserved(e),a}},can.__clearObserved=can.__clearReading=function(){if(e.length){var n=e[e.length-1];return e[e.length-1]={observed:{}},n}},can.__setObserved=can.__setReading=function(n){e.length&&(e[e.length-1]=n)},can.__addObserved=can.__addReading=function(n){e.length&&can.simpleExtend(e[e.length-1],n)};var a=function(n,a){e.push({names:"",observed:{}});var r=n.call(a),t=e.pop();return t.value=r,t},r=function(n,e,a){for(var r in e)t(n,e,r,a)},t=function(n,e,a,r){if(n[a])delete n[a];else{var t=e[a];t.obj.bind(t.event,r)}},c=function(n,e){for(var a in n){var r=n[a];r.obj.unbind(r.event,e)}};return n}); +/*can@2.2.6#compute/proto_compute*/ +define("can/compute/proto_compute",["can/util/util","can/util/bind/bind","can/compute/read","can/compute/get_value_and_bind","can/util/batch/batch"],function(t,e,n,i){var s=function(e,n,i,s){n!==i&&t.batch.trigger(e,s?{type:"change",batchNum:s}:"change",[n,i])},u=function(e,n,s,u){var o,h,r;return u=!1,{on:function(a){var c=this;h||(h=function(t){if(o.ready&&e.bound&&(void 0===t.batchNum||t.batchNum!==r)){var a,f=o.value;u?(a=n.call(s),o.value=a):(o=i(n,s,o,h),a=o.value),c.updater(a,f,t.batchNum),r=r=t.batchNum}}),o=i(n,s,{observed:{}},h),u&&(n=t.__notObserve(n)),e.value=o.value,e.hasDependencies=!t.isEmptyObject(o.observed)},off:function(t){for(var e in o.observed){var n=o.observed[e];n.obj.unbind(n.event,h)}}}},o=function(){},h=function(t,e,n){this.value=t,s(this,t,e,n)},r=function(t,e,n){return function(){return t.call(e,n.get())}},a=function(t,e){return function(n){void 0!==n&&e(n,t.value)}};t.Compute=function(e,n,i,s){for(var u=[],o=0,h=arguments.length;h>o;o++)u[o]=arguments[o];var r=typeof u[1];"function"==typeof u[0]?this._setupGetterSetterFn(u[0],u[1],u[2],u[3]):u[1]?"string"===r?this._setupContextString(u[0],u[1],u[2]):"function"===r?this._setupContextFunction(u[0],u[1],u[2]):u[1]&&u[1].fn?this._setupAsyncCompute(u[0],u[1]):this._setupContextSettings(u[0],u[1]):this._setupInitialValue(u[0]),this._args=u,this.isComputed=!0,t.cid(this,"compute")},t.simpleExtend(t.Compute.prototype,{_bindsetup:t.__notObserve(function(){this.bound=!0,this._on(this.updater)}),_bindteardown:function(){this._off(this.updater),this.bound=!1},bind:t.bindAndSetup,unbind:t.unbindAndTeardown,clone:function(e){return e&&"function"==typeof this._args[0]?this._args[1]=e:e&&(this._args[2]=e),new t.Compute(this._args[0],this._args[1],this._args[2],this._args[3])},_on:o,_off:o,get:function(){return t.__isRecordingObserves()&&this._canObserve!==!1&&(t.__observe(this,"change"),this.bound||t.Compute.temporarilyBind(this)),this.bound?this.value:this._get()},_get:function(){return this.value},set:function(t){var e=this.value,n=this._set(t,e);return this.hasDependencies?this._setUpdates?this.value:this._get():(void 0===n?this.value=this._get():this.value=n,s(this,this.value,e),this.value)},_set:function(t){return this.value=t},updater:h,_computeFn:function(t){return arguments.length?this.set(t):this.get()},toFunction:function(){return t.proxy(this._computeFn,this)},_setupGetterSetterFn:function(e,n,i,s){this._set=t.proxy(e,n),this._get=t.proxy(e,n),this._canObserve=i===!1?!1:!0;var o=u(this,e,n||this,s);this._on=o.on,this._off=o.off},_setupContextString:function(e,n,i){var s=t.isMapLike(e),u=this,o=function(t,e,n){u.updater(e,n,t.batchNum)};s?(this.hasDependencies=!0,this._get=function(){return e.attr(n)},this._set=function(t){e.attr(n,t)},this._on=function(t){e.bind(i||n,o),this.value=this._get()},this._off=function(){return e.unbind(i||n,o)}):(this._get=t.proxy(this._get,e),this._set=t.proxy(this._set,e))},_setupContextFunction:function(e,n,i){this.value=e,this._set=n,t.simpleExtend(this,i)},_setupContextSettings:function(e,n){if(this.value=e,this._set=n.set?t.proxy(n.set,n):this._set,this._get=n.get?t.proxy(n.get,n):this._get,!n.__selfUpdater){var i=this,s=this.updater;this.updater=function(){s.call(i,i._get(),i.value)}}this._on=n.on?n.on:this._on,this._off=n.off?n.off:this._off},_setupAsyncCompute:function(e,n){this.value=e;var i,s=t.proxy(this.updater,this),o=this,h=n.fn;this.updater=s;var c=new t.Compute(e);this.lastSetValue=c,this._setUpdates=!0,this._set=function(t){return t===c.get()?this.value:c.set(t)},this._get=r(h,n.context,c),0===h.length?i=u(this,h,n.context):1===h.length?i=u(this,function(){return h.call(n.context,c.get())},n):(this.updater=a(this,s),i=u(this,function(){var t=h.call(n.context,c.get(),function(t){s(t,o.value)});return void 0!==t?t:this.value},n)),this._on=i.on,this._off=i.off},_setupInitialValue:function(t){this.value=t}});var c,f=function(){for(var t=0,e=c.length;e>t;t++)c[t].unbind("change",o);c=null};return t.Compute.temporarilyBind=function(t){t.bind("change",o),c||(c=[],setTimeout(f,10)),c.push(t)},t.Compute.async=function(e,n,i){return new t.Compute(e,{fn:n,context:i})},t.Compute.read=n,t.Compute.set=n.write,t.Compute.truthy=function(e){return new t.Compute(function(){var t=e.get();return"function"==typeof t&&(t=t.get()),!!t})},t.Compute}); +/*can@2.2.6#compute/compute*/ +define("can/compute/compute",["can/util/util","can/util/bind/bind","can/util/batch/batch","can/compute/proto_compute"],function(t,n){t.compute=function(n,u,e,o){var c=new t.Compute(n,u,e,o),i=function(t){return arguments.length?c.set(t):c.get()};return i.bind=t.proxy(c.bind,c),i.unbind=t.proxy(c.unbind,c),i.isComputed=c.isComputed,i.clone=function(e){return"function"==typeof n&&(u=e),t.compute(n,u,e,o)},i.computeInstance=c,i};var u,e=function(){},o=function(){for(var t=0,n=u.length;n>t;t++)u[t].unbind("change",e);u=null};return t.compute.temporarilyBind=function(t){t.bind("change",e),u||(u=[],setTimeout(o,10)),u.push(t)},t.compute.truthy=function(n){return t.compute(function(){var t=n();return"function"==typeof t&&(t=t()),!!t})},t.compute.async=function(n,u,e){return t.compute(n,{fn:u,context:e})},t.compute.read=t.Compute.read,t.compute.set=t.Compute.set,t.compute}); +/*can@2.2.6#observe/observe*/ +define("can/observe/observe",["can/util/util","can/map/map","can/list/list","can/compute/compute"],function(t){return t.Observe=t.Map,t.Observe.startBatch=t.batch.start,t.Observe.stopBatch=t.batch.stop,t.Observe.triggerBatch=t.batch.trigger,t}); +/*can@2.2.6#view/scope/compute_data*/ +define("can/view/scope/compute_data",["can/util/util","can/compute/compute","can/compute/get_value_and_bind"],function(e,t,n){var o=function(t){return t.reads&&1===t.reads.length&&t.root instanceof e.Map&&!e.isFunction(t.root[t.reads[0]])},a=function(e,t){return n(e,null,{observed:{}},t)},u=function(e,t){for(var n in e.observed){var o=e.observed[n];o.obj.unbind(o.event,t)}},r=function(e,t){var n=e.root,o=e.reads[0];return n.bind(o,t),{value:e.initialValue,observed:{something:!0}}},c=function(e,t){e.root.unbind(e.reads[0],t)},i=function(t,n,o,a,u){if(!(arguments.length>4)){if(a.root)return e.compute.read(a.root,a.reads,o).value;var r=t.read(n,o);return a.scope=r.scope,a.initialValue=r.value,a.reads=r.reads,a.root=r.rootObserve,r.value}if(a.root.isComputed)a.root(u);else if(a.reads.length){var c=a.reads.length-1,i=a.reads.length?e.compute.read(a.root,a.reads.slice(0,c)).value:a.root;e.compute.set(i,a.reads[c],u,o)}};return function(t,s,d){d=d||{args:[]};var l,v,f={},p=function(e){return arguments.length?i(t,s,d,f,e):i(t,s,d,f)},m=function(e){if(v.ready&&g.computeInstance.bound&&(void 0===e.batchNum||e.batchNum!==l)){var t,o=v.value;v=n(p,null,v,m),t=v.value,g.computeInstance.updater(t,o,e.batchNum),l=l=e.batchNum}},b=function(e,t,n){"function"!=typeof t?g.computeInstance.updater(t,n,e.batchNum):(c(f,b),v=a(p,m),h=!1,g.computeInstance.updater(v.value,n,e.batchNum))},h=!1,g=e.compute(void 0,{on:function(){if(v=a(p,m),o(f)){var t=v;v=r(f,b),u(t,m),h=!0}g.computeInstance.value=v.value,g.computeInstance.hasDependencies=!e.isEmptyObject(v.observed)},off:function(){h?c(f,b):u(v,m)},set:p,get:p,__selfUpdater:!0});return f.compute=g,f}}); +/*can@2.2.6#view/scope/scope*/ +define("can/view/scope/scope",["can/util/util","can/view/scope/compute_data","can/construct/construct","can/map/map","can/list/list","can/view/view","can/compute/compute"],function(e,t){var n=/(\\)?\./g,r=/\\\./g,u=function(e){var t=[],u=0;return e.replace(n,function(n,i,s){i||(t.push(e.slice(u,s).replace(r,".")),u=s+n.length)}),t.push(e.slice(u).replace(r,".")),t},i=e.Construct.extend({read:e.compute.read},{init:function(e,t){this._context=e,this._parent=t,this.__cache={}},attr:e.__notObserve(function(t,n){var r={isArgument:!0,returnObserveMethods:!0,proxyMethods:!1},u=this.read(t,r);if(2===arguments.length){var i=t.lastIndexOf("."),s=-1!==i?t.substring(0,i):".",a=this.read(s,r).value;-1!==i&&(t=t.substring(i+1,t.length)),e.compute.set(a,t,n,r)}return u.value}),add:function(e){return e!==this._context?new this.constructor(e,this):this},computeData:function(e,n){return t(this,e,n)},compute:function(e,t){return this.computeData(e,t).compute},read:function(t,n){var r;if("./"===t.substr(0,2))r=!0,t=t.substr(2);else{if("../"===t.substr(0,3))return this._parent.read(t.substr(3),n);if(".."===t)return{value:this._parent._context};if("."===t||"this"===t)return{value:this._context}}for(var i,s,a,c,o,l,p=-1===t.indexOf("\\.")?t.split("."):u(t),v=this,d=[],f=-1;v;){if(i=v._context,null!==i&&("object"==typeof i||"function"==typeof i)){var h=e.compute.read(i,p,e.simpleExtend({foundObservable:function(e,t){o=e,l=p.slice(t)},earlyExit:function(t,n){n>f&&(s=o,d=l,f=n,c=v,a=e.__clearReading())},executeAnonymousFunctions:!0},n));if(void 0!==h.value)return{scope:v,rootObserve:o,value:h.value,reads:l}}e.__clearReading(),v=r?null:v._parent}return s?(e.__setReading(a),{scope:c,rootObserve:s,reads:d,value:void 0}):{names:p,value:void 0}}});return e.view.Scope=i,i}); +/*can@2.2.6#view/scanner*/ +define("can/view/scanner",["can/view/view","can/view/elements","can/view/callbacks/callbacks"],function(can,elements,viewCallbacks){var newLine=/(\r|\n)+/g,notEndTag=/\//,clean=function(t){return t.split("\\").join("\\\\").split("\n").join("\\n").split('"').join('\\"').split(" ").join("\\t")},getTag=function(t,e,n){if(t)return t;for(;n":">",'"':'"',"'":"'"},this.tokenComplex=[],this.tokenMap={};for(var e,n=0;e=this.tokens[n];n++)e[2]?(this.tokenReg.push(e[2]),this.tokenComplex.push({abbr:e[1],re:new RegExp(e[2]),rescan:e[3]})):(this.tokenReg.push(e[1]),this.tokenSimple[e[1]]=e[0]),this.tokenMap[e[0]]=e[1];this.tokenReg=new RegExp("("+this.tokenReg.slice(0).concat(["<",">",'"',"'"]).join("|")+")","g")},Scanner.prototype={helpers:[],scan:function(t,e){var n=[],s=0,a=this.tokenSimple,r=this.tokenComplex;t=t.replace(newLine,"\n"),this.transform&&(t=this.transform(t)),t.replace(this.tokenReg,function(e,i){var o=arguments[arguments.length-2];if(o>s&&n.push(t.substring(s,o)),a[e])n.push(e);else for(var u,c=0;u=r[c];c++)if(u.re.test(e)){n.push(u.abbr),u.rescan&&n.push(u.rescan(i));break}s=o+i.length}),s":htmlTag=0;var H="/"===l.substr(l.length-1)||"--"===l.substr(l.length-2),N="";if(k.attributeHookups.length&&(N="attrs: ['"+k.attributeHookups.join("','")+"'], ",k.attributeHookups=[]),v+k.tagHookups.length!==k.lastTagHookup&&v===top(k.tagHookups))H&&(l=l.substr(0,l.length-1)),p.push(put_cmd,'"',clean(l),'"',",can.view.pending({tagName:'"+v+"',"+N+"scope: "+(this.text.scope||"this")+this.text.options),H?(p.push("}));"),l="/>",b()):"<"===n[d]&&n[d+1]==="/"+v?(p.push("}));"),l=u,b()):(p.push(",subtemplate: function("+this.text.argNames+"){\n"+startTxt+(this.text.start||"")),l="");else if(m||!w&&elements.tagToContentPropMap[x[x.length-1]]||N){var R=",can.view.pending({"+N+"scope: "+(this.text.scope||"this")+this.text.options+'}),"';H?h(l.substr(0,l.length-1),R+'/>"'):h(l,R+'>"'),l="",m=0}else l+=u;(H||w)&&(x.pop(),v=x[x.length-1],w=!1),k.attributeHookups=[];break;case"'":case'"':if(htmlTag)if(quote&"e===u){quote=null;var L=getAttrName();if(viewCallbacks.attr(L)&&k.attributeHookups.push(L),T){l+=u,h(l),p.push(finishTxt,"}));\n"),l="",T=!1;break}}else if(null===quote&&(quote=u,beforeQuote=i,c=getAttrName(),"img"===v&&"src"===c||"style"===c)){h(l.replace(attrReg,"")),l="",T=!0,p.push(insert_cmd,"can.view.txt(2,'"+getTag(v,n,d)+"',"+status()+",this,function(){",startTxt),h(c+"="+u);break}default:if("<"===i){v="!--"===u.substr(0,3)?"!--":u.split(/\s/)[0];var S,y=!1;0===v.indexOf("/")&&(y=!0,S=v.substr(1)),y?(top(x)===S&&(v=S,w=!0),top(k.tagHookups)===S&&(h(l.substr(0,l.length-1)),p.push(finishTxt+"}}) );"),l="><",b())):(v.lastIndexOf("/")===v.length-1&&(v=v.substr(0,v.length-1)),"!--"!==v&&viewCallbacks.tag(v)&&("content"===v&&elements.tagMap[top(x)]&&(u=u.replace("content",elements.tagMap[top(x)])),k.tagHookups.push(v)),x.push(v))}l+=u}else switch(u){case _.right:case _.returnRight:switch(f){case _.left:o=bracketNum(l),1===o?(p.push(insert_cmd,"can.view.txt(0,'"+getTag(v,n,d)+"',"+status()+",this,function(){",startTxt,l),g.push({before:"",after:finishTxt+"}));\n"})):(s=g.length&&-1===o?g.pop():{after:";"},s.before&&p.push(s.before),p.push(l,";",s.after));break;case _.escapeLeft:case _.returnLeft:o=bracketNum(l),o&&g.push({before:finishTxt,after:"}));\n"});for(var j=f===_.escapeLeft?1:0,C={insert:insert_cmd,tagName:getTag(v,n,d),status:status(),specialAttribute:T},q=0;q[\s]*\w*/.source&&(j=0);break}}"object"==typeof l?l.startTxt&&l.end&&T?p.push(insert_cmd,"can.view.toStr( ",l.content,"() ) );"):(l.startTxt?p.push(insert_cmd,"can.view.txt(\n"+("string"==typeof status()||(null!=l.escaped?l.escaped:j))+",\n'"+v+"',\n"+status()+",\nthis,\n"):l.startOnlyTxt&&p.push(insert_cmd,"can.view.onlytxt(this,\n"),p.push(l.content),l.end&&p.push("));")):T?p.push(insert_cmd,l,");"):p.push(insert_cmd,"can.view.txt(\n"+("string"==typeof status()||j)+",\n'"+v+"',\n"+status()+",\nthis,\nfunction(){ "+(this.text.escape||"")+"return ",l,o?startTxt:"}));\n"),rescan&&rescan.after&&rescan.after.length&&(h(rescan.after.length),rescan=null)}f=null,l="";break;case _.templateLeft:l+=_.left;break;default:l+=u}i=u}l.length&&h(l),p.push(";");var M=p.join(""),A={out:(this.text.outStart||"")+M+" "+finishTxt+(this.text.outEnd||"")};return myEval.call(A,"this.fn = (function("+this.text.argNames+"){"+A.out+"});\r\n//# sourceURL="+e+".js"),A}},can.view.pending=function(t){var e=can.view.getHooks();return can.view.hook(function(n){can.each(e,function(t){t(n)}),t.templateType="legacy",t.tagName&&viewCallbacks.tagHandler(n,t.tagName,t),can.each(t&&t.attrs||[],function(e){t.attributeName=e;var s=viewCallbacks.attr(e);s&&s(n,t)})})},can.view.tag("content",function(t,e){return e.scope}),can.view.Scanner=Scanner,Scanner}); +/*can@2.2.6#view/node_lists/node_lists*/ +define("can/view/node_lists/node_lists",["can/util/util","can/view/elements"],function(e){var n=!0;try{document.createTextNode("")._=0}catch(t){n=!1}var r={},a={},i="ejs_"+Math.random(),s=0,u=function(e,t){var r=t||a,u=l(e,r);return u?u:n||3!==e.nodeType?(++s,e[i]=(e.nodeName?"element_":"obj_")+s):(++s,r["text_"+s]=e,"text_"+s)},l=function(e,t){if(n||3!==e.nodeType)return e[i];for(var r in t)if(t[r]===e)return r},c=[].splice,o=[].push,p=function(e){for(var n=0,t=0,r=e.length;r>t;t++){var a=e[t];a.nodeType?n++:n+=p(a)}return n},f=function(e,n){for(var t={},r=0,a=e.length;a>r;r++){var i=d.first(e[r]);t[u(i,n)]=e[r]}return t},d={id:u,update:function(n,t){var r=d.unregisterChildren(n);t=e.makeArray(t);var a=n.length;return c.apply(n,[0,a].concat(t)),n.replacements?d.nestReplacements(n):d.nestList(n),r},nestReplacements:function(e){for(var n=0,t={},r=f(e.replacements,t),a=e.replacements.length;nr;r++){var n=e[r];t[n.tokenType].apply(t,n.args)}return e}var a="-:A-Za-z0-9_",n="[a-zA-Z_:]["+a+":.]*",s="\\s*=\\s*",i='"((?:\\\\.|[^"])*)"',o="'((?:\\\\.|[^'])*)'",l="(?:"+s+"(?:(?:\"[^\"]*\")|(?:'[^']*')|[^>\\s]+))?",c="\\{\\{[^\\}]*\\}\\}\\}?",u="\\{\\{([^\\}]*)\\}\\}\\}?",p=new RegExp("^<(["+a+"]+)((?:\\s*(?:(?:(?:"+n+")?"+l+")|(?:"+c+")+))*)\\s*(\\/?)>"),f=new RegExp("^<\\/(["+a+"]+)[^>]*>"),d=new RegExp("(?:(?:("+n+")|"+u+")(?:"+s+"(?:(?:"+i+")|(?:"+o+")|([^>\\s]+)))?)","g"),g=new RegExp(u,"g"),h=/<|\{\{/,m=t("area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed"),b=t("a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video"),v=t("abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var"),x=t("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr"),w=t("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"),y=t("script,style"),k="start,end,close,attrStart,attrEnd,attrValue,chars,comment,special,done".split(","),E=function(){},A=function(t,a,n){function s(e,t,r,n){if(t=t.toLowerCase(),b[t])for(;w.last()&&v[w.last()];)i("",w.last());x[t]&&w.last()===t&&i("",t),n=m[t]||!!n,a.start(t,n),n||w.push(t),A.parseAttrs(r,a),a.end(t,n)}function i(e,t){var r;if(t)for(r=w.length-1;r>=0&&w[r]!==t;r--);else r=0;if(r>=0){for(var n=w.length-1;n>=r;n--)a.close&&a.close(w[n]);w.length=r}}function o(e,t){a.special&&a.special(t)}if("object"==typeof t)return r(t,a);var l=[];a=a||{},n&&e.each(k,function(t){var r=a[t]||E;a[t]=function(){r.apply(this,arguments)!==!1&&l.push({tokenType:t,args:e.makeArray(arguments)})}});var c,u,d,w=[],O=t;for(w.last=function(){return this[this.length-1]};t;){if(u=!0,w.last()&&y[w.last()])t=t.replace(new RegExp("([\\s\\S]*?)]*>"),function(e,t){return t=t.replace(/|/g,"$1$2"),a.chars&&a.chars(t),""}),i("",w.last());else if(0===t.indexOf(""),c>=0&&(a.comment&&a.comment(t.substring(4,c)),t=t.substring(c+3),u=!1)):0===t.indexOf("c?t:t.substring(0,c);t=0>c?"":t.substring(c),a.chars&&R&&a.chars(R)}if(t===O)throw"Parse Error: "+t;O=t}return i(),a.done(),l};return A.parseAttrs=function(e,t){(null!=e?e:"").replace(d,function(e,r,a,n,s,i){if(a&&t.special(a),r||n||s||i){var o=arguments[3]?arguments[3]:arguments[4]?arguments[4]:arguments[5]?arguments[5]:w[r.toLowerCase()]?r:"";t.attrStart(r||"");for(var l,c=g.lastIndex=0,u=g.exec(o);u;)l=o.substring(c,g.lastIndex-u[0].length),l.length&&t.attrValue(l),t.special(u[1]),c=g.lastIndex,u=g.exec(o);l=o.substr(c,o.length),l&&t.attrValue(l),t.attrEnd(r||"")}})},e.view.parser=A,A}); +/*can@2.2.6#view/live/live*/ +define("can/view/live/live",["can/util/util","can/view/elements","can/view/view","can/view/node_lists/node_lists","can/view/parser/parser"],function(e,t,n,r,i){t=t||e.view.elements,r=r||e.view.NodeLists,i=i||e.view.parser;var a=function(t,n,r){var i=!1,a=function(){return i||(i=!0,r(o),e.unbind.call(t,"removed",a)),!0},o={teardownCheck:function(e){return e?!1:a()}};return e.bind.call(t,"removed",a),n(o),o},o=function(e,t,n){return a(e,function(){t.bind("change",n)},function(e){t.unbind("change",n),e.nodeList&&r.unregister(e.nodeList)})},c=function(e){var t,n={};return i.parseAttrs(e,{attrStart:function(e){n[e]="",t=e},attrValue:function(e){n[t]+=e},attrEnd:function(){}}),n},u=[].splice,d=function(e){return e&&e.nodeType},s=function(e){e.childNodes.length||e.appendChild(document.createTextNode(""))},l={list:function(n,i,o,c,d,s){var f,p=s||[n],v=[],h=!1,g=!1,b=function(n,i,a){if(h){var d=document.createDocumentFragment(),l=[],f=[];e.each(i,function(t,n){var i=[];s&&r.register(i,null,!0);var u=e.compute(n+a),p=o.call(c,t,u,i),v="string"==typeof p,h=e.frag(p);h=v?e.view.hookup(h):h;var g=e.makeArray(h.childNodes);s?(r.update(i,g),l.push(i)):l.push(r.register(g)),d.appendChild(h),f.push(u)});var g=a+1;if(p[g]){var b=r.first(p[g]);e.insertBefore(b.parentNode,d,b)}else t.after(1===g?[N]:[r.last(p[g-1])],d);u.apply(p,[g,0].concat(l)),u.apply(v,[a,0].concat(f));for(var m=a+f.length,w=v.length;w>m;m++)v[m](m)}},m=function(t,n,i,a,o){if(h&&(a||!y.teardownCheck(N.parentNode))){0>i&&(i=v.length+i);var c=p.splice(i+1,n.length),u=[];e.each(c,function(e){var t=r.unregister(e);[].push.apply(u,t)}),v.splice(i,n.length);for(var d=i,s=v.length;s>d;d++)v[d](d);o?r.unregister(p):e.remove(e.$(u))}},w=function(t,n,i,a){if(h){i+=1,a+=1;var o,c=p[i],u=e.frag(r.flatten(p[a]));o=i>a?r.last(c).nextSibling:r.first(c);var d=p[0].parentNode;d.insertBefore(u,o);var s=p[a];[].splice.apply(p,[a,1]),[].splice.apply(p,[i,0,s])}},N=document.createTextNode(""),k=function(e){f&&f.unbind&&f.unbind("add",b).unbind("remove",m).unbind("move",w),m({},{length:p.length-1},0,!0,e)},A=function(t,n,r){g||(k(),f=n||[],f.bind&&f.bind("add",b).bind("remove",m).bind("move",w),h=!0,b({},f,0),h=!1,e.batch.afterPreviousEvents(function(){h=!0}))};d=t.getParentNode(n,d);var y=a(d,function(){e.isFunction(i)&&i.bind("change",A)},function(){e.isFunction(i)&&i.unbind("change",A),k(!0)});s?(t.replace(p,N),r.update(p,[N]),s.unregistered=function(){y.teardownCheck(),g=!0}):l.replace(p,N,y.teardownCheck),A({},e.isFunction(i)?i():i)},html:function(n,i,a,c){var u;a=t.getParentNode(n,a),u=o(a,i,function(e,t,n){var i=r.first(l).parentNode;i&&f(t),u.teardownCheck(r.first(l).parentNode)});var l=c||[n],f=function(n){var i="function"==typeof n,o=d(n),c=e.frag(i?"":n),u=e.makeArray(l);s(c),o||i||(c=e.view.hookup(c,a)),u=r.update(l,c.childNodes),i&&n(c.childNodes[0]),t.replace(u,c)};u.nodeList=l,c?c.unregistered=u.teardownCheck:r.register(l,u.teardownCheck),f(i())},replace:function(n,i,a){var o=n.slice(0),c=e.frag(i);return r.register(n,a),"string"==typeof i&&(c=e.view.hookup(c,n[0].parentNode)),r.update(n,c.childNodes),t.replace(o,c),n},text:function(n,i,a,c){var u=t.getParentNode(n,a),d=o(u,i,function(t,n,r){"unknown"!=typeof s.nodeValue&&(s.nodeValue=e.view.toStr(n)),d.teardownCheck(s.parentNode)}),s=document.createTextNode(e.view.toStr(i()));c?(c.unregistered=d.teardownCheck,d.nodeList=c,r.update(c,[s]),t.replace([n],s)):d.nodeList=l.replace([n],s,d.teardownCheck)},setAttributes:function(t,n){var r=c(n);for(var i in r)e.attr.set(t,i,r[i])},attributes:function(n,r,i){var a={},u=function(r){var i,o=c(r);for(i in o){var u=o[i],d=a[i];u!==d&&e.attr.set(n,i,u),delete a[i]}for(i in a)t.removeAttr(n,i);a=o};o(n,r,function(e,t){u(t)}),arguments.length>=3?a=c(i):u(r())},attributePlaceholder:"__!!__",attributeReplace:/__!!__/g,attribute:function(n,r,i){o(n,i,function(e,i){t.setAttr(n,r,u.render())});var a,c=e.$(n);a=e.data(c,"hooks"),a||e.data(c,"hooks",a={});var u,d=t.getAttr(n,r),s=d.split(l.attributePlaceholder),f=[];f.push(s.shift(),s.join(l.attributePlaceholder)),a[r]?a[r].computes.push(i):a[r]={render:function(){var e=0,n=d?d.replace(l.attributeReplace,function(){return t.contentText(u.computes[e++]())}):t.contentText(u.computes[e++]());return n},computes:[i],batchNum:void 0},u=a[r],f.splice(1,0,i()),t.setAttr(n,r,f.join(""))},specialAttribute:function(e,n,r){o(e,r,function(r,i){t.setAttr(e,n,p(i))}),t.setAttr(e,n,p(r()))},simpleAttribute:function(e,n,r){o(e,r,function(r,i){t.setAttr(e,n,i)}),t.setAttr(e,n,r())}};l.attr=l.simpleAttribute,l.attrs=l.attributes;var f=/(\r|\n)+/g,p=function(e){var n=/^["'].*["']$/;return e=e.replace(t.attrReg,"").replace(f,""),n.test(e)?e.substr(1,e.length-2):e};return e.view.live=l,l}); +/*can@2.2.6#view/render*/ +define("can/view/render",["can/view/view","can/view/elements","can/view/live/live","can/util/string/string"],function(t,n,e){var i,r=[],u=function(t){var e=n.tagMap[t]||"span";return"span"===e?"@@!!@@":"<"+e+">"+u(e)+""},o=function(n,e){if("string"==typeof n)return n;if(!n&&0!==n)return"";var i=n.hookup&&function(t,e){n.hookup.call(n,t,e)}||"function"==typeof n&&n;return i?e?"<"+e+" "+t.view.hook(i)+">":(r.push(i),""):""+n},c=function(n,e){return"string"==typeof n||"number"==typeof n?t.esc(n):o(n,e)},s=!1,a=function(){};return t.extend(t.view,{live:e,setupLists:function(){var n,e=t.view.lists;return t.view.lists=function(t,e){return n={list:t,renderer:e},Math.random()},function(){return t.view.lists=e,n}},getHooks:function(){var t=r.slice(0);return i=t,r=[],t},onlytxt:function(t,n){return c(n.call(t))},txt:function(f,p,l,v,h){var w,g,d,b,y=n.tagMap[p]||"span",k=!1,m=a;if(s)w=h.call(v);else{("string"==typeof l||1===l)&&(s=!0);var x=t.view.setupLists();m=function(){d.unbind("change",a)},d=t.compute(h,v,!1),d.bind("change",a),g=x(),w=d(),s=!1,k=d.computeInstance.hasDependencies}if(g)return m(),"<"+y+t.view.hook(function(t,n){e.list(t,g.list,g.renderer,v,n)})+">";if(!k||"function"==typeof w)return m(),(s||2===f||!f?o:c)(w,0===l&&y);var M=n.tagToContentPropMap[p];return 0!==l||M?1===l?(r.push(function(t){e.attributes(t,d,d()),m()}),d()):2===f?(b=l,r.push(function(t){e.specialAttribute(t,b,d),m()}),d()):(b=0===l?M:l,(0===l?i:r).push(function(t){e.attribute(t,b,d),m()}),e.attributePlaceholder):"<"+y+t.view.hook(f&&"object"!=typeof w?function(t,n){e.text(t,d,n),m()}:function(t,n){e.html(t,d,n),m()})+">"+u(y)+""}}),t}); +/*can@2.2.6#view/stache/utils*/ +define("can/view/stache/utils",["can/util/util"],function(){return{isArrayLike:function(t){return t&&t.splice&&"number"==typeof t.length},isObserveLike:function(t){return t instanceof can.Map||t&&!!t._get},emptyHandler:function(){},jsonParse:function(str){return"'"===str[0]?str.substr(1,str.length-2):"undefined"===str?void 0:can.global.JSON?JSON.parse(str):eval("("+str+")")},mixins:{last:function(){return this.stack[this.stack.length-1]},add:function(t){this.last().add(t)},subSectionDepth:function(){return this.stack.length-1}}}}); +/*can@2.2.6#view/stache/mustache_helpers*/ +define("can/view/stache/mustache_helpers",["can/util/util","can/view/stache/utils","can/view/live/live"],function(e,n,t){t=t||e.view.live;var i=function(t){return n.isObserveLike(t)&&n.isArrayLike(t)&&t.attr("length")?t:e.isFunction(t)?t():t},r={each:function(r,s){var o,u,a,c=i(r),f=[];if(c instanceof e.List)return function(n){var i=[n];i.expression="live.list",e.view.nodeLists.register(i,null,s.nodeList),e.view.nodeLists.update(s.nodeList,[n]);var o=function(e,n,t){return s.fn(s.scope.add({"@index":n}).add(e),s.options,t)};t.list(n,r,o,s.context,n.parentNode,i)};var l=c;if(l&&n.isArrayLike(l))for(a=0;a0&&t!==n)return r.inverse();n=t}return r.fn()},eq:function(){return r.is.apply(this,arguments)},unless:function(n,t){return r["if"].apply(this,[e.isFunction(n)?e.compute(function(){return!n()}):!n,t])},"with":function(e,n){var t=e;return e=i(e),e?n.fn(t):void 0},log:function(e,n){"undefined"!=typeof console&&console.log&&(n?console.log(e,n.context):console.log(e.context))},data:function(n){var t=2===arguments.length?this:arguments[1];return function(i){e.data(e.$(i),n,t||this.context)}}};return{registerHelper:function(e,n){r[e]=n},getHelper:function(e,n){var t=n.attr("helpers."+e);return t||(t=r[e]),t?{fn:t}:void 0}}}); +/*can@2.2.6#view/stache/mustache_core*/ +define("can/view/stache/mustache_core",["can/util/util","can/view/stache/utils","can/view/stache/mustache_helpers","can/view/live/live","can/view/elements","can/view/scope/scope","can/view/node_lists/node_lists"],function(e,t,n,r,i,a,s){r=r||e.view.live,i=i||e.view.elements,a=a||e.view.Scope,s=s||e.view.nodeLists;var o=/((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g,u=/^(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(?:(.+?)=(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(.+))))$/,c=/(?:(?:^|(\r?)\n)(\s*)(\{\{([^\}]*)\}\}\}?)([^\S\n\r]*)($|\r?\n))|(\{\{([^\}]*)\}\}\}?)/g,l=function(e){return e&&"string"==typeof e.get},f=function(e,t,n,r){for(var i=document.createDocumentFragment(),a=0,s=e.length;s>a;a++)p(i,n.fn(t?e.attr(""+a):e[a],r));return i},p=function(e,t){t&&e.appendChild("string"==typeof t?document.createTextNode(t):t)},h=function(e,t,n,r){for(var i="",a=0,s=e.length;s>a;a++)i+=n.fn(t?e.attr(""+a):e[a],r);return i},d=function(t,n,r){var i=n.computeData(t,{isArgument:r,args:[n.attr("."),n]});return e.compute.temporarilyBind(i.compute),i},v=function(e,t){var n=d(e,t,!0);return n.compute.computeInstance.hasDependencies?n.compute:n.initialValue},g=function(e,t,n,r,i,a){i&&(e.fn=m(i,t,n,r)),a&&(e.inverse=m(a,t,n,r))},m=function(t,n,r,i){var a=function(e,r,i){return t(e||n,r,i)};return e.__notObserve(function(t,s,o){void 0===t||t instanceof e.view.Scope||(t=n.add(t)),void 0===s||s instanceof x.Options||(s=r.add(s));var u=a(t,s||r,o||i);return u})},x={expressionData:function(n){var r=[],i={},a=0;return(e.trim(n)+" ").replace(o,function(e,n){var s;a&&(s=n.match(u))?s[1]||s[2]?r.push(t.jsonParse(s[1]||s[2])):i[s[3]]=s[6]?{get:s[6]}:t.jsonParse(s[4]||s[5]):r.push({get:n}),a++}),{name:r.shift(),args:r,hash:i}},makeEvaluator:function(r,i,a,s,o,u,c,p){for(var m,x,y,w=[],b={},_={fn:function(){},inverse:function(){}},O=r.attr("."),k=o.name,D=o.args.length||!e.isEmptyObject(o.hash),E=0,L=o.args.length;L>E;E++){var A=o.args[E];w.push(A&&l(A)?v(A.get,r,!0):A)}for(var N in o.hash)l(o.hash[N])?b[N]=v(o.hash[N].get,r):b[N]=o.hash[N];if(l(k)&&(D&&(m=n.getHelper(k.get,i),m||"function"!=typeof O[k.get]||(m={fn:O[k.get]})),!m)){var S=k.get,B=d(k.get,r,!1),R=B.compute;x=B.initialValue,k=B.compute.computeInstance.hasDependencies?R:x,D||void 0!==x?"function"==typeof x&&(m={fn:x}):m=n.getHelper(S,i)}if("^"===s){var j=u;u=c,c=j}if(m)return g(_,r,i,a,u,c),e.simpleExtend(_,{context:O,scope:r,contexts:r,hash:b,nodeList:a,exprData:o}),w.push(_),y=function(){return m.fn.apply(O,w)||""},y.bindOnce=!1,y;if(!s)return k&&k.isComputed?k:function(){return""+(null!=k?k:"")};if("#"===s||"^"===s){g(_,r,i,a,u,c);var F=function(){var n;if(n=e.isFunction(k)&&k.isComputed?k():k,t.isArrayLike(n)){var a=t.isObserveLike(n);return(a?n.attr("length"):n.length)?(p?h:f)(n,a,_,i):_.inverse(r,i)}return n?_.fn(n||r,i):_.inverse(r,i)};return F.bindOnce=!1,F}},makeLiveBindingPartialRenderer:function(t,n){return t=e.trim(t),function(i,a,o){var u=[this];u.expression=">"+t,s.register(u,null,n.directlyNested?o||!0:!0);var c=e.compute(function(){var n,r=t,s=a.attr("partials."+r);if(s)n=s.render?s.render(i,a):s(i,a);else{var o=i.read(r,{isArgument:!0,returnObserveMethods:!0,proxyMethods:!1}).value;o&&(r=o),n=e.view.render(r,i,a)}return e.frag(n)});r.html(this,c,this.parentNode,u)}},makeStringBranchRenderer:function(e,t){var n=w(t),r=e+t;return function(t,i,a,s){var o=t.__cache[r];(e||!o)&&(o=y(t,i,null,e,n,a,s,!0),e||(t.__cache[r]=o));var u=o();return null==u?"":""+u}},makeLiveBindingBranchRenderer:function(t,n,a){var o=w(n);return function(u,c,l,f,p){var h=[this];h.expression=n,s.register(h,null,a.directlyNested?l||!0:!0);var d=y(u,c,h,t,o,f,p,a.tag),v=e.compute(d,null,!1,d.bindOnce===!1?!1:!0);v.bind("change",e.k);var g=v();if("function"==typeof g){var m=e.__clearReading();g(this),e.__setReading(m)}else v.computeInstance.hasDependencies?a.attr?r.simpleAttribute(this,a.attr,v):a.tag?r.attributes(this,v):a.text&&"object"!=typeof g?r.text(this,v,this.parentNode,h):r.html(this,v,this.parentNode,h):a.attr?e.attr.set(this,a.attr,g):a.tag?r.setAttributes(this,g):a.text&&"string"==typeof g?this.nodeValue=g:g&&i.replace([this],e.frag(g));v.unbind("change",e.k)}},splitModeFromExpression:function(t,n){t=e.trim(t);var r=t.charAt(0);return"#/{&^>!".indexOf(r)>=0?t=e.trim(t.substr(1)):r=null,"{"===r&&n.node&&(r=null),{mode:r,expression:t}},cleanLineEndings:function(e){return e.replace(c,function(e,t,n,r,i,a,s,o,u,c){a=a||"",t=t||"",n=n||"";var l=b(i||u,{});return o||">{".indexOf(l.mode)>=0?e:"^#!/".indexOf(l.mode)>=0?r+(0!==c&&s.length?t+"\n":""):n+r+a+(n.length||0!==c?t+"\n":"")})},Options:e.view.Scope.extend({init:function(t,n){t.helpers||t.partials||t.tags||(t={helpers:t}),e.view.Scope.prototype.init.apply(this,arguments)}})},y=x.makeEvaluator,w=x.expressionData,b=x.splitModeFromExpression;return x}); +/*can@2.2.6#view/bindings/bindings*/ +define("can/view/bindings/bindings",["can/util/util","can/view/stache/mustache_core","can/view/callbacks/callbacks","can/control/control","can/view/scope/scope"],function(e,t){var n=function(){var e={"":!0,"true":!0,"false":!1},t=function(t){if(t&&t.getAttribute){var n=t.getAttribute("contenteditable");return e[n]}};return function(e){var n=t(e);return"boolean"==typeof n?n:!!t(e.parentNode)}}(),i=function(e){return"{"===e[0]&&"}"===e[e.length-1]?e.substr(1,e.length-2):e};e.view.attr("can-value",function(t,a){var c,l,h=e.trim(i(t.getAttribute("can-value"))),v=a.scope.computeData(h,{args:[]}).compute;return"input"===t.nodeName.toLowerCase()&&("checkbox"===t.type&&(c=e.attr.has(t,"can-true-value")?t.getAttribute("can-true-value"):!0,l=e.attr.has(t,"can-false-value")?t.getAttribute("can-false-value"):!1),"checkbox"===t.type||"radio"===t.type)?void new o(t,{value:v,trueValue:c,falseValue:l}):"select"===t.nodeName.toLowerCase()&&t.multiple?void new u(t,{value:v}):n(t)?void new r(t,{value:v}):void new s(t,{value:v})});var a={enter:function(e,t,n){return{event:"keyup",handler:function(e){return 13===e.keyCode?n.call(this,e):void 0}}}};e.view.attr(/can-[\w\.]+/,function(n,s){var o=s.attributeName,u=o.substr("can-".length),r=function(a){var u=n.getAttribute(o);if(u){var r=t.expressionData(i(u)),c=s.scope.read(r.name.get,{returnObserveMethods:!0,isArgument:!0,executeAnonymousFunctions:!0}),l=[],h=e.$(this),v=e.viewModel(h[0]),f=s.scope.add({"@element":h,"@event":a,"@viewModel":v,"@scope":s.scope,"@context":s.scope._context});if(!e.isEmptyObject(r.hash)){var p={};e.each(r.hash,function(e,t){if(e&&e.hasOwnProperty("get")){var n=e.get.indexOf("@")?s.scope:f;p[t]=n.read(e.get,{}).value}else p[t]=e}),l.unshift(p)}if(r.args.length)for(var d,g=r.args.length-1;g>=0;g--)if(d=r.args[g],d&&d.hasOwnProperty("get")){var m=d.get.indexOf("@")?s.scope:f;l.unshift(m.read(d.get,{}).value)}else l.unshift(d);return l.length||(l=[s.scope._context,h].concat(e.makeArray(arguments))),c.value.apply(c.parent,l)}};if(a[u]){var c=a[u](s,n,r);r=c.handler,u=c.event}e.bind.call(n,u,r)});var s=e.Control.extend({init:function(){"SELECT"===this.element[0].nodeName.toUpperCase()?setTimeout(e.proxy(this.set,this),1):this.set()},"{value} change":"set",set:function(){if(this.element){var e=this.options.value();this.element[0].value=null==e?"":e}},change:function(){if(this.element){var e=this.element[0];this.options.value(e.value);var t=this.options.value();e.value!==t&&(e.value=t)}}}),o=e.Control.extend({init:function(){this.isCheckbox="checkbox"===this.element[0].type.toLowerCase(),this.check()},"{value} change":"check",check:function(){if(this.isCheckbox){var t=this.options.value(),n=this.options.trueValue||!0;this.element[0].checked=t==n}else{var i=this.options.value()==this.element[0].value?"set":"remove";e.attr[i](this.element[0],"checked",!0)}},change:function(){this.isCheckbox?this.options.value(this.element[0].checked?this.options.trueValue:this.options.falseValue):this.element[0].checked&&this.options.value(this.element[0].value)}}),u=s.extend({init:function(){this.delimiter=";",setTimeout(e.proxy(this.set,this),1)},set:function(){var t=this.options.value();"string"==typeof t?(t=t.split(this.delimiter),this.isString=!0):t&&(t=e.makeArray(t));var n={};e.each(t,function(e){n[e]=!0}),e.each(this.element[0].childNodes,function(e){e.value&&(e.selected=!!n[e.value])})},get:function(){var t=[],n=this.element[0].childNodes;return e.each(n,function(e){e.selected&&e.value&&t.push(e.value)}),t},change:function(){var t=this.get(),n=this.options.value();this.isString||"string"==typeof n?(this.isString=!0,this.options.value(t.join(this.delimiter))):n instanceof e.List?n.attr(t,!0):this.options.value(t)}}),r=e.Control.extend({init:function(){this.set(),this.on("blur","setValue")},"{value} change":"set",set:function(){var e=this.options.value();this.element[0].innerHTML="undefined"==typeof e?"":e},setValue:function(){this.options.value(this.element[0].innerHTML)}})}); +/*can@2.2.6#view/mustache/mustache*/ +define("can/view/mustache/mustache",["can/util/util","can/view/scope/scope","can/view/view","can/view/scanner","can/compute/compute","can/view/render","can/view/bindings/bindings"],function(e){e.view.ext=".mustache";var n="scope",t="___h4sh",r="{scope:"+n+",options:options}",i="{scope:"+n+",options:options, special: true}",s=n+",options",o=/((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g,a=/^(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false|null|undefined)|((.+?)=(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false)|(.+))))$/,c=function(e){return'{get:"'+e.replace(/"/g,'\\"')+'"}'},u=function(e){return e&&"string"==typeof e.get},f=function(n){return n instanceof e.Map||n&&!!n._get},p=function(e){return e&&e.splice&&"number"==typeof e.length},l=function(n,t,r){var i=function(e,r){return n(e||t,r)};return function(n,s){return void 0===n||n instanceof e.view.Scope||(n=t.add(n)),void 0===s||s instanceof e.view.Options||(s=r.add(s)),i(n,s||r)}},h=function(n,t){if(this.constructor!==h){var r=new h(n);return function(e,n){return r.render(e,n)}}return"function"==typeof n?void(this.template={fn:n}):(e.extend(this,n),void(this.template=this.scanner.scan(this.text,this.name)))};e.Mustache=e.global.Mustache=h,h.prototype.render=function(n,t){return n instanceof e.view.Scope||(n=new e.view.Scope(n||{})),t instanceof e.view.Options||(t=new e.view.Options(t||{})),t=t||{},this.template.fn.call(n,n,t)},e.extend(h.prototype,{scanner:new e.view.Scanner({text:{start:"",scope:n,options:",options: options",argNames:s},tokens:[["returnLeft","{{{","{{[{&]"],["commentFull","{{!}}","^[\\s\\t]*{{!.+?}}\\n"],["commentLeft","{{!","(\\n[\\s\\t]*{{!|{{!)"],["escapeFull","{{}}","(^[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}$)",function(e){return{before:/^\n.+?\n$/.test(e)?"\n":"",content:e.match(/\{\{(.+?)\}\}/)[1]||""}}],["escapeLeft","{{"],["returnRight","}}}"],["right","}}"]],helpers:[{name:/^>[\s]*\w*/,fn:function(n,t){var r=e.trim(n.replace(/^>\s?/,"")).replace(/["|']/g,"");return"can.Mustache.renderPartial('"+r+"',"+s+")"}},{name:/^\s*data\s/,fn:function(e,t){var r=e.match(/["|'](.*)["|']/)[1];return"can.proxy(function(__){can.data(can.$(__),'"+r+"', this.attr('.')); }, "+n+")"}},{name:/\s*\(([\$\w]+)\)\s*->([^\n]*)/,fn:function(e){var t=/\s*\(([\$\w]+)\)\s*->([^\n]*)/,r=e.match(t);return"can.proxy(function(__){var "+r[1]+"=can.$(__);with("+n+".attr('.')){"+r[2]+"}}, this);"}},{name:/^.*$/,fn:function(n,u){var f=!1,p={content:"",startTxt:!1,startOnlyTxt:!1,end:!1};if(n=e.trim(n),n.length&&(f=n.match(/^([#^\/]|else$)/))){switch(f=f[0]){case"#":case"^":u.specialAttribute?p.startOnlyTxt=!0:(p.startTxt=!0,p.escaped=0);break;case"/":return p.end=!0,p.content+='return ___v1ew.join("");}}])',p}n=n.substring(1)}if("else"!==f){var l,h=[],v=[],g=0;p.content+="can.Mustache.txt(\n"+(u.specialAttribute?i:r)+",\n"+(f?'"'+f+'"':"null")+",",(e.trim(n)+" ").replace(o,function(e,n){g&&(l=n.match(a))?l[2]?h.push(l[0]):v.push(l[4]+":"+(l[6]?l[6]:c(l[5]))):h.push(c(n)),g++}),p.content+=h.join(","),v.length&&(p.content+=",{"+t+":{"+v.join(",")+"}}")}switch(f&&"else"!==f&&(p.content+=",[\n\n"),f){case"^":case"#":p.content+="{fn:function("+s+"){var ___v1ew = [];";break;case"else":p.content+='return ___v1ew.join("");}},\n{inverse:function('+s+"){\nvar ___v1ew = [];";break;default:p.content+=")"}return f||(p.startTxt=!0,p.end=!0),p}}]})});for(var v=e.view.Scanner.prototype.helpers,g=0;g0&&t!==n)return r.inverse();n=t}return r.fn()},eq:function(){return h._helpers.is.fn.apply(this,arguments)},unless:function(n,t){return h._helpers["if"].fn.apply(this,[e.isFunction(n)?e.compute(function(){return!n()}):!n,t])},each:function(n,t){var r,i,s,o=h.resolve(n),a=[];if(e.view.lists&&(o instanceof e.List||n&&n.isComputed&&void 0===o))return e.view.lists(n,function(e,n){return t.fn(t.scope.add({"@index":n}).add(e))});if(n=o,n&&p(n)){for(s=0;st;t++)f[t]()};if(t.each(this.constructor.attributeScopeMappings,function(e,n){r[n]=i.getAttribute(t.hyphenate(e))}),t.each(t.makeArray(i.attributes),function(n,i){var c=t.camelize(n.nodeName.toLowerCase()),u=n.value;if(!(p.constructor.attributeScopeMappings[c]||o.test(c)||e.attr(n.nodeName))){if("{"===u[0]&&"}"===u[u.length-1])u=u.substr(1,u.length-2);else if("legacy"!==s.templateType)return void(r[c]=u);var h=s.scope.computeData(u,{args:[]}),m=h.compute,v=function(e,n){d[c]=(d[c]||0)+1,a.attr(c,n),t.batch.afterPreviousEvents(function(){--d[c]})};m.bind("change",v),r[c]=m(),m.computeInstance.hasDependencies?(f.push(function(){m.unbind("change",v)}),l[c]=h):m.unbind("change",v)}}),this.constructor.Map)a=new this.constructor.Map(r);else if(h instanceof t.Map)a=h;else if(t.isFunction(h)){var v=h.call(this,r,s.scope,i);a=v instanceof t.Map?v:v.prototype instanceof t.Map?new v(r):new(t.Map.extend(v))(r)}var g={};t.each(l,function(t,e){g[e]=function(n,o){d[e]||t.compute(o)},a.bind(e,g[e])}),t.isEmptyObject(this.constructor.attributeScopeMappings)&&"legacy"===s.templateType||t.bind.call(i,"attributes",function(e){var n=t.camelize(e.attributeName);l[n]||o.test(n)||a.attr(n,i.getAttribute(e.attributeName))}),this.scope=this.viewModel=a,t.data(t.$(i),"scope",this.scope),t.data(t.$(i),"viewModel",this.scope);var b=u?this.scope:s.scope.add(this.scope),y={helpers:{}};if(t.each(this.helpers||{},function(e,n){t.isFunction(e)&&(y.helpers[n]=function(){return e.apply(a,arguments)})}),f.push(function(){t.each(g,function(t,e){a.unbind(e,g[e])})}),this._control=new this.constructor.Control(i,{scope:this.scope,viewModel:this.scope}),this._control&&this._control.destroy){var w=this._control.destroy;this._control.destroy=function(){w.apply(this,arguments),m()},this._control.on()}else t.bind.call(i,"removed",function(){m()});var M=t.view.nodeLists.register([],void 0,!0);f.push(function(){t.view.nodeLists.unregister(M)}),this.constructor.renderer?(y.tags||(y.tags={}),y.tags.content=function C(e,o){var i=s.subtemplate||o.subtemplate;if(i){delete y.tags.content;var a=u&&i===s.subtemplate?s:o;if(o.parentNodeList){var c=i(a.scope,a.options,o.parentNodeList);n.replace([e],c)}else t.view.live.replace([e],i(a.scope,a.options));y.tags.content=C}},c=this.constructor.renderer(b,s.options.add(y),M)):c="legacy"===s.templateType?t.view.frag(s.subtemplate?s.subtemplate(b,s.options.add(y)):""):s.subtemplate?s.subtemplate(b,s.options.add(y),M):document.createDocumentFragment(),t.appendChild(i,c),t.view.nodeLists.update(M,i.childNodes)}}),a=t.Control.extend({_lookup:function(t){return[t.scope,t,window]},_action:function(e,n,o){var s,a;if(i.lastIndex=0,s=i.test(e),o||!s){if(s){a=t.compute(function(){var o,s=e.replace(i,function(e,i){var s;return"scope"===i||"viewModel"===i?(o=n.scope,""):(i=i.replace(/^(scope|^viewModel)\./,""),s=t.compute.read(n.scope,i.split("."),{isArgument:!0}).value,void 0===s&&(s=t.getObject(i)),"string"==typeof s?s:(o=s,""))}),a=s.split(/\s+/g),c=a.pop();return{processor:this.processors[c]||this.processors.click,parts:[s,a.join(" "),c],delegate:o||void 0}},this);var c=function(t,n){o._bindings.control[e](o.element),o._bindings.control[e]=n.processor(n.delegate||o.element,n.parts[2],n.parts[1],e,o)};return a.bind("change",c),o._bindings.readyComputes[e]={compute:a,handler:c},a()}return t.Control._action.apply(this,arguments)}}},{setup:function(e,n){return this.scope=n.scope,this.viewModel=n.viewModel,t.Control.prototype.setup.call(this,e,n)},off:function(){this._bindings&&t.each(this._bindings.readyComputes||{},function(t){t.compute.unbind("change",t.handler)}),t.Control.prototype.off.apply(this,arguments),this._bindings.readyComputes={}}}),c=t.$;return c.fn&&(c.fn.scope=c.fn.viewModel=function(){return t.viewModel.apply(t,[this].concat(t.makeArray(arguments)))}),s}); +/*can@2.2.6#model/model*/ +define("can/model/model",["can/util/util","can/map/map","can/list/list"],function(t){var e=function(e,r,i){var n=new t.Deferred;return e.then(function(){var e=t.makeArray(arguments),s=!0;try{e[0]=i.apply(r,e)}catch(o){s=!1,n.rejectWith(n,[o].concat(e))}s&&n.resolveWith(n,e)},function(){n.rejectWith(this,arguments)}),"function"==typeof e.abort&&(n.abort=function(){return e.abort()}),n},r=0,i=function(e){return t.__observe(e,e.constructor.id),e.__get(e.constructor.id)},n=function(e,r,i,n,s,o){var a={};if("string"==typeof e){var u=e.split(/\s+/);a.url=u.pop(),u.length&&(a.type=u.pop())}else t.extend(a,e);return a.data="object"!=typeof r||t.isArray(r)?r:t.extend(a.data||{},r),a.url=t.sub(a.url,a.data,!0),t.ajax(t.extend({type:i||"post",dataType:n||"json",success:s,error:o},a))},s=function(r,n,s,o,a){var u;t.isArray(r)?(u=r[1],r=r[0]):u=r.serialize(),u=[u];var c,l,d=r.constructor;return("update"===n||"destroy"===n)&&u.unshift(i(r)),l=d[n].apply(d,u),c=e(l,r,function(t){return r[a||n+"d"](t,l),r}),l.abort&&(c.abort=function(){l.abort()}),c.then(s,o),c},o={models:function(e,r,i){if(t.Model._reqs++,e){if(e instanceof this.List)return e;var n=this,s=[],o=n.List||f,a=r instanceof t.List?r:new o,u=e instanceof f,c=u?e.serialize():e;if(c=n.parseModels(c,i),c.data&&(e=c,c=c.data),"undefined"==typeof c||!t.isArray(c))throw new Error("Could not get any raw data while converting using .models");return a.length&&a.splice(0),t.each(c,function(t){s.push(n.model(t,i))}),a.push.apply(a,s),t.isArray(e)||t.each(e,function(t,e){"data"!==e&&a.attr(e,t)}),setTimeout(t.proxy(this._clean,this),1),a}},model:function(e,r,i){if(e){e="function"==typeof e.serialize?e.serialize():this.parseModel(e,i);var n=e[this.id];(n||0===n)&&this.store[n]&&(r=this.store[n]);var s=r&&t.isFunction(r.attr)?r.attr(e,this.removeAttr||!1):new this(e);return s}}},a={parseModel:function(e){return function(r){return e?t.getObject(e,r):r}},parseModels:function(e){return function(r){if(t.isArray(r))return r;e=e||"data";var i=t.getObject(e,r);if(!t.isArray(i))throw new Error("Could not get any raw data while converting using .models");return i}}},u={create:{url:"_shortName",type:"post"},update:{data:function(e,r){r=r||{};var i=this.id;return r[i]&&r[i]!==e&&(r["new"+t.capitalize(e)]=r[i],delete r[i]),r[i]=e,r},type:"put"},destroy:{type:"delete",data:function(t,e){return e=e||{},e.id=e[this.id]=t,e}},findAll:{url:"_shortName"},findOne:{}},c=function(t,e){return function(r){return r=t.data?t.data.apply(this,arguments):r,n(e||this[t.url||"_url"],r,t.type||"get")}},l=function(t,e){if(t.resource){var r=t.resource.replace(/\/+$/,"");return"findAll"===e||"create"===e?r:r+"/{"+t.id+"}"}};t.Model=t.Map.extend({fullName:"can.Model",_reqs:0,setup:function(e,i,n,s){if("string"!=typeof i&&(s=n,n=i),s||(s=n),this.store={},t.Map.setup.apply(this,arguments),t.Model){n&&n.List?(this.List=n.List,this.List.Map=this):this.List=e.List.extend({Map:this},{});var d=this,p=t.proxy(this._clean,d);t.each(u,function(r,i){if(n&&n[i]&&("string"==typeof n[i]||"object"==typeof n[i])?d[i]=c(r,n[i]):n&&n.resource&&!t.isFunction(n[i])&&(d[i]=c(r,l(d,i))),d["make"+t.capitalize(i)]){var s=d["make"+t.capitalize(i)](d[i]);t.Construct._overwrite(d,e,i,function(){t.Model._reqs++;var e=s.apply(this,arguments),r=e.then(p,p);return r.abort=e.abort,r})}});var h={};t.each(o,function(r,i){var s="parse"+t.capitalize(i),o=n&&n[i]||d[i];"string"==typeof o?(d[s]=o,t.Construct._overwrite(d,e,i,r)):n&&n[i]&&(h[s]=!0)}),t.each(a,function(r,i){var s=n&&n[i]||d[i];if("string"==typeof s)t.Construct._overwrite(d,e,i,r(s));else if(!(n&&t.isFunction(n[i])||d[i])){var o=r();o.useModelConverter=h[i],t.Construct._overwrite(d,e,i,o)}}),"can.Model"!==d.fullName&&d.fullName||(d.fullName="Model"+ ++r),t.Model._reqs=0,this._url=this._shortName+"/{"+this.id+"}"}},_ajax:c,_makeRequest:s,_clean:function(){if(t.Model._reqs--,!t.Model._reqs)for(var e in this.store)this.store[e]._bindings||delete this.store[e];return arguments[0]},models:o.models,model:o.model},{setup:function(e){var r=e&&e[this.constructor.id];t.Model._reqs&&null!=r&&(this.constructor.store[r]=this),t.Map.prototype.setup.apply(this,arguments)},isNew:function(){var t=i(this);return!(t||0===t)},save:function(t,e){return s(this,this.isNew()?"create":"update",t,e)},destroy:function(e,r){if(this.isNew()){var i=this,n=t.Deferred();return n.then(e,r),n.done(function(t){i.destroyed(t)}).resolve(i)}return s(this,"destroy",e,r,"destroyed")},_bindsetup:function(){var e=this.__get(this.constructor.id);return null!=e&&(this.constructor.store[e]=this),t.Map.prototype._bindsetup.apply(this,arguments)},_bindteardown:function(){return delete this.constructor.store[i(this)],t.Map.prototype._bindteardown.apply(this,arguments)},___set:function(e,r){t.Map.prototype.___set.call(this,e,r),e===this.constructor.id&&this._bindings&&(this.constructor.store[i(this)]=this)}});var d=function(t){return function(e,r,i){return this[t](e,null,i)}},p=function(t){return this.parseModel.useModelConverter?this.model(t):this.parseModel(t)},h={makeFindAll:d("models"),makeFindOne:d("model"),makeCreate:p,makeUpdate:p,makeDestroy:p};t.each(h,function(r,i){t.Model[i]=function(i){return function(){var n=t.makeArray(arguments),s=t.isFunction(n[1])?n.splice(0,1):n.splice(0,2),o=e(i.apply(this,s),this,r);return o.then(n[0],n[1]),o}}}),t.each(["created","updated","destroyed"],function(e){t.Model.prototype[e]=function(r){var i=this,n=i.constructor;r&&"object"==typeof r&&this.attr(t.isFunction(r.attr)?r.attr():r),t.dispatch.call(this,{type:"change",target:this},[e]),t.dispatch.call(n,e,[this])}});var f=t.Model.List=t.List.extend({_bubbleRule:function(e,r){var i=t.List._bubbleRule(e,r);return i.push("destroyed"),i}},{setup:function(e){t.isPlainObject(e)&&!t.isArray(e)?(t.List.prototype.setup.apply(this),this.replace(t.isDeferred(e)?e:this.constructor.Map.findAll(e))):t.List.prototype.setup.apply(this,arguments),this._init=1,this.bind("destroyed",t.proxy(this._destroyed,this)),delete this._init},_destroyed:function(t,e){if(/\w+/.test(e))for(var r;(r=this.indexOf(t.target))>-1;)this.splice(r,1)}});return t.Model}); +/*can@2.2.6#util/string/deparam/deparam*/ +define("can/util/string/deparam/deparam",["can/util/util","can/util/string/string"],function(t){var n=/^\d+$/,e=/([^\[\]]+)|(\[\])/g,r=/([^?#]*)(#.*)?$/,i=function(t){return decodeURIComponent(t.replace(/\+/g," "))};return t.extend(t,{deparam:function(a){var u,c,o={};return a&&r.test(a)&&(u=a.split("&"),t.each(u,function(t){var r=t.split("="),a=i(r.shift()),u=i(r.join("=")),p=o;if(a){r=a.match(e);for(var s=0,d=r.length-1;d>s;s++)p[r[s]]||(p[r[s]]=n.test(r[s+1])||"[]"===r[s+1]?[]:{}),p=p[r[s]];c=r.pop(),"[]"===c?p.push(u):p[c]=u}})),o}}),t}); +/*can@2.2.6#route/route*/ +define("can/route/route",["can/util/util","can/map/map","can/list/list","can/util/string/deparam/deparam"],function(t){var e,r,n,a,u=/\:([\w\.]+)/g,o=/^(?:&[^=]+=[^&]*)+/,i=function(e){var r=[];return t.each(e,function(e,n){r.push(("className"===n?"class":n)+'="'+("href"===n?e:t.esc(e))+'"')}),r.join(" ")},c=function(t,e){var r=0,n=0,a={};for(var u in t.defaults)t.defaults[u]===e[u]&&(a[u]=1,r++);for(;no&&(n=t,o=a),a>=l?!1:void 0}),t.route.routes[i]&&c(t.route.routes[i],e)===o&&(n=t.route.routes[i]),n){var s,h=f({},e),p=n.route.replace(u,function(t,r){return delete h[r],e[r]===n.defaults[r]?"":encodeURIComponent(e[r])}).replace("\\","");return d(n.defaults,function(t,e){h[e]===t&&delete h[e]}),s=t.param(h),r&&t.route.attr("route",n.route),p+(s?t.route._call("querySeparator")+s:"")}return t.isEmptyObject(e)?"":t.route._call("querySeparator")+t.param(e)},deparam:function(e){var r=t.route._call("root");r.lastIndexOf("/")===r.length-1&&0===e.indexOf("/")&&(e=e.substr(1));var n={length:-1},a=t.route._call("querySeparator"),u=t.route._call("paramsMatcher");if(d(t.route.routes,function(t,r){t.test.test(e)&&t.length>n.length&&(n=t)}),n.length>-1){var o=e.match(n.test),i=o.shift(),c=e.substr(i.length-(o[o.length-1]===a?1:0)),l=c&&u.test(c)?t.deparam(c.slice(1)):{};return l=f(!0,{},n.defaults,l),d(o,function(t,e){t&&t!==a&&(l[n.names[e]]=decodeURIComponent(t))}),l.route=n.route,l}return e.charAt(0)!==a&&(e=a+e),u.test(e)?t.deparam(e.slice(1)):{}},data:new t.Map({}),map:function(e){var r;r=e.prototype instanceof t.Map?new e:e,t.route.data=r},routes:{},ready:function(e){return e!==!0&&(t.route._setup(),t.route.setState()),t.route},url:function(e,r){return r&&(e=t.extend({},t.route.deparam(t.route._call("matchingPartOfURL")),e)),t.route._call("root")+t.route.param(e)},link:function(e,r,n,a){return""+e+""},current:function(e){return t.__observe(_,"__url"),this._call("matchingPartOfURL")===t.route.param(e)},bindings:{hashchange:{paramsMatcher:o,querySeparator:"&",matchSlashes:!1,bind:function(){t.bind.call(window,"hashchange",b)},unbind:function(){t.unbind.call(window,"hashchange",b)},matchingPartOfURL:function(){return l.href.split(/#!?/)[1]||""},setURL:function(t){return l.hash!=="#"+t&&(l.hash="!"+t),t},root:"#!"}},defaultBinding:"hashchange",currentBinding:null,_setup:function(){t.route.currentBinding||(t.route._call("bind"),t.route.bind("change",m),t.route.currentBinding=t.route.defaultBinding)},_teardown:function(){t.route.currentBinding&&(t.route._call("unbind"),t.route.unbind("change",m),t.route.currentBinding=null),clearTimeout(e),a=0},_call:function(){var e=t.makeArray(arguments),r=e.shift(),n=t.route.bindings[t.route.currentBinding||t.route.defaultBinding],a=n[r];return a.apply?a.apply(n,e):a}}),d(["bind","unbind","on","off","delegate","undelegate","removeAttr","compute","_get","__get","each"],function(e){t.route[e]=function(){return t.route.data[e]?t.route.data[e].apply(t.route.data,arguments):void 0}}),t.route.attr=function(e,r){var n,a=typeof e;return n=void 0===r?arguments:"string"!==a&&"number"!==a?[h(e),r]:[e,h(r)],t.route.data.attr.apply(t.route.data,n)};var b=t.route.setState=function(){var e=t.route._call("matchingPartOfURL"),u=r;r=t.route.deparam(e),a&&e===n||(t.batch.start(),v(u,r,t.route.data),t.route.attr(r),t.batch.trigger(_,"__url",[e,n]),t.batch.stop())},v=function(t,e,r){for(var n in t)void 0===e[n]?r.removeAttr(n):"[object Object]"===Object.prototype.toString.call(t[n])&&v(t[n],e[n],r.attr(n))};return t.route}); +/*can@2.2.6#control/route/route*/ +define("can/control/route/route",["can/util/util","can/route/route","can/control/control"],function(t){return t.Control.processors.route=function(o,r,u,n,e){u=u||"",t.route.routes[u]||("/"===u[0]&&(u=u.substring(1)),t.route(u));var c,i=function(o,r,i){if(t.route.attr("route")===u&&(void 0===o.batchNum||o.batchNum!==c)){c=o.batchNum;var a=t.route.attr();delete a.route,t.isFunction(e[n])?e[n](a):e[e[n]](a)}};return t.route.bind("change",i),function(){t.route.unbind("change",i)}},t}); +/*[global-shim-end]*/ +!function(){window._define=window.define,window.define=window.define.orig}(); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/can.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/can.js new file mode 100644 index 0000000000..a068acb153 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/can.js @@ -0,0 +1,15 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#can*/ +var can = require('./util/util.js'); +require('./control/route/route.js'); +require('./model/model.js'); +require('./view/mustache/mustache.js'); +require('./component/component.js'); +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/component/component.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/component/component.js new file mode 100644 index 0000000000..13a839004b --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/component/component.js @@ -0,0 +1,271 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#component/component*/ +var can = require('../util/util.js'); +var viewCallbacks = require('../view/callbacks/callbacks.js'); +var elements = require('../view/elements.js'); +require('../control/control.js'); +require('../observe/observe.js'); +require('../view/mustache/mustache.js'); +require('../view/bindings/bindings.js'); +var ignoreAttributesRegExp = /^(dataViewId|class|id)$/i, paramReplacer = /\{([^\}]+)\}/g; +var Component = can.Component = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Component) { + var self = this, scope = this.prototype.scope || this.prototype.viewModel; + this.Control = ComponentControl.extend(this.prototype.events); + if (!scope || typeof scope === 'object' && !(scope instanceof can.Map)) { + this.Map = can.Map.extend(scope || {}); + } else if (scope.prototype instanceof can.Map) { + this.Map = scope; + } + this.attributeScopeMappings = {}; + can.each(this.Map ? this.Map.defaults : {}, function (val, prop) { + if (val === '@') { + self.attributeScopeMappings[prop] = prop; + } + }); + if (this.prototype.template) { + if (typeof this.prototype.template === 'function') { + var temp = this.prototype.template; + this.renderer = function () { + return can.view.frag(temp.apply(null, arguments)); + }; + } else { + this.renderer = can.view.mustache(this.prototype.template); + } + } + can.view.tag(this.prototype.tag, function (el, options) { + new self(el, options); + }); + } + } + }, { + setup: function (el, hookupOptions) { + var initialScopeData = {}, component = this, lexicalContent = (typeof this.leakScope === 'undefined' ? false : !this.leakScope) && this.template, twoWayBindings = {}, scope = this.scope || this.viewModel, viewModelPropertyUpdates = {}, componentScope, frag, teardownFunctions = [], callTeardownFunctions = function () { + for (var i = 0, len = teardownFunctions.length; i < len; i++) { + teardownFunctions[i](); + } + }; + can.each(this.constructor.attributeScopeMappings, function (val, prop) { + initialScopeData[prop] = el.getAttribute(can.hyphenate(val)); + }); + can.each(can.makeArray(el.attributes), function (node, index) { + var name = can.camelize(node.nodeName.toLowerCase()), value = node.value; + if (component.constructor.attributeScopeMappings[name] || ignoreAttributesRegExp.test(name) || viewCallbacks.attr(node.nodeName)) { + return; + } + if (value[0] === '{' && value[value.length - 1] === '}') { + value = value.substr(1, value.length - 2); + } else { + if (hookupOptions.templateType !== 'legacy') { + initialScopeData[name] = value; + return; + } + } + var computeData = hookupOptions.scope.computeData(value, { args: [] }), compute = computeData.compute; + var handler = function (ev, newVal) { + viewModelPropertyUpdates[name] = (viewModelPropertyUpdates[name] || 0) + 1; + componentScope.attr(name, newVal); + can.batch.afterPreviousEvents(function () { + --viewModelPropertyUpdates[name]; + }); + }; + compute.bind('change', handler); + initialScopeData[name] = compute(); + if (!compute.computeInstance.hasDependencies) { + compute.unbind('change', handler); + } else { + teardownFunctions.push(function () { + compute.unbind('change', handler); + }); + twoWayBindings[name] = computeData; + } + }); + if (this.constructor.Map) { + componentScope = new this.constructor.Map(initialScopeData); + } else if (scope instanceof can.Map) { + componentScope = scope; + } else if (can.isFunction(scope)) { + var scopeResult = scope.call(this, initialScopeData, hookupOptions.scope, el); + if (scopeResult instanceof can.Map) { + componentScope = scopeResult; + } else if (scopeResult.prototype instanceof can.Map) { + componentScope = new scopeResult(initialScopeData); + } else { + componentScope = new (can.Map.extend(scopeResult))(initialScopeData); + } + } + var handlers = {}; + can.each(twoWayBindings, function (computeData, prop) { + handlers[prop] = function (ev, newVal) { + if (!viewModelPropertyUpdates[prop]) { + computeData.compute(newVal); + } + }; + componentScope.bind(prop, handlers[prop]); + }); + if (!can.isEmptyObject(this.constructor.attributeScopeMappings) || hookupOptions.templateType !== 'legacy') { + can.bind.call(el, 'attributes', function (ev) { + var camelized = can.camelize(ev.attributeName); + if (!twoWayBindings[camelized] && !ignoreAttributesRegExp.test(camelized)) { + componentScope.attr(camelized, el.getAttribute(ev.attributeName)); + } + }); + } + this.scope = this.viewModel = componentScope; + can.data(can.$(el), 'scope', this.scope); + can.data(can.$(el), 'viewModel', this.scope); + var renderedScope = lexicalContent ? this.scope : hookupOptions.scope.add(this.scope), options = { helpers: {} }; + can.each(this.helpers || {}, function (val, prop) { + if (can.isFunction(val)) { + options.helpers[prop] = function () { + return val.apply(componentScope, arguments); + }; + } + }); + teardownFunctions.push(function () { + can.each(handlers, function (handler, prop) { + componentScope.unbind(prop, handlers[prop]); + }); + }); + this._control = new this.constructor.Control(el, { + scope: this.scope, + viewModel: this.scope + }); + if (this._control && this._control.destroy) { + var oldDestroy = this._control.destroy; + this._control.destroy = function () { + oldDestroy.apply(this, arguments); + callTeardownFunctions(); + }; + this._control.on(); + } else { + can.bind.call(el, 'removed', function () { + callTeardownFunctions(); + }); + } + var nodeList = can.view.nodeLists.register([], undefined, true); + teardownFunctions.push(function () { + can.view.nodeLists.unregister(nodeList); + }); + if (this.constructor.renderer) { + if (!options.tags) { + options.tags = {}; + } + options.tags.content = function contentHookup(el, rendererOptions) { + var subtemplate = hookupOptions.subtemplate || rendererOptions.subtemplate; + if (subtemplate) { + delete options.tags.content; + var opts = !lexicalContent || subtemplate !== hookupOptions.subtemplate ? rendererOptions : hookupOptions; + if (rendererOptions.parentNodeList) { + var frag = subtemplate(opts.scope, opts.options, rendererOptions.parentNodeList); + elements.replace([el], frag); + } else { + can.view.live.replace([el], subtemplate(opts.scope, opts.options)); + } + options.tags.content = contentHookup; + } + }; + frag = this.constructor.renderer(renderedScope, hookupOptions.options.add(options), nodeList); + } else { + if (hookupOptions.templateType === 'legacy') { + frag = can.view.frag(hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options)) : ''); + } else { + frag = hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options), nodeList) : document.createDocumentFragment(); + } + } + can.appendChild(el, frag); + can.view.nodeLists.update(nodeList, el.childNodes); + } + }); +var ComponentControl = can.Control.extend({ + _lookup: function (options) { + return [ + options.scope, + options, + window + ]; + }, + _action: function (methodName, options, controlInstance) { + var hasObjectLookup, readyCompute; + paramReplacer.lastIndex = 0; + hasObjectLookup = paramReplacer.test(methodName); + if (!controlInstance && hasObjectLookup) { + return; + } else if (!hasObjectLookup) { + return can.Control._action.apply(this, arguments); + } else { + readyCompute = can.compute(function () { + var delegate; + var name = methodName.replace(paramReplacer, function (matched, key) { + var value; + if (key === 'scope' || key === 'viewModel') { + delegate = options.scope; + return ''; + } + key = key.replace(/^(scope|^viewModel)\./, ''); + value = can.compute.read(options.scope, key.split('.'), { isArgument: true }).value; + if (value === undefined) { + value = can.getObject(key); + } + if (typeof value === 'string') { + return value; + } else { + delegate = value; + return ''; + } + }); + var parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: this.processors[event] || this.processors.click, + parts: [ + name, + parts.join(' '), + event + ], + delegate: delegate || undefined + }; + }, this); + var handler = function (ev, ready) { + controlInstance._bindings.control[methodName](controlInstance.element); + controlInstance._bindings.control[methodName] = ready.processor(ready.delegate || controlInstance.element, ready.parts[2], ready.parts[1], methodName, controlInstance); + }; + readyCompute.bind('change', handler); + controlInstance._bindings.readyComputes[methodName] = { + compute: readyCompute, + handler: handler + }; + return readyCompute(); + } + } + }, { + setup: function (el, options) { + this.scope = options.scope; + this.viewModel = options.viewModel; + return can.Control.prototype.setup.call(this, el, options); + }, + off: function () { + if (this._bindings) { + can.each(this._bindings.readyComputes || {}, function (value) { + value.compute.unbind('change', value.handler); + }); + } + can.Control.prototype.off.apply(this, arguments); + this._bindings.readyComputes = {}; + } + }); +var $ = can.$; +if ($.fn) { + $.fn.scope = $.fn.viewModel = function () { + return can.viewModel.apply(can, [this].concat(can.makeArray(arguments))); + }; +} +module.exports = Component; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/compute/compute.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/compute/compute.js new file mode 100644 index 0000000000..ad6cdb18d3 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/compute/compute.js @@ -0,0 +1,67 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#compute/compute*/ +var can = require('../util/util.js'); +var bind = require('../util/bind/bind.js'); +require('../util/batch/batch.js'); +require('./proto_compute.js'); +can.compute = function (getterSetter, context, eventName, bindOnce) { + var internalCompute = new can.Compute(getterSetter, context, eventName, bindOnce); + var compute = function (val) { + if (arguments.length) { + return internalCompute.set(val); + } + return internalCompute.get(); + }; + compute.bind = can.proxy(internalCompute.bind, internalCompute); + compute.unbind = can.proxy(internalCompute.unbind, internalCompute); + compute.isComputed = internalCompute.isComputed; + compute.clone = function (ctx) { + if (typeof getterSetter === 'function') { + context = ctx; + } + return can.compute(getterSetter, context, ctx, bindOnce); + }; + compute.computeInstance = internalCompute; + return compute; +}; +var k = function () { +}; +var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; +can.compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); +}; +can.compute.truthy = function (compute) { + return can.compute(function () { + var res = compute(); + if (typeof res === 'function') { + res = res(); + } + return !!res; + }); +}; +can.compute.async = function (initialValue, asyncComputer, context) { + return can.compute(initialValue, { + fn: asyncComputer, + context: context + }); +}; +can.compute.read = can.Compute.read; +can.compute.set = can.Compute.set; +module.exports = can.compute; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/compute/get_value_and_bind.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/compute/get_value_and_bind.js new file mode 100644 index 0000000000..35b8d5eb39 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/compute/get_value_and_bind.js @@ -0,0 +1,90 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#compute/get_value_and_bind*/ +require('../util/util.js'); +function observe(func, context, oldInfo, onchanged) { + var info = getValueAndObserved(func, context), newObserveSet = info.observed, oldObserved = oldInfo.observed; + if (info.names !== oldInfo.names) { + bindNewSet(oldObserved, newObserveSet, onchanged); + unbindOldSet(oldObserved, onchanged); + } + can.batch.afterPreviousEvents(function () { + info.ready = true; + }); + return info; +} +var observedStack = []; +can.__isRecordingObserves = function () { + return observedStack.length; +}; +can.__observe = can.__reading = function (obj, event) { + if (observedStack.length) { + var name = obj._cid + '|' + event, top = observedStack[observedStack.length - 1]; + top.names += name; + top.observed[name] = { + obj: obj, + event: event + '' + }; + } +}; +can.__notObserve = function (fn) { + return function () { + var previousReads = can.__clearObserved(); + var res = fn.apply(this, arguments); + can.__setObserved(previousReads); + return res; + }; +}; +can.__clearObserved = can.__clearReading = function () { + if (observedStack.length) { + var ret = observedStack[observedStack.length - 1]; + observedStack[observedStack.length - 1] = { observed: {} }; + return ret; + } +}; +can.__setObserved = can.__setReading = function (o) { + if (observedStack.length) { + observedStack[observedStack.length - 1] = o; + } +}; +can.__addObserved = can.__addReading = function (o) { + if (observedStack.length) { + can.simpleExtend(observedStack[observedStack.length - 1], o); + } +}; +var getValueAndObserved = function (func, self) { + observedStack.push({ + names: '', + observed: {} + }); + var value = func.call(self); + var stackItem = observedStack.pop(); + stackItem.value = value; + return stackItem; +}; +var bindNewSet = function (oldObserved, newObserveSet, onchanged) { + for (var name in newObserveSet) { + bindOrPreventUnbinding(oldObserved, newObserveSet, name, onchanged); + } +}; +var bindOrPreventUnbinding = function (oldObserved, newObserveSet, name, onchanged) { + if (oldObserved[name]) { + delete oldObserved[name]; + } else { + var obEv = newObserveSet[name]; + obEv.obj.bind(obEv.event, onchanged); + } +}; +var unbindOldSet = function (oldObserved, onchanged) { + for (var name in oldObserved) { + var obEv = oldObserved[name]; + obEv.obj.unbind(obEv.event, onchanged); + } +}; +module.exports = observe; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/compute/proto_compute.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/compute/proto_compute.js new file mode 100644 index 0000000000..511c10f124 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/compute/proto_compute.js @@ -0,0 +1,290 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#compute/proto_compute*/ +var can = require('../util/util.js'); +var bind = require('../util/bind/bind.js'); +var read = require('./read.js'); +var getValueAndBind = require('./get_value_and_bind.js'); +require('../util/batch/batch.js'); +var updateOnChange = function (compute, newValue, oldValue, batchNum) { + if (newValue !== oldValue) { + can.batch.trigger(compute, batchNum ? { + type: 'change', + batchNum: batchNum + } : 'change', [ + newValue, + oldValue + ]); + } +}; +var setupComputeHandlers = function (compute, func, context, singleBind) { + var readInfo, onchanged, batchNum; + singleBind = false; + return { + on: function (updater) { + var self = this; + if (!onchanged) { + onchanged = function (ev) { + if (readInfo.ready && compute.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + if (singleBind) { + newValue = func.call(context); + readInfo.value = newValue; + } else { + readInfo = getValueAndBind(func, context, readInfo, onchanged); + newValue = readInfo.value; + } + self.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }; + } + readInfo = getValueAndBind(func, context, { observed: {} }, onchanged); + if (singleBind) { + func = can.__notObserve(func); + } + compute.value = readInfo.value; + compute.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function (updater) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, onchanged); + } + } + }; +}; +var k = function () { +}; +var updater = function (newVal, oldVal, batchNum) { + this.value = newVal; + updateOnChange(this, newVal, oldVal, batchNum); + }, asyncGet = function (fn, context, lastSetValue) { + return function () { + return fn.call(context, lastSetValue.get()); + }; + }, asyncUpdater = function (context, oldUpdater) { + return function (newVal) { + if (newVal !== undefined) { + oldUpdater(newVal, context.value); + } + }; + }; +can.Compute = function (getterSetter, context, eventName, bindOnce) { + var args = []; + for (var i = 0, arglen = arguments.length; i < arglen; i++) { + args[i] = arguments[i]; + } + var contextType = typeof args[1]; + if (typeof args[0] === 'function') { + this._setupGetterSetterFn(args[0], args[1], args[2], args[3]); + } else if (args[1]) { + if (contextType === 'string') { + this._setupContextString(args[0], args[1], args[2]); + } else if (contextType === 'function') { + this._setupContextFunction(args[0], args[1], args[2]); + } else { + if (args[1] && args[1].fn) { + this._setupAsyncCompute(args[0], args[1]); + } else { + this._setupContextSettings(args[0], args[1]); + } + } + } else { + this._setupInitialValue(args[0]); + } + this._args = args; + this.isComputed = true; + can.cid(this, 'compute'); +}; +can.simpleExtend(can.Compute.prototype, { + _bindsetup: can.__notObserve(function () { + this.bound = true; + this._on(this.updater); + }), + _bindteardown: function () { + this._off(this.updater); + this.bound = false; + }, + bind: can.bindAndSetup, + unbind: can.unbindAndTeardown, + clone: function (context) { + if (context && typeof this._args[0] === 'function') { + this._args[1] = context; + } else if (context) { + this._args[2] = context; + } + return new can.Compute(this._args[0], this._args[1], this._args[2], this._args[3]); + }, + _on: k, + _off: k, + get: function () { + if (can.__isRecordingObserves() && this._canObserve !== false) { + can.__observe(this, 'change'); + if (!this.bound) { + can.Compute.temporarilyBind(this); + } + } + if (this.bound) { + return this.value; + } else { + return this._get(); + } + }, + _get: function () { + return this.value; + }, + set: function (newVal) { + var old = this.value; + var setVal = this._set(newVal, old); + if (this.hasDependencies) { + if (this._setUpdates) { + return this.value; + } + return this._get(); + } + if (setVal === undefined) { + this.value = this._get(); + } else { + this.value = setVal; + } + updateOnChange(this, this.value, old); + return this.value; + }, + _set: function (newVal) { + return this.value = newVal; + }, + updater: updater, + _computeFn: function (newVal) { + if (arguments.length) { + return this.set(newVal); + } + return this.get(); + }, + toFunction: function () { + return can.proxy(this._computeFn, this); + }, + _setupGetterSetterFn: function (getterSetter, context, eventName, bindOnce) { + this._set = can.proxy(getterSetter, context); + this._get = can.proxy(getterSetter, context); + this._canObserve = eventName === false ? false : true; + var handlers = setupComputeHandlers(this, getterSetter, context || this, bindOnce); + this._on = handlers.on; + this._off = handlers.off; + }, + _setupContextString: function (target, propertyName, eventName) { + var isObserve = can.isMapLike(target), self = this, handler = function (ev, newVal, oldVal) { + self.updater(newVal, oldVal, ev.batchNum); + }; + if (isObserve) { + this.hasDependencies = true; + this._get = function () { + return target.attr(propertyName); + }; + this._set = function (val) { + target.attr(propertyName, val); + }; + this._on = function (update) { + target.bind(eventName || propertyName, handler); + this.value = this._get(); + }; + this._off = function () { + return target.unbind(eventName || propertyName, handler); + }; + } else { + this._get = can.proxy(this._get, target); + this._set = can.proxy(this._set, target); + } + }, + _setupContextFunction: function (initialValue, setter, eventName) { + this.value = initialValue; + this._set = setter; + can.simpleExtend(this, eventName); + }, + _setupContextSettings: function (initialValue, settings) { + this.value = initialValue; + this._set = settings.set ? can.proxy(settings.set, settings) : this._set; + this._get = settings.get ? can.proxy(settings.get, settings) : this._get; + if (!settings.__selfUpdater) { + var self = this, oldUpdater = this.updater; + this.updater = function () { + oldUpdater.call(self, self._get(), self.value); + }; + } + this._on = settings.on ? settings.on : this._on; + this._off = settings.off ? settings.off : this._off; + }, + _setupAsyncCompute: function (initialValue, settings) { + this.value = initialValue; + var oldUpdater = can.proxy(this.updater, this), self = this, fn = settings.fn, data; + this.updater = oldUpdater; + var lastSetValue = new can.Compute(initialValue); + this.lastSetValue = lastSetValue; + this._setUpdates = true; + this._set = function (newVal) { + if (newVal === lastSetValue.get()) { + return this.value; + } + return lastSetValue.set(newVal); + }; + this._get = asyncGet(fn, settings.context, lastSetValue); + if (fn.length === 0) { + data = setupComputeHandlers(this, fn, settings.context); + } else if (fn.length === 1) { + data = setupComputeHandlers(this, function () { + return fn.call(settings.context, lastSetValue.get()); + }, settings); + } else { + this.updater = asyncUpdater(this, oldUpdater); + data = setupComputeHandlers(this, function () { + var res = fn.call(settings.context, lastSetValue.get(), function (newVal) { + oldUpdater(newVal, self.value); + }); + return res !== undefined ? res : this.value; + }, settings); + } + this._on = data.on; + this._off = data.off; + }, + _setupInitialValue: function (initialValue) { + this.value = initialValue; + } +}); +var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; +can.Compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); +}; +can.Compute.async = function (initialValue, asyncComputer, context) { + return new can.Compute(initialValue, { + fn: asyncComputer, + context: context + }); +}; +can.Compute.read = read; +can.Compute.set = read.write; +can.Compute.truthy = function (compute) { + return new can.Compute(function () { + var res = compute.get(); + if (typeof res === 'function') { + res = res.get(); + } + return !!res; + }); +}; +module.exports = can.Compute; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/compute/read.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/compute/read.js new file mode 100644 index 0000000000..0b8e590409 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/compute/read.js @@ -0,0 +1,188 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#compute/read*/ +var can = require('../util/util.js'); +var read = function (parent, reads, options) { + options = options || {}; + var state = { foundObservable: false }; + var cur = readValue(parent, 0, reads, options, state), type, prev, readLength = reads.length, i = 0; + while (i < readLength) { + prev = cur; + for (var r = 0, readersLength = read.propertyReaders.length; r < readersLength; r++) { + var reader = read.propertyReaders[r]; + if (reader.test(cur)) { + cur = reader.read(cur, reads[i], i, options, state); + break; + } + } + i = i + 1; + cur = readValue(cur, i, reads, options, state, prev); + type = typeof cur; + if (i < reads.length && (cur === null || type !== 'function' && type !== 'object')) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1, cur); + } + return { + value: undefined, + parent: prev + }; + } + } + if (cur === undefined) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1); + } + } + return { + value: cur, + parent: prev + }; +}; +var readValue = function (value, index, reads, options, state, prev) { + var usedValueReader; + do { + usedValueReader = false; + for (var i = 0, len = read.valueReaders.length; i < len; i++) { + if (read.valueReaders[i].test(value, index, reads, options)) { + value = read.valueReaders[i].read(value, index, reads, options, state, prev); + } + } + } while (usedValueReader); + return value; +}; +read.valueReaders = [ + { + name: 'compute', + test: function (value, i, reads, options) { + return value && value.isComputed; + }, + read: function (value, i, reads, options, state) { + if (options.isArgument && i === reads.length) { + return value; + } + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, i); + state.foundObservable = true; + } + return value instanceof can.Compute ? value.get() : value(); + } + }, + { + name: 'function', + test: function (value, i, reads, options) { + var type = typeof value; + return type === 'function' && !value.isComputed && (options.executeAnonymousFunctions || options.isArgument && i === reads.length) && !(can.Construct && value.prototype instanceof can.Construct) && !(can.route && value === can.route); + }, + read: function (value, i, reads, options, state, prev) { + if (options.isArgument && i === reads.length) { + return options.proxyMethods !== false ? can.proxy(value, prev) : value; + } + return value.call(prev); + } + } +]; +read.propertyReaders = [ + { + name: 'map', + test: can.isMapLike, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + if (typeof value[prop] === 'function' && value.constructor.prototype[prop] === value[prop]) { + if (options.returnObserveMethods) { + return value[prop]; + } else if (prop === 'constructor' && value instanceof can.Construct || value[prop].prototype instanceof can.Construct) { + return value[prop]; + } else { + return value[prop].apply(value, options.args || []); + } + } else { + return value.attr(prop); + } + } + }, + { + name: 'promise', + test: function (value) { + return can.isPromise(value); + }, + read: function (value, prop, index, options, state) { + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + var observeData = value.__observeData; + if (!value.__observeData) { + observeData = value.__observeData = { + isPending: true, + state: 'pending', + isResolved: false, + isRejected: false, + value: undefined, + reason: undefined + }; + can.cid(observeData); + can.simpleExtend(observeData, can.event); + value.then(function (value) { + observeData.isPending = false; + observeData.isResolved = true; + observeData.value = value; + observeData.state = 'resolved'; + observeData.dispatch('state', [ + 'resolved', + 'pending' + ]); + }, function (reason) { + observeData.isPending = false; + observeData.isRejected = true; + observeData.reason = reason; + observeData.state = 'rejected'; + observeData.dispatch('state', [ + 'rejected', + 'pending' + ]); + }); + } + can.__observe(observeData, 'state'); + return prop in observeData ? observeData[prop] : value[prop]; + } + }, + { + name: 'object', + test: function () { + return true; + }, + read: function (value, prop) { + if (value == null) { + return undefined; + } else { + return value[prop]; + } + } + } +]; +read.write = function (parent, key, value, options) { + options = options || {}; + if (can.isMapLike(parent)) { + if (!options.isArgument && parent._data && parent._data[key] && parent._data[key].isComputed) { + return parent._data[key](value); + } else { + return parent.attr(key, value); + } + } + if (parent[key] && parent[key].isComputed) { + return parent[key](value); + } + if (typeof parent === 'object') { + parent[key] = value; + } +}; +module.exports = read; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/construct/construct.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/construct/construct.js new file mode 100644 index 0000000000..c44710f835 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/construct/construct.js @@ -0,0 +1,139 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#construct/construct*/ +var can = require('../util/string/string.js'); +var initializing = 0; +var canGetDescriptor; +try { + Object.getOwnPropertyDescriptor({}); + canGetDescriptor = true; +} catch (e) { + canGetDescriptor = false; +} +var getDescriptor = function (newProps, name) { + var descriptor = Object.getOwnPropertyDescriptor(newProps, name); + if (descriptor && (descriptor.get || descriptor.set)) { + return descriptor; + } + return null; + }, inheritGetterSetter = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + var descriptor; + for (var name in newProps) { + if (descriptor = getDescriptor(newProps, name)) { + this._defineProperty(addTo, oldProps, name, descriptor); + } else { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + } + }, simpleInherit = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + for (var name in newProps) { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + }; +can.Construct = function () { + if (arguments.length) { + return can.Construct.extend.apply(can.Construct, arguments); + } +}; +can.extend(can.Construct, { + constructorExtends: true, + newInstance: function () { + var inst = this.instance(), args; + if (inst.setup) { + args = inst.setup.apply(inst, arguments); + } + if (inst.init) { + inst.init.apply(inst, args || arguments); + } + return inst; + }, + _inherit: canGetDescriptor ? inheritGetterSetter : simpleInherit, + _defineProperty: function (what, oldProps, propName, descriptor) { + Object.defineProperty(what, propName, descriptor); + }, + _overwrite: function (what, oldProps, propName, val) { + what[propName] = val; + }, + setup: function (base, fullName) { + this.defaults = can.extend(true, {}, base.defaults, this.defaults); + }, + instance: function () { + initializing = 1; + var inst = new this(); + initializing = 0; + return inst; + }, + extend: function (name, staticProperties, instanceProperties) { + var fullName = name, klass = staticProperties, proto = instanceProperties; + if (typeof fullName !== 'string') { + proto = klass; + klass = fullName; + fullName = null; + } + if (!proto) { + proto = klass; + klass = null; + } + proto = proto || {}; + var _super_class = this, _super = this.prototype, Constructor, parts, current, _fullName, _shortName, propName, shortName, namespace, prototype; + prototype = this.instance(); + can.Construct._inherit(proto, _super, prototype); + if (fullName) { + parts = fullName.split('.'); + shortName = parts.pop(); + } + if (typeof constructorName === 'undefined') { + Constructor = function () { + return init.apply(this, arguments); + }; + } + function init() { + if (!initializing) { + return this.constructor !== Constructor && arguments.length && Constructor.constructorExtends ? Constructor.extend.apply(Constructor, arguments) : Constructor.newInstance.apply(Constructor, arguments); + } + } + for (propName in _super_class) { + if (_super_class.hasOwnProperty(propName)) { + Constructor[propName] = _super_class[propName]; + } + } + can.Construct._inherit(klass, _super_class, Constructor); + if (fullName) { + current = can.getObject(parts.join('.'), window, true); + namespace = current; + _fullName = can.underscore(fullName.replace(/\./g, '_')); + _shortName = can.underscore(shortName); + current[shortName] = Constructor; + } + can.extend(Constructor, { + constructor: Constructor, + prototype: prototype, + namespace: namespace, + _shortName: _shortName, + fullName: fullName, + _fullName: _fullName + }); + if (shortName !== undefined) { + Constructor.shortName = shortName; + } + Constructor.prototype.constructor = Constructor; + var t = [_super_class].concat(can.makeArray(arguments)), args = Constructor.setup.apply(Constructor, t); + if (Constructor.init) { + Constructor.init.apply(Constructor, args || t); + } + return Constructor; + } +}); +can.Construct.prototype.setup = function () { +}; +can.Construct.prototype.init = function () { +}; +module.exports = can.Construct; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/construct/proxy/proxy.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/construct/proxy/proxy.js new file mode 100644 index 0000000000..27aeb7e9a9 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/construct/proxy/proxy.js @@ -0,0 +1,46 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#construct/proxy/proxy*/ +var can = require('../../util/util.js'); +var Construct = require('../construct.js'); +var isFunction = can.isFunction, isArray = can.isArray, makeArray = can.makeArray, proxy = function (funcs) { + var args = makeArray(arguments), self; + funcs = args.shift(); + if (!isArray(funcs)) { + funcs = [funcs]; + } + self = this; + return function class_cb() { + var cur = args.concat(makeArray(arguments)), isString, length = funcs.length, f = 0, func; + for (; f < length; f++) { + func = funcs[f]; + if (!func) { + continue; + } + isString = typeof func === 'string'; + cur = (isString ? self[func] : func).apply(self, cur || []); + if (f < length - 1) { + cur = !isArray(cur) || cur._use_call ? [cur] : cur; + } + } + return cur; + }; + }; +can.Construct.proxy = can.Construct.prototype.proxy = proxy; +var correctedClasses = [ + can.Map, + can.Control, + can.Model + ], i = 0; +for (; i < correctedClasses.length; i++) { + if (correctedClasses[i]) { + correctedClasses[i].proxy = proxy; + } +} +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/construct/super/super.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/construct/super/super.js new file mode 100644 index 0000000000..cdea2247c2 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/construct/super/super.js @@ -0,0 +1,42 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#construct/super/super*/ +var can = require('../../util/util.js'); +var Construct = require('../construct.js'); +var isFunction = can.isFunction, fnTest = /xyz/.test(function () { + return this.xyz; + }) ? /\b_super\b/ : /.*/, getset = [ + 'get', + 'set' + ], getSuper = function (base, name, fn) { + return function () { + var tmp = this._super, ret; + this._super = base[name]; + ret = fn.apply(this, arguments); + this._super = tmp; + return ret; + }; + }; +can.Construct._defineProperty = function (addTo, base, name, descriptor) { + var _super = Object.getOwnPropertyDescriptor(base, name); + if (_super) { + can.each(getset, function (method) { + if (isFunction(_super[method]) && isFunction(descriptor[method])) { + descriptor[method] = getSuper(_super, method, descriptor[method]); + } else if (!isFunction(descriptor[method])) { + descriptor[method] = _super[method]; + } + }); + } + Object.defineProperty(addTo, name, descriptor); +}; +can.Construct._overwrite = function (addTo, base, name, val) { + addTo[name] = isFunction(val) && isFunction(base[name]) && fnTest.test(val) ? getSuper(base, name, val) : val; +}; +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/control/control.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/control/control.js new file mode 100644 index 0000000000..0f17489581 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/control/control.js @@ -0,0 +1,200 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#control/control*/ +var can = require('../util/util.js'); +require('../construct/construct.js'); +var bind = function (el, ev, callback) { + can.bind.call(el, ev, callback); + return function () { + can.unbind.call(el, ev, callback); + }; + }, isFunction = can.isFunction, extend = can.extend, each = can.each, slice = [].slice, paramReplacer = /\{([^\}]+)\}/g, special = can.getObject('$.event.special', [can]) || {}, delegate = function (el, selector, ev, callback) { + can.delegate.call(el, selector, ev, callback); + return function () { + can.undelegate.call(el, selector, ev, callback); + }; + }, binder = function (el, ev, callback, selector) { + return selector ? delegate(el, can.trim(selector), ev, callback) : bind(el, ev, callback); + }, basicProcessor; +var Control = can.Control = can.Construct({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Control) { + var control = this, funcName; + control.actions = {}; + for (funcName in control.prototype) { + if (control._isAction(funcName)) { + control.actions[funcName] = control._action(funcName); + } + } + } + }, + _shifter: function (context, name) { + var method = typeof name === 'string' ? context[name] : name; + if (!isFunction(method)) { + method = context[method]; + } + return function () { + context.called = name; + return method.apply(context, [this.nodeName ? can.$(this) : this].concat(slice.call(arguments, 0))); + }; + }, + _isAction: function (methodName) { + var val = this.prototype[methodName], type = typeof val; + return methodName !== 'constructor' && (type === 'function' || type === 'string' && isFunction(this.prototype[val])) && !!(special[methodName] || processors[methodName] || /[^\w]/.test(methodName)); + }, + _action: function (methodName, options) { + paramReplacer.lastIndex = 0; + if (options || !paramReplacer.test(methodName)) { + var convertedName = options ? can.sub(methodName, this._lookup(options)) : methodName; + if (!convertedName) { + return null; + } + var arr = can.isArray(convertedName), name = arr ? convertedName[1] : convertedName, parts = name.split(/\s+/g), event = parts.pop(); + return { + processor: processors[event] || basicProcessor, + parts: [ + name, + parts.join(' '), + event + ], + delegate: arr ? convertedName[0] : undefined + }; + } + }, + _lookup: function (options) { + return [ + options, + window + ]; + }, + processors: {}, + defaults: {} + }, { + setup: function (element, options) { + var cls = this.constructor, pluginname = cls.pluginName || cls._fullName, arr; + this.element = can.$(element); + if (pluginname && pluginname !== 'can_control') { + this.element.addClass(pluginname); + } + arr = can.data(this.element, 'controls'); + if (!arr) { + arr = []; + can.data(this.element, 'controls', arr); + } + arr.push(this); + this.options = extend({}, cls.defaults, options); + this.on(); + return [ + this.element, + this.options + ]; + }, + on: function (el, selector, eventName, func) { + if (!el) { + this.off(); + var cls = this.constructor, bindings = this._bindings, actions = cls.actions, element = this.element, destroyCB = can.Control._shifter(this, 'destroy'), funcName, ready; + for (funcName in actions) { + if (actions.hasOwnProperty(funcName)) { + ready = actions[funcName] || cls._action(funcName, this.options, this); + if (ready) { + bindings.control[funcName] = ready.processor(ready.delegate || element, ready.parts[2], ready.parts[1], funcName, this); + } + } + } + can.bind.call(element, 'removed', destroyCB); + bindings.user.push(function (el) { + can.unbind.call(el, 'removed', destroyCB); + }); + return bindings.user.length; + } + if (typeof el === 'string') { + func = eventName; + eventName = selector; + selector = el; + el = this.element; + } + if (func === undefined) { + func = eventName; + eventName = selector; + selector = null; + } + if (typeof func === 'string') { + func = can.Control._shifter(this, func); + } + this._bindings.user.push(binder(el, eventName, func, selector)); + return this._bindings.user.length; + }, + off: function () { + var el = this.element[0], bindings = this._bindings; + if (bindings) { + each(bindings.user || [], function (value) { + value(el); + }); + each(bindings.control || {}, function (value) { + value(el); + }); + } + this._bindings = { + user: [], + control: {} + }; + }, + destroy: function () { + if (this.element === null) { + return; + } + var Class = this.constructor, pluginName = Class.pluginName || Class._fullName, controls; + this.off(); + if (pluginName && pluginName !== 'can_control') { + this.element.removeClass(pluginName); + } + controls = can.data(this.element, 'controls'); + controls.splice(can.inArray(this, controls), 1); + can.trigger(this, 'destroyed'); + this.element = null; + } + }); +var processors = can.Control.processors; +basicProcessor = function (el, event, selector, methodName, control) { + return binder(el, event, can.Control._shifter(control, methodName), selector); +}; +each([ + 'change', + 'click', + 'contextmenu', + 'dblclick', + 'keydown', + 'keyup', + 'keypress', + 'mousedown', + 'mousemove', + 'mouseout', + 'mouseover', + 'mouseup', + 'reset', + 'resize', + 'scroll', + 'select', + 'submit', + 'focusin', + 'focusout', + 'mouseenter', + 'mouseleave', + 'touchstart', + 'touchmove', + 'touchcancel', + 'touchend', + 'touchleave', + 'inserted', + 'removed' +], function (v) { + processors[v] = basicProcessor; +}); +module.exports = Control; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/control/plugin/plugin.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/control/plugin/plugin.js new file mode 100644 index 0000000000..b04da75507 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/control/plugin/plugin.js @@ -0,0 +1,78 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#control/plugin/plugin*/ +var $ = require('jquery'); +var can = require('../../util/util.js'); +require('../control.js'); +$ = $ || window.$; +var i, isAControllerOf = function (instance, controllers) { + var name = instance.constructor.pluginName || instance.constructor._shortName; + for (i = 0; i < controllers.length; i++) { + if (typeof controllers[i] === 'string' ? name === controllers[i] : instance instanceof controllers[i]) { + return true; + } + } + return false; + }, makeArray = can.makeArray, old = can.Control.setup; +can.Control.setup = function () { + if (this !== can.Control) { + var pluginName = this.pluginName || this._fullName; + if (pluginName !== 'can_control') { + this.plugin(pluginName); + } + old.apply(this, arguments); + } +}; +$.fn.extend({ + controls: function () { + var controllerNames = makeArray(arguments), instances = [], controls, c; + this.each(function () { + controls = can.$(this).data('controls'); + if (!controls) { + return; + } + for (var i = 0; i < controls.length; i++) { + c = controls[i]; + if (!controllerNames.length || isAControllerOf(c, controllerNames)) { + instances.push(c); + } + } + }); + return instances; + }, + control: function (control) { + return this.controls.apply(this, arguments)[0]; + } +}); +can.Control.plugin = function (pluginname) { + var control = this; + if (!$.fn[pluginname]) { + $.fn[pluginname] = function (options) { + var args = makeArray(arguments), isMethod = typeof options === 'string' && $.isFunction(control.prototype[options]), meth = args[0], returns; + this.each(function () { + var plugin = can.$(this).control(control); + if (plugin) { + if (isMethod) { + returns = plugin[meth].apply(plugin, args.slice(1)); + } else { + plugin.update.apply(plugin, args); + } + } else { + control.newInstance.apply(control, [this].concat(args)); + } + }); + return returns !== undefined ? returns : this; + }; + } +}; +can.Control.prototype.update = function (options) { + can.extend(this.options, options); + this.on(); +}; +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/control/route/route.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/control/route/route.js new file mode 100644 index 0000000000..a2af861860 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/control/route/route.js @@ -0,0 +1,38 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#control/route/route*/ +var can = require('../../util/util.js'); +require('../../route/route.js'); +require('../control.js'); +can.Control.processors.route = function (el, event, selector, funcName, controller) { + selector = selector || ''; + if (!can.route.routes[selector]) { + if (selector[0] === '/') { + selector = selector.substring(1); + } + can.route(selector); + } + var batchNum, check = function (ev, attr, how) { + if (can.route.attr('route') === selector && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + batchNum = ev.batchNum; + var d = can.route.attr(); + delete d.route; + if (can.isFunction(controller[funcName])) { + controller[funcName](d); + } else { + controller[controller[funcName]](d); + } + } + }; + can.route.bind('change', check); + return function () { + can.route.unbind('change', check); + }; +}; +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/event/event.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/event/event.js new file mode 100644 index 0000000000..ef8ba9b1fc --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/event/event.js @@ -0,0 +1,151 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#event/event*/ +var can = require('../util/can.js'); +can.addEvent = function (event, handler) { + var allEvents = this.__bindEvents || (this.__bindEvents = {}), eventList = allEvents[event] || (allEvents[event] = []); + eventList.push({ + handler: handler, + name: event + }); + return this; +}; +can.listenTo = function (other, event, handler) { + var idedEvents = this.__listenToEvents; + if (!idedEvents) { + idedEvents = this.__listenToEvents = {}; + } + var otherId = can.cid(other); + var othersEvents = idedEvents[otherId]; + if (!othersEvents) { + othersEvents = idedEvents[otherId] = { + obj: other, + events: {} + }; + } + var eventsEvents = othersEvents.events[event]; + if (!eventsEvents) { + eventsEvents = othersEvents.events[event] = []; + } + eventsEvents.push(handler); + can.bind.call(other, event, handler); +}; +can.stopListening = function (other, event, handler) { + var idedEvents = this.__listenToEvents, iterIdedEvents = idedEvents, i = 0; + if (!idedEvents) { + return this; + } + if (other) { + var othercid = can.cid(other); + (iterIdedEvents = {})[othercid] = idedEvents[othercid]; + if (!idedEvents[othercid]) { + return this; + } + } + for (var cid in iterIdedEvents) { + var othersEvents = iterIdedEvents[cid], eventsEvents; + other = idedEvents[cid].obj; + if (!event) { + eventsEvents = othersEvents.events; + } else { + (eventsEvents = {})[event] = othersEvents.events[event]; + } + for (var eventName in eventsEvents) { + var handlers = eventsEvents[eventName] || []; + i = 0; + while (i < handlers.length) { + if (handler && handler === handlers[i] || !handler) { + can.unbind.call(other, eventName, handlers[i]); + handlers.splice(i, 1); + } else { + i++; + } + } + if (!handlers.length) { + delete othersEvents.events[eventName]; + } + } + if (can.isEmptyObject(othersEvents.events)) { + delete idedEvents[cid]; + } + } + return this; +}; +can.removeEvent = function (event, fn, __validate) { + if (!this.__bindEvents) { + return this; + } + var events = this.__bindEvents[event] || [], i = 0, ev, isFunction = typeof fn === 'function'; + while (i < events.length) { + ev = events[i]; + if (__validate ? __validate(ev, event, fn) : isFunction && ev.handler === fn || !isFunction && (ev.cid === fn || !fn)) { + events.splice(i, 1); + } else { + i++; + } + } + return this; +}; +can.dispatch = function (event, args) { + var events = this.__bindEvents; + if (!events) { + return; + } + if (typeof event === 'string') { + event = { type: event }; + } + var eventName = event.type, handlers = (events[eventName] || []).slice(0), passed = [event]; + if (args) { + passed.push.apply(passed, args); + } + for (var i = 0, len = handlers.length; i < len; i++) { + handlers[i].handler.apply(this, passed); + } + return event; +}; +can.one = function (event, handler) { + var one = function () { + can.unbind.call(this, event, one); + return handler.apply(this, arguments); + }; + can.bind.call(this, event, one); + return this; +}; +can.event = { + on: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.on.call(this); + } else { + return can.addEvent.apply(this, arguments); + } + }, + off: function () { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.off.call(this); + } else { + return can.removeEvent.apply(this, arguments); + } + }, + bind: can.addEvent, + unbind: can.removeEvent, + delegate: function (selector, event, handler) { + return can.addEvent.call(this, event, handler); + }, + undelegate: function (selector, event, handler) { + return can.removeEvent.call(this, event, handler); + }, + trigger: can.dispatch, + one: can.one, + addEvent: can.addEvent, + removeEvent: can.removeEvent, + listenTo: can.listenTo, + stopListening: can.stopListening, + dispatch: can.dispatch +}; +module.exports = can.event; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/list/list.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/list/list.js new file mode 100644 index 0000000000..0913b4aa7d --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/list/list.js @@ -0,0 +1,261 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#list/list*/ +var can = require('../util/util.js'); +var Map = require('../map/map.js'); +var bubble = require('../map/bubble.js'); +var splice = [].splice, spliceRemovesProps = function () { + var obj = { + 0: 'a', + length: 1 + }; + splice.call(obj, 0, 1); + return !obj[0]; + }(); +var list = Map.extend({ Map: Map }, { + setup: function (instances, options) { + this.length = 0; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + this._setupComputes(); + instances = instances || []; + var teardownMapping; + if (can.isDeferred(instances)) { + this.replace(instances); + } else { + teardownMapping = instances.length && can.Map.helpers.addToMap(instances, this); + this.push.apply(this, can.makeArray(instances || [])); + } + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + can.simpleExtend(this, options); + delete this._init; + }, + _triggerChange: function (attr, how, newVal, oldVal) { + Map.prototype._triggerChange.apply(this, arguments); + var index = +attr; + if (!~('' + attr).indexOf('.') && !isNaN(index)) { + if (how === 'add') { + can.batch.trigger(this, how, [ + newVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else if (how === 'remove') { + can.batch.trigger(this, how, [ + oldVal, + index + ]); + can.batch.trigger(this, 'length', [this.length]); + } else { + can.batch.trigger(this, how, [ + newVal, + index + ]); + } + } + }, + __get: function (attr) { + if (attr) { + if (this[attr] && this[attr].isComputed && can.isFunction(this.constructor.prototype[attr])) { + return this[attr](); + } else { + return this[attr]; + } + } else { + return this; + } + }, + __set: function (prop, value, current) { + prop = isNaN(+prop) || prop % 1 ? prop : +prop; + if (typeof prop === 'number' && prop > this.length - 1) { + var newArr = new Array(prop + 1 - this.length); + newArr[newArr.length - 1] = value; + this.push.apply(this, newArr); + return newArr; + } + return can.Map.prototype.__set.call(this, '' + prop, value, current); + }, + ___set: function (attr, val) { + this[attr] = val; + if (+attr >= this.length) { + this.length = +attr + 1; + } + }, + _remove: function (prop, current) { + if (isNaN(+prop)) { + delete this[prop]; + this._triggerChange(prop, 'remove', undefined, current); + } else { + this.splice(prop, 1); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var i = 0; i < data.length; i++) { + callback(data[i], i); + } + }, + serialize: function () { + return Map.helpers.serialize(this, 'serialize', []); + }, + splice: function (index, howMany) { + var args = can.makeArray(arguments), added = [], i, len, listIndex, allSame = args.length > 2; + index = index || 0; + for (i = 0, len = args.length - 2; i < len; i++) { + listIndex = i + 2; + args[listIndex] = this.__type(args[listIndex], listIndex); + added.push(args[listIndex]); + if (this[i + index] !== args[listIndex]) { + allSame = false; + } + } + if (allSame && this.length <= added.length) { + return added; + } + if (howMany === undefined) { + howMany = args[1] = this.length - index; + } + var removed = splice.apply(this, args); + if (!spliceRemovesProps) { + for (i = this.length; i < removed.length + this.length; i++) { + delete this[i]; + } + } + can.batch.start(); + if (howMany > 0) { + bubble.removeMany(this, removed); + this._triggerChange('' + index, 'remove', undefined, removed); + } + if (args.length > 2) { + for (i = 0, len = added.length; i < len; i++) { + bubble.set(this, i, added[i]); + } + this._triggerChange('' + index, 'add', added, removed); + } + can.batch.stop(); + return removed; + }, + _attrs: function (items, remove) { + if (items === undefined) { + return Map.helpers.serialize(this, 'attr', []); + } + items = can.makeArray(items); + can.batch.start(); + this._updateAttrs(items, remove); + can.batch.stop(); + }, + _updateAttrs: function (items, remove) { + var len = Math.min(items.length, this.length); + for (var prop = 0; prop < len; prop++) { + var curVal = this[prop], newVal = items[prop]; + if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + this._set(prop, newVal); + } else { + } + } + if (items.length > this.length) { + this.push.apply(this, items.slice(this.length)); + } else if (items.length < this.length && remove) { + this.splice(items.length); + } + } + }), getArgs = function (args) { + return args[0] && can.isArray(args[0]) ? args[0] : can.makeArray(args); + }; +can.each({ + push: 'length', + unshift: 0 +}, function (where, name) { + var orig = [][name]; + list.prototype[name] = function () { + var args = [], len = where ? this.length : 0, i = arguments.length, res, val; + while (i--) { + val = arguments[i]; + args[i] = bubble.set(this, i, this.__type(val, i)); + } + res = orig.apply(this, args); + if (!this.comparator || args.length) { + this._triggerChange('' + len, 'add', args, undefined); + } + return res; + }; +}); +can.each({ + pop: 'length', + shift: 0 +}, function (where, name) { + list.prototype[name] = function () { + if (!this.length) { + return undefined; + } + var args = getArgs(arguments), len = where && this.length ? this.length - 1 : 0; + var res = [][name].apply(this, args); + this._triggerChange('' + len, 'remove', undefined, [res]); + if (res && res.unbind) { + bubble.remove(this, res); + } + return res; + }; +}); +can.extend(list.prototype, { + indexOf: function (item, fromIndex) { + this.attr('length'); + return can.inArray(item, this, fromIndex); + }, + join: function () { + return [].join.apply(this.attr(), arguments); + }, + reverse: function () { + var list = [].reverse.call(can.makeArray(this)); + this.replace(list); + }, + slice: function () { + var temp = Array.prototype.slice.apply(this, arguments); + return new this.constructor(temp); + }, + concat: function () { + var args = []; + can.each(can.makeArray(arguments), function (arg, i) { + args[i] = arg instanceof can.List ? arg.serialize() : arg; + }); + return new this.constructor(Array.prototype.concat.apply(this.serialize(), args)); + }, + forEach: function (cb, thisarg) { + return can.each(this, cb, thisarg || this); + }, + replace: function (newList) { + if (can.isDeferred(newList)) { + newList.then(can.proxy(this.replace, this)); + } else { + this.splice.apply(this, [ + 0, + this.length + ].concat(can.makeArray(newList || []))); + } + return this; + }, + filter: function (callback, thisArg) { + var filteredList = new can.List(), self = this, filtered; + this.each(function (item, index, list) { + filtered = callback.call(thisArg | self, item, index, self); + if (filtered) { + filteredList.push(item); + } + }); + return filteredList; + } +}); +can.List = Map.List = list; +module.exports = can.List; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/list/promise/promise.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/list/promise/promise.js new file mode 100644 index 0000000000..7d2d29d39c --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/list/promise/promise.js @@ -0,0 +1,57 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#list/promise/promise*/ +var list = require('../list.js'); +var oldReplace = can.List.prototype.replace; +can.List.prototype.replace = function (data) { + var result = oldReplace.apply(this, arguments); + if (can.isDeferred(data)) { + can.batch.start(); + this.attr('state', data.state()); + this.removeAttr('reason'); + can.batch.stop(); + var self = this; + var deferred = this._deferred = new can.Deferred(); + data.then(function () { + self.attr('state', data.state()); + deferred.resolve(self); + }, function (reason) { + can.batch.start(); + self.attr('state', data.state()); + self.attr('reason', reason); + can.batch.stop(); + deferred.reject(reason); + }); + } + return result; +}; +can.each({ + isResolved: 'resolved', + isPending: 'pending', + isRejected: 'rejected' +}, function (value, method) { + can.List.prototype[method] = function () { + return this.attr('state') === value; + }; +}); +can.each([ + 'then', + 'done', + 'fail', + 'always', + 'promise' +], function (name) { + can.List.prototype[name] = function () { + if (!this._deferred) { + this._deferred = new can.Deferred(); + this._deferred.resolve(this); + } + return this._deferred[name].apply(this._deferred, arguments); + }; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/list/sort/sort.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/list/sort/sort.js new file mode 100644 index 0000000000..c0b5077d3a --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/list/sort/sort.js @@ -0,0 +1,195 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#list/sort/sort*/ +require('../../util/util.js'); +require('../list.js'); +var oldBubbleRule = can.List._bubbleRule; +can.List._bubbleRule = function (eventName, list) { + var oldBubble = oldBubbleRule.apply(this, arguments); + if (list.comparator && can.inArray('change', oldBubble) === -1) { + oldBubble.push('change'); + } + return oldBubble; +}; +var proto = can.List.prototype, _changes = proto._changes, setup = proto.setup, unbind = proto.unbind; +can.extend(proto, { + setup: function (instances, options) { + setup.apply(this, arguments); + this._comparatorBound = false; + this._init = 1; + this.bind('comparator', can.proxy(this._comparatorUpdated, this)); + delete this._init; + if (this.comparator) { + this.sort(); + } + }, + _comparatorUpdated: function (ev, newValue) { + if (newValue || newValue === 0) { + this.sort(); + if (this._bindings > 0 && !this._comparatorBound) { + this.bind('change', this._comparatorBound = function () { + }); + } + } else if (this._comparatorBound) { + unbind.call(this, 'change', this._comparatorBound); + this._comparatorBound = false; + } + }, + unbind: function (ev, handler) { + var res = unbind.apply(this, arguments); + if (this._comparatorBound && this._bindings === 1) { + unbind.call(this, 'change', this._comparatorBound); + this._comparatorBound = false; + } + return res; + }, + _comparator: function (a, b) { + var comparator = this.comparator; + if (comparator && typeof comparator === 'function') { + return comparator(a, b); + } + return a === b ? 0 : a < b ? -1 : 1; + }, + _changes: function (ev, attr, how, newVal, oldVal) { + if (this.comparator && /^\d+/.test(attr)) { + if (ev.batchNum && ev.batchNum !== this._lastBatchNum) { + this.sort(); + this._lastBatchNum = ev.batchNum; + return; + } + var currentIndex = +/^\d+/.exec(attr)[0], item = this[currentIndex]; + if (typeof item !== 'undefined') { + var newIndex = this._getInsertIndex(item, currentIndex); + if (newIndex !== currentIndex) { + this._swapItems(currentIndex, newIndex); + can.trigger(this, 'length', [this.length]); + } + } + } + _changes.apply(this, arguments); + }, + _getInsertIndex: function (item, currentIndex) { + var a = this._getComparatorValue(item), b, offset = 0; + for (var i = 0; i < this.length; i++) { + b = this._getComparatorValue(this[i]); + if (typeof currentIndex !== 'undefined' && i === currentIndex) { + offset = -1; + continue; + } + if (this._comparator(a, b) < 0) { + return i + offset; + } + } + return i + offset; + }, + _getComparatorValue: function (item, overwrittenComparator) { + var comparator = typeof overwrittenComparator === 'string' ? overwrittenComparator : this.comparator; + if (item && comparator && typeof comparator === 'string') { + item = typeof item[comparator] === 'function' ? item[comparator]() : item.attr(comparator); + } + return item; + }, + _getComparatorValues: function () { + var self = this; + var a = []; + this.each(function (item, index) { + a.push(self._getComparatorValue(item)); + }); + return a; + }, + sort: function (comparator, silent) { + var a, b, c, isSorted; + var comparatorFn = can.isFunction(comparator) ? comparator : this._comparator; + for (var i, iMin, j = 0, n = this.length; j < n - 1; j++) { + iMin = j; + isSorted = true; + c = undefined; + for (i = j + 1; i < n; i++) { + a = this._getComparatorValue(this.attr(i), comparator); + b = this._getComparatorValue(this.attr(iMin), comparator); + if (comparatorFn.call(this, a, b) < 0) { + isSorted = false; + iMin = i; + } + if (c && comparatorFn.call(this, a, c) < 0) { + isSorted = false; + } + c = a; + } + if (isSorted) { + break; + } + if (iMin !== j) { + this._swapItems(iMin, j, silent); + } + } + if (!silent) { + can.trigger(this, 'length', [this.length]); + } + return this; + }, + _swapItems: function (oldIndex, newIndex, silent) { + var temporaryItemReference = this[oldIndex]; + [].splice.call(this, oldIndex, 1); + [].splice.call(this, newIndex, 0, temporaryItemReference); + if (!silent) { + can.trigger(this, 'move', [ + temporaryItemReference, + newIndex, + oldIndex + ]); + } + } +}); +var getArgs = function (args) { + return args[0] && can.isArray(args[0]) ? args[0] : can.makeArray(args); +}; +can.each({ + push: 'length', + unshift: 0 +}, function (where, name) { + var proto = can.List.prototype, old = proto[name]; + proto[name] = function () { + if (this.comparator && arguments.length) { + var args = getArgs(arguments); + var i = args.length; + while (i--) { + var val = can.bubble.set(this, i, this.__type(args[i], i)); + var newIndex = this._getInsertIndex(val); + Array.prototype.splice.apply(this, [ + newIndex, + 0, + val + ]); + this._triggerChange('' + newIndex, 'add', [val], undefined); + } + can.batch.trigger(this, 'reset', [args]); + return this; + } else { + return old.apply(this, arguments); + } + }; +}); +(function () { + var proto = can.List.prototype; + var oldSplice = proto.splice; + proto.splice = function (index, howMany) { + var args = can.makeArray(arguments), newElements = [], i, len; + if (!this.comparator) { + return oldSplice.apply(this, args); + } + for (i = 2, len = args.length; i < len; i++) { + args[i] = this.__type(args[i], i); + newElements.push(args[i]); + } + oldSplice.call(this, index, howMany); + proto.push.apply(this, newElements); + }; +}()); +module.exports = can.Map; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/attributes/attributes.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/attributes/attributes.js new file mode 100644 index 0000000000..424013131b --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/attributes/attributes.js @@ -0,0 +1,118 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/attributes/attributes*/ +var can = require('../../util/util.js'); +var Map = require('../map.js'); +require('../../list/list.js'); +can.each([ + can.Map, + can.Model +], function (clss) { + if (clss === undefined) { + return; + } + var isObject = function (obj) { + return typeof obj === 'object' && obj !== null && obj; + }; + can.extend(clss, { + attributes: {}, + convert: { + 'date': function (str) { + var type = typeof str; + if (type === 'string') { + str = Date.parse(str); + return isNaN(str) ? null : new Date(str); + } else if (type === 'number') { + return new Date(str); + } else { + return str; + } + }, + 'number': function (val) { + return parseFloat(val); + }, + 'boolean': function (val) { + if (val === 'false' || val === '0' || !val) { + return false; + } + return true; + }, + 'default': function (val, oldVal, error, type) { + if (can.Map.prototype.isPrototypeOf(type.prototype) && typeof type.model === 'function' && typeof type.models === 'function') { + return type[can.isArray(val) ? 'models' : 'model'](val); + } + if (can.Map.prototype.isPrototypeOf(type.prototype)) { + if (can.isArray(val) && typeof type.List === 'function') { + return new type.List(val); + } + return new type(val); + } + if (typeof type === 'function') { + return type(val, oldVal); + } + var construct = can.getObject(type), context = window, realType; + if (type.indexOf('.') >= 0) { + realType = type.substring(0, type.lastIndexOf('.')); + context = can.getObject(realType); + } + return typeof construct === 'function' ? construct.call(context, val, oldVal) : val; + } + }, + serialize: { + 'default': function (val, type) { + return isObject(val) && val.serialize ? val.serialize() : val; + }, + 'date': function (val) { + return val && val.getTime(); + } + } + }); + var oldSetup = clss.setup; + clss.setup = function (superClass, stat, proto) { + var self = this; + oldSetup.call(self, superClass, stat, proto); + can.each(['attributes'], function (name) { + if (!self[name] || superClass[name] === self[name]) { + self[name] = {}; + } + }); + can.each([ + 'convert', + 'serialize' + ], function (name) { + if (superClass[name] !== self[name]) { + self[name] = can.extend({}, superClass[name], self[name]); + } + }); + }; +}); +can.Map.prototype.__convert = function (prop, value) { + var Class = this.constructor, oldVal = this.__get(prop), type, converter; + if (Class.attributes) { + type = Class.attributes[prop]; + converter = Class.convert[type] || Class.convert['default']; + } + return value === null || !type ? value : converter.call(Class, value, oldVal, function () { + }, type); +}; +var oldSerialize = can.Map.helpers._serialize; +can.Map.helpers._serialize = function (map, name, val) { + var constructor = map.constructor, type = constructor.attributes ? constructor.attributes[name] : 0, converter = constructor.serialize ? constructor.serialize[type] : 0; + return val && typeof val.serialize === 'function' ? oldSerialize.apply(this, arguments) : converter ? converter(val, type) : oldSerialize.apply(this, arguments); +}; +var mapSerialize = can.Map.prototype.serialize; +can.Map.prototype.serialize = function (attrName) { + var baseResult = mapSerialize.apply(this, arguments); + if (attrName) { + return baseResult[attrName]; + } else { + return baseResult; + } +}; +module.exports = can.Map; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/backup/backup.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/backup/backup.js new file mode 100644 index 0000000000..56dbd2e9c1 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/backup/backup.js @@ -0,0 +1,46 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/backup/backup*/ +var can = require('../../util/util.js'); +require('../../compute/compute.js'); +require('../map.js'); +require('../../util/object/object.js'); +var flatProps = function (a, cur) { + var obj = {}; + for (var prop in a) { + if (typeof a[prop] !== 'object' || a[prop] === null || a[prop] instanceof Date) { + obj[prop] = a[prop]; + } else { + obj[prop] = cur.attr(prop); + } + } + return obj; +}; +var oldSetup = can.Map.prototype.setup; +can.extend(can.Map.prototype, { + setup: function () { + this._backupStore = can.compute(); + return oldSetup.apply(this, arguments); + }, + backup: function () { + this._backupStore(this.attr()); + return this; + }, + isDirty: function (checkAssociations) { + return this._backupStore() && !can.Object.same(this.attr(), this._backupStore(), undefined, undefined, undefined, !!checkAssociations); + }, + restore: function (restoreAssociations) { + var props = restoreAssociations ? this._backupStore() : flatProps(this._backupStore(), this); + if (this.isDirty(restoreAssociations)) { + this.attr(props, true); + } + return this; + } +}); +module.exports = can.Map; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/bubble.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/bubble.js new file mode 100644 index 0000000000..604e75f39b --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/bubble.js @@ -0,0 +1,114 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/bubble*/ +var can = require('../util/util.js'); +var bubble = can.bubble = { + event: function (map, boundEventName) { + return map.constructor._bubbleRule(boundEventName, map); + }, + childrenOf: function (parentMap, eventName) { + parentMap._each(function (child, prop) { + if (child && child.bind) { + bubble.toParent(child, parentMap, prop, eventName); + } + }); + }, + teardownChildrenFrom: function (parentMap, eventName) { + parentMap._each(function (child) { + bubble.teardownFromParent(parentMap, child, eventName); + }); + }, + toParent: function (child, parent, prop, eventName) { + can.listenTo.call(parent, child, eventName, function () { + var args = can.makeArray(arguments), ev = args.shift(); + args[0] = (can.List && parent instanceof can.List ? parent.indexOf(child) : prop) + (args[0] ? '.' + args[0] : ''); + ev.triggeredNS = ev.triggeredNS || {}; + if (ev.triggeredNS[parent._cid]) { + return; + } + ev.triggeredNS[parent._cid] = true; + can.trigger(parent, ev, args); + }); + }, + teardownFromParent: function (parent, child, eventName) { + if (child && child.unbind) { + can.stopListening.call(parent, child, eventName); + } + }, + isBubbling: function (parent, eventName) { + return parent._bubbleBindings && parent._bubbleBindings[eventName]; + }, + bind: function (parent, eventName) { + if (!parent._init) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + if (!parent._bubbleBindings) { + parent._bubbleBindings = {}; + } + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (!parent._bubbleBindings[bubbleEvent]) { + parent._bubbleBindings[bubbleEvent] = 1; + bubble.childrenOf(parent, bubbleEvent); + } else { + parent._bubbleBindings[bubbleEvent]++; + } + } + } + }, + unbind: function (parent, eventName) { + var bubbleEvents = bubble.event(parent, eventName), len = bubbleEvents.length, bubbleEvent; + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + if (parent._bubbleBindings) { + parent._bubbleBindings[bubbleEvent]--; + } + if (parent._bubbleBindings && !parent._bubbleBindings[bubbleEvent]) { + delete parent._bubbleBindings[bubbleEvent]; + bubble.teardownChildrenFrom(parent, bubbleEvent); + if (can.isEmptyObject(parent._bubbleBindings)) { + delete parent._bubbleBindings; + } + } + } + }, + add: function (parent, child, prop) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + bubble.toParent(child, parent, prop, eventName); + } + } + } + }, + removeMany: function (parent, children) { + for (var i = 0, len = children.length; i < len; i++) { + bubble.remove(parent, children[i]); + } + }, + remove: function (parent, child) { + if (child instanceof can.Map && parent._bubbleBindings) { + for (var eventName in parent._bubbleBindings) { + if (parent._bubbleBindings[eventName]) { + bubble.teardownFromParent(parent, child, eventName); + } + } + } + }, + set: function (parent, prop, value, current) { + if (can.Map.helpers.isObservable(value)) { + bubble.add(parent, value, prop); + } + if (can.Map.helpers.isObservable(current)) { + bubble.remove(parent, current); + } + return value; + } + }; +module.exports = bubble; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/define/define.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/define/define.js new file mode 100644 index 0000000000..124f99a543 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/define/define.js @@ -0,0 +1,246 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/define/define*/ +var can = require('../../util/util.js'); +require('../../observe/observe.js'); +var define = can.define = {}; +var getPropDefineBehavior = function (behavior, attr, define) { + var prop, defaultProp; + if (define) { + prop = define[attr]; + defaultProp = define['*']; + if (prop && prop[behavior] !== undefined) { + return prop[behavior]; + } else if (defaultProp && defaultProp[behavior] !== undefined) { + return defaultProp[behavior]; + } + } +}; +can.Map.helpers.define = function (Map) { + var definitions = Map.prototype.define; + Map.defaultGenerators = {}; + for (var prop in definitions) { + var type = definitions[prop].type; + if (typeof type === 'string') { + if (typeof define.types[type] === 'object') { + delete definitions[prop].type; + can.extend(definitions[prop], define.types[type]); + } + } + if ('value' in definitions[prop]) { + if (typeof definitions[prop].value === 'function') { + Map.defaultGenerators[prop] = definitions[prop].value; + } else { + Map.defaults[prop] = definitions[prop].value; + } + } + if (typeof definitions[prop].Value === 'function') { + (function (Constructor) { + Map.defaultGenerators[prop] = function () { + return new Constructor(); + }; + }(definitions[prop].Value)); + } + } +}; +var oldSetupDefaults = can.Map.prototype._setupDefaults; +can.Map.prototype._setupDefaults = function (obj) { + var defaults = oldSetupDefaults.call(this), propsCommittedToAttr = {}, Map = this.constructor, originalGet = this._get; + this._get = function (originalProp) { + prop = originalProp.indexOf('.') !== -1 ? originalProp.substr(0, originalProp.indexOf('.')) : prop; + if (prop in defaults && !(prop in propsCommittedToAttr)) { + this.attr(prop, defaults[prop]); + propsCommittedToAttr[prop] = true; + } + return originalGet.apply(this, arguments); + }; + for (var prop in Map.defaultGenerators) { + if (!obj || !(prop in obj)) { + defaults[prop] = Map.defaultGenerators[prop].call(this); + } + } + this._get = originalGet; + return defaults; +}; +var proto = can.Map.prototype, oldSet = proto.__set; +proto.__set = function (prop, value, current, success, error) { + var errorCallback = function (errors) { + var stub = error && error.call(self, errors); + if (stub !== false) { + can.trigger(self, 'error', [ + prop, + errors + ], true); + } + return false; + }, self = this, setter = getPropDefineBehavior('set', prop, this.define), getter = getPropDefineBehavior('get', prop, this.define); + if (setter) { + can.batch.start(); + var setterCalled = false, setValue = setter.call(this, value, function (value) { + if (getter) { + self[prop](value); + } else { + oldSet.call(self, prop, value, current, success, errorCallback); + } + setterCalled = true; + }, errorCallback, getter ? this[prop].computeInstance.lastSetValue.get() : current); + if (getter) { + if (setValue !== undefined && !setterCalled && setter.length >= 1) { + this[prop](setValue); + } + can.batch.stop(); + return; + } else if (setValue === undefined && !setterCalled && setter.length >= 1) { + can.batch.stop(); + return; + } else { + if (!setterCalled) { + oldSet.call(self, prop, setter.length === 0 && setValue === undefined ? value : setValue, current, success, errorCallback); + } + can.batch.stop(); + return this; + } + } else { + oldSet.call(self, prop, value, current, success, errorCallback); + } + return this; +}; +define.types = { + 'date': function (str) { + var type = typeof str; + if (type === 'string') { + str = Date.parse(str); + return isNaN(str) ? null : new Date(str); + } else if (type === 'number') { + return new Date(str); + } else { + return str; + } + }, + 'number': function (val) { + if (val == null) { + return val; + } + return +val; + }, + 'boolean': function (val) { + if (val === 'false' || val === '0' || !val) { + return false; + } + return true; + }, + 'htmlbool': function (val) { + return typeof val === 'string' || !!val; + }, + '*': function (val) { + return val; + }, + 'string': function (val) { + if (val == null) { + return val; + } + return '' + val; + }, + 'compute': { + set: function (newValue, setVal, setErr, oldValue) { + if (newValue.isComputed) { + return newValue; + } + if (oldValue && oldValue.isComputed) { + oldValue(newValue); + return oldValue; + } + return newValue; + }, + get: function (value) { + return value && value.isComputed ? value() : value; + } + } +}; +var oldType = proto.__type; +proto.__type = function (value, prop) { + var type = getPropDefineBehavior('type', prop, this.define), Type = getPropDefineBehavior('Type', prop, this.define), newValue = value; + if (typeof type === 'string') { + type = define.types[type]; + } + if (type || Type) { + if (type) { + newValue = type.call(this, newValue, prop); + } + if (Type && !(newValue instanceof Type)) { + newValue = new Type(newValue); + } + return newValue; + } else if (can.isPlainObject(newValue) && newValue.define) { + newValue = can.Map.extend(newValue); + newValue = new newValue(); + } + return oldType.call(this, newValue, prop); +}; +var oldRemove = proto._remove; +proto._remove = function (prop, current) { + var remove = getPropDefineBehavior('remove', prop, this.define), res; + if (remove) { + can.batch.start(); + res = remove.call(this, current); + if (res === false) { + can.batch.stop(); + return; + } else { + res = oldRemove.call(this, prop, current); + can.batch.stop(); + return res; + } + } + return oldRemove.call(this, prop, current); +}; +var oldSetupComputes = proto._setupComputes; +proto._setupComputes = function (defaultsValues) { + oldSetupComputes.apply(this, arguments); + for (var attr in this.define) { + var def = this.define[attr], get = def.get; + if (get) { + this[attr] = can.compute.async(defaultsValues[attr], get, this); + this._computedBindings[attr] = { count: 0 }; + } + } +}; +var oldSingleSerialize = can.Map.helpers._serialize; +can.Map.helpers._serialize = function (map, name, val) { + return serializeProp(map, name, val); +}; +var serializeProp = function (map, attr, val) { + var serializer = attr === '*' ? false : getPropDefineBehavior('serialize', attr, map.define); + if (serializer === undefined) { + return oldSingleSerialize.apply(this, arguments); + } else if (serializer !== false) { + return typeof serializer === 'function' ? serializer.call(map, val, attr) : oldSingleSerialize.apply(this, arguments); + } +}; +var oldSerialize = proto.serialize; +proto.serialize = function (property) { + var serialized = oldSerialize.apply(this, arguments); + if (property) { + return serialized; + } + var serializer, val; + for (var attr in this.define) { + if (!(attr in serialized)) { + serializer = this.define && this.define[attr] && this.define[attr].serialize; + if (serializer) { + val = serializeProp(this, attr, this.attr(attr)); + if (val !== undefined) { + serialized[attr] = val; + } + } + } + } + return serialized; +}; +module.exports = can.define; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/delegate/delegate.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/delegate/delegate.js new file mode 100644 index 0000000000..19bf35560c --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/delegate/delegate.js @@ -0,0 +1,130 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/delegate/delegate*/ +var can = require('../../util/util.js'); +require('../map.js'); +var delegateMatches = function (parts, props) { + var len = parts.length, i = 0, matchedProps = [], prop; + for (i; i < len; i++) { + prop = props[i]; + if (typeof prop !== 'string') { + return null; + } else if (parts[i] === '**') { + return props.join('.'); + } else if (parts[i] === '*') { + matchedProps.push(prop); + } else if (prop === parts[i]) { + matchedProps.push(prop); + } else { + return null; + } + } + return matchedProps.join('.'); + }, delegateHandler = function (event, prop, how, newVal, oldVal) { + var props = prop.split('.'), delegates = (this._observe_delegates || []).slice(0), delegate, attr, matchedAttr, hasMatch, valuesEqual; + event.attr = prop; + event.lastAttr = props[props.length - 1]; + for (var i = 0; delegate = delegates[i++];) { + if (event.batchNum && delegate.batchNum === event.batchNum || delegate.undelegated) { + continue; + } + hasMatch = undefined; + valuesEqual = true; + for (var a = 0; a < delegate.attrs.length; a++) { + attr = delegate.attrs[a]; + matchedAttr = delegateMatches(attr.parts, props); + if (matchedAttr) { + hasMatch = matchedAttr; + } + if (attr.value && valuesEqual) { + valuesEqual = attr.value === '' + this.attr(attr.attr); + } else if (valuesEqual && delegate.attrs.length > 1) { + valuesEqual = this.attr(attr.attr) !== undefined; + } + } + if (hasMatch && valuesEqual) { + var from = prop.replace(hasMatch + '.', ''); + if (event.batchNum) { + delegate.batchNum = event.batchNum; + } + if (delegate.event === 'change') { + prop = from; + event.curAttr = hasMatch; + delegate.callback.apply(this.attr(hasMatch), can.makeArray(arguments)); + } else if (delegate.event === how) { + delegate.callback.apply(this.attr(hasMatch), [ + event, + newVal, + oldVal, + from + ]); + } else if (delegate.event === 'set' && how === 'add') { + delegate.callback.apply(this.attr(hasMatch), [ + event, + newVal, + oldVal, + from + ]); + } + } + } + }; +can.extend(can.Map.prototype, { + delegate: function (selector, event, handler) { + selector = can.trim(selector); + var delegates = this._observe_delegates || (this._observe_delegates = []), attrs = [], selectorRegex = /([^\s=,]+)(?:=("[^",]*"|'[^',]*'|[^\s"',]*))?(,?)\s*/g, matches; + while ((matches = selectorRegex.exec(selector)) !== null) { + if (matches[2] && can.inArray(matches[2].substr(0, 1), [ + '"', + '\'' + ]) >= 0) { + matches[2] = matches[2].substr(1, -1); + } + attrs.push({ + attr: matches[1], + parts: matches[1].split('.'), + value: matches[2], + or: matches[3] === ',' + }); + } + delegates.push({ + selector: selector, + attrs: attrs, + callback: handler, + event: event + }); + if (delegates.length === 1) { + this.bind('change', delegateHandler); + } + return this; + }, + undelegate: function (selector, event, handler) { + selector = selector && can.trim(selector); + var i = 0, delegates = this._observe_delegates || [], delegateOb; + if (selector) { + while (i < delegates.length) { + delegateOb = delegates[i]; + if (delegateOb.callback === handler || !handler && delegateOb.selector === selector) { + delegateOb.undelegated = true; + delegates.splice(i, 1); + } else { + i++; + } + } + } else { + delegates = []; + } + if (!delegates.length) { + this.unbind('change', delegateHandler); + } + return this; + } +}); +can.Map.prototype.delegate.matches = delegateMatches; +module.exports = can.Map; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/lazy/bubble.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/lazy/bubble.js new file mode 100644 index 0000000000..5a02200ca6 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/lazy/bubble.js @@ -0,0 +1,25 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/lazy/bubble*/ +var can = require('../../util/util.js'); +require('../bubble.js'); +var bubble = can.bubble; +module.exports = can.extend({}, bubble, { + childrenOf: function (parentMap, eventName) { + if (parentMap._nestedReference) { + parentMap._nestedReference.each(function (child, ref) { + if (child && child.bind) { + bubble.toParent(child, parentMap, ref(), eventName); + } + }); + } else { + bubble._each.apply(this, arguments); + } + } +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/lazy/lazy.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/lazy/lazy.js new file mode 100644 index 0000000000..4e6838570d --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/lazy/lazy.js @@ -0,0 +1,222 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/lazy/lazy*/ +var can = require('../../util/util.js'); +var bubble = require('./bubble.js'); +require('../map.js'); +require('../../list/list.js'); +require('./nested_reference.js'); +can.LazyMap = can.Map.extend({ _bubble: bubble }, { + setup: function (obj) { + this.constructor.Map = this.constructor; + this.constructor.List = can.LazyList; + this._data = can.extend(can.extend(true, {}, this._setupDefaults() || {}), obj); + can.cid(this, '.lazyMap'); + this._init = 1; + this._computedBindings = {}; + this._setupComputes(); + var teardownMapping = obj && can.Map.helpers.addToMap(obj, this); + this._nestedReference = new can.NestedReference(this._data); + if (teardownMapping) { + teardownMapping(); + } + can.each(this._data, can.proxy(function (value, prop) { + this.___set(prop, value); + }, this)); + this.bind('change', can.proxy(this._changes, this)); + delete this._init; + }, + _addChild: function (path, newChild, setNewChild) { + var self = this; + this._nestedReference.removeChildren(path, function (oldChild, oldChildPath) { + bubble.remove(self, oldChild); + if (newChild) { + var newChildPath = oldChildPath.replace(path + '.', ''); + if (path === newChildPath) { + oldChild._nestedReference.each(function (obj, path) { + newChild._nestedReference.make(path()); + if (self._bindings) { + bubble.add(this, newChild, path()); + } + }); + } else { + var reference = newChild._nestedReference.make(newChildPath); + if (self._bindings) { + bubble.add(oldChild, newChild, reference()); + } + } + } + }); + if (setNewChild) { + setNewChild(); + } + if (newChild) { + var reference = this._nestedReference.make(path); + if (this._bindings) { + bubble.add(this, newChild, reference()); + } + } + return newChild; + }, + removeAttr: function (attr) { + var data = this._goto(attr); + if (data.parts.length) { + return data.value.removeAttr(data.parts.join('.')); + } else { + if (can.isArray(data.parent)) { + data.parent.splice(data.prop, 1); + this._triggerChange(attr, 'remove', undefined, [this.__type(data.value, data.prop)]); + } else { + if (data.parent[data.prop]) { + delete data.parent[data.prop]; + can.batch.trigger(this, data.path.length ? data.path.join('.') + '.__keys' : '__keys'); + this._triggerChange(attr, 'remove', undefined, this.__type(data.value, data.prop)); + } + } + this._nestedReference.removeChildren(); + return data.value; + } + }, + __type: function (value, prop) { + if (!(value instanceof can.LazyMap) && can.Map.helpers.canMakeObserve(value)) { + if (can.isArray(value)) { + var List = can.LazyList; + return new List(value); + } else { + var Map = this.constructor.Map || can.LazyMap; + return new Map(value); + } + } + return value; + }, + _goto: function (attr, keepKey) { + var parts = can.Map.helpers.attrParts(attr, keepKey).slice(0), prev, path = [], part; + var cur = this instanceof can.List ? this[parts.shift()] : this.__get(); + while (cur && !can.Map.helpers.isObservable(cur) && parts.length) { + if (part !== undefined) { + path.push(part); + } + prev = cur; + cur = cur[part = parts.shift()]; + } + return { + parts: parts, + prop: part, + value: cur, + parent: prev, + path: path + }; + }, + _get: function (attr) { + can.__observe(this, attr); + var data = this._goto(attr); + if (can.Map.helpers.isObservable(data.value)) { + if (data.parts.length) { + return data.value._get(data.parts); + } else { + return data.value; + } + } else if (data.value && can.Map.helpers.canMakeObserve(data.value)) { + var converted = this.__type(data.value, data.prop); + this._addChild(attr, converted, function () { + data.parent[data.prop] = converted; + }); + return converted; + } else if (data.value !== undefined) { + return data.value; + } else { + return this.__get(attr); + } + }, + _set: function (attr, value, keepKey) { + var data = this._goto(attr, keepKey); + if (can.Map.helpers.isObservable(data.value) && data.parts.length) { + return data.value._set(data.parts, value); + } else if (!data.parts.length) { + this.__set(attr, value, data.value, data); + } else { + throw 'can.LazyMap: object does not exist'; + } + }, + __set: function (prop, value, current, data, convert) { + convert = convert || true; + if (value !== current) { + var changeType = data.parent.hasOwnProperty(data.prop) ? 'set' : 'add'; + if (convert && can.Map.helpers.canMakeObserve(value)) { + value = this.__type(value, prop); + var self = this; + this._addChild(prop, value, function () { + self.___set(prop, value, data); + }); + } else { + this.___set(prop, value, data); + } + if (changeType === 'add') { + can.batch.trigger(this, data.path.length ? data.path.join('.') + '.__keys' : '__keys', undefined); + } + this._triggerChange(prop, changeType, value, current); + } + }, + ___set: function (prop, val, data) { + if (this[prop] && this[prop].isComputed && can.isFunction(this.constructor.prototype[prop])) { + this[prop](val); + } else if (data) { + data.parent[data.prop] = val; + } else { + this._data[prop] = val; + } + if (!can.isFunction(this.constructor.prototype[prop])) { + this[prop] = val; + } + }, + _attrs: function (props, remove) { + if (props === undefined) { + return can.Map.helpers.serialize(this, 'attr', {}); + } + props = can.extend({}, props); + var self = this, prop, data, newVal; + can.batch.start(); + this.each(function (curVal, prop) { + newVal = props[prop]; + data = self._goto(prop, true); + if (newVal === undefined) { + if (remove) { + self.removeAttr(prop); + } + return; + } else if (!can.Map.helpers.isObservable(curVal) && can.Map.helpers.canMakeObserve(curVal)) { + curVal = self.attr(prop); + } + if (self.__convert) { + newVal = self.__convert(prop, newVal); + } + if (newVal instanceof can.Map) { + self.__set(prop, newVal, curVal, data); + } else if (can.Map.helpers.isObservable(curVal) && can.Map.helpers.canMakeObserve(newVal) && curVal.attr) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + self.__set(prop, newVal, curVal, data); + } + delete props[prop]; + }); + for (prop in props) { + newVal = props[prop]; + this._set(prop, newVal, true); + } + can.batch.stop(); + return this; + } +}); +can.LazyList = can.List.extend({ Map: can.LazyMap }, { + setup: function () { + can.List.prototype.setup.apply(this, arguments); + this._nestedReference = new can.NestedReference(this); + } +}); +module.exports = can.LazyMap; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/lazy/nested_reference.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/lazy/nested_reference.js new file mode 100644 index 0000000000..e86d23d280 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/lazy/nested_reference.js @@ -0,0 +1,79 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/lazy/nested_reference*/ +var can = require('../../util/util.js'); +var pathIterator = function (root, propPath, callback) { + var props = propPath.split('.'), cur = root, part; + while (part = props.shift()) { + cur = cur[part]; + if (callback) { + callback(cur, part); + } + } + return cur; +}; +var ArrIndex = function (array) { + this.array = array; +}; +ArrIndex.prototype.toString = function () { + return '' + can.inArray(this.item, this.array); +}; +var NestedReference = function (root) { + this.root = root; + this.references = []; +}; +NestedReference.ArrIndex = ArrIndex; +can.extend(NestedReference.prototype, { + make: function (propPath) { + var path = [], arrIndex; + if (can.isArray(this.root) || this.root instanceof can.LazyList) { + arrIndex = new ArrIndex(this.root); + } + pathIterator(this.root, propPath, function (item, prop) { + if (arrIndex) { + arrIndex.item = item; + path.push(arrIndex); + arrIndex = undefined; + } else { + path.push(prop); + if (can.isArray(item)) { + arrIndex = new ArrIndex(item); + } + } + }); + var pathFunc = function () { + return path.join('.'); + }; + this.references.push(pathFunc); + return pathFunc; + }, + removeChildren: function (path, callback) { + var i = 0; + while (i < this.references.length) { + var reference = this.references[i](); + if (reference.indexOf(path) === 0) { + callback(this.get(reference), reference); + this.references.splice(i, 1); + } else { + i++; + } + } + }, + get: function (path) { + return pathIterator(this.root, path); + }, + each: function (callback) { + var self = this; + can.each(this.references, function (ref) { + var path = ref(); + callback(self.get(path), ref, path); + }); + } +}); +can.NestedReference = NestedReference; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/list/list.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/list/list.js new file mode 100644 index 0000000000..ea8297f0f9 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/list/list.js @@ -0,0 +1,74 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/list/list*/ +var can = require('../../util/util.js'); +require('../map.js'); +require('../../list/list.js'); +require('../../compute/compute.js'); +can.extend(can.List.prototype, { + filter: function (callback) { + var filtered = new this.constructor(); + var self = this; + var generator = function (element, index) { + var binder = function (ev, val) { + var index = filtered.indexOf(element); + if (!val && index !== -1) { + filtered.splice(index, 1); + } + if (val && index === -1) { + filtered.push(element); + } + }; + var compute = can.compute(function () { + return callback(element, self.indexOf(element), self); + }); + compute.bind('change', binder); + binder(null, compute()); + }; + this.bind('add', function (ev, data, index) { + can.each(data, function (element, i) { + generator(element, index + i); + }); + }); + this.bind('remove', function (ev, data, index) { + can.each(data, function (element, i) { + var index = filtered.indexOf(element); + if (index !== -1) { + filtered.splice(index, 1); + } + }); + }); + this.forEach(generator); + return filtered; + }, + map: function (callback) { + var mapped = new can.List(); + var self = this; + var generator = function (element, index) { + var compute = can.compute(function () { + return callback(element, index, self); + }); + compute.bind('change', function (ev, val) { + mapped.splice(index, 1, val); + }); + mapped.splice(index, 0, compute()); + }; + this.forEach(generator); + this.bind('add', function (ev, data, index) { + can.each(data, function (element, i) { + generator(element, index + i); + }); + }); + this.bind('remove', function (ev, data, index) { + mapped.splice(index, data.length); + }); + return mapped; + } +}); +module.exports = can.List; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/map.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/map.js new file mode 100644 index 0000000000..5b722b84a6 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/map.js @@ -0,0 +1,436 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/map*/ +var can = require('../util/util.js'); +var bind = require('../util/bind/bind.js'); +var bubble = require('./bubble.js'); +require('../construct/construct.js'); +require('../util/batch/batch.js'); +var madeMap = null; +var teardownMap = function () { + for (var cid in madeMap) { + if (madeMap[cid].added) { + delete madeMap[cid].obj._cid; + } + } + madeMap = null; +}; +var getMapFromObject = function (obj) { + return madeMap && madeMap[obj._cid] && madeMap[obj._cid].instance; +}; +var serializeMap = null; +var Map = can.Map = can.Construct.extend({ + setup: function () { + can.Construct.setup.apply(this, arguments); + if (can.Map) { + if (!this.defaults) { + this.defaults = {}; + } + this._computes = []; + for (var prop in this.prototype) { + if (prop !== 'define' && prop !== 'constructor' && (typeof this.prototype[prop] !== 'function' || this.prototype[prop].prototype instanceof can.Construct)) { + this.defaults[prop] = this.prototype[prop]; + } else if (this.prototype[prop].isComputed) { + this._computes.push(prop); + } + } + if (this.helpers.define) { + this.helpers.define(this); + } + } + if (can.List && !(this.prototype instanceof can.List)) { + this.List = Map.List.extend({ Map: this }, {}); + } + }, + _bubble: bubble, + _bubbleRule: function (eventName) { + return eventName === 'change' || eventName.indexOf('.') >= 0 ? ['change'] : []; + }, + _computes: [], + bind: can.bindAndSetup, + on: can.bindAndSetup, + unbind: can.unbindAndTeardown, + off: can.unbindAndTeardown, + id: 'id', + helpers: { + define: null, + attrParts: function (attr, keepKey) { + if (keepKey) { + return [attr]; + } + return typeof attr === 'object' ? attr : ('' + attr).split('.'); + }, + addToMap: function (obj, instance) { + var teardown; + if (!madeMap) { + teardown = teardownMap; + madeMap = {}; + } + var hasCid = obj._cid; + var cid = can.cid(obj); + if (!madeMap[cid]) { + madeMap[cid] = { + obj: obj, + instance: instance, + added: !hasCid + }; + } + return teardown; + }, + isObservable: function (obj) { + return obj instanceof can.Map || obj && obj === can.route; + }, + canMakeObserve: function (obj) { + return obj && !can.isDeferred(obj) && (can.isArray(obj) || can.isPlainObject(obj)); + }, + serialize: function (map, how, where) { + var cid = can.cid(map), firstSerialize = false; + if (!serializeMap) { + firstSerialize = true; + serializeMap = { + attr: {}, + serialize: {} + }; + } + serializeMap[how][cid] = where; + map.each(function (val, name) { + var result, isObservable = Map.helpers.isObservable(val), serialized = isObservable && serializeMap[how][can.cid(val)]; + if (serialized) { + result = serialized; + } else { + if (how === 'serialize') { + result = Map.helpers._serialize(map, name, val); + } else { + result = Map.helpers._getValue(map, name, val, how); + } + } + if (result !== undefined) { + where[name] = result; + } + }); + can.__observe(map, '__keys'); + if (firstSerialize) { + serializeMap = null; + } + return where; + }, + _serialize: function (map, name, val) { + return Map.helpers._getValue(map, name, val, 'serialize'); + }, + _getValue: function (map, name, val, how) { + if (Map.helpers.isObservable(val)) { + return val[how](); + } else { + return val; + } + } + }, + keys: function (map) { + var keys = []; + can.__observe(map, '__keys'); + for (var keyName in map._data) { + keys.push(keyName); + } + return keys; + } + }, { + setup: function (obj) { + if (obj instanceof can.Map) { + obj = obj.serialize(); + } + this._data = {}; + can.cid(this, '.map'); + this._init = 1; + this._computedBindings = {}; + var defaultValues = this._setupDefaults(obj); + this._setupComputes(defaultValues); + var teardownMapping = obj && can.Map.helpers.addToMap(obj, this); + var data = can.extend(can.extend(true, {}, defaultValues), obj); + this.attr(data); + if (teardownMapping) { + teardownMapping(); + } + this.bind('change', can.proxy(this._changes, this)); + delete this._init; + }, + _setupComputes: function () { + var computes = this.constructor._computes; + for (var i = 0, len = computes.length, prop; i < len; i++) { + prop = computes[i]; + this[prop] = this[prop].clone(this); + this._computedBindings[prop] = { count: 0 }; + } + }, + _setupDefaults: function () { + return this.constructor.defaults || {}; + }, + _bindsetup: function () { + }, + _bindteardown: function () { + }, + _changes: function (ev, attr, how, newVal, oldVal) { + can.batch.trigger(this, { + type: attr, + batchNum: ev.batchNum, + target: ev.target + }, [ + newVal, + oldVal + ]); + }, + _triggerChange: function (attr, how, newVal, oldVal) { + if (bubble.isBubbling(this, 'change')) { + can.batch.trigger(this, { + type: 'change', + target: this + }, [ + attr, + how, + newVal, + oldVal + ]); + } else { + can.batch.trigger(this, attr, [ + newVal, + oldVal + ]); + } + if (how === 'remove' || how === 'add') { + can.batch.trigger(this, { + type: '__keys', + target: this + }); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var prop in data) { + if (data.hasOwnProperty(prop)) { + callback(data[prop], prop); + } + } + }, + attr: function (attr, val) { + var type = typeof attr; + if (type !== 'string' && type !== 'number') { + return this._attrs(attr, val); + } else if (arguments.length === 1) { + return this._get(attr); + } else { + this._set(attr, val); + return this; + } + }, + each: function () { + return can.each.apply(undefined, [this].concat(can.makeArray(arguments))); + }, + removeAttr: function (attr) { + var isList = can.List && this instanceof can.List, parts = can.Map.helpers.attrParts(attr), prop = parts.shift(), current = isList ? this[prop] : this._data[prop]; + if (parts.length && current) { + return current.removeAttr(parts); + } else { + if (typeof attr === 'string' && !!~attr.indexOf('.')) { + prop = attr; + } + this._remove(prop, current); + return current; + } + }, + _remove: function (prop, current) { + if (prop in this._data) { + delete this._data[prop]; + if (!(prop in this.constructor.prototype)) { + delete this[prop]; + } + this._triggerChange(prop, 'remove', undefined, current); + } + }, + _get: function (attr) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'); + if (dotIndex >= 0) { + var value = this.__get(attr); + if (value !== undefined) { + return value; + } + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + can.__observe(this, first); + var current = this.__get(first); + return current && current._get ? current._get(second) : undefined; + } else { + can.__observe(this, attr); + return this.__get(attr); + } + }, + __get: function (attr) { + if (attr) { + if (this._computedBindings[attr]) { + return this[attr](); + } else { + return this._data[attr]; + } + } else { + return this._data; + } + }, + __type: function (value, prop) { + if (!(value instanceof can.Map) && can.Map.helpers.canMakeObserve(value)) { + var cached = getMapFromObject(value); + if (cached) { + return cached; + } + if (can.isArray(value)) { + var List = can.List; + return new List(value); + } else { + var Map = this.constructor.Map || can.Map; + return new Map(value); + } + } + return value; + }, + _set: function (attr, value, keepKey) { + attr = '' + attr; + var dotIndex = attr.indexOf('.'), current; + if (!keepKey && dotIndex >= 0) { + var first = attr.substr(0, dotIndex), second = attr.substr(dotIndex + 1); + current = this._init ? undefined : this.__get(first); + if (Map.helpers.isObservable(current)) { + current._set(second, value); + } else { + throw 'can.Map: Object does not exist'; + } + } else { + if (this.__convert) { + value = this.__convert(attr, value); + } + current = this._init ? undefined : this.__get(attr); + this.__set(attr, this.__type(value, attr), current); + } + }, + __set: function (prop, value, current) { + if (value !== current) { + var changeType = current !== undefined || this.__get().hasOwnProperty(prop) ? 'set' : 'add'; + this.___set(prop, this.constructor._bubble.set(this, prop, value, current)); + if (!this._computedBindings[prop]) { + this._triggerChange(prop, changeType, value, current); + } + if (current) { + this.constructor._bubble.teardownFromParent(this, current); + } + } + }, + ___set: function (prop, val) { + if (this._computedBindings[prop]) { + this[prop](val); + } else { + this._data[prop] = val; + } + if (typeof this.constructor.prototype[prop] !== 'function' && !this._computedBindings[prop]) { + this[prop] = val; + } + }, + bind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (!computedBinding.count) { + computedBinding.count = 1; + var self = this; + computedBinding.handler = function (ev, newVal, oldVal) { + can.batch.trigger(self, { + type: eventName, + batchNum: ev.batchNum, + target: self + }, [ + newVal, + oldVal + ]); + }; + this[eventName].bind('change', computedBinding.handler); + } else { + computedBinding.count++; + } + } + this.constructor._bubble.bind(this, eventName); + return can.bindAndSetup.apply(this, arguments); + }, + unbind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + if (computedBinding.count === 1) { + computedBinding.count = 0; + this[eventName].unbind('change', computedBinding.handler); + delete computedBinding.handler; + } else { + computedBinding.count--; + } + } + this.constructor._bubble.unbind(this, eventName); + return can.unbindAndTeardown.apply(this, arguments); + }, + serialize: function () { + return can.Map.helpers.serialize(this, 'serialize', {}); + }, + _attrs: function (props, remove) { + if (props === undefined) { + return Map.helpers.serialize(this, 'attr', {}); + } + props = can.simpleExtend({}, props); + var prop, self = this, newVal; + can.batch.start(); + this.each(function (curVal, prop) { + if (prop === '_cid') { + return; + } + newVal = props[prop]; + if (newVal === undefined) { + if (remove) { + self.removeAttr(prop); + } + return; + } + if (self.__convert) { + newVal = self.__convert(prop, newVal); + } + if (Map.helpers.isObservable(newVal)) { + self.__set(prop, self.__type(newVal, prop), curVal); + } else if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + } else if (curVal !== newVal) { + self.__set(prop, self.__type(newVal, prop), curVal); + } + delete props[prop]; + }); + for (prop in props) { + if (prop !== '_cid') { + newVal = props[prop]; + this._set(prop, newVal, true); + } + } + can.batch.stop(); + return this; + }, + compute: function (prop) { + if (can.isFunction(this.constructor.prototype[prop])) { + return can.compute(this[prop], this); + } else { + var reads = prop.split('.'), last = reads.length - 1, options = { args: [] }; + return can.compute(function (newVal) { + if (arguments.length) { + can.compute.read(this, reads.slice(0, last)).value.attr(reads[last], newVal); + } else { + return can.compute.read(this, reads, options).value; + } + }, this); + } + } + }); +Map.prototype.on = Map.prototype.bind; +Map.prototype.off = Map.prototype.unbind; +module.exports = Map; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/setter/setter.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/setter/setter.js new file mode 100644 index 0000000000..4ca6ca9de4 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/setter/setter.js @@ -0,0 +1,49 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/setter/setter*/ +var can = require('../../util/util.js'); +require('../map.js'); +can.classize = function (s, join) { + var parts = s.split(can.undHash), i = 0; + for (; i < parts.length; i++) { + parts[i] = can.capitalize(parts[i]); + } + return parts.join(join || ''); +}; +var classize = can.classize, proto = can.Map.prototype, old = proto.__set; +proto.__set = function (prop, value, current, success, error) { + var cap = classize(prop), setName = 'set' + cap, errorCallback = function (errors) { + var stub = error && error.call(self, errors); + if (stub !== false) { + can.trigger(self, 'error', [ + prop, + errors + ], true); + } + return false; + }, self = this; + if (this[setName]) { + can.batch.start(); + value = this[setName](value, function (value) { + old.call(self, prop, value, current, success, errorCallback); + }, errorCallback); + if (value === undefined) { + can.batch.stop(); + return; + } else { + old.call(self, prop, value, current, success, errorCallback); + can.batch.stop(); + return this; + } + } else { + old.call(self, prop, value, current, success, errorCallback); + } + return this; +}; +module.exports = can.Map; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/sort/sort.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/sort/sort.js new file mode 100644 index 0000000000..f67289fcad --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/sort/sort.js @@ -0,0 +1,11 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/sort/sort*/ +var sortPlugin = require('../../list/sort/sort.js'); +module.exports = sortPlugin; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/validations/validations.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/validations/validations.js new file mode 100644 index 0000000000..4f8c06bfef --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/map/validations/validations.js @@ -0,0 +1,158 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/validations/validations*/ +var can = require('../../util/util.js'); +require('../map.js'); +var validate = function (attrNames, options, proc) { + if (!proc) { + proc = options; + options = {}; + } + options = options || {}; + attrNames = typeof attrNames === 'string' ? [attrNames] : can.makeArray(attrNames); + if (options.testIf && !options.testIf.call(this)) { + return; + } + var self = this; + can.each(attrNames, function (attrName) { + if (!self.validations[attrName]) { + self.validations[attrName] = []; + } + self.validations[attrName].push(function (newVal) { + var res = proc.call(this, newVal, attrName); + return res === undefined ? undefined : options.message || res; + }); + }); +}; +var old = can.Map.prototype.__set; +can.Map.prototype.__set = function (prop, value, current, success, error) { + var self = this, validations = self.constructor.validations, errorCallback = function (errors) { + var stub = error && error.call(self, errors); + if (stub !== false) { + can.trigger(self, 'error', [ + prop, + errors + ], true); + } + return false; + }; + old.call(self, prop, value, current, success, errorCallback); + if (validations && validations[prop]) { + var errors = self.errors(prop); + if (errors) { + errorCallback(errors); + } + } + return this; +}; +can.each([ + can.Map, + can.Model +], function (clss) { + if (clss === undefined) { + return; + } + var oldSetup = clss.setup; + can.extend(clss, { + setup: function (superClass) { + oldSetup.apply(this, arguments); + if (!this.validations || superClass.validations === this.validations) { + this.validations = {}; + } + }, + validate: validate, + validationMessages: { + format: 'is invalid', + inclusion: 'is not a valid option (perhaps out of range)', + lengthShort: 'is too short', + lengthLong: 'is too long', + presence: 'can\'t be empty', + range: 'is out of range', + numericality: 'must be a number' + }, + validateFormatOf: function (attrNames, regexp, options) { + validate.call(this, attrNames, options, function (value) { + if (typeof value !== 'undefined' && value !== null && value !== '' && String(value).match(regexp) === null) { + return this.constructor.validationMessages.format; + } + }); + }, + validateInclusionOf: function (attrNames, inArray, options) { + validate.call(this, attrNames, options, function (value) { + if (typeof value === 'undefined') { + return; + } + for (var i = 0; i < inArray.length; i++) { + if (inArray[i] === value) { + return; + } + } + return this.constructor.validationMessages.inclusion; + }); + }, + validateLengthOf: function (attrNames, min, max, options) { + validate.call(this, attrNames, options, function (value) { + if ((typeof value === 'undefined' || value === null) && min > 0 || typeof value !== 'undefined' && value !== null && value.length < min) { + return this.constructor.validationMessages.lengthShort + ' (min=' + min + ')'; + } else if (typeof value !== 'undefined' && value !== null && value.length > max) { + return this.constructor.validationMessages.lengthLong + ' (max=' + max + ')'; + } + }); + }, + validatePresenceOf: function (attrNames, options) { + validate.call(this, attrNames, options, function (value) { + if (typeof value === 'undefined' || value === '' || value === null) { + return this.constructor.validationMessages.presence; + } + }); + }, + validateRangeOf: function (attrNames, low, hi, options) { + validate.call(this, attrNames, options, function (value) { + if ((typeof value === 'undefined' || value === null) && low > 0 || typeof value !== 'undefined' && value !== null && (value < low || value > hi)) { + return this.constructor.validationMessages.range + ' [' + low + ',' + hi + ']'; + } + }); + }, + validatesNumericalityOf: function (attrNames) { + validate.call(this, attrNames, function (value) { + var res = !isNaN(parseFloat(value)) && isFinite(value); + if (!res) { + return this.constructor.validationMessages.numericality; + } + }); + } + }); +}); +can.extend(can.Map.prototype, { + errors: function (attrs, newVal) { + if (attrs) { + attrs = can.isArray(attrs) ? attrs : [attrs]; + } + var errors = {}, self = this, addErrors = function (attr, funcs) { + can.each(funcs, function (func) { + var res = func.call(self, isTest ? self.__convert ? self.__convert(attr, newVal) : newVal : self.attr(attr)); + if (res) { + if (!errors[attr]) { + errors[attr] = []; + } + errors[attr].push(res); + } + }); + }, validations = this.constructor.validations || {}, isTest = attrs && attrs.length === 1 && arguments.length === 2; + can.each(attrs || validations, function (funcs, attr) { + if (typeof attr === 'number') { + attr = funcs; + funcs = validations[attr]; + } + addErrors(attr, funcs || []); + }); + return can.isEmptyObject(errors) ? null : isTest ? errors[attrs[0]] : errors; + } +}); +module.exports = can.Map; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/model/model.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/model/model.js new file mode 100644 index 0000000000..212672b1cb --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/model/model.js @@ -0,0 +1,391 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#model/model*/ +var can = require('../util/util.js'); +require('../map/map.js'); +require('../list/list.js'); +var pipe = function (def, thisArg, func) { + var d = new can.Deferred(); + def.then(function () { + var args = can.makeArray(arguments), success = true; + try { + args[0] = func.apply(thisArg, args); + } catch (e) { + success = false; + d.rejectWith(d, [e].concat(args)); + } + if (success) { + d.resolveWith(d, args); + } + }, function () { + d.rejectWith(this, arguments); + }); + if (typeof def.abort === 'function') { + d.abort = function () { + return def.abort(); + }; + } + return d; + }, modelNum = 0, getId = function (inst) { + can.__observe(inst, inst.constructor.id); + return inst.__get(inst.constructor.id); + }, ajax = function (ajaxOb, data, type, dataType, success, error) { + var params = {}; + if (typeof ajaxOb === 'string') { + var parts = ajaxOb.split(/\s+/); + params.url = parts.pop(); + if (parts.length) { + params.type = parts.pop(); + } + } else { + can.extend(params, ajaxOb); + } + params.data = typeof data === 'object' && !can.isArray(data) ? can.extend(params.data || {}, data) : data; + params.url = can.sub(params.url, params.data, true); + return can.ajax(can.extend({ + type: type || 'post', + dataType: dataType || 'json', + success: success, + error: error + }, params)); + }, makeRequest = function (modelObj, type, success, error, method) { + var args; + if (can.isArray(modelObj)) { + args = modelObj[1]; + modelObj = modelObj[0]; + } else { + args = modelObj.serialize(); + } + args = [args]; + var deferred, model = modelObj.constructor, jqXHR; + if (type === 'update' || type === 'destroy') { + args.unshift(getId(modelObj)); + } + jqXHR = model[type].apply(model, args); + deferred = pipe(jqXHR, modelObj, function (data) { + modelObj[method || type + 'd'](data, jqXHR); + return modelObj; + }); + if (jqXHR.abort) { + deferred.abort = function () { + jqXHR.abort(); + }; + } + deferred.then(success, error); + return deferred; + }, converters = { + models: function (instancesRawData, oldList, xhr) { + can.Model._reqs++; + if (!instancesRawData) { + return; + } + if (instancesRawData instanceof this.List) { + return instancesRawData; + } + var self = this, tmp = [], ListClass = self.List || ML, modelList = oldList instanceof can.List ? oldList : new ListClass(), rawDataIsList = instancesRawData instanceof ML, raw = rawDataIsList ? instancesRawData.serialize() : instancesRawData; + raw = self.parseModels(raw, xhr); + if (raw.data) { + instancesRawData = raw; + raw = raw.data; + } + if (typeof raw === 'undefined' || !can.isArray(raw)) { + throw new Error('Could not get any raw data while converting using .models'); + } + if (modelList.length) { + modelList.splice(0); + } + can.each(raw, function (rawPart) { + tmp.push(self.model(rawPart, xhr)); + }); + modelList.push.apply(modelList, tmp); + if (!can.isArray(instancesRawData)) { + can.each(instancesRawData, function (val, prop) { + if (prop !== 'data') { + modelList.attr(prop, val); + } + }); + } + setTimeout(can.proxy(this._clean, this), 1); + return modelList; + }, + model: function (attributes, oldModel, xhr) { + if (!attributes) { + return; + } + if (typeof attributes.serialize === 'function') { + attributes = attributes.serialize(); + } else { + attributes = this.parseModel(attributes, xhr); + } + var id = attributes[this.id]; + if ((id || id === 0) && this.store[id]) { + oldModel = this.store[id]; + } + var model = oldModel && can.isFunction(oldModel.attr) ? oldModel.attr(attributes, this.removeAttr || false) : new this(attributes); + return model; + } + }, makeParser = { + parseModel: function (prop) { + return function (attributes) { + return prop ? can.getObject(prop, attributes) : attributes; + }; + }, + parseModels: function (prop) { + return function (attributes) { + if (can.isArray(attributes)) { + return attributes; + } + prop = prop || 'data'; + var result = can.getObject(prop, attributes); + if (!can.isArray(result)) { + throw new Error('Could not get any raw data while converting using .models'); + } + return result; + }; + } + }, ajaxMethods = { + create: { + url: '_shortName', + type: 'post' + }, + update: { + data: function (id, attrs) { + attrs = attrs || {}; + var identity = this.id; + if (attrs[identity] && attrs[identity] !== id) { + attrs['new' + can.capitalize(id)] = attrs[identity]; + delete attrs[identity]; + } + attrs[identity] = id; + return attrs; + }, + type: 'put' + }, + destroy: { + type: 'delete', + data: function (id, attrs) { + attrs = attrs || {}; + attrs.id = attrs[this.id] = id; + return attrs; + } + }, + findAll: { url: '_shortName' }, + findOne: {} + }, ajaxMaker = function (ajaxMethod, str) { + return function (data) { + data = ajaxMethod.data ? ajaxMethod.data.apply(this, arguments) : data; + return ajax(str || this[ajaxMethod.url || '_url'], data, ajaxMethod.type || 'get'); + }; + }, createURLFromResource = function (model, name) { + if (!model.resource) { + return; + } + var resource = model.resource.replace(/\/+$/, ''); + if (name === 'findAll' || name === 'create') { + return resource; + } else { + return resource + '/{' + model.id + '}'; + } + }; +can.Model = can.Map.extend({ + fullName: 'can.Model', + _reqs: 0, + setup: function (base, fullName, staticProps, protoProps) { + if (typeof fullName !== 'string') { + protoProps = staticProps; + staticProps = fullName; + } + if (!protoProps) { + protoProps = staticProps; + } + this.store = {}; + can.Map.setup.apply(this, arguments); + if (!can.Model) { + return; + } + if (staticProps && staticProps.List) { + this.List = staticProps.List; + this.List.Map = this; + } else { + this.List = base.List.extend({ Map: this }, {}); + } + var self = this, clean = can.proxy(this._clean, self); + can.each(ajaxMethods, function (method, name) { + if (staticProps && staticProps[name] && (typeof staticProps[name] === 'string' || typeof staticProps[name] === 'object')) { + self[name] = ajaxMaker(method, staticProps[name]); + } else if (staticProps && staticProps.resource && !can.isFunction(staticProps[name])) { + self[name] = ajaxMaker(method, createURLFromResource(self, name)); + } + if (self['make' + can.capitalize(name)]) { + var newMethod = self['make' + can.capitalize(name)](self[name]); + can.Construct._overwrite(self, base, name, function () { + can.Model._reqs++; + var def = newMethod.apply(this, arguments); + var then = def.then(clean, clean); + then.abort = def.abort; + return then; + }); + } + }); + var hasCustomConverter = {}; + can.each(converters, function (converter, name) { + var parseName = 'parse' + can.capitalize(name), dataProperty = staticProps && staticProps[name] || self[name]; + if (typeof dataProperty === 'string') { + self[parseName] = dataProperty; + can.Construct._overwrite(self, base, name, converter); + } else if (staticProps && staticProps[name]) { + hasCustomConverter[parseName] = true; + } + }); + can.each(makeParser, function (maker, parseName) { + var prop = staticProps && staticProps[parseName] || self[parseName]; + if (typeof prop === 'string') { + can.Construct._overwrite(self, base, parseName, maker(prop)); + } else if ((!staticProps || !can.isFunction(staticProps[parseName])) && !self[parseName]) { + var madeParser = maker(); + madeParser.useModelConverter = hasCustomConverter[parseName]; + can.Construct._overwrite(self, base, parseName, madeParser); + } + }); + if (self.fullName === 'can.Model' || !self.fullName) { + self.fullName = 'Model' + ++modelNum; + } + can.Model._reqs = 0; + this._url = this._shortName + '/{' + this.id + '}'; + }, + _ajax: ajaxMaker, + _makeRequest: makeRequest, + _clean: function () { + can.Model._reqs--; + if (!can.Model._reqs) { + for (var id in this.store) { + if (!this.store[id]._bindings) { + delete this.store[id]; + } + } + } + return arguments[0]; + }, + models: converters.models, + model: converters.model +}, { + setup: function (attrs) { + var id = attrs && attrs[this.constructor.id]; + if (can.Model._reqs && id != null) { + this.constructor.store[id] = this; + } + can.Map.prototype.setup.apply(this, arguments); + }, + isNew: function () { + var id = getId(this); + return !(id || id === 0); + }, + save: function (success, error) { + return makeRequest(this, this.isNew() ? 'create' : 'update', success, error); + }, + destroy: function (success, error) { + if (this.isNew()) { + var self = this; + var def = can.Deferred(); + def.then(success, error); + return def.done(function (data) { + self.destroyed(data); + }).resolve(self); + } + return makeRequest(this, 'destroy', success, error, 'destroyed'); + }, + _bindsetup: function () { + var modelInstance = this.__get(this.constructor.id); + if (modelInstance != null) { + this.constructor.store[modelInstance] = this; + } + return can.Map.prototype._bindsetup.apply(this, arguments); + }, + _bindteardown: function () { + delete this.constructor.store[getId(this)]; + return can.Map.prototype._bindteardown.apply(this, arguments); + }, + ___set: function (prop, val) { + can.Map.prototype.___set.call(this, prop, val); + if (prop === this.constructor.id && this._bindings) { + this.constructor.store[getId(this)] = this; + } + } +}); +var makeGetterHandler = function (name) { + return function (data, readyState, xhr) { + return this[name](data, null, xhr); + }; + }, createUpdateDestroyHandler = function (data) { + if (this.parseModel.useModelConverter) { + return this.model(data); + } + return this.parseModel(data); + }; +var responseHandlers = { + makeFindAll: makeGetterHandler('models'), + makeFindOne: makeGetterHandler('model'), + makeCreate: createUpdateDestroyHandler, + makeUpdate: createUpdateDestroyHandler, + makeDestroy: createUpdateDestroyHandler + }; +can.each(responseHandlers, function (method, name) { + can.Model[name] = function (oldMethod) { + return function () { + var args = can.makeArray(arguments), oldArgs = can.isFunction(args[1]) ? args.splice(0, 1) : args.splice(0, 2), def = pipe(oldMethod.apply(this, oldArgs), this, method); + def.then(args[0], args[1]); + return def; + }; + }; +}); +can.each([ + 'created', + 'updated', + 'destroyed' +], function (funcName) { + can.Model.prototype[funcName] = function (attrs) { + var self = this, constructor = self.constructor; + if (attrs && typeof attrs === 'object') { + this.attr(can.isFunction(attrs.attr) ? attrs.attr() : attrs); + } + can.dispatch.call(this, { + type: 'change', + target: this + }, [funcName]); + can.dispatch.call(constructor, funcName, [this]); + }; +}); +var ML = can.Model.List = can.List.extend({ + _bubbleRule: function (eventName, list) { + var bubbleRules = can.List._bubbleRule(eventName, list); + bubbleRules.push('destroyed'); + return bubbleRules; + } + }, { + setup: function (params) { + if (can.isPlainObject(params) && !can.isArray(params)) { + can.List.prototype.setup.apply(this); + this.replace(can.isDeferred(params) ? params : this.constructor.Map.findAll(params)); + } else { + can.List.prototype.setup.apply(this, arguments); + } + this._init = 1; + this.bind('destroyed', can.proxy(this._destroyed, this)); + delete this._init; + }, + _destroyed: function (ev, attr) { + if (/\w+/.test(attr)) { + var index; + while ((index = this.indexOf(ev.target)) > -1) { + this.splice(index, 1); + } + } + } + }); +module.exports = can.Model; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/model/queue/queue.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/model/queue/queue.js new file mode 100644 index 0000000000..68e4efd05f --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/model/queue/queue.js @@ -0,0 +1,106 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#model/queue/queue*/ +var can = require('../../util/util.js'); +require('../model.js'); +require('../../map/backup/backup.js'); +var cleanAttrs = function (changedAttrs, attrs) { + var newAttrs = can.extend(true, {}, attrs), current, path; + if (changedAttrs) { + for (var i = 0; i < changedAttrs.length; i++) { + current = newAttrs; + path = changedAttrs[i].split('.'); + while (path.length > 1) { + current = current && current[path.shift()]; + } + if (current) { + delete current[path.shift()]; + } + } + } + return newAttrs; + }, queueRequests = function (success, error, method, callback) { + this._changedAttrs = this._changedAttrs || []; + var def = new can.Deferred(), self = this, attrs = this.serialize(), queue = this._requestQueue, changedAttrs = this._changedAttrs, reqFn, index; + reqFn = function (self, type, success, error) { + return function () { + return self.constructor._makeRequest([ + self, + attrs + ], type || (self.isNew() ? 'create' : 'update'), success, error, callback); + }; + }(this, method, function () { + def.resolveWith(self, arguments); + queue.splice(0, 1); + if (queue.length > 0) { + queue[0] = queue[0](); + } else { + changedAttrs.splice(0); + } + }, function () { + def.rejectWith(self, arguments); + queue.splice(0); + changedAttrs.splice(0); + }); + index = queue.push(reqFn) - 1; + if (queue.length === 1) { + queue[0] = queue[0](); + } + def.abort = function () { + var abort; + abort = queue[index].abort && queue[index].abort(); + queue.splice(index); + if (queue.length === 0) { + changedAttrs.splice(0); + } + return abort; + }; + def.then(success, error); + return def; + }, _triggerChange = can.Model.prototype._triggerChange, destroyFn = can.Model.prototype.destroy, setupFn = can.Model.prototype.setup; +can.each([ + 'created', + 'updated', + 'destroyed' +], function (fn) { + var prototypeFn = can.Model.prototype[fn]; + can.Model.prototype[fn] = function (attrs) { + if (attrs && typeof attrs === 'object') { + attrs = attrs.attr ? attrs.attr() : attrs; + this._backupStore(attrs); + attrs = cleanAttrs(this._changedAttrs || [], attrs); + } + prototypeFn.call(this, attrs); + }; +}); +can.extend(can.Model.prototype, { + setup: function () { + setupFn.apply(this, arguments); + this._requestQueue = new can.List(); + }, + _triggerChange: function (attr, how, newVal, oldVal) { + if (this._changedAttrs) { + this._changedAttrs.push(attr); + } + _triggerChange.apply(this, arguments); + }, + hasQueuedRequests: function () { + return this._requestQueue.attr('length') > 1; + }, + save: function () { + return queueRequests.apply(this, arguments); + }, + destroy: function (success, error) { + if (this.isNew()) { + return destroyFn.call(this, success, error); + } + return queueRequests.call(this, success, error, 'destroy', 'destroyed'); + } +}); +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/observe/observe.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/observe/observe.js new file mode 100644 index 0000000000..6aef1dc6da --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/observe/observe.js @@ -0,0 +1,18 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#observe/observe*/ +var can = require('../util/util.js'); +require('../map/map.js'); +require('../list/list.js'); +require('../compute/compute.js'); +can.Observe = can.Map; +can.Observe.startBatch = can.batch.start; +can.Observe.stopBatch = can.batch.stop; +can.Observe.triggerBatch = can.batch.trigger; +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/route/pushstate/pushstate.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/route/pushstate/pushstate.js new file mode 100644 index 0000000000..5ebd817624 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/route/pushstate/pushstate.js @@ -0,0 +1,122 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#route/pushstate/pushstate*/ +var can = require('../../util/util.js'); +require('../route.js'); +'use strict'; +if (window.history && history.pushState) { + can.route.bindings.pushstate = { + root: '/', + matchSlashes: false, + paramsMatcher: /^\?(?:[^=]+=[^&]*&)*[^=]+=[^&]*/, + querySeparator: '?', + bind: function () { + can.delegate.call(can.$(document.documentElement), 'a', 'click', anchorClickHandler); + can.each(methodsToOverwrite, function (method) { + originalMethods[method] = window.history[method]; + window.history[method] = function (state, title, url) { + var absolute = url.indexOf('http') === 0; + var searchHash = window.location.search + window.location.hash; + if (!absolute && url !== window.location.pathname + searchHash || absolute && url !== window.location.href + searchHash) { + originalMethods[method].apply(window.history, arguments); + can.route.setState(); + } + }; + }); + can.bind.call(window, 'popstate', can.route.setState); + }, + unbind: function () { + can.undelegate.call(can.$(document.documentElement), 'click', 'a', anchorClickHandler); + can.each(methodsToOverwrite, function (method) { + window.history[method] = originalMethods[method]; + }); + can.unbind.call(window, 'popstate', can.route.setState); + }, + matchingPartOfURL: function () { + var root = cleanRoot(), loc = location.pathname + location.search, index = loc.indexOf(root); + return loc.substr(index + root.length); + }, + setURL: function (path, changed) { + var method = 'pushState'; + if (includeHash && path.indexOf('#') === -1 && window.location.hash) { + path += window.location.hash; + } + if (replaceStateAttrs.length > 0) { + var toRemove = []; + for (var i = 0, l = changed.length; i < l; i++) { + if (can.inArray(changed[i], replaceStateAttrs) !== -1) { + method = 'replaceState'; + } + if (can.inArray(changed[i], replaceStateAttrs.once) !== -1) { + toRemove.push(changed[i]); + } + } + if (toRemove.length > 0) { + removeAttrs(replaceStateAttrs, toRemove); + removeAttrs(replaceStateAttrs.once, toRemove); + } + } + window.history[method](null, null, can.route._call('root') + path); + } + }; + var anchorClickHandler = function (e) { + if (!(e.isDefaultPrevented ? e.isDefaultPrevented() : e.defaultPrevented === true)) { + var node = this._node || this; + var linksHost = node.host || window.location.host; + if (window.location.host === linksHost) { + var root = cleanRoot(); + if (node.pathname.indexOf(root) === 0) { + var url = (node.pathname + node.search).substr(root.length); + var curParams = can.route.deparam(url); + if (curParams.hasOwnProperty('route')) { + includeHash = true; + window.history.pushState(null, null, node.href); + if (e.preventDefault) { + e.preventDefault(); + } + } + } + } + } + }, cleanRoot = function () { + var domain = location.protocol + '//' + location.host, root = can.route._call('root'), index = root.indexOf(domain); + if (index === 0) { + return root.substr(domain.length); + } + return root; + }, removeAttrs = function (arr, attrs) { + var index; + for (var i = attrs.length - 1; i >= 0; i--) { + if ((index = can.inArray(attrs[i], arr)) !== -1) { + arr.splice(index, 1); + } + } + }, methodsToOverwrite = [ + 'pushState', + 'replaceState' + ], originalMethods = {}, includeHash = false, replaceStateAttrs = []; + can.route.defaultBinding = 'pushstate'; + can.extend(can.route, { + replaceStateOn: function () { + var attrs = can.makeArray(arguments); + Array.prototype.push.apply(replaceStateAttrs, attrs); + }, + replaceStateOnce: function () { + var attrs = can.makeArray(arguments); + replaceStateAttrs.once = can.makeArray(replaceStateAttrs.once); + Array.prototype.push.apply(replaceStateAttrs.once, attrs); + can.route.replaceStateOn.apply(this, arguments); + }, + replaceStateOff: function () { + var attrs = can.makeArray(arguments); + removeAttrs(replaceStateAttrs, attrs); + } + }); +} +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/route/route.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/route/route.js new file mode 100644 index 0000000000..59f2f1832c --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/route/route.js @@ -0,0 +1,302 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#route/route*/ +var can = require('../util/util.js'); +require('../map/map.js'); +require('../list/list.js'); +require('../util/string/deparam/deparam.js'); +var matcher = /\:([\w\.]+)/g, paramsMatcher = /^(?:&[^=]+=[^&]*)+/, makeProps = function (props) { + var tags = []; + can.each(props, function (val, name) { + tags.push((name === 'className' ? 'class' : name) + '="' + (name === 'href' ? val : can.esc(val)) + '"'); + }); + return tags.join(' '); + }, matchesData = function (route, data) { + var count = 0, i = 0, defaults = {}; + for (var name in route.defaults) { + if (route.defaults[name] === data[name]) { + defaults[name] = 1; + count++; + } + } + for (; i < route.names.length; i++) { + if (!data.hasOwnProperty(route.names[i])) { + return -1; + } + if (!defaults[route.names[i]]) { + count++; + } + } + return count; + }, location = window.location, wrapQuote = function (str) { + return (str + '').replace(/([.?*+\^$\[\]\\(){}|\-])/g, '\\$1'); + }, each = can.each, extend = can.extend, stringify = function (obj) { + if (obj && typeof obj === 'object') { + if (obj instanceof can.Map) { + obj = obj.attr(); + } else { + obj = can.isFunction(obj.slice) ? obj.slice() : can.extend({}, obj); + } + can.each(obj, function (val, prop) { + obj[prop] = stringify(val); + }); + } else if (obj !== undefined && obj !== null && can.isFunction(obj.toString)) { + obj = obj.toString(); + } + return obj; + }, removeBackslash = function (str) { + return str.replace(/\\/g, ''); + }, timer, curParams, lastHash, changingData, changedAttrs = [], onRouteDataChange = function (ev, attr, how, newval) { + changingData = 1; + changedAttrs.push(attr); + clearTimeout(timer); + timer = setTimeout(function () { + changingData = 0; + var serialized = can.route.data.serialize(), path = can.route.param(serialized, true); + can.route._call('setURL', path, changedAttrs); + can.batch.trigger(eventsObject, '__url', [ + path, + lastHash + ]); + lastHash = path; + changedAttrs = []; + }, 10); + }, eventsObject = can.extend({}, can.event); +can.route = function (url, defaults) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + defaults = defaults || {}; + var names = [], res, test = '', lastIndex = matcher.lastIndex = 0, next, querySeparator = can.route._call('querySeparator'), matchSlashes = can.route._call('matchSlashes'); + while (res = matcher.exec(url)) { + names.push(res[1]); + test += removeBackslash(url.substring(lastIndex, matcher.lastIndex - res[0].length)); + next = '\\' + (removeBackslash(url.substr(matcher.lastIndex, 1)) || querySeparator + (matchSlashes ? '' : '|/')); + test += '([^' + next + ']' + (defaults[res[1]] ? '*' : '+') + ')'; + lastIndex = matcher.lastIndex; + } + test += url.substr(lastIndex).replace('\\', ''); + can.route.routes[url] = { + test: new RegExp('^' + test + '($|' + wrapQuote(querySeparator) + ')'), + route: url, + names: names, + defaults: defaults, + length: url.split('/').length + }; + return can.route; +}; +extend(can.route, { + param: function (data, _setRoute) { + var route, matches = 0, matchCount, routeName = data.route, propCount = 0; + delete data.route; + each(data, function () { + propCount++; + }); + each(can.route.routes, function (temp, name) { + matchCount = matchesData(temp, data); + if (matchCount > matches) { + route = temp; + matches = matchCount; + } + if (matchCount >= propCount) { + return false; + } + }); + if (can.route.routes[routeName] && matchesData(can.route.routes[routeName], data) === matches) { + route = can.route.routes[routeName]; + } + if (route) { + var cpy = extend({}, data), res = route.route.replace(matcher, function (whole, name) { + delete cpy[name]; + return data[name] === route.defaults[name] ? '' : encodeURIComponent(data[name]); + }).replace('\\', ''), after; + each(route.defaults, function (val, name) { + if (cpy[name] === val) { + delete cpy[name]; + } + }); + after = can.param(cpy); + if (_setRoute) { + can.route.attr('route', route.route); + } + return res + (after ? can.route._call('querySeparator') + after : ''); + } + return can.isEmptyObject(data) ? '' : can.route._call('querySeparator') + can.param(data); + }, + deparam: function (url) { + var root = can.route._call('root'); + if (root.lastIndexOf('/') === root.length - 1 && url.indexOf('/') === 0) { + url = url.substr(1); + } + var route = { length: -1 }, querySeparator = can.route._call('querySeparator'), paramsMatcher = can.route._call('paramsMatcher'); + each(can.route.routes, function (temp, name) { + if (temp.test.test(url) && temp.length > route.length) { + route = temp; + } + }); + if (route.length > -1) { + var parts = url.match(route.test), start = parts.shift(), remainder = url.substr(start.length - (parts[parts.length - 1] === querySeparator ? 1 : 0)), obj = remainder && paramsMatcher.test(remainder) ? can.deparam(remainder.slice(1)) : {}; + obj = extend(true, {}, route.defaults, obj); + each(parts, function (part, i) { + if (part && part !== querySeparator) { + obj[route.names[i]] = decodeURIComponent(part); + } + }); + obj.route = route.route; + return obj; + } + if (url.charAt(0) !== querySeparator) { + url = querySeparator + url; + } + return paramsMatcher.test(url) ? can.deparam(url.slice(1)) : {}; + }, + data: new can.Map({}), + map: function (data) { + var appState; + if (data.prototype instanceof can.Map) { + appState = new data(); + } else { + appState = data; + } + can.route.data = appState; + }, + routes: {}, + ready: function (val) { + if (val !== true) { + can.route._setup(); + can.route.setState(); + } + return can.route; + }, + url: function (options, merge) { + if (merge) { + options = can.extend({}, can.route.deparam(can.route._call('matchingPartOfURL')), options); + } + return can.route._call('root') + can.route.param(options); + }, + link: function (name, options, props, merge) { + return '' + name + ''; + }, + current: function (options) { + can.__observe(eventsObject, '__url'); + return this._call('matchingPartOfURL') === can.route.param(options); + }, + bindings: { + hashchange: { + paramsMatcher: paramsMatcher, + querySeparator: '&', + matchSlashes: false, + bind: function () { + can.bind.call(window, 'hashchange', setState); + }, + unbind: function () { + can.unbind.call(window, 'hashchange', setState); + }, + matchingPartOfURL: function () { + return location.href.split(/#!?/)[1] || ''; + }, + setURL: function (path) { + if (location.hash !== '#' + path) { + location.hash = '!' + path; + } + return path; + }, + root: '#!' + } + }, + defaultBinding: 'hashchange', + currentBinding: null, + _setup: function () { + if (!can.route.currentBinding) { + can.route._call('bind'); + can.route.bind('change', onRouteDataChange); + can.route.currentBinding = can.route.defaultBinding; + } + }, + _teardown: function () { + if (can.route.currentBinding) { + can.route._call('unbind'); + can.route.unbind('change', onRouteDataChange); + can.route.currentBinding = null; + } + clearTimeout(timer); + changingData = 0; + }, + _call: function () { + var args = can.makeArray(arguments), prop = args.shift(), binding = can.route.bindings[can.route.currentBinding || can.route.defaultBinding], method = binding[prop]; + if (method.apply) { + return method.apply(binding, args); + } else { + return method; + } + } +}); +each([ + 'bind', + 'unbind', + 'on', + 'off', + 'delegate', + 'undelegate', + 'removeAttr', + 'compute', + '_get', + '__get', + 'each' +], function (name) { + can.route[name] = function () { + if (!can.route.data[name]) { + return; + } + return can.route.data[name].apply(can.route.data, arguments); + }; +}); +can.route.attr = function (attr, val) { + var type = typeof attr, newArguments; + if (val === undefined) { + newArguments = arguments; + } else if (type !== 'string' && type !== 'number') { + newArguments = [ + stringify(attr), + val + ]; + } else { + newArguments = [ + attr, + stringify(val) + ]; + } + return can.route.data.attr.apply(can.route.data, newArguments); +}; +var setState = can.route.setState = function () { + var hash = can.route._call('matchingPartOfURL'); + var oldParams = curParams; + curParams = can.route.deparam(hash); + if (!changingData || hash !== lastHash) { + can.batch.start(); + recursiveClean(oldParams, curParams, can.route.data); + can.route.attr(curParams); + can.batch.trigger(eventsObject, '__url', [ + hash, + lastHash + ]); + can.batch.stop(); + } + }; +var recursiveClean = function (old, cur, data) { + for (var attr in old) { + if (cur[attr] === undefined) { + data.removeAttr(attr); + } else if (Object.prototype.toString.call(old[attr]) === '[object Object]') { + recursiveClean(old[attr], cur[attr], data.attr(attr)); + } + } +}; +module.exports = can.route; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/array/each.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/array/each.js new file mode 100644 index 0000000000..54b0c0659d --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/array/each.js @@ -0,0 +1,55 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/array/each*/ +var can = require('../can.js'); +var isArrayLike = function (obj) { + var length = 'length' in obj && obj.length; + return typeof arr !== 'function' && (length === 0 || typeof length === 'number' && length > 0 && length - 1 in obj); +}; +can.each = function (elements, callback, context) { + var i = 0, key, len, item; + if (elements) { + if (isArrayLike(elements)) { + if (can.List && elements instanceof can.List) { + for (len = elements.attr('length'); i < len; i++) { + item = elements.attr(i); + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } else { + for (len = elements.length; i < len; i++) { + item = elements[i]; + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } + } else if (typeof elements === 'object') { + if (can.Map && elements instanceof can.Map || elements === can.route) { + var keys = can.Map.keys(elements); + for (i = 0, len = keys.length; i < len; i++) { + key = keys[i]; + item = elements.attr(key); + if (callback.call(context || item, item, key, elements) === false) { + break; + } + } + } else { + for (key in elements) { + if (elements.hasOwnProperty(key) && callback.call(context || elements[key], elements[key], key, elements) === false) { + break; + } + } + } + } + } + return elements; +}; +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/array/makeArray.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/array/makeArray.js new file mode 100644 index 0000000000..3eda7574c6 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/array/makeArray.js @@ -0,0 +1,18 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/array/makeArray*/ +var can = require('./each.js'); +can.makeArray = function (arr) { + var ret = []; + can.each(arr, function (a, i) { + ret[i] = a; + }); + return ret; +}; +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/attr/attr.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/attr/attr.js new file mode 100644 index 0000000000..26a699d273 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/attr/attr.js @@ -0,0 +1,129 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/attr/attr*/ +var can = require('../can.js'); +var setImmediate = can.global.setImmediate || function (cb) { + return setTimeout(cb, 0); + }, attr = { + MutationObserver: can.global.MutationObserver || can.global.WebKitMutationObserver || can.global.MozMutationObserver, + map: { + 'class': 'className', + 'value': 'value', + 'innertext': 'innerText', + 'textcontent': 'textContent', + 'checked': true, + 'disabled': true, + 'readonly': true, + 'required': true, + src: function (el, val) { + if (val == null || val === '') { + el.removeAttribute('src'); + return null; + } else { + el.setAttribute('src', val); + return val; + } + }, + style: function (el, val) { + return el.style.cssText = val || ''; + } + }, + defaultValue: [ + 'input', + 'textarea' + ], + set: function (el, attrName, val) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var tagName = el.nodeName.toString().toLowerCase(), prop = attr.map[attrName], newValue; + if (typeof prop === 'function') { + newValue = prop(el, val); + } else if (prop === true) { + newValue = el[attrName] = true; + if (attrName === 'checked' && el.type === 'radio') { + if (can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultChecked = true; + } + } + } else if (prop) { + newValue = val; + if (el[prop] !== val) { + el[prop] = val; + } + if (prop === 'value' && can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultValue = val; + } + } else { + el.setAttribute(attrName, val); + newValue = val; + } + if (!attr.MutationObserver && newValue !== oldValue) { + attr.trigger(el, attrName, oldValue); + } + }, + trigger: function (el, attrName, oldValue) { + if (can.data(can.$(el), 'canHasAttributesBindings')) { + attrName = attrName.toLowerCase(); + return setImmediate(function () { + can.trigger(el, { + type: 'attributes', + attributeName: attrName, + target: el, + oldValue: oldValue, + bubbles: false + }, []); + }); + } + }, + get: function (el, attrName) { + attrName = attrName.toLowerCase(); + var prop = attr.map[attrName]; + if (typeof prop === 'string' && el[prop]) { + return el[prop]; + } + return el.getAttribute(attrName); + }, + remove: function (el, attrName) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + var setter = attr.map[attrName]; + if (typeof setter === 'function') { + setter(el, undefined); + } + if (setter === true) { + el[attrName] = false; + } else if (typeof setter === 'string') { + el[setter] = ''; + } else { + el.removeAttribute(attrName); + } + if (!attr.MutationObserver && oldValue != null) { + attr.trigger(el, attrName, oldValue); + } + }, + has: function () { + var el = can.global.document && document.createElement('div'); + if (el && el.hasAttribute) { + return function (el, name) { + return el.hasAttribute(name); + }; + } else { + return function (el, name) { + return el.getAttribute(name) !== null; + }; + } + }() + }; +module.exports = attr; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/batch/batch.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/batch/batch.js new file mode 100644 index 0000000000..4d9ccb3902 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/batch/batch.js @@ -0,0 +1,88 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/batch/batch*/ +var can = require('../can.js'); +var batchNum = 1, transactions = 0, batchEvents = [], stopCallbacks = [], currentBatchEvents = null; +can.batch = { + start: function (batchStopHandler) { + transactions++; + if (batchStopHandler) { + stopCallbacks.push(batchStopHandler); + } + }, + stop: function (force, callStart) { + if (force) { + transactions = 0; + } else { + transactions--; + } + if (transactions === 0) { + if (currentBatchEvents !== null) { + return; + } + currentBatchEvents = batchEvents.slice(0); + var callbacks = stopCallbacks.slice(0), i, len; + batchEvents = []; + stopCallbacks = []; + can.batch.batchNum = batchNum; + batchNum++; + if (callStart) { + can.batch.start(); + } + for (i = 0; i < currentBatchEvents.length; i++) { + can.dispatch.apply(currentBatchEvents[i][0], currentBatchEvents[i][1]); + } + currentBatchEvents = null; + for (i = 0, len = callbacks.length; i < callbacks.length; i++) { + callbacks[i](); + } + can.batch.batchNum = undefined; + } + }, + trigger: function (item, event, args) { + if (!item._init) { + event = typeof event === 'string' ? { type: event } : event; + if (currentBatchEvents) { + currentBatchEvents.push([ + item, + [ + event, + args + ] + ]); + } else if (transactions === 0) { + return can.dispatch.call(item, event, args); + } else { + event.batchNum = batchNum; + batchEvents.push([ + item, + [ + event, + args + ] + ]); + } + } + }, + afterPreviousEvents: function (handler) { + if (currentBatchEvents) { + var obj = {}; + can.bind.call(obj, 'ready', handler); + currentBatchEvents.push([ + obj, + [ + { type: 'ready' }, + [] + ] + ]); + } else { + handler(); + } + } +}; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/bind/bind.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/bind/bind.js new file mode 100644 index 0000000000..7eb7b902d1 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/bind/bind.js @@ -0,0 +1,39 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/bind/bind*/ +var can = require('../util.js'); +can.bindAndSetup = function () { + can.addEvent.apply(this, arguments); + if (!this._init) { + if (!this._bindings) { + this._bindings = 1; + if (this._bindsetup) { + this._bindsetup(); + } + } else { + this._bindings++; + } + } + return this; +}; +can.unbindAndTeardown = function (event, handler) { + var handlers = this.__bindEvents[event] || []; + var handlerCount = handlers.length; + can.removeEvent.apply(this, arguments); + if (this._bindings === null) { + this._bindings = 0; + } else { + this._bindings = this._bindings - (handlerCount - handlers.length); + } + if (!this._bindings && this._bindteardown) { + this._bindteardown(); + } + return this; +}; +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/can.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/can.js new file mode 100644 index 0000000000..4581e7f701 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/can.js @@ -0,0 +1,122 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/can*/ +var glbl = typeof window !== 'undefined' ? window : global; +var can = {}; +if (typeof GLOBALCAN === 'undefined' || GLOBALCAN !== false) { + glbl.can = can; +} +can.global = glbl; +can.k = function () { +}; +can.isDeferred = can.isPromise = function (obj) { + return obj && typeof obj.then === 'function' && typeof obj.pipe === 'function'; +}; +can.isMapLike = function (obj) { + return can.Map && (obj instanceof can.Map || obj && obj.__get); +}; +var cid = 0; +can.cid = function (object, name) { + if (!object._cid) { + cid++; + object._cid = (name || '') + cid; + } + return object._cid; +}; +can.VERSION = '2.2.6'; +can.simpleExtend = function (d, s) { + for (var prop in s) { + d[prop] = s[prop]; + } + return d; +}; +can.last = function (arr) { + return arr && arr[arr.length - 1]; +}; +var protoBind = Function.prototype.bind; +if (protoBind) { + can.proxy = function (fn, context) { + return protoBind.call(fn, context); + }; +} else { + can.proxy = function (fn, context) { + return function () { + return fn.apply(context, arguments); + }; + }; +} +can.frag = function (item) { + var frag; + if (!item || typeof item === 'string') { + frag = can.buildFragment(item == null ? '' : '' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } else if (item.nodeType === 11) { + return item; + } else if (typeof item.nodeType === 'number') { + frag = document.createDocumentFragment(); + frag.appendChild(item); + return frag; + } else if (typeof item.length === 'number') { + frag = document.createDocumentFragment(); + can.each(item, function (item) { + frag.appendChild(can.frag(item)); + }); + return frag; + } else { + frag = can.buildFragment('' + item, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } +}; +can.scope = can.viewModel = function (el, attr, val) { + el = can.$(el); + var scope = can.data(el, 'scope') || can.data(el, 'viewModel'); + if (!scope) { + scope = new can.Map(); + can.data(el, 'scope', scope); + can.data(el, 'viewModel', scope); + } + switch (arguments.length) { + case 0: + case 1: + return scope; + case 2: + return scope.attr(attr); + default: + scope.attr(attr, val); + return el; + } +}; +can['import'] = function (moduleName) { + var deferred = new can.Deferred(); + if (typeof window.System === 'object' && can.isFunction(window.System['import'])) { + window.System['import'](moduleName).then(can.proxy(deferred.resolve, deferred), can.proxy(deferred.reject, deferred)); + } else if (window.define && window.define.amd) { + window.require([moduleName], function (value) { + deferred.resolve(value); + }); + } else if (window.steal) { + steal.steal(moduleName, function (value) { + deferred.resolve(value); + }); + } else if (window.require) { + deferred.resolve(window.require(moduleName)); + } else { + deferred.resolve(); + } + return deferred.promise(); +}; +can.__observe = function () { +}; +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/domless/domless.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/domless/domless.js new file mode 100644 index 0000000000..0a408d03d7 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/domless/domless.js @@ -0,0 +1,103 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/domless/domless*/ +var can = require('../can.js'); +var attr = require('../attr/attr.js'); +require('../array/each.js'); +require('../array/makeArray.js'); +var core_trim = String.prototype.trim; +var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g; +function likeArray(obj) { + return typeof obj.length === 'number'; +} +function flatten(array) { + return array.length > 0 ? Array.prototype.concat.apply([], array) : array; +} +can.isArray = function (arr) { + return arr instanceof Array; +}; +can.isFunction = function () { + if (typeof document !== 'undefined' && typeof document.getElementsByTagName('body') === 'function') { + return function (value) { + return Object.prototype.toString.call(value) === '[object Function]'; + }; + } else { + return function (value) { + return typeof value === 'function'; + }; + } +}(); +can.trim = core_trim && !core_trim.call('\uFEFF\xA0') ? function (text) { + return text == null ? '' : core_trim.call(text); +} : function (text) { + return text == null ? '' : (text + '').replace(rtrim, ''); +}; +can.extend = function () { + var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, length = arguments.length, deep = false; + if (typeof target === 'boolean') { + deep = target; + target = arguments[1] || {}; + i = 2; + } + if (typeof target !== 'object' && !can.isFunction(target)) { + target = {}; + } + if (length === i) { + target = this; + --i; + } + for (; i < length; i++) { + if ((options = arguments[i]) != null) { + for (name in options) { + src = target[name]; + copy = options[name]; + if (target === copy) { + continue; + } + if (deep && copy && (can.isPlainObject(copy) || (copyIsArray = can.isArray(copy)))) { + if (copyIsArray) { + copyIsArray = false; + clone = src && can.isArray(src) ? src : []; + } else { + clone = src && can.isPlainObject(src) ? src : {}; + } + target[name] = can.extend(deep, clone, copy); + } else if (copy !== undefined) { + target[name] = copy; + } + } + } + } + return target; +}; +can.map = function (elements, callback) { + var values = [], putValue = function (val, index) { + var value = callback(val, index); + if (value != null) { + values.push(value); + } + }; + if (likeArray(elements)) { + for (var i = 0, l = elements.length; i < l; i++) { + putValue(elements[i], i); + } + } else { + for (var key in elements) { + putValue(elements[key], key); + } + } + return flatten(values); +}; +can.proxy = function (cb, that) { + return function () { + return cb.apply(that, arguments); + }; +}; +can.attr = attr; +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/event.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/event.js new file mode 100644 index 0000000000..1b5f99015e --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/event.js @@ -0,0 +1,12 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/event*/ +var can = require('./can.js'); +require('../event/event.js'); +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/fixture/fixture.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/fixture/fixture.js new file mode 100644 index 0000000000..6c1ab078cc --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/fixture/fixture.js @@ -0,0 +1,492 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/fixture/fixture*/ +var can = require('../util.js'); +require('../string/string.js'); +require('../object/object.js'); +if (!can.Object) { + throw new Error('can.fixture depends on can.Object. Please include it before can.fixture.'); +} +var getUrl = function (url) { + if (typeof steal !== 'undefined') { + if (steal.joinURIs) { + var base = steal.config('baseUrl'); + var joined = steal.joinURIs(base, url); + return joined; + } + if (can.isFunction(steal.config)) { + if (steal.System) { + return steal.joinURIs(steal.config('baseURL'), url); + } else { + return steal.config().root.mapJoin(url).toString(); + } + } + return steal.root.join(url).toString(); + } + return (can.fixture.rootUrl || '') + url; +}; +var updateSettings = function (settings, originalOptions) { + if (!can.fixture.on || settings.fixture === false) { + return; + } + var log = function () { + }; + settings.type = settings.type || settings.method || 'GET'; + var data = overwrite(settings); + if (!settings.fixture) { + if (window.location.protocol === 'file:') { + log('ajax request to ' + settings.url + ', no fixture found'); + } + return; + } + if (typeof settings.fixture === 'string' && can.fixture[settings.fixture]) { + settings.fixture = can.fixture[settings.fixture]; + } + if (typeof settings.fixture === 'string') { + var url = settings.fixture; + if (/^\/\//.test(url)) { + url = getUrl(settings.fixture.substr(2)); + } + if (data) { + url = can.sub(url, data); + } + delete settings.fixture; + settings.url = url; + settings.data = null; + settings.type = 'GET'; + if (!settings.error) { + settings.error = function (xhr, error, message) { + throw 'fixtures.js Error ' + error + ' ' + message; + }; + } + } else { + if (settings.dataTypes) { + settings.dataTypes.splice(0, 0, 'fixture'); + } + if (data && originalOptions) { + originalOptions.data = originalOptions.data || {}; + can.extend(originalOptions.data, data); + } + } + }, extractResponse = function (status, statusText, responses, headers) { + if (typeof status !== 'number') { + headers = statusText; + responses = status; + statusText = 'success'; + status = 200; + } + if (typeof statusText !== 'string') { + headers = responses; + responses = statusText; + statusText = 'success'; + } + if (status >= 400 && status <= 599) { + this.dataType = 'text'; + } + return [ + status, + statusText, + extractResponses(this, responses), + headers + ]; + }, extractResponses = function (settings, responses) { + var next = settings.dataTypes ? settings.dataTypes[0] : settings.dataType || 'json'; + if (!responses || !responses[next]) { + var tmp = {}; + tmp[next] = responses; + responses = tmp; + } + return responses; + }; +if (can.ajaxPrefilter && can.ajaxTransport) { + can.ajaxPrefilter(updateSettings); + can.ajaxTransport('fixture', function (s, original) { + s.dataTypes.shift(); + var timeout, stopped = false; + return { + send: function (headers, callback) { + timeout = setTimeout(function () { + var success = function () { + if (stopped === false) { + callback.apply(null, extractResponse.apply(s, arguments)); + } + }, result = s.fixture(original, success, headers, s); + if (result !== undefined) { + callback(200, 'success', extractResponses(s, result), {}); + } + }, can.fixture.delay); + }, + abort: function () { + stopped = true; + clearTimeout(timeout); + } + }; + }); +} else { + var AJAX = can.ajax; + can.ajax = function (settings) { + updateSettings(settings, settings); + if (settings.fixture) { + var timeout, deferred = new can.Deferred(), stopped = false; + deferred.getResponseHeader = function () { + }; + deferred.then(settings.success, settings.fail); + deferred.abort = function () { + clearTimeout(timeout); + stopped = true; + deferred.reject(deferred); + }; + timeout = setTimeout(function () { + var success = function () { + var response = extractResponse.apply(settings, arguments), status = response[0]; + if ((status >= 200 && status < 300 || status === 304) && stopped === false) { + deferred.resolve(response[2][settings.dataType]); + } else { + deferred.reject(deferred, 'error', response[1]); + } + }, result = settings.fixture(settings, success, settings.headers, settings); + if (result !== undefined) { + deferred.resolve(result); + } + }, can.fixture.delay); + return deferred; + } else { + return AJAX(settings); + } + }; +} +var overwrites = [], find = function (settings, exact) { + for (var i = 0; i < overwrites.length; i++) { + if ($fixture._similar(settings, overwrites[i], exact)) { + return i; + } + } + return -1; + }, overwrite = function (settings) { + var index = find(settings); + if (index > -1) { + settings.fixture = overwrites[index].fixture; + return $fixture._getData(overwrites[index].url, settings.url); + } + }, getId = function (settings) { + var id = settings.data.id; + if (id === undefined && typeof settings.data === 'number') { + id = settings.data; + } + if (id === undefined) { + settings.url.replace(/\/(\d+)(\/|$|\.)/g, function (all, num) { + id = num; + }); + } + if (id === undefined) { + id = settings.url.replace(/\/(\w+)(\/|$|\.)/g, function (all, num) { + if (num !== 'update') { + id = num; + } + }); + } + if (id === undefined) { + id = Math.round(Math.random() * 1000); + } + return id; + }; +var $fixture = can.fixture = function (settings, fixture) { + if (fixture !== undefined) { + if (typeof settings === 'string') { + var matches = settings.match(/(GET|POST|PUT|DELETE) (.+)/i); + if (!matches) { + settings = { url: settings }; + } else { + settings = { + url: matches[2], + type: matches[1] + }; + } + } + var index = find(settings, !!fixture); + if (index > -1) { + overwrites.splice(index, 1); + } + if (fixture == null) { + return; + } + settings.fixture = fixture; + overwrites.push(settings); + } else { + can.each(settings, function (fixture, url) { + $fixture(url, fixture); + }); + } + }; +var replacer = can.replacer; +can.extend(can.fixture, { + _similar: function (settings, overwrite, exact) { + if (exact) { + return can.Object.same(settings, overwrite, { fixture: null }); + } else { + return can.Object.subset(settings, overwrite, can.fixture._compare); + } + }, + _compare: { + url: function (a, b) { + return !!$fixture._getData(b, a); + }, + fixture: null, + type: 'i' + }, + _getData: function (fixtureUrl, url) { + var order = [], fixtureUrlAdjusted = fixtureUrl.replace('.', '\\.').replace('?', '\\?'), res = new RegExp(fixtureUrlAdjusted.replace(replacer, function (whole, part) { + order.push(part); + return '([^/]+)'; + }) + '$').exec(url), data = {}; + if (!res) { + return null; + } + res.shift(); + can.each(order, function (name) { + data[name] = res.shift(); + }); + return data; + }, + store: function (count, make, filter) { + var currentId = 0, findOne = function (id) { + for (var i = 0; i < items.length; i++) { + if (id == items[i].id) { + return items[i]; + } + } + }, methods = {}, types, items, reset; + if (can.isArray(count) && typeof count[0] === 'string') { + types = count; + count = make; + make = filter; + filter = arguments[3]; + } else if (typeof count === 'string') { + types = [ + count + 's', + count + ]; + count = make; + make = filter; + filter = arguments[3]; + } + if (typeof count === 'number') { + items = []; + reset = function () { + items = []; + for (var i = 0; i < count; i++) { + var item = make(i, items); + if (!item.id) { + item.id = i; + } + currentId = Math.max(item.id + 1, currentId + 1) || items.length; + items.push(item); + } + if (can.isArray(types)) { + can.fixture['~' + types[0]] = items; + can.fixture['-' + types[0]] = methods.findAll; + can.fixture['-' + types[1]] = methods.findOne; + can.fixture['-' + types[1] + 'Update'] = methods.update; + can.fixture['-' + types[1] + 'Destroy'] = methods.destroy; + can.fixture['-' + types[1] + 'Create'] = methods.create; + } + }; + } else { + filter = make; + var initialItems = count; + reset = function () { + items = initialItems.slice(0); + }; + } + can.extend(methods, { + findAll: function (request) { + request = request || {}; + var retArr = items.slice(0); + request.data = request.data || {}; + can.each((request.data.order || []).slice(0).reverse(), function (name) { + var split = name.split(' '); + retArr = retArr.sort(function (a, b) { + if (split[1].toUpperCase() !== 'ASC') { + if (a[split[0]] < b[split[0]]) { + return 1; + } else if (a[split[0]] === b[split[0]]) { + return 0; + } else { + return -1; + } + } else { + if (a[split[0]] < b[split[0]]) { + return -1; + } else if (a[split[0]] === b[split[0]]) { + return 0; + } else { + return 1; + } + } + }); + }); + can.each((request.data.group || []).slice(0).reverse(), function (name) { + var split = name.split(' '); + retArr = retArr.sort(function (a, b) { + return a[split[0]] > b[split[0]]; + }); + }); + var offset = parseInt(request.data.offset, 10) || 0, limit = parseInt(request.data.limit, 10) || items.length - offset, i = 0; + for (var param in request.data) { + i = 0; + if (request.data[param] !== undefined && (param.indexOf('Id') !== -1 || param.indexOf('_id') !== -1)) { + while (i < retArr.length) { + if (request.data[param] != retArr[i][param]) { + retArr.splice(i, 1); + } else { + i++; + } + } + } + } + if (typeof filter === 'function') { + i = 0; + while (i < retArr.length) { + if (!filter(retArr[i], request)) { + retArr.splice(i, 1); + } else { + i++; + } + } + } else if (typeof filter === 'object') { + i = 0; + while (i < retArr.length) { + if (!can.Object.subset(retArr[i], request.data, filter)) { + retArr.splice(i, 1); + } else { + i++; + } + } + } + return { + 'count': retArr.length, + 'limit': request.data.limit, + 'offset': request.data.offset, + 'data': retArr.slice(offset, offset + limit) + }; + }, + findOne: function (request, response) { + var item = findOne(getId(request)); + if (typeof item === 'undefined') { + return response(404, 'Requested resource not found'); + } + response(item); + }, + update: function (request, response) { + var id = getId(request), item = findOne(id); + if (typeof item === 'undefined') { + return response(404, 'Requested resource not found'); + } + can.extend(item, request.data); + response({ id: id }, { location: request.url || '/' + getId(request) }); + }, + destroy: function (request, response) { + var id = getId(request), item = findOne(id); + if (typeof item === 'undefined') { + return response(404, 'Requested resource not found'); + } + for (var i = 0; i < items.length; i++) { + if (items[i].id == id) { + items.splice(i, 1); + break; + } + } + return {}; + }, + create: function (settings, response) { + var item = typeof make === 'function' ? make(items.length, items) : {}; + can.extend(item, settings.data); + if (!item.id) { + item.id = currentId++; + } + items.push(item); + response({ id: item.id }, { location: settings.url + '/' + item.id }); + } + }); + reset(); + return can.extend({ + getId: getId, + find: function (settings) { + return findOne(getId(settings)); + }, + reset: reset + }, methods); + }, + rand: function randomize(arr, min, max) { + if (typeof arr === 'number') { + if (typeof min === 'number') { + return arr + Math.floor(Math.random() * (min - arr)); + } else { + return Math.floor(Math.random() * arr); + } + } + var rand = randomize; + if (min === undefined) { + return rand(arr, rand(arr.length + 1)); + } + var res = []; + arr = arr.slice(0); + if (!max) { + max = min; + } + max = min + Math.round(rand(max - min)); + for (var i = 0; i < max; i++) { + res.push(arr.splice(rand(arr.length), 1)[0]); + } + return res; + }, + xhr: function (xhr) { + return can.extend({}, { + abort: can.noop, + getAllResponseHeaders: function () { + return ''; + }, + getResponseHeader: function () { + return ''; + }, + open: can.noop, + overrideMimeType: can.noop, + readyState: 4, + responseText: '', + responseXML: null, + send: can.noop, + setRequestHeader: can.noop, + status: 200, + statusText: 'OK' + }, xhr); + }, + on: true +}); +can.fixture.delay = 200; +can.fixture.rootUrl = getUrl(''); +can.fixture['-handleFunction'] = function (settings) { + if (typeof settings.fixture === 'string' && can.fixture[settings.fixture]) { + settings.fixture = can.fixture[settings.fixture]; + } + if (typeof settings.fixture === 'function') { + setTimeout(function () { + if (settings.success) { + settings.success.apply(null, settings.fixture(settings, 'success')); + } + if (settings.complete) { + settings.complete.apply(null, settings.fixture(settings, 'complete')); + } + }, can.fixture.delay); + return true; + } + return false; +}; +can.fixture.overwrites = overwrites; +can.fixture.make = can.fixture.store; +module.exports = can.fixture; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/function/function.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/function/function.js new file mode 100644 index 0000000000..5bda45019a --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/function/function.js @@ -0,0 +1,42 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/function/function*/ +var can = require('../util.js'); +can.debounce = function (fn, time, context) { + var timeout; + return function () { + var args = arguments; + clearTimeout(timeout); + timeout = setTimeout(can.proxy(function () { + fn.apply(this, args); + }, context || this), time); + }; +}; +can.throttle = function (fn, time, context) { + var run; + return function () { + var args = arguments; + var ctx = context || this; + if (!run) { + run = true; + setTimeout(function () { + fn.apply(ctx, args); + run = false; + }, time); + } + }; +}; +can.defer = function (fn, context) { + var args = arguments; + var ctx = context || this; + setTimeout(function () { + fn.apply(ctx, args); + }, 0); +}; +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/inserted/inserted.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/inserted/inserted.js new file mode 100644 index 0000000000..89fc099837 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/inserted/inserted.js @@ -0,0 +1,54 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/inserted/inserted*/ +var can = require('../can.js'); +can.inserted = function (elems) { + elems = can.makeArray(elems); + var inDocument = false, doc = can.$(document.contains ? document : document.body), children; + for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { + if (!inDocument) { + if (elem.getElementsByTagName) { + if (can.has(doc, elem).length) { + inDocument = true; + } else { + return; + } + } else { + continue; + } + } + if (inDocument && elem.getElementsByTagName) { + children = can.makeArray(elem.getElementsByTagName('*')); + can.trigger(elem, 'inserted', [], false); + for (var j = 0, child; (child = children[j]) !== undefined; j++) { + can.trigger(child, 'inserted', [], false); + } + } + } +}; +can.appendChild = function (el, child) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.appendChild(child); + can.inserted(children); +}; +can.insertBefore = function (el, child, ref) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.insertBefore(child, ref); + can.inserted(children); +}; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/jquery/jquery.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/jquery/jquery.js new file mode 100644 index 0000000000..49d757bfcf --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/jquery/jquery.js @@ -0,0 +1,226 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/jquery/jquery*/ +var $ = require('jquery'); +var can = require('../can.js'); +var attr = require('../attr/attr.js'); +var event = require('../../event/event.js'); +require('../array/each.js'); +require('../inserted/inserted.js'); +var isBindableElement = function (node) { + return node.nodeName && (node.nodeType === 1 || node.nodeType === 9) || node == window; +}; +$ = $ || window.jQuery; +$.extend(can, $, { + trigger: function (obj, event, args, bubbles) { + if (isBindableElement(obj)) { + $.event.trigger(event, args, obj, !bubbles); + } else if (obj.trigger) { + obj.trigger(event, args); + } else { + if (typeof event === 'string') { + event = { type: event }; + } + event.target = event.target || obj; + if (args) { + if (args.length && typeof args === 'string') { + args = [args]; + } else if (!args.length) { + args = [args]; + } + } + if (!args) { + args = []; + } + can.dispatch.call(obj, event, args); + } + }, + event: can.event, + addEvent: can.addEvent, + removeEvent: can.removeEvent, + buildFragment: function (elems, context) { + var ret; + elems = [elems]; + context = context || document; + context = !context.nodeType && context[0] || context; + context = context.ownerDocument || context; + ret = $.buildFragment(elems, context); + return ret.cacheable ? $.clone(ret.fragment) : ret.fragment || ret; + }, + $: $, + each: can.each, + bind: function (ev, cb) { + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (isBindableElement(this)) { + $.event.add(this, ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + return this; + }, + unbind: function (ev, cb) { + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (isBindableElement(this)) { + $.event.remove(this, ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + return this; + }, + delegate: function (selector, ev, cb) { + if (this.delegate) { + this.delegate(selector, ev, cb); + } else if (isBindableElement(this)) { + $(this).delegate(selector, ev, cb); + } else { + can.bind.call(this, ev, cb); + } + return this; + }, + undelegate: function (selector, ev, cb) { + if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else if (isBindableElement(this)) { + $(this).undelegate(selector, ev, cb); + } else { + can.unbind.call(this, ev, cb); + } + return this; + }, + proxy: can.proxy, + attr: attr +}); +can.on = can.bind; +can.off = can.unbind; +$.each([ + 'append', + 'filter', + 'addClass', + 'remove', + 'data', + 'get', + 'has' +], function (i, name) { + can[name] = function (wrapped) { + return wrapped[name].apply(wrapped, can.makeArray(arguments).slice(1)); + }; +}); +var oldClean = $.cleanData; +$.cleanData = function (elems) { + $.each(elems, function (i, elem) { + if (elem) { + can.trigger(elem, 'removed', [], false); + } + }); + oldClean(elems); +}; +var oldDomManip = $.fn.domManip, cbIndex; +$.fn.domManip = function (args, cb1, cb2) { + for (var i = 1; i < arguments.length; i++) { + if (typeof arguments[i] === 'function') { + cbIndex = i; + break; + } + } + return oldDomManip.apply(this, arguments); +}; +$(document.createElement('div')).append(document.createElement('div')); +$.fn.domManip = cbIndex === 2 ? function (args, table, callback) { + return oldDomManip.call(this, args, table, function (elem) { + var elems; + if (elem.nodeType === 11) { + elems = can.makeArray(elem.childNodes); + } + var ret = callback.apply(this, arguments); + can.inserted(elems ? elems : [elem]); + return ret; + }); +} : function (args, callback) { + return oldDomManip.call(this, args, function (elem) { + var elems; + if (elem.nodeType === 11) { + elems = can.makeArray(elem.childNodes); + } + var ret = callback.apply(this, arguments); + can.inserted(elems ? elems : [elem]); + return ret; + }); +}; +if (!can.attr.MutationObserver) { + var oldAttr = $.attr; + $.attr = function (el, attrName) { + var oldValue, newValue; + if (arguments.length >= 3) { + oldValue = oldAttr.call(this, el, attrName); + } + var res = oldAttr.apply(this, arguments); + if (arguments.length >= 3) { + newValue = oldAttr.call(this, el, attrName); + } + if (newValue !== oldValue) { + can.attr.trigger(el, attrName, oldValue); + } + return res; + }; + var oldRemove = $.removeAttr; + $.removeAttr = function (el, attrName) { + var oldValue = oldAttr.call(this, el, attrName), res = oldRemove.apply(this, arguments); + if (oldValue != null) { + can.attr.trigger(el, attrName, oldValue); + } + return res; + }; + $.event.special.attributes = { + setup: function () { + can.data(can.$(this), 'canHasAttributesBindings', true); + }, + teardown: function () { + $.removeData(this, 'canHasAttributesBindings'); + } + }; +} else { + $.event.special.attributes = { + setup: function () { + var self = this; + var observer = new can.attr.MutationObserver(function (mutations) { + mutations.forEach(function (mutation) { + var copy = can.simpleExtend({}, mutation); + can.trigger(self, copy, []); + }); + }); + observer.observe(this, { + attributes: true, + attributeOldValue: true + }); + can.data(can.$(this), 'canAttributesObserver', observer); + }, + teardown: function () { + can.data(can.$(this), 'canAttributesObserver').disconnect(); + $.removeData(this, 'canAttributesObserver'); + } + }; +} +(function () { + var text = '<-\n>', frag = can.buildFragment(text, document); + if (text !== frag.childNodes[0].nodeValue) { + var oldBuildFragment = can.buildFragment; + can.buildFragment = function (content, context) { + var res = oldBuildFragment(content, context); + if (res.childNodes.length === 1 && res.childNodes[0].nodeType === 3) { + res.childNodes[0].nodeValue = content; + } + return res; + }; + } +}()); +$.event.special.inserted = {}; +$.event.special.removed = {}; +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/object/object.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/object/object.js new file mode 100644 index 0000000000..716bcf7ecc --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/object/object.js @@ -0,0 +1,101 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/object/object*/ +var can = require('../util.js'); +var isArray = can.isArray; +can.Object = {}; +var same = can.Object.same = function (a, b, compares, aParent, bParent, deep) { + var aType = typeof a, aArray = isArray(a), comparesType = typeof compares, compare; + if (comparesType === 'string' || compares === null) { + compares = compareMethods[compares]; + comparesType = 'function'; + } + if (comparesType === 'function') { + return compares(a, b, aParent, bParent); + } + compares = compares || {}; + if (a === null || b === null) { + return a === b; + } + if (a instanceof Date || b instanceof Date) { + return a === b; + } + if (deep === -1) { + return aType === 'object' || a === b; + } + if (aType !== typeof b || aArray !== isArray(b)) { + return false; + } + if (a === b) { + return true; + } + if (aArray) { + if (a.length !== b.length) { + return false; + } + for (var i = 0; i < a.length; i++) { + compare = compares[i] === undefined ? compares['*'] : compares[i]; + if (!same(a[i], b[i], a, b, compare)) { + return false; + } + } + return true; + } else if (aType === 'object' || aType === 'function') { + var bCopy = can.extend({}, b); + for (var prop in a) { + compare = compares[prop] === undefined ? compares['*'] : compares[prop]; + if (!same(a[prop], b[prop], compare, a, b, deep === false ? -1 : undefined)) { + return false; + } + delete bCopy[prop]; + } + for (prop in bCopy) { + if (compares[prop] === undefined || !same(undefined, b[prop], compares[prop], a, b, deep === false ? -1 : undefined)) { + return false; + } + } + return true; + } + return false; + }; +can.Object.subsets = function (checkSet, sets, compares) { + var len = sets.length, subsets = []; + for (var i = 0; i < len; i++) { + var set = sets[i]; + if (can.Object.subset(checkSet, set, compares)) { + subsets.push(set); + } + } + return subsets; +}; +can.Object.subset = function (subset, set, compares) { + compares = compares || {}; + for (var prop in set) { + if (!same(subset[prop], set[prop], compares[prop], subset, set)) { + return false; + } + } + return true; +}; +var compareMethods = { + 'null': function () { + return true; + }, + i: function (a, b) { + return ('' + a).toLowerCase() === ('' + b).toLowerCase(); + }, + eq: function (a, b) { + return a === b; + }, + similar: function (a, b) { + return a == b; + } + }; +compareMethods.eqeq = compareMethods.similar; +module.exports = can.Object; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/string/deparam/deparam.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/string/deparam/deparam.js new file mode 100644 index 0000000000..ec59235c03 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/string/deparam/deparam.js @@ -0,0 +1,42 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/string/deparam/deparam*/ +var can = require('../../util.js'); +require('../string.js'); +var digitTest = /^\d+$/, keyBreaker = /([^\[\]]+)|(\[\])/g, paramTest = /([^?#]*)(#.*)?$/, prep = function (str) { + return decodeURIComponent(str.replace(/\+/g, ' ')); + }; +can.extend(can, { + deparam: function (params) { + var data = {}, pairs, lastPart; + if (params && paramTest.test(params)) { + pairs = params.split('&'); + can.each(pairs, function (pair) { + var parts = pair.split('='), key = prep(parts.shift()), value = prep(parts.join('=')), current = data; + if (key) { + parts = key.match(keyBreaker); + for (var j = 0, l = parts.length - 1; j < l; j++) { + if (!current[parts[j]]) { + current[parts[j]] = digitTest.test(parts[j + 1]) || parts[j + 1] === '[]' ? [] : {}; + } + current = current[parts[j]]; + } + lastPart = parts.pop(); + if (lastPart === '[]') { + current.push(value); + } else { + current[lastPart] = value; + } + } + }); + } + return data; + } +}); +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/string/string.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/string/string.js new file mode 100644 index 0000000000..224b6b7f92 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/string/string.js @@ -0,0 +1,92 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/string/string*/ +var can = require('../util.js'); +var strUndHash = /_|-/, strColons = /\=\=/, strWords = /([A-Z]+)([A-Z][a-z])/g, strLowUp = /([a-z\d])([A-Z])/g, strDash = /([a-z\d])([A-Z])/g, strReplacer = /\{([^\}]+)\}/g, strQuote = /"/g, strSingleQuote = /'/g, strHyphenMatch = /-+(.)?/g, strCamelMatch = /[a-z][A-Z]/g, getNext = function (obj, prop, add) { + var result = obj[prop]; + if (result === undefined && add === true) { + result = obj[prop] = {}; + } + return result; + }, isContainer = function (current) { + return /^f|^o/.test(typeof current); + }, convertBadValues = function (content) { + var isInvalid = content === null || content === undefined || isNaN(content) && '' + content === 'NaN'; + return '' + (isInvalid ? '' : content); + }; +can.extend(can, { + esc: function (content) { + return convertBadValues(content).replace(/&/g, '&').replace(//g, '>').replace(strQuote, '"').replace(strSingleQuote, '''); + }, + getObject: function (name, roots, add) { + var parts = name ? name.split('.') : [], length = parts.length, current, r = 0, i, container, rootsLength; + roots = can.isArray(roots) ? roots : [roots || window]; + rootsLength = roots.length; + if (!length) { + return roots[0]; + } + for (r; r < rootsLength; r++) { + current = roots[r]; + container = undefined; + for (i = 0; i < length && isContainer(current); i++) { + container = current; + current = getNext(container, parts[i]); + } + if (container !== undefined && current !== undefined) { + break; + } + } + if (add === false && current !== undefined) { + delete container[parts[i - 1]]; + } + if (add === true && current === undefined) { + current = roots[0]; + for (i = 0; i < length && isContainer(current); i++) { + current = getNext(current, parts[i], true); + } + } + return current; + }, + capitalize: function (s, cache) { + return s.charAt(0).toUpperCase() + s.slice(1); + }, + camelize: function (str) { + return convertBadValues(str).replace(strHyphenMatch, function (match, chr) { + return chr ? chr.toUpperCase() : ''; + }); + }, + hyphenate: function (str) { + return convertBadValues(str).replace(strCamelMatch, function (str, offset) { + return str.charAt(0) + '-' + str.charAt(1).toLowerCase(); + }); + }, + underscore: function (s) { + return s.replace(strColons, '/').replace(strWords, '$1_$2').replace(strLowUp, '$1_$2').replace(strDash, '_').toLowerCase(); + }, + sub: function (str, data, remove) { + var obs = []; + str = str || ''; + obs.push(str.replace(strReplacer, function (whole, inside) { + var ob = can.getObject(inside, data, remove === true ? false : undefined); + if (ob === undefined || ob === null) { + obs = null; + return ''; + } + if (isContainer(ob) && obs) { + obs.push(ob); + return ''; + } + return '' + ob; + })); + return obs === null ? obs : obs.length <= 1 ? obs[0] : obs; + }, + replacer: strReplacer, + undHash: strUndHash +}); +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/tests/tests.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/tests/tests.js new file mode 100644 index 0000000000..2213845d8c --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/tests/tests.js @@ -0,0 +1,15 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/tests/tests*/ +define([ + '../string/string.js', + '../inserted/inserted.js', + '../attr/attr.js', + '../array/each.js' +]); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/util.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/util.js new file mode 100644 index 0000000000..fd04bf3f5d --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/util/util.js @@ -0,0 +1,11 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/util*/ +var can = require('./jquery/jquery.js'); +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/autorender/autorender.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/autorender/autorender.js new file mode 100644 index 0000000000..35c0a107ef --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/autorender/autorender.js @@ -0,0 +1,86 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/autorender/autorender*/ +var can = require('../../util/util.js'); +var deferred = new can.Deferred(), ignoreAttributesRegExp = /^(dataViewId|class|id|type|src)$/i; +var typeMatch = /\s*text\/(mustache|stache|ejs)\s*/; +function isIn(element, type) { + while (element.parentNode) { + element = element.parentNode; + if (element.nodeName.toLowerCase() === type.toLowerCase()) { + return true; + } + } +} +function setAttr(el, attr, scope) { + var camelized = can.camelize(attr); + if (!ignoreAttributesRegExp.test(camelized)) { + scope.attr(camelized, el.getAttribute(attr)); + } +} +function insertAfter(ref, element) { + if (ref.nextSibling) { + can.insertBefore(ref.parentNode, element, ref.nextSibling); + } else { + can.appendChild(ref.parentNode, element); + } +} +function render(renderer, scope, el) { + var frag = renderer(scope); + if (isIn(el, 'head')) { + can.appendChild(document.body, frag); + } else if (el.nodeName.toLowerCase() === 'script') { + insertAfter(el, frag); + } else { + insertAfter(el, frag); + el.parentNode.removeChild(el); + } +} +function setupScope(el) { + var scope = can.viewModel(el); + can.each(el.attributes || [], function (attr) { + setAttr(el, attr.name, scope); + }); + can.bind.call(el, 'attributes', function (ev) { + setAttr(el, ev.attributeName, scope); + }); + return scope; +} +function autoload() { + var promises = []; + can.each(can.$('[can-autorender]'), function (el, i) { + el.style.display = 'none'; + var text = el.innerHTML || el.text, typeAttr = el.getAttribute('type'), typeInfo = typeAttr.match(typeMatch), type = typeInfo && typeInfo[1], typeModule = 'can/view/' + type; + if (window.System || !(window.define && window.define.amd)) { + typeModule += '/' + type; + } + promises.push(can['import'](typeModule).then(function (engine) { + engine = can[type] || engine; + if (engine.async) { + return engine.async(text).then(function (renderer) { + render(renderer, setupScope(el), el); + }); + } else { + var renderer = engine(text); + render(renderer, setupScope(el), el); + } + })); + }); + can.when.apply(can, promises).then(can.proxy(deferred.resolve, deferred), can.proxy(deferred.reject, deferred)); +} +if (document.readyState === 'complete') { + autoload(); +} else { + can.bind.call(window, 'load', autoload); +} +var promise = deferred.promise(); +can.autorender = function (success, error) { + return promise.then(success, error); +}; +module.exports = can.autorender; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/bindings/bindings.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/bindings/bindings.js new file mode 100644 index 0000000000..b47f624cf1 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/bindings/bindings.js @@ -0,0 +1,256 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/bindings/bindings*/ +var can = require('../../util/util.js'); +var mustacheCore = require('../stache/mustache_core.js'); +require('../callbacks/callbacks.js'); +require('../../control/control.js'); +require('../scope/scope.js'); +var isContentEditable = function () { + var values = { + '': true, + 'true': true, + 'false': false + }; + var editable = function (el) { + if (!el || !el.getAttribute) { + return; + } + var attr = el.getAttribute('contenteditable'); + return values[attr]; + }; + return function (el) { + var val = editable(el); + if (typeof val === 'boolean') { + return val; + } else { + return !!editable(el.parentNode); + } + }; + }(), removeCurly = function (value) { + if (value[0] === '{' && value[value.length - 1] === '}') { + return value.substr(1, value.length - 2); + } + return value; + }; +can.view.attr('can-value', function (el, data) { + var attr = can.trim(removeCurly(el.getAttribute('can-value'))), value = data.scope.computeData(attr, { args: [] }).compute, trueValue, falseValue; + if (el.nodeName.toLowerCase() === 'input') { + if (el.type === 'checkbox') { + if (can.attr.has(el, 'can-true-value')) { + trueValue = el.getAttribute('can-true-value'); + } else { + trueValue = true; + } + if (can.attr.has(el, 'can-false-value')) { + falseValue = el.getAttribute('can-false-value'); + } else { + falseValue = false; + } + } + if (el.type === 'checkbox' || el.type === 'radio') { + new Checked(el, { + value: value, + trueValue: trueValue, + falseValue: falseValue + }); + return; + } + } + if (el.nodeName.toLowerCase() === 'select' && el.multiple) { + new Multiselect(el, { value: value }); + return; + } + if (isContentEditable(el)) { + new Content(el, { value: value }); + return; + } + new Value(el, { value: value }); +}); +var special = { + enter: function (data, el, original) { + return { + event: 'keyup', + handler: function (ev) { + if (ev.keyCode === 13) { + return original.call(this, ev); + } + } + }; + } + }; +can.view.attr(/can-[\w\.]+/, function (el, data) { + var attributeName = data.attributeName, event = attributeName.substr('can-'.length), handler = function (ev) { + var attrVal = el.getAttribute(attributeName); + if (!attrVal) { + return; + } + var attrInfo = mustacheCore.expressionData(removeCurly(attrVal)); + var scopeData = data.scope.read(attrInfo.name.get, { + returnObserveMethods: true, + isArgument: true, + executeAnonymousFunctions: true + }); + var args = []; + var $el = can.$(this); + var viewModel = can.viewModel($el[0]); + var localScope = data.scope.add({ + '@element': $el, + '@event': ev, + '@viewModel': viewModel, + '@scope': data.scope, + '@context': data.scope._context + }); + if (!can.isEmptyObject(attrInfo.hash)) { + var hash = {}; + can.each(attrInfo.hash, function (val, key) { + if (val && val.hasOwnProperty('get')) { + var s = !val.get.indexOf('@') ? localScope : data.scope; + hash[key] = s.read(val.get, {}).value; + } else { + hash[key] = val; + } + }); + args.unshift(hash); + } + if (attrInfo.args.length) { + var arg; + for (var i = attrInfo.args.length - 1; i >= 0; i--) { + arg = attrInfo.args[i]; + if (arg && arg.hasOwnProperty('get')) { + var s = !arg.get.indexOf('@') ? localScope : data.scope; + args.unshift(s.read(arg.get, {}).value); + } else { + args.unshift(arg); + } + } + } + if (!args.length) { + args = [ + data.scope._context, + $el + ].concat(can.makeArray(arguments)); + } + return scopeData.value.apply(scopeData.parent, args); + }; + if (special[event]) { + var specialData = special[event](data, el, handler); + handler = specialData.handler; + event = specialData.event; + } + can.bind.call(el, event, handler); +}); +var Value = can.Control.extend({ + init: function () { + if (this.element[0].nodeName.toUpperCase() === 'SELECT') { + setTimeout(can.proxy(this.set, this), 1); + } else { + this.set(); + } + }, + '{value} change': 'set', + set: function () { + if (!this.element) { + return; + } + var val = this.options.value(); + this.element[0].value = val == null ? '' : val; + }, + 'change': function () { + if (!this.element) { + return; + } + var el = this.element[0]; + this.options.value(el.value); + var newVal = this.options.value(); + if (el.value !== newVal) { + el.value = newVal; + } + } + }), Checked = can.Control.extend({ + init: function () { + this.isCheckbox = this.element[0].type.toLowerCase() === 'checkbox'; + this.check(); + }, + '{value} change': 'check', + check: function () { + if (this.isCheckbox) { + var value = this.options.value(), trueValue = this.options.trueValue || true; + this.element[0].checked = value == trueValue; + } else { + var setOrRemove = this.options.value() == this.element[0].value ? 'set' : 'remove'; + can.attr[setOrRemove](this.element[0], 'checked', true); + } + }, + 'change': function () { + if (this.isCheckbox) { + this.options.value(this.element[0].checked ? this.options.trueValue : this.options.falseValue); + } else { + if (this.element[0].checked) { + this.options.value(this.element[0].value); + } + } + } + }), Multiselect = Value.extend({ + init: function () { + this.delimiter = ';'; + setTimeout(can.proxy(this.set, this), 1); + }, + set: function () { + var newVal = this.options.value(); + if (typeof newVal === 'string') { + newVal = newVal.split(this.delimiter); + this.isString = true; + } else if (newVal) { + newVal = can.makeArray(newVal); + } + var isSelected = {}; + can.each(newVal, function (val) { + isSelected[val] = true; + }); + can.each(this.element[0].childNodes, function (option) { + if (option.value) { + option.selected = !!isSelected[option.value]; + } + }); + }, + get: function () { + var values = [], children = this.element[0].childNodes; + can.each(children, function (child) { + if (child.selected && child.value) { + values.push(child.value); + } + }); + return values; + }, + 'change': function () { + var value = this.get(), currentValue = this.options.value(); + if (this.isString || typeof currentValue === 'string') { + this.isString = true; + this.options.value(value.join(this.delimiter)); + } else if (currentValue instanceof can.List) { + currentValue.attr(value, true); + } else { + this.options.value(value); + } + } + }), Content = can.Control.extend({ + init: function () { + this.set(); + this.on('blur', 'setValue'); + }, + '{value} change': 'set', + set: function () { + var val = this.options.value(); + this.element[0].innerHTML = typeof val === 'undefined' ? '' : val; + }, + setValue: function () { + this.options.value(this.element[0].innerHTML); + } + }); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/callbacks/callbacks.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/callbacks/callbacks.js new file mode 100644 index 0000000000..1c717fbb45 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/callbacks/callbacks.js @@ -0,0 +1,80 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/callbacks/callbacks*/ +var can = require('../../util/util.js'); +require('../view.js'); +var attr = can.view.attr = function (attributeName, attrHandler) { + if (attrHandler) { + if (typeof attributeName === 'string') { + attributes[attributeName] = attrHandler; + } else { + regExpAttributes.push({ + match: attributeName, + handler: attrHandler + }); + } + } else { + var cb = attributes[attributeName]; + if (!cb) { + for (var i = 0, len = regExpAttributes.length; i < len; i++) { + var attrMatcher = regExpAttributes[i]; + if (attrMatcher.match.test(attributeName)) { + cb = attrMatcher.handler; + break; + } + } + } + return cb; + } + }; +var attributes = {}, regExpAttributes = [], automaticCustomElementCharacters = /[-\:]/; +var tag = can.view.tag = function (tagName, tagHandler) { + if (tagHandler) { + if (can.global.html5) { + can.global.html5.elements += ' ' + tagName; + can.global.html5.shivDocument(); + } + tags[tagName.toLowerCase()] = tagHandler; + } else { + var cb = tags[tagName.toLowerCase()]; + if (!cb && automaticCustomElementCharacters.test(tagName)) { + cb = function () { + }; + } + return cb; + } + }; +var tags = {}; +can.view.callbacks = { + _tags: tags, + _attributes: attributes, + _regExpAttributes: regExpAttributes, + tag: tag, + attr: attr, + tagHandler: function (el, tagName, tagData) { + var helperTagCallback = tagData.options.attr('tags.' + tagName), tagCallback = helperTagCallback || tags[tagName]; + var scope = tagData.scope, res; + if (tagCallback) { + var reads = can.__clearReading(); + res = tagCallback(el, tagData); + can.__setReading(reads); + } else { + res = scope; + } + if (res && tagData.subtemplate) { + if (scope !== res) { + scope = scope.add(res); + } + var result = tagData.subtemplate(scope, tagData.options); + var frag = typeof result === 'string' ? can.view.frag(result) : result; + can.appendChild(el, frag); + } + } +}; +module.exports = can.view.callbacks; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/ejs/ejs.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/ejs/ejs.js new file mode 100644 index 0000000000..98cf041f78 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/ejs/ejs.js @@ -0,0 +1,158 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/ejs/ejs*/ +var can = require('../../util/util.js'); +require('../view.js'); +require('../../util/string/string.js'); +require('../../compute/compute.js'); +require('../scanner.js'); +require('../render.js'); +var extend = can.extend, EJS = function (options) { + if (this.constructor !== EJS) { + var ejs = new EJS(options); + return function (data, helpers) { + return ejs.render(data, helpers); + }; + } + if (typeof options === 'function') { + this.template = { fn: options }; + return; + } + extend(this, options); + this.template = this.scanner.scan(this.text, this.name); + }; +can.EJS = EJS; +EJS.prototype.render = function (object, extraHelpers) { + object = object || {}; + return this.template.fn.call(object, object, new EJS.Helpers(object, extraHelpers || {})); +}; +extend(EJS.prototype, { + scanner: new can.view.Scanner({ + text: { + outStart: 'with(_VIEW) { with (_CONTEXT) {', + outEnd: '}}', + argNames: '_CONTEXT,_VIEW', + context: 'this' + }, + tokens: [ + [ + 'templateLeft', + '<%%' + ], + [ + 'templateRight', + '%>' + ], + [ + 'returnLeft', + '<%==' + ], + [ + 'escapeLeft', + '<%=' + ], + [ + 'commentLeft', + '<%#' + ], + [ + 'left', + '<%' + ], + [ + 'right', + '%>' + ], + [ + 'returnRight', + '%>' + ] + ], + helpers: [{ + name: /\s*\(([\$\w]+)\)\s*->([^\n]*)/, + fn: function (content) { + var quickFunc = /\s*\(([\$\w]+)\)\s*->([^\n]*)/, parts = content.match(quickFunc); + return 'can.proxy(function(__){var ' + parts[1] + '=can.$(__);' + parts[2] + '}, this);'; + } + }], + transform: function (source) { + return source.replace(/<%([\s\S]+?)%>/gm, function (whole, part) { + var brackets = [], foundBracketPair, i; + part.replace(/[{}]/gm, function (bracket, offset) { + brackets.push([ + bracket, + offset + ]); + }); + do { + foundBracketPair = false; + for (i = brackets.length - 2; i >= 0; i--) { + if (brackets[i][0] === '{' && brackets[i + 1][0] === '}') { + brackets.splice(i, 2); + foundBracketPair = true; + break; + } + } + } while (foundBracketPair); + if (brackets.length >= 2) { + var result = ['<%'], bracket, last = 0; + for (i = 0; bracket = brackets[i]; i++) { + result.push(part.substring(last, last = bracket[1])); + if (bracket[0] === '{' && i < brackets.length - 1 || bracket[0] === '}' && i > 0) { + result.push(bracket[0] === '{' ? '{ %><% ' : ' %><% }'); + } else { + result.push(bracket[0]); + } + ++last; + } + result.push(part.substring(last), '%>'); + return result.join(''); + } else { + return '<%' + part + '%>'; + } + }); + } + }) +}); +EJS.Helpers = function (data, extras) { + this._data = data; + this._extras = extras; + extend(this, extras); +}; +EJS.Helpers.prototype = { + list: function (list, cb) { + can.each(list, function (item, i) { + cb(item, i, list); + }); + }, + each: function (list, cb) { + if (can.isArray(list)) { + this.list(list, cb); + } else { + can.view.lists(list, cb); + } + } +}; +can.view.register({ + suffix: 'ejs', + script: function (id, src) { + return 'can.EJS(function(_CONTEXT,_VIEW) { ' + new EJS({ + text: src, + name: id + }).template.out + ' })'; + }, + renderer: function (id, text) { + return EJS({ + text: text, + name: id + }); + } +}); +can.ejs.Helpers = EJS.Helpers; +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/ejs/system.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/ejs/system.js new file mode 100644 index 0000000000..fdc6626589 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/ejs/system.js @@ -0,0 +1,17 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/ejs/system*/ +var can = require('./ejs.js'); +function translate(load) { + return 'define([\'can/view/ejs/ejs\'],function(can){' + 'return can.view.preloadStringRenderer(\'' + load.metadata.pluginArgument + '\',' + 'can.EJS(function(_CONTEXT,_VIEW) { ' + new can.EJS({ + text: load.source, + name: load.name + }).template.out + ' })' + ')' + '})'; +} +module.exports = { translate: translate }; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/elements.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/elements.js new file mode 100644 index 0000000000..4a86f8259d --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/elements.js @@ -0,0 +1,80 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/elements*/ +var can = require('../util/util.js'); +require('./view.js'); +var doc = typeof document !== 'undefined' ? document : null; +var selectsCommentNodes = doc && function () { + return can.$(document.createComment('~')).length === 1; + }(); +var elements = { + tagToContentPropMap: { + option: doc && 'textContent' in document.createElement('option') ? 'textContent' : 'innerText', + textarea: 'value' + }, + attrMap: can.attr.map, + attrReg: /([^\s=]+)[\s]*=[\s]*/, + defaultValue: can.attr.defaultValue, + tagMap: { + '': 'span', + colgroup: 'col', + table: 'tbody', + tr: 'td', + ol: 'li', + ul: 'li', + tbody: 'tr', + thead: 'tr', + tfoot: 'tr', + select: 'option', + optgroup: 'option' + }, + reverseTagMap: { + col: 'colgroup', + tr: 'tbody', + option: 'select', + td: 'tr', + th: 'tr', + li: 'ul' + }, + getParentNode: function (el, defaultParentNode) { + return defaultParentNode && el.parentNode.nodeType === 11 ? defaultParentNode : el.parentNode; + }, + setAttr: can.attr.set, + getAttr: can.attr.get, + removeAttr: can.attr.remove, + contentText: function (text) { + if (typeof text === 'string') { + return text; + } + if (!text && text !== 0) { + return ''; + } + return '' + text; + }, + after: function (oldElements, newFrag) { + var last = oldElements[oldElements.length - 1]; + if (last.nextSibling) { + can.insertBefore(last.parentNode, newFrag, last.nextSibling); + } else { + can.appendChild(last.parentNode, newFrag); + } + }, + replace: function (oldElements, newFrag) { + elements.after(oldElements, newFrag); + if (can.remove(can.$(oldElements)).length < oldElements.length && !selectsCommentNodes) { + can.each(oldElements, function (el) { + if (el.nodeType === 8) { + el.parentNode.removeChild(el); + } + }); + } + } + }; +can.view.elements = elements; +module.exports = elements; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/live/live.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/live/live.js new file mode 100644 index 0000000000..a2b87edaa6 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/live/live.js @@ -0,0 +1,342 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/live/live*/ +var can = require('../../util/util.js'); +var elements = require('../elements.js'); +var view = require('../view.js'); +var nodeLists = require('../node_lists/node_lists.js'); +var parser = require('../parser/parser.js'); +elements = elements || can.view.elements; +nodeLists = nodeLists || can.view.NodeLists; +parser = parser || can.view.parser; +var setup = function (el, bind, unbind) { + var tornDown = false, teardown = function () { + if (!tornDown) { + tornDown = true; + unbind(data); + can.unbind.call(el, 'removed', teardown); + } + return true; + }, data = { + teardownCheck: function (parent) { + return parent ? false : teardown(); + } + }; + can.bind.call(el, 'removed', teardown); + bind(data); + return data; + }, listen = function (el, compute, change) { + return setup(el, function () { + compute.bind('change', change); + }, function (data) { + compute.unbind('change', change); + if (data.nodeList) { + nodeLists.unregister(data.nodeList); + } + }); + }, getAttributeParts = function (newVal) { + var attrs = {}, attr; + parser.parseAttrs(newVal, { + attrStart: function (name) { + attrs[name] = ''; + attr = name; + }, + attrValue: function (value) { + attrs[attr] += value; + }, + attrEnd: function () { + } + }); + return attrs; + }, splice = [].splice, isNode = function (obj) { + return obj && obj.nodeType; + }, addTextNodeIfNoChildren = function (frag) { + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + }; +var live = { + list: function (el, compute, render, context, parentNode, nodeList) { + var masterNodeList = nodeList || [el], indexMap = [], afterPreviousEvents = false, isTornDown = false, add = function (ev, items, index) { + if (!afterPreviousEvents) { + return; + } + var frag = document.createDocumentFragment(), newNodeLists = [], newIndicies = []; + can.each(items, function (item, key) { + var itemNodeList = []; + if (nodeList) { + nodeLists.register(itemNodeList, null, true); + } + var itemIndex = can.compute(key + index), itemHTML = render.call(context, item, itemIndex, itemNodeList), gotText = typeof itemHTML === 'string', itemFrag = can.frag(itemHTML); + itemFrag = gotText ? can.view.hookup(itemFrag) : itemFrag; + var childNodes = can.makeArray(itemFrag.childNodes); + if (nodeList) { + nodeLists.update(itemNodeList, childNodes); + newNodeLists.push(itemNodeList); + } else { + newNodeLists.push(nodeLists.register(childNodes)); + } + frag.appendChild(itemFrag); + newIndicies.push(itemIndex); + }); + var masterListIndex = index + 1; + if (!masterNodeList[masterListIndex]) { + elements.after(masterListIndex === 1 ? [text] : [nodeLists.last(masterNodeList[masterListIndex - 1])], frag); + } else { + var el = nodeLists.first(masterNodeList[masterListIndex]); + can.insertBefore(el.parentNode, frag, el); + } + splice.apply(masterNodeList, [ + masterListIndex, + 0 + ].concat(newNodeLists)); + splice.apply(indexMap, [ + index, + 0 + ].concat(newIndicies)); + for (var i = index + newIndicies.length, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + }, remove = function (ev, items, index, duringTeardown, fullTeardown) { + if (!afterPreviousEvents) { + return; + } + if (!duringTeardown && data.teardownCheck(text.parentNode)) { + return; + } + if (index < 0) { + index = indexMap.length + index; + } + var removedMappings = masterNodeList.splice(index + 1, items.length), itemsToRemove = []; + can.each(removedMappings, function (nodeList) { + var nodesToRemove = nodeLists.unregister(nodeList); + [].push.apply(itemsToRemove, nodesToRemove); + }); + indexMap.splice(index, items.length); + for (var i = index, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + if (!fullTeardown) { + can.remove(can.$(itemsToRemove)); + } else { + nodeLists.unregister(masterNodeList); + } + }, move = function (ev, item, newIndex, currentIndex) { + if (!afterPreviousEvents) { + return; + } + newIndex = newIndex + 1; + currentIndex = currentIndex + 1; + var referenceNodeList = masterNodeList[newIndex]; + var movedElements = can.frag(nodeLists.flatten(masterNodeList[currentIndex])); + var referenceElement; + if (currentIndex < newIndex) { + referenceElement = nodeLists.last(referenceNodeList).nextSibling; + } else { + referenceElement = nodeLists.first(referenceNodeList); + } + var parentNode = masterNodeList[0].parentNode; + parentNode.insertBefore(movedElements, referenceElement); + var temp = masterNodeList[currentIndex]; + [].splice.apply(masterNodeList, [ + currentIndex, + 1 + ]); + [].splice.apply(masterNodeList, [ + newIndex, + 0, + temp + ]); + }, text = document.createTextNode(''), list, teardownList = function (fullTeardown) { + if (list && list.unbind) { + list.unbind('add', add).unbind('remove', remove).unbind('move', move); + } + remove({}, { length: masterNodeList.length - 1 }, 0, true, fullTeardown); + }, updateList = function (ev, newList, oldList) { + if (isTornDown) { + return; + } + teardownList(); + list = newList || []; + if (list.bind) { + list.bind('add', add).bind('remove', remove).bind('move', move); + } + afterPreviousEvents = true; + add({}, list, 0); + afterPreviousEvents = false; + can.batch.afterPreviousEvents(function () { + afterPreviousEvents = true; + }); + }; + parentNode = elements.getParentNode(el, parentNode); + var data = setup(parentNode, function () { + if (can.isFunction(compute)) { + compute.bind('change', updateList); + } + }, function () { + if (can.isFunction(compute)) { + compute.unbind('change', updateList); + } + teardownList(true); + }); + if (!nodeList) { + live.replace(masterNodeList, text, data.teardownCheck); + } else { + elements.replace(masterNodeList, text); + nodeLists.update(masterNodeList, [text]); + nodeList.unregistered = function () { + data.teardownCheck(); + isTornDown = true; + }; + } + updateList({}, can.isFunction(compute) ? compute() : compute); + }, + html: function (el, compute, parentNode, nodeList) { + var data; + parentNode = elements.getParentNode(el, parentNode); + data = listen(parentNode, compute, function (ev, newVal, oldVal) { + var attached = nodeLists.first(nodes).parentNode; + if (attached) { + makeAndPut(newVal); + } + data.teardownCheck(nodeLists.first(nodes).parentNode); + }); + var nodes = nodeList || [el], makeAndPut = function (val) { + var isFunction = typeof val === 'function', aNode = isNode(val), frag = can.frag(isFunction ? '' : val), oldNodes = can.makeArray(nodes); + addTextNodeIfNoChildren(frag); + if (!aNode && !isFunction) { + frag = can.view.hookup(frag, parentNode); + } + oldNodes = nodeLists.update(nodes, frag.childNodes); + if (isFunction) { + val(frag.childNodes[0]); + } + elements.replace(oldNodes, frag); + }; + data.nodeList = nodes; + if (!nodeList) { + nodeLists.register(nodes, data.teardownCheck); + } else { + nodeList.unregistered = data.teardownCheck; + } + makeAndPut(compute()); + }, + replace: function (nodes, val, teardown) { + var oldNodes = nodes.slice(0), frag = can.frag(val); + nodeLists.register(nodes, teardown); + if (typeof val === 'string') { + frag = can.view.hookup(frag, nodes[0].parentNode); + } + nodeLists.update(nodes, frag.childNodes); + elements.replace(oldNodes, frag); + return nodes; + }, + text: function (el, compute, parentNode, nodeList) { + var parent = elements.getParentNode(el, parentNode); + var data = listen(parent, compute, function (ev, newVal, oldVal) { + if (typeof node.nodeValue !== 'unknown') { + node.nodeValue = can.view.toStr(newVal); + } + data.teardownCheck(node.parentNode); + }); + var node = document.createTextNode(can.view.toStr(compute())); + if (nodeList) { + nodeList.unregistered = data.teardownCheck; + data.nodeList = nodeList; + nodeLists.update(nodeList, [node]); + elements.replace([el], node); + } else { + data.nodeList = live.replace([el], node, data.teardownCheck); + } + }, + setAttributes: function (el, newVal) { + var attrs = getAttributeParts(newVal); + for (var name in attrs) { + can.attr.set(el, name, attrs[name]); + } + }, + attributes: function (el, compute, currentValue) { + var oldAttrs = {}; + var setAttrs = function (newVal) { + var newAttrs = getAttributeParts(newVal), name; + for (name in newAttrs) { + var newValue = newAttrs[name], oldValue = oldAttrs[name]; + if (newValue !== oldValue) { + can.attr.set(el, name, newValue); + } + delete oldAttrs[name]; + } + for (name in oldAttrs) { + elements.removeAttr(el, name); + } + oldAttrs = newAttrs; + }; + listen(el, compute, function (ev, newVal) { + setAttrs(newVal); + }); + if (arguments.length >= 3) { + oldAttrs = getAttributeParts(currentValue); + } else { + setAttrs(compute()); + } + }, + attributePlaceholder: '__!!__', + attributeReplace: /__!!__/g, + attribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, hook.render()); + }); + var wrapped = can.$(el), hooks; + hooks = can.data(wrapped, 'hooks'); + if (!hooks) { + can.data(wrapped, 'hooks', hooks = {}); + } + var attr = elements.getAttr(el, attributeName), parts = attr.split(live.attributePlaceholder), goodParts = [], hook; + goodParts.push(parts.shift(), parts.join(live.attributePlaceholder)); + if (hooks[attributeName]) { + hooks[attributeName].computes.push(compute); + } else { + hooks[attributeName] = { + render: function () { + var i = 0, newAttr = attr ? attr.replace(live.attributeReplace, function () { + return elements.contentText(hook.computes[i++]()); + }) : elements.contentText(hook.computes[i++]()); + return newAttr; + }, + computes: [compute], + batchNum: undefined + }; + } + hook = hooks[attributeName]; + goodParts.splice(1, 0, compute()); + elements.setAttr(el, attributeName, goodParts.join('')); + }, + specialAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, getValue(newVal)); + }); + elements.setAttr(el, attributeName, getValue(compute())); + }, + simpleAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, newVal); + }); + elements.setAttr(el, attributeName, compute()); + } + }; +live.attr = live.simpleAttribute; +live.attrs = live.attributes; +var newLine = /(\r|\n)+/g; +var getValue = function (val) { + var regexp = /^["'].*["']$/; + val = val.replace(elements.attrReg, '').replace(newLine, ''); + return regexp.test(val) ? val.substr(1, val.length - 2) : val; +}; +can.view.live = live; +module.exports = live; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/modifiers/modifiers.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/modifiers/modifiers.js new file mode 100644 index 0000000000..29687f8046 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/modifiers/modifiers.js @@ -0,0 +1,97 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/modifiers/modifiers*/ +var $ = require('jquery'); +var can = require('../../util/util.js'); +require('../view.js'); +$ = $ || window.$; +var convert, modify, isTemplate, isHTML, isDOM, getCallback, noHookup = { + 'val': true, + 'text': true + }; +convert = function (func_name) { + var old = $.fn[func_name]; + $.fn[func_name] = function () { + var args = can.makeArray(arguments), callbackNum, callback, self = this, result; + if (can.isDeferred(args[0])) { + args[0].done(function (res) { + modify.call(self, [res], old); + }); + return this; + } else if (isTemplate(args)) { + if (callbackNum = getCallback(args)) { + callback = args[callbackNum]; + args[callbackNum] = function (result) { + modify.call(self, [result], old); + callback.call(self, result); + }; + can.view.apply(can.view, args); + return this; + } + result = can.view.apply(can.view, args); + if (!can.isDeferred(result)) { + args = [result]; + } else { + result.done(function (res) { + modify.call(self, [res], old); + }); + return this; + } + } + return noHookup[func_name] ? old.apply(this, args) : modify.call(this, args, old); + }; +}; +modify = function (args, old) { + var res; + for (var hasHookups in can.view.hookups) { + break; + } + if (hasHookups && args[0] && isHTML(args[0])) { + args[0] = can.view.frag(args[0]).childNodes; + } + res = old.apply(this, args); + return res; +}; +isTemplate = function (args) { + var secArgType = typeof args[1]; + return typeof args[0] === 'string' && (secArgType === 'object' || secArgType === 'function') && !isDOM(args[1]); +}; +isDOM = function (arg) { + return arg.nodeType || arg[0] && arg[0].nodeType; +}; +isHTML = function (arg) { + if (isDOM(arg)) { + return true; + } else if (typeof arg === 'string') { + arg = can.trim(arg); + return arg.substr(0, 1) === '<' && arg.substr(arg.length - 1, 1) === '>' && arg.length >= 3; + } else { + return false; + } +}; +getCallback = function (args) { + return typeof args[3] === 'function' ? 3 : typeof args[2] === 'function' && 2; +}; +$.fn.hookup = function () { + can.view.frag(this); + return this; +}; +can.each([ + 'prepend', + 'append', + 'after', + 'before', + 'text', + 'html', + 'replaceWith', + 'val' +], function (func) { + convert(func); +}); +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/mustache/mustache.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/mustache/mustache.js new file mode 100644 index 0000000000..1a3f3b7599 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/mustache/mustache.js @@ -0,0 +1,503 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/mustache/mustache*/ +var can = require('../../util/util.js'); +require('../scope/scope.js'); +require('../view.js'); +require('../scanner.js'); +require('../../compute/compute.js'); +require('../render.js'); +require('../bindings/bindings.js'); +can.view.ext = '.mustache'; +var SCOPE = 'scope', HASH = '___h4sh', CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options}', SPECIAL_CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options, special: true}', ARG_NAMES = SCOPE + ',options', argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false|null|undefined)|((.+?)=(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false)|(.+))))$/, makeLookupLiteral = function (type) { + return '{get:"' + type.replace(/"/g, '\\"') + '"}'; + }, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, isObserveLike = function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, isArrayLike = function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, makeConvertToScopes = function (original, scope, options) { + var originalWithScope = function (ctx, opts) { + return original(ctx || scope, opts); + }; + return function (updatedScope, updatedOptions) { + if (updatedScope !== undefined && !(updatedScope instanceof can.view.Scope)) { + updatedScope = scope.add(updatedScope); + } + if (updatedOptions !== undefined && !(updatedOptions instanceof can.view.Options)) { + updatedOptions = options.add(updatedOptions); + } + return originalWithScope(updatedScope, updatedOptions || options); + }; + }; +var Mustache = function (options, helpers) { + if (this.constructor !== Mustache) { + var mustache = new Mustache(options); + return function (data, options) { + return mustache.render(data, options); + }; + } + if (typeof options === 'function') { + this.template = { fn: options }; + return; + } + can.extend(this, options); + this.template = this.scanner.scan(this.text, this.name); +}; +can.Mustache = can.global.Mustache = Mustache; +Mustache.prototype.render = function (data, options) { + if (!(data instanceof can.view.Scope)) { + data = new can.view.Scope(data || {}); + } + if (!(options instanceof can.view.Options)) { + options = new can.view.Options(options || {}); + } + options = options || {}; + return this.template.fn.call(data, data, options); +}; +can.extend(Mustache.prototype, { + scanner: new can.view.Scanner({ + text: { + start: '', + scope: SCOPE, + options: ',options: options', + argNames: ARG_NAMES + }, + tokens: [ + [ + 'returnLeft', + '{{{', + '{{[{&]' + ], + [ + 'commentFull', + '{{!}}', + '^[\\s\\t]*{{!.+?}}\\n' + ], + [ + 'commentLeft', + '{{!', + '(\\n[\\s\\t]*{{!|{{!)' + ], + [ + 'escapeFull', + '{{}}', + '(^[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}$)', + function (content) { + return { + before: /^\n.+?\n$/.test(content) ? '\n' : '', + content: content.match(/\{\{(.+?)\}\}/)[1] || '' + }; + } + ], + [ + 'escapeLeft', + '{{' + ], + [ + 'returnRight', + '}}}' + ], + [ + 'right', + '}}' + ] + ], + helpers: [ + { + name: /^>[\s]*\w*/, + fn: function (content, cmd) { + var templateName = can.trim(content.replace(/^>\s?/, '')).replace(/["|']/g, ''); + return 'can.Mustache.renderPartial(\'' + templateName + '\',' + ARG_NAMES + ')'; + } + }, + { + name: /^\s*data\s/, + fn: function (content, cmd) { + var attr = content.match(/["|'](.*)["|']/)[1]; + return 'can.proxy(function(__){' + 'can.data(can.$(__),\'' + attr + '\', this.attr(\'.\')); }, ' + SCOPE + ')'; + } + }, + { + name: /\s*\(([\$\w]+)\)\s*->([^\n]*)/, + fn: function (content) { + var quickFunc = /\s*\(([\$\w]+)\)\s*->([^\n]*)/, parts = content.match(quickFunc); + return 'can.proxy(function(__){var ' + parts[1] + '=can.$(__);with(' + SCOPE + '.attr(\'.\')){' + parts[2] + '}}, this);'; + } + }, + { + name: /^.*$/, + fn: function (content, cmd) { + var mode = false, result = { + content: '', + startTxt: false, + startOnlyTxt: false, + end: false + }; + content = can.trim(content); + if (content.length && (mode = content.match(/^([#^\/]|else$)/))) { + mode = mode[0]; + switch (mode) { + case '#': + case '^': + if (cmd.specialAttribute) { + result.startOnlyTxt = true; + } else { + result.startTxt = true; + result.escaped = 0; + } + break; + case '/': + result.end = true; + result.content += 'return ___v1ew.join("");}}])'; + return result; + } + content = content.substring(1); + } + if (mode !== 'else') { + var args = [], hashes = [], i = 0, m; + result.content += 'can.Mustache.txt(\n' + (cmd.specialAttribute ? SPECIAL_CONTEXT_OBJ : CONTEXT_OBJ) + ',\n' + (mode ? '"' + mode + '"' : 'null') + ','; + (can.trim(content) + ' ').replace(argumentsRegExp, function (whole, arg) { + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[2]) { + args.push(m[0]); + } else { + hashes.push(m[4] + ':' + (m[6] ? m[6] : makeLookupLiteral(m[5]))); + } + } else { + args.push(makeLookupLiteral(arg)); + } + i++; + }); + result.content += args.join(','); + if (hashes.length) { + result.content += ',{' + HASH + ':{' + hashes.join(',') + '}}'; + } + } + if (mode && mode !== 'else') { + result.content += ',[\n\n'; + } + switch (mode) { + case '^': + case '#': + result.content += '{fn:function(' + ARG_NAMES + '){var ___v1ew = [];'; + break; + case 'else': + result.content += 'return ___v1ew.join("");}},\n{inverse:function(' + ARG_NAMES + '){\nvar ___v1ew = [];'; + break; + default: + result.content += ')'; + break; + } + if (!mode) { + result.startTxt = true; + result.end = true; + } + return result; + } + } + ] + }) +}); +var helpers = can.view.Scanner.prototype.helpers; +for (var i = 0; i < helpers.length; i++) { + Mustache.prototype.scanner.helpers.unshift(helpers[i]); +} +Mustache.txt = function (scopeAndOptions, mode, name) { + var scope = scopeAndOptions.scope, options = scopeAndOptions.options, args = [], helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, hash, context = scope.attr('.'), getHelper = true, helper; + for (var i = 3; i < arguments.length; i++) { + var arg = arguments[i]; + if (mode && can.isArray(arg)) { + helperOptions = can.extend.apply(can, [helperOptions].concat(arg)); + } else if (arg && arg[HASH]) { + hash = arg[HASH]; + for (var prop in hash) { + if (isLookup(hash[prop])) { + hash[prop] = Mustache.get(hash[prop].get, scopeAndOptions, false, true); + } + } + } else if (arg && isLookup(arg)) { + args.push(Mustache.get(arg.get, scopeAndOptions, false, true, true)); + } else { + args.push(arg); + } + } + if (isLookup(name)) { + var get = name.get; + name = Mustache.get(name.get, scopeAndOptions, args.length, false); + getHelper = get === name; + } + helperOptions.fn = makeConvertToScopes(helperOptions.fn, scope, options); + helperOptions.inverse = makeConvertToScopes(helperOptions.inverse, scope, options); + if (mode === '^') { + var tmp = helperOptions.fn; + helperOptions.fn = helperOptions.inverse; + helperOptions.inverse = tmp; + } + if (helper = getHelper && (typeof name === 'string' && Mustache.getHelper(name, options)) || can.isFunction(name) && !name.isComputed && { fn: name }) { + can.extend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash + }); + args.push(helperOptions); + return function () { + return helper.fn.apply(context, args) || ''; + }; + } + return function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + var validArgs = args.length ? args : [value], valid = true, result = [], i, argIsObserve, arg; + if (mode) { + for (i = 0; i < validArgs.length; i++) { + arg = validArgs[i]; + argIsObserve = typeof arg !== 'undefined' && isObserveLike(arg); + if (isArrayLike(arg)) { + if (mode === '#') { + valid = valid && !!(argIsObserve ? arg.attr('length') : arg.length); + } else if (mode === '^') { + valid = valid && !(argIsObserve ? arg.attr('length') : arg.length); + } + } else { + valid = mode === '#' ? valid && !!arg : mode === '^' ? valid && !arg : valid; + } + } + } + if (valid) { + if (mode === '#') { + if (isArrayLike(value)) { + var isObserveList = isObserveLike(value); + for (i = 0; i < value.length; i++) { + result.push(helperOptions.fn(isObserveList ? value.attr('' + i) : value[i])); + } + return result.join(''); + } else { + return helperOptions.fn(value || {}) || ''; + } + } else if (mode === '^') { + return helperOptions.inverse(value || {}) || ''; + } else { + return '' + (value != null ? value : ''); + } + } + return ''; + }; +}; +Mustache.get = function (key, scopeAndOptions, isHelper, isArgument, isLookup) { + var context = scopeAndOptions.scope.attr('.'), options = scopeAndOptions.options || {}; + if (isHelper) { + if (Mustache.getHelper(key, options)) { + return key; + } + if (scopeAndOptions.scope && can.isFunction(context[key])) { + return context[key]; + } + } + var computeData = scopeAndOptions.scope.computeData(key, { + isArgument: isArgument, + args: [ + context, + scopeAndOptions.scope + ] + }), compute = computeData.compute; + can.compute.temporarilyBind(compute); + var initialValue = computeData.initialValue, helperObj = Mustache.getHelper(key, options); + if (!isLookup && (initialValue === undefined || computeData.scope !== scopeAndOptions.scope) && Mustache.getHelper(key, options)) { + return key; + } + if (!compute.computeInstance.hasDependencies) { + return initialValue; + } else { + return compute; + } +}; +Mustache.resolve = function (value) { + if (isObserveLike(value) && isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } +}; +can.view.Options = can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } +}); +Mustache._helpers = {}; +Mustache.registerHelper = function (name, fn) { + this._helpers[name] = { + name: name, + fn: fn + }; +}; +Mustache.getHelper = function (name, options) { + var helper; + if (options) { + helper = options.attr('helpers.' + name); + } + return helper ? { fn: helper } : this._helpers[name]; +}; +Mustache.render = function (partial, scope, options) { + if (!can.view.cached[partial]) { + var reads = can.__clearReading(); + var scopePartialName = scope.attr(partial); + if (scopePartialName) { + partial = scopePartialName; + } + can.__setReading(reads); + } + return can.view.render(partial, scope, options); +}; +Mustache.safeString = function (str) { + return { + toString: function () { + return str; + } + }; +}; +Mustache.renderPartial = function (partialName, scope, options) { + var partial = options.attr('partials.' + partialName); + if (partial) { + return partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + return can.Mustache.render(partialName, scope, options); + } +}; +can.each({ + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!Mustache.resolve(expr); + } + if (value) { + return options.fn(options.contexts || this); + } else { + return options.inverse(options.contexts || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = Mustache.resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return Mustache._helpers.is.fn.apply(this, arguments); + }, + 'unless': function (expr, options) { + return Mustache._helpers['if'].fn.apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'each': function (expr, options) { + var resolved = Mustache.resolve(expr), result = [], keys, key, i; + if (can.view.lists && (resolved instanceof can.List || expr && expr.isComputed && resolved === undefined)) { + return can.view.lists(expr, function (item, index) { + return options.fn(options.scope.add({ '@index': index }).add(item)); + }); + } + expr = resolved; + if (!!expr && isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + return result.join(''); + } else if (isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + return result.join(''); + } + }, + 'with': function (expr, options) { + var ctx = expr; + expr = Mustache.resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + } +}, function (fn, name) { + Mustache.registerHelper(name, fn); +}); +can.view.register({ + suffix: 'mustache', + contentType: 'x-mustache-template', + script: function (id, src) { + return 'can.Mustache(function(' + ARG_NAMES + ') { ' + new Mustache({ + text: src, + name: id + }).template.out + ' })'; + }, + renderer: function (id, text) { + return Mustache({ + text: text, + name: id + }); + } +}); +can.mustache.registerHelper = can.proxy(can.Mustache.registerHelper, can.Mustache); +can.mustache.safeString = can.Mustache.safeString; +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/mustache/system.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/mustache/system.js new file mode 100644 index 0000000000..60381d0c78 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/mustache/system.js @@ -0,0 +1,17 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/mustache/system*/ +var can = require('./mustache.js'); +function translate(load) { + return 'define([\'can/view/mustache/mustache\'],function(can){' + 'return can.view.preloadStringRenderer(\'' + load.metadata.pluginArgument + '\',' + 'can.Mustache(function(scope,options) { ' + new can.Mustache({ + text: load.source, + name: load.name + }).template.out + ' })' + ')' + '})'; +} +module.exports = { translate: translate }; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/node_lists/node_lists.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/node_lists/node_lists.js new file mode 100644 index 0000000000..0cb1a17ab9 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/node_lists/node_lists.js @@ -0,0 +1,173 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/node_lists/node_lists*/ +var can = require('../../util/util.js'); +require('../elements.js'); +var canExpando = true; +try { + document.createTextNode('')._ = 0; +} catch (ex) { + canExpando = false; +} +var nodeMap = {}, textNodeMap = {}, expando = 'ejs_' + Math.random(), _id = 0, id = function (node, localMap) { + var _textNodeMap = localMap || textNodeMap; + var id = readId(node, _textNodeMap); + if (id) { + return id; + } else { + if (canExpando || node.nodeType !== 3) { + ++_id; + return node[expando] = (node.nodeName ? 'element_' : 'obj_') + _id; + } else { + ++_id; + _textNodeMap['text_' + _id] = node; + return 'text_' + _id; + } + } + }, readId = function (node, textNodeMap) { + if (canExpando || node.nodeType !== 3) { + return node[expando]; + } else { + for (var textNodeID in textNodeMap) { + if (textNodeMap[textNodeID] === node) { + return textNodeID; + } + } + } + }, splice = [].splice, push = [].push, itemsInChildListTree = function (list) { + var count = 0; + for (var i = 0, len = list.length; i < len; i++) { + var item = list[i]; + if (item.nodeType) { + count++; + } else { + count += itemsInChildListTree(item); + } + } + return count; + }, replacementMap = function (replacements, idMap) { + var map = {}; + for (var i = 0, len = replacements.length; i < len; i++) { + var node = nodeLists.first(replacements[i]); + map[id(node, idMap)] = replacements[i]; + } + return map; + }; +var nodeLists = { + id: id, + update: function (nodeList, newNodes) { + var oldNodes = nodeLists.unregisterChildren(nodeList); + newNodes = can.makeArray(newNodes); + var oldListLength = nodeList.length; + splice.apply(nodeList, [ + 0, + oldListLength + ].concat(newNodes)); + if (nodeList.replacements) { + nodeLists.nestReplacements(nodeList); + } else { + nodeLists.nestList(nodeList); + } + return oldNodes; + }, + nestReplacements: function (list) { + var index = 0, idMap = {}, rMap = replacementMap(list.replacements, idMap), rCount = list.replacements.length; + while (index < list.length && rCount) { + var node = list[index], replacement = rMap[readId(node, idMap)]; + if (replacement) { + list.splice(index, itemsInChildListTree(replacement), replacement); + rCount--; + } + index++; + } + list.replacements = []; + }, + nestList: function (list) { + var index = 0; + while (index < list.length) { + var node = list[index], childNodeList = nodeMap[id(node)]; + if (childNodeList) { + if (childNodeList !== list) { + list.splice(index, itemsInChildListTree(childNodeList), childNodeList); + } + } else { + nodeMap[id(node)] = list; + } + index++; + } + }, + last: function (nodeList) { + var last = nodeList[nodeList.length - 1]; + if (last.nodeType) { + return last; + } else { + return nodeLists.last(last); + } + }, + first: function (nodeList) { + var first = nodeList[0]; + if (first.nodeType) { + return first; + } else { + return nodeLists.first(first); + } + }, + flatten: function (nodeList) { + var items = []; + for (var i = 0; i < nodeList.length; i++) { + var item = nodeList[i]; + if (item.nodeType) { + items.push(item); + } else { + items.push.apply(items, nodeLists.flatten(item)); + } + } + return items; + }, + register: function (nodeList, unregistered, parent) { + nodeList.unregistered = unregistered; + nodeList.parentList = parent; + if (parent === true) { + nodeList.replacements = []; + } else if (parent) { + parent.replacements.push(nodeList); + nodeList.replacements = []; + } else { + nodeLists.nestList(nodeList); + } + return nodeList; + }, + unregisterChildren: function (nodeList) { + var nodes = []; + can.each(nodeList, function (node) { + if (node.nodeType) { + if (!nodeList.replacements) { + delete nodeMap[id(node)]; + } + nodes.push(node); + } else { + push.apply(nodes, nodeLists.unregister(node)); + } + }); + return nodes; + }, + unregister: function (nodeList) { + var nodes = nodeLists.unregisterChildren(nodeList); + if (nodeList.unregistered) { + var unregisteredCallback = nodeList.unregistered; + delete nodeList.unregistered; + delete nodeList.replacements; + unregisteredCallback(); + } + return nodes; + }, + nodeMap: nodeMap + }; +can.view.nodeLists = nodeLists; +module.exports = nodeLists; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/parser/parser.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/parser/parser.js new file mode 100644 index 0000000000..5a180da735 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/parser/parser.js @@ -0,0 +1,188 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/parser/parser*/ +var can = require('../view.js'); +function makeMap(str) { + var obj = {}, items = str.split(','); + for (var i = 0; i < items.length; i++) { + obj[items[i]] = true; + } + return obj; +} +function handleIntermediate(intermediate, handler) { + for (var i = 0, len = intermediate.length; i < len; i++) { + var item = intermediate[i]; + handler[item.tokenType].apply(handler, item.args); + } + return intermediate; +} +var alphaNumericHU = '-:A-Za-z0-9_', attributeNames = '[a-zA-Z_:][' + alphaNumericHU + ':.]*', spaceEQspace = '\\s*=\\s*', dblQuote2dblQuote = '"((?:\\\\.|[^"])*)"', quote2quote = '\'((?:\\\\.|[^\'])*)\'', attributeEqAndValue = '(?:' + spaceEQspace + '(?:' + '(?:"[^"]*")|(?:\'[^\']*\')|[^>\\s]+))?', matchStash = '\\{\\{[^\\}]*\\}\\}\\}?', stash = '\\{\\{([^\\}]*)\\}\\}\\}?', startTag = new RegExp('^<([' + alphaNumericHU + ']+)' + '(' + '(?:\\s*' + '(?:(?:' + '(?:' + attributeNames + ')?' + attributeEqAndValue + ')|' + '(?:' + matchStash + ')+)' + ')*' + ')\\s*(\\/?)>'), endTag = new RegExp('^<\\/([' + alphaNumericHU + ']+)[^>]*>'), attr = new RegExp('(?:' + '(?:(' + attributeNames + ')|' + stash + ')' + '(?:' + spaceEQspace + '(?:' + '(?:' + dblQuote2dblQuote + ')|(?:' + quote2quote + ')|([^>\\s]+)' + ')' + ')?)', 'g'), mustache = new RegExp(stash, 'g'), txtBreak = /<|\{\{/; +var empty = makeMap('area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed'); +var block = makeMap('a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video'); +var inline = makeMap('abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var'); +var closeSelf = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr'); +var fillAttrs = makeMap('checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected'); +var special = makeMap('script,style'); +var tokenTypes = 'start,end,close,attrStart,attrEnd,attrValue,chars,comment,special,done'.split(','); +var fn = function () { +}; +var HTMLParser = function (html, handler, returnIntermediate) { + if (typeof html === 'object') { + return handleIntermediate(html, handler); + } + var intermediate = []; + handler = handler || {}; + if (returnIntermediate) { + can.each(tokenTypes, function (name) { + var callback = handler[name] || fn; + handler[name] = function () { + if (callback.apply(this, arguments) !== false) { + intermediate.push({ + tokenType: name, + args: can.makeArray(arguments) + }); + } + }; + }); + } + function parseStartTag(tag, tagName, rest, unary) { + tagName = tagName.toLowerCase(); + if (block[tagName]) { + while (stack.last() && inline[stack.last()]) { + parseEndTag('', stack.last()); + } + } + if (closeSelf[tagName] && stack.last() === tagName) { + parseEndTag('', tagName); + } + unary = empty[tagName] || !!unary; + handler.start(tagName, unary); + if (!unary) { + stack.push(tagName); + } + HTMLParser.parseAttrs(rest, handler); + handler.end(tagName, unary); + } + function parseEndTag(tag, tagName) { + var pos; + if (!tagName) { + pos = 0; + } else { + for (pos = stack.length - 1; pos >= 0; pos--) { + if (stack[pos] === tagName) { + break; + } + } + } + if (pos >= 0) { + for (var i = stack.length - 1; i >= pos; i--) { + if (handler.close) { + handler.close(stack[i]); + } + } + stack.length = pos; + } + } + function parseMustache(mustache, inside) { + if (handler.special) { + handler.special(inside); + } + } + var index, chars, match, stack = [], last = html; + stack.last = function () { + return this[this.length - 1]; + }; + while (html) { + chars = true; + if (!stack.last() || !special[stack.last()]) { + if (html.indexOf(''); + if (index >= 0) { + if (handler.comment) { + handler.comment(html.substring(4, index)); + } + html = html.substring(index + 3); + chars = false; + } + } else if (html.indexOf(']*>'), function (all, text) { + text = text.replace(/|/g, '$1$2'); + if (handler.chars) { + handler.chars(text); + } + return ''; + }); + parseEndTag('', stack.last()); + } + if (html === last) { + throw 'Parse Error: ' + html; + } + last = html; + } + parseEndTag(); + handler.done(); + return intermediate; +}; +HTMLParser.parseAttrs = function (rest, handler) { + (rest != null ? rest : '').replace(attr, function (text, name, special, dblQuote, singleQuote, val) { + if (special) { + handler.special(special); + } + if (name || dblQuote || singleQuote || val) { + var value = arguments[3] ? arguments[3] : arguments[4] ? arguments[4] : arguments[5] ? arguments[5] : fillAttrs[name.toLowerCase()] ? name : ''; + handler.attrStart(name || ''); + var last = mustache.lastIndex = 0, res = mustache.exec(value), chars; + while (res) { + chars = value.substring(last, mustache.lastIndex - res[0].length); + if (chars.length) { + handler.attrValue(chars); + } + handler.special(res[1]); + last = mustache.lastIndex; + res = mustache.exec(value); + } + chars = value.substr(last, value.length); + if (chars) { + handler.attrValue(chars); + } + handler.attrEnd(name || ''); + } + }); +}; +can.view.parser = HTMLParser; +module.exports = HTMLParser; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/render.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/render.js new file mode 100644 index 0000000000..9043036017 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/render.js @@ -0,0 +1,130 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/render*/ +var can = require('./view.js'); +var elements = require('./elements.js'); +var live = require('./live/live.js'); +require('../util/string/string.js'); +var pendingHookups = [], tagChildren = function (tagName) { + var newTag = elements.tagMap[tagName] || 'span'; + if (newTag === 'span') { + return '@@!!@@'; + } + return '<' + newTag + '>' + tagChildren(newTag) + ''; + }, contentText = function (input, tag) { + if (typeof input === 'string') { + return input; + } + if (!input && input !== 0) { + return ''; + } + var hook = input.hookup && function (el, id) { + input.hookup.call(input, el, id); + } || typeof input === 'function' && input; + if (hook) { + if (tag) { + return '<' + tag + ' ' + can.view.hook(hook) + '>'; + } else { + pendingHookups.push(hook); + } + return ''; + } + return '' + input; + }, contentEscape = function (txt, tag) { + return typeof txt === 'string' || typeof txt === 'number' ? can.esc(txt) : contentText(txt, tag); + }, withinTemplatedSectionWithinAnElement = false, emptyHandler = function () { + }; +var lastHookups; +can.extend(can.view, { + live: live, + setupLists: function () { + var old = can.view.lists, data; + can.view.lists = function (list, renderer) { + data = { + list: list, + renderer: renderer + }; + return Math.random(); + }; + return function () { + can.view.lists = old; + return data; + }; + }, + getHooks: function () { + var hooks = pendingHookups.slice(0); + lastHookups = hooks; + pendingHookups = []; + return hooks; + }, + onlytxt: function (self, func) { + return contentEscape(func.call(self)); + }, + txt: function (escape, tagName, status, self, func) { + var tag = elements.tagMap[tagName] || 'span', setupLiveBinding = false, value, listData, compute, unbind = emptyHandler, attributeName; + if (withinTemplatedSectionWithinAnElement) { + value = func.call(self); + } else { + if (typeof status === 'string' || status === 1) { + withinTemplatedSectionWithinAnElement = true; + } + var listTeardown = can.view.setupLists(); + unbind = function () { + compute.unbind('change', emptyHandler); + }; + compute = can.compute(func, self, false); + compute.bind('change', emptyHandler); + listData = listTeardown(); + value = compute(); + withinTemplatedSectionWithinAnElement = false; + setupLiveBinding = compute.computeInstance.hasDependencies; + } + if (listData) { + unbind(); + return '<' + tag + can.view.hook(function (el, parentNode) { + live.list(el, listData.list, listData.renderer, self, parentNode); + }) + '>'; + } + if (!setupLiveBinding || typeof value === 'function') { + unbind(); + return (withinTemplatedSectionWithinAnElement || escape === 2 || !escape ? contentText : contentEscape)(value, status === 0 && tag); + } + var contentProp = elements.tagToContentPropMap[tagName]; + if (status === 0 && !contentProp) { + return '<' + tag + can.view.hook(escape && typeof value !== 'object' ? function (el, parentNode) { + live.text(el, compute, parentNode); + unbind(); + } : function (el, parentNode) { + live.html(el, compute, parentNode); + unbind(); + }) + '>' + tagChildren(tag) + ''; + } else if (status === 1) { + pendingHookups.push(function (el) { + live.attributes(el, compute, compute()); + unbind(); + }); + return compute(); + } else if (escape === 2) { + attributeName = status; + pendingHookups.push(function (el) { + live.specialAttribute(el, attributeName, compute); + unbind(); + }); + return compute(); + } else { + attributeName = status === 0 ? contentProp : status; + (status === 0 ? lastHookups : pendingHookups).push(function (el) { + live.attribute(el, attributeName, compute); + unbind(); + }); + return live.attributePlaceholder; + } + } +}); +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/scanner.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/scanner.js new file mode 100644 index 0000000000..96b46b1214 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/scanner.js @@ -0,0 +1,381 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/scanner*/ +var can = require('./view.js'); +var elements = require('./elements.js'); +var viewCallbacks = require('./callbacks/callbacks.js'); +var newLine = /(\r|\n)+/g, notEndTag = /\//, clean = function (content) { + return content.split('\\').join('\\\\').split('\n').join('\\n').split('"').join('\\"').split('\t').join('\\t'); + }, getTag = function (tagName, tokens, i) { + if (tagName) { + return tagName; + } else { + while (i < tokens.length) { + if (tokens[i] === '<' && !notEndTag.test(tokens[i + 1])) { + return elements.reverseTagMap[tokens[i + 1]] || 'span'; + } + i++; + } + } + return ''; + }, bracketNum = function (content) { + return --content.split('{').length - --content.split('}').length; + }, myEval = function (script) { + eval(script); + }, attrReg = /([^\s]+)[\s]*=[\s]*$/, startTxt = 'var ___v1ew = [];', finishTxt = 'return ___v1ew.join(\'\')', put_cmd = '___v1ew.push(\n', insert_cmd = put_cmd, htmlTag = null, quote = null, beforeQuote = null, rescan = null, getAttrName = function () { + var matches = beforeQuote.match(attrReg); + return matches && matches[1]; + }, status = function () { + return quote ? '\'' + getAttrName() + '\'' : htmlTag ? 1 : 0; + }, top = function (stack) { + return stack[stack.length - 1]; + }, Scanner; +can.view.Scanner = Scanner = function (options) { + can.extend(this, { + text: {}, + tokens: [] + }, options); + this.text.options = this.text.options || ''; + this.tokenReg = []; + this.tokenSimple = { + '<': '<', + '>': '>', + '"': '"', + '\'': '\'' + }; + this.tokenComplex = []; + this.tokenMap = {}; + for (var i = 0, token; token = this.tokens[i]; i++) { + if (token[2]) { + this.tokenReg.push(token[2]); + this.tokenComplex.push({ + abbr: token[1], + re: new RegExp(token[2]), + rescan: token[3] + }); + } else { + this.tokenReg.push(token[1]); + this.tokenSimple[token[1]] = token[0]; + } + this.tokenMap[token[0]] = token[1]; + } + this.tokenReg = new RegExp('(' + this.tokenReg.slice(0).concat([ + '<', + '>', + '"', + '\'' + ]).join('|') + ')', 'g'); +}; +Scanner.prototype = { + helpers: [], + scan: function (source, name) { + var tokens = [], last = 0, simple = this.tokenSimple, complex = this.tokenComplex; + source = source.replace(newLine, '\n'); + if (this.transform) { + source = this.transform(source); + } + source.replace(this.tokenReg, function (whole, part) { + var offset = arguments[arguments.length - 2]; + if (offset > last) { + tokens.push(source.substring(last, offset)); + } + if (simple[whole]) { + tokens.push(whole); + } else { + for (var i = 0, token; token = complex[i]; i++) { + if (token.re.test(whole)) { + tokens.push(token.abbr); + if (token.rescan) { + tokens.push(token.rescan(part)); + } + break; + } + } + } + last = offset + part.length; + }); + if (last < source.length) { + tokens.push(source.substr(last)); + } + var content = '', buff = [startTxt + (this.text.start || '')], put = function (content, bonus) { + buff.push(put_cmd, '"', clean(content), '"' + (bonus || '') + ');'); + }, endStack = [], lastToken, startTag = null, magicInTag = false, specialStates = { + attributeHookups: [], + tagHookups: [], + lastTagHookup: '' + }, popTagHookup = function () { + specialStates.lastTagHookup = specialStates.tagHookups.pop() + specialStates.tagHookups.length; + }, tagName = '', tagNames = [], popTagName = false, bracketCount, specialAttribute = false, i = 0, token, tmap = this.tokenMap, attrName; + htmlTag = quote = beforeQuote = null; + for (; (token = tokens[i++]) !== undefined;) { + if (startTag === null) { + switch (token) { + case tmap.left: + case tmap.escapeLeft: + case tmap.returnLeft: + magicInTag = htmlTag && 1; + case tmap.commentLeft: + startTag = token; + if (content.length) { + put(content); + } + content = ''; + break; + case tmap.escapeFull: + magicInTag = htmlTag && 1; + rescan = 1; + startTag = tmap.escapeLeft; + if (content.length) { + put(content); + } + rescan = tokens[i++]; + content = rescan.content || rescan; + if (rescan.before) { + put(rescan.before); + } + tokens.splice(i, 0, tmap.right); + break; + case tmap.commentFull: + break; + case tmap.templateLeft: + content += tmap.left; + break; + case '<': + if (tokens[i].indexOf('!--') !== 0) { + htmlTag = 1; + magicInTag = 0; + } + content += token; + break; + case '>': + htmlTag = 0; + var emptyElement = content.substr(content.length - 1) === '/' || content.substr(content.length - 2) === '--', attrs = ''; + if (specialStates.attributeHookups.length) { + attrs = 'attrs: [\'' + specialStates.attributeHookups.join('\',\'') + '\'], '; + specialStates.attributeHookups = []; + } + if (tagName + specialStates.tagHookups.length !== specialStates.lastTagHookup && tagName === top(specialStates.tagHookups)) { + if (emptyElement) { + content = content.substr(0, content.length - 1); + } + buff.push(put_cmd, '"', clean(content), '"', ',can.view.pending({tagName:\'' + tagName + '\',' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options); + if (emptyElement) { + buff.push('}));'); + content = '/>'; + popTagHookup(); + } else if (tokens[i] === '<' && tokens[i + 1] === '/' + tagName) { + buff.push('}));'); + content = token; + popTagHookup(); + } else { + buff.push(',subtemplate: function(' + this.text.argNames + '){\n' + startTxt + (this.text.start || '')); + content = ''; + } + } else if (magicInTag || !popTagName && elements.tagToContentPropMap[tagNames[tagNames.length - 1]] || attrs) { + var pendingPart = ',can.view.pending({' + attrs + 'scope: ' + (this.text.scope || 'this') + this.text.options + '}),"'; + if (emptyElement) { + put(content.substr(0, content.length - 1), pendingPart + '/>"'); + } else { + put(content, pendingPart + '>"'); + } + content = ''; + magicInTag = 0; + } else { + content += token; + } + if (emptyElement || popTagName) { + tagNames.pop(); + tagName = tagNames[tagNames.length - 1]; + popTagName = false; + } + specialStates.attributeHookups = []; + break; + case '\'': + case '"': + if (htmlTag) { + if (quote && quote === token) { + quote = null; + var attr = getAttrName(); + if (viewCallbacks.attr(attr)) { + specialStates.attributeHookups.push(attr); + } + if (specialAttribute) { + content += token; + put(content); + buff.push(finishTxt, '}));\n'); + content = ''; + specialAttribute = false; + break; + } + } else if (quote === null) { + quote = token; + beforeQuote = lastToken; + attrName = getAttrName(); + if (tagName === 'img' && attrName === 'src' || attrName === 'style') { + put(content.replace(attrReg, '')); + content = ''; + specialAttribute = true; + buff.push(insert_cmd, 'can.view.txt(2,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt); + put(attrName + '=' + token); + break; + } + } + } + default: + if (lastToken === '<') { + tagName = token.substr(0, 3) === '!--' ? '!--' : token.split(/\s/)[0]; + var isClosingTag = false, cleanedTagName; + if (tagName.indexOf('/') === 0) { + isClosingTag = true; + cleanedTagName = tagName.substr(1); + } + if (isClosingTag) { + if (top(tagNames) === cleanedTagName) { + tagName = cleanedTagName; + popTagName = true; + } + if (top(specialStates.tagHookups) === cleanedTagName) { + put(content.substr(0, content.length - 1)); + buff.push(finishTxt + '}}) );'); + content = '><'; + popTagHookup(); + } + } else { + if (tagName.lastIndexOf('/') === tagName.length - 1) { + tagName = tagName.substr(0, tagName.length - 1); + } + if (tagName !== '!--' && viewCallbacks.tag(tagName)) { + if (tagName === 'content' && elements.tagMap[top(tagNames)]) { + token = token.replace('content', elements.tagMap[top(tagNames)]); + } + specialStates.tagHookups.push(tagName); + } + tagNames.push(tagName); + } + } + content += token; + break; + } + } else { + switch (token) { + case tmap.right: + case tmap.returnRight: + switch (startTag) { + case tmap.left: + bracketCount = bracketNum(content); + if (bracketCount === 1) { + buff.push(insert_cmd, 'can.view.txt(0,\'' + getTag(tagName, tokens, i) + '\',' + status() + ',this,function(){', startTxt, content); + endStack.push({ + before: '', + after: finishTxt + '}));\n' + }); + } else { + last = endStack.length && bracketCount === -1 ? endStack.pop() : { after: ';' }; + if (last.before) { + buff.push(last.before); + } + buff.push(content, ';', last.after); + } + break; + case tmap.escapeLeft: + case tmap.returnLeft: + bracketCount = bracketNum(content); + if (bracketCount) { + endStack.push({ + before: finishTxt, + after: '}));\n' + }); + } + var escaped = startTag === tmap.escapeLeft ? 1 : 0, commands = { + insert: insert_cmd, + tagName: getTag(tagName, tokens, i), + status: status(), + specialAttribute: specialAttribute + }; + for (var ii = 0; ii < this.helpers.length; ii++) { + var helper = this.helpers[ii]; + if (helper.name.test(content)) { + content = helper.fn(content, commands); + if (helper.name.source === /^>[\s]*\w*/.source) { + escaped = 0; + } + break; + } + } + if (typeof content === 'object') { + if (content.startTxt && content.end && specialAttribute) { + buff.push(insert_cmd, 'can.view.toStr( ', content.content, '() ) );'); + } else { + if (content.startTxt) { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || (content.escaped != null ? content.escaped : escaped)) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\n'); + } else if (content.startOnlyTxt) { + buff.push(insert_cmd, 'can.view.onlytxt(this,\n'); + } + buff.push(content.content); + if (content.end) { + buff.push('));'); + } + } + } else if (specialAttribute) { + buff.push(insert_cmd, content, ');'); + } else { + buff.push(insert_cmd, 'can.view.txt(\n' + (typeof status() === 'string' || escaped) + ',\n\'' + tagName + '\',\n' + status() + ',\nthis,\nfunction(){ ' + (this.text.escape || '') + 'return ', content, bracketCount ? startTxt : '}));\n'); + } + if (rescan && rescan.after && rescan.after.length) { + put(rescan.after.length); + rescan = null; + } + break; + } + startTag = null; + content = ''; + break; + case tmap.templateLeft: + content += tmap.left; + break; + default: + content += token; + break; + } + } + lastToken = token; + } + if (content.length) { + put(content); + } + buff.push(';'); + var template = buff.join(''), out = { out: (this.text.outStart || '') + template + ' ' + finishTxt + (this.text.outEnd || '') }; + myEval.call(out, 'this.fn = (function(' + this.text.argNames + '){' + out.out + '});\r\n//# sourceURL=' + name + '.js'); + return out; + } +}; +can.view.pending = function (viewData) { + var hooks = can.view.getHooks(); + return can.view.hook(function (el) { + can.each(hooks, function (fn) { + fn(el); + }); + viewData.templateType = 'legacy'; + if (viewData.tagName) { + viewCallbacks.tagHandler(el, viewData.tagName, viewData); + } + can.each(viewData && viewData.attrs || [], function (attributeName) { + viewData.attributeName = attributeName; + var callback = viewCallbacks.attr(attributeName); + if (callback) { + callback(el, viewData); + } + }); + }); +}; +can.view.tag('content', function (el, tagData) { + return tagData.scope; +}); +can.view.Scanner = Scanner; +module.exports = Scanner; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/scope/compute_data.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/scope/compute_data.js new file mode 100644 index 0000000000..bc7ac72d5d --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/scope/compute_data.js @@ -0,0 +1,107 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/scope/compute_data*/ +var can = require('../../util/util.js'); +var compute = require('../../compute/compute.js'); +var getValueAndBind = require('../../compute/get_value_and_bind.js'); +var isFastPath = function (computeData) { + return computeData.reads && computeData.reads.length === 1 && computeData.root instanceof can.Map && !can.isFunction(computeData.root[computeData.reads[0]]); +}; +var getValueAndBindScopeRead = function (scopeRead, scopeReadChanged) { + return getValueAndBind(scopeRead, null, { observed: {} }, scopeReadChanged); +}; +var unbindScopeRead = function (readInfo, scopeReadChanged) { + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, scopeReadChanged); + } +}; +var getValueAndBindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + var target = computeData.root, prop = computeData.reads[0]; + target.bind(prop, singlePropertyReadChanged); + return { + value: computeData.initialValue, + observed: { something: true } + }; +}; +var unbindSinglePropertyRead = function (computeData, singlePropertyReadChanged) { + computeData.root.unbind(computeData.reads[0], singlePropertyReadChanged); +}; +var scopeReader = function (scope, key, options, computeData, newVal) { + if (arguments.length > 4) { + if (computeData.root.isComputed) { + computeData.root(newVal); + } else if (computeData.reads.length) { + var last = computeData.reads.length - 1; + var obj = computeData.reads.length ? can.compute.read(computeData.root, computeData.reads.slice(0, last)).value : computeData.root; + can.compute.set(obj, computeData.reads[last], newVal, options); + } + } else { + if (computeData.root) { + return can.compute.read(computeData.root, computeData.reads, options).value; + } + var data = scope.read(key, options); + computeData.scope = data.scope; + computeData.initialValue = data.value; + computeData.reads = data.reads; + computeData.root = data.rootObserve; + return data.value; + } +}; +module.exports = function (scope, key, options) { + options = options || { args: [] }; + var computeData = {}, scopeRead = function (newVal) { + if (arguments.length) { + return scopeReader(scope, key, options, computeData, newVal); + } else { + return scopeReader(scope, key, options, computeData); + } + }, batchNum, readInfo, scopeReadChanged = function (ev) { + if (readInfo.ready && compute.computeInstance.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + var oldValue = readInfo.value, newValue; + readInfo = getValueAndBind(scopeRead, null, readInfo, scopeReadChanged); + newValue = readInfo.value; + compute.computeInstance.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }, singlePropertyReadChanged = function (ev, newVal, oldVal) { + if (typeof newVal !== 'function') { + compute.computeInstance.updater(newVal, oldVal, ev.batchNum); + } else { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + isFastPathBound = false; + compute.computeInstance.updater(readInfo.value, oldVal, ev.batchNum); + } + }, isFastPathBound = false, compute = can.compute(undefined, { + on: function () { + readInfo = getValueAndBindScopeRead(scopeRead, scopeReadChanged); + if (isFastPath(computeData)) { + var oldReadInfo = readInfo; + readInfo = getValueAndBindSinglePropertyRead(computeData, singlePropertyReadChanged); + unbindScopeRead(oldReadInfo, scopeReadChanged); + isFastPathBound = true; + } + compute.computeInstance.value = readInfo.value; + compute.computeInstance.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + off: function () { + if (isFastPathBound) { + unbindSinglePropertyRead(computeData, singlePropertyReadChanged); + } else { + unbindScopeRead(readInfo, scopeReadChanged); + } + }, + set: scopeRead, + get: scopeRead, + __selfUpdater: true + }); + computeData.compute = compute; + return computeData; +}; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/scope/scope.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/scope/scope.js new file mode 100644 index 0000000000..7d16152a1c --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/scope/scope.js @@ -0,0 +1,127 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/scope/scope*/ +var can = require('../../util/util.js'); +var makeComputeData = require('./compute_data.js'); +require('../../construct/construct.js'); +require('../../map/map.js'); +require('../../list/list.js'); +require('../view.js'); +require('../../compute/compute.js'); +var escapeReg = /(\\)?\./g, escapeDotReg = /\\\./g, getNames = function (attr) { + var names = [], last = 0; + attr.replace(escapeReg, function (first, second, index) { + if (!second) { + names.push(attr.slice(last, index).replace(escapeDotReg, '.')); + last = index + first.length; + } + }); + names.push(attr.slice(last).replace(escapeDotReg, '.')); + return names; + }; +var Scope = can.Construct.extend({ read: can.compute.read }, { + init: function (context, parent) { + this._context = context; + this._parent = parent; + this.__cache = {}; + }, + attr: can.__notObserve(function (key, value) { + var options = { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }, res = this.read(key, options); + if (arguments.length === 2) { + var lastIndex = key.lastIndexOf('.'), readKey = lastIndex !== -1 ? key.substring(0, lastIndex) : '.', obj = this.read(readKey, options).value; + if (lastIndex !== -1) { + key = key.substring(lastIndex + 1, key.length); + } + can.compute.set(obj, key, value, options); + } + return res.value; + }), + add: function (context) { + if (context !== this._context) { + return new this.constructor(context, this); + } else { + return this; + } + }, + computeData: function (key, options) { + return makeComputeData(this, key, options); + }, + compute: function (key, options) { + return this.computeData(key, options).compute; + }, + read: function (attr, options) { + var stopLookup; + if (attr.substr(0, 2) === './') { + stopLookup = true; + attr = attr.substr(2); + } else if (attr.substr(0, 3) === '../') { + return this._parent.read(attr.substr(3), options); + } else if (attr === '..') { + return { value: this._parent._context }; + } else if (attr === '.' || attr === 'this') { + return { value: this._context }; + } + var names = attr.indexOf('\\.') === -1 ? attr.split('.') : getNames(attr), context, scope = this, defaultObserve, defaultReads = [], defaultPropertyDepth = -1, defaultComputeReadings, defaultScope, currentObserve, currentReads; + while (scope) { + context = scope._context; + if (context !== null && (typeof context === 'object' || typeof context === 'function')) { + var data = can.compute.read(context, names, can.simpleExtend({ + foundObservable: function (observe, nameIndex) { + currentObserve = observe; + currentReads = names.slice(nameIndex); + }, + earlyExit: function (parentValue, nameIndex) { + if (nameIndex > defaultPropertyDepth) { + defaultObserve = currentObserve; + defaultReads = currentReads; + defaultPropertyDepth = nameIndex; + defaultScope = scope; + defaultComputeReadings = can.__clearReading(); + } + }, + executeAnonymousFunctions: true + }, options)); + if (data.value !== undefined) { + return { + scope: scope, + rootObserve: currentObserve, + value: data.value, + reads: currentReads + }; + } + } + can.__clearReading(); + if (!stopLookup) { + scope = scope._parent; + } else { + scope = null; + } + } + if (defaultObserve) { + can.__setReading(defaultComputeReadings); + return { + scope: defaultScope, + rootObserve: defaultObserve, + reads: defaultReads, + value: undefined + }; + } else { + return { + names: names, + value: undefined + }; + } + } + }); +can.view.Scope = Scope; +module.exports = Scope; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/html_section.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/html_section.js new file mode 100644 index 0000000000..dd58cb8067 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/html_section.js @@ -0,0 +1,126 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/stache/html_section*/ +var can = require('../../util/util.js'); +var target = require('../target/target.js'); +var utils = require('./utils.js'); +var mustacheCore = require('./mustache_core.js'); +var decodeHTML = typeof document !== 'undefined' && function () { + var el = document.createElement('div'); + return function (html) { + if (html.indexOf('&') === -1) { + return html.replace(/\r\n/g, '\n'); + } + el.innerHTML = html; + return el.childNodes.length === 0 ? '' : el.childNodes[0].nodeValue; + }; + }(); +var HTMLSectionBuilder = function () { + this.stack = [new HTMLSection()]; +}; +can.extend(HTMLSectionBuilder.prototype, utils.mixins); +can.extend(HTMLSectionBuilder.prototype, { + startSubSection: function (process) { + var newSection = new HTMLSection(process); + this.stack.push(newSection); + return newSection; + }, + endSubSectionAndReturnRenderer: function () { + if (this.last().isEmpty()) { + this.stack.pop(); + return null; + } else { + var htmlSection = this.endSection(); + return can.proxy(htmlSection.compiled.hydrate, htmlSection.compiled); + } + }, + startSection: function (process) { + var newSection = new HTMLSection(process); + this.last().add(newSection.targetCallback); + this.stack.push(newSection); + }, + endSection: function () { + this.last().compile(); + return this.stack.pop(); + }, + inverse: function () { + this.last().inverse(); + }, + compile: function () { + var compiled = this.stack.pop().compile(); + return function (scope, options, nodeList) { + if (!(scope instanceof can.view.Scope)) { + scope = new can.view.Scope(scope || {}); + } + if (!(options instanceof mustacheCore.Options)) { + options = new mustacheCore.Options(options || {}); + } + return compiled.hydrate(scope, options, nodeList); + }; + }, + push: function (chars) { + this.last().push(chars); + }, + pop: function () { + return this.last().pop(); + } +}); +var HTMLSection = function (process) { + this.data = 'targetData'; + this.targetData = []; + this.targetStack = []; + var self = this; + this.targetCallback = function (scope, options, sectionNode) { + process.call(this, scope, options, sectionNode, can.proxy(self.compiled.hydrate, self.compiled), self.inverseCompiled && can.proxy(self.inverseCompiled.hydrate, self.inverseCompiled)); + }; +}; +can.extend(HTMLSection.prototype, { + inverse: function () { + this.inverseData = []; + this.data = 'inverseData'; + }, + push: function (data) { + this.add(data); + this.targetStack.push(data); + }, + pop: function () { + return this.targetStack.pop(); + }, + add: function (data) { + if (typeof data === 'string') { + data = decodeHTML(data); + } + if (this.targetStack.length) { + this.targetStack[this.targetStack.length - 1].children.push(data); + } else { + this[this.data].push(data); + } + }, + compile: function () { + this.compiled = target(this.targetData); + if (this.inverseData) { + this.inverseCompiled = target(this.inverseData); + delete this.inverseData; + } + delete this.targetData; + delete this.targetStack; + return this.compiled; + }, + children: function () { + if (this.targetStack.length) { + return this.targetStack[this.targetStack.length - 1].children; + } else { + return this[this.data]; + } + }, + isEmpty: function () { + return !this.targetData.length; + } +}); +module.exports = HTMLSectionBuilder; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/intermediate_and_imports.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/intermediate_and_imports.js new file mode 100644 index 0000000000..c392ed8928 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/intermediate_and_imports.js @@ -0,0 +1,59 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/stache/intermediate_and_imports*/ +var mustacheCore = require('./mustache_core.js'); +var parser = require('../parser/parser.js'); +module.exports = function (source) { + var template = mustacheCore.cleanLineEndings(source); + var imports = [], inImport = false, inFrom = false; + var keepToken = function () { + return inImport ? false : true; + }; + var intermediate = parser(template, { + start: function (tagName, unary) { + if (tagName === 'can-import') { + inImport = true; + } + return keepToken(); + }, + end: function (tagName, unary) { + if (tagName === 'can-import') { + inImport = false; + return false; + } + return keepToken(); + }, + attrStart: function (attrName) { + if (attrName === 'from') { + inFrom = true; + } + return keepToken(); + }, + attrEnd: function (attrName) { + if (attrName === 'from') { + inFrom = false; + } + return keepToken(); + }, + attrValue: function (value) { + if (inFrom && inImport) { + imports.push(value); + } + return keepToken(); + }, + chars: keepToken, + comment: keepToken, + special: keepToken, + done: keepToken + }, true); + return { + intermediate: intermediate, + imports: imports + }; +}; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/mustache_core.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/mustache_core.js new file mode 100644 index 0000000000..8521e7a4c9 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/mustache_core.js @@ -0,0 +1,320 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/stache/mustache_core*/ +var can = require('../../util/util.js'); +var utils = require('./utils.js'); +var mustacheHelpers = require('./mustache_helpers.js'); +var live = require('../live/live.js'); +var elements = require('../elements.js'); +var Scope = require('../scope/scope.js'); +var nodeLists = require('../node_lists/node_lists.js'); +live = live || can.view.live; +elements = elements || can.view.elements; +Scope = Scope || can.view.Scope; +nodeLists = nodeLists || can.view.nodeLists; +var argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, literalNumberStringBooleanRegExp = /^(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(?:(.+?)=(?:(?:('.*?'|".*?")|([0-9]+\.?[0-9]*|true|false|null|undefined))|(.+))))$/, mustacheLineBreakRegExp = /(?:(?:^|(\r?)\n)(\s*)(\{\{([^\}]*)\}\}\}?)([^\S\n\r]*)($|\r?\n))|(\{\{([^\}]*)\}\}\}?)/g, isLookup = function (obj) { + return obj && typeof obj.get === 'string'; + }, getItemsFragContent = function (items, isObserveList, helperOptions, options) { + var frag = document.createDocumentFragment(); + for (var i = 0, len = items.length; i < len; i++) { + append(frag, helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options)); + } + return frag; + }, append = function (frag, content) { + if (content) { + frag.appendChild(typeof content === 'string' ? document.createTextNode(content) : content); + } + }, getItemsStringContent = function (items, isObserveList, helperOptions, options) { + var txt = ''; + for (var i = 0, len = items.length; i < len; i++) { + txt += helperOptions.fn(isObserveList ? items.attr('' + i) : items[i], options); + } + return txt; + }, getKeyComputeData = function (key, scope, isArgument) { + var data = scope.computeData(key, { + isArgument: isArgument, + args: [ + scope.attr('.'), + scope + ] + }); + can.compute.temporarilyBind(data.compute); + return data; + }, getKeyArgValue = function (key, scope) { + var data = getKeyComputeData(key, scope, true); + if (!data.compute.computeInstance.hasDependencies) { + return data.initialValue; + } else { + return data.compute; + } + }, convertToScopes = function (helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer) { + if (truthyRenderer) { + helperOptions.fn = makeRendererConvertScopes(truthyRenderer, scope, options, nodeList); + } + if (falseyRenderer) { + helperOptions.inverse = makeRendererConvertScopes(falseyRenderer, scope, options, nodeList); + } + }, makeRendererConvertScopes = function (renderer, parentScope, parentOptions, nodeList) { + var rendererWithScope = function (ctx, opts, parentNodeList) { + return renderer(ctx || parentScope, opts, parentNodeList); + }; + return can.__notObserve(function (newScope, newOptions, parentNodeList) { + if (newScope !== undefined && !(newScope instanceof can.view.Scope)) { + newScope = parentScope.add(newScope); + } + if (newOptions !== undefined && !(newOptions instanceof core.Options)) { + newOptions = parentOptions.add(newOptions); + } + var result = rendererWithScope(newScope, newOptions || parentOptions, parentNodeList || nodeList); + return result; + }); + }; +var core = { + expressionData: function (expression) { + var args = [], hashes = {}, i = 0; + (can.trim(expression) + ' ').replace(argumentsRegExp, function (whole, arg) { + var m; + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + if (m[1] || m[2]) { + args.push(utils.jsonParse(m[1] || m[2])); + } else { + hashes[m[3]] = m[6] ? { get: m[6] } : utils.jsonParse(m[4] || m[5]); + } + } else { + args.push({ get: arg }); + } + i++; + }); + return { + name: args.shift(), + args: args, + hash: hashes + }; + }, + makeEvaluator: function (scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, stringOnly) { + var args = [], hash = {}, helperOptions = { + fn: function () { + }, + inverse: function () { + } + }, context = scope.attr('.'), name = exprData.name, helper, looksLikeAHelper = exprData.args.length || !can.isEmptyObject(exprData.hash), initialValue, helperEvaluator; + for (var i = 0, len = exprData.args.length; i < len; i++) { + var arg = exprData.args[i]; + if (arg && isLookup(arg)) { + args.push(getKeyArgValue(arg.get, scope, true)); + } else { + args.push(arg); + } + } + for (var prop in exprData.hash) { + if (isLookup(exprData.hash[prop])) { + hash[prop] = getKeyArgValue(exprData.hash[prop].get, scope); + } else { + hash[prop] = exprData.hash[prop]; + } + } + if (isLookup(name)) { + if (looksLikeAHelper) { + helper = mustacheHelpers.getHelper(name.get, options); + if (!helper && typeof context[name.get] === 'function') { + helper = { fn: context[name.get] }; + } + } + if (!helper) { + var get = name.get; + var computeData = getKeyComputeData(name.get, scope, false), compute = computeData.compute; + initialValue = computeData.initialValue; + if (computeData.compute.computeInstance.hasDependencies) { + name = compute; + } else { + name = initialValue; + } + if (!looksLikeAHelper && initialValue === undefined) { + helper = mustacheHelpers.getHelper(get, options); + } else if (typeof initialValue === 'function') { + helper = { fn: initialValue }; + } + } + } + if (mode === '^') { + var temp = truthyRenderer; + truthyRenderer = falseyRenderer; + falseyRenderer = temp; + } + if (helper) { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + can.simpleExtend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash, + nodeList: nodeList, + exprData: exprData + }); + args.push(helperOptions); + helperEvaluator = function () { + return helper.fn.apply(context, args) || ''; + }; + helperEvaluator.bindOnce = false; + return helperEvaluator; + } + if (!mode) { + if (name && name.isComputed) { + return name; + } else { + return function () { + return '' + (name != null ? name : ''); + }; + } + } else if (mode === '#' || mode === '^') { + convertToScopes(helperOptions, scope, options, nodeList, truthyRenderer, falseyRenderer); + var evaluator = function () { + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + if (utils.isArrayLike(value)) { + var isObserveList = utils.isObserveLike(value); + if (isObserveList ? value.attr('length') : value.length) { + return (stringOnly ? getItemsStringContent : getItemsFragContent)(value, isObserveList, helperOptions, options); + } else { + return helperOptions.inverse(scope, options); + } + } else { + return value ? helperOptions.fn(value || scope, options) : helperOptions.inverse(scope, options); + } + }; + evaluator.bindOnce = false; + return evaluator; + } else { + } + }, + makeLiveBindingPartialRenderer: function (partialName, state) { + partialName = can.trim(partialName); + return function (scope, options, parentSectionNodeList) { + var nodeList = [this]; + nodeList.expression = '>' + partialName; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var partialFrag = can.compute(function () { + var localPartialName = partialName; + var partial = options.attr('partials.' + localPartialName), res; + if (partial) { + res = partial.render ? partial.render(scope, options) : partial(scope, options); + } else { + var scopePartialName = scope.read(localPartialName, { + isArgument: true, + returnObserveMethods: true, + proxyMethods: false + }).value; + if (scopePartialName) { + localPartialName = scopePartialName; + } + res = can.view.render(localPartialName, scope, options); + } + return can.frag(res); + }); + live.html(this, partialFrag, this.parentNode, nodeList); + }; + }, + makeStringBranchRenderer: function (mode, expression) { + var exprData = expressionData(expression), fullExpression = mode + expression; + return function branchRenderer(scope, options, truthyRenderer, falseyRenderer) { + var evaluator = scope.__cache[fullExpression]; + if (mode || !evaluator) { + evaluator = makeEvaluator(scope, options, null, mode, exprData, truthyRenderer, falseyRenderer, true); + if (!mode) { + scope.__cache[fullExpression] = evaluator; + } + } + var res = evaluator(); + return res == null ? '' : '' + res; + }; + }, + makeLiveBindingBranchRenderer: function (mode, expression, state) { + var exprData = expressionData(expression); + return function branchRenderer(scope, options, parentSectionNodeList, truthyRenderer, falseyRenderer) { + var nodeList = [this]; + nodeList.expression = expression; + nodeLists.register(nodeList, null, state.directlyNested ? parentSectionNodeList || true : true); + var evaluator = makeEvaluator(scope, options, nodeList, mode, exprData, truthyRenderer, falseyRenderer, state.tag); + var compute = can.compute(evaluator, null, false, evaluator.bindOnce === false ? false : true); + compute.bind('change', can.k); + var value = compute(); + if (typeof value === 'function') { + var old = can.__clearReading(); + value(this); + can.__setReading(old); + } else if (compute.computeInstance.hasDependencies) { + if (state.attr) { + live.simpleAttribute(this, state.attr, compute); + } else if (state.tag) { + live.attributes(this, compute); + } else if (state.text && typeof value !== 'object') { + live.text(this, compute, this.parentNode, nodeList); + } else { + live.html(this, compute, this.parentNode, nodeList); + } + } else { + if (state.attr) { + can.attr.set(this, state.attr, value); + } else if (state.tag) { + live.setAttributes(this, value); + } else if (state.text && typeof value === 'string') { + this.nodeValue = value; + } else if (value) { + elements.replace([this], can.frag(value)); + } + } + compute.unbind('change', can.k); + }; + }, + splitModeFromExpression: function (expression, state) { + expression = can.trim(expression); + var mode = expression.charAt(0); + if ('#/{&^>!'.indexOf(mode) >= 0) { + expression = can.trim(expression.substr(1)); + } else { + mode = null; + } + if (mode === '{' && state.node) { + mode = null; + } + return { + mode: mode, + expression: expression + }; + }, + cleanLineEndings: function (template) { + return template.replace(mustacheLineBreakRegExp, function (whole, returnBefore, spaceBefore, special, expression, spaceAfter, returnAfter, spaceLessSpecial, spaceLessExpression, matchIndex) { + spaceAfter = spaceAfter || ''; + returnBefore = returnBefore || ''; + spaceBefore = spaceBefore || ''; + var modeAndExpression = splitModeFromExpression(expression || spaceLessExpression, {}); + if (spaceLessSpecial || '>{'.indexOf(modeAndExpression.mode) >= 0) { + return whole; + } else if ('^#!/'.indexOf(modeAndExpression.mode) >= 0) { + return special + (matchIndex !== 0 && returnAfter.length ? returnBefore + '\n' : ''); + } else { + return spaceBefore + special + spaceAfter + (spaceBefore.length || matchIndex !== 0 ? returnBefore + '\n' : ''); + } + }); + }, + Options: can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { helpers: data }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }) + }; +var makeEvaluator = core.makeEvaluator, expressionData = core.expressionData, splitModeFromExpression = core.splitModeFromExpression; +module.exports = core; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/mustache_helpers.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/mustache_helpers.js new file mode 100644 index 0000000000..065d1cc135 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/mustache_helpers.js @@ -0,0 +1,141 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/stache/mustache_helpers*/ +var can = require('../../util/util.js'); +var utils = require('./utils.js'); +var live = require('../live/live.js'); +live = live || can.view.live; +var resolve = function (value) { + if (utils.isObserveLike(value) && utils.isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } +}; +var helpers = { + 'each': function (items, options) { + var resolved = resolve(items), result = [], keys, key, i; + if (resolved instanceof can.List) { + return function (el) { + var nodeList = [el]; + nodeList.expression = 'live.list'; + can.view.nodeLists.register(nodeList, null, options.nodeList); + can.view.nodeLists.update(options.nodeList, [el]); + var cb = function (item, index, parentNodeList) { + return options.fn(options.scope.add({ '@index': index }).add(item), options.options, parentNodeList); + }; + live.list(el, items, cb, options.context, el.parentNode, nodeList); + }; + } + var expr = resolved; + if (!!expr && utils.isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ '@index': i }).add(expr[i]))); + } + } else if (utils.isObserveLike(expr)) { + keys = can.Map.keys(expr); + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ '@key': key }).add(expr[key]))); + } + } + return result; + }, + '@index': function (offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr('@index'); + return '' + ((can.isFunction(index) ? index() : index) + offset); + }, + 'if': function (expr, options) { + var value; + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !!resolve(expr); + } + if (value) { + return options.fn(options.scope || this); + } else { + return options.inverse(options.scope || this); + } + }, + 'is': function () { + var lastValue, curValue, options = arguments[arguments.length - 1]; + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + for (var i = 0; i < arguments.length - 1; i++) { + curValue = resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + return options.fn(); + }, + 'eq': function () { + return helpers.is.apply(this, arguments); + }, + 'unless': function (expr, options) { + return helpers['if'].apply(this, [ + can.isFunction(expr) ? can.compute(function () { + return !expr(); + }) : !expr, + options + ]); + }, + 'with': function (expr, options) { + var ctx = expr; + expr = resolve(expr); + if (!!expr) { + return options.fn(ctx); + } + }, + 'log': function (expr, options) { + if (typeof console !== 'undefined' && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + 'data': function (attr) { + var data = arguments.length === 2 ? this : arguments[1]; + return function (el) { + can.data(can.$(el), attr, data || this.context); + }; + } + }; +module.exports = { + registerHelper: function (name, callback) { + helpers[name] = callback; + }, + getHelper: function (name, options) { + var helper = options.attr('helpers.' + name); + if (!helper) { + helper = helpers[name]; + } + if (helper) { + return { fn: helper }; + } + } +}; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/stache.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/stache.js new file mode 100644 index 0000000000..14615b0d8b --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/stache.js @@ -0,0 +1,271 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/stache/stache*/ +var can = require('../../util/util.js'); +var parser = require('../parser/parser.js'); +var target = require('../target/target.js'); +var HTMLSectionBuilder = require('./html_section.js'); +var TextSectionBuilder = require('./text_section.js'); +var mustacheCore = require('./mustache_core.js'); +var mustacheHelpers = require('./mustache_helpers.js'); +var getIntermediateAndImports = require('./intermediate_and_imports.js'); +var viewCallbacks = require('../callbacks/callbacks.js'); +require('../bindings/bindings.js'); +parser = parser || can.view.parser; +viewCallbacks = viewCallbacks || can.view.callbacks; +var svgNamespace = 'http://www.w3.org/2000/svg'; +var namespaces = { + 'svg': svgNamespace, + 'g': svgNamespace + }; +function stache(template) { + if (typeof template === 'string') { + template = mustacheCore.cleanLineEndings(template); + } + var section = new HTMLSectionBuilder(), state = { + node: null, + attr: null, + sectionElementStack: [], + text: false, + namespaceStack: [] + }, makeRendererAndUpdateSection = function (section, mode, stache) { + if (mode === '>') { + section.add(mustacheCore.makeLiveBindingPartialRenderer(stache, state)); + } else if (mode === '/') { + section.endSection(); + if (section instanceof HTMLSectionBuilder) { + state.sectionElementStack.pop(); + } + } else if (mode === 'else') { + section.inverse(); + } else { + var makeRenderer = section instanceof HTMLSectionBuilder ? mustacheCore.makeLiveBindingBranchRenderer : mustacheCore.makeStringBranchRenderer; + if (mode === '{' || mode === '&') { + section.add(makeRenderer(null, stache, copyState())); + } else if (mode === '#' || mode === '^') { + section.startSection(makeRenderer(mode, stache, copyState())); + if (section instanceof HTMLSectionBuilder) { + state.sectionElementStack.push('section'); + } + } else { + section.add(makeRenderer(null, stache, copyState({ text: true }))); + } + } + }, copyState = function (overwrites) { + var lastElement = state.sectionElementStack[state.sectionElementStack.length - 1]; + var cur = { + tag: state.node && state.node.tag, + attr: state.attr && state.attr.name, + directlyNested: state.sectionElementStack.length ? lastElement === 'section' || lastElement === 'custom' : true + }; + return overwrites ? can.simpleExtend(cur, overwrites) : cur; + }, addAttributesCallback = function (node, callback) { + if (!node.attributes) { + node.attributes = []; + } + node.attributes.push(callback); + }; + parser(template, { + start: function (tagName, unary) { + var matchedNamespace = namespaces[tagName]; + if (matchedNamespace && !unary) { + state.namespaceStack.push(matchedNamespace); + } + state.node = { + tag: tagName, + children: [], + namespace: matchedNamespace || can.last(state.namespaceStack) + }; + }, + end: function (tagName, unary) { + var isCustomTag = viewCallbacks.tag(tagName); + if (unary) { + section.add(state.node); + if (isCustomTag) { + addAttributesCallback(state.node, function (scope, options, parentNodeList) { + viewCallbacks.tagHandler(this, tagName, { + scope: scope, + options: options, + subtemplate: null, + templateType: 'stache', + parentNodeList: parentNodeList + }); + }); + } + } else { + section.push(state.node); + state.sectionElementStack.push(isCustomTag ? 'custom' : 'element'); + if (isCustomTag) { + section.startSubSection(); + } + } + state.node = null; + }, + close: function (tagName) { + var matchedNamespace = namespaces[tagName]; + if (matchedNamespace) { + state.namespaceStack.pop(); + } + var isCustomTag = viewCallbacks.tag(tagName), renderer; + if (isCustomTag) { + renderer = section.endSubSectionAndReturnRenderer(); + } + var oldNode = section.pop(); + if (isCustomTag) { + addAttributesCallback(oldNode, function (scope, options, parentNodeList) { + viewCallbacks.tagHandler(this, tagName, { + scope: scope, + options: options, + subtemplate: renderer, + templateType: 'stache', + parentNodeList: parentNodeList + }); + }); + } + state.sectionElementStack.pop(); + }, + attrStart: function (attrName) { + if (state.node.section) { + state.node.section.add(attrName + '="'); + } else { + state.attr = { + name: attrName, + value: '' + }; + } + }, + attrEnd: function (attrName) { + if (state.node.section) { + state.node.section.add('" '); + } else { + if (!state.node.attrs) { + state.node.attrs = {}; + } + state.node.attrs[state.attr.name] = state.attr.section ? state.attr.section.compile(copyState()) : state.attr.value; + var attrCallback = viewCallbacks.attr(attrName); + if (attrCallback) { + if (!state.node.attributes) { + state.node.attributes = []; + } + state.node.attributes.push(function (scope, options) { + attrCallback(this, { + attributeName: attrName, + scope: scope, + options: options + }); + }); + } + state.attr = null; + } + }, + attrValue: function (value) { + var section = state.node.section || state.attr.section; + if (section) { + section.add(value); + } else { + state.attr.value += value; + } + }, + chars: function (text) { + section.add(text); + }, + special: function (text) { + var firstAndText = mustacheCore.splitModeFromExpression(text, state), mode = firstAndText.mode, expression = firstAndText.expression; + if (expression === 'else') { + (state.attr && state.attr.section ? state.attr.section : section).inverse(); + return; + } + if (mode === '!') { + return; + } + if (state.node && state.node.section) { + makeRendererAndUpdateSection(state.node.section, mode, expression); + if (state.node.section.subSectionDepth() === 0) { + state.node.attributes.push(state.node.section.compile(copyState())); + delete state.node.section; + } + } else if (state.attr) { + if (!state.attr.section) { + state.attr.section = new TextSectionBuilder(); + if (state.attr.value) { + state.attr.section.add(state.attr.value); + } + } + makeRendererAndUpdateSection(state.attr.section, mode, expression); + } else if (state.node) { + if (!state.node.attributes) { + state.node.attributes = []; + } + if (!mode) { + state.node.attributes.push(mustacheCore.makeLiveBindingBranchRenderer(null, expression, copyState())); + } else if (mode === '#' || mode === '^') { + if (!state.node.section) { + state.node.section = new TextSectionBuilder(); + } + makeRendererAndUpdateSection(state.node.section, mode, expression); + } else { + throw mode + ' is currently not supported within a tag.'; + } + } else { + makeRendererAndUpdateSection(section, mode, expression); + } + }, + comment: function (text) { + section.add({ comment: text }); + }, + done: function () { + } + }); + return section.compile(); +} +var escMap = { + '\n': '\\n', + '\r': '\\r', + '\u2028': '\\u2028', + '\u2029': '\\u2029' + }; +var esc = function (string) { + return ('' + string).replace(/["'\\\n\r\u2028\u2029]/g, function (character) { + if ('\'"\\'.indexOf(character) >= 0) { + return '\\' + character; + } else { + return escMap[character]; + } + }); +}; +can.view.register({ + suffix: 'stache', + contentType: 'x-stache-template', + fragRenderer: function (id, text) { + return stache(text); + }, + script: function (id, src) { + return 'can.stache("' + esc(src) + '")'; + } +}); +can.view.ext = '.stache'; +can.extend(can.stache, mustacheHelpers); +can.extend(stache, mustacheHelpers); +can.stache.safeString = stache.safeString = function (text) { + return { + toString: function () { + return text; + } + }; +}; +can.stache.async = function (source) { + var iAi = getIntermediateAndImports(source); + var importPromises = can.map(iAi.imports, function (moduleName) { + return can['import'](moduleName); + }); + return can.when.apply(can, importPromises).then(function () { + return stache(iAi.intermediate); + }); +}; +module.exports = stache; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/system.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/system.js new file mode 100644 index 0000000000..40f9529d20 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/system.js @@ -0,0 +1,17 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/stache/system*/ +var stache = require('./stache.js'); +var getIntermediateAndImports = require('./intermediate_and_imports.js'); +function translate(load) { + var intermediateAndImports = getIntermediateAndImports(load.source); + intermediateAndImports.imports.unshift('can/view/stache/stache'); + return 'define(' + JSON.stringify(intermediateAndImports.imports) + ',function(stache){' + 'return stache(' + JSON.stringify(intermediateAndImports.intermediate) + ')' + '})'; +} +module.exports = { translate: translate }; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/text_section.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/text_section.js new file mode 100644 index 0000000000..1e39ecc0dc --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/text_section.js @@ -0,0 +1,95 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/stache/text_section*/ +var can = require('../../util/util.js'); +var live = require('../live/live.js'); +var utils = require('./utils.js'); +live = live || can.view.live; +var TextSectionBuilder = function () { + this.stack = [new TextSection()]; + }, emptyHandler = function () { + }; +can.extend(TextSectionBuilder.prototype, utils.mixins); +can.extend(TextSectionBuilder.prototype, { + startSection: function (process) { + var subSection = new TextSection(); + this.last().add({ + process: process, + truthy: subSection + }); + this.stack.push(subSection); + }, + endSection: function () { + this.stack.pop(); + }, + inverse: function () { + this.stack.pop(); + var falseySection = new TextSection(); + this.last().last().falsey = falseySection; + this.stack.push(falseySection); + }, + compile: function (state) { + var renderer = this.stack[0].compile(); + return function (scope, options) { + var compute = can.compute(function () { + return renderer(scope, options); + }, this, false, true); + compute.bind('change', emptyHandler); + var value = compute(); + if (compute.computeInstance.hasDependencies) { + if (state.attr) { + live.simpleAttribute(this, state.attr, compute); + } else { + live.attributes(this, compute); + } + compute.unbind('change', emptyHandler); + } else { + if (state.attr) { + can.attr.set(this, state.attr, value); + } else { + live.setAttributes(this, value); + } + } + }; + } +}); +var passTruthyFalsey = function (process, truthy, falsey) { + return function (scope, options) { + return process.call(this, scope, options, truthy, falsey); + }; +}; +var TextSection = function () { + this.values = []; +}; +can.extend(TextSection.prototype, { + add: function (data) { + this.values.push(data); + }, + last: function () { + return this.values[this.values.length - 1]; + }, + compile: function () { + var values = this.values, len = values.length; + for (var i = 0; i < len; i++) { + var value = this.values[i]; + if (typeof value === 'object') { + values[i] = passTruthyFalsey(value.process, value.truthy && value.truthy.compile(), value.falsey && value.falsey.compile()); + } + } + return function (scope, options) { + var txt = '', value; + for (var i = 0; i < len; i++) { + value = values[i]; + txt += typeof value === 'string' ? value : value.call(this, scope, options); + } + return txt; + }; + } +}); +module.exports = TextSectionBuilder; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/utils.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/utils.js new file mode 100644 index 0000000000..a79663b558 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/stache/utils.js @@ -0,0 +1,42 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/stache/utils*/ +require('../../util/util.js'); +module.exports = { + isArrayLike: function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, + isObserveLike: function (obj) { + return obj instanceof can.Map || obj && !!obj._get; + }, + emptyHandler: function () { + }, + jsonParse: function (str) { + if (str[0] === '\'') { + return str.substr(1, str.length - 2); + } else if (str === 'undefined') { + return undefined; + } else if (can.global.JSON) { + return JSON.parse(str); + } else { + return eval('(' + str + ')'); + } + }, + mixins: { + last: function () { + return this.stack[this.stack.length - 1]; + }, + add: function (chars) { + this.last().add(chars); + }, + subSectionDepth: function () { + return this.stack.length - 1; + } + } +}; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/target/target.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/target/target.js new file mode 100644 index 0000000000..285fb9cb65 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/target/target.js @@ -0,0 +1,164 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/target/target*/ +var can = require('../../util/util.js'); +var elements = require('../elements.js'); +var processNodes = function (nodes, paths, location) { + var frag = document.createDocumentFragment(); + for (var i = 0, len = nodes.length; i < len; i++) { + var node = nodes[i]; + frag.appendChild(processNode(node, paths, location.concat(i))); + } + return frag; + }, keepsTextNodes = typeof document !== 'undefined' && function () { + var testFrag = document.createDocumentFragment(); + var div = document.createElement('div'); + div.appendChild(document.createTextNode('')); + div.appendChild(document.createTextNode('')); + testFrag.appendChild(div); + var cloned = testFrag.cloneNode(true); + return cloned.childNodes[0].childNodes.length === 2; + }(), clonesWork = typeof document !== 'undefined' && function () { + var a = document.createElement('a'); + a.innerHTML = ''; + var clone = a.cloneNode(true); + return clone.innerHTML === ''; + }(), namespacesWork = typeof document !== 'undefined' && !!document.createElementNS; +var cloneNode = clonesWork ? function (el) { + return el.cloneNode(true); + } : function (node) { + var copy; + if (node.nodeType === 1) { + copy = document.createElement(node.nodeName); + } else if (node.nodeType === 3) { + copy = document.createTextNode(node.nodeValue); + } else if (node.nodeType === 8) { + copy = document.createComment(node.nodeValue); + } else if (node.nodeType === 11) { + copy = document.createDocumentFragment(); + } + if (node.attributes) { + var attributes = can.makeArray(node.attributes); + can.each(attributes, function (node) { + if (node && node.specified) { + copy.setAttribute(node.nodeName, node.nodeValue); + } + }); + } + if (node.childNodes) { + can.each(node.childNodes, function (child) { + copy.appendChild(cloneNode(child)); + }); + } + return copy; + }; +function processNode(node, paths, location) { + var callback, loc = location, nodeType = typeof node, el, p, i, len; + var getCallback = function () { + if (!callback) { + callback = { + path: location, + callbacks: [] + }; + paths.push(callback); + loc = []; + } + return callback; + }; + if (nodeType === 'object') { + if (node.tag) { + if (namespacesWork && node.namespace) { + el = document.createElementNS(node.namespace, node.tag); + } else { + el = document.createElement(node.tag); + } + if (node.attrs) { + for (var attrName in node.attrs) { + var value = node.attrs[attrName]; + if (typeof value === 'function') { + getCallback().callbacks.push({ callback: value }); + } else { + el.setAttribute(attrName, value); + } + } + } + if (node.attributes) { + for (i = 0, len = node.attributes.length; i < len; i++) { + getCallback().callbacks.push({ callback: node.attributes[i] }); + } + } + if (node.children && node.children.length) { + if (callback) { + p = callback.paths = []; + } else { + p = paths; + } + el.appendChild(processNodes(node.children, p, loc)); + } + } else if (node.comment) { + el = document.createComment(node.comment); + if (node.callbacks) { + for (i = 0, len = node.attributes.length; i < len; i++) { + getCallback().callbacks.push({ callback: node.callbacks[i] }); + } + } + } + } else if (nodeType === 'string') { + el = document.createTextNode(node); + } else if (nodeType === 'function') { + if (keepsTextNodes) { + el = document.createTextNode(''); + getCallback().callbacks.push({ callback: node }); + } else { + el = document.createComment('~'); + getCallback().callbacks.push({ + callback: function () { + var el = document.createTextNode(''); + elements.replace([this], el); + return node.apply(el, arguments); + } + }); + } + } + return el; +} +function hydratePath(el, pathData, args) { + var path = pathData.path, callbacks = pathData.callbacks, paths = pathData.paths, callbackData, child = el; + for (var i = 0, len = path.length; i < len; i++) { + child = child.childNodes[path[i]]; + } + for (i = 0, len = callbacks.length; i < len; i++) { + callbackData = callbacks[i]; + callbackData.callback.apply(child, args); + } + if (paths && paths.length) { + for (i = paths.length - 1; i >= 0; i--) { + hydratePath(child, paths[i], args); + } + } +} +function makeTarget(nodes) { + var paths = []; + var frag = processNodes(nodes, paths, []); + return { + paths: paths, + clone: frag, + hydrate: function () { + var cloned = cloneNode(this.clone); + var args = can.makeArray(arguments); + for (var i = paths.length - 1; i >= 0; i--) { + hydratePath(cloned, paths[i], args); + } + return cloned; + } + }; +} +makeTarget.keepsTextNodes = keepsTextNodes; +can.view.target = makeTarget; +module.exports = makeTarget; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/view.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/view.js new file mode 100644 index 0000000000..4db48b0228 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/cjs/view/view.js @@ -0,0 +1,281 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/view*/ +var can = require('../util/util.js'); +var isFunction = can.isFunction, makeArray = can.makeArray, hookupId = 1; +var makeRenderer = function (textRenderer) { + var renderer = function () { + return $view.frag(textRenderer.apply(this, arguments)); + }; + renderer.render = function () { + return textRenderer.apply(textRenderer, arguments); + }; + return renderer; +}; +var checkText = function (text, url) { + if (!text.length) { + throw 'can.view: No template or empty template:' + url; + } +}; +var getRenderer = function (obj, async) { + if (isFunction(obj)) { + var def = can.Deferred(); + return def.resolve(obj); + } + var url = typeof obj === 'string' ? obj : obj.url, suffix = obj.engine && '.' + obj.engine || url.match(/\.[\w\d]+$/), type, el, id; + if (url.match(/^#/)) { + url = url.substr(1); + } + if (el = document.getElementById(url)) { + suffix = '.' + el.type.match(/\/(x\-)?(.+)/)[2]; + } + if (!suffix && !$view.cached[url]) { + url += suffix = $view.ext; + } + if (can.isArray(suffix)) { + suffix = suffix[0]; + } + id = $view.toId(url); + if (url.match(/^\/\//)) { + url = url.substr(2); + url = !window.steal ? url : steal.config().root.mapJoin('' + steal.id(url)); + } + if (window.require) { + if (require.toUrl) { + url = require.toUrl(url); + } + } + type = $view.types[suffix]; + if ($view.cached[id]) { + return $view.cached[id]; + } else if (el) { + return $view.registerView(id, el.innerHTML, type); + } else { + var d = new can.Deferred(); + can.ajax({ + async: async, + url: url, + dataType: 'text', + error: function (jqXHR) { + checkText('', url); + d.reject(jqXHR); + }, + success: function (text) { + checkText(text, url); + $view.registerView(id, text, type, d); + } + }); + return d; + } +}; +var getDeferreds = function (data) { + var deferreds = []; + if (can.isDeferred(data)) { + return [data]; + } else { + for (var prop in data) { + if (can.isDeferred(data[prop])) { + deferreds.push(data[prop]); + } + } + } + return deferreds; +}; +var usefulPart = function (resolved) { + return can.isArray(resolved) && resolved[1] === 'success' ? resolved[0] : resolved; +}; +var $view = can.view = can.template = function (view, data, helpers, callback) { + if (isFunction(helpers)) { + callback = helpers; + helpers = undefined; + } + return $view.renderAs('fragment', view, data, helpers, callback); + }; +can.extend($view, { + frag: function (result, parentNode) { + return $view.hookup($view.fragment(result), parentNode); + }, + fragment: function (result) { + if (typeof result !== 'string' && result.nodeType === 11) { + return result; + } + var frag = can.buildFragment(result, document.body); + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + }, + toId: function (src) { + return can.map(src.toString().split(/\/|\./g), function (part) { + if (part) { + return part; + } + }).join('_'); + }, + toStr: function (txt) { + return txt == null ? '' : '' + txt; + }, + hookup: function (fragment, parentNode) { + var hookupEls = [], id, func; + can.each(fragment.childNodes ? can.makeArray(fragment.childNodes) : fragment, function (node) { + if (node.nodeType === 1) { + hookupEls.push(node); + hookupEls.push.apply(hookupEls, can.makeArray(node.getElementsByTagName('*'))); + } + }); + can.each(hookupEls, function (el) { + if (el.getAttribute && (id = el.getAttribute('data-view-id')) && (func = $view.hookups[id])) { + func(el, parentNode, id); + delete $view.hookups[id]; + el.removeAttribute('data-view-id'); + } + }); + return fragment; + }, + hookups: {}, + hook: function (cb) { + $view.hookups[++hookupId] = cb; + return ' data-view-id=\'' + hookupId + '\''; + }, + cached: {}, + cachedRenderers: {}, + cache: true, + register: function (info) { + this.types['.' + info.suffix] = info; + can[info.suffix] = $view[info.suffix] = function (id, text) { + var renderer, renderFunc; + if (!text) { + renderFunc = function () { + if (!renderer) { + if (info.fragRenderer) { + renderer = info.fragRenderer(null, id); + } else { + renderer = makeRenderer(info.renderer(null, id)); + } + } + return renderer.apply(this, arguments); + }; + renderFunc.render = function () { + var textRenderer = info.renderer(null, id); + return textRenderer.apply(textRenderer, arguments); + }; + return renderFunc; + } + var registeredRenderer = function () { + if (!renderer) { + if (info.fragRenderer) { + renderer = info.fragRenderer(id, text); + } else { + renderer = info.renderer(id, text); + } + } + return renderer.apply(this, arguments); + }; + if (info.fragRenderer) { + return $view.preload(id, registeredRenderer); + } else { + return $view.preloadStringRenderer(id, registeredRenderer); + } + }; + }, + types: {}, + ext: '.ejs', + registerScript: function (type, id, src) { + return 'can.view.preloadStringRenderer(\'' + id + '\',' + $view.types['.' + type].script(id, src) + ');'; + }, + preload: function (id, renderer) { + var def = $view.cached[id] = new can.Deferred().resolve(function (data, helpers) { + return renderer.call(data, data, helpers); + }); + def.__view_id = id; + $view.cachedRenderers[id] = renderer; + return renderer; + }, + preloadStringRenderer: function (id, stringRenderer) { + return this.preload(id, makeRenderer(stringRenderer)); + }, + render: function (view, data, helpers, callback) { + return can.view.renderAs('string', view, data, helpers, callback); + }, + renderTo: function (format, renderer, data, helpers) { + return (format === 'string' && renderer.render ? renderer.render : renderer)(data, helpers); + }, + renderAs: function (format, view, data, helpers, callback) { + if (isFunction(helpers)) { + callback = helpers; + helpers = undefined; + } + var deferreds = getDeferreds(data); + var reading, deferred, dataCopy, async, response; + if (deferreds.length) { + deferred = new can.Deferred(); + dataCopy = can.extend({}, data); + deferreds.push(getRenderer(view, true)); + can.when.apply(can, deferreds).then(function (resolved) { + var objs = makeArray(arguments), renderer = objs.pop(), result; + if (can.isDeferred(data)) { + dataCopy = usefulPart(resolved); + } else { + for (var prop in data) { + if (can.isDeferred(data[prop])) { + dataCopy[prop] = usefulPart(objs.shift()); + } + } + } + result = can.view.renderTo(format, renderer, dataCopy, helpers); + deferred.resolve(result, dataCopy); + if (callback) { + callback(result, dataCopy); + } + }, function () { + deferred.reject.apply(deferred, arguments); + }); + return deferred; + } else { + reading = can.__clearReading(); + async = isFunction(callback); + deferred = getRenderer(view, async); + if (reading) { + can.__setReading(reading); + } + if (async) { + response = deferred; + deferred.then(function (renderer) { + callback(data ? can.view.renderTo(format, renderer, data, helpers) : renderer); + }); + } else { + if (deferred.state() === 'resolved' && deferred.__view_id) { + var currentRenderer = $view.cachedRenderers[deferred.__view_id]; + return data ? can.view.renderTo(format, currentRenderer, data, helpers) : currentRenderer; + } else { + deferred.then(function (renderer) { + response = data ? can.view.renderTo(format, renderer, data, helpers) : renderer; + }); + } + } + return response; + } + }, + registerView: function (id, text, type, def) { + var info = typeof type === 'object' ? type : $view.types[type || $view.ext], renderer; + if (info.fragRenderer) { + renderer = info.fragRenderer(id, text); + } else { + renderer = makeRenderer(info.renderer(id, text)); + } + def = def || new can.Deferred(); + if ($view.cache) { + $view.cached[id] = def; + def.__view_id = id; + $view.cachedRenderers[id] = renderer; + } + return def.resolve(renderer); + } +}); +module.exports = can; diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/readme.md b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/readme.md new file mode 100644 index 0000000000..d13f71bef6 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/readme.md @@ -0,0 +1,7 @@ +[![Build Status](https://travis-ci.org/bitovi/canjs.png?branch=master)](https://travis-ci.org/bitovi/canjs) + +CanJS is a MIT-licensed, client-side, JavaScript framework that makes building +rich web applications easy. + +__This is the distributable repository for the downloadable files. Go to the [CanJS repository](https://github.com/bitovi/canjs) for issues and development.__ + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/can.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/can.js new file mode 100644 index 0000000000..3a768ce898 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/can.js @@ -0,0 +1,13 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#can*/ +steal('can/util', 'can/control/route', 'can/model', + 'can/view/mustache', 'can/component', function(can) { + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/component/component.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/component/component.js new file mode 100644 index 0000000000..69dd1aaaaf --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/component/component.js @@ -0,0 +1,539 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#component/component*/ +// # can/component/component.js +// +// This implements the `can.Component` which allows you to create widgets +// that use a template, a view-model and custom tags. +// +// `can.Component` implements most of it's functionality in the `can.Component.setup` +// and the `can.Component.prototype.setup` functions. +// +// `can.Component.setup` prepares everything needed by the `can.Component.prototype.setup` +// to hookup the component. + +steal("can/util", "can/view/callbacks","can/view/elements.js","can/control", "can/observe", "can/view/mustache", "can/view/bindings", function (can, viewCallbacks, elements) { + // ## Helpers + // Attribute names to ignore for setting viewModel values. + var ignoreAttributesRegExp = /^(dataViewId|class|id)$/i, + paramReplacer = /\{([^\}]+)\}/g; + + /** + * @add can.Component + */ + var Component = can.Component = can.Construct.extend( + + // ## Static + /** + * @static + */ + + { + // ### setup + // + // When a component is extended, this sets up the component's internal constructor + // functions and templates for later fast initialization. + setup: function () { + can.Construct.setup.apply(this, arguments); + + // When `can.Component.setup` function is ran for the first time, `can.Component` doesn't exist yet + // which ensures that the following code is ran only in constructors that extend `can.Component`. + if (can.Component) { + var self = this, + scope = this.prototype.scope || this.prototype.viewModel; + + // Define a control using the `events` prototype property. + this.Control = ComponentControl.extend( this.prototype.events ); + + // Look to convert `scope` to a Map constructor function. + if (!scope || (typeof scope === "object" && ! (scope instanceof can.Map) ) ) { + // If scope is an object, use that object as the prototype of an extended + // Map constructor function. + // A new instance of that Map constructor function will be created and + // set a the constructor instance's viewModel. + this.Map = can.Map.extend(scope || {}); + } + else if (scope.prototype instanceof can.Map) { + // If viewModel is a can.Map constructor function, just use that. + this.Map = scope; + } + + // Look for default `@` values. If a `@` is found, these + // attributes string values will be set and 2-way bound on the + // component instance's viewModel. + this.attributeScopeMappings = {}; + can.each(this.Map ? this.Map.defaults : {}, function (val, prop) { + if (val === "@") { + self.attributeScopeMappings[prop] = prop; + } + }); + + // Convert the template into a renderer function. + if (this.prototype.template) { + // If `this.prototype.template` is a function create renderer from it by + // wrapping it with the anonymous function that will pass it the arguments, + // otherwise create the render from the string + if (typeof this.prototype.template === "function") { + var temp = this.prototype.template; + this.renderer = function () { + return can.view.frag(temp.apply(null, arguments)); + }; + } else { + this.renderer = can.view.mustache(this.prototype.template); + } + } + + // Register this component to be created when its `tag` is found. + can.view.tag(this.prototype.tag, function (el, options) { + new self(el, options); + }); + } + + } + }, { + // ## Prototype + /** + * @prototype + */ + // ### setup + // When a new component instance is created, setup bindings, render the template, etc. + setup: function (el, hookupOptions) { + // Setup values passed to component + var initialScopeData = {}, + component = this, + // If a template is not provided, we fall back to + // dynamic scoping regardless of settings. + lexicalContent = ((typeof this.leakScope === "undefined" ? + false : + !this.leakScope) && + this.template), + twoWayBindings = {}, + scope = this.scope || this.viewModel, + // tracks which viewModel property is currently updating + viewModelPropertyUpdates = {}, + // the object added to the viewModel + componentScope, + frag, + // an array of teardown stuff that should happen when the element is removed + teardownFunctions = [], + callTeardownFunctions = function(){ + for(var i = 0, len = teardownFunctions.length ; i < len; i++) { + teardownFunctions[i](); + } + }; + + // ## Scope + + // Add viewModel prototype properties marked with an "@" to the `initialScopeData` object + can.each(this.constructor.attributeScopeMappings, function (val, prop) { + initialScopeData[prop] = el.getAttribute(can.hyphenate(val)); + }); + + // Get the value in the viewModel for each attribute + // the hookup should probably happen after? + can.each(can.makeArray(el.attributes), function (node, index) { + var name = can.camelize(node.nodeName.toLowerCase()), + value = node.value; + + //!steal-remove-start + // user tried to pass something like id="{foo}", so give them a good warning + if(ignoreAttributesRegExp.test(name) && value[0] === "{" && value[value.length-1] === "}") { + can.dev.warn("can/component: looks like you're trying to pass "+name+" as an attribute into a component, "+ + "but it is not a supported attribute"); + } + //!steal-remove-end + + // Ignore attributes already present in the ScopeMappings. + if (component.constructor.attributeScopeMappings[name] || ignoreAttributesRegExp.test(name) || viewCallbacks.attr(node.nodeName)) { + return; + } + // Only setup bindings if attribute looks like `foo="{bar}"` + if(value[0] === "{" && value[value.length-1] === "}") { + value = value.substr(1, value.length - 2 ); + } else { + // Legacy template types will crossbind "foo=bar" + if(hookupOptions.templateType !== "legacy") { + initialScopeData[name] = value; + return; + } + } + // Cross-bind the value in the scope to this + // component's viewModel + var computeData = hookupOptions.scope.computeData(value, { + args: [] + }), + compute = computeData.compute; + + // bind on this, check it's value, if it has dependencies + var handler = function (ev, newVal) { + // setup counter to prevent updating the scope with viewModel changes caused by scope updates. + viewModelPropertyUpdates[name] = (viewModelPropertyUpdates[name] || 0 )+1; + + componentScope.attr(name, newVal); + can.batch.afterPreviousEvents(function(){ + --viewModelPropertyUpdates[name]; + }); + }; + + // Compute only returned if bindable + compute.bind("change", handler); + + // Set the value to be added to the viewModel + initialScopeData[name] = compute(); + + // We don't need to listen to the compute `change` if it doesn't have any dependencies + if (!compute.computeInstance.hasDependencies) { + compute.unbind("change", handler); + } else { + // Make sure we unbind (there's faster ways of doing this) + teardownFunctions.push(function () { + compute.unbind("change", handler); + }); + // Setup the two-way binding + twoWayBindings[name] = computeData; + } + + }); + if (this.constructor.Map) { + // If `Map` property is set on the constructor use it to wrap the `initialScopeData` + componentScope = new this.constructor.Map(initialScopeData); + } else if (scope instanceof can.Map) { + // If `this.scope` is instance of `can.Map` assign it to the `componentScope` + componentScope = scope; + } else if (can.isFunction(scope)) { + // If `this.viewModel` is a function, call the function and + var scopeResult = scope.call(this, initialScopeData, hookupOptions.scope, el); + + if (scopeResult instanceof can.Map) { + // If the function returns a can.Map, use that as the viewModel + componentScope = scopeResult; + } else if (scopeResult.prototype instanceof can.Map) { + // If `scopeResult` is of a `can.Map` type, use it to wrap the `initialScopeData` + componentScope = new scopeResult(initialScopeData); + } else { + // Otherwise extend `can.Map` with the `scopeResult` and initialize it with the `initialScopeData` + componentScope = new(can.Map.extend(scopeResult))(initialScopeData); + } + + } + + // ## Two way bindings + + // Object to hold the bind handlers so we can tear them down + var handlers = {}; + // Setup reverse bindings + can.each(twoWayBindings, function (computeData, prop) { + handlers[prop] = function (ev, newVal) { + // Check that this property is not being changed because + // it's scope value just changed + if (!viewModelPropertyUpdates[prop]) { + //console.log("updating view.scope ",prop,"from", componentScope._cid); + computeData.compute(newVal); + } + }; + componentScope.bind(prop, handlers[prop]); + }); + // Setup the attributes bindings + if (!can.isEmptyObject(this.constructor.attributeScopeMappings) || hookupOptions.templateType !== "legacy") { + // Bind on the `attributes` event and update the viewModel. + can.bind.call(el, "attributes", function (ev) { + // Convert attribute name from the `attribute-name` to the `attributeName` format. + var camelized = can.camelize(ev.attributeName); + if (!twoWayBindings[camelized] && !ignoreAttributesRegExp.test(camelized) ) { + // If there is a mapping for this attribute, update the `componentScope` attribute + componentScope.attr(camelized, el.getAttribute(ev.attributeName)); + } + }); + + } + + // Set `componentScope` to `this.viewModel` and set it to the element's `data` object as a `viewModel` property + this.scope = this.viewModel = componentScope; + can.data(can.$(el), "scope", this.scope); + can.data(can.$(el), "viewModel", this.scope); + + // Create a real Scope object out of the viewModel property + var renderedScope = lexicalContent ? + this.scope : + hookupOptions.scope.add(this.scope), + options = { + helpers: {} + }; + + // ## Helpers + + // Setup helpers to callback with `this` as the component + can.each(this.helpers || {}, function (val, prop) { + if (can.isFunction(val)) { + options.helpers[prop] = function () { + return val.apply(componentScope, arguments); + }; + } + }); + + + // Teardown reverse bindings when the element is removed + teardownFunctions.push(function(){ + can.each(handlers, function (handler, prop) { + componentScope.unbind(prop, handlers[prop]); + }); + }); + + // ## `events` control + + // Create a control to listen to events + this._control = new this.constructor.Control(el, { + // Pass the viewModel to the control so we can listen to it's changes from the controller. + scope: this.scope, + viewModel: this.scope + }); + + // If control has a 'destroy' event, unbind the properties after its called #1415 + if(this._control && this._control.destroy){ + var oldDestroy = this._control.destroy; + this._control.destroy = function(){ + oldDestroy.apply(this, arguments); + callTeardownFunctions(); + }; + this._control.on(); + } else { + can.bind.call(el, "removed", function () { + callTeardownFunctions(); + }); + } + + // ## Rendering + + // Keep a nodeList so we can kill any directly nested nodeLists within this component + var nodeList = can.view.nodeLists.register([], undefined, true); + teardownFunctions.push(function(){ + can.view.nodeLists.unregister(nodeList); + }); + + // If this component has a template (that we've already converted to a renderer) + if (this.constructor.renderer) { + // If `options.tags` doesn't exist set it to an empty object. + if (!options.tags) { + options.tags = {}; + } + + // We need be alerted to when a element is rendered so we can put the original contents of the widget in its place + options.tags.content = function contentHookup(el, rendererOptions) { + // First check if there was content within the custom tag + // otherwise, render what was within , the default code + var subtemplate = hookupOptions.subtemplate || rendererOptions.subtemplate; + + if (subtemplate) { + + // `rendererOptions.options` is a viewModel of helpers where `` was found, so + // the right helpers should already be available. + // However, `_tags.content` is going to point to this current content callback. We need to + // remove that so it will walk up the chain + + delete options.tags.content; + + // By default, light dom scoping is + // dynamic. This means that any `{{foo}}` + // bindings inside the "light dom" content of + // the component will have access to the + // internal viewModel. This can be overridden to be + // lexical with the lexicalContent + // option, + var opts = !lexicalContent || + subtemplate !== hookupOptions.subtemplate ? + rendererOptions : + hookupOptions; + + if(rendererOptions.parentNodeList) { + var frag = subtemplate( opts.scope, opts.options, rendererOptions.parentNodeList ); + elements.replace([el], frag); + } else { + can.view.live.replace([el], subtemplate( opts.scope, opts.options )); + } + + // Restore the content tag so it could potentially be used again (as in lists) + options.tags.content = contentHookup; + } + }; + // Render the component's template + frag = this.constructor.renderer(renderedScope, hookupOptions.options.add(options), nodeList); + } else { + // Otherwise render the contents between the + if(hookupOptions.templateType === "legacy") { + frag = can.view.frag(hookupOptions.subtemplate ? hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options)) : ""); + } else { + // we need to be the parent ... or we need to + frag = hookupOptions.subtemplate ? + hookupOptions.subtemplate(renderedScope, hookupOptions.options.add(options), nodeList) : + document.createDocumentFragment(); + } + + } + // Append the resulting document fragment to the element + can.appendChild(el, frag); + + // update the nodeList with the new children so the mapping gets applied + can.view.nodeLists.update(nodeList, el.childNodes); + } + }); + + var ComponentControl = can.Control.extend({ + // Change lookup to first look in the viewModel. + _lookup: function (options) { + return [options.scope, options, window]; + }, + _action: function (methodName, options, controlInstance ) { + var hasObjectLookup, readyCompute; + + paramReplacer.lastIndex = 0; + + hasObjectLookup = paramReplacer.test(methodName); + + // If we don't have options (a `control` instance), we'll run this + // later. + if( !controlInstance && hasObjectLookup) { + return; + } else if( !hasObjectLookup ) { + return can.Control._action.apply(this, arguments); + } else { + // We have `hasObjectLookup` and `controlInstance`. + + readyCompute = can.compute(function(){ + var delegate; + + // Set the delegate target and get the name of the event we're listening to. + var name = methodName.replace(paramReplacer, function(matched, key){ + var value; + + // If we are listening directly on the `viewModel` set it as a delegate target. + if(key === "scope" || key === "viewModel") { + delegate = options.scope; + return ""; + } + + // Remove `scope.` from the start of the key and read the value from the `viewModel`. + key = key.replace(/^(scope|^viewModel)\./,""); + value = can.compute.read(options.scope, key.split("."), {isArgument: true}).value; + + // If `value` is undefined use `can.getObject` to get the value. + if(value === undefined) { + value = can.getObject(key); + } + + // If `value` is a string we just return it, otherwise we set it as a delegate target. + if(typeof value === "string") { + return value; + } else { + delegate = value; + return ""; + } + + }); + + // Get the name of the `event` we're listening to. + var parts = name.split(/\s+/g), + event = parts.pop(); + + // Return everything needed to handle the event we're listening to. + return { + processor: this.processors[event] || this.processors.click, + parts: [name, parts.join(" "), event], + delegate: delegate || undefined + }; + + }, this); + + // Create a handler function that we'll use to handle the `change` event on the `readyCompute`. + var handler = function(ev, ready){ + controlInstance._bindings.control[methodName](controlInstance.element); + controlInstance._bindings.control[methodName] = ready.processor( + ready.delegate || controlInstance.element, + ready.parts[2], ready.parts[1], methodName, controlInstance); + }; + + readyCompute.bind("change", handler); + + controlInstance._bindings.readyComputes[methodName] = { + compute: readyCompute, + handler: handler + }; + + return readyCompute(); + } + } + }, + // Extend `events` with a setup method that listens to changes in `viewModel` and + // rebinds all templated event handlers. + { + setup: function (el, options) { + this.scope = options.scope; + this.viewModel = options.viewModel; + return can.Control.prototype.setup.call(this, el, options); + }, + off: function(){ + // If `this._bindings` exists we need to go through it's `readyComputes` and manually + // unbind `change` event listeners set by the controller. + if( this._bindings ) { + can.each(this._bindings.readyComputes || {}, function (value) { + value.compute.unbind("change", value.handler); + }); + } + // Call `can.Control.prototype.off` function on this instance to cleanup the bindings. + can.Control.prototype.off.apply(this, arguments); + this._bindings.readyComputes = {}; + } + }); + + /** + * @description Read and write a component element's viewModel. + * + * @function can.viewModel + * @parent can.util + * @signature `can.viewModel(el[, attr[, value]])` + * @param {HTMLElement|NodeList} el can.Component element to get viewModel of. + * @param {String} [attr] Attribute name to access. + * @param {*} [val] Value to write to the viewModel attribute. + * + * @return {*} If only one argument, returns the viewModel itself. If two + * arguments are given, returns the attribute value. If three arguments + * are given, returns the element itself after assigning the value (for + * chaining). + * + * @body + * + * `can.viewModel` can be used to directly access a [can.Component]'s + * viewModel. Depending on how it's called, it can be used to get the + * entire viewModel object, read a specific property from it, or write a + * property. The property read and write features can be seen as a + * shorthand for code such as `$("my-thing").viewModel().attr("foo", val);` + * + * If using jQuery, this function is accessible as a jQuery plugin, + * with one fewer argument to the call. For example, + * `$("my-element").viewModel("name", "Whatnot");` + * + */ + // Define the `can.viewModel` function that can be used to retrieve the + // `viewModel` from the element + + + var $ = can.$; + + // If `$` has an `fn` object create the + // `scope` plugin that returns the scope object. + if ($.fn) { + $.fn.scope = $.fn.viewModel = function () { + // Just use `can.scope` as the base for this function instead + // of repeating ourselves. + return can.viewModel.apply(can, [this].concat(can.makeArray(arguments))); + }; + } + + return Component; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/compute/compute.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/compute/compute.js new file mode 100644 index 0000000000..8499c2f6d3 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/compute/compute.js @@ -0,0 +1,101 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#compute/compute*/ +/* jshint maxdepth:7*/ + +// # can.compute +// +// `can.compute` allows creation of observable values +// from the result of a funciton. Any time an observable +// value that the function depends on changes, the +// function automatically updates. This enables creating +// observable data that relies on other sources, potentially +// multiple different ones. For instance, a `can.compute` is +// able to: +// - Combine a first and last name into a full name and update when either changes +// - Calculate the absolute value of an observable number, updating any time the observable number does +// - Specify complicated behavior for getting and setting a value, as well as how to handle changes + +steal('can/util', 'can/util/bind', 'can/util/batch', 'can/compute/proto_compute.js', function (can, bind) { + + + + can.compute = function (getterSetter, context, eventName, bindOnce) { + + var internalCompute = new can.Compute(getterSetter, context, eventName, bindOnce); + + var compute = function(val) { + if(arguments.length) { + return internalCompute.set(val); + } + + return internalCompute.get(); + }; + + compute.bind = can.proxy(internalCompute.bind, internalCompute); + compute.unbind = can.proxy(internalCompute.unbind, internalCompute); + compute.isComputed = internalCompute.isComputed; + compute.clone = function(ctx) { + if(typeof getterSetter === 'function') { + context = ctx; + } + + return can.compute(getterSetter, context, ctx, bindOnce); + }; + + compute.computeInstance = internalCompute; + + return compute; + }; + // Instead of calculating whether anything is listening every time, + // use a function to do nothing (which may be overwritten) + var k = function () {}; + // A list of temporarily bound computes + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + // Binds computes for a moment to retain their value and prevent caching + can.compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + + // Whether a compute is truthy + can.compute.truthy = function (compute) { + return can.compute(function () { + var res = compute(); + if (typeof res === 'function') { + res = res(); + } + return !!res; + }); + }; + can.compute.async = function(initialValue, asyncComputer, context){ + return can.compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + + + can.compute.read = can.Compute.read; + + + can.compute.set = can.Compute.set; + + return can.compute; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/compute/get_value_and_bind.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/compute/get_value_and_bind.js new file mode 100644 index 0000000000..01affb52e4 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/compute/get_value_and_bind.js @@ -0,0 +1,162 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#compute/get_value_and_bind*/ +steal("can/util", function(){ + + // # can/compute/observe + // Exports a function that calls a function and binds to any observables it reads. + // When any of those observables change, a callback function is called. + // + // And ... + // + // Adds two main methods to can: + // + // - can.__observe - All other observes call this method to be visible to computed functions. + // - can.__notObserve - Returns a function that can not be observed. + // + // ## observe + // This module's export: + // - `func` - A function to read and and bind to all observables it might read. + // - `context` - What `func` should be called with. + // - `oldObserved` - A map of observable / event pairs this function used to be listening to. + // - `onchanged` - What to callback whenever any of the observables changed. + function observe(func, context, oldInfo, onchanged) { + // Call the function, get the value as well as the observed objects and events + var info = getValueAndObserved(func, context), + // The objects-event pairs that must be bound to + newObserveSet = info.observed, + oldObserved = oldInfo.observed; + // Go through what needs to be observed. + if(info.names !== oldInfo.names) { + bindNewSet(oldObserved, newObserveSet, onchanged); + unbindOldSet(oldObserved, onchanged); + } + // set ready after all previous events have fired + can.batch.afterPreviousEvents(function(){ + info.ready = true; + }); + + return info; + } + + // The top of this is what observables and events the current observer + // should listen to. + + // ## Observe Helpers + // + // The following methods are used to call a function that relies on + // observable data and to track the observable events which should + // be listened to when changes occur. + // To do this, `can.__observe(observable, event)` is called to + // "broadcast" the corresponding event on each read. + // + // ### Observed + // + // An "Observed" is an object of observable objects and events that + // a function relies on. These objects and events must be listened to + // in order to determine when to check a function for updates. + // This looks like the following: + // + // { + // "map1|first": {obj: map, event: "first"}, + // "map1|last" : {obj: map, event: "last"} + // } + // + // Each object-event pair is mapped so no duplicates will be listed. + var observedStack = []; + + // returns if some function is in the process of recording observes. + can.__isRecordingObserves = function(){ + return observedStack.length; + }; + + can.__observe = can.__reading = function (obj, event) { + if (observedStack.length) { + var name = obj._cid + '|' + event, + top = observedStack[observedStack.length-1]; + + top.names += name; + top.observed[name] = { + obj: obj, + event: event + "" + }; + } + }; + + + // protects a function from being observed. + can.__notObserve = function(fn){ + return function(){ + var previousReads = can.__clearObserved(); + var res = fn.apply(this, arguments); + can.__setObserved(previousReads); + return res; + }; + }; + + // The following methods + can.__clearObserved = can.__clearReading = function () { + if (observedStack.length) { + var ret = observedStack[observedStack.length-1]; + observedStack[observedStack.length-1] = {observed: {}}; + return ret; + } + }; + + can.__setObserved = can.__setReading = function (o) { + if (observedStack.length) { + observedStack[observedStack.length-1] = o; + } + }; + + can.__addObserved = can.__addReading = function(o){ + if (observedStack.length) { + can.simpleExtend(observedStack[observedStack.length-1], o); + } + }; + + var getValueAndObserved = function (func, self) { + + observedStack.push({names: "", observed: {}}); + + var value = func.call(self); + var stackItem = observedStack.pop(); + stackItem.value = value; + return stackItem; + }; + + // This will not be optimized. + var bindNewSet = function(oldObserved, newObserveSet, onchanged){ + for(var name in newObserveSet ) { + bindOrPreventUnbinding(oldObserved, newObserveSet, name, onchanged); + } + }; + + // This will be optimized. + var bindOrPreventUnbinding = function(oldObserved, newObserveSet, name, onchanged){ + if( oldObserved[name] ) { + delete oldObserved[name]; + } else { + var obEv = newObserveSet[name]; + obEv.obj.bind(obEv.event, onchanged); + } + }; + + var unbindOldSet = function(oldObserved, onchanged){ + for (var name in oldObserved) { + var obEv = oldObserved[name]; + obEv.obj.unbind(obEv.event, onchanged); + } + }; + + + return observe; + +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/compute/proto_compute.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/compute/proto_compute.js new file mode 100644 index 0000000000..a43dbf25f8 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/compute/proto_compute.js @@ -0,0 +1,434 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#compute/proto_compute*/ +steal('can/util', 'can/util/bind', 'can/compute/read.js','can/compute/get_value_and_bind.js','can/util/batch', function (can, bind, read, getValueAndBind) { + + // # can/compute/proto_compute (aka can.Compute) + // + // A prototype based version of can.compute. `can.compute` uses this internally. + // + // can.Computes have public `.get`, `.set`, `.on`, and `.off` methods that call + // internally configured methods: + // + // - `_on(updater)` - Called the first time the compute is bound. This should bind to + // any source observables. When any of the source observables have changed, it should call + // `updater(newVal, oldVal, batchNum)`. + // + // - `_off(updater)` - Called when the compute has no more event handlers. This should unbind to any source observables. + // - `_get` - Called to get the current value of the compute. + // - `_set` - Called to set the value of the compute. + // + // Other internal flags and values: + // - `value` - the cached value + // - `_setUpdates` - if calling `_set` will have updated the cached value itself so `_get` does not need to be called. + // - `_canObserve` - if this compute can be observed. + // - `hasDependencies` - if this compute has source observable values. + + // A helper to trigger an event when a value changes + var updateOnChange = function(compute, newValue, oldValue, batchNum){ + // Only trigger event when value has changed + if (newValue !== oldValue) { + can.batch.trigger(compute, batchNum ? {type: "change", batchNum: batchNum} : 'change', [ + newValue, + oldValue + ]); + } + }; + + // A helper that creates an ._on and ._off function that + // will bind on source observables and update the value of the compute. + var setupComputeHandlers = function(compute, func, context, singleBind) { + var readInfo, + onchanged, + batchNum; + singleBind = false; + return { + // Set up handler for when the compute changes + on: function(updater){ + var self = this; + if(!onchanged) { + onchanged = function(ev){ + // only run this + if (readInfo.ready && compute.bound && (ev.batchNum === undefined || ev.batchNum !== batchNum) ) { + // Keep the old value + var oldValue = readInfo.value, + newValue; + // Get the new value + if(singleBind) { + newValue = func.call(context); + readInfo.value = newValue; + } else { + readInfo = getValueAndBind(func, context, readInfo, onchanged); + newValue = readInfo.value; + } + + // Call the updater with old and new values + self.updater(newValue, oldValue, ev.batchNum); + batchNum = batchNum = ev.batchNum; + } + }; + } + + readInfo = getValueAndBind(func, context, {observed: {}}, onchanged); + + if(singleBind) { + // prevent other calls from being observed; + func = can.__notObserve(func); + } + + compute.value = readInfo.value; + compute.hasDependencies = !can.isEmptyObject(readInfo.observed); + }, + // Remove handler for the compute + off: function(updater){ + for (var name in readInfo.observed) { + var ob = readInfo.observed[name]; + ob.obj.unbind(ob.event, onchanged); + } + } + }; + }; + + // Instead of calculating whether anything is listening every time, + // use a function to do nothing (which may be overwritten) + var k = function () {}; + + var updater = function(newVal, oldVal, batchNum) { + this.value = newVal; + updateOnChange(this, newVal, oldVal, batchNum); + }, + + asyncGet = function(fn, context, lastSetValue) { + return function() { + return fn.call(context, lastSetValue.get()); + }; + }, + + asyncUpdater = function(context, oldUpdater) { + return function(newVal) { + if(newVal !== undefined) { + oldUpdater(newVal, context.value); + } + }; + }; + + // ## can.Compute + // Checks the arguments and calls different setup methods + can.Compute = function(getterSetter, context, eventName, bindOnce) { + var args = []; + + for(var i = 0, arglen = arguments.length; i < arglen; i++) { + args[i] = arguments[i]; + } + + var contextType = typeof args[1]; + + if (typeof args[0] === 'function') { + this._setupGetterSetterFn(args[0], args[1], args[2], args[3]); + } else if (args[1]) { + if (contextType === 'string') { + // `can.compute(object, propertyName[, eventName])` + this._setupContextString(args[0], args[1], args[2]); + } else if(contextType === 'function') { + // `can.compute(initialValue, setter)` + this._setupContextFunction(args[0], args[1], args[2]); + } else { + //`new can.Compute(initialValue, {})` + if(args[1] && args[1].fn) { + this._setupAsyncCompute(args[0], args[1]); + } else { + this._setupContextSettings(args[0], args[1]); + } + + } + } else { + // `can.compute(initialValue)` + this._setupInitialValue(args[0]); + } + + this._args = args; + + this.isComputed = true; + can.cid(this, 'compute'); + }; + + can.simpleExtend(can.Compute.prototype, { + //TODO: verify "this" is the instance of a compute + _bindsetup: can.__notObserve(function () { + this.bound = true; + this._on(this.updater); + }), + + _bindteardown: function () { + this._off(this.updater); + this.bound = false; + }, + + bind: can.bindAndSetup, + unbind: can.unbindAndTeardown, + + clone: function(context) { + if(context && typeof this._args[0] === 'function') { + this._args[1] = context; + } else if(context) { + this._args[2] = context; + } + + return new can.Compute(this._args[0], this._args[1], this._args[2], this._args[3]); + }, + + _on: k, + _off: k, + // Returns the cached value if `bound`, otherwise, returns + // the _get value. + get: function() { + // Another compute may bind to this `computed` + if(can.__isRecordingObserves() && this._canObserve !== false) { + + // Tell the compute to listen to change on this computed + // Use `can.__observe` to allow other compute to listen + // for a change on this `computed` + can.__observe(this, 'change'); + // We are going to bind on this compute. + // If we are not bound, we should bind so that + // we don't have to re-read to get the value of this compute. + if (!this.bound) { + can.Compute.temporarilyBind(this); + } + } + // If computed is bound, use the cached value + if (this.bound) { + return this.value; + } else { + return this._get(); + } + }, + _get: function() { + return this.value; + }, + // + set: function(newVal) { + // Save a reference to the old value + var old = this.value; + // Setter may return the value if setter + // is for a value maintained exclusively by this compute. + var setVal = this._set(newVal, old); + + + + // If the computed function has dependencies, + // return the current value + if (this.hasDependencies) { + // If set can update the value, + // just return the updated value. + if(this._setUpdates) { + return this.value; + } + + return this._get(); + } + // Setting may not fire a change event, in which case + // the value must be read + if (setVal === undefined) { + this.value = this._get(); + } else { + this.value = setVal; + } + // Fire the change + updateOnChange(this, this.value, old); + return this.value; + }, + + _set: function(newVal) { + return this.value = newVal; + }, + + updater: updater, + + _computeFn: function(newVal) { + if(arguments.length) { + return this.set(newVal); + } + + return this.get(); + }, + + toFunction: function() { + return can.proxy(this._computeFn, this); + }, + + _setupGetterSetterFn: function(getterSetter, context, eventName, bindOnce) { + this._set = can.proxy(getterSetter, context); + this._get = can.proxy(getterSetter, context); + this._canObserve = eventName === false ? false : true; + + var handlers = setupComputeHandlers(this, getterSetter, context || this, bindOnce); + this._on = handlers.on; + this._off = handlers.off; + + }, + // can.compute(input, value, "change"); + _setupContextString: function(target, propertyName, eventName) { + var isObserve = can.isMapLike( target ), + self = this, + handler = function(ev, newVal,oldVal) { + self.updater(newVal, oldVal, ev.batchNum); + }; + + if(isObserve) { + this.hasDependencies = true; + this._get = function() { + return target.attr(propertyName); + }; + this._set = function(val) { + target.attr(propertyName, val); + }; + this._on = function(update) { + target.bind(eventName || propertyName, handler); + // Set the cached value + this.value = this._get(); + }; + this._off = function() { + return target.unbind(eventName || propertyName, handler); + }; + } else { + this._get = can.proxy(this._get, target); + this._set = can.proxy(this._set, target); + } + }, + + _setupContextFunction: function(initialValue, setter, eventName) { + this.value = initialValue; + this._set = setter; + can.simpleExtend(this, eventName); + }, + // new can.Compute(5,{get, set, on, off}) + _setupContextSettings: function(initialValue, settings) { + + this.value = initialValue; + + this._set = settings.set ? can.proxy(settings.set, settings) : this._set; + this._get = settings.get ? can.proxy(settings.get, settings) : this._get; + + // This allows updater to be called without any arguments. + // selfUpdater flag can be set by things that want to call updater themselves. + if(!settings.__selfUpdater) { + var self = this, + oldUpdater = this.updater; + this.updater = function() { + oldUpdater.call(self, self._get(), self.value); + }; + } + + + this._on = settings.on ? settings.on : this._on; + this._off = settings.off ? settings.off : this._off; + }, + _setupAsyncCompute: function(initialValue, settings){ + + this.value = initialValue; + + var oldUpdater = can.proxy(this.updater, this), + self = this, + fn = settings.fn, + data; + + this.updater = oldUpdater; + + var lastSetValue = new can.Compute(initialValue); + // expose this compute so it can be read + this.lastSetValue = lastSetValue; + this._setUpdates = true; + this._set = function(newVal){ + if(newVal === lastSetValue.get()) { + return this.value; + } + + // this is the value passed to the fn + return lastSetValue.set(newVal); + }; + + // make sure get is called with the newVal, but not setter + this._get = asyncGet(fn, settings.context, lastSetValue); + // Check the number of arguments the + // async function takes. + if(fn.length === 0) { + // if it takes no arguments, it is calculated from other things. + data = setupComputeHandlers(this, fn, settings.context); + } else if(fn.length === 1) { + // If it has a single argument, pass it the current value + // or the value from define.set. + data = setupComputeHandlers(this, function() { + return fn.call(settings.context, lastSetValue.get() ); + }, settings); + } else { + // The updater function passed to on so that if called with + // a single, non undefined value, works. + this.updater = asyncUpdater(this, oldUpdater); + + // Finally, pass the function so it can decide the final value. + data = setupComputeHandlers(this, function() { + // Call fn, and get new value + var res = fn.call(settings.context, lastSetValue.get(), function(newVal) { + oldUpdater(newVal, self.value); + }); + // If undefined is returned, don't update the value. + return res !== undefined ? res : this.value; + }, settings); + } + + this._on = data.on; + this._off = data.off; + }, + _setupInitialValue: function(initialValue) { + this.value = initialValue; + } + }); + + // A list of temporarily bound computes + var computes, unbindComputes = function () { + for (var i = 0, len = computes.length; i < len; i++) { + computes[i].unbind('change', k); + } + computes = null; + }; + + // Binds computes for a moment to retain their value and prevent caching + can.Compute.temporarilyBind = function (compute) { + compute.bind('change', k); + if (!computes) { + computes = []; + setTimeout(unbindComputes, 10); + } + computes.push(compute); + }; + + can.Compute.async = function(initialValue, asyncComputer, context){ + return new can.Compute(initialValue, { + fn: asyncComputer, + context: context + }); + }; + + can.Compute.read = read; + can.Compute.set = read.write; + + can.Compute.truthy = function(compute) { + return new can.Compute(function() { + var res = compute.get(); + if(typeof res === 'function') { + res = res.get(); + } + return !!res; + }); + }; + + return can.Compute; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/compute/read.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/compute/read.js new file mode 100644 index 0000000000..118e74bd55 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/compute/read.js @@ -0,0 +1,239 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#compute/read*/ +steal("can/util", function(can){ + + + + + // there are things that you need to evaluate when you get them back as a property read + // for example a compute or a function you might need to call to get the next value to + // actually check + // - isArgument - should be renamed to something like "dontReadLastPropertyValue" + var read = function (parent, reads, options) { + options = options || {}; + var state = { + foundObservable: false + }; + + // `cur` is the current value. + var cur = readValue(parent, 0, reads, options, state), + type, + // `prev` is the object we are reading from. + prev, + // `foundObs` did we find an observable. + readLength = reads.length, + i = 0; + + + while( i < readLength ) { + prev = cur; + // try to read the property + for(var r=0, readersLength = read.propertyReaders.length; r < readersLength; r++) { + var reader = read.propertyReaders[r]; + if(reader.test(cur)) { + cur = reader.read(cur, reads[i], i, options, state); + break; // there can be only one reading of a property + } + } + i = i+1; + // read the value if it is a compute or function + cur = readValue(cur, i, reads, options, state, prev); + type = typeof cur; + // early exit if need be + if (i < reads.length && (cur === null || type !== 'function' && type !== 'object')) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1, cur); + } + // return undefined so we know this isn't the right value + return { + value: undefined, + parent: prev + }; + } + + } + // if we don't have a value, exit early. + if (cur === undefined) { + if (options.earlyExit) { + options.earlyExit(prev, i - 1); + } + } + return { + value: cur, + parent: prev + }; + }; + + + var readValue = function(value, index, reads, options, state, prev){ + var usedValueReader; + do { + + usedValueReader = false; + for(var i =0, len = read.valueReaders.length; i < len; i++){ + if( read.valueReaders[i].test(value, index, reads, options) ) { + value = read.valueReaders[i].read(value, index, reads, options, state, prev); + //usedValueReader = true; + } + } + } while(usedValueReader); + + return value; + }; + // value readers check the current value + // and get a new value from it + // ideally they would keep calling until + // none of these passed + read.valueReaders = [{ + name: "compute", + // compute value reader + test: function(value, i, reads, options){ + return value && value.isComputed; + }, + read: function(value, i, reads, options, state){ + if(options.isArgument && i === reads.length ) { + return value; + } + + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, i); + state.foundObservable = true; + } + return value instanceof can.Compute ? value.get() : value(); + } + },{ + name: "function", + // if this is a function before the last read and its not a constructor function + test: function(value, i, reads, options){ + var type = typeof value; + // i = reads.length if this is the last iteration of the read for-loop. + return type === 'function' && !value.isComputed && + (options.executeAnonymousFunctions || (options.isArgument && i === reads.length) ) && + !(can.Construct && value.prototype instanceof can.Construct) && + !(can.route && value === can.route); + }, + read: function(value, i, reads, options, state, prev){ + if (options.isArgument && i === reads.length) { + return options.proxyMethods !== false ? can.proxy(value, prev) : value; + } + return value.call(prev); + } + }]; + + // propertyReaders actually read a property value + read.propertyReaders = [ + // read a can.Map or can.route + { + name: "map", + test: can.isMapLike, + read: function(value, prop, index, options, state){ + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + if (typeof value[prop] === 'function' && value.constructor.prototype[prop] === value[prop]) { + // call that method + if (options.returnObserveMethods) { + return value[prop]; + // if the property value is a can.Construct + } else if ( (prop === 'constructor' && value instanceof can.Construct) || + (value[prop].prototype instanceof can.Construct)) { + return value[prop]; + } else { + return value[prop].apply(value, options.args || []); + } + } else { + // use attr to get that value + return value.attr(prop); + } + } + }, + // read a promise + { + name: "promise", + test: function(value){ + return can.isPromise(value); + }, + read: function(value, prop, index, options, state){ + if (!state.foundObservable && options.foundObservable) { + options.foundObservable(value, index); + state.foundObservable = true; + } + var observeData = value.__observeData; + if(!value.__observeData) { + observeData = value.__observeData = { + isPending: true, + state: "pending", + isResolved: false, + isRejected: false, + value: undefined, + reason: undefined + }; + can.cid(observeData); + // proto based would be faster + can.simpleExtend(observeData, can.event); + value.then(function(value){ + observeData.isPending = false; + observeData.isResolved = true; + observeData.value = value; + observeData.state = "resolved"; + observeData.dispatch("state",["resolved","pending"]); + }, function(reason){ + observeData.isPending = false; + observeData.isRejected = true; + observeData.reason = reason; + observeData.state = "rejected"; + observeData.dispatch("state",["rejected","pending"]); + }); + } + can.__observe(observeData,"state"); + return prop in observeData ? observeData[prop] : value[prop]; + } + }, + + // read a normal object + { + name: "object", + // this is the default + test: function(){return true;}, + read: function(value, prop){ + if(value == null) { + return undefined; + } else { + return value[prop]; + } + } + } + ]; + + // This should be able to set a property similar to how read works. + read.write = function(parent, key, value, options) { + options = options || {}; + if(can.isMapLike(parent)) { + // HACK! ... check if the attr is a comptue, if it is, set it. + if(!options.isArgument && parent._data && parent._data[key] && parent._data[key].isComputed) { + return parent._data[key](value); + } else { + return parent.attr(key, value); + } + } + + if(parent[key] && parent[key].isComputed) { + return parent[key](value); + } + + if(typeof parent === 'object') { + parent[key] = value; + } + }; + + + return read; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/construct/construct.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/construct/construct.js new file mode 100644 index 0000000000..1c117c476c --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/construct/construct.js @@ -0,0 +1,767 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#construct/construct*/ +// steal-clean +steal('can/util/string', function (can) { + // ## construct.js + // `can.Construct` + // _This is a modified version of + // [John Resig's class](http://ejohn.org/blog/simple-javascript-inheritance/). + // It provides class level inheritance and callbacks._ + // A private flag used to initialize a new class instance without + // initializing it's bindings. + var initializing = 0; + + var canGetDescriptor; + try { + Object.getOwnPropertyDescriptor({}); + canGetDescriptor = true; + } catch(e) { + canGetDescriptor = false; + } + + var getDescriptor = function(newProps, name) { + var descriptor = Object.getOwnPropertyDescriptor(newProps, name); + if(descriptor && (descriptor.get || descriptor.set)) { + return descriptor; + } + return null; + }, + inheritGetterSetter = function(newProps, oldProps, addTo) { + addTo = addTo || newProps; + var descriptor; + + for (var name in newProps) { + if( (descriptor = getDescriptor(newProps, name)) ) { + this._defineProperty(addTo, oldProps, name, descriptor); + } else { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + } + }, + simpleInherit = function (newProps, oldProps, addTo) { + addTo = addTo || newProps; + + for (var name in newProps) { + can.Construct._overwrite(addTo, oldProps, name, newProps[name]); + } + }; + + /** + * @add can.Construct + */ + can.Construct = function () { + if (arguments.length) { + return can.Construct.extend.apply(can.Construct, arguments); + } + }; + /** + * @static + */ + can.extend(can.Construct, { + /** + * @property {Boolean} can.Construct.constructorExtends + * @parent can.Construct.static + * + * @description + * Toggles the behavior of a constructor function called + * without the `new` keyword to extend the constructor function or + * create a new instance. + * + * ``` + * var animal = Animal(); + * // vs + * var animal = new Animal(); + * ``` + * + * @body + * + * If `constructorExtends` is: + * + * - `true` - the constructor extends + * - `false` - a new instance of the constructor is created + * + * This property defaults to false. + * + * Example of constructExtends is true: + * ``` + * var Animal = can.Construct.extend({ + * constructorExtends: true // the constructor extends + * },{ + * sayHi: function() { + * console.log("hai!"); + * } + * }); + * + * var Pony = Animal({ + * gallop: function () { + * console.log("Galloping!!"); + * } + * }); // Pony is now a constructor function extended from Animal + * + * var frank = new Animal(); // frank is a new instance of Animal + * + * var gertrude = new Pony(); // gertrude is a new instance of Pony + * gertrude.sayHi(); // "hai!" - sayHi is "inherited" from Animal + * gertrude.gallop(); // "Galloping!!" - gallop is unique to instances of Pony + *``` + * + * The default behavior is shown in the example below: + * ``` + * var Animal = can.Construct.extend({ + * constructorExtends: false // the constructor does NOT extend + * },{ + * sayHi: function() { + * console.log("hai!"); + * } + * }); + * + * var pony = Animal(); // pony is a new instance of Animal + * var frank = new Animal(); // frank is a new instance of Animal + * + * pony.sayHi() // "hai!" + * frank.sayHi() // "hai!" + *``` + * By default to extend a constructor, you must use [can.Construct.extend extend]. + */ + constructorExtends: true, + /** + * @function can.Construct.newInstance newInstance + * @parent can.Construct.static + * + * @description Returns an instance of `can.Construct`. This method + * can be overridden to return a cached instance. + * + * @signature `can.Construct.newInstance([...args])` + * + * @param {*} [args] arguments that get passed to [can.Construct::setup] and [can.Construct::init]. Note + * that if [can.Construct::setup] returns an array, those arguments will be passed to [can.Construct::init] + * instead. + * @return {class} instance of the class + * + * @body + * Creates a new instance of the constructor function. This method is useful for creating new instances + * with arbitrary parameters. Typically, however, you will simply want to call the constructor with the + * __new__ operator. + * + * ## Example + * + * The following creates a `Person` Construct and overrides `newInstance` to cache all + * instances of Person to prevent duplication. If the properties of a new Person match an existing one it + * will return a reference to the previously created object, otherwise it returns a new object entirely. + * + * ``` + * // define and create the Person constructor + * var Person = can.Construct.extend({ + * init : function(first, middle, last) { + * this.first = first; + * this.middle = middle; + * this.last = last; + * } + * }); + * + * // store a reference to the original newInstance function + * var _newInstance = Person.newInstance; + * + * // override Person's newInstance function + * Person.newInstance = function() { + * // if cache does not exist make it an new object + * this.__cache = this.__cache || {}; + * // id is a stingified version of the passed arguments + * var id = JSON.stringify(arguments); + * + * // look in the cache to see if the object already exists + * var cachedInst = this.__cache[id]; + * if(cachedInst) { + * return cachedInst; + * } + * + * //otherwise call the original newInstance function and return a new instance of Person. + * var newInst = _newInstance.apply(this, arguments); + * this.__cache[id] = newInst; + * return newInst; + * } + * + * // create two instances with the same arguments + * var justin = new Person('Justin', 'Barry', 'Meyer'), + * brian = new Person('Justin', 'Barry', 'Meyer'); + * + * console.log(justin === brian); // true - both are references to the same instance + * ``` + * + */ + newInstance: function () { + // Get a raw instance object (`init` is not called). + var inst = this.instance(), + args; + // Call `setup` if there is a `setup` + if (inst.setup) { + args = inst.setup.apply(inst, arguments); + } + // Call `init` if there is an `init` + // If `setup` returned `args`, use those as the arguments + if (inst.init) { + inst.init.apply(inst, args || arguments); + } + return inst; + }, + // Overwrites an object with methods. Used in the `super` plugin. + // `newProps` - New properties to add. + // `oldProps` - Where the old properties might be (used with `super`). + // `addTo` - What we are adding to. + _inherit: canGetDescriptor ? inheritGetterSetter : simpleInherit, + + // Adds a `defineProperty` with the given name and descriptor + // Will only ever be called if ES5 is supported + _defineProperty: function(what, oldProps, propName, descriptor) { + Object.defineProperty(what, propName, descriptor); + }, + + // used for overwriting a single property. + // this should be used for patching other objects + // the super plugin overwrites this + _overwrite: function (what, oldProps, propName, val) { + what[propName] = val; + }, + // Set `defaults` as the merger of the parent `defaults` and this + // object's `defaults`. If you overwrite this method, make sure to + // include option merging logic. + /** + * @function can.Construct.setup setup + * @parent can.Construct.static + * + * @description Perform initialization logic for a constructor function. + * + * @signature `can.Construct.setup(base, fullName, staticProps, protoProps)` + * + * A static `setup` method provides inheritable setup functionality + * for a Constructor function. The following example + * creates a Group constructor function. Any constructor + * functions that inherit from Group will be added to + * `Group.childGroups`. + * + * + * Group = can.Construct.extend({ + * setup: function(Construct, fullName, staticProps, protoProps){ + * this.childGroups = []; + * if(Construct !== can.Construct){ + * this.childGroups.push(Construct) + * } + * Construct.setup.apply(this, arguments) + * } + * },{}) + * var Flock = Group.extend(...) + * Group.childGroups[0] //-> Flock + * + * @param {constructor} base The base constructor that is being inherited from. + * @param {String} fullName The name of the new constructor. + * @param {Object} staticProps The static properties of the new constructor. + * @param {Object} protoProps The prototype properties of the new constructor. + * + * @body + * The static `setup` method is called immediately after a constructor + * function is created and + * set to inherit from its base constructor. It is useful for setting up + * additional inheritance work. + * Do not confuse this with the prototype `[can.Construct::setup]` method. + * + * ## Example + * + * This `Parent` class adds a reference to its base class to itself, and + * so do all the classes that inherit from it. + * + * ``` + * Parent = can.Construct.extend({ + * setup : function(base, fullName, staticProps, protoProps){ + * this.base = base; + * + * // call base functionality + * can.Construct.setup.apply(this, arguments) + * } + * },{}); + * + * Parent.base; // can.Construct + * + * Child = Parent({}); + * + * Child.base; // Parent + * ``` + */ + setup: function (base, fullName) { + this.defaults = can.extend(true, {}, base.defaults, this.defaults); + }, + // Create's a new `class` instance without initializing by setting the + // `initializing` flag. + instance: function () { + // Prevents running `init`. + initializing = 1; + var inst = new this(); + // Allow running `init`. + initializing = 0; + return inst; + }, + // Extends classes. + /** + * @function can.Construct.extend extend + * @parent can.Construct.static + * + * @signature `can.Construct.extend([name,] [staticProperties,] instanceProperties)` + * + * Extends `can.Construct`, or constructor functions derived from `can.Construct`, + * to create a new constructor function. Example: + * + * var Animal = can.Construct.extend({ + * sayHi: function(){ + * console.log("hi") + * } + * }) + * var animal = new Animal() + * animal.sayHi(); + * + * @param {String} [name] Creates the necessary properties and + * objects that point from the `window` to the created constructor function. The following: + * + * can.Construct.extend("company.project.Constructor",{}) + * + * creates a `company` object on window if it does not find one, a + * `project` object on `company` if it does not find one, and it will set the + * `Constructor` property on the `project` object to point to the constructor function. + * + * Finally, it sets "company.project.Constructor" as [can.Construct.fullName fullName] + * and "Constructor" as [can.Construct.shortName shortName]. + * + * @param {Object} [staticProperties] Properties that are added the constructor + * function directly. For example: + * + * ``` + * var Animal = can.Construct.extend({ + * findAll: function(){ + * return can.ajax({url: "/animals"}) + * } + * },{}); // need to pass an empty instanceProperties object + * + * Animal.findAll().then(function(json){ ... }) + * ``` + * + * The [can.Construct.setup static setup] method can be used to + * specify inheritable behavior when a Constructor function is created. + * + * @param {Object} instanceProperties Properties that belong to + * instances made with the constructor. These properties are added to the + * constructor's `prototype` object. Example: + * + * var Animal = can.Construct.extend({ + * findAll: function() { + * return can.ajax({url: "/animals"}); + * } + * },{ + * init: function(name) { + * this.name = name; + * }, + * sayHi: function() { + * console.log(this.name," says hai!"); + * } + * }) + * var pony = new Animal("Gertrude"); + * pony.sayHi(); // "Gertrude says hai!" + * + * The [can.Construct::init init] and [can.Construct::setup setup] properties + * are used for initialization. + * + * @return {function} The constructor function. + * ``` + * var Animal = can.Construct.extend(...); + * var pony = new Animal(); // Animal is a constructor function + * ``` + * @body + * ## Inheritance + * Creating "subclasses" with `can.Construct` is simple. All you need to do is call the base constructor + * with the new function's static and instance properties. For example, we want our `Snake` to + * be an `Animal`, but there are some differences: + * + * + * var Snake = Animal.extend({ + * legs: 0 + * }, { + * init: function() { + * Animal.prototype.init.call(this, 'ssssss'); + * }, + * slither: function() { + * console.log('slithering...'); + * } + * }); + * + * var baslisk = new Snake(); + * baslisk.speak(); // "ssssss" + * baslisk.slither(); // "slithering..." + * baslisk instanceof Snake; // true + * baslisk instanceof Animal; // true + * + * + * ## Static properties and inheritance + * + * If you pass all three arguments to can.Construct, the second one will be attached directy to the + * constructor, allowing you to imitate static properties and functions. You can access these + * properties through the `[can.Construct::constructor this.constructor]` property. + * + * Static properties can get overridden through inheritance just like instance properties. In the example below, + * we override both the legs static property as well as the the init function for each instance: + * + * ``` + * var Animal = can.Construct.extend({ + * legs: 4 + * }, { + * init: function(sound) { + * this.sound = sound; + * }, + * speak: function() { + * console.log(this.sound); + * } + * }); + * + * var Snake = Animal.extend({ + * legs: 0 + * }, { + * init: function() { + * this.sound = 'ssssss'; + * }, + * slither: function() { + * console.log('slithering...'); + * } + * }); + * + * Animal.legs; // 4 + * Snake.legs; // 0 + * var dog = new Animal('woof'); + * var blackMamba = new Snake(); + * dog.speak(); // 'woof' + * blackMamba.speak(); // 'ssssss' + * ``` + */ + extend: function (name, staticProperties, instanceProperties) { + var fullName = name, + klass = staticProperties, + proto = instanceProperties; + + // Figure out what was passed and normalize it. + if (typeof fullName !== 'string') { + proto = klass; + klass = fullName; + fullName = null; + } + if (!proto) { + proto = klass; + klass = null; + } + proto = proto || {}; + var _super_class = this, + _super = this.prototype, + Constructor, parts, current, _fullName, _shortName, propName, shortName, namespace, prototype; + // Instantiate a base class (but only create the instance, + // don't run the init constructor). + prototype = this.instance(); + // Copy the properties over onto the new prototype. + can.Construct._inherit(proto, _super, prototype); + + if(fullName) { + parts = fullName.split('.'); + shortName = parts.pop(); + } + //!steal-remove-start + /* jshint ignore:start */ + // In dev builds we want constructor.name to be the same as shortName. + // The only way to do that right now is using eval. jshint does not like + // this at all so we hide it + + // Strip semicolons + var constructorName = shortName ? shortName.replace(/;/g, '') : 'Constructor'; + + // Assign a name to the constructor + eval('Constructor = function ' + constructorName + '() { return init.apply(this, arguments); }'); + /* jshint ignore:end */ + //!steal-remove-end + + // Make sure Constructor is still defined when the constructor name + // code is removed. + if(typeof constructorName === 'undefined') { + Constructor = function() { + return init.apply(this, arguments); + }; + } + // The dummy class constructor. + function init() { + // All construction is actually done in the init method. + if (!initializing) { + //!steal-remove-start + if(this.constructor !== Constructor && + // We are being called without `new` or we are extending. + arguments.length && Constructor.constructorExtends) { + can.dev.warn('can/construct/construct.js: extending a can.Construct without calling extend'); + } + //!steal-remove-end + + return this.constructor !== Constructor && + // We are being called without `new` or we are extending. + arguments.length && Constructor.constructorExtends ? Constructor.extend.apply(Constructor, arguments) : + // We are being called with `new`. + Constructor.newInstance.apply(Constructor, arguments); + } + } + // Copy old stuff onto class (can probably be merged w/ inherit) + for (propName in _super_class) { + if (_super_class.hasOwnProperty(propName)) { + Constructor[propName] = _super_class[propName]; + } + } + // Copy new static properties on class. + can.Construct._inherit(klass, _super_class, Constructor); + // Setup namespaces. + if (fullName) { + + current = can.getObject(parts.join('.'), window, true); + namespace = current; + _fullName = can.underscore(fullName.replace(/\./g, "_")); + _shortName = can.underscore(shortName); + + //!steal-remove-start + if (current[shortName]) { + can.dev.warn("can/construct/construct.js: There's already something called " + fullName); + } + //!steal-remove-end + + current[shortName] = Constructor; + } + // Set things that shouldn't be overwritten. + can.extend(Constructor, { + constructor: Constructor, + prototype: prototype, + /** + * @property {String} can.Construct.namespace namespace + * @parent can.Construct.static + * + * The `namespace` property returns the namespace your constructor is in. + * This provides a way organize code and ensure globally unique types. The + * `namespace` is the [can.Construct.fullName fullName] you passed without the [can.Construct.shortName shortName]. + * + * ``` + * can.Construct("MyApplication.MyConstructor",{},{}); + * MyApplication.MyConstructor.namespace // "MyApplication" + * MyApplication.MyConstructor.shortName // "MyConstructor" + * MyApplication.MyConstructor.fullName // "MyApplication.MyConstructor" + * ``` + */ + namespace: namespace, + /** + * @property {String} can.Construct.shortName shortName + * @parent can.Construct.static + * + * If you pass a name when creating a Construct, the `shortName` property will be set to the + * name you passed without the [can.Construct.namespace namespace]. + * + * ``` + * can.Construct("MyApplication.MyConstructor",{},{}); + * MyApplication.MyConstructor.namespace // "MyApplication" + * MyApplication.MyConstructor.shortName // "MyConstructor" + * MyApplication.MyConstructor.fullName // "MyApplication.MyConstructor" + * ``` + */ + _shortName: _shortName, + /** + * @property {String} can.Construct.fullName fullName + * @parent can.Construct.static + * + * If you pass a name when creating a Construct, the `fullName` property will be set to + * the name you passed. The `fullName` consists of the [can.Construct.namespace namespace] and + * the [can.Construct.shortName shortName]. + * + * ``` + * can.Construct("MyApplication.MyConstructor",{},{}); + * MyApplication.MyConstructor.namespace // "MyApplication" + * MyApplication.MyConstructor.shortName // "MyConstructor" + * MyApplication.MyConstructor.fullName // "MyApplication.MyConstructor" + * ``` + */ + fullName: fullName, + _fullName: _fullName + }); + // Dojo and YUI extend undefined + if (shortName !== undefined) { + Constructor.shortName = shortName; + } + // Make sure our prototype looks nice. + Constructor.prototype.constructor = Constructor; + // Call the class `setup` and `init` + var t = [_super_class].concat(can.makeArray(arguments)), + args = Constructor.setup.apply(Constructor, t); + if (Constructor.init) { + Constructor.init.apply(Constructor, args || t); + } + /** + * @prototype + */ + return Constructor; // + /** + * @property {Object} can.Construct.prototype.constructor constructor + * @parent can.Construct.prototype + * + * A reference to the constructor function that created the instance. This allows you to access + * the constructor's static properties from an instance. + * + * @body + * ## Example + * + * This can.Construct has a static counter that counts how many instances have been created: + * + * ``` + * var Counter = can.Construct.extend({ + * count: 0 + * }, { + * init: function() { + * this.constructor.count++; + * } + * }); + * + * var childCounter = new Counter(); + * console.log(childCounter.constructor.count); // 1 + * console.log(Counter.count); // 1 + * ``` + */ + } + }); + /** + * @function can.Construct.prototype.setup setup + * @parent can.Construct.prototype + * + * @signature `construct.setup(...args)` + * + * A setup function for the instantiation of a constructor function. + * + * @param {*} args The arguments passed to the constructor. + * + * @return {Array|undefined} If an array is returned, the array's items are passed as + * arguments to [can.Construct::init init]. The following example always makes + * sure that init is called with a jQuery wrapped element: + * + * WidgetFactory = can.Construct.extend({ + * setup: function(element){ + * return [$(element)] + * } + * }) + * + * MyWidget = WidgetFactory.extend({ + * init: function($el){ + * $el.html("My Widget!!") + * } + * }) + * + * Otherwise, the arguments to the + * constructor are passed to [can.Construct::init] and the return value of `setup` is discarded. + * + * @body + * + * ## Deciding between `setup` and `init` + * + * + * Usually, you should use [can.Construct::init init] to do your constructor function's initialization. + * Use `setup` instead for: + * + * - initialization code that you want to run before the inheriting constructor's + * `init` method is called. + * - initialization code that should run whether or not inheriting constructors + * call their base's `init` methods. + * - modifying the arguments that will get passed to `init`. + * + * ## Example + * + * This code is a simplified version of the code in [can.Control]'s setup + * method. It converts the first argument to a jQuery collection and + * extends the controller's defaults with the options that were passed. + * + * + * can.Control = can.Construct.extend({ + * setup: function(domElement, rawOptions) { + * // set up this.element + * this.element = $(domElement); + * + * // set up this.options + * this.options = can.extend({}, + * this.constructor.defaults, + * rawOptions + * ); + * + * // pass this.element and this.options to init. + * return [this.element, this.options]; + * } + * }); + * + */ + can.Construct.prototype.setup = function () {}; + /** + * @function can.Construct.prototype.init init + * @parent can.Construct.prototype + * + * @description Called when a new instance of a can.Construct is created. + * + * @signature `construct.init(...args)` + * @param {*} args the arguments passed to the constructor (or the items of the array returned from [can.Construct::setup]) + * + * @body + * If a prototype `init` method is provided, it is called when a new Construct is created, + * after [can.Construct::setup]. The `init` method is where the bulk of your initialization code + * should go, and a common thing to do in `init` is to save the arguments passed into the constructor. + * + * ## Examples + * + * First, we'll make a Person constructor that has a first and last name: + * + * ``` + * var Person = can.Construct.extend({ + * init: function(first, last) { + * this.first = first; + * this.last = last; + * } + * }); + * + * var justin = new Person("Justin", "Meyer"); + * justin.first; // "Justin" + * justin.last; // "Meyer" + * ``` + * + * Then we'll extend Person into Programmer and add a favorite language: + * + * ``` + * var Programmer = Person.extend({ + * init: function(first, last, language) { + * // call base's init + * Person.prototype.init.apply(this, arguments); + * + * // other initialization code + * this.language = language; + * }, + * bio: function() { + * return "Hi! I'm "" + this.first + " " + this.last + + * " and I write " + this.language + "."; + * } + * }); + * + * var brian = new Programmer("Brian", "Moschel", 'ECMAScript'); + * brian.bio(); // "Hi! I'm Brian Moschel and I write ECMAScript."; + * ``` + * + * ## Modified Arguments + * + * [can.Construct::setup] is able to modify the arguments passed to `init`. + * If you aren't receiving the exact arguments as those passed to `new Construct(args)`, + * check to make sure that they aren't being changed by `setup` somewhere along + * the inheritance chain. + */ + can.Construct.prototype.init = function () {}; + return can.Construct; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/construct/proxy/proxy.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/construct/proxy/proxy.js new file mode 100644 index 0000000000..adb7ac9835 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/construct/proxy/proxy.js @@ -0,0 +1,75 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#construct/proxy/proxy*/ +steal('can/util', 'can/construct', function (can, Construct) { + var isFunction = can.isFunction, + isArray = can.isArray, + makeArray = can.makeArray, + proxy = function (funcs) { + //args that should be curried + var args = makeArray(arguments), + self; + // get the functions to callback + funcs = args.shift(); + // if there is only one function, make funcs into an array + if (!isArray(funcs)) { + funcs = [funcs]; + } + // keep a reference to us in self + self = this; + + //!steal-remove-start + for (var i = 0; i < funcs.length; i++) { + if (typeof funcs[i] === "string" && !isFunction(this[funcs[i]])) { + throw ("class.js " + (this.fullName || this.Class.fullName) + " does not have a " + funcs[i] + "method!"); + } + } + //!steal-remove-end + + return function class_cb() { + // add the arguments after the curried args + var cur = args.concat(makeArray(arguments)), + isString, length = funcs.length, + f = 0, + func; + // go through each function to call back + for (; f < length; f++) { + func = funcs[f]; + if (!func) { + continue; + } + // set called with the name of the function on self (this is how this.view works) + isString = typeof func === 'string'; + // call the function + cur = (isString ? self[func] : func) + .apply(self, cur || []); + // pass the result to the next function (if there is a next function) + if (f < length - 1) { + cur = !isArray(cur) || cur._use_call ? [cur] : cur; + } + } + return cur; + }; + }; + can.Construct.proxy = can.Construct.prototype.proxy = proxy; + // this corrects the case where can/control loads after can/construct/proxy, so static props don't have proxy + var correctedClasses = [ + can.Map, + can.Control, + can.Model + ], + i = 0; + for (; i < correctedClasses.length; i++) { + if (correctedClasses[i]) { + correctedClasses[i].proxy = proxy; + } + } + return can; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/construct/super/super.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/construct/super/super.js new file mode 100644 index 0000000000..f54d8fbfd7 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/construct/super/super.js @@ -0,0 +1,55 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#construct/super/super*/ +steal('can/util', 'can/construct', function (can, Construct) { + // tests if we can get super in .toString() + var isFunction = can.isFunction, + fnTest = /xyz/.test(function () { + return this.xyz; + }) ? /\b_super\b/ : /.*/, + getset = ['get', 'set'], + getSuper = function (base, name, fn) { + return function () { + var tmp = this._super, + ret; + // Add a new ._super() method that is the same method + // but on the super-class + this._super = base[name]; + // The method only need to be bound temporarily, so we + // remove it when we're done executing + ret = fn.apply(this, arguments); + this._super = tmp; + return ret; + }; + }; + + can.Construct._defineProperty = function(addTo, base, name, descriptor) { + var _super = Object.getOwnPropertyDescriptor(base, name); + if(_super) { + can.each(getset, function (method) { + if(isFunction(_super[method]) && isFunction(descriptor[method])) { + descriptor[method] = getSuper(_super, method, descriptor[method]); + } else if(!isFunction(descriptor[method])) { + descriptor[method] = _super[method]; + } + }); + } + + Object.defineProperty(addTo, name, descriptor); + }; + + // overwrites a single property so it can still call super + can.Construct._overwrite = function (addTo, base, name, val) { + // Check if we're overwriting an existing function + addTo[name] = isFunction(val) && isFunction(base[name]) && fnTest.test(val) ? + getSuper(base, name, val) : val; + }; + return can; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/control/control.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/control/control.js new file mode 100644 index 0000000000..762faeb740 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/control/control.js @@ -0,0 +1,343 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#control/control*/ +// # can/control/control.js +// +// Create organized, memory-leak free, rapidly performing, stateful +// controls with declarative eventing binding. Used when creating UI +// controls with behaviors, bound to elements on the page. +// ## helpers + +steal('can/util', 'can/construct', function (can) { + // + // ### bind + // this helper binds to one element and returns a function that unbinds from that element. + var bind = function (el, ev, callback) { + + can.bind.call(el, ev, callback); + + return function () { + can.unbind.call(el, ev, callback); + }; + }, + isFunction = can.isFunction, + extend = can.extend, + each = can.each, + slice = [].slice, + paramReplacer = /\{([^\}]+)\}/g, + special = can.getObject("$.event.special", [can]) || {}, + + // ### delegate + // + // this helper binds to elements based on a selector and returns a + // function that unbinds. + delegate = function (el, selector, ev, callback) { + can.delegate.call(el, selector, ev, callback); + return function () { + can.undelegate.call(el, selector, ev, callback); + }; + }, + + // ### binder + // + // Calls bind or unbind depending if there is a selector. + binder = function (el, ev, callback, selector) { + return selector ? + delegate(el, can.trim(selector), ev, callback) : + bind(el, ev, callback); + }, + + basicProcessor; + + var Control = can.Control = can.Construct( + /** + * @add can.Control + */ + // ## *static functions* + /** + * @static + */ + { + // ## can.Control.setup + // + // This function pre-processes which methods are event listeners and which are methods of + // the control. It has a mechanism to allow controllers to inherit default values from super + // classes, like `can.Construct`, and will cache functions that are action functions (see `_isAction`) + // or functions with an underscored name. + setup: function () { + can.Construct.setup.apply(this, arguments); + + if (can.Control) { + var control = this, + funcName; + + control.actions = {}; + for (funcName in control.prototype) { + if (control._isAction(funcName)) { + control.actions[funcName] = control._action(funcName); + } + } + } + }, + // ## can.Control._shifter + // + // Moves `this` to the first argument, wraps it with `jQuery` if it's + // an element. + _shifter: function (context, name) { + + var method = typeof name === "string" ? context[name] : name; + + if (!isFunction(method)) { + method = context[method]; + } + + return function () { + context.called = name; + return method.apply(context, [this.nodeName ? can.$(this) : this].concat(slice.call(arguments, 0))); + }; + }, + + // ## can.Control._isAction + // + // Return `true` if `methodName` refers to an action. An action is a `methodName` value that + // is not the constructor, and is either a function or string that refers to a function, or is + // defined in `special`, `processors`. Detects whether `methodName` is also a valid method name. + _isAction: function (methodName) { + var val = this.prototype[methodName], + type = typeof val; + + return (methodName !== 'constructor') && + (type === "function" || (type === "string" && isFunction(this.prototype[val]))) && + !! (special[methodName] || processors[methodName] || /[^\w]/.test(methodName)); + }, + // ## can.Control._action + // + // Takes a method name and the options passed to a control and tries to return the data + // necessary to pass to a processor (something that binds things). + // + // For performance reasons, `_action` is called twice: + // * It's called when the Control class is created. for templated method names (e.g., `{window} foo`), it returns null. For non-templated method names it returns the event binding data. That data is added to `this.actions`. + // * It is called wehn a control instance is created, but only for templated actions. + _action: function (methodName, options) { + + // If we don't have options (a `control` instance), we'll run this later. If we have + // options, run `can.sub` to replace the action template `{}` with values from the `options` + // or `window`. If a `{}` template resolves to an object, `convertedName` will be an array. + // In that case, the event name we want will be the last item in that array. + paramReplacer.lastIndex = 0; + if (options || !paramReplacer.test(methodName)) { + var convertedName = options ? can.sub(methodName, this._lookup(options)) : methodName; + if (!convertedName) { + //!steal-remove-start + can.dev.log('can/control/control.js: No property found for handling ' + methodName); + //!steal-remove-end + return null; + } + var arr = can.isArray(convertedName), + name = arr ? convertedName[1] : convertedName, + parts = name.split(/\s+/g), + event = parts.pop(); + + return { + processor: processors[event] || basicProcessor, + parts: [name, parts.join(" "), event], + delegate: arr ? convertedName[0] : undefined + }; + } + }, + _lookup: function (options) { + return [options, window]; + }, + // ## can.Control.processors + // + // An object of `{eventName : function}` pairs that Control uses to + // hook up events automatically. + processors: {}, + // ## can.Control.defaults + // A object of name-value pairs that act as default values for a control instance + defaults: {} + }, { + // ## *prototype functions* + /** + * @prototype + */ + // ## setup + // + // Setup is where most of the Control's magic happens. It performs several pre-initialization steps: + // - Sets `this.element` + // - Adds the Control's name to the element's className + // - Saves the Control in `$.data` + // - Merges Options + // - Binds event handlers using `delegate` + // The final step is to return pass the element and prepareed options, to be used in `init`. + setup: function (element, options) { + + var cls = this.constructor, + pluginname = cls.pluginName || cls._fullName, + arr; + + // Retrieve the raw element, then set the plugin name as a class there. + this.element = can.$(element); + + if (pluginname && pluginname !== 'can_control') { + this.element.addClass(pluginname); + } + + // Set up the 'controls' data on the element. If it does not exist, initialize + // it to an empty array. + arr = can.data(this.element, 'controls'); + if (!arr) { + arr = []; + can.data(this.element, 'controls', arr); + } + arr.push(this); + + // The `this.options` property is an Object that contains configuration data + // passed to a control when it is created (`new can.Control(element, options)`) + // + // The `options` argument passed when creating the control is merged with `can.Control.defaults` + // in [can.Control.prototype.setup setup]. + // + // If no `options` value is used during creation, the value in `defaults` is used instead + this.options = extend({}, cls.defaults, options); + + this.on(); + + return [this.element, this.options]; + }, + // ## on + // + // This binds an event handler for an event to a selector under the scope of `this.element` + // If no options are specified, all events are rebound to their respective elements. The actions, + // which were cached in `setup`, are used and all elements are bound using `delegate` from `this.element`. + on: function (el, selector, eventName, func) { + if (!el) { + this.off(); + + var cls = this.constructor, + bindings = this._bindings, + actions = cls.actions, + element = this.element, + destroyCB = can.Control._shifter(this, "destroy"), + funcName, ready; + + for (funcName in actions) { + // Only push if we have the action and no option is `undefined` + if ( actions.hasOwnProperty(funcName) ) { + ready = actions[funcName] || cls._action(funcName, this.options, this); + if( ready ) { + bindings.control[funcName] = ready.processor(ready.delegate || element, + ready.parts[2], ready.parts[1], funcName, this); + } + } + } + + // Set up the ability to `destroy` the control later. + can.bind.call(element, "removed", destroyCB); + bindings.user.push(function (el) { + can.unbind.call(el, "removed", destroyCB); + }); + return bindings.user.length; + } + + // if `el` is a string, use that as `selector` and re-set it to this control's element... + if (typeof el === 'string') { + func = eventName; + eventName = selector; + selector = el; + el = this.element; + } + + // ...otherwise, set `selector` to null + if (func === undefined) { + func = eventName; + eventName = selector; + selector = null; + } + + if (typeof func === 'string') { + func = can.Control._shifter(this, func); + } + + this._bindings.user.push(binder(el, eventName, func, selector)); + + return this._bindings.user.length; + }, + // ## off + // + // Unbinds all event handlers on the controller. + // This should _only_ be called in combination with .on() + off: function () { + var el = this.element[0], + bindings = this._bindings; + if( bindings ) { + each(bindings.user || [], function (value) { + value(el); + }); + each(bindings.control || {}, function (value) { + value(el); + }); + } + // Adds bindings. + this._bindings = {user: [], control: {}}; + }, + // ## destroy + // + // Prepares a `control` for garbage collection. + // First checks if it has already been removed. Then, removes all the bindings, data, and + // the element from the Control instance. + destroy: function () { + if (this.element === null) { + //!steal-remove-start + can.dev.warn("can/control/control.js: Control already destroyed"); + //!steal-remove-end + return; + } + var Class = this.constructor, + pluginName = Class.pluginName || Class._fullName, + controls; + + this.off(); + + if (pluginName && pluginName !== 'can_control') { + this.element.removeClass(pluginName); + } + + controls = can.data(this.element, "controls"); + controls.splice(can.inArray(this, controls), 1); + + can.trigger(this, "destroyed"); + + this.element = null; + } + }); + + // ## Processors + // + // Processors do the binding. This basic processor binds events. Each returns a function that unbinds + // when called. + var processors = can.Control.processors; + basicProcessor = function (el, event, selector, methodName, control) { + return binder(el, event, can.Control._shifter(control, methodName), selector); + }; + + // Set common events to be processed as a `basicProcessor` + each(["change", "click", "contextmenu", "dblclick", "keydown", "keyup", + "keypress", "mousedown", "mousemove", "mouseout", "mouseover", + "mouseup", "reset", "resize", "scroll", "select", "submit", "focusin", + "focusout", "mouseenter", "mouseleave", + "touchstart", "touchmove", "touchcancel", "touchend", "touchleave", + "inserted","removed" + ], function (v) { + processors[v] = basicProcessor; + }); + + return Control; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/control/plugin/plugin.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/control/plugin/plugin.js new file mode 100644 index 0000000000..dea4aeee86 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/control/plugin/plugin.js @@ -0,0 +1,256 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#control/plugin/plugin*/ +steal('jquery', 'can/util', 'can/control', function ($, can) { + $ = $ || window.$; + + //used to determine if a control instance is one of controllers + //controllers can be strings or classes + var i, isAControllerOf = function (instance, controllers) { + var name = instance.constructor.pluginName || instance.constructor._shortName; + for (i = 0; i < controllers.length; i++) { + if (typeof controllers[i] === 'string' ? name === controllers[i] : instance instanceof controllers[i]) { + return true; + } + } + return false; + }, makeArray = can.makeArray, + old = can.Control.setup; + /* + * static + */ + can.Control.setup = function () { + // if you didn't provide a name, or are control, don't do anything + if (this !== can.Control) { + /** + * @property {String} can.Control.plugin.static.pluginName pluginName + * @parent can.Control.plugin + * + * @description + * + * Allows you to define the name of the jQuery plugin. + * + * @body + * + * Setting the static `pluginName` property allows you to override the default name + * with your own. + * + * var Filler = can.Control({ + * pluginName: 'fillWith' + * },{}); + * + * $("#foo").fillWith(); + * + * If you don't provide a `pluginName`, the control falls back to the + * [can.Construct.fullName fullName] attribute: + * + * can.Control('Ui.Layout.FillWith', {}, {}); + * $("#foo").ui_layout_fill_with(); + * + */ + var pluginName = this.pluginName || this._fullName; + // create jQuery plugin + if (pluginName !== 'can_control') { + this.plugin(pluginName); + } + old.apply(this, arguments); + } + }; + /* + * prototype + */ + $.fn.extend({ + + /** + * @function jQuery.fn.controls jQuery.fn.controls + * @parent can.Control.plugin + * @description Get the Controls associated with elements. + * @signature `jQuery.fn.controls([type])` + * @param {String|can.Control} [control] The type of Controls to find. + * @return {can.Control} The controls associated with the given elements. + * + * @body + * When the widget is initialized, the plugin control creates an array + * of control instance(s) with the DOM element it was initialized on using + * [can.data] method. + * + * The `controls` method allows you to get the control instance(s) for any element + * either by their type or pluginName. + * + * var MyBox = can.Control({ + * pluginName : 'myBox' + * }, {}); + * + * var MyClock = can.Control({ + * pluginName : 'myClock' + * }, {}); + * + * + * //- Inits the widgets + * $('.widgets:eq(0)').myBox(); + * $('.widgets:eq(1)').myClock(); + * + * $('.widgets').controls() //-> [ MyBox, MyClock ] + * $('.widgets').controls('myBox') // -> [MyBox] + * $('.widgets').controls(MyClock) // -> MyClock + * + */ + controls: function () { + var controllerNames = makeArray(arguments), + instances = [], + controls, c; + //check if arguments + this.each(function () { + controls = can.$(this) + .data('controls'); + if (!controls) { + return; + } + for (var i = 0; i < controls.length; i++) { + c = controls[i]; + if (!controllerNames.length || isAControllerOf(c, controllerNames)) { + instances.push(c); + } + } + }); + return instances; + }, + + /** + * @function jQuery.fn.control jQuery.fn.control + * @parent can.Control.plugin + * @description Get the Control associated with elements. + * @signature `jQuery.fn.control([type])` + * @param {String|can.Control} [control] The type of Control to find. + * @return {can.Control} The first control found. + * + * @body + * This is the same as [jQuery.fn.controls $().controls] except that + * it only returns the first Control found. + * + * //- Init MyBox widget + * $('.widgets').my_box(); + * + *
            + * + * $('.widgets').controls() //-> MyBox + */ + control: function (control) { + return this.controls.apply(this, arguments)[0]; + } + }); + can.Control.plugin = function (pluginname) { + var control = this; + if (!$.fn[pluginname]) { + $.fn[pluginname] = function (options) { + var args = makeArray(arguments), + //if the arg is a method on this control + isMethod = typeof options === 'string' && $.isFunction(control.prototype[options]), + meth = args[0], + returns; + this.each(function () { + //check if created + var plugin = can.$(this) + .control(control); + if (plugin) { + if (isMethod) { + // call a method on the control with the remaining args + returns = plugin[meth].apply(plugin, args.slice(1)); + } else { + // call the plugin's update method + plugin.update.apply(plugin, args); + } + } else { + //create a new control instance + control.newInstance.apply(control, [this].concat(args)); + } + }); + return returns !== undefined ? returns : this; + }; + } + }; + /** + * @function can.Control.plugin.prototype.update update + * @parent can.Control.plugin + * + * @description Reconfigure a control. + * @signature `update(newOptions)` + * @param {Object} newOptions Options to merge into the current options. + * + * @body + * Update extends [can.Control.prototype.options options] + * with the `options` argument and rebinds all events. It + * re-configures the control. + * + * For example, the following control wraps a recipe form. When the form + * is submitted, it creates the recipe on the server. When the recipe + * is `created`, it resets the form with a new instance. + * + * var Creator = can.Control({ + * "{recipe} created" : function(){ + * this.update({recipe : new Recipe()}); + * this.element[0].reset(); + * this.element.find("[type=submit]").val("Create Recipe") + * }, + * "submit" : function(el, ev){ + * ev.preventDefault(); + * var recipe = this.options.recipe; + * recipe.attrs( this.element.formParams() ); + * this.element.find("[type=submit]").val("Saving...") + * recipe.save(); + * } + * }); + * + * $('#createRecipes').creator({ recipe : new Recipe() }) + * + * *Update* is called if a control's plugin helper is called with the plugin options on an element + * that already has a control instance of the same type. If you want to implement your + * own update method make sure to call the old one either using the [can.Construct.super super] plugin or + * by calling `can.Control.prototype.update.apply(this, arguments);`. + * For example, you can change the content of the control element every time the options change: + * + * var Plugin = can.Control({ + * pluginName: 'myPlugin' + * }, { + * init : function(el, options) { + * this.updateCount = 0; + * this.update({ + * text : 'Initialized' + * }); + * }, + * update : function(options) { + * // Call the can.Control update first. + * // Use this._super when using can/construct/super + * can.Control.prototype.update.call(this, options); + * this.element.html(this.options.text + ' ' + + * (++this.updateCount) + ' times'); + * } + * }); + * + * $('#control').myPlugin(); + * $('#control').html(); + * // Initialized. Updated 1 times + * + * $('#control').myPlugin({ text : 'Calling update. Updated' }); + * $('#control').html(); + * // Calling update. Updated 2 times + * + * @demo can/control/plugin/demo-update.html + * + * @param {Object} options A list of options to merge with + * [can.Control.prototype.options this.options]. Often this method + * is called by the [can.Control.plugin jQuery helper function]. + */ + can.Control.prototype.update = function (options) { + can.extend(this.options, options); + this.on(); + }; + return can; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/control/route/route.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/control/route/route.js new file mode 100644 index 0000000000..7208981f88 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/control/route/route.js @@ -0,0 +1,48 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#control/route/route*/ +steal('can/util', 'can/route', 'can/control', function (can) { + + // ## control/route.js + // _Controller route integration._ + + can.Control.processors.route = function (el, event, selector, funcName, controller) { + selector = selector || ""; + if (!can.route.routes[selector]) { + if (selector[0] === '/') { + selector = selector.substring(1); + } + can.route(selector); + } + var batchNum, + check = function (ev, attr, how) { + if (can.route.attr('route') === (selector) && + (ev.batchNum === undefined || ev.batchNum !== batchNum)) { + + batchNum = ev.batchNum; + + var d = can.route.attr(); + delete d.route; + if (can.isFunction(controller[funcName])) { + controller[funcName](d); + } else { + controller[controller[funcName]](d); + } + + } + }; + can.route.bind('change', check); + return function () { + can.route.unbind('change', check); + }; + }; + + return can; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/event/event.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/event/event.js new file mode 100644 index 0000000000..f7aab214c0 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/event/event.js @@ -0,0 +1,446 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#event/event*/ +// # can/event +// +// Implements a basic event system that can be used with any type of object. +// In addition to adding basic event functionality, it also provides the `can.event` object +// that can be mixed into objects and prototypes. +// +// Most of the time when this is used, it will be used with the mixin: +// +// ``` +// var SomeClass = can.Construct("SomeClass"); +// can.extend(SomeClass.prototype, can.event); +// ``` + +steal('can/util/can.js', function (can) { + // ## can.event.addEvent + // + // Adds a basic event listener to an object. + // This consists of storing a cache of event listeners on each object, + // that are iterated through later when events are dispatched. + /** + * @function can.event.addEvent + * @parent can.event.static + * @signature `obj.addEvent( event, handler )` + * + * Add a basic event listener to an object. + * + * @param {String} event The name of the event to listen for. + * @param {Function} handler The handler that will be executed to handle the event. + * @return {Object} this + * + * @signature `can.event.addEvent.call( obj, event, handler )` + * + * This syntax can be used for objects that don't include the `can.event` mixin. + */ + can.addEvent = function (event, handler) { + // Initialize event cache. + var allEvents = this.__bindEvents || (this.__bindEvents = {}), + eventList = allEvents[event] || (allEvents[event] = []); + + // Add the event + eventList.push({ + handler: handler, + name: event + }); + return this; + }; + + // ## can.event.listenTo + // + // Listens to an event without know how bind is implemented. + // The primary use for this is to listen to another's objects event while + // tracking events on the local object (similar to namespacing). + // + // The API was heavily influenced by BackboneJS: http://backbonejs.org/ + /** + * @function can.event.listenTo + * @parent can.event.static + * @signature `obj.listenTo( other, event, handler )` + * + * Listens for an event on another object. + * This is similar to concepts like event namespacing, except that the namespace + * is the scope of the calling object. + * + * @param {Object} other The object to listen for events on. + * @param {String} event The name of the event to listen for. + * @param {Function} handler The handler that will be executed to handle the event. + * @return {Object} this + * + * @signature `can.event.listenTo.call( obj, other, event, handler )` + * + * This syntax can be used for objects that don't include the `can.event` mixin. + */ + can.listenTo = function (other, event, handler) { + // Initialize event cache + var idedEvents = this.__listenToEvents; + if (!idedEvents) { + idedEvents = this.__listenToEvents = {}; + } + + // Identify the other object + var otherId = can.cid(other); + var othersEvents = idedEvents[otherId]; + + // Create a local event cache + if (!othersEvents) { + othersEvents = idedEvents[otherId] = { + obj: other, + events: {} + }; + } + var eventsEvents = othersEvents.events[event]; + if (!eventsEvents) { + eventsEvents = othersEvents.events[event] = []; + } + + // Add the event, both locally and to the other object + eventsEvents.push(handler); + can.bind.call(other, event, handler); + }; + + // ## can.event.stopListening + // + // Stops listening for events on other objects + /** + * @function can.event.stopListening + * @parent can.event.static + * @signature `obj.stopListening( other, event, handler )` + * + * Stops listening for an event on another object. + * + * @param {Object} other The object to listen for events on. + * @param {String} event The name of the event to listen for. + * @param {Function} handler The handler that will be executed to handle the event. + * @return {Object} this + * + * @signature `can.event.stopListening.call( obj, other, event, handler )` + * + * This syntax can be used for objects that don't include the `can.event` mixin. + */ + can.stopListening = function (other, event, handler) { + var idedEvents = this.__listenToEvents, + iterIdedEvents = idedEvents, + i = 0; + if (!idedEvents) { + return this; + } + if (other) { + var othercid = can.cid(other); + (iterIdedEvents = {})[othercid] = idedEvents[othercid]; + // you might be trying to listen to something that is not there + if (!idedEvents[othercid]) { + return this; + } + } + + // Clean up events on the other object + for (var cid in iterIdedEvents) { + var othersEvents = iterIdedEvents[cid], + eventsEvents; + other = idedEvents[cid].obj; + + // Find the cache of events + if (!event) { + eventsEvents = othersEvents.events; + } else { + (eventsEvents = {})[event] = othersEvents.events[event]; + } + + // Unbind event handlers, both locally and on the other object + for (var eventName in eventsEvents) { + var handlers = eventsEvents[eventName] || []; + i = 0; + while (i < handlers.length) { + if (handler && handler === handlers[i] || !handler) { + can.unbind.call(other, eventName, handlers[i]); + handlers.splice(i, 1); + } else { + i++; + } + } + // no more handlers? + if (!handlers.length) { + delete othersEvents.events[eventName]; + } + } + if (can.isEmptyObject(othersEvents.events)) { + delete idedEvents[cid]; + } + } + return this; + }; + + // ## can.event.removeEvent + // + // Removes a basic event listener from an object. + // This removes event handlers from the cache of listened events. + /** + * @function can.event.removeEvent + * @parent can.event.static + * @signature `obj.removeEvent( event, handler )` + * + * Removes a basic event listener from an object. + * + * @param {String} event The name of the event to listen for. + * @param {Function} handler The handler that will be executed to handle the event. + * @param {Function} [__validate] An extra function that can validate an event handler + * as a match. This is an internal parameter and only used + * for `can/event` plugins. + * @return {Object} this + * + * @signature `can.event.removeEvent.call( obj, event, handler )` + * + * This syntax can be used for objects that don't include the `can.event` mixin. + */ + can.removeEvent = function (event, fn, __validate) { + if (!this.__bindEvents) { + return this; + } + var events = this.__bindEvents[event] || [], + i = 0, + ev, isFunction = typeof fn === 'function'; + while (i < events.length) { + ev = events[i]; + // Determine whether this event handler is "equivalent" to the one requested + // Generally this requires the same event/function, but a validation function + // can be included for extra conditions. This is used in some plugins like `can/event/namespace`. + if (__validate ? __validate(ev, event, fn) : isFunction && ev.handler === fn || !isFunction && (ev.cid === fn || !fn)) { + events.splice(i, 1); + } else { + i++; + } + } + return this; + }; + + // ## can.event.dispatch + // + // Dispatches/triggers a basic event on an object. + /** + * @function can.event.dispatch + * @parent can.event.static + * @signature `obj.dispatch( event, args )` + * + * Dispatches/triggers a basic event on an object. + * + * @param {String|Object} event The event to dispatch + * @param {Array} [args] Additional arguments to pass to event handlers + * @return {Object} event The resulting event object + * + * @signature `can.event.dispatch.call( obj, event, args )` + * + * This syntax can be used for objects that don't include the `can.event` mixin. + */ + can.dispatch = function (event, args) { + var events = this.__bindEvents; + if (!events) { + return; + } + + // Initialize the event object + if (typeof event === 'string') { + event = { + type: event + }; + } + + // Grab event listeners + var eventName = event.type, + handlers = (events[eventName] || []).slice(0), + passed = [event]; + + // Execute handlers listening for this event. + if(args) { + passed.push.apply(passed, args); + } + + for (var i = 0, len = handlers.length; i < len; i++) { + handlers[i].handler.apply(this, passed); + } + + return event; + }; + + // ## can.event.one + // + // Adds a basic event listener that listens to an event once and only once. + /** + * @function can.event.one + * @parent can.event.static + * @signature `obj.one( event, handler )` + * + * Adds a basic event listener that listens to an event once and only once. + * + * @param {String} event The name of the event to listen for. + * @param {Function} handler The handler that will be executed to handle the event. + * @return {Object} this + */ + can.one = function(event, handler) { + // Unbind the listener after it has been executed + var one = function() { + can.unbind.call(this, event, one); + return handler.apply(this, arguments); + }; + + // Bind the altered listener + can.bind.call(this, event, one); + return this; + }; + + // ## can.event + // Create and export the `can.event` mixin + can.event = { + // Event method aliases + /** + * @function can.event.on + * @parent can.event.static + * @signature `obj.on( event, handler )` + * + * Add a basic event listener to an object. + * + * This is an alias of [can.event.addEvent addEvent]. + * + * @signature `can.event.on.call( obj, event, handler )` + * + * This syntax can be used for objects that don't include the `can.event` mixin. + */ + on: function() { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.on.call(this); + } + else { + return can.addEvent.apply(this, arguments); + } + }, + + /** + * @function can.event.off + * @parent can.event.static + * @signature `obj.off( event, handler )` + * + * Removes a basic event listener from an object. + * + * This is an alias of [can.event.removeEvent removeEvent]. + * + * @signature `can.event.off.call( obj, event, handler )` + * + * This syntax can be used for objects that don't include the `can.event` mixin. + */ + off: function() { + if (arguments.length === 0 && can.Control && this instanceof can.Control) { + return can.Control.prototype.off.call(this); + } + else { + return can.removeEvent.apply(this, arguments); + } + }, + + /** + * @function can.event.bind + * @parent can.event.static + * @signature `obj.bind( event, handler )` + * + * Add a basic event listener to an object. + * + * This is an alias of [can.event.addEvent addEvent]. + * + * @signature `can.event.bind.call( obj, event, handler )` + * + * This syntax can be used for objects that don't include the `can.event` mixin. + */ + bind: can.addEvent, + /** + * @function can.event.unbind + * @parent can.event.static + * @signature `obj.unbind( event, handler )` + * + * Removes a basic event listener from an object. + * + * This is an alias of [can.event.removeEvent removeEvent]. + * + * @signature `can.event.unbind.call( obj, event, handler )` + * + * This syntax can be used for objects that don't include the `can.event` mixin. + */ + unbind: can.removeEvent, + /** + * @function can.event.delegate + * @parent can.event.static + * @signature `obj.delegate( selector, event, handler )` + * + * Provides a compatibility layer for adding delegate event listeners. + * This doesn't actually implement delegates, but rather allows + * logic that assumes a delegate to still function. + * + * Therefore, this is essentially an alias of [can.event.addEvent addEvent] with the selector ignored. + * + * @param {String} selector The **ignored** selector to use for the delegate. + * @param {String} event The name of the event to listen for. + * @param {Function} handler The handler that will be executed to handle the event. + * @return {Object} this + * + * @signature `can.event.delegate.call( obj, selector, event, handler )` + * + * This syntax can be used for objects that don't include the `can.event` mixin. + */ + delegate: function(selector, event, handler) { + return can.addEvent.call(this, event, handler); + }, + /** + * @function can.event.undelegate + * @parent can.event.static + * @signature `obj.undelegate( selector, event, handler )` + * + * Provides a compatibility layer for removing delegate event listeners. + * This doesn't actually implement delegates, but rather allows + * logic that assumes a delegate to still function. + * + * Therefore, this is essentially an alias of [can.event.removeEvent removeEvent] with the selector ignored. + * + * @param {String} selector The **ignored** selector to use for the delegate. + * @param {String} event The name of the event to listen for. + * @param {Function} handler The handler that will be executed to handle the event. + * @return {Object} this + * + * @signature `can.event.undelegate.call( obj, selector, event, handler )` + * + * This syntax can be used for objects that don't include the `can.event` mixin. + */ + undelegate: function(selector, event, handler) { + return can.removeEvent.call(this, event, handler); + }, + /** + * @function can.event.trigger + * @parent can.event.static + * @signature `obj.trigger( event, args )` + * + * Dispatches/triggers a basic event on an object. + * This is an alias of [can.event.dispatch dispatch]. + * + * @signature `can.event.trigger.call( obj, event, args )` + * + * This syntax can be used for objects that don't include the `can.event` mixin. + */ + trigger: can.dispatch, + + // Normal can/event methods + one: can.one, + addEvent: can.addEvent, + removeEvent: can.removeEvent, + listenTo: can.listenTo, + stopListening: can.stopListening, + dispatch: can.dispatch + }; + + return can.event; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/list/list.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/list/list.js new file mode 100644 index 0000000000..5931903b90 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/list/list.js @@ -0,0 +1,1126 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#list/list*/ +steal("can/util", "can/map", "can/map/bubble.js",function (can, Map, bubble) { + + // Helpers for `observable` lists. + var splice = [].splice, + // test if splice works correctly + spliceRemovesProps = (function () { + // IE's splice doesn't remove properties + var obj = { + 0: "a", + length: 1 + }; + splice.call(obj, 0, 1); + return !obj[0]; + })(); + + /** + * @add can.List + */ + var list = Map.extend( + /** + * @static + */ + { + /** + * @property {can.Map} can.List.Map + * + * @description Specify the Map type used to make objects added to this list observable. + * + * @option {can.Map} When objects are added to a can.List, those objects are + * converted into can.Map instances. For example: + * + * var list = new can.List(); + * list.push({name: "Justin"}); + * + * var map = list.attr(0); + * map.attr("name") //-> "Justin" + * + * By changing [can.List.Map], you can specify a different type of Map instance to + * create. For example: + * + * var User = can.Map.extend({ + * fullName: function(){ + * return this.attr("first")+" "+this.attr("last") + * } + * }); + * + * User.List = can.List.extend({ + * Map: User + * }, {}); + * + * var list = new User.List(); + * list.push({first: "Justin", last: "Meyer"}); + * + * var user = list.attr(0); + * user.fullName() //-> "Justin Meyer" + * + * + * + */ + Map: Map + /** + * @function can.Map.extend + * + * @signature `can.List.extend([name,] [staticProperties,] instanceProperties)` + * + * Creates a new extended constructor function. Learn more at [can.Construct.extend]. + * + * @param {String} [name] If provided, adds the extened List constructor function + * to the window at the given name. + * + * @param {Object} [staticProperties] Properties and methods + * directly on the constructor function. The most common property to set is [can.List.Map]. + * + * @param {Object} [instanceProperties] Properties and methods on instances of this list type. + * + * @body + * + * ## Use + * + * + */ + }, + /** + * @prototype + */ + { + setup: function (instances, options) { + this.length = 0; + can.cid(this, ".map"); + this._init = 1; + this._computedBindings = {}; + this._setupComputes(); + instances = instances || []; + var teardownMapping; + + if (can.isDeferred(instances)) { + this.replace(instances); + } else { + teardownMapping = instances.length && can.Map.helpers.addToMap(instances, this); + this.push.apply(this, can.makeArray(instances || [])); + } + + if (teardownMapping) { + teardownMapping(); + } + + // this change needs to be ignored + this.bind('change', can.proxy(this._changes, this)); + can.simpleExtend(this, options); + delete this._init; + }, + _triggerChange: function (attr, how, newVal, oldVal) { + + Map.prototype._triggerChange.apply(this, arguments); + // `batchTrigger` direct add and remove events... + var index = +attr; + // Make sure this is not nested and not an expando + if (!~(""+attr).indexOf('.') && !isNaN(index)) { + + if (how === 'add') { + can.batch.trigger(this, how, [newVal, index]); + can.batch.trigger(this, 'length', [this.length]); + } else if (how === 'remove') { + can.batch.trigger(this, how, [oldVal, index]); + can.batch.trigger(this, 'length', [this.length]); + } else { + can.batch.trigger(this, how, [newVal, index]); + } + + } + + }, + __get: function (attr) { + if (attr) { + if (this[attr] && this[attr].isComputed && can.isFunction(this.constructor.prototype[attr])) { + return this[attr](); + } else { + return this[attr]; + } + } else { + return this; + } + }, + __set: function (prop, value, current) { + // We want change events to notify using integers if we're + // setting an integer index. Note that % 1 !== 0; + prop = isNaN(+prop) || (prop % 1) ? prop : +prop; + + // Check to see if we're doing a .attr() on an out of + // bounds index property. + if (typeof prop === "number" && + prop > this.length - 1) { + var newArr = new Array((prop + 1) - this.length); + newArr[newArr.length-1] = value; + this.push.apply(this, newArr); + return newArr; + } + + return can.Map.prototype.__set.call(this, ""+prop, value, current); + }, + ___set: function (attr, val) { + this[attr] = val; + if (+attr >= this.length) { + this.length = (+attr + 1); + } + }, + _remove: function(prop, current) { + // if removing an expando property + if(isNaN(+prop)) { + delete this[prop]; + this._triggerChange(prop, "remove", undefined, current); + } else { + this.splice(prop, 1); + } + }, + _each: function (callback) { + var data = this.__get(); + for (var i = 0; i < data.length; i++) { + callback(data[i], i); + } + }, + // Returns the serialized form of this list. + /** + * @hide + * Returns the serialized form of this list. + */ + serialize: function () { + return Map.helpers.serialize(this, 'serialize', []); + }, + /** + * @function can.List.prototype.each each + * @description Call a function on each element of a List. + * @signature `list.each( callback(item, index) )` + * + * `each` iterates through the Map, calling a function + * for each element. + * + * @param {function(*, Number)} callback the function to call for each element + * The value and index of each element will be passed as the first and second + * arguments, respectively, to the callback. If the callback returns false, + * the loop will stop. + * + * @return {can.List} this List, for chaining + * + * @body + * ``` + * var i = 0; + * new can.Map([1, 10, 100]).each(function(element, index) { + * i += element; + * }); + * + * i; // 111 + * + * i = 0; + * new can.Map([1, 10, 100]).each(function(element, index) { + * i += element; + * if(index >= 1) { + * return false; + * } + * }); + * + * i; // 11 + * ``` + */ + // + /** + * @function can.List.prototype.splice splice + * @description Insert and remove elements from a List. + * @signature `list.splice(index[, howMany[, ...newElements]])` + * @param {Number} index where to start removing or inserting elements + * + * @param {Number} [howMany] the number of elements to remove + * If _howMany_ is not provided, `splice` will remove all elements from `index` to the end of the List. + * + * @param {*} newElements elements to insert into the List + * + * @return {Array} the elements removed by `splice` + * + * @body + * `splice` lets you remove elements from and insert elements into a List. + * + * This example demonstrates how to do surgery on a list of numbers: + * + * ``` + * var list = new can.List([0, 1, 2, 3]); + * + * // starting at index 2, remove one element and insert 'Alice' and 'Bob': + * list.splice(2, 1, 'Alice', 'Bob'); + * list.attr(); // [0, 1, 'Alice', 'Bob', 3] + * ``` + * + * ## Events + * + * `splice` causes the List it's called on to emit _change_ events, + * _add_ events, _remove_ events, and _length_ events. If there are + * any elements to remove, a _change_ event, a _remove_ event, and a + * _length_ event will be fired. If there are any elements to insert, a + * separate _change_ event, an _add_ event, and a separate _length_ event + * will be fired. + * + * This slightly-modified version of the above example should help + * make it clear how `splice` causes events to be emitted: + * + * ``` + * var list = new can.List(['a', 'b', 'c', 'd']); + * list.bind('change', function(ev, attr, how, newVals, oldVals) { + * console.log('change: ' + attr + ', ' + how + ', ' + newVals + ', ' + oldVals); + * }); + * list.bind('add', function(ev, newVals, where) { + * console.log('add: ' + newVals + ', ' + where); + * }); + * list.bind('remove', function(ev, oldVals, where) { + * console.log('remove: ' + oldVals + ', ' + where); + * }); + * list.bind('length', function(ev, length) { + * console.log('length: ' + length + ', ' + this.attr()); + * }); + * + * // starting at index 2, remove one element and insert 'Alice' and 'Bob': + * list.splice(2, 1, 'Alice', 'Bob'); // change: 2, 'remove', undefined, ['c'] + * // remove: ['c'], 2 + * // length: 5, ['a', 'b', 'Alice', 'Bob', 'd'] + * // change: 2, 'add', ['Alice', 'Bob'], ['c'] + * // add: ['Alice', 'Bob'], 2 + * // length: 5, ['a', 'b', 'Alice', 'Bob', 'd'] + * ``` + * + * More information about binding to these events can be found under [can.List.attr attr]. + */ + splice: function (index, howMany) { + var args = can.makeArray(arguments), + added =[], + i, len, listIndex, + allSame = args.length > 2; + + index = index || 0; + + // converting the arguments to the right type + for (i = 0, len = args.length-2; i < len; i++) { + listIndex = i + 2; + args[listIndex] = this.__type(args[listIndex], listIndex); + added.push(args[listIndex]); + + // Now lets check if anything will change + if(this[i+index] !== args[listIndex]) { + allSame = false; + } + } + + // if nothing has changed, then return + if(allSame && this.length <= added.length) { + return added; + } + + // default howMany if not provided + if (howMany === undefined) { + howMany = args[1] = this.length - index; + } + + var removed = splice.apply(this, args); + + // delete properties for browsers who's splice sucks (old ie) + if (!spliceRemovesProps) { + for (i = this.length; i < removed.length + this.length; i++) { + delete this[i]; + } + } + + can.batch.start(); + if (howMany > 0) { + // tears down bubbling + bubble.removeMany(this, removed); + this._triggerChange("" + index, "remove", undefined, removed); + } + if (args.length > 2) { + // make added items bubble to this list + for (i = 0, len = added.length; i < len; i++) { + bubble.set(this, i, added[i]); + } + this._triggerChange("" + index, "add", added, removed); + } + can.batch.stop(); + return removed; + }, + /** + * @description Get or set elements in a List. + * @function can.List.prototype.attr attr + * + * @signature `list.attr()` + * + * Gets an array of all the elements in this `can.List`. + * + * @return {Array} An array with all the elements in this List. + * + * @signature `list.attr(index)` + * + * Reads an element from this `can.List`. + * + * @param {Number} index The element to read. + * @return {*} The value at _index_. + * + * @signature `list.attr(index, value)` + * + * Assigns _value_ to the index _index_ on this `can.List`, expanding the list if necessary. + * + * @param {Number} index The element to set. + * @param {*} value The value to assign at _index_. + * @return {can.List} This list, for chaining. + * + * @signature `list.attr(elements[, replaceCompletely])` + * + * Merges the members of _elements_ into this List, replacing each from the beginning in order. If + * _elements_ is longer than the current List, the current List will be expanded. If _elements_ + * is shorter than the current List, the extra existing members are not affected (unless + * _replaceCompletely_ is `true`). To remove elements without replacing them, use `[can.Map::removeAttr removeAttr]`. + * + * @param {Array} elements An array of elements to merge in. + * + * @param {bool} [replaceCompletely=false] whether to completely replace the elements of List + * If _replaceCompletely_ is `true` and _elements_ is shorter than the List, the existing + * extra members of the List will be removed. + * + * @return {can.List} This list, for chaining. + * + * @body + * + * + * ## Use + * + * `attr` gets or sets elements on the `can.List` it's called on. Here's a tour through + * how all of its forms work: + * + * var people = new can.List(['Alex', 'Bill']); + * + * // set an element: + * people.attr(0, 'Adam'); + * + * // get an element: + * people.attr(0); // 'Adam' + * people[0]; // 'Adam' + * + * // get all elements: + * people.attr(); // ['Adam', 'Bill'] + * + * // extend the array: + * people.attr(4, 'Charlie'); + * people.attr(); // ['Adam', 'Bill', undefined, undefined, 'Charlie'] + * + * // merge the elements: + * people.attr(['Alice', 'Bob', 'Eve']); + * people.attr(); // ['Alice', 'Bob', 'Eve', undefined, 'Charlie'] + * + * ## Deep properties + * + * `attr` can also set and read deep properties. All you have to do is specify + * the property name as you normally would if you weren't using `attr`. + * + * ``` + * var people = new can.List([{name: 'Alex'}, {name: 'Bob'}]); + * + * // set a property: + * people.attr('0.name', 'Alice'); + * + * // get a property: + * people.attr('0.name'); // 'Alice' + * people[0].attr('name'); // 'Alice' + * + * // get all properties: + * people.attr(); // [{name: 'Alice'}, {name: 'Bob'}] + * ``` + * + * The discussion of deep properties under `[can.Map.prototype.attr]` may also + * be enlightening. + * + * ## Events + * + * `can.List`s emit five types of events in response to changes. They are: + * + * - the _change_ event fires on every change to a List. + * - the _set_ event is fired when an element is set. + * - the _add_ event is fired when an element is added to the List. + * - the _remove_ event is fired when an element is removed from the List. + * - the _length_ event is fired when the length of the List changes. + * + * ### The _change_ event + * + * The first event that is fired is the _change_ event. The _change_ event is useful + * if you want to react to all changes on an List. + * + * ``` + * var list = new can.List([]); + * list.bind('change', function(ev, index, how, newVal, oldVal) { + * console.log('Something changed.'); + * }); + * ``` + * + * The parameters of the event handler for the _change_ event are: + * + * - _ev_ The event object. + * - _index_ Where the change took place. + * - _how_ Whether elements were added, removed, or set. + * Possible values are `'add'`, `'remove'`, or `'set'`. + * - _newVal_ The elements affected after the change + * _newVal_ will be a single value when an index is set, an Array when elements + * were added, and `undefined` if elements were removed. + * - _oldVal_ The elements affected before the change. + * _newVal_ will be a single value when an index is set, an Array when elements + * were removed, and `undefined` if elements were added. + * + * Here is a concrete tour through the _change_ event handler's arguments: + * + * ``` + * var list = new can.List(); + * list.bind('change', function(ev, index, how, newVal, oldVal) { + * console.log(ev + ', ' + index + ', ' + how + ', ' + newVal + ', ' + oldVal); + * }); + * + * list.attr(['Alexis', 'Bill']); // [object Object], 0, add, ['Alexis', 'Bill'], undefined + * list.attr(2, 'Eve'); // [object Object], 2, add, Eve, undefined + * list.attr(0, 'Adam'); // [object Object], 0, set, Adam, Alexis + * list.attr(['Alice', 'Bob']); // [object Object], 0, set, Alice, Adam + * // [object Object], 1, set, Bob, Bill + * list.removeAttr(1); // [object Object], 1, remove, undefined, Bob + * ``` + * + * ### The _set_ event + * + * _set_ events are fired when an element at an index that already exists in the List is + * modified. Actions can cause _set_ events to fire never also cause _length_ events + * to fire (although some functions, such as `[can.List.prototype.splice splice]` + * may cause unrelated sets of events to fire after being batched). + * + * The parameters of the event handler for the _set_ event are: + * + * - _ev_ The event object. + * - _newVal_ The new value of the element. + * - _index_ where the set took place. + * + * Here is a concrete tour through the _set_ event handler's arguments: + * + * ``` + * var list = new can.List(); + * list.bind('set', function(ev, newVal, index) { + * console.log(newVal + ', ' + index); + * }); + * + * list.attr(['Alexis', 'Bill']); + * list.attr(2, 'Eve'); + * list.attr(0, 'Adam'); // Adam, 0 + * list.attr(['Alice', 'Bob']); // Alice, 0 + * // Bob, 1 + * list.removeAttr(1); + * ``` + * + * ### The _add_ event + * + * _add_ events are fired when elements are added or inserted + * into the List. + * + * The parameters of the event handler for the _add_ event are: + * + * - _ev_ The event object. + * - _newElements_ The new elements. + * An array of zero or more elements that were added. + * - _index_ Where the add or insert took place. + * + * Here is a concrete tour through the _add_ event handler's arguments: + * + * ``` + * var list = new can.List(); + * list.bind('add', function(ev, newElements, index) { + * console.log(newElements + ', ' + index); + * }); + * + * list.attr(['Alexis', 'Bill']); // ['Alexis', 'Bill'], 0 + * list.attr(2, 'Eve'); // Eve, 2 + * list.attr(0, 'Adam'); + * list.attr(['Alice', 'Bob']); + * + * list.removeAttr(1); + * ``` + * + * ### The _remove_ event + * + * _remove_ events are fired when elements are removed from the list. + * + * The parameters of the event handler for the _remove_ event are: + * + * - _ev_ The event object. + * - _removedElements_ The removed elements. + * An array of zero or more elements that were removed. + * - _index_ Where the removal took place. + * + * Here is a concrete tour through the _remove_ event handler's arguments: + * + * ``` + * var list = new can.List(); + * list.bind('remove', function(ev, removedElements, index) { + * console.log(removedElements + ', ' + index); + * }); + * + * list.attr(['Alexis', 'Bill']); + * list.attr(2, 'Eve'); + * list.attr(0, 'Adam'); + * list.attr(['Alice', 'Bob']); + * + * list.removeAttr(1); // Bob, 1 + * ``` + * + * ### The _length_ event + * + * _length_ events are fired whenever the list changes. + * + * The parameters of the event handler for the _length_ event are: + * + * - _ev_ The event object. + * - _length_ The current length of the list. + * If events were batched when the _length_ event was triggered, _length_ + * will have the length of the list when `stopBatch` was called. Because + * of this, you may receive multiple _length_ events with the same + * _length_ parameter. + * + * Here is a concrete tour through the _length_ event handler's arguments: + * + * ``` + * var list = new can.List(); + * list.bind('length', function(ev, length) { + * console.log(length); + * }); + * + * list.attr(['Alexis', 'Bill']); // 2 + * list.attr(2, 'Eve'); // 3 + * list.attr(0, 'Adam'); + * list.attr(['Alice', 'Bob']); + * + * list.removeAttr(1); // 2 + * ``` + */ + _attrs: function (items, remove) { + if (items === undefined) { + return Map.helpers.serialize(this, 'attr', []); + } + + // Create a copy. + items = can.makeArray(items); + + can.batch.start(); + this._updateAttrs(items, remove); + can.batch.stop(); + }, + + _updateAttrs: function (items, remove) { + var len = Math.min(items.length, this.length); + + for (var prop = 0; prop < len; prop++) { + var curVal = this[prop], + newVal = items[prop]; + + if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal)) { + curVal.attr(newVal, remove); + //changed from a coercion to an explicit + } else if (curVal !== newVal) { + this._set(prop, newVal); + } else { + + } + } + if (items.length > this.length) { + // Add in the remaining props. + this.push.apply(this, items.slice(this.length)); + } else if (items.length < this.length && remove) { + this.splice(items.length); + } + } + }), + + // Converts to an `array` of arguments. + getArgs = function (args) { + return args[0] && can.isArray(args[0]) ? + args[0] : + can.makeArray(args); + }; + // Create `push`, `pop`, `shift`, and `unshift` + can.each({ + /** + * @function can.List.prototype.push push + * @description Add elements to the end of a list. + * @signature `list.push(...elements)` + * + * `push` adds elements onto the end of a List. + * + * @param {*} elements the elements to add to the List + * + * @return {Number} the new length of the List + * + * @body + * `push` adds elements onto the end of a List here is an example: + * + * ``` + * var list = new can.List(['Alice']); + * + * list.push('Bob', 'Eve'); + * list.attr(); // ['Alice', 'Bob', 'Eve'] + * ``` + * + * If you have an array you want to concatenate to the end + * of the List, you can use `apply`: + * + * ``` + * var names = ['Bob', 'Eve'], + * list = new can.List(['Alice']); + * + * list.push.apply(list, names); + * list.attr(); // ['Alice', 'Bob', 'Eve'] + * ``` + * + * ## Events + * + * `push` causes _change_, _add_, and _length_ events to be fired. + * + * ## See also + * + * `push` has a counterpart in [can.List::pop pop], or you may be + * looking for [can.List::unshift unshift] and its counterpart [can.List::shift shift]. + */ + push: "length", + /** + * @function can.List.prototype.unshift unshift + * @description Add elements to the beginning of a List. + * @signature `list.unshift(...elements)` + * + * `unshift` adds elements onto the beginning of a List. + * + * @param {*} elements the elements to add to the List + * + * @return {Number} the new length of the List + * + * @body + * `unshift` adds elements to the front of the list in bulk in the order specified: + * + * ``` + * var list = new can.List(['Alice']); + * + * list.unshift('Bob', 'Eve'); + * list.attr(); // ['Bob', 'Eve', 'Alice'] + * ``` + * + * If you have an array you want to concatenate to the beginning + * of the List, you can use `apply`: + * + * ``` + * var names = ['Bob', 'Eve'], + * list = new can.List(['Alice']); + * + * list.push.apply(list, names); + * list.attr(); // ['Bob', 'Eve', 'Alice'] + * ``` + * + * ## Events + * + * `unshift` causes _change_, _add_, and _length_ events to be fired. + * + * ## See also + * + * `unshift` has a counterpart in [can.List::shift shift], or you may be + * looking for [can.List::push push] and its counterpart [can.List::pop pop]. + */ + unshift: 0 + }, + // Adds a method + // `name` - The method name. + // `where` - Where items in the `array` should be added. + function (where, name) { + var orig = [][name]; + list.prototype[name] = function () { + // Get the items being added. + var args = [], + // Where we are going to add items. + len = where ? this.length : 0, + i = arguments.length, + res, val; + + // Go through and convert anything to an `map` that needs to be converted. + while (i--) { + val = arguments[i]; + args[i] = bubble.set(this, i, this.__type(val, i) ); + } + + // Call the original method. + res = orig.apply(this, args); + + if (!this.comparator || args.length) { + + this._triggerChange("" + len, "add", args, undefined); + } + + return res; + }; + }); + + can.each({ + /** + * @function can.List.prototype.pop pop + * @description Remove an element from the end of a List. + * @signature `list.pop()` + * + * `pop` removes an element from the end of a List. + * + * @return {*} the element just popped off the List, or `undefined` if the List was empty + * + * @body + * `pop` is the opposite action from `[can.List.push push]`: + * + * ``` + * var list = new can.List(['Alice', 'Bob', 'Eve']); + * list.attr(); // ['Alice', 'Bob', 'Eve'] + * + * list.pop(); // 'Eve' + * list.pop(); // 'Bob' + * list.pop(); // 'Alice' + * list.pop(); // undefined + * ``` + * + * ## Events + * + * `pop` causes _change_, _remove_, and _length_ events to be fired if the List is not empty + * when it is called. + * + * ## See also + * + * `pop` has its counterpart in [can.List::push push], or you may be + * looking for [can.List::unshift unshift] and its counterpart [can.List::shift shift]. + */ + pop: "length", + /** + * @function can.List.prototype.shift shift + * @description Remove en element from the front of a list. + * @signature `list.shift()` + * + * `shift` removes an element from the beginning of a List. + * + * @return {*} the element just shifted off the List, or `undefined` if the List is empty + * + * @body + * `shift` is the opposite action from `[can.List::unshift unshift]`: + * + * ``` + * var list = new can.List(['Alice']); + * + * list.unshift('Bob', 'Eve'); + * list.attr(); // ['Bob', 'Eve', 'Alice'] + * + * list.shift(); // 'Bob' + * list.shift(); // 'Eve' + * list.shift(); // 'Alice' + * list.shift(); // undefined + * ``` + * + * ## Events + * + * `pop` causes _change_, _remove_, and _length_ events to be fired if the List is not empty + * when it is called. + * + * ## See also + * + * `shift` has a counterpart in [can.List::unshift unshift], or you may be + * looking for [can.List::push push] and its counterpart [can.List::pop pop]. + */ + shift: 0 + }, + // Creates a `remove` type method + function (where, name) { + list.prototype[name] = function () { + if (!this.length) { + // For shift and pop, we just return undefined without + // triggering events. + return undefined; + } + + var args = getArgs(arguments), + len = where && this.length ? this.length - 1 : 0; + + var res = [][name].apply(this, args); + + // Create a change where the args are + // `len` - Where these items were removed. + // `remove` - Items removed. + // `undefined` - The new values (there are none). + // `res` - The old, removed values (should these be unbound). + this._triggerChange("" + len, "remove", undefined, [res]); + + if (res && res.unbind) { + bubble.remove(this, res); + } + + return res; + }; + }); + + can.extend(list.prototype, { + /** + * @function can.List.prototype.indexOf indexOf + * @description Look for an item in a List. + * @signature `list.indexOf(item)` + * + * `indexOf` finds the position of a given item in the List. + * + * @param {*} item the item to find + * + * @return {Number} the position of the item in the List, or -1 if the item is not found. + * + * @body + * ``` + * var list = new can.List(['Alice', 'Bob', 'Eve']); + * list.indexOf('Alice'); // 0 + * list.indexOf('Charlie'); // -1 + * ``` + * + * It is trivial to make a `contains`-type function using `indexOf`: + * + * ``` + * function(list, item) { + * return list.indexOf(item) >= 0; + * } + * ``` + */ + indexOf: function (item, fromIndex) { + this.attr('length'); + return can.inArray(item, this, fromIndex); + }, + + /** + * @function can.List.prototype.join join + * @description Join a List's elements into a string. + * @signature `list.join(separator)` + * + * `join` turns a List into a string by inserting _separator_ between the string representations + * of all the elements of the List. + * + * @param {String} separator the string to seperate elements with + * + * @return {String} the joined string + * + * @body + * ``` + * var list = new can.List(['Alice', 'Bob', 'Eve']); + * list.join(', '); // 'Alice, Bob, Eve' + * + * var beatles = new can.List(['John', 'Paul', 'Ringo', 'George']); + * beatles.join('&'); // 'John&Paul&Ringo&George' + * ``` + */ + join: function () { + return [].join.apply(this.attr(), arguments); + }, + + /** + * @function can.List.prototype.reverse reverse + * @description Reverse the order of a List. + * @signature `list.reverse()` + * + * `reverse` reverses the elements of the List in place. + * + * @return {can.List} the List, for chaining + * + * @body + * ``` + * var list = new can.List(['Alice', 'Bob', 'Eve']); + * var reversedList = list.reverse(); + * + * reversedList.attr(); // ['Eve', 'Bob', 'Alice']; + * list === reversedList; // true + * ``` + */ + reverse: function() { + var list = [].reverse.call(can.makeArray(this)); + this.replace(list); + }, + + /** + * @function can.List.prototype.slice slice + * @description Make a copy of a part of a List. + * @signature `list.slice([start[, end]])` + * + * `slice` creates a copy of a portion of the List. + * + * @param {Number} [start=0] the index to start copying from + * + * @param {Number} [end] the first index not to include in the copy + * If _end_ is not supplied, `slice` will copy until the end of the list. + * + * @return {can.List} a new `can.List` with the extracted elements + * + * @body + * ``` + * var list = new can.List(['Alice', 'Bob', 'Charlie', 'Daniel', 'Eve']); + * var newList = list.slice(1, 4); + * newList.attr(); // ['Bob', 'Charlie', 'Daniel'] + * ``` + * + * `slice` is the simplest way to copy a List: + * + * ``` + * var list = new can.List(['Alice', 'Bob', 'Eve']); + * var copy = list.slice(); + * + * copy.attr(); // ['Alice', 'Bob', 'Eve'] + * list === copy; // false + * ``` + */ + slice: function () { + var temp = Array.prototype.slice.apply(this, arguments); + return new this.constructor(temp); + }, + + /** + * @function can.List.prototype.concat concat + * @description Merge many collections together into a List. + * @signature `list.concat(...args)` + * @param {Array|can.List|*} args Any number of arrays, Lists, or values to add in + * For each parameter given, if it is an Array or a List, each of its elements will be added to + * the end of the concatenated List. Otherwise, the parameter itself will be added. + * + * @body + * `concat` makes a new List with the elements of the List followed by the elements of the parameters. + * + * ``` + * var list = new can.List(); + * var newList = list.concat( + * 'Alice', + * ['Bob', 'Charlie']), + * new can.List(['Daniel', 'Eve']), + * {f: 'Francis'} + * ); + * newList.attr(); // ['Alice', 'Bob', 'Charlie', 'Daniel', 'Eve', {f: 'Francis'}] + * ``` + */ + concat: function () { + var args = []; + can.each(can.makeArray(arguments), function (arg, i) { + args[i] = arg instanceof can.List ? arg.serialize() : arg; + }); + return new this.constructor(Array.prototype.concat.apply(this.serialize(), args)); + }, + + /** + * @function can.List.prototype.forEach forEach + * @description Call a function for each element of a List. + * @signature `list.forEach(callback[, thisArg])` + * @param {function(element, index, list)} callback a function to call with each element of the List + * The three parameters that _callback_ gets passed are _element_, the element at _index_, _index_ the + * current element of the list, and _list_ the List the elements are coming from. + * @param {Object} [thisArg] the object to use as `this` inside the callback + * + * @body + * `forEach` calls a callback for each element in the List. + * + * ``` + * var list = new can.List([1, 2, 3]); + * list.forEach(function(element, index, list) { + * list.attr(index, element * element); + * }); + * list.attr(); // [1, 4, 9] + * ``` + */ + forEach: function (cb, thisarg) { + return can.each(this, cb, thisarg || this); + }, + + /** + * @function can.List.prototype.replace replace + * @description Replace all the elements of a List. + * @signature `list.replace(collection)` + * @param {Array|can.List|can.Deferred} collection the collection of new elements to use + * If a [can.Deferred] is passed, it must resolve to an `Array` or `can.List`. + * The elements of the list are not actually removed until the Deferred resolves. + * + * @body + * `replace` replaces all the elements of this List with new ones. + * + * `replace` is especially useful when `can.List`s are live-bound into `[can.Control]`s, + * and you intend to populate them with the results of a `[can.Model]` call: + * + * ``` + * can.Control({ + * init: function() { + * this.list = new Todo.List(); + * // live-bind the list into the DOM + * this.element.html(can.view('list.mustache', this.list)); + * // when this AJAX call returns, the live-bound DOM will be updated + * this.list.replace(Todo.findAll()); + * } + * }); + * ``` + * + * Learn more about [can.Model.List making Lists of models]. + * + * ## Events + * + * A major difference between `replace` and `attr(newElements, true)` is that `replace` always emits + * an _add_ event and a _remove_ event, whereas `attr` will cause _set_ events along with an _add_ or _remove_ + * event if needed. Corresponding _change_ and _length_ events will be fired as well. + * + * The differences in the events fired by `attr` and `replace` are demonstrated concretely by this example: + * ``` + * var attrList = new can.List(['Alexis', 'Bill']); + * attrList.bind('change', function(ev, index, how, newVals, oldVals) { + * console.log(index + ', ' + how + ', ' + newVals + ', ' + oldVals); + * }); + * + * var replaceList = new can.List(['Alexis', 'Bill']); + * replaceList.bind('change', function(ev, index, how, newVals, oldVals) { + * console.log(index + ', ' + how + ', ' + newVals + ', ' + oldVals); + * }); + * + * attrList.attr(['Adam', 'Ben'], true); // 0, set, Adam, Alexis + * // 1, set, Ben, Bill + * replaceList.replace(['Adam', 'Ben']); // 0, remove, undefined, ['Alexis', 'Bill'] + * // 0, add, undefined, ['Adam', 'Ben'] + * + * attrList.attr(['Amber'], true); // 0, set, Amber, Adam + * // 1, remove, undefined, Ben + * replaceList.replace(['Amber']); // 0, remove, undefined, ['Adam', 'Ben'] + * // 0, add, Amber, ['Adam', 'Ben'] + * + * attrList.attr(['Alice', 'Bob', 'Eve'], true); // 0, set, Alice, Amber + * // 1, add, ['Bob', 'Eve'], undefined + * replaceList.replace(['Alice', 'Bob', 'Eve']); // 0, remove, undefined, Amber + * // 0, add, ['Alice', 'Bob', 'Eve'], Amber + * ``` + */ + replace: function (newList) { + if (can.isDeferred(newList)) { + newList.then(can.proxy(this.replace, this)); + } else { + this.splice.apply(this, [0, this.length].concat(can.makeArray(newList || []))); + } + + return this; + }, + filter: function (callback, thisArg) { + var filteredList = new can.List(), + self = this, + filtered; + this.each(function(item, index, list){ + filtered = callback.call( thisArg | self, item, index, self); + if(filtered){ + filteredList.push(item); + } + }); + return filteredList; + } + }); + can.List = Map.List = list; + return can.List; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/list/promise/promise.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/list/promise/promise.js new file mode 100644 index 0000000000..9919393ea5 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/list/promise/promise.js @@ -0,0 +1,77 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#list/promise/promise*/ +steal("can/list", function (list) { + + var oldReplace = can.List.prototype.replace; + + can.List.prototype.replace = function (data) { + // First call the old replace so its + // deferred callbacks will be called first + var result = oldReplace.apply(this, arguments); + + // If there is a deferred: + if (can.isDeferred(data)) { + // Set up its state. Must call this way + // because we are working on an array. + can.batch.start(); + this.attr("state", data.state()); + this.removeAttr("reason"); + can.batch.stop(); + + var self = this; + // update its state when it changes + var deferred = this._deferred = new can.Deferred(); + + data.then(function(){ + self.attr("state", data.state()); + // The deferred methods will always return this object + deferred.resolve(self); + },function(reason){ + can.batch.start(); + self.attr("state", data.state()); + self.attr("reason", reason); + can.batch.stop(); + deferred.reject(reason); + }); + } + return result; + }; + + can.each({ + isResolved: "resolved", + isPending: "pending", + isRejected: "rejected" + }, function (value, method) { + can.List.prototype[method] = function () { + return this.attr("state") === value; + }; + }); + + + can.each([ + "then", + "done", + "fail", + "always", + "promise" + ], function (name) { + can.List.prototype[name] = function () { + // it's possible a list is created manually and returned as the result + // of .then. It should not break. + if(!this._deferred) { + this._deferred = new can.Deferred(); + this._deferred.resolve(this); + } + + return this._deferred[name].apply(this._deferred, arguments); + }; + }); +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/list/sort/sort.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/list/sort/sort.js new file mode 100644 index 0000000000..801afd745b --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/list/sort/sort.js @@ -0,0 +1,401 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#list/sort/sort*/ +steal('can/util', 'can/list', function () { + + // BUBBLE RULE + // 1. list.bind("change") -> bubbling + // list.unbind("change") -> no bubbling + + // 2. list.attr("comparator","id") -> nothing + // list.bind("length") -> bubbling + // list.removeAttr("comparator") -> nothing + + // 3. list.bind("change") -> bubbling + // list.attr("comparator","id") -> bubbling + // list.unbind("change") -> no bubbling + + + + // 4. list.bind("length") -> nothing + // list.attr("comparator","id") -> bubbling + // list.removeAttr("comparator") -> nothing + + // 5. list.bind("length") -> nothing + // list.attr("comparator","id") -> bubbling + // list.unbind("length") -> nothing + + // Change bubble rule to bubble on change if there is a comparator. + var oldBubbleRule = can.List._bubbleRule; + can.List._bubbleRule = function(eventName, list) { + var oldBubble = oldBubbleRule.apply(this, arguments); + + if (list.comparator && can.inArray('change', oldBubble) === -1) { + oldBubble.push('change'); + } + + return oldBubble; + }; + + var proto = can.List.prototype, + _changes = proto._changes, + setup = proto.setup, + unbind = proto.unbind; + + //Add `move` as an event that lazy-bubbles + + // extend the list for sorting support + + can.extend(proto, { + setup: function (instances, options) { + setup.apply(this, arguments); + this._comparatorBound = false; + this._init = 1; + this.bind('comparator', can.proxy(this._comparatorUpdated, this)); + delete this._init; + + if (this.comparator) { + this.sort(); + } + }, + _comparatorUpdated: function(ev, newValue){ + if( newValue || newValue === 0 ) { + this.sort(); + + if(this._bindings > 0 && ! this._comparatorBound) { + this.bind("change", this._comparatorBound = function(){}); + } + } else if(this._comparatorBound){ + unbind.call(this, "change", this._comparatorBound); + this._comparatorBound = false; + + } + + // if anyone is listening to this object + }, + unbind: function(ev, handler){ + var res = unbind.apply(this, arguments); + + if(this._comparatorBound && this._bindings === 1) { + unbind.call(this,"change", this._comparatorBound); + this._comparatorBound = false; + } + + return res; + }, + _comparator: function (a, b) { + var comparator = this.comparator; + + // If the user has defined a comparator, use it + if (comparator && typeof comparator === 'function') { + return comparator(a, b); + } + + return a === b ? 0 : a < b ? -1 : 1; + }, + _changes: function (ev, attr, how, newVal, oldVal) { + + // If a comparator is defined and the change was to a + // list item, consider moving the item. + if (this.comparator && /^\d+/.test(attr)) { + + if (ev.batchNum && ev.batchNum !== this._lastBatchNum) { + this.sort(); + this._lastBatchNum = ev.batchNum; + return; + } + + // get the index + var currentIndex = +/^\d+/.exec(attr)[0], + // and item + item = this[currentIndex]; + + if (typeof item !== 'undefined') { + + // Determine where this item should reside as a result + // of the change + var newIndex = this._getInsertIndex(item, currentIndex); + + if (newIndex !== currentIndex) { + this._swapItems(currentIndex, newIndex); + + // Trigger length change so that {{#block}} helper can re-render + can.trigger(this, 'length', [ + this.length + ]); + } + + } + } + _changes.apply(this, arguments); + }, + /** + * @hide + */ + _getInsertIndex: function (item, currentIndex) { + var a = this._getComparatorValue(item), + b, + offset = 0; + + for (var i = 0; i < this.length; i++) { + b = this._getComparatorValue(this[i]); + + // If we've reached the index that the item currently + // resides in and still haven't found an ideal insert index, + // offset the returned index by -1 to account for the fact + // that this item would be moved if placed at the + // suggested index. + if (typeof currentIndex !== 'undefined' && i === currentIndex) { + offset = -1; + continue; + } + + // If we've found an item ranked greater than or the same as this + // item, consider this a good "insert" index. + if (this._comparator(a, b) < 0) { + return i + offset; + } + } + + // The index of the last item in the list + return i + offset; + }, + + _getComparatorValue: function (item, overwrittenComparator) { + + // Use the value passed to .sort() as the comparator value + // if it is a string + var comparator = typeof overwrittenComparator === 'string' ? + overwrittenComparator : + this.comparator; + + // If the comparator is a string use that value to get + // property on the item. If the comparator is a method, + // it'll be used elsewhere. + if (item && comparator && typeof comparator === 'string') { + item = typeof item[comparator] === 'function' ? + item[comparator]() : + item.attr(comparator); + } + + return item; + }, + + _getComparatorValues: function () { + var self = this; + var a = []; + this.each(function (item, index) { + a.push(self._getComparatorValue(item)); + }); + return a; + }, + + /** + * @hide + */ + sort: function (comparator, silent) { + var a, b, c, isSorted; + + // Use the value passed to .sort() as the comparator function + // if it is a function + var comparatorFn = can.isFunction(comparator) ? + comparator : + this._comparator; + + for (var i, iMin, j = 0, n = this.length; j < n-1; j++) { + iMin = j; + + isSorted = true; + c = undefined; + + for (i = j+1; i < n; i++) { + + a = this._getComparatorValue(this.attr(i), comparator); + b = this._getComparatorValue(this.attr(iMin), comparator); + + // [1, 2, 3, 4(b), 9, 6, 3(a)] + if (comparatorFn.call(this, a, b) < 0) { + isSorted = false; + iMin = i; + } + + // [1, 2, 3, 4, 8(b), 12, 49, 9(c), 6(a), 3] + // While iterating over the unprocessed items in search + // of a "min", attempt to find two neighboring values + // that are improperly sorted. + // Note: This is not part of the original selection + // sort agortithm + if (c && comparatorFn.call(this, a, c) < 0) { + isSorted = false; + } + + c = a; + } + + if (isSorted) { + break; + } + + if (iMin !== j) { + this._swapItems(iMin, j, silent); + } + } + + + if (! silent) { + // Trigger length change so that {{#block}} helper can re-render + can.trigger(this, 'length', [this.length]); + } + + return this; + }, + + /** + * @hide + */ + _swapItems: function (oldIndex, newIndex, silent) { + + var temporaryItemReference = this[oldIndex]; + + // Remove the item from the list + [].splice.call(this, oldIndex, 1); + + // Place the item at the correct index + [].splice.call(this, newIndex, 0, temporaryItemReference); + + if (! silent) { + // Update the DOM via can.view.live.list + can.trigger(this, 'move', [ + temporaryItemReference, + newIndex, + oldIndex + ]); + } + } + + }); + // create push, unshift + // converts to an array of arguments + var getArgs = function (args) { + return args[0] && can.isArray(args[0]) ? args[0] : can.makeArray(args); + }; + can.each({ + /** + * @function push + * Add items to the end of the list. + * + * var l = new can.List([]); + * + * l.bind('change', function( + * ev, // the change event + * attr, // the attr that was changed, for multiple items, "*" is used + * how, // "add" + * newVals, // an array of new values pushed + * oldVals, // undefined + * where // the location where these items where added + * ) { + * + * }) + * + * l.push('0','1','2'); + * + * @param {...*} [...items] items to add to the end of the list. + * @return {Number} the number of items in the array + */ + push: "length", + /** + * @function unshift + * Add items to the start of the list. This is very similar to + * [can.List::push]. Example: + * + * var l = new can.List(["a","b"]); + * l.unshift(1,2,3) //-> 5 + * l.attr() //-> [1,2,3,"a","b"] + * + * @param {...*} [...items] items to add to the start of the list. + * @return {Number} the length of the array. + */ + unshift: 0 + }, + // adds a method where + // @param where items in the array should be added + // @param name method name + function (where, name) { + var proto = can.List.prototype, + old = proto[name]; + proto[name] = function () { + + if (this.comparator && arguments.length) { + // get the items being added + var args = getArgs(arguments); + var i = args.length; + + while (i--) { + // Go through and convert anything to an `map` that needs + // to be converted. + var val = can.bubble.set(this, i, this.__type(args[i], i) ); + + // Insert this item at the correct index + var newIndex = this._getInsertIndex(val); + Array.prototype.splice.apply(this, [newIndex, 0, val]); + + this._triggerChange('' + newIndex, 'add', [val], undefined); + } + + can.batch.trigger(this, 'reset', [args]); + + return this; + } else { + // call the original method + return old.apply(this, arguments); + } + + + + }; + }); + + // Overwrite .splice so that items added to the list (no matter what the + // defined index) are inserted at the correct index, while preserving the + // ability to remove items from a list. + (function () { + var proto = can.List.prototype; + var oldSplice = proto.splice; + + proto.splice = function (index, howMany) { + + var args = can.makeArray(arguments), + newElements =[], + i, len; + + // Don't use this "sort" oriented splice unless this list has a + // comparator + if (! this.comparator) { + return oldSplice.apply(this, args); + } + + // Get the list of new items intended to be added to the list + for (i = 2, len = args.length; i < len; i++) { + args[i] = this.__type(args[i], i); + newElements.push(args[i]); + } + + // Remove items using the original splice method + oldSplice.call(this, index, howMany); + + // Add items by way of push so that they're sorted into + // the correct position + proto.push.apply(this, newElements); + }; + })(); + + + return can.Map; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/attributes/attributes.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/attributes/attributes.js new file mode 100644 index 0000000000..36088c4aa4 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/attributes/attributes.js @@ -0,0 +1,167 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/attributes/attributes*/ +steal('can/util', 'can/map', 'can/list', function (can, Map) { + + //!steal-remove-start + can.dev.warn("can/map/attributes is a deprecated plugin and will be removed in a future release. "+ + "can/map/define provides the same functionality in a more complete API."); + //!steal-remove-end + + can.each([ + can.Map, + can.Model + ], function (clss) { + + // in some cases model might not be defined quite yet. + if (clss === undefined) { + return; + } + var isObject = function (obj) { + return typeof obj === 'object' && obj !== null && obj; + }; + can.extend(clss, { + + attributes: {}, + + convert: { + 'date': function (str) { + var type = typeof str; + if (type === 'string') { + str = Date.parse(str); + return isNaN(str) ? null : new Date(str); + } else if (type === 'number') { + return new Date(str); + } else { + return str; + } + }, + 'number': function (val) { + return parseFloat(val); + }, + 'boolean': function (val) { + if (val === 'false' || val === '0' || !val) { + return false; + } + return true; + }, + 'default': function (val, oldVal, error, type) { + // Convert can.Model types using .model and .models + if (can.Map.prototype.isPrototypeOf(type.prototype) && typeof type.model === 'function' && typeof type.models === 'function') { + return type[can.isArray(val) ? 'models' : 'model'](val); + } + if (can.Map.prototype.isPrototypeOf(type.prototype)) { + if (can.isArray(val) && typeof type.List === 'function') { + return new type.List(val); + } + return new type(val); + } + if (typeof type === 'function') { + return type(val, oldVal); + } + var construct = can.getObject(type), + context = window, + realType; + // if type has a . we need to look it up + if (type.indexOf('.') >= 0) { + // get everything before the last . + realType = type.substring(0, type.lastIndexOf('.')); + // get the object before the last . + context = can.getObject(realType); + } + return typeof construct === 'function' ? construct.call(context, val, oldVal) : val; + } + }, + serialize: { + 'default': function (val, type) { + return isObject(val) && val.serialize ? val.serialize() : val; + }, + 'date': function (val) { + return val && val.getTime(); + } + } + }); + // overwrite setup to do this stuff + var oldSetup = clss.setup; + /** + * @hide + * @function can.Map.setup + * @parent can.Map.attributes + * + * `can.Map.static.setup` overrides default `can.Map` setup to provide + * functionality for attributes. + * + */ + clss.setup = function (superClass, stat, proto) { + var self = this; + oldSetup.call(self, superClass, stat, proto); + can.each(['attributes'], function (name) { + if (!self[name] || superClass[name] === self[name]) { + self[name] = {}; + } + }); + can.each([ + 'convert', + 'serialize' + ], function (name) { + if (superClass[name] !== self[name]) { + self[name] = can.extend({}, superClass[name], self[name]); + } + }); + }; + }); + /** + * @hide + * @function can.Map.prototype.convert + * @parent can.Map.attributes + */ + can.Map.prototype.__convert = function (prop, value) { + // check if there is a + var Class = this.constructor, + oldVal = this.__get(prop), + type, converter; + if (Class.attributes) { + // the type of the attribute + type = Class.attributes[prop]; + converter = Class.convert[type] || Class.convert['default']; + } + return value === null || !type ? value : converter.call(Class, value, oldVal, function () {}, type); + }; + + var oldSerialize = can.Map.helpers._serialize; + can.Map.helpers._serialize = function(map, name, val){ + + var constructor = map.constructor, + type = constructor.attributes ? constructor.attributes[name] : 0, + converter = constructor.serialize ? constructor.serialize[type] : 0; + + return val && typeof val.serialize === 'function' ? + // call attrs or serialize to get the original data back + oldSerialize.apply(this, arguments) : + // otherwise if we have a converter + converter ? + // use the converter + converter(val, type) : + // or return the val + oldSerialize.apply(this, arguments); + }; + // add support for single value serialize + var mapSerialize = can.Map.prototype.serialize; + can.Map.prototype.serialize = function (attrName) { + var baseResult = mapSerialize.apply(this, arguments); + if(attrName){ + return baseResult[attrName]; + } else { + return baseResult; + } + }; + + return can.Map; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/backup/backup.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/backup/backup.js new file mode 100644 index 0000000000..0ea3eef105 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/backup/backup.js @@ -0,0 +1,49 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/backup/backup*/ +//allows you to backup and restore a map instance +steal('can/util', 'can/compute', 'can/map', 'can/util/object', function (can) { + var flatProps = function (a, cur) { + var obj = {}; + for (var prop in a) { + if (typeof a[prop] !== 'object' || a[prop] === null || a[prop] instanceof Date) { + obj[prop] = a[prop]; + } else { + obj[prop] = cur.attr(prop); + } + } + return obj; + }; + + var oldSetup = can.Map.prototype.setup; + + can.extend(can.Map.prototype, { + setup: function() { + this._backupStore = can.compute(); + return oldSetup.apply(this, arguments); + }, + + backup: function () { + this._backupStore(this.attr()); + return this; + }, + isDirty: function (checkAssociations) { + return this._backupStore() && !can.Object.same(this.attr(), this._backupStore(), undefined, undefined, undefined, !! checkAssociations); + }, + restore: function (restoreAssociations) { + var props = restoreAssociations ? this._backupStore() : flatProps(this._backupStore(), this); + if (this.isDirty(restoreAssociations)) { + this.attr(props, true); + } + return this; + } + }); + return can.Map; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/bubble.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/bubble.js new file mode 100644 index 0000000000..9da00bf895 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/bubble.js @@ -0,0 +1,153 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/bubble*/ +steal('can/util', function(can){ + + + + var bubble = can.bubble = { + // Given a binding, returns a string event name used to set up bubbline. + // If no binding should be done, undefined or null should be returned + event: function(map, boundEventName) { + return map.constructor._bubbleRule(boundEventName, map); + }, + childrenOf: function (parentMap, eventName) { + + parentMap._each(function (child, prop) { + if (child && child.bind) { + bubble.toParent(child, parentMap, prop, eventName); + } + }); + + }, + teardownChildrenFrom: function(parentMap, eventName){ + parentMap._each(function (child) { + + bubble.teardownFromParent(parentMap, child, eventName); + + }); + }, + toParent: function(child, parent, prop, eventName) { + can.listenTo.call(parent, child, eventName, function ( /* ev, attr */ ) { + // `batchTrigger` the type on this... + var args = can.makeArray(arguments), + ev = args.shift(); + + args[0] = + (can.List && parent instanceof can.List ? + parent.indexOf(child) : + prop ) + (args[0] ? "."+args[0] : ""); + + // track objects dispatched on this map + ev.triggeredNS = ev.triggeredNS || {}; + + // if it has already been dispatched exit + if (ev.triggeredNS[parent._cid]) { + return; + } + + ev.triggeredNS[parent._cid] = true; + // send change event with modified attr to parent + can.trigger(parent, ev, args); + }); + }, + teardownFromParent: function (parent, child, eventName ) { + if(child && child.unbind ) { + can.stopListening.call(parent, child, eventName); + } + }, + isBubbling: function(parent, eventName){ + return parent._bubbleBindings && parent._bubbleBindings[eventName]; + }, + bind: function(parent, eventName) { + if (!parent._init ) { + var bubbleEvents = bubble.event(parent, eventName), + len = bubbleEvents.length, + bubbleEvent; + + if(!parent._bubbleBindings) { + parent._bubbleBindings = {}; + } + + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + + if (!parent._bubbleBindings[bubbleEvent]) { + parent._bubbleBindings[bubbleEvent] = 1; + // setup live-binding + bubble.childrenOf(parent, bubbleEvent); + } else { + parent._bubbleBindings[bubbleEvent]++; + } + } + } + }, + unbind: function(parent, eventName) { + var bubbleEvents = bubble.event(parent, eventName), + len = bubbleEvents.length, + bubbleEvent; + + for (var i = 0; i < len; i++) { + bubbleEvent = bubbleEvents[i]; + + if (parent._bubbleBindings ) { + parent._bubbleBindings[bubbleEvent]--; + } + + if (parent._bubbleBindings && !parent._bubbleBindings[bubbleEvent] ) { + delete parent._bubbleBindings[bubbleEvent]; + bubble.teardownChildrenFrom(parent, bubbleEvent); + if(can.isEmptyObject(parent._bubbleBindings)) { + delete parent._bubbleBindings; + } + } + } + }, + add: function(parent, child, prop){ + if(child instanceof can.Map && parent._bubbleBindings) { + for(var eventName in parent._bubbleBindings) { + if( parent._bubbleBindings[eventName] ) { + bubble.teardownFromParent(parent, child, eventName); + bubble.toParent(child, parent, prop, eventName); + } + } + } + }, + removeMany: function(parent, children){ + for(var i = 0, len = children.length; i < len; i++) { + bubble.remove(parent, children[i]); + } + }, + remove: function(parent, child){ + if(child instanceof can.Map && parent._bubbleBindings) { + for(var eventName in parent._bubbleBindings) { + if( parent._bubbleBindings[eventName] ) { + bubble.teardownFromParent(parent, child, eventName); + } + } + } + }, + set: function(parent, prop, value, current){ + + //var res = parent.__type(value, prop); + if( can.Map.helpers.isObservable(value) ) { + bubble.add(parent, value, prop); + } + // bubble.add will remove, so only remove if we are replacing another object + if( can.Map.helpers.isObservable(current) ) { + bubble.remove(parent, current); + } + return value; + } + }; + + return bubble; + +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/define/define.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/define/define.js new file mode 100644 index 0000000000..8b04d46f28 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/define/define.js @@ -0,0 +1,372 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/define/define*/ +steal('can/util', 'can/observe', function (can) { + var define = can.define = {}; + + var getPropDefineBehavior = function(behavior, attr, define) { + var prop, defaultProp; + + if(define) { + prop = define[attr]; + defaultProp = define['*']; + + if(prop && prop[behavior] !== undefined) { + return prop[behavior]; + } + else if(defaultProp && defaultProp[behavior] !== undefined) { + return defaultProp[behavior]; + } + } + }; + + // This is called when the Map is defined + can.Map.helpers.define = function (Map) { + var definitions = Map.prototype.define; + //!steal-remove-start + if(Map.define){ + can.dev.warn("The define property should be on the map's prototype properties, "+ + "not the static properies."); + } + //!steal-remove-end + Map.defaultGenerators = {}; + for (var prop in definitions) { + var type = definitions[prop].type; + if( typeof type === "string" ) { + if(typeof define.types[type] === "object") { + delete definitions[prop].type; + can.extend(definitions[prop], define.types[type]); + } + } + if ("value" in definitions[prop]) { + if (typeof definitions[prop].value === "function") { + Map.defaultGenerators[prop] = definitions[prop].value; + } else { + Map.defaults[prop] = definitions[prop].value; + } + } + if (typeof definitions[prop].Value === "function") { + (function (Constructor) { + Map.defaultGenerators[prop] = function () { + return new Constructor(); + }; + })(definitions[prop].Value); + } + } + }; + + + var oldSetupDefaults = can.Map.prototype._setupDefaults; + can.Map.prototype._setupDefaults = function (obj) { + var defaults = oldSetupDefaults.call(this), + propsCommittedToAttr = {}, + Map = this.constructor, + originalGet = this._get; + + // Overwrite this._get with a version that commits defaults to + // this.attr() as needed. Because calling this.attr() for each individual + // default would be expensive. + this._get = function (originalProp) { + + // If a this.attr() was called using dot syntax (e.g number.0), + // disregard everything after the "." until we call the + // original this._get(). + prop = (originalProp.indexOf('.') !== -1 ? + originalProp.substr(0, originalProp.indexOf('.')) : + prop); + + // If this property has a default and we haven't yet committed it to + // this.attr() + if ((prop in defaults) && ! (prop in propsCommittedToAttr)) { + + // Commit the property's default so that it can be read in + // other defaultGenerators. + this.attr(prop, defaults[prop]); + + // Make not so that we don't commit this property again. + propsCommittedToAttr[prop] = true; + } + + return originalGet.apply(this, arguments); + }; + + for (var prop in Map.defaultGenerators) { + // Only call the prop's value method if the property wasn't provided + // during instantiation. + if (! obj || ! (prop in obj)) { + defaults[prop] = Map.defaultGenerators[prop].call(this); + } + } + + // Replace original this.attr + this._get = originalGet; + + return defaults; + }; + + + var proto = can.Map.prototype, + oldSet = proto.__set; + proto.__set = function (prop, value, current, success, error) { + //!steal-remove-start + var asyncTimer; + //!steal-remove-end + + // check if there's a setter + var errorCallback = function (errors) { + //!steal-remove-start + clearTimeout(asyncTimer); + //!steal-remove-end + + var stub = error && error.call(self, errors); + // if 'validations' is on the page it will trigger + // the error itself and we dont want to trigger + // the event twice. :) + if (stub !== false) { + can.trigger(self, 'error', [ + prop, + errors + ], true); + } + return false; + }, + self = this, + setter = getPropDefineBehavior("set", prop, this.define), + getter = getPropDefineBehavior("get", prop, this.define); + + + // if we have a setter + if (setter) { + // call the setter, if returned value is undefined, + // this means the setter is async so we + // do not call update property and return right away + can.batch.start(); + var setterCalled = false, + + setValue = setter.call(this, value, function (value) { + if(getter) { + self[prop](value); + } else { + oldSet.call(self, prop, value, current, success, errorCallback); + } + + setterCalled = true; + //!steal-remove-start + clearTimeout(asyncTimer); + //!steal-remove-end + }, errorCallback, getter ? this[prop].computeInstance.lastSetValue.get() : current); + if (getter) { + // if there's a getter we don't call old set + // instead we call the getter's compute with the new value + if(setValue !== undefined && !setterCalled && setter.length >= 1) { + this[prop](setValue); + } + + can.batch.stop(); + return; + } + // if it took a setter and returned nothing, don't set the value + else if (setValue === undefined && !setterCalled && setter.length >= 1) { + //!steal-remove-start + asyncTimer = setTimeout(function () { + can.dev.warn('can/map/setter.js: Setter "' + prop + '" did not return a value or call the setter callback.'); + }, can.dev.warnTimeout); + //!steal-remove-end + can.batch.stop(); + return; + } else { + if (!setterCalled) { + oldSet.call(self, prop, + // if no arguments, we are side-effects only + setter.length === 0 && setValue === undefined ? value : setValue, + current, + success, + errorCallback); + } + can.batch.stop(); + return this; + } + + } else { + oldSet.call(self, prop, value, current, success, errorCallback); + } + + return this; + }; + + define.types = { + 'date': function (str) { + var type = typeof str; + if (type === 'string') { + str = Date.parse(str); + return isNaN(str) ? null : new Date(str); + } else if (type === 'number') { + return new Date(str); + } else { + return str; + } + }, + 'number': function (val) { + if(val == null) { + return val; + } + return +(val); + }, + 'boolean': function (val) { + if (val === 'false' || val === '0' || !val) { + return false; + } + return true; + }, + /** + * Implements HTML-style boolean logic for attribute strings, where + * any string, including "", is truthy. + */ + 'htmlbool': function(val) { + return typeof val === "string" || !!val; + }, + '*': function (val) { + return val; + }, + 'string': function (val) { + if(val == null) { + return val; + } + return '' + val; + }, + 'compute': { + set: function(newValue, setVal, setErr, oldValue){ + if(newValue.isComputed) { + return newValue; + } + if(oldValue && oldValue.isComputed) { + oldValue(newValue); + return oldValue; + } + return newValue; + }, + get: function(value){ + return value && value.isComputed ? value() : value; + } + } + }; + + // the old type sets up bubbling + var oldType = proto.__type; + proto.__type = function (value, prop) { + var type = getPropDefineBehavior("type", prop, this.define), + Type = getPropDefineBehavior("Type", prop, this.define), + newValue = value; + + if (typeof type === "string") { + type = define.types[type]; + } + + if (type || Type) { + // If there's a type, convert it. + if (type) { + newValue = type.call(this, newValue, prop); + } + // If there's a Type create a new instance of it + if (Type && !(newValue instanceof Type)) { + newValue = new Type(newValue); + } + // If the newValue is a Map, we need to hook it up + return newValue; + + } + // If we pass in a object with define + else if(can.isPlainObject(newValue) && newValue.define) { + newValue = can.Map.extend(newValue); + newValue = new newValue(); + } + return oldType.call(this, newValue, prop); + }; + + var oldRemove = proto._remove; + proto._remove = function (prop, current) { + var remove = getPropDefineBehavior("remove", prop, this.define), + res; + if (remove) { + can.batch.start(); + res = remove.call(this, current); + + if (res === false) { + can.batch.stop(); + return; + } else { + + res = oldRemove.call(this, prop, current); + can.batch.stop(); + return res; + } + } + return oldRemove.call(this, prop, current); + }; + + var oldSetupComputes = proto._setupComputes; + proto._setupComputes = function (defaultsValues) { + oldSetupComputes.apply(this, arguments); + for (var attr in this.define) { + var def = this.define[attr], + get = def.get; + if (get) { + this[attr] = can.compute.async(defaultsValues[attr], get, this); + this._computedBindings[attr] = { + count: 0 + }; + } + } + }; + // Overwrite the invidual property serializer b/c we will overwrite it. + var oldSingleSerialize = can.Map.helpers._serialize; + can.Map.helpers._serialize = function(map, name, val){ + return serializeProp(map, name, val); + }; + // If the map has a define serializer for the given attr, run it. + var serializeProp = function(map, attr, val) { + var serializer = attr === "*" ? false : getPropDefineBehavior("serialize", attr, map.define); + if(serializer === undefined) { + return oldSingleSerialize.apply(this, arguments); + } else if(serializer !== false){ + return typeof serializer === "function" ? serializer.call(map, val, attr): oldSingleSerialize.apply(this, arguments); + } + }; + + // Overwrite serialize to add in any missing define serialized properties. + var oldSerialize = proto.serialize; + proto.serialize = function (property) { + var serialized = oldSerialize.apply(this, arguments); + if(property){ + return serialized; + } + // add in properties not already serialized + + var serializer, + val; + // Go through each property. + for(var attr in this.define){ + // if it's not already defined + if(!(attr in serialized)) { + // check there is a serializer so we aren't doing extra work on serializer:false + serializer = this.define && this.define[attr] && this.define[attr].serialize; + if(serializer) { + val = serializeProp(this, attr, this.attr(attr)); + if(val !== undefined) { + serialized[attr] = val; + } + } + } + } + return serialized; + }; + + return can.define; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/delegate/delegate.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/delegate/delegate.js new file mode 100644 index 0000000000..85a39f36a8 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/delegate/delegate.js @@ -0,0 +1,198 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/delegate/delegate*/ +steal('can/util', 'can/map', function (can) { + // ** - 'this' will be the deepest item changed + // * - 'this' will be any changes within *, but * will be the + // this returned + // tells if the parts part of a delegate matches the broken up props of the event + // gives the prop to use as 'this' + // - parts - the attribute name of the delegate split in parts ['foo','*'] + // - props - the split props of the event that happened ['foo','bar','0'] + // - returns - the attribute to delegate too ('foo.bar'), or null if not a match + var delegateMatches = function (parts, props) { + //check props parts are the same or + var len = parts.length, + i = 0, + // keeps the matched props we will use + matchedProps = [], + prop; + // if the event matches + for (i; i < len; i++) { + prop = props[i]; + // if no more props (but we should be matching them) + // return null + if (typeof prop !== 'string') { + return null; + } else // if we have a "**", match everything + if (parts[i] === '**') { + return props.join('.'); + } else // a match, but we want to delegate to "*" + if (parts[i] === '*') { + // only do this if there is nothing after ... + matchedProps.push(prop); + } else if (prop === parts[i]) { + matchedProps.push(prop); + } else { + return null; + } + } + return matchedProps.join('.'); + }, + // gets a change event and tries to figure out which + // delegates to call + delegateHandler = function (event, prop, how, newVal, oldVal) { + // pre-split properties to save some regexp time + var props = prop.split('.'), + delegates = (this._observe_delegates || []) + .slice(0), + delegate, attr, matchedAttr, hasMatch, valuesEqual; + event.attr = prop; + event.lastAttr = props[props.length - 1]; + // for each delegate + for (var i = 0; delegate = delegates[i++];) { + // if there is a batchNum, this means that this + // event is part of a series of events caused by a single + // attrs call. We don't want to issue the same event + // multiple times + // setting the batchNum happens later + if (event.batchNum && delegate.batchNum === event.batchNum || delegate.undelegated) { + continue; + } + // reset match and values tests + hasMatch = undefined; + valuesEqual = true; + // yeah, all this under here has to be redone v + // for each attr in a delegate + for (var a = 0; a < delegate.attrs.length; a++) { + attr = delegate.attrs[a]; + matchedAttr = delegateMatches(attr.parts, props); + // check if it is a match + if (matchedAttr) { + hasMatch = matchedAttr; + } + // if it has a value, make sure it's the right value + // if it's set, we should probably check that it has a + // value no matter what + if (attr.value && valuesEqual) { + valuesEqual = attr.value === '' + this.attr(attr.attr); + } else if (valuesEqual && delegate.attrs.length > 1) { + // if there are multiple attributes, each has to at + // least have some value + valuesEqual = this.attr(attr.attr) !== undefined; + } + } + // if there is a match and valuesEqual ... call back + if (hasMatch && valuesEqual) { + // how to get to the changed property from the delegate + var from = prop.replace(hasMatch + '.', ''); + // if this event is part of a batch, set it on the delegate + // to only send one event + if (event.batchNum) { + delegate.batchNum = event.batchNum; + } + // if we listen to change, fire those with the same attrs + // TODO: the attrs should probably be using from + if (delegate.event === 'change') { + prop = from; + event.curAttr = hasMatch; + delegate.callback.apply(this.attr(hasMatch), can.makeArray(arguments)); + } else if (delegate.event === how) { + // if it's a match, callback with the location of the match + delegate.callback.apply(this.attr(hasMatch), [ + event, + newVal, + oldVal, + from + ]); + } else if (delegate.event === 'set' && how === 'add') { + // if we are listening to set, we should also listen to add + delegate.callback.apply(this.attr(hasMatch), [ + event, + newVal, + oldVal, + from + ]); + } + } + } + }; + can.extend(can.Map.prototype, { + delegate: function (selector, event, handler) { + selector = can.trim(selector); + var delegates = this._observe_delegates || (this._observe_delegates = []), + attrs = [], + selectorRegex = /([^\s=,]+)(?:=("[^",]*"|'[^',]*'|[^\s"',]*))?(,?)\s*/g, + matches; + // parse each property in the selector + while ((matches = selectorRegex.exec(selector)) !== null) { + // we need to do a little doctoring to make up for the quotes. + if (matches[2] && can.inArray(matches[2].substr(0, 1), [ + '"', + '\'' + ]) >= 0) { + matches[2] = matches[2].substr(1, -1); + } + attrs.push({ + // the attribute name + attr: matches[1], + // the attribute name, pre-split for speed + parts: matches[1].split('.'), + // the value associated with this property (if there was one given) + value: matches[2], + // whether this selector combines with the one after it with AND or OR + or: matches[3] === ',' + }); + } + // delegates has pre-processed info about the event + delegates.push({ + // the attrs name for unbinding + selector: selector, + // an object of attribute names and values {type: 'recipe',id: undefined} + // undefined means a value was not defined + attrs: attrs, + callback: handler, + event: event + }); + if (delegates.length === 1) { + this.bind('change', delegateHandler); + } + return this; + }, + undelegate: function (selector, event, handler) { + selector = selector && can.trim(selector); + var i = 0, + delegates = this._observe_delegates || [], + delegateOb; + if (selector) { + while (i < delegates.length) { + delegateOb = delegates[i]; + if (delegateOb.callback === handler || !handler && delegateOb.selector === selector) { + delegateOb.undelegated = true; + delegates.splice(i, 1); + } else { + i++; + } + } + } else { + // remove all delegates + delegates = []; + } + if (!delegates.length) { + //can.removeData(this, "_observe_delegates"); + this.unbind('change', delegateHandler); + } + return this; + } + }); + // add helpers for testing .. + can.Map.prototype.delegate.matches = delegateMatches; + return can.Map; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/lazy/bubble.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/lazy/bubble.js new file mode 100644 index 0000000000..47c9d59f76 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/lazy/bubble.js @@ -0,0 +1,27 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/lazy/bubble*/ +steal('can/util', 'can/map/bubble.js', function(can) { + var bubble = can.bubble; + + return can.extend({}, bubble, { + childrenOf: function (parentMap, eventName) { + if(parentMap._nestedReference) { + parentMap._nestedReference.each(function (child, ref) { + if (child && child.bind) { + bubble.toParent(child, parentMap, ref(), eventName); + } + }); + } else { + bubble._each.apply(this, arguments); + } + } + }); +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/lazy/lazy.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/lazy/lazy.js new file mode 100644 index 0000000000..4a4af627e6 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/lazy/lazy.js @@ -0,0 +1,341 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/lazy/lazy*/ +steal('can/util', './bubble.js', 'can/map', 'can/list', './nested_reference.js', function (can, bubble) { + + can.LazyMap = can.Map.extend({ + _bubble: bubble + }, { + setup: function (obj) { + this.constructor.Map = this.constructor; + this.constructor.List = can.LazyList; + + // `_data` is where we keep the properties. + this._data = can.extend(can.extend(true, {}, this._setupDefaults() || {}), obj); + + // The namespace this `object` uses to listen to events. + can.cid(this, ".lazyMap"); + // Sets all `attrs`. + this._init = 1; + this._computedBindings = {}; + this._setupComputes(); + var teardownMapping = obj && can.Map.helpers.addToMap(obj, this); + + + // keep references to Observes in `_data` + this._nestedReference = new can.NestedReference(this._data); + + if (teardownMapping) { + teardownMapping(); + } + + // Make the data directly accessible (if possible) + can.each(this._data, can.proxy(function(value, prop) { + this.___set(prop, value); + }, this)); + this.bind('change', can.proxy(this._changes, this)); + + delete this._init; + }, + + // todo: function should be renamed + _addChild: function (path, newChild, setNewChild) { + var self = this; + + // remove 'old' references that are starting with `path` and do rewiring + this._nestedReference.removeChildren(path, function (oldChild, oldChildPath) { + // unhook every current child on path + bubble.remove(self, oldChild); + + // if `newChild` passed bind it to every child and make references (1st step: rewiring to bottom/children) + if (newChild) { + var newChildPath = oldChildPath.replace(path + ".", ""); + + // check if we are replacing existing observe or inserting new one + if (path === newChildPath) { + // + oldChild._nestedReference.each(function (obj, path) { + newChild._nestedReference.make(path()); + if (self._bindings) { + bubble.add(this, newChild, path()); + } + }); + // + } else { + var reference = newChild._nestedReference.make(newChildPath); + if (self._bindings) { + bubble.add(oldChild, newChild, reference()); + } + } + + } + }); + + // callback + if (setNewChild) { + setNewChild(); + } + + // bind parent on `newChild` and make reference (2st step: rewiring to top/parent) + if (newChild) { + var reference = this._nestedReference.make(path); + if (this._bindings) { + bubble.add(this, newChild, reference()); + } + } + return newChild; + }, + + removeAttr: function (attr) { + var data = this._goto(attr); + + // if there are more attr parts remaining, it means we + // hit an internal observable + if (data.parts.length) { + // ask that observable to remove the attr + return data.value.removeAttr(data.parts.join(".")); + } else { + // otherwise, are we removing a property from an array + if (can.isArray(data.parent)) { + data.parent.splice(data.prop, 1); + this._triggerChange(attr, "remove", undefined, [this.__type(data.value, data.prop)]); + } else { + // do not trigger if prop does not exists + if (data.parent[data.prop]) { + delete data.parent[data.prop]; + can.batch.trigger(this, data.path.length ? data.path.join(".") + ".__keys" : "__keys"); + this._triggerChange(attr, "remove", undefined, this.__type(data.value, data.prop)); + } + } + // unhookup anything that was in here + //this._addChild(attr); // --> CHECK THIS ONE! (previous bug was causing this to work even if it shouldn't,) + // instead remove all references, do not unbind as _addChild does + this._nestedReference.removeChildren(); + return data.value; + } + }, + // converts the value into an observable if needed + __type: function(value, prop){ + // If we are getting an object. + if (!( value instanceof can.LazyMap) && can.Map.helpers.canMakeObserve(value) ) { + + if( can.isArray(value) ) { + var List = can.LazyList; + return new List(value); + } else { + var Map = this.constructor.Map || can.LazyMap; + return new Map(value); + } + } + return value; + }, + // walks to a property on the lazy map + // if it finds an object, uses [] to follow properties + // if it finds something else, it uses __get + _goto: function (attr, keepKey) { + var parts = can.Map.helpers.attrParts(attr, keepKey).slice(0), + prev, + path = [], + part; + + // are we dealing with list or map + var cur = this instanceof can.List ? this[parts.shift()] : this.__get(); + + // TODO we might also have to check for dot separated keys in each iteration + while (cur && !can.Map.helpers.isObservable(cur) && parts.length) { + if (part !== undefined) { + path.push(part); + } + prev = cur; + cur = cur[part = parts.shift()]; + } + + return { + parts: parts, + prop: part, + value: cur, + parent: prev, + path: path + }; + }, + // Reads a property from the `object`. + _get: function (attr) { + can.__observe(this, attr); + var data = this._goto(attr); + + // if it's already observe return it + if (can.Map.helpers.isObservable(data.value)) { + if (data.parts.length) { + return data.value._get(data.parts); + } else { + return data.value; + } + } else if (data.value && can.Map.helpers.canMakeObserve(data.value)) { + // if object create LazyMap/LazyList + var converted = this.__type(data.value, data.prop); + // ... and replace it + this._addChild(attr, converted, function () { + data.parent[data.prop] = converted; + }); + return converted; + } else if(data.value !== undefined) { + // Return if we have a value + return data.value; + } else { + // Otherwise get it directly from this object + return this.__get(attr); + } + }, + // Sets `attr` prop as value on this object where. + // `attr` - Is a string of properties or an array of property values. + // `value` - The raw value to set. + _set: function (attr, value, keepKey) { + var data = this._goto(attr, keepKey); + if (can.Map.helpers.isObservable(data.value) && data.parts.length) { + return data.value._set(data.parts, value); + } else if (!data.parts.length) { + this.__set(attr, value, data.value, data); + } else { + throw "can.LazyMap: object does not exist"; + } + }, + __set: function (prop, value, current, data, convert) { + // Otherwise, we are setting it on this `object`. + // are we changing the value. + + // maybe not needed at all + convert = convert || true; + + if (value !== current) { + // Check if we are adding this for the first time -- + // if we are, we need to create an `add` event. + + var changeType = data.parent.hasOwnProperty(data.prop) ? "set" : "add"; + + // if it is or should be a Lazy + if (convert && can.Map.helpers.canMakeObserve(value)) { + // make it a lazy + value = this.__type(value, prop); + var self = this; + // hook up it's bindings + this._addChild(prop, value, function () { + // set the value + self.___set(prop, value, data); + }); + } else { + // just set the value + this.___set(prop, value, data); + } + + if (changeType === "add") { + // If there is no current value, let others know that + // the the number of keys have changed + + can.batch.trigger(this, data.path.length ? data.path.join(".") + ".__keys" : "__keys", undefined); + + } + // `batchTrigger` the change event. + this._triggerChange(prop, changeType, value, current); + } + }, + // Directly sets a property on this `object`. + ___set: function (prop, val, data) { + if (this[prop] && this[prop].isComputed && can.isFunction(this.constructor.prototype[prop])) { + this[prop](val); + } else if (data) { + data.parent[data.prop] = val; + } else { + this._data[prop] = val; + } + + // Add property directly for easy writing. + // Check if its on the `prototype` so we don't overwrite methods like `attrs`. + if (!(can.isFunction(this.constructor.prototype[prop]))) { + this[prop] = val; + } + }, + /** + * @hide + * Set multiple properties on the observable + * @param {Object} props + * @param {Boolean} remove true if you should remove properties that are not in props + */ + _attrs: function (props, remove) { + if (props === undefined) { + return can.Map.helpers.serialize(this, 'attr', {}); + } + + props = can.extend({}, props); + var self = this, + prop, + data, + newVal; + + can.batch.start(); + + // Update existing props + this.each(function (curVal, prop) { + newVal = props[prop]; + data = self._goto(prop, true); + + // remove existing prop and return if there is no new prop to merge and `remove` param exists + if (newVal === undefined) { + if (remove) { + self.removeAttr(prop); + } + return; + } else if (!can.Map.helpers.isObservable(curVal) && can.Map.helpers.canMakeObserve(curVal)) { + // convert curVal to observe + curVal = self.attr(prop); + } + + // + if (self.__convert) { + newVal = self.__convert(prop, newVal); + } + + // if we're dealing with models, want to call _set to let converter run + if (newVal instanceof can.Map) { + self.__set(prop, newVal, curVal, data); + // if its an object, let attr merge + } else if (can.Map.helpers.isObservable(curVal) && can.Map.helpers.canMakeObserve(newVal) && curVal.attr) { + curVal.attr(newVal, remove); + // otherwise just set + } else if (curVal !== newVal) { + // OK till here + self.__set(prop, newVal, curVal, data); + } + + // delete passed prop after setting + delete props[prop]; + }); + + // add remaining props + for (prop in props) { + newVal = props[prop]; + this._set(prop, newVal, true); + } + + can.batch.stop(); + return this; + } + }); + + can.LazyList = can.List.extend({ + Map: can.LazyMap + }, { + setup: function() { + can.List.prototype.setup.apply(this, arguments); + this._nestedReference = new can.NestedReference(this); + } + }); + + return can.LazyMap; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/lazy/nested_reference.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/lazy/nested_reference.js new file mode 100644 index 0000000000..c6d63592a2 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/lazy/nested_reference.js @@ -0,0 +1,113 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/lazy/nested_reference*/ +steal('can/util', function (can) { + + // iterates through `propPath` + // and calls `callback` with current object and path part + var pathIterator = function (root, propPath, callback) { + var props = propPath.split("."), + cur = root, + part; + while (part = props.shift()) { + cur = cur[part]; + if (callback) { + callback(cur, part); + } + } + return cur; + }; + + // has `array` and `item` props, toString() returns item's index in `array` + var ArrIndex = function (array) { + this.array = array; + }; + ArrIndex.prototype.toString = function () { + return "" + can.inArray(this.item, this.array); + }; + + // `root` points to actual data + // `references` keeps path functions to certain nodes within `root` + var NestedReference = function (root) { + this.root = root; + this.references = []; + }; + + NestedReference.ArrIndex = ArrIndex; + + can.extend(NestedReference.prototype, { + + // pushes path func to `references` + make: function (propPath) { + var path = [], // holds path elements + arrIndex; + + if (can.isArray(this.root) || this.root instanceof can.LazyList) { + arrIndex = new ArrIndex(this.root); + } + + // iter through `propPath` and keep path elements in `path` + pathIterator(this.root, propPath, function (item, prop) { + if (arrIndex) { + arrIndex.item = item; + path.push(arrIndex); + arrIndex = undefined; + } else { + path.push(prop); + if (can.isArray(item)) { + arrIndex = new ArrIndex(item); + } + } + }); + + // finally push path func to references and return + var pathFunc = function () { + return path.join("."); + }; + + this.references.push(pathFunc); + return pathFunc; + }, + + // removes all references that starts with `path` + // calls `callback` with object on the current path and path itself + removeChildren: function (path, callback) { + var i = 0; + while (i < this.references.length) { + var reference = this.references[i](); + if (reference.indexOf(path) === 0) { + callback(this.get(reference), reference); + this.references.splice(i, 1); + } else { + i++; + } + } + }, + + // returns node on the `path` + get: function (path) { + return pathIterator(this.root, path); + }, + + // iterates through references and calls `callback` + // with actual object, path func and path + each: function (callback) { + var self = this; + can.each(this.references, function (ref) { + var path = ref(); + callback(self.get(path), ref, path); + }); + } + + }); + + // expose + can.NestedReference = NestedReference; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/list/list.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/list/list.js new file mode 100644 index 0000000000..0143d35ef1 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/list/list.js @@ -0,0 +1,120 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/list/list*/ +steal('can/util', 'can/map', 'can/list', 'can/compute', function (can) { + can.extend(can.List.prototype, { + filter: function (callback) { + // The filtered list + var filtered = new this.constructor(); + var self = this; + // Creates the binder for a single element at a given index + var generator = function (element, index) { + // The event handler that updates the filtered list + var binder = function (ev, val) { + var index = filtered.indexOf(element); + // Remove it from the list if it exists but the new value is false + if (!val && index !== -1) { + filtered.splice(index, 1); + } + // Add it to the list if it isn't in there and the new value is true + if (val && index === -1) { + filtered.push(element); + } + }; + // a can.compute that executes the callback + var compute = can.compute(function () { + return callback(element, self.indexOf(element), self); + }); + // Update the filtered list on any compute change + compute.bind('change', binder); + // Call binder explicitly for the initial list + binder(null, compute()); + }; + // We also want to know when something gets added to our original list + this.bind('add', function (ev, data, index) { + can.each(data, function (element, i) { + // Call the generator for each newly added element + // The index is the start index + the loop index + generator(element, index + i); + }); + }); + // Removed items should be removed from both lists + this.bind('remove', function (ev, data, index) { + can.each(data, function (element, i) { + var index = filtered.indexOf(element); + if (index !== -1) { + filtered.splice(index, 1); + } + }); + }); + // Run the generator for each list element + this.forEach(generator); + return filtered; + }, + map: function (callback) { + var mapped = new can.List(); + var self = this; + // Again, lets run a generator function + var generator = function (element, index) { + // The can.compute for the mapping + var compute = can.compute(function () { + return callback(element, index, self); + }); + compute.bind('change', function (ev, val) { + // On change, replace the current value with the new one + mapped.splice(index, 1, val); + }); + mapped.splice(index, 0, compute()); + }; + this.forEach(generator); + // We also want to know when something gets added to our original list + this.bind('add', function (ev, data, index) { + can.each(data, function (element, i) { + // Call the generator for each newly added element + // The index is the start index + the loop index + generator(element, index + i); + }); + }); + this.bind('remove', function (ev, data, index) { + // The indices in the mapped list are the same so lets just splice it out + mapped.splice(index, data.length); + }); + return mapped; + } + /* TODO + , + + every : function() { + + }, + + some : function(callback) { + + }, + + reduce : function() { + + }, + + reduceRight : function() { + + }, + + max : function() { + + }, + + min : function() { + + } + */ + }); + return can.List; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/map.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/map.js new file mode 100644 index 0000000000..da35c7b631 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/map.js @@ -0,0 +1,703 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/map*/ +// # can/map/map.js +// `can.Map` provides the observable pattern for JavaScript Objects. + + + + + + +steal('can/util', 'can/util/bind','./bubble.js', 'can/construct', 'can/util/batch', function (can, bind, bubble) { + // ## Helpers + + // A temporary map of Maps that have been made from plain JS objects. + var madeMap = null; + // Clears out map of converted objects. + var teardownMap = function () { + for (var cid in madeMap) { + if (madeMap[cid].added) { + delete madeMap[cid].obj._cid; + } + } + madeMap = null; + }; + // Retrieves a Map instance from an Object. + var getMapFromObject = function (obj) { + return madeMap && madeMap[obj._cid] && madeMap[obj._cid].instance; + }; + // A temporary map of Maps + var serializeMap = null; + + + /** + * @add can.Map + */ + // + var Map = can.Map = can.Construct.extend({ + /** + * @static + */ + setup: function () { + + can.Construct.setup.apply(this, arguments); + + // Do not run if we are defining can.Map. + if (can.Map) { + if (!this.defaults) { + this.defaults = {}; + } + // Builds a list of compute and non-compute properties in this Object's prototype. + this._computes = []; + //!steal-remove-start + if(this.prototype.define && !this.helpers.define) { + can.dev.warn("can/map/define is not included, yet there is a define property "+ + "used. You may want to add this plugin."); + } + if(this.define && !this.helpers.define) { + can.dev.warn("The define property should be on the map's prototype properties, "+ + "not the static properies. Also, can/map/define is not included."); + } + //!steal-remove-end + for (var prop in this.prototype) { + // Non-functions are regular defaults. + if ( + prop !== "define" && + prop !== "constructor" && + ( + typeof this.prototype[prop] !== "function" || + this.prototype[prop].prototype instanceof can.Construct + ) + ) { + this.defaults[prop] = this.prototype[prop]; + // Functions with an `isComputed` property are computes. + } else if (this.prototype[prop].isComputed) { + this._computes.push(prop); + } + } + if(this.helpers.define) { + this.helpers.define(this); + } + } + // If we inherit from can.Map, but not can.List, make sure any lists are the correct type. + if (can.List && !(this.prototype instanceof can.List)) { + this.List = Map.List.extend({ + Map: this + }, {}); + } + + }, + // Reference to bubbling helpers. + _bubble: bubble, + // Given an eventName, determine if bubbling should be setup. + _bubbleRule: function(eventName) { + return (eventName === "change" || eventName.indexOf(".") >= 0 ) ? + ["change"] : + []; + }, + // List of computes on the Map's prototype. + _computes: [], + // Adds an event to this Map. + bind: can.bindAndSetup, + on: can.bindAndSetup, + // Removes an event from this Map. + unbind: can.unbindAndTeardown, + off: can.unbindAndTeardown, + // Name of the id field. Used in can.Model. + id: "id", + // ## Internal helpers + helpers: { + // ### can.Map.helpers.define + // Stub function for the define plugin. + define: null, + /** + * @hide + * Parses attribute name into its parts + * @param {String|Array} attr attribute name + * @param {Boolean} keepKey whether to keep the key intact + * @return {Array} attribute parts + */ + // ### can.Map.helpers.attrParts + // Parses attribute name into its parts. + attrParts: function (attr, keepKey) { + //Keep key intact + + if (keepKey ) { + return [attr]; + } + // Split key on '.' + return typeof attr === "object" ? attr : ("" + attr) + .split("."); + }, + /** + * @hide + * Tracks Map instances created from JS Objects + * @param {Object} obj original Object + * @param {can.Map} instance the can.Map instance + * @return {Function} function to clear out object mapping + */ + // ### can.Map.helpers.addToMap + // Tracks Map instances created from JS Objects + addToMap: function (obj, instance) { + var teardown; + // Setup a fresh mapping if `madeMap` is missing. + if (!madeMap) { + teardown = teardownMap; + madeMap = {}; + } + // Record if Object has a `_cid` before adding one. + var hasCid = obj._cid; + var cid = can.cid(obj); + + // Only update if there already isn't one already. + if (!madeMap[cid]) { + + madeMap[cid] = { + obj: obj, + instance: instance, + added: !hasCid + }; + } + return teardown; + }, + /** + * @hide + * Determines if `obj` is observable + * @param {Object} obj Object to check + * @return {Boolean} whether `obj` is an observable + */ + // ### can.Map.helpers.isObservable + // Determines if `obj` is observable. + isObservable: function(obj){ + return obj instanceof can.Map || (obj && obj === can.route); + }, + /** + * @hide + * Determines if `obj` can be made into an observable + * @param {Object} obj Object to check + * @return {Boolean} whether `obj` can be made into an observable + */ + // ### can.Map.helpers.canMakeObserve + // Determines if an object can be made into an observable. + canMakeObserve: function (obj) { + return obj && !can.isDeferred(obj) && (can.isArray(obj) || can.isPlainObject(obj) ); + }, + /** + * @hide + * Serializes a Map or Map.List + * @param {can.Map|can.List} map The observable. + * @param {String} how To serialize using `attr` or `serialize`. + * @param {String} where Object or Array to put properties in. + * @return {Object|Array} serialized Map or List data. + */ + // ### can.Map.helpers.serialize + // Serializes a Map or Map.List + serialize: function (map, how, where) { + var cid = can.cid(map), + firstSerialize = false; + if(!serializeMap) { + firstSerialize = true; + // Serialize might call .attr() so we need to keep different map + serializeMap = { + attr: {}, + serialize: {} + }; + } + serializeMap[how][cid] = where; + // Go through each property. + map.each(function (val, name) { + // If the value is an `object`, and has an `attrs` or `serialize` function. + var result, + isObservable = Map.helpers.isObservable(val), + serialized = isObservable && serializeMap[how][can.cid(val)]; + if( serialized ) { + result = serialized; + } else { + if(how === "serialize") { + result = Map.helpers._serialize(map, name, val); + } else { + result = Map.helpers._getValue(map, name, val, how); + } + } + // this is probably removable + if(result !== undefined){ + where[name] = result; + } + }); + + can.__observe(map, '__keys'); + if(firstSerialize) { + serializeMap = null; + } + return where; + }, + _serialize: function(map, name, val){ + return Map.helpers._getValue(map, name, val, "serialize"); + }, + _getValue: function(map, name, val, how){ + if( Map.helpers.isObservable(val) ) { + return val[how](); + } else { + return val; + } + } + }, + /** + * @hide + * Returns list of keys in a Map + * @param {can.Map} map + * @returns {Array} + */ + keys: function (map) { + var keys = []; + can.__observe(map, '__keys'); + for (var keyName in map._data) { + keys.push(keyName); + } + return keys; + } + }, + /** + * @prototype + */ + { + setup: function (obj) { + if(obj instanceof can.Map){ + obj = obj.serialize(); + } + + // `_data` is where we keep the properties. + this._data = {}; + /** + * @property {String} can.Map.prototype._cid + * @hide + * + * A globally unique ID for this `can.Map` instance. + */ + // The namespace this `object` uses to listen to events. + can.cid(this, ".map"); + // Sets all `attrs`. + this._init = 1; + this._computedBindings = {}; + + // It's handy if we pass this to computes, because computes can have a default value. + var defaultValues = this._setupDefaults(obj); + this._setupComputes(defaultValues); + var teardownMapping = obj && can.Map.helpers.addToMap(obj, this); + + var data = can.extend(can.extend(true, {}, defaultValues), obj); + + this.attr(data); + + if (teardownMapping) { + teardownMapping(); + } + + // `batchTrigger` change events. + this.bind('change', can.proxy(this._changes, this)); + + delete this._init; + }, + // Sets up computed properties on a Map. + _setupComputes: function () { + var computes = this.constructor._computes; + + for (var i = 0, len = computes.length, prop; i < len; i++) { + prop = computes[i]; + // Make the context of the compute the current Map + this[prop] = this[prop].clone(this); + // Keep track of computed properties + this._computedBindings[prop] = { + count: 0 + }; + } + }, + _setupDefaults: function(){ + return this.constructor.defaults || {}; + }, + // Setup child bindings. + _bindsetup: function(){}, + // Teardown child bindings. + _bindteardown: function(){}, + // `change`event handler. + _changes: function (ev, attr, how, newVal, oldVal) { + // when a change happens, create the named event. + can.batch.trigger(this, { + type: attr, + batchNum: ev.batchNum, + target: ev.target + }, [newVal, oldVal]); + + + }, + // Trigger a change event. + _triggerChange: function (attr, how, newVal, oldVal) { + // so this change can bubble ... a bubbling change triggers the + // _changes trigger + if(bubble.isBubbling(this, "change")) { + can.batch.trigger(this, { + type: "change", + target: this + }, [attr, how, newVal, oldVal]); + } else { + can.batch.trigger(this, attr, [newVal, oldVal]); + } + + if(how === "remove" || how === "add") { + can.batch.trigger(this, { + type: "__keys", + target: this + }); + } + }, + // Iterator that does not trigger live binding. + _each: function (callback) { + var data = this.__get(); + for (var prop in data) { + if (data.hasOwnProperty(prop)) { + callback(data[prop], prop); + } + } + }, + + attr: function (attr, val) { + // This is super obfuscated for space -- basically, we're checking + // if the type of the attribute is not a `number` or a `string`. + var type = typeof attr; + if (type !== "string" && type !== "number") { + return this._attrs(attr, val); + // If we are getting a value. + } else if (arguments.length === 1) { + return this._get(attr); + } else { + // Otherwise we are setting. + this._set(attr, val); + return this; + } + }, + + each: function () { + return can.each.apply(undefined, [this].concat(can.makeArray(arguments))); + }, + + removeAttr: function (attr) { + // If this is List. + var isList = can.List && this instanceof can.List, + // Convert the `attr` into parts (if nested). + parts = can.Map.helpers.attrParts(attr), + // The actual property to remove. + prop = parts.shift(), + // The current value. + current = isList ? this[prop] : this._data[prop]; + + // If we have more parts, call `removeAttr` on that part. + if (parts.length && current) { + return current.removeAttr(parts); + } else { + + // If attr does not have a `.` + if (typeof attr === 'string' && !!~attr.indexOf('.')) { + prop = attr; + } + + this._remove(prop, current); + return current; + } + }, + // Remove a property. + _remove: function(prop, current){ + if (prop in this._data) { + // Delete the property from `_data` and the Map + // as long as it isn't part of the Map's prototype. + delete this._data[prop]; + if (!(prop in this.constructor.prototype)) { + delete this[prop]; + } + // Let others now this property has been removed. + this._triggerChange(prop, "remove", undefined, current); + + } + }, + // Reads a property from the `object`. + _get: function (attr) { + attr = ""+attr; + var dotIndex = attr.indexOf('.'); + + + // Handles the case of a key having a `.` in its name + // Otherwise we have to dig deeper into the Map to get the value. + if( dotIndex >= 0 ) { + // Attempt to get the value + var value = this.__get(attr); + // For keys with a `.` in them, value will be defined + if (value !== undefined) { + return value; + } + var first = attr.substr(0, dotIndex), + second = attr.substr(dotIndex+1); + can.__observe(this, first); + var current = this.__get( first ); + + return current && current._get ? current._get(second) : undefined; + } else { + can.__observe(this, attr); + return this.__get( attr ); + } + }, + // Reads a property directly if an `attr` is provided, otherwise + // returns the "real" data object itself. + __get: function (attr) { + if (attr) { + // If property is a compute return the result, otherwise get the value directly + if (this._computedBindings[attr]) { + return this[attr](); + } else { + return this._data[attr]; + } + // If not property is provided, return entire `_data` object + } else { + return this._data; + } + }, + // converts the value into an observable if needed + __type: function(value, prop){ + // If we are getting an object. + if (!( value instanceof can.Map) && can.Map.helpers.canMakeObserve(value) ) { + + var cached = getMapFromObject(value); + if(cached) { + return cached; + } + if( can.isArray(value) ) { + var List = can.List; + return new List(value); + } else { + var Map = this.constructor.Map || can.Map; + return new Map(value); + } + } + return value; + }, + // Sets `attr` prop as value on this object where. + // `attr` - Is a string of properties or an array of property values. + // `value` - The raw value to set. + _set: function (attr, value, keepKey) { + attr = ""+attr; + var dotIndex = attr.indexOf('.'), + current; + if(!keepKey && dotIndex >= 0){ + var first = attr.substr(0, dotIndex), + second = attr.substr(dotIndex+1); + + current = this._init ? undefined : this.__get( first ); + + if( Map.helpers.isObservable(current) ) { + current._set(second, value); + } else { + throw "can.Map: Object does not exist"; + } + } else { + if (this.__convert) { + //Convert if there is a converter + value = this.__convert(attr, value); + } + current = this._init ? undefined : this.__get( attr ); + this.__set(attr, this.__type(value, attr), current); + } + }, + __set: function (prop, value, current) { + // TODO: Check if value is object and transform. + // Don't do anything if the value isn't changing. + if (value !== current) { + // Check if we are adding this for the first time -- + // if we are, we need to create an `add` event. + var changeType = current !== undefined || this.__get() + .hasOwnProperty(prop) ? "set" : "add"; + + // Set the value on `_data` and hook it up to send event. + this.___set(prop, this.constructor._bubble.set(this, prop, value, current) ); + + // `batchTrigger` the change event. + if(!this._computedBindings[prop]) { + this._triggerChange(prop, changeType, value, current); + } + + + // If we can stop listening to our old value, do it. + if (current) { + this.constructor._bubble.teardownFromParent(this, current); + } + } + + }, + // Directly sets a property on this `object`. + ___set: function (prop, val) { + if ( this._computedBindings[prop] ) { + this[prop](val); + } else { + this._data[prop] = val; + } + // Add property directly for easy writing. + // Check if its on the `prototype` so we don't overwrite methods like `attrs`. + if ( typeof this.constructor.prototype[prop] !== 'function' && !this._computedBindings[prop] ) { + this[prop] = val; + } + }, + + bind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + // The first time we bind to this computed property we + // initialize `count` and `batchTrigger` the change event. + if (!computedBinding.count) { + computedBinding.count = 1; + var self = this; + computedBinding.handler = function (ev, newVal, oldVal) { + can.batch.trigger(self, { + type: eventName, + batchNum: ev.batchNum, + target: self + }, [newVal, oldVal]); + }; + this[eventName].bind("change", computedBinding.handler); + } else { + // Increment number of things listening to this computed property. + computedBinding.count++; + } + + } + // The first time we bind to this Map, `_bindsetup` will + // be called to setup child event bubbling. + this.constructor._bubble.bind(this, eventName); + return can.bindAndSetup.apply(this, arguments); + + }, + + unbind: function (eventName, handler) { + var computedBinding = this._computedBindings && this._computedBindings[eventName]; + if (computedBinding) { + // If there is only one listener, we unbind the change event handler + // and clean it up since no one is listening to this property any more. + if (computedBinding.count === 1) { + computedBinding.count = 0; + this[eventName].unbind("change", computedBinding.handler); + delete computedBinding.handler; + } else { + // Decrement number of things listening to this computed property + computedBinding.count--; + } + + } + this.constructor._bubble.unbind(this, eventName); + return can.unbindAndTeardown.apply(this, arguments); + + }, + + serialize: function () { + return can.Map.helpers.serialize(this, 'serialize', {}); + }, + /** + * @hide + * Set multiple properties on the observable + * @param {Object} props + * @param {Boolean} remove true if you should remove properties that are not in props + */ + _attrs: function (props, remove) { + if (props === undefined) { + return Map.helpers.serialize(this, 'attr', {}); + } + + props = can.simpleExtend({}, props); + var prop, + self = this, + newVal; + + // Batch all of the change events until we are done. + can.batch.start(); + // Merge current properties with the new ones. + this.each(function (curVal, prop) { + // You can not have a _cid property; abort. + if (prop === "_cid") { + return; + } + newVal = props[prop]; + + // If we are merging, remove the property if it has no value. + if (newVal === undefined) { + if (remove) { + self.removeAttr(prop); + } + return; + } + + // Run converter if there is one + if (self.__convert) { + newVal = self.__convert(prop, newVal); + } + + // If we're dealing with models, we want to call _set to let converters run. + if ( Map.helpers.isObservable( newVal ) ) { + + self.__set(prop, self.__type(newVal, prop), curVal); + // If its an object, let attr merge. + } else if (Map.helpers.isObservable(curVal) && Map.helpers.canMakeObserve(newVal) ) { + curVal.attr(newVal, remove); + // Otherwise just set. + } else if (curVal !== newVal) { + self.__set(prop, self.__type(newVal, prop), curVal); + } + + delete props[prop]; + }); + // Add remaining props. + for (prop in props) { + // Ignore _cid. + if (prop !== "_cid") { + newVal = props[prop]; + this._set(prop, newVal, true); + } + + } + can.batch.stop(); + return this; + }, + + compute: function (prop) { + // If the property is a function, use it as the getter/setter + // otherwise, create a new compute that returns the value of a property on `this` + if (can.isFunction(this.constructor.prototype[prop])) { + return can.compute(this[prop], this); + } else { + var reads = prop.split("."), + last = reads.length - 1, + options = { + args: [] + }; + return can.compute(function (newVal) { + if (arguments.length) { + can.compute.read(this, reads.slice(0, last)) + .value.attr(reads[last], newVal); + } else { + return can.compute.read(this, reads, options) + .value; + } + }, this); + } + + } + }); + + // Setup on/off aliases + Map.prototype.on = Map.prototype.bind; + Map.prototype.off = Map.prototype.unbind; + + return Map; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/setter/setter.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/setter/setter.js new file mode 100644 index 0000000000..fcff217cf4 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/setter/setter.js @@ -0,0 +1,92 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/setter/setter*/ +steal('can/util', 'can/map', function (can) { + + can.classize = function (s, join) { + // this can be moved out .. + // used for getter setter + var parts = s.split(can.undHash), + i = 0; + for (; i < parts.length; i++) { + parts[i] = can.capitalize(parts[i]); + } + return parts.join(join || ''); + }; + var classize = can.classize, + proto = can.Map.prototype, + old = proto.__set; + proto.__set = function (prop, value, current, success, error) { + //!steal-remove-start + var asyncTimer; + can.dev.warn("can/map/setter is a deprecated plugin and will be removed in a future release. "+ + "can/map/define provides the same functionality in a more complete API."); + //!steal-remove-end + + // check if there's a setter + var cap = classize(prop), + setName = 'set' + cap, + errorCallback = function (errors) { + //!steal-remove-start + clearTimeout(asyncTimer); + //!steal-remove-end + + var stub = error && error.call(self, errors); + // if 'validations' is on the page it will trigger + // the error itself and we dont want to trigger + // the event twice. :) + if (stub !== false) { + can.trigger(self, 'error', [ + prop, + errors + ], true); + } + return false; + }, self = this; + + + + // if we have a setter + if (this[setName] ) { + // call the setter, if returned value is undefined, + // this means the setter is async so we + // do not call update property and return right away + can.batch.start(); + + value = this[setName](value, function (value) { + old.call(self, prop, value, current, success, errorCallback); + //!steal-remove-start + clearTimeout(asyncTimer); + //!steal-remove-end + }, errorCallback); + + + if(value === undefined) { + //!steal-remove-start + asyncTimer = setTimeout(function(){ + can.dev.warn('can/map/setter.js: Setter ' + setName+' did not return a value or call the setter callback.'); + },can.dev.warnTimeout); + //!steal-remove-end + can.batch.stop(); + return; + } else { + old.call(self, prop, value, current, success, errorCallback); + can.batch.stop(); + return this; + } + + } else { + old.call(self, prop, value, current, success, errorCallback); + } + + return this; + }; + return can.Map; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/sort/sort.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/sort/sort.js new file mode 100644 index 0000000000..ec36ad8736 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/sort/sort.js @@ -0,0 +1,12 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/sort/sort*/ +steal('can/list/sort', function (sortPlugin) { + return sortPlugin; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/validations/validations.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/validations/validations.js new file mode 100644 index 0000000000..12cf001ed8 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/map/validations/validations.js @@ -0,0 +1,192 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#map/validations/validations*/ +steal('can/util', 'can/map', function (can) { + //validations object is by property. You can have validations that + //span properties, but this way we know which ones to run. + // proc should return true if there's an error or the error message + var validate = function (attrNames, options, proc) { + // normalize argumetns + if (!proc) { + proc = options; + options = {}; + } + options = options || {}; + attrNames = typeof attrNames === 'string' ? [attrNames] : can.makeArray(attrNames); + // run testIf if it exists + if (options.testIf && !options.testIf.call(this)) { + return; + } + var self = this; + can.each(attrNames, function (attrName) { + // Add a test function for each attribute + if (!self.validations[attrName]) { + self.validations[attrName] = []; + } + self.validations[attrName].push(function (newVal) { + // if options has a message return that, otherwise, return the error + var res = proc.call(this, newVal, attrName); + return res === undefined ? undefined : options.message || res; + }); + }); + }; + var old = can.Map.prototype.__set; + can.Map.prototype.__set = function (prop, value, current, success, error) { + var self = this, + validations = self.constructor.validations, + errorCallback = function (errors) { + var stub = error && error.call(self, errors); + // if 'setter' is on the page it will trigger + // the error itself and we dont want to trigger + // the event twice. :) + if (stub !== false) { + can.trigger(self, 'error', [ + prop, + errors + ], true); + } + return false; + }; + old.call(self, prop, value, current, success, errorCallback); + if (validations && validations[prop]) { + var errors = self.errors(prop); + if (errors) { + errorCallback(errors); + } + } + return this; + }; + can.each([ + can.Map, + can.Model + ], function (clss) { + // in some cases model might not be defined quite yet. + if (clss === undefined) { + return; + } + var oldSetup = clss.setup; + /** + * @static + */ + can.extend(clss, { + setup: function (superClass) { + oldSetup.apply(this, arguments); + if (!this.validations || superClass.validations === this.validations) { + this.validations = {}; + } + }, + validate: validate, + + validationMessages: { + format: 'is invalid', + inclusion: 'is not a valid option (perhaps out of range)', + lengthShort: 'is too short', + lengthLong: 'is too long', + presence: 'can\'t be empty', + range: 'is out of range', + numericality: 'must be a number' + }, + validateFormatOf: function (attrNames, regexp, options) { + validate.call(this, attrNames, options, function (value) { + if (typeof value !== 'undefined' && value !== null && value !== '' && String(value) + .match(regexp) === null) { + return this.constructor.validationMessages.format; + } + }); + }, + validateInclusionOf: function (attrNames, inArray, options) { + validate.call(this, attrNames, options, function (value) { + if (typeof value === 'undefined') { + return; + } + for (var i = 0; i < inArray.length; i++) { + if (inArray[i] === value) { + return; + } + } + return this.constructor.validationMessages.inclusion; + }); + }, + validateLengthOf: function (attrNames, min, max, options) { + validate.call(this, attrNames, options, function (value) { + if ((typeof value === 'undefined' || value === null) && min > 0 || typeof value !== 'undefined' && value !== null && value.length < min) { + return this.constructor.validationMessages.lengthShort + ' (min=' + min + ')'; + } else if (typeof value !== 'undefined' && value !== null && value.length > max) { + return this.constructor.validationMessages.lengthLong + ' (max=' + max + ')'; + } + }); + }, + validatePresenceOf: function (attrNames, options) { + validate.call(this, attrNames, options, function (value) { + if (typeof value === 'undefined' || value === '' || value === null) { + return this.constructor.validationMessages.presence; + } + }); + }, + validateRangeOf: function (attrNames, low, hi, options) { + validate.call(this, attrNames, options, function (value) { + if ((typeof value === 'undefined' || value === null) && low > 0 || typeof value !== 'undefined' && value !== null && (value < low || value > hi)) { + return this.constructor.validationMessages.range + ' [' + low + ',' + hi + ']'; + } + }); + }, + validatesNumericalityOf: function (attrNames) { + validate.call(this, attrNames, function (value) { + var res = !isNaN(parseFloat(value)) && isFinite(value); + if (!res) { + return this.constructor.validationMessages.numericality; + } + }); + } + }); + }); + /** + * @prototype + */ + can.extend(can.Map.prototype, { + errors: function (attrs, newVal) { + // convert attrs to an array + if (attrs) { + attrs = can.isArray(attrs) ? attrs : [attrs]; + } + var errors = {}, self = this, + // helper function that adds error messages to errors object + // attr - the name of the attribute + // funcs - the validation functions + addErrors = function (attr, funcs) { + can.each(funcs, function (func) { + var res = func.call(self, isTest ? self.__convert ? self.__convert(attr, newVal) : newVal : self.attr(attr)); + if (res) { + if (!errors[attr]) { + errors[attr] = []; + } + errors[attr].push(res); + } + }); + }, validations = this.constructor.validations || {}, + isTest = attrs && attrs.length === 1 && arguments.length === 2; + // go through each attribute or validation and + // add any errors + can.each(attrs || validations, function (funcs, attr) { + // if we are iterating through an array, use funcs + // as the attr name + if (typeof attr === 'number') { + attr = funcs; + funcs = validations[attr]; + } + // add errors to the + addErrors(attr, funcs || []); + }); + // return errors as long as we have one + return can.isEmptyObject(errors) ? null : isTest ? errors[attrs[0]] : errors; + } + }); + return can.Map; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/model/model.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/model/model.js new file mode 100644 index 0000000000..ef7505d088 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/model/model.js @@ -0,0 +1,695 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#model/model*/ +steal('can/util', 'can/map', 'can/list', function (can) { + /** @add can.Model **/ + // ## model.js + // (Don't steal this file directly in your code.) + + // ## pipe + // `pipe` lets you pipe the results of a successful deferred + // through a function before resolving the deferred. + var pipe = function (def, thisArg, func) { + // The piped result will be available through a new Deferred. + var d = new can.Deferred(); + def.then(function () { + var args = can.makeArray(arguments), + success = true; + + try { + // Pipe the results through the function. + args[0] = func.apply(thisArg, args); + } catch (e) { + success = false; + // The function threw an error, so reject the Deferred. + d.rejectWith(d, [e].concat(args)); + } + if (success) { + // Resolve the new Deferred with the piped value. + d.resolveWith(d, args); + } + }, function () { + // Pass on the rejection if the original Deferred never resolved. + d.rejectWith(this, arguments); + }); + + // `can.ajax` returns a Deferred with an abort method to halt the AJAX call. + if (typeof def.abort === 'function') { + d.abort = function () { + return def.abort(); + }; + } + + // Return the new (piped) Deferred. + return d; + }, + + // ## modelNum + // When new model constructors are set up without a full name, + // `modelNum` lets us name them uniquely (to keep track of them). + modelNum = 0, + + // ## getId + getId = function (inst) { + // `can.__observe` makes a note that `id` was just read. + can.__observe(inst, inst.constructor.id); + // Use `__get` instead of `attr` for performance. (But that means we have to remember to call `can.__observe`.) + return inst.__get(inst.constructor.id); + }, + + // ## ajax + // This helper method makes it easier to make an AJAX call from the configuration of the Model. + ajax = function (ajaxOb, data, type, dataType, success, error) { + + var params = {}; + + // A string here would be something like `"GET /endpoint"`. + if (typeof ajaxOb === 'string') { + // Split on spaces to separate the HTTP method and the URL. + var parts = ajaxOb.split(/\s+/); + params.url = parts.pop(); + if (parts.length) { + params.type = parts.pop(); + } + } else { + // If the first argument is an object, just load it into `params`. + can.extend(params, ajaxOb); + } + + // If the `data` argument is a plain object, copy it into `params`. + params.data = typeof data === "object" && !can.isArray(data) ? + can.extend(params.data || {}, data) : data; + + // Substitute in data for any templated parts of the URL. + params.url = can.sub(params.url, params.data, true); + + return can.ajax(can.extend({ + type: type || 'post', + dataType: dataType || 'json', + success: success, + error: error + }, params)); + }, + + // ## makeRequest + // This function abstracts making the actual AJAX request away from the Model. + makeRequest = function (modelObj, type, success, error, method) { + var args; + + // If `modelObj` is an Array, it it means we are coming from + // the queued request, and we're passing already-serialized data. + if (can.isArray(modelObj)) { + // In that case, modelObj's signature will be `[modelObj, serializedData]`, so we need to unpack it. + args = modelObj[1]; + modelObj = modelObj[0]; + } else { + // If we aren't supplied with serialized data, we'll make our own. + args = modelObj.serialize(); + } + args = [args]; + + var deferred, + model = modelObj.constructor, + jqXHR; + + // When calling `update` and `destroy`, the current ID needs to be the first parameter in the AJAX call. + if (type === 'update' || type === 'destroy') { + args.unshift(getId(modelObj)); + } + jqXHR = model[type].apply(model, args); + + // Make sure that can.Model can react to the request before anything else does. + deferred = pipe(jqXHR, modelObj, function (data) { + // `method` is here because `"destroyed" !== "destroy" + "d"`. + // TODO: Do something smarter/more consistent here? + modelObj[method || type + "d"](data, jqXHR); + return modelObj; + }); + + // Hook up `abort` + if (jqXHR.abort) { + deferred.abort = function () { + jqXHR.abort(); + }; + } + + deferred.then(success, error); + return deferred; + }, + + converters = { + // ## models + // The default function for converting into a list of models. Needs to be stored separate + // because we will reference it in models static `setup`, too. + models: function (instancesRawData, oldList, xhr) { + // Increment reqs counter so new instances will be added to the store. + // (This is cleaned up at the end of the method.) + can.Model._reqs++; + + // If there is no data, we can't really do anything with it. + if (!instancesRawData) { + return; + } + + // If the "raw" data is already a List, it's not raw. + if (instancesRawData instanceof this.List) { + return instancesRawData; + } + + var self = this, + // `tmp` will hold the models before we push them onto `modelList`. + tmp = [], + // `ML` (see way below) is just `can.Model.List`. + ListClass = self.List || ML, + modelList = oldList instanceof can.List ? oldList : new ListClass(), + + // Check if we were handed an Array or a model list. + rawDataIsList = instancesRawData instanceof ML, + + // Get the "plain" objects from the models from the list/array. + raw = rawDataIsList ? instancesRawData.serialize() : instancesRawData; + + raw = self.parseModels(raw, xhr); + + if(raw.data) { + instancesRawData = raw; + raw = raw.data; + } + + if (typeof raw === 'undefined' || !can.isArray(raw)) { + throw new Error('Could not get any raw data while converting using .models'); + } + + //!steal-remove-start + if (!raw.length) { + can.dev.warn("model.js models has no data."); + } + //!steal-remove-end + + // If there was anything left in the list we were given, get rid of it. + if (modelList.length) { + modelList.splice(0); + } + + // If we pushed these directly onto the list, it would cause a change event for each model. + // So, we push them onto `tmp` first and then push everything at once, causing one atomic change event that contains all the models at once. + can.each(raw, function (rawPart) { + tmp.push(self.model(rawPart, xhr)); + }); + modelList.push.apply(modelList, tmp); + + // If there was other stuff on `instancesRawData`, let's transfer that onto `modelList` too. + if (!can.isArray(instancesRawData)) { + can.each(instancesRawData, function (val, prop) { + if (prop !== 'data') { + modelList.attr(prop, val); + } + }); + } + // Clean up the store on the next turn of the event loop. (`this` is a model constructor.) + setTimeout(can.proxy(this._clean, this), 1); + return modelList; + }, + // ## model + // A function that, when handed a plain object, turns it into a model. + model: function (attributes, oldModel, xhr) { + // If there're no properties, there can be no model. + if (!attributes) { + return; + } + + // If this object knows how to serialize, parse, or access itself, we'll use that instead. + if (typeof attributes.serialize === 'function') { + attributes = attributes.serialize(); + } else { + attributes = this.parseModel(attributes, xhr); + } + + var id = attributes[this.id]; + // Models from the store always have priority + // 0 is a valid ID. + if((id || id === 0) && this.store[id]) { + oldModel = this.store[id]; + } + + var model = oldModel && can.isFunction(oldModel.attr) ? + // If this model is in the store already, just update it. + oldModel.attr(attributes, this.removeAttr || false) : + // Otherwise, we need a new model. + new this(attributes); + + return model; + } + }, + + // ## makeParser + // This object describes how to take the data from an AJAX request and prepare it for `models` and `model`. + // These functions are meant to be overwritten (if necessary) in an extended model constructor. + makeParser = { + parseModel: function (prop) { + return function (attributes) { + return prop ? can.getObject(prop, attributes) : attributes; + }; + }, + parseModels: function (prop) { + return function (attributes) { + if(can.isArray(attributes)) { + return attributes; + } + + prop = prop || 'data'; + + var result = can.getObject(prop, attributes); + if(!can.isArray(result)) { + throw new Error('Could not get any raw data while converting using .models'); + } + return result; + }; + } + }, + + // ## ajaxMethods + // This object describes how to make an AJAX request for each ajax method (`create`, `update`, etc.) + // Each AJAX method is an object in `ajaxMethods` and can have the following properties: + // + // - `url`: Which property on the model contains the default URL for this method. + // - `type`: The default HTTP request method. + // - `data`: A method that takes the arguments from `makeRequest` (see above) and returns a data object for use in the AJAX call. + ajaxMethods = { + create: { + url: "_shortName", + type: "post" + }, + update: { + // ## update.data + data: function (id, attrs) { + attrs = attrs || {}; + + // `this.id` is the property that represents the ID (and is usually `"id"`). + var identity = this.id; + + // If the value of the property being used as the ID changed, + // indicate that in the request and replace the current ID property. + if (attrs[identity] && attrs[identity] !== id) { + attrs["new" + can.capitalize(id)] = attrs[identity]; + delete attrs[identity]; + } + attrs[identity] = id; + + return attrs; + }, + type: "put" + }, + destroy: { + type: 'delete', + // ## destroy.data + data: function (id, attrs) { + attrs = attrs || {}; + // `this.id` is the property that represents the ID (and is usually `"id"`). + attrs.id = attrs[this.id] = id; + return attrs; + } + }, + findAll: { + url: "_shortName" + }, + findOne: {} + }, + // ## ajaxMaker + // Takes a method defined just above and a string that describes how to call that method + // and makes a function that calls that method with the given data. + // + // - `ajaxMethod`: The object defined above in `ajaxMethods`. + // - `str`: The string the configuration provided (such as `"/recipes.json"` for a `findAll` call). + ajaxMaker = function (ajaxMethod, str) { + return function (data) { + data = ajaxMethod.data ? + // If the AJAX method mentioned above has its own way of getting `data`, use that. + ajaxMethod.data.apply(this, arguments) : + // Otherwise, just use the data passed in. + data; + + // Make the AJAX call with the URL, data, and type indicated by the proper `ajaxMethod` above. + return ajax(str || this[ajaxMethod.url || "_url"], data, ajaxMethod.type || "get"); + }; + }, + // ## createURLFromResource + // For each of the names (create, update, destroy, findOne, and findAll) use the + // URL provided by the `resource` property. For example: + // + // ToDo = can.Model.extend({ + // resource: "/todos" + // }, {}); + // + // Will create a can.Model that is identical to: + // + // ToDo = can.Model.extend({ + // findAll: "GET /todos", + // findOne: "GET /todos/{id}", + // create: "POST /todos", + // update: "PUT /todos/{id}", + // destroy: "DELETE /todos/{id}" + // },{}); + // + // - `model`: the can.Model that has the resource property + // - `method`: a property from the ajaxMethod object + createURLFromResource = function(model, name) { + if (!model.resource) { return; } + + var resource = model.resource.replace(/\/+$/, ""); + if (name === "findAll" || name === "create") { + return resource; + } else { + return resource + "/{" + model.id + "}"; + } + }; + + // # can.Model + // A can.Map that connects to a RESTful interface. + /** @static */ + can.Model = can.Map.extend({ + // `fullName` identifies the model type in debugging. + fullName: "can.Model", + _reqs: 0, + // ## can.Model.setup + setup: function (base, fullName, staticProps, protoProps) { + // Assume `fullName` wasn't passed. (`can.Model.extend({ ... }, { ... })`) + // This is pretty usual. + if (typeof fullName !== "string") { + protoProps = staticProps; + staticProps = fullName; + } + // Assume no static properties were passed. (`can.Model.extend({ ... })`) + // This is really unusual for a model though, since there's so much configuration. + if (!protoProps) { + //!steal-remove-start + can.dev.warn("can/model/model.js: can.Model extended without static properties."); + //!steal-remove-end + protoProps = staticProps; + } + + // Create the model store here, in case someone wants to use can.Model without inheriting from it. + this.store = {}; + + can.Map.setup.apply(this, arguments); + if (!can.Model) { + return; + } + + // `List` is just a regular can.Model.List that knows what kind of Model it's hooked up to. + if(staticProps && staticProps.List) { + this.List = staticProps.List; + this.List.Map = this; + } else { + this.List = base.List.extend({ + Map: this + }, {}); + } + + var self = this, + clean = can.proxy(this._clean, self); + + // Go through `ajaxMethods` and set up static methods according to their configurations. + can.each(ajaxMethods, function (method, name) { + // Check the configuration for this ajaxMethod. + // If the configuration isn't a function, it should be a string (like `"GET /endpoint"`) + // or an object like `{url: "/endpoint", type: 'GET'}`. + + //if we have a string(like `"GET /endpoint"`) or an object(ajaxSettings) set in the static definition(not inherited), + //convert it to a function. + if(staticProps && staticProps[name] && (typeof staticProps[name] === 'string' || typeof staticProps[name] === 'object')) { + self[name] = ajaxMaker(method, staticProps[name]); + } + //if we have a resource property set in the static definition, but check if function exists already + else if(staticProps && staticProps.resource && !can.isFunction(staticProps[name])) { + self[name] = ajaxMaker(method, createURLFromResource(self, name)); + } + + // There may also be a "maker" function (like `makeFindAll`) that alters the behavior of acting upon models + // by changing when and how the function we just made with `ajaxMaker` gets called. + // For example, you might cache responses and only make a call when you don't have a cached response. + if (self["make" + can.capitalize(name)]) { + // Use the "maker" function to make the new "ajaxMethod" function. + var newMethod = self["make" + can.capitalize(name)](self[name]); + // Replace the "ajaxMethod" function in the configuration with the new one. + // (`_overwrite` just overwrites a property in a given Construct.) + can.Construct._overwrite(self, base, name, function () { + // Increment the numer of requests... + can.Model._reqs++; + // ...make the AJAX call (and whatever else you're doing)... + var def = newMethod.apply(this, arguments); + // ...and clean up the store. + var then = def.then(clean, clean); + // Pass along `abort` so you can still abort the AJAX call. + then.abort = def.abort; + + return then; + }); + } + }); + + var hasCustomConverter = {}; + + // Set up `models` and `model`. + can.each(converters, function(converter, name) { + var parseName = "parse" + can.capitalize(name), + dataProperty = (staticProps && staticProps[name]) || self[name]; + + // For legacy e.g. models: 'someProperty' we set the `parseModel(s)` property + // to the given string and set .model(s) to the original converter + if(typeof dataProperty === 'string') { + self[parseName] = dataProperty; + can.Construct._overwrite(self, base, name, converter); + } else if((staticProps && staticProps[name])) { + hasCustomConverter[parseName] = true; + } + }); + + // Sets up parseModel(s) + can.each(makeParser, function(maker, parseName) { + var prop = (staticProps && staticProps[parseName]) || self[parseName]; + // e.g. parseModels: 'someProperty' make a default parseModel(s) + if(typeof prop === 'string') { + can.Construct._overwrite(self, base, parseName, maker(prop)); + } else if( (!staticProps || !can.isFunction(staticProps[parseName])) && !self[parseName] ) { + var madeParser = maker(); + madeParser.useModelConverter = hasCustomConverter[parseName]; + // Add a default parseModel(s) if there is none + can.Construct._overwrite(self, base, parseName, madeParser); + } + }); + + // Make sure we have a unique name for this Model. + if (self.fullName === "can.Model" || !self.fullName) { + self.fullName = "Model" + (++modelNum); + } + + can.Model._reqs = 0; + this._url = this._shortName + "/{" + this.id + "}"; + }, + _ajax: ajaxMaker, + _makeRequest: makeRequest, + // ## can.Model._clean + // `_clean` cleans up the model store after a request happens. + _clean: function () { + can.Model._reqs--; + // Don't clean up unless we have no pending requests. + if (!can.Model._reqs) { + for (var id in this.store) { + // Delete all items in the store without any event bindings. + if (!this.store[id]._bindings) { + delete this.store[id]; + } + } + } + return arguments[0]; + }, + models: converters.models, + model: converters.model + }, + /** @prototype */ + { + // ## can.Model#setup + setup: function (attrs) { + // Try to add things as early as possible to the store (#457). + // This is the earliest possible moment, even before any properties are set. + var id = attrs && attrs[this.constructor.id]; + if (can.Model._reqs && id != null) { + this.constructor.store[id] = this; + } + can.Map.prototype.setup.apply(this, arguments); + }, + // ## can.Model#isNew + // Something is new if its ID is `null` or `undefined`. + isNew: function () { + var id = getId(this); + // 0 is a valid ID. + // TODO: Why not `return id === null || id === undefined;`? + return !(id || id === 0); // If `null` or `undefined` + }, + // ## can.Model#save + // `save` calls `create` or `update` as necessary, based on whether a model is new. + save: function (success, error) { + return makeRequest(this, this.isNew() ? 'create' : 'update', success, error); + }, + // ## can.Model#destroy + // Acts like can.Map.destroy but it also makes an AJAX call. + destroy: function (success, error) { + // If this model is new, don't make an AJAX call. + // Instead, we have to construct the Deferred ourselves and return it. + if (this.isNew()) { + var self = this; + var def = can.Deferred(); + def.then(success, error); + + return def.done(function (data) { + self.destroyed(data); + }).resolve(self); + } + + // If it isn't new, though, go ahead and make a request. + return makeRequest(this, 'destroy', success, error, 'destroyed'); + }, + // ## can.Model#bind and can.Model#unbind + // These aren't actually implemented here, but their setup needs to be changed to account for the store. + _bindsetup: function () { + var modelInstance = this.__get(this.constructor.id); + if (modelInstance != null) { + this.constructor.store[modelInstance ] = this; + } + return can.Map.prototype._bindsetup.apply(this, arguments); + }, + _bindteardown: function () { + delete this.constructor.store[getId(this)]; + return can.Map.prototype._bindteardown.apply(this, arguments); + }, + // Change the behavior of `___set` to account for the store. + ___set: function (prop, val) { + can.Map.prototype.___set.call(this, prop, val); + // If we add or change the ID, update the store accordingly. + // TODO: shouldn't this also delete the record from the old ID in the store? + if (prop === this.constructor.id && this._bindings) { + this.constructor.store[getId(this)] = this; + } + } + }); + + // Returns a function that knows how to prepare data from `findAll` or `findOne` calls. + // `name` should be either `model` or `models`. + var makeGetterHandler = function (name) { + return function (data, readyState, xhr) { + return this[name](data, null, xhr); + }; + }, + // Handle data returned from `create`, `update`, and `destroy` calls. + createUpdateDestroyHandler = function (data) { + if(this.parseModel.useModelConverter) { + return this.model(data); + } + + return this.parseModel(data); + }; + + var responseHandlers = { + makeFindAll: makeGetterHandler("models"), + makeFindOne: makeGetterHandler("model"), + makeCreate: createUpdateDestroyHandler, + makeUpdate: createUpdateDestroyHandler, + makeDestroy: createUpdateDestroyHandler + }; + + // Go through the response handlers and make the actual "make" methods. + can.each(responseHandlers, function (method, name) { + can.Model[name] = function (oldMethod) { + return function () { + var args = can.makeArray(arguments), + // If args[1] is a function, we were only passed one argument before success and failure callbacks. + oldArgs = can.isFunction(args[1]) ? args.splice(0, 1) : args.splice(0, 2), + // Call the AJAX method (`findAll` or `update`, etc.) and pipe it through the response handler from above. + def = pipe(oldMethod.apply(this, oldArgs), this, method); + + def.then(args[0], args[1]); + return def; + }; + }; + }); + + // ## can.Model.created, can.Model.updated, and can.Model.destroyed + // Livecycle methods for models. + can.each([ + "created", + "updated", + "destroyed" + ], function (funcName) { + // Each of these is pretty much the same, except for the events they trigger. + can.Model.prototype[funcName] = function (attrs) { + var self = this, + constructor = self.constructor; + + // Update attributes if attributes have been passed + if(attrs && typeof attrs === 'object') { + this.attr(can.isFunction(attrs.attr) ? attrs.attr() : attrs); + } + + // triggers change event that bubble's like + // handler( 'change','1.destroyed' ). This is used + // to remove items on destroyed from Model Lists. + // but there should be a better way. + can.dispatch.call(this, {type:"change", target: this}, [funcName]); + + //!steal-remove-start + can.dev.log("Model.js - " + constructor.shortName + " " + funcName); + //!steal-remove-end + + // Call event on the instance's Class + can.dispatch.call(constructor, funcName, [this]); + }; + }); + + + // # can.Model.List + // Model Lists are just like `Map.List`s except that when their items are + // destroyed, they automatically get removed from the List. + var ML = can.Model.List = can.List.extend({ + // ## can.Model.List.setup + // On change or a nested named event, setup change bubbling. + // On any other type of event, setup "destroyed" bubbling. + _bubbleRule: function(eventName, list) { + var bubbleRules = can.List._bubbleRule(eventName, list); + bubbleRules.push('destroyed'); + return bubbleRules; + } + },{ + setup: function (params) { + // If there was a plain object passed to the List constructor, + // we use those as parameters for an initial findAll. + if (can.isPlainObject(params) && !can.isArray(params)) { + can.List.prototype.setup.apply(this); + this.replace(can.isDeferred(params) ? params : this.constructor.Map.findAll(params)); + } else { + // Otherwise, set up the list like normal. + can.List.prototype.setup.apply(this, arguments); + } + this._init = 1; + this.bind('destroyed', can.proxy(this._destroyed, this)); + delete this._init; + }, + _destroyed: function (ev, attr) { + if (/\w+/.test(attr)) { + var index; + while((index = this.indexOf(ev.target)) > -1) { + this.splice(index, 1); + } + } + } + }); + + return can.Model; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/model/queue/queue.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/model/queue/queue.js new file mode 100644 index 0000000000..898e265294 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/model/queue/queue.js @@ -0,0 +1,151 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#model/queue/queue*/ +steal('can/util', 'can/model', 'can/map/backup', function (can) { + var cleanAttrs = function (changedAttrs, attrs) { + var newAttrs = can.extend(true, {}, attrs), + current, path; + if (changedAttrs) { + // go through the attributes returned from the server + // and remove those that were changed during the current + // request batch + for (var i = 0; i < changedAttrs.length; i++) { + current = newAttrs; + path = changedAttrs[i].split('.'); + while (path.length > 1) { + current = current && current[path.shift()]; + } + if (current) { + delete current[path.shift()]; + } + } + } + return newAttrs; + }, queueRequests = function (success, error, method, callback) { + this._changedAttrs = this._changedAttrs || []; + var def = new can.Deferred(), + self = this, + attrs = this.serialize(), + queue = this._requestQueue, + changedAttrs = this._changedAttrs, + reqFn, index; + reqFn = function (self, type, success, error) { + // Function that performs actual request + return function () { + // pass already serialized attributes because we want to + // save model in state it was when request was queued, not + // when request is ran + return self.constructor._makeRequest([ + self, + attrs + ], type || (self.isNew() ? 'create' : 'update'), success, error, callback); + }; + }(this, method, function () { + // resolve deferred with results from the request + def.resolveWith(self, arguments); + // remove current deferred from the queue + queue.splice(0, 1); + if (queue.length > 0) { + // replace queued wrapper function with deferred + // returned from the makeRequest function so we + // can access it's `abort` function + queue[0] = queue[0](); + } else { + // clean up changed attrs since there is no more requests in the queue + changedAttrs.splice(0); + } + }, function () { + // reject deferred with results from the request + def.rejectWith(self, arguments); + // since we failed remove all pending requests from the queue + queue.splice(0); + // clean up changed attrs since there is no more requests in the queue + changedAttrs.splice(0); + }); + // Add our fn to the queue + index = queue.push(reqFn) - 1; + // If there is only one request in the queue, run + // it immediately. + if (queue.length === 1) { + // replace queued wrapper function with deferred + // returned from the makeRequest function so we + // can access it's `abort` function + queue[0] = queue[0](); + } + def.abort = function () { + var abort; + // check if this request is running, if it's not + // just remove it from the queue + // + // also all subsequent requests should be removed too + abort = queue[index].abort && queue[index].abort(); + // remove aborted request and any requests after it + queue.splice(index); + // if there is no more requests in the queue clean up + // the changed attributes array + if (queue.length === 0) { + changedAttrs.splice(0); + } + return abort; + }; + // deferred will be resolved with original success and + // error functions + def.then(success, error); + return def; + }, _triggerChange = can.Model.prototype._triggerChange, + destroyFn = can.Model.prototype.destroy, + setupFn = can.Model.prototype.setup; + can.each([ + 'created', + 'updated', + 'destroyed' + ], function (fn) { + var prototypeFn = can.Model.prototype[fn]; + can.Model.prototype[fn] = function (attrs) { + if (attrs && typeof attrs === 'object') { + attrs = attrs.attr ? attrs.attr() : attrs; + // Create backup of last good known state returned + // from the server. This allows users to restore it + // if API returns error + this._backupStore(attrs); + attrs = cleanAttrs(this._changedAttrs || [], attrs); + } + // call the original function with the cleaned up attributes + prototypeFn.call(this, attrs); + }; + }); + can.extend(can.Model.prototype, { + setup: function () { + setupFn.apply(this, arguments); + this._requestQueue = new can.List(); + }, + _triggerChange: function (attr, how, newVal, oldVal) { + // record changes if there is a request running + if (this._changedAttrs) { + this._changedAttrs.push(attr); + } + _triggerChange.apply(this, arguments); + }, + hasQueuedRequests: function () { + return this._requestQueue.attr('length') > 1; + }, + save: function () { + return queueRequests.apply(this, arguments); + }, + destroy: function (success, error) { + if (this.isNew()) { + // if it's a new instance, call default destroy method + return destroyFn.call(this, success, error); + } + return queueRequests.call(this, success, error, 'destroy', 'destroyed'); + } + }); + return can; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/observe/observe.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/observe/observe.js new file mode 100644 index 0000000000..5d377fbdfc --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/observe/observe.js @@ -0,0 +1,18 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#observe/observe*/ +// Loads all observable core modules +steal("can/util", "can/map", "can/list", "can/compute", function (can) { + can.Observe = can.Map; + can.Observe.startBatch = can.batch.start; + can.Observe.stopBatch = can.batch.stop; + can.Observe.triggerBatch = can.batch.trigger; + return can; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/route/pushstate/pushstate.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/route/pushstate/pushstate.js new file mode 100644 index 0000000000..6b82ada0fa --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/route/pushstate/pushstate.js @@ -0,0 +1,238 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#route/pushstate/pushstate*/ +// # can/route/pushstate/pushstate.js +// +// Plugin for `can.route` which uses browser `history.pushState` support +// to update window's pathname instead of the `hash`. +// +// It registers itself as binding on `can.route`, intercepts `click` events +// on `` elements across document and accordingly updates `can.route` state +// and window's pathname. + +/*jshint maxdepth:6*/ + +steal('can/util', 'can/route', function (can) { + "use strict"; + + // Initialize plugin only if browser supports pushstate. + if (window.history && history.pushState) { + + // Registers itself within `can.route.bindings`. + can.route.bindings.pushstate = { + /** + * @property {String} can.route.pushstate.root + * @parent can.route.pushstate + * + * @description Configure the base url that will not be modified. + * + * @option {String} Represents the base url that pushstate will prepend to all + * routes. `root` defaults to: `"/"`. + * + * @body + * + * ## Use + * + * By default, a route like: + * + * can.route(":type/:id") + * + * Matches urls like: + * + * http://domain.com/contact/5 + * + * But sometimes, you only want to match pages within a certain directory. For + * example, an application that is a filemanager. You might want to + * specify root and routes like: + * + * can.route.pushstate.root = "/filemanager/" + * can.route("file-:fileId"); + * can.route("folder-:fileId") + * + * Which matches urls like: + * + * http://domain.com/filemanager/file-34234 + * + */ + + // Start of `location.pathname` is the root. + // (Can be configured via `can.route.bindings.pushstate.root`) + root: "/", + // don't greedily match slashes in routing rules + matchSlashes: false, + paramsMatcher: /^\?(?:[^=]+=[^&]*&)*[^=]+=[^&]*/, + querySeparator: '?', + + // ## bind + + // Intercepts clicks on `` elements and rewrites original `history` methods. + bind: function () { + // Intercept routable links. + can.delegate.call(can.$(document.documentElement), 'a', 'click', anchorClickHandler); + + // Rewrites original `pushState`/`replaceState` methods on `history` and keeps pointer to original methods + can.each(methodsToOverwrite, function (method) { + originalMethods[method] = window.history[method]; + window.history[method] = function (state, title, url) { + // Avoid doubled history states (with pushState). + var absolute = url.indexOf("http") === 0; + var searchHash = window.location.search + window.location.hash; + // If url differs from current call original histoy method and update `can.route` state. + if ((!absolute && url !== window.location.pathname + searchHash) || (absolute && url !== window.location.href + searchHash)) { + originalMethods[method].apply(window.history, arguments); + can.route.setState(); + } + }; + }); + + // Bind to `popstate` event, fires on back/forward. + can.bind.call(window, 'popstate', can.route.setState); + }, + + // ## unbind + + // Unbinds and restores original `history` methods + unbind: function () { + can.undelegate.call(can.$(document.documentElement), 'click', 'a', anchorClickHandler); + + can.each(methodsToOverwrite, function (method) { + window.history[method] = originalMethods[method]; + }); + can.unbind.call(window, 'popstate', can.route.setState); + }, + + // ## matchingPartOfURL + + // Returns matching part of url without root. + matchingPartOfURL: function () { + var root = cleanRoot(), + loc = (location.pathname + location.search), + index = loc.indexOf(root); + + return loc.substr(index + root.length); + }, + + // ## setURL + + // Updates URL by calling `pushState`. + setURL: function (path, changed) { + var method = "pushState"; + // Keeps hash if not in path. + if (includeHash && path.indexOf("#") === -1 && window.location.hash) { + path += window.location.hash; + } + if(replaceStateAttrs.length > 0) { + var toRemove = []; + for(var i = 0, l = changed.length; i < l; i++) { + if(can.inArray(changed[i], replaceStateAttrs) !== -1) { + method = "replaceState"; + } + if(can.inArray(changed[i], replaceStateAttrs.once) !== -1) { + toRemove.push(changed[i]); + } + } + if(toRemove.length > 0) { + removeAttrs(replaceStateAttrs, toRemove); + removeAttrs(replaceStateAttrs.once, toRemove); + } + } + window.history[method](null, null, can.route._call("root") + path); + } + }; + + // ## anchorClickHandler + + // Handler function for `click` events. + var anchorClickHandler = function (e) { + if (!(e.isDefaultPrevented ? e.isDefaultPrevented() : e.defaultPrevented === true)) { + // YUI calls back events triggered with this as a wrapped object. + var node = this._node || this; + // Fix for IE showing blank host, but blank host means current host. + var linksHost = node.host || window.location.host; + + // If link is within the same domain and descendant of `root` + if (window.location.host === linksHost) { + var root = cleanRoot(); + if (node.pathname.indexOf(root) === 0) { + + // Removes root from url. + var url = (node.pathname + node.search).substr(root.length); + // If a route matches update the data. + var curParams = can.route.deparam(url); + if (curParams.hasOwnProperty('route')) { + // Makes it possible to have a link with a hash. + includeHash = true; + window.history.pushState(null, null, node.href); + + // Test if you can preventDefault + // our tests can't call .click() b/c this + // freezes phantom. + if (e.preventDefault) { + e.preventDefault(); + } + } + } + } + } + }, + + // ## cleanRoot + + // Always returns clean root, without domain. + cleanRoot = function () { + var domain = location.protocol + "//" + location.host, + root = can.route._call("root"), + index = root.indexOf(domain); + if (index === 0) { + return root.substr(domain.length); + } + return root; + }, + removeAttrs = function(arr, attrs) { + var index; + for(var i = attrs.length - 1; i >= 0; i--) { + if( (index = can.inArray(attrs[i], arr)) !== -1) { + arr.splice(index, 1); + } + } + }, + // Original methods on `history` that will be overwritten + methodsToOverwrite = ['pushState', 'replaceState'], + // A place to store pointers to original `history` methods. + originalMethods = {}, + // Used to tell setURL to include the hash because we clicked on a link. + includeHash = false, + // Attributes that will cause replaceState to be called + replaceStateAttrs = []; + + // Enables plugin, by default `hashchange` binding is used. + can.route.defaultBinding = "pushstate"; + + can.extend(can.route, { + replaceStateOn: function() { + var attrs = can.makeArray(arguments); + Array.prototype.push.apply(replaceStateAttrs, attrs); + }, + replaceStateOnce: function() { + var attrs = can.makeArray(arguments); + replaceStateAttrs.once = can.makeArray(replaceStateAttrs.once); + + Array.prototype.push.apply(replaceStateAttrs.once, attrs); + can.route.replaceStateOn.apply(this, arguments); + }, + replaceStateOff: function() { + var attrs = can.makeArray(arguments); + removeAttrs(replaceStateAttrs, attrs); + } + }); + } + + return can; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/route/route.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/route/route.js new file mode 100644 index 0000000000..a64a58cb40 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/route/route.js @@ -0,0 +1,692 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#route/route*/ +steal('can/util', 'can/map', 'can/list','can/util/string/deparam', function (can) { + + // ## route.js + // `can.route` + // _Helps manage browser history (and client state) by synchronizing the + // `window.location.hash` with a `can.Map`._ + // + // Helper methods used for matching routes. + var + // `RegExp` used to match route variables of the type ':name'. + // Any word character or a period is matched. + matcher = /\:([\w\.]+)/g, + // Regular expression for identifying &key=value lists. + paramsMatcher = /^(?:&[^=]+=[^&]*)+/, + // Converts a JS Object into a list of parameters that can be + // inserted into an html element tag. + makeProps = function (props) { + var tags = []; + can.each(props, function (val, name) { + tags.push((name === 'className' ? 'class' : name) + '="' + + (name === "href" ? val : can.esc(val)) + '"'); + }); + return tags.join(" "); + }, + // Checks if a route matches the data provided. If any route variable + // is not present in the data, the route does not match. If all route + // variables are present in the data, the number of matches is returned + // to allow discerning between general and more specific routes. + matchesData = function (route, data) { + var count = 0, + i = 0, + defaults = {}; + // look at default values, if they match ... + for (var name in route.defaults) { + if (route.defaults[name] === data[name]) { + // mark as matched + defaults[name] = 1; + count++; + } + } + for (; i < route.names.length; i++) { + if (!data.hasOwnProperty(route.names[i])) { + return -1; + } + if (!defaults[route.names[i]]) { + count++; + } + + } + + return count; + }, + location = window.location, + wrapQuote = function (str) { + return (str + '') + .replace(/([.?*+\^$\[\]\\(){}|\-])/g, "\\$1"); + }, + each = can.each, + extend = can.extend, + // Helper for convert any object (or value) to stringified object (or value) + stringify = function (obj) { + // Object is array, plain object, Map or List + if (obj && typeof obj === "object") { + // Get native object or array from Map or List + if (obj instanceof can.Map) { + obj = obj.attr(); + // Clone object to prevent change original values + } else { + obj = can.isFunction(obj.slice) ? obj.slice() : can.extend({}, obj); + } + // Convert each object property or array item into stringified new + can.each(obj, function (val, prop) { + obj[prop] = stringify(val); + }); + // Object supports toString function + } else if (obj !== undefined && obj !== null && can.isFunction(obj.toString)) { + obj = obj.toString(); + } + + return obj; + }, + removeBackslash = function (str) { + return str.replace(/\\/g, ""); + }, + // A ~~throttled~~ debounced function called multiple times will only fire once the + // timer runs down. Each call resets the timer. + timer, + // Intermediate storage for `can.route.data`. + curParams, + // The last hash caused by a data change + lastHash, + // Are data changes pending that haven't yet updated the hash + changingData, + // List of attributes that have changed since last update + changedAttrs = [], + // If the `can.route.data` changes, update the hash. + // Using `.serialize()` retrieves the raw data contained in the `observable`. + // This function is ~~throttled~~ debounced so it only updates once even if multiple values changed. + // This might be able to use batchNum and avoid this. + onRouteDataChange = function (ev, attr, how, newval) { + // indicate that data is changing + changingData = 1; + // collect attributes that are changing + changedAttrs.push(attr); + clearTimeout(timer); + timer = setTimeout(function () { + // indicate that the hash is set to look like the data + changingData = 0; + var serialized = can.route.data.serialize(), + path = can.route.param(serialized, true); + can.route._call("setURL", path, changedAttrs); + // trigger a url change so its possible to live-bind on url-based changes + can.batch.trigger(eventsObject,"__url",[path, lastHash]); + lastHash = path; + changedAttrs = []; + }, 10); + }, + // A dummy events object used to dispatch url change events on. + eventsObject = can.extend({}, can.event); + + can.route = function (url, defaults) { + // if route ends with a / and url starts with a /, remove the leading / of the url + var root = can.route._call("root"); + + if (root.lastIndexOf("/") === root.length - 1 && + url.indexOf("/") === 0) { + url = url.substr(1); + } + + defaults = defaults || {}; + // Extract the variable names and replace with `RegExp` that will match + // an atual URL with values. + var names = [], + res, + test = "", + lastIndex = matcher.lastIndex = 0, + next, + querySeparator = can.route._call("querySeparator"), + matchSlashes = can.route._call("matchSlashes"); + + // res will be something like [":foo","foo"] + while (res = matcher.exec(url)) { + names.push(res[1]); + test += removeBackslash(url.substring(lastIndex, matcher.lastIndex - res[0].length)); + // if matchSlashes is false (the default) don't greedily match any slash in the string, assume its part of the URL + next = "\\" + (removeBackslash(url.substr(matcher.lastIndex, 1)) || querySeparator+(matchSlashes? "": "|/")); + // a name without a default value HAS to have a value + // a name that has a default value can be empty + // The `\\` is for string-escaping giving single `\` for `RegExp` escaping. + test += "([^" + next + "]" + (defaults[res[1]] ? "*" : "+") + ")"; + lastIndex = matcher.lastIndex; + } + test += url.substr(lastIndex) + .replace("\\", ""); + // Add route in a form that can be easily figured out. + can.route.routes[url] = { + // A regular expression that will match the route when variable values + // are present; i.e. for `:page/:type` the `RegExp` is `/([\w\.]*)/([\w\.]*)/` which + // will match for any value of `:page` and `:type` (word chars or period). + test: new RegExp("^" + test + "($|" + wrapQuote(querySeparator) + ")"), + // The original URL, same as the index for this entry in routes. + route: url, + // An `array` of all the variable names in this route. + names: names, + // Default values provided for the variables. + defaults: defaults, + // The number of parts in the URL separated by `/`. + length: url.split('/') + .length + }; + return can.route; + }; + + /** + * @static + */ + extend(can.route, { + + /** + * @function can.route.param param + * @parent can.route.static + * @description Get a route path from given data. + * @signature `can.route.param( data )` + * @param {data} object The data to populate the route with. + * @return {String} The route, with the data populated in it. + * + * @body + * Parameterizes the raw JS object representation provided in data. + * + * can.route.param( { type: "video", id: 5 } ) + * // -> "type=video&id=5" + * + * If a route matching the provided data is found, that URL is built + * from the data. Any remaining data is added at the end of the + * URL as & separated key/value parameters. + * + * can.route(":type/:id") + * + * can.route.param( { type: "video", id: 5 } ) // -> "video/5" + * can.route.param( { type: "video", id: 5, isNew: false } ) + * // -> "video/5&isNew=false" + */ + param: function (data, _setRoute) { + // Check if the provided data keys match the names in any routes; + // Get the one with the most matches. + var route, + // Need to have at least 1 match. + matches = 0, + matchCount, + routeName = data.route, + propCount = 0; + + delete data.route; + + each(data, function () { + propCount++; + }); + // Otherwise find route. + each(can.route.routes, function (temp, name) { + // best route is the first with all defaults matching + + matchCount = matchesData(temp, data); + if (matchCount > matches) { + route = temp; + matches = matchCount; + } + if (matchCount >= propCount) { + return false; + } + }); + // If we have a route name in our `can.route` data, and it's + // just as good as what currently matches, use that + if (can.route.routes[routeName] && matchesData(can.route.routes[routeName], data) === matches) { + route = can.route.routes[routeName]; + } + // If this is match... + if (route) { + var cpy = extend({}, data), + // Create the url by replacing the var names with the provided data. + // If the default value is found an empty string is inserted. + res = route.route.replace(matcher, function (whole, name) { + delete cpy[name]; + return data[name] === route.defaults[name] ? "" : encodeURIComponent(data[name]); + }) + .replace("\\", ""), + after; + // Remove matching default values + each(route.defaults, function (val, name) { + if (cpy[name] === val) { + delete cpy[name]; + } + }); + + // The remaining elements of data are added as + // `&` separated parameters to the url. + after = can.param(cpy); + // if we are paraming for setting the hash + // we also want to make sure the route value is updated + if (_setRoute) { + can.route.attr('route', route.route); + } + return res + (after ? can.route._call("querySeparator") + after : ""); + } + // If no route was found, there is no hash URL, only paramters. + return can.isEmptyObject(data) ? "" : can.route._call("querySeparator") + can.param(data); + }, + /** + * @function can.route.deparam deparam + * @parent can.route.static + * @description Extract data from a route path. + * @signature `can.route.deparam( url )` + * @param {String} url A route fragment to extract data from. + * @return {Object} An object containing the extracted data. + * + * @body + * Creates a data object based on the query string passed into it. This is + * useful to create an object based on the `location.hash`. + * + * can.route.deparam("id=5&type=videos") + * // -> { id: 5, type: "videos" } + * + * + * It's important to make sure the hash or exclamantion point is not passed + * to `can.route.deparam` otherwise it will be included in the first property's + * name. + * + * can.route.attr("id", 5) // location.hash -> #!id=5 + * can.route.attr("type", "videos") + * // location.hash -> #!id=5&type=videos + * can.route.deparam(location.hash) + * // -> { #!id: 5, type: "videos" } + * + * `can.route.deparam` will try and find a matching route and, if it does, + * will deconstruct the URL and parse our the key/value parameters into the data object. + * + * can.route(":type/:id") + * + * can.route.deparam("videos/5"); + * // -> { id: 5, route: ":type/:id", type: "videos" } + */ + deparam: function (url) { + + // remove the url + var root = can.route._call("root"); + if (root.lastIndexOf("/") === root.length - 1 && + url.indexOf("/") === 0) { + url = url.substr(1); + } + + // See if the url matches any routes by testing it against the `route.test` `RegExp`. + // By comparing the URL length the most specialized route that matches is used. + var route = { + length: -1 + }, + querySeparator = can.route._call("querySeparator"), + paramsMatcher = can.route._call("paramsMatcher"); + + each(can.route.routes, function (temp, name) { + if (temp.test.test(url) && temp.length > route.length) { + route = temp; + } + }); + // If a route was matched. + if (route.length > -1) { + + var // Since `RegExp` backreferences are used in `route.test` (parens) + // the parts will contain the full matched string and each variable (back-referenced) value. + parts = url.match(route.test), + // Start will contain the full matched string; parts contain the variable values. + start = parts.shift(), + // The remainder will be the `&key=value` list at the end of the URL. + remainder = url.substr(start.length - (parts[parts.length - 1] === querySeparator ? 1 : 0)), + // If there is a remainder and it contains a `&key=value` list deparam it. + obj = (remainder && paramsMatcher.test(remainder)) ? can.deparam(remainder.slice(1)) : {}; + + // Add the default values for this route. + obj = extend(true, {}, route.defaults, obj); + // Overwrite each of the default values in `obj` with those in + // parts if that part is not empty. + each(parts, function (part, i) { + if (part && part !== querySeparator) { + obj[route.names[i]] = decodeURIComponent(part); + } + }); + obj.route = route.route; + return obj; + } + // If no route was matched, it is parsed as a `&key=value` list. + if (url.charAt(0) !== querySeparator) { + url = querySeparator + url; + } + return paramsMatcher.test(url) ? can.deparam(url.slice(1)) : {}; + }, + /** + * @hide + * A can.Map that represents the state of the history. + */ + data: new can.Map({}), + map: function(data){ + var appState; + // appState is a can.Map constructor function + if(data.prototype instanceof can.Map){ + appState = new data(); + } + // appState is an instance of can.Map + else { + appState = data; + } + can.route.data = appState; + }, + /** + * @property {Object} routes + * @hide + * + * A list of routes recognized by the router indixed by the url used to add it. + * Each route is an object with these members: + * + * - test - A regular expression that will match the route when variable values + * are present; i.e. for :page/:type the `RegExp` is /([\w\.]*)/([\w\.]*)/ which + * will match for any value of :page and :type (word chars or period). + * + * - route - The original URL, same as the index for this entry in routes. + * + * - names - An array of all the variable names in this route + * + * - defaults - Default values provided for the variables or an empty object. + * + * - length - The number of parts in the URL separated by '/'. + */ + routes: {}, + /** + * @function can.route.ready ready + * @parent can.route.static + * + * Initialize can.route. + * + * @signature `can.route.ready()` + * + * Sets up the two-way binding between the hash and the can.route observable map and + * sets the can.route map to its initial values. + * + * @return {can.route} The `can.route` object. + * + * @body + * + * ## Use + * + * After setting all your routes, call can.route.ready(). + * + * can.route("overview/:dateStart-:dateEnd"); + * can.route(":type/:id") + * can.route.ready() + */ + ready: function (val) { + if (val !== true) { + can.route._setup(); + can.route.setState(); + } + return can.route; + }, + /** + * @function can.route.url url + * @parent can.route.static + * @signature `can.route.url( data [, merge] )` + * + * Make a URL fragment that when set to window.location.hash will update can.route's properties + * to match those in `data`. + * + * @param {Object} data The data to populate the route with. + * @param {Boolean} [merge] Whether the given options should be merged into the current state of the route. + * @return {String} The route URL and query string. + * + * @body + * Similar to [can.route.link], but instead of creating an anchor tag, `can.route.url` creates + * only the URL based on the route options passed into it. + * + * can.route.url( { type: "videos", id: 5 } ) + * // -> "#!type=videos&id=5" + * + * If a route matching the provided data is found the URL is built from the data. Any remaining + * data is added at the end of the URL as & separated key/value parameters. + * + * can.route(":type/:id") + * + * can.route.url( { type: "videos", id: 5 } ) // -> "#!videos/5" + * can.route.url( { type: "video", id: 5, isNew: false } ) + * // -> "#!video/5&isNew=false" + */ + url: function (options, merge) { + + if (merge) { + options = can.extend({}, can.route.deparam(can.route._call("matchingPartOfURL")), options); + } + return can.route._call("root") + can.route.param(options); + }, + /** + * @function can.route.link link + * @parent can.route.static + * @signature `can.route.link( innerText, data, props [, merge] )` + * + * Make an anchor tag (``) that when clicked on will update can.route's properties + * to match those in `data`. + * + * @param {Object} innerText The text inside the link. + * @param {Object} data The data to populate the route with. + * @param {Object} props Properties for the anchor other than `href`. + * @param {Boolean} [merge] Whether the given options should be merged into the current state of the route. + * @return {String} A string with an anchor tag that points to the populated route. + * + * @body + * Creates and returns an anchor tag with an href of the route + * attributes passed into it, as well as any properies desired + * for the tag. + * + * can.route.link( "My videos", { type: "videos" }, {}, false ) + * // -> My videos + * + * Other attributes besides href can be added to the anchor tag + * by passing in a data object with the attributes desired. + * + * can.route.link( "My videos", { type: "videos" }, + * { className: "new" }, false ) + * // -> My Videos + * + * It is possible to utilize the current route options when making anchor + * tags in order to make your code more reusable. If merge is set to true, + * the route options passed into `can.route.link` will be passed into the + * current ones. + * + * location.hash = "#!type=videos" + * can.route.link( "The zoo", { id: 5 }, true ) + * // -> The zoo + * + * location.hash = "#!type=pictures" + * can.route.link( "The zoo", { id: 5 }, true ) + * // -> The zoo + * + * + */ + link: function (name, options, props, merge) { + return "" + name + ""; + }, + /** + * @function can.route.current current + * @parent can.route.static + * @signature `can.route.current( data )` + * + * Check if data represents the current route. + * + * @param {Object} data Data to check agains the current route. + * @return {Boolean} Whether the data matches the current URL. + * + * @body + * Checks the page's current URL to see if the route represents the options passed + * into the function. + * + * Returns true if the options respresent the current URL. + * + * can.route.attr('id', 5) // location.hash -> "#!id=5" + * can.route.current({ id: 5 }) // -> true + * can.route.current({ id: 5, type: 'videos' }) // -> false + * + * can.route.attr('type', 'videos') + * // location.hash -> #!id=5&type=videos + * can.route.current({ id: 5, type: 'videos' }) // -> true + */ + current: function (options) { + // "reads" the url so the url is live-bindable. + can.__observe(eventsObject,"__url"); + return this._call("matchingPartOfURL") === can.route.param(options); + }, + bindings: { + hashchange: { + paramsMatcher: paramsMatcher, + querySeparator: "&", + // don't greedily match slashes in routing rules + matchSlashes: false, + bind: function () { + can.bind.call(window, 'hashchange', setState); + }, + unbind: function () { + can.unbind.call(window, 'hashchange', setState); + }, + // Gets the part of the url we are determinging the route from. + // For hashbased routing, it's everything after the #, for + // pushState it's configurable + matchingPartOfURL: function () { + return location.href.split(/#!?/)[1] || ""; + }, + // gets called with the serialized can.route data after a route has changed + // returns what the url has been updated to (for matching purposes) + setURL: function (path) { + if(location.hash !== "#" + path) { + location.hash = "!" + path; + } + return path; + }, + root: "#!" + } + }, + defaultBinding: "hashchange", + currentBinding: null, + // ready calls setup + // setup binds and listens to data changes + // bind listens to whatever you should be listening to + // data changes tries to set the path + + // we need to be able to + // easily kick off calling setState + // teardown whatever is there + // turn on a particular binding + + // called when the route is ready + _setup: function () { + if (!can.route.currentBinding) { + can.route._call("bind"); + can.route.bind("change", onRouteDataChange); + can.route.currentBinding = can.route.defaultBinding; + } + }, + _teardown: function () { + if (can.route.currentBinding) { + can.route._call("unbind"); + can.route.unbind("change", onRouteDataChange); + can.route.currentBinding = null; + } + clearTimeout(timer); + changingData = 0; + }, + // a helper to get stuff from the current or default bindings + _call: function () { + var args = can.makeArray(arguments), + prop = args.shift(), + binding = can.route.bindings[can.route.currentBinding || can.route.defaultBinding], + method = binding[prop]; + if (method.apply) { + return method.apply(binding, args); + } else { + return method; + } + } + }); + + // The functions in the following list applied to `can.route` (e.g. `can.route.attr('...')`) will + // instead act on the `can.route.data` observe. + each(['bind', 'unbind', 'on', 'off', 'delegate', 'undelegate', 'removeAttr', 'compute', '_get', '__get','each'], function (name) { + can.route[name] = function () { + // `delegate` and `undelegate` require + // the `can/map/delegate` plugin + if (!can.route.data[name]) { + return; + } + + return can.route.data[name].apply(can.route.data, arguments); + }; + }); + + // Because everything in hashbang is in fact a string this will automaticaly convert new values to string. Works with single value, or deep hashes. + // Main motivation for this is to prevent double route event call for same value. + // Example (the problem): + // When you load page with hashbang like #!&some_number=2 and bind 'some_number' on routes. + // It will fire event with adding of "2" (string) to 'some_number' property + // But when you after this set can.route.attr({some_number: 2}) or can.route.attr('some_number', 2). it fires another event with change of 'some_number' from "2" (string) to 2 (integer) + // This wont happen again with this normalization + can.route.attr = function (attr, val) { + var type = typeof attr, + newArguments; + + // Reading + if (val === undefined) { + newArguments = arguments; + // Sets object + } else if (type !== "string" && type !== "number") { + newArguments = [stringify(attr), val]; + // Sets key - value + } else { + newArguments = [attr, stringify(val)]; + } + + return can.route.data.attr.apply(can.route.data, newArguments); + }; + + var // Deparameterizes the portion of the hash of interest and assign the + // values to the `can.route.data` removing existing values no longer in the hash. + // setState is called typically by hashchange which fires asynchronously + // So it's possible that someone started changing the data before the + // hashchange event fired. For this reason, it will not set the route data + // if the data is changing or the hash already matches the hash that was set. + setState = can.route.setState = function () { + var hash = can.route._call("matchingPartOfURL"); + var oldParams = curParams; + curParams = can.route.deparam(hash); + + // if the hash data is currently changing, or + // the hash is what we set it to anyway, do NOT change the hash + if (!changingData || hash !== lastHash) { + can.batch.start(); + recursiveClean(oldParams, curParams, can.route.data); + + can.route.attr(curParams); + // trigger a url change so its possible to live-bind on url-based changes + can.batch.trigger(eventsObject,"__url",[hash, lastHash]); + can.batch.stop(); + } + }; + + var recursiveClean = function(old, cur, data){ + for(var attr in old){ + if(cur[attr] === undefined){ + data.removeAttr(attr); + } + else if(Object.prototype.toString.call(old[attr]) === "[object Object]") { + recursiveClean( old[attr], cur[attr], data.attr(attr) ); + } + } + }; + + return can.route; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/array/each.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/array/each.js new file mode 100644 index 0000000000..9c91d1b4a4 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/array/each.js @@ -0,0 +1,70 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/array/each*/ +/* jshint maxdepth:7*/ +steal('can/util/can.js', function (can) { + + // The following is from jQuery + var isArrayLike = function(obj){ + // The `in` check is from jQuery’s fix for an iOS 8 64-bit JIT object length bug: + // https://github.com/jquery/jquery/pull/2185 + var length = "length" in obj && obj.length; + return typeof arr !== "function" && + ( length === 0 || typeof length === "number" && length > 0 && ( length - 1 ) in obj ); + }; + + can.each = function (elements, callback, context) { + var i = 0, + key, + len, + item; + if (elements) { + if ( isArrayLike(elements) ) { + if(can.List && elements instanceof can.List ) { + for (len = elements.attr("length"); i < len; i++) { + item = elements.attr(i); + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } else { + for (len = elements.length; i < len; i++) { + item = elements[i]; + if (callback.call(context || item, item, i, elements) === false) { + break; + } + } + } + + } else if (typeof elements === "object") { + + if (can.Map && elements instanceof can.Map || elements === can.route) { + var keys = can.Map.keys(elements); + for(i =0, len = keys.length; i < len; i++) { + key = keys[i]; + item = elements.attr(key); + if (callback.call(context || item, item, key, elements) === false) { + break; + } + } + } else { + for (key in elements) { + if (elements.hasOwnProperty(key) && callback.call(context || elements[key], elements[key], key, elements) === false) { + break; + } + } + } + + } + } + return elements; + }; + return can; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/array/makeArray.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/array/makeArray.js new file mode 100644 index 0000000000..7bb4d5ef4d --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/array/makeArray.js @@ -0,0 +1,19 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/array/makeArray*/ +steal('./each.js', function (can) { + can.makeArray = function (arr) { + var ret = []; + can.each(arr, function (a, i) { + ret[i] = a; + }); + return ret; + }; + return can; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/attr/attr.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/attr/attr.js new file mode 100644 index 0000000000..b80620ac9a --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/attr/attr.js @@ -0,0 +1,195 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/attr/attr*/ +// # can/util/attr.js +// Central location for attribute changing to occur, used to trigger an +// `attributes` event on elements. This enables the user to do (jQuery example): `$(el).bind("attributes", function(ev) { ... })` where `ev` contains `attributeName` and `oldValue`. + + +steal("can/util/can.js", function (can) { + + // Acts as a polyfill for setImmediate which only works in IE 10+. Needed to make + // the triggering of `attributes` event async. + var setImmediate = can.global.setImmediate || function (cb) { + return setTimeout(cb, 0); + }, + attr = { + // This property lets us know if the browser supports mutation observers. + // If they are supported then that will be setup in can/util/jquery and those native events will be used to inform observers of attribute changes. + // Otherwise this module handles triggering an `attributes` event on the element. + MutationObserver: can.global.MutationObserver || can.global.WebKitMutationObserver || can.global.MozMutationObserver, + + /** + * @property {Object.} can.view.attr.map + * @parent can.view.elements + * @hide + * + * + * A mapping of + * special attributes to their JS property. For example: + * + * "class" : "className" + * + * means get or set `element.className`. And: + * + * "checked" : true + * + * means set `element.checked = true`. + * + * + * If the attribute name is not found, it's assumed to use + * `element.getAttribute` and `element.setAttribute`. + */ + map: { + "class": "className", + "value": "value", + "innertext": "innerText", + "textcontent": "textContent", + "checked": true, + "disabled": true, + "readonly": true, + "required": true, + // For the `src` attribute we are using a setter function to prevent values such as an empty string or null from being set. + // An `img` tag attempts to fetch the `src` when it is set, so we need to prevent that from happening by removing the attribute instead. + src: function (el, val) { + if (val == null || val === "") { + el.removeAttribute("src"); + return null; + } else { + el.setAttribute("src", val); + return val; + } + }, + style: function (el, val) { + return el.style.cssText = val || ""; + } + }, + // These are elements whos default value we should set. + defaultValue: ["input", "textarea"], + // ## attr.set + // Set the value an attribute on an element. + set: function (el, attrName, val) { + attrName = attrName.toLowerCase(); + var oldValue; + // In order to later trigger an event we need to compare the new value to the old value, so here we go ahead and retrieve the old value for browsers that don't have native MutationObservers. + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + + var tagName = el.nodeName.toString().toLowerCase(), + prop = attr.map[attrName], + newValue; + + // Using the property of `attr.map`, go through and check if the property is a function, and if so call it. Then check if the property is `true`, and if so set the value to `true`, also making sure to set `defaultChecked` to `true` for elements of `attr.defaultValue`. We always set the value to true because for these boolean properties, setting them to false would be the same as removing the attribute. + // + // For all other attributes use `setAttribute` to set the new value. + if (typeof prop === "function") { + newValue = prop(el, val); + } else if (prop === true) { + newValue = el[attrName] = true; + + if (attrName === "checked" && el.type === "radio") { + if (can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultChecked = true; + } + } + + } else if (prop) { + newValue = val; + if (el[prop] !== val) { + el[prop] = val; + } + if (prop === "value" && can.inArray(tagName, attr.defaultValue) >= 0) { + el.defaultValue = val; + } + } else { + el.setAttribute(attrName, val); + newValue = val; + } + + // Now that the value has been set, for browsers without MutationObservers, check to see that value has changed and if so trigger the "attributes" event on the element. + if (!attr.MutationObserver && newValue !== oldValue) { + attr.trigger(el, attrName, oldValue); + } + }, + // ## attr.trigger + // Used to trigger an "attributes" event on an element. Checks to make sure that someone is listening for the event and then queues a function to be called asynchronously using `setImmediate. + trigger: function (el, attrName, oldValue) { + if (can.data(can.$(el), "canHasAttributesBindings")) { + attrName = attrName.toLowerCase(); + return setImmediate(function () { + can.trigger(el, { + type: "attributes", + attributeName: attrName, + target: el, + oldValue: oldValue, + bubbles: false + }, []); + }); + } + }, + // ## attr.get + // Gets the value of an attribute. First checks to see if the property is a string on `attr.map` and if so returns the value from the element's property. Otherwise uses `getAttribute` to retrieve the value. + get: function (el, attrName) { + attrName = attrName.toLowerCase(); + var prop = attr.map[attrName]; + if(typeof prop === "string" && el[prop]) { + return el[prop]; + } + + return el.getAttribute(attrName); + }, + // ## attr.remove + // Removes an attribute from an element. Works by using the `attr.map` to see if the attribute is a special type of property. If the property is a function then the fuction is called with `undefined` as the value. If the property is `true` then the attribute is set to false. If the property is a string then the attribute is set to an empty string. Otherwise `removeAttribute` is used. + // + // If the attribute previously had a value and the browser doesn't support MutationObservers we then trigger an "attributes" event. + remove: function (el, attrName) { + attrName = attrName.toLowerCase(); + var oldValue; + if (!attr.MutationObserver) { + oldValue = attr.get(el, attrName); + } + + var setter = attr.map[attrName]; + if (typeof setter === "function") { + setter(el, undefined); + } + if (setter === true) { + el[attrName] = false; + } else if (typeof setter === "string") { + el[setter] = ""; + } else { + el.removeAttribute(attrName); + } + if (!attr.MutationObserver && oldValue != null) { + attr.trigger(el, attrName, oldValue); + } + + }, + // ## attr.has + // Checks if an element contains an attribute. + // For browsers that support `hasAttribute`, creates a function that calls hasAttribute, otherwise creates a function that uses `getAttribute` to check that the attribute is not null. + has: (function () { + var el = can.global.document && document.createElement('div'); + if (el && el.hasAttribute) { + return function (el, name) { + return el.hasAttribute(name); + }; + } else { + return function (el, name) { + return el.getAttribute(name) !== null; + }; + } + })() + }; + + return attr; + +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/batch/batch.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/batch/batch.js new file mode 100644 index 0000000000..cb3655e95b --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/batch/batch.js @@ -0,0 +1,263 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/batch/batch*/ +steal('can/util/can.js', function (can) { + // Which batch of events this is for -- might not want to send multiple + // messages on the same batch. This is mostly for event delegation. + var batchNum = 1, + // how many times has start been called without a stop + transactions = 0, + // an array of events within a transaction + batchEvents = [], + stopCallbacks = [], + // an array of the currently dispatching batch events ... here so we can add things to the end of it (1519). + currentBatchEvents = null; + + can.batch = { + /** + * @function can.batch.start + * @parent can.batch + * @description Begin an event batch. + * + * @signature `can.batch.start([batchStopHandler])` + * + * @param {Function} [batchStopHandler] a callback that gets called after all batched events have been called + * + * @body + * `can.batch.start` causes can.Map to begin an event batch. Until `[can.batch.stop]` is called, any + * events that would result from calls to `[can.Map::attr attr]` are held back from firing. If you have + * lots of changes to make to can.Maps, batching them together can help performance &emdash; especially if + * those can.Maps are live-bound to the DOM. + * + * In this example, you can see how the _first_ and _change_ events are not fired (and their handlers + * are not called) until `can.batch.stop` is called. + * + * ``` + * var person = new can.Map({ + * first: 'Alexis', + * last: 'Abril' + * }); + * + * person.bind('first', function() { + * console.log("First name changed.""); + * }).bind('change', function() { + * console.log("Something changed."); + * }); + * + * can.batch.start(); + * person.attr('first', 'Alex'); + * console.log('Still in the batch.'); + * can.batch.stop(); + * + * // the log has: + * // Still in the batch. + * // First name changed. + * // Something changed. + * ``` + * + * You can also pass a callback to `can.batch.start` which will be called after all the events have + * been fired: + * ``` + * can.batch.start(function() { + * console.log('The batch is over.'); + * }); + * person.attr('first', 'Izzy'); + * console.log('Still in the batch.'); + * can.batch.stop(); + * + * // The console has: + * // Still in the batch. + * // First name changed. + * // Something changed. + * // The batch is over. + * ``` + * + * ## Calling `can.batch.start` multiple times + * + * If you call `can.batch.start` more than once, `can.batch.stop` needs to be called + * the same number of times before any batched events will fire. For ways + * to circumvent this process, see [can.batch.stop]. + * + * Here is an example that demonstrates how events are affected by calling + * `can.batch.start` multiple times. + * + * ``` + * var addPeople = function(observable) { + * can.batch.start(); + * observable.attr('a', 'Alice'); + * observable.attr('b', 'Bob'); + * observable.attr('e', 'Eve'); + * can.batch.stop(); + * }; + * + * // In a completely different place: + * var list = new can.Map(); + * list.bind('change', function() { + * console.log('The list changed.'); + * }); + * + * can.batch.start(); + * addPeople(list); + * console.log('Still in the batch.'); + * + * // Here, the console has: + * // Still in the batch. + * + * can.batch.stop(); + * + * // Here, the console has: + * // Still in the batch. + * // The list changed. + * // The list changed. + * // The list changed. + * ``` + */ + start: function (batchStopHandler) { + transactions++; + if (batchStopHandler) { + stopCallbacks.push(batchStopHandler); + } + }, + /** + * @function can.batch.stop + * @parent can.batch + * @description End an event batch. + * @signature `can.batch.stop([force[, callStart]])` + * @param {bool} [force=false] whether to stop batching events immediately + * @param {bool} [callStart=false] whether to call `[can.batch.start can.batch.start]` after firing batched events + * + * @body + * `can.batch.stop` matches an earlier `[can.batch.start]` call. If `can.batch.stop` has been + * called as many times as `can.batch.start` (or if _force_ is true), all batched events will be + * fired and any callbacks passed to `can.batch.start` since the beginning of the batch will be + * called. If _force and _callStart_ are both true, a new batch will be started when all + * the events and callbacks have been fired. + * + * See `[can.batch.start]` for examples of `can.batch.start` and `can.batch.stop` in normal use. + * + * In this example, the batch is forceably ended in the `addPeople` function. + * ``` + * var addPeople = function(observable) { + * can.batch.start(); + * observable.attr('a', 'Alice'); + * observable.attr('b', 'Bob'); + * observable.attr('e', 'Eve'); + * can.batch.stop(true); + * }; + * + * // In a completely different place: + * var list = new can.Map(); + * list.bind('change', function() { + * console.log('The list changed.'); + * }); + * + * can.batch.start(); + * addPeople(list); + * console.log('Still in the batch.'); + * + * // Here, the console has: + * // Still in the batch. + * + * can.batch.stop(); + * + * // Here, the console has: + * // The list changed. + * // The list changed. + * // The list changed. + * // Still in the batch. + * ``` + */ + stop: function (force, callStart) { + if (force) { + transactions = 0; + } else { + transactions--; + } + if (transactions === 0) { + if(currentBatchEvents !== null) { + return; + } + + currentBatchEvents = batchEvents.slice(0); + + var callbacks = stopCallbacks.slice(0), + i, len; + batchEvents = []; + stopCallbacks = []; + // Capture current batchNum so it can be check in live bindings + can.batch.batchNum = batchNum; + batchNum++; + if (callStart) { + can.batch.start(); + } + for(i = 0; i < currentBatchEvents.length; i++) { + can.dispatch.apply(currentBatchEvents[i][0],currentBatchEvents[i][1]); + } + currentBatchEvents = null; + + for(i = 0, len = callbacks.length; i < callbacks.length; i++) { + callbacks[i](); + } + can.batch.batchNum = undefined; + } + }, + /** + * @function can.batch.trigger + * @parent can.batch + * @description Trigger an event to be added to the current batch. + * @signature `can.batch.trigger(item, event [, args])` + * @param {can.Map} item the target of the event + * @param {String|{type: String}} event the type of event, or an event object with a type given + * @param {Array} [args] the parameters to trigger the event with. + * + * @body + * If events are currently being batched, calling `can.batch.trigger` adds an event + * to the batch. If events are not currently being batched, the event is triggered + * immediately. + */ + trigger: function (item, event, args) { + // Don't send events if initalizing. + if (!item._init) { + event = typeof event === 'string' ? { + type: event + } : event; + + if( currentBatchEvents) { + + currentBatchEvents.push([ + item, + [event, args] + ]); + + } else if (transactions === 0) { + return can.dispatch.call( item, event, args ); + } else { + event.batchNum = batchNum; + batchEvents.push([ + item, + [event, args] + ]); + } + } + }, + afterPreviousEvents: function(handler){ + if(currentBatchEvents) { + var obj = {}; + can.bind.call(obj,"ready", handler); + currentBatchEvents.push([ + obj, + [{type: "ready"}, []] + ]); + } else { + handler(); + } + } + }; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/bind/bind.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/bind/bind.js new file mode 100644 index 0000000000..bfec0c035b --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/bind/bind.js @@ -0,0 +1,61 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/bind/bind*/ +steal('can/util', function (can) { + /** + * @typedef {{bind:function():*,unbind:function():*}} can.util.bind + * + * Provides mixin-able bind and unbind methods. `bind()` calls `this._bindsetup` + * when the first bind happens and. `unbind()` calls `this._bindteardown` when there + * are no more event handlers. + * + */ + // ## Bind helpers + can.bindAndSetup = function () { + // Add the event to this object + can.addEvent.apply(this, arguments); + // If not initializing, and the first binding + // call bindsetup if the function exists. + if (!this._init) { + if (!this._bindings) { + this._bindings = 1; + // setup live-binding + if (this._bindsetup) { + this._bindsetup(); + } + } else { + this._bindings++; + } + } + return this; + }; + can.unbindAndTeardown = function (event, handler) { + + var handlers = this.__bindEvents[event] || []; + var handlerCount = handlers.length; + + // Remove the event handler + can.removeEvent.apply(this, arguments); + if (this._bindings === null) { + this._bindings = 0; + } else { + // Subtract the difference in the number of handlers bound to this + // event before/after removeEvent + this._bindings = this._bindings - (handlerCount - handlers.length); + } + // If there are no longer any bindings and + // there is a bindteardown method, call it. + if (!this._bindings && this._bindteardown) { + this._bindteardown(); + } + return this; + }; + return can; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/can.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/can.js new file mode 100644 index 0000000000..1fbfe0f3ad --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/can.js @@ -0,0 +1,203 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/can*/ +/* global global: false */ +steal(function () { + /* global GLOBALCAN */ + var glbl = typeof window !== "undefined" ? window : global; + + var can = {}; + if (typeof GLOBALCAN === 'undefined' || GLOBALCAN !== false) { + glbl.can = can; + } + can.global = glbl; + + // An empty function useful for where you need a dummy callback. + can.k = function(){}; + + can.isDeferred = can.isPromise = function (obj) { + // Returns `true` if something looks like a deferred. + return obj && typeof obj.then === "function" && typeof obj.pipe === "function"; + }; + can.isMapLike = function(obj){ + return can.Map && (obj instanceof can.Map || obj && obj.__get); + }; + + var cid = 0; + can.cid = function (object, name) { + if (!object._cid) { + cid++; + object._cid = (name || '') + cid; + } + return object._cid; + }; + can.VERSION = '2.2.6'; + + can.simpleExtend = function (d, s) { + for (var prop in s) { + d[prop] = s[prop]; + } + return d; + }; + + can.last = function(arr){ + return arr && arr[arr.length - 1]; + }; + var protoBind = Function.prototype.bind; + if(protoBind) { + can.proxy = function(fn, context){ + return protoBind.call(fn, context); + }; + } else { + can.proxy = function (fn, context) { + return function () { + return fn.apply(context, arguments); + }; + }; + } + + + can.frag = function(item){ + var frag; + if(!item || typeof item === "string"){ + frag = can.buildFragment(item == null ? "" : ""+item, document.body); + // If we have an empty frag... + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } else if(item.nodeType === 11) { + return item; + } else if(typeof item.nodeType === "number") { + frag = document.createDocumentFragment(); + frag.appendChild(item); + return frag; + } else if(typeof item.length === "number") { + frag = document.createDocumentFragment(); + can.each(item, function(item){ + frag.appendChild( can.frag(item) ); + }); + return frag; + } else { + frag = can.buildFragment( ""+item, document.body); + // If we have an empty frag... + if (!frag.childNodes.length) { + frag.appendChild(document.createTextNode('')); + } + return frag; + } + }; + + // Define the `can.scope` function that can be used to retrieve the `scope` from the element + can.scope = can.viewModel = function (el, attr, val) { + el = can.$(el); + var scope = can.data(el, "scope") || can.data(el, "viewModel"); + if(!scope) { + scope = new can.Map(); + can.data(el, "scope", scope); + can.data(el, "viewModel", scope); + } + switch (arguments.length) { + case 0: + case 1: + return scope; + case 2: + return scope.attr(attr); + default: + scope.attr(attr, val); + return el; + } + }; + + can["import"] = function(moduleName) { + var deferred = new can.Deferred(); + + if(typeof window.System === "object" && can.isFunction(window.System["import"])) { + window.System["import"](moduleName).then(can.proxy(deferred.resolve, deferred), + can.proxy(deferred.reject, deferred)); + } else if(window.define && window.define.amd){ + + window.require([moduleName], function(value){ + deferred.resolve(value); + }); + + } else if(window.steal) { + + steal.steal(moduleName, function(value){ + deferred.resolve(value); + }); + + } else if(window.require){ + deferred.resolve(window.require(moduleName)); + } else { + // ideally this will use can.getObject + deferred.resolve(); + } + + return deferred.promise(); + }; + + // this is here in case can.compute hasn't loaded + can.__observe = function () {}; + + //!steal-remove-start + can.dev = { + warnTimeout: 5000, + logLevel: 0, + /** + * Adds a warning message to the console. + * ``` + * can.dev.warn("something evil"); + * ``` + * @param {String} out the message + */ + warn: function (out) { + var ll = this.logLevel; + if (ll < 2) { + Array.prototype.unshift.call(arguments, 'WARN:'); + if (typeof window !== undefined && window.console && console.warn) { + this._logger("warn", Array.prototype.slice.call(arguments)); + } else if (window.console && console.log) { + this._logger("log", Array.prototype.slice.call(arguments)); + } else if (window.opera && window.opera.postError) { + window.opera.postError("steal.js WARNING: " + out); + } + } + }, + /** + * Adds a message to the console. + * ``` + * can.dev.log("hi"); + * ``` + * @param {String} out the message + */ + log: function (out) { + var ll = this.logLevel; + if (ll < 1) { + if (window.console && console.log) { + Array.prototype.unshift.call(arguments, 'Info:'); + this._logger("log", Array.prototype.slice.call(arguments)); + } else if (window.opera && window.opera.postError) { + window.opera.postError("steal.js INFO: " + out); + } + } + }, + _logger: function (type, arr) { + if (console.log.apply) { + console[type].apply(console, arr); + } else { + console[type](arr); + } + } + }; + //!steal-remove-end + + return can; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/deferred.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/deferred.js new file mode 100644 index 0000000000..20db57ea39 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/deferred.js @@ -0,0 +1,185 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/deferred*/ +steal('can/util/can.js', function (can) { + // deferred.js + // --------- + // _Lightweight, jQuery style deferreds._ + // extend is usually provided by the wrapper but to avoid steal.then calls + // we define a simple extend here as well + var extend = function (target, src) { + for (var key in src) { + if (src.hasOwnProperty(key)) { + target[key] = src[key]; + } + } + }, Deferred = function (func) { + if (!(this instanceof Deferred)) { + return new Deferred(); + } + this._doneFuncs = []; + this._failFuncs = []; + this._resultArgs = null; + this._status = ''; + // Check for option `function` -- call it with this as context and as first + // parameter, as specified in jQuery API. + if (func) { + func.call(this, this); + } + }; + can.Deferred = Deferred; + can.when = Deferred.when = function () { + var args = can.makeArray(arguments); + if (args.length < 2) { + var obj = args[0]; + if (obj && (can.isFunction(obj.isResolved) && can.isFunction(obj.isRejected))) { + return obj; + } else { + return Deferred() + .resolve(obj); + } + } else { + var df = Deferred(), + done = 0, + // Resolve params -- params of each resolve, we need to track them down + // to be able to pass them in the correct order if the master + // needs to be resolved. + rp = []; + can.each(args, function (arg, j) { + arg.done(function () { + rp[j] = arguments.length < 2 ? arguments[0] : arguments; + if (++done === args.length) { + df.resolve.apply(df, rp); + } + }) + .fail(function () { + df.reject(arguments.length === 1 ? arguments[0] : arguments); + }); + }); + return df; + } + }; + var resolveFunc = function (type, _status) { + return function (context) { + var args = this._resultArgs = arguments.length > 1 ? arguments[1] : []; + return this.exec(context, this[type], args, _status); + }; + }, doneFunc = function doneFunc(type, _status) { + return function () { + var self = this; + // In Safari, the properties of the `arguments` object are not enumerable, + // so we have to convert arguments to an `Array` that allows `can.each` to loop over them. + can.each(Array.prototype.slice.call(arguments), function (v, i, args) { + if (!v) { + return; + } + if (v.constructor === Array) { + doneFunc.apply(self, v); + } else { + // Immediately call the `function` if the deferred has been resolved. + if (self._status === _status) { + v.apply(self, self._resultArgs || []); + } + self[type].push(v); + } + }); + return this; + }; + }; + + var isDeferred = function(obj){ + return obj && obj.then && obj.fail && obj.done; + }; + + var wire = function(parentDeferred, result, setter, value){ + if( isDeferred(result) ) { + result.done(can.proxy(parentDeferred.resolve, parentDeferred)) + .fail( can.proxy(parentDeferred.reject, parentDeferred) ); + } else { + setter.call(parentDeferred,result !== undefined ? result : value); + } + }; + extend(Deferred.prototype, { + then: function (done, fail) { + var d = can.Deferred(), + resolve = d.resolve, + reject = d.reject; + this.done(function (value) { + if(typeof done === "function") { + wire(d, done.apply(this, arguments), resolve, value); + } else { + resolve.apply(d, arguments); + } + + }); + this.fail(function (value) { + if (typeof fail === "function") { + wire(d, fail.apply(this, arguments), reject, value); + } else { + reject.apply(d, arguments); + } + }); + return d; + }, + resolveWith: resolveFunc('_doneFuncs', 'rs'), + rejectWith: resolveFunc('_failFuncs', 'rj'), + done: doneFunc('_doneFuncs', 'rs'), + fail: doneFunc('_failFuncs', 'rj'), + always: function () { + var args = can.makeArray(arguments); + if (args.length && args[0]) { + this.done(args[0]) + .fail(args[0]); + } + return this; + }, + state: function () { + switch (this._status) { + case 'rs': + return 'resolved'; + case 'rj': + return 'rejected'; + default: + return 'pending'; + } + }, + isResolved: function () { + return this._status === 'rs'; + }, + isRejected: function () { + return this._status === 'rj'; + }, + reject: function () { + return this.rejectWith(this, arguments); + }, + resolve: function () { + return this.resolveWith(this, arguments); + }, + exec: function (context, dst, args, st) { + if (this._status !== '') { + return this; + } + this._status = st; + can.each(dst, function (d) { + if (typeof d.apply === 'function') { + d.apply(context, args); + } + }); + return this; + }, + promise: function(){ + var promise = this.then(); + promise.reject = promise.resolve = undefined; + return promise; + } + }); + Deferred.prototype.pipe = Deferred.prototype.then; + return can; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/dojo/dojo.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/dojo/dojo.js new file mode 100644 index 0000000000..a1e62db605 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/dojo/dojo.js @@ -0,0 +1,694 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/util*/ +"format steal"; +steal('can/util/can.js', 'can/util/attr', 'dojo', 'can/event', 'can/util/fragment.js', + 'can/util/array/each.js', + 'can/util/object/isplain', + 'can/util/deferred.js', + 'can/util/hashchange.js', + 'can/util/inserted', + function (can, attr, djo) { + + var dojo = djo || window.dojo; + define('plugd/trigger', ['dojo/main'], function () { + var d = dojo; + var isfn = d.isFunction; + var leaveRe = /mouse(enter|leave)/; + var _fix = function (_, p) { + return 'mouse' + (p === 'enter' ? 'over' : 'out'); + }; + var mix = d._mixin; + // the guts of the node triggering logic: + // the function accepts node (not string|node), "on"-less event name, + // and an object of args to mix into the event. + var realTrigger; + + if (d.doc.createEvent) { + realTrigger = function (n, e, a) { + // the sane branch + var ev = d.doc.createEvent('HTMLEvents'); + e = e.replace(leaveRe, _fix); + // removed / inserted events should not bubble + ev.initEvent(e, e === 'removed' || e === 'inserted' ? false : true, true); + if (a) { + mix(ev, a); + } + n.dispatchEvent(ev); + }; + } else { + realTrigger = function (n, e, a) { + // the janktastic branch + var ev = 'on' + e, + stop = false; + try { + // FIXME: is this worth it? for mixed-case native event support:? Opera ends up in the + // createEvent path above, and also fails on _some_ native-named events. + // if(lc !== e && d.indexOf(d.NodeList.events, lc) >= 0){ + // // if the event is one of those listed in our NodeList list + // // in lowercase form but is mixed case, throw to avoid + // // fireEvent. /me sighs. http://gist.github.com/315318 + // throw("janktastic"); + // } + var evObj = document.createEventObject(); + if (e === "inserted" || e === "removed") { + evObj.cancelBubble = true; + } + mix(evObj, a); + n.fireEvent(ev, evObj); + } catch (er) { + // a lame duck to work with. we're probably a 'custom event' + var evdata = mix({ + type: e, + target: n, + faux: true, + // HACK: [needs] added support for customStopper to _base/event.js + // some tests will fail until del._stopPropagation has support. + _stopper: function () { + stop = this.cancelBubble; + } + }, a); + if (isfn(n[ev])) { + n[ev](evdata); + } + if (e === "inserted" || e === "removed") { + return; + } + // handle bubbling of custom events, unless the event was stopped. + while (!stop && n !== d.doc && n.parentNode) { + n = n.parentNode; + if (isfn(n[ev])) { + n[ev](evdata); + } + } + } + }; + } + d._trigger = function (node, event, extraArgs) { + if (typeof event !== 'string') { + extraArgs = event; + event = extraArgs.type; + delete extraArgs.type; + } + // summary: + // Helper for `dojo.trigger`, which handles the DOM cases. We should never + // be here without a domNode reference and a string eventname. + var n = d.byId(node), + ev = event && event.slice(0, 2) === 'on' ? event.slice(2) : event; + realTrigger(n, ev, extraArgs); + }; + d.trigger = function (obj, event, extraArgs) { + // summary: + // Trigger some event. It can be either a Dom Event, Custom Event, + // or direct function call. + // + // description: + // Trigger some event. It can be either a Dom Event, Custom Event, + // or direct function call. NOTE: This function does not trigger + // default behavior, only triggers bound event listeneres. eg: + // one cannot trigger("anchorNode", "onclick") and expect the browser + // to follow the href="" attribute naturally. + // + // obj: String|DomNode|Object|Function + // An ID, or DomNode reference, from which to trigger the event. + // If an Object, fire the `event` in the scope of this object, + // similar to calling dojo.hitch(obj, event)(). The return value + // in this case is returned from `dojo.trigger` + // + // event: String|Function + // The name of the event to trigger. can be any DOM level 2 event + // and can be in either form: "onclick" or "click" for instance. + // In the object-firing case, this method can be a function or + // a string version of a member function, just like `dojo.hitch`. + // + // extraArgs: Object? + // An object to mix into the `event` object passed to any bound + // listeners. Be careful not to override important members, like + // `type`, or `preventDefault`. It will likely error. + // + // Additionally, extraArgs is moot in the object-triggering case, + // as all arguments beyond the `event` are curried onto the triggered + // function. + // + // example: + // | dojo.connect(node, "onclick", function(e){ /* stuff */ }); + // | // later: + // | dojo.trigger(node, "onclick"); + // + // example: + // | // or from within dojo.query: (requires dojo.NodeList) + // | dojo.query("a").onclick(function(){}).trigger("onclick"); + // + // example: + // | // fire obj.method() in scope of obj + // | dojo.trigger(obj, "method"); + // + // example: + // | // fire an anonymous function: + // | dojo.trigger(d.global, function(){ /* stuff */ }); + // + // example: + // | // fire and anonymous function in the scope of obj + // | dojo.trigger(obj, function(){ this == obj; }); + // + // example: + // | // with a connected function like: + // | dojo.connect(dojo.doc, "onclick", function(e){ + // | if(e && e.manuallydone){ + // | console.log("this was a triggered onclick, not natural"); + // | } + // | }); + // | // fire onclick, passing in a custom bit of info + // | dojo.trigger("someId", "onclick", { manuallydone:true }); + // + // returns: Anything + // Will not return anything in the Dom event case, but will return whatever + // return value is received from the triggered event. + return isfn(obj) || isfn(event) || isfn(obj[event]) ? d.hitch.apply(d, arguments)() : d._trigger.apply(d, arguments); + }; + d.NodeList.prototype.trigger = d.NodeList._adaptAsForEach(d._trigger); + // if the node.js module is available, extend trigger into that. + if (d._Node && !d._Node.prototype.trigger) { + d.extend(d._Node, { + trigger: function (ev, data) { + // summary: + // Fire some some event originating from this node. + // Only available if both the `dojo.trigger` and `dojo.node` plugin + // are enabled. Allows chaining as all `dojo._Node` methods do. + // + // ev: String + // Some string event name to fire. eg: "onclick", "submit" + // + // data: Object + // Just like `extraArgs` for `dojo.trigger`, additional data + // to mix into the event object. + // + // example: + // | // fire onlick orginiating from a node with id="someAnchorId" + // | dojo.node("someAnchorId").trigger("click"); + d._trigger(this, ev, data); + return this; // dojo._Node + } + }); + } + return d.trigger; + }); + // dojo.js + // --------- + // _dojo node list._ + // + // These are pre-loaded by `steal` -> no callback. + require([ + 'dojo/main', + 'dojo/query', + 'plugd/trigger', + 'dojo/NodeList-dom' + ]); + // Map string helpers. + can.trim = function (s) { + return s && dojo.trim(s); + }; + // Map array helpers. + can.makeArray = function (arr) { + var array = []; + dojo.forEach(arr, function (item) { + array.push(item); + }); + return array; + }; + can.isArray = dojo.isArray; + can.inArray = function (item, arr, from) { + return dojo.indexOf(arr, item, from); + }; + can.map = function (arr, fn) { + return dojo.map(can.makeArray(arr || []), fn); + }; + // Map object helpers. + can.extend = function (first) { + if (first === true) { + var args = can.makeArray(arguments); + args.shift(); + return dojo.mixin.apply(dojo, args); + } + return dojo.mixin.apply(dojo, arguments); + }; + can.isEmptyObject = function (object) { + var prop; + for (prop in object) { + break; + } + return prop === undefined; + }; + // Use a version of param similar to jQuery's param that + // handles nested data instead of dojo.objectToQuery which doesn't + can.param = function (object) { + var pairs = [], + add = function (key, value) { + pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(value)); + }; + for (var name in object) { + can.buildParam(name, object[name], add); + } + return pairs.join('&') + .replace(/%20/g, '+'); + }; + can.buildParam = function (prefix, obj, add) { + if (can.isArray(obj)) { + for (var i = 0, l = obj.length; i < l; ++i) { + add(prefix + '[]', obj[i]); + } + } else if (dojo.isObject(obj)) { + for (var name in obj) { + can.buildParam(prefix + '[' + name + ']', obj[name], add); + } + } else { + add(prefix, obj); + } + }; + // Map function helpers. + can.proxy = function (func, context) { + return dojo.hitch(context, func); + }; + can.isFunction = function (f) { + return dojo.isFunction(f); + }; + /** + * EVENTS + * + * Dojo does not use the callback handler when unbinding. Instead + * when binding (dojo.connect or dojo.on) an object with a remove + * method is returned. + * + * Because of this, we have to map each callback to the "remove" + * object to it can be passed to dojo.disconnect. + */ + // The id of the `function` to be bound, used as an expando on the `function` + // so we can lookup it's `remove` object. + var dojoId = 0, + // Takes a node list, goes through each node + // and adds events data that has a map of events to + // callbackId to `remove` object. It looks like + // `{click: {5: {remove: fn}}}`. + dojoAddBinding = function (nodelist, ev, cb) { + nodelist.forEach(function (node) { + // Converting a raw select node to a node list + // returns a node list of its options due to a + // bug in Dojo 1.7.1, this is sovled by wrapping + // it in an array. + node = new dojo.NodeList(node.nodeName === 'SELECT' ? [node] : node); + var events = can.data(node, 'events'); + if (!events) { + can.data(node, 'events', events = {}); + } + if (!events[ev]) { + events[ev] = {}; + } + if (cb.__bindingsIds === undefined) { + cb.__bindingsIds = dojoId++; + } + events[ev][cb.__bindingsIds] = node.on(ev, cb)[0]; + }); + }, + // Removes a binding on a `nodelist` by finding + // the remove object within the object's data. + dojoRemoveBinding = function (nodelist, ev, cb) { + nodelist.forEach(function (node) { + var currentNode = new dojo.NodeList(node), + events = can.data(currentNode, 'events'); + if (!events) { + return; + } + var handlers = events[ev]; + if (!handlers) { + return; + } + var handler = handlers[cb.__bindingsIds]; + dojo.disconnect(handler); + delete handlers[cb.__bindingsIds]; + if (can.isEmptyObject(handlers)) { + delete events[ev]; + } + }); + }; + can.bind = function (ev, cb) { + // If we can bind to it... + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); // Otherwise it's an element or `nodeList`. + } else if (this.on || this.nodeType) { + // Converting a raw select node to a node list + // returns a node list of its options due to a + // bug in Dojo 1.7.1, this is sovled by wrapping + // it in an array. + dojoAddBinding(new dojo.NodeList(this.nodeName === 'SELECT' ? [this] : this), ev, cb); + } else if (this.addEvent) { + this.addEvent(ev, cb); + } else { + // Make it bind-able... + can.addEvent.call(this, ev, cb); + } + return this; + }; + can.unbind = function (ev, cb) { + // If we can bind to it... + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (this.on || this.nodeType) { + dojoRemoveBinding(new dojo.NodeList(this), ev, cb); + } else { + // Make it bind-able... + can.removeEvent.call(this, ev, cb); + } + return this; + }; + // Alias on/off to bind/unbind respectively + can.on = can.bind; + can.off = can.unbind; + can.trigger = function (item, event, args, bubble) { + if (!(item instanceof dojo.NodeList) && (item.nodeName || item === window)) { + item = can.$(item); + } + if (item.trigger) { + if (bubble === false) { + if (!item[0] || item[0].nodeType === 3) { + return; + } + // Force stop propagation by + // listening to `on` and then immediately disconnecting. + var connect = item.on(event, function (ev) { + if (ev.stopPropagation) { + ev.stopPropagation(); + } + ev.cancelBubble = true; + if (ev._stopper) { + ev._stopper(); + } + dojo.disconnect(connect); + }); + item.trigger(event, args); + } else { + item.trigger(event, args); + } + } else { + if (typeof event === 'string') { + event = { + type: event + }; + } + event.target = event.target || item; + can.dispatch.call(item, event, can.makeArray(args)); + } + }; + can.delegate = function (selector, ev, cb) { + if (!selector) { + // Dojo fails with no selector + can.bind.call(this, ev, cb); + } else if (this.on || this.nodeType) { + dojoAddBinding(new dojo.NodeList(this), selector + ':' + ev, cb); + } else if (this.delegate) { + this.delegate(selector, ev, cb); + } else { + // make it bind-able ... + can.bind.call(this, ev, cb); + } + return this; + }; + can.undelegate = function (selector, ev, cb) { + if (!selector) { + // Dojo fails with no selector + can.unbind.call(this, ev, cb); + } else if (this.on || this.nodeType) { + dojoRemoveBinding(new dojo.NodeList(this), selector + ':' + ev, cb); + } else if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else { + can.unbind.call(this, ev, cb); + } + return this; + }; + /** + * Ajax + */ + var updateDeferred = function (xhr, d) { + for (var prop in xhr) { + if (typeof d[prop] === 'function') { + d[prop] = function () { + xhr[prop].apply(xhr, arguments); + }; + } else { + d[prop] = prop[xhr]; + } + } + }; + can.ajax = function (options) { + var type = can.capitalize((options.type || 'get') + .toLowerCase()), + method = dojo['xhr' + type]; + var success = options.success, + error = options.error, + d = new can.Deferred(); + var def = method({ + url: options.url, + handleAs: options.dataType, + sync: !options.async, + headers: options.headers, + content: options.data + }); + def.then(function (data, ioargs) { + updateDeferred(xhr, d); + d.resolve(data, 'success', xhr); + if (success) { + success(data, 'success', xhr); + } + }, function (data, ioargs) { + updateDeferred(xhr, d); + d.reject(xhr, 'error'); + error(xhr, 'error'); + }); + var xhr = def.ioArgs.xhr; + updateDeferred(xhr, d); + return d; + }; + // Element - get the wrapped helper. + can.$ = function (selector) { + if (selector === window) { + return window; + } + if (typeof selector === 'string') { + return dojo.query(selector); + } else { + return new dojo.NodeList(selector && selector.nodeName ? [selector] : selector); + } + }; + can.append = function (wrapped, html) { + return wrapped.forEach(function (node) { + dojo.place(html, node); + }); + }; + /** + * can.data + * + * can.data is used to store arbitrary data on an element. + * Dojo does not support this, so we implement it itself. + * + * The important part is to call cleanData on any elements + * that are removed from the DOM. For this to happen, we + * overwrite + * + * -dojo.empty + * -dojo.destroy + * -dojo.place when "replace" is used TODO!!!! + * + * For can.Control, we also need to trigger a non bubbling event + * when an element is removed. We do this also in cleanData. + */ + var data = {}, uuid = can.uuid = +new Date(), + exp = can.expando = 'can' + uuid; + + function getData(node, name) { + var id = node[exp], + store = id && data[id]; + return name === undefined ? store || setData(node) : store && store[name]; + } + + function setData(node, name, value) { + var id = node[exp] || (node[exp] = ++uuid), + store = data[id] || (data[id] = {}); + if (name !== undefined) { + store[name] = value; + } + return store; + } + + var cleanData = function (elems) { + var nodes = []; + + for (var i = 0, len = elems.length; i < len; i++) { + if (elems[i].nodeType === 1) { + nodes.push(elems[i]); + } + } + can.trigger(new dojo.NodeList(nodes), 'removed', [], false); + i = 0; + for (var elem; + (elem = elems[i]) !== undefined; i++) { + var id = elem[exp]; + delete data[id]; + } + }; + can.data = function (wrapped, name, value) { + return value === undefined ? wrapped.length === 0 ? undefined : getData(wrapped[0], name) : wrapped.forEach(function (node) { + setData(node, name, value); + }); + }; + can.cleanData = function (elem, prop) { + var id = elem[exp]; + delete data[id][prop]; + }; + // Overwrite `dojo.destroy`, `dojo.empty` and `dojo.place`. + dojo.empty = function (node) { + for (var c; c = node.lastChild;) { + // Intentional assignment. + dojo.destroy(c); + } + }; + var destroy = dojo.destroy; + dojo.destroy = function (node) { + node = dojo.byId(node); + // we must call clean data at one time + var nodes = [node]; + if (node.getElementsByTagName) { + nodes.concat(can.makeArray(node.getElementsByTagName('*'))); + } + cleanData(nodes); + return destroy.apply(dojo, arguments); + }; + var place = dojo.place; + dojo.place = function (node, refNode, position) { + if (typeof node === 'string' && /^\s* 0 ? Array.prototype.concat.apply([], array) : array; + } + + can.isArray = function(arr){ + return arr instanceof Array; + }; + + can.isFunction = (function () { + if (typeof document !== 'undefined' && typeof document.getElementsByTagName('body') === 'function') { + return function (value) { + return Object.prototype.toString.call(value) === '[object Function]'; + }; + } else { + return function (value) { + return typeof value === 'function'; + }; + } + })(); + + can.trim = core_trim && !core_trim.call('\uFEFF\xA0') ? + function (text) { + return text == null ? '' : core_trim.call(text); + } : + // Otherwise use our own trimming functionality + function (text) { + return text == null ? '' : (text + '') + .replace(rtrim, ''); + }; + + // This extend() function is ruthlessly and shamelessly stolen from + // jQuery 1.8.2:, lines 291-353. + can.extend = function () { + /*jshint maxdepth:6 */ + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // 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" && !can.isFunction(target)) { + target = {}; + } + + // extend jQuery itself if only one argument is passed + if (length === i) { + target = this; + --i; + } + + for (; i < length; i++) { + // Only deal with non-null/undefined values + if ((options = arguments[i]) != null) { + // Extend the base object + for (name in options) { + src = target[name]; + copy = options[name]; + + // Prevent never-ending loop + if (target === copy) { + continue; + } + + // Recurse if we're merging plain objects or arrays + if (deep && copy && (can.isPlainObject(copy) || (copyIsArray = can.isArray(copy)))) { + if (copyIsArray) { + copyIsArray = false; + clone = src && can.isArray(src) ? src : []; + + } else { + clone = src && can.isPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[name] = can.extend(deep, clone, copy); + + // Don't bring in undefined values + } else if (copy !== undefined) { + target[name] = copy; + } + } + } + } + + // Return the modified object + return target; + }; + + can.map = function (elements, callback) { + var values = [], + putValue = function (val, index) { + var value = callback(val, index); + if (value != null) { + values.push(value); + } + }; + if (likeArray(elements)) { + for (var i = 0, l = elements.length; i < l; i++) { + putValue(elements[i], i); + } + } else { + for (var key in elements) { + putValue(elements[key], key); + } + } + return flatten(values); + }; + can.proxy = function (cb, that) { + return function () { + return cb.apply(that, arguments); + }; + }; + + can.attr = attr; + + return can; + +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/event.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/event.js new file mode 100644 index 0000000000..17e642c3c8 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/event.js @@ -0,0 +1,15 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/event*/ +steal('can/util/can.js', 'can/event', function (can) { + // # can/util/event + // This imports can/event for API compatibility. + return can; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/fixture/fixture.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/fixture/fixture.js new file mode 100644 index 0000000000..4de7a6e5dc --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/fixture/fixture.js @@ -0,0 +1,773 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/fixture/fixture*/ +// # can/util/fixture.js +// +// Intercepts AJAX requests and simulates them with either a function or a +// file. This is used to develop independently from backend services. +steal('can/util', 'can/util/string', 'can/util/object', function (can) { + // can.fixture relies on can.Object in order to work and needs to be + // included before can.fixture in order to use it, otherwise it'll error. + if (!can.Object) { + throw new Error('can.fixture depends on can.Object. Please include it before can.fixture.'); + } + + // Get the URL from old Steal root, new Steal config or can.fixture.rootUrl + var getUrl = function (url) { + if (typeof steal !== 'undefined') { + // New steal + // TODO The correct way to make this work with new Steal is to change getUrl + // to return a deferred and have the other code accept a deferred. + if(steal.joinURIs) { + var base = steal.config("baseUrl"); + var joined = steal.joinURIs(base, url); + return joined; + } + + // Legacy steal + if (can.isFunction(steal.config)) { + if (steal.System) { + return steal.joinURIs(steal.config('baseURL'), url); + } + else { + return steal.config() + .root.mapJoin(url) + .toString(); + } + } + return steal.root.join(url) + .toString(); + } + return (can.fixture.rootUrl || '') + url; + }; + + // Manipulates the AJAX prefilter to identify whether or not we should + // manipulate the AJAX call to change the URL to a static file or call + // a function for a dynamic fixture. + var updateSettings = function (settings, originalOptions) { + if (!can.fixture.on || settings.fixture === false) { + return; + } + + // A simple wrapper for logging fixture.js. + var log = function () { + //!steal-remove-start + can.dev.log('can/fixture/fixture.js: ' + Array.prototype.slice.call(arguments) + .join(' ')); + //!steal-remove-end + }; + + // We always need the type which can also be called method, default to GET + settings.type = settings.type || settings.method || 'GET'; + + // add the fixture option if programmed in + var data = overwrite(settings); + + // If there is not a fixture for this AJAX request, do nothing. + if (!settings.fixture) { + if (window.location.protocol === "file:") { + log("ajax request to " + settings.url + ", no fixture found"); + } + return; + } + + // If the fixture already exists on can.fixture, update the fixture option + if (typeof settings.fixture === "string" && can.fixture[settings.fixture]) { + settings.fixture = can.fixture[settings.fixture]; + } + + // If the fixture setting is a string, we just change the URL of the + // AJAX call to the fixture URL. + if (typeof settings.fixture === "string") { + var url = settings.fixture; + + // If the URL starts with //, we need to update the URL to become + // the full path. + if (/^\/\//.test(url)) { + // this lets us use rootUrl w/o having steal... + url = getUrl(settings.fixture.substr(2)); + } + + if (data) { + // Template static fixture URLs + url = can.sub(url, data); + } + + delete settings.fixture; + + //!steal-remove-start + log("looking for fixture in " + url); + //!steal-remove-end + + // Override the AJAX settings, changing the URL to the fixture file, + // removing the data, and changing the type to GET. + settings.url = url; + settings.data = null; + settings.type = "GET"; + if (!settings.error) { + // If no error handling is provided, we provide one and throw an + // error. + settings.error = function (xhr, error, message) { + throw "fixtures.js Error " + error + " " + message; + }; + } + // Otherwise, it is a function and we add the fixture data type so the + // fixture transport will handle it. + } else { + //!steal-remove-start + log("using a dynamic fixture for " + settings.type + " " + settings.url); + //!steal-remove-end + + // TODO: make everything go here for timing and other fun stuff + // add to settings data from fixture ... + if (settings.dataTypes) { + settings.dataTypes.splice(0, 0, "fixture"); + } + + if (data && originalOptions) { + originalOptions.data = originalOptions.data || {}; + can.extend(originalOptions.data, data); + } + } + }, + // A helper function that takes what's called with response + // and moves some common args around to make it easier to call + extractResponse = function (status, statusText, responses, headers) { + // if we get response(RESPONSES, HEADERS) + if (typeof status !== "number") { + headers = statusText; + responses = status; + statusText = "success"; + status = 200; + } + // if we get response(200, RESPONSES, HEADERS) + if (typeof statusText !== "string") { + headers = responses; + responses = statusText; + statusText = "success"; + } + if (status >= 400 && status <= 599) { + this.dataType = "text"; + } + return [status, statusText, extractResponses(this, responses), headers]; + }, + // If we get data instead of responses, make sure we provide a response + // type that matches the first datatype (typically JSON) + extractResponses = function (settings, responses) { + var next = settings.dataTypes ? settings.dataTypes[0] : (settings.dataType || 'json'); + if (!responses || !responses[next]) { + var tmp = {}; + tmp[next] = responses; + responses = tmp; + } + return responses; + }; + + // Set up prefiltering and transmission handling in order to actually power + // can.fixture. This is handled two different ways, depending on whether or + // not CanJS is using jQuery or not. + + // If we are using jQuery, we have access to ajaxPrefilter and ajaxTransport + if (can.ajaxPrefilter && can.ajaxTransport) { + + // the pre-filter needs to re-route the url + can.ajaxPrefilter(updateSettings); + + can.ajaxTransport("fixture", function (s, original) { + // remove the fixture from the datatype + s.dataTypes.shift(); + + //we'll return the result of the next data type + var timeout, stopped = false; + + return { + send: function (headers, callback) { + // we'll immediately wait the delay time for all fixtures + timeout = setTimeout(function () { + // if the user wants to call success on their own, we allow it ... + var success = function () { + if (stopped === false) { + callback.apply(null, extractResponse.apply(s, arguments)); + } + }, + // get the result form the fixture + result = s.fixture(original, success, headers, s); + if (result !== undefined) { + // Run the callback as a 200 success and with the results with the correct dataType + callback(200, "success", extractResponses(s, result), {}); + } + }, can.fixture.delay); + }, + abort: function () { + stopped = true; + clearTimeout(timeout); + } + }; + }); + // If we are not using jQuery, we don't have access to those nice ajaxPrefilter + // and ajaxTransport functions, so we need to monkey patch can.ajax. + } else { + var AJAX = can.ajax; + can.ajax = function (settings) { + updateSettings(settings, settings); + + // If the call is a fixture call, we run the same type of code as we would + // with jQuery's ajaxTransport. + if (settings.fixture) { + var timeout, deferred = new can.Deferred(), + stopped = false; + + //TODO this should work with response + deferred.getResponseHeader = function () {}; + + // Call success or fail after deferred resolves + deferred.then(settings.success, settings.fail); + + // Abort should stop the timeout and calling the success callback + deferred.abort = function () { + clearTimeout(timeout); + stopped = true; + deferred.reject(deferred); + }; + // set a timeout that simulates making a request .... + timeout = setTimeout(function () { + // if the user wants to call success on their own, we allow it ... + var success = function () { + var response = extractResponse.apply(settings, arguments), + status = response[0]; + + if ((status >= 200 && status < 300 || status === 304) && stopped === false) { + deferred.resolve(response[2][settings.dataType]); + } else { + // TODO probably resolve better + deferred.reject(deferred, 'error', response[1]); + } + }, + // Get the results from the fixture. + result = settings.fixture(settings, success, settings.headers, settings); + if (result !== undefined) { + // Resolve with fixture results + deferred.resolve(result); + } + }, can.fixture.delay); + + return deferred; + // Otherwise just run a normal can.ajax call. + } else { + return AJAX(settings); + } + }; + } + + // A list of 'overwrite' settings objects + var overwrites = [], + // Finds and returns the index of an overwrite function + find = function (settings, exact) { + for (var i = 0; i < overwrites.length; i++) { + if ($fixture._similar(settings, overwrites[i], exact)) { + return i; + } + } + return -1; + }, + // Overwrites the settings fixture if an overwrite matches + overwrite = function (settings) { + var index = find(settings); + if (index > -1) { + settings.fixture = overwrites[index].fixture; + return $fixture._getData(overwrites[index].url, settings.url); + } + + }, + // Attemps to guess where the id is in an AJAX call's URL and returns it. + getId = function (settings) { + var id = settings.data.id; + + if (id === undefined && typeof settings.data === "number") { + id = settings.data; + } + + // Parses the URL looking for all digits + if (id === undefined) { + // Set id equal to the value + settings.url.replace(/\/(\d+)(\/|$|\.)/g, function (all, num) { + id = num; + }); + } + + if (id === undefined) { + // If that doesn't work Parses the URL looking for all words + id = settings.url.replace(/\/(\w+)(\/|$|\.)/g, function (all, num) { + // As long as num isn't the word "update", set id equal to the value + if (num !== 'update') { + id = num; + } + }); + } + + if (id === undefined) { + // If id is still not set, a random number is guessed. + id = Math.round(Math.random() * 1000); + } + + return id; + }; + + // ## can.fixture + // Simulates AJAX requests. + var $fixture = can.fixture = function (settings, fixture) { + // If fixture is provided, set up a new fixture. + if (fixture !== undefined) { + if (typeof settings === 'string') { + // Match URL if it has GET, POST, PUT, or DELETE. + var matches = settings.match(/(GET|POST|PUT|DELETE) (.+)/i); + // If not, we don't set the type, which eventually defaults to GET + if (!matches) { + settings = { + url: settings + }; + // If it does match, we split the URL in half and create an object with + // each half as the url and type properties. + } else { + settings = { + url: matches[2], + type: matches[1] + }; + } + } + + // Check if the same fixture was previously added, if so, we remove it + // from our array of fixture overwrites. + var index = find(settings, !! fixture); + if (index > -1) { + overwrites.splice(index, 1); + } + if (fixture == null) { + return; + } + settings.fixture = fixture; + overwrites.push(settings); + // If a fixture isn't provided, we assume that settings is + // an array of fixtures, and we should iterate over it, and set up + // the new fixtures. + } else { + can.each(settings, function (fixture, url) { + $fixture(url, fixture); + }); + } + }; + var replacer = can.replacer; + + can.extend(can.fixture, { + // Find an overwrite, given some ajax settings. + _similar: function (settings, overwrite, exact) { + if (exact) { + return can.Object.same(settings, overwrite, { + fixture: null + }); + } else { + return can.Object.subset(settings, overwrite, can.fixture._compare); + } + }, + // Comparator object used to find a similar overwrite. + _compare: { + url: function (a, b) { + return !!$fixture._getData(b, a); + }, + fixture: null, + type: "i" + }, + // Returns data from a url, given a fixtue URL. For example, given + // "todo/{id}" and "todo/5", it will return an object with an id property + // equal to 5. + _getData: function (fixtureUrl, url) { + var order = [], + // Sanitizes fixture URL + fixtureUrlAdjusted = fixtureUrl.replace('.', '\\.') + .replace('?', '\\?'), + // Creates a regular expression out of the adjusted fixture URL and + // runs it on the URL we passed in. + res = new RegExp(fixtureUrlAdjusted.replace(replacer, function (whole, part) { + order.push(part); + return "([^\/]+)"; + }) + "$") + .exec(url), + data = {}; + + // If there were no matches, return null; + if (!res) { + return null; + } + + // Shift off the URL and just keep the data. + res.shift(); + can.each(order, function (name) { + // Add data from regular expression onto data object. + data[name] = res.shift(); + }); + return data; + }, + // ## can.fixture.store + // Make a store of objects to use when making requests against fixtures. + store: function (count, make, filter) { + /*jshint eqeqeq:false */ + + // the currentId to use when a new instance is created. + var currentId = 0, + findOne = function (id) { + for (var i = 0; i < items.length; i++) { + if (id == items[i].id) { + return items[i]; + } + } + }, + methods = {}, + types, + items, + reset; + + if(can.isArray(count) && typeof count[0] === "string" ){ + types = count; + count = make; + make= filter; + filter = arguments[3]; + } else if(typeof count === "string") { + types = [count + "s", count]; + count = make; + make= filter; + filter = arguments[3]; + } + + + if(typeof count === "number") { + items = []; + reset = function () { + items = []; + for (var i = 0; i < (count); i++) { + //call back provided make + var item = make(i, items); + + if (!item.id) { + item.id = i; + } + currentId = Math.max(item.id + 1, currentId + 1) || items.length; + items.push(item); + } + if (can.isArray(types)) { + can.fixture["~" + types[0]] = items; + can.fixture["-" + types[0]] = methods.findAll; + can.fixture["-" + types[1]] = methods.findOne; + can.fixture["-" + types[1] + "Update"] = methods.update; + can.fixture["-" + types[1] + "Destroy"] = methods.destroy; + can.fixture["-" + types[1] + "Create"] = methods.create; + } + }; + } else { + filter = make; + var initialItems = count; + reset = function(){ + items = initialItems.slice(0); + }; + } + + + // make all items + can.extend(methods, { + findAll: function (request) { + request = request || {}; + //copy array of items + var retArr = items.slice(0); + request.data = request.data || {}; + //sort using order + //order looks like ["age ASC","gender DESC"] + can.each((request.data.order || []) + .slice(0) + .reverse(), function (name) { + var split = name.split(" "); + retArr = retArr.sort(function (a, b) { + if (split[1].toUpperCase() !== "ASC") { + if (a[split[0]] < b[split[0]]) { + return 1; + } else if (a[split[0]] === b[split[0]]) { + return 0; + } else { + return -1; + } + } else { + if (a[split[0]] < b[split[0]]) { + return -1; + } else if (a[split[0]] === b[split[0]]) { + return 0; + } else { + return 1; + } + } + }); + }); + + //group is just like a sort + can.each((request.data.group || []) + .slice(0) + .reverse(), function (name) { + var split = name.split(" "); + retArr = retArr.sort(function (a, b) { + return a[split[0]] > b[split[0]]; + }); + }); + + var offset = parseInt(request.data.offset, 10) || 0, + limit = parseInt(request.data.limit, 10) || (items.length - offset), + i = 0; + + //filter results if someone added an attr like parentId + for (var param in request.data) { + i = 0; + if (request.data[param] !== undefined && // don't do this if the value of the param is null (ignore it) + (param.indexOf("Id") !== -1 || param.indexOf("_id") !== -1)) { + while (i < retArr.length) { + if (request.data[param] != retArr[i][param]) { // jshint eqeqeq: false + retArr.splice(i, 1); + } else { + i++; + } + } + } + } + + if ( typeof filter === "function" ) { + i = 0; + while (i < retArr.length) { + if (!filter(retArr[i], request)) { + retArr.splice(i, 1); + } else { + i++; + } + } + } else if( typeof filter === "object" ) { + i = 0; + while (i < retArr.length) { + if ( !can.Object.subset(retArr[i], request.data, filter) ) { + retArr.splice(i, 1); + } else { + i++; + } + } + } + + // Return the data spliced with limit and offset, along with related values + // (e.g. count, limit, offset) + return { + "count": retArr.length, + "limit": request.data.limit, + "offset": request.data.offset, + "data": retArr.slice(offset, offset + limit) + }; + }, + + /** + * @description Simulate a findOne request on a fixture. + * @function can.fixture.types.Store.findOne + * @parent can.fixture.types.Store + * @signature `store.findOne(request, response)` + * @param {Object} request Parameters for the request. + * @param {Function} response A function to call with the retrieved item. + * + * @body + * `store.findOne(request, response(item))` simulates a request to + * get a single item from the server by id. + * + * todosStore.findOne({ + * url: "/todos/5" + * }, function(todo){ + * + * }); + * + */ + findOne: function (request, response) { + var item = findOne(getId(request)); + + if(typeof item === "undefined") { + return response(404, 'Requested resource not found'); + } + + response(item); + }, + // ## fixtureStore.update + // Simulates a can.Model.update to a fixture + update: function (request, response) { + var id = getId(request), + item = findOne(id); + + if(typeof item === "undefined") { + return response(404, 'Requested resource not found'); + } + + // TODO: make it work with non-linear ids .. + can.extend(item, request.data); + response({ + id: id + }, { + location: request.url || "/" + getId(request) + }); + }, + + /** + * @description Simulate destroying a Model on a fixture. + * @function can.fixture.types.Store.destroy + * @parent can.fixture.types.Store + * @signature `store.destroy(request, callback)` + * @param {Object} request Parameters for the request. + * @param {Function} callback A function to call after destruction. + * + * @body + * `store.destroy(request, response())` simulates + * a request to destroy an item from the server. + * + * ``` + * todosStore.destroy({ + * url: "/todos/5" + * }, function(){}); + * ``` + */ + destroy: function (request, response) { + var id = getId(request), + item = findOne(id); + + if(typeof item === "undefined") { + return response(404, 'Requested resource not found'); + } + + for (var i = 0; i < items.length; i++) { + if (items[i].id == id) { // jshint eqeqeq: false + items.splice(i, 1); + break; + } + } + + // TODO: make it work with non-linear ids .. + return {}; + }, + + // ## fixtureStore.create + // Simulates a can.Model.create to a fixture + create: function (settings, response) { + var item = typeof make === 'function' ? make(items.length, items) : {}; + + can.extend(item, settings.data); + + // If an ID wasn't passed into the request, we give the item + // a unique ID. + if (!item.id) { + item.id = currentId++; + } + + // Push the new item into the store. + items.push(item); + response({ + id: item.id + }, { + location: settings.url + "/" + item.id + }); + } + }); + reset(); + // if we have types given add them to can.fixture + + return can.extend({ + getId: getId, + find: function (settings) { + return findOne(getId(settings)); + }, + reset: reset + }, methods); + }, + rand: function randomize(arr, min, max) { + if (typeof arr === 'number') { + if (typeof min === 'number') { + return arr + Math.floor(Math.random() * (min - arr)); + } else { + return Math.floor(Math.random() * arr); + } + + } + var rand = randomize; + // get a random set + if (min === undefined) { + return rand(arr, rand(arr.length + 1)); + } + // get a random selection of arr + var res = []; + arr = arr.slice(0); + // set max + if (!max) { + max = min; + } + //random max + max = min + Math.round(rand(max - min)); + for (var i = 0; i < max; i++) { + res.push(arr.splice(rand(arr.length), 1)[0]); + } + return res; + }, + xhr: function (xhr) { + return can.extend({}, { + abort: can.noop, + getAllResponseHeaders: function () { + return ""; + }, + getResponseHeader: function () { + return ""; + }, + open: can.noop, + overrideMimeType: can.noop, + readyState: 4, + responseText: "", + responseXML: null, + send: can.noop, + setRequestHeader: can.noop, + status: 200, + statusText: "OK" + }, xhr); + }, + on: true + }); + + // ## can.fixture.delay + // The delay, in milliseconds, between an AJAX request being made and when + // the success callback gets called. + can.fixture.delay = 200; + + // ## can.fixture.rootUrl + // The root URL which fixtures will use. + can.fixture.rootUrl = getUrl(''); + + can.fixture["-handleFunction"] = function (settings) { + if (typeof settings.fixture === "string" && can.fixture[settings.fixture]) { + settings.fixture = can.fixture[settings.fixture]; + } + if (typeof settings.fixture === "function") { + setTimeout(function () { + if (settings.success) { + settings.success.apply(null, settings.fixture(settings, "success")); + } + if (settings.complete) { + settings.complete.apply(null, settings.fixture(settings, "complete")); + } + }, can.fixture.delay); + return true; + } + return false; + }; + + //Expose this for fixture debugging + can.fixture.overwrites = overwrites; + can.fixture.make = can.fixture.store; + return can.fixture; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/fragment.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/fragment.js new file mode 100644 index 0000000000..1fc0fdbc0e --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/fragment.js @@ -0,0 +1,89 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/fragment*/ +steal('can/util/can.js', function (can) { + // fragment.js + // --------- + // _DOM Fragment support._ + var fragmentRE = /^\s*<(\w+)[^>]*>/, + toString = {}.toString, + fragment = function (html, name) { + if (name === undefined) { + name = fragmentRE.test(html) && RegExp.$1; + } + if (html && toString.call(html.replace) === "[object Function]") { + // Fix "XHTML"-style tags in all browsers + html = html.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, '<$1>'); + } + var container = document.createElement('div'), + temp = document.createElement('div'); + // IE's parser will strip any `` tags when `innerHTML` + // is called on a `tbody`. To get around this, we construct a + // valid table with a `tbody` that has the `innerHTML` we want. + // Then the container is the `firstChild` of the `tbody`. + // [source](http://www.ericvasilik.com/2006/07/code-karma.html). + if (name === 'tbody' || name === 'tfoot' || name === 'thead') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; + } else if (name === 'tr') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild; + } else if (name === 'td' || name === 'th') { + temp.innerHTML = '' + html + '
            '; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild.firstChild; + } else if (name === 'option') { + temp.innerHTML = ''; + container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; + } else { + container.innerHTML = '' + html; + } + // IE8 barfs if you pass slice a `childNodes` object, so make a copy. + var tmp = {}, children = container.childNodes; + tmp.length = children.length; + for (var i = 0; i < children.length; i++) { + tmp[i] = children[i]; + } + return [].slice.call(tmp); + }; + can.buildFragment = function (html, nodes) { + if(html && html.nodeType === 11) { + return html; + } + var parts = fragment(html), + frag = document.createDocumentFragment(); + for(var i = 0, length = parts.length; i < length; i++) { + frag.appendChild(parts[i]); + } + return frag; + }; + + // ## Fix build fragment. + // In IE8, we can pass a fragment and it removes newlines. + // This checks for that and replaces can.buildFragment with something + // that if only a single text node is returned, returns a fragment with + // a text node that is set to the content. + (function(){ + var text = "<-\n>", + frag = can.buildFragment(text, document); + if(text !== frag.childNodes[0].nodeValue) { + var oldBuildFragment = can.buildFragment; + can.buildFragment = function(html, nodes){ + var res = oldBuildFragment(html, nodes); + if(res.childNodes.length === 1 && res.childNodes[0].nodeType === 3) { + res.childNodes[0].nodeValue = html; + } + return res; + }; + + } + })(); + + return can; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/function/function.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/function/function.js new file mode 100644 index 0000000000..4d0f57b57f --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/function/function.js @@ -0,0 +1,47 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/function/function*/ +steal('can/util', function (can) { + can.debounce = function (fn, time, context) { + var timeout; + return function () { + var args = arguments; + clearTimeout(timeout); + timeout = setTimeout(can.proxy(function () { + fn.apply(this, args); + }, context || this), time); + }; + }; + + can.throttle = function (fn, time, context) { + var run; + return function () { + var args = arguments; + var ctx = context || this; + if (!run) { + run = true; + setTimeout(function () { + fn.apply(ctx, args); + run = false; + }, time); + } + }; + }; + + can.defer = function (fn, context) { + var args = arguments; + var ctx = context || this; + setTimeout(function () { + fn.apply(ctx, args); + }, 0); + }; + + return can; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/hashchange.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/hashchange.js new file mode 100644 index 0000000000..ca666d20b6 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/hashchange.js @@ -0,0 +1,27 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/hashchange*/ +steal('can/util/can.js', function (can) { + // This is a workaround for libraries that don't natively listen to the window hashchange event + (function () { + var addEvent = function (el, ev, fn) { + if (el.addEventListener) { + el.addEventListener(ev, fn, false); + } else if (el.attachEvent) { + el.attachEvent('on' + ev, fn); + } else { + el['on' + ev] = fn; + } + }, onHashchange = function () { + can.trigger(window, 'hashchange'); + }; + addEvent(window, 'hashchange', onHashchange); + }()); +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/inserted/inserted.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/inserted/inserted.js new file mode 100644 index 0000000000..035caf2a29 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/inserted/inserted.js @@ -0,0 +1,77 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/inserted/inserted*/ +// # can/util/inserted +// Used to alert interested parties of when an element is inserted into the DOM. +// Given a list of elements, check if the first is in the DOM, and if so triggers the `inserted` event on all elements and their descendants. + +steal('can/util/can.js', function (can) { + can.inserted = function (elems) { + // Turn the `elems` property into an array to prevent mutations from changing the looping. + elems = can.makeArray(elems); + var inDocument = false, + // Gets the `doc` to use as a reference for finding out whether the element is in the document. + doc = can.$(document.contains ? document : document.body), + children; + // Go through `elems` and trigger the `inserted` event. + // If the first element is not in the document (a Document Fragment) it will exit the function. If it is in the document it sets the `inDocument` flag to true. This means that we only check for the first element and either exit the function or start triggering "inserted" for child elements. + for (var i = 0, elem; + (elem = elems[i]) !== undefined; i++) { + if (!inDocument) { + if (elem.getElementsByTagName) { + if (can.has(doc, elem) + .length) { + inDocument = true; + } else { + return; + } + } else { + continue; + } + } + + // If we've found an element in the document then we can now trigger **"inserted"** for `elem` and all of its children. We are using `getElementsByTagName("*")` so that we grab all of the descendant nodes. + if (inDocument && elem.getElementsByTagName) { + children = can.makeArray(elem.getElementsByTagName("*")); + can.trigger(elem, "inserted", [], false); + for (var j = 0, child; + (child = children[j]) !== undefined; j++) { + can.trigger(child, "inserted", [], false); + } + } + } + }; + + // ## can.appendChild + // Used to append a node to an element and trigger the "inserted" event on all of the newly inserted children. Since `can.inserted` takes an array we convert the child to an array, or in the case of a DocumentFragment we first convert the childNodes to an array and call inserted on those. + can.appendChild = function (el, child) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.appendChild(child); + can.inserted(children); + }; + + // ## can.insertBefore + // Like can.appendChild, used to insert a node to an element before a reference node and then trigger the "inserted" event. + can.insertBefore = function (el, child, ref) { + var children; + if (child.nodeType === 11) { + children = can.makeArray(child.childNodes); + } else { + children = [child]; + } + el.insertBefore(child, ref); + can.inserted(children); + }; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/jquery/jquery.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/jquery/jquery.js new file mode 100644 index 0000000000..0cc564355a --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/jquery/jquery.js @@ -0,0 +1,277 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/jquery/jquery*/ +steal('jquery', 'can/util/can.js', 'can/util/attr', "can/event", 'can/util/array/each.js', "can/util/inserted", function ($, can, attr, event) { + var isBindableElement = function (node) { + // In IE8 window.window !== window.window, so we allow == here. + /*jshint eqeqeq:false*/ + return ( node.nodeName && (node.nodeType === 1 || node.nodeType === 9) )|| node == window; + }; + $ = $ || window.jQuery; + // _jQuery node list._ + $.extend(can, $, { + trigger: function (obj, event, args, bubbles) { + if (isBindableElement( obj ) ) { + $.event.trigger(event, args, obj, !bubbles); + } else if (obj.trigger) { + obj.trigger(event, args); + } else { + if (typeof event === 'string') { + event = { + type: event + }; + } + event.target = event.target || obj; + if(args){ + if( args.length && typeof args === "string") { + args = [args]; + } else if(! args.length ) { + args = [args]; + } + } + if(!args){ + args = []; + } + can.dispatch.call(obj, event, args); + } + }, + event: can.event, + addEvent: can.addEvent, + removeEvent: can.removeEvent, + buildFragment: function (elems, context) { + // Check if this has any html nodes on our own. + var ret; + elems = [elems]; + // Set context per 1.8 logic + context = context || document; + context = !context.nodeType && context[0] || context; + context = context.ownerDocument || context; + ret = $.buildFragment(elems, context); + return ret.cacheable ? $.clone(ret.fragment) : ret.fragment || ret; + }, + $: $, + each: can.each, + bind: function (ev, cb) { + // If we can bind to it... + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (isBindableElement(this)) { + $.event.add(this, ev, cb); + } else { + // Make it bind-able... + can.addEvent.call(this, ev, cb); + } + return this; + }, + unbind: function (ev, cb) { + // If we can bind to it... + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (isBindableElement(this)) { + $.event.remove(this, ev, cb); + } else { + // Make it bind-able... + can.removeEvent.call(this, ev, cb); + } + return this; + }, + delegate: function (selector, ev, cb) { + if (this.delegate) { + this.delegate(selector, ev, cb); + } else if (isBindableElement(this)) { + $(this) + .delegate(selector, ev, cb); + } else { + // make it bind-able ... + can.bind.call(this, ev, cb); + } + return this; + }, + undelegate: function (selector, ev, cb) { + if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else if (isBindableElement(this)) { + $(this) + .undelegate(selector, ev, cb); + } else { + can.unbind.call(this, ev, cb); + } + return this; + }, + proxy: can.proxy, + attr: attr + }); + // Wrap binding functions. + /*$.each(['bind','unbind','undelegate','delegate'],function(i,func){ + can[func] = function(){ + var t = this[func] ? this : $([this]); + t[func].apply(t, arguments); + return this; + }; + });*/ + // Aliases + can.on = can.bind; + can.off = can.unbind; + // Wrap modifier functions. + $.each([ + 'append', + 'filter', + 'addClass', + 'remove', + 'data', + 'get', + 'has' + ], function (i, name) { + can[name] = function (wrapped) { + return wrapped[name].apply(wrapped, can.makeArray(arguments) + .slice(1)); + }; + }); + // Memory safe destruction. + var oldClean = $.cleanData; + $.cleanData = function (elems) { + $.each(elems, function (i, elem) { + if (elem) { + can.trigger(elem, 'removed', [], false); + } + }); + oldClean(elems); + }; + var oldDomManip = $.fn.domManip, + cbIndex; + // feature detect which domManip we are using + $.fn.domManip = function (args, cb1, cb2) { + for (var i = 1; i < arguments.length; i++) { + if (typeof arguments[i] === 'function') { + cbIndex = i; + break; + } + } + return oldDomManip.apply(this, arguments); + }; + $(document.createElement("div")) + .append(document.createElement("div")); + + $.fn.domManip = (cbIndex === 2 ? + function (args, table, callback) { + return oldDomManip.call(this, args, table, function (elem) { + var elems; + if (elem.nodeType === 11) { + elems = can.makeArray(elem.childNodes); + } + var ret = callback.apply(this, arguments); + can.inserted(elems ? elems : [elem]); + return ret; + }); + } : + function (args, callback) { + return oldDomManip.call(this, args, function (elem) { + var elems; + if (elem.nodeType === 11) { + elems = can.makeArray(elem.childNodes); + } + var ret = callback.apply(this, arguments); + can.inserted(elems ? elems : [elem]); + return ret; + }); + }); + + if (!can.attr.MutationObserver) { + // handle via calls to attr + var oldAttr = $.attr; + $.attr = function (el, attrName) { + var oldValue, newValue; + if (arguments.length >= 3) { + oldValue = oldAttr.call(this, el, attrName); + } + var res = oldAttr.apply(this, arguments); + if (arguments.length >= 3) { + newValue = oldAttr.call(this, el, attrName); + } + if (newValue !== oldValue) { + can.attr.trigger(el, attrName, oldValue); + } + return res; + }; + var oldRemove = $.removeAttr; + $.removeAttr = function (el, attrName) { + var oldValue = oldAttr.call(this, el, attrName), + res = oldRemove.apply(this, arguments); + + if (oldValue != null) { + can.attr.trigger(el, attrName, oldValue); + } + return res; + }; + $.event.special.attributes = { + setup: function () { + can.data(can.$(this), "canHasAttributesBindings", true); + }, + teardown: function () { + $.removeData(this, "canHasAttributesBindings"); + } + }; + } else { + // setup a special events + $.event.special.attributes = { + setup: function () { + var self = this; + var observer = new can.attr.MutationObserver(function (mutations) { + mutations.forEach(function (mutation) { + var copy = can.simpleExtend({}, mutation); + can.trigger(self, copy, []); + }); + + }); + observer.observe(this, { + attributes: true, + attributeOldValue: true + }); + can.data(can.$(this), "canAttributesObserver", observer); + }, + teardown: function () { + can.data(can.$(this), "canAttributesObserver") + .disconnect(); + $.removeData(this, "canAttributesObserver"); + + } + }; + } + + // ## Fix build fragment. + // In IE8, we can pass jQuery a fragment and it removes newlines. + // This checks for that and replaces can.buildFragment with something + // that if only a single text node is returned, returns a fragment with + // a text node that is set to the content. + (function(){ + + var text = "<-\n>", + frag = can.buildFragment(text, document); + if(text !== frag.childNodes[0].nodeValue) { + + var oldBuildFragment = can.buildFragment; + can.buildFragment = function(content, context){ + var res = oldBuildFragment(content, context); + if(res.childNodes.length === 1 && res.childNodes[0].nodeType === 3) { + res.childNodes[0].nodeValue = content; + } + return res; + }; + + } + + + + })(); + + $.event.special.inserted = {}; + $.event.special.removed = {}; + return can; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/mootools/mootools.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/mootools/mootools.js new file mode 100644 index 0000000000..c56ebafe0d --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/mootools/mootools.js @@ -0,0 +1,414 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/util*/ +steal('can/util/can.js', 'can/util/attr', 'mootools', 'can/event', 'can/util/fragment.js', 'can/util/deferred.js', + 'can/util/array/each.js', 'can/util/object/isplain', "can/util/inserted", function (can, attr) { + /* jshint maxdepth:5 */ + // mootools.js + // --------- + // _MooTools node list._ + // + // Map string helpers. + can.trim = function (s) { + return s ? s.trim() : s; + }; + // This extend() function is ruthlessly and shamelessly stolen from + // jQuery 1.8.2:, lines 291-353. + var extend = function () { + var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, + length = arguments.length, + deep = false; + // 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' && !can.isFunction(target)) { + target = {}; + } + // extend jQuery itself if only one argument is passed + if (length === i) { + target = this; + --i; + } + for (; i < length; i++) { + // Only deal with non-null/undefined values + if ((options = arguments[i]) !== null) { + // Extend the base object + for (name in options) { + src = target[name]; + copy = options[name]; + // Prevent never-ending loop + if (target === copy) { + continue; + } + // Recurse if we're merging plain objects or arrays + if (deep && copy && (can.isPlainObject(copy) || (copyIsArray = can.isArray(copy)))) { + if (copyIsArray) { + copyIsArray = false; + clone = src && can.isArray(src) ? src : []; + } else { + clone = src && can.isPlainObject(src) ? src : {}; + } + // Never move original objects, clone them + target[name] = can.extend(deep, clone, copy); // Don't bring in undefined values + } else if (copy !== undefined) { + target[name] = copy; + } + } + } + } + // Return the modified object + return target; + }; + can.extend = extend; + // Map array helpers. + can.makeArray = function (item) { + // All other libraries return a copy if item is an array. + // The original Mootools Array.from returned the same item so we need to slightly modify it + if (item === null) { + return []; + } + try { + return Type.isEnumerable(item) && typeof item !== 'string' ? Array.prototype.slice.call(item) : [item]; + } catch (ex) { + // some things like DOMNodeChildCollections don't slice so good. + // This pains me, but it has to be done. + var arr = [], + i; + for (i = 0; i < item.length; ++i) { + arr.push(item[i]); + } + return arr; + } + }; + can.isArray = function (arr) { + return typeOf(arr) === 'array'; + }; + can.inArray = function (item, arr, fromIndex) { + if (!arr) { + return -1; + } + return Array.prototype.indexOf.call(arr, item, fromIndex); + }; + can.map = function (arr, fn) { + return Array.from(arr || []) + .map(fn); + }; + // Map object helpers. + can.param = function (object) { + return Object.toQueryString(object); + }; + can.isEmptyObject = function (object) { + return Object.keys(object) + .length === 0; + }; + can.isFunction = function (f) { + return typeOf(f) === 'function'; + }; + // Make this object so you can bind on it. + can.bind = function (ev, cb) { + // If we can bind to it... + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (this.nodeName && (this.nodeType && this.nodeType !== 11)) { + can.$(this) + .addEvent(ev, cb); + } else if (this.addEvent) { + this.addEvent(ev, cb); + } else { + // Make it bind-able... + can.addEvent.call(this, ev, cb); + } + return this; + }; + can.unbind = function (ev, cb) { + // If we can bind to it... + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (this.nodeName && (this.nodeType && this.nodeType !== 11)) { + can.$(this) + .removeEvent(ev, cb); + } else if (this.removeEvent) { + this.removeEvent(ev, cb); + } else { + // Make it bind-able... + can.removeEvent.call(this, ev, cb); + } + return this; + }; + // Alias on/off to bind/unbind respectively + can.on = can.bind; + can.off = can.unbind; + can.trigger = function (item, event, args, bubble) { + // Defaults to `true`. + bubble = bubble === undefined ? true : bubble; + args = args || []; + var propagating = true; + if (item.fireEvent) { + item = item[0] || item; + // walk up parents to simulate bubbling . + while (item && propagating) { + // Handle walking yourself. + if (!event.type) { + event = { + type: event, + target: item, + stopPropagation: function () { + propagating = false; + } + }; + } + var events = item !== window ? can.$(item) + .retrieve('events')[0] : item.retrieve('events'); + if (events && events[event.type]) { + events[event.type].keys.each(function (fn) { + fn.apply(item, [event].concat(args)); + }, this); + } + // If we are bubbling, get parent node. + if (bubble && item.parentNode && item.parentNode.nodeType !== 11) { + item = item.parentNode; + } else { + item = null; + } + } + } else { + if (typeof event === 'string') { + event = { + type: event + }; + } + event.target = event.target || item; + can.dispatch.call(item, event, can.makeArray(args)); + } + }; + can.delegate = function (selector, ev, cb) { + if (this.delegate) { + this.delegate(selector, ev, cb); + } else if (this.addEvent) { + this.addEvent(ev + ':relay(' + selector + ')', cb); + } else { + // make it bind-able ... + can.bind.call(this, ev, cb); + } + return this; + }; + can.undelegate = function (selector, ev, cb) { + if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else if (this.removeEvent) { + this.removeEvent(ev + ':relay(' + selector + ')', cb); + } else { + can.unbind.call(this, ev, cb); + } + return this; + }; + var optionsMap = { + type: 'method', + success: undefined, + error: undefined + }; + var updateDeferred = function (xhr, d) { + for (var prop in xhr) { + if (typeof d[prop] === 'function') { + d[prop] = function () { + xhr[prop].apply(xhr, arguments); + }; + } else { + d[prop] = prop[xhr]; + } + } + }; + can.ajax = function (options) { + var d = can.Deferred(), + requestOptions = can.extend({}, options), + request; + // Map jQuery options to MooTools options. + for (var option in optionsMap) { + if (requestOptions[option] !== undefined) { + requestOptions[optionsMap[option]] = requestOptions[option]; + delete requestOptions[option]; + } + } + // Mootools defaults to 'post', but Can expects a default of 'get' + requestOptions.method = requestOptions.method || 'get'; + requestOptions.url = requestOptions.url.toString(); + var success = options.onSuccess || options.success, + error = options.onFailure || options.error; + requestOptions.onSuccess = function (response, xml) { + var data = response; + updateDeferred(request.xhr, d); + d.resolve(data, 'success', request.xhr); + if (success) { + success(data, 'success', request.xhr); + } + }; + requestOptions.onFailure = function () { + updateDeferred(request.xhr, d); + d.reject(request.xhr, 'error'); + if (error) { + error(request.xhr, 'error'); + } + }; + if (options.dataType === 'json') { + request = new Request.JSON(requestOptions); + } else { + request = new Request(requestOptions); + } + request.send(); + updateDeferred(request.xhr, d); + return d; + }; + // Element -- get the wrapped helper. + can.$ = function (selector) { + if (selector === window) { + return window; + } + return $$(selector && selector.nodeName ? [selector] : selector); + }; + + // Add `document` fragment support. + var old = document.id; + document.id = function (el) { + if (el && el.nodeType === 11) { + return el; + } else { + return old.apply(document, arguments); + } + }; + can.append = function (wrapped, html) { + if (typeof html === 'string') { + html = can.buildFragment(html); + } + return wrapped.grab(html); + }; + can.filter = function (wrapped, filter) { + return wrapped.filter(filter); + }; + can.data = function (wrapped, key, value) { + if (value === undefined) { + return wrapped[0].retrieve(key); + } else { + return wrapped.store(key, value); + } + }; + can.addClass = function (wrapped, className) { + return wrapped.addClass(className); + }; + can.remove = function (wrapped) { + // We need to remove text nodes ourselves. + var filtered = wrapped.filter(function (node) { + if (node.nodeType !== 1) { + node.parentNode.removeChild(node); + } else { + return true; + } + }); + filtered.destroy(); + return filtered; + }; + can.has = function (wrapped, element) { + // this way work in mootools + if (Slick.contains(wrapped[0], element)) { + return wrapped; + } else { + return []; + } + }; + // Destroyed method. + var destroy = Element.prototype.destroy, + grab = Element.prototype.grab, + oldSet = Element.prototype.set; + Element.implement({ + destroy: function () { + can.trigger(this, 'removed', [], false); + var elems = this.getElementsByTagName('*'); + for (var i = 0, elem; + (elem = elems[i]) !== undefined; i++) { + can.trigger(elem, 'removed', [], false); + } + destroy.apply(this, arguments); + }, + grab: function (el) { + var elems; + if (el && el.nodeType === 11) { + elems = can.makeArray(el.childNodes); + } else { + elems = [el]; + } + var ret = grab.apply(this, arguments); + can.inserted(elems); + return ret; + }, + set: function (attrName, value) { + var isAttributeOrProp = can.inArray(attrName, ["events", "html", "load", "morph", "send", "tag", "tween"]) === -1, + newValue, + oldValue; + + if (isAttributeOrProp) { + oldValue = this.get(attrName); + } + + var res = oldSet.apply(this, arguments); + + if (isAttributeOrProp) { + newValue = this.get(attrName); + } + if (newValue !== oldValue) { + can.attr.trigger(this, attrName, oldValue); + } + return res; + }.overloadSetter() + }); + can.get = function (wrapped, index) { + return wrapped[index]; + }; + // Overwrite to handle IE not having an id. + // IE barfs if text node. + var idOf = Slick.uidOf; + Slick.uidOf = function (node) { + // for some reason, in IE8, node will be the window but not equal it. + if (node.nodeType === 1 || node === window || node.document === document) { + return idOf(node); + } else { + return Math.random(); + } + }; + Element.NativeEvents.hashchange = 2; + + // Setup attributes events + + can.attr = attr; + + // turn off mutation events for zepto + delete attr.MutationObserver; + + Element.Events.attributes = { + onAdd: function () { + var el = can.$(this); + can.data(el, "canHasAttributesBindings", (can.data(el, "canHasAttributesBindings") || 0) + 1); + }, + onRemove: function () { + var el = can.$(this), + cur = can.data(el, "canHasAttributesBindings") || 0; + if (cur <= 0) { + can.cleanData(el, "canHasAttributesBindings"); + } else { + can.data(el, "canHasAttributesBindings", cur - 1); + } + } + }; + + return can; + }); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/object/isplain/isplain.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/object/isplain/isplain.js new file mode 100644 index 0000000000..e58f0a9078 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/object/isplain/isplain.js @@ -0,0 +1,41 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/object/isplain/isplain*/ +steal('can/util/can.js', function () { + var core_hasOwn = Object.prototype.hasOwnProperty, + isWindow = function (obj) { + // In IE8 window.window !== window.window, so we allow == here. + /*jshint eqeqeq:false*/ + return obj !== null && obj == obj.window; + }, isPlainObject = function (obj) { + // Must be an Object. + // Because of IE, we also have to check the presence of the constructor property. + // Make sure that DOM nodes and window objects don't pass through, as well + if (!obj || typeof obj !== 'object' || obj.nodeType || isWindow(obj)) { + return false; + } + try { + // Not own constructor property must be Object + if (obj.constructor && !core_hasOwn.call(obj, 'constructor') && !core_hasOwn.call(obj.constructor.prototype, 'isPrototypeOf')) { + return false; + } + } catch (e) { + // IE8,9 Will throw exceptions on certain host objects #9897 + return false; + } + // Own properties are enumerated firstly, so to speed up, + // if last one is own, then all properties are own. + var key; + for (key in obj) {} + return key === undefined || core_hasOwn.call(obj, key); + }; + can.isPlainObject = isPlainObject; + return can; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/object/object.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/object/object.js new file mode 100644 index 0000000000..4e7e03fa81 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/object/object.js @@ -0,0 +1,196 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/object/object*/ +steal('can/util', function (can) { + var isArray = can.isArray; + can.Object = {}; + /** + * @function can.Object.same + * @parent can.util + * @description Checks if two objects are the same. + * @signature `can.Object.same(a, b, compares, aParent, bParent, deep)` + * @param {Object} a An object to compare against `b`. + * @param {Object} b An object to compare against `a`. + * @param {Object} [compares] An object that specifies how to compare properties. + * The keys of the `compares` object are names of properties in the objects to compare, + * and the values are functions that compare those properties. You can also pass `'i'` + * to compare values as case-insensitive strings, or `null` not to compare the properties + * at all. + * @return {{boolean}} Whether the two objects have the same properties and values. + * + * @body + * This function does not work with objects that create circular references. + * + * ## Examples + * ``` + * can.Object.same({name: "Justin"}, {name: "JUSTIN"}) //-> false + * + * // ignore the name property + * can.Object.same({name: "Brian"}, {name: "JUSTIN"}, {name: null}) //-> true + * + * // ignore case + * can.Object.same({name: "Justin"}, {name: "JUSTIN"}, {name: "i"}) //-> true + * + * // deep rule + * can.Object.same({ person : { name: "Justin" } }, + * { person : { name: "JUSTIN" } }, + * { person : { name: "i" } }) //-> true + * + * // supplied compare function + * can.Object.same({age: "Thirty"}, + * {age: 30}, + * {age: function( a, b ){ + * if( a == "Thirty" ) { + * a = 30 + * } + * if( b == "Thirty" ) { + * b = 30 + * } + * return a === b; + * }}) //-> true + * ``` + */ + var same = can.Object.same = function (a, b, compares, aParent, bParent, deep) { + var aType = typeof a, + aArray = isArray(a), + comparesType = typeof compares, + compare; + if (comparesType === 'string' || compares === null) { + compares = compareMethods[compares]; + comparesType = 'function'; + } + if (comparesType === 'function') { + return compares(a, b, aParent, bParent); + } + compares = compares || {}; + if (a === null || b === null) { + return a === b; + } + if (a instanceof Date || b instanceof Date) { + return a === b; + } + if (deep === -1) { + return aType === 'object' || a === b; + } + if (aType !== typeof b || aArray !== isArray(b)) { + return false; + } + if (a === b) { + return true; + } + if (aArray) { + if (a.length !== b.length) { + return false; + } + for (var i = 0; i < a.length; i++) { + compare = compares[i] === undefined ? compares['*'] : compares[i]; + if (!same(a[i], b[i], a, b, compare)) { + return false; + } + } + return true; + } else if (aType === 'object' || aType === 'function') { + var bCopy = can.extend({}, b); + for (var prop in a) { + compare = compares[prop] === undefined ? compares['*'] : compares[prop]; + if (!same(a[prop], b[prop], compare, a, b, deep === false ? -1 : undefined)) { + return false; + } + delete bCopy[prop]; + } + // go through bCopy props ... if there is no compare .. return false + for (prop in bCopy) { + if (compares[prop] === undefined || !same(undefined, b[prop], compares[prop], a, b, deep === false ? -1 : undefined)) { + return false; + } + } + return true; + } + return false; + }; + /** + * @function can.Object.subsets + * @parent can.util + * @description Returns the sets in 'sets' that are a subset of checkSet + * @signature `can.Object.subsets(checkSet, sets, compares)` + * @param {Object} checkSet + * @param {Object} sets + * @param {Object} compares + * @body + * ## Example + * ``` + * can.Object.subsets({userId: 20}, [ + * {userId: 20, limit: 30}, + * {userId: 5}, + * {} + * ]); //-> [{userId: 20, limit: 30}] + * ``` + */ + can.Object.subsets = function (checkSet, sets, compares) { + var len = sets.length, + subsets = []; + for (var i = 0; i < len; i++) { + //check this subset + var set = sets[i]; + if (can.Object.subset(checkSet, set, compares)) { + subsets.push(set); + } + } + return subsets; + }; + /** + * @function can.Object.subset + * @parent can.util + * @description Returns true if an Object is a subset of another Object + * @signature `can.Object.subset(subset, set, compares)` + * @param {Object} subset + * @param {Object} set + * @param {Object} compares + * @returns {Boolean} Whether or not subset is a subset of set + * @body + * ## Example + * ``` + * can.Object.subset({}, {foo: "bar"} ) //-> true + * ``` + */ + can.Object.subset = function (subset, set, compares) { + // go through set {type: 'folder'} and make sure every property + // is in subset {type: 'folder', parentId :5} + // then make sure that set has fewer properties + // make sure we are only checking 'important' properties + // in subset (ones that have to have a value) + compares = compares || {}; + for (var prop in set) { + if (!same(subset[prop], set[prop], compares[prop], subset, set)) { + return false; + } + } + return true; + }; + var compareMethods = { + 'null': function () { + return true; + }, + i: function (a, b) { + return ('' + a) + .toLowerCase() === ('' + b) + .toLowerCase(); + }, + eq: function(a, b) { + return a === b; + }, + similar: function(a, b) { + /*jshint eqeqeq:false */ + return a == b; + } + }; + compareMethods.eqeq = compareMethods.similar; + return can.Object; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/string/deparam/deparam.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/string/deparam/deparam.js new file mode 100644 index 0000000000..ef242c4f9d --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/string/deparam/deparam.js @@ -0,0 +1,53 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/string/deparam/deparam*/ +steal('can/util', 'can/util/string', function (can) { + // ## deparam.js + // `can.deparam` + // _Takes a string of name value pairs and returns a Object literal that represents those params._ + var digitTest = /^\d+$/, + keyBreaker = /([^\[\]]+)|(\[\])/g, + paramTest = /([^?#]*)(#.*)?$/, + prep = function (str) { + return decodeURIComponent(str.replace(/\+/g, ' ')); + }; + can.extend(can, { + deparam: function (params) { + var data = {}, pairs, lastPart; + if (params && paramTest.test(params)) { + pairs = params.split('&'); + can.each(pairs, function (pair) { + var parts = pair.split('='), + key = prep(parts.shift()), + value = prep(parts.join('=')), + current = data; + if (key) { + parts = key.match(keyBreaker); + for (var j = 0, l = parts.length - 1; j < l; j++) { + if (!current[parts[j]]) { + // If what we are pointing to looks like an `array` + current[parts[j]] = digitTest.test(parts[j + 1]) || parts[j + 1] === '[]' ? [] : {}; + } + current = current[parts[j]]; + } + lastPart = parts.pop(); + if (lastPart === '[]') { + current.push(value); + } else { + current[lastPart] = value; + } + } + }); + } + return data; + } + }); + return can; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/string/string.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/string/string.js new file mode 100644 index 0000000000..0e3aa9a1e3 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/string/string.js @@ -0,0 +1,143 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/string/string*/ +steal('can/util', function (can) { + // ##string.js + // _Miscellaneous string utility functions._ + // Several of the methods in this plugin use code adapated from Prototype + // Prototype JavaScript framework, version 1.6.0.1. + // © 2005-2007 Sam Stephenson + var strUndHash = /_|-/, + strColons = /\=\=/, + strWords = /([A-Z]+)([A-Z][a-z])/g, + strLowUp = /([a-z\d])([A-Z])/g, + strDash = /([a-z\d])([A-Z])/g, + strReplacer = /\{([^\}]+)\}/g, + strQuote = /"/g, + strSingleQuote = /'/g, + strHyphenMatch = /-+(.)?/g, + strCamelMatch = /[a-z][A-Z]/g, + // Returns the `prop` property from `obj`. + // If `add` is true and `prop` doesn't exist in `obj`, create it as an + // empty object. + getNext = function (obj, prop, add) { + var result = obj[prop]; + if (result === undefined && add === true) { + result = obj[prop] = {}; + } + return result; + }, + // Returns `true` if the object can have properties (no `null`s). + isContainer = function (current) { + return /^f|^o/.test(typeof current); + }, convertBadValues = function (content) { + // Convert bad values into empty strings + var isInvalid = content === null || content === undefined || isNaN(content) && '' + content === 'NaN'; + return '' + (isInvalid ? '' : content); + }; + can.extend(can, { + esc: function (content) { + return convertBadValues(content) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(strQuote, '"') + .replace(strSingleQuote, '''); + }, + getObject: function (name, roots, add) { + // The parts of the name we are looking up + // `['App','Models','Recipe']` + var parts = name ? name.split('.') : [], + length = parts.length, + current, r = 0, + i, container, rootsLength; + // Make sure roots is an `array`. + roots = can.isArray(roots) ? roots : [roots || window]; + rootsLength = roots.length; + if (!length) { + return roots[0]; + } + // For each root, mark it as current. + for (r; r < rootsLength; r++) { + current = roots[r]; + container = undefined; + // Walk current to the 2nd to last object or until there + // is not a container. + for (i = 0; i < length && isContainer(current); i++) { + container = current; + current = getNext(container, parts[i]); + } + // If we found property break cycle + if (container !== undefined && current !== undefined) { + break; + } + } + // Remove property from found container + if (add === false && current !== undefined) { + delete container[parts[i - 1]]; + } + // When adding property add it to the first root + if (add === true && current === undefined) { + current = roots[0]; + for (i = 0; i < length && isContainer(current); i++) { + current = getNext(current, parts[i], true); + } + } + return current; + }, + capitalize: function (s, cache) { + // Used to make newId. + return s.charAt(0) + .toUpperCase() + s.slice(1); + }, + camelize: function (str) { + return convertBadValues(str) + .replace(strHyphenMatch, function (match, chr) { + return chr ? chr.toUpperCase() : ''; + }); + }, + hyphenate: function (str) { + return convertBadValues(str) + .replace(strCamelMatch, function (str, offset) { + return str.charAt(0) + '-' + str.charAt(1) + .toLowerCase(); + }); + }, + underscore: function (s) { + return s.replace(strColons, '/') + .replace(strWords, '$1_$2') + .replace(strLowUp, '$1_$2') + .replace(strDash, '_') + .toLowerCase(); + }, + sub: function (str, data, remove) { + var obs = []; + str = str || ''; + obs.push(str.replace(strReplacer, function (whole, inside) { + // Convert inside to type. + var ob = can.getObject(inside, data, remove === true ? false : undefined); + if (ob === undefined || ob === null) { + obs = null; + return ''; + } + // If a container, push into objs (which will return objects found). + if (isContainer(ob) && obs) { + obs.push(ob); + return ''; + } + return '' + ob; + })); + return obs === null ? obs : obs.length <= 1 ? obs[0] : obs; + }, + replacer: strReplacer, + undHash: strUndHash + }); + return can; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/tests/tests.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/tests/tests.js new file mode 100644 index 0000000000..e56fe9b0e8 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/tests/tests.js @@ -0,0 +1,11 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/tests/tests*/ +steal('../string/string', '../inserted/inserted', '../attr/attr', '../array/each'); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/util.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/util.js new file mode 100644 index 0000000000..5123b297f4 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/util.js @@ -0,0 +1,14 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/util*/ +// comments are in func.js for documentation purposes. +steal('can/util/jquery', function (can) { + return can; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/yui/yui.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/yui/yui.js new file mode 100644 index 0000000000..bfaa196280 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/yui/yui.js @@ -0,0 +1,546 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/util*/ +/* + YUI modules: http://yuilibrary.com/yui/configurator/ + node + io-base + querystring + event-focus + array-extras + */ + +// This was used to build the custom YUI download. Re-run it to generate a new yui-.js file +// var yuilibs = ['yui-base/yui-base.js', 'oop/oop.js', 'event-custom-base/event-custom-base.js', 'features/features.js', 'dom-core/dom-core.js', 'dom-base/dom-base.js', 'selector-native/selector-native.js', 'selector-css2/selector-css2.js', 'selector/selector.js', 'node-core/node-core.js', 'node-base/node-base.js', 'event-base/event-base.js', 'event-delegate/event-delegate.js', 'node-event-delegate/node-event-delegate.js', 'pluginhost-base/pluginhost-base.js', 'pluginhost-config/pluginhost-config.js', 'node-pluginhost/node-pluginhost.js', 'dom-style/dom-style.js', 'dom-screen/dom-screen.js', 'node-screen/node-screen.js', 'node-style/node-style.js', 'querystring-stringify-simple/querystring-stringify-simple.js', 'io-base/io-base.js', 'array-extras/array-extras.js', 'querystring-parse/querystring-parse.js', 'querystring-stringify/querystring-stringify.js', 'event-custom-complex/event-custom-complex.js', 'event-synthetic/event-synthetic.js', 'event-focus/event-focus.js'] +// +// var url = "http://yui.yahooapis.com/combo?3.7.3/build/" + yuilibs.join("&3.7.3/build/") + +steal('can/util/can.js', "can/util/attr", 'yui', 'can/event', + "can/util/fragment.js", 'can/util/array/each.js', + 'can/util/object/isplain', 'can/util/deferred.js', + 'can/util/hashchange.js', "can/util/inserted", function (can, attr, YUI) { + YUI = YUI || window.YUI; + // lets overwrite + YUI.add('can-modifications', function (Y, NAME) { + var addHTML = Y.DOM.addHTML; + + Y.DOM.addHTML = function (node, content, where) { + if (typeof content === "string" || typeof content === "number") { + content = can.buildFragment(content); + } + var elems; + if (content.nodeType === 11) { + elems = can.makeArray(content.childNodes); + } else { + elems = [content]; + } + var ret = addHTML.call(this, node, content, where); + + can.inserted(elems); + + return ret; + }; + + var oldOn = Y.Node.prototype.on; + Y.Node.prototype.on = function (type, fn) { + if (type === "attributes") { + // YUI changes where the extra data comes from + var el = can.$(this); + can.data(el, "canHasAttributesBindings", (can.data(el, "canHasAttributesBindings") || 0) + 1); + + var handle = oldOn.apply(this, arguments), + oldDetach = handle.detach; + handle.detach = function () { + var cur = can.data(el, "canHasAttributesBindings") || 0; + if (cur <= 0) { + can.cleanData(el, "canHasAttributesBindings"); + } else { + can.data(el, "canHasAttributesBindings", cur - 1); + } + return oldDetach.apply(this, arguments); + }; + return handle; + } else { + return oldOn.apply(this, arguments); + } + }; + + }, '3.7.3', { + "requires": ["node-base"] + }); + + // --------- + // _YUI node list._ + // `can.Y` is set as part of the build process. + // `YUI().use('*')` is called for when `YUI` is statically loaded (like when running tests). + var Y = can.Y = can.Y || YUI() + .use('*'); + // Map string helpers. + can.trim = function (s) { + return Y.Lang.trim(s); + }; + // Map array helpers. + can.makeArray = function (arr) { + if (!arr) { + return []; + } + return Y.Array(arr); + }; + can.isArray = Y.Lang.isArray; + can.inArray = function (item, arr, fromIndex) { + if (!arr) { + return -1; + } + return Y.Array.indexOf(arr, item, fromIndex); + }; + can.map = function (arr, fn) { + return Y.Array.map(can.makeArray(arr || []), fn); + }; + // Map object helpers. + can.extend = function (first) { + var deep = first === true ? 1 : 0, + target = arguments[deep], + i = deep + 1, + arg; + for (; arg = arguments[i]; i++) { + Y.mix(target, arg, true, null, null, !!deep); + } + return target; + }; + can.param = function (object) { + return Y.QueryString.stringify(object, { + arrayKey: true + }); + }; + can.isEmptyObject = function (object) { + return Y.Object.isEmpty(object); + }; + // Map function helpers. + can.proxy = function (func, context) { + return Y.bind.apply(Y, arguments); + }; + can.isFunction = function (f) { + return Y.Lang.isFunction(f); + }; + // Element -- get the wrapped helper. + var prepareNodeList = function (nodelist) { + nodelist.each(function (node, i) { + nodelist[i] = node.getDOMNode(); + }); + nodelist.length = nodelist.size(); + return nodelist; + }; + can.$ = function (selector) { + if (selector === window) { + return window; + } else if (selector instanceof Y.NodeList) { + return prepareNodeList(selector); + } else if (typeof selector === 'object' && !can.isArray(selector) && typeof selector.nodeType === 'undefined' && !selector.getDOMNode) { + return new Y.NodeList(selector); + } else { + return prepareNodeList(Y.all(selector)); + } + }; + can.get = function (wrapped, index) { + return wrapped._nodes[index]; + }; + can.append = function (wrapped, html) { + wrapped.each(function (node) { + if (typeof html === 'string') { + html = can.buildFragment(html, node); + } + node.append(html); + }); + }; + can.addClass = function (wrapped, className) { + return wrapped.addClass(className); + }; + can.data = function (wrapped, key, value) { + if(!wrapped.item(0)) { return; } + if (value === undefined) { + return wrapped.item(0) + .getData(key); + } else { + return wrapped.item(0) + .setData(key, value); + } + }; + can.remove = function (wrapped) { + return wrapped.remove() && wrapped.destroy(); + }; + can.has = function (wrapped, node) { + if (Y.DOM.contains(wrapped[0], node)) { + return wrapped; + } else { + return []; + } + }; + // Destroyed method. + can._yNodeRemove = can._yNodeRemove || Y.Node.prototype.remove; + Y.Node.prototype.remove = function () { + // make sure this is only fired on normal nodes, if it + // is fired on a text node, it will bubble because + // the method used to stop bubbling (listening to an event) + // does not work on text nodes + var node = this.getDOMNode(); + if (node.nodeType === 1) { + can.trigger(this, 'removed', [], false); + var elems = node.getElementsByTagName('*'); + for (var i = 0, elem; + (elem = elems[i]) !== undefined; i++) { + can.trigger(elem, 'removed', [], false); + } + } + can._yNodeRemove.apply(this, arguments); + }; + // Let `nodelist` know about the new destroy... + Y.NodeList.addMethod('remove', Y.Node.prototype.remove); + // Ajax + var optionsMap = { + type: 'method', + success: undefined, + error: undefined + }; + var updateDeferred = function (request, d) { + // `YUI` only returns a request if it is asynchronous. + if (request && request.io) { + var xhr = request.io; + for (var prop in xhr) { + if (typeof d[prop] === 'function') { + d[prop] = function () { + xhr[prop].apply(xhr, arguments); + }; + } else { + d[prop] = prop[xhr]; + } + } + } + }; + can.ajax = function (options) { + var d = can.Deferred(), + requestOptions = can.extend({}, options); + for (var option in optionsMap) { + if (requestOptions[option] !== undefined) { + requestOptions[optionsMap[option]] = requestOptions[option]; + delete requestOptions[option]; + } + } + requestOptions.sync = !options.async; + var success = options.success, + error = options.error; + requestOptions.on = { + success: function (transactionid, response) { + var data = response.responseText; + if (options.dataType === 'json') { + data = eval('(' + data + ')'); + } + updateDeferred(request, d); + d.resolve(data); + if (success) { + success(data, 'success', request); + } + }, + failure: function (transactionid, response) { + updateDeferred(request, d); + d.reject(request, 'error'); + if (error) { + error(request, 'error'); + } + } + }; + var request = Y.io(requestOptions.url, requestOptions); + updateDeferred(request, d); + return d; + }; + // Events - The `id` of the `function` to be bound, used as an expando on the `function` + // so we can lookup it's `remove` object. + var yuiEventId = 0, + // Takes a node list, goes through each node + // and adds events data that has a map of events to + // `callbackId` to `remove` object. It looks like + // `{click: {5: {remove: fn}}}`. + addBinding = function (nodelist, selector, ev, cb) { + if (nodelist instanceof Y.NodeList || !nodelist.on || nodelist.getDOMNode) { + nodelist.each(function (node) { + node = can.$(node); + var events = can.data(node, 'events'), + eventName = ev + ':' + selector; + if (!events) { + can.data(node, 'events', events = {}); + } + if (!events[eventName]) { + events[eventName] = {}; + } + if (cb.__bindingsIds === undefined) { + cb.__bindingsIds = yuiEventId++; + } + events[eventName][cb.__bindingsIds] = selector ? node.item(0) + .delegate(ev, cb, selector) : node.item(0) + .on(ev, cb); + }); + } else { + var obj = nodelist, + events = obj.__canEvents = obj.__canEvents || {}; + if (!events[ev]) { + events[ev] = {}; + } + if (cb.__bindingsIds === undefined) { + cb.__bindingsIds = yuiEventId++; + } + events[ev][cb.__bindingsIds] = obj.on(ev, cb); + } + }, + // Removes a binding on a `nodelist` by finding + // the remove object within the object's data. + removeBinding = function (nodelist, selector, ev, cb) { + if (nodelist instanceof Y.NodeList || !nodelist.on || nodelist.getDOMNode) { + nodelist.each(function (node) { + node = can.$(node); + var events = can.data(node, 'events'); + if (events) { + var eventName = ev + ':' + selector, + handlers = events[eventName], + handler = handlers[cb.__bindingsIds]; + handler.detach(); + delete handlers[cb.__bindingsIds]; + if (can.isEmptyObject(handlers)) { + delete events[ev]; + } + if (can.isEmptyObject(events)) { + } + } + }); + } else { + var obj = nodelist, + events = obj.__canEvents || {}, handlers = events[ev], + handler = handlers[cb.__bindingsIds]; + handler.detach(); + delete handlers[cb.__bindingsIds]; + if (can.isEmptyObject(handlers)) { + delete events[ev]; + } + if (can.isEmptyObject(events)) { + } + } + }; + can.bind = function (ev, cb) { + // If we can bind to it... + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (this.on || this.nodeType) { + addBinding(can.$(this), undefined, ev, cb); + } else if (this.addEvent) { + this.addEvent(ev, cb); + } else { + // Make it bind-able... + can.addEvent.call(this, ev, cb); + } + return this; + }; + can.unbind = function (ev, cb) { + // If we can bind to it... + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (this.on || this.nodeType) { + removeBinding(can.$(this), undefined, ev, cb); + } else { + // Make it bind-able... + can.removeEvent.call(this, ev, cb); + } + return this; + }; + // Alias on/off to bind/unbind respectively + can.on = can.bind; + can.off = can.unbind; + can.trigger = function (item, event, args, bubble) { + if (item instanceof Y.NodeList) { + item = item.item(0); + } + if (item.getDOMNode) { + item = item.getDOMNode(); + } + if (item.nodeName) { + item = Y.Node(item); + if (bubble === false) { + // Force stop propagation by listening to `on` and then + // immediately disconnecting + item.once(event, function (ev) { + if (ev.stopPropagation) { + ev.stopPropagation(); + } + ev.cancelBubble = true; + if (ev._stopper) { + ev._stopper(); + } + }); + } + if (typeof event !== 'string') { + args = event; + event = args.type; + delete args.type; + } + realTrigger(item.getDOMNode(), event, args || {}); + } else { + if (typeof event === 'string') { + event = { + type: event + }; + } + event.target = event.target || item; + can.dispatch.call(item, event, can.makeArray(args)); + } + }; + // Allow `dom` `destroyed` events. + Y.mix(Y.Node.DOM_EVENTS, { + removed: true, + inserted: true, + attributes: true, + // foo is here for testing + foo: true + }); + + Y.Env.evt.plugins.attributes = { + // forces YUI not to change this event signature + on: function () { + var args = can.makeArray(arguments); + return Y.Event._attach(args, { + facade: false + }); + } + }; + + can.delegate = function (selector, ev, cb) { + if (this.on || this.nodeType) { + addBinding(can.$(this), selector, ev, cb); + } else if (this.delegate) { + this.delegate(selector, ev, cb); + } else { + // make it bind-able ... + can.bind.call(this, ev, cb); + } + return this; + }; + can.undelegate = function (selector, ev, cb) { + if (this.on || this.nodeType) { + removeBinding(can.$(this), selector, ev, cb); + } else if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else { + can.unbind.call(this, ev, cb); + } + return this; + }; + + + + // `realTrigger` taken from `dojo`. + var /*leaveRe = /mouse(enter|leave)/, + _fix = function (_, p) { + return 'mouse' + (p === 'enter' ? 'over' : 'out'); + },*/ realTrigger, + realTriggerHandler = function (n, e, evdata) { + var node = Y.Node(n), + handlers = can.Y.Event.getListeners(node._yuid, e), + i; + if (handlers) { + for (i = 0; i < handlers.length; i++) { + if (handlers[i].fire) { + handlers[i].fire(evdata); + } else if (handlers[i].handles) { + can.each(handlers[i].handles, function (handle) { + handle.evt.fire(evdata); + }); + } else { + throw "can not fire event"; + } + } + } + }, + fakeTrigger = function(n, e, a){ + var stop = false; + // a lame duck to work with. we're probably a 'custom event' + var evdata = can.extend({ + type: e, + target: n, + faux: true, + _stopper: function () { + stop = this.cancelBubble; + }, + stopPropagation: function () { + stop = this.cancelBubble; + }, + preventDefault: function(){ + + } + }, a); + realTriggerHandler(n, e, evdata); + if (e === "inserted" || e === "removed") { + return; + } + + // handle bubbling of custom events, unless the event was stopped. + while (!stop && n !== document && n.parentNode) { + n = n.parentNode; + realTriggerHandler(n, e, evdata); //can.isFunction(n[ev]) && n[ev](evdata); + } + }; + if (document.createEvent) { + realTrigger = function (n, e, a) { + // the same branch + fakeTrigger(n, e, a); + return; + /*var ev = document.createEvent('HTMLEvents'); + e = e.replace(leaveRe, _fix); + ev.initEvent(e, e === 'removed' || e === 'inserted' ? false : true, true); + if (a) { + can.extend(ev, a); + } + n.dispatchEvent(ev);*/ + }; + } else { + realTrigger = function (n, e, a) { + fakeTrigger(n, e, a); + return; + /* + // the janktastic branch + var ev = 'on' + e; + if(e === "focus" || e === "blur") { + fakeTrigger(n, e, a); + } + + try { + // FIXME: is this worth it? for mixed-case native event support:? Opera ends up in the + // createEvent path above, and also fails on _some_ native-named events. + // if(lc !== e && d.indexOf(d.NodeList.events, lc) >= 0){ + // // if the event is one of those listed in our NodeList list + // // in lowercase form but is mixed case, throw to avoid + // // fireEvent. /me sighs. http://gist.github.com/315318 + // throw("janktastic"); + // } + var evObj = document.createEventObject(); + if (e === "inserted" || e === "removed") { + evObj.cancelBubble = true; + } + can.extend(evObj, a); + n.fireEvent(ev, evObj); + + } catch (er) { + fakeTrigger(n,e,a); + + }*/ + }; + } + + // setup attributes event + can.attr = attr; + delete attr.MutationObserver; + + return can; + }); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/zepto/zepto.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/zepto/zepto.js new file mode 100644 index 0000000000..3442053d24 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/util/zepto/zepto.js @@ -0,0 +1,380 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#util/util*/ +steal('can/util/can.js', 'can/util/attr', 'can/event', 'zepto', 'can/util/object/isplain', + 'can/util/fragment.js', 'can/util/deferred.js', 'can/util/array/each.js', 'can/util/inserted', + function (can, attr, event) { + // data.js + // --------- + // _jQuery-like data methods._ + var $ = Zepto; + + // data.js + // --------- + // _jQuery-like data methods._ + var data = {}, dataAttr = $.fn.data, + uuid = $.uuid = +new Date(), + exp = $.expando = 'Zepto' + uuid; + + function getData(node, name) { + var id = node[exp], + store = id && data[id]; + return name === undefined ? store || setData(node) : + (store && store[name]) || dataAttr.call($(node), name); + } + + function setData(node, name, value) { + var id = node[exp] || (node[exp] = ++uuid), + store = data[id] || (data[id] = {}); + if (name !== undefined) { + store[name] = value; + } + return store; + } + + $.fn.data = function (name, value) { + return value === undefined ? + this.length === 0 ? undefined : getData(this[0], name) : + this.each(function (idx) { + setData(this, name, $.isFunction(value) ? + value.call(this, idx, getData(this, name)) : value); + }); + }; + $.cleanData = function (elems) { + // trigger all the events ... then remove the data + for (var i = 0, elem; + (elem = elems[i]) !== undefined; i++) { + can.trigger(elem, "removed", [], false); + } + for (i = 0; + (elem = elems[i]) !== undefined; i++) { + var id = elem[exp]; + delete data[id]; + } + + }; + + // zepto.js + // --------- + // _Zepto node list._ + + var oldEach = can.each; + // Extend what you can out of Zepto. + var oldPlain = can.isPlainObject; + $.extend(can, Zepto); + can.inArray = function(el, arr) { + return !arr ? -1 : $.inArray.apply($, arguments); + }; + can.isPlainObject = oldPlain; + can.each = oldEach; + can.attr = attr; + can.event = event; + var arrHas = function (obj, name) { + return obj[0] && obj[0][name] || obj[name]; + }; + + // Do what's similar for jQuery. + can.trigger = function (obj, event, args, bubble) { + if (obj.trigger) { + obj.trigger(event, args); + } else if (arrHas(obj, "dispatchEvent")) { + if (bubble === false) { + $([obj]) + .triggerHandler(event, args); + } else { + $([obj]) + .trigger(event, args); + } + + } else { + if (typeof event === "string") { + event = { + type: event + }; + } + event.target = event.target || obj; + can.dispatch.call(obj, event, can.makeArray(args)); + } + + }; + + can.$ = Zepto; + + can.bind = function (ev, cb) { + // If we can bind to it... + if (this.bind && this.bind !== can.bind) { + this.bind(ev, cb); + } else if (arrHas(this, "addEventListener")) { + $([this]) + .bind(ev, cb); + } else { + can.addEvent.call(this, ev, cb); + } + return this; + }; + can.unbind = function (ev, cb) { + // If we can bind to it... + if (this.unbind && this.unbind !== can.unbind) { + this.unbind(ev, cb); + } else if (arrHas(this, "addEventListener")) { + $([this]) + .unbind(ev, cb); + } else { + can.removeEvent.call(this, ev, cb); + } + return this; + }; + + // Alias on/off to bind/unbind respectively + can.on = can.bind; + can.off = can.unbind; + + can.delegate = function (selector, ev, cb) { + if (!selector) { + // Zepto fails with no selector + can.bind.call(this, ev, cb); + } else if (this.delegate) { + this.delegate(selector, ev, cb); + } else if (arrHas(this, "addEventListener")) { + $([this]) + .delegate(selector, ev, cb); + } else { + // Make it bind-able... + can.addEvent.call(this, ev, cb); + } + }; + can.undelegate = function (selector, ev, cb) { + if (!selector) { + // Zepto fails with no selector + can.unbind.call(this, ev, cb); + } else if (this.undelegate) { + this.undelegate(selector, ev, cb); + } else if (arrHas(this, "addEventListener")) { + $([this]) + .undelegate(selector, ev, cb); + } else { + // Make it bind-able... + can.removeEvent.call(this, ev, cb); + } + }; + + $.each(["append", "filter", "addClass", "remove", "data", "has"], function (i, name) { + can[name] = function (wrapped) { + return wrapped[name].apply(wrapped, can.makeArray(arguments) + .slice(1)); + }; + }); + + can.makeArray = function (arr) { + var ret = []; + + if(arr == null) { + return []; + } + + if(arr.length === undefined || typeof arr === 'string') { + return [arr]; + } + + can.each(arr, function (a, i) { + ret[i] = a; + }); + + return ret; + }; + + // Make ajax. + var XHR = $.ajaxSettings.xhr; + $.ajaxSettings.xhr = function () { + var xhr = XHR(); + var open = xhr.open; + xhr.open = function (type, url, async) { + open.call(this, type, url, ASYNC === undefined ? true : ASYNC); + }; + return xhr; + }; + var ASYNC; + var AJAX = $.ajax; + var updateDeferred = function (xhr, d) { + for (var prop in xhr) { + if (typeof d[prop] === 'function') { + d[prop] = function () { + xhr[prop].apply(xhr, arguments); + }; + } else { + d[prop] = prop[xhr]; + } + } + }; + can.ajax = function (options) { + + var success = options.success, + error = options.error; + var d = can.Deferred(); + + options.success = function (data) { + + updateDeferred(xhr, d); + d.resolve.call(d, data); + if (success) { + success.apply(this, arguments); + } + }; + options.error = function () { + updateDeferred(xhr, d); + d.reject.apply(d, arguments); + if (error) { + error.apply(this, arguments); + } + }; + if (options.async === false) { + ASYNC = false; + } + var xhr = AJAX(options); + ASYNC = undefined; + updateDeferred(xhr, d); + return d; + }; + + // Make destroyed and empty work. + var $_empty = $.fn.empty; + $.fn.empty = function () { + this.each(function () { + $.cleanData(this.getElementsByTagName('*')); + this.innerHTML = ''; + }); + return $_empty.call(this); + }; + + var $_remove = $.fn.remove; + $.fn.remove = function () { + this.each(function () { + if (this.getElementsByTagName) { + $.cleanData([this].concat(can.makeArray(this.getElementsByTagName('*')))); + } + }); + return $_remove.call(this); + }; + + can.trim = function (str) { + return str.trim(); + }; + can.isEmptyObject = function (object) { + var name; + for (name in object) {} + return name === undefined; + }; + + // Make extend handle `true` for deep. + can.extend = function (first) { + if (first === true) { + var args = can.makeArray(arguments); + args.shift(); + return $.extend.apply($, args); + } + return $.extend.apply($, arguments); + }; + + can.get = function (wrapped, index) { + return wrapped[index]; + }; + + // setup inserted calls + can.each(['after', 'prepend', 'before', 'append'], function (name) { + var original = Zepto.fn[name]; + Zepto.fn[name] = function () { + var elems, + args = can.makeArray(arguments); + + if (args[0] != null) { + // documentFragment + if (typeof args[0] === "string") { + args[0] = $.zepto.fragment(args[0]); + } + if (args[0].nodeType === 11) { + elems = can.makeArray(args[0].childNodes); + } else if(args[0] instanceof Zepto.fn.constructor) { + elems = can.makeArray(args[0]); + } else { + elems = [args[0]]; + } + } + + var ret = original.apply(this, args); + + can.inserted(elems); + + return ret; + }; + }); + + // Setup attributes events + + // turn off mutation events for zepto + delete attr.MutationObserver; + + var oldAttr = $.fn.attr; + $.fn.attr = function (attrName, value) { + var isString = typeof attrName === "string", + oldValue, + newValue; + if (value !== undefined && isString) { + oldValue = oldAttr.call(this, attrName); + } + var res = oldAttr.apply(this, arguments); + if (value !== undefined && isString) { + newValue = oldAttr.call(this, attrName); + } + if (newValue !== oldValue) { + can.attr.trigger(this[0], attrName, oldValue); + } + return res; + }; + var oldRemove = $.fn.removeAttr; + $.fn.removeAttr = function (attrName) { + var oldValue = oldAttr.call(this, attrName), + res = oldRemove.apply(this, arguments); + + if (oldValue != null) { + can.attr.trigger(this[0], attrName, oldValue); + } + return res; + }; + + var oldBind = $.fn.bind, + oldUnbind = $.fn.unbind; + + $.fn.bind = function (event) { + if (event === "attributes") { + this.each(function () { + var el = can.$(this); + can.data(el, "canHasAttributesBindings", (can.data(el, "canHasAttributesBindings") || 0) + 1); + }); + } + return oldBind.apply(this, arguments); + }; + + $.fn.unbind = function (event) { + if (event === "attributes") { + this.each(function () { + var el = can.$(this), + cur = can.data(el, "canHasAttributesBindings") || 0; + if (cur <= 0) { + can.data(el, "canHasAttributesBindings", 0); + } else { + can.data(el, "canHasAttributesBindings", cur - 1); + } + }); + } + return oldUnbind.apply(this, arguments); + }; + + return can; + }); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/autorender/autorender.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/autorender/autorender.js new file mode 100644 index 0000000000..60843f5977 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/autorender/autorender.js @@ -0,0 +1,115 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/autorender/autorender*/ +"format steal"; +steal("can/util",function(can){ + + var deferred = new can.Deferred(), + ignoreAttributesRegExp = /^(dataViewId|class|id|type|src)$/i; + + var typeMatch = /\s*text\/(mustache|stache|ejs)\s*/; + function isIn(element, type) { + while(element.parentNode) { + element = element.parentNode; + if(element.nodeName.toLowerCase() === type.toLowerCase()) { + return true; + } + } + } + function setAttr(el, attr, scope){ + var camelized = can.camelize(attr); + if (!ignoreAttributesRegExp.test(camelized) ) { + scope.attr(camelized, el.getAttribute(attr)); + } + } + function insertAfter(ref, element) { + if(ref.nextSibling){ + can.insertBefore(ref.parentNode, element, ref.nextSibling); + } else { + can.appendChild(ref.parentNode, element); + } + } + + function render(renderer, scope, el) { + var frag = renderer(scope); + if( isIn(el,"head") ) { + can.appendChild(document.body, frag); + } else if(el.nodeName.toLowerCase() === "script") { + insertAfter(el, frag); + } else { + insertAfter(el, frag); + el.parentNode.removeChild(el); + } + } + function setupScope(el) { + var scope = can.viewModel(el); + + can.each(el.attributes||[], function(attr) { + setAttr(el, attr.name, scope); + }); + + can.bind.call(el, "attributes", function (ev) { + setAttr(el, ev.attributeName, scope); + }); + + return scope; + } + + function autoload(){ + var promises = []; + + can.each( can.$("[can-autorender]"), function( el, i){ + el.style.display = "none"; + + + var text = el.innerHTML || el.text, + typeAttr = el.getAttribute("type"), + typeInfo = typeAttr.match( typeMatch ), + type = typeInfo && typeInfo[1], + typeModule = "can/view/" + type; + + if(window.System || !(window.define && window.define.amd)) { + typeModule += "/" + type; + } + + promises.push( can["import"](typeModule).then(function(engine){ + + engine = can[type] || engine; + if(engine.async) { + return engine.async(text).then(function(renderer){ + render(renderer, setupScope(el), el); + }); + } else { + var renderer = engine(text); + render(renderer, setupScope(el), el); + } + + }) ); + + }); + + can.when.apply(can, promises).then( + can.proxy(deferred.resolve, deferred), + can.proxy(deferred.reject, deferred) + ); + } + + if (document.readyState === 'complete') { + autoload(); + } else { + can.bind.call(window, 'load', autoload); + } + + var promise = deferred.promise(); + can.autorender = function(success, error){ + return promise.then(success, error); + }; + return can.autorender; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/bindings/bindings.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/bindings/bindings.js new file mode 100644 index 0000000000..8224338a4c --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/bindings/bindings.js @@ -0,0 +1,477 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/bindings/bindings*/ +// # can/view/bindings/bindings.js +// +// This file defines the `can-value` attribute for two-way bindings and the `can-EVENT` attribute +// for in template event bindings. These are usable in any mustache template, but mainly and documented +// for use within can.Component. +steal("can/util", "can/view/stache/mustache_core.js", "can/view/callbacks", "can/control", "can/view/scope", function (can, mustacheCore) { + /** + * @function isContentEditable + * @hide + * + * Determines if an element is contenteditable. + * + * An element is contenteditable if it contains the `contenteditable` + * attribute set to either an empty string or "true". + * + * By default an element is also contenteditable if its immediate parent + * has a truthy version of the attribute, unless the element is explicitly + * set to "false". + * + * @param {HTMLElement} el + * @return {Boolean} returns if the element is editable + */ + // Function for determining of an element is contenteditable + var isContentEditable = (function(){ + // A contenteditable element has a value of an empty string or "true" + var values = { + "": true, + "true": true, + "false": false + }; + + // Tests if an element has the appropriate contenteditable attribute + var editable = function(el){ + // DocumentFragments do not have a getAttribute + if(!el || !el.getAttribute) { + return; + } + + var attr = el.getAttribute("contenteditable"); + return values[attr]; + }; + + return function (el){ + // First check if the element is explicitly true or false + var val = editable(el); + if(typeof val === "boolean") { + return val; + } else { + // Otherwise, check the parent + return !!editable(el.parentNode); + } + }; + })(), + removeCurly = function(value){ + if(value[0] === "{" && value[value.length-1] === "}") { + return value.substr(1, value.length - 2); + } + return value; + }; + + // ## can-value + // Implement the `can-value` special attribute + // + // ### Usage + // + // + // + // When a view engine finds this attribute, it will call this callback. The value of the attribute + // should be a string representing some value in the current scope to cross-bind to. + can.view.attr("can-value", function (el, data) { + + var attr = can.trim(removeCurly(el.getAttribute("can-value"))), + // Turn the attribute passed in into a compute. If the user passed in can-value="name" and the current + // scope of the template is some object called data, the compute representing this can-value will be the + // data.attr('name') property. + value = data.scope.computeData(attr, { + args: [] + }) + .compute, + trueValue, + falseValue; + + // Depending on the type of element, this attribute has different behavior. can.Controls are defined (further below + // in this file) for each type of input. This block of code collects arguments and instantiates each can.Control. There + // is one for checkboxes/radios, another for multiselect inputs, and another for everything else. + if (el.nodeName.toLowerCase() === "input") { + if (el.type === "checkbox") { + // If the element is a checkbox and has an attribute called "can-true-value", + // set up a compute that toggles the value of the checkbox to "true" based on another attribute. + // + // + if (can.attr.has(el, "can-true-value")) { + trueValue = el.getAttribute("can-true-value"); + } else { + trueValue = true; + } + if (can.attr.has(el, "can-false-value")) { + falseValue = el.getAttribute("can-false-value"); + } else { + falseValue = false; + } + } + + if (el.type === "checkbox" || el.type === "radio") { + // For checkboxes and radio buttons, create a Checked can.Control around the input. Pass in + // the compute representing the can-value and can-true-value and can-false-value properties (if + // they were used). + new Checked(el, { + value: value, + trueValue: trueValue, + falseValue: falseValue + }); + return; + } + } + if (el.nodeName.toLowerCase() === "select" && el.multiple) { + // For multiselect enabled select inputs, we instantiate a special control around that select element + // called Multiselect + new Multiselect(el, { + value: value + }); + return; + } + // For contenteditable elements, we instantiate a Content control. + if (isContentEditable(el)) { + new Content(el, { + value: value + }); + return; + } + // The default case. Instantiate the Value control around the element. Pass it the compute representing + // the observable attribute property that was set. + new Value(el, { + value: value + }); + }); + + // ## Special Event Types (can-SPECIAL) + + // A special object, similar to [$.event.special](http://benalman.com/news/2010/03/jquery-special-events/), + // for adding hooks for special can-SPECIAL types (not native DOM events). Right now, only can-enter is + // supported, but this object might be exported so that it can be added to easily. + // + // To implement a can-SPECIAL event type, add a property to the special object, whose value is a function + // that returns the following: + // + // // the real event name to bind to + // event: "event-name", + // handler: function (ev) { + // // some logic that figures out if the original handler should be called or not, and if so... + // return original.call(this, ev); + // } + var special = { + enter: function (data, el, original) { + return { + event: "keyup", + handler: function (ev) { + if (ev.keyCode === 13) { + return original.call(this, ev); + } + } + }; + } + }; + + // ## can-EVENT + // The following section contains code for implementing the can-EVENT attribute. + // This binds on a wildcard attribute name. Whenever a view is being processed + // and can-xxx (anything starting with can-), this callback will be run. Inside, its setting up an event handler + // that calls a method identified by the value of this attribute. + can.view.attr(/can-[\w\.]+/, function (el, data) { + + // the attribute name is the function to call + var attributeName = data.attributeName, + // The event type to bind on is deteremined by whatever is after can- + // + // For example, can-submit binds on the submit event. + event = attributeName.substr("can-".length), + // This is the method that the event will initially trigger. It will look up the method by the string name + // passed in the attribute and call it. + handler = function (ev) { + var attrVal = el.getAttribute(attributeName); + if (!attrVal) { return; } + // mustacheCore.expressionData will read the attribute + // value and parse it identically to how mustache helpers + // get parsed. + var attrInfo = mustacheCore.expressionData(removeCurly(attrVal)); + + // We grab the first item and treat it as a method that + // we'll call. + var scopeData = data.scope.read(attrInfo.name.get, { + returnObserveMethods: true, + isArgument: true, + executeAnonymousFunctions: true + }); + + // We break out early if the first argument isn't available + // anywhere. + + //!steal-remove-start + if (!scopeData.value) { + can.dev.warn("can/view/bindings: " + attributeName + " couldn't find method named " + attrInfo.name.get, { + element: el, + scope: data.scope + }); + return null; + } + //!steal-remove-end + + var args = []; + var $el = can.$(this); + var viewModel = can.viewModel($el[0]); + var localScope = data.scope.add({ + "@element": $el, + "@event": ev, + "@viewModel": viewModel, + "@scope": data.scope, + "@context": data.scope._context + }); + + // .expressionData() gives us a hash object representing + // any expressions inside the definition that look like + // foo=bar. If there's no hash keys, we'll omit this hash + // from our method arguments. + if (!can.isEmptyObject(attrInfo.hash)) { + var hash = {}; + can.each(attrInfo.hash, function(val, key) { + if (val && val.hasOwnProperty("get")) { + var s = !val.get.indexOf("@") ? localScope : data.scope; + hash[key] = s.read(val.get, {}).value; + } else { + hash[key] = val; + } + }); + args.unshift(hash); + } + + // We go through each non-hash expression argument and + // prepend it to our argument list. + if (attrInfo.args.length) { + var arg; + for (var i = attrInfo.args.length-1; i >= 0; i--) { + arg = attrInfo.args[i]; + if (arg && arg.hasOwnProperty("get")) { + var s = !arg.get.indexOf("@") ? localScope : data.scope; + args.unshift(s.read(arg.get, {}).value); + } else { + args.unshift(arg); + } + } + } + // If no arguments are provided, the method will simply + // receive the legacy arguments. + if (!args.length) { + // The arguments array includes extra args passed in to + // the event. + args = [data.scope._context, $el].concat(can.makeArray(arguments)); + } + return scopeData.value.apply(scopeData.parent, args); + }; + + // This code adds support for special event types, like can-enter="foo". special.enter (or any special[event]) is + // a function that returns an object containing an event and a handler. These are to be used for binding. For example, + // when a user adds a can-enter attribute, we'll bind on the keyup event, and the handler performs special logic to + // determine on keyup if the enter key was pressed. + if (special[event]) { + var specialData = special[event](data, el, handler); + handler = specialData.handler; + event = specialData.event; + } + // Bind the handler defined above to the element we're currently processing and the event name provided in this + // attribute name (can-click="foo") + can.bind.call(el, event, handler); + }); + + + // ## Two way binding can.Controls + // Each type of input that is supported by view/bindings is wrapped with a special can.Control. The control serves + // two functions: + // 1. Bind on the property changing (the compute we're two-way binding to) and change the input value. + // 2. Bind on the input changing and change the property (compute) we're two-way binding to. + // There is one control per input type. There could easily be more for more advanced input types, like the HTML5 type="date" input type. + + + // ### Value + // A can.Control that manages the two-way bindings on most inputs. When can-value is found as an attribute + // on an input, the callback above instantiates this Value control on the input element. + var Value = can.Control.extend({ + init: function () { + // Handle selects by calling `set` after this thread so the rest of the element can finish rendering. + if (this.element[0].nodeName.toUpperCase() === "SELECT") { + setTimeout(can.proxy(this.set, this), 1); + } else { + this.set(); + } + + }, + // If the live bound data changes, call set to reflect the change in the dom. + "{value} change": "set", + set: function () { + // This may happen in some edgecases, esp. with selects that are not in DOM after the timeout has fired + if (!this.element) { + return; + } + var val = this.options.value(); + // Set the element's value to match the attribute that was passed in + this.element[0].value = (val == null ? '' : val); + }, + // If the input value changes, this will set the live bound data to reflect the change. + // If the input value changes, this will set the live bound data to reflect the change. + "change": function () { + // This may happen in some edgecases, esp. with selects that are not in DOM after the timeout has fired + if (!this.element) { + return; + } + var el = this.element[0]; + + // Set the value of the attribute passed in to reflect what the user typed + this.options.value(el.value); + var newVal = this.options.value(); + + // If the newVal isn't the same as the input, set it's value + if(el.value !== newVal) { + el.value = newVal; + } + } + }), + // ### Checked + // A can.Control that manages the two-way bindings on a checkbox element. When can-value is found as an attribute + // on a checkbox, the callback above instantiates this Checked control on the checkbox element. + Checked = can.Control.extend({ + init: function () { + // If its not a checkbox, its a radio input + this.isCheckbox = (this.element[0].type.toLowerCase() === "checkbox"); + this.check(); + }, + // `value` is the compute representing the can-value for this element. For example can-value="foo" and current + // scope is someObj, value is the compute representing someObj.attr('foo') + "{value} change": "check", + check: function () { + // jshint eqeqeq: false + if (this.isCheckbox) { + var value = this.options.value(), + trueValue = this.options.trueValue || true; + // If `can-true-value` attribute was set, check if the value is equal to that string value, and set + // the checked property based on their equality. + this.element[0].checked = (value == trueValue); + } + // Its a radio input type + else { + var setOrRemove = this.options.value() == this.element[0].value ? + "set" : "remove"; + + can.attr[setOrRemove](this.element[0], 'checked', true); + + } + + }, + // This event is triggered by the DOM. If a change event occurs, we must set the value of the compute (options.value). + "change": function () { + + if (this.isCheckbox) { + // If the checkbox is checked and can-true-value was used, set value to the string value of can-true-value. If + // can-false-value was used and checked is false, set value to the string value of can-false-value. + this.options.value(this.element[0].checked ? this.options.trueValue : this.options.falseValue); + } + // Radio input type + else { + if (this.element[0].checked) { + this.options.value(this.element[0].value); + } + } + + } + }), + // ### Multiselect + // A can.Control that handles select input with the "multiple" attribute (meaning more than one can be selected at once). + Multiselect = Value.extend({ + init: function () { + this.delimiter = ";"; + // Call `set` after this thread so the rest of the element can finish rendering. + setTimeout(can.proxy(this.set, this), 1); + }, + // Since this control extends Value (above), the set method will be called when the value compute changes (and on init). + set: function () { + + var newVal = this.options.value(); + + + // When given a string, try to extract all the options from it (i.e. "a;b;c;d") + if (typeof newVal === 'string') { + newVal = newVal.split(this.delimiter); + this.isString = true; + } + // When given something else, try to make it an array and deal with it + else if (newVal) { + newVal = can.makeArray(newVal); + } + + // Make an object containing all the options passed in for convenient lookup + var isSelected = {}; + can.each(newVal, function (val) { + isSelected[val] = true; + }); + + // Go through each <option/> element, if it has a value property (its a valid option), then + // set its selected property if it was in the list of vals that were just set. + can.each(this.element[0].childNodes, function (option) { + if (option.value) { + option.selected = !! isSelected[option.value]; + } + + }); + + }, + // A helper function used by the 'change' handler below. Its purpose is to return an array of selected + // values, like ["foo", "bar"] + get: function () { + var values = [], + children = this.element[0].childNodes; + + can.each(children, function (child) { + if (child.selected && child.value) { + values.push(child.value); + } + }); + + return values; + }, + // Called when the user changes this input in any way. + 'change': function () { + // Get an array of the currently selected values + var value = this.get(), + currentValue = this.options.value(); + + // If the compute is a string, set its value to the joined version of the values array (i.e. "foo;bar") + if (this.isString || typeof currentValue === "string") { + this.isString = true; + this.options.value(value.join(this.delimiter)); + } + // If the compute is a can.List, replace its current contents with the new array of values + else if (currentValue instanceof can.List) { + currentValue.attr(value, true); + } + // Otherwise set the value to the array of values selected in the input. + else { + this.options.value(value); + } + + } + }), + Content = can.Control.extend({ + init: function () { + this.set(); + this.on("blur", "setValue"); + }, + "{value} change": "set", + set: function () { + var val = this.options.value(); + this.element[0].innerHTML = (typeof val === 'undefined' ? '' : val); + }, + setValue: function () { + this.options.value(this.element[0].innerHTML); + } + }); + +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/callbacks/callbacks.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/callbacks/callbacks.js new file mode 100644 index 0000000000..6063e9cfef --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/callbacks/callbacks.js @@ -0,0 +1,112 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/callbacks/callbacks*/ +steal("can/util", "can/view",function(can){ + + + var attr = can.view.attr = function (attributeName, attrHandler) { + if(attrHandler) { + if (typeof attributeName === "string") { + attributes[attributeName] = attrHandler; + } else { + regExpAttributes.push({ + match: attributeName, + handler: attrHandler + }); + } + } else { + var cb = attributes[attributeName]; + if( !cb ) { + + for( var i = 0, len = regExpAttributes.length; i < len; i++) { + var attrMatcher = regExpAttributes[i]; + if(attrMatcher.match.test(attributeName)) { + cb = attrMatcher.handler; + break; + } + } + } + return cb; + } + }; + + var attributes = {}, + regExpAttributes = [], + automaticCustomElementCharacters = /[-\:]/; + + var tag = can.view.tag = function (tagName, tagHandler) { + if(tagHandler) { + //!steal-remove-start + if (typeof tags[tagName.toLowerCase()] !== 'undefined') { + can.dev.warn("Custom tag: " + tagName.toLowerCase() + " is already defined"); + } + //!steal-remove-end + // if we have html5shive ... re-generate + if (can.global.html5) { + can.global.html5.elements += " " + tagName; + can.global.html5.shivDocument(); + } + + tags[tagName.toLowerCase()] = tagHandler; + } else { + var cb = tags[tagName.toLowerCase()]; + if(!cb && automaticCustomElementCharacters.test(tagName)) { + // empty callback for things that look like special tags + cb = function(){}; + } + return cb; + } + + }; + var tags = {}; + + can.view.callbacks = { + _tags: tags, + _attributes: attributes, + _regExpAttributes: regExpAttributes, + tag: tag, + attr: attr, + // handles calling back a tag callback + tagHandler: function(el, tagName, tagData){ + var helperTagCallback = tagData.options.attr('tags.' + tagName), + tagCallback = helperTagCallback || tags[tagName]; + + // If this was an element like that doesn't have a component, just render its content + var scope = tagData.scope, + res; + + if(tagCallback) { + var reads = can.__clearReading(); + res = tagCallback(el, tagData); + can.__setReading(reads); + } else { + res = scope; + } + + //!steal-remove-start + if (!tagCallback) { + can.dev.warn('can/view/scanner.js: No custom element found for ' + tagName); + } + //!steal-remove-end + + // If the tagCallback gave us something to render with, and there is content within that element + // render it! + if (res && tagData.subtemplate) { + + if (scope !== res) { + scope = scope.add(res); + } + var result = tagData.subtemplate(scope, tagData.options); + var frag = typeof result === "string" ? can.view.frag(result) : result; + can.appendChild(el, frag); + } + } + }; + return can.view.callbacks; +}); diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/ejs/ejs.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/ejs/ejs.js new file mode 100644 index 0000000000..a22542f9f0 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/ejs/ejs.js @@ -0,0 +1,217 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/ejs/ejs*/ +// # can/view/ejs/ejs.js +// +// `can.EJS`: Embedded JavaScript Templates +// +steal('can/util', + 'can/view', + 'can/util/string', + 'can/compute', + 'can/view/scanner.js', + 'can/view/render.js', +function (can) { + // ## Helper methods + var extend = can.extend, + EJS = function (options) { + // Supports calling EJS without the constructor. + // This returns a function that renders the template. + if (this.constructor !== EJS) { + var ejs = new EJS(options); + return function (data, helpers) { + return ejs.render(data, helpers); + }; + } + // If we get a `function` directly, it probably is coming from + // a `steal`-packaged view. + if (typeof options === 'function') { + this.template = { + fn: options + }; + return; + } + // Set options on self. + extend(this, options); + this.template = this.scanner.scan(this.text, this.name); + }; + // Expose EJS via the `can` object. + can.EJS = EJS; + + EJS.prototype. + // ## Render + // Render a view object with data and helpers. + render = function (object, extraHelpers) { + object = object || {}; + return this.template.fn.call(object, object, new EJS.Helpers(object, extraHelpers || {})); + }; + extend(EJS.prototype, { + // ## Scanner + // Singleton scanner instance for parsing templates. See [scanner.js](scanner.html) + // for more information. + // + // ### Text + // + // #### Definitions + // + // * `outStart` - Wrapper start text for view function. + // + // * `outEnd` - Wrapper end text for view function. + // + // * `argNames` - Arguments passed into view function. + scanner: new can.view.Scanner({ + text: { + outStart: 'with(_VIEW) { with (_CONTEXT) {', + outEnd: "}}", + argNames: '_CONTEXT,_VIEW', + context: "this" + }, + // ### Tokens + // + // An ordered token registry for the scanner. Scanner makes evaluations + // based on which tags are considered opening/closing as well as escaped, etc. + tokens: [ + ["templateLeft", "<%%"], + ["templateRight", "%>"], + ["returnLeft", "<%=="], + ["escapeLeft", "<%="], + ["commentLeft", "<%#"], + ["left", "<%"], + ["right", "%>"], + ["returnRight", "%>"] + ], + // ### Helpers + helpers: [ + { + // Regex to see if its a func like `()->`. + name: /\s*\(([\$\w]+)\)\s*->([^\n]*)/, + // Evaluate rocket syntax function with correct context. + fn: function (content) { + var quickFunc = /\s*\(([\$\w]+)\)\s*->([^\n]*)/, + parts = content.match(quickFunc); + + return "can.proxy(function(__){var " + parts[1] + "=can.$(__);" + parts[2] + "}, this);"; + } + } + ], + // ### transform + // Transforms the EJS template to add support for shared blocks. + // Essentially, this breaks up EJS tags into multiple EJS tags + // if they contained unmatched brackets. + // + // For example, this doesn't work: + // + // `<% if (1) { %><% if (1) { %> hi <% } } %>` + // + // ...without isolated EJS blocks: + // + // `<% if (1) { %><% if (1) { %> hi <% } %><% } %>` + // + // The result of transforming: + // + // `<% if (1) { %><% %><% if (1) { %><% %> hi <% } %><% } %>` + transform: function (source) { + return source.replace(/<%([\s\S]+?)%>/gm, function (whole, part) { + var brackets = [], + foundBracketPair, i; + // Look for brackets (for removing self-contained blocks) + part.replace(/[{}]/gm, function (bracket, offset) { + brackets.push([ + bracket, + offset + ]); + }); + // Remove bracket pairs from the list of replacements + do { + foundBracketPair = false; + for (i = brackets.length - 2; i >= 0; i--) { + if (brackets[i][0] === '{' && brackets[i + 1][0] === '}') { + brackets.splice(i, 2); + foundBracketPair = true; + break; + } + } + } while (foundBracketPair); + // Unmatched brackets found, inject EJS tags + if (brackets.length >= 2) { + var result = ['<%'], + bracket, last = 0; + for (i = 0; bracket = brackets[i]; i++) { + result.push(part.substring(last, last = bracket[1])); + if (bracket[0] === '{' && i < brackets.length - 1 || bracket[0] === '}' && i > 0) { + result.push(bracket[0] === '{' ? '{ %><% ' : ' %><% }'); + } else { + result.push(bracket[0]); + } + ++last; + } + result.push(part.substring(last), '%>'); + return result.join(''); + } + // Otherwise return the original + else { + return '<%' + part + '%>'; + } + }); + } + }) + }); + + // ## Helpers + // + // In your EJS view you can then call the helper on an element tag: + // + // `
            >
            ` + EJS.Helpers = function (data, extras) { + this._data = data; + this._extras = extras; + extend(this, extras); + }; + + EJS.Helpers.prototype = { + // List allows for live binding a can.List easily within a template. + list: function (list, cb) { + can.each(list, function (item, i) { + cb(item, i, list); + }); + }, + // `each` iterates through a enumerated source(such as can.List or array) + // and sets up live binding when possible. + each: function (list, cb) { + // Normal arrays don't get live updated + if (can.isArray(list)) { + this.list(list, cb); + } else { + can.view.lists(list, cb); + } + } + }; + // Registers options for a `steal` build. + can.view.register({ + suffix: 'ejs', + script: function (id, src) { + return 'can.EJS(function(_CONTEXT,_VIEW) { ' + new EJS({ + text: src, + name: id + }) + .template.out + ' })'; + }, + renderer: function (id, text) { + return EJS({ + text: text, + name: id + }); + } + }); + can.ejs.Helpers = EJS.Helpers; + + + return can; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/ejs/system.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/ejs/system.js new file mode 100644 index 0000000000..15539e110d --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/ejs/system.js @@ -0,0 +1,30 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/ejs/system*/ +"format steal"; +steal("can/view/ejs", function(can){ + + function translate(load) { + return "define(['can/view/ejs/ejs'],function(can){" + + "return can.view.preloadStringRenderer('" + load.metadata.pluginArgument + "'," + + 'can.EJS(function(_CONTEXT,_VIEW) { ' + new can.EJS({ + text: load.source, + name: load.name + }) + .template.out + ' })' + + ")" + + "})"; + } + + return { + translate: translate + }; + +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/elements.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/elements.js new file mode 100644 index 0000000000..0822bf0865 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/elements.js @@ -0,0 +1,152 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/elements*/ +steal('can/util', "can/view",function (can) { + + var doc = typeof document !== "undefined" ? document: null; + + var selectsCommentNodes = doc && (function(){ + return can.$(document.createComment('~')).length === 1; + })(); + + /** + * @property {Object} can.view.elements + * @parent can.view + * + * Provides helper methods for and information about the behavior + * of DOM elements. + */ + var elements = { + tagToContentPropMap: { + option: ( doc && "textContent" in document.createElement("option") ) ? "textContent" : "innerText", + textarea: 'value' + }, + /** + * @property {Object.} can.view.elements.attrMap + * @parent can.view.elements + * + * + * A mapping of + * special attributes to their JS property. For example: + * + * "class" : "className" + * + * means get or set `element.className`. And: + * + * "checked" : true + * + * means set `element.checked = true`. + * + * + * If the attribute name is not found, it's assumed to use + * `element.getAttribute` and `element.setAttribute`. + */ + // 3.0 TODO: remove + attrMap: can.attr.map, + // matches the attrName of a regexp + attrReg: /([^\s=]+)[\s]*=[\s]*/, + // 3.0 TODO: remove + defaultValue: can.attr.defaultValue, + // a map of parent element to child elements + /** + * @property {Object.} can.view.elements.tagMap + * @parent can.view.elements + * + * A mapping of parent node names to child node names that can be inserted within + * the parent node name. For example: `table: "tbody"` means that + * if you want a placeholder element within a `table`, a `tbody` will be + * created. + */ + tagMap: { + '': 'span', + colgroup: 'col', + table: 'tbody', + tr: 'td', + ol: 'li', + ul: 'li', + tbody: 'tr', + thead: 'tr', + tfoot: 'tr', + select: 'option', + optgroup: 'option' + }, + // a tag's parent element + reverseTagMap: { + col: 'colgroup', + tr: 'tbody', + option: 'select', + td: 'tr', + th: 'tr', + li: 'ul' + }, + // Used to determine the parentNode if el is directly within a documentFragment + getParentNode: function (el, defaultParentNode) { + return defaultParentNode && el.parentNode.nodeType === 11 ? defaultParentNode : el.parentNode; + }, + // 3.0 TODO: remove + setAttr: can.attr.set, + // 3.0 TODO: remove + getAttr: can.attr.get, + // 3.0 TODO: remove + removeAttr: can.attr.remove, + // Gets a "pretty" value for something + contentText: function (text) { + if (typeof text === 'string') { + return text; + } + // If has no value, return an empty string. + if (!text && text !== 0) { + return ''; + } + return '' + text; + }, + /** + * @function can.view.elements.after + * @parent can.view.elements + * + * Inserts newFrag after oldElements. + * + * @param {Array.} oldElements + * @param {DocumentFragment} newFrag + */ + after: function (oldElements, newFrag) { + var last = oldElements[oldElements.length - 1]; + // Insert it in the `document` or `documentFragment` + if (last.nextSibling) { + can.insertBefore(last.parentNode, newFrag, last.nextSibling); + } else { + can.appendChild(last.parentNode, newFrag); + } + }, + /** + * @function can.view.elements.replace + * @parent can.view.elements + * + * Replaces `oldElements` with `newFrag` + * + * @param {Array.} oldElements + * @param {DocumentFragment} newFrag + */ + replace: function (oldElements, newFrag) { + elements.after(oldElements, newFrag); + if(can.remove(can.$(oldElements)).length < oldElements.length && !selectsCommentNodes) { + can.each(oldElements, function(el) { + if(el.nodeType === 8) { + el.parentNode.removeChild(el); + } + }); + } + } + }; + + can.view.elements = elements; + + return elements; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/live/live.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/live/live.js new file mode 100644 index 0000000000..a9d2bd3682 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/live/live.js @@ -0,0 +1,687 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/live/live*/ +steal('can/util', 'can/view/elements.js', 'can/view', 'can/view/node_lists', 'can/view/parser',function (can, elements, view, nodeLists, parser) { + + elements = elements || can.view.elements; + nodeLists = nodeLists || can.view.NodeLists; + parser = parser || can.view.parser; + + // ## live.js + // + // The live module provides live binding for computes + // and can.List. + // + // Currently, it's API is designed for `can/view/render`, but + // it could easily be used for other purposes. + // ### Helper methods + // + // #### setup + // + // `setup(HTMLElement, bind(data), unbind(data)) -> data` + // + // Calls bind right away, but will call unbind + // if the element is "destroyed" (removed from the DOM). + var setup = function (el, bind, unbind) { + // Removing an element can call teardown which + // unregister the nodeList which calls teardown + var tornDown = false, + teardown = function () { + if (!tornDown) { + tornDown = true; + unbind(data); + can.unbind.call(el, 'removed', teardown); + } + return true; + }, data = { + teardownCheck: function (parent) { + return parent ? false : teardown(); + } + }; + can.bind.call(el, 'removed', teardown); + bind(data); + return data; + }, + // #### listen + // Calls setup, but presets bind and unbind to + // operate on a compute + listen = function (el, compute, change) { + return setup(el, function () { + compute.bind('change', change); + }, function (data) { + compute.unbind('change', change); + if (data.nodeList) { + nodeLists.unregister(data.nodeList); + } + }); + }, + // #### getAttributeParts + // Breaks up a string like foo='bar' into ["foo","'bar'""] + getAttributeParts = function (newVal) { + var attrs = {}, + attr; + parser.parseAttrs(newVal,{ + attrStart: function(name){ + attrs[name] = ""; + attr = name; + }, + attrValue: function(value){ + attrs[attr] += value; + }, + attrEnd: function(){} + }); + return attrs; + }, + splice = [].splice, + isNode = function(obj){ + return obj && obj.nodeType; + }, + addTextNodeIfNoChildren = function(frag){ + if(!frag.childNodes.length) { + frag.appendChild(document.createTextNode("")); + } + }; + /** + * @property {Object} can.view.live + * @parent can.view.static + * @release 2.0.4 + * + * Setup live-binding between the DOM and a compute manually. + * + * @option {Object} An object with the live-binding methods: + * [can.view.live.html], [can.view.live.list], [can.view.live.text], + * [can.view.live.attr] and [can.view.live.attrs]. + * + * @body + * + * ## Use + * + * `can.view.live` is an object with utlitiy methods for setting up + * live-binding in relation to different parts of the DOM and DOM elements. For + * example, to make an `

            `'s text stay live with + * a compute: + * + * var text = can.compute("Hello World"); + * var textNode = $("h2").text(" ")[0].childNodes[0]; + * can.view.live.text(textNode, text); + * + * + */ + var live = { + /** + * @function can.view.live.list + * @parent can.view.live + * @release 2.0.4 + * + * Live binds a compute's [can.List] incrementally. + * + * + * @param {HTMLElement} el An html element to replace with the live-section. + * + * @param {can.compute|can.List} list A [can.List] or [can.compute] whose value is a [can.List]. + * + * @param {function(this:*,*,index):String} render(index, index) A function that when called with + * the incremental item to render and the index of the item in the list. + * + * @param {Object} context The `this` the `render` function will be called with. + * + * @param {HTMLElement} [parentNode] An overwritable parentNode if `el`'s parent is + * a documentFragment. + * + * ## Use + * + * `can.view.live.list` is used to setup incremental live-binding. + * + * // a compute that change's it's list + * var todos = can.compute(function(){ + * return new Todo.List({page: can.route.attr("page")}) + * }) + * + * var placeholder = document.createTextNode(" ") + * $("ul#todos").append(placeholder) + * + * + * + * can.view.live.list( + * placeholder, + * todos, + * function(todo, index){ + * return "
          • "+todo.attr("name")+"
          • " + * }) + * + */ + list: function (el, compute, render, context, parentNode, nodeList) { + // A nodeList of all elements this live-list manages. + // This is here so that if this live list is within another section + // that section is able to remove the items in this list. + var masterNodeList = nodeList || [el], + // A mapping of items to their indicies' + indexMap = [], + // True once all previous events have been fired + afterPreviousEvents = false, + // Indicates that we should not be responding to changes in the list. + // It's possible that the compute change causes this list behavior to be torn down. + // However that same "change" dispatch will eventually fire the updateList handler because + // the list of "change" handlers is copied when dispatching starts. + // A 'perfect' fix would be to use linked lists for event handlers. + isTornDown = false, + // Called when items are added to the list. + add = function (ev, items, index) { + if (!afterPreviousEvents) { + return; + } + // Collect new html and mappings + var frag = document.createDocumentFragment(), + newNodeLists = [], + newIndicies = []; + // For each new item, + can.each(items, function (item, key) { + var itemNodeList = []; + + if(nodeList) { + nodeLists.register(itemNodeList,null, true); + } + + var itemIndex = can.compute(key + index), + // get its string content + itemHTML = render.call(context, item, itemIndex, itemNodeList), + gotText = typeof itemHTML === "string", + // and convert it into elements. + itemFrag = can.frag(itemHTML); + // Add those elements to the mappings. + + itemFrag = gotText ? can.view.hookup(itemFrag) : itemFrag; + + var childNodes = can.makeArray(itemFrag.childNodes); + if(nodeList) { + nodeLists.update(itemNodeList, childNodes); + newNodeLists.push(itemNodeList); + } else { + newNodeLists.push(nodeLists.register(childNodes)); + } + + + // Hookup the fragment (which sets up child live-bindings) and + // add it to the collection of all added elements. + frag.appendChild(itemFrag); + // track indicies; + newIndicies.push(itemIndex); + }); + // The position of elements is always after the initial text placeholder node + var masterListIndex = index+1; + + + // Check if we are adding items at the end + if (!masterNodeList[masterListIndex]) { + elements.after(masterListIndex === 1 ? [text] : [nodeLists.last(masterNodeList[masterListIndex - 1])], frag); + } else { + // Add elements before the next index's first element. + var el = nodeLists.first(masterNodeList[masterListIndex]); + can.insertBefore(el.parentNode, frag, el); + } + splice.apply(masterNodeList, [ + masterListIndex, + 0 + ].concat(newNodeLists)); + + // update indices after insert point + splice.apply(indexMap, [ + index, + 0 + ].concat(newIndicies)); + + for (var i = index + newIndicies.length, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + }, + // Called when items are removed or when the bindings are torn down. + remove = function (ev, items, index, duringTeardown, fullTeardown) { + if (!afterPreviousEvents) { + return; + } + // If this is because an element was removed, we should + // check to make sure the live elements are still in the page. + // If we did this during a teardown, it would cause an infinite loop. + if (!duringTeardown && data.teardownCheck(text.parentNode)) { + return; + } + if(index < 0) { + index = indexMap.length + index; + } + + var removedMappings = masterNodeList.splice(index + 1, items.length), + itemsToRemove = []; + can.each(removedMappings, function (nodeList) { + + // Unregister to free up event bindings. + var nodesToRemove = nodeLists.unregister(nodeList); + + // add items that we will remove all at once + [].push.apply(itemsToRemove, nodesToRemove); + }); + // update indices after remove point + indexMap.splice(index, items.length); + for (var i = index, len = indexMap.length; i < len; i++) { + indexMap[i](i); + } + // don't remove elements during teardown. Something else will probably be doing that. + if(!fullTeardown) { + can.remove(can.$(itemsToRemove)); + } else { + nodeLists.unregister(masterNodeList); + } + + }, + move = function (ev, item, newIndex, currentIndex) { + if (!afterPreviousEvents) { + return; + } + // The position of elements is always after the initial text + // placeholder node + newIndex = newIndex + 1; + currentIndex = currentIndex + 1; + + var referenceNodeList = masterNodeList[newIndex]; + var movedElements = can.frag( nodeLists.flatten(masterNodeList[currentIndex]) ); + var referenceElement; + + // If we're moving forward in the list, we want to be placed before + // the item AFTER the target index since removing the item from + // the currentIndex drops the referenceItem's index. If there is no + // nextSibling, insertBefore acts like appendChild. + if (currentIndex < newIndex) { + referenceElement = nodeLists.last(referenceNodeList).nextSibling; + } else { + referenceElement = nodeLists.first(referenceNodeList); + } + + var parentNode = masterNodeList[0].parentNode; + + + // Move the DOM nodes into the proper location + parentNode.insertBefore(movedElements, referenceElement); + + // Now, do the same for the masterNodeList. We need to keep it + // in sync with the DOM. + + // Save a reference to the "node" in that we're manually moving + var temp = masterNodeList[currentIndex]; + + // Remove the movedItem from the masterNodeList + [].splice.apply(masterNodeList, [currentIndex, 1]); + + // Move the movedItem to the correct index in the masterNodeList + [].splice.apply(masterNodeList, [newIndex, 0, temp]); + }, + // A text node placeholder + text = document.createTextNode(''), + // The current list. + list, + // Called when the list is replaced with a new list or the binding is torn-down. + teardownList = function (fullTeardown) { + // there might be no list right away, and the list might be a plain + // array + if (list && list.unbind) { + list.unbind('add', add) + .unbind('remove', remove) + .unbind('move', move); + } + // use remove to clean stuff up for us + remove({}, { + length: masterNodeList.length - 1 + }, 0, true, fullTeardown); + }, + // Called when the list is replaced or setup. + updateList = function (ev, newList, oldList) { + if(isTornDown) { + return; + } + teardownList(); + // make an empty list if the compute returns null or undefined + list = newList || []; + + // list might be a plain array + if (list.bind) { + list.bind('add', add) + .bind('remove', remove) + .bind('move', move); + } + // temporarily allow add method. + afterPreviousEvents = true; + add({}, list, 0); + afterPreviousEvents = false; + + can.batch.afterPreviousEvents(function(){ + afterPreviousEvents = true; + }); + }; + parentNode = elements.getParentNode(el, parentNode); + // Setup binding and teardown to add and remove events + var data = setup(parentNode, function () { + // TODO: for stache, binding on the compute is not necessary. + if (can.isFunction(compute)) { + compute.bind('change', updateList); + } + }, function () { + if (can.isFunction(compute)) { + compute.unbind('change', updateList); + } + teardownList(true); + }); + + if(!nodeList) { + live.replace(masterNodeList, text, data.teardownCheck); + } else { + elements.replace(masterNodeList, text); + nodeLists.update(masterNodeList, [text]); + nodeList.unregistered = function(){ + data.teardownCheck(); + isTornDown = true; + }; + } + + // run the list setup + updateList({}, can.isFunction(compute) ? compute() : compute); + }, + /** + * @function can.view.live.html + * @parent can.view.live + * @release 2.0.4 + * + * Live binds a compute's value to a collection of elements. + * + * + * @param {HTMLElement} el An html element to replace with the live-section. + * + * @param {can.compute} compute A [can.compute] whose value is HTML. + * + * @param {HTMLElement} [parentNode] An overwritable parentNode if `el`'s parent is + * a documentFragment. + * + * ## Use + * + * `can.view.live.html` is used to setup incremental live-binding. + * + * // a compute that change's it's list + * var greeting = can.compute(function(){ + * return "Welcome "+me.attr("name")+"" + * }); + * + * var placeholder = document.createTextNode(" "); + * $("#greeting").append(placeholder); + * + * can.view.live.html( placeholder, greeting ); + * + */ + html: function (el, compute, parentNode, nodeList) { + var data; + parentNode = elements.getParentNode(el, parentNode); + data = listen(parentNode, compute, function (ev, newVal, oldVal) { + + // TODO: remove teardownCheck in 2.1 + var attached = nodeLists.first(nodes).parentNode; + // update the nodes in the DOM with the new rendered value + if (attached) { + makeAndPut(newVal); + } + data.teardownCheck(nodeLists.first(nodes).parentNode); + }); + + var nodes = nodeList || [el], + makeAndPut = function (val) { + var isFunction = typeof val === "function", + aNode = isNode(val), + frag = can.frag(isFunction ? "" : val), + oldNodes = can.makeArray(nodes); + + // Add a placeholder textNode if necessary. + addTextNodeIfNoChildren(frag); + + if(!aNode && !isFunction){ + frag = can.view.hookup(frag, parentNode); + } + + // We need to mark each node as belonging to the node list. + oldNodes = nodeLists.update(nodes, frag.childNodes); + if(isFunction) { + val(frag.childNodes[0]); + } + elements.replace(oldNodes, frag); + + }; + + data.nodeList = nodes; + + // register the span so nodeLists knows the parentNodeList + if(!nodeList) { + nodeLists.register(nodes, data.teardownCheck); + } else { + nodeList.unregistered = data.teardownCheck; + } + makeAndPut(compute()); + }, + /** + * @function can.view.live.replace + * @parent can.view.live + * @release 2.0.4 + * + * Replaces one element with some content while keeping [can.view.live.nodeLists nodeLists] data + * correct. + * + * @param {Array.} nodes An array of elements. There should typically be one element. + * @param {String|HTMLElement|DocumentFragment} val The content that should replace + * `nodes`. If a string is passed, it will be [can.view.hookup hookedup]. + * + * @param {function} [teardown] A callback if these elements are torn down. + */ + replace: function (nodes, val, teardown) { + var oldNodes = nodes.slice(0), + frag = can.frag(val); + nodeLists.register(nodes, teardown); + + + if (typeof val === 'string') { + // if it was a string, check for hookups + frag = can.view.hookup(frag, nodes[0].parentNode); + } + // We need to mark each node as belonging to the node list. + nodeLists.update(nodes, frag.childNodes); + elements.replace(oldNodes, frag); + return nodes; + }, + /** + * @function can.view.live.text + * @parent can.view.live + * @release 2.0.4 + * + * Replaces one element with some content while keeping [can.view.live.nodeLists nodeLists] data + * correct. + */ + text: function (el, compute, parentNode, nodeList) { + var parent = elements.getParentNode(el, parentNode); + // setup listening right away so we don't have to re-calculate value + var data = listen(parent, compute, function (ev, newVal, oldVal) { + // Sometimes this is 'unknown' in IE and will throw an exception if it is + /* jshint ignore:start */ + if (typeof node.nodeValue !== 'unknown') { + node.nodeValue = can.view.toStr(newVal); + } + /* jshint ignore:end */ + // TODO: remove in 2.1 + data.teardownCheck(node.parentNode); + }); + // The text node that will be updated + + var node = document.createTextNode(can.view.toStr(compute())); + if(nodeList) { + nodeList.unregistered = data.teardownCheck; + data.nodeList = nodeList; + + nodeLists.update(nodeList, [node]); + elements.replace([el], node); + } else { + // Replace the placeholder with the live node and do the nodeLists thing. + // Add that node to nodeList so we can remove it when the parent element is removed from the page + data.nodeList = live.replace([el], node, data.teardownCheck); + } + + }, + setAttributes: function(el, newVal) { + var attrs = getAttributeParts(newVal); + for(var name in attrs) { + can.attr.set(el, name, attrs[name]); + } + }, + /** + * @function can.view.live.attrs + * @parent can.view.live + * + * Keep attributes live to a [can.compute]. + * + * @param {HTMLElement} el The element whos attributes will be kept live. + * @param {can.compute} compute The compute. + * + * @body + * + * ## Use + * + * var div = document.createElement('div'); + * var compute = can.compute("foo='bar' zed='ted'"); + * can.view.live.attr(div,compute); + * + */ + attributes: function (el, compute, currentValue) { + var oldAttrs = {}; + + var setAttrs = function (newVal) { + var newAttrs = getAttributeParts(newVal), + name; + for( name in newAttrs ) { + var newValue = newAttrs[name], + oldValue = oldAttrs[name]; + if(newValue !== oldValue) { + can.attr.set(el, name, newValue); + } + delete oldAttrs[name]; + } + for( name in oldAttrs ) { + elements.removeAttr(el, name); + } + oldAttrs = newAttrs; + }; + listen(el, compute, function (ev, newVal) { + setAttrs(newVal); + }); + // current value has been set + if (arguments.length >= 3) { + oldAttrs = getAttributeParts(currentValue); + } else { + setAttrs(compute()); + } + }, + attributePlaceholder: '__!!__', + attributeReplace: /__!!__/g, + attribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, hook.render()); + }); + var wrapped = can.$(el), + hooks; + // Get the list of hookups or create one for this element. + // Hooks is a map of attribute names to hookup `data`s. + // Each hookup data has: + // `render` - A `function` to render the value of the attribute. + // `funcs` - A list of hookup `function`s on that attribute. + // `batchNum` - The last event `batchNum`, used for performance. + hooks = can.data(wrapped, 'hooks'); + if (!hooks) { + can.data(wrapped, 'hooks', hooks = {}); + } + // Get the attribute value. + var attr = elements.getAttr(el, attributeName), + // Split the attribute value by the template. + // Only split out the first __!!__ so if we have multiple hookups in the same attribute, + // they will be put in the right spot on first render + parts = attr.split(live.attributePlaceholder), + goodParts = [], + hook; + goodParts.push(parts.shift(), parts.join(live.attributePlaceholder)); + // If we already had a hookup for this attribute... + if (hooks[attributeName]) { + // Just add to that attribute's list of `function`s. + hooks[attributeName].computes.push(compute); + } else { + // Create the hookup data. + hooks[attributeName] = { + render: function () { + var i = 0, + // attr doesn't have a value in IE + newAttr = attr ? attr.replace(live.attributeReplace, function () { + return elements.contentText(hook.computes[i++]()); + }) : elements.contentText(hook.computes[i++]()); + return newAttr; + }, + computes: [compute], + batchNum: undefined + }; + } + // Save the hook for slightly faster performance. + hook = hooks[attributeName]; + // Insert the value in parts. + goodParts.splice(1, 0, compute()); + + // Set the attribute. + elements.setAttr(el, attributeName, goodParts.join('')); + }, + specialAttribute: function (el, attributeName, compute) { + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, getValue(newVal)); + }); + elements.setAttr(el, attributeName, getValue(compute())); + }, + /** + * @function can.view.live.attr + * @parent can.view.live + * + * Keep an attribute live to a [can.compute]. + * + * @param {HTMLElement} el The element whos attribute will be kept live. + * @param {String} attributeName The attribute name. + * @param {can.compute} compute The compute. + * + * @body + * + * ## Use + * + * var div = document.createElement('div'); + * var compute = can.compute("foo bar"); + * can.view.live.attr(div,"class", compute); + */ + simpleAttribute: function(el, attributeName, compute){ + listen(el, compute, function (ev, newVal) { + elements.setAttr(el, attributeName, newVal); + }); + elements.setAttr(el, attributeName, compute()); + } + }; + live.attr = live.simpleAttribute; + live.attrs = live.attributes; + var newLine = /(\r|\n)+/g; + var getValue = function (val) { + var regexp = /^["'].*["']$/; + val = val.replace(elements.attrReg, '') + .replace(newLine, ''); + // check if starts and ends with " or ' + return regexp.test(val) ? val.substr(1, val.length - 2) : val; + }; + can.view.live = live; + + return live; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/modifiers/modifiers.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/modifiers/modifiers.js new file mode 100644 index 0000000000..c2026d7725 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/modifiers/modifiers.js @@ -0,0 +1,286 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/modifiers/modifiers*/ +steal('jquery', 'can/util', 'can/view', function ($, can) { + $ = $ || window.$; + + //---- ADD jQUERY HELPERS ----- + //converts jquery functions to use views + var convert, modify, isTemplate, isHTML, isDOM, getCallback, + // text and val cannot produce an element, so don't run hookups on them + noHookup = { + 'val': true, + 'text': true + }; + convert = function (func_name) { + // save the old jQuery helper + var old = $.fn[func_name]; + // replace it with our new helper + $.fn[func_name] = function () { + var args = can.makeArray(arguments), + callbackNum, callback, self = this, + result; + // if the first arg is a deferred + // wait until it finishes, and call + // modify with the result + if (can.isDeferred(args[0])) { + args[0].done(function (res) { + modify.call(self, [res], old); + }); + return this; + } //check if a template + else if (isTemplate(args)) { + // if we should operate async + if (callbackNum = getCallback(args)) { + callback = args[callbackNum]; + args[callbackNum] = function (result) { + modify.call(self, [result], old); + callback.call(self, result); + }; + can.view.apply(can.view, args); + return this; + } + // call view with args (there might be deferreds) + result = can.view.apply(can.view, args); + // if we got a string back + if (!can.isDeferred(result)) { + // we are going to call the old method with that string + args = [result]; + } else { + // if there is a deferred, wait until it is done before calling modify + result.done(function (res) { + modify.call(self, [res], old); + }); + return this; + } + } + return noHookup[func_name] ? old.apply(this, args) : modify.call(this, args, old); + }; + }; + // modifies the content of the element + // but also will run any hookup + modify = function (args, old) { + var res; + //check if there are new hookups + for (var hasHookups in can.view.hookups) { + break; + } + //if there are hookups, turn into a frag + // and insert that + // by using a frag, the element can be recursively hooked up + // before insterion + if (hasHookups && args[0] && isHTML(args[0])) { + args[0] = can.view.frag(args[0]) + .childNodes; + } + //then insert into DOM + res = old.apply(this, args); + return res; + }; + // returns true or false if the args indicate a template is being used + // $('#foo').html('/path/to/template.ejs',{data}) + // in general, we want to make sure the first arg is a string + // and the second arg is data + isTemplate = function (args) { + // save the second arg type + var secArgType = typeof args[1]; + // the first arg is a string + return typeof args[0] === "string" && + // the second arg is an object or function + (secArgType === 'object' || secArgType === 'function') && + // but it is not a dom element + !isDOM(args[1]); + }; + // returns true if the arg is a jQuery object or HTMLElement + isDOM = function (arg) { + return arg.nodeType || arg[0] && arg[0].nodeType; + }; + // returns whether the argument is some sort of HTML data + isHTML = function (arg) { + if (isDOM(arg)) { + // if jQuery object or DOM node we're good + return true; + } else if (typeof arg === 'string') { + // if string, do a quick sanity check that we're HTML + arg = can.trim(arg); + return arg.substr(0, 1) === '<' && arg.substr(arg.length - 1, 1) === '>' && arg.length >= 3; + } else { + // don't know what you are + return false; + } + }; + //returns the callback arg number if there is one (for async view use) + getCallback = function (args) { + return typeof args[3] === 'function' ? 3 : typeof args[2] === 'function' && 2; + }; + /** + * @function jQuery.fn.hookup + * @parent can.view.modifiers + * Called on a jQuery collection that was rendered with can.View with pending hookups. can.View can render a + * template with hookups, but not actually perform the hookup, because it returns a string without actual DOM + * elements to hook up to. So hookup performs the hookup and clears the pending hookups, preventing errors in + * future templates. + * + * ``` + * $(can.View('//views/recipes.ejs',recipeData)).hookup() + * ``` + */ + $.fn.hookup = function () { + can.view.frag(this); + return this; + }; + can.each([ + /** + * @function jQuery.fn.prepend + * @parent can.view.modifiers + * + * Extending the original [http://api.jquery.com/prepend/ jQuery().prepend()] + * to render [can.view] templates inserted at the beginning of each element in the set of matched elements. + * + * $('#test').prepend('path/to/template.ejs', { name : 'canjs' }); + * + * @param {String|Object|Function} content A template filename or the id of a view script tag + * or a DOM element, array of elements, HTML string, or can object. + * @param {Object} [data] The data to render the view with. + * If rendering a view template this parameter always has to be present + * (use the empty object initializer {} for no data). + * @param {Function} [callback] A success callback to load the view asynchronously + * + * @return {jQuery|can.Deferred} The jQuery object or a [can.Deferred] if a deferred has + * been passed in data. + */ + "prepend", + /** + * @function jQuery.fn.append + * @parent can.view.modifiers + * + * Extending the original [http://api.jquery.com/append/ jQuery().append()] + * to render [can.view] templates inserted at the end of each element in the set of matched elements. + * + * $('#test').append('path/to/template.ejs', { name : 'canjs' }); + * + * @param {String|Object|Function} content A template filename or the id of a view script tag + * or a DOM element, array of elements, HTML string, or can object. + * @param {Object} [data] The data to render the view with. + * If rendering a view template this parameter always has to be present + * (use the empty object initializer {} for no data). + * @param {Function} [callback] A success callback to load the view asynchronously + * + * @return {jQuery|can.Deferred} The jQuery object or a [can.Deferred] if a deferred has + * been passed in data. + */ + "append", + /** + * @function jQuery.fn.after + * @parent can.view.modifiers + * + * Extending the original [http://api.jquery.com/after/ jQuery().after()] + * to render [can.view] templates inserted after each element in the set of matched elements. + * + * $('#test').after('path/to/template.ejs', { name : 'canjs' }); + * + * @param {String|Object|Function} content A template filename or the id of a view script tag + * or a DOM element, array of elements, HTML string, or can object. + * @param {Object} [data] The data to render the view with. + * If rendering a view template this parameter always has to be present + * (use the empty object initializer {} for no data). + * @param {Function} [callback] A success callback to load the view asynchronously + * + * @return {jQuery|can.Deferred} The jQuery object or a [can.Deferred] if a deferred has + * been passed in data. + */ + "after", + /** + * @function jQuery.fn.before + * @parent can.view.modifiers + * + * Extending the original [http://api.jquery.com/before/ jQuery().before()] + * to render [can.view] templates inserted before each element in the set of matched elements. + * + * $('#test').before('path/to/template.ejs', { name : 'canjs' }); + * + * @param {String|Object|Function} content A template filename or the id of a view script tag + * or a DOM element, array of elements, HTML string, or can object. + * @param {Object} [data] The data to render the view with. + * If rendering a view template this parameter always has to be present + * (use the empty object initializer {} for no data). + * @param {Function} [callback] A success callback to load the view asynchronously + * + * @return {jQuery|can.Deferred} The jQuery object or a [can.Deferred] if a deferred has + * been passed in data. + */ + "before", + /** + * @function jQuery.fn.text + * @parent can.view.modifiers + * + * Extending the original [http://api.jquery.com/text/ jQuery().text()] + * to render [can.View] templates as the content of each matched element. + * Unlike [jQuery.fn.html] jQuery.fn.text also works with XML, escaping the provided + * string as necessary. + * + * $('#test').text('path/to/template.ejs', { name : 'canjs' }); + * + * @param {String|Object|Function} content A template filename or the id of a view script tag + * or a DOM element, array of elements, HTML string, or can object. + * @param {Object} [data] The data to render the view with. + * If rendering a view template this parameter always has to be present + * (use the empty object initializer {} for no data). + * @param {Function} [callback] A success callback to load the view asynchronously + * + * @return {jQuery|can.Deferred} The jQuery object or a [can.Deferred] if a deferred has + * been passed in data. + */ + "text", + /** + * @function jQuery.fn.html + * @parent can.view.modifiers + * + * Extending the original [http://api.jquery.com/html/ jQuery().html()] + * to render [can.view] templates as the content of each matched element. + * + * $('#test').html('path/to/template.ejs', { name : 'canjs' }); + * + * @param {String|Object|Function} content A template filename or the id of a view script tag + * or a DOM element, array of elements, HTML string, or can object. + * @param {Object} [data] The data to render the view with. + * If rendering a view template this parameter always has to be present + * (use the empty object initializer {} for no data). + * @param {Function} [callback] A success callback to load the view asynchronously + * + * @return {jQuery|can.Deferred} The jQuery object or a [can.Deferred] if a deferred has + * been passed in data. + */ + "html", + /** + * @function jQuery.fn.replaceWith + * @parent can.view.modifiers + * + * Extending the original [http://api.jquery.com/replaceWith/ jQuery().replaceWith()] + * to render [can.view] templates replacing each element in the set of matched elements. + * + * $('#test').replaceWith('path/to/template.ejs', { name : 'canjs' }); + * + * @param {String|Object|Function} content A template filename or the id of a view script tag + * or a DOM element, array of elements, HTML string, or can object. + * @param {Object} [data] The data to render the view with. + * If rendering a view template this parameter always has to be present + * (use the empty object initializer {} for no data). + * @param {Function} [callback] A success callback to load the view asynchronously + * + * @return {jQuery|can.Deferred} The jQuery object or a [can.Deferred] if a deferred has + * been passed in data. + */ + "replaceWith", "val" + ], function (func) { + convert(func); + }); + return can; +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/mustache/mustache.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/mustache/mustache.js new file mode 100644 index 0000000000..a0f9597394 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/mustache/mustache.js @@ -0,0 +1,2263 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/mustache/mustache*/ +steal('can/util', + 'can/view/scope', + 'can/view', + 'can/view/scanner.js', + 'can/compute', + 'can/view/render.js', + 'can/view/bindings', + function (can) { + + // # mustache.js + // `can.Mustache`: The Mustache templating engine. + // + // See the [Transformation](#section-29) section within *Scanning Helpers* for a detailed explanation + // of the runtime render code design. The majority of the Mustache engine implementation + // occurs within the *Transformation* scanning helper. + + // ## Initialization + // + // Define the view extension. + can.view.ext = ".mustache"; + + // ### Setup internal helper variables and functions. + // + // An alias for the context variable used for tracking a stack of contexts. + // This is also used for passing to helper functions to maintain proper context. + var SCOPE = 'scope', + // An alias for the variable used for the hash object that can be passed + // to helpers via `options.hash`. + HASH = '___h4sh', + // An alias for the most used context stacking call. + CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options}', + // a context object used to incidate being special + SPECIAL_CONTEXT_OBJ = '{scope:' + SCOPE + ',options:options, special: true}', + // argument names used to start the function (used by scanner and steal) + ARG_NAMES = SCOPE + ",options", + + // matches arguments inside a {{ }} + argumentsRegExp = /((([^'"\s]+?=)?('.*?'|".*?"))|.*?)\s/g, + + // matches a literal number, string, null or regexp + literalNumberStringBooleanRegExp = /^(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false|null|undefined)|((.+?)=(('.*?'|".*?"|[0-9]+\.?[0-9]*|true|false)|(.+))))$/, + + // returns an object literal that we can use to look up a value in the current scope + makeLookupLiteral = function (type) { + return '{get:"' + type.replace(/"/g, '\\"') + '"}'; + }, + // returns if the object is a lookup + isLookup = function (obj) { + return obj && typeof obj.get === "string"; + }, + + /* + * Checks whether an object is like a can.Map. This takes into + * fact that can.route is can.Map like. + * @param {[can.Map]} observable + * @return {Boolean} returns if the object is observable like. + */ + isObserveLike = function (obj) { + return obj instanceof can.Map || (obj && !! obj._get); + }, + + /* + * Tries to determine if the object passed is an array. + * @param {Array} obj The object to check. + * @return {Boolean} returns if the object is an array. + */ + isArrayLike = function (obj) { + return obj && obj.splice && typeof obj.length === 'number'; + }, + // used to make sure .fn and .inverse are always called with a Scope like object + makeConvertToScopes = function (original, scope, options) { + var originalWithScope = function(ctx, opts){ + return original(ctx || scope, opts); + }; + return function (updatedScope, updatedOptions) { + if (updatedScope !== undefined && !(updatedScope instanceof can.view.Scope)) { + updatedScope = scope.add(updatedScope); + } + if (updatedOptions !== undefined && !(updatedOptions instanceof can.view.Options)) { + updatedOptions = options.add(updatedOptions); + } + return originalWithScope(updatedScope, updatedOptions || options); + }; + }; + + // ## Mustache + /** + * @hide + * The Mustache templating engine. + * @param {Object} options Configuration options + */ + var Mustache = function (options, helpers) { + // Support calling Mustache without the constructor. + // This returns a function that renders the template. + if (this.constructor !== Mustache) { + var mustache = new Mustache(options); + return function (data, options) { + return mustache.render(data, options); + }; + } + + // If we get a `function` directly, it probably is coming from + // a `steal`-packaged view. + if (typeof options === "function") { + this.template = { + fn: options + }; + return; + } + + // Set options on self. + can.extend(this, options); + this.template = this.scanner.scan(this.text, this.name); + }; + + /** + * @add can.MustacheConstructor + */ + // Put Mustache on the `can` object. + can.Mustache = can.global.Mustache = Mustache; + + /** + * @prototype + */ + Mustache.prototype. + /** + * @function can.MustacheConstructor.prototype.render render + * @parent can.MustacheConstructor.prototype + * @signature `mustache.render( data [, helpers] )` + * @param {Object} data Data to interpolate into the template. + * @return {String} The template with interpolated data, in string form. + * @hide + * + * @body + * Renders an object with view helpers attached to the view. + * + * new Mustache({text: "<%= message %>"}).render({ + * message: "foo" + * }) + */ + render = function (data, options) { + if (!(data instanceof can.view.Scope)) { + data = new can.view.Scope(data || {}); + } + if (!(options instanceof can.view.Options)) { + options = new can.view.Options(options || {}); + } + options = options || {}; + + return this.template.fn.call(data, data, options); + }; + + can.extend(Mustache.prototype, { + // Share a singleton scanner for parsing templates. + scanner: new can.view.Scanner({ + // A hash of strings for the scanner to inject at certain points. + text: { + // This is the logic to inject at the beginning of a rendered template. + // This includes initializing the `context` stack. + start: "", //"var "+SCOPE+"= this instanceof can.view.Scope? this : new can.view.Scope(this);\n", + scope: SCOPE, + options: ",options: options", + argNames: ARG_NAMES + }, + + // An ordered token registry for the scanner. + // This needs to be ordered by priority to prevent token parsing errors. + // Each token follows the following structure: + // + // [ + // // Which key in the token map to match. + // "tokenMapName", + // + // // A simple token to match, like "{{". + // "token", + // + // // Optional. A complex (regexp) token to match that + // // overrides the simple token. + // "[\\s\\t]*{{", + // + // // Optional. A function that executes advanced + // // manipulation of the matched content. This is + // // rarely used. + // function(content){ + // return content; + // } + // ] + tokens: [ + /** + * @function can.mustache.tags.escaped {{key}} + * + * @description Insert the value of the [can.mustache.key key] into the + * output of the template. + * + * @parent can.mustache.tags 0 + * + * @signature `{{key}}` + * + * @param {can.mustache.key} key A key that references one of the following: + * + * - A [can.mustache.registerHelper registered helper]. + * - A value within the current or parent + * [can.mustache.context context]. If the value is a function or [can.compute], the + * function's return value is used. + * + * @return {String|Function|*} + * + * After the key's value is found (and set to any function's return value), + * it is passed to [can.view.txt] as the result of a call to its `func` + * argument. There, if the value is a: + * + * - `null` or `undefined` - an empty string is inserted into the rendered template result. + * - `String` or `Number` - the value is inserted into the rendered template result. + * - `Function` - A [can.view.hook hookup] attribute or element is inserted so this function + * will be called back with the DOM element after it is created. + * + * @body + * + * ## Use + * + * `{{key}}` insert data into the template. It most commonly references + * values within the current [can.mustache.context context]. For example: + * + * Rendering: + * + *

            {{name}}

            + * + * With: + * + * {name: "Austin"} + * + * Results in: + * + *

            Austin

            + * + * If the key value is a String or Number, it is inserted into the template. + * If it is `null` or `undefined`, nothing is added to the template. + * + * + * ## Nested Properties + * + * Mustache supports nested paths, making it possible to + * look up properties nested deep inside the current context. For example: + * + * Rendering: + * + *

            {{book.author}}

            + * + * With: + * + * { + * book: { + * author: "Ernest Hemingway" + * } + * } + * + * Results in: + * + *

            Ernest Hemingway

            + * + * ## Looking up values in parent contexts + * + * Sections and block helpers can create their own contexts. If a key's value + * is not found in the current context, it will look up the key's value + * in parent contexts. For example: + * + * Rendering: + * + * {{#chapters}} + *
          • {{title}} - {{name}}
          • + * {{chapters}} + * + * With: + * + * { + * title: "The Book of Bitovi" + * chapters: [{name: "Breakdown"}] + * } + * + * Results in: + * + *
          • The Book of Bitovi - Breakdown
          • + * + * + */ + // Return unescaped + ["returnLeft", "{{{", "{{[{&]"], + // Full line comments + ["commentFull", "{{!}}", "^[\\s\\t]*{{!.+?}}\\n"], + /** + * @function can.mustache.tags.comment {{!key}} + * + * @parent can.mustache.tags 7 + * + * @description A comment that doesn't get inserted into the rendered result. + * + * @signature `{{!key}}` + * + * The comment tag operates similarly to a `` tag in HTML. It exists in your template but never shows up. + * + * @param {can.mustache.key} key Everything within this tag is completely ignored. + * @return {String} + * + */ + // Inline comments + ["commentLeft", "{{!", "(\\n[\\s\\t]*{{!|{{!)"], + /** + * @function can.mustache.tags.unescaped {{{key}}} + * + * @parent can.mustache.tags 1 + * + * @description Insert the unescaped value of the [can.mustache.key key] into the + * output of the template. + * + * @signature `{{{key}}}` + * + * Behaves just like [can.mustache.tags.escaped {{key}}] and [can.mustache.helpers.helper {{helper}}] but does not + * escape the result. + * + * @param {can.mustache.key} key A key that references a value within the current or parent + * context. If the value is a function or can.compute, the function's return value is used. + * @return {String|Function|*} + * + * + */ + // + /** + * @function can.mustache.tags.unescaped2 {{&key}} + * + * @parent can.mustache.tags 2 + * + * @description Insert the unescaped value of the [can.mustache.key key] into the + * output of the template. + * + * @signature `{{&key}}` + * + * The `{{&key}}` tag is an alias for [can.mustache.tags.unescaped {{{key}}}], behaving just + * like [can.mustache.tags.escaped {{key}}] and [can.mustache.helpers.helper {{helper}}] but does not + * escape the result. + * + * @param {can.mustache.key} key A key that references a value within the current or parent + * context. If the value is a function or can.compute, the function's return value is used. + * @return {String|Function|*} + * + */ + // Full line escapes + // This is used for detecting lines with only whitespace and an escaped tag + ["escapeFull", "{{}}", "(^[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}$)", + function (content) { + return { + before: /^\n.+?\n$/.test(content) ? '\n' : '', + content: content.match(/\{\{(.+?)\}\}/)[1] || '' + }; + } + ], + // Return escaped + ["escapeLeft", "{{"], + // Close return unescaped + ["returnRight", "}}}"], + // Close tag + ["right", "}}"] + ], + + // ## Scanning Helpers + // + // This is an array of helpers that transform content that is within escaped tags like `{{token}}`. These helpers are solely for the scanning phase; they are unrelated to Mustache/Handlebars helpers which execute at render time. Each helper has a definition like the following: + // + // { + // // The content pattern to match in order to execute. + // // Only the first matching helper is executed. + // name: /pattern to match/, + // + // // The function to transform the content with. + // // @param {String} content The content to transform. + // // @param {Object} cmd Scanner helper data. + // // { + // // insert: "insert command", + // // tagName: "div", + // // status: 0 + // // } + // fn: function(content, cmd) { + // return 'for text injection' || + // { raw: 'to bypass text injection' }; + // } + // } + helpers: [ + // ### Partials + // + // Partials begin with a greater than sign, like {{> box}}. + // + // Partials are rendered at runtime (as opposed to compile time), + // so recursive partials are possible. Just avoid infinite loops. + // + // For example, this template and partial: + // + // base.mustache: + //

            Names

            + // {{#names}} + // {{> user}} + // {{/names}} + // + // user.mustache: + // {{name}} + { + name: /^>[\s]*\w*/, + fn: function (content, cmd) { + // Get the template name and call back into the render method, + // passing the name and the current context. + var templateName = can.trim(content.replace(/^>\s?/, '')) + .replace(/["|']/g, ""); + return "can.Mustache.renderPartial('" + templateName + "'," + ARG_NAMES + ")"; + } + }, + + // ### Data Hookup + // + // This will attach the data property of `this` to the element + // its found on using the first argument as the data attribute + // key. + // + // For example: + // + //
          • + // + // then later you can access it like: + // + // can.$('#nameli').data('name'); + /** + * @function can.mustache.helpers.data {{data name}} + * @parent can.mustache.htags 7 + * @signature `{{data name}}` + * + * Adds the current [can.mustache.context context] to the + * element's [can.data]. + * + * @param {String} name The name of the data attribute to use for the + * context. + * + * @body + * + * ## Use + * + * It is common for you to want some data in the template to be available + * on an element. `{{data name}}` allows you to save the + * context so it can later be retrieved by [can.data] or + * `$.fn.data`. For example, + * + * The template: + * + *
              + *
            • {{name}}
            • + *
            + * + * Rendered with: + * + * document.body.appendChild( + * can.view.mustache(template,{ person: { name: 'Austin' } }); + * + * Retrieve the person data back with: + * + * $("#person").data("person") + * + */ + { + name: /^\s*data\s/, + fn: function (content, cmd) { + var attr = content.match(/["|'](.*)["|']/)[1]; + // return a function which calls `can.data` on the element + // with the attribute name with the current context. + return "can.proxy(function(__){" + + // "var context = this[this.length-1];" + + // "context = context." + STACKED + " ? context[context.length-2] : context; console.warn(this, context);" + + "can.data(can.$(__),'" + attr + "', this.attr('.')); }, " + SCOPE + ")"; + } + }, { + name: /\s*\(([\$\w]+)\)\s*->([^\n]*)/, + fn: function (content) { + var quickFunc = /\s*\(([\$\w]+)\)\s*->([^\n]*)/, + parts = content.match(quickFunc); + + //find + return "can.proxy(function(__){var " + parts[1] + "=can.$(__);with(" + SCOPE + ".attr('.')){" + parts[2] + "}}, this);"; + } + }, + // ### Transformation (default) + // + // This transforms all content to its interpolated equivalent, + // including calls to the corresponding helpers as applicable. + // This outputs the render code for almost all cases. + // + // #### Definitions + // + // * `context` - This is the object that the current rendering context operates within. + // Each nested template adds a new `context` to the context stack. + // * `stack` - Mustache supports nested sections, + // each of which add their own context to a stack of contexts. + // Whenever a token gets interpolated, it will check for a match against the + // last context in the stack, then iterate through the rest of the stack checking for matches. + // The first match is the one that gets returned. + // * `Mustache.txt` - This serializes a collection of logic, optionally contained within a section. + // If this is a simple interpolation, only the interpolation lookup will be passed. + // If this is a section, then an `options` object populated by the truthy (`options.fn`) and + // falsey (`options.inverse`) encapsulated functions will also be passed. This section handling + // exists to support the runtime context nesting that Mustache supports. + // * `Mustache.get` - This resolves an interpolation reference given a stack of contexts. + // * `options` - An object containing methods for executing the inner contents of sections or helpers. + // `options.fn` - Contains the inner template logic for a truthy section. + // `options.inverse` - Contains the inner template logic for a falsey section. + // `options.hash` - Contains the merged hash object argument for custom helpers. + // + // #### Design + // + // This covers the design of the render code that the transformation helper generates. + // + // ##### Pseudocode + // + // A detailed explanation is provided in the following sections, but here is some brief pseudocode + // that gives a high level overview of what the generated render code does (with a template similar to + // `"{{#a}}{{b.c.d.e.name}}{{/a}}" == "Phil"`). + // + // *Initialize the render code.* + // + // view = [] + // context = [] + // stack = fn { context.concat([this]) } + // + // *Render the root section.* + // + // view.push( "string" ) + // view.push( can.view.txt( + // + // *Render the nested section with `can.Mustache.txt`.* + // + // txt( + // + // *Add the current context to the stack.* + // + // stack(), + // + // *Flag this for truthy section mode.* + // + // "#", + // + // *Interpolate and check the `a` variable for truthyness using the stack with `can.Mustache.get`.* + // + // get( "a", stack() ), + // + // *Include the nested section's inner logic. + // The stack argument is usually the parent section's copy of the stack, + // but it can be an override context that was passed by a custom helper. + // Sections can nest `0..n` times -- **NESTCEPTION**.* + // + // { fn: fn(stack) { + // + // *Render the nested section (everything between the `{{#a}}` and `{{/a}}` tokens).* + // + // view = [] + // view.push( "string" ) + // view.push( + // + // *Add the current context to the stack.* + // + // stack(), + // + // *Flag this as interpolation-only mode.* + // + // null, + // + // *Interpolate the `b.c.d.e.name` variable using the stack.* + // + // get( "b.c.d.e.name", stack() ), + // ) + // view.push( "string" ) + // + // *Return the result for the nested section.* + // + // return view.join() + // }} + // ) + // )) + // view.push( "string" ) + // + // *Return the result for the root section, which includes all nested sections.* + // + // return view.join() + // + // ##### Initialization + // + // Each rendered template is started with the following initialization code: + // + // var ___v1ew = []; + // var ___c0nt3xt = []; + // ___c0nt3xt.__sc0pe = true; + // var __sc0pe = function(context, self) { + // var s; + // if (arguments.length == 1 && context) { + // s = !context.__sc0pe ? [context] : context; + // } else { + // s = context && context.__sc0pe + // ? context.concat([self]) + // : __sc0pe(context).concat([self]); + // } + // return (s.__sc0pe = true) && s; + // }; + // + // The `___v1ew` is the the array used to serialize the view. + // The `___c0nt3xt` is a stacking array of contexts that slices and expands with each nested section. + // The `__sc0pe` function is used to more easily update the context stack in certain situations. + // Usually, the stack function simply adds a new context (`self`/`this`) to a context stack. + // However, custom helpers will occasionally pass override contexts that need their own context stack. + // + // ##### Sections + // + // Each section, `{{#section}} content {{/section}}`, within a Mustache template generates a section + // context in the resulting render code. The template itself is treated like a root section, with the + // same execution logic as any others. Each section can have `0..n` nested sections within it. + // + // Here's an example of a template without any descendent sections. + // Given the template: `"{{a.b.c.d.e.name}}" == "Phil"` + // Would output the following render code: + // + // ___v1ew.push("\""); + // ___v1ew.push(can.view.txt(1, '', 0, this, function() { + // return can.Mustache.txt(__sc0pe(___c0nt3xt, this), null, + // can.Mustache.get("a.b.c.d.e.name", + // __sc0pe(___c0nt3xt, this)) + // ); + // })); + // ___v1ew.push("\" == \"Phil\""); + // + // The simple strings will get appended to the view. Any interpolated references (like `{{a.b.c.d.e.name}}`) + // will be pushed onto the view via `can.view.txt` in order to support live binding. + // The function passed to `can.view.txt` will call `can.Mustache.txt`, which serializes the object data by doing + // a context lookup with `can.Mustache.get`. + // + // `can.Mustache.txt`'s first argument is a copy of the context stack with the local context `this` added to it. + // This stack will grow larger as sections nest. + // + // The second argument is for the section type. This will be `"#"` for truthy sections, `"^"` for falsey, + // or `null` if it is an interpolation instead of a section. + // + // The third argument is the interpolated value retrieved with `can.Mustache.get`, which will perform the + // context lookup and return the approriate string or object. + // + // Any additional arguments, if they exist, are used for passing arguments to custom helpers. + // + // For nested sections, the last argument is an `options` object that contains the nested section's logic. + // + // Here's an example of a template with a single nested section. + // Given the template: `"{{#a}}{{b.c.d.e.name}}{{/a}}" == "Phil"` + // Would output the following render code: + // + // ___v1ew.push("\""); + // ___v1ew.push(can.view.txt(0, '', 0, this, function() { + // return can.Mustache.txt(__sc0pe(___c0nt3xt, this), "#", + // can.Mustache.get("a", __sc0pe(___c0nt3xt, this)), + // [{ + // _: function() { + // return ___v1ew.join(""); + // } + // }, { + // fn: function(___c0nt3xt) { + // var ___v1ew = []; + // ___v1ew.push(can.view.txt(1, '', 0, this, + // function() { + // return can.Mustache.txt( + // __sc0pe(___c0nt3xt, this), + // null, + // can.Mustache.get("b.c.d.e.name", + // __sc0pe(___c0nt3xt, this)) + // ); + // } + // )); + // return ___v1ew.join(""); + // } + // }] + // ) + // })); + // ___v1ew.push("\" == \"Phil\""); + // + // This is specified as a truthy section via the `"#"` argument. The last argument includes an array of helper methods used with `options`. + // These act similarly to custom helpers: `options.fn` will be called for truthy sections, `options.inverse` will be called for falsey sections. + // The `options._` function only exists as a dummy function to make generating the section nesting easier (a section may have a `fn`, `inverse`, + // or both, but there isn't any way to determine that at compilation time). + // + // Within the `fn` function is the section's render context, which in this case will render anything between the `{{#a}}` and `{{/a}}` tokens. + // This function has `___c0nt3xt` as an argument because custom helpers can pass their own override contexts. For any case where custom helpers + // aren't used, `___c0nt3xt` will be equivalent to the `__sc0pe(___c0nt3xt, this)` stack created by its parent section. The `inverse` function + // works similarly, except that it is added when `{{^a}}` and `{{else}}` are used. `var ___v1ew = []` is specified in `fn` and `inverse` to + // ensure that live binding in nested sections works properly. + // + // All of these nested sections will combine to return a compiled string that functions similar to EJS in its uses of `can.view.txt`. + // + // #### Implementation + { + name: /^.*$/, + fn: function (content, cmd) { + var mode = false, + result = { + content: "", + startTxt: false, + startOnlyTxt: false, + end: false + }; + + // Trim the content so we don't have any trailing whitespace. + content = can.trim(content); + + // Determine what the active mode is. + // + // * `#` - Truthy section + // * `^` - Falsey section + // * `/` - Close the prior section + // * `else` - Inverted section (only exists within a truthy/falsey section) + if (content.length && (mode = content.match(/^([#^/]|else$)/))) { + mode = mode[0]; + switch (mode) { + /** + * @function can.mustache.helpers.section {{#key}} + * @parent can.mustache.tags 3 + * + * @signature `{{#key}}BLOCK{{/key}}` + * + * Render blocks of text one or more times, depending + * on the value of the key in the current context. + * + * @param {can.mustache.key} key A key that references a value within the current or parent + * [can.mustache.context context]. If the value is a function or [can.compute], the + * function's return value is used. + * + * + * @return {String} + * + * Depending on the value's type, the following actions happen: + * + * - `Array` or [can.List] - the block is rendered for + * each item in the array. The [can.mustache.context context] is set to + * the item within each block rendering. + * - A `truthy` value - the block is rendered with the [can.mustache.context context] + * set to the value. + * - A `falsey` value - the block is not rendered. + * + * The rendered result of the blocks, block or an empty string is returned. + * + * @body + * + * Sections contain text blocks and evaluate whether to render it or not. If + * the object evaluates to an array it will iterate over it and render the block + * for each item in the array. There are four different types of sections. + * + * ## Falseys or Empty Arrays + * + * If the value returns a `false`, `undefined`, `null`, `""` or `[]` we consider + * that a *falsey* value. + * + * If the value is falsey, the section will **NOT** render the block. + * + * { + * friends: false + * } + * + * {{#friends}} + * Never shown! + * {{/friends}} + * + * + * ## Arrays + * + * If the value is a non-empty array, sections will iterate over the + * array of items, rendering the items in the block. + * + * For example, a list of friends will iterate + * over each of those items within a section. + * + * { + * friends: [ + * { name: "Austin" }, + * { name: "Justin" } + * ] + * } + * + *
              + * {{#friends}} + *
            • {{name}}
            • + * {{/friends}} + *
            + * + * would render: + * + *
              + *
            • Austin
            • + *
            • Justin
            • + *
            + * + * Reminder: Sections will reset the current context to the value for which it is iterating. + * See the [basics of contexts](#Basics) for more information. + * + * ## Truthys + * + * When the value is a non-falsey object but not a list, it is considered truthy and will be used + * as the context for a single rendering of the block. + * + * { + * friends: { name: "Jon" } + * } + * + * {{#friends}} + * Hi {{name}} + * {{/friends}} + * + * would render: + * + * Hi Jon! + */ + // + /** + * @function can.mustache.helpers.helper {{helper args hashes}} + * @parent can.mustache.htags 0 + * + * @description Calls a mustache helper function and inserts its return value into + * the rendered template. + * + * @signature `{{helper [args...] [hashProperty=hashValue...]}}` + * + * Calls a mustache helper function or a function. For example: + * + * The template: + * + *

            {{madLib "Lebron James" verb 4 foo="bar"}}

            + * + * Rendered with: + * + * {verb: "swept"} + * + * Will call a `madLib` helper with the following arguements: + * + * can.mustache.registerHelper('madLib', + * function(subject, verb, number, options){ + * // subject -> "Lebron James" + * // verb -> "swept" + * // number -> 4 + * // options.hash.foo -> "bar" + * }); + * + * @param {can.mustache.key} helper A key that finds a [can.mustache.helper helper function] + * that is either [can.mustache.registerHelper registered] or found within the + * current or parent [can.mustache.context context]. + * + * @param {...can.mustache.key|String|Number} [args] Space seperated arguments + * that get passed to the helper function as arguments. If the key's value is a: + * + * - [can.Map] - A getter/setter [can.compute] is passed. + * - [can.compute] - The can.compute is passed. + * - `function` - The function's return value is passed. + * + * @param {String} hashProperty + * + * A property name that gets added to a [can.mustache.helperOptions helper options]'s + * hash object. + * + * @param {...can.mustache.key|String|Number} hashValue A value that gets + * set as a property value of the [can.mustache.helperOptions helper option argument]'s + * hash object. + * + * @body + * + * ## Use + * + * The `{{helper}}` syntax is used to call out to Mustache [can.mustache.helper helper functions] functions + * that may contain more complex functionality. `helper` is a [can.mustache.key key] that must match either: + * + * - a [can.mustache.registerHelper registered helper function], or + * - a function in the current or parent [can.mustache.context contexts] + * + * The following example shows both cases. + * + * The Template: + * + *

            {{greeting}} {{user}}

            + * + * Rendered with data: + * + * { + * user: function(){ return "Justin" } + * } + * + * And a with a registered helper like: + * + * can.mustache.registerHelper('greeting', function(){ + * return "Hello" + * }); + * + * Results in: + * + *

            Hello Justin

            + * + * ## Arguments + * + * Arguments can be passed from the template to helper function by + * listing space seperated strings, numbers or other [can.mustache.key keys] after the + * `helper` name. For example: + * + * The template: + * + *

            {{madLib "Lebron James" verb 4}}

            + * + * Rendered with: + * + * {verb: "swept"} + * + * Will call a `madLib` helper with the following arguements: + * + * can.mustache.registerHelper('madLib', + * function(subject, verb, number, options){ + * // subject -> "Lebron James" + * // verb -> "swept" + * // number -> 4 + * }); + * + * If an argument `key` value is a [can.Map] property, the Observe's + * property is converted to a getter/setter [can.compute]. For example: + * + * The template: + * + *

            What! My name is: {{mr user.name}}

            + * + * Rendered with: + * + * {user: new can.Map({name: "Slim Shady"})} + * + * Needs the helper to check if name is a function or not: + * + * can.mustache.registerHelper('mr',function(name){ + * return "Mr. "+ (typeof name === "function" ? + * name(): + * name) + * }) + * + * This behavior enables two way binding helpers and is explained in more detail + * on the [can.mustache.helper helper functions] docs. + * + * ## Hash + * + * If enumerated arguments isn't an appropriate way to configure the behavior + * of a helper, it's possible to pass a hash of key-value pairs to the + * [can.mustache.helperOptions helper option argument]'s + * hash object. Properties and values are specified + * as `hashProperty=hashValue`. For example: + * + * The template: + * + *

            My {{excuse who=pet how="shreded"}}

            + * ` + * And the helper: + * + * can.mustache.registerHelper("excuse",function(options){ + * return ["My", + * options.hash.who || "dog". + * options.hash.how || "ate", + * "my", + * options.hash.what || "homework"].join(" ") + * }) + * + * Render with: + * + * {pet: "cat"} + * + * Results in: + * + *

            My cat shareded my homework

            + * + * ## Returning an element callback function + * + * If a helper returns a function, that function is called back after + * the template has been rendered into DOM elements. This can + * be used to create mustache tags that have rich behavior. Read about it + * on the [can.mustache.helper helper function] page. + * + */ + // + /** + * @function can.mustache.helpers.sectionHelper {{#helper args hashes}} + * @parent can.mustache.htags 1 + * + * Calls a mustache helper function with a block, and optional inverse + * block. + * + * @signature `{{#helper [args...] [hashName=hashValue...]}}BLOCK{{/helper}}` + * + * Calls a mustache helper function or a function with a block to + * render. + * + * The template: + * + *

            {{countTo number}}{{num}}{{/countTo}}

            + * + * Rendered with: + * + * {number: 5} + * + * Will call the `countTo` helper: + * + * can.mustache.registerHelper('madLib', + * function(number, options){ + * var out = [] + * for(var i =0; i < number; i++){ + * out.push( options.fn({num: i+1}) ) + * } + * return out.join(" ") + * }); + * + * Results in: + * + *

            1 2 3 4 5

            + * + * @param {can.mustache.key} helper A key that finds a [can.mustache.helper helper function] + * that is either [can.mustache.registerHelper registered] or found within the + * current or parent [can.mustache.context context]. + * + * @param {...can.mustache.key|String|Number} [args] Space seperated arguments + * that get passed to the helper function as arguments. If the key's value is a: + * + * - [can.Map] - A getter/setter [can.compute] is passed. + * - [can.compute] - The can.compute is passed. + * - `function` - The function's return value is passed. + * + * @param {String} hashProperty + * + * A property name that gets added to a [can.mustache.helperOptions helper options]'s + * hash object. + * + * @param {...can.mustache.key|String|Number} hashValue A value that gets + * set as a property value of the [can.mustache.helperOptions helper option argument]'s + * hash object. + * + * @param {mustache} BLOCK A mustache template that gets compiled and + * passed to the helper function as the [can.mustache.helperOptions options argument's] `fn` + * property. + * + * + * @signature `{{#helper [args...] [hashName=hashValue...]}}BLOCK{{else}}INVERSE{{/helper}}` + * + * Calls a mustache helper function or a function with a `fn` and `inverse` block to + * render. + * + * The template: + * + *

            The bed is + * {{isJustRight firmness}} + * pefect! + * {{else}} + * uncomfortable. + * {{/justRight}}

            + * + * Rendered with: + * + * {firmness: 45} + * + * Will call the `isJustRight` helper: + * + * can.mustache.registerHelper('isJustRight', + * function(number, options){ + * if(number > 50){ + * return options.fn(this) + * } else { + * return options.inverse(this) + * } + * return out.join(" ") + * }); + * + * Results in: + * + *

            The bed is uncomfortable.

            + * + * @param {can.mustache.key} helper A key that finds a [can.mustache.helper helper function] + * that is either [can.mustache.registerHelper registered] or found within the + * current or parent [can.mustache.context context]. + * + * @param {...can.mustache.key|String|Number} [args] Space seperated arguments + * that get passed to the helper function as arguments. If the key's value is a: + * + * - [can.Map] - A getter/setter [can.compute] is passed. + * - [can.compute] - The can.compute is passed. + * - `function` - The function's return value is passed. + * + * @param {String} hashProperty + * + * A property name that gets added to a [can.mustache.helperOptions helper options]'s + * hash object. + * + * @param {...can.mustache.key|String|Number} hashValue A value that gets + * set as a property value of the [can.mustache.helperOptions helper option argument]'s + * hash object. + * + * @param {mustache} BLOCK A mustache template that gets compiled and + * passed to the helper function as the [can.mustache.helperOptions options argument's] `fn` + * property. + * + * @param {mustache} INVERSE A mustache template that gets compiled and + * passed to the helper function as the [can.mustache.helperOptions options argument's] `inverse` + * property. + * + * + * @body + * + * ## Use + * + * Read the [use section of {{helper}}](can.mustache.helpers.helper.html#section_Use) to better understand how: + * + * - [Helper functions are found](can.mustache.helpers.helper.html#section_Arguments) + * - [Arguments are passed to the helper](can.mustache.helpers.helper.html#section_Arguments) + * - [Hash values are passed to the helper](can.mustache.helpers.helper.html#section_Hash) + * + * Read how [helpers that return functions](can.mustache.helper.html#section_Returninganelementcallbackfunction) can + * be used for rich behavior like 2-way binding. + * + */ + // Open a new section. + case '#': + /** + * @function can.mustache.helpers.inverse {{^key}} + * @parent can.mustache.tags 5 + * + * @signature `{{^key}}BLOCK{{/key}}` + * + * Render blocks of text if the value of the key + * is falsey. An inverted section syntax is similar to regular + * sections except it begins with a caret rather than a + * pound. If the value referenced is falsey, the section will render. + * + * @param {can.mustache.key} key A key that references a value within the current or parent + * [can.mustache.context context]. If the value is a function or [can.compute], the + * function's return value is used. + * + * @return {String} + * + * Depending on the value's type, the following actions happen: + * + * - A `truthy` value - the block is not rendered. + * - A `falsey` value - the block is rendered. + * + * The rendered result of the block or an empty string is returned. + * + * @body + * + * ## Use + * + * Inverted sections match falsey values. An inverted section + * syntax is similar to regular sections except it begins with a caret + * rather than a pound. If the value referenced is falsey, the section + * will render. For example: + * + * + * The template: + * + *
              + * {{#friends}} + * {{name}} + * {{/friends}} + * {{^friends}} + *
            • No friends.
            • + * {{/friends}} + *
            + * + * And data: + * + * { + * friends: [] + * } + * + * Results in: + * + * + *
              + *
            • No friends.
            • + *
            + */ + case '^': + if (cmd.specialAttribute) { + result.startOnlyTxt = true; + //result.push(cmd.insert + 'can.view.onlytxt(this,function(){ return '); + } else { + result.startTxt = true; + // sections should never be escaped + result.escaped = 0; + //result.push(cmd.insert + 'can.view.txt(0,\'' + cmd.tagName + '\',' + cmd.status + ',this,function(){ return '); + } + break; + // Close the prior section. + /** + * @function can.mustache.helpers.close {{/key}} + * @parent can.mustache.tags 4 + * + * @signature `{{/key}}` + * + * Ends a [can.mustache.helpers.section {{#key}}] or [can.mustache.helpers.sectionHelper {{#helper}}] + * block. + * + * @param {can.mustache.key} [key] A key that matches the opening key or helper name. It's also + * possible to simply write `{{/}}` to end a block. + */ + case '/': + result.end = true; + result.content += 'return ___v1ew.join("");}}])'; + return result; + } + + // Trim the mode off of the content. + content = content.substring(1); + } + + // `else` helpers are special and should be skipped since they don't + // have any logic aside from kicking off an `inverse` function. + if (mode !== 'else') { + var args = [], + hashes = [], + i = 0, + m; + + // Start the content render block. + result.content += 'can.Mustache.txt(\n' + + (cmd.specialAttribute ? SPECIAL_CONTEXT_OBJ : CONTEXT_OBJ ) + + ',\n' + (mode ? '"' + mode + '"' : 'null') + ','; + + // Parse the helper arguments. + // This needs uses this method instead of a split(/\s/) so that + // strings with spaces can be correctly parsed. + (can.trim(content) + ' ') + .replace(argumentsRegExp, function (whole, arg) { + + // Check for special helper arguments (string/number/boolean/hashes). + if (i && (m = arg.match(literalNumberStringBooleanRegExp))) { + // Found a native type like string/number/boolean. + if (m[2]) { + args.push(m[0]); + } + // Found a hash object. + else { + // Addd to the hash object. + + hashes.push(m[4] + ":" + (m[6] ? m[6] : makeLookupLiteral(m[5]))); + } + } + // Otherwise output a normal interpolation reference. + else { + args.push(makeLookupLiteral(arg)); + } + i++; + }); + + result.content += args.join(","); + if (hashes.length) { + result.content += ",{" + HASH + ":{" + hashes.join(",") + "}}"; + } + + } + + // Create an option object for sections of code. + if (mode && mode !== 'else') { + result.content += ',[\n\n'; + } + switch (mode) { + // Truthy section + case '^': + case '#': + result.content += ('{fn:function(' + ARG_NAMES + '){var ___v1ew = [];'); + break; + // If/else section + // Falsey section + /** + * @function can.mustache.helpers.else {{else}} + * @parent can.mustache.htags 3 + * + * @signature `{{#helper}}BLOCK{{else}}INVERSE{{/helper}}` + * + * Creates an `inverse` block for a [can.mustache.helper helper function]'s + * [can.mustache.helperOptions options argument]'s `inverse` property. + * + * @param {can.mustache} INVERSE a mustache template coverted to a + * function and set as the [can.mustache.helper helper function]'s + * [can.mustache.helperOptions options argument]'s `inverse` property. + * + * @body + * + * ## Use + * + * For more information on how `{{else}}` is used checkout: + * + * - [can.mustache.helpers.if {{if key}}] + * - [can.mustache.helpers.sectionHelper {{#helper}}] + * + */ + case 'else': + result.content += 'return ___v1ew.join("");}},\n{inverse:function(' + ARG_NAMES + '){\nvar ___v1ew = [];'; + break; + + // Not a section, no mode + default: + result.content += (')'); + break; + } + + if (!mode) { + result.startTxt = true; + result.end = true; + } + + return result; + } + } + ] + }) + }); + + // Add in default scanner helpers first. + // We could probably do this differently if we didn't 'break' on every match. + var helpers = can.view.Scanner.prototype.helpers; + for (var i = 0; i < helpers.length; i++) { + Mustache.prototype.scanner.helpers.unshift(helpers[i]); + } + + /** + * @function can.MustacheConstructor.txt + * @hide + * + * Evaluates the resulting string based on the context/name. + * + * @param {Object|Array} context The context stack to be used with evaluation. + * @param {String} mode The mode to evaluate the section with: # for truthy, ^ for falsey + * @param {String|Object} name The string (or sometimes object) to pass to the given helper method. + */ + Mustache.txt = function (scopeAndOptions, mode, name) { + + // here we are going to cache the lookup values so future calls are much faster + var scope = scopeAndOptions.scope, + options = scopeAndOptions.options, + args = [], + helperOptions = { + fn: function () {}, + inverse: function () {} + }, + hash, + context = scope.attr("."), + getHelper = true, + helper; + + // convert lookup values to actual values in name, arguments, and hash + for (var i = 3; i < arguments.length; i++) { + var arg = arguments[i]; + if (mode && can.isArray(arg)) { + // merge into options + helperOptions = can.extend.apply(can, [helperOptions].concat(arg)); + } else if (arg && arg[HASH]) { + hash = arg[HASH]; + // get values on hash + for (var prop in hash) { + if (isLookup(hash[prop])) { + hash[prop] = Mustache.get(hash[prop].get, scopeAndOptions, false, true); + } + } + } else if (arg && isLookup(arg)) { + args.push(Mustache.get(arg.get, scopeAndOptions, false, true, true)); + } else { + args.push(arg); + } + } + + if (isLookup(name)) { + var get = name.get; + name = Mustache.get(name.get, scopeAndOptions, args.length, false); + + // Base whether or not we will get a helper on whether or not the original + // name.get and Mustache.get resolve to the same thing. Saves us from running + // into issues like {{text}} / {text: 'with'} + getHelper = (get === name); + } + + // overwrite fn and inverse to always convert to scopes + helperOptions.fn = makeConvertToScopes(helperOptions.fn, scope, options); + helperOptions.inverse = makeConvertToScopes(helperOptions.inverse, scope, options); + + // if mode is ^, swap fn and inverse + if(mode === '^') { + var tmp = helperOptions.fn; + helperOptions.fn = helperOptions.inverse; + helperOptions.inverse = tmp; + } + + // Check for a registered helper or a helper-like function. + if (helper = (getHelper && (typeof name === "string" && Mustache.getHelper(name, options)) || (can.isFunction(name) && !name.isComputed && { + fn: name + }))) { + // Add additional data to be used by helper functions + + can.extend(helperOptions, { + context: context, + scope: scope, + contexts: scope, + hash: hash + }); + + args.push(helperOptions); + // Call the helper. + return function () { + return helper.fn.apply(context, args) || ''; + }; + + } + /*if( !mode && !args.length && can.isFunction(name) && name.isComputed ) { + if(!scopeAndOptions.special) { + name.canReadForChangeEvent = false; + } + return name; + }*/ + return function () { + //{{#foo.bar zed ted}} + var value; + if (can.isFunction(name) && name.isComputed) { + value = name(); + } else { + value = name; + } + // An array of arguments to check for truthyness when evaluating sections. + var validArgs = args.length ? args : [value], + // Whether the arguments meet the condition of the section. + valid = true, + result = [], + i, argIsObserve, arg; + // Validate the arguments based on the section mode. + if (mode) { + for (i = 0; i < validArgs.length; i++) { + arg = validArgs[i]; + argIsObserve = typeof arg !== 'undefined' && isObserveLike(arg); + // Array-like objects are falsey if their length = 0. + if (isArrayLike(arg)) { + // Use .attr to trigger binding on empty lists returned from function + if (mode === '#') { + valid = valid && !! (argIsObserve ? arg.attr('length') : arg.length); + } else if (mode === '^') { + valid = valid && !(argIsObserve ? arg.attr('length') : arg.length); + } + } + // Otherwise just check if it is truthy or not. + else { + valid = mode === '#' ? valid && !! arg : mode === '^' ? valid && !arg : valid; + } + } + } + + // Otherwise interpolate like normal. + if (valid) { + + if (mode === "#") { + if (isArrayLike(value)) { + var isObserveList = isObserveLike(value); + + // Add the reference to the list in the contexts. + for (i = 0; i < value.length; i++) { + result.push(helperOptions.fn( + isObserveList ? value.attr('' + i) : value[i])); + } + return result.join(''); + } + // Normal case. + else { + return helperOptions.fn(value || {}) || ''; + } + } else if (mode === "^") { + return helperOptions.inverse(value || {}) || ''; + } else { + return '' + (value != null ? value : ''); + } + } + + return ''; + }; + }; + + /** + * @function can.MustacheConstructor.get + * @hide + * + * Resolves a key for a given object (and then a context if that fails). + * + * obj = this + * context = { a: true } + * ref = 'a.b.c' + * => obj.a.b.c || context.a.b.c || '' + * + * This implements the following Mustache specs: + * Deeply Nested Contexts + * All elements on the context stack should be accessible. + * + * {{#bool}}B {{#bool}}C{{/bool}} D{{/bool}} + * { bool: true } + * => "B C D" + * + * Basic Context Miss Interpolation + * Failed context lookups should default to empty strings. + * + * {{cannot}} + * => "" + * + * Dotted Names - Broken Chains + * Any falsey value prior to the last part of the name should yield ''. + * {{a.b.c}} + * { a: { d: 1 } } + * => "" + * + * @param {can.mustache.key} key The reference to check for on the obj/context. + * @param {Object} obj The object to use for checking for a reference. + * @param {Object} context The context to use for checking for a reference if it doesn't exist in the object. + * @param {Boolean} [isHelper] Whether the reference is seen as a helper. + */ + Mustache.get = function (key, scopeAndOptions, isHelper, isArgument, isLookup) { + + // Cache a reference to the current context and options, we will use them a bunch. + var context = scopeAndOptions.scope.attr('.'), + options = scopeAndOptions.options || {}; + + // If key is called as a helper, + if (isHelper) { + // try to find a registered helper. + if (Mustache.getHelper(key, options)) { + return key; + } + // Support helper-like functions as anonymous helpers. + // Check if there is a method directly in the "top" context. + if (scopeAndOptions.scope && can.isFunction(context[key])) { + return context[key]; + } + + //!steal-remove-start + can.dev.warn('can/view/mustache/mustache.js: Unable to find helper "' + key + '".'); + //!steal-remove-end + } + + // Get a compute (and some helper data) that represents key's value in the current scope + var computeData = scopeAndOptions.scope.computeData(key, { + isArgument: isArgument, + args: [context, scopeAndOptions.scope] + }), + compute = computeData.compute; + + // Bind on the compute to cache its value. We will unbind in a timeout later. + can.compute.temporarilyBind(compute); + + // computeData gives us an initial value + var initialValue = computeData.initialValue, + helperObj = Mustache.getHelper(key, options); + + //!steal-remove-start + if (initialValue === undefined && !isHelper && !helperObj) { + can.dev.warn('can/view/mustache/mustache.js: Unable to find key "' + key + '".'); + } + //!steal-remove-end + + // Use helper over the found value if the found value isn't in the current context + if (!isLookup && (initialValue === undefined || computeData.scope !== scopeAndOptions.scope) && Mustache.getHelper(key, options)) { + return key; + } + + // If there are no dependencies, just return the value. + if (!compute.computeInstance.hasDependencies) { + return initialValue; + } else { + return compute; + } + }; + + /** + * @hide + * + * Resolves an object to its truthy equivalent. + * + * @param {Object} value The object to resolve. + * @return {Object} The resolved object. + */ + Mustache.resolve = function (value) { + if (isObserveLike(value) && isArrayLike(value) && value.attr('length')) { + return value; + } else if (can.isFunction(value)) { + return value(); + } else { + return value; + } + }; + + /** + * @static + */ + + can.view.Options = can.view.Scope.extend({ + init: function (data, parent) { + if (!data.helpers && !data.partials && !data.tags) { + data = { + helpers: data + }; + } + can.view.Scope.prototype.init.apply(this, arguments); + } + }); + + // ## Helpers + // + // Helpers are functions that can be called from within a template. + // These helpers differ from the scanner helpers in that they execute + // at runtime instead of during compilation. + // + // Custom helpers can be added via `can.Mustache.registerHelper`, + // but there are also some built-in helpers included by default. + // Most of the built-in helpers are little more than aliases to actions + // that the base version of Mustache simply implies based on the + // passed in object. + // + // Built-in helpers: + // + // * `data` - `data` is a special helper that is implemented via scanning helpers. + // It hooks up the active element to the active data object: `
            ` + // * `if` - Renders a truthy section: `{{#if var}} render {{/if}}` + // * `unless` - Renders a falsey section: `{{#unless var}} render {{/unless}}` + // * `each` - Renders an array: `{{#each array}} render {{this}} {{/each}}` + // * `with` - Opens a context section: `{{#with var}} render {{/with}}` + Mustache._helpers = {}; + /** + * @function can.mustache.registerHelper + * @parent can.mustache.methods + * @description Register a helper. + * @function can.mustache.registerHelper registerHelper + * @signature `Mustache.registerHelper(name, helper)` + * @param {String} name The name of the helper. + * @param {can.mustache.helper} helper The helper function. + * + * @body + * Registers a helper with the Mustache system. + * Pass the name of the helper followed by the + * function to which Mustache should invoke. + * These are run at runtime. + */ + Mustache.registerHelper = function (name, fn) { + this._helpers[name] = { + name: name, + fn: fn + }; + }; + + /** + * @hide + * @function can.MustacheConstructor.getHelper getHelper + * @description Retrieve a helper. + * @signature `Mustache.getHelper(name)` + * @param {String} name The name of the helper. + * @return {Function|null} The helper, or `null` if + * no helper by that name is found. + * + * @body + * Returns a helper given the name. + */ + Mustache.getHelper = function (name, options) { + var helper; + if (options) { + helper = options.attr("helpers." + name); + } + return helper ? { + fn: helper + } : this._helpers[name]; + }; + + /** + * @function can.MustacheConstructor.static.render render + * @hide + * @parent can.Mustache.static + * @signature `Mustache.render(partial, context)` + * @param {Object} partial + * @param {can.view.Scope} scope + * + * @body + * `Mustache.render` is a helper method that calls + * into `can.view.render` passing the partial + * and the context object. + * + * Its purpose is to determine if the partial object + * being passed represents a template like: + * + * partial === "movember.mustache" + * + * or if the partial is a variable name that represents + * a partial on the context object such as: + * + * context[partial] === "movember.mustache" + */ + Mustache.render = function (partial, scope, options) { + // TOOD: clean up the following + // If there is a "partial" property and there is not + // an already-cached partial, we use the value of the + // property to look up the partial + + // if this partial is not cached ... + if (!can.view.cached[partial]) { + // we don't want to bind to changes so clear and restore reading + var reads = can.__clearReading(); + var scopePartialName = scope.attr(partial); + if (scopePartialName) { + partial = scopePartialName; + } + can.__setReading(reads); + } + + // Call into `can.view.render` passing the + // partial and scope. + return can.view.render(partial, scope, options); + }; + + /** + * @function can.mustache.safeString + * @parent can.mustache.methods + * + * @signature `can.mustache.safeString(str)` + * + * @param {String} str A string you don't want to become escaped. + * @return {String} A string flagged by `can.mustache` as safe, which will + * not become escaped, even if you use [can.mustache.tags.unescaped](triple slash). + * + * @body + * If you write a helper that generates its own HTML, you will + * usually want to return a `can.mustache.safeString.` In this case, + * you will want to manually escape parameters with `[can.esc].` + * + * ``` + * can.mustache.registerHelper('link', function(text, url) { + * text = can.esc(text); + * url = can.esc(url); + * + * var result = '' + text + ''; + * return can.mustache.safeString(result); + * }); + * ``` + * + * Rendering: + * ``` + *
            {{link "Google", "http://google.com"}}
            + * ``` + * + * Results in: + * + * ``` + * + * ``` + * + * As an anchor tag whereas if we would have just returned the result rather than a + * `can.mustache.safeString` our template would have rendered a div with the escaped anchor tag. + * + */ + Mustache.safeString = function (str) { + return { + toString: function () { + return str; + } + }; + }; + + Mustache.renderPartial = function (partialName, scope, options) { + var partial = options.attr("partials." + partialName); + if (partial) { + return partial.render ? partial.render(scope, options) : + partial(scope, options); + } else { + return can.Mustache.render(partialName, scope, options); + } + }; + + // The built-in Mustache helpers. + can.each({ + // Implements the `if` built-in helper. + /** + * @function can.mustache.helpers.if {{#if key}} + * @parent can.mustache.htags 2 + * @signature `{{#if key}}BLOCK{{/if}}` + * + * Renders the `BLOCK` template within the current template. + * + * @param {can.mustache.key} key A key that references a value within the current or parent + * context. If the value is a function or can.compute, the function's return value is used. + * + * @param {can.mustache} BLOCK A mustache template. + * + * @return {String} If the key's value is truthy, the `BLOCK` is rendered with the + * current context and its value is returned; otherwise, an empty string. + * + * @body + * + * ## Use + * + * `{{#if key}}` provides explicit conditional truthy tests. For example, + * + * The template: + * + * {{#if user.isFemale}} + * {{#if user.isMarried}} + * Mrs + * {{/if}} + * {{#if user.isSingle}} + * Miss + * {{/if}} + * {{/if}} + * + * Rendered with: + * + * {user: {isFemale: true, isMarried: true}} + * + * Results in: + * + * Mrs + * + * If can be used with [can.mustache.helpers.else {{else}}] too. For example, + * + * {{#if user.isFemale}} + * {{#if user.isMarried}} + * Mrs + * {{else}} + * Miss + * {{/if}} + * {{/if}} + * + * Rendered with: + * + * {user: {isFemale: true, isMarried: false}} + * + * Results in: + * + * Miss + */ + 'if': function (expr, options) { + var value; + // if it's a function, wrap its value in a compute + // that will only change values from true to false + if (can.isFunction(expr)) { + value = can.compute.truthy(expr)(); + } else { + value = !! Mustache.resolve(expr); + } + + if (value) { + return options.fn(options.contexts || this); + } else { + return options.inverse(options.contexts || this); + } + }, + /** + * @function can.stache.helpers.is {{#is expr1 expr2 expr3}} + * @parent can.stache.htags 12 + * + * @signature `{{#is expr1 expr2}}BLOCK{{/is}}` + * + * Renders the `BLOCK` template within the current template. + * + * @param {can.stache.expression} [expr...] An expression or key that references a + * value within the current or parent + * + * @param {can.stache} BLOCK A template that is rendered + * if the result of comparsion `expr1` and `expr2` value is truthy. + * + * @return {DocumentFragment} If the key's value is truthy, the `BLOCK` is rendered with the + * current context and its value is returned; otherwise, an empty string. + * + * @body + * + * The `is` helper compares expr1 and expr2 and renders the blocks accordingly. + * + * {{#is expr1 expr2}} + * // truthy + * {{else}} + * // falsey + * {{/is}} + */ + 'is': function() { + var lastValue, curValue, + options = arguments[arguments.length - 1]; + + if (arguments.length - 2 <= 0) { + return options.inverse(); + } + + for (var i = 0; i < arguments.length - 1; i++) { + curValue = Mustache.resolve(arguments[i]); + curValue = can.isFunction(curValue) ? curValue() : curValue; + + if (i > 0) { + if (curValue !== lastValue) { + return options.inverse(); + } + } + lastValue = curValue; + } + + return options.fn(); + }, + 'eq': function() { + return Mustache._helpers.is.fn.apply(this, arguments); + }, + // Implements the `unless` built-in helper. + /** + * @function can.mustache.helpers.unless {{#unless key}} + * @parent can.mustache.htags 4 + * + * @signature `{{#unless key}}BLOCK{{/unless}}` + * + * Render the block of text if the key's value is falsey. + * + * @param {can.mustache.key} key A key that references a value within the current or parent + * context. If the value is a function or can.compute, the function's + * return value is used. + * + * @param {can.mustache} BLOCK A template that is rendered + * if the `key`'s value is falsey. + * + * @body + * + * The `unless` helper evaluates the inverse of the value + * of the key and renders the block between the helper and the slash. + * + * {{#unless expr}} + * // unless + * {{/unless}} + */ + 'unless': function (expr, options) { + return Mustache._helpers['if'].fn.apply(this, [can.isFunction(expr) ? can.compute(function() { return !expr(); }) : !expr, options]); + }, + + // Implements the `each` built-in helper. + /** + * @function can.mustache.helpers.each {{#each key}} + * @parent can.mustache.htags 5 + * + * @signature `{{#each key}}BLOCK{{/each}}` + * + * Render the block of text for each item in key's value. + * + * @param {can.mustache.key} key A key that references a value within the current or parent + * context. If the value is a function or can.compute, the function's + * return value is used. + * + * If the value of the key is a [can.List], the resulting HTML is updated when the + * list changes. When a change in the list happens, only the minimum amount of DOM + * element changes occur. + * + * If the value of the key is a [can.Map], the resulting HTML is updated whenever + * attributes are added or removed. When a change in the map happens, only + * the minimum amount of DOM element changes occur. + * + * @param {can.mustache} BLOCK A template that is rendered for each item in + * the `key`'s value. The `BLOCK` is rendered with the context set to the item being rendered. + * + * @body + * + * ## Use + * + * Use the `each` helper to iterate over a array + * of items and render the block between the helper and the slash. For example, + * + * The template: + * + *
              + * {{#each friends}} + *
            • {{name}}
            • + * {{/each}} + *
            + * + * Rendered with: + * + * {friends: [{name: "Austin"},{name: "Justin"}]} + * + * Renders: + * + *
              + *
            • Austin
            • + *
            • Justin
            • + *
            + * + * ## Object iteration + * + * As of 2.1, you can now iterate over properties of objects and attributes with + * the `each` helper. When iterating over [can.Map] it will only iterate over the + * map's [keys](can.Map.keys.html) and none of the hidden properties of a can.Map. For example, + * + * The template: + * + *
              + * {{#each person}} + *
            • {{.}}
            • + * {{/each}} + *
            + * + * Rendered with: + * + * {person: {name: 'Josh', age: 27}} + * + * Renders: + * + *
              + *
            • Josh
            • + *
            • 27
            • + *
            + */ + 'each': function (expr, options) { + // Check if this is a list or a compute that resolves to a list, and setup + // the incremental live-binding + + // First, see what we are dealing with. It's ok to read the compute + // because can.view.text is only temporarily binding to what is going on here. + // Calling can.view.lists prevents anything from listening on that compute. + var resolved = Mustache.resolve(expr), + result = [], + keys, + key, + i; + + // When resolved === undefined, the property hasn't been defined yet + // Assume it is intended to be a list + if (can.view.lists && (resolved instanceof can.List || (expr && expr.isComputed && resolved === undefined))) { + return can.view.lists(expr, function (item, index) { + return options.fn(options.scope.add({ + "@index": index + }) + .add(item)); + }); + } + expr = resolved; + + if ( !! expr && isArrayLike(expr)) { + for (i = 0; i < expr.length; i++) { + result.push(options.fn(options.scope.add({ + "@index": i + }) + .add(expr[i]))); + } + return result.join(''); + } else if (isObserveLike(expr)) { + keys = can.Map.keys(expr); + // listen to keys changing so we can livebind lists of attributes. + + for (i = 0; i < keys.length; i++) { + key = keys[i]; + result.push(options.fn(options.scope.add({ + "@key": key + }) + .add(expr[key]))); + } + return result.join(''); + } else if (expr instanceof Object) { + for (key in expr) { + result.push(options.fn(options.scope.add({ + "@key": key + }) + .add(expr[key]))); + } + return result.join(''); + + } + }, + // Implements the `with` built-in helper. + /** + * @function can.mustache.helpers.with {{#with key}} + * @parent can.mustache.htags 6 + * + * @signature `{{#with key}}BLOCK{{/with}}` + * + * Changes the context within a block. + * + * @param {can.mustache.key} key A key that references a value within the current or parent + * context. If the value is a function or can.compute, the function's + * return value is used. + * + * @param {can.mustache} BLOCK A template that is rendered + * with the context of the `key`'s value. + * + * @body + * + * Mustache typically applies the context passed in the section + * at compiled time. However, if you want to override this + * context you can use the `with` helper. + * + * {{#with arr}} + * // with + * {{/with}} + */ + 'with': function (expr, options) { + var ctx = expr; + expr = Mustache.resolve(expr); + if ( !! expr) { + return options.fn(ctx); + } + }, + /** + * @function can.mustache.helpers.log {{log}} + * @parent can.mustache.htags 9 + * + * @signature `{{#log [message]}}` + * + * Logs the context of the current block with an optional message. + * + * @param {*} message An optional message to log out in addition to the + * current context. + * + */ + 'log': function (expr, options) { + if(typeof console !== "undefined" && console.log) { + if (!options) { + console.log(expr.context); + } else { + console.log(expr, options.context); + } + } + }, + /** + * @function can.mustache.helpers.elementCallback {{(el)->CODE}} + * + * @parent can.mustache.htags 8 + * + * @signature `{{(el) -> CODE}}` + * + * Executes an element callback with the inline code on the element. + * + * @param {String} code The inline code to execute on the element. + * + * @body + * + * ## Use + * + * It is common for you to want to execute some code on a given + * DOM element. An example would be for initializing a jQuery plugin + * on the new HTML. + * + *
            el.jquery_tabs()}}>
            + * + */ + // + /** + * @function can.mustache.helpers.index {{@index}} + * + * @parent can.mustache.htags 10 + * + * @signature `{{@index [offset]}}` + * + * Insert the index of an Array or can.List we are iterating on with [#each](can.mustache.helpers.each) + * + * @param {Number} offset The number to optionally offset the index by. + * + * @body + * + * ## Use + * + * When iterating over and array or list of items, you might need to render the index + * of the item. Use the `@index` directive to do so. For example, + * + * The template: + * + *
              + * {{#each items}} + *
            • {{@index}} - {{.}}
            • + * {{/each}} + *
            + * + * Rendered with: + * + * { items: ['Josh', 'Eli', 'David'] } + * + * Renders: + * + *
              + *
            • 0 - Josh
            • + *
            • 1 - Eli
            • + *
            • 2 - David
            • + *
            + * + */ + "@index": function(offset, options) { + if (!options) { + options = offset; + offset = 0; + } + var index = options.scope.attr("@index"); + return ""+((can.isFunction(index) ? index() : index) + offset); + } + /** + * @function can.mustache.helpers.key {{@key}} + * + * @parent can.mustache.htags 11 + * + * @signature `{{@key}}` + * + * Insert the property name of an Object or attribute name of a can.Map that we iterate over with [#each](can.mustache.helpers.each) + * + * @body + * + * ## Use + * + * Use `{{@key}}` to render the property or attribute name of an Object or can.Map, when iterating over it with [#each](can.mustache.helpers.each). For example, + * + * The template: + * + *
              + * {{#each person}} + *
            • {{@key}}: {{.}}
            • + * {{/each}} + *
            + * + * Rendered with: + * + * { person: {name: 'Josh', age: 27, likes: 'Mustache, JavaScript, High Fives'} } + * + * Renders: + * + *
              + *
            • name: Josh
            • + *
            • age: 27
            • + *
            • likes: Mustache, JavaScript, High Fives
            • + *
            + * + */ + }, function (fn, name) { + Mustache.registerHelper(name, fn); + }); + + // ## Registration + // + // Registers Mustache with can.view. + can.view.register({ + suffix: "mustache", + + contentType: "x-mustache-template", + + // Returns a `function` that renders the view. + script: function (id, src) { + return "can.Mustache(function(" + ARG_NAMES + ") { " + new Mustache({ + text: src, + name: id + }) + .template.out + " })"; + }, + + renderer: function (id, text) { + return Mustache({ + text: text, + name: id + }); + } + }); + + can.mustache.registerHelper = can.proxy(can.Mustache.registerHelper, can.Mustache); + can.mustache.safeString = can.Mustache.safeString; + return can; + }); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/mustache/system.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/mustache/system.js new file mode 100644 index 0000000000..fbfc7ce1af --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/mustache/system.js @@ -0,0 +1,30 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/mustache/system*/ +"format steal"; +steal("can/view/mustache", function(can){ + + function translate(load) { + return "define(['can/view/mustache/mustache'],function(can){" + + "return can.view.preloadStringRenderer('" + load.metadata.pluginArgument + "'," + + 'can.Mustache(function(scope,options) { ' + new can.Mustache({ + text: load.source, + name: load.name + }) + .template.out + ' })' + + ")" + + "})"; + } + + return { + translate: translate + }; + +}); + diff --git a/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/node_lists/node_lists.js b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/node_lists/node_lists.js new file mode 100644 index 0000000000..189efa4727 --- /dev/null +++ b/todomvc/canjs/node_modules/canjs-feathers/bower_components/canjs/steal/can/view/node_lists/node_lists.js @@ -0,0 +1,373 @@ +/*! + * CanJS - 2.2.6 + * http://canjs.com/ + * Copyright (c) 2015 Bitovi + * Wed, 20 May 2015 23:00:01 GMT + * Licensed MIT + */ + +/*can@2.2.6#view/node_lists/node_lists*/ +// # can/view/node_lists/node_list.js +// +// `can.view.nodeLists` are used to make sure "directly nested" live-binding +// sections update content correctly. +// +// Consider the following template: +// +// ``` +//
            +// {{#if items.length}} +// Items: +// {{#items}} +// +// {{/items}} +// {{/if}} +//
            +// ``` +// +// The `{{#if}}` and `{{#items}}` seconds are "directly nested" because +// they share the same `
            ` parent element. +// +// If `{{#items}}` changes the DOM by adding more ``, +// `{{#if}}` needs to know about the `` to remove them +// if `{{#if}}` is re-rendered. `{{#if}}` would be re-rendered, for example, if +// all items were removed. +steal('can/util', 'can/view/elements.js', function (can) { + // ## Helpers + // Some browsers don't allow expando properties on HTMLTextNodes + // so let's try to assign a custom property, an 'expando' property. + // We use this boolean to determine how we are going to hold on + // to HTMLTextNode within a nodeList. More about this in the 'id' + // function. + var canExpando = true; + try { + document.createTextNode('')._ = 0; + } catch (ex) { + canExpando = false; + } + + // A mapping of element ids to nodeList id allowing us to quickly find an element + // that needs to be replaced when updated. + var nodeMap = {}, + // A mapping of ids to text nodes, this map will be used in the + // case of the browser not supporting expando properties. + textNodeMap = {}, + // The name of the expando property; the value returned + // given a nodeMap key. + expando = 'ejs_' + Math.random(), + // The id used as the key in our nodeMap, this integer + // will be preceded by 'element_' or 'obj_' depending on whether + // the element has a nodeName. + _id = 0, + + // ## nodeLists.id + // Given a template node, create an id on the node as a expando + // property, or if the node is an HTMLTextNode and the browser + // doesn't support expando properties store the id with a + // reference to the text node in an internal collection then return + // the lookup id. + id = function (node, localMap) { + var _textNodeMap = localMap || textNodeMap; + var id = readId(node,_textNodeMap); + if(id) { + return id; + } else { + // If the browser supports expando properties or the node + // provided is not an HTMLTextNode, we don't need to work + // with the internal textNodeMap and we can place the property + // on the node. + if (canExpando || node.nodeType !== 3) { + ++_id; + return node[expando] = (node.nodeName ? 'element_' : 'obj_') + _id; + } else { + // If we didn't find the node, we need to register it and return + // the id used. + ++_id; + + // If we didn't find the node, we need to register it and return + // the id used. + // + // We have to store the node itself because of the browser's lack + // of support for expando properties (i.e. we can't use a look-up + // table and store the id on the node as a custom property). + _textNodeMap['text_' + _id] = node; + return 'text_' + _id; + } + } + }, + readId = function(node,textNodeMap){ + if (canExpando || node.nodeType !== 3) { + return node[expando]; + } else { + // The nodeList has a specific collection for HTMLTextNodes for + // (older) browsers that do not support expando properties. + for (var textNodeID in textNodeMap) { + if (textNodeMap[textNodeID] === node) { + return textNodeID; + } + } + } + }, + splice = [].splice, + push = [].push, + + // ## nodeLists.itemsInChildListTree + // Given a nodeList return the number of child items in the provided + // list and any child lists. + itemsInChildListTree = function(list){ + var count = 0; + for(var i = 0, len = list.length ; i < len; i++){ + var item = list[i]; + // If the item is an HTMLElement then increment the count by 1. + if(item.nodeType) { + count++; + } else { + // If the item is not an HTMLElement it is a list, so + // increment the count by the number of items in the child + // list. + count += itemsInChildListTree(item); + } + } + return count; + }, + replacementMap = function(replacements, idMap){ + var map = {}; + for(var i = 0, len = replacements.length; i < len; i++){ + var node = nodeLists.first(replacements[i]); + map[id(node, idMap)] = replacements[i]; + } + return map; + }; + + // ## Registering & Updating + // + // To keep all live-bound sections knowing which elements they are managing, + // all live-bound elments are registered and updated when they change. + // + // For example, the above template, when rendered with data like: + // + // data = new can.Map({ + // items: ["first","second"] + // }) + // + // This will first render the following content: + // + //
            + // + //
            + // + // When the `5` callback is called, this will register the `` like: + // + // var ifsNodes = [] + // nodeLists.register(ifsNodes); + // + // And then render `{{if}}`'s contents and update `ifsNodes` with it: + // + // nodeLists.update( ifsNodes, [<"\nItems:\n">, ] ); + // + // Next, hookup `6` is called which will regsiter the `` like: + // + // var eachsNodes = []; + // nodeLists.register(eachsNodes); + // + // And then it will render `{{#each}}`'s content and update `eachsNodes` with it: + // + // nodeLists.update(eachsNodes, [