Skip to content

Commit

Permalink
Mild refactoring of default exports & method renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
DogAndHerDude committed Jun 9, 2016
1 parent 39f7f8a commit f19c21a
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 67 deletions.
32 changes: 16 additions & 16 deletions dist/jsRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ define("../node_modules/almond/almond", function(){});
_event = new CustomEvent(eventName, eventData);
element.dispatchEvent(_event);
}
exports.broadcastEvent = broadcastEvent;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = broadcastEvent;
});
//# sourceMappingURL=../../src/tmp/maps/events/eventHandler.js.map;
(function (factory) {
Expand Down Expand Up @@ -514,18 +515,18 @@ define("../node_modules/almond/almond", function(){});
this.matchingPath = '';
}
$Location.prototype.path = function (href) {
router_events_1.startRouteChange(constructRoute(href));
router_events_1.startRouteChange(routeFactory(href));
};
return $Location;
}());
exports.$Location = $Location;
function constructRoute(url) {
function routeFactory(url) {
var prev = window.location;
var next = new $Location(url);
var locationList = { next: next, prev: prev };
return locationList;
}
exports.constructRoute = constructRoute;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = routeFactory;
});
//# sourceMappingURL=../../src/tmp/maps/location/location.model.js.map;
(function (factory) {
Expand All @@ -537,25 +538,25 @@ define("../node_modules/almond/almond", function(){});
}
})(function (require, exports) {
'use strict';
var eventHandler = require('../events/eventHandler');
var eventHandler_1 = require('../events/eventHandler');
var location_model_1 = require('../location/location.model');
var utils = require('../utils/utils');
function onRun() {
startRouteChange(location_model_1.constructRoute(window.location.origin + window.location.pathname));
startRouteChange(location_model_1.default(window.location.origin + window.location.pathname));
}
exports.onRun = onRun;
function startRouteChange(location) {
var root = utils.getRoot();
var locationList = location;
eventHandler.broadcastEvent('routeChange', root, { detail: locationList });
eventHandler_1.default('routeChange', root, { detail: locationList });
}
exports.startRouteChange = startRouteChange;
function interceptLinks() {
var root = utils.getRoot();
root.addEventListener('click', function (ev) {
if (ev.target.nodeName === 'A') {
ev.preventDefault();
startRouteChange(location_model_1.constructRoute(ev.target.href));
startRouteChange(location_model_1.default(ev.target.href));
}
});
}
Expand Down Expand Up @@ -624,7 +625,7 @@ define("../node_modules/almond/almond", function(){});
window.addEventListener('popstate', function (ev) {
ev.preventDefault();
popStateInvoked = true;
router_events_1.startRouteChange(location_model_1.constructRoute(ev.state.path));
router_events_1.startRouteChange(location_model_1.default(ev.state.path));
});
}
exports.monitorBrowserNavigation = monitorBrowserNavigation;
Expand Down Expand Up @@ -660,10 +661,8 @@ define("../node_modules/almond/almond", function(){});
return callback();
}
view.innerHTML = data;
if (route.options.cache) {
if (!isCached) {
route.storeTemplateToCache(data);
}
if (route.options.cache && !isCached) {
route.storeTemplateToCache(data);
}
return callback(null, true);
});
Expand Down Expand Up @@ -782,7 +781,8 @@ define("../node_modules/almond/almond", function(){});
};
return Route;
}());
exports.Route = Route;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Route;
});
//# sourceMappingURL=../../src/tmp/maps/route/route.model.js.map;
(function (factory) {
Expand All @@ -798,7 +798,7 @@ define("../node_modules/almond/almond", function(){});
var observer = require('./route.observer');
var provider = {
when: function (path, options) {
var route = new route_model_1.Route(path, options);
var route = new route_model_1.default(path, options);
observer.addRoute(route);
return this;
},
Expand Down
2 changes: 1 addition & 1 deletion dist/jsRoute.min.js

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions dist/jsRoute.noamd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/jsRoute.noamd.min.js

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions example/jsRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ define("../node_modules/almond/almond", function(){});
_event = new CustomEvent(eventName, eventData);
element.dispatchEvent(_event);
}
exports.broadcastEvent = broadcastEvent;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = broadcastEvent;
});
//# sourceMappingURL=../../src/tmp/maps/events/eventHandler.js.map;
(function (factory) {
Expand Down Expand Up @@ -514,18 +515,18 @@ define("../node_modules/almond/almond", function(){});
this.matchingPath = '';
}
$Location.prototype.path = function (href) {
router_events_1.startRouteChange(constructRoute(href));
router_events_1.startRouteChange(routeFactory(href));
};
return $Location;
}());
exports.$Location = $Location;
function constructRoute(url) {
function routeFactory(url) {
var prev = window.location;
var next = new $Location(url);
var locationList = { next: next, prev: prev };
return locationList;
}
exports.constructRoute = constructRoute;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = routeFactory;
});
//# sourceMappingURL=../../src/tmp/maps/location/location.model.js.map;
(function (factory) {
Expand All @@ -537,25 +538,25 @@ define("../node_modules/almond/almond", function(){});
}
})(function (require, exports) {
'use strict';
var eventHandler = require('../events/eventHandler');
var eventHandler_1 = require('../events/eventHandler');
var location_model_1 = require('../location/location.model');
var utils = require('../utils/utils');
function onRun() {
startRouteChange(location_model_1.constructRoute(window.location.origin + window.location.pathname));
startRouteChange(location_model_1.default(window.location.origin + window.location.pathname));
}
exports.onRun = onRun;
function startRouteChange(location) {
var root = utils.getRoot();
var locationList = location;
eventHandler.broadcastEvent('routeChange', root, { detail: locationList });
eventHandler_1.default('routeChange', root, { detail: locationList });
}
exports.startRouteChange = startRouteChange;
function interceptLinks() {
var root = utils.getRoot();
root.addEventListener('click', function (ev) {
if (ev.target.nodeName === 'A') {
ev.preventDefault();
startRouteChange(location_model_1.constructRoute(ev.target.href));
startRouteChange(location_model_1.default(ev.target.href));
}
});
}
Expand Down Expand Up @@ -624,7 +625,7 @@ define("../node_modules/almond/almond", function(){});
window.addEventListener('popstate', function (ev) {
ev.preventDefault();
popStateInvoked = true;
router_events_1.startRouteChange(location_model_1.constructRoute(ev.state.path));
router_events_1.startRouteChange(location_model_1.default(ev.state.path));
});
}
exports.monitorBrowserNavigation = monitorBrowserNavigation;
Expand Down Expand Up @@ -660,10 +661,8 @@ define("../node_modules/almond/almond", function(){});
return callback();
}
view.innerHTML = data;
if (route.options.cache) {
if (!isCached) {
route.storeTemplateToCache(data);
}
if (route.options.cache && !isCached) {
route.storeTemplateToCache(data);
}
return callback(null, true);
});
Expand Down Expand Up @@ -782,7 +781,8 @@ define("../node_modules/almond/almond", function(){});
};
return Route;
}());
exports.Route = Route;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Route;
});
//# sourceMappingURL=../../src/tmp/maps/route/route.model.js.map;
(function (factory) {
Expand All @@ -798,7 +798,7 @@ define("../node_modules/almond/almond", function(){});
var observer = require('./route.observer');
var provider = {
when: function (path, options) {
var route = new route_model_1.Route(path, options);
var route = new route_model_1.default(path, options);
observer.addRoute(route);
return this;
},
Expand Down
2 changes: 1 addition & 1 deletion src/events/eventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ function broadcastEvent(eventName: string, element, eventData): void {
element.dispatchEvent(_event);
}

export { broadcastEvent };
export default broadcastEvent;
4 changes: 2 additions & 2 deletions src/history/history.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import { startRouteChange } from '../router/router.events';
import { constructRoute } from '../location/location.model';
import routeFactory from '../location/location.model';

var $history = window.history;
var popStateInvoked = false;
Expand All @@ -21,7 +21,7 @@ function monitorBrowserNavigation() {
window.addEventListener('popstate', (ev) => {
ev.preventDefault();
popStateInvoked = true;
startRouteChange(constructRoute(ev.state.path));
startRouteChange(routeFactory(ev.state.path));
});
}

Expand Down
7 changes: 3 additions & 4 deletions src/location/location.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,16 @@ class $Location {
}

public path(href: string): void {
startRouteChange(constructRoute(href));
startRouteChange(routeFactory(href));
}
}

function constructRoute(url: string): LocationInterface.LocationList {
function routeFactory(url: string): LocationInterface.LocationList {
var prev: Location = window.location;
var next: LocationInterface.NewLocation = new $Location(url);
var locationList: LocationInterface.LocationList = { next, prev };

return locationList;
}

export { constructRoute };
export { $Location };
export default routeFactory;
2 changes: 1 addition & 1 deletion src/route/route.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ class Route {
}
}

export { Route };
export default Route;
6 changes: 3 additions & 3 deletions src/route/route.observer.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';

import * as routeModel from './route.model';
import Route from './route.model';
import * as utils from '../utils/utils';
import $http from '../http/http';
import * as $history from '../history/history';

var routes: Array<routeModel.Route> = [];
var routes: Array<Route> = [];
var fallback = '/';

function monitorRouteChange(): void {
Expand All @@ -14,7 +14,7 @@ function monitorRouteChange(): void {
root.addEventListener('routeChange', changeCallback, false);
}

function insertTemplate(route: routeModel.Route, callback): void {
function insertTemplate(route: Route, callback): void {
const isCached = route.isCached();
var view = utils.getView();

Expand Down
2 changes: 1 addition & 1 deletion src/route/route.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import RouteInterface from '../typings/route/route.d';

import { Route } from './route.model';
import Route from './route.model';
import * as observer from './route.observer';

var provider: RouteInterface.RouteProvider = {
Expand Down
Loading

0 comments on commit f19c21a

Please sign in to comment.