Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5C99717465 for ; Tue, 28 Apr 2015 04:08:50 +0000 (UTC) Received: (qmail 61897 invoked by uid 500); 28 Apr 2015 04:08:50 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 61747 invoked by uid 500); 28 Apr 2015 04:08:50 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 61711 invoked by uid 99); 28 Apr 2015 04:08:50 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Apr 2015 04:08:50 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E1B7CE17F7; Tue, 28 Apr 2015 04:08:49 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: axemclion@apache.org To: commits@cordova.apache.org Date: Tue, 28 Apr 2015 04:08:52 -0000 Message-Id: In-Reply-To: <69bf32e2969a4128b410fefc33e23465@git.apache.org> References: <69bf32e2969a4128b410fefc33e23465@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [4/7] cordova-windows git commit: CB-8923 Add support for Windows 10 platform http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/0d2387d9/template/WinJS/js/WinJS.intellisense-setup.js ---------------------------------------------------------------------- diff --git a/template/WinJS/js/WinJS.intellisense-setup.js b/template/WinJS/js/WinJS.intellisense-setup.js new file mode 100644 index 0000000..e506887 --- /dev/null +++ b/template/WinJS/js/WinJS.intellisense-setup.js @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. +/* global intellisense, window */ +(function () { + "use strict"; + + var redirect = intellisense.redirectDefinition; + + var originalKeys = Object.keys; + function baseKeys(o) { + var values = Object.getOwnPropertyNames(o); + for (var i = 0, len = values.length; i < len; ++i) { + if (values[i].substr(0, 7) === "_$field") { return values; } + } + return originalKeys(o); + } + Object.keys = baseKeys; + + redirect(baseKeys, originalKeys); + + window._$originalAddEventListener = window.addEventListener; + function addEventListener(type, handler, useCapture) { + if (typeof (type) === "string" && (type === "pointerdown" || type === "keydown")) { + handler = function () { }; + } + return window._$originalAddEventListener(type, handler, useCapture); + } + window.addEventListener = addEventListener; + + redirect(addEventListener, window._$originalAddEventListener); +})(); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/0d2387d9/template/WinJS/js/WinJS.intellisense.js ---------------------------------------------------------------------- diff --git a/template/WinJS/js/WinJS.intellisense.js b/template/WinJS/js/WinJS.intellisense.js new file mode 100644 index 0000000..587dbad --- /dev/null +++ b/template/WinJS/js/WinJS.intellisense.js @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. +/* global intellisense, window, document, setTimeout, WinJS */ +(function () { + "use strict"; + var redirect = intellisense.redirectDefinition; + + function makeAllEnumerable(v) { + /// + if (v && typeof v === "object") { + Object.getOwnPropertyNames(v).forEach(function (name) { + var pd = Object.getOwnPropertyDescriptor(v, name); + if (!pd.enumerable && pd.configurable) { + pd.enumerable = true; + Object.defineProperty(v, name, pd); + } + }); + } + return v; + } + + function wrap(old) { + /// + var wrapper = function () { + var args = []; + for (var i = 0, len = arguments.length; i < len; i++) { + args.push(makeAllEnumerable(arguments[i])); + } + return old.apply(this, args); + }; + redirect(wrapper, old); + return wrapper; + } + + function wrapAllMethods(v) { + /// + if (v) { + Object.getOwnPropertyNames(v).forEach(function (name) { + var value = v[name]; + if (typeof value === "function") { + v[name] = wrap(value); + } + }); + } + return v; + } + + if (this.WinJS) { + wrapAllMethods(WinJS.Namespace); + wrapAllMethods(WinJS.Class); + } + + (function () { + var originalApplicationStart = WinJS.Application.start; + WinJS.Application.start = function () { + // Call app.stop() when execution completes to ensure that the subsequent calls to app.start() do not see the app as running. + var app = this; + setTimeout(function () { + app.stop(); + }, 0); + return originalApplicationStart.apply(this, arguments); + }; + redirect(WinJS.Application.start, originalApplicationStart); + + var originalPagesDefine = WinJS.UI.Pages.define; + WinJS.UI.Pages.define = function (uri, members) { + var result = originalPagesDefine.apply(this, arguments); + + intellisense.callerDefines(result, members); + if (typeof uri === 'string') { + intellisense.declareNavigationContainer(result, "Page (" + uri + ")"); + } + + // Set the call contexts for IPageControlMembers + if (members) { + var pageInstance = new result(); + + if (typeof members.error === 'function') { + intellisense.setCallContext(members.error, { thisArg: pageInstance, args: [new Error()] }); + } + if (typeof members.init === 'function') { + intellisense.setCallContext(members.init, { thisArg: pageInstance, args: [document.createElement('element'), {}] }); + } + if (typeof members.load === 'function') { + intellisense.setCallContext(members.load, { thisArg: pageInstance, args: [""] }); + } + if (typeof members.processed === 'function') { + intellisense.setCallContext(members.processed, { thisArg: pageInstance, args: [document.createElement('element'), {}] }); + } + if (typeof members.ready === 'function') { + intellisense.setCallContext(members.ready, { thisArg: pageInstance, args: [document.createElement('element'), {}] }); + } + if (typeof members.render === 'function') { + intellisense.setCallContext(members.render, { thisArg: pageInstance, args: [document.createElement('element'), {}, WinJS.Promise.wrap()] }); + } + } + + return result; + }; + redirect(WinJS.UI.Pages.define, originalPagesDefine); + + // Simulate a call to a class' instance/static methods for WinJS.Class.define + var originalClassDefine = WinJS.Class.define; + WinJS.Class.define = function (constructor, instanceMembers, staticMembers) { + var result = originalClassDefine.call(this, constructor, instanceMembers, staticMembers); + // Go through the instance members to find methods + if (instanceMembers) { + var classInstance; + Object.getOwnPropertyNames(instanceMembers).forEach(function (name) { + var member = instanceMembers[name]; + if (typeof member === 'function') { + intellisense.setCallContext(member, { + get thisArg() { + if (!classInstance) { + classInstance = new result(); + } + return classInstance; + } + }); + } + }); + } + // Go through the static members to find methods + if (staticMembers) { + Object.getOwnPropertyNames(staticMembers).forEach(function (name) { + var member = staticMembers[name]; + if (typeof member === 'function') { + intellisense.setCallContext(member, { thisArg: result }); + } + }); + } + + return result; + }; + redirect(WinJS.Class.define, originalClassDefine); + + // Define the caller location property for WinJS.Namespace.define + var originalNamespaceDefine = WinJS.Namespace.define; + WinJS.Namespace.define = function (name, members) { + var result = originalNamespaceDefine.call(this, name, members); + if (typeof name === 'string' && result) { + // Get the global object + var globalObj = (function () { + return this; + })(); + + // Define the caller location of parent namespaces that haven't yet been defined + var path; + var namespaceParts = name.split("."); + for (var i = 0; i < namespaceParts.length - 1; i++) { + path = ((i === 0) ? namespaceParts[i] : path += "." + namespaceParts[i]); + var item = globalObj[path]; + if (item) { + intellisense.callerDefines(item); + } + } + + // Define the caller location of the original namespace + intellisense.callerDefines(result, members); + } + return result; + }; + redirect(WinJS.Namespace.define, originalNamespaceDefine); + + intellisense.setCallContext(WinJS.Promise, { thisArg: {}, args: [function () { }] }); + })(); + + (function () { + // In the language serivce all promises are completed promises. The completed promise class is private + // to WinJS, however, we can get access to the prototype through one of the promise instances by + // getting the instance's constructor's prototype. + var promisePrototype = WinJS.Promise.as(1).constructor.prototype; + + // Setting the argument calling context of the done and then methods to be an instance of Error(). + // The completion callback is handled in WinJS itself through a metadata comment. + var originalDone = promisePrototype.done; + promisePrototype.done = function (c, e, p) { + intellisense.setCallContext(e, { thisArg: this, args: [new Error()] }); + return originalDone.apply(this, arguments); + }; + redirect(promisePrototype.done, originalDone); + + var originalThen = promisePrototype.then; + promisePrototype.then = function (c, e, p) { + intellisense.setCallContext(e, { thisArg: this, args: [new Error()] }); + return originalThen.apply(this, arguments); + }; + redirect(promisePrototype.then, originalThen); + })(); + + if (window._$originalAddEventListener) { + window.addEventListener = window._$originalAddEventListener; + window._$originalAddEventListener = null; + delete window._$originalAddEventListener; + } +})(); \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org For additional commands, e-mail: commits-help@cordova.apache.org