Created
January 2, 2014 16:44
-
-
Save joshualambert/8222100 to your computer and use it in GitHub Desktop.
hintText shim for Appcelerator's Titanium allowing hintText to be colored. Simply call this function after creating each textfield, and pass the option isPswd boolean if you're dealing with a password field.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Used to fake hintText coloring to the font color. | |
// Requires hintText to be defined on the object being passed. | |
function hintTextShim(uiObject, isPswd) { | |
uiObject.objectFocus = function () { | |
if (uiObject.value === uiObject.hintText) { | |
if (typeof isPswd !== 'undefined' && isPswd === true) { | |
uiObject.passwordMask = true; | |
} | |
uiObject.value = ''; | |
} | |
}; | |
uiObject.objectBlur = function () { | |
if (uiObject.value === '') { | |
if (typeof isPswd !== 'undefined' && isPswd === true) { | |
uiObject.passwordMask = false; | |
} | |
uiObject.value = uiObject.hintText; | |
} | |
}; | |
uiObject.addEventListener('focus', uiObject.objectFocus); | |
uiObject.addEventListener('blur', uiObject.objectBlur); | |
uiObject.objectBlur(); // Go ahead and set the default hintText. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment