idx
int64
0
58k
question
stringlengths
46
4.3k
target
stringlengths
5
845
100
function ( ) { var behaviorEvents = _ . result ( this , 'events' ) ; var viewEvents = this . view . events ; if ( ! viewEvents ) { if ( ! behaviorEvents ) { return ; } else { viewEvents = { } ; } } var namespacedEvents = this . __namespaceEvents ( behaviorEvents ) ; var boundBehaviorEvents = this . __bindEventCallbacks...
Adds behavior s event handlers to view Behavior s event handlers fire on view events but are run in the context of the behavior
101
function ( eventHash ) { var delegateEventSplitter = / ^(\S+)\s*(.*)$ / ; var namespacedEvents = { } ; var behaviorId = this . cid ; _ . each ( eventHash , function ( value , key ) { var splitEventKey = key . match ( delegateEventSplitter ) ; var eventName = splitEventKey [ 1 ] ; var selector = splitEventKey [ 2 ] ; va...
Namespaces events in event hash
102
function ( name ) { if ( name === 'change' || name . indexOf ( 'change:' ) === 0 ) { View . prototype . trigger . apply ( this . view , arguments ) ; } if ( name . indexOf ( 'change:hide:' ) === 0 ) { this . view . render ( ) ; } NestedCell . prototype . trigger . apply ( this , arguments ) ; }
Retrigger view state change events on the view as well .
103
function ( el , template , context , opts ) { opts = opts || { } ; if ( _ . isString ( template ) ) { opts . newHTML = template ; } templateRenderer . render ( el , template , context , opts ) ; }
Hotswap rendering system reroute method .
104
function ( ) { this . undelegateEvents ( ) ; Backbone . View . prototype . delegateEvents . call ( this ) ; this . __generateFeedbackBindings ( ) ; this . __generateFeedbackCellCallbacks ( ) ; _ . each ( this . getTrackedViews ( ) , function ( view ) { if ( view . isAttachedToParent ( ) ) { view . delegateEvents ( ) ; ...
Overrides the base delegateEvents Binds DOM events with the view using events hash while also adding feedback event bindings
105
function ( ) { Backbone . View . prototype . undelegateEvents . call ( this ) ; _ . each ( this . getTrackedViews ( ) , function ( view ) { view . undelegateEvents ( ) ; } ) ; }
Overrides undelegateEvents Unbinds DOM events from the view .
106
function ( $el , options ) { options = options || { } ; var view = this ; if ( ! this . isAttachedToParent ( ) ) { this . __pendingAttachInfo = { $el : $el , options : options } ; return this . render ( ) . done ( function ( ) { if ( ! view . __attachedCallbackInvoked && view . isAttached ( ) ) { view . __invokeAttache...
If detached will replace the element passed in with this view s element and activate the view .
107
function ( ) { var wasAttached ; if ( this . isAttachedToParent ( ) ) { wasAttached = this . isAttached ( ) ; this . trigger ( 'before-dom-detach' ) ; if ( this . injectionSite ) { this . $el . replaceWith ( this . injectionSite ) ; this . injectionSite = undefined ; } else { this . $el . detach ( ) ; } if ( wasAttache...
If attached will detach the view from the DOM . This method will only separate this view from the DOM it was attached to but it WILL invoke the _detach callback on each tracked view recursively .
108
function ( ) { this . trigger ( 'before-dispose' ) ; this . trigger ( 'before-dispose-callback' ) ; this . _dispose ( ) ; this . detach ( ) ; this . deactivate ( ) ; this . __disposeChildViews ( ) ; if ( this . $el ) { this . remove ( ) ; } this . off ( ) ; this . stopListening ( ) ; if ( this . viewState ) { this . vi...
Removes all listeners disposes children views stops listening to events removes DOM . After dispose is called the view can be safely garbage collected . Called while recursively removing views from the hierarchy .
109
function ( view , options ) { options = options || { } ; this . unregisterTrackedView ( view ) ; if ( options . child || ! options . shared ) { this . __childViews [ view . cid ] = view ; } else { this . __sharedViews [ view . cid ] = view ; } return view ; }
Binds the view as a tracked view - any recursive calls like activate deactivate or dispose will be done to the tracked view as well . Except dispose for shared views . This method defaults to register the view as a child view unless specified by options . shared .
110
function ( options ) { var trackedViewsHash = this . getTrackedViews ( options ) ; _ . each ( trackedViewsHash , function ( view ) { this . unregisterTrackedView ( view , options ) ; } , this ) ; }
Unbinds all tracked view - no recursive calls will be made to this shared view You can limit the types of views that will be unregistered by using the options parameter .
111
function ( to , evt , indexMap ) { var result , feedbackToInvoke = _ . find ( this . feedback , function ( feedback ) { var toToCheck = feedback . to ; if ( _ . isArray ( toToCheck ) ) { return _ . contains ( toToCheck , to ) ; } else { return to === toToCheck ; } } ) , feedbackCellField = to ; if ( feedbackToInvoke ) ...
Invokes a feedback entry s then method
112
function ( viewOptions ) { var view = this ; if ( ! _ . isEmpty ( this . behaviors ) ) { view . __behaviorInstances = { } ; _ . each ( this . behaviors , function ( behaviorDefinition , alias ) { if ( ! _ . has ( behaviorDefinition , 'behavior' ) ) { behaviorDefinition = { behavior : behaviorDefinition } ; } var Behavi...
Initializes the behaviors
113
function ( injectionSiteName , previousView , newView , options ) { var newInjectionSite , currentPromise , previousDeferred = $ . Deferred ( ) ; this . attachView ( injectionSiteName , previousView , options ) ; options . cachedInjectionSite = previousView . injectionSite ; newInjectionSite = options . newInjectionSit...
Will transition out previousView at the same time as transitioning in newView .
114
function ( $el , newView , options ) { var currentDeferred = $ . Deferred ( ) , parentView = this ; options = _ . extend ( { } , options ) ; _ . defaults ( options , { parentView : this , newView : newView } ) ; newView . transitionIn ( function ( ) { parentView . attachView ( $el , newView , options ) ; } , currentDef...
Simliar to this . attachView except it utilizes the new view s transitionIn method instead of just attaching the view . This method is invoked on the parent view to attach a tracked view where the transitionIn method defines how a tracked view is brought onto the page .
115
function ( ) { var parentView = this ; this . __injectionSiteMap = { } ; this . __lastTrackedViews = { } ; _ . each ( this . getTrackedViews ( ) , function ( view ) { if ( view . isAttachedToParent ( ) && view . injectionSite ) { parentView . __injectionSiteMap [ view . injectionSite . attr ( 'inject' ) ] = view ; } pa...
Used internally by Torso . View to keep a cache of tracked views and their current injection sites before detaching during render logic .
116
function ( ) { if ( ! this . __attachedCallbackInvoked ) { this . trigger ( 'before-attached-callback' ) ; this . _attached ( ) ; this . __attachedCallbackInvoked = true ; _ . each ( this . getTrackedViews ( ) , function ( view ) { if ( view . isAttachedToParent ( ) ) { view . __invokeAttached ( ) ; } } ) ; } }
Call this method when a view is attached to the DOM . It is recursive to child views but checks whether each child view is attached .
117
function ( ) { if ( this . __attachedCallbackInvoked ) { this . trigger ( 'before-detached-callback' ) ; this . _detached ( ) ; this . __attachedCallbackInvoked = false ; } _ . each ( this . getTrackedViews ( ) , function ( view ) { if ( view . isAttachedToParent ( ) ) { view . __invokeDetached ( ) ; } } ) ; }
Call this method when a view is detached from the DOM . It is recursive to child views .
118
function ( result , feedbackCellField ) { var newState = $ . extend ( { } , result ) ; this . feedbackCell . set ( feedbackCellField , newState , { silent : true } ) ; this . feedbackCell . trigger ( 'change:' + feedbackCellField ) ; }
Processes the result of the then method . Adds to the feedback cell .
119
function ( bindInfo , eventKey ) { return function ( ) { var result , args = [ { args : arguments , type : eventKey } ] ; args . push ( bindInfo . indices ) ; result = bindInfo . fn . apply ( this , args ) ; this . __processFeedbackThenResult ( result , bindInfo . feedbackCellField ) ; } ; }
Returns a properly wrapped then using a configuration object bindInfo and an eventKey that will be passed as the type
120
function ( whenMap , indexMap ) { var self = this , events = [ ] ; _ . each ( whenMap , function ( whenEvents , whenField ) { var substitutedWhenField , qualifiedFields = [ whenField ] , useAtNotation = ( whenField . charAt ( 0 ) === '@' ) ; if ( whenField !== 'on' || whenField !== 'listenTo' ) { if ( useAtNotation ) {...
Generates the events needed to listen to the feedback s when methods . A when event is only created if the appropriate element exist on the page
121
function ( model , attr ) { var attrValidationSet = model . validation ? _ . result ( model , 'validation' ) [ attr ] || { } : { } ; if ( _ . isFunction ( attrValidationSet ) || _ . isString ( attrValidationSet ) ) { attrValidationSet = { fn : attrValidationSet } ; } if ( ! _ . isArray ( attrValidationSet ) ) { attrVal...
Looks on the model for validations for a specified attribute . Returns an array of any validators defined or an empty array if none is defined .
122
function ( model , attrs , validatedAttrs ) { var error , invalidAttrs = { } , isValid = true , computed = _ . clone ( attrs ) ; _ . each ( validatedAttrs , function ( val , attr ) { error = validateAttrWithOpenArray ( model , attr , val , computed ) ; if ( error ) { invalidAttrs [ attr ] = error ; isValid = false ; } ...
Loops through the model s attributes and validates the specified attrs . Returns and object containing names of invalid attributes as well as error messages .
123
function ( model , value , attr ) { var indices , validators , validations = model . validation ? _ . result ( model , 'validation' ) || { } : { } ; if ( _ . contains ( _ . keys ( validations ) , attr ) ) { return validateAttrWithOpenArray ( model , attr , value , _ . extend ( { } , model . attributes ) ) ; } else { in...
Validates attribute without open array notation .
124
function ( attr , value ) { var self = this , result = { } , error ; if ( _ . isArray ( attr ) ) { _ . each ( attr , function ( attr ) { error = self . preValidate ( attr ) ; if ( error ) { result [ attr ] = error ; } } ) ; return _ . isEmpty ( result ) ? undefined : result ; } else if ( _ . isObject ( attr ) ) { _ . e...
Check whether an attribute or a set of attributes are valid . It will default to use the model s current values but you can pass in different values to use in the validation process instead .
125
function ( value , attr , fn , model , computed , indices ) { return fn . call ( this , value , attr , model , computed , indices ) ; }
Allows the creation of an inline function that uses the validators context instead of the model context .
126
function ( value , attr , required , model , computed ) { var isRequired = _ . isFunction ( required ) ? required . call ( model , value , attr , computed ) : required ; if ( ! isRequired && ! hasValue ( value ) ) { return false ; } if ( isRequired && ! hasValue ( value ) ) { return this . format ( getMessageKey ( this...
Required validator Validates if the attribute is required or not This can be specified as either a boolean value or a function that returns a boolean value
127
function ( value , attr , maxValue , model ) { if ( ! isNumber ( value ) || value > maxValue ) { return this . format ( getMessageKey ( this . msgKey , defaultMessages . max ) , this . formatLabel ( attr , model ) , maxValue ) ; } }
Max validator Validates that the value has to be a number and equal to or less than the max value specified
128
function ( value , attr , range , model ) { if ( ! isNumber ( value ) || value < range [ 0 ] || value > range [ 1 ] ) { return this . format ( getMessageKey ( this . msgKey , defaultMessages . range ) , this . formatLabel ( attr , model ) , range [ 0 ] , range [ 1 ] ) ; } }
Range validator Validates that the value has to be a number and equal to or between the two numbers specified
129
function ( value , attr , minLength , model ) { if ( ! _ . isString ( value ) || value . length < minLength ) { return this . format ( getMessageKey ( this . msgKey , defaultMessages . minLength ) , this . formatLabel ( attr , model ) , minLength ) ; } }
Min length validator Validates that the value has to be a string with length equal to or greater than the min length value specified
130
function ( value , attr , maxLength , model ) { if ( ! _ . isString ( value ) || value . length > maxLength ) { return this . format ( getMessageKey ( this . msgKey , defaultMessages . maxLength ) , this . formatLabel ( attr , model ) , maxLength ) ; } }
Max length validator Validates that the value has to be a string with length equal to or less than the max length value specified
131
function ( value , attr , range , model ) { if ( ! _ . isString ( value ) || value . length < range [ 0 ] || value . length > range [ 1 ] ) { return this . format ( getMessageKey ( this . msgKey , defaultMessages . rangeLength ) , this . formatLabel ( attr , model ) , range [ 0 ] , range [ 1 ] ) ; } }
Range length validator Validates that the value has to be a string and equal to or between the two numbers specified
132
function ( value , attr , pattern , model ) { if ( ! hasValue ( value ) || ! value . toString ( ) . match ( defaultPatterns [ pattern ] || pattern ) ) { return this . format ( getMessageKey ( this . msgKey , defaultMessages [ pattern ] ) || defaultMessages . inlinePattern , this . formatLabel ( attr , model ) , pattern...
Pattern validator Validates that the value has to match the pattern specified . Can be a regular expression or the name of one of the built in patterns
133
function ( alias , model , copy ) { this . __currentObjectModels [ alias ] = model ; this . __updateCache ( model ) ; this . resetUpdating ( ) ; if ( copy ) { _ . each ( this . getMappings ( ) , function ( config , mappingAlias ) { var modelAliases ; if ( alias === mappingAlias ) { this . __pull ( mappingAlias ) ; } if...
Update or create a binding between an object model and an alias .
134
function ( models , copy ) { _ . each ( models , function ( instance , alias ) { this . trackModel ( alias , instance , copy ) ; } , this ) ; }
Binds multiple models to their aliases .
135
function ( aliasOrModel ) { var model , alias = this . __findAlias ( aliasOrModel ) ; if ( alias ) { model = this . __currentObjectModels [ alias ] ; delete this . __currentObjectModels [ alias ] ; this . __updateCache ( model ) ; } this . resetUpdating ( ) ; }
Removes the binding between a model alias and a model instance . Effectively stops tracking that model .
136
function ( ) { _ . each ( this . __currentUpdateEvents , function ( eventConfig ) { this . stopListening ( eventConfig . model , eventConfig . eventName ) ; } , this ) ; this . __currentUpdateEvents = [ ] ; }
This will stop the form model from listening to its object models .
137
function ( computedAlias ) { var hasAllModels = true , config = this . getMapping ( computedAlias ) , modelConfigs = [ ] ; _ . each ( this . __getModelAliases ( computedAlias ) , function ( modelAlias ) { var modelConfig = this . __createModelConfig ( modelAlias , config . mapping [ modelAlias ] ) ; if ( modelConfig ) ...
Repackages a computed mapping to be easier consumed by methods wanting the model mappings tied to the model instances . Returns a list of objects that contain the model instance and the mapping for that model .
138
function ( deferred , options ) { var staleModels , formModel = this , responsesSucceeded = 0 , responsesFailed = 0 , responses = { } , oldValues = { } , models = formModel . getTrackedModels ( ) , numberOfSaves = models . length ; if ( ! options . force ) { staleModels = formModel . checkIfModelsAreStale ( ) ; if ( st...
Pushes the form model values to the object models it is tracking and invokes save on each one . Returns a promise .
139
function responseCallback ( response , model , success ) { responses [ model . cid ] = { success : success , response : response } ; if ( responsesFailed + responsesSucceeded === numberOfSaves ) { if ( responsesFailed > 0 ) { if ( options . rollback ) { _ . each ( formModel . getTrackedModels ( ) , function ( model ) {...
Callback for each response
140
function ( alias ) { var config = this . getMapping ( alias ) ; if ( config . computed && config . mapping . pull ) { this . __invokeComputedPull . call ( { formModel : this , alias : alias } ) ; } else if ( config . computed ) { var modelAliases = this . __getModelAliases ( alias ) ; _ . each ( modelAliases , function...
Pulls in new information from tracked models using the mapping defined by the given alias . This works for both model mappings and computed value mappings
141
function ( alias ) { var config = this . getMapping ( alias ) ; if ( config . computed && config . mapping . push ) { var models = this . __getComputedModels ( alias ) ; if ( models ) { config . mapping . push . call ( this , models ) ; } } else if ( config . computed ) { var modelAliases = this . __getModelAliases ( a...
Pushes form model information to tracked models using the mapping defined by the given alias . This works for both model mappings and computed value mappings
142
function ( model ) { if ( ! model ) { this . __cache = { } ; _ . each ( this . getTrackedModels ( ) , function ( model ) { if ( model ) { this . __updateCache ( model ) ; } } , this ) ; } else { this . __cache [ model . cid ] = this . __generateHashValue ( model ) ; } }
Updates the form model s snapshot of the model s attributes to use later
143
function ( val ) { var seed ; if ( _ . isArray ( val ) ) { seed = [ ] ; } else if ( _ . isObject ( val ) ) { seed = { } ; } else { return val ; } return $ . extend ( true , seed , val ) ; }
Deep clones the attributes . There should be no functions in the attributes
144
function ( options ) { var mapping , models , defaultMapping = _ . result ( this , 'mapping' ) , defaultModels = _ . result ( this , 'models' ) ; mapping = options . mapping || defaultMapping ; models = options . models || defaultModels ; if ( mapping ) { this . setMappings ( mapping , models ) ; } }
Sets the mapping using the form model s default mapping or the options . mappings if available . Also sets the tracked models if the form model s default models or the options . models is provided .
145
function ( model ) { var allFields , fieldsUsed = { } , modelFields = { } , modelConfigs = [ ] ; _ . each ( this . __getAllModelConfigs ( ) , function ( modelConfig ) { if ( modelConfig . model && modelConfig . model . cid === model . cid ) { modelConfigs . push ( modelConfig ) ; } } ) ; allFields = _ . reduce ( modelC...
Returns a map where the keys are the fields that are being tracked on tracked model and values are the with current values of those fields .
146
function ( modelAlias , fields ) { var model = this . getTrackedModel ( modelAlias ) ; if ( model ) { return { fields : fields , model : model } ; } }
Returns a useful data structure that binds a tracked model to the fields being tracked on a mapping .
147
function ( ) { var modelConfigs = [ ] ; _ . each ( this . getMappings ( ) , function ( config , alias ) { if ( config . computed ) { var computedModelConfigs = this . __getComputedModelConfigs ( alias ) ; if ( computedModelConfigs ) { modelConfigs = modelConfigs . concat ( computedModelConfigs ) ; } } else { var modelC...
Returns an array of convenience data structures that bind tracked models to the fields they are tracking for each mapping including model mappings inside computed mappings . There will be a model config for each tracked model on a computed mapping meaning there can be multiple model configs for the same tracked model .
148
function ( args ) { View . apply ( this , arguments ) ; args = args || { } ; var collection = args . collection || this . collection ; this . template = args . template || this . template ; this . emptyTemplate = args . emptyTemplate || this . emptyTemplate ; this . itemView = args . itemView || this . itemView ; this ...
Constructor for the list view object .
149
function ( collection , preventUpdate ) { this . stopListening ( this . collection , 'remove' , removeItemView ) ; this . stopListening ( this . collection , 'add' , addItemView ) ; this . stopListening ( this . collection , 'sort' , this . reorder ) ; this . stopListening ( this . collection , 'reset' , this . update ...
Sets the collection from which this view generates item views . This method will attach all necessary event listeners to the new collection to auto - generate item views and has the option of removing listeners on a previous collection . It will immediately update child views and re - render if it is necessary - this b...
150
function ( ) { _ . each ( this . modelsToRender ( ) , function ( model ) { var itemView = this . getItemViewFromModel ( model ) ; if ( itemView ) { itemView . delegateEvents ( ) ; if ( ! itemView . __attachedCallbackInvoked && itemView . isAttached ( ) ) { itemView . __invokeAttached ( ) ; } itemView . activate ( ) ; }...
Completes each item view s lifecycle of being attached to a parent . Because the item views are attached in a non - standard way it s important to make sure that the item views are in the appropriate state after being attached as one fragment .
151
function ( ) { var oldViews = this . getItemViews ( ) ; var newViews = this . __createItemViews ( ) ; var staleViews = this . __getStaleItemViews ( ) ; var sizeOfOldViews = _ . size ( oldViews ) ; var sizeOfNewViews = _ . size ( newViews ) ; var sizeOfStaleViews = _ . size ( staleViews ) ; var sizeOfFinalViews = sizeOf...
Builds any new views removes stale ones and re - renders
152
function ( model , noUpdateToIdList ) { var itemView , ItemViewClass = this . itemView ; if ( ! _ . isFunction ( this . itemView . extend ) ) { ItemViewClass = this . itemView ( model ) ; } itemView = new ItemViewClass ( this . __generateItemViewArgs ( model ) ) ; this . registerTrackedView ( itemView , { shared : fals...
Creates an item view and stores a reference to it
153
function ( ) { var staleItemViews = [ ] ; var modelsWithViews = _ . clone ( this . __modelToViewMap ) ; _ . each ( this . modelsToRender ( ) , function ( model ) { var itemView = this . getItemViewFromModel ( model ) ; if ( itemView ) { delete modelsWithViews [ model [ this . __modelId ] ] ; } } , this ) ; _ . each ( m...
Gets all item views that have models that are no longer tracked by modelsToRender
154
function ( oldViews , newViews , staleViews ) { var firstItemViewLeft , injectionSite , view = this , sizeOfOldViews = _ . size ( oldViews ) , sizeOfNewViews = _ . size ( newViews ) , sizeOfStaleViews = _ . size ( staleViews ) ; if ( view . itemContainer && sizeOfOldViews && sizeOfOldViews == sizeOfStaleViews ) { injec...
Attempts to insert new views and remove stale views individually and correctly reorder all views in an attempt to be faster then a full view re - render
155
function normalizeIds ( ids ) { if ( _ . isArray ( ids ) ) { ids = _ . flatten ( ids ) ; return _ . uniq ( ids ) ; } else if ( _ . isString ( ids ) || _ . isNumber ( ids ) ) { return [ ids ] ; } else if ( ids && ids . skipObjectRetrieval ) { return ids ; } }
Converts string or number values into an array with a single string or number item . If the input is not a string number array or info about the ids then undefined is returned . This is a private helper method used internally by this behavior and is not exposed in any way .
156
function undefinedOrNullToEmptyArray ( valueToConvert ) { if ( _ . isUndefined ( valueToConvert ) || _ . isNull ( valueToConvert ) ) { valueToConvert = [ ] ; } return valueToConvert ; }
Converts any undefined or null values to an empty array . All other values are left unchanged .
157
function getNestedProperty ( rootObject , propertyString ) { propertyString = propertyString . replace ( / \[(\w+)\] / g , '.$1' ) ; propertyString = propertyString . replace ( / ^\. / , '' ) ; var propertyStringParts = propertyString . split ( PROPERTY_SEPARATOR ) ; return _ . reduce ( propertyStringParts , function (...
Gets a nested property from an object returning undefined if it doesn t exist on any level .
158
function ( ) { var behaviorContext = Behavior . prototype . prepare . apply ( this ) || { } ; behaviorContext . data = this . data . toJSON ( ) ; behaviorContext . loading = this . isLoading ( ) ; behaviorContext . loadingIds = this . isLoadingIds ( ) ; behaviorContext . loadingObjects = this . isLoadingObjects ( ) ; r...
Adds the toJSON of the data represented by this behavior to the context .
159
function ( ) { if ( ! _ . isUndefined ( this . ids . property ) ) { this . stopListeningToIdsPropertyChangeEvent ( ) ; var idsPropertyNameAndContext = this . __parseIdsPropertyNameAndIdContainer ( ) ; var idContainer = idsPropertyNameAndContext . idContainer ; var canListenToEvents = idContainer && _ . isFunction ( idC...
Listens for the change event on the ids property and if triggered re - fetches the data based on the new ids .
160
function ( ) { this . _undelegateUpdateEvents ( ) ; var updateEvents = this . __parseUpdateEvents ( ) ; _ . each ( updateEvents , function ( parsedUpdateEvent ) { this . listenTo ( parsedUpdateEvent . idContainer , parsedUpdateEvent . eventName , this . retrieve ) ; } , this ) ; }
Removes existing listeners and adds new ones for all of the updateEvents configured .
161
function ( ) { var updateEvents = this . __parseUpdateEvents ( ) ; _ . each ( updateEvents , function ( parsedUpdateEvent ) { this . stopListening ( parsedUpdateEvent . idContainer , parsedUpdateEvent . eventName , this . retrieve ) ; } , this ) ; }
Removes existing event listeners .
162
function ( ) { this . __normalizeAndValidateUpdateEvents ( ) ; var updateEvents = _ . flatten ( _ . map ( this . updateEvents , this . __parseUpdateEvent , this ) ) ; return _ . compact ( updateEvents ) ; }
Parses this . updateEvents configuration .
163
function ( ) { var updateEventsIsArray = _ . isArray ( this . updateEvents ) ; var updateEventsIsSingleValue = ! updateEventsIsArray && ( _ . isObject ( this . updateEvents ) || _ . isString ( this . updateEvents ) ) ; var updateEventsIsUndefined = _ . isUndefined ( this . updateEvents ) ; var updateEventsIsValidType =...
Validates that the updateEvents property is valid and if not throws an error describing why its not valid .
164
function ( updateEventConfiguration ) { var validStringConfig = _ . isString ( updateEventConfiguration ) ; var validObjectConfig = _ . isObject ( updateEventConfiguration ) && _ . keys ( updateEventConfiguration ) . length > 0 ; if ( ! validStringConfig && ! validObjectConfig ) { throw new Error ( 'Not a valid updateE...
Validates that the updateEventConfiguration is valid and if not throws an error describing why its not valid .
165
function ( ) { var propertyName = this . ids . property ; var propertyNameContainsIdContainer = containsContainerDefinition ( propertyName ) ; var hasIdContainerProperty = ! _ . isUndefined ( this . ids . idContainer ) ; var idContainer ; if ( hasIdContainerProperty ) { idContainer = this . __parseIdContainer ( ) ; } i...
Converts the definition into the actual idContainer object and property name to retrieve off of that idContainer .
166
function ( ) { var idContainerDefinition = this . ids . idContainer ; var idContainer ; if ( _ . isUndefined ( idContainerDefinition ) ) { idContainer = undefined ; } else if ( _ . isFunction ( idContainerDefinition ) ) { var idContainerFxn = _ . bind ( idContainerDefinition , this ) ; idContainer = idContainerFxn ( ) ...
Parses the idContainer property of ids .
167
function ( ) { var resultDeferred = $ . Deferred ( ) ; if ( this . isDisposed ( ) ) { var rejectArguments = Array . prototype . slice . call ( arguments ) ; rejectArguments . push ( 'Data Behavior disposed, aborting.' ) ; resultDeferred . reject . apply ( resultDeferred , rejectArguments ) ; } else { resultDeferred . r...
Rejects the promise chain if this behavior is already disposed .
168
function ( idsResult ) { if ( _ . isEmpty ( idsResult ) && _ . isEmpty ( this . data . privateCollection . getTrackedIds ( ) ) ) { return { skipObjectRetrieval : true , forceFetchedEvent : true } ; } else { return idsResult ; } }
Skip retrieving objects if new ids list is empty and existing ids list is empty .
169
function ( ) { var privateCollection = this . privateCollection ; if ( ! this . parentBehavior . returnSingleResult ) { return privateCollection . toJSON ( ) ; } if ( privateCollection . length === 0 ) { return undefined ; } else if ( privateCollection . length === 1 ) { var singleResultModel = privateCollection . at (...
Get the full data object contents . Either an array if returnSingleResult is false or a single object if it is true .
170
function ( args ) { args = args || { } ; var FormModelClass = args . FormModelClass || this . FormModelClass || FormModel ; this . model = args . model || this . model || ( new FormModelClass ( ) ) ; this . template = args . template || this . template ; this . events = _ . extend ( { } , this . events || { } , args . ...
Validation error hash
171
function ( ) { var templateContext = View . prototype . prepare . apply ( this ) ; templateContext . formErrors = ( _ . size ( this . _errors ) !== 0 ) ? this . _errors : null ; templateContext . formSuccess = this . _success ; return templateContext ; }
Prepare the formview s default render context
172
function ( model , stopListening ) { if ( this . model && stopListening ) { this . stopListening ( this . model ) ; } this . model = model ; this . listenTo ( this . model , 'validated:valid' , this . valid ) ; this . listenTo ( this . model , 'validated:invalid' , this . invalid ) ; }
Resets the form model with the passed in model . Stops listening to current form model and sets up listeners on the new one .
173
function deltaE ( labA , labB ) { var deltaL = labA [ 0 ] - labB [ 0 ] ; var deltaA = labA [ 1 ] - labB [ 1 ] ; var deltaB = labA [ 2 ] - labB [ 2 ] ; return Math . sqrt ( Math . pow ( deltaL , 2 ) + Math . pow ( deltaA , 2 ) + Math . pow ( deltaB , 2 ) ) ; }
Find the perceptual color distance between two LAB colors
174
function autoLayout ( ) { if ( ! clay . meta . activeWatchInfo || clay . meta . activeWatchInfo . firmware . major === 2 || [ 'aplite' , 'diorite' ] . indexOf ( clay . meta . activeWatchInfo . platform ) > - 1 && ! self . config . allowGray ) { return standardLayouts . BLACK_WHITE ; } if ( [ 'aplite' , 'diorite' ] . in...
Returns the layout based on the connected watch
175
function sources ( k ) { ( src [ k ] || [ ] ) . forEach ( function ( s ) { deps [ s ] = k ; sources ( s ) ; } ) ; }
collect source data set dependencies
176
function lib ( val ) { var p = path . join ( process . cwd ( ) , val ) ; return require ( p ) ; }
Returns a require d library from a path
177
function highlight ( value ) { var html = ngPrettyJsonFunctions . syntaxHighlight ( value ) || "" ; html = html . replace ( / \{ / g , "<span class='sep'>{</span>" ) . replace ( / \} / g , "<span class='sep'>}</span>" ) . replace ( / \[ / g , "<span class='sep'>[</span>" ) . replace ( / \] / g , "<span class='sep'>]</s...
prefer the json attribute over the prettyJson one . the value on the scope might not be defined yet so look at the markup .
178
function _populateMeta ( ) { self . meta = { activeWatchInfo : Pebble . getActiveWatchInfo && Pebble . getActiveWatchInfo ( ) , accountToken : Pebble . getAccountToken ( ) , watchToken : Pebble . getWatchToken ( ) , userData : deepcopy ( options . userData || { } ) } ; }
Populate the meta with data from the Pebble object . Make sure to run this inside either the showConfiguration or ready event handler
179
function initCasperCli ( casperArgs ) { var baseTestsPath = fs . pathJoin ( phantom . casperPath , 'tests' ) ; if ( ! ! casperArgs . options . version ) { return __terminate ( phantom . casperVersion . toString ( ) ) } else if ( casperArgs . get ( 0 ) === "test" ) { phantom . casperScript = fs . absolute ( fs . pathJoi...
Initializes the CasperJS Command Line Interface .
180
function setValueDisplay ( ) { var value = self . get ( ) . toFixed ( self . precision ) ; $value . set ( 'value' , value ) ; $valuePad . set ( 'innerHTML' , value ) ; }
Sets the value display
181
function keysInObject ( obj , keys ) { for ( var i in keys ) { if ( keys [ i ] in obj ) return true ; } return false ; }
Determines if any key in an array exists on an object .
182
function setValueDisplay ( ) { var selectedIndex = self . $manipulatorTarget . get ( 'selectedIndex' ) ; var $options = self . $manipulatorTarget . select ( 'option' ) ; var value = $options [ selectedIndex ] && $options [ selectedIndex ] . innerHTML ; $value . set ( 'innerHTML' , value ) ; }
Updates the HTML value of the component to match the slected option s label
183
function coerceElementMatchingCallback ( value ) { if ( typeof value === 'string' ) { return element => element . element === value ; } if ( value . constructor && value . extend ) { return element => element instanceof value ; } return value ; }
Coerces an a parameter into a callback for matching elements . This accepts an element name an element type and returns a callback to match for those elements .
184
function inFromVoid ( from , to ) { return to !== null && to !== 'nofx' && from === 'void' && to !== 'void' ? true : false ; }
used for showing
185
function ( event_type ) { var rest_args = arguments . length > 1 ? rest ( arguments ) : root , event = new CJSEvent ( false , false , function ( transition ) { var targets = [ ] , timeout_id = false , event_type_val = [ ] , listener = bind ( this . _fire , this ) , fsm = transition . getFSM ( ) , from = transition . ge...
Create a new event for use in a finite state machine transition
186
function ( ) { var args = slice . call ( arguments ) , constraint = options . args_map . getOrPut ( args , function ( ) { return new Constraint ( function ( ) { return getter_fn . apply ( options . context , args ) ; } ) ; } ) ; return constraint . get ( ) ; }
When getting a value either create a constraint or return the existing value
187
function ( silent ) { if ( options . on_destroy ) { options . on_destroy . call ( options . context , silent ) ; } node . destroy ( silent ) ; }
Destroy the node and make sure no memory is allocated
188
function ( ) { if ( paused === true ) { paused = false ; node . onChangeWithPriority ( options . priority , do_get ) ; if ( options . run_on_create !== false ) { if ( constraint_solver . semaphore >= 0 ) { node . get ( false ) ; } else { each ( node . _changeListeners , constraint_solver . add_in_call_stack , constrain...
Re - add to the event queue
189
function ( options ) { this . options = options ; this . targets = options . targets ; var setter = options . setter , getter = options . getter , init_val = options . init_val , curr_value , last_value , old_targets = [ ] , do_update = function ( ) { this . _timeout_id = false ; var new_targets = filter ( get_dom_arra...
A binding calls some arbitrary functions passed into options . It is responsible for keeping some aspect of a DOM node in line with a constraint value . For example it might keep an element s class name in sync with a class_name constraint
190
function ( ) { this . _timeout_id = false ; var new_targets = filter ( get_dom_array ( this . targets ) , isAnyElement ) ; if ( has ( options , "onChange" ) ) { options . onChange . call ( this , curr_value , last_value ) ; } each ( new_targets , function ( target ) { setter . call ( this , target , curr_value , last_v...
the DOM nodes
191
function ( infos , silent ) { each ( infos , function ( info ) { info . key . destroy ( silent ) ; info . value . destroy ( silent ) ; info . index . destroy ( silent ) ; } ) ; }
Deallocate memory from constraints
192
function ( index , silent ) { var info = this . _ordered_values [ index ] ; _destroy_info ( this . _ordered_values . splice ( index , 1 ) , silent ) ; if ( silent !== true ) { this . $size . invalidate ( ) ; } }
removes the selected item and destroys its value to deallocate it
193
function ( dom_node ) { var index = get_template_instance_index ( getFirstDOMChild ( dom_node ) ) , instance = index >= 0 ? template_instances [ index ] : false ; if ( instance ) { delete template_instances [ index ] ; instance . destroy ( ) ; } return this ; }
Destroy a template instance
194
function ( str , context ) { return cjs ( function ( ) { try { var node = jsep ( cjs . get ( str ) ) ; if ( node . type === LITERAL ) { return node . value ; } else { return get_node_value ( node , context , [ context ] ) ; } } catch ( e ) { console . error ( e ) ; } } ) ; }
Parses a string and returns a constraint whose value represents the result of eval ing that string
195
function promisify ( f , args ) { return new Promise ( ( resolve , reject ) => f . apply ( this , args . concat ( ( err , x ) => err ? reject ( err ) : resolve ( x ) ) ) ) ; }
Converts a callback style call to a Promise
196
function getKernelResources ( kernelInfo ) { return promisify ( fs . readdir , [ kernelInfo . resourceDir ] ) . then ( files => { const kernelJSONIndex = files . indexOf ( 'kernel.json' ) ; if ( kernelJSONIndex === - 1 ) { throw new Error ( 'kernel.json not found' ) ; } return promisify ( fs . readFile , [ path . join ...
Get a kernel resources object
197
function getKernelInfos ( directory ) { return promisify ( fs . readdir , [ directory ] ) . then ( files => files . map ( fileName => ( { name : fileName , resourceDir : path . join ( directory , fileName ) , } ) ) ) ; }
Gets a list of kernelInfo objects for a given directory of kernels
198
function find ( kernelName ) { return jp . dataDirs ( { withSysPrefix : true } ) . then ( dirs => { const kernelInfos = dirs . map ( dir => ( { name : kernelName , resourceDir : path . join ( dir , 'kernels' , kernelName ) , } ) ) return extractKernelResources ( kernelInfos ) ; } ) . then ( kernelResource => kernelReso...
find a kernel by name
199
function findAll ( ) { return jp . dataDirs ( { withSysPrefix : true } ) . then ( dirs => { return Promise . all ( dirs . map ( dir => getKernelInfos ( path . join ( dir , 'kernels' ) ) . catch ( ( ) => { } ) ) ) . then ( extractKernelResources ) } ) ; }
Get an array of kernelResources objects for the host environment This matches the Jupyter notebook API for kernelspecs exactly