Changeset 72 for trunk/style
- Timestamp:
- Feb 6, 2009, 9:00:42 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/style/global.js
r71 r72 11 11 } 12 12 13 function adjustRows(textarea)13 function getAppVersion() 14 14 { 15 if(document.all) 15 appname = navigator.appName; 16 appversion = navigator.appVersion; 17 majorver = appversion.substring(0, 1); 18 if ( (appname == "Netscape") && ( majorver >= 3 ) ) return 1; 19 if ( (appname == "Microsoft Internet Explorer") && (majorver >= 4) ) return 1; 20 return 0; 21 } 22 23 function ResizeTextArea(t) 24 { 25 a = t.value.split('\n'); 26 //if(getAppVersion()) b = 3; else 27 b = 1; 28 for(x = 0; x < a.length; x++) 16 29 { 17 while(textarea.scrollHeight > textarea.clientHeight) 18 textarea.rows++; 19 textarea.scrollTop = 0; 30 if(a[x].length >= t.cols) b += Math.floor(a[x].length / t.cols); 20 31 } 21 else if(textarea.rows) 32 b += a.length; 33 //if(b > t.rows) 34 t.rows = b; 35 } 36 37 onload = function() 38 { 39 if (document.getElementsByClassName == undefined) 22 40 { 23 textarea.rows = 30; 24 /* 25 var lineBreaks = 50;//countLineBreaks(textarea.value); 26 var rows = parseInt(textarea.rows); 27 var wrap = textarea.getAttribute('wrap'); 28 if(lineBreaks > rows) 29 textarea.rows = ++rows; 30 else if(wrap.toLowerCase() == 'soft' || wrap.toLowerCase() == 'hard') 41 document.getElementsByClassName = function(className) 31 42 { 32 while(textarea.rows * textarea.cols <= textarea.value.length) 33 { 34 textarea.rows = 4; //++rows; 35 } 36 } 37 */ 43 var hasClassName = new RegExp("(?:^|\\s)" + className + "(?:$|\\s)"); 44 var allElements = document.getElementsByTagName("*"); 45 var results = []; 46 47 var element; 48 for (var i = 0; (element = allElements[i]) != null; i++) 49 { 50 var elementClass = element.className; 51 if (elementClass && elementClass.indexOf(className) != -1 && hasClassName.test(elementClass)) 52 results.push(element); 53 } 54 55 return results; 56 } 57 58 } 59 60 arr = document.getElementsByClassName('textedit'); 61 for (i = 0; i < arr.length; i++) 62 { 63 ResizeTextArea(arr[i]); 38 64 } 39 65 } 66
Note:
See TracChangeset
for help on using the changeset viewer.