Changeset 702 for trunk/forum/styles/prosilver/template/editor.js
- Timestamp:
- Mar 31, 2010, 6:32:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/forum/styles/prosilver/template/editor.js
r400 r702 8 8 var theSelection = false; 9 9 10 var bbcodeEnabled = true; 10 11 // Check for Browser & Platform for PC & IE specific bits 11 12 // More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html … … 15 16 var is_ie = ((clientPC.indexOf('msie') != -1) && (clientPC.indexOf('opera') == -1)); 16 17 var is_win = ((clientPC.indexOf('win') != -1) || (clientPC.indexOf('16bit') != -1)); 17 18 18 var baseHeight; 19 onload_functions.push('initInsertions()');20 19 21 20 /** … … 252 251 if (theSelection) 253 252 { 254 insert_text('[quote="' + username + '"]' + theSelection + '[/quote]'); 253 if (bbcodeEnabled) 254 { 255 insert_text('[quote="' + username + '"]' + theSelection + '[/quote]'); 256 } 257 else 258 { 259 var lines = split_lines(theSelection); 260 for (i = 0; i < lines.length; i++) 261 { 262 insert_text('> ' + lines[i] + '\n') 263 } 264 } 255 265 } 256 266 … … 258 268 } 259 269 270 function split_lines(text) 271 { 272 var lines = text.split('\n'); 273 var splitLines = new Array(); 274 var j = 0; 275 for(i = 0; i < lines.length; i++) 276 { 277 if (lines[i].length <= 80) 278 { 279 splitLines[j] = lines[i]; 280 j++; 281 } 282 else 283 { 284 var line = lines[i]; 285 do 286 { 287 var splitAt = line.indexOf(' ', 80); 288 289 if (splitAt == -1) 290 { 291 splitLines[j] = line; 292 j++ 293 } 294 else 295 { 296 splitLines[j] = line.substring(0, splitAt); 297 line = line.substring(splitAt); 298 j++; 299 } 300 } 301 while(splitAt != -1) 302 } 303 } 304 return splitLines; 305 } 260 306 /** 261 307 * From http://www.massless.org/mozedit/ … … 263 309 function mozWrap(txtarea, open, close) 264 310 { 265 var selLength = txtarea.textLength;311 var selLength = (typeof(txtarea.textLength) == 'undefined') ? txtarea.value.length : txtarea.textLength; 266 312 var selStart = txtarea.selectionStart; 267 313 var selEnd = txtarea.selectionEnd; … … 278 324 279 325 txtarea.value = s1 + open + s2 + close + s3; 280 txtarea.selectionStart = sel End + open.length + close.length;281 txtarea.selectionEnd = txtarea.selectionStart;326 txtarea.selectionStart = selStart + open.length; 327 txtarea.selectionEnd = selEnd + open.length; 282 328 txtarea.focus(); 283 329 txtarea.scrollTop = scrollTop;
Note:
See TracChangeset
for help on using the changeset viewer.