@@ -90,13 +90,13 @@ function clickHook(
9090 type : TypeInfo ,
9191 getDef : ( ) => Def
9292) {
93- return function ( e : JQueryMouseEventObject ) {
93+ return function ( e : JQueryMouseEventObject ) {
9494 const button = e . which || e . button ,
9595 target = getDef ( ) ;
9696
9797 if ( ! ( button > 1 || e . ctrlKey || e . metaKey || e . shiftKey || el . attr ( 'target' ) ) ) {
9898 // HACK: This is to allow ng-clicks to be processed before the transition is initiated:
99- const transition = $timeout ( function ( ) {
99+ const transition = $timeout ( function ( ) {
100100 if ( ! el . attr ( 'disabled' ) ) {
101101 $state . go ( target . uiState , target . uiStateParams , target . uiStateOpts ) ;
102102 }
@@ -106,7 +106,7 @@ function clickHook(
106106 // if the state has no URL, ignore one preventDefault from the <a> directive.
107107 let ignorePreventDefaultCount = type . isAnchor && ! target . href ? 1 : 0 ;
108108
109- e . preventDefault = function ( ) {
109+ e . preventDefault = function ( ) {
110110 if ( ignorePreventDefaultCount -- <= 0 ) $timeout . cancel ( transition ) ;
111111 } ;
112112 }
@@ -139,7 +139,7 @@ function bindEvents(element: IAugmentedJQuery, scope: IScope, hookFn: EventListe
139139 element [ on ] ( event , hookFn ) ;
140140 }
141141
142- scope . $on ( '$destroy' , function ( ) {
142+ scope . $on ( '$destroy' , function ( ) {
143143 const off = element . off ? 'off' : 'unbind' ;
144144 for ( const event of events ) {
145145 element [ off ] ( event , hookFn as any ) ;
@@ -290,7 +290,7 @@ uiSrefDirective = [
290290 return {
291291 restrict : 'A' ,
292292 require : [ '?^uiSrefActive' , '?^uiSrefActiveEq' ] ,
293- link : function ( scope : IScope , element : IAugmentedJQuery , attrs : any , uiSrefActive : any ) {
293+ link : function ( scope : IScope , element : IAugmentedJQuery , attrs : any , uiSrefActive : any ) {
294294 const type = getTypeInfo ( element ) ;
295295 const active = uiSrefActive [ 1 ] || uiSrefActive [ 0 ] ;
296296 let unlinkInfoFn : Function = null ;
@@ -313,7 +313,7 @@ uiSrefDirective = [
313313 if ( ref . paramExpr ) {
314314 scope . $watch (
315315 ref . paramExpr ,
316- function ( val ) {
316+ function ( val ) {
317317 rawDef . uiStateParams = extend ( { } , val ) ;
318318 update ( ) ;
319319 } ,
@@ -429,7 +429,7 @@ uiStateDirective = [
429429 return {
430430 restrict : 'A' ,
431431 require : [ '?^uiSrefActive' , '?^uiSrefActiveEq' ] ,
432- link : function ( scope : IScope , element : IAugmentedJQuery , attrs : any , uiSrefActive : any ) {
432+ link : function ( scope : IScope , element : IAugmentedJQuery , attrs : any , uiSrefActive : any ) {
433433 const type = getTypeInfo ( element ) ;
434434 const active = uiSrefActive [ 1 ] || uiSrefActive [ 0 ] ;
435435 let unlinkInfoFn : Function = null ;
@@ -448,14 +448,14 @@ uiStateDirective = [
448448 if ( def . href != null ) attrs . $set ( type . attr , def . href ) ;
449449 }
450450
451- inputAttrs . forEach ( field => {
451+ inputAttrs . forEach ( ( field ) => {
452452 rawDef [ field ] = attrs [ field ] ? scope . $eval ( attrs [ field ] ) : null ;
453453
454- attrs . $observe ( field , expr => {
454+ attrs . $observe ( field , ( expr ) => {
455455 watchDeregFns [ field ] ( ) ;
456456 watchDeregFns [ field ] = scope . $watch (
457457 expr ,
458- newval => {
458+ ( newval ) => {
459459 rawDef [ field ] = newval ;
460460 update ( ) ;
461461 } ,
@@ -587,7 +587,7 @@ uiSrefActiveDirective = [
587587 '$scope' ,
588588 '$element' ,
589589 '$attrs' ,
590- function ( $scope : IScope , $element : IAugmentedJQuery , $attrs : any ) {
590+ function ( $scope : IScope , $element : IAugmentedJQuery , $attrs : any ) {
591591 let states : StateData [ ] = [ ] ;
592592 let activeEqClass : string ;
593593 let uiSrefActive : any ;
@@ -607,7 +607,7 @@ uiSrefActiveDirective = [
607607 setStatesFromDefinitionObject ( uiSrefActive ) ;
608608
609609 // Allow uiSref to communicate with uiSrefActive[Equals]
610- this . $$addStateInfo = function ( newState : string , newParams : Obj ) {
610+ this . $$addStateInfo = function ( newState : string , newParams : Obj ) {
611611 // we already got an explicit state provided by ui-sref-active, so we
612612 // shadow the one that comes from ui-sref
613613 if ( isObject ( uiSrefActive ) && states . length > 0 ) {
@@ -644,9 +644,9 @@ uiSrefActiveDirective = [
644644 function setStatesFromDefinitionObject ( statesDefinition : object ) {
645645 if ( isObject ( statesDefinition ) ) {
646646 states = [ ] ;
647- forEach ( statesDefinition , function ( stateOrName : StateOrName | Array < StateOrName > , activeClass : string ) {
647+ forEach ( statesDefinition , function ( stateOrName : StateOrName | Array < StateOrName > , activeClass : string ) {
648648 // Helper function to abstract adding state.
649- const addStateForClass = function ( stateOrName : string , activeClass : string ) {
649+ const addStateForClass = function ( stateOrName : string , activeClass : string ) {
650650 const ref = parseStateRef ( stateOrName ) ;
651651 addState ( ref . state , $scope . $eval ( ref . paramExpr ) , activeClass ) ;
652652 } ;
@@ -656,7 +656,7 @@ uiSrefActiveDirective = [
656656 addStateForClass ( stateOrName as string , activeClass ) ;
657657 } else if ( isArray ( stateOrName ) ) {
658658 // If state is an array, iterate over it and add each array item individually.
659- forEach ( stateOrName , function ( stateOrName : string ) {
659+ forEach ( stateOrName , function ( stateOrName : string ) {
660660 addStateForClass ( stateOrName , activeClass ) ;
661661 } ) ;
662662 }
@@ -682,26 +682,24 @@ uiSrefActiveDirective = [
682682
683683 // Update route state
684684 function update ( ) {
685- const splitClasses = str => str . split ( / \s / ) . filter ( identity ) ;
685+ const splitClasses = ( str ) => str . split ( / \s / ) . filter ( identity ) ;
686686 const getClasses = ( stateList : StateData [ ] ) =>
687687 stateList
688- . map ( x => x . activeClass )
688+ . map ( ( x ) => x . activeClass )
689689 . map ( splitClasses )
690690 . reduce ( unnestR , [ ] ) ;
691691
692- const allClasses = getClasses ( states )
693- . concat ( splitClasses ( activeEqClass ) )
694- . reduce ( uniqR , [ ] ) ;
695- const fuzzyClasses = getClasses ( states . filter ( x => $state . includes ( x . state . name , x . params ) ) ) ;
696- const exactlyMatchesAny = ! ! states . filter ( x => $state . is ( x . state . name , x . params ) ) . length ;
692+ const allClasses = getClasses ( states ) . concat ( splitClasses ( activeEqClass ) ) . reduce ( uniqR , [ ] ) ;
693+ const fuzzyClasses = getClasses ( states . filter ( ( x ) => $state . includes ( x . state . name , x . params ) ) ) ;
694+ const exactlyMatchesAny = ! ! states . filter ( ( x ) => $state . is ( x . state . name , x . params ) ) . length ;
697695 const exactClasses = exactlyMatchesAny ? splitClasses ( activeEqClass ) : [ ] ;
698696
699697 const addClasses = fuzzyClasses . concat ( exactClasses ) . reduce ( uniqR , [ ] ) ;
700- const removeClasses = allClasses . filter ( cls => ! inArray ( addClasses , cls ) ) ;
698+ const removeClasses = allClasses . filter ( ( cls ) => ! inArray ( addClasses , cls ) ) ;
701699
702700 $scope . $evalAsync ( ( ) => {
703- addClasses . forEach ( className => $element . addClass ( className ) ) ;
704- removeClasses . forEach ( className => $element . removeClass ( className ) ) ;
701+ addClasses . forEach ( ( className ) => $element . addClass ( className ) ) ;
702+ removeClasses . forEach ( ( className ) => $element . removeClass ( className ) ) ;
705703 } ) ;
706704 }
707705
0 commit comments