Skip to content

Commit

Permalink
refactor(UIRouter): Switched symbol names from Ui* to UI* (upper case…
Browse files Browse the repository at this point in the history
… UI)

BC-BREAK: UIRouter class names no longer have mixed case Ui. They now have upper case UI.
- UiView -> UIView
- UiSref -> UISref (and related directives)
- UiInjector -> UIInjector
  • Loading branch information
christopherthielen committed Jun 30, 2016
1 parent aa37ee7 commit 822fc10
Show file tree
Hide file tree
Showing 30 changed files with 179 additions and 179 deletions.
2 changes: 1 addition & 1 deletion src/common/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* An interface for getting values from dependency injection.
*/
export interface UiInjector {
export interface UIInjector {
/**
* Gets a value from the injector
*
Expand Down
18 changes: 9 additions & 9 deletions src/common/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import {parse} from "../common/hof";
import {isNumber} from "../common/predicates";
import {Transition} from "../transition/transition";
import {ActiveUiView, ViewConfig} from "../view/interface";
import {ActiveUIView, ViewConfig} from "../view/interface";
import {stringify, functionToString, maxLength, padString} from "./strings";
import {Resolvable} from "../resolve/resolvable";
import {PathNode} from "../path/node";
Expand Down Expand Up @@ -211,27 +211,27 @@ export class Trace {
}

/** called by ui-router code */
traceUiViewEvent(event: string, viewData: ActiveUiView, extra = "") {
traceUIViewEvent(event: string, viewData: ActiveUIView, extra = "") {
if (!this.enabled(Category.UIVIEW)) return;
console.log(`ui-view: ${padString(30, event)} ${uiViewString(viewData)}${extra}`);
}

/** called by ui-router code */
traceUiViewConfigUpdated(viewData: ActiveUiView, context) {
traceUIViewConfigUpdated(viewData: ActiveUIView, context) {
if (!this.enabled(Category.UIVIEW)) return;
this.traceUiViewEvent("Updating", viewData, ` with ViewConfig from context='${context}'`);
this.traceUIViewEvent("Updating", viewData, ` with ViewConfig from context='${context}'`);
}

/** called by ui-router code */
traceUiViewScopeCreated(viewData: ActiveUiView, newScope) {
traceUIViewScopeCreated(viewData: ActiveUIView, newScope) {
if (!this.enabled(Category.UIVIEW)) return;
this.traceUiViewEvent("Created scope for", viewData, `, scope #${newScope.$id}`);
this.traceUIViewEvent("Created scope for", viewData, `, scope #${newScope.$id}`);
}

/** called by ui-router code */
traceUiViewFill(viewData: ActiveUiView, html) {
traceUIViewFill(viewData: ActiveUIView, html) {
if (!this.enabled(Category.UIVIEW)) return;
this.traceUiViewEvent("Fill", viewData, ` with: ${maxLength(200, html)}`);
this.traceUIViewEvent("Fill", viewData, ` with: ${maxLength(200, html)}`);
}

/** called by ui-router code */
Expand All @@ -241,7 +241,7 @@ export class Trace {
}

/** called by ui-router code */
traceViewServiceUiViewEvent(event: string, viewData: ActiveUiView) {
traceViewServiceUIViewEvent(event: string, viewData: ActiveUIView) {
if (!this.enabled(Category.VIEWCONFIG)) return;
console.log(`VIEWCONFIG: ${event} ${uiViewString(viewData)}`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export * from "./url/module";
export * from "./view/module";
export * from "./globals";

export { UiRouter } from "./router";
export { UIRouter } from "./router";
4 changes: 2 additions & 2 deletions src/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {Observable} from "rxjs/Rx";
* This is where we hold the global mutable state such as current state, current
* params, current transition, etc.
*/
export interface UiRouterGlobals {
export interface UIRouterGlobals {
/**
* Current parameter values
*
Expand Down Expand Up @@ -43,7 +43,7 @@ export interface UiRouterGlobals {
/**
* Global mutable state
*/
export class Globals implements UiRouterGlobals {
export class Globals implements UIRouterGlobals {
params: StateParams = new StateParams();
current: StateDeclaration;
$current: State;
Expand Down
4 changes: 2 additions & 2 deletions src/ng1/directives/stateDirectives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/ /** for typedoc */
import {extend, forEach, toJson, tail} from "../../common/common";
import {isString, isObject} from "../../common/predicates";
import {UiViewData} from "./viewDirective";
import {UIViewData} from "./viewDirective";
import {parse} from "../../common/hof";
import {PathNode} from "../../path/node";

Expand All @@ -22,7 +22,7 @@ function parseStateRef(ref, current) {

/** @hidden */
function stateContext(el) {
let $uiView: UiViewData = el.parent().inheritedData('$uiView');
let $uiView: UIViewData = el.parent().inheritedData('$uiView');
let path: PathNode[] = parse('$cfg.path')($uiView);
return path ? tail(path).state.name : undefined;
}
Expand Down
36 changes: 18 additions & 18 deletions src/ng1/directives/viewDirective.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import {extend, unnestR, filter, tail} from "../../common/common";
import {isDefined, isFunction, isString} from "../../common/predicates";
import {trace} from "../../common/trace";
import {ActiveUiView} from "../../view/interface";
import {ActiveUIView} from "../../view/interface";
import {Ng1ViewConfig} from "../statebuilders/views";
import {TransitionService} from "../../transition/transitionService";
import {parse} from "../../common/hof";
Expand All @@ -17,9 +17,9 @@ import {Ng1Controller, Ng1StateDeclaration} from "../interface";
import {getLocals} from "../services";

/** @hidden */
export type UiViewData = {
export type UIViewData = {
$cfg: Ng1ViewConfig;
$uiView: ActiveUiView;
$uiView: ActiveUIView;

$animEnter: Promise<any>;
$animLeave: Promise<any>;
Expand Down Expand Up @@ -203,7 +203,7 @@ function $ViewDirective( $view, $animate, $uiViewScroll, $interpolate,
inherited = $element.inheritedData('$uiView') || rootData,
name = $interpolate(attrs.uiView || attrs.name || '')(scope) || '$default';

let activeUiView: ActiveUiView = {
let activeUIView: ActiveUIView = {
$type: 'ng1',
id: directive.count++, // Global sequential ID for ui-view tags added to DOM
name: name, // ui-view name (<div ui-view="name"></div>
Expand All @@ -215,43 +215,43 @@ function $ViewDirective( $view, $animate, $uiViewScroll, $interpolate,
}
};

trace.traceUiViewEvent("Linking", activeUiView);
trace.traceUIViewEvent("Linking", activeUIView);

function configUpdatedCallback(config?: Ng1ViewConfig) {
if (config && !(config instanceof Ng1ViewConfig)) return;
if (configsEqual(viewConfig, config)) return;
trace.traceUiViewConfigUpdated(activeUiView, config && config.viewDecl && config.viewDecl.$context);
trace.traceUIViewConfigUpdated(activeUIView, config && config.viewDecl && config.viewDecl.$context);

viewConfig = config;
updateView(config);
}

$element.data('$uiView', { $uiView: activeUiView });
$element.data('$uiView', { $uiView: activeUIView });

updateView();

unregister = $view.registerUiView(activeUiView);
unregister = $view.registerUIView(activeUIView);
scope.$on("$destroy", function() {
trace.traceUiViewEvent("Destroying/Unregistering", activeUiView);
trace.traceUIViewEvent("Destroying/Unregistering", activeUIView);
unregister();
});

function cleanupLastView() {
if (previousEl) {
trace.traceUiViewEvent("Removing (previous) el", previousEl.data('$uiView'));
trace.traceUIViewEvent("Removing (previous) el", previousEl.data('$uiView'));
previousEl.remove();
previousEl = null;
}

if (currentScope) {
trace.traceUiViewEvent("Destroying scope", activeUiView);
trace.traceUIViewEvent("Destroying scope", activeUIView);
currentScope.$destroy();
currentScope = null;
}

if (currentEl) {
let _viewData = currentEl.data('$uiView');
trace.traceUiViewEvent("Animate out", _viewData);
trace.traceUIViewEvent("Animate out", _viewData);
renderer.leave(currentEl, function() {
_viewData.$$animLeave.resolve();
previousEl = null;
Expand All @@ -264,19 +264,19 @@ function $ViewDirective( $view, $animate, $uiViewScroll, $interpolate,

function updateView(config?: Ng1ViewConfig) {
let newScope = scope.$new();
trace.traceUiViewScopeCreated(activeUiView, newScope);
trace.traceUIViewScopeCreated(activeUIView, newScope);
let animEnter = $q.defer(), animLeave = $q.defer();

let $uiViewData: UiViewData = {
let $uiViewData: UIViewData = {
$cfg: config,
$uiView: activeUiView,
$uiView: activeUIView,
$animEnter: animEnter.promise,
$animLeave: animLeave.promise,
$$animLeave: animLeave
};

let cloned = $transclude(newScope, function(clone) {
renderer.enter(clone.data('$uiView', $uiViewData), $element, function onUiViewEnter() {
renderer.enter(clone.data('$uiView', $uiViewData), $element, function onUIViewEnter() {
animEnter.resolve();
if (currentScope) currentScope.$emit('$viewContentAnimationEnded');

Expand Down Expand Up @@ -323,12 +323,12 @@ function $ViewDirectiveFill ( $compile, $controller, $transitions, $view,
let initial = tElement.html();

return function (scope, $element) {
let data: UiViewData = $element.data('$uiView');
let data: UIViewData = $element.data('$uiView');
if (!data) return;

let cfg: Ng1ViewConfig = data.$cfg || <any> { viewDecl: {} };
$element.html(cfg.template || initial);
trace.traceUiViewFill(data.$uiView, $element.html());
trace.traceUIViewFill(data.$uiView, $element.html());

let link = $compile($element.contents());
let controller = cfg.controller;
Expand Down
44 changes: 22 additions & 22 deletions src/ng1/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
*
* - Provides an implementation for the [[CoreServices]] API, based on angular 1 services.
* - Also registers some services with the angular 1 injector.
* - Creates and bootstraps a new [[UiRouter]] object. Ties it to the the angular 1 lifecycle.
* - Creates and bootstraps a new [[UIRouter]] object. Ties it to the the angular 1 lifecycle.
*
* @module ng1
* @preferred
*/

/** for typedoc */
import {UiRouter} from "../router";
import {UIRouter} from "../router";
import {services} from "../common/coreservices";
import {bindFunctions, removeFrom, applyPairs} from "../common/common";
import {prop} from "../common/hof";
Expand Down Expand Up @@ -156,14 +156,14 @@ function runBlock($injector, $q) {

app.run(runBlock);

let router: UiRouter = null;
let router: UIRouter = null;

ng1UiRouter.$inject = ['$locationProvider'];
ng1UIRouter.$inject = ['$locationProvider'];
/** This angular 1 provider instantiates a Router and exposes its services via the angular injector */
function ng1UiRouter($locationProvider) {
function ng1UIRouter($locationProvider) {

// Create a new instance of the Router when the ng1UiRouterProvider is initialized
router = new UiRouter();
// Create a new instance of the Router when the ng1UIRouterProvider is initialized
router = new UIRouter();

// Apply ng1 specific StateBuilder code for `views`, `resolve`, and `onExit/Retain/Enter` properties
router.stateRegistry.decorator("views", ng1ViewsBuilder);
Expand Down Expand Up @@ -211,17 +211,17 @@ function ng1UiRouter($locationProvider) {
}
}

function $stateParamsFactory(ng1UiRouter) {
return ng1UiRouter.globals.params;
function $stateParamsFactory(ng1UIRouter) {
return ng1UIRouter.globals.params;
}

// The 'ui.router' ng1 module depends on 'ui.router.init' module.
angular.module('ui.router.init', []).provider("ng1UiRouter", <any> ng1UiRouter);
angular.module('ui.router.init', []).provider("ng1UIRouter", <any> ng1UIRouter);
// This effectively calls $get() to init when we enter runtime
angular.module('ui.router.init').run(['ng1UiRouter', function(ng1UiRouter) { }]);
angular.module('ui.router.init').run(['ng1UIRouter', function(ng1UIRouter) { }]);

// $urlMatcherFactory service and $urlMatcherFactoryProvider
angular.module('ui.router.util').provider('$urlMatcherFactory', ['ng1UiRouterProvider', () => router.urlMatcherFactory]);
angular.module('ui.router.util').provider('$urlMatcherFactory', ['ng1UIRouterProvider', () => router.urlMatcherFactory]);
angular.module('ui.router.util').run(['$urlMatcherFactory', function($urlMatcherFactory) { }]);

// $urlRouter service and $urlRouterProvider
Expand All @@ -233,7 +233,7 @@ function getUrlRouterProvider() {
};
return router.urlRouterProvider;
}
angular.module('ui.router.router').provider('$urlRouter', ['ng1UiRouterProvider', getUrlRouterProvider]);
angular.module('ui.router.router').provider('$urlRouter', ['ng1UIRouterProvider', getUrlRouterProvider]);
angular.module('ui.router.router').run(['$urlRouter', function($urlRouter) { }]);

// $state service and $stateProvider
Expand All @@ -246,22 +246,22 @@ function getStateProvider() {
};
return router.stateProvider;
}
angular.module('ui.router.state').provider('$state', ['ng1UiRouterProvider', getStateProvider]);
angular.module('ui.router.state').provider('$state', ['ng1UIRouterProvider', getStateProvider]);
angular.module('ui.router.state').run(['$state', function($state) { }]);

// $stateParams service
angular.module('ui.router.state').factory('$stateParams', ['ng1UiRouter', (ng1UiRouter) =>
ng1UiRouter.globals.params]);
angular.module('ui.router.state').factory('$stateParams', ['ng1UIRouter', (ng1UIRouter) =>
ng1UIRouter.globals.params]);

// $transitions service and $transitionsProvider
function getTransitionsProvider() {
router.transitionService["$get"] = () => router.transitionService;
return router.transitionService;
}
angular.module('ui.router.state').provider('$transitions', ['ng1UiRouterProvider', getTransitionsProvider]);
angular.module('ui.router.state').provider('$transitions', ['ng1UIRouterProvider', getTransitionsProvider]);

// $templateFactory service
angular.module('ui.router.util').factory('$templateFactory', ['ng1UiRouter', () => new TemplateFactory()]);
angular.module('ui.router.util').factory('$templateFactory', ['ng1UIRouter', () => new TemplateFactory()]);

// The $view service
angular.module('ui.router').factory('$view', () => router.viewService);
Expand All @@ -283,16 +283,16 @@ export const getLocals = (ctx: ResolveContext) => {
return tuples.reduce(applyPairs, {});
};

/** Adds the angular 1 `$injector` to the `UiInjector` interface */
/** Adds the angular 1 `$injector` to the `UIInjector` interface */
declare module "../common/interface" {
/**
* This enhances the [[common.UiInjector]] interface by adding the `$injector` service as the [[native]] injector.
* This enhances the [[common.UIInjector]] interface by adding the `$injector` service as the [[native]] injector.
*/
interface UiInjector {
interface UIInjector {
/**
* The native Angular 1 `$injector` service
*
* When you have access to a `UiInjector`, this property will contain the native `$injector` Angular 1 service.
* When you have access to a `UIInjector`, this property will contain the native `$injector` Angular 1 service.
*
* @example:
* ```js
Expand Down
2 changes: 1 addition & 1 deletion src/ng1/statebuilders/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function ng1ViewsBuilder(state: State) {
config.$context = state;
config.$name = name;

let normalized = ViewService.normalizeUiViewTarget(config.$context, config.$name);
let normalized = ViewService.normalizeUIViewTarget(config.$context, config.$name);
config.$uiViewName = normalized.uiViewName;
config.$uiViewContextAnchor = normalized.uiViewContextAnchor;

Expand Down
16 changes: 8 additions & 8 deletions src/ng2/directives/directives.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/**
* The UI-Router Angular 2 directives:
*
* - [[UiView]]: A viewport for routed components
* - [[UiSref]]: A state ref to a target state; navigates when clicked
* - [[UiSrefActive]]: (and `UiSrefActiveEq`) Adds a css class when a UiSref's target state (or a child state) is active
* - [[UIView]]: A viewport for routed components
* - [[UISref]]: A state ref to a target state; navigates when clicked
* - [[UISrefActive]]: (and `UISrefActiveEq`) Adds a css class when a UISref's target state (or a child state) is active
*
* @preferred @module ng2_directives
*/ /** */
import {UiSref, AnchorUiSref} from "./uiSref";
import {UiSrefActive} from "./uiSrefActive";
import {UiView} from "./uiView";
import {UiSrefStatus} from "./uiSrefStatus";
import {UISref, AnchorUISref} from "./uiSref";
import {UISrefActive} from "./uiSrefActive";
import {UIView} from "./uiView";
import {UISrefStatus} from "./uiSrefStatus";

export * from "./uiView";
export * from "./uiSref";
Expand All @@ -30,4 +30,4 @@ export * from "./uiSrefActive";
* })
* ```
*/
export let UIROUTER_DIRECTIVES = [UiSref, AnchorUiSref, UiView, UiSrefActive, UiSrefStatus];
export let UIROUTER_DIRECTIVES = [UISref, AnchorUISref, UIView, UISrefActive, UISrefStatus];
Loading

0 comments on commit 822fc10

Please sign in to comment.