├── VERSION ├── packages ├── ember-runtime │ ├── .gitignore │ ├── lib │ │ ├── ext.js │ │ ├── system │ │ │ ├── container.js │ │ │ ├── deferred.js │ │ │ ├── object.js │ │ │ ├── lazy_load.js │ │ │ └── application.js │ │ ├── controllers.js │ │ ├── main.js │ │ ├── mixins.js │ │ ├── system.js │ │ ├── controllers │ │ │ └── object_controller.js │ │ └── mixins │ │ │ ├── comparable.js │ │ │ ├── target_action_support.js │ │ │ ├── deferred.js │ │ │ └── copyable.js │ ├── tests │ │ ├── core │ │ │ ├── copy_test.js │ │ │ ├── error_test.js │ │ │ ├── keys_test.js │ │ │ ├── isNone_test.js │ │ │ ├── isArray_test.js │ │ │ ├── type_test.js │ │ │ ├── inspect_test.js │ │ │ ├── isEmpty_test.js │ │ │ ├── compare_test.js │ │ │ └── isEqual_test.js │ │ ├── system │ │ │ ├── application │ │ │ │ └── base_test.js │ │ │ ├── native_array │ │ │ │ ├── suite_test.js │ │ │ │ └── copyable_suite_test.js │ │ │ ├── array_proxy │ │ │ │ ├── suite_test.js │ │ │ │ └── content_update_test.js │ │ │ ├── set │ │ │ │ ├── copyable_suite_test.js │ │ │ │ └── enumerable_suite_test.js │ │ │ ├── string │ │ │ │ ├── fmt_string.js │ │ │ │ ├── w_test.js │ │ │ │ ├── classify.js │ │ │ │ ├── underscore.js │ │ │ │ ├── decamelize.js │ │ │ │ ├── camelize.js │ │ │ │ ├── loc_test.js │ │ │ │ ├── dasherize.js │ │ │ │ └── capitalize.js │ │ │ ├── object │ │ │ │ ├── reopenClass_test.js │ │ │ │ ├── detect_test.js │ │ │ │ ├── reopen_test.js │ │ │ │ ├── subclasses_test.js │ │ │ │ ├── detectInstance_test.js │ │ │ │ ├── extend_test.js │ │ │ │ └── destroy_test.js │ │ │ ├── deferred_test.js │ │ │ └── lazy_load_test.js │ │ ├── suites │ │ │ ├── mutable_enumerable.js │ │ │ ├── enumerable │ │ │ │ ├── toArray.js │ │ │ │ ├── compact.js │ │ │ │ ├── firstObject.js │ │ │ │ ├── mapProperty.js │ │ │ │ ├── lastObject.js │ │ │ │ ├── contains.js │ │ │ │ ├── invoke.js │ │ │ │ ├── without.js │ │ │ │ ├── reduce.js │ │ │ │ ├── uniq.js │ │ │ │ ├── forEach.js │ │ │ │ └── map.js │ │ │ ├── copyable │ │ │ │ ├── copy.js │ │ │ │ └── frozenCopy.js │ │ │ ├── mutable_array.js │ │ │ ├── array │ │ │ │ ├── indexOf.js │ │ │ │ └── objectAt.js │ │ │ ├── copyable.js │ │ │ ├── array.js │ │ │ └── mutable_array │ │ │ │ └── reverseObjects.js │ │ ├── controllers │ │ │ ├── object_controller_tests.js │ │ │ └── array_controller_test.js │ │ ├── ext │ │ │ ├── function_test.js │ │ │ └── mixin_test.js │ │ ├── mixins │ │ │ ├── copyable_test.js │ │ │ ├── comparable_test.js │ │ │ ├── mutable_array_test.js │ │ │ └── mutable_enumerable_test.js │ │ ├── legacy_1x │ │ │ └── mixins │ │ │ │ └── observable │ │ │ │ ├── observersForKey_test.js │ │ │ │ └── chained_test.js │ │ └── props_helper.js │ ├── README │ └── package.json ├── ember-old-router │ ├── lib │ │ ├── helpers.js │ │ ├── application │ │ │ └── system.js │ │ ├── location.js │ │ ├── application.js │ │ ├── route.js │ │ ├── main.js │ │ ├── view_ext.js │ │ ├── resolved_state.js │ │ ├── location │ │ │ ├── none_location.js │ │ │ └── api.js │ │ ├── promise_chain.js │ │ ├── route_matcher.js │ │ └── handlebars_ext.js │ ├── package.json │ └── tests │ │ ├── view_test.js │ │ ├── helpers │ │ └── action_url_test.js │ │ └── application_test.js ├── ember │ ├── lib │ │ └── main.js │ └── package.json ├── ember-routing │ ├── lib │ │ ├── ext.js │ │ ├── helpers.js │ │ ├── system.js │ │ ├── location.js │ │ ├── main.js │ │ ├── ext │ │ │ └── view.js │ │ ├── system │ │ │ ├── controller_for.js │ │ │ └── dsl.js │ │ ├── location │ │ │ ├── none_location.js │ │ │ └── api.js │ │ └── helpers │ │ │ └── render.js │ ├── package.json │ └── tests │ │ └── system │ │ └── controller_test.js ├── ember-application │ ├── lib │ │ ├── system.js │ │ └── main.js │ └── package.json ├── ember-handlebars │ ├── lib │ │ ├── views.js │ │ ├── controls │ │ │ ├── tabs.js │ │ │ ├── text_support.js │ │ │ ├── checkbox.js │ │ │ └── text_area.js │ │ ├── controls.js │ │ ├── helpers │ │ │ ├── shared.js │ │ │ ├── unbound.js │ │ │ ├── debug.js │ │ │ └── yield.js │ │ ├── helpers.js │ │ ├── main.js │ │ └── string.js │ ├── package.json │ └── tests │ │ └── helpers │ │ └── if_unless_test.js ├── ember-views │ ├── lib │ │ ├── views.js │ │ ├── system.js │ │ ├── main.js │ │ ├── system │ │ │ ├── ext.js │ │ │ ├── jquery_ext.js │ │ │ └── controller.js │ │ ├── core.js │ │ └── views │ │ │ ├── states.js │ │ │ └── states │ │ │ ├── pre_render.js │ │ │ ├── default.js │ │ │ └── destroyed.js │ ├── tests │ │ ├── views │ │ │ └── view │ │ │ │ ├── destroy_test.js │ │ │ │ ├── context_test.js │ │ │ │ ├── create_child_view_test.js │ │ │ │ ├── evented_test.js │ │ │ │ ├── create_element_test.js │ │ │ │ ├── controller_test.js │ │ │ │ ├── nearest_of_type_test.js │ │ │ │ ├── init_test.js │ │ │ │ └── jquery_test.js │ │ └── system │ │ │ └── ext_test.js │ └── package.json ├── ember-states │ ├── lib │ │ └── main.js │ └── package.json ├── ember-debug │ └── package.json ├── ember-metal │ ├── tests │ │ ├── mixin │ │ │ ├── without_test.js │ │ │ ├── reopen_test.js │ │ │ ├── apply_test.js │ │ │ ├── detect_test.js │ │ │ ├── required_test.js │ │ │ └── introspection_test.js │ │ ├── props_helper.js │ │ ├── run_loop │ │ │ ├── next_test.js │ │ │ ├── sync_test.js │ │ │ ├── run_test.js │ │ │ ├── onerror_test.js │ │ │ ├── later_test.js │ │ │ ├── unwind_test.js │ │ │ ├── once_test.js │ │ │ └── schedule_test.js │ │ ├── accessors │ │ │ ├── isGlobalPath_test.js │ │ │ ├── set_test.js │ │ │ └── getPath_test.js │ │ ├── utils │ │ │ ├── can_invoke_test.js │ │ │ └── try_invoke_test.js │ │ ├── platform │ │ │ └── create_test.js │ │ ├── binding │ │ │ └── oneWay_test.js │ │ ├── properties_test.js │ │ └── watching │ │ │ └── isWatching_test.js │ ├── lib │ │ └── main.js │ └── package.json ├── loader │ ├── package.json │ └── lib │ │ └── main.js ├── rsvp │ └── package.json ├── container │ └── package.json ├── metamorph │ └── package.json └── ember-handlebars-compiler │ └── package.json ├── benchmarks ├── nano.jar ├── suites │ ├── plain_object.js │ ├── object_with_scalar.js │ ├── object_with_cp.js │ ├── object_with_observer.js │ ├── extended_object_at_runtime.js │ ├── extended_object.js │ └── views │ │ ├── destroy_view.js │ │ ├── template_view.js │ │ └── each_view.js ├── README.md ├── index.html ├── setup.markdown └── simple.html ├── docs ├── package.json └── yuidoc.json ├── .travis.yml ├── .gitmodules ├── Gemfile ├── config.ru ├── generators └── license.js ├── Vagrantfile ├── .gitignore ├── ember.json ├── scripts └── list_file_sizes.rb ├── LICENSE ├── Gemfile.lock ├── .jshintrc └── tests └── minispade.js /VERSION: -------------------------------------------------------------------------------- 1 | 1.0.0-pre.4 2 | -------------------------------------------------------------------------------- /packages/ember-runtime/.gitignore: -------------------------------------------------------------------------------- 1 | .spade 2 | -------------------------------------------------------------------------------- /packages/ember-old-router/lib/helpers.js: -------------------------------------------------------------------------------- 1 | require('ember-old-router/helpers/action'); 2 | -------------------------------------------------------------------------------- /benchmarks/nano.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codegram/ember.js/master/benchmarks/nano.jar -------------------------------------------------------------------------------- /packages/ember/lib/main.js: -------------------------------------------------------------------------------- 1 | require('ember-application'); 2 | 3 | /** 4 | Ember 5 | 6 | @module ember 7 | */ 8 | -------------------------------------------------------------------------------- /packages/ember-routing/lib/ext.js: -------------------------------------------------------------------------------- 1 | require('ember-routing/ext/controller'); 2 | require('ember-routing/ext/view'); 3 | -------------------------------------------------------------------------------- /packages/ember-runtime/lib/ext.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/ext/string'); 2 | require('ember-runtime/ext/function'); 3 | -------------------------------------------------------------------------------- /packages/ember-runtime/lib/system/container.js: -------------------------------------------------------------------------------- 1 | Ember.Container = requireModule('container'); 2 | Ember.Container.set = Ember.set; 3 | -------------------------------------------------------------------------------- /packages/ember-application/lib/system.js: -------------------------------------------------------------------------------- 1 | require('ember-application/system/dag'); 2 | require('ember-application/system/application'); 3 | -------------------------------------------------------------------------------- /packages/ember-handlebars/lib/views.js: -------------------------------------------------------------------------------- 1 | require("ember-handlebars/views/handlebars_bound_view"); 2 | require("ember-handlebars/views/metamorph_view"); 3 | -------------------------------------------------------------------------------- /benchmarks/suites/plain_object.js: -------------------------------------------------------------------------------- 1 | /*global bench alert*/ 2 | 3 | bench("Ember.Object.create()", function() { 4 | Ember.Object.create(); 5 | }); 6 | 7 | -------------------------------------------------------------------------------- /docs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-docs", 3 | "version": "0.0.1", 4 | "dependencies": { 5 | "yuidoc": "git://github.com/wagenet/yuidoc.git" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/ember-old-router/lib/application/system.js: -------------------------------------------------------------------------------- 1 | require('ember-old-router/application/system/dag'); 2 | require('ember-old-router/application/system/application'); 3 | -------------------------------------------------------------------------------- /benchmarks/suites/object_with_scalar.js: -------------------------------------------------------------------------------- 1 | /*global bench alert*/ 2 | 3 | bench("foo should not exist", function() { 4 | Ember.Object.create({ foo: 'bar' }); 5 | }); 6 | 7 | 8 | -------------------------------------------------------------------------------- /benchmarks/suites/object_with_cp.js: -------------------------------------------------------------------------------- 1 | /*global bench before*/ 2 | 3 | bench("foo should not exist", function() { 4 | Ember.Object.create({ foo: function() { }.property('bar') }); 5 | }); 6 | -------------------------------------------------------------------------------- /benchmarks/suites/object_with_observer.js: -------------------------------------------------------------------------------- 1 | /*global bench alert*/ 2 | 3 | bench("foo should not exist", function() { 4 | Ember.Object.create({ foo: function() { }.observes('bar') }); 5 | }); 6 | 7 | -------------------------------------------------------------------------------- /packages/ember-runtime/lib/controllers.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/controllers/array_controller'); 2 | require('ember-runtime/controllers/object_controller'); 3 | require('ember-runtime/controllers/controller'); 4 | -------------------------------------------------------------------------------- /packages/ember-views/lib/views.js: -------------------------------------------------------------------------------- 1 | require("ember-views/views/view"); 2 | require("ember-views/views/states"); 3 | require("ember-views/views/container_view"); 4 | require("ember-views/views/collection_view"); 5 | -------------------------------------------------------------------------------- /packages/ember-routing/lib/helpers.js: -------------------------------------------------------------------------------- 1 | require('ember-routing/helpers/link_to'); 2 | require('ember-routing/helpers/outlet'); 3 | require('ember-routing/helpers/render'); 4 | require('ember-routing/helpers/action'); 5 | -------------------------------------------------------------------------------- /packages/ember-routing/lib/system.js: -------------------------------------------------------------------------------- 1 | require('ember-routing/system/dsl'); 2 | require('ember-routing/system/controller_for'); 3 | require('ember-routing/system/router'); 4 | require('ember-routing/system/route'); 5 | -------------------------------------------------------------------------------- /packages/ember-handlebars/lib/controls/tabs.js: -------------------------------------------------------------------------------- 1 | require("ember-handlebars/controls/tabs/tab_container_view"); 2 | require("ember-handlebars/controls/tabs/tab_pane_view"); 3 | require("ember-handlebars/controls/tabs/tab_view"); 4 | 5 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/core/copy_test.js: -------------------------------------------------------------------------------- 1 | module("Ember Copy Method"); 2 | 3 | test("Ember.copy null", function() { 4 | var obj = {field: null}; 5 | equal(Ember.copy(obj, true).field, null, "null should still be null"); 6 | }); 7 | 8 | -------------------------------------------------------------------------------- /packages/ember-routing/lib/location.js: -------------------------------------------------------------------------------- 1 | require('ember-views'); 2 | require('ember-routing/location/api'); 3 | require('ember-routing/location/none_location'); 4 | require('ember-routing/location/hash_location'); 5 | require('ember-routing/location/history_location'); 6 | -------------------------------------------------------------------------------- /packages/ember-states/lib/main.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime'); 2 | 3 | /** 4 | Ember States 5 | 6 | @module ember 7 | @submodule ember-states 8 | @requires ember-runtime 9 | */ 10 | 11 | require('ember-states/state_manager'); 12 | require('ember-states/state'); 13 | -------------------------------------------------------------------------------- /benchmarks/suites/extended_object_at_runtime.js: -------------------------------------------------------------------------------- 1 | /*globals before bench*/ 2 | 3 | bench("extending an object and creating it immediately", function() { 4 | var klass = Ember.Object.extend({ template: function() {}.property('templateName') }); 5 | klass.create(); 6 | }); 7 | 8 | -------------------------------------------------------------------------------- /packages/ember-old-router/lib/location.js: -------------------------------------------------------------------------------- 1 | require('ember-views'); 2 | require('ember-old-router/location/api'); 3 | require('ember-old-router/location/none_location'); 4 | require('ember-old-router/location/hash_location'); 5 | require('ember-old-router/location/history_location'); 6 | -------------------------------------------------------------------------------- /packages/ember-handlebars/lib/controls.js: -------------------------------------------------------------------------------- 1 | require("ember-handlebars/controls/checkbox"); 2 | require("ember-handlebars/controls/text_field"); 3 | require("ember-handlebars/controls/button"); 4 | require("ember-handlebars/controls/text_area"); 5 | require("ember-handlebars/controls/select"); 6 | -------------------------------------------------------------------------------- /packages/ember-application/lib/main.js: -------------------------------------------------------------------------------- 1 | require('ember-views'); 2 | require('ember-routing'); 3 | require('ember-application/system'); 4 | 5 | /** 6 | Ember Application 7 | 8 | @module ember 9 | @submodule ember-application 10 | @requires ember-views, ember-states, ember-routing 11 | */ 12 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/system/application/base_test.js: -------------------------------------------------------------------------------- 1 | module('Ember.Application'); 2 | 3 | test('Ember.Application should be a subclass of Ember.Namespace', function() { 4 | 5 | ok(Ember.Namespace.detect(Ember.Application), 'Ember.Application subclass of Ember.Namespace'); 6 | 7 | }); 8 | -------------------------------------------------------------------------------- /packages/ember-views/lib/system.js: -------------------------------------------------------------------------------- 1 | require("ember-views/system/jquery_ext"); 2 | require("ember-views/system/utils"); 3 | require("ember-views/system/render_buffer"); 4 | require("ember-views/system/event_dispatcher"); 5 | require("ember-views/system/ext"); 6 | require("ember-views/system/controller"); 7 | -------------------------------------------------------------------------------- /packages/ember-old-router/lib/application.js: -------------------------------------------------------------------------------- 1 | require('ember-views'); 2 | require('ember-states'); 3 | require('ember-old-router/application/system'); 4 | 5 | /** 6 | Ember Application 7 | 8 | @module ember 9 | @submodule ember-application 10 | @requires ember-views, ember-states, ember-routing 11 | */ 12 | -------------------------------------------------------------------------------- /benchmarks/suites/extended_object.js: -------------------------------------------------------------------------------- 1 | /*globals before bench*/ 2 | 3 | var klass; 4 | 5 | before(function() { 6 | var klass = Ember.Object.extend({ template: function() {}.property('templateName') }); 7 | }); 8 | 9 | bench("creating an object that was already extended", function() { 10 | klass.create(); 11 | }); 12 | -------------------------------------------------------------------------------- /packages/ember-old-router/lib/route.js: -------------------------------------------------------------------------------- 1 | require('ember-old-router/routable'); 2 | 3 | /** 4 | @module ember 5 | @submodule ember-old-router 6 | */ 7 | 8 | /** 9 | @class Route 10 | @namespace Ember 11 | @extends Ember.State 12 | @uses Ember.Routable 13 | */ 14 | Ember.Route = Ember.State.extend(Ember.Routable); 15 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/suites/mutable_enumerable.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/~tests/suites/enumerable'); 2 | 3 | Ember.MutableEnumerableTests = Ember.EnumerableTests.extend(); 4 | 5 | require('ember-runtime/~tests/suites/mutable_enumerable/addObject'); 6 | require('ember-runtime/~tests/suites/mutable_enumerable/removeObject'); 7 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/core/error_test.js: -------------------------------------------------------------------------------- 1 | module("Ember Error Throwing"); 2 | 3 | test("new Ember.Error displays provided message", function() { 4 | raises( function(){ 5 | throw new Ember.Error('A Message'); 6 | }, function(e){ 7 | return e.message === 'A Message'; 8 | }, 'the assigned message was displayed' ); 9 | }); 10 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/suites/enumerable/toArray.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/~tests/suites/enumerable'); 2 | 3 | var suite = Ember.EnumerableTests; 4 | 5 | suite.module('toArray'); 6 | 7 | suite.test('toArray should convert to an array', function() { 8 | var obj = this.newObject(); 9 | deepEqual(obj.toArray(), this.toArray(obj)); 10 | }); 11 | 12 | -------------------------------------------------------------------------------- /packages/ember-views/lib/main.js: -------------------------------------------------------------------------------- 1 | /*globals jQuery*/ 2 | 3 | require("ember-runtime"); 4 | require("container"); 5 | 6 | /** 7 | Ember Views 8 | 9 | @module ember 10 | @submodule ember-views 11 | @requires ember-runtime 12 | @main ember-views 13 | */ 14 | 15 | require("ember-views/core"); 16 | require("ember-views/system"); 17 | require("ember-views/views"); 18 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | rvm: 2 | - 1.9.3 3 | bundler_args: --without development 4 | before_script: 5 | - "export DISPLAY=:99.0" 6 | - "sh -e /etc/init.d/xvfb start" 7 | script: "rake test\\[standard]" 8 | notifications: 9 | webhooks: http://emberjs-master-builds.herokuapp.com/upload/ember.js 10 | branches: 11 | except: 12 | - latest-builds 13 | - release-builds 14 | -------------------------------------------------------------------------------- /packages/ember-runtime/lib/main.js: -------------------------------------------------------------------------------- 1 | /** 2 | Ember Runtime 3 | 4 | @module ember 5 | @submodule ember-runtime 6 | @requires ember-metal 7 | */ 8 | 9 | require('container'); 10 | require('ember-metal'); 11 | require('ember-runtime/core'); 12 | require('ember-runtime/ext'); 13 | require('ember-runtime/mixins'); 14 | require('ember-runtime/system'); 15 | require('ember-runtime/controllers'); 16 | -------------------------------------------------------------------------------- /benchmarks/README.md: -------------------------------------------------------------------------------- 1 | # Extremely simple Ember benchmarks 2 | 3 | To run the benchmarks, serve the repository root on a web server (`gem install 4 | asdf; asdf`), run `rake` to build Ember, and open e.g. 5 | `http://localhost:9292/benchmarks/index.html?suitePath=plain_object.js` to run 6 | `benchmarks/suites/plain_object.js`. Run `cp -r dist distold` to benchmark 7 | different versions against each other. 8 | -------------------------------------------------------------------------------- /packages/ember-handlebars/lib/helpers/shared.js: -------------------------------------------------------------------------------- 1 | Ember.Handlebars.resolvePaths = function(options) { 2 | var ret = [], 3 | contexts = options.contexts, 4 | roots = options.roots, 5 | data = options.data; 6 | 7 | for (var i=0, l=contexts.length; i= 1.7.2), 1.8 or 1.9", jQuery && (jQuery().jquery.match(/^1\.(7(?!$)(?!\.[01])|8|9)(\.\d+)?(pre|rc\d?)?/) || Ember.ENV.FORCE_JQUERY)); 8 | 9 | /** 10 | Alias for jQuery 11 | 12 | @method $ 13 | @for Ember 14 | */ 15 | Ember.$ = jQuery; 16 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "http://rubygems.org" 2 | 3 | gem "rake-pipeline", :git => "https://github.com/livingsocial/rake-pipeline.git" 4 | gem "rake-pipeline-web-filters", :git => "https://github.com/wycats/rake-pipeline-web-filters.git" 5 | gem "colored" 6 | # Using git to prevent deprecation warnings 7 | gem "uglifier", :git => "https://github.com/lautis/uglifier.git" 8 | 9 | group :development do 10 | gem "rack" 11 | gem "kicker" 12 | end 13 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/system/native_array/suite_test.js: -------------------------------------------------------------------------------- 1 | Ember.MutableArrayTests.extend({ 2 | 3 | name: 'Native Array', 4 | 5 | newObject: function(ary) { 6 | return Ember.A(ary ? ary.slice() : this.newFixture(3)); 7 | }, 8 | 9 | mutate: function(obj) { 10 | obj.pushObject(obj.length+1); 11 | }, 12 | 13 | toArray: function(obj) { 14 | return obj.slice(); // make a copy. 15 | } 16 | 17 | }).run(); 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /benchmarks/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /packages/ember-handlebars/lib/helpers.js: -------------------------------------------------------------------------------- 1 | require("ember-handlebars/helpers/shared"); 2 | require("ember-handlebars/helpers/binding"); 3 | require("ember-handlebars/helpers/collection"); 4 | require("ember-handlebars/helpers/view"); 5 | require("ember-handlebars/helpers/unbound"); 6 | require("ember-handlebars/helpers/debug"); 7 | require("ember-handlebars/helpers/each"); 8 | require("ember-handlebars/helpers/template"); 9 | require("ember-handlebars/helpers/yield"); 10 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | require 'bundler/setup' 2 | require 'rake-pipeline' 3 | require 'rake-pipeline/middleware' 4 | 5 | class NoCache 6 | def initialize(app) 7 | @app = app 8 | end 9 | 10 | def call(env) 11 | @app.call(env).tap do |status, headers, body| 12 | headers["Cache-Control"] = "no-store" 13 | end 14 | end 15 | end 16 | 17 | use NoCache 18 | use Rake::Pipeline::Middleware, Rake::Pipeline::Project.new("Assetfile") 19 | run Rack::Directory.new('.') 20 | -------------------------------------------------------------------------------- /packages/ember-debug/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-debug", 3 | "summary": "Debugging for Ember", 4 | "description": "Debugging helpers for Ember", 5 | "homepage": "http://www.emberjs.com", 6 | "author": "Peter Wagenet", 7 | "version": "1.0.0-pre.4", 8 | 9 | "directories": { 10 | "lib": "lib" 11 | }, 12 | 13 | "bpm:build": { 14 | "bpm_libs.js": { 15 | "files": ["lib"], 16 | "modes": "*" 17 | } 18 | } 19 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /packages/ember-metal/tests/mixin/without_test.js: -------------------------------------------------------------------------------- 1 | /*globals setup */ 2 | 3 | test('without should create a new mixin excluding named properties', function() { 4 | 5 | var MixinA = Ember.Mixin.create({ 6 | foo: 'FOO', 7 | bar: 'BAR' 8 | }); 9 | 10 | var MixinB = MixinA.without('bar'); 11 | 12 | var obj = {}; 13 | MixinB.apply(obj); 14 | 15 | equal(obj.foo, 'FOO', 'should defined foo'); 16 | equal(obj.bar, undefined, 'should not define bar'); 17 | 18 | }); 19 | -------------------------------------------------------------------------------- /packages/ember-metal/tests/props_helper.js: -------------------------------------------------------------------------------- 1 | /*global testBoth:true */ 2 | 3 | // used by unit tests to test both accessor mode and non-accessor mode 4 | testBoth = function(testname, callback) { 5 | test(testname+' using Ember.get()/Ember.set()', function() { 6 | callback(Ember.get, Ember.set); 7 | }); 8 | 9 | // test(testname+' using accessors', function() { 10 | // if (Ember.USES_ACCESSORS) callback(aget, aset); 11 | // else ok('SKIPPING ACCESSORS'); 12 | // }); 13 | }; 14 | -------------------------------------------------------------------------------- /packages/ember-runtime/README: -------------------------------------------------------------------------------- 1 | ember/runtime 2 | 3 | == About Ember Runtime 4 | 5 | The Ember Runtime is a library that adds property bindings and observers 6 | to JavaScript. You can use the runtime in web pages, applications, and 7 | everything in between to easily manage the state of your page with less code. 8 | 9 | This library is a part of the Ember JavaScript Application Framework, 10 | which is a full-stack MVC framework for building desktop-like applications on 11 | the web. 12 | -------------------------------------------------------------------------------- /benchmarks/setup.markdown: -------------------------------------------------------------------------------- 1 | Files: 2 | 3 | * `index.html`: bootstrap file for testing 4 | * `../lib/ember.js`: the Ember file that represents the "before" in the test 5 | * `../dist/ember.prod.js`: the Ember file that represents the "after" in the test 6 | * `../lib/jquery-1.9.0.js`: the latest version of jQuery 7 | * `benchmark.js`: the benchmark JS runner 8 | * `nano.jar`: the nanosecond timer 9 | * `runner.js`: the bootstrap for the runner 10 | * `_bench.js`: individual benchmark suites 11 | 12 | -------------------------------------------------------------------------------- /packages/ember-routing/lib/main.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime'); 2 | require('ember-views'); 3 | require('ember-handlebars'); 4 | require('ember-routing/vendor/route-recognizer'); 5 | require('ember-routing/vendor/router'); 6 | require('ember-routing/system'); 7 | require('ember-routing/helpers'); 8 | require('ember-routing/ext'); 9 | require('ember-routing/location'); 10 | 11 | /** 12 | Ember Routing 13 | 14 | @module ember 15 | @submodule ember-routing 16 | @requires ember-states 17 | @requires ember-views 18 | */ 19 | -------------------------------------------------------------------------------- /benchmarks/suites/views/destroy_view.js: -------------------------------------------------------------------------------- 1 | /*globals App:true Ember before after bench*/ 2 | 3 | var view; 4 | 5 | before(function() { 6 | Ember.run(function() { 7 | view = Ember.ContainerView.create({ 8 | childViews: [ 'one', 'two', 'three' ], 9 | 10 | one: Ember.View, 11 | two: Ember.View, 12 | three: Ember.View 13 | }).append(); 14 | }); 15 | }); 16 | 17 | bench("creating a new view", function() { 18 | Ember.run(function() { 19 | view.destroy(); 20 | }); 21 | }); 22 | 23 | -------------------------------------------------------------------------------- /generators/license.js: -------------------------------------------------------------------------------- 1 | // ========================================================================== 2 | // Project: Ember - JavaScript Application Framework 3 | // Copyright: ©2011-2013 Tilde Inc. and contributors 4 | // Portions ©2006-2011 Strobe Inc. 5 | // Portions ©2008-2011 Apple Inc. All rights reserved. 6 | // License: Licensed under MIT license 7 | // See https://raw.github.com/emberjs/ember.js/master/LICENSE 8 | // ========================================================================== 9 | -------------------------------------------------------------------------------- /packages/ember-metal/tests/run_loop/next_test.js: -------------------------------------------------------------------------------- 1 | module('system/run_loop/next_test'); 2 | 3 | test('should invoke immediately on next timeout', function() { 4 | 5 | var invoked = false; 6 | 7 | stop(); 8 | 9 | Ember.run(function() { 10 | Ember.run.next(function() { invoked = true; }); 11 | }); 12 | 13 | equal(invoked, false, 'should not have invoked yet'); 14 | 15 | 16 | setTimeout(function() { 17 | start(); 18 | equal(invoked, true, 'should have invoked later item'); 19 | }, 20); 20 | 21 | }); 22 | -------------------------------------------------------------------------------- /packages/ember-old-router/lib/main.js: -------------------------------------------------------------------------------- 1 | require('ember-states'); 2 | require('ember-old-router/promise_chain'); 3 | require('ember-old-router/application'); 4 | require('ember-old-router/route'); 5 | require('ember-old-router/router'); 6 | require('ember-old-router/helpers'); 7 | require('ember-old-router/handlebars_ext'); 8 | require('ember-old-router/controller_ext'); 9 | require('ember-old-router/view_ext'); 10 | 11 | /** 12 | Ember Old Router 13 | 14 | @module ember 15 | @submodule ember-old-router 16 | @requires ember-states 17 | */ 18 | -------------------------------------------------------------------------------- /packages/ember-metal/tests/mixin/reopen_test.js: -------------------------------------------------------------------------------- 1 | module('Ember.Mixin#reopen'); 2 | 3 | test('using reopen() to add more properties to a simple', function() { 4 | var MixinA = Ember.Mixin.create({ foo: 'FOO', baz: 'BAZ' }); 5 | MixinA.reopen({ bar: 'BAR', foo: 'FOO2' }); 6 | var obj = {}; 7 | MixinA.apply(obj); 8 | 9 | equal(Ember.get(obj, 'foo'), 'FOO2', 'mixin() should override'); 10 | equal(Ember.get(obj, 'baz'), 'BAZ', 'preserve MixinA props'); 11 | equal(Ember.get(obj, 'bar'), 'BAR', 'include MixinB props'); 12 | }); 13 | 14 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/suites/enumerable/firstObject.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/~tests/suites/enumerable'); 2 | 3 | var suite = Ember.EnumerableTests; 4 | 5 | suite.module('firstObject'); 6 | 7 | suite.test('returns first item in enumerable', function() { 8 | var obj = this.newObject(); 9 | equal(Ember.get(obj, 'firstObject'), this.toArray(obj)[0]); 10 | }); 11 | 12 | suite.test('returns undefined if enumerable is empty', function() { 13 | var obj = this.newObject([]); 14 | equal(Ember.get(obj, 'firstObject'), undefined); 15 | }); -------------------------------------------------------------------------------- /packages/ember-runtime/tests/suites/enumerable/mapProperty.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/~tests/suites/enumerable'); 2 | 3 | var suite = Ember.EnumerableTests; 4 | 5 | suite.module('mapProperty'); 6 | 7 | suite.test('get value of each property', function() { 8 | var obj = this.newObject([{a: 1},{a: 2}]); 9 | equal(obj.mapProperty('a').join(''), '12'); 10 | }); 11 | 12 | suite.test('should work also through getEach alias', function() { 13 | var obj = this.newObject([{a: 1},{a: 2}]); 14 | equal(obj.getEach('a').join(''), '12'); 15 | }); 16 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/system/array_proxy/suite_test.js: -------------------------------------------------------------------------------- 1 | Ember.MutableArrayTests.extend({ 2 | 3 | name: 'Ember.ArrayProxy', 4 | 5 | newObject: function(ary) { 6 | var ret = ary ? ary.slice() : this.newFixture(3); 7 | return Ember.ArrayProxy.create({ content: Ember.A(ret) }); 8 | }, 9 | 10 | mutate: function(obj) { 11 | obj.pushObject(Ember.get(obj, 'length')+1); 12 | }, 13 | 14 | toArray: function(obj) { 15 | return obj.toArray ? obj.toArray() : obj.slice(); 16 | } 17 | 18 | }).run(); 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /benchmarks/suites/views/template_view.js: -------------------------------------------------------------------------------- 1 | /*globals App:true Ember before after bench*/ 2 | 3 | var view; 4 | 5 | before(function() { 6 | var view; 7 | window.App = Ember.Namespace.create(); 8 | 9 | App.View = Ember.View.extend({ 10 | template: Ember.Handlebars.compile("{{view}}") 11 | }); 12 | 13 | App.View.create().destroy(); 14 | }); 15 | 16 | after(function() { 17 | view.destroy(); 18 | }); 19 | 20 | bench("creating a new view", function() { 21 | Ember.run(function() { 22 | view = App.View.create().append(); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /packages/ember-handlebars/lib/main.js: -------------------------------------------------------------------------------- 1 | require("ember-handlebars-compiler"); 2 | require("ember-runtime"); 3 | require("ember-views"); 4 | require("ember-handlebars/ext"); 5 | require("ember-handlebars/string"); 6 | require("ember-handlebars/helpers"); 7 | require("ember-handlebars/views"); 8 | require("ember-handlebars/controls"); 9 | require("ember-handlebars/loader"); 10 | 11 | /** 12 | Ember Handlebars 13 | 14 | @module ember 15 | @submodule ember-handlebars 16 | @requires ember-views 17 | */ 18 | 19 | Ember.runLoadHooks('Ember.Handlebars', Ember.Handlebars); 20 | -------------------------------------------------------------------------------- /packages/ember-runtime/lib/mixins.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/mixins/array'); 2 | require('ember-runtime/mixins/comparable'); 3 | require('ember-runtime/mixins/copyable'); 4 | require('ember-runtime/mixins/enumerable'); 5 | require('ember-runtime/mixins/freezable'); 6 | require('ember-runtime/mixins/mutable_array'); 7 | require('ember-runtime/mixins/mutable_enumerable'); 8 | require('ember-runtime/mixins/observable'); 9 | require('ember-runtime/mixins/target_action_support'); 10 | require('ember-runtime/mixins/evented'); 11 | require('ember-runtime/mixins/deferred'); 12 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant::Config.run do |config| 5 | config.vm.box = "precise64-ruby-1.9.3-p194" 6 | config.vm.box_url = "https://dl.dropbox.com/u/14292474/vagrantboxes/precise64-ruby-1.9.3-p194.box" 7 | 8 | # We need a javascript runtime to build ember.js with rake 9 | # and phantomjs to execute test suite. 10 | # 11 | config.vm.provision :chef_solo do |chef| 12 | chef.cookbooks_path = "cookbooks" 13 | chef.add_recipe "nodejs::install_from_source" 14 | chef.add_recipe "phantomjs" 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/suites/enumerable/lastObject.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/~tests/suites/enumerable'); 2 | 3 | var suite = Ember.EnumerableTests; 4 | 5 | suite.module('lastObject'); 6 | 7 | suite.test('returns last item in enumerable', function() { 8 | var obj = this.newObject(), 9 | ary = this.toArray(obj); 10 | equal(Ember.get(obj, 'lastObject'), ary[ary.length-1]); 11 | }); 12 | 13 | suite.test('returns undefined if enumerable is empty', function() { 14 | var obj = this.newObject([]); 15 | equal(Ember.get(obj, 'lastObject'), undefined); 16 | }); -------------------------------------------------------------------------------- /packages/ember-views/lib/system/jquery_ext.js: -------------------------------------------------------------------------------- 1 | /** 2 | @module ember 3 | @submodule ember-views 4 | */ 5 | 6 | // http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dndevents 7 | var dragEvents = Ember.String.w('dragstart drag dragenter dragleave dragover drop dragend'); 8 | 9 | // Copies the `dataTransfer` property from a browser event object onto the 10 | // jQuery event object for the specified events 11 | Ember.EnumerableUtils.forEach(dragEvents, function(eventName) { 12 | Ember.$.event.fixHooks[eventName] = { props: ['dataTransfer'] }; 13 | }); 14 | -------------------------------------------------------------------------------- /packages/ember-handlebars/lib/string.js: -------------------------------------------------------------------------------- 1 | /** 2 | @method htmlSafe 3 | @for Ember.String 4 | @static 5 | */ 6 | Ember.String.htmlSafe = function(str) { 7 | return new Handlebars.SafeString(str); 8 | }; 9 | 10 | var htmlSafe = Ember.String.htmlSafe; 11 | 12 | if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.String) { 13 | 14 | /** 15 | See {{#crossLink "Ember.String/htmlSafe"}}{{/crossLink}} 16 | 17 | @method htmlSafe 18 | @for String 19 | */ 20 | String.prototype.htmlSafe = function() { 21 | return htmlSafe(this); 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /packages/ember-views/lib/system/controller.js: -------------------------------------------------------------------------------- 1 | /** 2 | @module ember 3 | @submodule ember-views 4 | */ 5 | 6 | var get = Ember.get, set = Ember.set; 7 | 8 | // Original class declaration and documentation in runtime/lib/controllers/controller.js 9 | // NOTE: It may be possible with YUIDoc to combine docs in two locations 10 | 11 | /** 12 | Additional methods for the ControllerMixin 13 | 14 | @class ControllerMixin 15 | @namespace Ember 16 | */ 17 | Ember.ControllerMixin.reopen({ 18 | target: null, 19 | namespace: null, 20 | view: null, 21 | container: null 22 | }); 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.bpkg 2 | *.gem 3 | *.rbc 4 | .DS_Store 5 | .bpm 6 | .bundle 7 | .config 8 | .github-upload-token 9 | .yardoc 10 | InstalledFiles 11 | _site 12 | _yardoc 13 | assets 14 | assets/bpm_libs.js 15 | assets/bpm_styles.css 16 | bin/ 17 | coverage 18 | dist 19 | docs/build 20 | docs/node_modules 21 | lib/*/tests/all.js 22 | lib/*/tests/qunit* 23 | lib/bundler/man 24 | pkg 25 | rdoc 26 | spade-boot.js 27 | spec/reports 28 | test/tmp 29 | test/version_tmp 30 | test_*.html 31 | /tests/ember-tests.js 32 | tmp 33 | tmp*.gem 34 | tmp.bpm 35 | tmp.spade 36 | tests/source 37 | node_modules 38 | .vagrant 39 | -------------------------------------------------------------------------------- /packages/loader/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-microloader", 3 | "summary": "Ember Microloader", 4 | "description": "The external dependency loader for Ember", 5 | "homepage": "http://emberjs.com", 6 | "author": "Yehuda Katz", 7 | "version": "1.0.0-pre.2", 8 | 9 | "directories": { 10 | "lib": "lib" 11 | }, 12 | 13 | "dependencies": {}, 14 | 15 | "dependencies:development": {}, 16 | 17 | "bpm:build": { 18 | 19 | "bpm_libs.js": { 20 | "files": ["lib"], 21 | "modes": "*" 22 | }, 23 | 24 | "ember-views/bpm_tests.js": {} 25 | } 26 | } 27 | 28 | 29 | -------------------------------------------------------------------------------- /packages/ember-runtime/lib/system/deferred.js: -------------------------------------------------------------------------------- 1 | require("ember-runtime/mixins/deferred"); 2 | require("ember-runtime/system/object"); 3 | 4 | var DeferredMixin = Ember.DeferredMixin, // mixins/deferred 5 | EmberObject = Ember.Object, // system/object 6 | get = Ember.get; 7 | 8 | var Deferred = Ember.Object.extend(DeferredMixin); 9 | 10 | Deferred.reopenClass({ 11 | promise: function(callback, binding) { 12 | var deferred = Deferred.create(); 13 | callback.call(binding, deferred); 14 | return get(deferred, 'promise'); 15 | } 16 | }); 17 | 18 | Ember.Deferred = Deferred; 19 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/core/keys_test.js: -------------------------------------------------------------------------------- 1 | // ======================================================================== 2 | // Ember.keys Tests 3 | // ======================================================================== 4 | /*globals module test */ 5 | 6 | module("Fetch Keys "); 7 | 8 | test("should get a key array for a specified object ",function(){ 9 | var object1 = {}; 10 | 11 | object1.names = "Rahul"; 12 | object1.age = "23"; 13 | object1.place = "Mangalore"; 14 | 15 | var object2 = []; 16 | object2 = Ember.keys(object1); 17 | deepEqual(object2,['names','age','place']); 18 | }); 19 | 20 | 21 | -------------------------------------------------------------------------------- /packages/ember-metal/lib/main.js: -------------------------------------------------------------------------------- 1 | /** 2 | Ember Metal 3 | 4 | @module ember 5 | @submodule ember-metal 6 | */ 7 | 8 | require('ember-metal/core'); 9 | require('ember-metal/instrumentation'); 10 | require('ember-metal/map'); 11 | require('ember-metal/platform'); 12 | require('ember-metal/utils'); 13 | require('ember-metal/accessors'); 14 | require('ember-metal/properties'); 15 | require('ember-metal/computed'); 16 | require('ember-metal/watching'); 17 | require('ember-metal/events'); 18 | require('ember-metal/observer'); 19 | require('ember-metal/mixin'); 20 | require('ember-metal/binding'); 21 | require('ember-metal/run_loop'); 22 | -------------------------------------------------------------------------------- /packages/ember-runtime/lib/system.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/system/container'); 2 | require('ember-runtime/system/application'); 3 | require('ember-runtime/system/array_proxy'); 4 | require('ember-runtime/system/object_proxy'); 5 | require('ember-runtime/system/core_object'); 6 | require('ember-runtime/system/each_proxy'); 7 | 8 | require('ember-runtime/system/namespace'); 9 | require('ember-runtime/system/native_array'); 10 | require('ember-runtime/system/object'); 11 | require('ember-runtime/system/set'); 12 | require('ember-runtime/system/string'); 13 | require('ember-runtime/system/deferred'); 14 | 15 | require('ember-runtime/system/lazy_load'); 16 | -------------------------------------------------------------------------------- /packages/ember-metal/tests/accessors/isGlobalPath_test.js: -------------------------------------------------------------------------------- 1 | module('Ember.isGlobalPath'); 2 | 3 | test("global path's are recognized", function(){ 4 | ok( Ember.isGlobalPath('App.myProperty') ); 5 | ok( Ember.isGlobalPath('App.myProperty.subProperty') ); 6 | }); 7 | 8 | test("if there is a 'this' in the path, it's not a global path", function(){ 9 | ok( !Ember.isGlobalPath('this.myProperty') ); 10 | ok( !Ember.isGlobalPath('this') ); 11 | }); 12 | 13 | test("if the path starts with a lowercase character, it is not a global path", function(){ 14 | ok( !Ember.isGlobalPath('myObj') ); 15 | ok( !Ember.isGlobalPath('myObj.SecondProperty') ); 16 | }); -------------------------------------------------------------------------------- /packages/ember-runtime/lib/system/object.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/mixins/observable'); 2 | require('ember-runtime/system/core_object'); 3 | require('ember-runtime/system/set'); 4 | 5 | /** 6 | @module ember 7 | @submodule ember-runtime 8 | */ 9 | 10 | /** 11 | `Ember.Object` is the main base class for all Ember objects. It is a subclass 12 | of `Ember.CoreObject` with the `Ember.Observable` mixin applied. For details, 13 | see the documentation for each of these. 14 | 15 | @class Object 16 | @namespace Ember 17 | @extends Ember.CoreObject 18 | @uses Ember.Observable 19 | */ 20 | Ember.Object = Ember.CoreObject.extend(Ember.Observable); 21 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/system/set/copyable_suite_test.js: -------------------------------------------------------------------------------- 1 | // .......................................................... 2 | // COPYABLE TESTS 3 | // 4 | Ember.CopyableTests.extend({ 5 | name: 'Ember.Set Copyable', 6 | 7 | newObject: function() { 8 | var set = new Ember.Set(); 9 | set.addObject(Ember.generateGuid()); 10 | return set; 11 | }, 12 | 13 | isEqual: function(a,b) { 14 | if (!(a instanceof Ember.Set)) return false; 15 | if (!(b instanceof Ember.Set)) return false; 16 | return Ember.get(a, 'firstObject') === Ember.get(b, 'firstObject'); 17 | }, 18 | 19 | shouldBeFreezable: true 20 | }).run(); 21 | 22 | 23 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/system/set/enumerable_suite_test.js: -------------------------------------------------------------------------------- 1 | // .......................................................... 2 | // MUTABLE ENUMERABLE TESTS 3 | // 4 | Ember.MutableEnumerableTests.extend({ 5 | 6 | name: 'Ember.Set', 7 | 8 | newObject: function(ary) { 9 | ary = ary ? ary.slice() : this.newFixture(3); 10 | var ret = new Ember.Set(); 11 | ret.addObjects(ary); 12 | return ret; 13 | }, 14 | 15 | mutate: function(obj) { 16 | obj.addObject(Ember.get(obj, 'length')+1); 17 | }, 18 | 19 | toArray: function(obj) { 20 | return obj.toArray ? obj.toArray() : obj.slice(); // make a copy. 21 | } 22 | 23 | }).run(); 24 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/system/string/fmt_string.js: -------------------------------------------------------------------------------- 1 | module('Ember.String.fmt'); 2 | 3 | test("'Hello %@ %@'.fmt('John', 'Doe') => 'Hello John Doe'", function() { 4 | equal(Ember.String.fmt('Hello %@ %@', ['John', 'Doe']), 'Hello John Doe'); 5 | if (Ember.EXTEND_PROTOTYPES) { 6 | equal('Hello %@ %@'.fmt('John', 'Doe'), 'Hello John Doe'); 7 | } 8 | }); 9 | 10 | test("'Hello %@2 %@1'.fmt('John', 'Doe') => 'Hello Doe John'", function() { 11 | equal(Ember.String.fmt('Hello %@2 %@1', ['John', 'Doe']), 'Hello Doe John'); 12 | if (Ember.EXTEND_PROTOTYPES) { 13 | equal('Hello %@2 %@1'.fmt('John', 'Doe'), 'Hello Doe John'); 14 | } 15 | }); 16 | 17 | 18 | -------------------------------------------------------------------------------- /packages/ember-routing/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-routing", 3 | "summary": "Ember Routing", 4 | "description": "The Ember routing system", 5 | "homepage": "http://emberjs.com", 6 | "author": "Yehuda Katz", 7 | "version": "1.0.0-pre.4", 8 | 9 | "directories": { 10 | "lib": "lib" 11 | }, 12 | 13 | "dependencies": { 14 | "spade": "~> 1.0", 15 | "ember-views": "1.0.0-pre.4" 16 | }, 17 | 18 | "dependencies:development": { 19 | "spade-qunit": "~> 1.0.0" 20 | }, 21 | 22 | "bpm:build": { 23 | 24 | "bpm_libs.js": { 25 | "files": ["lib"], 26 | "modes": "*" 27 | } 28 | } 29 | } 30 | 31 | 32 | -------------------------------------------------------------------------------- /packages/ember-states/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-states", 3 | "summary": "Ember Storyboards", 4 | "description": "The Ember state management system", 5 | "homepage": "http://emberjs.com", 6 | "author": "Yehuda Katz", 7 | "version": "1.0.0-pre.4", 8 | 9 | "directories": { 10 | "lib": "lib" 11 | }, 12 | 13 | "dependencies": { 14 | "spade": "~> 1.0", 15 | "ember-runtime": "1.0.0-pre.4" 16 | }, 17 | 18 | "dependencies:development": { 19 | "spade-qunit": "~> 1.0.0" 20 | }, 21 | 22 | "bpm:build": { 23 | 24 | "bpm_libs.js": { 25 | "files": ["lib"], 26 | "modes": "*" 27 | } 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /packages/ember-views/tests/views/view/destroy_test.js: -------------------------------------------------------------------------------- 1 | var set = Ember.set, get = Ember.get; 2 | 3 | module("Ember.View#destroy"); 4 | 5 | test("should teardown viewName on parentView when childView is destroyed", function() { 6 | var viewName = "someChildView", 7 | parentView = Ember.View.create(), 8 | childView = parentView.createChildView(Ember.View, {viewName: viewName}); 9 | 10 | equal(get(parentView, viewName), childView, "Precond - child view was registered on parent"); 11 | 12 | Ember.run(function(){ 13 | childView.destroy(); 14 | }); 15 | 16 | equal(get(parentView, viewName), null, "viewName reference was removed on parent"); 17 | }); 18 | 19 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/controllers/array_controller_test.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/~tests/suites/mutable_array'); 2 | 3 | module("ember-runtime/controllers/array_controller_test"); 4 | 5 | Ember.MutableArrayTests.extend({ 6 | 7 | name: 'Ember.ArrayController', 8 | 9 | newObject: function(ary) { 10 | var ret = ary ? ary.slice() : this.newFixture(3); 11 | return Ember.ArrayController.create({ 12 | content: Ember.A(ret) 13 | }); 14 | }, 15 | 16 | mutate: function(obj) { 17 | obj.pushObject(Ember.get(obj, 'length')+1); 18 | }, 19 | 20 | toArray: function(obj) { 21 | return obj.toArray ? obj.toArray() : obj.slice(); 22 | } 23 | }).run(); 24 | -------------------------------------------------------------------------------- /packages/ember-metal/tests/run_loop/sync_test.js: -------------------------------------------------------------------------------- 1 | module('system/run_loop/schedule_test'); 2 | 3 | test('sync() will immediately flush the sync queue only', function() { 4 | var cnt = 0; 5 | 6 | Ember.run(function() { 7 | 8 | function cntup() { cnt++; } 9 | 10 | function syncfunc() { 11 | if (++cnt<5) Ember.run.schedule('sync', syncfunc); 12 | Ember.run.schedule('actions', cntup); 13 | } 14 | 15 | syncfunc(); 16 | 17 | equal(cnt, 1, 'should not run action yet') ; 18 | Ember.run.sync(); 19 | 20 | equal(cnt, 5, 'should have run sync queue continuously'); 21 | }); 22 | 23 | equal(cnt, 10, 'should flush actions now too'); 24 | 25 | }); 26 | -------------------------------------------------------------------------------- /packages/rsvp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rsvp", 3 | "summary": "Promises-A implementation", 4 | "description": "A lightweight library that provides tools for organizing asynchronous code", 5 | "homepage": "https://github.com/tildeio/rsvp.js", 6 | "authors": ["Yehuda Katz", "Tom Dale"], 7 | "version": "1.0.0", 8 | 9 | "dependencies": { 10 | "spade": "~> 1.0.0" 11 | }, 12 | 13 | "directories": { 14 | "lib": "lib" 15 | }, 16 | 17 | "bpm:build": { 18 | "bpm_libs.js": { 19 | "files": ["lib"], 20 | "modes": "*" 21 | }, 22 | 23 | "handlebars/bpm_tests.js": { 24 | "files": ["tests"], 25 | "modes": ["debug"] 26 | } 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /docs/yuidoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "The Ember API", 3 | "description": "The Ember API: a framework for building ambitious web applications", 4 | "version": "1.0 pre", 5 | "url": "http://emberjs.com/", 6 | "options": { 7 | "paths": [ 8 | "../packages/ember/lib", 9 | "../packages/ember-debug/lib", 10 | "../packages/ember-metal/lib", 11 | "../packages/ember-runtime/lib", 12 | "../packages/ember-states/lib", 13 | "../packages/ember-views/lib", 14 | "../packages/ember-handlebars/lib", 15 | "../packages/ember-routing/lib", 16 | "../packages/ember-application/lib" 17 | ], 18 | "exclude": "vendor", 19 | "outdir": "./build" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/suites/enumerable/contains.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/~tests/suites/enumerable'); 2 | 3 | var suite = Ember.EnumerableTests; 4 | 5 | suite.module('contains'); 6 | 7 | suite.test('contains returns true if items is in enumerable', function() { 8 | var data = this.newFixture(3); 9 | var obj = this.newObject(data); 10 | equal(obj.contains(data[1]), true, 'should return true if contained'); 11 | }); 12 | 13 | suite.test('contains returns false if item is not in enumerable', function() { 14 | var data = this.newFixture(1); 15 | var obj = this.newObject(this.newFixture(3)); 16 | equal(obj.contains(data[0]), false, 'should return false if not contained'); 17 | }); 18 | 19 | -------------------------------------------------------------------------------- /packages/ember-old-router/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-routing", 3 | "summary": "Ember Routing", 4 | "description": "The Ember routing system", 5 | "homepage": "http://emberjs.com", 6 | "author": "Yehuda Katz", 7 | "version": "1.0.0-pre.4", 8 | 9 | "directories": { 10 | "lib": "lib" 11 | }, 12 | 13 | "dependencies": { 14 | "spade": "~> 1.0", 15 | "ember-views": "1.0.0-pre.4", 16 | "ember-states": "1.0.0-pre.4" 17 | }, 18 | 19 | "dependencies:development": { 20 | "spade-qunit": "~> 1.0.0" 21 | }, 22 | 23 | "bpm:build": { 24 | 25 | "bpm_libs.js": { 26 | "files": ["lib"], 27 | "modes": "*" 28 | } 29 | } 30 | } 31 | 32 | 33 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/suites/mutable_array.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/~tests/suites/array'); 2 | 3 | Ember.MutableArrayTests = Ember.ArrayTests.extend(); 4 | 5 | require('ember-runtime/~tests/suites/mutable_array/insertAt'); 6 | require('ember-runtime/~tests/suites/mutable_array/popObject'); 7 | require('ember-runtime/~tests/suites/mutable_array/pushObject'); 8 | require('ember-runtime/~tests/suites/mutable_array/removeAt'); 9 | require('ember-runtime/~tests/suites/mutable_array/replace'); 10 | require('ember-runtime/~tests/suites/mutable_array/shiftObject'); 11 | require('ember-runtime/~tests/suites/mutable_array/unshiftObject'); 12 | require('ember-runtime/~tests/suites/mutable_array/reverseObjects'); 13 | -------------------------------------------------------------------------------- /packages/ember-metal/tests/run_loop/run_test.js: -------------------------------------------------------------------------------- 1 | module('system/run_loop/run_test'); 2 | 3 | test('Ember.run invokes passed function, returning value', function() { 4 | var obj = { 5 | foo: function() { return [this.bar, 'FOO']; }, 6 | bar: 'BAR', 7 | checkArgs: function(arg1, arg2) { return [ arg1, this.bar, arg2 ]; } 8 | }; 9 | 10 | equal(Ember.run(function() { return 'FOO'; }), 'FOO', 'pass function only'); 11 | deepEqual(Ember.run(obj, obj.foo), ['BAR', 'FOO'], 'pass obj and obj.method'); 12 | deepEqual(Ember.run(obj, 'foo'), ['BAR', 'FOO'], 'pass obj and "method"'); 13 | deepEqual(Ember.run(obj, obj.checkArgs, 'hello', 'world'), ['hello', 'BAR', 'world'], 'pass obj, obj.method, and extra arguments'); 14 | }); 15 | -------------------------------------------------------------------------------- /packages/ember-old-router/tests/view_test.js: -------------------------------------------------------------------------------- 1 | var set = Ember.set, get = Ember.get; 2 | 3 | module("Ember.View - Old Router Functionality", { 4 | setup: function() { 5 | Ember.TEMPLATES = {}; 6 | } 7 | }); 8 | 9 | test("should load named templates from View.templates", function() { 10 | var view; 11 | 12 | 13 | view = Ember.View.create({ 14 | templates: { 15 | testTemplate: function() { 16 | return "

template was called

"; 17 | } 18 | }, 19 | templateName: 'testTemplate' 20 | }); 21 | 22 | Ember.run(function(){ 23 | view.createElement(); 24 | }); 25 | 26 | ok(view.$('#old-router-template-was-called').length, "the named template was called"); 27 | }); 28 | -------------------------------------------------------------------------------- /packages/ember-metal/tests/run_loop/onerror_test.js: -------------------------------------------------------------------------------- 1 | module('system/run_loop/onerror_test'); 2 | 3 | test('With Ember.onerror undefined, errors in Ember.run are thrown', function () { 4 | var thrown = new Error('Boom!'), 5 | caught; 6 | 7 | try { 8 | Ember.run(function() { throw thrown; }); 9 | } catch (error) { 10 | caught = error; 11 | } 12 | 13 | deepEqual(caught, thrown); 14 | }); 15 | 16 | test('With Ember.onerror set, errors in Ember.run are caught', function () { 17 | var thrown = new Error('Boom!'), 18 | caught; 19 | 20 | Ember.onerror = function(error) { caught = error; }; 21 | 22 | Ember.run(function() { throw thrown; }); 23 | 24 | deepEqual(caught, thrown); 25 | 26 | Ember.onerror = undefined; 27 | }); 28 | -------------------------------------------------------------------------------- /ember.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember", 3 | "bpm": "1.0.0", 4 | "dependencies": { 5 | "ember": "1.0.0-pre.4" 6 | }, 7 | "dependencies:development": { 8 | "spade-qunit": "~> 1.0.0" 9 | }, 10 | "bpm:build": { 11 | "bpm_libs.js": { 12 | "minifier": "uglify-js" 13 | }, 14 | "jquery.js": { 15 | "minifier": "uglify-js", 16 | "include": [ 17 | "jquery" 18 | ] 19 | }, 20 | "ember.js": { 21 | "minifier": "uglify-js", 22 | "include": [ 23 | "spade", 24 | "ember-metal", 25 | "ember-runtime", 26 | "handlebars", 27 | "ember-views", 28 | "ember-states", 29 | "ember-routing", 30 | "ember-handlebars" 31 | ] 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/ember-metal/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-metal", 3 | "description": "JavaScript on Steroids", 4 | "summary": "JavaScript on Steroids", 5 | "homepage": "http://github.com/emberjs/ember.js", 6 | "author": "Charles Jolley", 7 | "version": "1.0.0-pre.4", 8 | 9 | "dependencies": { 10 | "spade": "~> 1.0.0" 11 | }, 12 | 13 | "directories": { 14 | "lib": "lib" 15 | }, 16 | 17 | "dependencies:development": { 18 | "spade-qunit": "~> 1.0.0" 19 | }, 20 | 21 | "bpm:build": { 22 | 23 | "bpm_libs.js": { 24 | "files": ["lib"], 25 | "modes": "*" 26 | }, 27 | 28 | "ember-metal/bpm_tests.js": { 29 | "files": ["tests"], 30 | "modes": ["debug"] 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /packages/container/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "container", 3 | "summary": "A lightweight dependency injection container", 4 | "description": "A lightweight library that provides a pluggable dependency injection container designed for use in Ember.js", 5 | "homepage": "https://github.com/emberjs/ember.js", 6 | "authors": ["Yehuda Katz", "Tom Dale"], 7 | "version": "1.0.0-pre.2", 8 | 9 | "dependencies": { 10 | "spade": "~> 1.0.0" 11 | }, 12 | 13 | "directories": { 14 | "lib": "lib" 15 | }, 16 | 17 | "bpm:build": { 18 | "bpm_libs.js": { 19 | "files": ["lib"], 20 | "modes": "*" 21 | }, 22 | 23 | "handlebars/bpm_tests.js": { 24 | "files": ["tests"], 25 | "modes": ["debug"] 26 | } 27 | } 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/suites/array/indexOf.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/~tests/suites/array'); 2 | 3 | var suite = Ember.ArrayTests; 4 | 5 | suite.module('indexOf'); 6 | 7 | suite.test("should return index of object", function() { 8 | var expected = this.newFixture(3), 9 | obj = this.newObject(expected), 10 | len = 3, 11 | idx; 12 | 13 | for(idx=0;idx 1.0.0", 11 | "ember-runtime": "1.0.0-pre.4", 12 | "ember-views": "1.0.0-pre.4", 13 | "ember-states": "1.0.0-pre.4", 14 | "ember-routing": "1.0.0-pre.4", 15 | "ember-handlebars": "1.0.0-pre.4" 16 | }, 17 | 18 | "directories": { 19 | "lib": "lib" 20 | }, 21 | 22 | "bpm:build": { 23 | "bpm_libs.js": { 24 | "files": ["lib"], 25 | "modes": "*" 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/metamorph/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "metamorph", 3 | "summary": "A library for performing DOM updates on arbitrary text", 4 | "description": "A library that can insert and update arbitrary text in the DOM, even inside tables and other restricted elements", 5 | "homepage": "https://github.com/tomhuda/metamorph.js", 6 | "authors": ["Yehuda Katz", "Tom Dale"], 7 | "version": "1.0.0", 8 | 9 | "dependencies": { 10 | "spade": "~> 1.0.0" 11 | }, 12 | 13 | "directories": { 14 | "lib": "lib" 15 | }, 16 | 17 | "bpm:build": { 18 | "bpm_libs.js": { 19 | "files": ["lib"], 20 | "modes": "*" 21 | }, 22 | 23 | "handlebars/bpm_tests.js": { 24 | "files": ["tests"], 25 | "modes": ["debug"] 26 | } 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/core/isNone_test.js: -------------------------------------------------------------------------------- 1 | module("Ember.isNone"); 2 | 3 | test("Ember.isNone", function() { 4 | var string = "string", fn = function() {}; 5 | 6 | equal(true, Ember.isNone(null), "for null"); 7 | equal(true, Ember.isNone(undefined), "for undefined"); 8 | equal(false, Ember.isNone(""), "for an empty String"); 9 | equal(false, Ember.isNone(true), "for true"); 10 | equal(false, Ember.isNone(false), "for false"); 11 | equal(false, Ember.isNone(string), "for a String"); 12 | equal(false, Ember.isNone(fn), "for a Function"); 13 | equal(false, Ember.isNone(0), "for 0"); 14 | equal(false, Ember.isNone([]), "for an empty Array"); 15 | equal(false, Ember.isNone({}), "for an empty Object"); 16 | }); 17 | -------------------------------------------------------------------------------- /packages/ember-old-router/lib/view_ext.js: -------------------------------------------------------------------------------- 1 | /** 2 | @module ember 3 | @submodule ember-old-router 4 | */ 5 | 6 | var get = Ember.get, set = Ember.set, fmt = Ember.String.fmt; 7 | 8 | /** 9 | Override functionality for Ember.View use in old-router 10 | 11 | @class View 12 | @namespace Ember 13 | */ 14 | Ember.View.reopen({ 15 | templateForName: function(name, type) { 16 | if (!name) { return; } 17 | 18 | Ember.assert("templateNames are not allowed to contain periods: "+name, name.indexOf('.') === -1); 19 | 20 | var templates = get(this, 'templates'), 21 | template = get(templates, name); 22 | 23 | if (!template) { 24 | throw new Ember.Error(fmt('%@ - Unable to find %@ "%@".', [this, type, name])); 25 | } 26 | 27 | return template; 28 | } 29 | }); 30 | -------------------------------------------------------------------------------- /packages/ember-handlebars/lib/helpers/unbound.js: -------------------------------------------------------------------------------- 1 | /*globals Handlebars */ 2 | 3 | require('ember-handlebars/ext'); 4 | 5 | /** 6 | @module ember 7 | @submodule ember-handlebars 8 | */ 9 | 10 | var handlebarsGet = Ember.Handlebars.get; 11 | 12 | /** 13 | `unbound` allows you to output a property without binding. *Important:* The 14 | output will not be updated if the property changes. Use with caution. 15 | 16 | ```handlebars 17 |
{{unbound somePropertyThatDoesntChange}}
18 | ``` 19 | 20 | @method unbound 21 | @for Ember.Handlebars.helpers 22 | @param {String} property 23 | @return {String} HTML string 24 | */ 25 | Ember.Handlebars.registerHelper('unbound', function(property, fn) { 26 | var context = (fn.contexts && fn.contexts[0]) || this; 27 | return handlebarsGet(context, property, fn); 28 | }); 29 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/system/object/reopenClass_test.js: -------------------------------------------------------------------------------- 1 | module('system/object/reopenClass'); 2 | 3 | test('adds new properties to subclass', function() { 4 | 5 | var Subclass = Ember.Object.extend(); 6 | Subclass.reopenClass({ 7 | foo: function() { return 'FOO'; }, 8 | bar: 'BAR' 9 | }); 10 | 11 | equal(Subclass.foo(), 'FOO', 'Adds method'); 12 | equal(Ember.get(Subclass, 'bar'), 'BAR', 'Adds property'); 13 | }); 14 | 15 | test('class properties inherited by subclasses', function() { 16 | 17 | var Subclass = Ember.Object.extend(); 18 | Subclass.reopenClass({ 19 | foo: function() { return 'FOO'; }, 20 | bar: 'BAR' 21 | }); 22 | 23 | var SubSub = Subclass.extend(); 24 | 25 | equal(SubSub.foo(), 'FOO', 'Adds method'); 26 | equal(Ember.get(SubSub, 'bar'), 'BAR', 'Adds property'); 27 | }); 28 | 29 | -------------------------------------------------------------------------------- /packages/ember-views/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-views", 3 | "summary": "Ember Views", 4 | "description": "The Ember view system", 5 | "homepage": "http://emberjs.com", 6 | "author": "Yehuda Katz", 7 | "version": "1.0.0-pre.4", 8 | 9 | "directories": { 10 | "lib": "lib" 11 | }, 12 | 13 | "dependencies": { 14 | "spade": "~> 1.0", 15 | "jquery": "~> 1.7", 16 | "ember-runtime": "1.0.0-pre.4", 17 | "container": "1.0.0-pre.2" 18 | }, 19 | 20 | "dependencies:development": { 21 | "spade-qunit": "~> 1.0.0" 22 | }, 23 | 24 | "bpm:build": { 25 | 26 | "bpm_libs.js": { 27 | "files": ["lib"], 28 | "modes": "*" 29 | }, 30 | 31 | "ember-views/bpm_tests.js": { 32 | "files": ["tests"], 33 | "modes": ["debug"] 34 | } 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /packages/loader/lib/main.js: -------------------------------------------------------------------------------- 1 | var define, requireModule; 2 | 3 | (function() { 4 | var registry = {}, seen = {}; 5 | 6 | define = function(name, deps, callback) { 7 | registry[name] = { deps: deps, callback: callback }; 8 | }; 9 | 10 | requireModule = function(name) { 11 | if (seen[name]) { return seen[name]; } 12 | seen[name] = {}; 13 | 14 | var mod = registry[name], 15 | deps = mod.deps, 16 | callback = mod.callback, 17 | reified = [], 18 | exports; 19 | 20 | for (var i=0, l=deps.length; i 1.0", 16 | "ember-metal": "1.0.0-pre.4", 17 | "container": "1.0.0-pre.2" 18 | }, 19 | 20 | "dependencies:development": { 21 | "spade-qunit": "~> 1.0.0" 22 | }, 23 | 24 | "bpm:build": { 25 | 26 | "bpm_libs.js": { 27 | "files": ["lib"], 28 | "modes": "*" 29 | }, 30 | 31 | "ember-runtime/bpm_tests.js": { 32 | "files": ["tests"], 33 | "modes": ["debug"] 34 | } 35 | } 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /packages/ember-views/lib/views/states.js: -------------------------------------------------------------------------------- 1 | require("ember-views/views/states/default"); 2 | require("ember-views/views/states/pre_render"); 3 | require("ember-views/views/states/in_buffer"); 4 | require("ember-views/views/states/in_dom"); 5 | require("ember-views/views/states/destroyed"); 6 | 7 | Ember.View.cloneStates = function(from) { 8 | var into = {}; 9 | 10 | into._default = {}; 11 | into.preRender = Ember.create(into._default); 12 | into.destroyed = Ember.create(into._default); 13 | into.inBuffer = Ember.create(into._default); 14 | into.hasElement = Ember.create(into._default); 15 | into.inDOM = Ember.create(into.hasElement); 16 | 17 | var viewState; 18 | 19 | for (var stateName in from) { 20 | if (!from.hasOwnProperty(stateName)) { continue; } 21 | Ember.merge(into[stateName], from[stateName]); 22 | } 23 | 24 | return into; 25 | }; 26 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/ext/function_test.js: -------------------------------------------------------------------------------- 1 | /*globals testBoth */ 2 | 3 | require('ember-runtime/~tests/props_helper'); 4 | 5 | module('Function.prototype.observes() helper'); 6 | 7 | testBoth('global observer helper takes multiple params', function(get, set) { 8 | 9 | if (Ember.EXTEND_PROTOTYPES === false) { 10 | ok('Function.prototype helper disabled'); 11 | return ; 12 | } 13 | 14 | var MyMixin = Ember.Mixin.create({ 15 | 16 | count: 0, 17 | 18 | foo: function() { 19 | set(this, 'count', get(this, 'count')+1); 20 | }.observes('bar', 'baz') 21 | 22 | }); 23 | 24 | var obj = Ember.mixin({}, MyMixin); 25 | equal(get(obj, 'count'), 0, 'should not invoke observer immediately'); 26 | 27 | set(obj, 'bar', "BAZ"); 28 | set(obj, 'baz', "BAZ"); 29 | equal(get(obj, 'count'), 2, 'should invoke observer after change'); 30 | }); 31 | 32 | -------------------------------------------------------------------------------- /packages/ember-runtime/lib/controllers/object_controller.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/system/object_proxy'); 2 | require('ember-runtime/controllers/controller'); 3 | 4 | /** 5 | @module ember 6 | @submodule ember-runtime 7 | */ 8 | 9 | /** 10 | `Ember.ObjectController` is part of Ember's Controller layer. A single shared 11 | instance of each `Ember.ObjectController` subclass in your application's 12 | namespace will be created at application initialization and be stored on your 13 | application's `Ember.Router` instance. 14 | 15 | `Ember.ObjectController` derives its functionality from its superclass 16 | `Ember.ObjectProxy` and the `Ember.ControllerMixin` mixin. 17 | 18 | @class ObjectController 19 | @namespace Ember 20 | @extends Ember.ObjectProxy 21 | @uses Ember.ControllerMixin 22 | **/ 23 | Ember.ObjectController = Ember.ObjectProxy.extend(Ember.ControllerMixin); 24 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/core/isArray_test.js: -------------------------------------------------------------------------------- 1 | module("Ember Type Checking"); 2 | 3 | var global = this; 4 | 5 | test("Ember.isArray" ,function(){ 6 | var numarray = [1,2,3], 7 | number = 23, 8 | strarray = ["Hello", "Hi"], 9 | string = "Hello", 10 | object = {}, 11 | length = {length: 12}, 12 | fn = function() {}; 13 | 14 | equal( Ember.isArray(numarray), true, "[1,2,3]" ); 15 | equal( Ember.isArray(number), false, "23" ); 16 | equal( Ember.isArray(strarray), true, '["Hello", "Hi"]' ); 17 | equal( Ember.isArray(string), false, '"Hello"' ); 18 | equal( Ember.isArray(object), false, "{}" ); 19 | equal( Ember.isArray(length), true, "{length: 12}" ); 20 | equal( Ember.isArray(global), false, "global" ); 21 | equal( Ember.isArray(fn), false, "function() {}" ); 22 | }); 23 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/core/type_test.js: -------------------------------------------------------------------------------- 1 | module("Ember Type Checking"); 2 | 3 | test("Ember.typeOf", function() { 4 | var a = null, 5 | arr = [1,2,3], 6 | obj = {}, 7 | object = Ember.Object.create({ method: function() {} }); 8 | 9 | equal(Ember.typeOf(undefined), 'undefined', "item of type undefined"); 10 | equal(Ember.typeOf(a), 'null', "item of type null"); 11 | equal(Ember.typeOf(arr), 'array', "item of type array"); 12 | equal(Ember.typeOf(obj), 'object', "item of type object"); 13 | equal(Ember.typeOf(object), 'instance', "item of type instance"); 14 | equal(Ember.typeOf(object.method), 'function', "item of type function") ; 15 | equal(Ember.typeOf(Ember.Object), 'class', "item of type class"); 16 | equal(Ember.typeOf(new Error()), 'error', "item of type error"); 17 | }); 18 | 19 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/mixins/copyable_test.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/~tests/suites/copyable'); 2 | 3 | // NOTE: See debug/suites/copyable.js for mosts tests 4 | 5 | var CopyableObject = Ember.Object.extend(Ember.Copyable, { 6 | 7 | id: null, 8 | 9 | init: function() { 10 | this._super(); 11 | Ember.set(this, 'id', Ember.generateGuid()); 12 | }, 13 | 14 | copy: function() { 15 | var ret = new CopyableObject(); 16 | Ember.set(ret, 'id', Ember.get(this, 'id')); 17 | return ret; 18 | } 19 | }); 20 | 21 | Ember.CopyableTests.extend({ 22 | 23 | name: 'Ember.Copyable Basic Test', 24 | 25 | newObject: function() { 26 | return new CopyableObject(); 27 | }, 28 | 29 | isEqual: function(a, b) { 30 | if (!(a instanceof CopyableObject) || !(b instanceof CopyableObject)) return false; 31 | return Ember.get(a, 'id') === Ember.get(b,'id'); 32 | } 33 | }).run(); 34 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/system/string/w_test.js: -------------------------------------------------------------------------------- 1 | module('Ember.String.w'); 2 | 3 | test("'one two three'.w() => ['one','two','three']", function() { 4 | deepEqual(Ember.String.w('one two three'), ['one','two','three']); 5 | if (Ember.EXTEND_PROTOTYPES) { 6 | deepEqual('one two three'.w(), ['one','two','three']); 7 | } 8 | }); 9 | 10 | test("'one two three'.w() with extra spaces between words => ['one','two','three']", function() { 11 | deepEqual(Ember.String.w('one two three'), ['one','two','three']); 12 | if (Ember.EXTEND_PROTOTYPES) { 13 | deepEqual('one two three'.w(), ['one','two','three']); 14 | } 15 | }); 16 | 17 | test("'one two three'.w() with tabs", function() { 18 | deepEqual(Ember.String.w('one\ttwo three'), ['one','two','three']); 19 | if (Ember.EXTEND_PROTOTYPES) { 20 | deepEqual('one\ttwo three'.w(), ['one','two','three']); 21 | } 22 | }); 23 | 24 | 25 | -------------------------------------------------------------------------------- /packages/ember-handlebars-compiler/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-handlebars-compiler", 3 | "summary": "Ember Handlebars Compiler", 4 | "description": "A programmatic compiler for Handlebars with the few syntax extensions supported by Ember with minimal dependencies", 5 | "homepage": "http://emberjs.com", 6 | "author": "Yehuda Katz", 7 | "version": "1.0.0-pre.4", 8 | "dependencies": { 9 | "spade": "~> 1.0.0", 10 | "handlebars": "~> 1.0.0.beta.6" 11 | }, 12 | 13 | "directories": { 14 | "lib": "lib" 15 | }, 16 | 17 | "dependencies:development": { 18 | "spade-qunit": "~> 1.0.0" 19 | }, 20 | 21 | "bpm:build": { 22 | 23 | "bpm_libs.js": { 24 | "files": ["lib"], 25 | "modes": "*" 26 | }, 27 | 28 | "ember-handlebars/bpm_tests.js": { 29 | "files": ["tests"], 30 | "modes": ["debug"] 31 | } 32 | } 33 | 34 | } 35 | 36 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/suites/enumerable/without.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/~tests/suites/enumerable'); 2 | 3 | var suite = Ember.EnumerableTests; 4 | 5 | suite.module('without'); 6 | 7 | suite.test('should return new instance with item removed', function() { 8 | var before, after, obj, ret; 9 | 10 | before = this.newFixture(3); 11 | after = [before[0], before[2]]; 12 | obj = this.newObject(before); 13 | 14 | ret = obj.without(before[1]); 15 | deepEqual(this.toArray(ret), after, 'should have removed item'); 16 | deepEqual(this.toArray(obj), before, 'should not have changed original'); 17 | }); 18 | 19 | suite.test('should return same instance if object not found', function() { 20 | var item, obj, ret; 21 | 22 | item = this.newFixture(1)[0]; 23 | obj = this.newObject(this.newFixture(3)); 24 | 25 | ret = obj.without(item); 26 | equal(ret, obj, 'should be same instance'); 27 | }); 28 | 29 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/mixins/comparable_test.js: -------------------------------------------------------------------------------- 1 | /*globals module test ok isObj equals expects */ 2 | 3 | var Rectangle = Ember.Object.extend(Ember.Comparable, { 4 | length: 0, 5 | width: 0, 6 | 7 | area: function() { 8 | return Ember.get(this,'length') * Ember.get(this, 'width'); 9 | }, 10 | 11 | compare: function(a, b) { 12 | return Ember.compare(a.area(), b.area()); 13 | } 14 | 15 | }); 16 | 17 | var r1, r2; 18 | 19 | module("Comparable", { 20 | 21 | setup: function() { 22 | r1 = Rectangle.create({length: 6, width: 12}); 23 | r2 = Rectangle.create({length: 6, width: 13}); 24 | }, 25 | 26 | teardown: function() { 27 | } 28 | 29 | }); 30 | 31 | test("should be comparable and return the correct result", function() { 32 | equal(Ember.Comparable.detect(r1), true); 33 | equal(Ember.compare(r1, r1), 0); 34 | equal(Ember.compare(r1, r2), -1); 35 | equal(Ember.compare(r2, r1), 1); 36 | }); 37 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/suites/enumerable/reduce.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/~tests/suites/enumerable'); 2 | 3 | var suite = Ember.EnumerableTests; 4 | 5 | suite.module('reduce'); 6 | 7 | suite.test('collectes a summary value from an enumeration', function() { 8 | var obj = this.newObject([1, 2, 3]); 9 | var res = obj.reduce(function(previousValue, item, index, enumerable) { return previousValue + item; }, 0); 10 | equal(res, 6); 11 | }); 12 | 13 | suite.test('passes index of item to callback', function() { 14 | var obj = this.newObject([1, 2, 3]); 15 | var res = obj.reduce(function(previousValue, item, index, enumerable) { return previousValue + index; }, 0); 16 | equal(res, 3); 17 | }); 18 | 19 | suite.test('passes enumerable object to callback', function() { 20 | var obj = this.newObject([1, 2, 3]); 21 | var res = obj.reduce(function(previousValue, item, index, enumerable) { return enumerable; }, 0); 22 | equal(res, obj); 23 | }); 24 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/system/native_array/copyable_suite_test.js: -------------------------------------------------------------------------------- 1 | // .......................................................... 2 | // COPYABLE TESTS 3 | // 4 | Ember.CopyableTests.extend({ 5 | name: 'NativeArray Copyable', 6 | 7 | newObject: function() { 8 | return Ember.A([Ember.generateGuid()]); 9 | }, 10 | 11 | isEqual: function(a,b) { 12 | if (!(a instanceof Array)) return false; 13 | if (!(b instanceof Array)) return false; 14 | if (a.length !== b.length) return false; 15 | return a[0]===b[0]; 16 | }, 17 | 18 | shouldBeFreezable: false 19 | }).run(); 20 | 21 | module("NativeArray Copyable"); 22 | 23 | test("deep copy is respected", function() { 24 | var array = Ember.A([ { id: 1 }, { id: 2 }, { id: 3 } ]); 25 | 26 | var copiedArray = array.copy(true); 27 | 28 | deepEqual(copiedArray, array, "copied array is equivalent"); 29 | ok(copiedArray[0] !== array[0], "objects inside should be unique"); 30 | }); 31 | -------------------------------------------------------------------------------- /packages/ember-metal/tests/utils/can_invoke_test.js: -------------------------------------------------------------------------------- 1 | var obj; 2 | 3 | module("Ember.canInvoke", { 4 | setup: function() { 5 | obj = { 6 | foobar: "foobar", 7 | aMethodThatExists: function() {} 8 | }; 9 | }, 10 | 11 | teardown: function() { 12 | obj = undefined; 13 | } 14 | }); 15 | 16 | test("should return false if the object doesn't exist", function() { 17 | equal(Ember.canInvoke(undefined, 'aMethodThatDoesNotExist'), false); 18 | }); 19 | 20 | test("should return true if the method exists on the object", function() { 21 | equal(Ember.canInvoke(obj, 'aMethodThatExists'), true); 22 | }); 23 | 24 | test("should return false if the method doesn't exist on the object", function() { 25 | equal(Ember.canInvoke(obj, 'aMethodThatDoesNotExist'), false); 26 | }); 27 | 28 | test("should return false if the property exists on the object but is a non-function", function() { 29 | equal(Ember.canInvoke(obj, 'foobar'), false); 30 | }); 31 | -------------------------------------------------------------------------------- /packages/ember-runtime/lib/system/lazy_load.js: -------------------------------------------------------------------------------- 1 | /** 2 | @module ember 3 | @submodule ember-runtime 4 | */ 5 | 6 | var loadHooks = {}; 7 | var loaded = {}; 8 | 9 | /** 10 | @method onLoad 11 | @for Ember 12 | @param name {String} name of hook 13 | @param callback {Function} callback to be called 14 | */ 15 | Ember.onLoad = function(name, callback) { 16 | var object; 17 | 18 | loadHooks[name] = loadHooks[name] || Ember.A(); 19 | loadHooks[name].pushObject(callback); 20 | 21 | if (object = loaded[name]) { 22 | callback(object); 23 | } 24 | }; 25 | 26 | /** 27 | @method runLoadHooks 28 | @for Ember 29 | @param name {String} name of hook 30 | @param object {Object} object to pass to callbacks 31 | */ 32 | Ember.runLoadHooks = function(name, object) { 33 | var hooks; 34 | 35 | loaded[name] = object; 36 | 37 | if (hooks = loadHooks[name]) { 38 | loadHooks[name].forEach(function(callback) { 39 | callback(object); 40 | }); 41 | } 42 | }; 43 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/suites/copyable/frozenCopy.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/~tests/suites/copyable'); 2 | 3 | var suite = Ember.CopyableTests; 4 | 5 | suite.module('frozenCopy'); 6 | 7 | suite.test("frozen objects should return same instance", function() { 8 | var obj, copy; 9 | 10 | obj = this.newObject(); 11 | if (Ember.get(this, 'shouldBeFreezable')) { 12 | ok(!Ember.Freezable || Ember.Freezable.detect(obj), 'object should be freezable'); 13 | 14 | copy = obj.frozenCopy(); 15 | ok(this.isEqual(obj, copy), 'new copy should be equal'); 16 | ok(Ember.get(copy, 'isFrozen'), 'returned value should be frozen'); 17 | 18 | copy = obj.freeze().frozenCopy(); 19 | equal(copy, obj, 'returns frozen object should be same'); 20 | ok(Ember.get(copy, 'isFrozen'), 'returned object should be frozen'); 21 | 22 | } else { 23 | ok(!Ember.Freezable || !Ember.Freezable.detect(obj), 'object should not be freezable'); 24 | } 25 | }); 26 | 27 | 28 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/suites/array/objectAt.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/~tests/suites/array'); 2 | 3 | var suite = Ember.ArrayTests; 4 | 5 | suite.module('objectAt'); 6 | 7 | suite.test("should return object at specified index", function() { 8 | var expected = this.newFixture(3), 9 | obj = this.newObject(expected), 10 | len = expected.length, 11 | idx; 12 | 13 | for(idx=0;idx a[2] }.each do |size| 37 | puts "%8d %8d %8d - %s" % size 38 | end 39 | 40 | uglified = uglify(all_files) 41 | gzipped = gzip(uglified) 42 | 43 | puts "%8d %8d %8d" % [all_files.size, uglified.size, gzipped.size] 44 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/suites/array.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/~tests/suites/enumerable'); 2 | 3 | 4 | 5 | var ObserverClass = Ember.EnumerableTests.ObserverClass.extend({ 6 | 7 | observeArray: function(obj) { 8 | obj.addArrayObserver(this); 9 | return this; 10 | }, 11 | 12 | stopObserveArray: function(obj) { 13 | obj.removeArrayObserver(this); 14 | return this; 15 | }, 16 | 17 | arrayWillChange: function() { 18 | equal(this._before, null, 'should only call once'); 19 | this._before = Array.prototype.slice.call(arguments); 20 | }, 21 | 22 | arrayDidChange: function() { 23 | equal(this._after, null, 'should only call once'); 24 | this._after = Array.prototype.slice.call(arguments); 25 | } 26 | 27 | }); 28 | 29 | Ember.ArrayTests = Ember.EnumerableTests.extend({ 30 | 31 | observerClass: ObserverClass 32 | 33 | }); 34 | 35 | Ember.ArrayTests.ObserverClass = ObserverClass; 36 | 37 | require('ember-runtime/~tests/suites/array/indexOf'); 38 | require('ember-runtime/~tests/suites/array/lastIndexOf'); 39 | require('ember-runtime/~tests/suites/array/objectAt'); 40 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/system/lazy_load_test.js: -------------------------------------------------------------------------------- 1 | module("Lazy Loading"); 2 | 3 | test("if a load hook is registered, it is executed when runLoadHooks are exected", function() { 4 | var count = 0; 5 | 6 | Ember.run(function() { 7 | Ember.onLoad("__test_hook__", function(object) { 8 | count += object; 9 | }); 10 | }); 11 | 12 | Ember.run(function() { 13 | Ember.runLoadHooks("__test_hook__", 1); 14 | }); 15 | 16 | equal(count, 1, "the object was passed into the load hook"); 17 | }); 18 | 19 | test("if runLoadHooks was already run, it executes newly added hooks immediately", function() { 20 | var count = 0; 21 | Ember.run(function() { 22 | Ember.onLoad("__test_hook__", function(object) { 23 | count += object; 24 | }); 25 | }); 26 | 27 | Ember.run(function() { 28 | Ember.runLoadHooks("__test_hook__", 1); 29 | }); 30 | 31 | count = 0; 32 | Ember.run(function() { 33 | Ember.onLoad("__test_hook__", function(object) { 34 | count += object; 35 | }); 36 | }); 37 | 38 | equal(count, 1, "the original object was passed into the load hook"); 39 | }); 40 | -------------------------------------------------------------------------------- /packages/ember-metal/tests/binding/oneWay_test.js: -------------------------------------------------------------------------------- 1 | /*globals MyApp:true */ 2 | 3 | module('system/mixin/binding/oneWay_test', { 4 | setup: function() { 5 | MyApp = { 6 | foo: { value: 'FOO' }, 7 | bar: { value: 'BAR' } 8 | }; 9 | }, 10 | 11 | teardown: function() { 12 | MyApp = null; 13 | } 14 | }); 15 | 16 | test('oneWay(true) should only sync one way', function() { 17 | var binding; 18 | Ember.run(function(){ 19 | binding = Ember.oneWay(MyApp, 'bar.value', 'foo.value'); 20 | }); 21 | 22 | equal(Ember.get('MyApp.foo.value'), 'FOO', 'foo synced'); 23 | equal(Ember.get('MyApp.bar.value'), 'FOO', 'bar synced'); 24 | 25 | Ember.run(function(){ 26 | Ember.set('MyApp.bar.value', 'BAZ'); 27 | }); 28 | 29 | equal(Ember.get('MyApp.foo.value'), 'FOO', 'foo synced'); 30 | equal(Ember.get('MyApp.bar.value'), 'BAZ', 'bar not synced'); 31 | 32 | Ember.run(function(){ 33 | Ember.set('MyApp.foo.value', 'BIFF'); 34 | }); 35 | 36 | equal(Ember.get('MyApp.foo.value'), 'BIFF', 'foo synced'); 37 | equal(Ember.get('MyApp.bar.value'), 'BIFF', 'foo synced'); 38 | 39 | }); 40 | 41 | -------------------------------------------------------------------------------- /packages/ember-application/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-application", 3 | "summary": "Ember Extensions to Handlebars", 4 | "description": "Extensions to the Handlebars templating engine for use with Ember. These extensions make Handlebars aware of property observing, which allows it to automatically update the DOM when the referenced properties change. It also provides Handlebars helpers for creating Ember views and working with collections.", 5 | "homepage": "http://emberjs.com", 6 | "author": "Yehuda Katz", 7 | "version": "1.0.0-pre.4", 8 | "dependencies": { 9 | "ember-views": "1.0.0-pre.4", 10 | "ember-states": "1.0.0-pre.4", 11 | "ember-routing": "1.0.0-pre.4" 12 | }, 13 | 14 | "directories": { 15 | "lib": "lib" 16 | }, 17 | 18 | "dependencies:development": { 19 | "spade-qunit": "~> 1.0.0" 20 | }, 21 | 22 | "bpm:build": { 23 | 24 | "bpm_libs.js": { 25 | "files": ["lib"], 26 | "modes": "*" 27 | }, 28 | 29 | "ember-handlebars/bpm_tests.js": { 30 | "files": ["tests"], 31 | "modes": ["debug"] 32 | } 33 | } 34 | 35 | } 36 | 37 | 38 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/system/string/decamelize.js: -------------------------------------------------------------------------------- 1 | module('Ember.String.decamelize'); 2 | 3 | test("does nothing with normal string", function() { 4 | deepEqual(Ember.String.decamelize('my favorite items'), 'my favorite items'); 5 | if (Ember.EXTEND_PROTOTYPES) { 6 | deepEqual('my favorite items'.decamelize(), 'my favorite items'); 7 | } 8 | }); 9 | 10 | test("does nothing with dasherized string", function() { 11 | deepEqual(Ember.String.decamelize('css-class-name'), 'css-class-name'); 12 | if (Ember.EXTEND_PROTOTYPES) { 13 | deepEqual('css-class-name'.decamelize(), 'css-class-name'); 14 | } 15 | }); 16 | 17 | test("does nothing with underscored string", function() { 18 | deepEqual(Ember.String.decamelize('action_name'), 'action_name'); 19 | if (Ember.EXTEND_PROTOTYPES) { 20 | deepEqual('action_name'.decamelize(), 'action_name'); 21 | } 22 | }); 23 | 24 | test("converts a camelized string into all lower case separated by underscores.", function() { 25 | deepEqual(Ember.String.decamelize('innerHTML'), 'inner_html'); 26 | if (Ember.EXTEND_PROTOTYPES) { 27 | deepEqual('innerHTML'.decamelize(), 'inner_html'); 28 | } 29 | }); -------------------------------------------------------------------------------- /packages/ember-views/lib/views/states/destroyed.js: -------------------------------------------------------------------------------- 1 | require('ember-views/views/states/default'); 2 | 3 | /** 4 | @module ember 5 | @submodule ember-views 6 | */ 7 | 8 | var destroyedError = "You can't call %@ on a destroyed view", fmt = Ember.String.fmt; 9 | 10 | var destroyed = Ember.View.states.destroyed = Ember.create(Ember.View.states._default); 11 | 12 | Ember.merge(destroyed, { 13 | appendChild: function() { 14 | throw fmt(destroyedError, ['appendChild']); 15 | }, 16 | rerender: function() { 17 | throw fmt(destroyedError, ['rerender']); 18 | }, 19 | destroyElement: function() { 20 | throw fmt(destroyedError, ['destroyElement']); 21 | }, 22 | empty: function() { 23 | throw fmt(destroyedError, ['empty']); 24 | }, 25 | 26 | setElement: function() { 27 | throw fmt(destroyedError, ["set('element', ...)"]); 28 | }, 29 | 30 | renderToBufferIfNeeded: function() { 31 | throw fmt(destroyedError, ["renderToBufferIfNeeded"]); 32 | }, 33 | 34 | // Since element insertion is scheduled, don't do anything if 35 | // the view has been destroyed between scheduling and execution 36 | insertElement: Ember.K 37 | }); 38 | 39 | -------------------------------------------------------------------------------- /packages/ember-handlebars/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-handlebars", 3 | "summary": "Ember Extensions to Handlebars", 4 | "description": "Extensions to the Handlebars templating engine for use with Ember. These extensions make Handlebars aware of property observing, which allows it to automatically update the DOM when the referenced properties change. It also provides Handlebars helpers for creating Ember views and working with collections.", 5 | "homepage": "http://emberjs.com", 6 | "author": "Yehuda Katz", 7 | "version": "1.0.0-pre.4", 8 | "dependencies": { 9 | "spade": "~> 1.0.0", 10 | "ember-handlebars-compiler", "1.0.0-pre.2", 11 | "ember-views": "1.0.0-pre.4", 12 | "metamorph": "~> 1.0.0" 13 | }, 14 | 15 | "directories": { 16 | "lib": "lib" 17 | }, 18 | 19 | "dependencies:development": { 20 | "spade-qunit": "~> 1.0.0" 21 | }, 22 | 23 | "bpm:build": { 24 | 25 | "bpm_libs.js": { 26 | "files": ["lib"], 27 | "modes": "*" 28 | }, 29 | 30 | "ember-handlebars/bpm_tests.js": { 31 | "files": ["tests"], 32 | "modes": ["debug"] 33 | } 34 | } 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Yehuda Katz, Tom Dale, Charles Jolley and Ember.js contributors 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /packages/ember-metal/tests/utils/try_invoke_test.js: -------------------------------------------------------------------------------- 1 | var obj; 2 | 3 | module("Ember.tryInvoke", { 4 | setup: function() { 5 | obj = { 6 | aMethodThatExists: function() { return true; }, 7 | aMethodThatTakesArguments: function(arg1, arg2) { return arg1 === arg2; } 8 | }; 9 | }, 10 | 11 | teardown: function() { 12 | obj = undefined; 13 | } 14 | }); 15 | 16 | test("should return undefined when the object doesn't exist", function() { 17 | equal(Ember.tryInvoke(undefined, 'aMethodThatDoesNotExist'), undefined); 18 | }); 19 | 20 | test("should return undefined when asked to perform a method that doesn't exist on the object", function() { 21 | equal(Ember.tryInvoke(obj, 'aMethodThatDoesNotExist'), undefined); 22 | }); 23 | 24 | test("should return what the method returns when asked to perform a method that exists on the object", function() { 25 | equal(Ember.tryInvoke(obj, 'aMethodThatExists'), true); 26 | }); 27 | 28 | test("should return what the method returns when asked to perform a method that takes arguments and exists on the object", function() { 29 | equal(Ember.tryInvoke(obj, 'aMethodThatTakesArguments', [true, true]), true); 30 | }); 31 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/system/object/detect_test.js: -------------------------------------------------------------------------------- 1 | module('system/object/detect'); 2 | 3 | test('detect detects classes correctly', function() { 4 | 5 | var A = Ember.Object.extend(); 6 | var B = A.extend(); 7 | var C = A.extend(); 8 | 9 | ok( Ember.Object.detect(Ember.Object), 'Ember.Object is an Ember.Object class' ); 10 | ok( Ember.Object.detect(A), 'A is an Ember.Object class' ); 11 | ok( Ember.Object.detect(B), 'B is an Ember.Object class' ); 12 | ok( Ember.Object.detect(C), 'C is an Ember.Object class' ); 13 | 14 | ok( !A.detect(Ember.Object), 'Ember.Object is not an A class' ); 15 | ok( A.detect(A), 'A is an A class' ); 16 | ok( A.detect(B), 'B is an A class' ); 17 | ok( A.detect(C), 'C is an A class' ); 18 | 19 | ok( !B.detect(Ember.Object), 'Ember.Object is not a B class' ); 20 | ok( !B.detect(A), 'A is not a B class' ); 21 | ok( B.detect(B), 'B is a B class' ); 22 | ok( !B.detect(C), 'C is not a B class' ); 23 | 24 | ok( !C.detect(Ember.Object), 'Ember.Object is not a C class' ); 25 | ok( !C.detect(A), 'A is not a C class' ); 26 | ok( !C.detect(B), 'B is not a C class' ); 27 | ok( C.detect(C), 'C is a C class' ); 28 | 29 | }); -------------------------------------------------------------------------------- /packages/ember-old-router/lib/resolved_state.js: -------------------------------------------------------------------------------- 1 | var get = Ember.get; 2 | 3 | Ember._ResolvedState = Ember.Object.extend({ 4 | manager: null, 5 | state: null, 6 | match: null, 7 | 8 | object: Ember.computed(function(key) { 9 | if (this._object) { 10 | return this._object; 11 | } else { 12 | var state = get(this, 'state'), 13 | match = get(this, 'match'), 14 | manager = get(this, 'manager'); 15 | return state.deserialize(manager, match.hash); 16 | } 17 | }), 18 | 19 | hasPromise: Ember.computed(function() { 20 | return Ember.canInvoke(get(this, 'object'), 'then'); 21 | }).property('object'), 22 | 23 | promise: Ember.computed(function() { 24 | var object = get(this, 'object'); 25 | if (Ember.canInvoke(object, 'then')) { 26 | return object; 27 | } else { 28 | return { 29 | then: function(success) { success(object); } 30 | }; 31 | } 32 | }).property('object'), 33 | 34 | transition: function() { 35 | var manager = get(this, 'manager'), 36 | path = get(this, 'state.path'), 37 | object = get(this, 'object'); 38 | manager.transitionTo(path, object); 39 | } 40 | }); 41 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GIT 2 | remote: https://github.com/lautis/uglifier.git 3 | revision: 2f6c31a67d6dbd04c3153603339fab49a06ec4ec 4 | specs: 5 | uglifier (1.3.0) 6 | execjs (>= 0.3.0) 7 | multi_json (~> 1.0, >= 1.0.2) 8 | 9 | GIT 10 | remote: https://github.com/livingsocial/rake-pipeline.git 11 | revision: 50b8d77b703c96539a433ee53a680c43542aaa75 12 | specs: 13 | rake-pipeline (0.8.0) 14 | json 15 | rake (~> 0.9.0) 16 | thor 17 | 18 | GIT 19 | remote: https://github.com/wycats/rake-pipeline-web-filters.git 20 | revision: 1a6dc173776b188836aa2ce2ac35b61c7f7daafe 21 | specs: 22 | rake-pipeline-web-filters (0.6.0) 23 | rack 24 | rake-pipeline (~> 0.6) 25 | 26 | GEM 27 | remote: http://rubygems.org/ 28 | specs: 29 | colored (1.2) 30 | execjs (1.4.0) 31 | multi_json (~> 1.0) 32 | json (1.7.6) 33 | kicker (2.6.1) 34 | listen 35 | listen (0.6.0) 36 | multi_json (1.3.7) 37 | rack (1.4.1) 38 | rake (0.9.6) 39 | thor (0.16.0) 40 | 41 | PLATFORMS 42 | ruby 43 | 44 | DEPENDENCIES 45 | colored 46 | kicker 47 | rack 48 | rake-pipeline! 49 | rake-pipeline-web-filters! 50 | uglifier! 51 | -------------------------------------------------------------------------------- /packages/ember-metal/tests/properties_test.js: -------------------------------------------------------------------------------- 1 | module('Ember.defineProperty'); 2 | 3 | test('toString', function() { 4 | 5 | var obj = {}; 6 | Ember.defineProperty(obj, 'toString', undefined, function() { return 'FOO'; }); 7 | equal(obj.toString(), 'FOO', 'should replace toString'); 8 | }); 9 | 10 | test("for data properties, didDefineProperty hook should be called if implemented", function() { 11 | expect(2); 12 | 13 | var obj = { 14 | didDefineProperty: function(obj, keyName, value) { 15 | equal(keyName, 'foo', "key name should be foo"); 16 | equal(value, 'bar', "value should be bar"); 17 | } 18 | }; 19 | 20 | Ember.defineProperty(obj, 'foo', undefined, "bar"); 21 | }); 22 | 23 | test("for descriptor properties, didDefineProperty hook should be called if implemented", function() { 24 | expect(2); 25 | 26 | var computedProperty = Ember.computed(Ember.K); 27 | 28 | var obj = { 29 | didDefineProperty: function(obj, keyName, value) { 30 | equal(keyName, 'foo', "key name should be foo"); 31 | strictEqual(value, computedProperty, "value should be passed descriptor"); 32 | } 33 | }; 34 | 35 | Ember.defineProperty(obj, 'foo', computedProperty); 36 | }); 37 | 38 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/system/object/reopen_test.js: -------------------------------------------------------------------------------- 1 | module('system/core_object/reopenClass'); 2 | 3 | test('adds new properties to subclass instance', function() { 4 | 5 | var Subclass = Ember.Object.extend(); 6 | Subclass.reopen({ 7 | foo: function() { return 'FOO'; }, 8 | bar: 'BAR' 9 | }); 10 | 11 | equal( new Subclass().foo(), 'FOO', 'Adds method'); 12 | equal(Ember.get(new Subclass(), 'bar'), 'BAR', 'Adds property'); 13 | }); 14 | 15 | test('reopened properties inherited by subclasses', function() { 16 | 17 | var Subclass = Ember.Object.extend(); 18 | var SubSub = Subclass.extend(); 19 | 20 | Subclass.reopen({ 21 | foo: function() { return 'FOO'; }, 22 | bar: 'BAR' 23 | }); 24 | 25 | 26 | equal( new SubSub().foo(), 'FOO', 'Adds method'); 27 | equal(Ember.get(new SubSub(), 'bar'), 'BAR', 'Adds property'); 28 | }); 29 | 30 | // We plan to allow this in the future 31 | test('does not allow reopening already instantiated classes', function() { 32 | var Subclass = Ember.Object.extend(); 33 | 34 | Subclass.create(); 35 | 36 | Subclass.reopen({ 37 | trololol: true 38 | }); 39 | 40 | equal(Subclass.create().get('trololol'), true, "reopen works"); 41 | }); 42 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/core/compare_test.js: -------------------------------------------------------------------------------- 1 | /*globals module ok equals same test MyApp */ 2 | 3 | // test parsing of query string 4 | var v = []; 5 | module("Ember.compare()", { 6 | setup: function() { 7 | // setup dummy data 8 | v[0] = null; 9 | v[1] = false; 10 | v[2] = true; 11 | v[3] = -12; 12 | v[4] = 3.5; 13 | v[5] = 'a string'; 14 | v[6] = 'another string'; 15 | v[7] = 'last string'; 16 | v[8] = [1,2]; 17 | v[9] = [1,2,3]; 18 | v[10] = [1,3]; 19 | v[11] = {a: 'hash'}; 20 | v[12] = Ember.Object.create(); 21 | v[13] = function (a) {return a;}; 22 | v[14] = new Date('2012/01/01'); 23 | v[15] = new Date('2012/06/06'); 24 | } 25 | }); 26 | 27 | 28 | // .......................................................... 29 | // TESTS 30 | // 31 | 32 | test("ordering should work", function() { 33 | for (var j=0; j < v.length; j++) { 34 | equal(Ember.compare(v[j],v[j]), 0, j +' should equal itself'); 35 | for (var i=j+1; i < v.length; i++) { 36 | equal(Ember.compare(v[j],v[i]), -1, 'v[' + j + '] (' + Ember.typeOf(v[j]) + ') should be smaller than v[' + i + '] (' + Ember.typeOf(v[i]) + ')' ); 37 | } 38 | 39 | } 40 | }); 41 | 42 | -------------------------------------------------------------------------------- /packages/ember-metal/tests/mixin/detect_test.js: -------------------------------------------------------------------------------- 1 | module('Mixin.detect'); 2 | 3 | test('detect() finds a directly applied mixin', function() { 4 | 5 | var MixinA = Ember.Mixin.create(); 6 | var obj = {}; 7 | 8 | equal(MixinA.detect(obj), false, 'MixinA.detect(obj) before apply()'); 9 | 10 | MixinA.apply(obj); 11 | equal(MixinA.detect(obj), true, 'MixinA.detect(obj) after apply()'); 12 | }); 13 | 14 | test('detect() finds nested mixins', function() { 15 | var MixinA = Ember.Mixin.create({}); 16 | var MixinB = Ember.Mixin.create(MixinA); 17 | var obj = {}; 18 | 19 | equal(MixinA.detect(obj), false, 'MixinA.detect(obj) before apply()'); 20 | 21 | MixinB.apply(obj); 22 | equal(MixinA.detect(obj), true, 'MixinA.detect(obj) after apply()'); 23 | }); 24 | 25 | test('detect() finds mixins on other mixins', function() { 26 | var MixinA = Ember.Mixin.create({}); 27 | var MixinB = Ember.Mixin.create(MixinA); 28 | equal(MixinA.detect(MixinB), true, 'MixinA is part of MixinB'); 29 | equal(MixinB.detect(MixinA), false, 'MixinB is not part of MixinA'); 30 | }); 31 | 32 | test('detect handles null values', function() { 33 | var MixinA = Ember.Mixin.create(); 34 | equal(MixinA.detect(null), false); 35 | }); 36 | -------------------------------------------------------------------------------- /packages/ember-routing/lib/location/none_location.js: -------------------------------------------------------------------------------- 1 | /** 2 | @module ember 3 | @submodule ember-routing 4 | */ 5 | 6 | var get = Ember.get, set = Ember.set; 7 | 8 | /** 9 | Ember.NoneLocation does not interact with the browser. It is useful for 10 | testing, or when you need to manage state with your Router, but temporarily 11 | don't want it to muck with the URL (for example when you embed your 12 | application in a larger page). 13 | 14 | @class NoneLocation 15 | @namespace Ember 16 | @extends Ember.Object 17 | */ 18 | Ember.NoneLocation = Ember.Object.extend({ 19 | path: '', 20 | 21 | getURL: function() { 22 | return get(this, 'path'); 23 | }, 24 | 25 | setURL: function(path) { 26 | set(this, 'path', path); 27 | }, 28 | 29 | onUpdateURL: function(callback) { 30 | // We are not wired up to the browser, so we'll never trigger the callback. 31 | }, 32 | 33 | formatURL: function(url) { 34 | // The return value is not overly meaningful, but we do not want to throw 35 | // errors when test code renders templates containing {{action href=true}} 36 | // helpers. 37 | return url; 38 | } 39 | }); 40 | 41 | Ember.Location.registerImplementation('none', Ember.NoneLocation); 42 | -------------------------------------------------------------------------------- /packages/ember-old-router/lib/location/none_location.js: -------------------------------------------------------------------------------- 1 | /** 2 | @module ember 3 | @submodule ember-old-router 4 | */ 5 | 6 | var get = Ember.get, set = Ember.set; 7 | 8 | /** 9 | `Ember.NoneLocation` does not interact with the browser. It is useful for 10 | testing, or when you need to manage state with your router, but temporarily 11 | don't want it to muck with the URL (for example when you embed your 12 | application in a larger page). 13 | 14 | @class NoneLocation 15 | @namespace Ember 16 | @extends Ember.Object 17 | */ 18 | Ember.NoneLocation = Ember.Object.extend({ 19 | path: '', 20 | 21 | getURL: function() { 22 | return get(this, 'path'); 23 | }, 24 | 25 | setURL: function(path) { 26 | set(this, 'path', path); 27 | }, 28 | 29 | onUpdateURL: function(callback) { 30 | // We are not wired up to the browser, so we'll never trigger the callback. 31 | }, 32 | 33 | formatURL: function(url) { 34 | // The return value is not overly meaningful, but we do not want to throw 35 | // errors when test code renders templates containing {{action href=true}} 36 | // helpers. 37 | return url; 38 | } 39 | }); 40 | 41 | Ember.Location.registerImplementation('none', Ember.NoneLocation); 42 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/system/object/subclasses_test.js: -------------------------------------------------------------------------------- 1 | module('system/object/subclasses'); 2 | 3 | test('chains should copy forward to subclasses when prototype created', function () { 4 | var ObjectWithChains, objWithChains, SubWithChains, SubSub, subSub; 5 | Ember.run(function () { 6 | ObjectWithChains = Ember.Object.extend({ 7 | obj: { 8 | a: 'a', 9 | hi: 'hi' 10 | }, 11 | aBinding: 'obj.a' // add chain 12 | }); 13 | // realize prototype 14 | objWithChains = ObjectWithChains.create(); 15 | // should not copy chains from parent yet 16 | SubWithChains = ObjectWithChains.extend({ 17 | hiBinding: 'obj.hi', // add chain 18 | hello: Ember.computed(function() { 19 | return this.get('obj.hi') + ' world'; 20 | }).property('hi').volatile(), // observe chain 21 | greetingBinding: 'hello' 22 | }); 23 | SubSub = SubWithChains.extend(); 24 | // should realize prototypes and copy forward chains 25 | subSub = SubSub.create(); 26 | }); 27 | equal(subSub.get('greeting'), 'hi world'); 28 | Ember.run(function () { 29 | objWithChains.set('obj.hi', 'hello'); 30 | }); 31 | equal(subSub.get('greeting'), 'hello world'); 32 | }); 33 | -------------------------------------------------------------------------------- /packages/ember-metal/tests/accessors/set_test.js: -------------------------------------------------------------------------------- 1 | module('Ember.set'); 2 | 3 | test('should set arbitrary properties on an object', function() { 4 | var obj = { 5 | string: 'string', 6 | number: 23, 7 | boolTrue: true, 8 | boolFalse: false, 9 | nullValue: null 10 | }; 11 | 12 | var newObj = {}; 13 | 14 | for(var key in obj) { 15 | if (!obj.hasOwnProperty(key)) continue; 16 | equal(Ember.set(newObj, key, obj[key]), obj[key], 'should return value'); 17 | equal(Ember.get(newObj, key), obj[key], 'should set value'); 18 | } 19 | 20 | }); 21 | 22 | test('should call setUnknownProperty if defined and value is undefined', function() { 23 | 24 | var obj = { 25 | count: 0, 26 | 27 | unknownProperty: function(key, value) { 28 | ok(false, 'should not invoke unknownProperty is setUnknownProperty is defined'); 29 | }, 30 | 31 | setUnknownProperty: function(key, value) { 32 | equal(key, 'foo', 'should pass key'); 33 | equal(value, 'BAR', 'should pass key'); 34 | this.count++; 35 | return 'FOO'; 36 | } 37 | }; 38 | 39 | equal(Ember.set(obj, 'foo', "BAR"), 'BAR', 'should return set value'); 40 | equal(obj.count, 1, 'should have invoked'); 41 | }); 42 | 43 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/system/array_proxy/content_update_test.js: -------------------------------------------------------------------------------- 1 | // ========================================================================== 2 | // Project: Ember Runtime 3 | // Copyright: ©2011 Strobe Inc. and contributors. 4 | // License: Licensed under MIT license (see license.js) 5 | // ========================================================================== 6 | 7 | module("Ember.ArrayProxy - content update"); 8 | 9 | test("The `contentArrayDidChange` method is invoked after `content` is updated.", function() { 10 | 11 | var proxy, observerCalled = false; 12 | 13 | proxy = Ember.ArrayProxy.createWithMixins({ 14 | content: Ember.A([]), 15 | 16 | arrangedContent: Ember.computed('content', function(key, value) { 17 | // setup arrangedContent as a different object than content, 18 | // which is the default 19 | return Ember.A(this.get('content').slice()); 20 | }).cacheable(), 21 | 22 | contentArrayDidChange: function(array, idx, removedCount, addedCount) { 23 | observerCalled = true; 24 | return this._super(array, idx, removedCount, addedCount); 25 | } 26 | }); 27 | 28 | proxy.pushObject(1); 29 | 30 | ok(observerCalled, "contentArrayDidChange is invoked"); 31 | }); 32 | -------------------------------------------------------------------------------- /packages/ember-views/tests/system/ext_test.js: -------------------------------------------------------------------------------- 1 | module("Ember.View additions to run queue"); 2 | 3 | test("View hierarchy is done rendering to DOM when functions queued in afterRender execute", function() { 4 | var lookup1, lookup2; 5 | var childView = Ember.View.create({ 6 | elementId: 'child_view', 7 | render: function(buffer) { 8 | buffer.push('child'); 9 | }, 10 | didInsertElement: function(){ 11 | this.$().addClass('extra-class'); 12 | } 13 | }); 14 | var parentView = Ember.View.create({ 15 | elementId: 'parent_view', 16 | render: function(buffer) { 17 | buffer.push('parent'); 18 | this.appendChild(childView); 19 | }, 20 | didInsertElement: function() { 21 | lookup1 = this.$('.extra-class'); 22 | Ember.run.scheduleOnce('afterRender', this, function(){ 23 | lookup2 = this.$('.extra-class'); 24 | }); 25 | } 26 | }); 27 | 28 | Ember.run(function() { 29 | parentView.appendTo('#qunit-fixture'); 30 | }); 31 | 32 | equal(lookup1.length, 0, "doesn't not find child in DOM on didInsertElement"); 33 | equal(lookup2.length, 1, "finds child in DOM afterRender"); 34 | 35 | Ember.run(function(){ 36 | parentView.destroy(); 37 | }); 38 | }); 39 | -------------------------------------------------------------------------------- /packages/ember-views/tests/views/view/create_child_view_test.js: -------------------------------------------------------------------------------- 1 | var set = Ember.set, get = Ember.get; 2 | 3 | var view, myViewClass ; 4 | 5 | module("Ember.View#createChildView", { 6 | setup: function() { 7 | view = Ember.View.create(); 8 | myViewClass = Ember.View.extend({ isMyView: true, foo: 'bar' }); 9 | } 10 | }); 11 | 12 | test("should create view from class with any passed attributes", function() { 13 | var attrs = { foo: "baz" }; 14 | var newView = view.createChildView(myViewClass, attrs); 15 | ok(get(newView, 'isMyView'), 'newView is instance of myView'); 16 | equal(get(newView, 'foo'), 'baz', 'view did get custom attributes'); 17 | ok(!attrs.parentView, "the original attributes hash was not mutated"); 18 | }); 19 | 20 | test("should set newView.parentView to receiver", function() { 21 | var newView = view.createChildView(myViewClass) ; 22 | equal(get(newView, 'parentView'), view, 'newView.parentView == view'); 23 | }); 24 | 25 | test("should create property on parentView to a childView instance if provided a viewName", function() { 26 | var attrs = { viewName: "someChildView" }; 27 | var newView = view.createChildView(myViewClass, attrs); 28 | 29 | equal(get(view, 'someChildView'), newView); 30 | }); 31 | -------------------------------------------------------------------------------- /packages/ember-views/tests/views/view/evented_test.js: -------------------------------------------------------------------------------- 1 | var set = Ember.set, get = Ember.get; 2 | 3 | module("Ember.View evented helpers"); 4 | 5 | test("fire should call method sharing event name if it exists on the view", function() { 6 | var eventFired = false; 7 | 8 | var view = Ember.View.create({ 9 | fireMyEvent: function() { 10 | this.trigger('myEvent'); 11 | }, 12 | 13 | myEvent: function() { 14 | eventFired = true; 15 | } 16 | }); 17 | 18 | Ember.run(function() { 19 | view.fireMyEvent(); 20 | }); 21 | 22 | equal(eventFired, true, "fired the view method sharing the event name"); 23 | }); 24 | 25 | test("fire does not require a view method with the same name", function() { 26 | var eventFired = false; 27 | 28 | var view = Ember.View.create({ 29 | fireMyEvent: function() { 30 | this.trigger('myEvent'); 31 | } 32 | }); 33 | 34 | var listenObject = Ember.Object.create({ 35 | onMyEvent: function() { 36 | eventFired = true; 37 | } 38 | }); 39 | 40 | view.on('myEvent', listenObject, 'onMyEvent'); 41 | 42 | Ember.run(function() { 43 | view.fireMyEvent(); 44 | }); 45 | 46 | equal(eventFired, true, "fired the event without a view method sharing its name"); 47 | }); 48 | 49 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/suites/mutable_array/reverseObjects.js: -------------------------------------------------------------------------------- 1 | /*globals raises */ 2 | 3 | require('ember-runtime/~tests/suites/mutable_array'); 4 | 5 | var suite = Ember.MutableArrayTests; 6 | 7 | suite.module('reverseObjects'); 8 | 9 | suite.test("[A,B,C].reverseObjects() => [] + notify", function () { 10 | var obj, before, after, observer; 11 | 12 | before = this.newFixture(3); 13 | after = [before[2], before[1], before[0]]; 14 | obj = this.newObject(before); 15 | observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); 16 | obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ 17 | 18 | equal(obj.reverseObjects(), obj, 'return self'); 19 | 20 | deepEqual(this.toArray(obj), after, 'post item results'); 21 | equal(Ember.get(obj, 'length'), after.length, 'length'); 22 | 23 | equal(observer.timesCalled('[]'), 1, 'should have notified [] once'); 24 | equal(observer.timesCalled('@each'), 1, 'should have notified @each once'); 25 | equal(observer.timesCalled('length'), 0, 'should have notified length once'); 26 | equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once'); 27 | equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once'); 28 | }); 29 | -------------------------------------------------------------------------------- /packages/ember-handlebars/lib/helpers/debug.js: -------------------------------------------------------------------------------- 1 | /*jshint debug:true*/ 2 | 3 | require('ember-handlebars/ext'); 4 | 5 | /** 6 | @module ember 7 | @submodule ember-handlebars 8 | */ 9 | 10 | var handlebarsGet = Ember.Handlebars.get, normalizePath = Ember.Handlebars.normalizePath; 11 | 12 | /** 13 | `log` allows you to output the value of a value in the current rendering 14 | context. 15 | 16 | ```handlebars 17 | {{log myVariable}} 18 | ``` 19 | 20 | @method log 21 | @for Ember.Handlebars.helpers 22 | @param {String} property 23 | */ 24 | Ember.Handlebars.registerHelper('log', function(property, options) { 25 | var context = (options.contexts && options.contexts[0]) || this, 26 | normalized = normalizePath(context, property, options.data), 27 | pathRoot = normalized.root, 28 | path = normalized.path, 29 | value = (path === 'this') ? pathRoot : handlebarsGet(pathRoot, path, options); 30 | Ember.Logger.log(value); 31 | }); 32 | 33 | /** 34 | Execute the `debugger` statement in the current context. 35 | 36 | ```handlebars 37 | {{debugger}} 38 | ``` 39 | 40 | @method debugger 41 | @for Ember.Handlebars.helpers 42 | @param {String} property 43 | */ 44 | Ember.Handlebars.registerHelper('debugger', function() { 45 | debugger; 46 | }); 47 | -------------------------------------------------------------------------------- /packages/ember-runtime/lib/mixins/comparable.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/core'); 2 | 3 | /** 4 | @module ember 5 | @submodule ember-runtime 6 | */ 7 | 8 | 9 | /** 10 | Implements some standard methods for comparing objects. Add this mixin to 11 | any class you create that can compare its instances. 12 | 13 | You should implement the `compare()` method. 14 | 15 | @class Comparable 16 | @namespace Ember 17 | @extends Ember.Mixin 18 | @since Ember 0.9 19 | */ 20 | Ember.Comparable = Ember.Mixin.create( /** @scope Ember.Comparable.prototype */{ 21 | 22 | /** 23 | walk like a duck. Indicates that the object can be compared. 24 | 25 | @property isComparable 26 | @type Boolean 27 | @default true 28 | */ 29 | isComparable: true, 30 | 31 | /** 32 | Override to return the result of the comparison of the two parameters. The 33 | compare method should return: 34 | 35 | - `-1` if `a < b` 36 | - `0` if `a == b` 37 | - `1` if `a > b` 38 | 39 | Default implementation raises an exception. 40 | 41 | @method compare 42 | @param a {Object} the first object to compare 43 | @param b {Object} the second object to compare 44 | @return {Integer} the result of the comparison 45 | */ 46 | compare: Ember.required(Function) 47 | 48 | }); 49 | 50 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/ext/mixin_test.js: -------------------------------------------------------------------------------- 1 | module('system/mixin/binding_test'); 2 | 3 | test('Defining a property ending in Binding should setup binding when applied', function() { 4 | 5 | var MyMixin = Ember.Mixin.create({ 6 | fooBinding: 'bar.baz' 7 | }); 8 | 9 | var obj = { bar: { baz: 'BIFF' } }; 10 | 11 | Ember.run(function(){ 12 | MyMixin.apply(obj); 13 | }); 14 | 15 | ok(Ember.get(obj, 'fooBinding') instanceof Ember.Binding, 'should be a binding object'); 16 | equal(Ember.get(obj, 'foo'), 'BIFF', 'binding should be created and synced'); 17 | 18 | }); 19 | 20 | test('Defining a property ending in Binding should apply to prototype children', function() { 21 | var MyMixin, obj, obj2; 22 | 23 | Ember.run(function(){ 24 | MyMixin = Ember.Mixin.create({ 25 | fooBinding: 'bar.baz' 26 | }); 27 | }); 28 | 29 | obj = { bar: { baz: 'BIFF' } }; 30 | 31 | Ember.run(function(){ 32 | MyMixin.apply(obj); 33 | }); 34 | 35 | 36 | obj2 = Ember.create(obj); 37 | Ember.run(function(){ 38 | Ember.set(Ember.get(obj2, 'bar'), 'baz', 'BARG'); 39 | }); 40 | 41 | 42 | ok(Ember.get(obj2, 'fooBinding') instanceof Ember.Binding, 'should be a binding object'); 43 | equal(Ember.get(obj2, 'foo'), 'BARG', 'binding should be created and synced'); 44 | 45 | }); 46 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/system/string/camelize.js: -------------------------------------------------------------------------------- 1 | module('Ember.String.camelize'); 2 | 3 | test("camelize normal string", function() { 4 | deepEqual(Ember.String.camelize('my favorite items'), 'myFavoriteItems'); 5 | if (Ember.EXTEND_PROTOTYPES) { 6 | deepEqual('my favorite items'.camelize(), 'myFavoriteItems'); 7 | } 8 | }); 9 | 10 | test("camelize dasherized string", function() { 11 | deepEqual(Ember.String.camelize('css-class-name'), 'cssClassName'); 12 | if (Ember.EXTEND_PROTOTYPES) { 13 | deepEqual('css-class-name'.camelize(), 'cssClassName'); 14 | } 15 | }); 16 | 17 | test("camelize underscored string", function() { 18 | deepEqual(Ember.String.camelize('action_name'), 'actionName'); 19 | if (Ember.EXTEND_PROTOTYPES) { 20 | deepEqual('action_name'.camelize(), 'actionName'); 21 | } 22 | }); 23 | 24 | test("camelize dot notation string", function() { 25 | deepEqual(Ember.String.camelize('action.name'), 'actionName'); 26 | if (Ember.EXTEND_PROTOTYPES) { 27 | deepEqual('action.name'.camelize(), 'actionName'); 28 | } 29 | }); 30 | 31 | test("does nothing with camelcased string", function() { 32 | deepEqual(Ember.String.camelize('innerHTML'), 'innerHTML'); 33 | if (Ember.EXTEND_PROTOTYPES) { 34 | deepEqual('innerHTML'.camelize(), 'innerHTML'); 35 | } 36 | }); 37 | 38 | -------------------------------------------------------------------------------- /packages/ember-metal/tests/run_loop/later_test.js: -------------------------------------------------------------------------------- 1 | var previousPreventRunloop; 2 | 3 | test('should invoke after specified period of time - function only', function() { 4 | 5 | var invoked = false; 6 | 7 | Ember.run(function() { 8 | Ember.run.later(function() { invoked = true; }, 100); 9 | }); 10 | 11 | stop(); 12 | 13 | setTimeout(function() { 14 | start(); 15 | equal(invoked, true, 'should have invoked later item'); 16 | }, 150); 17 | 18 | }); 19 | 20 | 21 | test('should invoke after specified period of time - target/method', function() { 22 | 23 | var obj = { invoked: false } ; 24 | 25 | Ember.run(function() { 26 | Ember.run.later(obj, function() { this.invoked = true; }, 100); 27 | }); 28 | 29 | stop(); 30 | 31 | setTimeout(function() { 32 | start(); 33 | equal(obj.invoked, true, 'should have invoked later item'); 34 | }, 150); 35 | 36 | }); 37 | 38 | 39 | test('should invoke after specified period of time - target/method/args', function() { 40 | 41 | var obj = { invoked: 0 } ; 42 | 43 | Ember.run(function() { 44 | Ember.run.later(obj, function(amt) { this.invoked += amt; }, 10, 100); 45 | }); 46 | 47 | stop(); 48 | 49 | setTimeout(function() { 50 | start(); 51 | equal(obj.invoked, 10, 'should have invoked later item'); 52 | }, 150); 53 | 54 | }); 55 | -------------------------------------------------------------------------------- /packages/ember-runtime/lib/mixins/target_action_support.js: -------------------------------------------------------------------------------- 1 | /** 2 | @module ember 3 | @submodule ember-runtime 4 | */ 5 | 6 | var get = Ember.get, set = Ember.set; 7 | 8 | /** 9 | @class TargetActionSupport 10 | @namespace Ember 11 | @extends Ember.Mixin 12 | */ 13 | Ember.TargetActionSupport = Ember.Mixin.create({ 14 | target: null, 15 | action: null, 16 | 17 | targetObject: Ember.computed(function() { 18 | var target = get(this, 'target'); 19 | 20 | if (Ember.typeOf(target) === "string") { 21 | var value = get(this, target); 22 | if (value === undefined) { value = get(Ember.lookup, target); } 23 | return value; 24 | } else { 25 | return target; 26 | } 27 | }).property('target'), 28 | 29 | triggerAction: function() { 30 | var action = get(this, 'action'), 31 | target = get(this, 'targetObject'); 32 | 33 | if (target && action) { 34 | var ret; 35 | 36 | if (typeof target.send === 'function') { 37 | ret = target.send(action, this); 38 | } else { 39 | if (typeof action === 'string') { 40 | action = target[action]; 41 | } 42 | ret = action.call(target, this); 43 | } 44 | if (ret !== false) ret = true; 45 | 46 | return ret; 47 | } else { 48 | return false; 49 | } 50 | } 51 | }); 52 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "predef": [ 3 | "define", 4 | "console", 5 | "Ember", 6 | "DS", 7 | "Handlebars", 8 | "Metamorph", 9 | "RSVP", 10 | "ember_assert", 11 | "ember_warn", 12 | "ember_deprecate", 13 | "ember_deprecateFunc", 14 | "require", 15 | "requireModule", 16 | "equal", 17 | "notEqual", 18 | "test", 19 | "asyncTest", 20 | "testBoth", 21 | "testWithDefault", 22 | "raises", 23 | "throws", 24 | "deepEqual", 25 | "start", 26 | "stop", 27 | "ok", 28 | "strictEqual", 29 | "module", 30 | "expect", 31 | "minispade" 32 | ], 33 | 34 | "node" : false, 35 | "browser" : true, 36 | 37 | "boss" : true, 38 | "curly": false, 39 | "debug": false, 40 | "devel": false, 41 | "eqeqeq": true, 42 | "evil": true, 43 | "forin": false, 44 | "immed": false, 45 | "laxbreak": false, 46 | "newcap": true, 47 | "noarg": true, 48 | "noempty": false, 49 | "nonew": false, 50 | "nomen": false, 51 | "onevar": false, 52 | "plusplus": false, 53 | "regexp": false, 54 | "undef": true, 55 | "sub": true, 56 | "strict": false, 57 | "white": false, 58 | "eqnull": true 59 | } 60 | -------------------------------------------------------------------------------- /packages/ember-views/tests/views/view/create_element_test.js: -------------------------------------------------------------------------------- 1 | var set = Ember.set, get = Ember.get; 2 | 3 | module("Ember.View#createElement"); 4 | 5 | test("returns the receiver", function() { 6 | var view = Ember.View.create(), ret; 7 | 8 | Ember.run(function(){ 9 | ret = view.createElement(); 10 | }); 11 | 12 | equal(ret, view, 'returns receiver'); 13 | }); 14 | 15 | test("calls render and turns resultant string into element", function() { 16 | var view = Ember.View.create({ 17 | tagName: 'span', 18 | 19 | render: function(buffer) { 20 | buffer.push("foo"); 21 | } 22 | }); 23 | 24 | equal(get(view, 'element'), null, 'precondition - has no element'); 25 | Ember.run(function(){ 26 | view.createElement(); 27 | }); 28 | 29 | 30 | var elem = get(view, 'element'); 31 | ok(elem, 'has element now'); 32 | equal(elem.innerHTML, 'foo', 'has innerHTML from context'); 33 | equal(elem.tagName.toString().toLowerCase(), 'span', 'has tagName from view'); 34 | }); 35 | 36 | test("generated element include HTML from child views as well", function() { 37 | var view = Ember.ContainerView.create({ 38 | childViews: [ Ember.View.create({ elementId: "foo" })] 39 | }); 40 | 41 | Ember.run(function(){ 42 | view.createElement(); 43 | }); 44 | 45 | ok(view.$('#foo').length, 'has element with child elementId'); 46 | }); 47 | 48 | -------------------------------------------------------------------------------- /benchmarks/simple.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /packages/ember-views/tests/views/view/controller_test.js: -------------------------------------------------------------------------------- 1 | module("Ember.View - controller property"); 2 | 3 | test("controller property should be inherited from nearest ancestor with controller", function() { 4 | var grandparent = Ember.ContainerView.create(); 5 | var parent = Ember.ContainerView.create(); 6 | var child = Ember.ContainerView.create(); 7 | var grandchild = Ember.ContainerView.create(); 8 | 9 | var grandparentController = {}; 10 | var parentController = {}; 11 | 12 | Ember.run(function() { 13 | grandparent.set('controller', grandparentController); 14 | parent.set('controller', parentController); 15 | 16 | grandparent.get('childViews').pushObject(parent); 17 | parent.get('childViews').pushObject(child); 18 | 19 | strictEqual(grandparent.get('controller'), grandparentController); 20 | strictEqual(parent.get('controller'), parentController); 21 | strictEqual(child.get('controller'), parentController); 22 | strictEqual(grandchild.get('controller'), null); 23 | 24 | child.get('childViews').pushObject(grandchild); 25 | strictEqual(grandchild.get('controller'), parentController); 26 | 27 | var newController = {}; 28 | parent.set('controller', newController); 29 | strictEqual(parent.get('controller'), newController); 30 | strictEqual(child.get('controller'), newController); 31 | strictEqual(grandchild.get('controller'), newController); 32 | }); 33 | }); 34 | -------------------------------------------------------------------------------- /packages/ember-metal/tests/run_loop/unwind_test.js: -------------------------------------------------------------------------------- 1 | module('system/run_loop/unwind_test'); 2 | 3 | test('RunLoop unwinds despite unhandled exception', function() { 4 | var initialRunLoop = Ember.run.currentRunLoop; 5 | 6 | raises(function(){ 7 | Ember.run(function() { 8 | Ember.run.schedule('actions', function() { throw new Error("boom!"); }); 9 | }); 10 | }, Error, "boom!"); 11 | 12 | // The real danger at this point is that calls to autorun will stick 13 | // tasks into the already-dead runloop, which will never get 14 | // flushed. I can't easily demonstrate this in a unit test because 15 | // autorun explicitly doesn't work in test mode. - ef4 16 | equal(Ember.run.currentRunLoop, initialRunLoop, "Previous run loop should be cleaned up despite exception"); 17 | 18 | // Prevent a failure in this test from breaking subsequent tests. 19 | Ember.run.currentRunLoop = initialRunLoop; 20 | 21 | }); 22 | 23 | test('Ember.run unwinds despite unhandled exception', function() { 24 | var initialRunLoop = Ember.run.currentRunLoop; 25 | 26 | raises(function(){ 27 | Ember.run(function() { 28 | throw new Error("boom!"); 29 | }); 30 | }, Error, "boom!"); 31 | 32 | equal(Ember.run.currentRunLoop, initialRunLoop, "Previous run loop should be cleaned up despite exception"); 33 | 34 | // Prevent a failure in this test from breaking subsequent tests. 35 | Ember.run.currentRunLoop = initialRunLoop; 36 | 37 | }); 38 | 39 | -------------------------------------------------------------------------------- /packages/ember-old-router/lib/promise_chain.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/system/object'); 2 | 3 | /** 4 | @module ember 5 | @submodule ember-runtime 6 | */ 7 | 8 | var get = Ember.get, set = Ember.set; 9 | 10 | Ember._PromiseChain = Ember.Object.extend({ 11 | promises: null, 12 | failureCallback: Ember.K, 13 | successCallback: Ember.K, 14 | abortCallback: Ember.K, 15 | promiseSuccessCallback: Ember.K, 16 | 17 | runNextPromise: function() { 18 | if (get(this, 'isDestroyed')) { return; } 19 | 20 | var item = get(this, 'promises').shiftObject(); 21 | if (item) { 22 | var promise = get(item, 'promise') || item; 23 | Ember.assert("Cannot find promise to invoke", Ember.canInvoke(promise, 'then')); 24 | 25 | var self = this; 26 | 27 | var successCallback = function() { 28 | self.promiseSuccessCallback.call(this, item, arguments); 29 | self.runNextPromise(); 30 | }; 31 | 32 | var failureCallback = get(self, 'failureCallback'); 33 | 34 | promise.then(successCallback, failureCallback); 35 | } else { 36 | this.successCallback(); 37 | } 38 | }, 39 | 40 | start: function() { 41 | this.runNextPromise(); 42 | return this; 43 | }, 44 | 45 | abort: function() { 46 | this.abortCallback(); 47 | this.destroy(); 48 | }, 49 | 50 | init: function() { 51 | set(this, 'promises', Ember.A(get(this, 'promises'))); 52 | this._super(); 53 | } 54 | }); 55 | 56 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/system/object/detectInstance_test.js: -------------------------------------------------------------------------------- 1 | module('system/object/detectInstance'); 2 | 3 | test('detectInstance detects instances correctly', function() { 4 | 5 | var A = Ember.Object.extend(); 6 | var B = A.extend(); 7 | var C = A.extend(); 8 | 9 | var o = Ember.Object.create(), 10 | a = A.create(), 11 | b = B.create(), 12 | c = C.create(); 13 | 14 | ok( Ember.Object.detectInstance(o), 'o is an instance of Ember.Object' ); 15 | ok( Ember.Object.detectInstance(a), 'a is an instance of Ember.Object' ); 16 | ok( Ember.Object.detectInstance(b), 'b is an instance of Ember.Object' ); 17 | ok( Ember.Object.detectInstance(c), 'c is an instance of Ember.Object' ); 18 | 19 | ok( !A.detectInstance(o), 'o is not an instance of A'); 20 | ok( A.detectInstance(a), 'a is an instance of A' ); 21 | ok( A.detectInstance(b), 'b is an instance of A' ); 22 | ok( A.detectInstance(c), 'c is an instance of A' ); 23 | 24 | ok( !B.detectInstance(o), 'o is not an instance of B' ); 25 | ok( !B.detectInstance(a), 'a is not an instance of B' ); 26 | ok( B.detectInstance(b), 'b is an instance of B' ); 27 | ok( !B.detectInstance(c), 'c is not an instance of B' ); 28 | 29 | ok( !C.detectInstance(o), 'o is not an instance of C' ); 30 | ok( !C.detectInstance(a), 'a is not an instance of C' ); 31 | ok( !C.detectInstance(b), 'b is not an instance of C' ); 32 | ok( C.detectInstance(c), 'c is an instance of C' ); 33 | 34 | }); -------------------------------------------------------------------------------- /packages/ember-metal/tests/mixin/required_test.js: -------------------------------------------------------------------------------- 1 | /*globals setup raises */ 2 | 3 | var PartialMixin, FinalMixin, obj; 4 | 5 | module('Module.required', { 6 | setup: function() { 7 | PartialMixin = Ember.Mixin.create({ 8 | foo: Ember.required(), 9 | bar: 'BAR' 10 | }); 11 | 12 | FinalMixin = Ember.Mixin.create({ 13 | foo: 'FOO' 14 | }); 15 | 16 | obj = {}; 17 | }, 18 | 19 | teardown: function() { 20 | PartialMixin = FinalMixin = obj = null; 21 | } 22 | }); 23 | 24 | test('applying a mixin to meet requirement', function() { 25 | FinalMixin.apply(obj); 26 | PartialMixin.apply(obj); 27 | equal(Ember.get(obj, 'foo'), 'FOO', 'should now be defined'); 28 | }); 29 | 30 | test('combined mixins to meet requirement', function() { 31 | Ember.Mixin.create(PartialMixin, FinalMixin).apply(obj); 32 | equal(Ember.get(obj, 'foo'), 'FOO', 'should now be defined'); 33 | }); 34 | 35 | test('merged mixin', function() { 36 | Ember.Mixin.create(PartialMixin, { foo: 'FOO' }).apply(obj); 37 | equal(Ember.get(obj, 'foo'), 'FOO', 'should now be defined'); 38 | }); 39 | 40 | test('define property on source object', function() { 41 | obj.foo = 'FOO'; 42 | PartialMixin.apply(obj); 43 | equal(Ember.get(obj, 'foo'), 'FOO', 'should now be defined'); 44 | }); 45 | 46 | test('using apply', function() { 47 | Ember.mixin(obj, PartialMixin, { foo: 'FOO' }); 48 | equal(Ember.get(obj, 'foo'), 'FOO', 'should now be defined'); 49 | }); 50 | 51 | -------------------------------------------------------------------------------- /packages/ember-runtime/lib/mixins/deferred.js: -------------------------------------------------------------------------------- 1 | var RSVP = requireModule("rsvp"); 2 | 3 | RSVP.async = function(callback, binding) { 4 | Ember.run.schedule('actions', binding, callback); 5 | }; 6 | 7 | /** 8 | @module ember 9 | @submodule ember-runtime 10 | */ 11 | 12 | var get = Ember.get, 13 | slice = Array.prototype.slice; 14 | 15 | /** 16 | @class Deferred 17 | @namespace Ember 18 | @extends Ember.Mixin 19 | */ 20 | Ember.DeferredMixin = Ember.Mixin.create({ 21 | /** 22 | Add handlers to be called when the Deferred object is resolved or rejected. 23 | 24 | @method then 25 | @param {Function} doneCallback a callback function to be called when done 26 | @param {Function} failCallback a callback function to be called when failed 27 | */ 28 | then: function(doneCallback, failCallback) { 29 | var promise = get(this, 'promise'); 30 | return promise.then.apply(promise, arguments); 31 | }, 32 | 33 | /** 34 | Resolve a Deferred object and call any `doneCallbacks` with the given args. 35 | 36 | @method resolve 37 | */ 38 | resolve: function(value) { 39 | get(this, 'promise').resolve(value); 40 | }, 41 | 42 | /** 43 | Reject a Deferred object and call any `failCallbacks` with the given args. 44 | 45 | @method reject 46 | */ 47 | reject: function(value) { 48 | get(this, 'promise').reject(value); 49 | }, 50 | 51 | promise: Ember.computed(function() { 52 | return new RSVP.Promise(); 53 | }) 54 | }); 55 | 56 | -------------------------------------------------------------------------------- /packages/ember-metal/tests/mixin/introspection_test.js: -------------------------------------------------------------------------------- 1 | // NOTE: A previous iteration differentiated between public and private props 2 | // as well as methods vs props. We are just keeping these for testing; the 3 | // current impl doesn't care about the differences as much... 4 | 5 | var PrivateProperty = Ember.Mixin.create({ 6 | _foo: '_FOO' 7 | }); 8 | 9 | var PublicProperty = Ember.Mixin.create({ 10 | foo: 'FOO' 11 | }); 12 | 13 | var PrivateMethod = Ember.Mixin.create({ 14 | _fooMethod: function() {} 15 | }); 16 | 17 | var PublicMethod = Ember.Mixin.create({ 18 | fooMethod: function() {} 19 | }); 20 | 21 | var BarProperties = Ember.Mixin.create({ 22 | _bar: '_BAR', 23 | bar: 'bar' 24 | }); 25 | 26 | var BarMethods = Ember.Mixin.create({ 27 | _barMethod: function() {}, 28 | barMethod: function() {} 29 | }); 30 | 31 | var Combined = Ember.Mixin.create(BarProperties, BarMethods); 32 | 33 | var obj ; 34 | 35 | module('Basic introspection', { 36 | setup: function() { 37 | obj = {}; 38 | Ember.mixin(obj, PrivateProperty, PublicProperty, PrivateMethod, PublicMethod, Combined); 39 | } 40 | }); 41 | 42 | test('Ember.mixins()', function() { 43 | 44 | function mapGuids(ary) { 45 | return Ember.EnumerableUtils.map(ary, function(x) { return Ember.guidFor(x); }); 46 | } 47 | 48 | deepEqual(mapGuids(Ember.Mixin.mixins(obj)), mapGuids([PrivateProperty, PublicProperty, PrivateMethod, PublicMethod, Combined, BarProperties, BarMethods]), 'should return included mixins'); 49 | }); 50 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/system/string/loc_test.js: -------------------------------------------------------------------------------- 1 | var oldString; 2 | 3 | module('Ember.String.loc', { 4 | setup: function() { 5 | oldString = Ember.STRINGS; 6 | Ember.STRINGS = { 7 | '_Hello World': 'Bonjour le monde', 8 | '_Hello %@ %@': 'Bonjour %@ %@', 9 | '_Hello %@# %@#': 'Bonjour %@2 %@1' 10 | }; 11 | }, 12 | 13 | teardown: function() { 14 | Ember.STRINGS = oldString; 15 | } 16 | }); 17 | 18 | test("'_Hello World'.loc() => 'Bonjour le monde'", function() { 19 | equal(Ember.String.loc('_Hello World'), 'Bonjour le monde'); 20 | if (Ember.EXTEND_PROTOTYPES) { 21 | equal('_Hello World'.loc(), 'Bonjour le monde'); 22 | } 23 | }); 24 | 25 | test("'_Hello %@ %@'.loc('John', 'Doe') => 'Bonjour John Doe'", function() { 26 | equal(Ember.String.loc('_Hello %@ %@', ['John', 'Doe']), 'Bonjour John Doe'); 27 | if (Ember.EXTEND_PROTOTYPES) { 28 | equal('_Hello %@ %@'.loc('John', 'Doe'), 'Bonjour John Doe'); 29 | } 30 | }); 31 | 32 | test("'_Hello %@# %@#'.loc('John', 'Doe') => 'Bonjour Doe John'", function() { 33 | equal(Ember.String.loc('_Hello %@# %@#', ['John', 'Doe']), 'Bonjour Doe John'); 34 | if (Ember.EXTEND_PROTOTYPES) { 35 | equal('_Hello %@# %@#'.loc('John', 'Doe'), 'Bonjour Doe John'); 36 | } 37 | }); 38 | 39 | test("'_Not In Strings'.loc() => '_Not In Strings'", function() { 40 | equal(Ember.String.loc('_Not In Strings'), '_Not In Strings'); 41 | if (Ember.EXTEND_PROTOTYPES) { 42 | equal('_Not In Strings'.loc(), '_Not In Strings'); 43 | } 44 | }); 45 | 46 | 47 | -------------------------------------------------------------------------------- /tests/minispade.js: -------------------------------------------------------------------------------- 1 | if (typeof document !== "undefined") { 2 | (function() { 3 | minispade = { 4 | root: null, 5 | modules: {}, 6 | loaded: {}, 7 | 8 | globalEval: function(data) { 9 | if ( data ) { 10 | var ev = "ev"; 11 | var execScript = "execScript"; 12 | 13 | // We use execScript on Internet Explorer 14 | // We use an anonymous function so that context is window 15 | // rather than jQuery in Firefox 16 | ( window[execScript] || function( data ) { 17 | window[ ev+"al" ].call( window, data ); 18 | } )( data ); 19 | } 20 | }, 21 | 22 | require: function(name) { 23 | var loaded = minispade.loaded[name]; 24 | var mod = minispade.modules[name]; 25 | 26 | if (!loaded) { 27 | if (mod) { 28 | minispade.loaded[name] = true; 29 | 30 | if (typeof mod === "string") { 31 | this.globalEval(mod); 32 | } else { 33 | mod(); 34 | } 35 | } else { 36 | if (minispade.root && name.substr(0,minispade.root.length) !== minispade.root) { 37 | return minispade.require(minispade.root+name); 38 | } else { 39 | throw "The module '" + name + "' could not be found"; 40 | } 41 | } 42 | } 43 | 44 | return loaded; 45 | }, 46 | 47 | register: function(name, callback) { 48 | minispade.modules[name] = callback; 49 | } 50 | }; 51 | })(); 52 | } 53 | -------------------------------------------------------------------------------- /packages/ember-handlebars/lib/controls/text_support.js: -------------------------------------------------------------------------------- 1 | require("ember-handlebars/ext"); 2 | require("ember-views/views/view"); 3 | 4 | /** 5 | @module ember 6 | @submodule ember-handlebars 7 | */ 8 | 9 | var get = Ember.get, set = Ember.set; 10 | 11 | /** 12 | Shared mixin used by `Ember.TextField` and `Ember.TextArea`. 13 | 14 | @class TextSupport 15 | @namespace Ember 16 | @extends Ember.Mixin 17 | @private 18 | */ 19 | Ember.TextSupport = Ember.Mixin.create({ 20 | value: "", 21 | 22 | attributeBindings: ['placeholder', 'disabled', 'maxlength', 'tabindex'], 23 | placeholder: null, 24 | disabled: false, 25 | maxlength: null, 26 | 27 | insertNewline: Ember.K, 28 | cancel: Ember.K, 29 | 30 | init: function() { 31 | this._super(); 32 | this.on("focusOut", this, this._elementValueDidChange); 33 | this.on("change", this, this._elementValueDidChange); 34 | this.on("paste", this, this._elementValueDidChange); 35 | this.on("cut", this, this._elementValueDidChange); 36 | this.on("input", this, this._elementValueDidChange); 37 | this.on("keyUp", this, this.interpretKeyEvents); 38 | }, 39 | 40 | interpretKeyEvents: function(event) { 41 | var map = Ember.TextSupport.KEY_EVENTS; 42 | var method = map[event.keyCode]; 43 | 44 | this._elementValueDidChange(); 45 | if (method) { return this[method](event); } 46 | }, 47 | 48 | _elementValueDidChange: function() { 49 | set(this, 'value', this.$().val()); 50 | } 51 | 52 | }); 53 | 54 | Ember.TextSupport.KEY_EVENTS = { 55 | 13: 'insertNewline', 56 | 27: 'cancel' 57 | }; 58 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/system/string/dasherize.js: -------------------------------------------------------------------------------- 1 | module('Ember.String.dasherize'); 2 | 3 | test("dasherize normal string", function() { 4 | deepEqual(Ember.String.dasherize('my favorite items'), 'my-favorite-items'); 5 | if (Ember.EXTEND_PROTOTYPES) { 6 | deepEqual('my favorite items'.dasherize(), 'my-favorite-items'); 7 | } 8 | }); 9 | 10 | test("does nothing with dasherized string", function() { 11 | deepEqual(Ember.String.dasherize('css-class-name'), 'css-class-name'); 12 | if (Ember.EXTEND_PROTOTYPES) { 13 | deepEqual('css-class-name'.dasherize(), 'css-class-name'); 14 | } 15 | }); 16 | 17 | test("dasherize underscored string", function() { 18 | deepEqual(Ember.String.dasherize('action_name'), 'action-name'); 19 | if (Ember.EXTEND_PROTOTYPES) { 20 | deepEqual('action_name'.dasherize(), 'action-name'); 21 | } 22 | }); 23 | 24 | test("dasherize camelcased string", function() { 25 | deepEqual(Ember.String.dasherize('innerHTML'), 'inner-html'); 26 | if (Ember.EXTEND_PROTOTYPES) { 27 | deepEqual('innerHTML'.dasherize(), 'inner-html'); 28 | } 29 | }); 30 | 31 | test("after call with the same passed value take object from cache", function() { 32 | var res = Ember.String.dasherize('innerHTML'); 33 | 34 | var callCount = 0; 35 | var decamelize = Ember.String.decamelize; 36 | 37 | try { 38 | Ember.String.decamelize = function() { 39 | callCount++; 40 | }; 41 | Ember.String.dasherize('innerHTML'); 42 | } finally { 43 | Ember.String.decamelize = decamelize; 44 | } 45 | 46 | equal(callCount, 0, "decamelize is not called again"); 47 | }); 48 | -------------------------------------------------------------------------------- /packages/ember-metal/tests/run_loop/once_test.js: -------------------------------------------------------------------------------- 1 | module('system/run_loop/once_test'); 2 | 3 | test('calling invokeOnce more than once invokes only once', function() { 4 | 5 | var count = 0; 6 | Ember.run(function() { 7 | var F = function() { count++; }; 8 | Ember.run.once(F); 9 | Ember.run.once(F); 10 | Ember.run.once(F); 11 | }); 12 | 13 | equal(count, 1, 'should have invoked once'); 14 | }); 15 | 16 | test('should differentiate based on target', function() { 17 | 18 | var A = { count: 0 }, B = { count: 0 }; 19 | Ember.run(function() { 20 | var F = function() { this.count++; }; 21 | Ember.run.once(A, F); 22 | Ember.run.once(B, F); 23 | Ember.run.once(A, F); 24 | Ember.run.once(B, F); 25 | }); 26 | 27 | equal(A.count, 1, 'should have invoked once on A'); 28 | equal(B.count, 1, 'should have invoked once on B'); 29 | }); 30 | 31 | 32 | test('should ignore other arguments - replacing previous ones', function() { 33 | 34 | var A = { count: 0 }, B = { count: 0 }; 35 | Ember.run(function() { 36 | var F = function(amt) { this.count += amt; }; 37 | Ember.run.once(A, F, 10); 38 | Ember.run.once(B, F, 20); 39 | Ember.run.once(A, F, 30); 40 | Ember.run.once(B, F, 40); 41 | }); 42 | 43 | equal(A.count, 30, 'should have invoked once on A'); 44 | equal(B.count, 40, 'should have invoked once on B'); 45 | }); 46 | 47 | test('should be inside of a runloop when running', function() { 48 | 49 | Ember.run(function() { 50 | Ember.run.once(function() { 51 | ok(!!Ember.run.currentRunLoop, 'should have a runloop'); 52 | }); 53 | }); 54 | }); 55 | 56 | 57 | -------------------------------------------------------------------------------- /packages/ember-old-router/lib/location/api.js: -------------------------------------------------------------------------------- 1 | /** 2 | @module ember 3 | @submodule ember-old-router 4 | */ 5 | 6 | var get = Ember.get, set = Ember.set; 7 | 8 | /* 9 | This file implements the `location` API used by Ember's router. 10 | 11 | That API is: 12 | 13 | getURL: returns the current URL 14 | setURL(path): sets the current URL 15 | onUpdateURL(callback): triggers the callback when the URL changes 16 | formatURL(url): formats `url` to be placed into `href` attribute 17 | 18 | Calling setURL will not trigger onUpdateURL callbacks. 19 | 20 | TODO: This should perhaps be moved so that it's visible in the doc output. 21 | */ 22 | 23 | /** 24 | Ember.Location returns an instance of the correct implementation of 25 | the `location` API. 26 | 27 | You can pass it a `implementation` (`hash`, `history`, `none`) to force a 28 | particular implementation. 29 | 30 | @class Location 31 | @namespace Ember 32 | @static 33 | */ 34 | Ember.Location = { 35 | create: function(options) { 36 | var implementation = options && options.implementation; 37 | Ember.assert("Ember.Location.create: you must specify a 'implementation' option", !!implementation); 38 | 39 | var implementationClass = this.implementations[implementation]; 40 | Ember.assert("Ember.Location.create: " + implementation + " is not a valid implementation", !!implementationClass); 41 | 42 | return implementationClass.create.apply(implementationClass, arguments); 43 | }, 44 | 45 | registerImplementation: function(name, implementation) { 46 | this.implementations[name] = implementation; 47 | }, 48 | 49 | implementations: {} 50 | }; 51 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/mixins/mutable_array_test.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/~tests/suites/mutable_array'); 2 | 3 | /* 4 | Implement a basic fake mutable array. This validates that any non-native 5 | enumerable can impl this API. 6 | */ 7 | var TestMutableArray = Ember.Object.extend(Ember.MutableArray, { 8 | 9 | _content: null, 10 | 11 | init: function(ary) { 12 | this._content = Ember.A(ary || []); 13 | }, 14 | 15 | replace: function(idx, amt, objects) { 16 | 17 | var args = objects ? objects.slice() : [], 18 | removeAmt = amt, 19 | addAmt = args.length; 20 | 21 | this.arrayContentWillChange(idx, removeAmt, addAmt); 22 | 23 | args.unshift(amt); 24 | args.unshift(idx); 25 | this._content.splice.apply(this._content, args); 26 | this.arrayContentDidChange(idx, removeAmt, addAmt); 27 | return this; 28 | }, 29 | 30 | objectAt: function(idx) { 31 | return this._content[idx]; 32 | }, 33 | 34 | length: Ember.computed(function() { 35 | return this._content.length; 36 | }), 37 | 38 | slice: function() { 39 | return this._content.slice(); 40 | } 41 | 42 | }); 43 | 44 | 45 | Ember.MutableArrayTests.extend({ 46 | 47 | name: 'Basic Mutable Array', 48 | 49 | newObject: function(ary) { 50 | ary = ary ? ary.slice() : this.newFixture(3); 51 | return new TestMutableArray(ary); 52 | }, 53 | 54 | // allows for testing of the basic enumerable after an internal mutation 55 | mutate: function(obj) { 56 | obj.addObject(this.getFixture(1)[0]); 57 | }, 58 | 59 | toArray: function(obj) { 60 | return obj.slice(); 61 | } 62 | 63 | }).run(); 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/legacy_1x/mixins/observable/observersForKey_test.js: -------------------------------------------------------------------------------- 1 | /* 2 | NOTE: This test is adapted from the 1.x series of unit tests. The tests 3 | are the same except for places where we intend to break the API we instead 4 | validate that we warn the developer appropriately. 5 | 6 | CHANGES FROM 1.6: 7 | 8 | * Create ObservableObject which includes Ember.Observable 9 | */ 10 | 11 | // ======================================================================== 12 | // Ember.Observable Tests 13 | // ======================================================================== 14 | /*globals module test ok isObj equals expects Namespace */ 15 | 16 | var ObservableObject = Ember.Object.extend(Ember.Observable); 17 | 18 | // .......................................................... 19 | // GET() 20 | // 21 | 22 | module("object.observesForKey()"); 23 | 24 | test("should get observers", function() { 25 | var o1 = ObservableObject.create({ foo: 100 }), 26 | o2 = ObservableObject.create({ func: function() {} }), 27 | o3 = ObservableObject.create({ func: function() {} }), 28 | observers = null; 29 | 30 | equal(Ember.get(o1.observersForKey('foo'), 'length'), 0, "o1.observersForKey should return empty array"); 31 | 32 | o1.addObserver('foo', o2, o2.func); 33 | o1.addObserver('foo', o3, o3.func); 34 | 35 | observers = o1.observersForKey('foo'); 36 | 37 | equal(Ember.get(observers, 'length'), 2, "o2.observersForKey should return an array with length 2"); 38 | equal(observers[0][0], o2, "first item in observers array should be o2"); 39 | equal(observers[1][0], o3, "second item in observers array should be o3"); 40 | }); 41 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/system/object/extend_test.js: -------------------------------------------------------------------------------- 1 | module('Ember.Object.extend'); 2 | 3 | test('Basic extend', function() { 4 | var SomeClass = Ember.Object.extend({ foo: 'BAR' }); 5 | ok(SomeClass.isClass, "A class has isClass of true"); 6 | var obj = new SomeClass(); 7 | equal(obj.foo, 'BAR'); 8 | ok(obj.isInstance, "An instance of a class has isInstance of true"); 9 | }); 10 | 11 | test('Sub-subclass', function() { 12 | var SomeClass = Ember.Object.extend({ foo: 'BAR' }); 13 | var AnotherClass = SomeClass.extend({ bar: 'FOO' }); 14 | var obj = new AnotherClass(); 15 | equal(obj.foo, 'BAR'); 16 | equal(obj.bar, 'FOO'); 17 | }); 18 | 19 | test('Overriding a method several layers deep', function() { 20 | var SomeClass = Ember.Object.extend({ 21 | fooCnt: 0, 22 | foo: function() { this.fooCnt++; }, 23 | 24 | barCnt: 0, 25 | bar: function() { this.barCnt++; } 26 | }); 27 | 28 | var AnotherClass = SomeClass.extend({ 29 | barCnt: 0, 30 | bar: function() { this.barCnt++; this._super(); } 31 | }); 32 | 33 | var FinalClass = AnotherClass.extend({ 34 | fooCnt: 0, 35 | foo: function() { this.fooCnt++; this._super(); } 36 | }); 37 | 38 | var obj = new FinalClass(); 39 | obj.foo(); 40 | obj.bar(); 41 | equal(obj.fooCnt, 2, 'should invoke both'); 42 | equal(obj.barCnt, 2, 'should invoke both'); 43 | 44 | // Try overriding on create also 45 | obj = FinalClass.createWithMixins({ 46 | foo: function() { this.fooCnt++; this._super(); } 47 | }); 48 | 49 | obj.foo(); 50 | obj.bar(); 51 | equal(obj.fooCnt, 3, 'should invoke final as well'); 52 | equal(obj.barCnt, 2, 'should invoke both'); 53 | }); 54 | 55 | 56 | -------------------------------------------------------------------------------- /packages/ember-views/tests/views/view/nearest_of_type_test.js: -------------------------------------------------------------------------------- 1 | var set = Ember.set, get = Ember.get; 2 | 3 | module("Ember.View#nearest*"); 4 | 5 | (function() { 6 | var Mixin = Ember.Mixin.create({}), 7 | Parent = Ember.View.extend(Mixin, { 8 | render: function(buffer) { 9 | this.appendChild( Ember.View.create() ); 10 | } 11 | }); 12 | 13 | test("nearestOfType should find the closest view by view class", function() { 14 | var parent, child; 15 | 16 | Ember.run(function() { 17 | parent = Parent.create(); 18 | parent.appendTo('#qunit-fixture'); 19 | }); 20 | 21 | child = parent.get('childViews')[0]; 22 | equal(child.nearestOfType(Parent), parent, "finds closest view in the hierarchy by class"); 23 | }); 24 | 25 | test("nearestOfType should find the closest view by mixin", function() { 26 | var parent, child; 27 | 28 | Ember.run(function() { 29 | parent = Parent.create(); 30 | parent.appendTo('#qunit-fixture'); 31 | }); 32 | 33 | child = parent.get('childViews')[0]; 34 | equal(child.nearestOfType(Mixin), parent, "finds closest view in the hierarchy by class"); 35 | }); 36 | 37 | test("nearestWithProperty should search immediate parent", function(){ 38 | var childView; 39 | 40 | var view = Ember.View.create({ 41 | myProp: true, 42 | 43 | render: function(buffer) { 44 | this.appendChild(Ember.View.create()); 45 | } 46 | }); 47 | 48 | Ember.run(function() { 49 | view.appendTo('#qunit-fixture'); 50 | }); 51 | 52 | childView = view.get('childViews')[0]; 53 | equal(childView.nearestWithProperty('myProp'), view); 54 | 55 | }); 56 | 57 | }()); 58 | -------------------------------------------------------------------------------- /packages/ember-metal/tests/accessors/getPath_test.js: -------------------------------------------------------------------------------- 1 | /*globals Foo:true $foo:true */ 2 | 3 | var obj, moduleOpts = { 4 | setup: function() { 5 | obj = { 6 | foo: { 7 | bar: { 8 | baz: { biff: 'BIFF' } 9 | } 10 | } 11 | 12 | }; 13 | 14 | Foo = { 15 | bar: { 16 | baz: { biff: 'FooBiff' } 17 | } 18 | }; 19 | 20 | $foo = { 21 | bar: { 22 | baz: { biff: '$FOOBIFF' } 23 | } 24 | }; 25 | }, 26 | 27 | teardown: function() { 28 | obj = null; 29 | Foo = null; 30 | $foo = null; 31 | } 32 | }; 33 | 34 | module('Ember.get with path', moduleOpts); 35 | 36 | // .......................................................... 37 | // LOCAL PATHS 38 | // 39 | 40 | test('[obj, foo] -> obj.foo', function() { 41 | deepEqual(Ember.get(obj, 'foo'), obj.foo); 42 | }); 43 | 44 | test('[obj, foo.bar] -> obj.foo.bar', function() { 45 | deepEqual(Ember.get(obj, 'foo.bar'), obj.foo.bar); 46 | }); 47 | 48 | test('[obj, this.foo] -> obj.foo', function() { 49 | deepEqual(Ember.get(obj, 'this.foo'), obj.foo); 50 | }); 51 | 52 | test('[obj, this.foo.bar] -> obj.foo.bar', function() { 53 | deepEqual(Ember.get(obj, 'this.foo.bar'), obj.foo.bar); 54 | }); 55 | 56 | test('[obj, this.Foo.bar] -> (null)', function() { 57 | deepEqual(Ember.get(obj, 'this.Foo.bar'), undefined); 58 | }); 59 | 60 | // .......................................................... 61 | // NO TARGET 62 | // 63 | 64 | test('[null, Foo] -> Foo', function() { 65 | deepEqual(Ember.get('Foo'), Foo); 66 | }); 67 | 68 | test('[null, Foo.bar] -> Foo.bar', function() { 69 | deepEqual(Ember.get('Foo.bar'), Foo.bar); 70 | }); 71 | 72 | -------------------------------------------------------------------------------- /packages/ember-handlebars/tests/helpers/if_unless_test.js: -------------------------------------------------------------------------------- 1 | var appendView = function(view) { 2 | Ember.run(function() { view.appendTo('#qunit-fixture'); }); 3 | }; 4 | 5 | var compile = Ember.Handlebars.compile; 6 | 7 | var view; 8 | 9 | module("Handlebars {{#if}} and {{#unless}} helpers", { 10 | teardown: function() { 11 | Ember.run(function(){ 12 | if (view) { 13 | view.destroy(); 14 | } 15 | }); 16 | } 17 | }); 18 | 19 | test("unless should keep the current context (#784)", function() { 20 | view = Ember.View.create({ 21 | o: Ember.Object.create({foo: '42'}), 22 | 23 | template: compile('{{#with view.o}}{{#view Ember.View}}{{#unless view.doesNotExist}}foo: {{foo}}{{/unless}}{{/view}}{{/with}}') 24 | }); 25 | 26 | appendView(view); 27 | 28 | equal(view.$().text(), 'foo: 42'); 29 | }); 30 | 31 | test("The `if` helper tests for `isTruthy` if available", function() { 32 | view = Ember.View.create({ 33 | truthy: Ember.Object.create({ isTruthy: true }), 34 | falsy: Ember.Object.create({ isTruthy: false }), 35 | 36 | template: compile('{{#if view.truthy}}Yep{{/if}}{{#if view.falsy}}Nope{{/if}}') 37 | }); 38 | 39 | appendView(view); 40 | 41 | equal(view.$().text(), 'Yep'); 42 | }); 43 | 44 | test("The `if` helper does not print the contents for an object proxy without content", function() { 45 | view = Ember.View.create({ 46 | truthy: Ember.ObjectProxy.create({ content: {} }), 47 | falsy: Ember.ObjectProxy.create({ content: null }), 48 | 49 | template: compile('{{#if view.truthy}}Yep{{/if}}{{#if view.falsy}}Nope{{/if}}') 50 | }); 51 | 52 | appendView(view); 53 | 54 | equal(view.$().text(), 'Yep'); 55 | }); 56 | -------------------------------------------------------------------------------- /packages/ember-metal/tests/run_loop/schedule_test.js: -------------------------------------------------------------------------------- 1 | module('system/run_loop/schedule_test'); 2 | 3 | test('scheduling item in queue should defer until finished', function() { 4 | var cnt = 0; 5 | 6 | Ember.run(function() { 7 | Ember.run.schedule('actions', function() { cnt++; }); 8 | Ember.run.schedule('actions', function() { cnt++; }); 9 | equal(cnt, 0, 'should not run action yet') ; 10 | }); 11 | 12 | equal(cnt, 2, 'should flush actions now'); 13 | 14 | }); 15 | 16 | test('nested runs should queue each phase independently', function() { 17 | var cnt = 0; 18 | 19 | Ember.run(function() { 20 | Ember.run.schedule('actions', function() { cnt++; }); 21 | equal(cnt, 0, 'should not run action yet') ; 22 | 23 | Ember.run(function() { 24 | Ember.run.schedule('actions', function() { cnt++; }); 25 | }); 26 | equal(cnt, 1, 'should not run action yet') ; 27 | 28 | }); 29 | 30 | equal(cnt, 2, 'should flush actions now'); 31 | 32 | }); 33 | 34 | test('prior queues should be flushed before moving on to next queue', function() { 35 | var order = []; 36 | 37 | Ember.run(function() { 38 | Ember.run.schedule('sync', function() { 39 | order.push('sync'); 40 | }); 41 | Ember.run.schedule('actions', function() { 42 | order.push('actions'); 43 | Ember.run.schedule('actions', function() { 44 | order.push('actions'); 45 | }); 46 | Ember.run.schedule('sync', function() { 47 | order.push('sync'); 48 | }); 49 | }); 50 | Ember.run.schedule('timers', function() { 51 | order.push('timers'); 52 | }); 53 | }); 54 | 55 | deepEqual(order, ['sync', 'actions', 'sync', 'actions', 'timers']); 56 | }); 57 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/system/object/destroy_test.js: -------------------------------------------------------------------------------- 1 | /*globals raises TestObject */ 2 | 3 | module('ember-runtime/system/object/destroy_test'); 4 | 5 | test("should schedule objects to be destroyed at the end of the run loop", function() { 6 | var obj = Ember.Object.create(); 7 | 8 | Ember.run(function() { 9 | var meta; 10 | obj.destroy(); 11 | meta = Ember.meta(obj); 12 | ok(meta, "object is not destroyed immediately"); 13 | }); 14 | 15 | ok(obj.get('isDestroyed'), "object is destroyed after run loop finishes"); 16 | }); 17 | 18 | test("should raise an exception when modifying watched properties on a destroyed object", function() { 19 | if (Ember.platform.hasAccessors) { 20 | var obj = Ember.Object.createWithMixins({ 21 | foo: "bar", 22 | fooDidChange: Ember.observer(function() { }, 'foo') 23 | }); 24 | 25 | Ember.run(function() { 26 | obj.destroy(); 27 | }); 28 | 29 | raises(function() { 30 | Ember.set(obj, 'foo', 'baz'); 31 | }, Error, "raises an exception"); 32 | } else { 33 | expect(0); 34 | } 35 | }); 36 | 37 | test("observers should not fire after an object has been destroyed", function() { 38 | var count = 0; 39 | var obj = Ember.Object.createWithMixins({ 40 | fooDidChange: Ember.observer(function() { 41 | count++; 42 | }, 'foo') 43 | }); 44 | 45 | obj.set('foo', 'bar'); 46 | 47 | equal(count, 1, "observer was fired once"); 48 | 49 | Ember.run(function() { 50 | Ember.beginPropertyChanges(); 51 | obj.set('foo', 'quux'); 52 | obj.destroy(); 53 | Ember.endPropertyChanges(); 54 | }); 55 | 56 | equal(count, 1, "observer was not called after object was destroyed"); 57 | }); 58 | -------------------------------------------------------------------------------- /packages/ember-routing/lib/location/api.js: -------------------------------------------------------------------------------- 1 | /** 2 | @module ember 3 | @submodule ember-routing 4 | */ 5 | 6 | var get = Ember.get, set = Ember.set; 7 | 8 | /* 9 | This file implements the `location` API used by Ember's router. 10 | 11 | That API is: 12 | 13 | getURL: returns the current URL 14 | setURL(path): sets the current URL 15 | replaceURL(path): replace the current URL (optional) 16 | onUpdateURL(callback): triggers the callback when the URL changes 17 | formatURL(url): formats `url` to be placed into `href` attribute 18 | 19 | Calling setURL or replaceURL will not trigger onUpdateURL callbacks. 20 | 21 | TODO: This should perhaps be moved so that it's visible in the doc output. 22 | */ 23 | 24 | /** 25 | Ember.Location returns an instance of the correct implementation of 26 | the `location` API. 27 | 28 | You can pass it a `implementation` ('hash', 'history', 'none') to force a 29 | particular implementation. 30 | 31 | @class Location 32 | @namespace Ember 33 | @static 34 | */ 35 | Ember.Location = { 36 | create: function(options) { 37 | var implementation = options && options.implementation; 38 | Ember.assert("Ember.Location.create: you must specify a 'implementation' option", !!implementation); 39 | 40 | var implementationClass = this.implementations[implementation]; 41 | Ember.assert("Ember.Location.create: " + implementation + " is not a valid implementation", !!implementationClass); 42 | 43 | return implementationClass.create.apply(implementationClass, arguments); 44 | }, 45 | 46 | registerImplementation: function(name, implementation) { 47 | this.implementations[name] = implementation; 48 | }, 49 | 50 | implementations: {} 51 | }; 52 | -------------------------------------------------------------------------------- /benchmarks/suites/views/each_view.js: -------------------------------------------------------------------------------- 1 | /*globals App:true Ember before after bench*/ 2 | 3 | // shut up jshint 4 | var view; 5 | 6 | before(function() { 7 | var view; 8 | window.App = Ember.Namespace.create(); 9 | 10 | var template = 11 | "" + 12 | " " + 13 | " " + 14 | " " + 15 | " " + 16 | " " + 17 | " " + 18 | " " + 19 | " " + 20 | " {{#each App.list}}" + 21 | ' {{#view Em.View tagName="tr"}}' + 22 | " " + 23 | " " + 24 | " " + 25 | " " + 26 | " " + 27 | " {{/view}}" + 28 | " {{/each}}" + 29 | " " + 30 | "
IDDateTagSpeedLength
{{id}}{{dateIn}}{{tag}}{{speed}}{{length}}
"; 31 | 32 | function newContent() { 33 | var content = [], i; 34 | for (i = 0; i < 10; i++) { 35 | content.push({ 36 | id: Math.round(Math.random() * 1000), 37 | dateIn: new Date(), 38 | tag: "TAG-0" + i, 39 | speed: Math.random() * 100, 40 | length: Math.random() * 1000 41 | }); 42 | } 43 | return content; 44 | } 45 | 46 | App.list = newContent(); 47 | 48 | App.View = Ember.View.extend({ 49 | template: Ember.Handlebars.compile(template) 50 | }); 51 | 52 | Ember.run(function() { 53 | view = App.View.create().append(); 54 | }); 55 | }); 56 | 57 | after(function() { 58 | view.destroy(); 59 | }); 60 | 61 | bench("creating and appending a new view with each", function() { 62 | Ember.run(function() { 63 | view = App.View.create().append(); 64 | }); 65 | }); 66 | 67 | -------------------------------------------------------------------------------- /packages/ember-views/tests/views/view/init_test.js: -------------------------------------------------------------------------------- 1 | /*global TestApp:true*/ 2 | var set = Ember.set, get = Ember.get; 3 | 4 | var originalLookup = Ember.lookup, lookup; 5 | 6 | module("Ember.View.create", { 7 | setup: function() { 8 | Ember.lookup = lookup = {}; 9 | }, 10 | teardown: function() { 11 | Ember.lookup = originalLookup; 12 | } 13 | }); 14 | 15 | test("registers view in the global views hash using layerId for event targeted", function() { 16 | var v = Ember.View.create(); 17 | equal(Ember.View.views[get(v, 'elementId')], v, 'registers view'); 18 | }); 19 | 20 | test("registers itself with a controller if the viewController property is set", function() { 21 | lookup.TestApp = {}; 22 | lookup.TestApp.fooController = Ember.Object.create(); 23 | 24 | var v = Ember.View.create({ 25 | viewController: 'TestApp.fooController' 26 | }); 27 | 28 | equal(lookup.TestApp.fooController.get('view'), v, "sets the view property of the controller"); 29 | }); 30 | 31 | module("Ember.View.createWithMixins"); 32 | 33 | test("should warn if a non-array is used for classNames", function() { 34 | raises(function() { 35 | Ember.View.createWithMixins({ 36 | classNames: Ember.computed(function() { 37 | return ['className']; 38 | }).volatile() 39 | }); 40 | }, /Only arrays are allowed/i, 'should warn that an array was not used'); 41 | }); 42 | 43 | test("should warn if a non-array is used for classNamesBindings", function() { 44 | raises(function() { 45 | Ember.View.createWithMixins({ 46 | classNameBindings: Ember.computed(function() { 47 | return ['className']; 48 | }).volatile() 49 | }); 50 | }, /Only arrays are allowed/i, 'should warn that an array was not used'); 51 | }); 52 | -------------------------------------------------------------------------------- /packages/ember-routing/tests/system/controller_test.js: -------------------------------------------------------------------------------- 1 | module("Controller dependencies"); 2 | 3 | test("If a controller specifies a dependency, it is available to `controllerFor`", function() { 4 | var container = new Ember.Container(); 5 | 6 | container.register('controller', 'post', Ember.Controller.extend({ 7 | needs: 'posts', 8 | 9 | postsController: Ember.computed(function() { 10 | return this.controllerFor('posts'); 11 | }) 12 | })); 13 | 14 | container.register('controller', 'posts', Ember.Controller.extend()); 15 | 16 | var postController = container.lookup('controller:post'), 17 | postsController = container.lookup('controller:posts'); 18 | 19 | equal(postsController, postController.get('postsController'), "Getting dependency controllers work"); 20 | }); 21 | 22 | test("If a controller specifies a dependency, it is accessible", function() { 23 | var container = new Ember.Container(); 24 | 25 | container.register('controller', 'post', Ember.Controller.extend({ 26 | needs: 'posts' 27 | })); 28 | 29 | container.register('controller', 'posts', Ember.Controller.extend()); 30 | 31 | var postController = container.lookup('controller:post'), 32 | postsController = container.lookup('controller:posts'); 33 | 34 | equal(postsController, postController.get('controllers.posts'), "controller.posts must be auto synthesized"); 35 | }); 36 | 37 | test("If a controller specifies an unavailable dependency, it raises", function() { 38 | var container = new Ember.Container(); 39 | 40 | container.register('controller', 'post', Ember.Controller.extend({ 41 | needs: 'posts' 42 | })); 43 | 44 | raises(function() { 45 | container.lookup('controller:post'); 46 | }, /controller:posts/); 47 | }); 48 | 49 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/props_helper.js: -------------------------------------------------------------------------------- 1 | // used by unit tests to test both accessor mode and non-accessor mode 2 | testBoth = function(testname, callback) { 3 | 4 | function emberget(x,y) { return Ember.get(x,y); } 5 | function emberset(x,y,z) { return Ember.set(x,y,z); } 6 | function aget(x,y) { return x[y]; } 7 | function aset(x,y,z) { return (x[y] = z); } 8 | 9 | test(testname+' using Ember.get()/Ember.set()', function() { 10 | callback(emberget, emberset); 11 | }); 12 | 13 | test(testname+' using accessors', function() { 14 | if (Ember.USES_ACCESSORS) callback(aget, aset); 15 | else ok('SKIPPING ACCESSORS'); 16 | }); 17 | }; 18 | 19 | testWithDefault = function(testname, callback) { 20 | function get(x,y) { return x.get(y); } 21 | function emberget(x,y) { return Ember.get(x,y); } 22 | function embergetwithdefault(x,y,z) { return Ember.getWithDefault(x,y,z); } 23 | function getwithdefault(x,y,z) { return x.getWithDefault(y,z); } 24 | function emberset(x,y,z) { return Ember.set(x,y,z); } 25 | function aget(x,y) { return x[y]; } 26 | function aset(x,y,z) { return (x[y] = z); } 27 | 28 | test(testname+' using obj.get()', function() { 29 | callback(emberget, emberset); 30 | }); 31 | 32 | test(testname+' using obj.getWithDefault()', function() { 33 | callback(getwithdefault, emberset); 34 | }); 35 | 36 | test(testname+' using Ember.get()', function() { 37 | callback(emberget, emberset); 38 | }); 39 | 40 | test(testname+' using Ember.getWithDefault()', function() { 41 | callback(embergetwithdefault, emberset); 42 | }); 43 | 44 | test(testname+' using accessors', function() { 45 | if (Ember.USES_ACCESSORS) callback(aget, aset); 46 | else ok('SKIPPING ACCESSORS'); 47 | }); 48 | }; 49 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/system/string/capitalize.js: -------------------------------------------------------------------------------- 1 | // ========================================================================== 2 | // Project: Ember Runtime 3 | // Copyright: ©2006-2011 Strobe Inc. and contributors. 4 | // ©2008-2011 Apple Inc. All rights reserved. 5 | // License: Licensed under MIT license (see license.js) 6 | // ========================================================================== 7 | 8 | module('Ember.String.capitalize'); 9 | 10 | test("capitalize normal string", function() { 11 | deepEqual(Ember.String.capitalize('my favorite items'), 'My favorite items'); 12 | if (Ember.EXTEND_PROTOTYPES) { 13 | deepEqual('my favorite items'.capitalize(), 'My favorite items'); 14 | } 15 | }); 16 | 17 | test("capitalize dasherized string", function() { 18 | deepEqual(Ember.String.capitalize('css-class-name'), 'Css-class-name'); 19 | if (Ember.EXTEND_PROTOTYPES) { 20 | deepEqual('css-class-name'.capitalize(), 'Css-class-name'); 21 | } 22 | }); 23 | 24 | test("capitalize underscored string", function() { 25 | deepEqual(Ember.String.capitalize('action_name'), 'Action_name'); 26 | if (Ember.EXTEND_PROTOTYPES) { 27 | deepEqual('action_name'.capitalize(), 'Action_name'); 28 | } 29 | }); 30 | 31 | test("capitalize camelcased string", function() { 32 | deepEqual(Ember.String.capitalize('innerHTML'), 'InnerHTML'); 33 | if (Ember.EXTEND_PROTOTYPES) { 34 | deepEqual('innerHTML'.capitalize(), 'InnerHTML'); 35 | } 36 | }); 37 | 38 | test("does nothing with capitalized string", function() { 39 | deepEqual(Ember.String.capitalize('Capitalized string'), 'Capitalized string'); 40 | if (Ember.EXTEND_PROTOTYPES) { 41 | deepEqual('Capitalized string'.capitalize(), 'Capitalized string'); 42 | } 43 | }); 44 | 45 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/core/isEqual_test.js: -------------------------------------------------------------------------------- 1 | // ======================================================================== 2 | // Ember.isEqual Tests 3 | // ======================================================================== 4 | /*globals module test */ 5 | 6 | module("isEqual"); 7 | 8 | test("undefined and null", function() { 9 | ok( Ember.isEqual(undefined, undefined), "undefined is equal to undefined" ); 10 | ok( !Ember.isEqual(undefined, null), "undefined is not equal to null" ); 11 | ok( Ember.isEqual(null, null), "null is equal to null" ); 12 | ok( !Ember.isEqual(null, undefined), "null is not equal to undefined" ); 13 | }); 14 | 15 | test("strings should be equal",function(){ 16 | ok( !Ember.isEqual("Hello", "Hi"), "different Strings are unequal" ); 17 | ok( Ember.isEqual("Hello", "Hello"), "same Strings are equal" ); 18 | }); 19 | 20 | test("numericals should be equal",function(){ 21 | ok( Ember.isEqual(24, 24), "same numbers are equal" ); 22 | ok( !Ember.isEqual(24, 21), "different numbers are inequal" ); 23 | }); 24 | 25 | test("array should be equal",function(){ 26 | // NOTE: We don't test for array contents -- that would be too expensive. 27 | ok( !Ember.isEqual( [1,2], [1,2] ), 'two array instances with the same values should not be equal' ); 28 | ok( !Ember.isEqual( [1,2], [1] ), 'two array instances with different values should not be equal' ); 29 | }); 30 | 31 | test("first object implements isEqual should use it", function() { 32 | ok(Ember.isEqual({ isEqual: function() { return true; } }, null), 'should return true always'); 33 | 34 | var obj = { isEqual: function() { return false; } }; 35 | equal(Ember.isEqual(obj, obj), false, 'should return false because isEqual returns false'); 36 | }); 37 | 38 | 39 | -------------------------------------------------------------------------------- /packages/ember-routing/lib/helpers/render.js: -------------------------------------------------------------------------------- 1 | /** 2 | @module ember 3 | @submodule ember-routing 4 | */ 5 | 6 | var get = Ember.get, set = Ember.set; 7 | 8 | require('ember-handlebars/helpers/view'); 9 | 10 | Ember.onLoad('Ember.Handlebars', function(Handlebars) { 11 | 12 | Ember.Handlebars.registerHelper('render', function(name, context, options) { 13 | Ember.assert("You must pass a template to render", arguments.length >= 2); 14 | var container, router, controller, view; 15 | 16 | if (arguments.length === 2) { 17 | options = context; 18 | context = undefined; 19 | } 20 | 21 | if (typeof context === 'string') { 22 | context = Ember.Handlebars.get(options.contexts[1], context, options); 23 | } 24 | 25 | name = name.replace(/\//g, '.'); 26 | container = options.data.keywords.controller.container; 27 | router = container.lookup('router:main'); 28 | 29 | Ember.assert("This view is already rendered", !router || !router._lookupActiveView(name)); 30 | 31 | view = container.lookup('view:' + name) || container.lookup('view:default'); 32 | 33 | if (controller = options.hash.controller) { 34 | controller = container.lookup('controller:' + controller); 35 | } else { 36 | controller = Ember.controllerFor(container, name, context); 37 | } 38 | 39 | if (controller && context) { 40 | controller.set('model', context); 41 | } 42 | 43 | controller.set('target', options.data.keywords.controller); 44 | 45 | options.hash.viewName = Ember.String.camelize(name); 46 | options.hash.template = container.lookup('template:' + name); 47 | options.hash.controller = controller; 48 | 49 | if (router) { 50 | router._connectActiveView(name, view); 51 | } 52 | 53 | Ember.Handlebars.helpers.view.call(this, view, options); 54 | }); 55 | 56 | }); 57 | -------------------------------------------------------------------------------- /packages/ember-old-router/lib/route_matcher.js: -------------------------------------------------------------------------------- 1 | var escapeForRegex = function(text) { 2 | return text.replace(/[\-\[\]{}()*+?.,\\\^\$|#\s]/g, "\\$&"); 3 | }; 4 | 5 | /** 6 | @class _RouteMatcher 7 | @namespace Ember 8 | @private 9 | @extends Ember.Object 10 | */ 11 | Ember._RouteMatcher = Ember.Object.extend({ 12 | state: null, 13 | 14 | init: function() { 15 | var route = this.route, 16 | identifiers = [], 17 | count = 1, 18 | escaped; 19 | 20 | // Strip off leading slash if present 21 | if (route.charAt(0) === '/') { 22 | route = this.route = route.substr(1); 23 | } 24 | 25 | escaped = escapeForRegex(route); 26 | 27 | var regex = escaped.replace(/(:|(?:\\\*))([a-z_]+)(?=$|\/)/gi, function(match, type, id) { 28 | identifiers[count++] = id; 29 | switch (type) { 30 | case ":": 31 | return "([^/]+)"; 32 | case "\\*": 33 | return "(.+)"; 34 | } 35 | }); 36 | 37 | this.identifiers = identifiers; 38 | this.regex = new RegExp("^/?" + regex); 39 | }, 40 | 41 | match: function(path) { 42 | var match = path.match(this.regex); 43 | 44 | if (match) { 45 | var identifiers = this.identifiers, 46 | hash = {}; 47 | 48 | for (var i=1, l=identifiers.length; i 0 ? hash : null 55 | }; 56 | } 57 | }, 58 | 59 | generate: function(hash) { 60 | var identifiers = this.identifiers, route = this.route, id; 61 | for (var i=1, l=identifiers.length; iHi") 22 | }); 23 | 24 | var controller = Ember.Object.createWithMixins(Ember.ControllerMixin, { 25 | target: { 26 | urlForEvent: function(event, context) { 27 | return "/foo/bar"; 28 | } 29 | } 30 | }); 31 | 32 | Ember.run(function() { 33 | view.set('controller', controller); 34 | view.appendTo('#qunit-fixture'); 35 | }); 36 | 37 | ok(view.$().html().match(/href=['"].*\/foo\/bar['"]/), "The html (" + view.$().html() + ") does not have the href /foo/bar in it"); 38 | }); 39 | 40 | test("it does not generate the URL when href property is not specified", function() { 41 | var view = Ember.View.create({ 42 | template: compile("Hi") 43 | }); 44 | 45 | var controller = Ember.Object.create(Ember.ControllerMixin, { 46 | target: { 47 | urlForEvent: function(event, context) { 48 | return "/foo/bar"; 49 | } 50 | } 51 | }); 52 | 53 | Ember.run(function() { 54 | view.set('controller', controller); 55 | view.appendTo('#qunit-fixture'); 56 | }); 57 | 58 | ok(!view.$().html().match(/href=['"]\/foo\/bar['"]/), "The html (" + view.$().html() + ") has the href /foo/bar in it"); 59 | }); 60 | 61 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/mixins/mutable_enumerable_test.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/~tests/suites/mutable_enumerable'); 2 | 3 | var indexOf = Ember.EnumerableUtils.indexOf; 4 | 5 | /* 6 | Implement a basic fake mutable array. This validates that any non-native 7 | enumerable can impl this API. 8 | */ 9 | var TestMutableEnumerable = Ember.Object.extend(Ember.MutableEnumerable, { 10 | 11 | _content: null, 12 | 13 | addObject: function(obj) { 14 | if (indexOf(this._content, obj)>=0) return this; 15 | this.enumerableContentWillChange(null, [obj]); 16 | this._content.push(obj); 17 | this.enumerableContentDidChange(null, [obj]); 18 | }, 19 | 20 | removeObject: function(obj) { 21 | var idx = indexOf(this._content, obj); 22 | if (idx<0) return this; 23 | 24 | this.enumerableContentWillChange([obj], null); 25 | this._content.splice(idx, 1); 26 | this.enumerableContentDidChange([obj], null); 27 | return this; 28 | }, 29 | 30 | init: function(ary) { 31 | this._content = ary || []; 32 | }, 33 | 34 | nextObject: function(idx) { 35 | return idx>=Ember.get(this, 'length') ? undefined : this._content[idx]; 36 | }, 37 | 38 | length: Ember.computed(function() { 39 | return this._content.length; 40 | }), 41 | 42 | slice: function() { 43 | return this._content.slice(); 44 | } 45 | }); 46 | 47 | 48 | Ember.MutableEnumerableTests.extend({ 49 | 50 | name: 'Basic Mutable Array', 51 | 52 | newObject: function(ary) { 53 | ary = ary ? ary.slice() : this.newFixture(3); 54 | return new TestMutableEnumerable(ary); 55 | }, 56 | 57 | // allows for testing of the basic enumerable after an internal mutation 58 | mutate: function(obj) { 59 | obj.addObject(this.getFixture(1)[0]); 60 | }, 61 | 62 | toArray: function(obj) { 63 | return obj.slice(); 64 | } 65 | 66 | }).run(); 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /packages/ember-views/tests/views/view/jquery_test.js: -------------------------------------------------------------------------------- 1 | var set = Ember.set, get = Ember.get; 2 | 3 | var view ; 4 | module("Ember.View#$", { 5 | setup: function() { 6 | view = Ember.View.extend({ 7 | render: function(context, firstTime) { 8 | context.push(''); 9 | } 10 | }).create(); 11 | 12 | Ember.run(function() { 13 | view.append(); 14 | }); 15 | }, 16 | 17 | teardown: function() { 18 | Ember.run(function(){ 19 | view.destroy(); 20 | }); 21 | } 22 | }); 23 | 24 | test("returns undefined if no element", function() { 25 | var view = Ember.View.create(); 26 | ok(!get(view, 'element'), 'precond - should have no element'); 27 | equal(view.$(), undefined, 'should return undefined'); 28 | equal(view.$('span'), undefined, 'should undefined if filter passed'); 29 | }); 30 | 31 | test("returns jQuery object selecting element if provided", function() { 32 | ok(get(view, 'element'), 'precond - should have element'); 33 | 34 | var jquery = view.$(); 35 | equal(jquery.length, 1, 'view.$() should have one element'); 36 | equal(jquery[0], get(view, 'element'), 'element should be element'); 37 | }); 38 | 39 | test("returns jQuery object selecting element inside element if provided", function() { 40 | ok(get(view, 'element'), 'precond - should have element'); 41 | 42 | var jquery = view.$('span'); 43 | equal(jquery.length, 1, 'view.$() should have one element'); 44 | equal(jquery[0].parentNode, get(view, 'element'), 'element should be in element'); 45 | }); 46 | 47 | test("returns empty jQuery object if filter passed that does not match item in parent", function() { 48 | ok(get(view, 'element'), 'precond - should have element'); 49 | 50 | var jquery = view.$('body'); // would normally work if not scoped to view 51 | equal(jquery.length, 0, 'view.$(body) should have no elements'); 52 | }); 53 | 54 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/suites/enumerable/forEach.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/~tests/suites/enumerable'); 2 | 3 | var suite = Ember.EnumerableTests, global = this; 4 | 5 | suite.module('forEach'); 6 | 7 | suite.test('forEach should iterate over list', function() { 8 | var obj = this.newObject(), 9 | ary = this.toArray(obj), 10 | found = []; 11 | 12 | obj.forEach(function(i) { found.push(i); }); 13 | deepEqual(found, ary, 'items passed during forEach should match'); 14 | }); 15 | 16 | 17 | suite.test('forEach should iterate over list after mutation', function() { 18 | if (Ember.get(this, 'canTestMutation')) { 19 | expect(0); 20 | return ; 21 | } 22 | 23 | var obj = this.newObject(), 24 | ary = this.toArray(obj), 25 | found = []; 26 | 27 | obj.forEach(function(i) { found.push(i); }); 28 | deepEqual(found, ary, 'items passed during forEach should match'); 29 | 30 | this.mutate(obj); 31 | ary = this.toArray(obj); 32 | found = []; 33 | 34 | obj.forEach(function(i) { found.push(i); }); 35 | deepEqual(found, ary, 'items passed during forEach should match'); 36 | }); 37 | 38 | suite.test('2nd target parameter', function() { 39 | var obj = this.newObject(), target = this; 40 | 41 | obj.forEach(function() { 42 | equal(Ember.guidFor(this), Ember.guidFor(global), 'should pass the global object as this if no context'); 43 | }); 44 | 45 | obj.forEach(function() { 46 | equal(Ember.guidFor(this), Ember.guidFor(target), 'should pass target as this if context'); 47 | }, target); 48 | 49 | }); 50 | 51 | 52 | suite.test('callback params', function() { 53 | var obj = this.newObject(), 54 | ary = this.toArray(obj), 55 | loc = 0; 56 | 57 | 58 | obj.forEach(function(item, idx, enumerable) { 59 | equal(item, ary[loc], 'item param'); 60 | equal(idx, loc, 'idx param'); 61 | equal(Ember.guidFor(enumerable), Ember.guidFor(obj), 'enumerable param'); 62 | loc++; 63 | }); 64 | 65 | }); 66 | -------------------------------------------------------------------------------- /packages/ember-old-router/tests/application_test.js: -------------------------------------------------------------------------------- 1 | var set = Ember.set, get = Ember.get, trim = Ember.$.trim; 2 | var app; 3 | 4 | module("Ember.Application initialization", { 5 | teardown: function() { 6 | Ember.run(function(){ app.destroy(); }); 7 | } 8 | }); 9 | 10 | test('initialized application go to initial route', function() { 11 | Ember.run(function() { 12 | app = Ember.Application.create({ 13 | rootElement: '#qunit-fixture' 14 | }); 15 | 16 | app.stateManager = Ember.Router.create({ 17 | location: { 18 | getURL: function() { 19 | return '/'; 20 | }, 21 | setURL: function() {}, 22 | onUpdateURL: function() {} 23 | }, 24 | 25 | root: Ember.Route.extend({ 26 | index: Ember.Route.extend({ 27 | route: '/' 28 | }) 29 | }) 30 | }); 31 | 32 | 33 | app.ApplicationView = Ember.View.extend({ 34 | template: function() { return "Hello!"; } 35 | }); 36 | 37 | app.ApplicationController = Ember.Controller.extend(); 38 | 39 | Ember.run(function() { app.initialize(app.stateManager); }); 40 | }); 41 | 42 | equal(app.get('router.currentState.path'), 'root.index', "The router moved the state into the right place"); 43 | }); 44 | 45 | test("Minimal Application initialized with an application template and injections", function() { 46 | Ember.$('#qunit-fixture').html(''); 47 | 48 | Ember.run(function () { 49 | app = Ember.Application.create({ 50 | router: false, 51 | rootElement: '#qunit-fixture' 52 | }); 53 | }); 54 | 55 | app.ApplicationController = Ember.Controller.extend({name: 'Kris'}); 56 | 57 | Ember.run(function () { 58 | // required to receive injections 59 | var stateManager = Ember.Object.create(); 60 | app.initialize(stateManager); 61 | }); 62 | 63 | equal(trim(Ember.$('#qunit-fixture').text()), 'Hello Kris!'); 64 | }); 65 | 66 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/suites/enumerable/map.js: -------------------------------------------------------------------------------- 1 | require('ember-runtime/~tests/suites/enumerable'); 2 | 3 | var suite = Ember.EnumerableTests, global = this; 4 | 5 | suite.module('map'); 6 | 7 | function mapFunc(item) { return item ? item.toString() : null; } 8 | 9 | suite.test('map should iterate over list', function() { 10 | var obj = this.newObject(), 11 | ary = Ember.EnumerableUtils.map(this.toArray(obj), mapFunc), 12 | found = []; 13 | 14 | found = obj.map(mapFunc); 15 | deepEqual(found, ary, 'mapped arrays should match'); 16 | }); 17 | 18 | 19 | suite.test('map should iterate over list after mutation', function() { 20 | if (Ember.get(this, 'canTestMutation')) { 21 | expect(0); 22 | return ; 23 | } 24 | 25 | var obj = this.newObject(), 26 | ary = this.toArray(obj).map(mapFunc), 27 | found; 28 | 29 | found = obj.map(mapFunc); 30 | deepEqual(found, ary, 'items passed during forEach should match'); 31 | 32 | this.mutate(obj); 33 | ary = this.toArray(obj).map(mapFunc); 34 | found = obj.map(mapFunc); 35 | deepEqual(found, ary, 'items passed during forEach should match'); 36 | }); 37 | 38 | suite.test('2nd target parameter', function() { 39 | var obj = this.newObject(), target = this; 40 | 41 | 42 | obj.map(function() { 43 | equal(Ember.guidFor(this), Ember.guidFor(global), 'should pass the global object as this if no context'); 44 | }); 45 | 46 | obj.map(function() { 47 | equal(Ember.guidFor(this), Ember.guidFor(target), 'should pass target as this if context'); 48 | }, target); 49 | 50 | }); 51 | 52 | 53 | suite.test('callback params', function() { 54 | var obj = this.newObject(), 55 | ary = this.toArray(obj), 56 | loc = 0; 57 | 58 | 59 | obj.map(function(item, idx, enumerable) { 60 | equal(item, ary[loc], 'item param'); 61 | equal(idx, loc, 'idx param'); 62 | equal(Ember.guidFor(enumerable), Ember.guidFor(obj), 'enumerable param'); 63 | loc++; 64 | }); 65 | 66 | }); 67 | -------------------------------------------------------------------------------- /packages/ember-routing/lib/system/dsl.js: -------------------------------------------------------------------------------- 1 | /** 2 | @module ember 3 | @submodule ember-routing 4 | */ 5 | 6 | function DSL(name) { 7 | this.parent = name; 8 | this.matches = []; 9 | } 10 | 11 | DSL.prototype = { 12 | resource: function(name, options, callback) { 13 | if (arguments.length === 2 && typeof options === 'function') { 14 | callback = options; 15 | options = {}; 16 | } 17 | 18 | if (arguments.length === 1) { 19 | options = {}; 20 | } 21 | 22 | if (typeof options.path !== 'string') { 23 | options.path = "/" + name; 24 | } 25 | 26 | if (callback) { 27 | var dsl = new DSL(name); 28 | callback.call(dsl); 29 | this.push(options.path, name, dsl.generate()); 30 | } else { 31 | this.push(options.path, name); 32 | } 33 | }, 34 | 35 | push: function(url, name, callback) { 36 | if (url === "" || url === "/") { this.explicitIndex = true; } 37 | 38 | this.matches.push([url, name, callback]); 39 | }, 40 | 41 | route: function(name, options) { 42 | Ember.assert("You must use `this.resource` to nest", typeof options !== 'function'); 43 | 44 | options = options || {}; 45 | 46 | if (typeof options.path !== 'string') { 47 | options.path = "/" + name; 48 | } 49 | 50 | if (this.parent && this.parent !== 'application') { 51 | name = this.parent + "." + name; 52 | } 53 | 54 | this.push(options.path, name); 55 | }, 56 | 57 | generate: function() { 58 | var dslMatches = this.matches; 59 | 60 | if (!this.explicitIndex) { 61 | this.route("index", { path: "/" }); 62 | } 63 | 64 | return function(match) { 65 | for (var i=0, l=dslMatches.length; i 28 | {{view Ember.Checkbox classNames="applicaton-specific-checkbox"}} 29 | Some Title 30 | 31 | ``` 32 | 33 | The `checked` attribute of an `Ember.Checkbox` object should always be set 34 | through the Ember object or by interacting with its rendered element 35 | representation via the mouse, keyboard, or touch. Updating the value of the 36 | checkbox via jQuery will result in the checked value of the object and its 37 | element losing synchronization. 38 | 39 | ## Layout and LayoutName properties 40 | 41 | Because HTML `input` elements are self closing `layout` and `layoutName` 42 | properties will not be applied. See `Ember.View`'s layout section for more 43 | information. 44 | 45 | @class Checkbox 46 | @namespace Ember 47 | @extends Ember.View 48 | */ 49 | Ember.Checkbox = Ember.View.extend({ 50 | classNames: ['ember-checkbox'], 51 | 52 | tagName: 'input', 53 | 54 | attributeBindings: ['type', 'checked', 'disabled', 'tabindex'], 55 | 56 | type: "checkbox", 57 | checked: false, 58 | disabled: false, 59 | 60 | init: function() { 61 | this._super(); 62 | this.on("change", this, this._updateElementValue); 63 | }, 64 | 65 | _updateElementValue: function() { 66 | set(this, 'checked', this.$().prop('checked')); 67 | } 68 | }); 69 | -------------------------------------------------------------------------------- /packages/ember-old-router/lib/handlebars_ext.js: -------------------------------------------------------------------------------- 1 | require('ember-handlebars/helpers/view'); 2 | 3 | Ember.onLoad('Ember.Handlebars', function(Handlebars) { 4 | /** 5 | @module ember 6 | @submodule ember-handlebars 7 | */ 8 | 9 | Handlebars.OutletView = Ember.ContainerView.extend(Ember._Metamorph); 10 | 11 | /** 12 | The `outlet` helper allows you to specify that the current 13 | view's controller will fill in the view for a given area. 14 | 15 | ``` handlebars 16 | {{outlet}} 17 | ``` 18 | 19 | By default, when the the current controller's `view` property changes, the 20 | outlet will replace its current view with the new view. You can set the 21 | `view` property directly, but it's normally best to use `connectOutlet`. 22 | 23 | ``` javascript 24 | # Instantiate App.PostsView and assign to `view`, so as to render into outlet. 25 | controller.connectOutlet('posts'); 26 | ``` 27 | 28 | You can also specify a particular name other than `view`: 29 | 30 | ``` handlebars 31 | {{outlet masterView}} 32 | {{outlet detailView}} 33 | ``` 34 | 35 | Then, you can control several outlets from a single controller. 36 | 37 | ``` javascript 38 | # Instantiate App.PostsView and assign to controller.masterView. 39 | controller.connectOutlet('masterView', 'posts'); 40 | # Also, instantiate App.PostInfoView and assign to controller.detailView. 41 | controller.connectOutlet('detailView', 'postInfo'); 42 | ``` 43 | 44 | @method outlet 45 | @for Ember.Handlebars.helpers 46 | @param {String} property the property on the controller 47 | that holds the view for this outlet 48 | */ 49 | Handlebars.registerHelper('outlet', function(property, options) { 50 | if (property && property.data && property.data.isRenderData) { 51 | options = property; 52 | property = 'view'; 53 | } 54 | 55 | options.hash.currentViewBinding = "view.context." + property; 56 | 57 | return Handlebars.helpers.view.call(this, Handlebars.OutletView, options); 58 | }); 59 | 60 | }); 61 | -------------------------------------------------------------------------------- /packages/ember-metal/tests/watching/isWatching_test.js: -------------------------------------------------------------------------------- 1 | module('Ember.isWatching'); 2 | 3 | var testObserver = function(setup, teardown) { 4 | var obj = {}, key = 'foo', fn = function() {}; 5 | 6 | equal(Ember.isWatching(obj, 'foo'), false, "precond - isWatching is false by default"); 7 | setup(obj, key, fn); 8 | equal(Ember.isWatching(obj, 'foo'), true, "isWatching is true when observers are added"); 9 | teardown(obj, key, fn); 10 | equal(Ember.isWatching(obj, 'foo'), false, "isWatching is false after observers are removed"); 11 | }; 12 | 13 | test("isWatching is true for regular local observers", function() { 14 | testObserver(function(obj, key, fn) { 15 | Ember.Mixin.create({ 16 | didChange: Ember.observer(fn, key) 17 | }).apply(obj); 18 | }, function(obj, key, fn) { 19 | Ember.removeObserver(obj, key, obj, fn); 20 | }); 21 | }); 22 | 23 | test("isWatching is true for nonlocal observers", function() { 24 | testObserver(function(obj, key, fn) { 25 | Ember.addObserver(obj, key, obj, fn); 26 | }, function(obj, key, fn) { 27 | Ember.removeObserver(obj, key, obj, fn); 28 | }); 29 | }); 30 | 31 | test("isWatching is true for chained observers", function() { 32 | testObserver(function(obj, key, fn) { 33 | Ember.addObserver(obj, key + '.bar', obj, fn); 34 | }, function(obj, key, fn) { 35 | Ember.removeObserver(obj, key + '.bar', obj, fn); 36 | }); 37 | }); 38 | 39 | test("isWatching is true for computed properties", function() { 40 | testObserver(function(obj, key, fn) { 41 | Ember.defineProperty(obj, 'computed', Ember.computed(fn).property(key)); 42 | Ember.watch(obj, 'computed'); 43 | }, function(obj, key, fn) { 44 | Ember.defineProperty(obj, 'computed', null); 45 | }); 46 | }); 47 | 48 | test("isWatching is true for chained computed properties", function() { 49 | testObserver(function(obj, key, fn) { 50 | Ember.defineProperty(obj, 'computed', Ember.computed(fn).property(key + '.bar')); 51 | Ember.watch(obj, 'computed'); 52 | }, function(obj, key, fn) { 53 | Ember.defineProperty(obj, 'computed', null); 54 | }); 55 | }); 56 | -------------------------------------------------------------------------------- /packages/ember-handlebars/lib/helpers/yield.js: -------------------------------------------------------------------------------- 1 | /** 2 | @module ember 3 | @submodule ember-handlebars 4 | */ 5 | 6 | var get = Ember.get, set = Ember.set; 7 | 8 | /** 9 | When used in a Handlebars template that is assigned to an `Ember.View` 10 | instance's `layout` property Ember will render the layout template first, 11 | inserting the view's own rendered output at the `{{yield}}` location. 12 | 13 | An empty `` and the following application code: 14 | 15 | ```javascript 16 | AView = Ember.View.extend({ 17 | classNames: ['a-view-with-layout'], 18 | layout: Ember.Handlebars.compile('
{{yield}}
'), 19 | template: Ember.Handlebars.compile('I am wrapped') 20 | }); 21 | 22 | aView = AView.create(); 23 | aView.appendTo('body'); 24 | ``` 25 | 26 | Will result in the following HTML output: 27 | 28 | ```html 29 | 30 |
31 |
32 | I am wrapped 33 |
34 |
35 | 36 | ``` 37 | 38 | The `yield` helper cannot be used outside of a template assigned to an 39 | `Ember.View`'s `layout` property and will throw an error if attempted. 40 | 41 | ```javascript 42 | BView = Ember.View.extend({ 43 | classNames: ['a-view-with-layout'], 44 | template: Ember.Handlebars.compile('{{yield}}') 45 | }); 46 | 47 | bView = BView.create(); 48 | bView.appendTo('body'); 49 | 50 | // throws 51 | // Uncaught Error: assertion failed: You called yield in a template that was not a layout 52 | ``` 53 | 54 | @method yield 55 | @for Ember.Handlebars.helpers 56 | @param {Hash} options 57 | @return {String} HTML string 58 | */ 59 | Ember.Handlebars.registerHelper('yield', function(options) { 60 | var view = options.data.view, template; 61 | 62 | while (view && !get(view, 'layout')) { 63 | view = get(view, 'parentView'); 64 | } 65 | 66 | Ember.assert("You called yield in a template that was not a layout", !!view); 67 | 68 | template = get(view, 'template'); 69 | 70 | if (template) { template(this, options); } 71 | }); 72 | -------------------------------------------------------------------------------- /packages/ember-runtime/tests/legacy_1x/mixins/observable/chained_test.js: -------------------------------------------------------------------------------- 1 | /* 2 | NOTE: This test is adapted from the 1.x series of unit tests. The tests 3 | are the same except for places where we intend to break the API we instead 4 | validate that we warn the developer appropriately. 5 | 6 | CHANGES FROM 1.6: 7 | 8 | * changed obj.set() and obj.get() to Ember.set() and Ember.get() 9 | * changed obj.addObserver() to Ember.addObserver() 10 | */ 11 | 12 | var get = Ember.get, set = Ember.set; 13 | 14 | module("Ember.Observable - Observing with @each"); 15 | 16 | test("chained observers on enumerable properties are triggered when the observed property of any item changes", function() { 17 | var family = Ember.Object.create({ momma: null }); 18 | var momma = Ember.Object.create({ children: [] }); 19 | 20 | var child1 = Ember.Object.create({ name: "Bartholomew" }); 21 | var child2 = Ember.Object.create({ name: "Agnes" }); 22 | var child3 = Ember.Object.create({ name: "Dan" }); 23 | var child4 = Ember.Object.create({ name: "Nancy" }); 24 | 25 | set(family, 'momma', momma); 26 | set(momma, 'children', Ember.A([child1, child2, child3])); 27 | 28 | var observerFiredCount = 0; 29 | Ember.addObserver(family, 'momma.children.@each.name', this, function() { 30 | observerFiredCount++; 31 | }); 32 | 33 | observerFiredCount = 0; 34 | Ember.run(function() { get(momma, 'children').setEach('name', 'Juan'); }); 35 | equal(observerFiredCount, 3, "observer fired after changing child names"); 36 | 37 | observerFiredCount = 0; 38 | Ember.run(function() { get(momma, 'children').pushObject(child4); }); 39 | equal(observerFiredCount, 1, "observer fired after adding a new item"); 40 | 41 | observerFiredCount = 0; 42 | Ember.run(function() { set(child4, 'name', "Herbert"); }); 43 | equal(observerFiredCount, 1, "observer fired after changing property on new object"); 44 | 45 | set(momma, 'children', []); 46 | 47 | observerFiredCount = 0; 48 | Ember.run(function() { set(child1, 'name', "Hanna"); }); 49 | equal(observerFiredCount, 0, "observer did not fire after removing changing property on a removed object"); 50 | }); 51 | 52 | -------------------------------------------------------------------------------- /packages/ember-handlebars/lib/controls/text_area.js: -------------------------------------------------------------------------------- 1 | require("ember-handlebars/ext"); 2 | require("ember-views/views/view"); 3 | require("ember-handlebars/controls/text_support"); 4 | 5 | /** 6 | @module ember 7 | @submodule ember-handlebars 8 | */ 9 | 10 | var get = Ember.get, set = Ember.set; 11 | 12 | /** 13 | The `Ember.TextArea` view class renders a 14 | [textarea](https://developer.mozilla.org/en/HTML/Element/textarea) element. 15 | It allows for binding Ember properties to the text area contents (`value`), 16 | live-updating as the user inputs text. 17 | 18 | ## Layout and LayoutName properties 19 | 20 | Because HTML `textarea` elements do not contain inner HTML the `layout` and 21 | `layoutName` properties will not be applied. See `Ember.View`'s layout 22 | section for more information. 23 | 24 | ## HTML Attributes 25 | 26 | By default `Ember.TextArea` provides support for `rows`, `cols`, 27 | `placeholder`, `disabled`, `maxlength` and `tabindex` attributes on a 28 | textarea. If you need to support more attributes have a look at the 29 | `attributeBindings` property in `Ember.View`'s HTML Attributes section. 30 | 31 | To globally add support for additional attributes you can reopen 32 | `Ember.TextArea` or `Ember.TextSupport`. 33 | 34 | ```javascript 35 | Ember.TextSupport.reopen({ 36 | attributeBindings: ["required"] 37 | }) 38 | ``` 39 | 40 | @class TextArea 41 | @namespace Ember 42 | @extends Ember.View 43 | @uses Ember.TextSupport 44 | */ 45 | Ember.TextArea = Ember.View.extend(Ember.TextSupport, { 46 | classNames: ['ember-text-area'], 47 | 48 | tagName: "textarea", 49 | attributeBindings: ['rows', 'cols'], 50 | rows: null, 51 | cols: null, 52 | 53 | _updateElementValue: Ember.observer(function() { 54 | // We do this check so cursor position doesn't get affected in IE 55 | var value = get(this, 'value'), 56 | $el = this.$(); 57 | if ($el && value !== $el.val()) { 58 | $el.val(value); 59 | } 60 | }, 'value'), 61 | 62 | init: function() { 63 | this._super(); 64 | this.on("didInsertElement", this, this._updateElementValue); 65 | } 66 | 67 | }); 68 | --------------------------------------------------------------------------------