aboutsummaryrefslogtreecommitdiff
path: root/node_modules/montage/core/shim
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/montage/core/shim')
-rw-r--r--[-rwxr-xr-x]node_modules/montage/core/shim/array.js51
-rw-r--r--node_modules/montage/core/shim/immediate.js57
-rw-r--r--node_modules/montage/core/shim/object.js36
-rwxr-xr-xnode_modules/montage/core/shim/string.js81
4 files changed, 37 insertions, 188 deletions
diff --git a/node_modules/montage/core/shim/array.js b/node_modules/montage/core/shim/array.js
index ff5d5d37..d5076440 100755..100644
--- a/node_modules/montage/core/shim/array.js
+++ b/node_modules/montage/core/shim/array.js
@@ -8,53 +8,11 @@
8 @see [Array class]{@link external:Array} 8 @see [Array class]{@link external:Array}
9 @module montage/core/shim/array 9 @module montage/core/shim/array
10*/ 10*/
11/**
12 @external Array
13*/
14 11
15/** 12/**
16 @function external:Array#equals 13 @external Array
17 @param {object} right The object to compare.
18 @returns {Boolean} true or false
19*/ 14*/
20if (!Array.prototype.equals) {
21 Object.defineProperty(Array.prototype, "equals", {
22 value: function (right) {
23 var i = 0,
24 length = this.length,
25 lhs,
26 rhs;
27
28 if (this === right) {
29 return true;
30 }
31
32 if (!right || !Array.isArray(right)) {
33 return false;
34 }
35
36 if (length !== right.length) {
37 return false;
38 } else {
39 for (; i < length; ++i) {
40 if (i in this) {
41 lhs = this[i],
42 rhs = right[i];
43 15
44 if (lhs !== rhs && (lhs && rhs && !lhs.equals(rhs))) {
45 return false;
46 }
47 } else {
48 if (i in right) {
49 return false;
50 }
51 }
52 }
53 }
54 return true;
55 }
56 });
57}
58/** 16/**
59 Shim implementation of Array.isArray() for browsers that don't yet support it. 17 Shim implementation of Array.isArray() for browsers that don't yet support it.
60 @function external:Array.isArray 18 @function external:Array.isArray
@@ -69,10 +27,3 @@ if (!Array.isArray) {
69 }); 27 });
70} 28}
71 29
72if (!Array.isCanvasPixelArray) {
73 Object.defineProperty(Array, "isCanvasPixelArray", {
74 value: function(obj) {
75 return Object.prototype.toString.call(obj) === "[object CanvasPixelArray]";
76 }
77 });
78}
diff --git a/node_modules/montage/core/shim/immediate.js b/node_modules/montage/core/shim/immediate.js
deleted file mode 100644
index 3ac48f31..00000000
--- a/node_modules/montage/core/shim/immediate.js
+++ /dev/null
@@ -1,57 +0,0 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6
7/**
8 [setImmediate()]{@link setImmediate}
9 and [clearImmediate()]{@link clearImmediate} shim functions.
10 @see setImmediate
11 @see clearImmediate
12 @module montage/core/shim/immediate
13*/
14
15/**
16 @function
17 @name setImmediate
18 @global
19*/
20
21/**
22 @function
23 @name clearImmediate
24 @global
25*/
26
27(function (global) {
28
29var nextTick = require("../next-tick").nextTick;
30
31if (typeof setImmediate === "undefined") {
32
33 var nextHandle = 0;
34 var handles = {};
35
36 global.setImmediate = function setImmediate(callback) {
37 var handle = nextHandle++;
38 var args = arguments.length > 1 ?
39 Array.prototype.slice.call(arguments, 1) :
40 void 0;
41 handles[handle] = true;
42 nextTick(function () {
43 if (handles[handle]) {
44 callback.apply(void 0, args);
45 delete handles[handle];
46 }
47 });
48 return handle;
49 };
50
51 global.clearImmediate = function clearImmediate(handle) {
52 delete handles[handle];
53 };
54
55}
56
57})(typeof global === "undefined" ? window : global);
diff --git a/node_modules/montage/core/shim/object.js b/node_modules/montage/core/shim/object.js
new file mode 100644
index 00000000..3b4f2351
--- /dev/null
+++ b/node_modules/montage/core/shim/object.js
@@ -0,0 +1,36 @@
1
2/**
3 @external Object
4 */
5
6if (!Object.create) {
7 Object._creator = function _ObjectCreator() {
8 this.__proto__ = _ObjectCreator.prototype;
9 };
10 Object.create = function(o, properties) {
11 this._creator.prototype = o || Object.prototype;
12 //Still needs to add properties....
13 return new this._creator;
14 };
15
16 Object.getPrototypeOf = function(o) {
17 return o.__proto__;
18 };
19}
20
21if (!Object.isSealed) {
22 Object.defineProperty(Object, "isSealed", {
23 value: function() {
24 return false;
25 }
26 });
27}
28
29if (!Object.seal) {
30 Object.defineProperty(Object, "seal", {
31 value: function(object) {
32 return object;
33 }
34 });
35}
36
diff --git a/node_modules/montage/core/shim/string.js b/node_modules/montage/core/shim/string.js
deleted file mode 100755
index 52f89710..00000000
--- a/node_modules/montage/core/shim/string.js
+++ /dev/null
@@ -1,81 +0,0 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6/**
7 Defines extensions to native String object.
8 @see [String class]{@link external:String}
9 @module montage/core/shim/string
10*/
11
12/**
13 @external String
14 */
15Object.defineProperties(String.prototype, /** @lends external:String.prototype#*/{
16 /**
17 @function external:String.addEventListener
18 @param {Listener} type The type of event listener.
19 @param {Listener} listener The event listener.
20 @param {Function} useCapture The capturing function.
21 */
22 addEventListener: {
23 value: function(type, listener, useCapture) {
24 //NO OP, on purpose
25 }
26
27 },
28 /**
29 Capitalizes the first letter in the string.
30 @function external:String.toCapitalized
31 @returns {String} The original string with its first letter capitalized.
32 @example
33 var fname = "abe";
34 var lname = "lincoln";
35 var name = fname.toCapitalized() + " " + lname.toCapitalized();
36 // name == "Abe Lincoln"
37 */
38 toCapitalized: {
39 value: function() {
40 return this.charAt(0).toUpperCase() + this.slice(1);
41 }
42 },
43
44 /**
45 Returns true if the two strings are equal, otherwise returns false.
46 @function external:String.equals
47 @param {Object} anObject The object to compare to the string.
48 @returns {Boolean} Returns true if the string is equal to <code>anObject</code>.
49 */
50 equals: {
51 value: function(anObject) {
52 if (this.toString() === anObject) {
53 return true;
54 }
55
56 if (!anObject || !(anObject instanceof String)) {
57 return false;
58 }
59
60 return (this == anObject);
61 }
62 }
63
64});