Input: Handles all events sent from the dispatcher . Filters out to only those sent via the Table [CODESPLIT] function ( payload ) { var action = payload . action ; if ( ! this . shouldHandleAction ( action . component ) ) { return ; } switch ( action . actionType ) { case ActionTypes . REQUEST_DATA : this . handleRequestDataAction ( action ) ; break ; case ActionTypes . TABLE_SORT : this . collection [ action . id ] . sortData ( action . data . colIndex , action . data . direction ) ; this . emitChange ( action . id ) ; break ; case ActionTypes . FILTER : this . collection [ action . id ] . setFilterValue ( action . data . value ) ; this . emitChange ( action . id ) ; break ; case ActionTypes . ADVANCED_FILTER : this . collection [ action . id ] . setAdvancedFilters ( action . data . advancedFilters ) ; this . emitChange ( action . id ) ; break ; case ActionTypes . PAGINATE : this . collection [ action . id ] . paginate ( action . data . direction ) ; this . emitChange ( action . id ) ; break ; case ActionTypes . TOGGLE_BULK_SELECT : this . collection [ action . id ] . updateBulkSelection ( action . data . deselect ) ; this . emitChange ( action . id ) ; break ; case ActionTypes . TOGGLE_ROW_SELECT : this . collection [ action . id ] . updateRowSelection ( action . data . rowIndex ) ; this . emitChange ( action . id ) ; break ; case ActionTypes . DESTROY_INSTANCE : this . destroyInstance ( action . id ) ; break ; } }


Input: Requests data for a component when the filter property changes . When comparing filters we do a direct comparison in addition to a JSON stringify comparison . This fixes issues where the filters object is a new literal object every time but isn t actually changing . Using a JSON stringify has the downside of causing requestData to be called if the objects are in a different order but that is pretty unlikely to happen . The setTimeout insures that the currently dispatched action has completed the dispatching process before the request data action is kicked off . [CODESPLIT] function ( nextProps ) { if ( this . props . filters !== nextProps . filters && JSON . stringify ( this . props . filters ) !== JSON . stringify ( nextProps . filters ) ) { setTimeout ( function ( ) { this . requestData ( ) ; } . bind ( this ) , 0 ) ; } }


Input:
Used to add and remove the listeners required when requesting data from the server . [CODESPLIT] function ( store ) { return { /**
             * Adds the listeners required when requesting data from the server.
             */ componentDidMount : function ( ) { store . on ( 'change:' + this . props . componentId , this . onDataReceived ) ; store . on ( 'fail:' + this . props . componentId , this . onError ) ; } , /**
             * Removes the listeners required when requesting data from the server.
             */ componentWillUnmount : function ( ) { store . removeListener ( 'change:' + this . props . componentId , this . onDataReceived ) ; store . removeListener ( 'fail:' + this . props . componentId , this . onError ) ; } } ; }


Input: Adds the listeners required when requesting data from the server . [CODESPLIT] function ( ) { store . on ( 'change:' + this . props . componentId , this . onDataReceived ) ; store . on ( 'fail:' + this . props . componentId , this . onError ) ; }


Input: Removes the listeners required when requesting data from the server . [CODESPLIT] function ( ) { store . removeListener ( 'change:' + this . props . componentId , this . onDataReceived ) ; store . removeListener ( 'fail:' + this . props . componentId , this . onError ) ; }


Input: Action for populating table data . Used both for initial and subsequent loads . [CODESPLIT] function ( id , definition , dataFormatter , filters ) { AppDispatcher . dispatchAction ( { actionType : this . actionTypes . REQUEST_DATA , component : 'Table' , id : id , data : { definition : definition , dataFormatter : dataFormatter , filters : filters } } ) ; }


Input: Filters out table data that does not match the filter value for table cols that have quickFilter set to true . [CODESPLIT] function ( id , value ) { AppDispatcher . dispatchAction ( { actionType : this . actionTypes . FILTER , component : 'Table' , id : id , data : { value : value } } ) ; }


Input: Filters out table data where any property value equals a matching property value on an advanced filter unless the advanced filter has been checked . [CODESPLIT] function ( id , advancedFilters ) { AppDispatcher . dispatchAction ( { actionType : this . actionTypes . ADVANCED_FILTER , component : 'Table' , id : id , data : { advancedFilters : advancedFilters } } ) ; }


Input: Moves the cursor forwards or backwards through paginated data . [CODESPLIT] function ( id , direction ) { AppDispatcher . dispatchAction ( { actionType : this . actionTypes . PAGINATE , component : 'Table' , id : id , data : { direction : direction } } ) ; }


Input: Sorts the array of data for the Table based on the sort column index and the direction . [CODESPLIT] function ( id , colIndex , direction ) { AppDispatcher . dispatchAction ( { actionType : this . actionTypes . TABLE_SORT , component : 'Table' , id : id , data : { colIndex : colIndex , direction : direction } } ) ; }


Input: Bulk toggle selection for table rows . [CODESPLIT] function ( id , deselect ) { AppDispatcher . dispatchAction ( { actionType : this . actionTypes . TOGGLE_BULK_SELECT , component : 'Table' , id : id , data : { deselect : deselect } } ) ; }


Input: Selects or deselects a table row . [CODESPLIT] function ( id , rowIndex ) { AppDispatcher . dispatchAction ( { actionType : this . actionTypes . TOGGLE_ROW_SELECT , component : 'Table' , id : id , data : { rowIndex : rowIndex } } ) ; }


Input: Extract the value default translate filter behavior else if it is an attribute we need to get its value first [CODESPLIT] function extractValue ( attr , node ) { if ( attr === 'translate' ) { return node . html ( ) || getAttr ( attr ) || '' ; } return getAttr ( attr ) || node . html ( ) || '' ; }


Input: returns the log array [CODESPLIT] function cleanerEval$624 ( str$629 , oldConsole$630 ) { var logArr$631 = [ ] ; var console$632 = { log : function ( msg$633 ) { logArr$631 . push ( msg$633 ) ; oldConsole$630 . log ( msg$633 ) ; } } ; eval ( str$629 ) ; return logArr$631 ; }


Input: Calls the map function on the passed object with a specified callback . This uses Ember . ArrayPolyfill s - map method when necessary . [CODESPLIT] function ( obj , callback , thisArg ) { return obj . map ? obj . map . call ( obj , callback , thisArg ) : map . call ( obj , callback , thisArg ) ; }


Input: Calls the filter function on the passed object with a specified callback . This uses Ember . ArrayPolyfill s - filter method when necessary . [CODESPLIT] function ( obj , callback , thisArg ) { return obj . filter ? obj . filter . call ( obj , callback , thisArg ) : filter . call ( obj , callback , thisArg ) ; }


Input: Returns an array of indexes of the first occurrences of the passed elements on the passed object . [CODESPLIT] function ( obj , elements ) { return elements === undefined ? [ ] : utils . map ( elements , function ( item ) { return utils . indexOf ( obj , item ) ; } ) ; }


Input: Adds an object to an array . If the array already includes the object this method has no effect . [CODESPLIT] function ( array , item ) { var index = utils . indexOf ( array , item ) ; if ( index === - 1 ) { array . push ( item ) ; } }


Input: Replaces objects in an array with the passed objects . [CODESPLIT] function ( array , idx , amt , objects ) { if ( array . replace ) { return array . replace ( idx , amt , objects ) ; } else { return utils . _replace ( array , idx , amt , objects ) ; } }


Input: Calculates the intersection of two arrays . This method returns a new array filled with the records that the two passed arrays share with each other . If there is no intersection an empty array will be returned . [CODESPLIT] function ( array1 , array2 ) { var intersection = [ ] ; utils . forEach ( array1 , function ( element ) { if ( utils . indexOf ( array2 , element ) >= 0 ) { intersection . push ( element ) ; } } ) ; return intersection ; }


