Created
June 26, 2013 18:36
-
-
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.
This file contains 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
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