├── view ├── test │ ├── deferred.ejs │ ├── template.tmpl │ ├── deferreds.ejs │ ├── extensionless │ ├── temp.ejs │ ├── template.ejs │ ├── template.micro │ ├── template.mustache │ ├── helpers.ejs │ ├── helpers.mustache │ ├── template.jaml │ ├── hookup.ejs │ ├── nested_plugin.ejs │ ├── plugin.ejs │ ├── hookupvalcall.ejs │ └── select.ejs ├── mustache │ ├── test │ │ ├── test_template.mustache │ │ ├── hello.mustache │ │ ├── noglobals.mustache │ │ ├── helper.mustache │ │ ├── partial.mustache │ │ ├── easyhookup.mustache │ │ ├── fancy_name.mustache │ │ ├── table.mustache │ │ └── recursive.mustache │ ├── doc │ │ ├── key.md │ │ ├── renderer.md │ │ ├── context.md │ │ ├── livebinding.md │ │ ├── acquisition.md │ │ └── sections.md │ ├── spec │ │ ├── Rakefile │ │ ├── Changes │ │ └── TESTING.md │ ├── mustache.html │ └── test.html ├── ejs │ ├── test │ │ ├── easyhookup.ejs │ │ ├── binding.ejs │ │ ├── nested_live_bindings.ejs │ │ ├── shared_blocks.ejs │ │ ├── indirect1.ejs │ │ ├── indirect2.ejs │ │ ├── test_template.ejs │ │ ├── recursive.ejs │ │ ├── foo.js │ │ ├── todo_comments.ejs │ │ ├── table_test.ejs │ │ └── qunit.html │ ├── tags.comment.md │ ├── tags.templated.md │ ├── tags.unescaped.md │ ├── tags.escaped.md │ ├── test.html │ ├── tags.scriptlet.md │ └── ejs.html ├── bindings │ ├── bindings.md │ ├── hyperloop.html │ ├── input-text.html │ ├── select.html │ ├── input-radio.html │ ├── can-event.html │ ├── input-checkbox.html │ └── test.html ├── test.html ├── live │ └── test.html ├── modifiers │ ├── test.html │ └── modifiers.md ├── scope │ ├── test.html │ ├── scope.md │ └── readOptions.md └── node_lists │ ├── test.html │ └── node_lists_test.js ├── guides ├── Home.md ├── Applications-using-CanJS.md ├── 3rd-Party-Plugins-and-Extensions.md ├── Guides.md ├── components │ ├── template-1.html │ ├── template-0.html │ ├── template-2.html │ ├── template.html │ ├── scope-0.html │ ├── scope-1.html │ ├── scope-2.html │ ├── scope-3.html │ ├── helpers-0.html │ ├── meetup-working.html │ └── meetup-start.html ├── recipes.md ├── CanJS-Website-Structure.md ├── deferred.md ├── recipes_livebindings.md ├── tutorial.md ├── CanJS-blog-posts,-tutorials,-and-examples.md └── using.md ├── util ├── fixture │ ├── fixtures │ │ ├── foo.json │ │ ├── stuff.3.json │ │ ├── foobar.json │ │ ├── remove.json │ │ ├── test.json │ │ └── messages.html │ ├── xhr.md │ ├── test.html │ ├── store.md │ └── responseHandler.md ├── zepto │ ├── thing.json │ ├── qunit.html │ └── zepto_test.js ├── mvc.js ├── util.md ├── util_test.js ├── library.js ├── util.js ├── array │ ├── makeArray.js │ └── each.js ├── inserted │ ├── inserted_test.js │ ├── test.html │ └── inserted.js ├── all.js ├── string │ ├── classize.js │ ├── deparam │ │ ├── qunit.html │ │ ├── deparam_test.js │ │ └── deparam.js │ ├── rsplit │ │ └── rsplit.js │ └── qunit.html ├── hashchange.js ├── object │ ├── qunit.html │ └── isplain │ │ ├── qunit.html │ │ └── isplain.js ├── function │ └── function.js ├── destroyed.js ├── event │ └── test.html └── bind │ └── bind.js ├── control ├── view │ ├── test │ │ ├── views │ │ │ └── init.micro │ │ └── view_test.js │ ├── test.html │ └── view.md ├── eventHandler.md ├── eventDescription.md ├── modifier │ ├── key │ │ ├── key_test.js │ │ ├── qunit.html │ │ └── key.html │ └── test.html ├── control.processor.md ├── route │ ├── route.js │ ├── pushstate.html │ ├── test.html │ └── route.md ├── test.html └── plugin │ ├── test.html │ ├── plugin.html │ └── demo-update.html ├── model ├── test │ ├── 4.json │ ├── create.json │ ├── update4.json │ ├── person.json │ ├── schools.json │ ├── findAll.json │ └── people.json ├── findOneData.md ├── list │ └── qunit.html ├── store │ └── qunit.html ├── findAllData.md ├── queue │ ├── qunit.html │ └── queue.html ├── cached │ └── qunit.html ├── test.html ├── pages │ └── deferreds.md └── local │ └── local.js ├── .travis.yml ├── .editorconfig ├── can.js ├── .gitignore ├── observe ├── observe.js └── test.html ├── component ├── tag.md ├── examples │ ├── my_greeting_full.html │ ├── click_me.html │ ├── hello-world.html │ ├── paginate_next.html │ ├── grid.js │ ├── paginate_events_next.html │ ├── paginate_events_next_update_page.html │ ├── name_editor.html │ ├── list.html │ └── selected.html ├── helpers.md ├── extend.md └── test.html ├── bower.json ├── map ├── sort │ ├── sort.md │ └── test.html ├── benchmark.html ├── map_benchmark.js ├── validations │ ├── model_validations.html │ └── test.html ├── test.html ├── setter │ ├── test.html │ ├── setter.html │ └── setter_test.js ├── backup │ ├── test.html │ └── backup.md ├── delegate │ └── test.html ├── attributes │ └── test.html └── list │ └── test.html ├── compute ├── computed.md └── test.html ├── .gitattributes ├── test ├── test.js ├── benchmarks.js ├── templates │ ├── test.html.ejs │ ├── __configuration__.html.ejs │ ├── __configuration__-dist.html.ejs │ ├── __configuration__-amd.html.ejs │ ├── __configuration__-dev.html.ejs │ └── __configuration__-compat.html.ejs └── index.html ├── .jsbeautifyrc ├── readme.md ├── .jshintrc ├── route ├── testing.html ├── pushstate │ ├── testing.html │ ├── binding.md │ ├── test.html │ └── pushstate.html └── test.html ├── list └── test.html ├── construct ├── test.html ├── proxy │ ├── test.html │ ├── proxy_test.js │ └── proxy.html ├── super │ ├── test.html │ ├── super.js │ ├── super.html │ └── super_test.js └── construct.html ├── license.md ├── package.json └── can.md /view/test/deferred.ejs: -------------------------------------------------------------------------------- 1 | <%= foo %> -------------------------------------------------------------------------------- /guides/Home.md: -------------------------------------------------------------------------------- 1 | Welcome to the canjs wiki! -------------------------------------------------------------------------------- /view/test/template.tmpl: -------------------------------------------------------------------------------- 1 |

${message}

-------------------------------------------------------------------------------- /util/fixture/fixtures/foo.json: -------------------------------------------------------------------------------- 1 | {"a" : "b"} 2 | -------------------------------------------------------------------------------- /view/test/deferreds.ejs: -------------------------------------------------------------------------------- 1 | <%= foo %> and <%= bar %> -------------------------------------------------------------------------------- /view/test/extensionless: -------------------------------------------------------------------------------- 1 |

{{ message }}

-------------------------------------------------------------------------------- /view/test/temp.ejs: -------------------------------------------------------------------------------- 1 |

<%= message %>

2 | -------------------------------------------------------------------------------- /view/test/template.ejs: -------------------------------------------------------------------------------- 1 |

<%= message %>

-------------------------------------------------------------------------------- /view/test/template.micro: -------------------------------------------------------------------------------- 1 |

{%= message %}

2 | -------------------------------------------------------------------------------- /view/test/template.mustache: -------------------------------------------------------------------------------- 1 |

{{ message }}

-------------------------------------------------------------------------------- /control/view/test/views/init.micro: -------------------------------------------------------------------------------- 1 |

Hello World

-------------------------------------------------------------------------------- /util/fixture/fixtures/stuff.3.json: -------------------------------------------------------------------------------- 1 | { 2 | "id" : 3 3 | } -------------------------------------------------------------------------------- /view/mustache/test/test_template.mustache: -------------------------------------------------------------------------------- 1 | Partials Rock -------------------------------------------------------------------------------- /model/test/4.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": 4, 3 | "name" : "adler" 4 | } -------------------------------------------------------------------------------- /view/mustache/test/hello.mustache: -------------------------------------------------------------------------------- 1 |

Hello {{> name}}

2 | -------------------------------------------------------------------------------- /view/mustache/test/noglobals.mustache: -------------------------------------------------------------------------------- 1 | {{sometext person.name}} -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 0.8 3 | script: npm test -------------------------------------------------------------------------------- /model/test/create.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": 4, 3 | "name" : "Highland" 4 | } -------------------------------------------------------------------------------- /model/test/update4.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": 4, 3 | "name" : "LHS" 4 | } -------------------------------------------------------------------------------- /util/fixture/fixtures/foobar.json: -------------------------------------------------------------------------------- 1 | { 2 | "sweet" :"ner" 3 | } 4 | -------------------------------------------------------------------------------- /util/fixture/fixtures/remove.json: -------------------------------------------------------------------------------- 1 | { 2 | "weird" : "ness" 3 | } 4 | -------------------------------------------------------------------------------- /util/fixture/fixtures/test.json: -------------------------------------------------------------------------------- 1 | { 2 | "sweet" :"ness" 3 | } 4 | -------------------------------------------------------------------------------- /util/zepto/thing.json: -------------------------------------------------------------------------------- 1 | { 2 | "id" :1, 3 | "name": "foo" 4 | } 5 | -------------------------------------------------------------------------------- /view/mustache/test/helper.mustache: -------------------------------------------------------------------------------- 1 |

Hello {{cap name}}

