This repository was archived by the owner on Dec 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathRouterEvent.js
111 lines (111 loc) · 4.72 KB
/
RouterEvent.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "./BaseEvent"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var BaseEvent_1 = require("./BaseEvent");
/**
* The RouterEvent is used in the {{#crossLink "Router"}}{{/crossLink}} class and gets passed to the callback in the {{#crossLink "Route"}}{{/crossLink}} class.
*
* @class RouterEvent
* @extends BaseEvent
* @param type {string} The type of event. The type is case-sensitive.
* @param [bubbles=false] {boolean} Indicates whether an event is a bubbling event. If the event can bubble, this value is true; otherwise it is false.
* Note: With event-bubbling you can let one Event subsequently call on every ancestor ({{#crossLink "EventDispatcher/parent:property"}}{{/crossLink}})
* (containers of containers of etc.) of the {{#crossLink "DisplayObjectContainer"}}{{/crossLink}} that originally dispatched the Event, all the way up to the surface ({{#crossLink "Stage"}}{{/crossLink}}). Any classes that do not have a parent cannot bubble.
* @param [cancelable=false] {boolean} Indicates whether the behavior associated with the event can be prevented. If the behavior can be canceled, this value is true; otherwise it is false.
* @param [data=null] {any} Use to pass any type of data with the event.
* @module StructureJS
* @submodule event
* @requires Extend
* @requires BaseEvent
* @constructor
* @author Robert S. (www.codeBelt.com)
*/
var RouterEvent = (function (_super) {
__extends(RouterEvent, _super);
function RouterEvent(type, bubbles, cancelable, data) {
if (type === void 0) { type = RouterEvent.CHANGE; }
if (bubbles === void 0) { bubbles = false; }
if (cancelable === void 0) { cancelable = false; }
if (data === void 0) { data = null; }
var _this = _super.call(this, type, bubbles, cancelable, data) || this;
/**
* The route that was matched against {{#crossLink "RouterEvent/routePattern:property"}}{{/crossLink}} property.
*
* @property route
* @type {string}
* @public
*/
_this.route = null;
/**
* The new URL to which the window is navigating.
*
* @property newURL
* @type {string}
* @public
*/
_this.newURL = null;
/**
* The previous URL from which the window was navigated.
*
* @property oldURL
* @type {string}
* @public
*/
_this.oldURL = null;
/**
* The route pattern that matched the {{#crossLink "RouterEvent/route:property"}}{{/crossLink}} property.
*
* @property routePattern
* @type {string}
* @public
*/
_this.routePattern = null;
/**
* An array containing the parameters captured from the Route.{{#crossLink "Route/match:method"}}{{/crossLink}}
* being called with the {{#crossLink "RouterEvent/routePattern:property"}}{{/crossLink}} property.
*
* @property params
* @type {Array.<string>}
* @public
*/
_this.params = [];
/**
* A query object the represents the query string in the hash url.
*
* @property query
* @type {any}
* @public
*/
_this.query = null;
return _this;
}
return RouterEvent;
}(BaseEvent_1.default));
/**
* The RouterEvent.CHANGE constant defines the value of the type property of an change route event object.
*
* @event CHANGE
* @type {string}
* @static
*/
RouterEvent.CHANGE = 'RouterEvent.change';
exports.default = RouterEvent;
});