页面文件
复制代码代码如下:
<html>
<adal>
<meta http-equiv = "contenu-type" contenu = "text / html; charset = utf-8">
<Title> </Title>
<script type = "text / javascript" src = "jQuery-1.6.min.js"> </ script>
<script type = "text / javascript" src = "queryi18n.js"> </ script>
<script type = "text / javascript">
</cript>
</ head>
<corps oncontextmenu = "return false">
<form id = "i18nform">
<div id = "i18ntablediv">
<table id = "i18ntable">
<tr>
<th width = '45% 'height =' 20px '> key </ th>
<th width = '45% 'height =' 20px '> valeur </th>
<th width = '5%' height = '20px'> valeur </ th>
</tr>
</ table>
</div>
<div id = "addtrdiv">
<a href = "#" iconcls = "icon-add" onclick = "addtr ()"> <span key = "ss"> 添加行 </span> </a>
</div>
<div>
<ballage>
<tr>
<td align = Center> <a href = "#" iconcls = "icon-ok" onclick = "SaveI18Ninfo ()"> <span key = "Save"> 保存 </span> </a> </td>
</tr>
</ table>
</div>
</ form>
</docy>
</html>
JS 文件
复制代码代码如下:
// 保存国际化文件
fonction SaveI18Ninfo () {
var i18Ninfo = geti18Ninfo ();
alerte (i18ninfo);
}
// 获取 i18n 值
fonction geti18ninfo () {
var key = "";
var valeur = "";
var i18ndata = "";
var table = $ ("# i18ntable");
var tbody = table.children ();
var trrs = tbody.children ();
pour (var i = 1; i <tr.length; i ++) {
var tds = tr.eq (i) .children ();
pour (var j = 0; j <tds.length; j ++) {
if (j == 0) {
if (tds.eq (j) .text () == null || tds.eq (j) .text () == "") {
retourner null;
}
key = "key /": / "" + tds.eq (j) .text ();
}
if (j == 1) {
if (tds.eq (j) .text () == null || tds.eq (j) .text () == "") {
retourner null;
}
value = "value /": / "" + tds.eq (j) .text ();
}
}
if (i == tr.length-1) {
i18ndata + = "{/" "+ key +" / ", /" "+ valeur +" / "}";
}autre{
i18ndata + = "{/" "+ key +" / ", /" "+ valeur +" / "},";
}
}
i18ndata = "[" + i18ndata + "]";
retour i18ndata;
}
var clientwidth = document.DocumentElement.ClientWidth;
var clientHeight = document.DocumentElement.ClientHeight;
var div_left_width = 200;
var tempWidth = 0;
/ **
* 描述 : 页面自适应
* /
$ (fenêtre) .bind ("redimensi", function () {
resizelayout ();
});
fonction resizelayout () {
essayer{
clientWidth = document.DocumentElement.ClientWidth;
var div_left_width = $ ("# Left"). width () + 11;
$ ("# cc"). Layout ("redimensit");
$ ('# userQuery'). Panneau ('redimensi', {width: clientwidth-div_left_width});
$ ('# 10100801'). DataGrid ('redimensi', {width: clientwidth-div_left_width});
$ ('# userrange'). ComboBox ({{
largeur: $ ('# droite'). largeur () * 0,35
});
} catch (e) {
}
}
fonction inintrésize () {
// 自动适应页面大小
$ (". Layout-Button-left"). bind ("click", function () {
$ ('# userQuery'). Panneau ('redimensi', {width: clientwidth-28});
$ ('# 10100801'). DataGrid ('redimensi', {width: clientwidth-28});
$ (". Layout-Button-right"). bind ("click", function () {
$ ('# userQuery'). Panneau ('redimensi', {width: tempwidth});
$ ('# 10100801'). DataGrid ('redimensi', {width: tempwidth});
});
});
}
fonction tdclick (tdObject) {
var td = $ (tdObject);
td.attr ("onclick", "");
// 1, 取出当前 TD 中的文本内容保存起来
var text = td.text ();
// 2, 清空 TD 里面的内容
td.html (""); // 也可以用 td.empty ();
// 3 , 建立一个文本框 , 也就是 Entrée 的元素节点
var input = $ ("<fort>");
// 4 , 设置文本框的值是保存起来的文本内容
input.attr ("valeur", texte);
input.bind ("blur", function () {
var inputNode = $ (this);
var inputText = inputNode.val ();
var tdnode = inputNode.parent ();
tdnode.html (inputText);
tdnode.click (tdclick);
td.attr ("onclick", "tdclick (this)");
});
input.keyup (fonction (événement) {
var myevent = event || window.event;
var kcode = myevent.KeyCode;
if (kcode == 13) {
var inputNode = $ (this);
var inputText = inputNode.val ();
var tdnode = inputNode.parent ();
tdnode.html (inputText);
tdnode.click (tdclick);
}
});
// 5 , 将文本框加入到 TD 中
TD.APPEND (entrée);
var t = input.val ();
input.val (""). focus (). val (t);
// input.focus ();
// 6, 清除点击事件
td.unbind ("cliquez");
}
fonction addtr () {
var table = $ ("# i18ntable");
var tr = $ ("<tr> <td height = '20px' onclick = 'tdclick (this)'>" + "</td> <td height = '20px' onclick = 'tdclick (this)'>" + "</td> <td height = '20px' align = 'Centre' onClick = 'Deletr (this)'> <font tails = '2' 2 '2' color = 'red'> "+" 删除 "+" </font> </td> </tr> ");
table.APPEND (tr);
}
fonction DeleTetr (tdObject) {
var td = $ (tdObject);
TD.parents ("tr"). relève ();
}