UEditor 自定义input,复选框,弹窗,修改,删除,取值,存值
以加入復(fù)選框?yàn)槔?#xff1a;
1.在ueditor.config.js中找到toolbars的數(shù)組,并在數(shù)組中添加一個(gè)你需要新增的功能名稱
2.在zh-cn.js 中找到labelMap,主要是用于鼠標(biāo)放置上去顯示的文字提示內(nèi)容
//當(dāng)鼠標(biāo)放在工具欄上時(shí)顯示的tooltip提示,留空支持自動(dòng)多語言配置,否則以配置值為準(zhǔn)labelMap:{'checkbox':'復(fù)選框'},3.在ueditor.all.js 中找到"btnCmds" ,在數(shù)組的最后添加"checkbox"
//為工具欄添加按鈕,以下都是統(tǒng)一的按鈕觸發(fā)命令,所以寫在一起var btnCmds = [......,'checkbox'];4.這是該圖標(biāo)的樣式是默認(rèn)的B,可以修改為自己想要的樣式,在ueditor.css中添加樣式
.edui-default .edui-for-checkbox .edui-icon {background-image: url(../images/checkbox.png) !important;background-size: 92%;background-repeat: no-repeat;padding: 9px; }完成以上4步后的效果圖:
5.點(diǎn)擊按鈕加入復(fù)選框,在ueditor.all.js中添加如下代碼,并加入你需要的功能
UE.plugins.checkbox = function() {var me = this;me.addListener("contentchange", function () {utils.each(domUtils.getElementsByTagName(me.document, 'input'), function (input) {input.onclick = function (evt) {if(evt.target.checked){//選中效果domUtils.setAttributes(this,{'checked':'checked'});}else{//取消選中效果domUtils.removeAttributes(this,'checked');}}})}),UE.commands.checkbox = {// execCommand //執(zhí)行各種操作命令execCommand: function(cmdName,ci) {var me= this;me.focus();me.execCommand('inserthtml','<input type="checkbox"/>');},}},完整效果圖/html
6、彈窗形式加參數(shù)
6.1、ueditor.all.js找到dialogBtns,如果設(shè)置彈窗,在ok里面添加checkbox
6.2、在dialogs下面新建checkbox文件夾,在文件夾里面新建checkbox.html,內(nèi)容自己定義,是彈框的內(nèi)容
6.3、ueditor.all.js找到iframeUrlMap,添加如下代碼
'checkbox': '~/dialogs/checkbox/checkbox.html',6.4、在ueditor.css中添加彈窗樣式
/*checkbox-dialog*/ .edui-default .edui-for-checkbox .edui-dialog-content {width: 320px;height: 180px;overflow: hidden; }6.5、參考上述第5步
UE.commands.checkbox = {execCommand: function(cmdname, obj) {//執(zhí)行操作}, }7、若想要加上修改屬性:
ueditor.all.js找到editor.addListener(‘mouseover’, function (t, evt) {}),添加如下代碼
參照iframe添加執(zhí)行代碼
事件寫在ueditor.all.js var popup = new baidu.editor.ui.Popup({})
var popup = new baidu.editor.ui.Popup({editor:editor,content:'',className:'edui-bubble',_edittext:function () {this.hide();baidu.editor.plugins['checkbox'].editdom = this.anchorEl;//用于在'~/dialogs/checkbox/checkbox.html'頁面上取數(shù)據(jù),UE.plugins['checkbox'].editdom 取得修改數(shù)據(jù)editor.ui._dialogs.checkboxDialog.open();},_delete:function(){baidu.editor.dom.domUtils.remove(this.anchorEl,false);//刪除this.hide();} })總結(jié)
以上是生活随笔為你收集整理的UEditor 自定义input,复选框,弹窗,修改,删除,取值,存值的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java中级面试题及答案(120道Jav
- 下一篇: C++类库Pugixml与rapidxm