Skip to content

Instantly share code, notes, and snippets.

@nitinhayaran
Created June 26, 2013 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nitinhayaran/5870106 to your computer and use it in GitHub Desktop.
Save nitinhayaran/5870106 to your computer and use it in GitHub Desktop.
create a input text box, similar to an existing div. Copying its text styles.
if (!window.getComputedStyle) {
window.getComputedStyle = function(el, pseudo) {
this.el = el;
this.getPropertyValue = function(prop) {
var re = /(\-([a-z]){1})/g;
if (prop === 'float') prop = 'styleFloat';
if (re.test(prop)) {
prop = prop.replace(re, function () {
return arguments[2].toUpperCase();
});
}
return el.currentStyle[prop] ? el.currentStyle[prop] : null;
};
return this;
};
}
var styles = window.getComputedStyle(this.element[0]);
var cssProperties = ['font-family','font-size', 'color','display'];
return $('<input />',{
value : this.getValue(),
class : this.options.textBoxClass,
css : _.object(cssProperties, _.map(cssProperties, function(prop){return styles[prop];}))
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment