dist/ember-runtime.js in ember-source-1.9.0.beta.4 vs dist/ember-runtime.js in ember-source-1.9.0

- old
+ new

@@ -3,29 +3,34 @@ * @copyright Copyright 2011-2014 Tilde Inc. and contributors * Portions Copyright 2006-2011 Strobe Inc. * Portions Copyright 2008-2011 Apple Inc. All rights reserved. * @license Licensed under MIT license * See https://raw.github.com/emberjs/ember.js/master/LICENSE - * @version 1.9.0-beta.4 + * @version 1.9.0 */ (function() { var define, requireModule, require, requirejs, Ember; (function() { Ember = this.Ember = this.Ember || {}; if (typeof Ember === 'undefined') { Ember = {}; }; + function UNDEFINED() { } if (typeof Ember.__loader === 'undefined') { var registry = {}, seen = {}; define = function(name, deps, callback) { registry[name] = { deps: deps, callback: callback }; }; requirejs = require = requireModule = function(name) { - if (seen.hasOwnProperty(name)) { return seen[name]; } + var s = seen[name]; + + if (s !== undefined) { return seen[name]; } + if (s === UNDEFINED) { return undefined; } + seen[name] = {}; if (!registry[name]) { throw new Error("Could not find module " + name); } @@ -33,38 +38,41 @@ var mod = registry[name]; var deps = mod.deps; var callback = mod.callback; var reified = []; var exports; + var length = deps.length; - for (var i=0, l=deps.length; i<l; i++) { + for (var i=0; i<length; i++) { if (deps[i] === 'exports') { reified.push(exports = {}); } else { - reified.push(requireModule(resolve(deps[i]))); + reified.push(requireModule(resolve(deps[i], name))); } } - var value = callback.apply(this, reified); - return seen[name] = exports || value; + var value = length === 0 ? callback.call(this) : callback.apply(this, reified); - function resolve(child) { - if (child.charAt(0) !== '.') { return child; } - var parts = child.split("/"); - var parentBase = name.split("/").slice(0, -1); + return seen[name] = exports || (value === undefined ? UNDEFINED : value); + }; - for (var i=0, l=parts.length; i<l; i++) { - var part = parts[i]; + function resolve(child, name) { + if (child.charAt(0) !== '.') { return child; } + var parts = child.split("/"); + var parentBase = name.split("/").slice(0, -1); - if (part === '..') { parentBase.pop(); } - else if (part === '.') { continue; } - else { parentBase.push(part); } - } + for (var i=0, l=parts.length; i<l; i++) { + var part = parts[i]; - return parentBase.join("/"); + if (part === '..') { parentBase.pop(); } + else if (part === '.') { continue; } + else { parentBase.push(part); } } - }; + + return parentBase.join("/"); + } + requirejs._eak_seen = registry; Ember.__loader = {define: define, require: require, registry: registry}; } else { define = Ember.__loader.define; @@ -4801,11 +4809,11 @@ The core Runtime framework is based on the jQuery API with a number of performance optimizations. @class Ember @static - @version 1.9.0-beta.4 + @version 1.9.0 */ if ('undefined' === typeof Ember) { // Create core object. Make it act like an instance of Ember.Namespace so that // objects assigned to it are given a sane string representation. @@ -4828,14 +4836,14 @@ /** @property VERSION @type String - @default '1.9.0-beta.4' + @default '1.9.0' @static */ - Ember.VERSION = '1.9.0-beta.4'; + Ember.VERSION = '1.9.0'; /** Standard environmental variables. You can define these in a global `EmberENV` variable before loading Ember to control various configuration settings. @@ -9605,39 +9613,45 @@ run.join = function() { return backburner.join.apply(backburner, arguments); }; /** - Provides a useful utility for when integrating with non-Ember libraries - that provide asynchronous callbacks. + Allows you to specify which context to call the specified function in while + adding the execution of that function to the Ember run loop. This ability + makes this method a great way to asynchronusly integrate third-party libraries + into your Ember application. - Ember utilizes a run-loop to batch and coalesce changes. This works by - marking the start and end of Ember-related Javascript execution. + `run.bind` takes two main arguments, the desired context and the function to + invoke in that context. Any additional arguments will be supplied as arguments + to the function that is passed in. - When using events such as a View's click handler, Ember wraps the event - handler in a run-loop, but when integrating with non-Ember libraries this - can be tedious. + Let's use the creation of a TinyMCE component as an example. Currently, + TinyMCE provides a setup configuration option we can use to do some processing + after the TinyMCE instance is initialized but before it is actually rendered. + We can use that setup option to do some additional setup for our component. + The component itself could look something like the following: - For example, the following is rather verbose but is the correct way to combine - third-party events and Ember code. - ```javascript - var that = this; - jQuery(window).on('resize', function(){ - run(function(){ - that.handleResize(); - }); + App.RichTextEditorComponent = Ember.Component.extend({ + initializeTinyMCE: function(){ + tinymce.init({ + selector: '#' + this.$().prop('id'), + setup: Ember.run.bind(this, this.setupEditor) + }); + }.on('didInsertElement'), + + setupEditor: function(editor) { + this.set('editor', editor); + editor.on('change', function(){ console.log('content changed!')} ); + } }); ``` - To reduce the boilerplate, the following can be used to construct a - run-loop-wrapped callback handler. + In this example, we use Ember.run.bind to bind the setupEditor message to the + context of the App.RichTextEditorComponent and to have the invocation of that + method be safely handled and excuted by the Ember run loop. - ```javascript - jQuery(window).on('resize', run.bind(this, this.handleResize)); - ``` - @method bind @namespace Ember @param {Object} [target] target of method to call @param {Function|String} method Method to invoke. May be a function or a string. If you pass a string @@ -9645,10 +9659,10 @@ @param {Object} [args*] Any additional arguments you wish to pass to the method. @return {Object} return value from invoking the passed function. Please note, when called within an existing loop, no return value is possible. @since 1.4.0 */ - run.bind = function(target, method /* args*/) { + run.bind = function(target, method /* args */) { var args = slice.call(arguments); return function() { return run.join.apply(run, args.concat(slice.call(arguments))); }; };