Initial commit,修正
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
<!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"/>␍
|
||||
<script type="text/javascript" src="../internal.js"></script>␍
|
||||
<style type="text/css">␍
|
||||
.warpper{ position:relative;width: 380px; height: 100%; margin: 10px auto;}␍
|
||||
.tabbody{height: 160px;}␍
|
||||
.tabbody table{width:100%;border-collapse: separate;border-spacing: 3px;}␍
|
||||
.tabbody .panel{width:373px;height:100%;padding-left: 5px;position: absolute;background-color: #fff;}␍
|
||||
.tabbody input.int{ width:190px;height:21px;border:1px solid #d7d7d7;line-height:21px;}␍
|
||||
.tabbody input.btn{padding: 0 5px; text-align:center;line-height:24px; text-decoration: none;height:24px;background:url("../../themes/default/images/dialog-title-bg.png") repeat-x;border:1px solid #ccc; }␍
|
||||
</style>␍
|
||||
</head>␍
|
||||
<body>␍
|
||||
<div class="warpper" id="searchtab">␍
|
||||
<div id="head" class="tabhead">␍
|
||||
<span tabsrc="find" class="focus"><var id="lang_tab_search"></var></span>␍
|
||||
<span tabsrc="replace" ><var id="lang_tab_replace"></var></span>␍
|
||||
</div>␍
|
||||
<div class="tabbody">␍
|
||||
<div class="panel" 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 colspan="2"><span style="color:red"><var id="lang_searchReg"></var></span></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>␍
|
||||
<tr>␍
|
||||
<td colspan="2">␍
|
||||
␍
|
||||
</td>␍
|
||||
</tr>␍
|
||||
<tr>␍
|
||||
<td colspan="2">␍
|
||||
<span id="search-msg" style="color:red"></span>␍
|
||||
</td>␍
|
||||
</tr>␍
|
||||
</table>␍
|
||||
</div>␍
|
||||
<div class="panel" 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 colspan="2"><span style="color:red"><var id="lang_searchReg1"></var></span></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>␍
|
||||
<tr>␍
|
||||
<td colspan="2">␍
|
||||
␍
|
||||
</td>␍
|
||||
</tr>␍
|
||||
<tr>␍
|
||||
<td colspan="2">␍
|
||||
<span id="replace-msg" style="color:red"></span>␍
|
||||
</td>␍
|
||||
</tr>␍
|
||||
</table>␍
|
||||
</div>␍
|
||||
</div>␍
|
||||
</div>␍
|
||||
<script type="text/javascript" src="searchreplace.js"></script>␍
|
||||
</body>␍
|
||||
</html>
|
||||
@@ -0,0 +1,164 @@
|
||||
/**
|
||||
* Created with JetBrains PhpStorm.
|
||||
* User: xuheng
|
||||
* Date: 12-9-26
|
||||
* Time: 下午12:29
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
|
||||
//清空上次查选的痕迹
|
||||
editor.firstForSR = 0;
|
||||
editor.currentRangeForSR = null;
|
||||
//给tab注册切换事件
|
||||
/**
|
||||
* tab点击处理事件
|
||||
* @param tabHeads
|
||||
* @param tabBodys
|
||||
* @param obj
|
||||
*/
|
||||
function clickHandler( tabHeads,tabBodys,obj ) {
|
||||
//head样式更改
|
||||
for ( var k = 0, len = tabHeads.length; k < len; k++ ) {
|
||||
tabHeads[k].className = "";
|
||||
}
|
||||
obj.className = "focus";
|
||||
//body显隐
|
||||
var tabSrc = obj.getAttribute( "tabSrc" );
|
||||
for ( var j = 0, length = tabBodys.length; j < length; j++ ) {
|
||||
var body = tabBodys[j],
|
||||
id = body.getAttribute( "id" );
|
||||
if ( id != tabSrc ) {
|
||||
body.style.zIndex = 1;
|
||||
} else {
|
||||
body.style.zIndex = 200;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* TAB切换
|
||||
* @param tabParentId tab的父节点ID或者对象本身
|
||||
*/
|
||||
function switchTab( tabParentId ) {
|
||||
var tabElements = $G( tabParentId ).children,
|
||||
tabHeads = tabElements[0].children,
|
||||
tabBodys = tabElements[1].children;
|
||||
|
||||
for ( var i = 0, length = tabHeads.length; i < length; i++ ) {
|
||||
var head = tabHeads[i];
|
||||
if ( head.className === "focus" )clickHandler(tabHeads,tabBodys, head );
|
||||
head.onclick = function () {
|
||||
clickHandler(tabHeads,tabBodys,this);
|
||||
}
|
||||
}
|
||||
}
|
||||
$G('searchtab').onmousedown = function(){
|
||||
$G('search-msg').innerHTML = '';
|
||||
$G('replace-msg').innerHTML = ''
|
||||
}
|
||||
//是否区分大小写
|
||||
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)) {
|
||||
var bk = editor.selection.getRange().createBookmark();
|
||||
$G('search-msg').innerHTML = lang.getEnd;
|
||||
editor.selection.getRange().moveToBookmark(bk).select();
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
$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)) {
|
||||
$G('search-msg').innerHTML = 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) {
|
||||
$G('replace-msg').innerHTML = lang.countMsg.replace("{#count}", num);
|
||||
}
|
||||
};
|
||||
//执行
|
||||
var frCommond = function (obj) {
|
||||
return editor.execCommand("searchreplace", obj);
|
||||
};
|
||||
switchTab("searchtab");
|
||||
Reference in New Issue
Block a user