﻿

String.implement({
	convertCssStringToJson: function (cssNotation) {
		var jsonNotation = this.trim();
		if (jsonNotation.substring(jsonNotation.length - 1) == ";")
			jsonNotation = jsonNotation.substring(0, jsonNotation.length - 1);
		jsonNotation = jsonNotation.replace(/:\s*([^\-0123456789][^0123456789;\s]+);?/g, ':\'$1\',');
		jsonNotation = jsonNotation.replace(/:\s*(-?[0123456789]*?)\s*;/g, ':$1,');
		if (jsonNotation.substring(jsonNotation.length - 1) == ',')
			jsonNotation = jsonNotation.substring(0, jsonNotation.length - 1);
		return jsonNotation;
	},
	cssUrl: function () {
		return 'url(' + this + ')';
	},
	removePx: function() {
		return Number(this.toLowerCase().replace('px', ''));
	}
});

Element.implement({
	measureSize: function () {
		return this.measure(function(){ return this.getSize(); });
	}
});