Input: Remove an event listener [CODESPLIT] function removeListener ( obj , eventName , target , method ) { Ember . assert ( "You must pass at least an object and event name to Ember.removeListener" , ! ! obj && ! ! eventName ) ; if ( ! method && 'function' === typeof target ) { method = target ; target = null ; } function _removeListener ( target , method ) { var actions = actionsFor ( obj , eventName ) , actionIndex = indexOf ( actions , target , method ) ; // action doesn't exist, give up silently if ( actionIndex === - 1 ) { return ; } actions . splice ( actionIndex , 3 ) ; if ( 'function' === typeof obj . didRemoveListener ) { obj . didRemoveListener ( eventName , target , method ) ; } } if ( method ) { _removeListener ( target , method ) ; } else { var meta = obj [ META_KEY ] , actions = meta && meta . listeners && meta . listeners [ eventName ] ; if ( ! actions ) { return ; } for ( var i = actions . length - 3 ; i >= 0 ; i -= 3 ) { _removeListener ( actions [ i ] , actions [ i + 1 ] ) ; } } }


Input: Suspend listener during callback . [CODESPLIT] function suspendListener ( obj , eventName , target , method , callback ) { if ( ! method && 'function' === typeof target ) { method = target ; target = null ; } var actions = actionsFor ( obj , eventName ) , actionIndex = indexOf ( actions , target , method ) ; if ( actionIndex !== - 1 ) { actions [ actionIndex + 2 ] |= SUSPENDED ; // mark the action as suspended } function tryable ( ) { return callback . call ( target ) ; } function finalizer ( ) { if ( actionIndex !== - 1 ) { actions [ actionIndex + 2 ] &= ~ SUSPENDED ; } } return Ember . tryFinally ( tryable , finalizer ) ; }


Input: called whenever a property has just changed to update dependent keys [CODESPLIT] function dependentKeysDidChange ( obj , depKey , meta ) { if ( obj . isDestroying ) { return ; } var seen = DID_SEEN , top = ! seen ; if ( top ) { seen = DID_SEEN = { } ; } iterDeps ( propertyDidChange , obj , depKey , seen , meta ) ; if ( top ) { DID_SEEN = null ; } }


Input: Sets the value of a property on an object respecting computed properties and notifying observers and other listeners of the change . If the property is not defined but the object implements the setUnknownProperty method then that will be invoked as well . [CODESPLIT] function set ( obj , keyName , value , tolerant ) { if ( typeof obj === 'string' ) { Ember . assert ( "Path '" + obj + "' must be global if no obj is given." , IS_GLOBAL . test ( obj ) ) ; value = keyName ; keyName = obj ; obj = null ; } Ember . assert ( "Cannot call set with " + keyName + " key." , ! ! keyName ) ; if ( ! obj || keyName . indexOf ( '.' ) !== - 1 ) { return setPath ( obj , keyName , value , tolerant ) ; } Ember . assert ( "You need to provide an object and key to `set`." , ! ! obj && keyName !== undefined ) ; Ember . assert ( 'calling set on destroyed object' , ! obj . isDestroyed ) ; var meta = obj [ META_KEY ] , desc = meta && meta . descs [ keyName ] , isUnknown , currentValue ; if ( desc ) { desc . set ( obj , keyName , value ) ; } else { isUnknown = 'object' === typeof obj && ! ( keyName in obj ) ; // setUnknownProperty is called if `obj` is an object, // the property does not already exist, and the // `setUnknownProperty` method exists on the object if ( isUnknown && 'function' === typeof obj . setUnknownProperty ) { obj . setUnknownProperty ( keyName , value ) ; } else if ( meta && meta . watching [ keyName ] > 0 ) { if ( MANDATORY_SETTER ) { currentValue = meta . values [ keyName ] ; } else { currentValue = obj [ keyName ] ; } // only trigger a change if the value has changed if ( value !== currentValue ) { Ember . propertyWillChange ( obj , keyName ) ; if ( MANDATORY_SETTER ) { if ( ( currentValue === undefined && ! ( keyName in obj ) ) || ! obj . propertyIsEnumerable ( keyName ) ) { Ember . defineProperty ( obj , keyName , null , value ) ; // setup mandatory setter } else { meta . values [ keyName ] = value ; } } else { obj [ keyName ] = value ; } Ember . propertyDidChange ( obj , keyName ) ; } } else { obj [ keyName ] = value ; } } return value ; }


Input: Adds a value to the map . If a value for the given key has already been provided the new value will replace the old value . [CODESPLIT] function ( key , value ) { var keys = this . keys , values = this . values , guid = guidFor ( key ) ; keys . add ( key ) ; values [ guid ] = value ; set ( this , 'length' , keys . list . length ) ; }


Input: Removes a value from the map for an associated key . [CODESPLIT] function ( key ) { // don't use ES6 "delete" because it will be annoying // to use in browsers that are not ES6 friendly; var keys = this . keys , values = this . values , guid = guidFor ( key ) ; if ( values . hasOwnProperty ( guid ) ) { keys . remove ( key ) ; delete values [ guid ] ; set ( this , 'length' , keys . list . length ) ; return true ; } else { return false ; } }


Input: Iterate over all the keys and values . Calls the function once for each key passing in the key and value in that order . [CODESPLIT] function ( callback , self ) { var keys = this . keys , values = this . values ; keys . forEach ( function ( key ) { var guid = guidFor ( key ) ; callback . call ( self , key , values [ guid ] ) ; } ) ; }


Input: .......................................................... COMPUTED PROPERTY A computed property transforms an objects function into a property . [CODESPLIT] function ComputedProperty ( func , opts ) { this . func = func ; if ( Ember . FEATURES . isEnabled ( 'composable-computed-properties' ) ) { setDependentKeys ( this , opts && opts . dependentKeys ) ; } else { this . _dependentKeys = opts && opts . dependentKeys ; } this . _cacheable = ( opts && opts . cacheable !== undefined ) ? opts . cacheable : true ; this . _readOnly = opts && ( opts . readOnly !== undefined || ! ! opts . readOnly ) ; }


Input: TODO : remove me only being used for Ember . run . sync [CODESPLIT] function ( ) { var queue = this . _queue , options = this . options , before = options && options . before , after = options && options . after , target , method , args , stack , i , l = queue . length ; if ( l && before ) { before ( ) ; } for ( i = 0 ; i < l ; i += 4 ) { target = queue [ i ] ; method = queue [ i + 1 ] ; args = queue [ i + 2 ] ; stack = queue [ i + 3 ] ; // Debugging assistance // TODO: error handling if ( args && args . length > 0 ) { method . apply ( target , args ) ; } else { method . call ( target ) ; } } if ( l && after ) { after ( ) ; } // check if new items have been added if ( queue . length > l ) { this . _queue = queue . slice ( l ) ; this . flush ( ) ; } else { this . _queue . length = 0 ; } }


Input: .......................................................... BINDING [CODESPLIT] function ( toPath , fromPath ) { this . _direction = 'fwd' ; this . _from = fromPath ; this . _to = toPath ; this . _directionMap = Ember . Map . create ( ) ; }


Input: .......................................................... CONNECT AND SYNC Attempts to connect this binding instance so that it can receive and relay changes . This method will raise an exception if you have not set the from / to properties yet . [CODESPLIT] function ( obj ) { Ember . assert ( 'Must pass a valid object to Ember.Binding.connect()' , ! ! obj ) ; var fromPath = this . _from , toPath = this . _to ; Ember . trySet ( obj , toPath , getWithGlobals ( obj , fromPath ) ) ; // add an observer on the object to be notified when the binding should be updated Ember . addObserver ( obj , fromPath , this , this . fromDidChange ) ; // if the binding is a two-way binding, also set up an observer on the target if ( ! this . _oneWay ) { Ember . addObserver ( obj , toPath , this , this . toDidChange ) ; } this . _readyToSync = true ; return this ; }


Input: Disconnects the binding instance . Changes will no longer be relayed . You will not usually need to call this method . [CODESPLIT] function ( obj ) { Ember . assert ( 'Must pass a valid object to Ember.Binding.disconnect()' , ! ! obj ) ; var twoWay = ! this . _oneWay ; // remove an observer on the object so we're no longer notified of // changes that should update bindings. Ember . removeObserver ( obj , this . _from , this , this . fromDidChange ) ; // if the binding is two-way, remove the observer from the target as well if ( twoWay ) { Ember . removeObserver ( obj , this . _to , this , this . toDidChange ) ; } this . _readyToSync = false ; // disable scheduled syncs... return this ; }


Input: Creates a new Binding instance and makes it apply in a single direction . A one - way binding will relay changes on the from side object ( supplied as the from argument ) the to side but not the other way around . This means that if you change the to side directly the from side may have a different value . [CODESPLIT] function ( from , flag ) { var C = this , binding = new C ( null , from ) ; return binding . oneWay ( flag ) ; }


Input: RSVP . filter is similar to JavaScript s native filter method except that it waits for all promises to become fulfilled before running the filterFn on each item in given to promises . RSVP . filter returns a promise that will become fulfilled with the result of running filterFn on the values the promises become fulfilled with . [CODESPLIT] function filter ( promises , filterFn , label ) { return all ( promises , label ) . then ( function ( values ) { if ( ! isArray ( promises ) ) { throw new TypeError ( 'You must pass an array to filter.' ) ; } if ( ! isFunction ( filterFn ) ) { throw new TypeError ( "You must pass a function to filter's second argument." ) ; } return map ( promises , filterFn , label ) . then ( function ( filterResults ) { var i , valuesLen = values . length , filtered = [ ] ; for ( i = 0 ; i < valuesLen ; i ++ ) { if ( filterResults [ i ] ) filtered . push ( values [ i ] ) ; } return filtered ; } ) ; } ) ; }


Input: A lightweight container that helps to assemble and decouple components . Public api for the container is still in flux . The public api specified on the application namespace should be considered the stable api . [CODESPLIT] function Container ( parent ) { this . parent = parent ; this . children = [ ] ; this . resolver = parent && parent . resolver || function ( ) { } ; this . registry = new InheritingDict ( parent && parent . registry ) ; this . cache = new InheritingDict ( parent && parent . cache ) ; this . factoryCache = new InheritingDict ( parent && parent . factoryCache ) ; this . resolveCache = new InheritingDict ( parent && parent . resolveCache ) ; this . typeInjections = new InheritingDict ( parent && parent . typeInjections ) ; this . injections = { } ; this . factoryTypeInjections = new InheritingDict ( parent && parent . factoryTypeInjections ) ; this . factoryInjections = { } ; this . _options = new InheritingDict ( parent && parent . _options ) ; this . _typeOptions = new InheritingDict ( parent && parent . _typeOptions ) ; }


Input: Registers a factory for later injection . [CODESPLIT] function ( fullName , factory , options ) { validateFullName ( fullName ) ; if ( factory === undefined ) { throw new TypeError ( 'Attempting to register an unknown factory: `' + fullName + '`' ) ; } var normalizedName = this . normalize ( fullName ) ; if ( this . cache . has ( normalizedName ) ) { throw new Error ( 'Cannot re-register: `' + fullName + '`, as it has already been looked up.' ) ; } this . registry . set ( normalizedName , factory ) ; this . _options . set ( normalizedName , options || { } ) ; }


Input: Unregister a fullName [CODESPLIT] function ( fullName ) { validateFullName ( fullName ) ; var normalizedName = this . normalize ( fullName ) ; this . registry . remove ( normalizedName ) ; this . cache . remove ( normalizedName ) ; this . factoryCache . remove ( normalizedName ) ; this . resolveCache . remove ( normalizedName ) ; this . _options . remove ( normalizedName ) ; }


Input: Given a fullName return the corresponding factory . [CODESPLIT] function ( fullName ) { validateFullName ( fullName ) ; var normalizedName = this . normalize ( fullName ) ; var cached = this . resolveCache . get ( normalizedName ) ; if ( cached ) { return cached ; } var resolved = this . resolver ( normalizedName ) || this . registry . get ( normalizedName ) ; this . resolveCache . set ( normalizedName , resolved ) ; return resolved ; }


Input: Used only via injection . [CODESPLIT] function ( type , property , fullName ) { validateFullName ( fullName ) ; if ( this . parent ) { illegalChildOperation ( 'typeInjection' ) ; } addTypeInjection ( this . typeInjections , type , property , fullName ) ; }


Input: Defines injection rules . [CODESPLIT] function ( fullName , property , injectionName ) { if ( this . parent ) { illegalChildOperation ( 'injection' ) ; } validateFullName ( injectionName ) ; var normalizedInjectionName = this . normalize ( injectionName ) ; if ( fullName . indexOf ( ':' ) === - 1 ) { return this . typeInjection ( fullName , property , normalizedInjectionName ) ; } validateFullName ( fullName ) ; var normalizedName = this . normalize ( fullName ) ; addInjection ( this . injections , normalizedName , property , normalizedInjectionName ) ; }


Input: Used only via factoryInjection . [CODESPLIT] function ( type , property , fullName ) { if ( this . parent ) { illegalChildOperation ( 'factoryTypeInjection' ) ; } addTypeInjection ( this . factoryTypeInjections , type , property , this . normalize ( fullName ) ) ; }


Input: Retrieve the value given a key if the value is present at the current level use it otherwise walk up the parent hierarchy and try again . If no matching key is found return undefined . [CODESPLIT] function ( key ) { var dict = this . dict ; if ( dict . hasOwnProperty ( key ) ) { return dict [ key ] ; } if ( this . parent ) { return this . parent . get ( key ) ; } }


Input: Check for the existence of given a key if the key is present at the current level return true otherwise walk up the parent hierarchy and try again . If no matching key is found return false . [CODESPLIT] function ( key ) { var dict = this . dict ; if ( dict . hasOwnProperty ( key ) ) { return true ; } if ( this . parent ) { return this . parent . has ( key ) ; } return false ; }


Input: Iterate and invoke a callback for each local key - value pair . [CODESPLIT] function ( callback , binding ) { var dict = this . dict ; for ( var prop in dict ) { if ( dict . hasOwnProperty ( prop ) ) { callback . call ( binding , prop , dict [ prop ] ) ; } } }


Input: Apply formatting options to the string . This will look for occurrences of %@ in your string and substitute them with the arguments you pass into this method . If you want to control the specific order of replacement you can add a number after the key as well to indicate which argument you want to insert . [CODESPLIT] function ( str , formats ) { // first, replace any ORDERED replacements. var idx = 0 ; // the current index for non-numerical replacements return str . replace ( / %@([0-9]+)? / g , function ( s , argIndex ) { argIndex = ( argIndex ) ? parseInt ( argIndex , 10 ) - 1 : idx ++ ; s = formats [ argIndex ] ; return ( s === null ) ? '(null)' : ( s === undefined ) ? '' : Ember . inspect ( s ) ; } ) ; }


Input: Formats the passed string but first looks up the string in the localized strings hash . This is a convenient way to localize text . See Ember . String . fmt () for more information on formatting . [CODESPLIT] function ( str , formats ) { str = Ember . STRINGS [ str ] || str ; return Ember . String . fmt ( str , formats ) ; }


Input: Replaces underscores spaces or camelCase with dashes . [CODESPLIT] function ( str ) { var cache = STRING_DASHERIZE_CACHE , hit = cache . hasOwnProperty ( str ) , ret ; if ( hit ) { return cache [ str ] ; } else { ret = Ember . String . decamelize ( str ) . replace ( STRING_DASHERIZE_REGEXP , '-' ) ; cache [ str ] = ret ; } return ret ; }


Input: Set the value of a property to the current value plus some amount . [CODESPLIT] function ( keyName , increment ) { if ( Ember . isNone ( increment ) ) { increment = 1 ; } Ember . assert ( "Must pass a numeric value to incrementProperty" , ( ! isNaN ( parseFloat ( increment ) ) && isFinite ( increment ) ) ) ; set ( this , keyName , ( get ( this , keyName ) || 0 ) + increment ) ; return get ( this , keyName ) ; }


Input: Set the value of a property to the current value minus some amount . [CODESPLIT] function ( keyName , decrement ) { if ( Ember . isNone ( decrement ) ) { decrement = 1 ; } Ember . assert ( "Must pass a numeric value to decrementProperty" , ( ! isNaN ( parseFloat ( decrement ) ) && isFinite ( decrement ) ) ) ; set ( this , keyName , ( get ( this , keyName ) || 0 ) - decrement ) ; return get ( this , keyName ) ; }


Input: Creates a new subclass . [CODESPLIT] function ( ) { var Class = makeCtor ( ) , proto ; Class . ClassMixin = Mixin . create ( this . ClassMixin ) ; Class . PrototypeMixin = Mixin . create ( this . PrototypeMixin ) ; Class . ClassMixin . ownerConstructor = Class ; Class . PrototypeMixin . ownerConstructor = Class ; reopen . apply ( Class . PrototypeMixin , arguments ) ; Class . superclass = this ; Class . __super__ = this . prototype ; proto = Class . prototype = o_create ( this . prototype ) ; proto . constructor = Class ; generateGuid ( proto ) ; meta ( proto ) . proto = proto ; // this will disable observers on prototype Class . ClassMixin . apply ( Class ) ; return Class ; }


Input: In some cases you may want to annotate computed properties with additional metadata about how they function or what values they operate on . For example computed property functions may close over variables that are then no longer available for introspection . [CODESPLIT] function ( key ) { var meta = this . proto ( ) [ META_KEY ] , desc = meta && meta . descs [ key ] ; Ember . assert ( "metaForProperty() could not find a computed property with key '" + key + "'." , ! ! desc && desc instanceof Ember . ComputedProperty ) ; return desc . _meta || { } ; }


Input: Iterate over each computed property for the class passing its name and any associated metadata ( see metaForProperty ) to the callback . [CODESPLIT] function ( callback , binding ) { var proto = this . proto ( ) , descs = meta ( proto ) . descs , empty = { } , property ; for ( var name in descs ) { property = descs [ name ] ; if ( property instanceof Ember . ComputedProperty ) { callback . call ( binding || this , name , property . _meta || empty ) ; } } }


Input: Returns an array with the items that do not have truthy values for key . You can pass an optional second argument with the target value . Otherwise this will match any property that evaluates to false . [CODESPLIT] function ( key , value ) { var exactValue = function ( item ) { return get ( item , key ) === value ; } , hasValue = function ( item ) { return ! ! get ( item , key ) ; } , use = ( arguments . length === 2 ? exactValue : hasValue ) ; return this . reject ( use ) ; }


Input: Returns a new enumerable that excludes the passed value . The default implementation returns an array regardless of the receiver type unless the receiver does not contain the value . [CODESPLIT] function ( value ) { if ( ! this . contains ( value ) ) return this ; // nothing to do var ret = Ember . A ( ) ; this . forEach ( function ( k ) { if ( k !== value ) ret [ ret . length ] = k ; } ) ; return ret ; }


Input: Returns a new enumerable that contains only unique values . The default implementation returns an array regardless of the receiver type . [CODESPLIT] function ( ) { var ret = Ember . A ( ) ; this . forEach ( function ( k ) { if ( a_indexOf ( ret , k ) < 0 ) ret . push ( k ) ; } ) ; return ret ; }


Input: .......................................................... ARRAY OBSERVERS Adds an array observer to the receiving array . The array observer object normally must implement two methods : [CODESPLIT] function ( target , opts ) { var willChange = ( opts && opts . willChange ) || 'arrayWillChange' , didChange = ( opts && opts . didChange ) || 'arrayDidChange' ; var hasObservers = get ( this , 'hasArrayObservers' ) ; if ( ! hasObservers ) Ember . propertyWillChange ( this , 'hasArrayObservers' ) ; Ember . addListener ( this , '@array:before' , target , willChange ) ; Ember . addListener ( this , '@array:change' , target , didChange ) ; if ( ! hasObservers ) Ember . propertyDidChange ( this , 'hasArrayObservers' ) ; return this ; }


Input: If you are implementing an object that supports Ember . Array call this method just before the array content changes to notify any observers and invalidate any related properties . Pass the starting index of the change as well as a delta of the amounts to change . [CODESPLIT] function ( startIdx , removeAmt , addAmt ) { // if no args are passed assume everything changes if ( startIdx === undefined ) { startIdx = 0 ; removeAmt = addAmt = - 1 ; } else { if ( removeAmt === undefined ) removeAmt = - 1 ; if ( addAmt === undefined ) addAmt = - 1 ; } // Make sure the @each proxy is set up if anyone is observing @each if ( Ember . isWatching ( this , '@each' ) ) { get ( this , '@each' ) ; } Ember . sendEvent ( this , '@array:before' , [ this , startIdx , removeAmt , addAmt ] ) ; var removing , lim ; if ( startIdx >= 0 && removeAmt >= 0 && get ( this , 'hasEnumerableObservers' ) ) { removing = [ ] ; lim = startIdx + removeAmt ; for ( var idx = startIdx ; idx < lim ; idx ++ ) removing . push ( this . objectAt ( idx ) ) ; } else { removing = removeAmt ; } this . enumerableContentWillChange ( removing , addAmt ) ; return this ; }


Input: If you are implementing an object that supports Ember . Array call this method just after the array content changes to notify any observers and invalidate any related properties . Pass the starting index of the change as well as a delta of the amounts to change . [CODESPLIT] function ( startIdx , removeAmt , addAmt ) { // if no args are passed assume everything changes if ( startIdx === undefined ) { startIdx = 0 ; removeAmt = addAmt = - 1 ; } else { if ( removeAmt === undefined ) removeAmt = - 1 ; if ( addAmt === undefined ) addAmt = - 1 ; } var adding , lim ; if ( startIdx >= 0 && addAmt >= 0 && get ( this , 'hasEnumerableObservers' ) ) { adding = [ ] ; lim = startIdx + addAmt ; for ( var idx = startIdx ; idx < lim ; idx ++ ) adding . push ( this . objectAt ( idx ) ) ; } else { adding = addAmt ; } this . enumerableContentDidChange ( removeAmt , adding ) ; Ember . sendEvent ( this , '@array:change' , [ this , startIdx , removeAmt , addAmt ] ) ; var length = get ( this , 'length' ) , cachedFirst = cacheFor ( this , 'firstObject' ) , cachedLast = cacheFor ( this , 'lastObject' ) ; if ( this . objectAt ( 0 ) !== cachedFirst ) { Ember . propertyWillChange ( this , 'firstObject' ) ; Ember . propertyDidChange ( this , 'firstObject' ) ; } if ( this . objectAt ( length - 1 ) !== cachedLast ) { Ember . propertyWillChange ( this , 'lastObject' ) ; Ember . propertyDidChange ( this , 'lastObject' ) ; } return this ; }


Input: A computed property whose dependent keys are arrays and which is updated with one at a time semantics . [CODESPLIT] function ReduceComputedProperty ( options ) { var cp = this ; this . options = options ; this . _dependentKeys = null ; // A map of dependentKey -> [itemProperty, ...] that tracks what properties of // items in the array we must track to update this property. this . _itemPropertyKeys = { } ; this . _previousItemPropertyKeys = { } ; this . readOnly ( ) ; this . cacheable ( ) ; this . recomputeOnce = function ( propertyName ) { // What we really want to do is coalesce by <cp, propertyName>. // We need a form of `scheduleOnce` that accepts an arbitrary token to // coalesce by, in addition to the target and method. Ember . run . once ( this , recompute , propertyName ) ; } ; var recompute = function ( propertyName ) { var dependentKeys = cp . _dependentKeys , meta = cp . _instanceMeta ( this , propertyName ) , callbacks = cp . _callbacks ( ) ; reset . call ( this , cp , propertyName ) ; meta . dependentArraysObserver . suspendArrayObservers ( function ( ) { forEach ( cp . _dependentKeys , function ( dependentKey ) { Ember . assert ( "dependent array " + dependentKey + " must be an `Ember.Array`.  " + "If you are not extending arrays, you will need to wrap native arrays with `Ember.A`" , ! ( Ember . isArray ( get ( this , dependentKey ) ) && ! Ember . Array . detect ( get ( this , dependentKey ) ) ) ) ; if ( ! partiallyRecomputeFor ( this , dependentKey ) ) { return ; } var dependentArray = get ( this , dependentKey ) , previousDependentArray = meta . dependentArrays [ dependentKey ] ; if ( dependentArray === previousDependentArray ) { // The array may be the same, but our item property keys may have // changed, so we set them up again.  We can't easily tell if they've // changed: the array may be the same object, but with different // contents. if ( cp . _previousItemPropertyKeys [ dependentKey ] ) { delete cp . _previousItemPropertyKeys [ dependentKey ] ; meta . dependentArraysObserver . setupPropertyObservers ( dependentKey , cp . _itemPropertyKeys [ dependentKey ] ) ; } } else { meta . dependentArrays [ dependentKey ] = dependentArray ; if ( previousDependentArray ) { meta . dependentArraysObserver . teardownObservers ( previousDependentArray , dependentKey ) ; } if ( dependentArray ) { meta . dependentArraysObserver . setupObservers ( dependentArray , dependentKey ) ; } } } , this ) ; } , this ) ; forEach ( cp . _dependentKeys , function ( dependentKey ) { if ( ! partiallyRecomputeFor ( this , dependentKey ) ) { return ; } var dependentArray = get ( this , dependentKey ) ; if ( dependentArray ) { addItems . call ( this , dependentArray , callbacks , cp , propertyName , meta ) ; } } , this ) ; } ; this . func = function ( propertyName ) { Ember . assert ( "Computed reduce values require at least one dependent key" , cp . _dependentKeys ) ; recompute . call ( this , propertyName ) ; return cp . _instanceMeta ( this , propertyName ) . getValue ( ) ; } ; }


Input: Adds each object in the passed enumerable to the receiver . [CODESPLIT] function ( objects ) { Ember . beginPropertyChanges ( this ) ; forEach ( objects , function ( obj ) { this . addObject ( obj ) ; } , this ) ; Ember . endPropertyChanges ( this ) ; return this ; }


Input: Removes each object in the passed enumerable from the receiver . [CODESPLIT] function ( objects ) { Ember . beginPropertyChanges ( this ) ; forEach ( objects , function ( obj ) { this . removeObject ( obj ) ; } , this ) ; Ember . endPropertyChanges ( this ) ; return this ; }


Input: This will use the primitive replace () method to insert an object at the specified index . [CODESPLIT] function ( idx , object ) { if ( idx > get ( this , 'length' ) ) throw new Ember . Error ( OUT_OF_RANGE_EXCEPTION ) ; this . replace ( idx , 0 , [ object ] ) ; return this ; }


Input: Pop object from array or nil if none are left . Works just like pop () but it is KVO - compliant . [CODESPLIT] function ( ) { var len = get ( this , 'length' ) ; if ( len === 0 ) return null ; var ret = this . objectAt ( len - 1 ) ; this . removeAt ( len - 1 , 1 ) ; return ret ; }


Input: .......................................................... IMPLEMENT Ember . MutableEnumerable [CODESPLIT] function ( obj ) { var loc = get ( this , 'length' ) || 0 ; while ( -- loc >= 0 ) { var curObject = this . objectAt ( loc ) ; if ( curObject === obj ) this . removeAt ( loc ) ; } return this ; }


Input: Send an action with an actionContext to a target . The action actionContext and target will be retrieved from properties of the object . For example : [CODESPLIT] function ( opts ) { opts = opts || { } ; var action = opts . action || get ( this , 'action' ) , target = opts . target || get ( this , 'targetObject' ) , actionContext = opts . actionContext ; function args ( options , actionName ) { var ret = [ ] ; if ( actionName ) { ret . push ( actionName ) ; } return ret . concat ( options ) ; } if ( typeof actionContext === 'undefined' ) { actionContext = get ( this , 'actionContextObject' ) || this ; } if ( target && action ) { var ret ; if ( target . send ) { ret = target . send . apply ( target , args ( actionContext , action ) ) ; } else { Ember . assert ( "The action '" + action + "' did not exist on " + target , typeof target [ action ] === 'function' ) ; ret = target [ action ] . apply ( target , args ( actionContext ) ) ; } if ( ret !== false ) ret = true ; return ret ; } else { return false ; } }


Input: Triggers a named event for the object . Any additional arguments will be passed as parameters to the functions that are subscribed to the event . [CODESPLIT] function ( name ) { var args = [ ] , i , l ; for ( i = 1 , l = arguments . length ; i < l ; i ++ ) { args . push ( arguments [ i ] ) ; } Ember . sendEvent ( this , name , args ) ; }


Input: Add handlers to be called when the Deferred object is resolved or rejected . [CODESPLIT] function ( resolve , reject , label ) { var deferred , promise , entity ; entity = this ; deferred = get ( this , '_deferred' ) ; promise = deferred . promise ; function fulfillmentHandler ( fulfillment ) { if ( fulfillment === promise ) { return resolve ( entity ) ; } else { return resolve ( fulfillment ) ; } } return promise . then ( resolve && fulfillmentHandler , reject , label ) ; }


Input: Resolve a Deferred object and call any doneCallbacks with the given args . [CODESPLIT] function ( value ) { var deferred , promise ; deferred = get ( this , '_deferred' ) ; promise = deferred . promise ; if ( value === this ) { deferred . resolve ( promise ) ; } else { deferred . resolve ( value ) ; } }


Input: The collection of functions keyed by name available on this ActionHandler as action targets . [CODESPLIT] function ( props ) { var hashName ; if ( ! props . _actions ) { Ember . assert ( "'actions' should not be a function" , typeof ( props . actions ) !== 'function' ) ; if ( typeOf ( props . actions ) === 'object' ) { hashName = 'actions' ; } else if ( typeOf ( props . events ) === 'object' ) { Ember . deprecate ( 'Action handlers contained in an `events` object are deprecated in favor of putting them in an `actions` object' , false ) ; hashName = 'events' ; } if ( hashName ) { props . _actions = Ember . merge ( props . _actions || { } , props [ hashName ] ) ; } delete props [ hashName ] ; } }


Input: Triggers a named action on the ActionHandler . Any parameters supplied after the actionName string will be passed as arguments to the action target function . [CODESPLIT] function ( actionName ) { var args = [ ] . slice . call ( arguments , 1 ) , target ; if ( this . _actions && this . _actions [ actionName ] ) { if ( this . _actions [ actionName ] . apply ( this , args ) === true ) { // handler returned true, so this action will bubble } else { return ; } } else if ( ! Ember . FEATURES . isEnabled ( 'ember-routing-drop-deprecated-action-style' ) && this . deprecatedSend && this . deprecatedSendHandles && this . deprecatedSendHandles ( actionName ) ) { Ember . warn ( "The current default is deprecated but will prefer to handle actions directly on the controller instead of a similarly named action in the actions hash. To turn off this deprecated feature set: Ember.FEATURES['ember-routing-drop-deprecated-action-style'] = true" ) ; if ( this . deprecatedSend . apply ( this , [ ] . slice . call ( arguments ) ) === true ) { // handler return true, so this action will bubble } else { return ; } } if ( target = get ( this , 'target' ) ) { Ember . assert ( "The `target` for " + this + " (" + target + ") does not have a `send` method" , typeof target . send === 'function' ) ; target . send . apply ( target , arguments ) ; } }


Input: Track that newItems were added to the tracked array at index . [CODESPLIT] function ( index , newItems ) { var count = get ( newItems , 'length' ) ; if ( count < 1 ) { return ; } var match = this . _findArrayOperation ( index ) , arrayOperation = match . operation , arrayOperationIndex = match . index , arrayOperationRangeStart = match . rangeStart , composeIndex , splitIndex , splitItems , splitArrayOperation , newArrayOperation ; newArrayOperation = new ArrayOperation ( INSERT , count , newItems ) ; if ( arrayOperation ) { if ( ! match . split ) { // insert left of arrayOperation this . _operations . splice ( arrayOperationIndex , 0 , newArrayOperation ) ; composeIndex = arrayOperationIndex ; } else { this . _split ( arrayOperationIndex , index - arrayOperationRangeStart , newArrayOperation ) ; composeIndex = arrayOperationIndex + 1 ; } } else { // insert at end this . _operations . push ( newArrayOperation ) ; composeIndex = arrayOperationIndex ; } this . _composeInsert ( composeIndex ) ; }


Input: Track that count items were removed at index . [CODESPLIT] function ( index , count ) { if ( count < 1 ) { return ; } var match = this . _findArrayOperation ( index ) , arrayOperation = match . operation , arrayOperationIndex = match . index , arrayOperationRangeStart = match . rangeStart , newArrayOperation , composeIndex ; newArrayOperation = new ArrayOperation ( DELETE , count ) ; if ( ! match . split ) { // insert left of arrayOperation this . _operations . splice ( arrayOperationIndex , 0 , newArrayOperation ) ; composeIndex = arrayOperationIndex ; } else { this . _split ( arrayOperationIndex , index - arrayOperationRangeStart , newArrayOperation ) ; composeIndex = arrayOperationIndex + 1 ; } return this . _composeDelete ( composeIndex ) ; }


Input: Apply all operations reducing them to retain : n for n the number of items in the array . [CODESPLIT] function ( callback ) { var items = [ ] , offset = 0 ; forEach ( this . _operations , function ( arrayOperation ) { callback ( arrayOperation . items , offset , arrayOperation . type ) ; if ( arrayOperation . type !== DELETE ) { offset += arrayOperation . count ; items = items . concat ( arrayOperation . items ) ; } } ) ; this . _operations = [ new ArrayOperation ( RETAIN , items . length , items ) ] ; }


Input: see SubArray for a better implementation . [CODESPLIT] function ( index ) { var newArrayOperation = this . _operations [ index ] , leftArrayOperation = this . _operations [ index - 1 ] , // may be undefined rightArrayOperation = this . _operations [ index + 1 ] , // may be undefined leftOp = leftArrayOperation && leftArrayOperation . type , rightOp = rightArrayOperation && rightArrayOperation . type ; if ( leftOp === INSERT ) { // merge left leftArrayOperation . count += newArrayOperation . count ; leftArrayOperation . items = leftArrayOperation . items . concat ( newArrayOperation . items ) ; if ( rightOp === INSERT ) { // also merge right (we have split an insert with an insert) leftArrayOperation . count += rightArrayOperation . count ; leftArrayOperation . items = leftArrayOperation . items . concat ( rightArrayOperation . items ) ; this . _operations . splice ( index , 2 ) ; } else { // only merge left this . _operations . splice ( index , 1 ) ; } } else if ( rightOp === INSERT ) { // merge right newArrayOperation . count += rightArrayOperation . count ; newArrayOperation . items = newArrayOperation . items . concat ( rightArrayOperation . items ) ; this . _operations . splice ( index + 1 , 1 ) ; } }


Input: Internal data structure to represent an array operation . [CODESPLIT] function ArrayOperation ( operation , count , items ) { this . type = operation ; // RETAIN | INSERT | DELETE this . count = count ; this . items = items ; }


Input: Internal data structure used to include information when looking up operations by item index . [CODESPLIT] function ArrayOperationMatch ( operation , index , split , rangeStart ) { this . operation = operation ; this . index = index ; this . split = split ; this . rangeStart = rangeStart ; }


Input: Track that an item was added to the tracked array . [CODESPLIT] function ( index , match ) { var returnValue = - 1 , itemType = match ? RETAIN : FILTER , self = this ; this . _findOperation ( index , function ( operation , operationIndex , rangeStart , rangeEnd , seenInSubArray ) { var newOperation , splitOperation ; if ( itemType === operation . type ) { ++ operation . count ; } else if ( index === rangeStart ) { // insert to the left of `operation` self . _operations . splice ( operationIndex , 0 , new Operation ( itemType , 1 ) ) ; } else { newOperation = new Operation ( itemType , 1 ) ; splitOperation = new Operation ( operation . type , rangeEnd - index + 1 ) ; operation . count = index - rangeStart ; self . _operations . splice ( operationIndex + 1 , 0 , newOperation , splitOperation ) ; } if ( match ) { if ( operation . type === RETAIN ) { returnValue = seenInSubArray + ( index - rangeStart ) ; } else { returnValue = seenInSubArray ; } } self . _composeAt ( operationIndex ) ; } , function ( seenInSubArray ) { self . _operations . push ( new Operation ( itemType , 1 ) ) ; if ( match ) { returnValue = seenInSubArray ; } self . _composeAt ( self . _operations . length - 1 ) ; } ) ; return returnValue ; }


Input: Track that an item was removed from the tracked array . [CODESPLIT] function ( index ) { var returnValue = - 1 , self = this ; this . _findOperation ( index , function ( operation , operationIndex , rangeStart , rangeEnd , seenInSubArray ) { if ( operation . type === RETAIN ) { returnValue = seenInSubArray + ( index - rangeStart ) ; } if ( operation . count > 1 ) { -- operation . count ; } else { self . _operations . splice ( operationIndex , 1 ) ; self . _composeAt ( operationIndex ) ; } } , function ( ) { throw new Ember . Error ( "Can't remove an item that has never been added." ) ; } ) ; return returnValue ; }


Input: You can directly access mapped properties by simply requesting them . The unknownProperty handler will generate an EachArray of each item . [CODESPLIT] function ( keyName , value ) { var ret ; ret = new EachArray ( this . _content , keyName , this ) ; Ember . defineProperty ( this , keyName , null , ret ) ; this . beginObservingContentKey ( keyName ) ; return ret ; }


Input: primitive for array support . [CODESPLIT] function ( idx , amt , objects ) { if ( this . isFrozen ) throw Ember . FROZEN_ERROR ; // if we replaced exactly the same number of items, then pass only the // replaced range. Otherwise, pass the full remaining array length // since everything has shifted var len = objects ? get ( objects , 'length' ) : 0 ; this . arrayContentWillChange ( idx , amt , len ) ; if ( len === 0 ) { this . splice ( idx , amt ) ; } else { replace ( this , idx , amt , objects ) ; } this . arrayContentDidChange ( idx , amt , len ) ; return this ; }


Input: Clears the set . This is useful if you want to reuse an existing set without having to recreate it . [CODESPLIT] function ( ) { if ( this . isFrozen ) { throw new Ember . Error ( Ember . FROZEN_ERROR ) ; } var len = get ( this , 'length' ) ; if ( len === 0 ) { return this ; } var guid ; this . enumerableContentWillChange ( len , 0 ) ; Ember . propertyWillChange ( this , 'firstObject' ) ; Ember . propertyWillChange ( this , 'lastObject' ) ; for ( var i = 0 ; i < len ; i ++ ) { guid = guidFor ( this [ i ] ) ; delete this [ guid ] ; delete this [ i ] ; } set ( this , 'length' , 0 ) ; Ember . propertyDidChange ( this , 'firstObject' ) ; Ember . propertyDidChange ( this , 'lastObject' ) ; this . enumerableContentDidChange ( len , 0 ) ; return this ; }


Input: Removes the last element from the set and returns it or null if it s empty . [CODESPLIT] function ( ) { if ( get ( this , 'isFrozen' ) ) throw new Ember . Error ( Ember . FROZEN_ERROR ) ; var obj = this . length > 0 ? this [ this . length - 1 ] : null ; this . remove ( obj ) ; return obj ; }


Input: Use this to find children by ID instead of using jQuery [CODESPLIT] function ( element , id ) { if ( element . getAttribute ( 'id' ) === id ) { return element ; } var len = element . childNodes . length , idx , node , found ; for ( idx = 0 ; idx < len ; idx ++ ) { node = element . childNodes [ idx ] ; found = node . nodeType === 1 && findChildById ( node , id ) ; if ( found ) { return found ; } } }


Input: Adds a class to the buffer which will be rendered to the class attribute . [CODESPLIT] function ( className ) { // lazily create elementClasses this . elementClasses = ( this . elementClasses || new ClassSet ( ) ) ; this . elementClasses . add ( className ) ; this . classes = this . elementClasses . list ; return this ; }


Input: duck type attribute functionality like jQuery so a render buffer can be used like a jQuery object in attribute binding scenarios . Adds an attribute which will be rendered to the element . [CODESPLIT] function ( name , value ) { var attributes = this . elementAttributes = ( this . elementAttributes || { } ) ; if ( arguments . length === 1 ) { return attributes [ name ] ; } else { attributes [ name ] = value ; } return this ; }


Input: Adds a property which will be rendered to the element . [CODESPLIT] function ( name , value ) { var properties = this . elementProperties = ( this . elementProperties || { } ) ; if ( arguments . length === 1 ) { return properties [ name ] ; } else { properties [ name ] = value ; } return this ; }


Input: Generates the HTML content for this buffer . [CODESPLIT] function ( ) { if ( this . _hasElement && this . _element ) { // Firefox versions < 11 do not have support for element.outerHTML. var thisElement = this . element ( ) , outerHTML = thisElement . outerHTML ; if ( typeof outerHTML === 'undefined' ) { return Ember . $ ( '<div/>' ) . append ( thisElement ) . html ( ) ; } return outerHTML ; } else { return this . innerString ( ) ; } }


Input: Sets up event listeners for standard browser events . [CODESPLIT] function ( addedEvents , rootElement ) { var event , events = get ( this , 'events' ) ; Ember . $ . extend ( events , addedEvents || { } ) ; if ( ! Ember . isNone ( rootElement ) ) { set ( this , 'rootElement' , rootElement ) ; } rootElement = Ember . $ ( get ( this , 'rootElement' ) ) ; Ember . assert ( fmt ( 'You cannot use the same root element (%@) multiple times in an Ember.Application' , [ rootElement . selector || rootElement [ 0 ] . tagName ] ) , ! rootElement . is ( '.ember-application' ) ) ; Ember . assert ( 'You cannot make a new Ember.Application using a root element that is a descendent of an existing Ember.Application' , ! rootElement . closest ( '.ember-application' ) . length ) ; Ember . assert ( 'You cannot make a new Ember.Application using a root element that is an ancestor of an existing Ember.Application' , ! rootElement . find ( '.ember-application' ) . length ) ; rootElement . addClass ( 'ember-application' ) ; Ember . assert ( 'Unable to add "ember-application" class to rootElement. Make sure you set rootElement to the body or an element in the body.' , rootElement . is ( '.ember-application' ) ) ; for ( event in events ) { if ( events . hasOwnProperty ( event ) ) { this . setupHandler ( rootElement , event , events [ event ] ) ; } } }


Input: Registers an event listener on the document . If the given event is triggered the provided event handler will be triggered on the target view . [CODESPLIT] function ( rootElement , event , eventName ) { var self = this ; rootElement . on ( event + '.ember' , '.ember-view' , function ( evt , triggeringManager ) { var view = Ember . View . views [ this . id ] , result = true , manager = null ; manager = self . _findNearestEventManager ( view , eventName ) ; if ( manager && manager !== triggeringManager ) { result = self . _dispatchEvent ( manager , evt , eventName , view ) ; } else if ( view ) { result = self . _bubbleEvent ( view , evt , eventName ) ; } else { evt . stopPropagation ( ) ; } return result ; } ) ; rootElement . on ( event + '.ember' , '[data-ember-action]' , function ( evt ) { var actionId = Ember . $ ( evt . currentTarget ) . attr ( 'data-ember-action' ) , action = Ember . Handlebars . ActionHelper . registeredActions [ actionId ] ; // We have to check for action here since in some cases, jQuery will trigger // an event on `removeChild` (i.e. focusout) after we've already torn down the // action handlers for the view. if ( action && action . eventName === eventName ) { return action . handler ( evt ) ; } } ) ; }


Input: Invoked by the view system when this view needs to produce an HTML representation . This method will create a new render buffer if needed then apply any default attributes such as class names and visibility . Finally the render () method is invoked which is responsible for doing the bulk of the rendering . [CODESPLIT] function ( parentBuffer , bufferOperation ) { var name = 'render.' + this . instrumentName , details = { } ; this . instrumentDetails ( details ) ; return Ember . instrument ( name , details , function instrumentRenderToBuffer ( ) { return this . _renderToBuffer ( parentBuffer , bufferOperation ) ; } , this ) ; }


Input: Override the default event firing from Ember . Evented to also call methods with the given name . [CODESPLIT] function ( name ) { this . _super . apply ( this , arguments ) ; var method = this [ name ] ; if ( method ) { var args = [ ] , i , l ; for ( i = 1 , l = arguments . length ; i < l ; i ++ ) { args . push ( arguments [ i ] ) ; } return method . apply ( this , args ) ; } }


Input: Return the nearest ancestor that is an instance of the provided class . [CODESPLIT] function ( klass ) { Ember . deprecate ( "nearestInstanceOf is deprecated and will be removed from future releases. Use nearestOfType." ) ; var view = get ( this , 'parentView' ) ; while ( view ) { if ( view instanceof klass ) { return view ; } view = get ( view , 'parentView' ) ; } }


Input: Return the nearest ancestor that has a given property . [CODESPLIT] function ( property ) { var view = get ( this , 'parentView' ) ; while ( view ) { if ( property in view ) { return view ; } view = get ( view , 'parentView' ) ; } }


Input: Return the nearest ancestor whose parent is an instance of klass . [CODESPLIT] function ( klass ) { var view = get ( this , 'parentView' ) ; while ( view ) { if ( get ( view , 'parentView' ) instanceof klass ) { return view ; } view = get ( view , 'parentView' ) ; } }


Input: Called on your view when it should push strings of HTML into a Ember . RenderBuffer . Most users will want to override the template or templateName properties instead of this method . [CODESPLIT] function ( buffer ) { // If this view has a layout, it is the responsibility of the // the layout to render the view's template. Otherwise, render the template // directly. var template = get ( this , 'layout' ) || get ( this , 'template' ) ; if ( template ) { var context = get ( this , 'context' ) ; var keywords = this . cloneKeywords ( ) ; var output ; var data = { view : this , buffer : buffer , isRenderData : true , keywords : keywords , insideGroup : get ( this , 'templateData.insideGroup' ) } ; // Invoke the template with the provided template context, which // is the view's controller by default. A hash of data is also passed that provides // the template with access to the view and render buffer. Ember . assert ( 'template must be a function. Did you mean to call Ember.Handlebars.compile("...") or specify templateName instead?' , typeof template === 'function' ) ; // The template should write directly to the render buffer instead // of returning a string. output = template ( context , { data : data } ) ; // If the template returned a string instead of writing to the buffer, // push the string onto the buffer. if ( output !== undefined ) { buffer . push ( output ) ; } } }


Input: Set up an observer on the context . If the property changes toggle the class name . [CODESPLIT] function ( ) { // Get the current value of the property newClass = this . _classStringForProperty ( binding ) ; elem = this . $ ( ) ; // If we had previously added a class to the element, remove it. if ( oldClass ) { elem . removeClass ( oldClass ) ; // Also remove from classNames so that if the view gets rerendered, // the class doesn't get added back to the DOM. classNames . removeObject ( oldClass ) ; } // If necessary, add a new class. Make sure we keep track of it so // it can be removed in the future. if ( newClass ) { elem . addClass ( newClass ) ; oldClass = newClass ; } else { oldClass = null ; } }


Input: Iterates through the view s attribute bindings sets up observers for each then applies the current value of the attributes to the passed render buffer . [CODESPLIT] function ( buffer , attributeBindings ) { var attributeValue , unspecifiedAttributeBindings = this . _unspecifiedAttributeBindings = this . _unspecifiedAttributeBindings || { } ; a_forEach ( attributeBindings , function ( binding ) { var split = binding . split ( ':' ) , property = split [ 0 ] , attributeName = split [ 1 ] || property ; if ( property in this ) { this . _setupAttributeBindingObservation ( property , attributeName ) ; // Determine the current value and add it to the render buffer // if necessary. attributeValue = get ( this , property ) ; Ember . View . applyAttributeBindings ( buffer , attributeName , attributeValue ) ; } else { unspecifiedAttributeBindings [ property ] = attributeName ; } } , this ) ; // Lazily setup setUnknownProperty after attributeBindings are initially applied this . setUnknownProperty = this . _setUnknownProperty ; }


Input: Gets defined after initialization by _applyAttributeBindings [CODESPLIT] function ( key , value ) { var attributeName = this . _unspecifiedAttributeBindings && this . _unspecifiedAttributeBindings [ key ] ; if ( attributeName ) { this . _setupAttributeBindingObservation ( key , attributeName ) ; } defineProperty ( this , key ) ; return set ( this , key , value ) ; }


Input: Run this callback on the current view ( unless includeSelf is false ) and recursively on child views . [CODESPLIT] function ( fn , includeSelf ) { var childViews = ( includeSelf === false ) ? this . _childViews : [ this ] ; var currentViews , view , currentChildViews ; while ( childViews . length ) { currentViews = childViews . slice ( ) ; childViews = [ ] ; for ( var i = 0 , l = currentViews . length ; i < l ; i ++ ) { view = currentViews [ i ] ; currentChildViews = view . _childViews ? view . _childViews . slice ( 0 ) : null ; fn ( view ) ; if ( currentChildViews ) { childViews . push . apply ( childViews , currentChildViews ) ; } } } }


Input: ....................................................... CORE DISPLAY METHODS Setup a view but do not finish waking it up . [CODESPLIT] function ( ) { this . elementId = this . elementId || guidFor ( this ) ; this . _super ( ) ; // setup child views. be sure to clone the child views array first this . _childViews = this . _childViews . slice ( ) ; Ember . assert ( "Only arrays are allowed for 'classNameBindings'" , Ember . typeOf ( this . classNameBindings ) === 'array' ) ; this . classNameBindings = Ember . A ( this . classNameBindings . slice ( ) ) ; Ember . assert ( "Only arrays are allowed for 'classNames'" , Ember . typeOf ( this . classNames ) === 'array' ) ; this . classNames = Ember . A ( this . classNames . slice ( ) ) ; }


Input: You must call destroy on a view to destroy the view ( and all of its child views ) . This will remove the view from any parent node then make sure that the DOM element managed by the view can be released by the memory manager . [CODESPLIT] function ( ) { var childViews = this . _childViews , // get parentView before calling super because it'll be destroyed nonVirtualParentView = get ( this , 'parentView' ) , viewName = this . viewName , childLen , i ; if ( ! this . _super ( ) ) { return ; } childLen = childViews . length ; for ( i = childLen - 1 ; i >= 0 ; i -- ) { childViews [ i ] . removedFromDOM = true ; } // remove from non-virtual parent view if viewName was specified if ( viewName && nonVirtualParentView ) { nonVirtualParentView . set ( viewName , null ) ; } childLen = childViews . length ; for ( i = childLen - 1 ; i >= 0 ; i -- ) { childViews [ i ] . destroy ( ) ; } return this ; }


Input: Instantiates a view to be added to the childViews array during view initialization . You generally will not call this method directly unless you are overriding createChildViews () . Note that this method will automatically configure the correct settings on the new view instance to act as a child of the parent . [CODESPLIT] function ( view , attrs ) { if ( ! view ) { throw new TypeError ( "createChildViews first argument must exist" ) ; } if ( view . isView && view . _parentView === this && view . container === this . container ) { return view ; } attrs = attrs || { } ; attrs . _parentView = this ; if ( Ember . CoreView . detect ( view ) ) { attrs . templateData = attrs . templateData || get ( this , 'templateData' ) ; attrs . container = this . container ; view = view . create ( attrs ) ; // don't set the property on a virtual view, as they are invisible to // consumers of the view API if ( view . viewName ) { set ( get ( this , 'concreteView' ) , view . viewName , view ) ; } } else if ( 'string' === typeof view ) { var fullName = 'view:' + view ; var View = this . container . lookupFactory ( fullName ) ; Ember . assert ( "Could not find view: '" + fullName + "'" , ! ! View ) ; attrs . templateData = get ( this , 'templateData' ) ; view = View . create ( attrs ) ; } else { Ember . assert ( 'You must pass instance or subclass of View' , view . isView ) ; attrs . container = this . container ; if ( ! get ( view , 'templateData' ) ) { attrs . templateData = get ( this , 'templateData' ) ; } Ember . setProperties ( view , attrs ) ; } return view ; }


Input: Parse a path and return an object which holds the parsed properties . [CODESPLIT] function ( path ) { var split = path . split ( ':' ) , propertyPath = split [ 0 ] , classNames = "" , className , falsyClassName ; // check if the property is defined as prop:class or prop:trueClass:falseClass if ( split . length > 1 ) { className = split [ 1 ] ; if ( split . length === 3 ) { falsyClassName = split [ 2 ] ; } classNames = ':' + className ; if ( falsyClassName ) { classNames += ":" + falsyClassName ; } } return { path : propertyPath , classNames : classNames , className : ( className === '' ) ? undefined : className , falsyClassName : falsyClassName } ; }


Input: a view leaves the preRender state once its element has been created ( createElement ) . [CODESPLIT] function ( view , fn ) { view . createElement ( ) ; var viewCollection = view . viewHierarchyCollection ( ) ; viewCollection . trigger ( 'willInsertElement' ) ; fn . call ( view ) ; // We transition to `inDOM` if the element exists in the DOM var element = view . get ( 'element' ) ; if ( document . body . contains ( element ) ) { viewCollection . transitionTo ( 'inDOM' , false ) ; viewCollection . trigger ( 'didInsertElement' ) ; } }


Input: when a view is rendered in a buffer appending a child view will render that view and append the resulting buffer into its buffer . [CODESPLIT] function ( view , childView , options ) { var buffer = view . buffer , _childViews = view . _childViews ; childView = view . createChildView ( childView , options ) ; if ( ! _childViews . length ) { _childViews = view . _childViews = _childViews . slice ( ) ; } _childViews . push ( childView ) ; childView . renderToBuffer ( buffer ) ; view . propertyDidChange ( 'childViews' ) ; return childView ; }


Input: when a view is rendered in a buffer destroying the element will simply destroy the buffer and put the state back into the preRender state . [CODESPLIT] function ( view ) { view . clearBuffer ( ) ; var viewCollection = view . _notifyWillDestroyElement ( ) ; viewCollection . transitionTo ( 'preRender' , false ) ; return view ; }


Input: once the view has been inserted into the DOM rerendering is deferred to allow bindings to synchronize . [CODESPLIT] function ( view ) { view . triggerRecursively ( 'willClearRender' ) ; view . clearRenderedChildren ( ) ; view . domManager . replace ( view ) ; return view ; }


Input: once the view is already in the DOM destroying it removes it from the DOM nukes its element and puts it back into the preRender state if inDOM . [CODESPLIT] function ( view ) { view . _notifyWillDestroyElement ( ) ; view . domManager . remove ( view ) ; set ( view , 'element' , null ) ; if ( view . _scheduledInsert ) { Ember . run . cancel ( view . _scheduledInsert ) ; view . _scheduledInsert = null ; } return view ; }


Input: Handle events from Ember . EventDispatcher [CODESPLIT] function ( view , eventName , evt ) { if ( view . has ( eventName ) ) { // Handler should be able to re-dispatch events, so we don't // preventDefault or stopPropagation. return view . trigger ( eventName , evt ) ; } else { return true ; // continue event propagation } }


Input: When a child view is removed destroy its element so that it is removed from the DOM . [CODESPLIT] function ( views , start , removed ) { this . propertyWillChange ( 'childViews' ) ; if ( removed > 0 ) { var changedViews = views . slice ( start , start + removed ) ; // transition to preRender before clearing parentView this . currentState . childViewsWillChange ( this , views , start , removed ) ; this . initializeViews ( changedViews , null , null ) ; } }


Input: When a child view is added make sure the DOM gets updated appropriately . [CODESPLIT] function ( views , start , removed , added ) { if ( added > 0 ) { var changedViews = views . slice ( start , start + added ) ; this . initializeViews ( changedViews , this , get ( this , 'templateData' ) ) ; this . currentState . childViewsDidChange ( this , views , start , added ) ; } this . propertyDidChange ( 'childViews' ) ; }


Input: Called when a mutation to the underlying content array will occur . [CODESPLIT] function ( content , start , removedCount ) { // If the contents were empty before and this template collection has an // empty view remove it now. var emptyView = get ( this , 'emptyView' ) ; if ( emptyView && emptyView instanceof Ember . View ) { emptyView . removeFromParent ( ) ; } // Loop through child views that correspond with the removed items. // Note that we loop from the end of the array to the beginning because // we are mutating it as we go. var childViews = this . _childViews , childView , idx , len ; len = this . _childViews . length ; var removingAll = removedCount === len ; if ( removingAll ) { this . currentState . empty ( this ) ; this . invokeRecursively ( function ( view ) { view . removedFromDOM = true ; } , false ) ; } for ( idx = start + removedCount - 1 ; idx >= start ; idx -- ) { childView = childViews [ idx ] ; childView . destroy ( ) ; } }


Input: Called when a mutation to the underlying content array occurs . [CODESPLIT] function ( content , start , removed , added ) { var addedViews = [ ] , view , item , idx , len , itemViewClass , emptyView ; len = content ? get ( content , 'length' ) : 0 ; if ( len ) { itemViewClass = get ( this , 'itemViewClass' ) ; if ( 'string' === typeof itemViewClass ) { itemViewClass = get ( itemViewClass ) || itemViewClass ; } Ember . assert ( fmt ( "itemViewClass must be a subclass of Ember.View, not %@" , [ itemViewClass ] ) , 'string' === typeof itemViewClass || Ember . View . detect ( itemViewClass ) ) ; for ( idx = start ; idx < start + added ; idx ++ ) { item = content . objectAt ( idx ) ; view = this . createChildView ( itemViewClass , { content : item , contentIndex : idx } ) ; addedViews . push ( view ) ; } } else { emptyView = get ( this , 'emptyView' ) ; if ( ! emptyView ) { return ; } if ( 'string' === typeof emptyView ) { emptyView = get ( emptyView ) || emptyView ; } emptyView = this . createChildView ( emptyView ) ; addedViews . push ( emptyView ) ; set ( this , 'emptyView' , emptyView ) ; if ( Ember . CoreView . detect ( emptyView ) ) { this . _createdEmptyView = emptyView ; } } this . replace ( start , 0 , addedViews ) ; }


Input: @private [CODESPLIT] function ( props ) { // must call _super here to ensure that the ActionHandler // mixin is setup properly (moves actions -> _actions) // // Calling super is only OK here since we KNOW that // there is another Mixin loaded first. this . _super . apply ( this , arguments ) ; var deprecatedProperty , replacementProperty , layoutSpecified = ( props . layoutName || props . layout || get ( this , 'layoutName' ) ) ; if ( props . templateName && ! layoutSpecified ) { deprecatedProperty = 'templateName' ; replacementProperty = 'layoutName' ; props . layoutName = props . templateName ; delete props [ 'templateName' ] ; } if ( props . template && ! layoutSpecified ) { deprecatedProperty = 'template' ; replacementProperty = 'layout' ; props . layout = props . template ; delete props [ 'template' ] ; } if ( deprecatedProperty ) { Ember . deprecate ( 'Do not specify ' + deprecatedProperty + ' on a Component, use ' + replacementProperty + ' instead.' , false ) ; } }


Input: Triggers a named action on the controller context where the component is used if this controller has registered for notifications of the action . [CODESPLIT] function ( action ) { var actionName , contexts = a_slice . call ( arguments , 1 ) ; // Send the default action if ( action === undefined ) { actionName = get ( this , 'action' ) ; Ember . assert ( "The default action was triggered on the component " + this . toString ( ) + ", but the action name (" + actionName + ") was not a string." , isNone ( actionName ) || typeof actionName === 'string' ) ; } else { actionName = get ( this , action ) ; Ember . assert ( "The " + action + " action was triggered on the component " + this . toString ( ) + ", but the action name (" + actionName + ") was not a string." , isNone ( actionName ) || typeof actionName === 'string' ) ; } // If no action name for that action could be found, just abort. if ( actionName === undefined ) { return ; } this . triggerAction ( { action : actionName , actionContext : contexts } ) ; }


Input: Constructor that supports either Metamorph ( foo ) or new Metamorph ( foo ) ; Takes a string of HTML as the argument . [CODESPLIT] function ( html ) { var self ; if ( this instanceof Metamorph ) { self = this ; } else { self = new K ( ) ; } self . innerHTML = html ; var myGuid = 'metamorph-' + ( guid ++ ) ; self . start = myGuid + '-start' ; self . end = myGuid + '-end' ; return self ; }


Input: / * Given a parent node and some HTML generate a set of nodes . Return the first node which will allow us to traverse the rest using nextSibling . [CODESPLIT] function ( parentNode , html ) { var arr = wrapMap [ parentNode . tagName . toLowerCase ( ) ] || wrapMap . _default ; var depth = arr [ 0 ] , start = arr [ 1 ] , end = arr [ 2 ] ; if ( needsShy ) { html = '' + html ; } var element = document . createElement ( 'div' ) ; setInnerHTML ( element , start + html + end ) ; for ( var i = 0 ; i <= depth ; i ++ ) { element = element . firstChild ; } // Look for  to remove it. if ( needsShy ) { var shyElement = element ; // Sometimes we get nameless elements with the shy inside while ( shyElement . nodeType === 1 && ! shyElement . nodeName ) { shyElement = shyElement . firstChild ; } // At this point it's the actual unicode character. if ( shyElement . nodeType === 3 && shyElement . nodeValue . charAt ( 0 ) === "\u00AD" ) { shyElement . nodeValue = shyElement . nodeValue . slice ( 1 ) ; } } return element ; }


Input: / * When automatically adding a tbody Internet Explorer inserts the tbody immediately before the first <tr > . Other browsers create it before the first node no matter what . [CODESPLIT] function ( start , end ) { if ( start . parentNode !== end . parentNode ) { end . parentNode . insertBefore ( start , end . parentNode . firstChild ) ; } }


Input: Renders the unbound form of an otherwise bound helper function . [CODESPLIT] function evaluateUnboundHelper ( context , fn , normalizedProperties , options ) { var args = [ ] , hash = options . hash , boundOptions = hash . boundOptions , types = slice . call ( options . types , 1 ) , loc , len , property , propertyType , boundOption ; for ( boundOption in boundOptions ) { if ( ! boundOptions . hasOwnProperty ( boundOption ) ) { continue ; } hash [ boundOption ] = Ember . Handlebars . get ( context , boundOptions [ boundOption ] , options ) ; } for ( loc = 0 , len = normalizedProperties . length ; loc < len ; ++ loc ) { property = normalizedProperties [ loc ] ; propertyType = types [ loc ] ; if ( propertyType === "ID" ) { args . push ( Ember . Handlebars . get ( property . root , property . path , options ) ) ; } else { args . push ( property . path ) ; } } args . push ( options ) ; return fn . apply ( context , args ) ; }


Input: This is messed up . [CODESPLIT] function ( view ) { var morph = view . morph ; view . transitionTo ( 'preRender' ) ; Ember . run . schedule ( 'render' , this , function renderMetamorphView ( ) { if ( view . isDestroying ) { return ; } view . clearRenderedChildren ( ) ; var buffer = view . renderToBuffer ( ) ; view . invokeRecursively ( function ( view ) { view . propertyWillChange ( 'element' ) ; } ) ; view . triggerRecursively ( 'willInsertElement' ) ; morph . replaceWith ( buffer . string ( ) ) ; view . transitionTo ( 'inDOM' ) ; view . invokeRecursively ( function ( view ) { view . propertyDidChange ( 'element' ) ; } ) ; view . triggerRecursively ( 'didInsertElement' ) ; notifyMutationListeners ( ) ; } ) ; }


Input: Binds a property into the DOM . This will create a hook in DOM that the KVO system will look for and update if the property changes . [CODESPLIT] function bind ( property , options , preserveContext , shouldDisplay , valueNormalizer , childProperties ) { var data = options . data , fn = options . fn , inverse = options . inverse , view = data . view , currentContext = this , normalized , observer , i ; normalized = normalizePath ( currentContext , property , data ) ; // Set up observers for observable objects if ( 'object' === typeof this ) { if ( data . insideGroup ) { observer = function ( ) { Ember . run . once ( view , 'rerender' ) ; } ; var template , context , result = handlebarsGet ( currentContext , property , options ) ; result = valueNormalizer ? valueNormalizer ( result ) : result ; context = preserveContext ? currentContext : result ; if ( shouldDisplay ( result ) ) { template = fn ; } else if ( inverse ) { template = inverse ; } template ( context , { data : options . data } ) ; } else { // Create the view that will wrap the output of this template/property // and add it to the nearest view's childViews array. // See the documentation of Ember._HandlebarsBoundView for more. var bindView = view . createChildView ( Ember . _HandlebarsBoundView , { preserveContext : preserveContext , shouldDisplayFunc : shouldDisplay , valueNormalizerFunc : valueNormalizer , displayTemplate : fn , inverseTemplate : inverse , path : property , pathRoot : currentContext , previousContext : currentContext , isEscaped : ! options . hash . unescaped , templateData : options . data } ) ; if ( options . hash . controller ) { bindView . set ( '_contextController' , this . container . lookupFactory ( 'controller:' + options . hash . controller ) . create ( { container : currentContext . container , parentController : currentContext , target : currentContext } ) ) ; } view . appendChild ( bindView ) ; observer = function ( ) { Ember . run . scheduleOnce ( 'render' , bindView , 'rerenderIfNeeded' ) ; } ; } // Observes the given property on the context and // tells the Ember._HandlebarsBoundView to re-render. If property // is an empty string, we are printing the current context // object ({{this}}) so updating it is not our responsibility. if ( normalized . path !== '' ) { view . registerObserver ( normalized . root , normalized . path , observer ) ; if ( childProperties ) { for ( i = 0 ; i < childProperties . length ; i ++ ) { view . registerObserver ( normalized . root , normalized . path + '.' + childProperties [ i ] , observer ) ; } } } } else { // The object is not observable, so just render it out and // be done with it. data . buffer . push ( handlebarsGetEscaped ( currentContext , property , options ) ) ; } }


Input: Transform bindings from the current context to a context that can be evaluated within the view . Returns null if the path shouldn t be changed . TODO : consider the addition of a prefix that would allow this method to return path . [CODESPLIT] function ( path , data ) { var normalized = Ember . Handlebars . normalizePath ( null , path , data ) ; if ( normalized . isKeyword ) { return 'templateData.keywords.' + path ; } else if ( Ember . isGlobalPath ( path ) ) { return null ; } else if ( path === 'this' || path === '' ) { return '_parentView.context' ; } else { return '_parentView.context.' + path ; } }


Input: Defeatureify doesn t seem to like nested functions that need to be removed [CODESPLIT] function _addMetamorphCheck ( ) { Ember . Handlebars . EachView . reopen ( { _checkMetamorph : Ember . on ( 'didInsertElement' , function ( ) { Ember . assert ( "The metamorph tags, " + this . morph . start + " and " + this . morph . end + ", have different parents.\nThe browser has fixed your template to output valid HTML (for example, check that you have properly closed all tags and have used a TBODY tag when creating a table with '{{#each}}')" , document . getElementById ( this . morph . start ) . parentNode === document . getElementById ( this . morph . end ) . parentNode ) ; } ) } ) ; }


Input: NOTE : this doesn t really belong here but here it shall remain until our ES6 transpiler can handle cyclical deps . [CODESPLIT] function ( intent , isIntermediate ) { var wasTransitioning = ! ! this . activeTransition ; var oldState = wasTransitioning ? this . activeTransition . state : this . state ; var newTransition ; var router = this ; try { var newState = intent . applyToState ( oldState , this . recognizer , this . getHandler , isIntermediate ) ; if ( handlerInfosEqual ( newState . handlerInfos , oldState . handlerInfos ) ) { // This is a no-op transition. See if query params changed. var queryParamChangelist = getChangelist ( oldState . queryParams , newState . queryParams ) ; if ( queryParamChangelist ) { // This is a little hacky but we need some way of storing // changed query params given that no activeTransition // is guaranteed to have occurred. this . _changedQueryParams = queryParamChangelist . changed ; trigger ( this , newState . handlerInfos , true , [ 'queryParamsDidChange' , queryParamChangelist . changed , queryParamChangelist . all , queryParamChangelist . removed ] ) ; this . _changedQueryParams = null ; if ( ! wasTransitioning && this . activeTransition ) { // One of the handlers in queryParamsDidChange // caused a transition. Just return that transition. return this . activeTransition ; } else { // Running queryParamsDidChange didn't change anything. // Just update query params and be on our way. oldState . queryParams = finalizeQueryParamChange ( this , newState . handlerInfos , newState . queryParams ) ; // We have to return a noop transition that will // perform a URL update at the end. This gives // the user the ability to set the url update // method (default is replaceState). newTransition = new Transition ( this ) ; newTransition . urlMethod = 'replace' ; newTransition . promise = newTransition . promise . then ( function ( result ) { updateURL ( newTransition , oldState , true ) ; if ( router . didTransition ) { router . didTransition ( router . currentHandlerInfos ) ; } return result ; } , null , promiseLabel ( "Transition complete" ) ) ; return newTransition ; } } // No-op. No need to create a new transition. return new Transition ( this ) ; } if ( isIntermediate ) { setupContexts ( this , newState ) ; return ; } // Create a new transition to the destination route. newTransition = new Transition ( this , intent , newState ) ; // Abort and usurp any previously active transition. if ( this . activeTransition ) { this . activeTransition . abort ( ) ; } this . activeTransition = newTransition ; // Transition promises by default resolve with resolved state. // For our purposes, swap out the promise to resolve // after the transition has been finalized. newTransition . promise = newTransition . promise . then ( function ( result ) { return router . async ( function ( ) { return finalizeTransition ( newTransition , result . state ) ; } , "Finalize transition" ) ; } , null , promiseLabel ( "Settle transition promise when transition is finalized" ) ) ; if ( ! wasTransitioning ) { trigger ( this , this . state . handlerInfos , true , [ 'willTransition' , newTransition ] ) ; } return newTransition ; } catch ( e ) { return new Transition ( this , intent , null , e ) ; } }


Input: Clears the current and target route handlers and triggers exit on each of them starting at the leaf and traversing up through its ancestors . [CODESPLIT] function ( ) { if ( this . state ) { forEach ( this . state . handlerInfos , function ( handlerInfo ) { var handler = handlerInfo . handler ; if ( handler . exit ) { handler . exit ( ) ; } } ) ; } this . state = new TransitionState ( ) ; this . currentHandlerInfos = null ; }


Input: var handler = handlerInfo . handler ; The entry point for handling a change to the URL ( usually via the back and forward button ) . [CODESPLIT] function ( url ) { // Perform a URL-based transition, but don't change // the URL afterward, since it already happened. var args = slice . call ( arguments ) ; if ( url . charAt ( 0 ) !== '/' ) { args [ 0 ] = '/' + url ; } return doTransition ( this , args ) . method ( 'replaceQuery' ) ; }


Input: @private [CODESPLIT] function setupContexts ( router , newState , transition ) { var partition = partitionHandlers ( router . state , newState ) ; forEach ( partition . exited , function ( handlerInfo ) { var handler = handlerInfo . handler ; delete handler . context ; if ( handler . exit ) { handler . exit ( ) ; } } ) ; var oldState = router . oldState = router . state ; router . state = newState ; var currentHandlerInfos = router . currentHandlerInfos = partition . unchanged . slice ( ) ; try { forEach ( partition . updatedContext , function ( handlerInfo ) { return handlerEnteredOrUpdated ( currentHandlerInfos , handlerInfo , false , transition ) ; } ) ; forEach ( partition . entered , function ( handlerInfo ) { return handlerEnteredOrUpdated ( currentHandlerInfos , handlerInfo , true , transition ) ; } ) ; } catch ( e ) { router . state = oldState ; router . currentHandlerInfos = oldState . handlerInfos ; throw e ; } router . state . queryParams = finalizeQueryParamChange ( router , currentHandlerInfos , newState . queryParams ) ; }


Input: @private [CODESPLIT] function handlerEnteredOrUpdated ( currentHandlerInfos , handlerInfo , enter , transition ) { var handler = handlerInfo . handler , context = handlerInfo . context ; if ( enter && handler . enter ) { handler . enter ( transition ) ; } if ( transition && transition . isAborted ) { throw new TransitionAborted ( ) ; } handler . context = context ; if ( handler . contextDidChange ) { handler . contextDidChange ( ) ; } if ( handler . setup ) { handler . setup ( context , transition ) ; } if ( transition && transition . isAborted ) { throw new TransitionAborted ( ) ; } currentHandlerInfos . push ( handlerInfo ) ; return true ; }


Input: @private [CODESPLIT] function doTransition ( router , args , isIntermediate ) { // Normalize blank transitions to root URL transitions. var name = args [ 0 ] || '/' ; var lastArg = args [ args . length - 1 ] ; var queryParams = { } ; if ( lastArg && lastArg . hasOwnProperty ( 'queryParams' ) ) { queryParams = pop . call ( args ) . queryParams ; } var intent ; if ( args . length === 0 ) { log ( router , "Updating query params" ) ; // A query param update is really just a transition // into the route you're already on. var handlerInfos = router . state . handlerInfos ; intent = new NamedTransitionIntent ( { name : handlerInfos [ handlerInfos . length - 1 ] . name , contexts : [ ] , queryParams : queryParams } ) ; } else if ( name . charAt ( 0 ) === '/' ) { log ( router , "Attempting URL transition to " + name ) ; intent = new URLTransitionIntent ( { url : name } ) ; } else { log ( router , "Attempting transition to " + name ) ; intent = new NamedTransitionIntent ( { name : args [ 0 ] , contexts : slice . call ( args , 1 ) , queryParams : queryParams } ) ; } return router . transitionByIntent ( intent , isIntermediate ) ; }


Input: @public [CODESPLIT] function ( ) { if ( this . isAborted ) { return this ; } log ( this . router , this . sequence , this . targetName + ": transition was aborted" ) ; this . isAborted = true ; this . isActive = false ; this . router . activeTransition = null ; return this ; }


Input: @public [CODESPLIT] function ( ) { var router = this . router ; return this . promise [ 'catch' ] ( function ( reason ) { if ( router . activeTransition ) { return router . activeTransition . followRedirects ( ) ; } return reject ( reason ) ; } ) ; }


Input: @private [CODESPLIT] function extractQueryParams ( array ) { var len = ( array && array . length ) , head , queryParams ; if ( len && len > 0 && array [ len - 1 ] && array [ len - 1 ] . hasOwnProperty ( 'queryParams' ) ) { queryParams = array [ len - 1 ] . queryParams ; head = slice . call ( array , 0 , len - 1 ) ; return [ head , queryParams ] ; } else { return [ array , null ] ; } }


Input: @private [CODESPLIT] function serialize ( handler , model , names ) { var object = { } ; if ( isParam ( model ) ) { object [ names [ 0 ] ] = model ; return object ; } // Use custom serialize if it exists. if ( handler . serialize ) { return handler . serialize ( model , names ) ; } if ( names . length !== 1 ) { return ; } var name = names [ 0 ] ; if ( / _id$ / . test ( name ) ) { object [ name ] = model . id ; } else { object [ name ] = model ; } return object ; }


Input: Initializes the current router instance and sets up the change handling event listeners used by the instances location implementation . [CODESPLIT] function ( ) { this . router = this . router || this . constructor . map ( Ember . K ) ; var router = this . router , location = get ( this , 'location' ) , container = this . container , self = this , initialURL = get ( this , 'initialURL' ) ; // Allow the Location class to cancel the router setup while it refreshes // the page if ( get ( location , 'cancelRouterSetup' ) ) { return ; } this . _setupRouter ( router , location ) ; container . register ( 'view:default' , DefaultView ) ; container . register ( 'view:toplevel' , Ember . View . extend ( ) ) ; location . onUpdateURL ( function ( url ) { self . handleURL ( url ) ; } ) ; if ( typeof initialURL === "undefined" ) { initialURL = location . getURL ( ) ; } this . handleURL ( initialURL ) ; }


Input: @private [CODESPLIT] function ( results , queryParams , callback ) { for ( var name in queryParams ) { var parts = name . split ( ':' ) ; var controller = controllerOrProtoFor ( parts [ 0 ] , this . container ) ; Ember . assert ( fmt ( "Could not lookup controller '%@' while setting up query params" , [ controller ] ) , controller ) ; // Now assign the final URL-serialized key-value pair, // e.g. "foo[propName]": "value" results [ queryParams [ name ] ] = get ( controller , parts [ 1 ] ) ; if ( callback ) { // Give callback a chance to override. callback ( name , queryParams [ name ] , name ) ; } } }


Input: This hook is the entry point for router . js [CODESPLIT] function ( context , transition ) { var controllerName = this . controllerName || this . routeName , controller = this . controllerFor ( controllerName , true ) ; if ( ! controller ) { controller = this . generateController ( controllerName , context ) ; } // Assign the route's controller so that it can more easily be // referenced in action handlers this . controller = controller ; if ( this . setupControllers ) { Ember . deprecate ( "Ember.Route.setupControllers is deprecated. Please use Ember.Route.setupController(controller, model) instead." ) ; this . setupControllers ( controller , context ) ; } else { this . setupController ( controller , context ) ; } if ( this . renderTemplates ) { Ember . deprecate ( "Ember.Route.renderTemplates is deprecated. Please use Ember.Route.renderTemplate(controller, model) instead." ) ; this . renderTemplates ( context ) ; } else { this . renderTemplate ( controller , context ) ; } }


Input: A hook you can implement to convert the URL into the model for this route . [CODESPLIT] function ( params , transition ) { var match , name , sawParams , value ; for ( var prop in params ) { if ( prop === 'queryParams' ) { continue ; } if ( match = prop . match ( / ^(.*)_id$ / ) ) { name = match [ 1 ] ; value = params [ prop ] ; } sawParams = true ; } if ( ! name && sawParams ) { return Ember . copy ( params ) ; } else if ( ! name ) { if ( transition . resolveIndex !== transition . state . handlerInfos . length - 1 ) { return ; } var parentModel = transition . state . handlerInfos [ transition . resolveIndex - 1 ] . context ; return parentModel ; } return this . findModel ( name , value ) ; }


Input: A hook you can implement to convert the route s model into parameters for the URL . [CODESPLIT] function ( model , params ) { if ( params . length < 1 ) { return ; } if ( ! model ) { return ; } var name = params [ 0 ] , object = { } ; if ( / _id$ / . test ( name ) && params . length === 1 ) { object [ name ] = get ( model , "id" ) ; } else { object = getProperties ( model , params ) ; } return object ; }


Input: Returns the controller for a particular route or name . [CODESPLIT] function ( name , _skipAssert ) { var container = this . container , route = container . lookup ( 'route:' + name ) , controller ; if ( route && route . controllerName ) { name = route . controllerName ; } controller = container . lookup ( 'controller:' + name ) ; // NOTE: We're specifically checking that skipAssert is true, because according //   to the old API the second parameter was model. We do not want people who //   passed a model to skip the assertion. Ember . assert ( "The controller named '" + name + "' could not be found. Make sure " + "that this route exists and has already been entered at least " + "once. If you are accessing a controller not associated with a " + "route, make sure the controller class is explicitly defined." , controller || _skipAssert === true ) ; return controller ; }


Input: Disconnects a view that has been rendered into an outlet . [CODESPLIT] function ( options ) { if ( ! options || typeof options === "string" ) { var outletName = options ; options = { } ; options . outlet = outletName ; } options . parentView = options . parentView ? options . parentView . replace ( / \/ / g , '.' ) : parentTemplate ( this ) ; options . outlet = options . outlet || 'main' ; var parentView = this . router . _lookupActiveView ( options . parentView ) ; if ( parentView ) { parentView . disconnectOutlet ( options . outlet ) ; } }


Input: @private [CODESPLIT] function ( ) { // Tear down the top level view if ( this . teardownTopLevelView ) { this . teardownTopLevelView ( ) ; } // Tear down any outlets rendered with 'into' var teardownOutletViews = this . teardownOutletViews || [ ] ; a_forEach ( teardownOutletViews , function ( teardownOutletView ) { teardownOutletView ( ) ; } ) ; delete this . teardownTopLevelView ; delete this . teardownOutletViews ; delete this . lastRenderedTemplate ; }


Input: This is called to setup observers that will trigger a rerender . [CODESPLIT] function ( ) { var helperParameters = this . parameters , linkTextPath = helperParameters . options . linkTextPath , paths = getResolvedPaths ( helperParameters ) , length = paths . length , path , i , normalizedPath ; if ( linkTextPath ) { normalizedPath = Ember . Handlebars . normalizePath ( helperParameters . context , linkTextPath , helperParameters . options . data ) ; this . registerObserver ( normalizedPath . root , normalizedPath . path , this , this . rerender ) ; } for ( i = 0 ; i < length ; i ++ ) { path = paths [ i ] ; if ( null === path ) { // A literal value was provided, not a path, so nothing to observe. continue ; } normalizedPath = Ember . Handlebars . normalizePath ( helperParameters . context , path , helperParameters . options . data ) ; this . registerObserver ( normalizedPath . root , normalizedPath . path , this , this . _paramsChanged ) ; } var queryParamsObject = this . queryParamsObject ; if ( queryParamsObject ) { var values = queryParamsObject . values ; // Install observers for all of the hash options // provided in the (query-params) subexpression. for ( var k in values ) { if ( ! values . hasOwnProperty ( k ) ) { continue ; } if ( queryParamsObject . types [ k ] === 'ID' ) { normalizedPath = Ember . Handlebars . normalizePath ( helperParameters . context , values [ k ] , helperParameters . options . data ) ; this . registerObserver ( normalizedPath . root , normalizedPath . path , this , this . _paramsChanged ) ; } } } }


Input: Event handler that invokes the link activating the associated route . [CODESPLIT] function ( event ) { if ( ! isSimpleClick ( event ) ) { return true ; } if ( this . preventDefault !== false ) { event . preventDefault ( ) ; } if ( this . bubbles === false ) { event . stopPropagation ( ) ; } if ( get ( this , '_isDisabled' ) ) { return false ; } if ( get ( this , 'loading' ) ) { Ember . Logger . warn ( "This link-to is in an inactive loading state because at least one of its parameters presently has a null/undefined value, or the provided route name is invalid." ) ; return false ; } var router = get ( this , 'router' ) , routeArgs = get ( this , 'routeArgs' ) ; var transition ; if ( get ( this , 'replace' ) ) { transition = router . replaceWith . apply ( router , routeArgs ) ; } else { transition = router . transitionTo . apply ( router , routeArgs ) ; } // Schedule eager URL update, but after we've given the transition // a chance to synchronously redirect. // We need to always generate the URL instead of using the href because // the href will include any rootURL set, but the router expects a URL // without it! Note that we don't use the first level router because it // calls location.formatURL(), which also would add the rootURL! var url = router . router . generate . apply ( router . router , get ( this , 'routeArgs' ) ) ; Ember . run . scheduleOnce ( 'routerTransitions' , this , this . _eagerUpdateUrl , transition , url ) ; }


Input: Transition the application into another route . The route may be either a single route or route path : [CODESPLIT] function ( ) { // target may be either another controller or a router var target = get ( this , 'target' ) , method = target . transitionToRoute || target . transitionTo ; return method . apply ( target , arguments ) ; }


Input: Transition into another route while replacing the current URL if possible . This will replace the current history entry instead of adding a new one . Beside that it is identical to transitionToRoute in all other respects . [CODESPLIT] function ( ) { // target may be either another controller or a router var target = get ( this , 'target' ) , method = target . replaceRoute || target . replaceWith ; return method . apply ( target , arguments ) ; }


Input: Determines if the view has already been created by checking if the view has the same constructor template and context as the view in the _outlets object . [CODESPLIT] function ( outletName , view ) { var existingView = get ( this , '_outlets.' + outletName ) ; return existingView && existingView . constructor === view . constructor && existingView . get ( 'template' ) === view . get ( 'template' ) && existingView . get ( 'context' ) === view . get ( 'context' ) ; }


Input: Gets an outlet that is pending disconnection and then nullifys the object on the _outlet object . [CODESPLIT] function ( ) { if ( this . isDestroyed ) return ; // _outlets will be gone anyway var outlets = get ( this , '_outlets' ) ; var pendingDisconnections = this . _pendingDisconnections ; this . _pendingDisconnections = null ; for ( var outletName in pendingDisconnections ) { set ( outlets , outletName , null ) ; } }


Input: Returns the current location . hash by parsing location . href since browsers inconsistently URL - decode location . hash . [CODESPLIT] function ( ) { // AutoLocation has it at _location, HashLocation at .location. // Being nice and not changing  var href = ( this . _location || this . location ) . href , hashIndex = href . indexOf ( '#' ) ; if ( hashIndex === - 1 ) { return '' ; } else { return href . substr ( hashIndex ) ; } }


Input: Replaces the current state . [CODESPLIT] function ( path ) { var state = { path : path } ; get ( this , 'history' ) . replaceState ( state , null , path ) ; // store state if browser doesn't support `history.state` if ( ! supportsHistoryState ) { this . _historyState = state ; } // used for webkit workaround this . _previousURL = this . getURL ( ) ; }


Input: Register a callback to be invoked whenever the browser history changes including using forward and back buttons . [CODESPLIT] function ( callback ) { var guid = Ember . guidFor ( this ) , self = this ; Ember . $ ( window ) . on ( 'popstate.ember-location-' + guid , function ( e ) { // Ignore initial page load popstate event in Chrome if ( ! popstateFired ) { popstateFired = true ; if ( self . getURL ( ) === self . _previousURL ) { return ; } } callback ( self . getURL ( ) ) ; } ) ; }


Input: @private [CODESPLIT] function ( ) { // Boosted from Modernizr: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js // The stock browser on Android 2.2 & 2.3 returns positive on history support // Unfortunately support is really buggy and there is no clean way to detect // these bugs, so we fall back to a user agent sniff :( var userAgent = this . _window . navigator . userAgent ; // We only want Android 2, stock browser, and not Chrome which identifies // itself as 'Mobile Safari' as well if ( userAgent . indexOf ( 'Android 2' ) !== - 1 && userAgent . indexOf ( 'Mobile Safari' ) !== - 1 && userAgent . indexOf ( 'Chrome' ) === - 1 ) { return false ; } return ! ! ( this . _history && 'pushState' in this . _history ) ; }


Input: @private [CODESPLIT] function ( ) { var window = this . _window , documentMode = window . document . documentMode ; return ( 'onhashchange' in window && ( documentMode === undefined || documentMode > 7 ) ) ; }