|
@@ -23,11 +23,11 @@ $(function(){
|
|
|
}
|
|
|
}
|
|
|
hasWords();
|
|
|
-
|
|
|
+
|
|
|
//添加按钮
|
|
|
$(".addKeyWord i").on('click',function(){
|
|
|
sessionStorage.removeItem("keyWord");
|
|
|
- window.location.href="/front/wx_dataExport/keyWordInput";
|
|
|
+ window.location.href="/jyapp/front/dataExport/keyWordInput";
|
|
|
});
|
|
|
|
|
|
// 添加keyWords检查输入框内是否有文字,如果有才能点击添加按钮
|
|
@@ -48,14 +48,23 @@ $(function(){
|
|
|
$(this).next().find(".exclude").prop("disabled", true);
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
+ $('textarea').each(function(i,dom){
|
|
|
+ // console.log(i,dom)
|
|
|
+ dom.style.height = dom.scrollHeight +'px';
|
|
|
+ });
|
|
|
+ $("textarea").on("input", function() {
|
|
|
+ this.style.height = 'auto';
|
|
|
+ this.style.height = this.scrollHeight + "px";
|
|
|
+ });
|
|
|
+
|
|
|
// 添加 按钮的点击事件
|
|
|
$('.addkeyWord .btn .save').on('click', function(){
|
|
|
var keyWord = $('.addkeyWord input.enterOne').val();
|
|
|
keyWord = keyWord.replace(/\s/g,"");
|
|
|
if (keyWord.length > 20) {
|
|
|
// var s = keyWord.slice(0,19);
|
|
|
- // $('.addkeyWord input.enterOne').val(s);
|
|
|
+ // $('.addkeyWord input.enterOne').val(s)
|
|
|
|
|
|
weui.toast('关键词不能超过20字', {
|
|
|
duration: 2000,
|
|
@@ -77,7 +86,7 @@ $(function(){
|
|
|
<button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
|
|
|
</div>
|
|
|
<div class="modify">
|
|
|
- <span class="ios-user-select" contentEditable="true">${ keyWord }</span>
|
|
|
+ <textarea name="" rows="1" placeholder="" maxlength="">${ keyWord}</textarea>
|
|
|
<button class="addAdjunctWord">编辑 附加词</button>
|
|
|
<button class="addExclusion">添加 排除词</button>
|
|
|
<button class="deleteKey">删除</button>
|
|
@@ -110,7 +119,7 @@ $(function(){
|
|
|
<button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
|
|
|
</div>
|
|
|
<div class="modify">
|
|
|
- <span class="ios-user-select" contentEditable="true">${ keys[i].keyWord }</span>
|
|
|
+ <textarea name="" rows="1" placeholder="" maxlength="">${ keys[i].keyWord}</textarea>
|
|
|
<button class="addAdjunctWord">编辑 附加词</button>
|
|
|
<button class="addExclusion">添加 排除词</button>
|
|
|
<button class="deleteKey">删除</button>
|
|
@@ -134,7 +143,7 @@ $(function(){
|
|
|
<button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
|
|
|
</div>
|
|
|
<div class="modify">
|
|
|
- <span class="ios-user-select" contentEditable="true">${ keys[i].keyWord }</span>
|
|
|
+ <textarea name="" rows="1" placeholder="" maxlength="">${ keys[i].keyWord}</textarea>
|
|
|
<button class="addAdjunctWord">编辑 附加词</button>
|
|
|
<button class="addExclusion">添加 排除词</button>
|
|
|
<button class="deleteKey">删除</button>
|
|
@@ -162,7 +171,7 @@ $(function(){
|
|
|
<button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
|
|
|
</div>
|
|
|
<div class="modify">
|
|
|
- <span class="ios-user-select" contentEditable="true">${ keys[i].keyWord }</span>
|
|
|
+ <textarea name="" rows="1" placeholder="" maxlength="">${ keys[i].keyWord}</textarea>
|
|
|
<button class="addAdjunctWord">编辑 附加词</button>
|
|
|
<button class="addExclusion">添加 排除词</button>
|
|
|
<button class="deleteKey">删除</button>
|
|
@@ -182,7 +191,7 @@ $(function(){
|
|
|
<button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
|
|
|
</div>
|
|
|
<div class="modify">
|
|
|
- <span class="ios-user-select" contentEditable="true">${ keys[i].keyWord }</span>
|
|
|
+ <textarea name="" rows="1" placeholder="" maxlength="">${ keys[i].keyWord}</textarea>
|
|
|
<button class="addAdjunctWord">编辑 附加词</button>
|
|
|
<button class="addExclusion">添加 排除词</button>
|
|
|
<button class="deleteKey">删除</button>
|
|
@@ -222,11 +231,10 @@ $(function(){
|
|
|
|
|
|
// 编辑
|
|
|
$(".showKeyWord").on('click', '.editKeyWord',function(e){
|
|
|
- let oSpan = e.target.parentNode.nextElementSibling.firstElementChild
|
|
|
- oSpan.focus();
|
|
|
- setTimeout(() => {
|
|
|
- keepLastIndex(oSpan)
|
|
|
- }, 40);
|
|
|
+ let oSpan = e.target.parentNode.nextElementSibling.children[0];
|
|
|
+ let val = $(oSpan).val();
|
|
|
+
|
|
|
+ // alert(oSpan.documentElement.scrollTop)
|
|
|
var keyWord = $(this).prev().children().find(".key").text();
|
|
|
for(var i in keyWordArr){
|
|
|
if(keyWordArr[i].keyWord === keyWord){
|
|
@@ -258,6 +266,7 @@ $(function(){
|
|
|
}
|
|
|
$(this).parent().hide();
|
|
|
$(this).parent().siblings().show().parent().siblings().children('.modify').hide().siblings('.one').show()
|
|
|
+ $(oSpan).val('').focus().val(val);
|
|
|
$(".addKeyWord").hide();
|
|
|
});
|
|
|
|
|
@@ -290,10 +299,11 @@ $(function(){
|
|
|
// 编辑确定
|
|
|
$('.showKeyWord').on('click', '.ascertainKey', function(e) {
|
|
|
var $this = $(this);
|
|
|
- var keyWord = $(this).siblings('span').text();
|
|
|
+ // var keyWord = $(this).siblings('span').text();
|
|
|
+ var keyWord = $(this).siblings('textarea').val();
|
|
|
var keyWords = $(this).parent().prev().find('.key').text();
|
|
|
keyWord = keyWord.replace(/\s/g,"");
|
|
|
- if ($(this).parent().find("span").html().length < 1) {
|
|
|
+ if ($(this).parent().find("textarea").val().length < 1) {
|
|
|
|
|
|
weui.toast('关键词不能为空', {
|
|
|
duration: 2000,
|
|
@@ -303,7 +313,7 @@ $(function(){
|
|
|
}
|
|
|
});
|
|
|
return
|
|
|
- }else if($(this).parent().find("span").text().length > 20){
|
|
|
+ }else if($(this).parent().find("textarea").val().length > 20){
|
|
|
// var s = $(this).parent().find("span").text().slice(0,19);
|
|
|
// $(this).parent().find("span").text(s);
|
|
|
weui.toast('关键词不能超过20字', {
|
|
@@ -330,19 +340,4 @@ $(function(){
|
|
|
return this.replace(/(^\s*)|(\s*$)/g, ' ');
|
|
|
}
|
|
|
|
|
|
- function keepLastIndex(obj) {
|
|
|
- if (window.getSelection) {//ie11 10 9 ff safari
|
|
|
- obj.focus(); //解决ff不获取焦点无法定位问题
|
|
|
- var range = window.getSelection();//创建range
|
|
|
- range.selectAllChildren(obj);//range 选择obj下所有子内容
|
|
|
- range.collapseToEnd();//光标移至最后
|
|
|
- }
|
|
|
- else if (document.selection) {//ie10 9 8 7 6 5
|
|
|
- var range = document.selection.createRange();//创建选择对象
|
|
|
- range.moveToElementText(obj);//range定位到obj
|
|
|
- range.collapse(false);//光标移至最后
|
|
|
- range.select();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
})
|