includes/clientside/tinymce/utils/form_utils.js
changeset 543 dffcbfbc4e59
parent 459 31c23016ab62
child 1193 e3b94bd055dc
equal deleted inserted replaced
542:5841df0ab575 543:dffcbfbc4e59
     1 /**
     1 /**
     2  * $Id: form_utils.js 614 2008-02-20 17:57:57Z spocke $
     2  * $Id: form_utils.js 673 2008-03-06 13:26:20Z spocke $
     3  *
     3  *
     4  * Various form utilitiy functions.
     4  * Various form utilitiy functions.
     5  *
     5  *
     6  * @author Moxiecode
     6  * @author Moxiecode
     7  * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
     7  * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
   168 
   168 
   169 	return col;
   169 	return col;
   170 }
   170 }
   171 
   171 
   172 function trimSize(size) {
   172 function trimSize(size) {
   173 	return size.replace(new RegExp('[^0-9%]', 'gi'), '');
   173 	return size.replace(/([0-9\.]+)px|(%|in|cm|mm|em|ex|pt|pc)/, '$1$2');
   174 }
   174 }
   175 
   175 
   176 function getCSSSize(size) {
   176 function getCSSSize(size) {
   177 	size = trimSize(size);
   177 	size = trimSize(size);
   178 
   178 
   179 	if (size == "")
   179 	if (size == "")
   180 		return "";
   180 		return "";
   181 
   181 
   182 	return size.indexOf('%') != -1 ? size : size + "px";
   182 	// Add px
       
   183 	if (/^[0-9]+$/.test(size))
       
   184 		size += 'px';
       
   185 
       
   186 	return size;
   183 }
   187 }
   184 
   188 
   185 function getStyle(elm, attrib, style) {
   189 function getStyle(elm, attrib, style) {
   186 	var val = tinyMCEPopup.dom.getAttrib(elm, attrib);
   190 	var val = tinyMCEPopup.dom.getAttrib(elm, attrib);
   187 
   191