| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <title></title>
- <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
- <style type="text/css">
- *{color: #838383}
- body {
- font-size: 12px;
- width:380px;
- height: 170px;
- overflow: hidden;
- margin:0;padding:0;
- }
- .warp{ padding: 39px 0 0 15px;height:88%;position:relative;}
- * +html .warp{height:80%}
- .head{position:absolute;height:31px;top:9px;}
- .content{height:110px;border: 1px solid #ddd;padding:5px}
- .head span{width:62px;height:29px;line-height:29px;background:red;display:block;float: left;text-align: center;margin-right: 1px;cursor: pointer }
- .head span.def{background:url("../../themes/default/images/dialog-title-bg.png") repeat-x;border:1px solid #ccc;}
- .head span.act{background:#FFF;border:1px solid #ccc;border-bottom: 1px solid #FFF}
- .content table{width:100%;}
- .content input.int{ width:190px;height:21px;background: #FFF;border:1px solid #d7d7d7;padding: 0; margin: 0;line-height:21px;}
- .content input.btn{padding: 0 5px; text-align:center;line-height:24px; text-decoration: none;height:24px;border: 0;margin:0;background:url("../../themes/default/images/dialog-title-bg.png") repeat-x;border:1px solid #ccc; }
- </style>
- </head>
- <body>
- <div class="warp">
- <div id="head" class="head">
- <span name="find" class="act"><var id="lang_tab_search"></var></span> <span name="replace" class="def"><var id="lang_tab_replace"></var></span>
- </div>
- <div class="content" id="find">
- <table>
- <tr>
- <td width="80"><var id="lang_search1"></var>: </td>
- <td><input id="findtxt" type="text" class="int" /></td>
- </tr>
- <tr>
- <td><var id="lang_case_sensitive1"></var></td>
- <td>
- <input id="matchCase" type="checkbox" />
- </td>
- </tr>
- <tr>
- <td colspan="2">
- <input id="nextFindBtn" type="button" class="btn" />
- <input id="preFindBtn" type="button" class="btn" />
- </td>
- </tr>
- </table>
- </div>
-
- <div class="content" id="replace">
- <table>
- <tr>
- <td width="80"><var id="lang_search2"></var>: </td>
- <td><input id="findtxt1" type="text" class="int" /></td>
- </tr>
- <tr>
- <td><var id="lang_replace"></var>: </td>
- <td><input id="replacetxt" type="text" class="int" /></td>
- </tr>
- <tr>
- <td><var id="lang_case_sensitive2"></var></td>
- <td>
- <input id="matchCase1" type="checkbox" />
- </td>
- </tr>
- <tr>
- <td colspan="2">
- <input id="nextReplaceBtn" type="button" class="btn" />
- <input id="preReplaceBtn" type="button" class="btn" />
- <input id="repalceBtn" type="button" class="btn" />
- <input id="repalceAllBtn" type="button" class="btn" />
- </td>
- </tr>
- </table>
- </div>
- </div>
- <script type="text/javascript" src="../internal.js"></script>
- <script type="text/javascript">
- //清空上次查选的痕迹
- editor.firstForSR = 0;
- editor.currentRangeForSR = null;
- $G("replace").style.display = "none";
- //给tab注册切换事件
- function toggletab(){
- var tabs = document.getElementsByTagName("span");
- for(var i=0,j;j=tabs[i];i++){
- domUtils.on(j,"click",function(){
- var name = this.getAttribute("name");
- var spans = document.getElementsByTagName("span");
- var len = spans.length;
- for(var s=0;s<len;s++){
- spans[s].className = 'def';
- }
- this.className = 'act';
- $G("find").style.display = "none";
- $G("replace").style.display = "none";
- $G(name).style.display = "";
- $G('findtxt1').value = $G('findtxt').value;
- if(name =="replace"){
- $focus($G("findtxt1"));
- }else{
- $focus($G("findtxt"));
- }
- });
- }
- }
- //是否区分大小写
- function getMatchCase (id){
- return $G(id).checked ? true : false;
- }
- //查找
- $G("nextFindBtn").onclick = function(txt,dir,mcase){
- var findtxt = $G("findtxt").value,obj;
- if(!findtxt){
- return false;
- }
- obj = {
- searchStr : findtxt,
- dir : 1,
- casesensitive : getMatchCase("matchCase")
- };
- if(!frCommond(obj)){
- alert(lang.getEnd);
- }
- };
- $G("nextReplaceBtn").onclick = function(txt,dir,mcase){
- var findtxt = $G("findtxt1").value,obj;
- if(!findtxt){
- return false;
- }
- obj = {
- searchStr : findtxt,
- dir : 1,
- casesensitive : getMatchCase("matchCase1")
- };
- frCommond(obj);
- }
- $G("preFindBtn").onclick = function(txt,dir,mcase){
- var findtxt = $G("findtxt").value,obj;
- if(!findtxt){
- return false;
- }
- obj = {
- searchStr : findtxt,
- dir : -1,
- casesensitive : getMatchCase("matchCase")
- };
- if(!frCommond(obj)){
- alert(lang.getStart);
- }
- }
- $G("preReplaceBtn").onclick = function(txt,dir,mcase){
- var findtxt = $G("findtxt1").value,obj;
- if(!findtxt){
- return false;
- }
- obj = {
- searchStr : findtxt,
- dir : -1,
- casesensitive : getMatchCase("matchCase1")
- };
- frCommond(obj);
- }
- //替换
- $G("repalceBtn").onclick = function(){
- var findtxt = $G("findtxt1").value.replace(/^\s|\s$/g,""),obj,
- replacetxt = $G("replacetxt").value.replace(/^\s|\s$/g,"");
- if(!findtxt){
- return false;
- }
- if(findtxt == replacetxt || (!getMatchCase("matchCase1") && findtxt.toLowerCase() == replacetxt.toLowerCase())){
- return false;
- }
- obj = {
- searchStr : findtxt,
- dir : 1,
- casesensitive : getMatchCase("matchCase1"),
- replaceStr : replacetxt
- };
- frCommond(obj);
- }
- //全部替换
- $G("repalceAllBtn").onclick = function(){
- var findtxt = $G("findtxt1").value.replace(/^\s|\s$/g,""),obj,
- replacetxt = $G("replacetxt").value.replace(/^\s|\s$/g,"");
- if(!findtxt){
- return false;
- }
- if(findtxt == replacetxt || (!getMatchCase("matchCase1") && findtxt.toLowerCase() == replacetxt.toLowerCase())){
- return false;
- }
- obj = {
- searchStr : findtxt,
- casesensitive : getMatchCase("matchCase1"),
- replaceStr : replacetxt,
- all : true
- };
- var num = frCommond(obj);
- if(num){
- alert(lang.countMsg.replace("{#count}",num));
- }
- }
- //执行
- var frCommond = function(obj){
- return editor.execCommand("searchreplace",obj);
- }
- toggletab();
- </script>
- </body>
- </html>
|