2 | -------------------------------------------------------------------------------- /view/mustache/test/partial.mustache: -------------------------------------------------------------------------------- 1 | {{#list}}{{.}}{{/list}} -------------------------------------------------------------------------------- /model/test/person.json: -------------------------------------------------------------------------------- 1 | { 2 | "id" : 5, 3 | "name" : "Justin" 4 | } 5 | -------------------------------------------------------------------------------- /model/test/schools.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "id": 1, 3 | "name" : "adler" 4 | }] 5 | -------------------------------------------------------------------------------- /util/mvc.js: -------------------------------------------------------------------------------- 1 | steal('can/model', 'can/control/route', 'can/view/ejs'); 2 | -------------------------------------------------------------------------------- /view/ejs/test/easyhookup.ejs: -------------------------------------------------------------------------------- 1 |
can.addClass(el,text) %>> -------------------------------------------------------------------------------- /view/test/helpers.ejs: -------------------------------------------------------------------------------- 1 |

<%= message %>

<%= helper() %>
-------------------------------------------------------------------------------- /view/test/helpers.mustache: -------------------------------------------------------------------------------- 1 |

{{ message }}

{{helper}}
-------------------------------------------------------------------------------- /view/test/template.jaml: -------------------------------------------------------------------------------- 1 | function(data) { 2 | h3(data.message); 3 | } -------------------------------------------------------------------------------- /model/test/findAll.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "id" : 1, 3 | "name" : "Thing 1" 4 | }] 5 | -------------------------------------------------------------------------------- /model/test/people.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "id" : 5, 3 | "name" : "Justin" 4 | }] 5 | -------------------------------------------------------------------------------- /view/mustache/test/easyhookup.mustache: -------------------------------------------------------------------------------- 1 |
can.addClass(el,text)}}> -------------------------------------------------------------------------------- /view/mustache/test/fancy_name.mustache: -------------------------------------------------------------------------------- 1 | {{name}} 2 | -------------------------------------------------------------------------------- /view/test/hookup.ejs: -------------------------------------------------------------------------------- 1 |
/> -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | ; Unix-style newlines 2 | [*] 3 | end_of_line = LF 4 | indent_style = tab 5 | -------------------------------------------------------------------------------- /util/util.md: -------------------------------------------------------------------------------- 1 | @page can.util can.util 2 | @parent canjs 3 | 4 | Utility methods supported by CanJS -------------------------------------------------------------------------------- /view/test/nested_plugin.ejs: -------------------------------------------------------------------------------- 1 |
el.text("Here is something") %> id='something'>
-------------------------------------------------------------------------------- /util/util_test.js: -------------------------------------------------------------------------------- 1 | steal('./fixture/fixture_test.js', './object/object_test.js', './string/string_test.js'); 2 | -------------------------------------------------------------------------------- /view/test/plugin.ejs: -------------------------------------------------------------------------------- 1 |
can.append(el,"Here is something") %> id='something'>
-------------------------------------------------------------------------------- /view/ejs/test/binding.ejs: -------------------------------------------------------------------------------- 1 |
'> 2 | <%== task.attr('name') %> 3 |
-------------------------------------------------------------------------------- /util/library.js: -------------------------------------------------------------------------------- 1 | // This is mainly used for the AMD build 2 | steal('can/util/jquery', function (can) { 3 | return can; 4 | }); 5 | -------------------------------------------------------------------------------- /view/mustache/test/table.mustache: -------------------------------------------------------------------------------- 1 | {{#data}}{{{> view/mustache/test/partial.mustache}}}{{/data}}
-------------------------------------------------------------------------------- /can.js: -------------------------------------------------------------------------------- 1 | steal('can/util', 'can/control/route', 'can/model', 2 | 'can/view/mustache', 'can/component', function(can) { 3 | return can; 4 | }); -------------------------------------------------------------------------------- /util/util.js: -------------------------------------------------------------------------------- 1 | // comments are in func.js for documentation purposes. 2 | steal('can/util/jquery', function (can) { 3 | return can; 4 | }); 5 | -------------------------------------------------------------------------------- /guides/Applications-using-CanJS.md: -------------------------------------------------------------------------------- 1 | ## Jumboiskon 2 | - website - https://jumbo.iskon.hr/index 3 | - developers 4 | - http://www.revolucija.hr -------------------------------------------------------------------------------- /model/findOneData.md: -------------------------------------------------------------------------------- 1 | @typedef {function} can.Model.findOneData findOneData 2 | 3 | @param {Object} params 4 | @return {can.Deferred} A deferred 5 | -------------------------------------------------------------------------------- /view/test/hookupvalcall.ejs: -------------------------------------------------------------------------------- 1 |
>
4 | -------------------------------------------------------------------------------- /control/eventHandler.md: -------------------------------------------------------------------------------- 1 | @typedef {function} can.Control.eventHandler eventHandler(element, event) 2 | @parent can.Control.types 3 | 4 | @signature `function(element, event)` 5 | 6 | -------------------------------------------------------------------------------- /util/fixture/xhr.md: -------------------------------------------------------------------------------- 1 | @typedef {{}} can.AjaxSettings 2 | 3 | @description The options available to be passed to [can.ajax]. 4 | 5 | @option {String} url 6 | @option {*} data 7 | 8 | -------------------------------------------------------------------------------- /view/ejs/test/nested_live_bindings.ejs: -------------------------------------------------------------------------------- 1 |
2 | {{#items}} 3 | {{ !item.attr('is_done') }} 4 |
5 | {{/item}} 6 | {{/items}} 7 |
-------------------------------------------------------------------------------- /control/eventDescription.md: -------------------------------------------------------------------------------- 1 | @typedef {String} can.Control.eventDescription eventDescription 2 | @parent can.Control.types 3 | 4 | @signature `"[CONTEXT ][SELECTOR ]EVENTNAME"` 5 | 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .tmp* 2 | /dist 3 | *.swp 4 | *.orig 5 | util/can.*.js 6 | *node_modules* 7 | standalone* 8 | docs* 9 | *.DS_Store 10 | .idea 11 | bower_components/ 12 | test/pluginified/latest.js -------------------------------------------------------------------------------- /view/ejs/test/shared_blocks.ejs: -------------------------------------------------------------------------------- 1 | <% for(var i = 0; i < items.length; i++) { %> 2 | <% if(this.mode !== "RESULTS") { 3 | if(items[i] !== "SOME_FAKE_VALUE") { %> 4 | hi 5 | <% } 6 | } else { %> 7 | nope 8 | <% } 9 | } %> -------------------------------------------------------------------------------- /util/array/makeArray.js: -------------------------------------------------------------------------------- 1 | steal('./each.js', function () { 2 | can.makeArray = function (arr) { 3 | var ret = []; 4 | can.each(arr, function (a, i) { 5 | ret[i] = a; 6 | }); 7 | return ret; 8 | }; 9 | return can; 10 | }); 11 | -------------------------------------------------------------------------------- /view/ejs/tags.comment.md: -------------------------------------------------------------------------------- 1 | @function can.EJS.tags.comment <%# CODE %> 2 | @parent can.EJS.tags 4 3 | 4 | 5 | @signature `<%# CODE %>` 6 | 7 | Used for explicitly for comments. This will not render anything. 8 | 9 | <%# 'hello world' %> -------------------------------------------------------------------------------- /guides/3rd-Party-Plugins-and-Extensions.md: -------------------------------------------------------------------------------- 1 | ## AppSwitcher 2 | 3 | Listens to changes in a can.route attribute and loads/unloads apps (can.Control). 4 | 5 | - https://github.com/thecountofzero/tcoz/tree/master/app_switcher 6 | - thecountofzero, @countofzero -------------------------------------------------------------------------------- /view/ejs/test/indirect1.ejs: -------------------------------------------------------------------------------- 1 |
    2 | <% unordered.each(function(item) { %> 3 |
  • 4 | <% if(item.ol) { %> 5 | <%== can.view.render(can.test.path('view/ejs/test/indirect2.ejs'), { ordered: item.ol }) %> 6 | <% } else { %> 7 | <%= item.toString() %> 8 | <% } %> 9 |
  • 10 | <% }) %> 11 |
-------------------------------------------------------------------------------- /view/ejs/test/indirect2.ejs: -------------------------------------------------------------------------------- 1 |
    2 | <% ordered.each(function(item) { %> 3 |
  1. 4 | <% if(item.ul) { %> 5 | <%== can.view.render(can.test.path('view/ejs/test/indirect1.ejs'), { unordered: item.ul }) %> 6 | <% } else { %> 7 | <%= item.toString() %> 8 | <% } %> 9 |
  2. 10 | <% }) %> 11 |
-------------------------------------------------------------------------------- /observe/observe.js: -------------------------------------------------------------------------------- 1 | // Loads all observable core modules 2 | steal("can/util", "can/map", "can/list", "can/compute", function (can) { 3 | can.Observe = can.Map; 4 | can.Observe.startBatch = can.batch.start; 5 | can.Observe.stopBatch = can.batch.stop; 6 | can.Observe.triggerBatch = can.batch.trigger; 7 | return can; 8 | }); 9 | -------------------------------------------------------------------------------- /view/test/select.ejs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /guides/Guides.md: -------------------------------------------------------------------------------- 1 | @page guides Guides 2 | 3 | @body 4 | This page contains recipes and tutorials that will get you started with building CanJS projects. Choose a section on the left to learn more about the components that make CanJS work and to see CanJS being used in real projects. If you're new to CanJS, a good starting point is [Why Why CanJS?] 5 | -------------------------------------------------------------------------------- /util/inserted/inserted_test.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | module('can/util/inserted'); 3 | if (window.jQuery) { 4 | test('jquery', function () { 5 | var el = $('
'); 6 | el.bind('inserted', function () { 7 | ok(true, 'inserted called'); 8 | }); 9 | $('#qunit-test-area') 10 | .append(el); 11 | }); 12 | } 13 | }()); 14 | -------------------------------------------------------------------------------- /view/mustache/test/recursive.mustache: -------------------------------------------------------------------------------- 1 |
2 | {{#items}} 3 |
4 | {{#item.children}} 5 |
6 | {{>'view/ejs/recursive.ejs'}} 7 |
8 | {{/item.children}} 9 | {{^item.children}} 10 |
L
11 | {{/item.children}} 12 |
13 | {{/items}} 14 |
15 | -------------------------------------------------------------------------------- /view/ejs/test/test_template.ejs: -------------------------------------------------------------------------------- 1 | <%# Test Something Produces Items%> 2 | <%== something(function(items){ %> 3 | <%== items.length%> 4 | <% can.each(items, function(){ %><%# Test Something Produces Items%> 5 | <%== something(function(items){ %>ItemsLength<%== items.length %><% }) %> 6 | <% }) %> 7 | <% }) %> 8 | <% for( var i =0; i < items.length; i++) { %>for <%= items[i] %><% } %> -------------------------------------------------------------------------------- /view/bindings/bindings.md: -------------------------------------------------------------------------------- 1 | @page can.view.bindings 2 | @parent can.view.plugins 3 | 4 | Provides template bindings and two-way bindings. 5 | 6 | @body 7 | 8 | ## Use 9 | 10 | The `can/view/bindings` plugin provides helpers useful for template declarative 11 | binding and two-way bindings. This plugin is included by default 12 | in core CanJS. 13 | 14 | @demo can/view/bindings/hyperloop.html -------------------------------------------------------------------------------- /view/ejs/tags.templated.md: -------------------------------------------------------------------------------- 1 | @function can.EJS.tags.templated <%% CODE %> 2 | @parent can.EJS.tags 3 3 | 4 | @signature `<%% CODE %>` 5 | 6 | Renders <% CODE %> as text in result of the template rather than running CODE itself. This is useful for generators. 7 | 8 | The following results in "<%= 'hello world' %>" rather than the string "hello world." 9 | 10 | <%%= 'hello world' %> -------------------------------------------------------------------------------- /component/tag.md: -------------------------------------------------------------------------------- 1 | @property {String} can.Component.prototype.tag 2 | @parent can.Component.prototype 3 | 4 | Specifies the HTML tag (or node-name) the can.Component will be created on. 5 | 6 | @option {String} The tag name the can.Component 7 | will be created on. Tag names are typically lower cased and 8 | hypenated like: "foo-bar". Component's register their 9 | tag with [can.view.tag]. 10 | 11 | 12 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "CanJS", 3 | "repo": "bitovi/canjs", 4 | "description": "Can do JavaScript MVC", 5 | "main": "can.jquery.js", 6 | "keywords": [ 7 | "mvc", 8 | "component", 9 | "amd" 10 | ], 11 | "license": "MIT", 12 | "devDependencies": { 13 | "qunit": "~1.12.0", 14 | "zepto": "~1.0.0", 15 | "benchmark": "~1.0.0", 16 | "requirejs": "~2.1.10" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /view/ejs/tags.unescaped.md: -------------------------------------------------------------------------------- 1 | @function can.EJS.tags.unescaped <%== CODE %> 2 | @parent can.EJS.tags 2 3 | 4 | @signature `<%== CODE %>` 5 | 6 | Runs JS Code and writes the _unescaped_ result into the result of the template. 7 | 8 | The following results in "my favorite element is B.". Using `<%==` is useful 9 | for sub-templates. 10 | 11 |
my favorite element is <%== 'B' %>.
-------------------------------------------------------------------------------- /view/ejs/test/recursive.ejs: -------------------------------------------------------------------------------- 1 |
2 | <% items.each(function(item){ %> 3 |
4 | <% if( item.attr('children') ) { %> 5 |
6 | <%== can.view.render(can.test.path('view/ejs/test/recursive.ejs'), {items:item.attr('children')}) %> 7 |
8 | <%} else {%> 9 |
L
10 | <%}%> 11 |
12 | <%}) %> 13 |
14 | -------------------------------------------------------------------------------- /map/sort/sort.md: -------------------------------------------------------------------------------- 1 | @page can.List.prototype.sort 2 | @parent can.List.prototype 3 | @plugin can/map/sort 4 | @test can/map/sort/test.html 5 | 6 | `list.sort(sortfunc)` 7 | 8 | Sorts the instances in the list. 9 | 10 | var list = new can.List([ 11 | { name: 'Justin' }, 12 | { name: 'Brian' }, 13 | { name: 'Austin' }, 14 | { name: 'Mihael' }]) 15 | 16 | list.comparator = 'name'; 17 | list.sort(); //- sorts the list by the name attribute -------------------------------------------------------------------------------- /guides/components/template-1.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | -------------------------------------------------------------------------------- /guides/components/template-0.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | -------------------------------------------------------------------------------- /view/mustache/doc/key.md: -------------------------------------------------------------------------------- 1 | @typedef {String} can.Mustache.key key 2 | @parent can.Mustache.types 3 | 4 | A key references a value within the current [can.Mustache.context context] of a 5 | template being rendered. In the following example, the 6 | key is `name`: 7 | 8 |

{{name}}

9 | 10 | If this template is rendered with: 11 | 12 | { 13 | name: "Austin" 14 | } 15 | 16 | The template writes out: 17 | 18 |

Austin

19 | -------------------------------------------------------------------------------- /guides/components/template-2.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | -------------------------------------------------------------------------------- /map/benchmark.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

can.Map Test Suite

7 | 8 |

9 | 10 |
11 |

12 |
    13 |
    14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /util/all.js: -------------------------------------------------------------------------------- 1 | steal( 2 | 'can/component', 3 | 'can/construct', 4 | 'can/construct/proxy', 5 | 'can/control', 6 | 'can/control/route', 7 | 'can/control/plugin', 8 | 'can/list', 9 | 'can/model', 10 | 'can/observe', 11 | 'can/map/attributes', 12 | 'can/map/backup', 13 | 'can/map/delegate', 14 | 'can/map/setter', 15 | 'can/map/validations', 16 | 'can/route', 17 | 'can/view/ejs', 18 | 'can/util/fixture', 19 | 'can/view/modifiers', 20 | 'can/view/mustache', 21 | 'can/util/func.js'); 22 | -------------------------------------------------------------------------------- /view/ejs/tags.escaped.md: -------------------------------------------------------------------------------- 1 | @function can.EJS.tags.escaped <%= CODE %> 2 | @parent can.EJS.tags 1 3 | 4 | 5 | @signature `<%= CODE %>` 6 | 7 | Runs JS Code and writes the _escaped_ result into the result of the template. This is useful for when you want to show code in your page. 8 | 9 | The following results in the user seeing "my favorite element is <blink>BLINK<blink>" and not 10 | BLINK. 11 | 12 |
    my favorite element is <%= 'BLINK' %>.
    13 | -------------------------------------------------------------------------------- /view/ejs/test/foo.js: -------------------------------------------------------------------------------- 1 | /*global list,animals*/ 2 | var ___v1ew = []; 3 | ___v1ew.push('
    myfavoriteanimals:'); 4 | ___v1ew.push(can.view.txt(0, 'div', 0, this, function () { 5 | var ___v1ew = []; 6 | list(animals, function (animal) { 7 | ___v1ew.push(' '); 8 | ___v1ew.push(can.view.txt(1, 'span', 0, this, function () { 9 | return animal; 10 | })); 11 | ___v1ew.push(''); 12 | }); 13 | return ___v1ew.join(''); 14 | })); 15 | ___v1ew.push('!
    '); 16 | -------------------------------------------------------------------------------- /guides/components/template.html: -------------------------------------------------------------------------------- 1 |
    2 | 3 | 4 | -------------------------------------------------------------------------------- /compute/computed.md: -------------------------------------------------------------------------------- 1 | @function can.computed compute 2 | @parent can.compute 3 | 4 | @signature `compute( [newVal] )` 5 | 6 | @param {*} [newVal] If `compute` is called with an argument, the first argument is used 7 | to set the compute to a new value. This may trigger a 8 | `"change"` event that can be listened for with [can.computed.bind]. 9 | 10 | If the compute is called without any arguments (`compute()`), it simply returns 11 | the current value of the compute. 12 | 13 | @return {*} The current value of the compute. 14 | -------------------------------------------------------------------------------- /map/map_benchmark.js: -------------------------------------------------------------------------------- 1 | steal('can/map', 'can/list', 'can/test/benchmarks.js', function (Map, List, benchmarks) { 2 | var objects, map; 3 | benchmarks.add('Adding a big array to an object', function () { 4 | objects = []; 5 | for (var i = 0; i < 10; i++) { 6 | objects.push({ 7 | prop: 'prop', 8 | nest: { 9 | prop: 'prop', 10 | nest: { 11 | prop: 'prop' 12 | } 13 | } 14 | }); 15 | } 16 | }, function () { 17 | map = new can.Map(); 18 | map.attr('obj', objects); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /util/string/classize.js: -------------------------------------------------------------------------------- 1 | steal('./string', function () { 2 | /** 3 | * Like [can.camelize camelize], but the first part is also capitalized 4 | * @param {String} s 5 | * @return {String} the classized string 6 | */ 7 | can.classize = function (s, join) { 8 | // this can be moved out .. 9 | // used for getter setter 10 | var parts = s.split(can.undHash), 11 | i = 0; 12 | for (; i < parts.length; i++) { 13 | parts[i] = can.capitalize(parts[i]); 14 | } 15 | return parts.join(join || ''); 16 | }; 17 | }); 18 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /util/hashchange.js: -------------------------------------------------------------------------------- 1 | steal('can/util/can.js', function (can) { 2 | // This is a workaround for libraries that don't natively listen to the window hashchange event 3 | (function () { 4 | var addEvent = function (el, ev, fn) { 5 | if (el.addEventListener) { 6 | el.addEventListener(ev, fn, false); 7 | } else if (el.attachEvent) { 8 | el.attachEvent('on' + ev, fn); 9 | } else { 10 | el['on' + ev] = fn; 11 | } 12 | }, onHashchange = function () { 13 | can.trigger(window, 'hashchange'); 14 | }; 15 | addEvent(window, 'hashchange', onHashchange); 16 | }()); 17 | }); 18 | -------------------------------------------------------------------------------- /model/list/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

    Model List Test Suite

    9 |

    10 |
    11 |

    12 |
    13 |
      14 |
      15 | 16 | -------------------------------------------------------------------------------- /map/validations/model_validations.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 20 | 21 | -------------------------------------------------------------------------------- /component/examples/my_greeting_full.html: -------------------------------------------------------------------------------- 1 | 2 |
      3 | 10 | 11 | 12 | 27 | 28 | -------------------------------------------------------------------------------- /guides/recipes.md: -------------------------------------------------------------------------------- 1 | @page Recipes Recipes 2 | @parent guides 4 3 | 4 | @body 5 | To the left is a list of __CanJS__ recipes to help you learn CanJS. To 6 | add your own, simply [edit this file](https://github.com/bitovi/canjs/edit/gh-pages/recipes.md). To 7 | help create a JSFiddle, we've created the following fiddles you can fork: 8 | 9 | - [jQuery and CanJS](http://jsfiddle.net/donejs/qYdwR/) 10 | - [Zepto and CanJS](http://jsfiddle.net/donejs/7Yaxk/) 11 | - [Dojo and CanJS](http://jsfiddle.net/donejs/9x96n/) 12 | - [YUI and CanJS](http://jsfiddle.net/donejs/w6m73/) 13 | - [Mootools and CanJS](http://jsfiddle.net/donejs/mnNJX/) 14 | -------------------------------------------------------------------------------- /view/bindings/hyperloop.html: -------------------------------------------------------------------------------- 1 |
      2 | 3 | 30 | 31 | -------------------------------------------------------------------------------- /view/bindings/input-text.html: -------------------------------------------------------------------------------- 1 |
      2 | 3 | 30 | 31 | -------------------------------------------------------------------------------- /model/store/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | store QUnit Test 5 | 6 | 7 | 8 | 9 |

      store Test Suite

      10 |

      11 |
      12 |

      13 |
      14 |
        15 |
        16 | 17 | -------------------------------------------------------------------------------- /component/examples/click_me.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 23 | -------------------------------------------------------------------------------- /control/modifier/key/key_test.js: -------------------------------------------------------------------------------- 1 | steal('can/control/modifier/key', function (Control) { 2 | module('can/control/modifier/key'); 3 | test('key down triggered', 1, function () { 4 | var Tester = can.Control({ 5 | 'keydown': function () {}, 6 | 'keydown:(shift+p)': function (elm, ev) { 7 | ok('key event pressed!'); 8 | } 9 | }); 10 | new Tester(document.body); 11 | // trigger event 12 | var e = jQuery.Event('keydown'); 13 | e.which = 80; 14 | e.keyCode = 80; 15 | e.shiftKey = true; 16 | e.altKey = false; 17 | e.charCode = 0; 18 | e.ctrlKey = false; 19 | e.metaKey = false; 20 | $(document.body) 21 | .trigger(e); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /util/string/deparam/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

        Deparam Test Suite

        8 |

        9 |
        10 |

        11 |
          12 |
          13 | associations 14 | list 15 | 16 | 17 | -------------------------------------------------------------------------------- /model/findAllData.md: -------------------------------------------------------------------------------- 1 | @typedef {function} can.Model.findAllData findAllData 2 | 3 | Retrieves a list of items for [can.Model.models], typically by making an 4 | Ajax request. 5 | 6 | @param {Object} params Specifies the list to be retrieved. 7 | 8 | @return {can.Deferred} A deferred that resolves to a data structure 9 | that can be understood by [can.Model.models]. 10 | 11 | 12 | 13 | 14 | @body 15 | 16 | ## Use 17 | 18 | Typically, `findAll` is implemented with a "string" or [can.AjaxSettings ajax settings object] like: 19 | 20 | findAll: "GET /tasks" 21 | 22 | or 23 | 24 | findAll: {url: "/tasks", dataType: "custom"} 25 | 26 | [can.Model.setup] converts 27 | -------------------------------------------------------------------------------- /control/view/test/view_test.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | /* global Myproject */ 3 | module('can/control/view'); 4 | test('complex paths nested inside a controller directory', function () { 5 | can.Control.extend('Myproject.Controllers.Foo.Bar'); 6 | //var path = jQuery.Controller._calculatePosition(Myproject.Controllers.Foo.Bar, "init.ejs", "init") 7 | //equal(path, "//myproject/views/foo/bar/init.ejs", "view path is correct") 8 | can.Control.extend('Myproject.Controllers.FooBar'); 9 | var path = can.Control._calculatePosition(Myproject.Controllers.FooBar, 'init.ejs', 'init'); 10 | equal(path, '//myproject/views/foo_bar/init.ejs', 'view path is correct'); 11 | }); 12 | }()); 13 | -------------------------------------------------------------------------------- /view/ejs/test/todo_comments.ejs: -------------------------------------------------------------------------------- 1 | 2 | <% this.each(function( todo ) { %> 3 | 4 |
        1. el.data('todo',todo) %>> 5 | 6 | > 8 | 9 | 10 | 11 | <%= todo.attr('name') %> 12 | 13 | 14 | 15 | X 16 |
        2. 17 | <% }) %> -------------------------------------------------------------------------------- /view/mustache/doc/renderer.md: -------------------------------------------------------------------------------- 1 | @typedef {function(Object,Object.):documentFragment} can.view.renderer(data,helpers) renderer 2 | 3 | @description A function returned by [can.view], [can.view.ejs], [can.view.mustache] that renders a 4 | template into an html documentFragment. 5 | 6 | @param {Object} data An object of data used to render the template. 7 | 8 | @param {Object.} helpers Local helper functions used by the template. 9 | 10 | @return {documentFragment} A documentFragment that contains the HTML rendered by the template. 11 | 12 | @body 13 | 14 | A "renderer" function is a function returned by various [can.view] APIs that can be used 15 | to render data into a documentFragment. 16 | -------------------------------------------------------------------------------- /component/examples/hello-world.html: -------------------------------------------------------------------------------- 1 |
          2 |
          3 | 6 |
          7 | 8 | 29 | 30 | -------------------------------------------------------------------------------- /guides/components/scope-0.html: -------------------------------------------------------------------------------- 1 |
          2 | 3 | -------------------------------------------------------------------------------- /guides/components/scope-1.html: -------------------------------------------------------------------------------- 1 |
          2 | 3 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | steal('can/util', function() { 2 | var viewCheck = /(\.mustache|\.ejs|extensionless)$/; 3 | 4 | can.test = { 5 | fixture: function (path) { 6 | if (typeof steal !== 'undefined') { 7 | return steal.config('root').toString() + '/' + path; 8 | } 9 | 10 | if (window.require && require.toUrl && !viewCheck.test(path)) { 11 | return require.toUrl(path); 12 | } 13 | return path; 14 | }, 15 | path: function (path) { 16 | if (typeof steal !== 'undefined') { 17 | return ""+steal.idToUri(steal.id("can/"+path).toString()) ; 18 | } 19 | 20 | if (window.require && require.toUrl && !viewCheck.test(path)) { 21 | return require.toUrl(path); 22 | } 23 | return path; 24 | } 25 | } 26 | }); 27 | -------------------------------------------------------------------------------- /util/string/rsplit/rsplit.js: -------------------------------------------------------------------------------- 1 | steal('can/util', 'can/util/string', function (can) { 2 | /** 3 | * @add jQuery.String 4 | */ 5 | can.rsplit = function (string, regex) { 6 | var result = regex.exec(string), 7 | retArr = [], 8 | first_idx, last_idx; 9 | while (result !== null) { 10 | first_idx = result.index; 11 | last_idx = regex.lastIndex; 12 | if (first_idx !== 0) { 13 | retArr.push(string.substring(0, first_idx)); 14 | string = string.slice(first_idx); 15 | } 16 | retArr.push(result[0]); 17 | string = string.slice(result[0].length); 18 | result = regex.exec(string); 19 | } 20 | if (string !== '') { 21 | retArr.push(string); 22 | } 23 | return retArr; 24 | }; 25 | return can; 26 | }); 27 | -------------------------------------------------------------------------------- /view/ejs/test/table_test.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | <% games.each( function(game) { %> 10 | 11 | 12 | 13 | 14 | <% }) %> 15 | <% games.each( function(game) { %> 16 | 17 | 18 | 19 | 20 | <% }) %> 21 | 22 |
          Game Name Rating
          <%= game.attr('name') %> <%= game.attr('rating') %>
          <%= game.attr('name') %> <%= game.attr('rating') %>
          -------------------------------------------------------------------------------- /guides/components/scope-2.html: -------------------------------------------------------------------------------- 1 |
          2 | 3 | -------------------------------------------------------------------------------- /component/examples/paginate_next.html: -------------------------------------------------------------------------------- 1 | 2 |
          3 | 4 | 25 | -------------------------------------------------------------------------------- /test/benchmarks.js: -------------------------------------------------------------------------------- 1 | steal("steal","benchmark", function(steal){ 2 | 3 | var suite = new Benchmark.Suite; 4 | 5 | suite.on('cycle', function(event) { 6 | console.log(String(event.target)); 7 | }) 8 | 9 | var benchmarks = { 10 | add: function(name, setup, benchmark){ 11 | if(!benchmark){ 12 | benchmark = setup; 13 | setup = undefined 14 | } 15 | suite.add(name, benchmark, { 16 | setup: setup 17 | }); 18 | return this; 19 | }, 20 | run: function(){ 21 | suite.run({ 'async': true, 'queued': true }); 22 | }, 23 | suite: suite, 24 | on: function(){ 25 | return suite.on.apply(this, arguments) 26 | } 27 | } 28 | steal.bind("done", function(){ 29 | benchmarks.run(); 30 | }) 31 | 32 | return benchmarks; 33 | }) 34 | -------------------------------------------------------------------------------- /.jsbeautifyrc: -------------------------------------------------------------------------------- 1 | { 2 | "html": { 3 | "braceStyle": "collapse", 4 | "indentWithTabs": true, 5 | "indentScripts": "keep", 6 | "maxPreserveNewlines": 10, 7 | "preserveNewlines": true, 8 | "unformatted": ["a", "sub", "sup", "b", "i", "u"], 9 | "wrapLineLength": 0 10 | }, 11 | "css": { 12 | "indentWithTabs": true 13 | }, 14 | "js": { 15 | "braceStyle": "expanded", 16 | "breakChainedMethods": true, 17 | "e4x": false, 18 | "evalCode": false, 19 | "indentLevel": 0, 20 | "indentWithTabs": true, 21 | "jslintHappy": true, 22 | "keepFunctionIndentation": false, 23 | "maxPreserveNewlines": 2, 24 | "preserveNewlines": true, 25 | "spaceBeforeConditional": true, 26 | "spaceInParen": false, 27 | "unescapeStrings": false, 28 | "wrapLineLength": 0 29 | } 30 | } -------------------------------------------------------------------------------- /view/bindings/select.html: -------------------------------------------------------------------------------- 1 |
          2 | 3 | 30 | 31 | -------------------------------------------------------------------------------- /test/templates/test.html.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

          <%= module.definition.name %> Test Suite

          8 | 9 |

          10 | 11 |
          12 |

          13 |
            14 |
            15 | 16 | 17 | 18 | 21 | 22 | -------------------------------------------------------------------------------- /util/object/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

            can.List Test Suite

            8 | 9 |

            10 | 11 |
            12 |

            13 |
              14 |
              15 | 16 | 17 | 18 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /util/string/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

              can.List Test Suite

              8 | 9 |

              10 | 11 |
              12 |

              13 |
                14 |
                15 | 16 | 17 | 18 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /util/fixture/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                can.fixture Test Suite

                8 | 9 |

                10 | 11 |
                12 |

                13 |
                  14 |
                  15 | 16 | 17 | 18 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /util/object/isplain/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | object QUnit Test 5 | 6 | 9 | 10 | 11 | 12 |

                  isPlainObject Test Suite

                  13 |

                  14 |
                  15 |

                  16 |
                  17 |
                    18 |
                    19 | 20 | -------------------------------------------------------------------------------- /model/queue/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                    Model Queue Test Suite

                    8 |

                    9 |
                    10 |

                    11 |
                      12 |
                      13 | 14 | 15 | 16 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /view/bindings/input-radio.html: -------------------------------------------------------------------------------- 1 |
                      2 | 3 | 30 | -------------------------------------------------------------------------------- /util/inserted/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                      inserted Test Suite

                      8 | 9 |

                      10 | 11 |
                      12 |

                      13 |
                        14 |
                        15 | 16 | 17 | 18 | 24 | 25 | -------------------------------------------------------------------------------- /component/examples/grid.js: -------------------------------------------------------------------------------- 1 | can.Component.extend({ 2 | tag: 'grid', 3 | scope: { 4 | items: [] 5 | }, 6 | template: '
                        ', 7 | events: { 8 | init: function () { 9 | this.update(); 10 | }, 11 | '{deferreddata} change': 'update', 12 | update: function () { 13 | var deferred = this.scope.attr('deferreddata'), 14 | scope = this.scope; 15 | if (can.isDeferred(deferred)) { 16 | this.element.find('tbody') 17 | .css('opacity', 0.5); 18 | deferred.then(function (items) { 19 | scope.attr('items') 20 | .attr(items, true); 21 | }); 22 | } else { 23 | scope.attr('items') 24 | .attr(deferred, true); 25 | } 26 | }, 27 | '{items} change': function () { 28 | this.element.find('tbody') 29 | .css('opacity', 1); 30 | } 31 | } 32 | }); 33 | -------------------------------------------------------------------------------- /view/mustache/spec/Rakefile: -------------------------------------------------------------------------------- 1 | require 'json' 2 | require 'yaml' 3 | 4 | # Our custom YAML tags must retain their magic. 5 | %w[ code ].each do |tag| 6 | YAML::add_builtin_type(tag) { |_,val| val.merge(:__tag__ => tag) } 7 | end 8 | 9 | desc 'Build all alternate versions of the specs.' 10 | multitask :build => [ 'build:json' ] 11 | 12 | namespace :build do 13 | note = 'Do not edit this file; changes belong in the appropriate YAML file.' 14 | 15 | desc 'Build JSON versions of the specs.' 16 | task :json do 17 | rm(Dir['specs/*.json'], :verbose => false) 18 | Dir.glob('specs/*.yml').each do |filename| 19 | json_file = filename.gsub('.yml', '.json') 20 | 21 | File.open(json_file, 'w') do |file| 22 | doc = YAML.load_file(filename) 23 | file << doc.merge(:__ATTN__ => note).to_json() 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /control/modifier/key/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | can.Control.modifier.key QUnit Test 6 | 7 | 8 | 9 |

                        route Test Suite

                        10 |

                        11 |
                        12 |

                        13 |
                        14 |
                          15 |
                          16 |
                          17 |
                          18 |
                          19 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /component/examples/paginate_events_next.html: -------------------------------------------------------------------------------- 1 | 2 |
                          3 | 4 | 30 | -------------------------------------------------------------------------------- /component/helpers.md: -------------------------------------------------------------------------------- 1 | @property {Object.} can.Component.prototype.helpers 2 | @parent can.Component.prototype 3 | 4 | Helper functions used with the component's template. 5 | 6 | @option {Object.} 7 | 8 | An object of [can.Mustache] helper names and methods. The helpers are only 9 | available within the component's template and source html. The helper's 10 | are always called back with `this` as the [can.Component::scope scope]. 11 | 12 | @body 13 | 14 | ## Use 15 | 16 | can.Component's helper object lets you provide helper functions that are localized to 17 | the component's [can.Component::template template]. The following example 18 | uses an `isSelected` helper to render content for selected items. Click 19 | one of the following libraries to toggle them within the `selected` array. 20 | 21 | @demo can/component/examples/selected.html -------------------------------------------------------------------------------- /view/bindings/can-event.html: -------------------------------------------------------------------------------- 1 |
                          2 | 3 | 38 | 39 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | [![CanJS](http://canjs.us/scripts/static/img/canjs_logo_yellow_small.png)](http://canjs.us/) 2 | 3 | [![Build Status](https://travis-ci.org/bitovi/canjs.png?branch=master)](https://travis-ci.org/bitovi/canjs) 4 | 5 | CanJS is a MIT-licensed, client-side, JavaScript framework that makes building 6 | rich web applications easy. Use it because it’s: 7 | 8 | - Smaller 9 | - Faster 10 | - Safer 11 | - Easier 12 | - Library-er 13 | 14 | ### Demos and Docs 15 | Go to [http://canjs.us/](http://canjs.us/) for docs, downloads, tests, demos, and more. 16 | 17 | ### Support / Contributing 18 | Before you make an issue, please read our [Contributing](contributing.md) guide. 19 | 20 | You can find the core team in [#canjs on irc.freenode.net](irc://irc.freenode.net/#canjs). 21 | 22 | ### Release History 23 | See the [Changelog](changelog.md). 24 | 25 | ### License 26 | MIT License, see [License](license.md). 27 | 28 | -------------------------------------------------------------------------------- /view/bindings/input-checkbox.html: -------------------------------------------------------------------------------- 1 |
                          2 | 3 | 35 | 36 | -------------------------------------------------------------------------------- /control/control.processor.md: -------------------------------------------------------------------------------- 1 | @typedef {function(HTMLElement,String,CSSSelectorString,Function,can.Control)} can.Control.processor(element,eventName,selector,handler,control) 2 | 3 | @description A function that handles the binding and unbinding of a [can.Control]'s declarative event method. 4 | 5 | @param {HTMLElement} element the control's element or the object 6 | specified by the templated event handler (`"{object}"`). 7 | 8 | @param {String} eventName The event type. 9 | 10 | @param {CSSSelectorString} selector The selector preceding the event in the binding used on the Control. 11 | 12 | @param {function(this:can.Control,Object,Event)} handler(element, event) The callback function being bound. 13 | 14 | @option {Object} element foo 15 | @option {Event} event bar 16 | 17 | @param {can.Control} control The Control the event is bound on. 18 | 19 | @return {function()} A callback function that unbinds any event handlers bound within this processor. 20 | -------------------------------------------------------------------------------- /view/ejs/test/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 |

                          ejs Test Suite

                          13 |

                          14 |
                          15 |

                          16 |
                          17 |
                            18 |
                            19 | 20 | 25 | 26 | -------------------------------------------------------------------------------- /util/function/function.js: -------------------------------------------------------------------------------- 1 | steal('can/util', function (can) { 2 | can.extend(can, { 3 | debounce: function (fn, time, context) { 4 | var timeout; 5 | return function () { 6 | var args = arguments; 7 | context = context || this; 8 | clearTimeout(timeout); 9 | timeout = setTimeout(function () { 10 | fn.apply(context, args); 11 | }, time); 12 | }; 13 | }, 14 | throttle: function (fn, time, context) { 15 | var run; 16 | return function () { 17 | var args = arguments; 18 | context = context || this; 19 | if (!run) { 20 | run = true; 21 | setTimeout(function () { 22 | fn.apply(context, args); 23 | run = false; 24 | }, time); 25 | } 26 | }; 27 | }, 28 | defer: function (fn, context) { 29 | var args = arguments; 30 | context = context || this; 31 | setTimeout(function () { 32 | fn.apply(context, args); 33 | }, 0); 34 | } 35 | }); 36 | return can; 37 | }); 38 | -------------------------------------------------------------------------------- /guides/components/scope-3.html: -------------------------------------------------------------------------------- 1 |
                            2 | 3 | -------------------------------------------------------------------------------- /util/array/each.js: -------------------------------------------------------------------------------- 1 | steal('can/util/can.js', function (can) { 2 | can.each = function (elements, callback, context) { 3 | var i = 0, 4 | key; 5 | if (elements) { 6 | if (typeof elements.length === 'number' && elements.pop) { 7 | if (elements.attr) { 8 | elements.attr('length'); 9 | } 10 | for (key = elements.length; i < key; i++) { 11 | if (callback.call(context || elements[i], elements[i], i, elements) === false) { 12 | break; 13 | } 14 | } 15 | } else if (elements.hasOwnProperty) { 16 | if (can.Map && elements instanceof can.Map) { 17 | if (can.__reading) { 18 | can.__reading(elements, '__keys'); 19 | } 20 | elements = elements.__get(); 21 | } 22 | for (key in elements) { 23 | if (elements.hasOwnProperty(key) && callback.call(context || elements[key], elements[key], key, elements) === false) { 24 | break; 25 | } 26 | } 27 | } 28 | } 29 | return elements; 30 | }; 31 | return can; 32 | }); 33 | -------------------------------------------------------------------------------- /util/fixture/fixtures/messages.html: -------------------------------------------------------------------------------- 1 | 2 |

                            Create a Message

                            3 |

                            Create a message, it will show up in "Get Messages".

                            4 |
                            5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
                            From:
                            Subject:
                            Body:
                            22 |
                            23 |

                            Get Messages

                            24 |

                            Enter a limit and offset to get a range of messages. 25 |

                            26 |
                            27 | Offset 28 | Limit 29 | 30 |
                            31 |
                            32 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "globals": { 3 | 4 | "steal": true, 5 | "can": true, 6 | 7 | 8 | "Zepto": true, 9 | 10 | 11 | "QUnit": true, 12 | "test": true, 13 | "asyncTest": true, 14 | "expect": true, 15 | "module": true, 16 | "ok": true, 17 | "equal": true, 18 | "notEqual": true, 19 | "deepEqual": true, 20 | "notDeepEqual": true, 21 | "strictEqual": true, 22 | "notStrictEqual": true, 23 | "raises": true, 24 | "start": true, 25 | "stop": true 26 | }, 27 | 28 | 29 | "curly": true, 30 | "eqeqeq": true, 31 | "freeze": true, 32 | "indent": 2, 33 | "latedef": true, 34 | "noarg": true, 35 | "undef": true, 36 | "unused": "vars", 37 | "trailing": true, 38 | "maxdepth": 4, 39 | "boss" : true, 40 | 41 | "eqnull": true, 42 | "evil": true, 43 | "loopfunc": true, 44 | "smarttabs": true, 45 | "maxerr" : 200, 46 | 47 | "jquery": true, 48 | "dojo": true, 49 | "mootools": true, 50 | "yui": true, 51 | "browser": true, 52 | "phantom": true, 53 | "rhino": true 54 | } 55 | -------------------------------------------------------------------------------- /model/cached/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | store QUnit Test 6 | 7 | 8 | 9 | 10 |

                            store Test Suite

                            11 |

                            12 |
                            13 |

                            14 |
                            15 |
                              16 |
                              17 | 18 | 19 | 20 | 21 | 27 | 28 | -------------------------------------------------------------------------------- /test/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 44 | Test... EVERYTHING 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /component/examples/paginate_events_next_update_page.html: -------------------------------------------------------------------------------- 1 | 2 |
                              3 | 4 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /util/fixture/store.md: -------------------------------------------------------------------------------- 1 | @typedef {} can.fixture.types.Store Store 2 | @parent can.fixture.types 3 | 4 | Contains an array of items and methods for 5 | finding, adding, updating, and removing items from the store. Many of those 6 | methods are designed to work with `can.fixture` and simulate [can.Model]'s CRUD 7 | behavior. 8 | 9 | ## Use 10 | 11 | For a model like: 12 | 13 | Todo = can.Model.extend({ 14 | findAll: "/todos", 15 | findOne: "/todos/{id}", 16 | create: "/todos", 17 | update: "/todos/{id}", 18 | destroy: "/todos/{id}" 19 | },{}) 20 | 21 | Create a fixture store and hook it up like: 22 | 23 | 24 | var todoStore = can.fixture.store(1000,function(id){ 25 | return {name: "Todo "+id} 26 | }) 27 | 28 | 29 | can.fixture({ 30 | 'GET /todos': todoStore.findAll, 31 | 'GET /todos/{id}': todoStore.findOne, 32 | 'POST /todos': todoStore.create, 33 | 'PUT /todos/{id}': todoStore.update, 34 | 'DELETE /todos/{id}': todoStore.destroy 35 | }); -------------------------------------------------------------------------------- /route/testing.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | can.route test page 5 | 6 | 7 |

                              This is a dummy page to use
                              for testing route goodness

                              8 | 9 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /control/route/route.js: -------------------------------------------------------------------------------- 1 | steal('can/util', 'can/route', 'can/control', function (can) { 2 | 3 | // ## control/route.js 4 | // _Controller route integration._ 5 | 6 | can.Control.processors.route = function (el, event, selector, funcName, controller) { 7 | selector = selector || ""; 8 | if (!can.route.routes[selector]) { 9 | if (selector[0] === '/') { 10 | selector = selector.substring(1); 11 | } 12 | can.route(selector); 13 | } 14 | var batchNum, 15 | check = function (ev, attr, how) { 16 | if (can.route.attr('route') === (selector) && 17 | (ev.batchNum === undefined || ev.batchNum !== batchNum)) { 18 | 19 | batchNum = ev.batchNum; 20 | 21 | var d = can.route.attr(); 22 | delete d.route; 23 | if (can.isFunction(controller[funcName])) { 24 | controller[funcName](d); 25 | } else { 26 | controller[controller[funcName]](d); 27 | } 28 | 29 | } 30 | }; 31 | can.route.bind('change', check); 32 | return function () { 33 | can.route.unbind('change', check); 34 | }; 35 | }; 36 | 37 | return can; 38 | }); 39 | -------------------------------------------------------------------------------- /route/pushstate/testing.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | can.route test page 5 | 6 | 7 |

                              This is a dummy page to use
                              for testing route goodness

                              8 | 9 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /component/examples/name_editor.html: -------------------------------------------------------------------------------- 1 | 2 |
                              3 | 4 | 5 | 6 | 7 | 13 | 49 | -------------------------------------------------------------------------------- /control/modifier/key/key.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | key 5 | 11 | 12 | 13 |

                              key Demo

                              14 |

                              NOT!

                              15 | 16 | 17 | 18 | 38 | 39 | -------------------------------------------------------------------------------- /map/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                              can.Map Test Suite

                              8 | 9 |

                              10 | 11 |
                              12 |

                              13 |
                                14 |
                                15 | 16 | 17 | 18 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /list/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                can.List Test Suite

                                8 | 9 |

                                10 | 11 |
                                12 |

                                13 |
                                  14 |
                                  15 | 16 | 17 | 18 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /view/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                  can.view Test Suite

                                  8 | 9 |

                                  10 | 11 |
                                  12 |

                                  13 |
                                    14 |
                                    15 | 16 | 17 | 18 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /component/extend.md: -------------------------------------------------------------------------------- 1 | @function can.Component.extend 2 | @parent can.Component.static 3 | 4 | Extends the [can.Component] constructor function. 5 | 6 | @signature `can.Component.extend(proto)` 7 | 8 | Extends the [can.Component] constructor function with prototype 9 | properties and methods. 10 | 11 | @param {{}} proto An object set as the prototype of the 12 | constructor function. You will typically provide the following values 13 | on the prototype object. 14 | 15 | @option {can.Component.prototype.tag} tag Defines the 16 | tag on which instances of the component constructor function will be 17 | created. 18 | 19 | @option {can.Component.prototype.events} [events] Defines events on 20 | dom elements or observable objects the component listens to. 21 | 22 | 23 | @option {can.Component.prototype.helpers} [helpers] Specifies mustache helpers 24 | used to render the component's template. 25 | 26 | @option {can.Component.prototype.scope} [scope] Specifies an object 27 | that is is used to render the component's template. 28 | 29 | @option {can.Component.prototype.tempate} [template] Specifies the template 30 | rendered within the custom element. -------------------------------------------------------------------------------- /model/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                    can.Model Test Suite

                                    8 | 9 |

                                    10 | 11 |
                                    12 |

                                    13 |
                                      14 |
                                      15 | 16 | 17 | 18 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /route/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                      can.route Test Suite

                                      8 | 9 |

                                      10 | 11 |
                                      12 |

                                      13 |
                                        14 |
                                        15 | 16 | 17 | 18 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /compute/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                        can.compute Test Suite

                                        8 | 9 |

                                        10 | 11 |
                                        12 |

                                        13 |
                                          14 |
                                          15 | 16 | 17 | 18 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /control/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                          can.Control Test Suite

                                          8 | 9 |

                                          10 | 11 |
                                          12 |

                                          13 |
                                            14 |
                                            15 | 16 | 17 | 18 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /observe/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                            can.Map Test Suite

                                            8 | 9 |

                                            10 | 11 |
                                            12 |

                                            13 |
                                              14 |
                                              15 | 16 | 17 | 18 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /control/route/pushstate.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | can.route test page 5 | 6 | 7 |

                                              This is a dummy page to use
                                              for testing route goodness

                                              8 | 9 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /view/ejs/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                              can.EJS Test Suite

                                              8 | 9 |

                                              10 | 11 |
                                              12 |

                                              13 |
                                                14 |
                                                15 | 16 | 17 | 18 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /construct/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                                can.Construct Test Suite

                                                8 | 9 |

                                                10 | 11 |
                                                12 |

                                                13 |
                                                  14 |
                                                  15 | 16 | 17 | 18 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /guides/CanJS-Website-Structure.md: -------------------------------------------------------------------------------- 1 | ## Home 2 | 3 | Purpose: increase engagement with the project. Quickly help people understand CanJS and link to more information. 4 | - Download button 5 | - Summarize features/benefits 6 | - Link/show social media, community activity 7 | - Show an example 8 | 9 | ## About ? 10 | Could just link to the homepage, be renamed "Home", or if there is other content? (Might be best to remove it) 11 | 12 | ## Guides 13 | 14 | Purpose: direct people how to learn CanJS. 15 | 16 | Links to: 17 | 18 | - API guide 19 | - CanJS Video 20 | - Developing CanJS 21 | - Recipes Page 22 | - Docs 23 | - Annotated Source 24 | 25 | ## API 26 | 27 | Formal documentation for CanJS's API 28 | 29 | ## Community 30 | 31 | Purpose: link users directly to community resources and show community activity 32 | 33 | Landing page for: 34 | 35 | - Forums 36 | - IRC 37 | - Articles, apps, and plugins (Bithub) 38 | - Twitter (tweet, follow) 39 | - Issues (report issues) 40 | - GitHub (fork follow) 41 | 42 | ## Download 43 | 44 | - Download button 45 | - Download builder: customize options, plugins, library 46 | - CDN links 47 | - Examples? -------------------------------------------------------------------------------- /map/sort/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                                  can.Map sort Test Suite

                                                  8 | 9 |

                                                  10 | 11 |
                                                  12 |

                                                  13 |
                                                    14 |
                                                    15 | 16 | 17 | 18 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /view/mustache/mustache.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | can.view.mustache demo 5 | 6 | 7 | 8 | 14 | 15 |
                                                    16 | 17 | 18 | 19 | 38 | 39 | -------------------------------------------------------------------------------- /map/setter/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                                    can.Map.setter Test Suite

                                                    8 | 9 |

                                                    10 | 11 |
                                                    12 |

                                                    13 |
                                                      14 |
                                                      15 | 16 | 17 | 18 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /control/route/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                                      can.Control.plugin Test Suite

                                                      8 | 9 |

                                                      10 | 11 |
                                                      12 |

                                                      13 |
                                                        14 |
                                                        15 | 16 | 17 | 18 | 30 | 31 | -------------------------------------------------------------------------------- /map/backup/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                                        can.Map Backup Test Suite

                                                        8 | 9 |

                                                        10 | 11 |
                                                        12 |

                                                        13 |
                                                          14 |
                                                          15 | 16 | 17 | 18 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /view/bindings/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                                          can.view Test Suite

                                                          8 | 9 |

                                                          10 | 11 |
                                                          12 |

                                                          13 |
                                                            14 |
                                                            15 | 16 | 17 | 18 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /map/delegate/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                                            can.Map.delegate Test Suite

                                                            8 | 9 |

                                                            10 | 11 |
                                                            12 |

                                                            13 |
                                                              14 |
                                                              15 | 16 | 17 | 18 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /view/mustache/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                                              can.Mustache Test Suite

                                                              8 | 9 |

                                                              10 | 11 |
                                                              12 |

                                                              13 |
                                                                14 |
                                                                15 | 16 | 17 | 18 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /control/plugin/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                                                can.Control.plugin Test Suite

                                                                8 | 9 |

                                                                10 | 11 |
                                                                12 |

                                                                13 |
                                                                  14 |
                                                                  15 | 16 | 17 | 18 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /view/live/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | can/view/mustache/live 5 | 6 | 7 |

                                                                  can.view.live Test Suite

                                                                  8 | 9 |

                                                                  10 | 11 |
                                                                  12 |

                                                                  13 |
                                                                    14 |
                                                                    15 | 16 | 17 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /view/modifiers/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                                                    can.modifiers Test Suite

                                                                    8 | 9 |

                                                                    10 | 11 |
                                                                    12 |

                                                                    13 |
                                                                      14 |
                                                                      15 | 16 | 17 | 18 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /construct/proxy/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                                                      can.Construct.proxy Test Suite

                                                                      8 | 9 |

                                                                      10 | 11 |
                                                                      12 |

                                                                      13 |
                                                                        14 |
                                                                        15 | 16 | 17 | 18 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /construct/super/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                                                        can.Construct.super Test Suite

                                                                        8 | 9 |

                                                                        10 | 11 |
                                                                        12 |

                                                                        13 |
                                                                          14 |
                                                                          15 | 16 | 17 | 18 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /map/attributes/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                                                          can.Map.attributes Test Suite

                                                                          8 | 9 |

                                                                          10 | 11 |
                                                                          12 |

                                                                          13 |
                                                                            14 |
                                                                            15 | 16 | 17 | 18 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /view/mustache/spec/Changes: -------------------------------------------------------------------------------- 1 | 2011-03-20: v1.1.2 2 | Added tests for standalone tags at string boundaries. 3 | Added tests for rendering lambda returns after delimiter changes. 4 | 5 | 2011-03-20: v1.0.3 6 | Added tests for standalone tags at string boundaries. 7 | Added tests for rendering lambda returns after delimiter changes. 8 | 9 | 2011-03-05: v1.1.1 10 | Added tests for indented inline sections. 11 | Added tests for Windows-style newlines. 12 | 13 | 2011-03-05: v1.0.2 14 | Added tests for indented inline sections. 15 | Added tests for Windows-style newlines. 16 | 17 | 2011-03-04: v1.1.0 18 | Implicit iterators. 19 | A single period (`.`) may now be used as a name in Interpolation tags, 20 | which represents the top of stack (cast as a String). 21 | Dotted names. 22 | Names containing one or more periods should be resolved as chained 23 | properties; naïvely, this is like nesting section tags, but with some 24 | built-in scoping protections. 25 | 26 | 2011-03-02: v1.0.1 27 | Clarifying a point in the README about version compliance. 28 | Adding high-level documentation to each spec file. 29 | 30 | 2011-02-28: v1.0.0 31 | Initial Release 32 | -------------------------------------------------------------------------------- /view/scope/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | can/view/mustache/scope 5 | 6 | 7 |

                                                                            can.view.Scope Test Suite

                                                                            8 | 9 |

                                                                            10 | 11 |
                                                                            12 |

                                                                            13 |
                                                                              14 |
                                                                              15 | 16 | 17 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /map/validations/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                                                              can.Map.validations Test Suite

                                                                              8 | 9 |

                                                                              10 | 11 |
                                                                              12 |

                                                                              13 |
                                                                                14 |
                                                                                15 | 16 | 17 | 18 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /license.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | Copyright (C) 2013 [Bitovi](http://bitovi.com) 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | -------------------------------------------------------------------------------- /view/node_lists/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | can/view/mustache/live/node_list/test 5 | 6 | 7 |

                                                                                can.view.live.nodeList Test Suite

                                                                                8 | 9 |

                                                                                10 | 11 |
                                                                                12 |

                                                                                13 |
                                                                                  14 |
                                                                                  15 | 16 | 17 | 29 | 30 | -------------------------------------------------------------------------------- /map/list/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | can.Map.Collection Test Suite 6 | 7 | 8 | 9 |

                                                                                  can.Map.Collection Test Suite

                                                                                  10 |

                                                                                  11 |
                                                                                  12 |

                                                                                  13 |
                                                                                    14 |
                                                                                    15 | 16 | 17 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /component/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 |

                                                                                    can.Component Test Suite

                                                                                    12 | 13 |

                                                                                    14 | 15 |
                                                                                    16 |

                                                                                    17 |
                                                                                      18 |
                                                                                      19 | 20 | 21 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /construct/proxy/proxy_test.js: -------------------------------------------------------------------------------- 1 | steal("can/construct/proxy", "can/control", function () { 2 | /* global Car */ 3 | var isSteal = typeof steal !== 'undefined'; 4 | module('can/construct/proxy'); 5 | test('static proxy if control is loaded first', function () { 6 | var curVal = 0; 7 | expect(2); 8 | can.Control('Car', { 9 | show: function (value) { 10 | equal(curVal, value); 11 | } 12 | }, {}); 13 | var cb = Car.proxy('show'); 14 | curVal = 1; 15 | cb(1); 16 | curVal = 2; 17 | var cb2 = Car.proxy('show', 2); 18 | cb2(); 19 | }); 20 | test('proxy', function () { 21 | var curVal = 0; 22 | expect(2); 23 | can.Construct('Car', { 24 | show: function (value) { 25 | equal(curVal, value); 26 | } 27 | }, {}); 28 | var cb = Car.proxy('show'); 29 | curVal = 1; 30 | cb(1); 31 | curVal = 2; 32 | var cb2 = Car.proxy('show', 2); 33 | cb2(); 34 | }); 35 | // this won't work in dist mode (this functionality is removed) 36 | if (isSteal) { 37 | test('proxy error', 1, function () { 38 | can.Construct('Car', {}); 39 | try { 40 | Car.proxy('huh'); 41 | ok(false, 'I should have errored'); 42 | } catch (e) { 43 | ok(true, 'Error was thrown'); 44 | } 45 | }); 46 | } 47 | }); 48 | -------------------------------------------------------------------------------- /control/modifier/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | can.Control modifier QUnit Test 5 | 6 | 7 | 8 |

                                                                                      route Test Suite

                                                                                      9 |

                                                                                      10 |
                                                                                      11 |

                                                                                      12 |
                                                                                      13 |
                                                                                        14 |
                                                                                        15 |
                                                                                        16 | 17 | 18 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /view/ejs/tags.scriptlet.md: -------------------------------------------------------------------------------- 1 | @function can.EJS.tags.scriptlet <% CODE %> 2 | @parent can.EJS.tags 0 3 | 4 | @signature `<% CODE %>` 5 | 6 | Runs JavaScript Code. 7 | 8 | This type of magic tag does not modify the template but is used for JS control statements 9 | like for-loops, if/else, switch, etc. An example: 10 | 11 | <% if( items.attr('length') === 0 ) { %> 12 | You have no items 13 | <% } else { %> 14 | <% items.each(function(item){ %> 15 | .... 16 | <% }) %> 17 | <% } %> 18 | 19 | Variable declarations and control blocks should always be defined in 20 | their own dedicated tags. Live binding leverages this hinting to ensure that logic is declared and executed at its intended scope. 21 | 22 | 23 | <% var address = person.attr('address') %> 24 | <% items.each(function(item){ %> 25 | .... 26 | <% }) %> 27 | <%= address.attr('street') %> 28 | 29 | 30 | <% 31 | var address = person.attr('address'); 32 | items.each(function(item) { 33 | %> 34 | .... 35 | <% }) %> 36 | <%= address.attr('street') %> -------------------------------------------------------------------------------- /route/pushstate/binding.md: -------------------------------------------------------------------------------- 1 | @typedef {{}} can.route.binding 2 | 3 | @option {String} root The starting point of 4 | the url to match. For `hashchange`, the value 5 | is "#!". For `pushstate`, the value is `/`. This can 6 | be overwritten before [can.route.ready] is called like: 7 | 8 | can.route.bindings.pushstate.root = "/site/" 9 | 10 | @option {String} querySeparator Specifies the seperator 11 | between the path part of the url and the query (also known as search) 12 | part of the url. For `hashchange`, the value 13 | is `"&"`. For `pushstate`, the value is `"?"`. 14 | 15 | @option {RegExp} paramsMatcher A regular expression that is used 16 | to identify the `key=value` pairs in the query part of the url. 17 | 18 | @option {function():String} matchingPartOfURL Reads the url and returns the 19 | part that is used for matching routes. 20 | 21 | @option {function(path):String} setURL Called with the 22 | serialized can.route data after a route has changed. 23 | Returns what the url has been updated to. 24 | 25 | @option {function} bind Attaches listeners to the document to know 26 | when the url has changed. Typically `bind` is called when [can.route.ready] is called. 27 | 28 | @option {function} unbind Tears down the bindings to the document. 29 | 30 | 31 | -------------------------------------------------------------------------------- /util/destroyed.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @add can.event.special 3 | */ 4 | steal('jquery', 'can/util', function ($, can) { 5 | /** 6 | * @property {Event} destroyed 7 | * @parent specialevents 8 | * @download http://jmvcsite.heroku.com/pluginify?plugins[]=jquery/dom/destroyed/destroyed.js 9 | * @test jquery/event/destroyed/qunit.html 10 | * Provides a destroyed event on an element. 11 | *

                                                                                        12 | * The destroyed event is called when the element 13 | * is removed as a result of jQuery DOM manipulators like remove, html, 14 | * replaceWith, etc. Destroyed events do not bubble, so make sure you don't use live or delegate with destroyed 15 | * events. 16 | *

                                                                                        17 | * 18 | *

                                                                                        Quick Example

                                                                                        19 | * @codestart 20 | * can.$(".foo").bind("destroyed", function(){ 21 | * //clean up code 22 | * }) 23 | * @codeend 24 | * 25 | *

                                                                                        Quick Demo

                                                                                        26 | * @demo jquery/event/destroyed/destroyed.html 27 | *

                                                                                        More Involved Demo

                                                                                        28 | * @demo jquery/event/destroyed/destroyed_menu.html 29 | */ 30 | 31 | var oldClean = $.cleanData; 32 | 33 | can.cleanData = function (elems) { 34 | can.each(elems, function (elem) { 35 | can.$(elem) 36 | .triggerHandler("removed"); 37 | }); 38 | oldClean(elems); 39 | }; 40 | 41 | return can; 42 | }); 43 | -------------------------------------------------------------------------------- /map/setter/setter.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Model Convert Demo 6 | 12 | 13 | 14 |
                                                                                        15 | 16 |
                                                                                        17 | 18 | 45 | 46 | -------------------------------------------------------------------------------- /control/view/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                                                                        Control.View Test Suite

                                                                                        8 |

                                                                                        9 |
                                                                                        10 |

                                                                                        11 |
                                                                                        12 |
                                                                                          13 |
                                                                                          14 | 15 | 16 | 28 | 29 | -------------------------------------------------------------------------------- /map/backup/backup.md: -------------------------------------------------------------------------------- 1 | @page can.Map.backup backup 2 | @parent can.Map.plugins 3 | @plugin can/map/backup 4 | @test can/map/backup/test.html 5 | 6 | can.Map.backup is a plugin that provides a dirty bit for properties on an Map, 7 | and lets you restore the original values of an Map's properties after they are changed. 8 | 9 | 10 | Here is an example showing how to use `[can.Map.backup.prototype.backup backup]` to save values, 11 | `[can.Map.backup.prototype.restore restore]` to restore them, and `[can.Map.backup.prototype.isDirty isDirty]` 12 | 13 | to check if the Map has changed: 14 | 15 | @codestart 16 | var recipe = new can.Map({ 17 | title: 'Pancake Mix', 18 | yields: '3 batches', 19 | ingredients: [{ 20 | ingredient: 'flour', 21 | quantity: '6 cups' 22 | },{ 23 | ingredient: 'baking soda', 24 | quantity: '1 1/2 teaspoons' 25 | },{ 26 | ingredient: 'baking powder', 27 | quantity: '3 teaspoons' 28 | },{ 29 | ingredient: 'salt', 30 | quantity: '1 tablespoon' 31 | },{ 32 | ingredient: 'sugar', 33 | quantity: '2 tablespoons' 34 | }] 35 | }); 36 | recipe.backup(); 37 | 38 | recipe.attr('title', 'Flapjack Mix'); 39 | recipe.title; // 'Flapjack Mix' 40 | recipe.isDirty(); // true 41 | 42 | recipe.restore(); 43 | recipe.title; // 'Pancake Mix' 44 | @codeend -------------------------------------------------------------------------------- /util/object/isplain/isplain.js: -------------------------------------------------------------------------------- 1 | steal('can/util/can.js', function (can) { 2 | var core_hasOwn = Object.prototype.hasOwnProperty, 3 | isWindow = function (obj) { 4 | // In IE8 window.window !== window.window, so we allow == here. 5 | /*jshint eqeqeq:false*/ 6 | return obj !== null && obj == obj.window; 7 | }, isPlainObject = function (obj) { 8 | // Must be an Object. 9 | // Because of IE, we also have to check the presence of the constructor property. 10 | // Make sure that DOM nodes and window objects don't pass through, as well 11 | if (!obj || typeof obj !== 'object' || obj.nodeType || isWindow(obj)) { 12 | return false; 13 | } 14 | try { 15 | // Not own constructor property must be Object 16 | if (obj.constructor && !core_hasOwn.call(obj, 'constructor') && !core_hasOwn.call(obj.constructor.prototype, 'isPrototypeOf')) { 17 | return false; 18 | } 19 | } catch (e) { 20 | // IE8,9 Will throw exceptions on certain host objects #9897 21 | return false; 22 | } 23 | // Own properties are enumerated firstly, so to speed up, 24 | // if last one is own, then all properties are own. 25 | var key; 26 | for (key in obj) {} 27 | return key === undefined || core_hasOwn.call(obj, key); 28 | }; 29 | can.isPlainObject = isPlainObject; 30 | return can; 31 | }); 32 | -------------------------------------------------------------------------------- /route/pushstate/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | can.route Pushstate Test 5 | 6 | 7 | 8 |

                                                                                          can/route/pushstate Test Suite

                                                                                          9 |

                                                                                          10 |
                                                                                          11 |

                                                                                          12 |
                                                                                            13 |
                                                                                            14 | 15 | 16 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /util/event/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | can.util.event Test 5 | 6 | 7 | 8 |

                                                                                            can/util/event test

                                                                                            9 |

                                                                                            10 |
                                                                                            11 |

                                                                                            12 |
                                                                                              13 |
                                                                                              14 | 15 | 16 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /guides/deferred.md: -------------------------------------------------------------------------------- 1 | @page Deferreds Deferreds 2 | @parent Tutorial 8 3 | 4 | @body 5 | Deferreds in CanJS are explained in greater detail in the [API](../docs/can.Deferred.html). 6 | Below is a quick tour through can.Deferred, which should look familiar to you 7 | if you have experience with the Deferred pattern. 8 | 9 | @codestart 10 | // Create a new Deferred: 11 | var dfd = new can.Deferred(); 12 | 13 | // Add a done callback: 14 | dfd.done(function(foo) { 15 | console.log('Resolved!'); 16 | }); 17 | // Add a fail callback: 18 | dfd.fail(function(bar) { 19 | console.log('Rejected!'); 20 | }); 21 | // Add a callback that fires whether the 22 | // Deferred is resolve or rejected. 23 | dfd.always(function(obj) { 24 | console.log('Apathetic!'); 25 | }); 26 | 27 | var dfd2 = new can.Deferred(); 28 | // Add done and fail callbacks: 29 | dfd2.then(functon(foo) { 30 | console.log('Also resolved.'); 31 | }, function(bar) { 32 | console.log('Also rejected.'); 33 | }); 34 | 35 | // Create a Deferred that resolves when 36 | // all passed Deferreds resolve: 37 | var endDfd = can.when(dfd, dfd2).then(function() { 38 | console.log('I open at the close.'); 39 | }); 40 | 41 | // Resolve a Deferred (and call all its done callbacks): 42 | dfd.resolve('foo'); 43 | 44 | // Reject a Deferred (and call all its fail callbacks): 45 | dfd.reject('bar'); 46 | @codeend 47 | -------------------------------------------------------------------------------- /util/zepto/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | mvc QUnit Test 5 | 6 | 7 | 8 | 9 | 10 | 11 |

                                                                                              Zepto Test Suite

                                                                                              12 |

                                                                                              13 |
                                                                                              14 |

                                                                                              15 |
                                                                                              16 |
                                                                                                17 |
                                                                                                18 | 19 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /util/bind/bind.js: -------------------------------------------------------------------------------- 1 | steal('can/util', function (can) { 2 | /** 3 | * @typedef {{bind:function():*,unbind:function():*}} can/util/bind 4 | * 5 | * Provides mixin-able bind and unbind methods. `bind()` calls `this._bindsetup` 6 | * when the first bind happens and. `unbind()` calls `this._bindteardown` when there 7 | * are no more event handlers. 8 | * 9 | */ 10 | // ## Bind helpers 11 | can.bindAndSetup = function () { 12 | // Add the event to this object 13 | can.addEvent.apply(this, arguments); 14 | // If not initializing, and the first binding 15 | // call bindsetup if the function exists. 16 | if (!this._init) { 17 | if (!this._bindings) { 18 | this._bindings = 1; 19 | // setup live-binding 20 | if (this._bindsetup) { 21 | this._bindsetup(); 22 | } 23 | } else { 24 | this._bindings++; 25 | } 26 | } 27 | return this; 28 | }; 29 | can.unbindAndTeardown = function (ev, handler) { 30 | // Remove the event handler 31 | can.removeEvent.apply(this, arguments); 32 | if (this._bindings === null) { 33 | this._bindings = 0; 34 | } else { 35 | this._bindings--; 36 | } 37 | // If there are no longer any bindings and 38 | // there is a bindteardown method, call it. 39 | if (!this._bindings && this._bindteardown) { 40 | this._bindteardown(); 41 | } 42 | return this; 43 | }; 44 | return can; 45 | }); 46 | -------------------------------------------------------------------------------- /util/fixture/responseHandler.md: -------------------------------------------------------------------------------- 1 | @typedef {function(Number,String,Object.,headers)} can.fixture.types.responseHandler(status,statusText,responses,headers) responseHandler 2 | @parent can.fixture.types 3 | 4 | @description Specifies the response of an AJAX request. 5 | 6 | @signature `response(status [,statusText], responses, headers)` 7 | 8 | Specify a HTTP response. 9 | 10 | @param {Number} status 11 | 12 | The [HTTP response code](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html). Ex: `200`. 13 | 14 | @param {String} [statusText] the status text of the response. Ex: "success" 15 | for 200. 16 | 17 | @param {Object.} responses An object of responses by type. For example: 18 | 19 | { 20 | text: "{\"age\":5}" 21 | } 22 | 23 | If responses does not have a `typeName` property for the type of request, the 24 | entire responses object is used as the response data. 25 | 26 | @param {Object.} headers HTTP response headers and values. 27 | 28 | @signature `response(responses)` 29 | 30 | Specify the body of a successful HTTP response. 31 | 32 | 33 | @param {Object.} responses An object of responses by type. For example: 34 | 35 | { 36 | text: "{\"age\":5}" 37 | } 38 | 39 | If responses does not have a `typeName` property for the type of request, the 40 | entire responses object is used as the response data. 41 | -------------------------------------------------------------------------------- /view/node_lists/node_lists_test.js: -------------------------------------------------------------------------------- 1 | steal('can/view/live/node_lists', 'can/view/elements.js', function (nodeLists, elements) { 2 | var toFrag = function (elements) { 3 | var frag = document.createDocumentFragment(); 4 | can.each(elements, function (element) { 5 | frag.appendChild(element); 6 | }); 7 | return frag; 8 | }; 9 | module('can/view/live/node_lists'); 10 | test('unregisters child nodeLists', function () { 11 | var div = document.createElement('div'); 12 | div.innerHTML = 'will be replaced'; 13 | var everything = can.makeArray(div.childNodes); 14 | nodeLists.register(everything, function () { 15 | console.log('unregistered everything'); 16 | }); 17 | div.innerHTML = '

                                                                                                first

                                                                                                ' + 'will be replaced' + '

                                                                                                second

                                                                                                '; 18 | nodeLists.update(everything, div.childNodes); 19 | var toBeLabels = can.makeArray(div.getElementsByTagName('span')); 20 | // finds where this is and set this parent/child relationship 21 | nodeLists.register(toBeLabels, function () { 22 | ok(true, 'unregistered labels'); 23 | }); 24 | var labels = [ 25 | document.createElement('label'), 26 | document.createElement('label') 27 | ]; 28 | elements.replace(toBeLabels, toFrag(labels)); 29 | nodeLists.update(toBeLabels, labels); 30 | div.innerHTML = '
                                                                                                '; 31 | nodeLists.update(everything, can.makeArray(div.childNodes)); 32 | }); 33 | }); 34 | -------------------------------------------------------------------------------- /util/string/deparam/deparam_test.js: -------------------------------------------------------------------------------- 1 | steal('./deparam', function (can) { 2 | module('can/util/string/deparam'); 3 | /** / 4 | test("Basic deparam",function(){ 5 | 6 | var data = can.deparam("a=b"); 7 | equal(data.a,"b") 8 | 9 | var data = can.deparam("a=b&c=d"); 10 | equal(data.a,"b") 11 | equal(data.c,"d") 12 | }) 13 | /**/ 14 | test('Nested deparam', function () { 15 | var data = can.deparam('a[b]=1&a[c]=2'); 16 | equal(data.a.b, 1); 17 | equal(data.a.c, 2); 18 | data = can.deparam('a[]=1&a[]=2'); 19 | equal(data.a[0], 1); 20 | equal(data.a[1], 2); 21 | data = can.deparam('a[b][]=1&a[b][]=2'); 22 | equal(data.a.b[0], 1); 23 | equal(data.a.b[1], 2); 24 | data = can.deparam('a[0]=1&a[1]=2'); 25 | equal(data.a[0], 1); 26 | equal(data.a[1], 2); 27 | }); 28 | test('Remaining ampersand', function () { 29 | var data = can.deparam('a[b]=1&a[c]=2&'); 30 | deepEqual(data, { 31 | a: { 32 | b: '1', 33 | c: '2' 34 | } 35 | }); 36 | }); 37 | /** / 38 | test("deparam an array", function(){ 39 | var data = can.deparam("a[0]=1&a[1]=2"); 40 | 41 | ok(can.isArray(data.a), "is array") 42 | 43 | equal(data.a[0],1) 44 | equal(data.a[1],2) 45 | }) 46 | 47 | test("deparam object with spaces", function(){ 48 | var data = can.deparam("a+b=c+d&+e+f+=+j+h+"); 49 | 50 | equal(data["a b"], "c d") 51 | equal(data[" e f "], " j h ") 52 | }) 53 | /**/ 54 | }); 55 | -------------------------------------------------------------------------------- /control/view/view.md: -------------------------------------------------------------------------------- 1 | @page can.Control.view 2 | @hide 3 | @parent can.Control 4 | @plugin can/control/view 5 | @test can/control/view/test.html 6 | @download http://donejs.com/can/dist/can.control.view.js 7 | 8 | __DEPRECATED__ 9 | 10 | Renders a View template with the controller instance. If the first argument 11 | is not supplied, it looks for a view in `/views/controlName/action_name.ejs`. 12 | If data is not provided, it uses the controller instance as data. 13 | 14 | var Tasks = can.Control.extend('Tasks',{ 15 | click: function( el ) { 16 | // renders with views/tasks/click.ejs with the control as data 17 | this.element.html( this.view() ) 18 | 19 | // renders with views/tasks/click.ejs with some data 20 | this.element.html( 21 | this.view({ name : 'The task' }) ); 22 | 23 | // renders with views/tasks/under.ejs 24 | this.element.html( 25 | this.view("under", [1,2]) ); 26 | 27 | // renders with views/tasks/under.micro 28 | this.element.html( 29 | this.view("under.micro", [1,2]) ); 30 | 31 | // renders with views/shared/top.ejs 32 | this.element.html( 33 | this.view("shared/top", {phrase: "hi"}) ); 34 | } 35 | }) 36 | 37 | The control name will be determined by its [can.Construct.fullName fullName] so 38 | make sure that it is set when using the plugin. If the view name doesn't include an extension the 39 | default view extension in [can.view.ext] will be added. -------------------------------------------------------------------------------- /construct/super/super.js: -------------------------------------------------------------------------------- 1 | steal('can/util', 'can/construct', function (can, Construct) { 2 | // tests if we can get super in .toString() 3 | var isFunction = can.isFunction, 4 | fnTest = /xyz/.test(function () { 5 | return this.xyz; 6 | }) ? /\b_super\b/ : /.*/; 7 | // overwrites a single property so it can still call super 8 | can.Construct._overwrite = function (addTo, base, name, val) { 9 | // Check if we're overwriting an existing function 10 | addTo[name] = isFunction(val) && isFunction(base[name]) && fnTest.test(val) ? function (name, fn) { 11 | return function () { 12 | var tmp = this._super, 13 | ret; 14 | // Add a new ._super() method that is the same method 15 | // but on the super-class 16 | this._super = base[name]; 17 | // The method only need to be bound temporarily, so we 18 | // remove it when we're done executing 19 | ret = fn.apply(this, arguments); 20 | this._super = tmp; 21 | return ret; 22 | }; 23 | }(name, val) : val; 24 | }; 25 | // overwrites an object with methods, sets up _super 26 | // newProps - new properties 27 | // oldProps - where the old properties might be 28 | // addTo - what we are adding to 29 | can.Construct._inherit = function (newProps, oldProps, addTo) { 30 | addTo = addTo || newProps; 31 | for (var name in newProps) { 32 | can.Construct._overwrite(addTo, oldProps, name, newProps[name]); 33 | } 34 | }; 35 | return can; 36 | }); 37 | -------------------------------------------------------------------------------- /util/string/deparam/deparam.js: -------------------------------------------------------------------------------- 1 | steal('can/util', 'can/util/string', function (can) { 2 | // ## deparam.js 3 | // `can.deparam` 4 | // _Takes a string of name value pairs and returns a Object literal that represents those params._ 5 | var digitTest = /^\d+$/, 6 | keyBreaker = /([^\[\]]+)|(\[\])/g, 7 | paramTest = /([^?#]*)(#.*)?$/, 8 | prep = function (str) { 9 | return decodeURIComponent(str.replace(/\+/g, ' ')); 10 | }; 11 | can.extend(can, { 12 | deparam: function (params) { 13 | var data = {}, pairs, lastPart; 14 | if (params && paramTest.test(params)) { 15 | pairs = params.split('&'); 16 | can.each(pairs, function (pair) { 17 | var parts = pair.split('='), 18 | key = prep(parts.shift()), 19 | value = prep(parts.join('=')), 20 | current = data; 21 | if (key) { 22 | parts = key.match(keyBreaker); 23 | for (var j = 0, l = parts.length - 1; j < l; j++) { 24 | if (!current[parts[j]]) { 25 | // If what we are pointing to looks like an `array` 26 | current[parts[j]] = digitTest.test(parts[j + 1]) || parts[j + 1] === '[]' ? [] : {}; 27 | } 28 | current = current[parts[j]]; 29 | } 30 | lastPart = parts.pop(); 31 | if (lastPart === '[]') { 32 | current.push(value); 33 | } else { 34 | current[lastPart] = value; 35 | } 36 | } 37 | }); 38 | } 39 | return data; 40 | } 41 | }); 42 | return can; 43 | }); 44 | -------------------------------------------------------------------------------- /control/plugin/plugin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | can.Control.plugin 5 | 11 | 12 | 13 | 14 |
                                                                                                15 |
                                                                                                16 | 17 |
                                                                                                18 | 19 | 51 | 52 | -------------------------------------------------------------------------------- /guides/recipes_livebindings.md: -------------------------------------------------------------------------------- 1 | @page RecipesLiveBindings Live Bindings 2 | @parent Recipes 1 3 | 4 | @body 5 | The following recipes show how to use `can.EJS`'s live binding. 6 | 7 | ### Updating timestamps 8 | 9 | The following shows how to create an automatically updating `prettyDate` 10 | helper for EJS that can be used like: 11 | 12 | @codestart 13 | <%= prettyDate( new Date() ) %> 14 | @codeend 15 | 16 | Notice how the _created_ value changes every couple min or 17 | so. 18 | 19 | The `prettyDate` method works with or without live-binding. It doesn't need to take 20 | an observe, just a date. Code with EJS becomes live naturally ... amazing. 21 | 22 | 26 | 27 | 28 | ### 2-way binding Mustache helpers 29 | 30 | Learn how to make 2-way binding mustache helpers. When you change the value of an input, it automatically 31 | changes the value of an observe. When you change the value of the observe, it changes the value of the 32 | input. 33 | 34 | 38 | 39 | [How it works](http://bitovi.com/blog/2013/01/weekly-widget-two-way-mustache-helpers.html) -------------------------------------------------------------------------------- /control/route/route.md: -------------------------------------------------------------------------------- 1 | @page can.Control.route 2 | @parent can.Control.plugins 3 | @plugin can/control/route 4 | @test can/control/view/test.html 5 | @download http://donejs.com/can/dist/can.control.route.js 6 | 7 | @body 8 | The can.Control.route plugin adds a __route__ [can.Control.processors processor] to [can.Control]. 9 | This allows creating routes and binding to [can.route] in a single step by listening to the _route_ event 10 | and a route part. Route events will be triggered whenever the route changes to the route part 11 | the control is listening to. For example: 12 | 13 | var Router = can.Control({ 14 | init : function(el, options) { 15 | }, 16 | 17 | ":type route" : function(data) { 18 | // the route says anything but todo 19 | }, 20 | 21 | "todo/:id route" : function(data) { 22 | // the route says todo/[id] 23 | // data.id is the id or default value 24 | }, 25 | 26 | "route" : function(data){ 27 | // the route is empty 28 | } 29 | }); 30 | 31 | new Router(window); 32 | 33 | `route` without a route part will get called when the route is empty. 34 | The data passed to the event handler is the serialized route data without the 35 | _route_ attribute. 36 | 37 | ## Demo 38 | 39 | The following demo shows the above control in action. 40 | You can edit the hash, follow some example links or directly change the can.route attributes. 41 | At the top it shows the control action being called and the data passed to it: 42 | 43 | @iframe can/control/route/demo.html 700 44 | -------------------------------------------------------------------------------- /test/templates/__configuration__.html.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= configuration.description %> Test Suite 5 | 6 | 7 | 8 | 9 |

                                                                                                <%= configuration.description %> Test Suite

                                                                                                10 |

                                                                                                11 |
                                                                                                12 |

                                                                                                13 |
                                                                                                  14 |
                                                                                                  15 | 16 | 17 | 18 | 35 | 36 | -------------------------------------------------------------------------------- /view/mustache/doc/context.md: -------------------------------------------------------------------------------- 1 | @page can.Mustache.context Paths and Contexts 2 | @parent can.Mustache.pages 1 3 | 4 | When using [can.Mustache.Basics tags] in Mustache, the `key` in `[can.Mustache.tags.escaped {{key}}]` 5 | references a property on the current context object. The default context always points to the data 6 | object initially passed to the template. 7 | 8 | Instead of simply referencing a key matching a property on the current context object, a full path can 9 | be included instead. When a path is found, Mustache will look for a matching property using the entire path: 10 | 11 | Template: 12 | {{person.name}} 13 | 14 | Data: 15 | { 16 | person: { 17 | name: "Austin" 18 | } 19 | } 20 | 21 | Result: 22 | Austin 23 | 24 | Additionally, the current context can be changed by using [can.Mustache.Sections sections]. Anytime a section 25 | is opened, any tags inside of it will use that object as the local context for any key lookups: 26 | 27 | Template: 28 | {{#person}} 29 | {{name}} 30 | {{/person}} 31 | 32 | Data: 33 | { 34 | person: { 35 | name: "Austin" 36 | } 37 | } 38 | 39 | Result: 40 | Austin 41 | 42 | If the key used within a section is not found on the local context, Mustache will look up the 43 | stack of contexts until it finds a matching key: 44 | 45 | Template: 46 | {{#person}} 47 | {{name}} is {{age}} 48 | {{/person}} 49 | 50 | Data: 51 | { 52 | person: { 53 | name: "Austin" 54 | } 55 | age: 29 56 | } 57 | 58 | Result: 59 | Austin is 29 60 | -------------------------------------------------------------------------------- /construct/proxy/proxy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | can.Construct.proxy demo 5 | 6 | 7 |

                                                                                                  proxy Demo

                                                                                                  8 |

                                                                                                  Open the console to see the status messages.

                                                                                                  9 | 11 | 50 | 51 | -------------------------------------------------------------------------------- /view/mustache/doc/livebinding.md: -------------------------------------------------------------------------------- 1 | @page can.Mustache.Binding Live Binding 2 | @parent can.Mustache.pages 5 3 | 4 | Live binding refers to templates which update themselves 5 | as the data used in the mustache tags change. 6 | 7 | It's very common as the page is interacted with that the underlying 8 | data represented in the page changes. Typically, you have callbacks 9 | in your AJAX methods or events and then update the content of your 10 | controls manually. 11 | 12 | In this example, we have a simple user welcome screen. 13 | 14 |

                                                                                                  Welcome {{user}}!

                                                                                                  15 |

                                                                                                  16 | {{#if messages}} 17 | You have {{messages}} new messages. 18 | {{else}} 19 | You have no messages. 20 | {{/messages}} 21 |

                                                                                                  22 | 23 | var data = new can.Map({ 24 | user: 'Tina Fey', 25 | messages: 0 26 | }); 27 | 28 | var template = can.view("#template", data); 29 | 30 | The template evaluates the `messages` and adds the hooks for live binding automatically. 31 | Since we have no message it will render: 32 | 33 |

                                                                                                  Welcome Tina Fey!

                                                                                                  34 |

                                                                                                  You have no messages.

                                                                                                  35 | 36 | Now say we have a request that updates 37 | the `messages` attribute to have `5` messages. We 38 | call the [attr](can.Map.prototype.attr) method on the [can.Map](can.Map) to update 39 | the attribute to the new value. 40 | 41 | data.attr('messages', 5) 42 | 43 | 44 | After [can.Map] receives this update, it will automatically 45 | update the paragraph tag to reflect the new value. 46 | 47 |

                                                                                                  You have 5 new messages.

                                                                                                  48 | 49 | 50 | For more information visit the [can.Map] documentation. 51 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "CanJS", 3 | "description": "MIT-licensed, client-side, JavaScript framework that makes building rich web applications easy.", 4 | "version": "2.0.7", 5 | "author": { 6 | "name": "Bitovi", 7 | "email": "contact@bitovi.com", 8 | "web": "http://bitovi.com/" 9 | }, 10 | "homepage": "http://canjs.us/", 11 | "repository": { 12 | "type": "git", 13 | "url": "git@github.com:bitovi/canjs.git", 14 | "github": "https://github.com/bitovi/canjs" 15 | }, 16 | "devDependencies": { 17 | "grunt": "~0.4.0", 18 | "grunt-string-replace": "~0.2.2", 19 | "grunt-contrib-qunit": "~0.2.1", 20 | "grunt-contrib-connect": "~0.3.0", 21 | "bitovi-tools": "https://github.com/bitovi/bitovi-tools/tarball/master", 22 | "steal": "https://github.com/bitovi/steal-build/tarball/master", 23 | "grunt-contrib-uglify": "~0.2.1", 24 | "grunt-contrib-clean": "~0.5.0", 25 | "grunt-shell": "~0.5.0", 26 | "grunt-release-steps": "~0.3.7", 27 | "bower": "~1.2.7", 28 | "grunt-contrib-jshint": "~0.8.0", 29 | "grunt-jsbeautifier": "~0.2.6", 30 | "grunt-docco": "~0.3.2", 31 | "grunt-plato": "~0.2.1" 32 | }, 33 | "scripts": { 34 | "test": "grunt test", 35 | "install": "node node_modules/bower/bin/bower install" 36 | }, 37 | "demos": [ 38 | "http://canjs.us/#examples", 39 | "http://canjs.us/recipes" 40 | ], 41 | "licenses": [ 42 | { 43 | "type": "MIT", 44 | "url": "http://opensource.org/licenses/mit-license.php" 45 | } 46 | ], 47 | "dependencies": { 48 | "grunt-cli": "~0.1.7" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /control/plugin/demo-update.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Controller Example 6 | 9 | 10 | 11 |
                                                                                                  12 |
                                                                                                  13 | 14 | 15 |
                                                                                                    16 |
                                                                                                    17 |
                                                                                                    18 | 19 | 55 | 56 | -------------------------------------------------------------------------------- /view/ejs/ejs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
                                                                                                    6 | 7 | 18 | 19 | 20 | 49 | 50 | -------------------------------------------------------------------------------- /model/pages/deferreds.md: -------------------------------------------------------------------------------- 1 | @page jquery.model.deferreds Deferreds 2 | @parent jQuery.Model 3 | 4 | Models (and views) work 5 | with [http://api.jquery.com/category/deferred-object/ jQuery.Deferred]. If 6 | you properly fill out a model's [jquery.model.services service API], asynchronous 7 | requests done via the model will return a jQuery.Deferred. 8 | 9 | ## findAll example 10 | 11 | The following example, requests tasks and people and waits for both requests 12 | to be complete before alerting the user: 13 | 14 | var tasksDef = Task.findAll(), 15 | peopleDef = People.findAll(); 16 | 17 | $.when(tasksDef,peopleDef).done(function(taskResponse, peopleResponse){ 18 | alert("There are "+taskRespone[0].length+" tasks and "+ 19 | peopleResponse[0].length+" people."); 20 | }); 21 | 22 | __Note__ taskResponse[0] is an Array of tasks. 23 | 24 | ## save and destroy example 25 | 26 | Calls to [jQuery.Model.prototype.save save] and [jQuery.Model.prototype.destroy] also 27 | return a deferred. The deferred is resolved to the newly created, destroyed, or updated 28 | model instance. 29 | 30 | The following creates a task, updates it, and destroys it: 31 | 32 | var taskD = new Task({name: "dishes"}).save(); 33 | 34 | taskD.done(function(task){ 35 | 36 | var taskD2 = task.update({name: "all the dishes"}) 37 | 38 | taskD2.done(function(task){ 39 | 40 | var taskD3 = task.destroy(); 41 | 42 | taskD3.done(function(){ 43 | console.log("task destroyed"); 44 | }) 45 | 46 | }) 47 | 48 | }); 49 | -------------------------------------------------------------------------------- /component/examples/list.html: -------------------------------------------------------------------------------- 1 | 2 |
                                                                                                    3 | 4 | 12 | 17 | 27 | 67 | -------------------------------------------------------------------------------- /construct/super/super.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | can.Construct.proxy demo 5 | 6 | 7 |

                                                                                                    Super Demo

                                                                                                    8 |

                                                                                                    Open the console to see the status messages.

                                                                                                    9 |

                                                                                                    This is a dummy page to show off your plugin

                                                                                                    10 | 11 | 51 | 52 | -------------------------------------------------------------------------------- /component/examples/selected.html: -------------------------------------------------------------------------------- 1 | 2 | 10 |
                                                                                                    11 |
                                                                                                    12 | 20 |
                                                                                                    21 | 22 | 23 | 26 | 67 | -------------------------------------------------------------------------------- /util/zepto/zepto_test.js: -------------------------------------------------------------------------------- 1 | /* jshint asi:true*/ 2 | can = {}; 3 | steal('zepto', function ($) { 4 | var empty = $.fn.empty; 5 | $.fn.empty = function () { 6 | this.each(function () { 7 | this.__empty = this.__empty || 0; 8 | this.__empty++; 9 | }); 10 | return empty.call(this); 11 | }; 12 | 13 | var remove = $.fn.remove; 14 | $.fn.remove = function () { 15 | this.each(function () { 16 | this.__remove = this.__remove || 0; 17 | this.__remove++; 18 | }); 19 | return remove.call(this); 20 | }; 21 | }) 22 | .then('can/util/zepto', 'can/util/destroyed.js', function ($, can) { 23 | 24 | module("zepto-fill") 25 | 26 | // Zepto 1.0 doesn't have deferreds 27 | test("deferred", 1, function () { 28 | var d = can.ajax({ 29 | url: 'thing.json', 30 | async: false, 31 | dataType: 'text' 32 | }) 33 | d.done(function (text) { 34 | ok(true, "called") 35 | }) 36 | }) 37 | 38 | test("removed", 1, function () { 39 | can.$("#qunit-test-area") 40 | .append("
                                                                                                    foo
                                                                                                    ") 41 | can.$('#foo') 42 | .bind('removed', function () { 43 | ok(true, "called") 44 | }) 45 | 46 | can.$('#foo') 47 | .remove() 48 | }) 49 | 50 | test("$.fn.remove/empty is extended, not replaced (#651)", function () { 51 | can.$("#qunit-test-area") 52 | .append("
                                                                                                    foo
                                                                                                    "); 53 | 54 | var foo = can.$('#zepto-remove') 55 | .remove(); 56 | equal(foo[0].__remove, 1); 57 | equal( !! foo[0].parentNode, false); 58 | 59 | can.$("#qunit-test-area") 60 | .empty(); 61 | equal(can.$("#qunit-test-area")[0].innerHTML, ''); 62 | equal(can.$("#qunit-test-area")[0].__empty, 1); 63 | }); 64 | 65 | }) 66 | -------------------------------------------------------------------------------- /guides/tutorial.md: -------------------------------------------------------------------------------- 1 | @page Tutorial Getting Started 2 | @parent guides 1 3 | 4 | @body 5 | This tutorial will walk you though the basics of CanJS by building a small 6 | to-do app with CanJS and jQuery like this: 7 | 8 | 9 | 10 | ## Loading CanJS 11 | 12 | The first step is to get and install CanJS. In this tutorial we will be using the [using-standalone standalone] version from our CDN (and jQuery from the [Google API CDN](https://developers.google.com/speed/libraries/devguide#jquery)) so an `index.html` like this will get you started: 13 | 14 | 15 | 16 | CanJS Tutorial 17 | 18 | 19 | 20 | 21 | 26 | 27 | 28 | 29 | ## Get started 30 | 31 | To get started, click [Constructs Constructs] in the navigation to the left, or you can watch the video version. 32 | 33 | 34 | 35 | You can also take a look around and see some nifty [Recipes recipes] for building functionality with CanJS, check out 36 | our [API](../docs/index.html), or dive right in and poke around the [annotated source](http://canjs.com/release/latest/docs/can.jquery.html) for CanJS. -------------------------------------------------------------------------------- /model/queue/queue.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Model Queue Demo 5 | 11 | 12 | 13 |
                                                                                                    14 |

                                                                                                    Model Queue Demo

                                                                                                    15 |

                                                                                                    This demo shows how queue works with the model

                                                                                                    16 |
                                                                                                    17 |
                                                                                                    18 | 19 |
                                                                                                    20 | 21 | 22 | 24 | 58 | 59 | -------------------------------------------------------------------------------- /test/templates/__configuration__-dist.html.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= configuration.description %> Test Suite 5 | 6 | 15 | 16 | 17 | 18 | 19 |

                                                                                                    <%= configuration.description %> Test Suite

                                                                                                    20 | 21 |

                                                                                                    22 | 23 |
                                                                                                    24 |

                                                                                                    25 |
                                                                                                      26 |
                                                                                                      27 | 28 | 29 | 32 | 33 | 34 | 35 | <% modules.forEach(function(module) { %> 36 | <% if(!module.isDefault) { %> 37 | 38 | <% } %> 39 | <% }); %> 40 | 41 | 42 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /test/templates/__configuration__-amd.html.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= configuration.description %> Test Suite 5 | 6 | 7 | 8 | 9 |

                                                                                                      <%= configuration.description %> Test Suite

                                                                                                      10 | 11 |

                                                                                                      12 | 13 |
                                                                                                      14 |

                                                                                                      15 |
                                                                                                        16 |
                                                                                                        17 | 18 | 19 | 20 | 49 | 50 | -------------------------------------------------------------------------------- /util/inserted/inserted.js: -------------------------------------------------------------------------------- 1 | steal('can/util/can.js', function (can) { 2 | // Given a list of elements, check if they are in the dom, if they 3 | // are in the dom, trigger inserted on them. 4 | can.inserted = function (elems) { 5 | // prevent mutations from changing the looping 6 | elems = can.makeArray(elems); 7 | var inDocument = false, 8 | // Not all browsers implement document.contains (Android) 9 | doc = can.$(document.contains ? document : document.body), 10 | children; 11 | for (var i = 0, elem; 12 | (elem = elems[i]) !== undefined; i++) { 13 | if (!inDocument) { 14 | if (elem.getElementsByTagName) { 15 | if (can.has(doc, elem) 16 | .length) { 17 | inDocument = true; 18 | } else { 19 | return; 20 | } 21 | } else { 22 | continue; 23 | } 24 | } 25 | 26 | if (inDocument && elem.getElementsByTagName) { 27 | children = can.makeArray(elem.getElementsByTagName("*")); 28 | can.trigger(elem, "inserted", [], false); 29 | for (var j = 0, child; 30 | (child = children[j]) !== undefined; j++) { 31 | // Trigger the destroyed event 32 | can.trigger(child, "inserted", [], false); 33 | } 34 | } 35 | } 36 | }; 37 | 38 | can.appendChild = function (el, child) { 39 | var children; 40 | if (child.nodeType === 11) { 41 | children = can.makeArray(child.childNodes); 42 | } else { 43 | children = [child]; 44 | } 45 | el.appendChild(child); 46 | can.inserted(children); 47 | }; 48 | can.insertBefore = function (el, child, ref) { 49 | var children; 50 | if (child.nodeType === 11) { 51 | children = can.makeArray(child.childNodes); 52 | } else { 53 | children = [child]; 54 | } 55 | el.insertBefore(child, ref); 56 | can.inserted(children); 57 | }; 58 | 59 | }); 60 | -------------------------------------------------------------------------------- /guides/components/helpers-0.html: -------------------------------------------------------------------------------- 1 |
                                                                                                        2 | 3 | -------------------------------------------------------------------------------- /view/mustache/doc/acquisition.md: -------------------------------------------------------------------------------- 1 | @page can.Mustache.Acquisition Template Acquisition 2 | @parent can.Mustache.pages 4 3 | 4 | There are number of ways to acquire templates such as: raw text, 5 | URL, or script tags in the markup. 6 | 7 | __Raw Text__ 8 | 9 | Raw text can be templated by passing an object with a `text` 10 | attribute containing your template and Mustache will return a 11 | document fragment back. For example: 12 | 13 | var template = "My body lies over the {{.}}"; 14 | var fragment = new can.Mustache({ text: template }) 15 | .render('water'); 16 | can.append(can.$(document.body), can.view.frag(fragment)); 17 | 18 | __Script Tags__ 19 | 20 | Inline script tags in your HTML document can be used to render 21 | templates. Set the `type` to `text/mustache` and the `id` as a unique 22 | key Mustache will use for look up. 23 | 24 | 27 | 28 | var template = can.view("#mytemplate", 'water'); 29 | can.$(document.body).append(template); 30 | 31 | __URL__ 32 | 33 | Templates can be defined in their own files and Mustache will fetch the 34 | files on render. This is the preferred way since it will keep your application 35 | nicely organized seperating views from logic code. 36 | 37 | var template = can.view('//lib/views/mytemplate.mustache', 38 | dataToPass); 39 | can.$(document.body).append(template); 40 | 41 | Since this could potentially make several XHR requests, in a big application 42 | this could be a performance concern. Creating a build step to 43 | concatenate and include all of the views in one file would be one way to optimize performance. 44 | If you are using Steal, it will do this automatically at build for you. -------------------------------------------------------------------------------- /construct/super/super_test.js: -------------------------------------------------------------------------------- 1 | steal("can/construct/super", function () { 2 | module('can/construct/super'); 3 | test('prototype super', function () { 4 | var A = can.Construct({ 5 | init: function (arg) { 6 | this.arg = arg + 1; 7 | }, 8 | add: function (num) { 9 | return this.arg + num; 10 | } 11 | }); 12 | var B = A({ 13 | init: function (arg) { 14 | this._super(arg + 2); 15 | }, 16 | add: function (arg) { 17 | return this._super(arg + 1); 18 | } 19 | }); 20 | var b = new B(1); 21 | equal(b.arg, 4); 22 | equal(b.add(2), 7); 23 | }); 24 | test('static super', function () { 25 | var First = can.Construct({ 26 | raise: function (num) { 27 | return num; 28 | } 29 | }, {}); 30 | var Second = First({ 31 | raise: function (num) { 32 | return this._super(num) * num; 33 | } 34 | }, {}); 35 | equal(Second.raise(2), 4); 36 | }); 37 | test('findAll super', function () { 38 | var Parent = can.Construct({ 39 | findAll: function () { 40 | equal(this.shortName, 'child'); 41 | return new can.Deferred(); 42 | }, 43 | shortName: 'parent' 44 | }, {}); 45 | var Child = Parent({ 46 | findAll: function () { 47 | return this._super(); 48 | }, 49 | shortName: 'child' 50 | }, {}); 51 | stop(); 52 | expect(1); 53 | Child.findAll({}); 54 | start(); 55 | }); 56 | /* Not sure I want to fix this yet. 57 | test("Super in derived when parent doesn't have init", function(){ 58 | can.Construct("Parent",{ 59 | }); 60 | 61 | Parent("Derived",{ 62 | init : function(){ 63 | this._super(); 64 | } 65 | }); 66 | 67 | try { 68 | new Derived(); 69 | ok(true, "can call super in init safely") 70 | } catch (e) { 71 | ok(false, "Failed to call super in init with error: " + e) 72 | } 73 | })*/ 74 | }); 75 | -------------------------------------------------------------------------------- /guides/components/meetup-working.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
                                                                                                        5 | 9 | 10 |
                                                                                                        11 | 12 | 13 |
                                                                                                          14 |
                                                                                                        • 15 |
                                                                                                          16 | 17 | 18 | 19 |
                                                                                                          20 | 21 |
                                                                                                        • 22 |
                                                                                                        • 23 |
                                                                                                          24 | 25 | 26 | 27 |
                                                                                                          28 | 29 |
                                                                                                        • 30 |
                                                                                                        • 31 |
                                                                                                          32 | 33 | 34 | 35 |
                                                                                                          36 | 37 |
                                                                                                        • 38 |
                                                                                                        39 |
                                                                                                        40 |
                                                                                                        41 | 42 | 2 items left 43 | 44 | 49 | 50 |
                                                                                                        51 |
                                                                                                        52 | -------------------------------------------------------------------------------- /test/templates/__configuration__-dev.html.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= configuration.description %> Test Suite 5 | 6 | 15 | 16 | 17 | 18 | 19 |

                                                                                                        <%= configuration.description %> Test Suite

                                                                                                        20 | 21 |

                                                                                                        22 | 23 |
                                                                                                        24 |

                                                                                                        25 |
                                                                                                          26 |
                                                                                                          27 | 28 | 29 | 32 | 33 | 34 | 35 | <% modules.forEach(function(module) { %> 36 | <% if(!module.isDefault) { %> 37 | 38 | <% } %> 39 | <% }); %> 40 | 41 | 42 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /can.md: -------------------------------------------------------------------------------- 1 | @page canjs CanJS 2 | @parent javascriptmvc 0 3 | 4 | @body 5 | 6 | This is the detailed documentation of the API for CanJS 2.0, a framework for building 7 | web applications that provides a lightweight inheritance system, observable 8 | objects and values, and a powerful MVC core with live-bound templates, among other 9 | resources. 10 | 11 | If you are just starting with CanJS, you may want to try our [getting started guide](../guides/Tutorial.html). 12 | 13 | CanJS is composed of modules on the left. The following are typically distributed as part of the core 14 | framework: 15 | 16 | - [can.Component] - widgets built on custom tags 17 | - [can.Construct] - inheritable constructor functions 18 | - [can.Control] - declarative event bindings 19 | - [can.Map], [can.List], [can.compute] - observable objects, list, and values. 20 | - [can.Model] - observes connected to a RESTful JSON interface 21 | - [can.view] - template loading, caching, rendering 22 | - [can.Mustache] - Live binding Handlebars and Mustache templates 23 | - [can.route] - back button and bookmarking support 24 | 25 | The following modules are typically distributed as plugins: 26 | 27 | - [can.EJS] - live binding templates 28 | - [can.Construct.proxy] - Proxy construct methods 29 | - [can.Construct.super] - Call super methods 30 | - [can.Map.delegate] - Listen to Observe attributes 31 | - [can.Map.setter] - Use setter methods on Observes 32 | - [can.Map.attributes] - Define Observe attributes 33 | - [can.Map.validations] - Validate attributes 34 | - [can.Map.backup] - Backup and restore an Observe's state 35 | - [can.Control.plugin] - Registers a jQuery plugin function for Controls[1] 36 | - [can.view.modifiers View modifiers] - Use jQuery modifiers to render views[1] 37 | 38 | 39 | You can use it out of the box on top of jQuery, Zepto, YUI, and Mootools, 40 | and it's only about 20K. 41 | 42 | @api canjs -------------------------------------------------------------------------------- /test/templates/__configuration__-compat.html.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= configuration.description %> Compatibility Test Suite 5 | 6 | 15 | 16 | 17 | 18 | 19 |

                                                                                                          <%= configuration.description %> Compatibility Test Suite

                                                                                                          20 | 21 |

                                                                                                          22 | 23 |
                                                                                                          24 |

                                                                                                          25 |
                                                                                                            26 |
                                                                                                            27 | 28 | 29 | 32 | 33 | 34 | 35 | <% modules.forEach(function(module) { %> 36 | <% if(!module.isDefault) { %> 37 | 38 | <% } %> 39 | <% }); %> 40 | <% pluginified.forEach(function(version) { %> 41 | 42 | <% }); %> 43 | 44 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /map/setter/setter_test.js: -------------------------------------------------------------------------------- 1 | /*global School*/ 2 | steal("can/map/setter", "can/test", function () { 3 | module('can/map/setter'); 4 | test('setter testing works', function () { 5 | var Contact = can.Map({ 6 | setBirthday: function (raw) { 7 | if (typeof raw === 'number') { 8 | return new Date(raw); 9 | } else if (raw instanceof Date) { 10 | return raw; 11 | } 12 | } 13 | }); 14 | var date = new Date(), 15 | contact = new Contact({ 16 | birthday: date.getTime() 17 | }); 18 | // set via constructor 19 | equal(contact.birthday.getTime(), date.getTime(), 'set as birthday'); 20 | // set via attr method 21 | date = new Date(); 22 | contact.attr('birthday', date.getTime()); 23 | equal(contact.birthday.getTime(), date.getTime(), 'set via attr'); 24 | // set via attr method w/ multiple attrs 25 | date = new Date(); 26 | contact.attr({ 27 | birthday: date.getTime() 28 | }); 29 | equal(contact.birthday.getTime(), date.getTime(), 'set as birthday'); 30 | }); 31 | test('error binding', 1, function () { 32 | can.Map('School', { 33 | setName: function (name, success, error) { 34 | if (!name) { 35 | error('no name'); 36 | } 37 | return error; 38 | } 39 | }); 40 | var school = new School(); 41 | school.bind('error', function (ev, attr, error) { 42 | equal(error, 'no name', 'error message provided'); 43 | }); 44 | school.attr('name', ''); 45 | }); 46 | test('asyncronous setting', function () { 47 | var Meyer = can.Map({ 48 | setName: function (newVal, success) { 49 | setTimeout(function () { 50 | success(newVal + ' Meyer'); 51 | }, 1); 52 | } 53 | }); 54 | stop(); 55 | var me = new Meyer(); 56 | me.bind('name', function (ev, newVal) { 57 | equal(newVal, 'Justin Meyer'); 58 | equal(me.attr('name'), 'Justin Meyer'); 59 | start(); 60 | }); 61 | me.attr('name', 'Justin'); 62 | }); 63 | }); 64 | -------------------------------------------------------------------------------- /view/modifiers/modifiers.md: -------------------------------------------------------------------------------- 1 | @page can.view.modifiers jQuery modifiers 2 | @parent can.view.plugins 3 | @plugin can/view/modifiers 4 | @test can/view/modifiers/test.html 5 | 6 | The can/view/modifiers plugin extends the jQuery view modifiers 7 | 8 | * [jQuery.fn.after .after()] 9 | * [jQuery.fn.append .append()] 10 | * [jQuery.fn.before .before()] 11 | * [jQuery.fn.html .html()] 12 | * [jQuery.fn.prepend .prepend()] 13 | * [jQuery.fn.replaceWith .replaceWith()] 14 | * [jQuery.fn.text .text()] 15 | 16 | to render a [can.view]. When rendering a view you call the view modifier the same way 17 | as can.view with the view name or id as the first, the data as the second and the optional 18 | success callback (to load the view asynchronously) as the third parameter. 19 | For example, you can render a template from *todo/todos.ejs* looking like this: 20 | 21 | <% for(var i = 0; i < this.length; i++ ){ %> 22 |
                                                                                                          1. <%= this[i].name %>
                                                                                                          2. 23 | <% } %> 24 | 25 | By calling the [can.prototype.jQuery.fn.html html] modifier on the `#todos` element like this: 26 | 27 | can.$('#todos').html('todo/todos.ejs', [ 28 | { name : 'First Todo' }, 29 | { name : 'Second Todo' } 30 | ]); 31 | 32 | __Note:__ You always have to provide the data (second) argument to render a view, otherwise the standard jQuery 33 | modifier will be used. If you have no data to render pass an empty object: 34 | 35 | $('#todos').html('todo/todos.ejs', {}); 36 | // Render todo/todos.ejs wit no data 37 | 38 | ## Deferreds 39 | 40 | Additionally it is also possible to pass a [can.Deferred] as a single parameter to any view modifier. Once 41 | the deferred resolves the result will be rendered using that modifier. This can be used to easily request 42 | and render static content. The following example inserts the content of _content/info.html_ after the `#todos` element: 43 | 44 | can.$('#todos').after(can.ajax({ 45 | url : 'content/info.html' 46 | })); 47 | -------------------------------------------------------------------------------- /guides/CanJS-blog-posts,-tutorials,-and-examples.md: -------------------------------------------------------------------------------- 1 | ## Example Sites with Tutorials 2 | 3 | - [CanJS Recipes](http://canjs.us/recipes.html) 4 | 5 | A wide variety of CanJS examples covering all parts of CanJS. 6 | 7 | - [Nettuts+ - Diving into CanJS](http://net.tutsplus.com/tutorials/javascript-ajax/diving-into-canjs/) 8 | 9 | A four part series on using CanJS to build a contact manager. 10 | 11 | ## Blog Posts 12 | 13 | ### Overview Blog Posts 14 | 15 | - [Introducing CanJS](http://bitovi.com/blog/2012/04/introducing-canjs.html) - [Bitovi](http://bitovi.com) 16 | - [CanJS and Memory](http://bitovi.com/blog/2012/04/zombie-apocolypse.html) - [Bitovi](http://bitovi.com) 17 | - [CanJS: The Best of Both Worlds](http://www.slideshare.net/moschel/canjs-the-best-of-both-worlds) - [@brianmoschel](http://twitter.com/brianmoschel) 18 | - [Yes We Can(.js)](http://dojo4.com/blog/yes-we-can-js) - [@cookrn](https://twitter.com/cookrn) 19 | 20 | ### Specific Blog Posts 21 | 22 | #### can.route 23 | 24 | - [Hashchange routing with can.route part 1](http://bitovi.com/blog/2012/05/hashchange-routing-can-route-1.html) - [Bitovi](http://bitovi.com) 25 | - [Hashchange routing with can.route part 2](http://bitovi.com/blog/2012/05/hashchange-routing-can-route-2.html) - [Bitovi](http://bitovi.com) 26 | 27 | #### AMD 28 | 29 | - [Modular TodoMVC app with CanJS and RequireJS](http://www.websector.de/blog/2012/08/26/modular-todomvc-app-with-canjs-and-requirejs/) - [@sectore](http://twitter.com/sectore) 30 | 31 | ### Comparison Blog Posts 32 | 33 | - [My Experience With Backbone, Ember and CanJS](http://sporto.github.com/blog/2012/08/18/backbone-ember-canjs/) - [@sebasporto](https://twitter.com/sebasporto) 34 | - [Rich JavaScript Applications - the Seven Frameworks / Throne of JS](http://blog.stevensanderson.com/2012/08/01/rich-javascript-applications-the-seven-frameworks-throne-of-js-2012/) - [@StevenSanderson](https://twitter.com/StevenSanderson) -------------------------------------------------------------------------------- /guides/using.md: -------------------------------------------------------------------------------- 1 | @page Using Setting up CanJS 2 | @parent guides 2 3 | 4 | CanJS is designed and packaged so that it can easily fit into your development workflow. You can use it with [jQuery](http://jquery.com), [Dojo](http://dojotoolkit.org/), [Mootools](http://mootools.net/), [YUI](http://yuilibrary.com/) and [Zepto](http://zeptojs.com/). The following pages contain guides on 5 | 6 | - [using-download Download] - How to get CanJS using the [big download](using-download.html#section_TheCanJSdownload), a [customized build](using-download.html#section_Thedownloadbuilder), [Bower](using-download.html#section_Bower) or our [CDN](using-download.html#section_TheGitHubCDN) 7 | - [using-loading Loading] - How to load CanJS via a [script tag](using-loading.html#section_Ina_script_tag), [AMD](using-loading.html#section_AMD) (RequireJS) or [StealJS](using-loading.html#section_StealJS) 8 | - [using-production In Production] - Tips on how to set up CanJS in a production environment. 9 | - [using-examples Examples] - Some examples on how it all works combined 10 | 11 | If you are looking for a quick start using our [CDN]() just create an HTML page like this: 12 | 13 | 14 | 15 | CanJS Test 16 | 17 | 18 | 19 | 20 | 25 | 26 | 27 | 28 | Or fork one the [JSFiddle](http://jsfiddle.com) with your library of choice: 29 | 30 | - [jQuery](http://jsfiddle.net/donejs/qYdwR/) 31 | - [Zepto](http://jsfiddle.net/donejs/7Yaxk/) 32 | - [Dojo](http://jsfiddle.net/donejs/9x96n/) 33 | - [YUI](http://jsfiddle.net/donejs/w6m73/) 34 | - [Mootools](http://jsfiddle.net/donejs/mnNJX/) 35 | -------------------------------------------------------------------------------- /model/local/local.js: -------------------------------------------------------------------------------- 1 | steal('can/model', 'jquery/lang/object', function () { 2 | can.Model('can.Model.Local', { 3 | compare: {}, 4 | identifier: function () { 5 | return parseInt(100000 * Math.random()); 6 | }, 7 | localStore: function (cb) { 8 | var name = this.shortName, 9 | data = $.evalJSON(window.localStorage[name] || (window.localStorage[name] = '{}')), 10 | res = cb.call(this, data); 11 | if (res !== false) { 12 | window.localStorage[name] = $.toJSON(data); 13 | } 14 | }, 15 | findAll: function (params, success) { 16 | var instances = [], 17 | def = $.Deferred() 18 | .then(success); 19 | this.localStore(function (objs) { 20 | for (var o in objs) { 21 | if ($.Object.same(objs[o], params, this.compare)) { 22 | instances.push(new this(objs[o])); 23 | } 24 | } 25 | }); 26 | return def.resolve(instances); 27 | }, 28 | findOne: function (id, success) { 29 | var idProp = this.id, 30 | def = $.Deferred() 31 | .then(success), 32 | one; 33 | this.localStore(function (objs) { 34 | for (var o in objs) { 35 | if (objs[o][idProp] === id) { 36 | one = new this(objs[id]); 37 | break; 38 | } 39 | } 40 | }); 41 | return def.resolve(one); 42 | }, 43 | destroyAll: function (params, success) { 44 | var def = $.Deferred() 45 | .then(success); 46 | this.localStore(function (objs) { 47 | $.each(params, function () { 48 | delete objs[this]; 49 | }); 50 | }); 51 | return def.resolve({}); 52 | }, 53 | destroy: function (id, success) { 54 | return this.destroyAll([id], success); 55 | }, 56 | create: function (attrs, success) { 57 | var idProp = this.id, 58 | def = $.Deferred() 59 | .then(success); 60 | this.localStore(function (objs) { 61 | attrs[idProp] = attrs[idProp] || this.identifier(); 62 | objs[attrs[idProp]] = attrs; 63 | }); 64 | return def.resolve(attrs); 65 | } 66 | }); 67 | }); 68 | -------------------------------------------------------------------------------- /view/scope/scope.md: -------------------------------------------------------------------------------- 1 | @constructor can.view.Scope 2 | @inherits can.Construct 3 | @parent can.view.static 4 | @test can/map/test.html 5 | @plugin can/view/scope 6 | @group can.view.Scope.types types 7 | 8 | @description Create a lookup node for [can.Mustache.key keys]. 9 | 10 | @signature `new can.view.Scope(context, [parent])` 11 | 12 | @param {*} context A value that represents the 13 | current context. This is often an object or observable and is the first 14 | place 15 | 16 | @param {can.view.Scope} [parent] The parent scope. If a `key` value 17 | is not found in the current scope, it will then look in the parent 18 | scope. 19 | 20 | @return {can.view.Scope} Returns a scope instance. 21 | 22 | @body 23 | 24 | ## Use 25 | 26 | A `can.view.Scope` represents a lookup context and parent contexts 27 | that can be used to lookup a [can.Mustache.key key] value. 28 | 29 | If no parent scope is provided, only the scope's context will be 30 | explored for values. For example: 31 | 32 | var data = {name: {first: "Justin"}}, 33 | scope = new can.view.Scope(data); 34 | 35 | scope.attr("name.first") //-> "Justin" 36 | scope.attr("length") //-> undefined 37 | 38 | However, if a `parent` scope is provided, key values will be 39 | searched in the parent's contexxt after the initial context is expored. For example: 40 | 41 | var list = [{name: "Justin"},{name: "Brian"}], 42 | justin = list[0]; 43 | 44 | var listScope = new can.view.Scope(list), 45 | curScope = new can.view.Scope(justin, listScope) 46 | 47 | curScope.attr("name") //-> "Justin" 48 | curScope.attr("length") //-> 2 49 | 50 | Use [can.view.Scope.prototype.add add] to easily create a new scope from a parent scope like: 51 | 52 | 53 | var list = [{name: "Justin"},{name: "Brian"}], 54 | justin = list[0]; 55 | 56 | var curScope = new can.view.Scope(list).add(justin); 57 | 58 | curScope.attr("name") //-> "Justin" 59 | curScope.attr("length") //-> 2 -------------------------------------------------------------------------------- /route/pushstate/pushstate.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 24 | 25 | 82 | -------------------------------------------------------------------------------- /view/mustache/spec/TESTING.md: -------------------------------------------------------------------------------- 1 | @page mustache.test 2 | Testing your Mustache implementation against this specification should be 3 | relatively simple. If you have a readily available testing framework on your 4 | platform, your task may be even simpler. 5 | 6 | In general, the process for each `.yml` file is as follows: 7 | 8 | 1. Use a YAML parser to load the file. 9 | 10 | 2. For each test in the 'tests' array: 11 | 12 | 1. Ensure that each element of the 'partials' hash (if it exists) is 13 | stored in a place where the interpreter will look for it. 14 | 15 | 2. If your implementation will not support lambdas, feel free to skip over 16 | the optional '~lambdas.yml' file. 17 | 18 | 2.1. If your implementation will support lambdas, ensure that each member of 19 | 'data' tagged with '!code' is properly processed into a language- 20 | specific lambda reference. 21 | 22 | * e.g. Given this YAML data hash: 23 | 24 | `{ x: !code { ruby: 'proc { "x" }', perl: 'sub { "x" }' } }` 25 | 26 | a Ruby-based Mustache implementation would process it such that it 27 | was equivalent to this Ruby hash: 28 | 29 | `{ 'x' => proc { "x" } }` 30 | 31 | * If your implementation language does not currently have lambda 32 | examples in the spec, feel free to implement them and send a pull 33 | request. 34 | 35 | * The JSON version of the spec represents these tagged values as a hash 36 | with a '`__tag__`' key of 'code'. 37 | 38 | 3. Render the template (stored in the 'template' key) with the given 'data' 39 | hash. 40 | 41 | 4. Compare the results of your rendering against the 'expected' value; any 42 | differences should be reported, along with any useful debugging 43 | information. 44 | 45 | * Of note, the 'desc' key contains a rough one-line description of the 46 | behavior being tested -- this is most useful in conjunction with the 47 | file name and test 'name'. 48 | -------------------------------------------------------------------------------- /view/mustache/doc/sections.md: -------------------------------------------------------------------------------- 1 | @page can.Mustache.Sections Sections 2 | @parent can.Mustache.pages 2 3 | 4 | Sections (`[can.Mustache.helpers.section {{#key}}]` followed by `[can.Mustache.helpers.close {{/key}}]`) have multiple uses 5 | depending on what type of object is passed to the section. In all cases, using a section will change 6 | the current [can.Mustache.context context]. 7 | 8 | The most basic form of section will simply render a section of code if the key referenced is considered **truthy** (has a value): 9 | 10 | Template: 11 | Hello! 12 | {{#person}} 13 | {{name}} 14 | {{/person}} 15 | 16 | Data: 17 | { 18 | person: { 19 | name: "Andy" 20 | } 21 | } 22 | 23 | Result: 24 | Hello! 25 | Andy 26 | 27 | Whenever the key doesn't exist or the value is **falsey**, the section won't be rendered: 28 | 29 | Template: 30 | Hello! 31 | {{#person}} 32 | {{name}} 33 | {{/person}} 34 | 35 | Data: 36 | {} 37 | 38 | Result: 39 | Hello! 40 | 41 | However, this scenario can be covered through the use of an inverse section 42 | (`[can.Mustache.helpers.inverse {{^key}}]` followed by `[can.Mustache.helpers.close {{/key}}]`): 43 | 44 | Template: 45 | Hello! 46 | {{#person}} 47 | {{name}} 48 | {{/person}} 49 | {{^person}} 50 | No one is here. 51 | {{/person}} 52 | 53 | Data: 54 | {} 55 | 56 | Result: 57 | Hello! 58 | No one is here. 59 | 60 | ## Iteration 61 | 62 | There is a special case for sections where the key references an array. In this case, the section iterates 63 | the entire array, rendering the inner text for each item in the array. Arrays are considered **truthy** if 64 | they aren't empty. The `{{.}}` tag will reference the current item within the array during iteration (which is 65 | primarily used when the items in the array are primitives like strings and numbers). 66 | 67 | Template: 68 | {{#people}} 69 | {{.}} 70 | {{/people}} 71 | 72 | Data: 73 | { 74 | people: ["Andy", "Austin", "Justin"] 75 | } 76 | 77 | Result: 78 | Andy Austin Justin 79 | -------------------------------------------------------------------------------- /construct/construct.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | can.Construct Demo 5 | 6 | 7 |

                                                                                                            Some can.Construct demos

                                                                                                            8 |

                                                                                                            Open the console to see the status messages.

                                                                                                            9 | 10 | 76 | 77 | -------------------------------------------------------------------------------- /guides/components/meetup-start.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
                                                                                                            12 | 16 |
                                                                                                            17 | 18 | 19 |
                                                                                                              20 |
                                                                                                            • 21 |
                                                                                                              22 | 23 | 24 | 25 |
                                                                                                              26 | 27 |
                                                                                                            • 28 |
                                                                                                            • 29 |
                                                                                                              30 | 31 | 32 | 33 |
                                                                                                              34 | 35 |
                                                                                                            • 36 |
                                                                                                            • 37 |
                                                                                                              38 | 39 | 40 | 41 |
                                                                                                              42 | 43 |
                                                                                                            • 44 |
                                                                                                            45 |
                                                                                                            46 |
                                                                                                            47 | 48 | 2 items left 49 | 50 | 61 | 64 |
                                                                                                            65 |
                                                                                                            66 | 72 | 73 | -------------------------------------------------------------------------------- /view/scope/readOptions.md: -------------------------------------------------------------------------------- 1 | @typedef {{isArgument: Boolean}} can.view.Scope.readOptions readOptions 2 | @parent can.view.Scope.types 3 | 4 | An options object used to configure [can.view.Scope.read]. 5 | 6 | 7 | @option {function(can.compute|can.Map,Number)} [foundObservable(observe, readIndex)] `foundObservable` is called 8 | when the first observable is found along the path along the read path. It's called with 9 | the `readIndex` where the observable was found. 10 | 11 | var data = {person : new can.Map({name: "Justin"})} 12 | Scope.read( data, 13 | ["person.name"], 14 | {foundObservable: function(observe, readIndex){ 15 | observe === data.person //-> true 16 | readIndex //-> 1 17 | }} ) 18 | 19 | @option {function(can.compute|can.Map,Number)} [earlyExit(observe, readIndex)] Is called if a value is not found. 20 | 21 | @option {Boolean} [isArgument] If true, and the last value is a function or compute, returns that 22 | function instead of calling it. 23 | 24 | MyMap = can.Map.extend({method: function(){}}); 25 | res = Scope.read( new MyMap(), 26 | ["method"], 27 | {isArgument: true, proxyMethods: false} ); 28 | res === MyMap.prototype.method //-> true 29 | 30 | @option {Array} args An array of arguments to pass to observable prototype methods. 31 | 32 | @option {Boolean} [returnObserveMethods] If true, returns 33 | methods found on an observable. Otherwise, it will call the function with `args` as arguments and return the 34 | value. 35 | 36 | var Dog = can.Map.extend({ 37 | age: function(){ 38 | return this.attr("years")*7 39 | } 40 | }) 41 | 42 | var dog = new Dog({years: 3}); 43 | 44 | Scope.read(dog,"age",{}) //-> 21 45 | 46 | Scope.read(dog, 47 | "age", 48 | {returnObserveMethods: true})() //-> 21 49 | 50 | @option {Boolean} [proxyMethods=true] Set to false to return just the function, preventing returning a function that 51 | always calls the original function with this as the parent. 52 | --------------------------------------------------------------------------------