From 0ba8308fbeddd7a672ed50ddea4dcf47f10df6b9 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 9 Feb 2012 16:25:20 -0800 Subject: Removing the un-used package.json Signed-off-by: Valerio Virgillito --- js/components/package.json | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 js/components/package.json (limited to 'js') diff --git a/js/components/package.json b/js/components/package.json deleted file mode 100644 index f3a6f0e0..00000000 --- a/js/components/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "directories": { - "lib": "../../" - }, - "mappings": { - "montage": "../../node_modules/montage/" - } -} \ No newline at end of file -- cgit v1.2.3 From c8720030e315d8c440354f54cf48f0c1464d72cb Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 9 Feb 2012 16:31:15 -0800 Subject: deleted old utils file and move single method into NJUtils Signed-off-by: Valerio Virgillito --- js/helper-classes/Utils.js | 33 --------------------------------- js/lib/NJUtils.js | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 33 deletions(-) delete mode 100644 js/helper-classes/Utils.js (limited to 'js') diff --git a/js/helper-classes/Utils.js b/js/helper-classes/Utils.js deleted file mode 100644 index 1cfc390e..00000000 --- a/js/helper-classes/Utils.js +++ /dev/null @@ -1,33 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - -// Adding to the String Prototype little utility function to capitalize the first Char of a String. -String.prototype.capitalizeFirstChar = function() { - return this.charAt(0).toUpperCase() + this.slice(1); -}; - -exports.utils = Object.create(Object.prototype, { - - getValueAndUnits: { - value: function(str) - { - var numberValue = parseFloat(str); - // Ignore all whitespace, digits, negative sign and "." when looking for units label - // The units must come after one or more digits - var objRegExp = /(\-*\d+\.*\d*)(\s*)(\w*\%*)/; - var unitsString = str.replace(objRegExp, "$3"); - if(unitsString) - { - var noSpaces = /(\s*)(\S*)(\s*)/; - // strip out spaces and convert to lower case - var match = (unitsString.replace(noSpaces, "$2")).toLowerCase(); - } - - return [numberValue, match]; - } - } - -}); \ No newline at end of file diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index d6548871..0e886ae7 100644 --- a/js/lib/NJUtils.js +++ b/js/lib/NJUtils.js @@ -183,6 +183,27 @@ exports.NJUtils = Object.create(Object.prototype, { }, + // Returns the numerical value and unit string from a string. + // Useful for element properties. + // 100px will return the following array: [100, px] + getValueAndUnits: { + value: function(input) { + var numberValue = parseFloat(input); + + // Ignore all whitespace, digits, negative sign and "." when looking for units label + // The units must come after one or more digits + var objRegExp = /(\-*\d+\.*\d*)(\s*)(\w*\%*)/; + var unitsString = input.replace(objRegExp, "$3"); + if(unitsString) { + var noSpaces = /(\s*)(\S*)(\s*)/; + // strip out spaces and convert to lower case + var match = (unitsString.replace(noSpaces, "$2")).toLowerCase(); + } + + return [numberValue, match]; + } + }, + /* ================= Style methods ================= */ ///// Get computed height of element -- cgit v1.2.3