var Jsonp = (function (_super) { __extends(Jsonp, _super); function Jsonp(backend, defaultOptions) { _super.call(this, backend, defaultOptions); } /** * Performs any type of http request. First argument is required, and can either be a url or * a {@link Request} instance. If the first argument is a url, an optional {@link RequestOptions} * object can be provided as the 2nd argument. The options object will be merged with the values * of {@link BaseRequestOptions} before performing the request. */ Jsonp.prototype.request = function (url, options) { var responseObservable; if (lang_1.isString(url)) { url = new static_request_1.Request(mergeOptions(this._defaultOptions, options, enums_1.RequestMethods.Get, url)); } if (url instanceof static_request_1.Request) { if (url.method !== enums_1.RequestMethods.Get) { exceptions_1.makeTypeError('JSONP requests must use GET request method.'); } responseObservable = httpRequest(this._backend, url); } else { throw exceptions_1.makeTypeError('First argument must be a url string or Request instance.'); } return responseObservable; }; Jsonp = __decorate([ angular2_1.Injectable(), __metadata('design:paramtypes', [interfaces_1.ConnectionBackend, base_request_options_1.RequestOptions]) ], Jsonp); return Jsonp; })(Http);
var NVEdge = (function () { function NVEdge(id, name, source, target, type) { this._id = id; this._name = name; this.source = source; this.target = target; this._type = type; } Object.defineProperty(NVEdge.prototype, "id", { get: function () { return this._id; }, enumerable: true, configurable: true }); Object.defineProperty(NVEdge.prototype, "name", { get: function () { return this._name; }, set: function (name) { this._name = name; }, enumerable: true, configurable: true }); Object.defineProperty(NVEdge.prototype, "type", { get: function () { return this._type; }, enumerable: true, configurable: true }); NVEdge = __decorate([ angular2_1.Injectable(), __metadata('design:paramtypes', [Number, String, node_1.NVNode, node_1.NVNode, String]) ], NVEdge); return NVEdge; })();
var BrowserJsonp = (function () { function BrowserJsonp() { } // Construct a <script> element with the specified URL BrowserJsonp.prototype.build = function (url) { var node = document.createElement('script'); node.src = url; return node; }; BrowserJsonp.prototype.nextRequestID = function () { return "__req" + _nextRequestId++; }; BrowserJsonp.prototype.requestCallback = function (id) { return exports.JSONP_HOME + "." + id + ".finished"; }; BrowserJsonp.prototype.exposeConnection = function (id, connection) { var connections = _getJsonpConnections(); connections[id] = connection; }; BrowserJsonp.prototype.removeConnection = function (id) { var connections = _getJsonpConnections(); connections[id] = null; }; // Attach the <script> element to the DOM BrowserJsonp.prototype.send = function (node) { document.body.appendChild((node)); }; // Remove <script> element from the DOM BrowserJsonp.prototype.cleanup = function (node) { if (node.parentNode) { node.parentNode.removeChild((node)); } }; BrowserJsonp = __decorate([ angular2_1.Injectable(), __metadata('design:paramtypes', []) ], BrowserJsonp); return BrowserJsonp; })();
var BrowserXhr = (function () { function BrowserXhr() { } BrowserXhr.prototype.build = function () { return (new XMLHttpRequest()); }; BrowserXhr = __decorate([ angular2_1.Injectable(), __metadata('design:paramtypes', []) ], BrowserXhr); return BrowserXhr; })();
var BaseRequestOptions = (function (_super) { __extends(BaseRequestOptions, _super); function BaseRequestOptions() { _super.call(this, { method: enums_1.RequestMethods.Get, headers: new headers_1.Headers() }); } BaseRequestOptions = __decorate([ angular2_1.Injectable(), __metadata('design:paramtypes', []) ], BaseRequestOptions); return BaseRequestOptions; })(RequestOptions);
var BaseResponseOptions = (function (_super) { __extends(BaseResponseOptions, _super); function BaseResponseOptions() { _super.call(this, { status: 200, statusText: 'Ok', type: enums_1.ResponseTypes.Default, headers: new headers_1.Headers() }); } BaseResponseOptions = __decorate([ angular2_1.Injectable(), __metadata('design:paramtypes', []) ], BaseResponseOptions); return BaseResponseOptions; })(ResponseOptions);
var ThreadsService = (function () { function ThreadsService(messagesService) { this.messagesService = messagesService; this.currentThread = new Rx.BehaviorSubject(new models_1.Thread()); this.threads = messagesService.messages .map(function (messages) { var threads = {}; messages.map(function (message) { threads[message.thread.id] = threads[message.thread.id] || message.thread; var messagesThread = threads[message.thread.id]; if (!messagesThread.lastMessage || messagesThread.lastMessage.sentAt < message.sentAt) { messagesThread.lastMessage = message; } }); return threads; }) .shareReplay(1); this.orderedThreads = this.threads .map(function (threadGroups) { var threads = _.values(threadGroups); return _.sortBy(threads, function (t) { return t.lastMessage.sentAt; }).reverse(); }) .shareReplay(1); this.currentThreadMessages = this.currentThread .combineLatest(messagesService.messages, function (currentThread, messages) { if (currentThread && messages.length > 0) { return _.chain(messages) .filter(function (message) { return (message.thread.id === currentThread.id); }) .map(function (message) { message.isRead = true; return message; }) .value(); } else { return []; } }) .shareReplay(1); this.currentThread.subscribe(this.messagesService.markThreadAsRead); } ThreadsService.prototype.setCurrentThread = function (newThread) { this.currentThread.onNext(newThread); }; ThreadsService = __decorate([ angular2_1.Injectable(), __metadata('design:paramtypes', [MessagesService_1.MessagesService]) ], ThreadsService); return ThreadsService; })();
var LoggerService = (function () { function LoggerService() { } LoggerService.prototype.log = function (message) { console.log(message); }; LoggerService = __decorate([ angular2_1.Injectable(), __metadata('design:paramtypes', []) ], LoggerService); return LoggerService; })();
var PreferencePopup = (function () { function PreferencePopup(activate, fadeout, details) { this._activate = activate; this._fadeout = fadeout; this._details = details; } PreferencePopup = __decorate([ angular2_1.Injectable(), __metadata('design:paramtypes', [Boolean, Boolean, Boolean]) ], PreferencePopup); return PreferencePopup; })();
var HeroService = (function () { function HeroService() { this.heroes = mock_heroes_1.HEROES; } HeroService.prototype.getHeroes = function () { return this.heroes; }; HeroService = __decorate([ angular2_1.Injectable(), __metadata('design:paramtypes', []) ], HeroService); return HeroService; })();
var PeopleService = (function () { // person: Person = null; function PeopleService(_http) { this._http = _http; this.people = []; } PeopleService.prototype.getPeople = function () { //return an observable return this._http.get('/api/people') .catch(function (err) { console.log(err); return []; }) .map(function (response) { return response.json(); }) .map(function (people) { var result = []; if (people) { people.forEach(function (p) { result.push(p); }); } return result; }); }; PeopleService.prototype.getPerson = function (id) { return this._http.get('/api/people/' + id.toString()) .map(function (response) { return response.json(); }) .map(function (person) { var result = null; if (person) { result = person; } ; return result; }); }; PeopleService.prototype._fetchFailed = function (error) { console.error(error); return Promise.reject(error); }; PeopleService = __decorate([ angular2_1.Injectable(), __metadata('design:paramtypes', [http_1.Http]) ], PeopleService); return PeopleService; }());
var XHRBackend = (function () { function XHRBackend(_browserXHR, _baseResponseOptions) { this._browserXHR = _browserXHR; this._baseResponseOptions = _baseResponseOptions; } XHRBackend.prototype.createConnection = function (request) { return new XHRConnection(request, this._browserXHR, this._baseResponseOptions); }; XHRBackend = __decorate([ angular2_1.Injectable(), __metadata('design:paramtypes', [browser_xhr_1.BrowserXhr, base_response_options_1.ResponseOptions]) ], XHRBackend); return XHRBackend; })();
var MockBackend = (function () { function MockBackend() { var _this = this; this.connectionsArray = []; this.connections = new Subject(); this.connections.subscribe(function (connection) { return _this.connectionsArray.push(connection); }); this.pendingConnections = new Subject(); } /** * Checks all connections, and raises an exception if any connection has not received a response. * * This method only exists in the mock implementation, not in real Backends. */ MockBackend.prototype.verifyNoPendingRequests = function () { var pending = 0; this.pendingConnections.subscribe(function (c) { return pending++; }); if (pending > 0) throw new exceptions_1.BaseException(pending + " pending connections to be resolved"); }; /** * Can be used in conjunction with `verifyNoPendingRequests` to resolve any not-yet-resolve * connections, if it's expected that there are connections that have not yet received a response. * * This method only exists in the mock implementation, not in real Backends. */ MockBackend.prototype.resolveAllConnections = function () { this.connections.subscribe(function (c) { return c.readyState = 4; }); }; /** * Creates a new {@link MockConnection}. This is equivalent to calling `new * MockConnection()`, except that it also will emit the new `Connection` to the `connections` * emitter of this `MockBackend` instance. This method will usually only be used by tests * against the framework itself, not by end-users. */ MockBackend.prototype.createConnection = function (req) { if (!lang_1.isPresent(req) || !(req instanceof static_request_1.Request)) { throw new exceptions_1.BaseException("createConnection requires an instance of Request, got " + req); } var connection = new MockConnection(req); this.connections.next(connection); return connection; }; MockBackend = __decorate([ angular2_1.Injectable(), __metadata('design:paramtypes', []) ], MockBackend); return MockBackend; })();
var Branch = (function () { function Branch(name, color, type, id) { this.types = ['Standard', 'User', 'Group', 'Temporal']; // TODO METTRE AUTRE PART if (name) this._name = name; if (color) this._color = color; if (type) this._type = 'Standard'; if (id) this._id = id; } Object.defineProperty(Branch.prototype, "id", { get: function () { return this._id; }, set: function (id) { this._id = id; }, enumerable: true, configurable: true }); Object.defineProperty(Branch.prototype, "name", { get: function () { return this._name; }, set: function (name) { this._name = name; }, enumerable: true, configurable: true }); Object.defineProperty(Branch.prototype, "color", { get: function () { return this._color; }, set: function (color) { this._color = color; }, enumerable: true, configurable: true }); Object.defineProperty(Branch.prototype, "type", { get: function () { return this._type; }, set: function (type) { this._type = type; }, enumerable: true, configurable: true }); Branch = __decorate([ angular2_1.Injectable(), __metadata('design:paramtypes', [String, String, String, Number]) ], Branch); return Branch; })();
var Friends = (function () { function Friends() { this.chats = [{ id: 0, name: 'Ben Sparrow', lastText: 'You on your way?', face: 'https://pbs.twimg.com/profile_images/514549811765211136/9SgAuHeY.png' }, { id: 1, name: 'Max Lynx', lastText: 'Hey, it\'s me', face: 'https://avatars3.githubusercontent.com/u/11214?v=3&s=460' }, { id: 2, name: 'Adam Bradleyson', lastText: 'I should buy a boat', face: 'https://pbs.twimg.com/profile_images/479090794058379264/84TKj_qa.jpeg' }, { id: 3, name: 'Perry Governor', lastText: 'Look at my mukluks!', face: 'https://pbs.twimg.com/profile_images/598205061232103424/3j5HUXMY.png' }, { id: 4, name: 'Mike Harrington', lastText: 'This is wicked good ice cream.', face: 'https://pbs.twimg.com/profile_images/578237281384841216/R3ae1n61.png' }]; } Friends.prototype.all = function () { return this.chats; }; Friends.prototype.remove = function (chat) { this.chats.splice(this.chats.indexOf(chat), 1); }; Friends = __decorate([ angular2_1.Injectable() ], Friends); return Friends; })();
var Group = (function () { function Group(id, name) { this._id = id; this._name = name; } Object.defineProperty(Group.prototype, "name", { get: function () { return this._name; }, set: function (name) { this._name = name; }, enumerable: true, configurable: true }); Object.defineProperty(Group.prototype, "users", { get: function () { return this._users; }, set: function (users) { this._users = users; }, enumerable: true, configurable: true }); Group = __decorate([ angular2_1.Injectable(), __metadata('design:paramtypes', [Number, String]) ], Group); return Group; })();
var ChessboardUI = (function () { function ChessboardUI() { this.isPieceSelected = false; this.lookahead = 3; this.breadth = 7; this.chessboard = new chessboard_1.Chessboard(new Array()); } Object.defineProperty(ChessboardUI.prototype, "fields", { get: function () { return this.chessboard.fields; }, enumerable: true, configurable: true }); Object.defineProperty(ChessboardUI.prototype, "isWhitePlaying", { get: function () { return this.chessboard.isWhitePlaying; }, enumerable: true, configurable: true }); Object.defineProperty(ChessboardUI.prototype, "capturedPieces", { get: function () { return this.chessboard.capturedPieces; }, enumerable: true, configurable: true }); Object.defineProperty(ChessboardUI.prototype, "check", { get: function () { return this.chessboard.check; }, enumerable: true, configurable: true }); Object.defineProperty(ChessboardUI.prototype, "checkMate", { get: function () { return this.chessboard.checkMate; }, enumerable: true, configurable: true }); Object.defineProperty(ChessboardUI.prototype, "staleMate", { get: function () { return this.chessboard.staleMate; }, enumerable: true, configurable: true }); Object.defineProperty(ChessboardUI.prototype, "ownCheck", { get: function () { return this.chessboard.ownCheck; }, enumerable: true, configurable: true }); Object.defineProperty(ChessboardUI.prototype, "ownCheckMate", { get: function () { return this.chessboard.ownCheckMate; }, enumerable: true, configurable: true }); ChessboardUI.prototype.ownThreats = function (row, col) { return this.chessboard.ownThreats(row, col); }; ChessboardUI.prototype.opponentThreats = function (row, col) { return this.chessboard.opponentThreats(row, col); }; ChessboardUI.prototype.suggestMove = function () { return new suggestor_1.Suggestor(this.chessboard).suggestMove(this.lookahead, this.breadth); }; Object.defineProperty(ChessboardUI.prototype, "moveHistory", { get: function () { return this.chessboard.moveHistory; }, enumerable: true, configurable: true }); ChessboardUI.prototype.onclick = function (row, col) { if (!this.isPieceSelected) this.setSelectedPiece(row, col); else { this.isPieceSelected = false; if (this.chessboard.isLegalMove(this.selectedPieceRow, this.selectedPieceCol, row, col)) { this.chessboard.move(this.selectedPieceRow, this.selectedPieceCol, row, col, this.isWhitePlaying ? 5 : -5); var answer = new suggestor_1.Suggestor(this.chessboard).suggestMove(this.lookahead, this.breadth); if (null != answer) this.move(answer); } } }; ChessboardUI.prototype.move = function (mv) { this.chessboard.move(mv.fromRow, mv.fromCol, mv.toRow, mv.toCol, mv.promotion); }; ChessboardUI.prototype.setSelectedPiece = function (row, col) { var piece = this.chessboard.fields[row][col]; if (this.isWhitePlaying) { if (piece <= 0) return; } else { if (piece >= 0) return; } this.isPieceSelected = true; this.selectedPieceRow = row; this.selectedPieceCol = col; }; ChessboardUI.prototype.isLegalMove2 = function (toRow, toCol) { if (!this.isPieceSelected) return false; return this.chessboard.isLegalMove(this.selectedPieceRow, this.selectedPieceCol, toRow, toCol); }; ChessboardUI.prototype.revertLastMove = function () { this.chessboard.revertLastMove(); }; ChessboardUI = __decorate([ angular2_1.Injectable(), __metadata('design:paramtypes', []) ], ChessboardUI); return ChessboardUI; })();
* bootstrap(App, [HTTP_PROVIDERS, provide(RequestOptions, {useClass: MyOptions})]); * ``` * * The options could also be extended when manually creating a {@link Request} * object. * * ### Example ([live demo](http://plnkr.co/edit/oyBoEvNtDhOSfi9YxaVb?p=preview)) * * ``` * import {BaseRequestOptions, Request, RequestMethods} from 'angular2/http'; * * var options = new BaseRequestOptions(); * var req = new Request(options.merge({ * method: RequestMethods.Post, * url: 'https://google.com' * })); * console.log('req.method:', RequestMethods[req.method]); // Post * console.log('options.url:', options.url); // null * console.log('req.url:', req.url); // https://google.com * ``` */ export let BaseRequestOptions = class extends RequestOptions { constructor() { super({ method: RequestMethods.Get, headers: new Headers() }); } }; BaseRequestOptions = __decorate([ Injectable(), __metadata('design:paramtypes', []) ], BaseRequestOptions); //# sourceMappingURL=base_request_options.js.map
var Http = (function () { function Http(_backend, _defaultOptions) { this._backend = _backend; this._defaultOptions = _defaultOptions; } /** * Performs any type of http request. First argument is required, and can either be a url or * a {@link Request} instance. If the first argument is a url, an optional {@link RequestOptions} * object can be provided as the 2nd argument. The options object will be merged with the values * of {@link BaseRequestOptions} before performing the request. */ Http.prototype.request = function (url, options) { var responseObservable; if (lang_1.isString(url)) { responseObservable = httpRequest(this._backend, new static_request_1.Request(mergeOptions(this._defaultOptions, options, enums_1.RequestMethods.Get, url))); } else if (url instanceof static_request_1.Request) { responseObservable = httpRequest(this._backend, url); } else { throw exceptions_1.makeTypeError('First argument must be a url string or Request instance.'); } return responseObservable; }; /** * Performs a request with `get` http method. */ Http.prototype.get = function (url, options) { return httpRequest(this._backend, new static_request_1.Request(mergeOptions(this._defaultOptions, options, enums_1.RequestMethods.Get, url))); }; /** * Performs a request with `post` http method. */ Http.prototype.post = function (url, body, options) { return httpRequest(this._backend, new static_request_1.Request(mergeOptions(this._defaultOptions.merge(new base_request_options_1.RequestOptions({ body: body })), options, enums_1.RequestMethods.Post, url))); }; /** * Performs a request with `put` http method. */ Http.prototype.put = function (url, body, options) { return httpRequest(this._backend, new static_request_1.Request(mergeOptions(this._defaultOptions.merge(new base_request_options_1.RequestOptions({ body: body })), options, enums_1.RequestMethods.Put, url))); }; /** * Performs a request with `delete` http method. */ Http.prototype.delete = function (url, options) { return httpRequest(this._backend, new static_request_1.Request(mergeOptions(this._defaultOptions, options, enums_1.RequestMethods.Delete, url))); }; /** * Performs a request with `patch` http method. */ Http.prototype.patch = function (url, body, options) { return httpRequest(this._backend, new static_request_1.Request(mergeOptions(this._defaultOptions.merge(new base_request_options_1.RequestOptions({ body: body })), options, enums_1.RequestMethods.Patch, url))); }; /** * Performs a request with `head` http method. */ Http.prototype.head = function (url, options) { return httpRequest(this._backend, new static_request_1.Request(mergeOptions(this._defaultOptions, options, enums_1.RequestMethods.Head, url))); }; Http = __decorate([ angular2_1.Injectable(), __metadata('design:paramtypes', [interfaces_1.ConnectionBackend, base_request_options_1.RequestOptions]) ], Http); return Http; })();
var NativeScriptRenderer = (function (_super) { __extends(NativeScriptRenderer, _super); function NativeScriptRenderer(_templateCloner) { _super.call(this); this._templateCloner = _templateCloner; console.log('NativeScriptRenderer created'); } NativeScriptRenderer.prototype.createRootHostView = function (hostProtoViewRef, fragmentCount, hostElementSelector) { console.log("NativeScriptRenderer.createRootHostView"); var hostProtoView = proto_view_1.resolveInternalDomProtoView(hostProtoViewRef); //return new NativeScriptViewRef(this._createView(hostProtoView, null, true)); return this._createView(hostProtoView, null, true); }; NativeScriptRenderer.prototype.detachFreeHostView = function (parentHostViewRef, hostViewRef) { console.log("NativeScriptRenderer.detachFreeHostView"); }; NativeScriptRenderer.prototype.createView = function (protoViewRef, fragmentCount) { console.log("NativeScriptRenderer.createView"); var protoView = proto_view_1.resolveInternalDomProtoView(protoViewRef); //return new NativeScriptViewRef(this._createView(protoView, null, false)); return this._createView(protoView, null, false); }; NativeScriptRenderer.prototype.destroyView = function (viewRef) { console.log("NativeScriptRenderer.destroyView"); // Seems to be called on component dispose only (router outlet) //TODO: handle this when we resolve routing and navigation. }; NativeScriptRenderer.prototype.attachFragmentAfterFragment = function (previousFragmentRef, fragmentRef) { console.log("NativeScriptRenderer.attachFragmentAfterFragment"); var previousFragmentNodes = previousFragmentRef.resolveNodes(); var lastNode = previousFragmentNodes[previousFragmentNodes.length - 1]; var fragmentNodes = fragmentRef.resolveNodes(); this.attachFragmentAfter(lastNode, fragmentNodes); }; NativeScriptRenderer.prototype.attachFragmentAfterElement = function (location, fragmentRef) { console.log("NativeScriptRenderer.attachFragmentAfterElement"); var hostView = location.renderView.resolveView(); var startNode = hostView.getBoundNode(location.renderBoundElementIndex); var fragmentNodes = fragmentRef.resolveNodes(); this.attachFragmentAfter(startNode, fragmentNodes); }; NativeScriptRenderer.prototype.attachFragmentAfter = function (anchorNode, fragmentNodes) { var startIndex = anchorNode.parentNode.getChildIndex(anchorNode) + 1; fragmentNodes.forEach(function (node, index) { console.log('attachFragmentAfterElement: child: ' + node.viewName + ' after: ' + anchorNode.viewName + ' startIndex: ' + startIndex + ' index: ' + index); anchorNode.parentNode.insertChildAt(startIndex + index, node); node.attachToView(startIndex + index); }); }; NativeScriptRenderer.prototype.detachFragment = function (fragmentRef) { //TODO: implement... console.log('NativeScriptRenderer.detachFragment'); var fragmentNodes = fragmentRef.resolveNodes(); fragmentNodes.forEach(function (node) { console.log('detaching fragment child: ' + node.viewName); if (node.parentNode) node.parentNode.removeChild(node); }); }; NativeScriptRenderer.prototype.hydrateView = function (viewRef) { console.log("NativeScriptRenderer.hydrateView "); //DOING nothing -- the view init code happens on attach: ViewNode#createUI }; NativeScriptRenderer.prototype.dehydrateView = function (viewRef) { console.log("NativeScriptRenderer.dehydrateView"); //TODO: detach events }; NativeScriptRenderer.prototype.setElementProperty = function (location, propertyName, propertyValue) { console.log("NativeScriptRenderer.setElementProperty " + propertyName + " = " + propertyValue); var view = location.renderView.resolveView(); var node = view.getBoundNode(location.renderBoundElementIndex); node.setProperty(propertyName, propertyValue); }; NativeScriptRenderer.prototype.setElementAttribute = function (location, attributeName, attributeValue) { console.log("NativeScriptRenderer.setElementAttribute " + attributeName + " = " + attributeValue); return this.setElementProperty(location, attributeName, attributeValue); }; NativeScriptRenderer.prototype.setElementClass = function (location, className, isAdd) { console.log("NativeScriptRenderer.setElementClass " + className + " - " + isAdd); var view = location.renderView.resolveView(); var node = view.getBoundNode(location.renderBoundElementIndex); if (isAdd) { node.addClass(className); } else { node.removeClass(className); } }; NativeScriptRenderer.prototype.getNativeElementSync = function (location) { console.log("NativeScriptRenderer.getNativeElementSync"); var view = location.renderView.resolveView(); var node = view.getBoundNode(location.renderBoundElementIndex); return node.nativeView; }; /** * Calls a method on an element. */ NativeScriptRenderer.prototype.invokeElementMethod = function (location, methodName, args) { console.log("NativeScriptRenderer.invokeElementMethod " + methodName + " " + args); }; NativeScriptRenderer.prototype.setText = function (viewRef, textNodeIndex, text) { console.log("NativeScriptRenderer.setText "); }; NativeScriptRenderer.prototype.setEventDispatcher = function (viewRef, dispatcher) { console.log("NativeScriptRenderer.setEventDispatcher "); var view = viewRef.resolveView(); view.eventDispatcher = dispatcher; }; NativeScriptRenderer.prototype._createView = function (proto, inplaceElement, isRoot) { if (isRoot === void 0) { isRoot = false; } console.log("NativeScriptRenderer._createView "); var clonedProtoView = util_1.cloneAndQueryProtoView(this._templateCloner, proto, true); var nativeElements; var boundElements = []; var templateRoot = clonedProtoView.fragments[0][0]; nativeElements = this._createNodes(null, [templateRoot], boundElements); if (isRoot) { nativeElements[0].attachToView(); } var view = new NativeScriptView(proto, nativeElements, boundElements); var binders = proto.elementBinders; for (var binderIdx = 0; binderIdx < binders.length; binderIdx++) { var binder = binders[binderIdx]; var viewNode = boundElements[binderIdx]; // events if (binder.eventLocals != null && binder.localEvents != null) { for (var i = 0; i < binder.localEvents.length; i++) { viewNode.createEventListener(view, binderIdx, binder.localEvents[i].name, binder.eventLocals); } } } var fragments = clonedProtoView.fragments.map(function (nodes) { console.log('Fragment with nodes: ' + nodes.length + ' first: ' + nodes[0].name); return new NativeScriptFragmentRef(nativeElements); }); return new api_1.RenderViewWithFragments(new NativeScriptViewRef(view), fragments); }; NativeScriptRenderer.prototype._createNodes = function (parent, parsedChildren, boundElements) { var _this = this; console.log('NativeScriptRenderer._createNodes ' + (parent ? parent.viewName : 'NULL')); var viewNodes = []; parsedChildren.forEach(function (node) { var viewNode; if (node.type == "tag") { viewNode = new view_node_1.ViewNode(parent, node.name, node.attribs); } else if (node.type == "text") { //viewNode = new ViewNode(parent, "rawtext", {text: node.data}); //Ignore text nodes return; } else if (node.type == "root") { //viewNode = new ViewNode(parent, "root", {}); //Ignore "root" elements. return; } else { console.dump(node); throw new Error('Unknown parse node type'); } if (dom_adapter_1.DOM.hasClass(node, util_1.NG_BINDING_CLASS)) { boundElements.push(viewNode); } if (node.children) { var children = _this._createNodes(viewNode, node.children, boundElements); children.forEach(function (childViewNode, index) { viewNode.insertChildAt(index, childViewNode); }); } viewNodes.push(viewNode); }); return viewNodes; }; NativeScriptRenderer = __decorate([ angular2_1.Injectable(), __metadata('design:paramtypes', [template_cloner_1.TemplateCloner]) ], NativeScriptRenderer); return NativeScriptRenderer; })(api_1.Renderer);
var Location = (function () { function Location(platformStrategy, href) { var _this = this; this.platformStrategy = platformStrategy; /** @internal */ this._subject = new async_1.EventEmitter(); var browserBaseHref = lang_1.isPresent(href) ? href : this.platformStrategy.getBaseHref(); if (lang_2.isBlank(browserBaseHref)) { throw new exceptions_1.BaseException("No base href set. Either provide a provider for the APP_BASE_HREF token or add a base element to the document."); } this._baseHref = stripTrailingSlash(stripIndexHtml(browserBaseHref)); this.platformStrategy.onPopState(function (_) { async_1.ObservableWrapper.callNext(_this._subject, { 'url': _this.path(), 'pop': true }); }); } /** * Returns the normalized URL path. */ Location.prototype.path = function () { return this.normalize(this.platformStrategy.path()); }; /** * Given a string representing a URL, returns the normalized URL path. */ Location.prototype.normalize = function (url) { return stripTrailingSlash(_stripBaseHref(this._baseHref, stripIndexHtml(url))); }; /** * Given a string representing a URL, returns the normalized URL path. * If the given URL doesn't begin with a leading slash (`'/'`), this method adds one * before normalizing. */ Location.prototype.normalizeAbsolutely = function (url) { if (!url.startsWith('/')) { url = '/' + url; } return stripTrailingSlash(_addBaseHref(this._baseHref, url)); }; /** * Changes the browsers URL to the normalized version of the given URL, and pushes a * new item onto the platform's history. */ Location.prototype.go = function (path, query) { if (query === void 0) { query = ''; } var absolutePath = this.normalizeAbsolutely(path); this.platformStrategy.pushState(null, '', absolutePath, query); }; /** * Navigates forward in the platform's history. */ Location.prototype.forward = function () { this.platformStrategy.forward(); }; /** * Navigates back in the platform's history. */ Location.prototype.back = function () { this.platformStrategy.back(); }; /** * Subscribe to the platform's `popState` events. */ Location.prototype.subscribe = function (onNext, onThrow, onReturn) { if (onThrow === void 0) { onThrow = null; } if (onReturn === void 0) { onReturn = null; } async_1.ObservableWrapper.subscribe(this._subject, onNext, onThrow, onReturn); }; Location = __decorate([ angular2_1.Injectable(), __param(1, angular2_1.Optional()), __param(1, angular2_1.Inject(exports.APP_BASE_HREF)), __metadata('design:paramtypes', [location_strategy_1.LocationStrategy, String]) ], Location); return Location; })();