Changeset 56
- Timestamp:
- 07/03/07 12:59:07 (3 years ago)
- Files:
-
- wikkaedit/trunk/wikkaedit.js (modified) (34 diffs)
- wikkaedit/trunk/wikkaedit_actions.js (modified) (12 diffs)
- wikkaedit/trunk/wikkaedit_data.js (modified) (2 diffs)
- wikkaedit/trunk/wikkaedit_search.js (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
wikkaedit/trunk/wikkaedit.js
r51 r56 6 6 // // 7 7 // Copyright (C) 2007 Olivier Borowski (coin at tuxfamily dot org) // 8 // based on WikiEdit (http://wackowiki.com/WikiEdit)//8 // Homepage : http://wikkawiki.org/WikkaEdit // 9 9 // // 10 10 // This program is free software; you can redistribute it and/or // … … 24 24 // // 25 25 //////////////////////////////////////////////////////////////////////// 26 known bugs :27 - key event cancellation doesn't work on opera28 - shift+tab doesn't work on konqueror29 26 */ 30 27 … … 36 33 37 34 // init data 38 this. _actionsMenuEnabled = (typeof(this.contextualHelp) != "undefined");39 this. _searchReplaceEnabled = (typeof(this.showSearchWindow) != "undefined");35 this.we_actionsMenuEnabled = (typeof(this.contextualHelp) != "undefined"); 36 this.we_searchReplaceEnabled = (typeof(this.showSearchWindow) != "undefined"); 40 37 this.initButtons(); 41 38 this.initCategs(); 42 if (this. _actionsMenuEnabled)39 if (this.we_actionsMenuEnabled) 43 40 this.initActions(); 44 41 45 42 // add a toolbar before textarea 46 this. _toolbar = document.createElement("div");47 this. _toolbar.id = "wikkatoolbar";48 this. _toolbar.innerHTML = this.genToolbar();49 this. _ta.parentNode.insertBefore(this._toolbar, this._ta);43 this.we_toolbar = document.createElement("div"); 44 this.we_toolbar.id = "wikkatoolbar"; 45 this.we_toolbar.innerHTML = this.genToolbar(); 46 this.we_ta.parentNode.insertBefore(this.we_toolbar, this.we_ta); 50 47 51 48 // submenu 52 this. _submenu = document.createElement("div");53 this. _submenu.id = "wikkasubmenu";54 this. _submenu.style.visibility = "hidden";55 this. _ta.parentNode.insertBefore(this._submenu, this._ta); //this._help.nextSibling);49 this.we_submenu = document.createElement("div"); 50 this.we_submenu.id = "wikkasubmenu"; 51 this.we_submenu.style.visibility = "hidden"; 52 this.we_ta.parentNode.insertBefore(this.we_submenu, this.we_ta); //this.we_help.nextSibling); 56 53 57 54 // search & replace 58 if (this. _searchReplaceEnabled) {55 if (this.we_searchReplaceEnabled) { 59 56 // search & replace window 60 this. _search = document.createElement("div");61 this. _search.id = "wikkasearch";62 this. _search.style.visibility = "hidden"63 this. _search.style.width = "500px"; // width & height can't be moved to the CSS, else JS can't read these values later64 this. _search.style.height = "180px";65 this. _ta.parentNode.insertBefore(this._search, this._ta.nextSibling);66 67 // dummy textarea, used to scroll this. _ta to the right position57 this.we_search = document.createElement("div"); 58 this.we_search.id = "wikkasearch"; 59 this.we_search.style.visibility = "hidden" 60 this.we_search.style.width = "500px"; // width & height can't be moved to the CSS, else JS can't read these values later 61 this.we_search.style.height = "180px"; 62 this.we_ta.parentNode.insertBefore(this.we_search, this.we_ta.nextSibling); 63 64 // dummy textarea, used to scroll this.we_ta to the right position 68 65 // it is hidden, but it needs to be inserted to the page to work 69 this. _searchTa = document.createElement("textarea");70 this. _searchTa.style.position = "absolute";71 this. _searchTa.style.left = 0;72 this. _searchTa.style.top = 0;73 this. _searchTa.style.visibility = "hidden";74 this. _searchTa.style.scroll = "auto";75 this. _ta.parentNode.insertBefore(this._searchTa, this._ta.nextSibling);66 this.we_searchTa = document.createElement("textarea"); 67 this.we_searchTa.style.position = "absolute"; 68 this.we_searchTa.style.left = 0; 69 this.we_searchTa.style.top = 0; 70 this.we_searchTa.style.visibility = "hidden"; 71 this.we_searchTa.style.scroll = "auto"; 72 this.we_ta.parentNode.insertBefore(this.we_searchTa, this.we_ta.nextSibling); 76 73 } 77 74 78 75 // actions 79 if (this. _actionsMenuEnabled) {76 if (this.we_actionsMenuEnabled) { 80 77 // help 81 this. _helpPreviousContent = " ";82 this. _help = document.createElement("div");83 this. _help.id = "wikkahelp";84 this. _help.innerHTML = this._helpPreviousContent; // contains at least a character to keep constant height85 this. _help.style.display = (this._actionsMenuEnabled ? "" : "none");86 this. _ta.parentNode.insertBefore(this._help, this._ta.nextSibling.nextSibling); // next*2 to skip following <br/>78 this.we_helpPreviousContent = " "; 79 this.we_help = document.createElement("div"); 80 this.we_help.id = "wikkahelp"; 81 this.we_help.innerHTML = this.we_helpPreviousContent; // contains at least a character to keep constant height 82 this.we_help.style.display = (this.we_actionsMenuEnabled ? "" : "none"); 83 this.we_ta.parentNode.insertBefore(this.we_help, this.we_ta.nextSibling.nextSibling); // next*2 to skip following <br/> 87 84 // tooltip 88 this. _tooltip = document.createElement("div");89 this. _tooltip.id = "wikkatooltip";90 this. _tooltip.style.visibility = "hidden"91 this. _ta.parentNode.insertBefore(this._tooltip, this._help.nextSibling);85 this.we_tooltip = document.createElement("div"); 86 this.we_tooltip.id = "wikkatooltip"; 87 this.we_tooltip.style.visibility = "hidden" 88 this.we_ta.parentNode.insertBefore(this.we_tooltip, this.we_help.nextSibling); 92 89 } 93 90 94 91 // log (debug) 95 this. _log = document.createElement("div");96 this. _log.id = "wikkalog";97 this. _log.innerHTML = "log<br/>";98 this. _log.style.display = "none";99 this. _ta.parentNode.insertBefore(this._log, this._ta.nextSibling);100 //this. _ta.parentNode.insertBefore(this._log, this._help.nextSibling);92 this.we_log = document.createElement("div"); 93 this.we_log.id = "wikkalog"; 94 this.we_log.innerHTML = "log<br/>"; 95 this.we_log.style.display = "none"; 96 this.we_ta.parentNode.insertBefore(this.we_log, this.we_ta.nextSibling); 97 //this.we_ta.parentNode.insertBefore(this.we_log, this.we_help.nextSibling); 101 98 102 99 // make sure nothing is selectionned in the textarea 103 100 this.setSelectionRange(0, 0); 104 101 // intercept special keys (tab...) 105 this. _ta.onkeydown = this.keyDown;106 //this. _ta.onkeyup = this.keyUp;107 this. _ta.onmousedown = this.mouseDown;102 this.we_ta.onkeydown = this.keyDown; 103 //this.we_ta.onkeyup = this.keyUp; 104 this.we_ta.onmousedown = this.mouseDown; 108 105 // focus on the textarea 109 this. _ta.focus();106 this.we_ta.focus(); 110 107 111 108 // editor height follow browser window height 112 109 setInterval("varWikkaEdit.moveElementsAfterWindowResize();", this.EDITOR_HEIGHT_POLL_INTERV); 113 110 // help for the command under the carret 114 if (this. _actionsMenuEnabled)111 if (this.we_actionsMenuEnabled) 115 112 setInterval("varWikkaEdit.contextualHelp();", this.CONTEXTUAL_HELP_POLL_INTERV); 116 113 } … … 120 117 var ok = false; 121 118 try { 122 var w3 = (this. _ta.selectionStart != null);119 var w3 = (this.we_ta.selectionStart != null); 123 120 var ie6 = (document.selection && document.selection.createRange); 124 121 if (w3 || ie6) … … 134 131 try { 135 132 // make editor height follow browser window height 136 if (this. _ta.style.height == "") this._ta.style.height = "500px"; // this._ta.style.height is "" the 1st time133 if (this.we_ta.style.height == "") this.we_ta.style.height = "500px"; // this.we_ta.style.height is "" the 1st time 137 134 var windowHeight = parseInt(window.innerHeight ? window.innerHeight : document.documentElement.clientHeight, 10); 138 135 var change = windowHeight - parseInt(document.body.offsetHeight, 10); 139 136 if (change != 0) { 140 var newheight = Math.max(this.EDITOR_MIN_HEIGHT, parseInt(this. _ta.style.height, 10) + change);141 this. _ta.style.height = newheight + "px";137 var newheight = Math.max(this.EDITOR_MIN_HEIGHT, parseInt(this.we_ta.style.height, 10) + change); 138 this.we_ta.style.height = newheight + "px"; 142 139 } 143 140 144 141 // keep search & replace window on the bottom of the window 145 if (this. _searchReplaceEnabled) {142 if (this.we_searchReplaceEnabled) { 146 143 var windowWidth = parseInt(window.innerWidth ? window.innerWidth : document.documentElement.clientWidth, 10); 147 this. _search.style.left = (windowWidth / 2 - parseInt(this._search.style.width,10) / 2) + "px";148 this. _search.style.top = (windowHeight - parseInt(this._search.style.height,10) - 1) + "px";144 this.we_search.style.left = (windowWidth / 2 - parseInt(this.we_search.style.width,10) / 2) + "px"; 145 this.we_search.style.top = (windowHeight - parseInt(this.we_search.style.height,10) - 1) + "px"; 149 146 } 150 147 } catch(e) { … … 159 156 // ========== main buttons ========== 160 157 var html = ""; 161 for(var i in this. _buttons) {162 switch (this. _buttons[i].type) {158 for(var i in this.we_buttons) { 159 switch (this.we_buttons[i].type) { 163 160 case "button" : // button 164 html += "<img class=\"toolbutton\" src=\"3rdparty/plugins/wikkaedit/images/" + i.substr(1) + ".gif\" alt=\"" + i.substr(1) + "\" title=\"" + this._buttons[i].title + "\" onclick=\"varWikkaEdit.toolbarButtonClick(this, '" + i.substr(1) + "');\"" + ie6_hover + " />";161 html += "<img class=\"toolbutton\" src=\"3rdparty/plugins/wikkaedit/images/" + this.refToName(i) + ".gif\" alt=\"" + this.refToName(i) + "\" title=\"" + this.we_buttons[i].title + "\" onclick=\"varWikkaEdit.toolbarButtonClick(this, '" + this.refToName(i) + "');\"" + ie6_hover + " />"; 165 162 break; 166 163 case "submenu" : // submenu 167 html += "<img class=\"toolbutton\" src=\"3rdparty/plugins/wikkaedit/images/submenu.gif\" alt=\"submenu\" title=\"" + this. _buttons[i].title + "\" onclick=\"varWikkaEdit.toolbarButtonClick(this, '" + i.substr(1) + "');\"" + ie6_hover + " />";164 html += "<img class=\"toolbutton\" src=\"3rdparty/plugins/wikkaedit/images/submenu.gif\" alt=\"submenu\" title=\"" + this.we_buttons[i].title + "\" onclick=\"varWikkaEdit.toolbarButtonClick(this, '" + this.refToName(i) + "');\"" + ie6_hover + " />"; 168 165 break; 169 166 case "separator" : // separator … … 171 168 break; 172 169 default : 173 alert("genToolbar() : unknown type (" + this. _buttons[i].type + ")");170 alert("genToolbar() : unknown type (" + this.we_buttons[i].type + ")"); 174 171 } 175 172 } 176 173 177 174 // ========== actions ========== 178 if (this. _actionsMenuEnabled) {175 if (this.we_actionsMenuEnabled) { 179 176 html += "<div style='border-top:1px solid #CCCCCC; margin:1px 0 4px 0'></div>"; 180 177 html += "<span style='vertical-align:middle;margin-left:5px'>Actions :</span>"; 181 for(i in this. _categs) {182 if (this. _categs[i].title != null) // hidden actions don't have a title183 html += "<span class=\"toolbutton\" style='margin-left:20px; padding:2px 5px 3px 6px' onclick=\"varWikkaEdit.toolbarCategClick('" + i + "', this);\">" + this. _categs[i].title + "<img src='3rdparty/plugins/wikkaedit/images/submenu.gif' style='vertical-align:middle'/></span>";178 for(i in this.we_categs) { 179 if (this.we_categs[i].title != null) // hidden actions don't have a title 180 html += "<span class=\"toolbutton\" style='margin-left:20px; padding:2px 5px 3px 6px' onclick=\"varWikkaEdit.toolbarCategClick('" + i + "', this);\">" + this.we_categs[i].title + "<img src='3rdparty/plugins/wikkaedit/images/submenu.gif' style='vertical-align:middle'/></span>"; 184 181 } 185 182 } … … 195 192 196 193 // hide a possible opened menu 197 if (((submenuName != null) || (this. _buttons["_" + buttonName].type != "submenu")) && (buttonName != "shortcuts"))194 if (((submenuName != null) || (this.we_buttons[this.nameToRef(buttonName)].type != "submenu")) && (buttonName != "shortcuts")) 198 195 this.hideSubmenu(); 199 196 … … 264 261 265 262 var actionAndParams = ""; 266 if (this. _actionsMenuEnabled) {263 if (this.we_actionsMenuEnabled) { 267 264 // === use actions data to insert the action === 268 265 // add the action and default parameters to the textarea 269 var actionName = this. _actions[actionRef].name;266 var actionName = this.we_actions[actionRef].name; 270 267 var OP; 271 268 actionAndParams += "{{" + actionName; 272 for(var i in this. _actions[actionRef].params) {273 OP = this. _actions[actionRef].params[i];269 for(var i in this.we_actions[actionRef].params) { 270 OP = this.we_actions[actionRef].params[i]; 274 271 if ((OP.nodefault == null) || (OP.nodefault == false)) // null or hide => add param 275 272 actionAndParams += " " + OP.name + "=\"" + OP.value + "\""; … … 294 291 // ===== hide a submenu (when necessary) ===== 295 292 WikkaEdit.prototype.hideSubmenu = function() { 296 this. _submenu.style.visibility = "hidden";293 this.we_submenu.style.visibility = "hidden"; 297 294 } 298 295 … … 304 301 WikkaEdit.prototype.toggleSubmenu = function(obj, newSubmenu, isAction) { 305 302 isAction = (isAction == true); 306 if ((newSubmenu == this. _currentSubmenu) && (this._submenu.style.visibility != "hidden")) {303 if ((newSubmenu == this.we_currentSubmenu) && (this.we_submenu.style.visibility != "hidden")) { 307 304 this.hideSubmenu(); 308 this. _ta.focus();305 this.we_ta.focus(); 309 306 return; 310 307 } … … 313 310 var coords = this.getObjectCoords(obj); 314 311 coords.y += 25; // TODO remove this hardcoded value (toolbar height) 315 this. _submenu.style.left = coords.x + "px";316 this. _submenu.style.top = coords.y + "px";312 this.we_submenu.style.left = coords.x + "px"; 313 this.we_submenu.style.top = coords.y + "px"; 317 314 318 315 var html = ""; … … 334 331 html += "<br/>"; 335 332 // Ctrl + F is not intercepted by Safari 336 if (!this. _webkit) {333 if (!this.we_webkit) { 337 334 html += "<span class='we_key'>Ctrl</span> + <span class='we_key'>F</span> : search & replace<br/>"; 338 335 html += "<br/>"; … … 343 340 344 341 // move the submenu to the left of the button 345 this. _submenu.style.left = (coords.x - SHORTCUTS_SUMMARY_WIDTH + 18) + "px"; // TODO remove this hardcoded value (button width)342 this.we_submenu.style.left = (coords.x - SHORTCUTS_SUMMARY_WIDTH + 18) + "px"; // TODO remove this hardcoded value (button width) 346 343 347 344 } else { … … 352 349 var i; 353 350 if (!isAction) { 354 for(i in this. _buttons["_" + newSubmenu]._buttons) {355 html += "<div class=\"smbutton\" onclick=\"varWikkaEdit.toolbarButtonClick(this, '" + i.substr(1) + "', '" + newSubmenu + "');\">";356 html += "<img class=\"smimage\" src=\"3rdparty/plugins/wikkaedit/images/" + i.substr(1) + ".gif\" alt=\"" + i.substr(1) + "\"" + ie6_hover + " />";357 html += this. _buttons["_" + newSubmenu]._buttons[i].title;351 for(i in this.we_buttons[this.nameToRef(newSubmenu)].we_buttons) { 352 html += "<div class=\"smbutton\" onclick=\"varWikkaEdit.toolbarButtonClick(this, '" + this.refToName(i) + "', '" + newSubmenu + "');\">"; 353 html += "<img class=\"smimage\" src=\"3rdparty/plugins/wikkaedit/images/" + this.refToName(i) + ".gif\" alt=\"" + this.refToName(i) + "\"" + ie6_hover + " />"; 354 html += this.we_buttons[this.nameToRef(newSubmenu)].we_buttons[i].title; 358 355 html += "</div>"; 359 356 } 360 357 } else { 361 for(i in this. _actions) {362 if (this. _actions[i].categ == newSubmenu) {363 html += "<div class=\"smbutton\" onclick=\"varWikkaEdit.toolbarActionClick('" + i + "');\"" + (this. _actions[i].summary == null ? "" : " title=\"" + this._actions[i].summary + "\"") + ">";364 html += "<img class=\"smimage\" src=\"3rdparty/plugins/wikkaedit/images/" + this. _actions[i].name + ".gif\" alt=\"" + this._actions[i].name + "\"" + ie6_hover + " />";365 html += this. _actions[i].title;358 for(i in this.we_actions) { 359 if (this.we_actions[i].categ == newSubmenu) { 360 html += "<div class=\"smbutton\" onclick=\"varWikkaEdit.toolbarActionClick('" + i + "');\"" + (this.we_actions[i].summary == null ? "" : " title=\"" + this.we_actions[i].summary + "\"") + ">"; 361 html += "<img class=\"smimage\" src=\"3rdparty/plugins/wikkaedit/images/" + this.we_actions[i].name + ".gif\" alt=\"" + this.we_actions[i].name + "\"" + ie6_hover + " />"; 362 html += this.we_actions[i].title; 366 363 html += "</div>"; 367 364 } … … 371 368 } 372 369 373 this. _submenu.innerHTML = html;374 this. _submenu.style.visibility = "";375 this. _currentSubmenu = newSubmenu;370 this.we_submenu.innerHTML = html; 371 this.we_submenu.style.visibility = ""; 372 this.we_currentSubmenu = newSubmenu; 376 373 } 377 374 … … 398 395 WikkaEdit.prototype.keyDown = function(e) { 399 396 // take care : this != varWikkaEdit 400 if (!varWikkaEdit. _canCancelKeyEvent)397 if (!varWikkaEdit.we_canCancelKeyEvent) 401 398 return true; 402 399 if (e == null) e = window.event; … … 426 423 case 27 : // escape 427 424 // TODO select the "note" textfield or the "store" button (when notes are disabled) 428 varWikkaEdit. _ta.blur();425 varWikkaEdit.we_ta.blur(); 429 426 return varWikkaEdit.cancelKey(e); 430 427 … … 447 444 } 448 445 case 70 : // ctrl + F 449 if (varWikkaEdit. _searchReplaceEnabled) {446 if (varWikkaEdit.we_searchReplaceEnabled) { 450 447 varWikkaEdit.showSearchWindow(); 451 448 return varWikkaEdit.cancelKey(e); … … 463 460 var key = (e.keyCode != null ? e.keyCode : e.which); 464 461 if ((e.ctrlKey) && (e.altKey)) 465 varWikkaEdit. _ta.blur();462 varWikkaEdit.we_ta.blur(); 466 463 }*/ 467 464 … … 511 508 newBeforeSel = beforeSel + "\n" + indentChars + marker + (marker == "" ? "" : " "); 512 509 // update new line 513 var scrollTop = this. _ta.scrollTop;514 this. _ta.value = newBeforeSel + afterSel;515 this. _ta.scrollTop = scrollTop;510 var scrollTop = this.we_ta.scrollTop; 511 this.we_ta.value = newBeforeSel + afterSel; 512 this.we_ta.scrollTop = scrollTop; 516 513 // move selection 517 514 // (note : after emptying a line, cursor goes to the previous line. It's not perfect but we … … 533 530 var afterSel = text.substr(sr.end); 534 531 // update selection content 535 this. _ta.value = beforeSel + content + afterSel;532 this.we_ta.value = beforeSel + content + afterSel; 536 533 // replace selection 537 534 sr.end += sr.start + content.length; 538 535 // focus on textarea 539 this. _ta.focus();536 this.we_ta.focus(); 540 537 this.setSelectionRange(sr.start, sr.end); 541 538 }*/ … … 564 561 } 565 562 // update selection content 566 var scrollTop = this. _ta.scrollTop;567 this. _ta.value = beforeSel + leftTag + sel + rightTag + afterSel;568 this. _ta.scrollTop = scrollTop;563 var scrollTop = this.we_ta.scrollTop; 564 this.we_ta.value = beforeSel + leftTag + sel + rightTag + afterSel; 565 this.we_ta.scrollTop = scrollTop; 569 566 // replace selection 570 567 if (false) { … … 575 572 } 576 573 // focus on textarea 577 this. _ta.focus();574 this.we_ta.focus(); 578 575 if (srAfter == null) 579 576 this.setSelectionRange(sr.start, sr.end); … … 615 612 case "outdent" : 616 613 if (arr[i].substr(0,1) == "\t") { 617 newSel += arr[i].substr(1) + (i < arr.length-1 ? "\n" : "");614 newSel += this.refToName(arr[i]) + (i < arr.length-1 ? "\n" : ""); 618 615 sr.end--; 619 616 } else { … … 632 629 } 633 630 // update selection content 634 var scrollTop = this. _ta.scrollTop;635 this. _ta.value = beforeSel + newSel + afterSel;636 this. _ta.scrollTop = scrollTop;631 var scrollTop = this.we_ta.scrollTop; 632 this.we_ta.value = beforeSel + newSel + afterSel; 633 this.we_ta.scrollTop = scrollTop; 637 634 // focus on textarea 638 this. _ta.focus();635 this.we_ta.focus(); 639 636 this.setSelectionRange(sr.start, sr.end); 640 637 } … … 660 657 661 658 WikkaEdit.prototype.setSelectionRange2 = function(start, end) { 662 if (typeof(this. _ta.setSelectionRange) != "undefined") { // W3659 if (typeof(this.we_ta.setSelectionRange) != "undefined") { // W3 663 660 // some browsers use CRLF for newlines in textarea (opera...) 664 if (this. _ta.value.indexOf("\r\n") != -1) {661 if (this.we_ta.value.indexOf("\r\n") != -1) { 665 662 var text = this.getTextAreaContent(); 666 663 var str; … … 677 674 // when (start == end) and a previous selection exists, setSelectionRange don't work 678 675 if (window.opera == null) { 679 this. _ta.setSelectionRange(start, end);676 this.we_ta.setSelectionRange(start, end); 680 677 } else { 681 678 if (start != end) { 682 this. _ta.setSelectionRange(start, end);679 this.we_ta.setSelectionRange(start, end); 683 680 } else { 684 681 var sr = this.getSelectionRange(); 685 682 // check whether a move is necessary 686 683 if ((sr.start != start) || (sr.end != end)) 687 this. _ta.setSelectionRange(start, end);684 this.we_ta.setSelectionRange(start, end); 688 685 // check whether the bug has occured => select one character (can't do better...) 689 686 if ((sr.start != start) || (sr.end != end)) 690 this. _ta.setSelectionRange(start, start + 1);687 this.we_ta.setSelectionRange(start, start + 1); 691 688 } 692 689 } 693 690 } else { // ie6 694 var range = this. _ta.createTextRange();691 var range = this.we_ta.createTextRange(); 695 692 range.collapse(true); 696 693 range.moveStart("character", start); … … 704 701 WikkaEdit.prototype.getSelection = function() { 705 702 var str; 706 if (typeof(this. _ta.setSelectionRange) != "undefined") { // W3707 var selStart = this. _ta.selectionStart;708 var selEnd = this. _ta.selectionEnd;709 str = this. _ta.value.substring(selStart, selEnd);703 if (typeof(this.we_ta.setSelectionRange) != "undefined") { // W3 704 var selStart = this.we_ta.selectionStart; 705 var selEnd = this.we_ta.selectionEnd; 706 str = this.we_ta.value.substring(selStart, selEnd); 710 707 } else { // ie6 711 708 var range = document.selection.createRange(); … … 722 719 var start = 0; 723 720 var end = 0; 724 if (typeof(this. _ta.setSelectionRange) != "undefined") { // W3725 start = this. _ta.selectionStart;726 end = this. _ta.selectionEnd;721 if (typeof(this.we_ta.setSelectionRange) != "undefined") { // W3 722 start = this.we_ta.selectionStart; 723 end = this.we_ta.selectionEnd; 727 724 // some browsers use CRLF for newlines in textarea (opera...) 728 if (this. _ta.value.indexOf("\r\n") != -1) {725 if (this.we_ta.value.indexOf("\r\n") != -1) { 729 726 var text = this.getTextAreaContent(); 730 727 var str; … … 739 736 } 740 737 } else { // ie6 741 this. _ta.focus();738 this.we_ta.focus(); 742 739 var sel1 = document.selection.createRange(); 743 740 var sel2 = sel1.duplicate(); 744 sel2.moveToElementText(this. _ta);741 sel2.moveToElementText(this.we_ta); 745 742 var marker = "<WikkaRangeMark>"; 746 743 var selText = sel1.text; … … 753 750 // setSelectionRange() is only a fix for khtml. The interval it uses cause 754 751 // some problems here, so we don't use it 755 var range = this. _ta.createTextRange();752 var range = this.we_ta.createTextRange(); 756 753 range.collapse(true); 757 754 range.moveStart("character", start); … … 776 773 // get textarea content with "\n" as line separator 777 774 WikkaEdit.prototype.getTextAreaContent = function() { 778 var text = this. _ta.value;775 var text = this.we_ta.value; 779 776 // IE use \r\n instead of \n 780 777 text = text.replace(/\r\n/g, "\n"); … … 785 782 // ===== add a line to the log ===== 786 783 WikkaEdit.prototype.addLog = function(ch) { 787 this. _log.style.display = "";788 this. _log.innerHTML = ch + "<br/>" + this._log.innerHTML;784 this.we_log.style.display = ""; 785 this.we_log.innerHTML = ch + "<br/>" + this.we_log.innerHTML; 789 786 } 790 787 791 788 // ===== clear the log ===== 792 789 WikkaEdit.prototype.clearLog = function() { 793 if (this. _log.style.display == "")794 this. _log.innerHTML = "";790 if (this.we_log.style.display == "") 791 this.we_log.innerHTML = ""; 795 792 } 796 793 wikkaedit/trunk/wikkaedit_actions.js
r53 r56 6 6 // // 7 7 // Copyright (C) 2007 Olivier Borowski (coin at tuxfamily dot org) // 8 // based on WikiEdit (http://wackowiki.com/WikiEdit)//8 // Homepage : http://wikkawiki.org/WikkaEdit // 9 9 // // 10 10 // This program is free software; you can redistribute it and/or // … … 129 129 var tabUsedParams = this.getParams(); 130 130 var tabAvailParams = new Array(); 131 var actionRef = this. actionNameToRef(objAction.name);131 var actionRef = this.nameToRef(objAction.name); 132 132 var i, j; 133 for(i in this. _actions[actionRef].params)134 tabAvailParams.push({name:this. _actions[actionRef].params[i].name, priority:-1});133 for(i in this.we_actions[actionRef].params) 134 tabAvailParams.push({name:this.we_actions[actionRef].params[i].name, priority:-1}); 135 135 for(i=0; i<tabUsedParams.length; i++) { 136 136 for(j=0; j<tabAvailParams.length; j++) { … … 151 151 } 152 152 153 // ===== action name to ref =====154 WikkaEdit.prototype.actionNameToRef = function(name) {155 return "_" + name;156 }157 158 // ===== parameter name to ref =====159 WikkaEdit.prototype.paramNameToRef = function(name) {160 return "_" + name;161 }162 163 153 // ===== contextual help ===== 164 154 WikkaEdit.prototype.contextualHelp = function() { … … 170 160 if (actionAndSr.text != "") { 171 161 var objAction = this.getActionNameAndParams(); 172 var actionRef = this. actionNameToRef(objAction.name);162 var actionRef = this.nameToRef(objAction.name); 173 163 // ensure this action exists 174 if (this. _actions[actionRef] != null) {164 if (this.we_actions[actionRef] != null) { 175 165 var paramUnderCarret = this.getParamUnderCarret(); 176 166 var tabAvailParams = this.sortParams(objAction); … … 179 169 var params="", AIP, paramRef, clickaction; 180 170 for(var i=0; i<tabAvailParams.length; i++) { 181 paramRef = this. paramNameToRef(tabAvailParams[i].name);182 AIP = this. _actions[actionRef].params[paramRef];171 paramRef = this.nameToRef(tabAvailParams[i].name); 172 AIP = this.we_actions[actionRef].params[paramRef]; 183 173 params += " "; 184 174 if (tabAvailParams[i].priority != -1) // parameter present 185 175 clickaction = " onclick=\"varWikkaEdit.paramClick('" + paramRef + "');\""; 186 176 else // parameter not used yet 187 clickaction = " onclick=\"varWikkaEdit. _ta.focus();\" ondblclick=\"varWikkaEdit.paramClick('" + paramRef + "');\"";177 clickaction = " onclick=\"varWikkaEdit.we_ta.focus();\" ondblclick=\"varWikkaEdit.paramClick('" + paramRef + "');\""; 188 178 params += "<span class=\"wikkaparamlink\"" + clickaction + " onmouseover=\"varWikkaEdit.paramOver(this, '" + actionRef + "', '" + paramRef + "', " + (tabAvailParams[i].priority != -1) + ");\" onmouseout=\"varWikkaEdit.paramOut('" + paramRef + "');\">"; 189 179 if (AIP.name == paramUnderCarret) params += "<b>"; … … 199 189 } 200 190 201 if (help != this. _helpPreviousContent)202 this. _help.innerHTML = help;203 this. _helpPreviousContent = help;204 this. _help.style.visibility = (help == " " ? "hidden" : "");191 if (help != this.we_helpPreviousContent) 192 this.we_help.innerHTML = help; 193 this.we_helpPreviousContent = help; 194 this.we_help.style.visibility = (help == " " ? "hidden" : ""); 205 195 } 206 196 … … 211 201 var coords = this.getObjectCoords(obj); 212 202 coords.y += 25; // TODO remove this hardcoded value (toolbar height) 213 this. _tooltip.style.left = coords.x + "px";214 this. _tooltip.style.top = coords.y + "px";215 this. _tooltip.style.visibility = "";203 this.we_tooltip.style.left = coords.x + "px"; 204 this.we_tooltip.style.top = coords.y + "px"; 205 this.we_tooltip.style.visibility = ""; 216 206 var tip; 217 207 if (paramRef == null) … … 225 215 html += "<div class='wikkatooltip_body'>"; 226 216 if (paramRef == null) { 227 html += this. _actions[actionRef].summary + "<br />";228 if (this. _actions[actionRef].usage != null)229 html += "<hr class='wikkatooltip_separator' />" + this. _actions[actionRef].usage;217 html += this.we_actions[actionRef].summary + "<br />"; 218 if (this.we_actions[actionRef].usage != null) 219 html += "<hr class='wikkatooltip_separator' />" + this.we_actions[actionRef].usage; 230 220 } else 231 html += this. _actions[actionRef].params[paramRef].description;221 html += this.we_actions[actionRef].params[paramRef].description; 232 222 html += "</div>"; 233 this. _tooltip.innerHTML = html;223 this.we_tooltip.innerHTML = html; 234 224 } 235 225 … … 237 227 // => hide tooltip 238 228 WikkaEdit.prototype.paramOut = function(paramRef) { 239 this. _tooltip.style.visibility = "hidden";229 this.we_tooltip.style.visibility = "hidden"; 240 230 } 241 231 … … 254 244 posEnd = posStart + actionAndSr.text.length + 4; // +4 = {{}} 255 245 this.setSelectionRange(posStart, posEnd); 256 this. _ta.focus();246 this.we_ta.focus(); 257 247 return; 258 248 } … … 260 250 // click on a param? 261 251 var objAction = this.getActionNameAndParams(); 262 var actionRef = this. actionNameToRef(objAction.name);263 var paramName = this. _actions[actionRef].params[paramRef].name;252 var actionRef = this.nameToRef(objAction.name); 253 var paramName = this.we_actions[actionRef].params[paramRef].name; 264 254 var pos = objAction.paramsHid.indexOf(" " + paramName); //, actionAndSr.sr.start); 265 255 if (pos == -1) { 266 256 // parameter doesn't exist => add it? 267 var actionRef = this. actionNameToRef(objAction.name);257 var actionRef = this.nameToRef(objAction.name); 268 258 var newCarretPos = actionAndSr.tagStart + actionAndSr.text.length + 2; 269 var paramValue = this. _actions[actionRef].params[paramRef].value;259 var paramValue = this.we_actions[actionRef].params[paramRef].value; 270 260 //this.setSelectionRange(newCarretPos, newCarretPos); 271 261 var srBefore = {start:newCarretPos, end:newCarretPos}; … … 285 275 this.setSelectionRange(posStart, posEnd); 286 276 } 287 this. _ta.focus();288 } 277 this.we_ta.focus(); 278 } wikkaedit/trunk/wikkaedit_data.js
r54 r56 6 6 // // 7 7 // Copyright (C) 2007 Olivier Borowski (coin at tuxfamily dot org) // 8 // based on WikiEdit (http://wackowiki.com/WikiEdit)//8 // Homepage : http://wikkawiki.org/WikkaEdit // 9 9 // // 10 10 // This program is free software; you can redistribute it and/or // … … 32 32 this.EDITOR_HEIGHT_POLL_INTERV = 500; // textarea height change poll interval (in ms) 33 33 this.CONTEXTUAL_HELP_POLL_INTERV = 500; // refresh time for contextual help (in ms) 34 this. _ta = textarea; // textarea (= document.getElementById("body"))35 this. _submenu = null; // submenu div (= document.getElementById("wikkasubmenu"))36 this. _toolbar = null; // toolbar div (= document.getElementById("wikkatoolbar"))37 this. _help = null; // help div (= document.getElementById("wikkahelp"))38 this. _buttons = new Object(); // buttons, submenus39 this. _categs = new Object(); // action categs40 this. _actions = new Object(); // actions41 this. _currentSubmenu = null; // submenu currently displayed34 this.we_ta = textarea; // textarea (= document.getElementById("body")) 35 this.we_submenu = null; // submenu div (= document.getElementById("wikkasubmenu")) 36 this.we_toolbar = null; // toolbar div (= document.getElementById("wikkatoolbar")) 37 this.we_help = null; // help div (= document.getElementById("wikkahelp")) 38 this.we_buttons = new Object(); // buttons, submenus 39 this.we_categs = new Object(); // action categs 40 this.we_actions = new Object(); // actions 41 this.we_currentSubmenu = null; // submenu currently displayed 42 42 // === modules === 43 this. _actionsMenuEnabled = null;44 this. _searchReplaceEnabled = null;43 this.we_actionsMenuEnabled = null; 44 this.we_searchReplaceEnabled = null; 45 45 // === browser dependant code === 46 46 // only used for rare-very-specific browser behaviour 47 this. _webkit = (navigator.userAgent.toLowerCase().indexOf("webkit") != -1);48 this. _gecko = ((!this._webkit) && (navigator.userAgent.toLowerCase().indexOf("gecko") != -1));49 this. _khtml = ((!this._webkit) && (navigator.userAgent.toLowerCase().indexOf("khtml") != -1));50 this. _opera = (navigator.userAgent.toLowerCase().indexOf("opera") != -1);51 this. _canCancelKeyEvent = (!this._opera); // opera can't cancel key events, so native browser shortcuts can't be overriden47 this.we_webkit = (navigator.userAgent.toLowerCase().indexOf("webkit") != -1); 48 this.we_gecko = ((!this.we_webkit) && (navigator.userAgent.toLowerCase().indexOf("gecko") != -1)); 49 this.we_khtml = ((!this.we_webkit) && (navigator.userAgent.toLowerCase().indexOf("khtml") != -1)); 50 this.we_opera = (navigator.userAgent.toLowerCase().indexOf("opera") != -1); 51 this.we_canCancelKeyEvent = (!this.we_opera); // opera can't cancel key events, so native browser shortcuts can't be overriden 52 52 // === search & replace === 53 this._searchFor = ""; 54 this._replaceWith = ""; 55 this._replace = false; 56 this._regexp = false; 57 this._case = false; 58 this._whole = false; 59 this._cursor = true; 60 this._reverse = false; 61 this._prompt = true; 62 this._lastMsg = ""; 53 this.we_searchFor = ""; 54 this.we_replaceWith = ""; 55 this.we_replace = false; 56 this.we_regexp = false; 57 this.we_case = false; 58 this.we_whole = false; 59 this.we_cursor = true; 60 this.we_reverse = false; 61 this.we_prompt = true; 62 this.we_lastMsg = ""; 63 } 64 65 // ===== name to ref ===== 66 WikkaEdit.prototype.nameToRef = function(name) { 67 return "we_" + name; 68 } 69 WikkaEdit.prototype.refToName = function(ref) { 70 return ref.substr(3); 63 71 } 64 72 65 73 WikkaEdit.prototype.initButtons = function() { 66 this. _buttons._h1 = {type:"button", title:"Heading 1"};67 this. _buttons._h2 = {type:"button", title:"Heading 2"};68 this. _buttons._h3 = {type:"button", title:"Heading 3"};69 this. _buttons._h4 = {type:"button", title:"Heading 4"};70 this. _buttons._h5 = {type:"button", title:"Heading 5"};71 72 this. _buttons._sep1 = {type:"separator"};73 74 this. _buttons._bold = {type:"button", title:"Bold"};75 this. _buttons._italic = {type:"button", title:"Italic"};76 this. _buttons._underline = {type:"button", title:"Underline"};77 this. _buttons._strike = {type:"button", title:"Strikethrough"};78 this. _buttons._style = {type:"submenu", title:"Show more",_buttons:new Object()};79 this. _buttons._style._buttons._forecolor = {type:"button", title:"Colored text"};80 this. _buttons._style._buttons._monospace = {type:"button", title:"Monospace"};81 this. _buttons._style._buttons._highlight = {type:"button", title:"Highlight"};82 this. _buttons._style._buttons._key = {type:"button", title:"Key"};83 this. _buttons._style._buttons._leftfloat = {type:"button", title:"Left float"};84 this. _buttons._style._buttons._rightfloat = {type:"button", title:"Right float"};85 86 this. _buttons._sep2 = {type:"separator"};87 88 this. _buttons._justifycenter = {type:"button", title:"Center text"};89 this. _buttons._bullist = {type:"button", title:"List"};90 this. _buttons._numlist = {type:"button", title:"Numbered list"};91 this. _buttons._comments = {type:"button", title:"Inline comments"};92 93 this. _buttons._sep3 = {type:"separator"};94 95 this. _buttons._indent = {type:"button", title:"Indent"};96 this. _buttons._outdent = {type:"button", title:"Outdent"};97 98 this. _buttons._sep4 = {type:"separator"};99 100 this. _buttons._hr = {type:"button", title:"Line"};101 this. _buttons._link = {type:"button", title:"Hyperlink"};102 this. _buttons._image = {type:"button", title:"Image"};103 this. _buttons._table = {type:"button", title:"Table"};104 105 this. _buttons._sep5 = {type:"separator"};106 107 this. _buttons._rawhtml = {type:"button", title:"Raw HTML"};108 this. _buttons._sourcecode = {type:"button", title:"Source code"};109 110 this. _buttons._sep6 = {type:"separator"};111 112 if (this. _searchReplaceEnabled)113 this. _buttons._find = {type:"button", title:"Search & replace"};114 115 if (varWikkaEdit. _canCancelKeyEvent)116 this. _buttons._shortcuts = {type:"button", title:"Display shortcuts"};117 118 this. _buttons._formatting_rules = {type:"button", title:"Formatting rules (new window)"};74 this.we_buttons.we_h1 = {type:"button", title:"Heading 1"}; 75 this.we_buttons.we_h2 = {type:"button", title:"Heading 2"}; 76 this.we_buttons.we_h3 = {type:"button", title:"Heading 3"}; 77 this.we_buttons.we_h4 = {type:"button", title:"Heading 4"}; 78 this.we_buttons.we_h5 = {type:"button", title:"Heading 5"}; 79 80 this.we_buttons.we_sep1 = {type:"separator"}; 81 82 this.we_buttons.we_bold = {type:"button", title:"Bold"}; 83 this.we_buttons.we_italic = {type:"button", title:"Italic"}; 84 this.we_buttons.we_underline = {type:"button", title:"Underline"}; 85 this.we_buttons.we_strike = {type:"button", title:"Strikethrough"}; 86 this.we_buttons.we_style = {type:"submenu", title:"Show more", we_buttons:new Object()}; 87 this.we_buttons.we_style.we_buttons.we_forecolor = {type:"button", title:"Colored text"}; 88 this.we_buttons.we_style.we_buttons.we_monospace = {type:"button", title:"Monospace"}; 89 this.we_buttons.we_style.we_buttons.we_highlight = {type:"button", title:"Highlight"}; 90 this.we_buttons.we_style.we_buttons.we_key = {type:"button", title:"Key"}; 91 this.we_buttons.we_style.we_buttons.we_leftfloat = {type:"button", title:"Left float"}; 92 this.we_buttons.we_style.we_buttons.we_rightfloat = {type:"button", title:"Right float"}; 93 94 this.we_buttons.we_sep2 = {type:"separator"}; 95 96 this.we_buttons.we_justifycenter = {type:"button", title:"Center text"}; 97 this.we_buttons.we_bullist = {type:"button", title:"List"}; 98 this.we_buttons.we_numlist = {type:"button", title:"Numbered list"}; 99 this.we_buttons.we_comments = {type:"button", title:"Inline comments"}; 100 101 this.we_buttons.we_sep3 = {type:"separator"}; 102 103 this.we_buttons.we_indent = {type:"button", title:"Indent"}; 104 this.we_buttons.we_outdent = {type:"button", title:"Outdent"}; 105 106 this.we_buttons.we_sep4 = {type:"separator"}; 107 108 this.we_buttons.we_hr = {type:"button", title:"Line"}; 109 this.we_buttons.we_link = {type:"button", title:"Hyperlink"}; 110 this.we_buttons.we_image = {type:"button", title:"Image"}; 111 this.we_buttons.we_table = {type:"button", title:"Table"}; 112 113 this.we_buttons.we_sep5 = {type:"separator"}; 114 115 this.we_buttons.we_rawhtml = {type:"button", title:"Raw HTML"}; 116 this.we_buttons.we_sourcecode = {type:"button", title:"Source code"}; 117 118 this.we_buttons.we_sep6 = {type:"separator"}; 119 120 if (this.we_searchReplaceEnabled) 121 this.we_buttons.we_find = {type:"button", title:"Search & replace"}; 122 123 if (varWikkaEdit.we_canCancelKeyEvent) 124 this.we_buttons.we_shortcuts = {type:"button", title:"Display shortcuts"}; 125 126 this.we_buttons.we_formatting_rules = {type:"button", title:"Formatting rules (new window)"}; 119 127 } 120 128 121 129 WikkaEdit.prototype.initCategs = function() { 122 this. _categs.hidden = {title:null};123 this. _categs.objects = {title:"Objects"};124 this. _categs.page = {title:"Page"};125 this. _categs.accounts = {title:"Accounts"};126 this. _categs.global = {title:"Global"};127 this. _categs.misc = {title:"Misc"};128 this. _categs.infos = {title:"Infos"};130 this.we_categs.hidden = {title:null}; 131 this.we_categs.objects = {title:"Objects"}; 132 this.we_categs.page = {title:"Page"}; 133 this.we_categs.accounts = {title:"Accounts"}; 134 this.we_categs.global = {title:"Global"}; 135 this.we_categs.misc = {title:"Misc"}; 136 this.we_categs.infos = {title:"Infos"}; 129 137 } 130 138 131 139 function WikkaAction(categName, tagName, title, summary, usage) { 132 this. _categ = categName;133 this. _name = tagName;134 this. _title = title;135 this. _summary = summary;136 this. _usage = usage;137 this. _params = new Object();140 this.we_categ = categName; 141 this.we_name = tagName; 142 this.we_title = title; 143 this.we_summary = summary; 144 this.we_usage = usage; 145 this.we_params = new Object(); 138 146 } 139 147 140 148 WikkaAction.prototype.addParam = function(name, value, nodefault, description) { 141 149 nodefault = (nodefault == true); 142 this. _params["_" + name] = {name:name, value:value, nodefault:nodefault, description:description};150 this.we_params[this.nameToRef(name)] = {name:name, value:value, nodefault:nodefault, description:description}; 143 151 } 144 152 145 153 WikkaEdit.prototype.initActions = function() { 146 154 // ===== basic (hidden) ===== 147 this. _actions._color = new WikkaAction("hidden", "color", "Text color");148 this. _actions._color.addParam("text", "text");149 this. _actions._color.addParam("c", "color");150 this. _actions._image = new WikkaAction("hidden", "image", "Image", "Display an image.");151 this. _actions._image.addParam("url", "url", null, "Image URL. Can be relative (images/img.png) or external (http://example.com/example.jpg)");152 this. _actions._image.addParam("title", "text", null, "Tooltip text");153 this. _actions._image.addParam("alt", "text", null, "Alternate text when image can't be displayed");154 this. _actions._image.addParam("class", "className", true, "Class name (defined in the CSS file)");155 this. _actions._image.addParam("link", "url", true, "Put a link on this image");155 this.we_actions.we_color = new WikkaAction("hidden", "color", "Text color"); 156 this.we_actions.we_color.addParam("text", "text"); 157 this.we_actions.we_color.addParam("c", "color"); 158 this.we_actions.we_image = new WikkaAction("hidden", "image", "Image", "Display an image."); 159 this.we_actions.we_image.addParam("url", "url", null, "Image URL. Can be relative (images/img.png) or external (http://example.com/example.jpg)"); 160 this.we_actions.we_image.addParam("title", "text", null, "Tooltip text"); 161 this.we_actions.we_image.addParam("alt", "text", null, "Alternate text when image can't be displayed"); 162 this.we_actions.we_image.addParam("class", "className", true, "Class name (defined in the CSS file)"); 163 this.we_actions.we_image.addParam("link", "url", true, "Put a link on this image"); 156 164 // ===== objects ===== 157 this. _actions._calendar = new WikkaAction("objects", "calendar", "Calendar", "Display a calendar face for a specified or the current month.", "Specifying a month and/or year in the action itself results in a \"static\" calendar face without navigation; conversely, providing no parameters in the action results in a calendar face with navigation links to previous, current and next month, with URL parameters determining which month is shown (with the current month as default).");158 this. _actions._calendar.addParam("year", "yyyy", null, "Year in 4 digits format");159 this. _actions._calendar.addParam("month", "mm", null, "Month in 2 digits format");160 this. _actions._flash = new WikkaAction("objects", "flash", "Flash animation");161 this. _actions._flash.addParam("url", "http://example.com/example.swf");162 this. _actions._flash.addParam("width", "w", true);163 this. _actions._flash.addParam("height", "h", true);164 this. _actions._include = new WikkaAction("objects", "include", "Page included");165 this. _actions._include.addParam("page", "PageName");166 this. _actions._files = new WikkaAction("objects", "files", "File upload/download manager");167 this. _actions._files.addParam("download", "filename");168 this. _actions._files.addParam("text", "descriptive text");169 this. _actions._mindmap = new WikkaAction("objects", "mindmap", "Mindmap", "Embed a mindmap in the current page.");165 this.we_actions.we_calendar = new WikkaAction("objects", "calendar", "Calendar", "Display a calendar face for a specified or the current month.", "Specifying a month and/or year in the action itself results in a \"static\" calendar face without navigation; conversely, providing no parameters in the action results in a calendar face with navigation links to previous, current and next month, with URL parameters determining which month is shown (with the current month as default)."); 166 this.we_actions.we_calendar.addParam("year", "yyyy", null, "Year in 4 digits format"); 167 this.we_actions.we_calendar.addParam("month", "mm", null, "Month in 2 digits format"); 168 this.we_actions.we_flash = new WikkaAction("objects", "flash", "Flash animation"); 169 this.we_actions.we_flash.addParam("url", "http://example.com/example.swf"); 170 this.we_actions.we_flash.addParam("width", "w", true); 171 this.we_actions.we_flash.addParam("height", "h", true); 172 this.we_actions.we_include = new WikkaAction("objects", "include", "Page included"); 173 this.we_actions.we_include.addParam("page", "PageName"); 174 this.we_actions.we_files = new WikkaAction("objects", "files", "File upload/download manager"); 175 this.we_actions.we_files.addParam("download", "filename"); 176 this.we_actions.we_files.addParam("text", "descriptive text"); 177 this.we_actions.we_mindmap = new WikkaAction("objects", "mindmap", "Mindmap", "Embed a mindmap in the current page."); 170 178 // ===== infos - this page ===== 171 this. _actions._rss = new WikkaAction("page", "rss", "RSS");172 this. _actions._backlinks = new WikkaAction("page", "backlinks", "Backlinks");173 this. _actions._lastedit = new WikkaAction("page", "lastedit", "Last edit");179 this.we_actions.we_rss = new WikkaAction("page", "rss", "RSS"); 180 this.we_actions.we_backlinks = new WikkaAction("page", "backlinks", "Backlinks"); 181 this.we_actions.we_lastedit = new WikkaAction("page", "lastedit", "Last edit"); 174 182 // === infos - accounts=== 175 this. _actions._usersettings = new WikkaAction("accounts", "usersettings", "My user settings");176 this. _actions._mychanges = new WikkaAction("accounts", "mychanges", "My changes");177 this. _actions._mypages = new WikkaAction("accounts", "mypages", "My pages");178 this. _actions._emailpassword = new WikkaAction("accounts", "emailpassword", "Lost password");179 this. _actions._lastusers = new WikkaAction("accounts", "lastusers", "Newly registered users");183 this.we_actions.we_usersettings = new WikkaAction("accounts", "usersettings", "My user settings"); 184 this.we_actions.we_mychanges = new WikkaAction("accounts", "mychanges", "My changes"); 185 this.we_actions.we_mypages = new WikkaAction("accounts", "mypages", "My pages"); 186 this.we_actions.we_emailpassword = new WikkaAction("accounts", "emailpassword", "Lost password"); 187 this.we_actions.we_lastusers = new WikkaAction("accounts", "lastusers", "Newly registered users"); 180 188 // === infos - global=== 181 this. _actions._category = new WikkaAction("global", "category", "Show thinks belonging to a category");182 this. _actions._wantedpages = new WikkaAction("global", "wantedpages", "Name of nonexisting pages");183 this. _actions._orphanedpages = new WikkaAction("global", "orphanedpages", "Orphaned pages");184 this. _actions._pageindex = new WikkaAction("global", "pageindex", "Page index");185 this. _actions._recentchanges = new WikkaAction("global", "recentchanges", "Recently changed pages");186 this. _actions._recentcomments = new WikkaAction("global", "recentcomments", "Recently commented pages");187 this. _actions._recentlycommented = new WikkaAction("global", "recentlycommented", "Latest comments");189 this.we_actions.we_category = new WikkaAction("global", "category", "Show thinks belonging to a category"); 190 this.we_actions.we_wantedpages = new WikkaAction("global", "wantedpages", "Name of nonexisting pages"); 191 this.we_actions.we_orphanedpages = new WikkaAction("global", "orphanedpages", "Orphaned pages"); 192 this.we_actions.we_pageindex = new WikkaAction("global", "pageindex", "Page index"); 193 this.we_actions.we_recentchanges = new WikkaAction("global", "recentchanges", "Recently changed pages"); 194 this.we_actions.we_recentcomments = new WikkaAction("global", "recentcomments", "Recently commented pages"); 195 this.we_actions.we_recentlycommented = new WikkaAction("global", "recentlycommented", "Latest comments"); 188 196 // === misc === 189 this. _actions._newpage = new WikkaAction("misc", "newpage", "New pages");190 this. _actions._textsearch = new WikkaAction("misc", "textsearch", "Search for a phrase");191 this. _actions._textsearchexpanded = new WikkaAction("misc", "textsearchexpanded", "Search for a phrase 2");192 this. _actions._googleform = new WikkaAction("misc", "googleform", "Google searchbox");193 this. _actions._feedback = new WikkaAction("misc", "feedback", "Feedback form");194 this. _actions._nocomments = new WikkaAction("misc", "nocomments", "Disallow comments");195 this. _actions._interwikilist = new WikkaAction("misc", "interwikilist", "InterWiki list");197 this.we_actions.we_newpage = new WikkaAction("misc", "newpage", "New pages"); 198 this.we_actions.we_textsearch = new WikkaAction("misc", "textsearch", "Search for a phrase"); 199 this.we_actions.we_textsearchexpanded = new WikkaAction("misc", "textsearchexpanded", "Search for a phrase 2"); 200 this.we_actions.we_googleform = new WikkaAction("misc", "googleform", "Google searchbox"); 201 this.we_actions.we_feedback = new WikkaAction("misc", "feedback", "Feedback form"); 202 this.we_actions.we_nocomments = new WikkaAction("misc", "nocomments", "Disallow comments"); 203 this.we_actions.we_interwikilist = new WikkaAction("misc", "interwikilist", "InterWiki list"); 196 204 // === infos - rare=== 197 this. _actions._wikkaname = new WikkaAction("infos", "wikkaname", "Wikka name");198 this. _actions._wikkaversion = new WikkaAction("infos", "wikkaversion", "Wikka version");199 this. _actions._wikkachanges = new WikkaAction("infos", "wikkachanges", "Wikka version & Release Notes");200 this. _actions._phpversion = new WikkaAction("infos", "phpversion", "PHP version");201 this. _actions._mysqlversion = new WikkaAction("infos", "mysqlversion", "mySQL version");202 this. _actions._system = new WikkaAction("infos", "system", "System informations");203 this. _actions._countpages = new WikkaAction("infos", "countpages", "Count pages");204 this. _actions._countowned = new WikkaAction("infos", "countowned", "Count owned pages");205 this. _actions._countcomments = new WikkaAction("infos", "countcomments", "Count comments");206 this. _actions._countusers = new WikkaAction("infos", "countusers", "Count users");205 this.we_actions.we_wikkaname = new WikkaAction("infos", "wikkaname", "Wikka name"); 206 this.we_actions.we_wikkaversion = new WikkaAction("infos", "wikkaversion", "Wikka version"); 207 this.we_actions.we_wikkachanges = new WikkaAction("infos", "wikkachanges", "Wikka version & Release Notes"); 208 this.we_actions.we_phpversion = new WikkaAction("infos", "phpversion", "PHP version"); 209 this.we_actions.we_mysqlversion = new WikkaAction("infos", "mysqlversion", "mySQL version"); 210 this.we_actions.we_system = new WikkaAction("infos", "system", "System informations"); 211 this.we_actions.we_countpages = new WikkaAction("infos", "countpages", "Count pages"); 212 this.we_actions.we_countowned = new WikkaAction("infos", "countowned", "Count owned pages"); 213 this.we_actions.we_countcomments = new WikkaAction("infos", "countcomments", "Count comments"); 214 this.we_actions.we_countusers = new WikkaAction("infos", "countusers", "Count users"); 207 215 } 208 216 wikkaedit/trunk/wikkaedit_search.js
r55 r56 6 6 // // 7 7 // Copyright (C) 2007 Olivier Borowski (coin at tuxfamily dot org) // 8 // based on WikiEdit (http://wackowiki.com/WikiEdit)//8 // Homepage : http://wikkawiki.org/WikkaEdit // 9 9 // // 10 10 // This program is free software; you can redistribute it and/or // … … 30 30 31 31 // radio to switch between search and replace 32 WikkaEdit.prototype.srRadioSearchReplaceClick = function(obj, _replace) {33 this. _replace =_replace;32 WikkaEdit.prototype.srRadioSearchReplaceClick = function(obj, we_replace) { 33 this.we_replace = we_replace; 34 34 // update search window content 35 35 this.showSearchWindow(); … … 39 39 WikkaEdit.prototype.srFieldSearchReplaceChange = function(obj) { 40 40 switch (obj.id) { 41 case "sr_field_searchFor" : this. _searchFor = obj.value; break;42 case "sr_field_replaceWith" : this. _replaceWith = obj.value; break;41 case "sr_field_searchFor" : this.we_searchFor = obj.value; break; 42 case "sr_field_replaceWith" : this.we_replaceWith = obj.value; break; 43 43 default : alert("srFieldSearchReplaceChange() : id=" + obj.id); 44 44 } … … 49 49 var key = (e.keyCode != null ? e.keyCode : e.which); 50 50 if (key == 13) { // enter 51 varWikkaEdit. _ta.focus(); // blur() the textfield to call its onchange()51 varWikkaEdit.we_ta.focus(); // blur() the textfield to call its onchange() 52 52 varWikkaEdit.srBtnFindNextClick(); 53 53 return varWikkaEdit.cancelKey(); … … 59 59 WikkaEdit.prototype.srCheckboxClick = function(obj) { 60 60 switch (obj.id) { 61 case "sr_check_regexp" : this. _regexp = obj.checked; break;62 case "sr_check_case" : this. _case = obj.checked; break;63 case "sr_check_whole" : this. _whole = obj.checked; break;64 case "sr_check_cursor" : this. _cursor = obj.checked; break;65 case "sr_check_reverse" : this. _reverse = obj.checked; break;66 case "sr_check_prompt" : this. _prompt = obj.checked; break;61 case "sr_check_regexp" : this.we_regexp = obj.checked; break; 62 case "sr_check_case" : this.we_case = obj.checked; break; 63 case "sr_check_whole" : this.we_whole = obj.checked; break; 64 case "sr_check_cursor" : this.we_cursor = obj.checked; break; 65 case "sr_check_reverse" : this.we_reverse = obj.checked; break; 66 case "sr_check_prompt" : this.we_prompt = obj.checked; break; 67 67 default : alert("srCheckboxClick() : id=" + obj.id); 68 68 } … … 87 87 return false; 88 88 // if "whole word" option is not selected, no need to do additional tests 89 if (!this. _whole)89 if (!this.we_whole) 90 90 return true; 91 91 // check for leading and trailing chars … … 104 104 // textarea content 105 105 var text = this.getTextAreaContent(); 106 var searchfor = this. _searchFor;106 var searchfor = this.we_searchFor; 107 107 108 108 // duplicate these variables to simplify search in case sensitive or not 109 109 var textC = text, searchforC = searchfor; 110 if (!this. _case) {110 if (!this.we_case) { 111 111 textC = textC.toLowerCase(); 112 112 searchforC = searchforC.toLowerCase(); … … 115 115 var currentSelectionMatch = this.checkIfMatch(searchforC, textC, sr.start, sr.end); 116 116 117 if ((this. _replace) && (currentSelectionMatch)) {117 if ((this.we_replace) && (currentSelectionMatch)) { 118 118 var beforeSel = text.substr(0, sr.start); 119 119 var afterSel = text.substr(sr.end); 120 120 // update selection content 121 var scrollTop = this. _ta.scrollTop;122 this. _ta.value = beforeSel + this._replaceWith + afterSel;123 this. _ta.scrollTop = scrollTop;121 var scrollTop = this.we_ta.scrollTop; 122 this.we_ta.value = beforeSel + this.we_replaceWith + afterSel; 123 this.we_ta.scrollTop = scrollTop; 124 124 // replace selection 125 this.setSelectionRange(sr.start, sr.start + this. _replaceWith.length);125 this.setSelectionRange(sr.start, sr.start + this.we_replaceWith.length); 126 126 // as the textarea content has change, textC, sr... are not up to date so 127 127 // we restart at the beginning of the function … … 131 131 132 132 // depending on the "from cursor" option, the initial position can be reset 133 var newSrStart = (this. _cursor ? sr.start : 0);133 var newSrStart = (this.we_cursor ? sr.start : 0); 134 134 135 135 // search for the next occurence 136 136 var finished = false; 137 137 while (!finished) { 138 if (!this. _reverse)138 if (!this.we_reverse) 139 139 newSrStart = textC.indexOf(searchforC, newSrStart + (currentSelectionMatch ? 1 : 0)); 140 140 else … … 142 142 if (newSrStart == -1) { // not found 143 143 finished = true; 144 this. _lastMsg = "no other occurence";145 } else if (!this. _whole) { // found => ok144 this.we_lastMsg = "no other occurence"; 145 } else if (!this.we_whole) { // found => ok 146 146 finished = true; 147 147 } else { // found but is this a whole word? … … 153 153 this.showSearchWindow(); 154 154 155 this. _ta.focus();155 this.we_ta.focus(); 156 156 157 157 if (newSrStart == -1) { … … 170 170 // - on opera, it can't be done :( 171 171 // - on gecko and webkit, the following hack is needed 172 if (this. _gecko || this._webkit) {172 if (this.we_gecko || this.we_webkit) { 173 173 var windowWidth = parseInt(window.innerWidth ? window.innerWidth : document.documentElement.clientWidth, 10); 174 174 var TEXTAREA_MARGINS_LR = 26; // TODO : hardcoded value : 26 is approximatly the left and right margins of textarea 175 175 var taWidth = windowWidth - TEXTAREA_MARGINS_LR; 176 var taHeight = parseInt(this. _ta.style.height, 10);177 178 // duplicate real textarea to _searchTa but limit it's value from the start to the selection179 this. _searchTa.style.width = taWidth + "px";180 this. _searchTa.style.height = taHeight + "px";181 this. _searchTa.value = text.substr(0, newSrStart);176 var taHeight = parseInt(this.we_ta.style.height, 10); 177 178 // duplicate real textarea to we_searchTa but limit it's value from the start to the selection 179 this.we_searchTa.style.width = taWidth + "px"; 180 this.we_searchTa.style.height = taHeight + "px"; 181 this.we_searchTa.value = text.substr(0, newSrStart); 182 182 183 183 // the textarea has to scroll down? 184 if (this. _ta.scrollTop < this._searchTa.scrollHeight - taHeight) {184 if (this.we_ta.scrollTop < this.we_searchTa.scrollHeight - taHeight) { 185 185 this.addLog("scroll down"); 186 this. _ta.scrollTop = this._searchTa.scrollHeight - taHeight;186 this.we_ta.scrollTop = this.we_searchTa.scrollHeight - taHeight; 187 187 } 188 188 189 189 // the textarea has to scroll up? 190 190 var LINE_HEIGHT = 20; // TODO : hardcoded value : line height (approximatly 20px) 191 this. _searchTa.style.height = LINE_HEIGHT + "px";192 if (this. _ta.scrollTop > this._searchTa.scrollHeight - LINE_HEIGHT) {191 this.we_searchTa.style.height = LINE_HEIGHT + "px"; 192 if (this.we_ta.scrollTop > this.we_searchTa.scrollHeight - LINE_HEIGHT) { 193 193 this.addLog("scroll up"); 194 this. _ta.scrollTop = this._searchTa.scrollHeight - LINE_HEIGHT;194 this.we_ta.scrollTop = this.we_searchTa.scrollHeight - LINE_HEIGHT; 195 195 } 196 196 } 197 197 198 198 // "replace all"? => loop again 199 if ((this. _replace) && (!this._prompt))199 if ((this.we_replace) && (!this.we_prompt)) 200 200 this.findNext(); 201 201 } … … 213 213 html += "<div style='position:absolute;left:479px;top:1px' onclick='varWikkaEdit.hideSearchWindow();'><img src='3rdparty/plugins/wikkaedit/images/close_window.png'></div>"; 214 214 215 html += "<div style='position:absolute;left:10px;top:"+(y+10)+"px;width:480px;height:"+(this. _replace?61:40)+"px;border:1px solid gray;-moz-border-radius:7px'></div>";216 html += "<div style='position:absolute;left:20px;top:"+y+"px;background-color:#f0f0ee;padding:0 3px 0 3px'><table border='0' cellspacing='0' cellpadding='0'><tr><td><input type='radio' id='sr_radio_search' name='sr_radio_sr' onclick='varWikkaEdit.srRadioSearchReplaceClick(this,false);'"+(this. _replace?"":" checked")+"></td><td><label for='sr_radio_search'>Search</label></td><td width='10'></td><td><input type='radio' id='sr_radio_replace' name='sr_radio_sr' onclick='varWikkaEdit.srRadioSearchReplaceClick(this,true);'"+(this._replace?" checked":"")+"></td><td><label for='sr_radio_replace'>Replace</label></td></tr></table></div>";215 html += "<div style='position:absolute;left:10px;top:"+(y+10)+"px;width:480px;height:"+(this.we_replace?61:40)+"px;border:1px solid gray;-moz-border-radius:7px'></div>"; 216 html += "<div style='position:absolute;left:20px;top:"+y+"px;background-color:#f0f0ee;padding:0 3px 0 3px'><table border='0' cellspacing='0' cellpadding='0'><tr><td><input type='radio' id='sr_radio_search' name='sr_radio_sr' onclick='varWikkaEdit.srRadioSearchReplaceClick(this,false);'"+(this.we_replace?"":" checked")+"></td><td><label for='sr_radio_search'>Search</label></td><td width='10'></td><td><input type='radio' id='sr_radio_replace' name='sr_radio_sr' onclick='varWikkaEdit.srRadioSearchReplaceClick(this,true);'"+(this.we_replace?" checked":"")+"></td><td><label for='sr_radio_replace'>Replace</label></td></tr></table></div>"; 217 217 html += "<div style='position:absolute;left:20px;top:"+(y+22)+"px'>"; 218 218 html += "<table border='0' cellspacing='0' cellpadding='0'>"; 219 html += "<tr><td style='width:100px;white-space:nowrap;padding-right:5px'>Search for :</td><td><input type='text' id='sr_field_searchFor' style='width:250px' onchange='varWikkaEdit.srFieldSearchReplaceChange(this);'></td><td style='padding-left:8px'><input type='checkbox' id='sr_check_regexp' onclick='varWikkaEdit.srCheckboxClick(this);'" + (this. _regexp ? " checked" : "") + " disabled></td><td><label for='sr_check_regexp' title='regular expression' style='color:grey'>regexp</label></td></tr>";220 if (this. _replace) {219 html += "<tr><td style='width:100px;white-space:nowrap;padding-right:5px'>Search for :</td><td><input type='text' id='sr_field_searchFor' style='width:250px' onchange='varWikkaEdit.srFieldSearchReplaceChange(this);'></td><td style='padding-left:8px'><input type='checkbox' id='sr_check_regexp' onclick='varWikkaEdit.srCheckboxClick(this);'" + (this.we_regexp ? " checked" : "") + " disabled></td><td><label for='sr_check_regexp' title='regular expression' style='color:grey'>regexp</label></td></tr>"; 220 if (this.we_replace) { 221 221 html += "<tr><td style='white-space:nowrap;padding-right:5px'>Replace with :</td><td><input type='text' id='sr_field_replaceWith' style='width:250px' onchange='varWikkaEdit.srFieldSearchReplaceChange(this);'></td><td></td><td></td></tr>"; 222 222 } … … 228 228 html += "<div style='position:absolute;left:20px;top:"+(y+49)+"px;background-color:#f0f0ee;padding:0 3px 0 3px'>Options</div>"; 229 229 230 html += "<div style='position:absolute;left:20px;top:"+(y+65)+"px'><table border='0' cellspacing='0' cellpadding='0'><tr><td><input type='checkbox' id='sr_check_case' onclick='varWikkaEdit.srCheckboxClick(this);'" + (this. _case ? " checked" : "") + "></td><td><label for='sr_check_case'>case sensitive</label></td></tr></table></div>";231 232 html += "<div style='position:absolute;left:20px;top:"+(y+80)+"px'><table border='0' cellspacing='0' cellpadding='0'><tr><td><input type='checkbox' id='sr_check_whole' onclick='varWikkaEdit.srCheckboxClick(this);'" + (this. _whole ? " checked" : "") + "></td><td><label for='sr_check_whole'>whole word</label></td></tr></table></div>";233 234 html += "<div style='position:absolute;left:190px;top:"+(y+65)+"px'><table border='0' cellspacing='0' cellpadding='0'><tr><td><input type='checkbox' id='sr_check_cursor' onclick='varWikkaEdit.srCheckboxClick(this);'" + (this. _cursor ? " checked" : "") + "></td><td><label for='sr_check_cursor'>from cursor</label></td></tr></table></div>";235 236 html += "<div style='position:absolute;left:190px;top:"+(y+80)+"px'><table border='0' cellspacing='0' cellpadding='0'><tr><td><input type='checkbox' id='sr_check_reverse' onclick='varWikkaEdit.srCheckboxClick(this);'" + (this. _reverse ? " checked" : "") + "></td><td><label for='sr_check_reverse'>reverse search</label></td></tr></table></div>";237 238 if (this. _replace)239 html += "<div style='position:absolute;left:360px;top:"+(y+65)+"px'><table border='0' cellspacing='0' cellpadding='0'><tr><td><input type='checkbox' id='sr_check_prompt' onclick='varWikkaEdit.srCheckboxClick(this);'" + (this. _prompt ? " checked" : "") + "></td><td><label for='sr_check_prompt'>prompt</label></td></tr></table></div>";240 241 var titleBtnOk = (!this. _replace ? "Find next" : (this._prompt ? "Replace" : "Replace all"));230 html += "<div style='position:absolute;left:20px;top:"+(y+65)+"px'><table border='0' cellspacing='0' cellpadding='0'><tr><td><input type='checkbox' id='sr_check_case' onclick='varWikkaEdit.srCheckboxClick(this);'" + (this.we_case ? " checked" : "") + "></td><td><label for='sr_check_case'>case sensitive</label></td></tr></table></div>"; 231 232 html += "<div style='position:absolute;left:20px;top:"+(y+80)+"px'><table border='0' cellspacing='0' cellpadding='0'><tr><td><input type='checkbox' id='sr_check_whole' onclick='varWikkaEdit.srCheckboxClick(this);'" + (this.we_whole ? " checked" : "") + "></td><td><label for='sr_check_whole'>whole word</label></td></tr></table></div>"; 233 234 html += "<div style='position:absolute;left:190px;top:"+(y+65)+"px'><table border='0' cellspacing='0' cellpadding='0'><tr><td><input type='checkbox' id='sr_check_cursor' onclick='varWikkaEdit.srCheckboxClick(this);'" + (this.we_cursor ? " checked" : "") + "></td><td><label for='sr_check_cursor'>from cursor</label></td></tr></table></div>"; 235 236 html += "<div style='position:absolute;left:190px;top:"+(y+80)+"px'><table border='0' cellspacing='0' cellpadding='0'><tr><td><input type='checkbox' id='sr_check_reverse' onclick='varWikkaEdit.srCheckboxClick(this);'" + (this.we_reverse ? " checked" : "") + "></td><td><label for='sr_check_reverse'>reverse search</label></td></tr></table></div>"; 237 238 if (this.we_replace) 239 html += "<div style='position:absolute;left:360px;top:"+(y+65)+"px'><table border='0' cellspacing='0' cellpadding='0'><tr><td><input type='checkbox' id='sr_check_prompt' onclick='varWikkaEdit.srCheckboxClick(this);'" + (this.we_prompt ? " checked" : "") + "></td><td><label for='sr_check_prompt'>prompt</label></td></tr></table></div>"; 240 241 var titleBtnOk = (!this.we_replace ? "Find next" : (this.we_prompt ? "Replace" : "Replace all")); 242 242 html += "<div style='position:absolute;left:308px;top:"+(y+107)+"px'><input type='button' value='" + titleBtnOk + "' onclick='varWikkaEdit.srBtnFindNextClick();' style='width:90px'></div>"; 243 243 html += "<div style='position:absolute;left:402px;top:"+(y+107)+"px'><input type='button' value='Cancel' onclick='varWikkaEdit.srBtnCancelClick();' style='width:90px'></div>"; 244 244 245 html += "<div style='position:absolute;left:20px;top:"+(y+107)+"px;color:red'>" + this. _lastMsg + "</div>";245 html += "<div style='position:absolute;left:20px;top:"+(y+107)+"px;color:red'>" + this.we_lastMsg + "</div>"; 246 246 247 247 html += "</div>"; … … 249 249 //html += "</form>"; 250 250 251 this. _lastMsg = "";252 253 this. _search.innerHTML = html;254 document.getElementById("sr_field_searchFor").value = this. _searchFor;251 this.we_lastMsg = ""; 252 253 this.we_search.innerHTML = html; 254 document.getElementById("sr_field_searchFor").value = this.we_searchFor; 255 255 document.getElementById("sr_field_searchFor").onkeypress = varWikkaEdit.srFieldSearchReplaceKeyPress; 256 if (this. _replace) {257 document.getElementById("sr_field_replaceWith").value = this. _replaceWith;256 if (this.we_replace) { 257 document.getElementById("sr_field_replaceWith").value = this.we_replaceWith; 258 258 document.getElementById("sr_field_replaceWith").onkeypress = varWikkaEdit.srFieldSearchReplaceKeyPress; 259 259 } 260 this. _search.style.visibility = "";260 this.we_search.style.visibility = ""; 261 261 document.getElementById("sr_field_searchFor").select(); 262 262 … … 301 301 // ===== hide search & replace window ===== 302 302 WikkaEdit.prototype.hideSearchWindow = function() { 303 this. _search.style.visibility = "hidden";303 this.we_search.style.visibility = "hidden"; 304 304 305 305 // re-enable the "enter" key … … 313 313 //document.onkeydown = ""; 314 314 315 this. _ta.focus();316 } 315 this.we_ta.focus(); 316 }