主题: 插件修改:在kindeditor 4.1的超级链接插件中增加说明
作者: 快乐篮球, 发布日期: 2012-05-24 16:07:43, 浏览数: 7338

修改方法如下:

第一步:修改lang/zh-cn.js,大约114行处增加

'link.linkTitle' : '链接标题',

第二步:修改plugins/link/link.js,增加红色处内容:

第1处:

html = '<div style="padding:20px;">' +

//title
 '<div class="ke-dialog-row">' +
'<label for="keTitle" style="width:60px;">' + lang.linkTitle + '</lable>' +
 '<input class="ke-input-text" type="text" id="keTitle" name="title" value="" style="width:260px;" /></div>' +

//url

 第2处:

yesBtn: {
            name: self.lang('yes'),
            click: function (e) {
                var title = K.trim(titleBox.val());
                var url = K.trim(urlBox.val());
                if (url == 'http://' || K.invalidUrl(url)) {
                    alert(self.lang('invalidUrl'));
                    urlBox[0].focus();
                    return;
                }
                self.exec('createlink', title, url, typeBox.val()).hideDialog().focus();
            }
        }

第3处:

div = dialog.div,
titleBox = K('input[name="title"]', div),
urlBox = K('input[name="url"]', div),

第4处:

if (a) {
                self.cmd.range.selectNode(a[0]);
                self.cmd.select();
                titleBox.val(a.attr('title'));
                urlBox.val(a.attr('data-ke-src'));
                typeBox.val(a.attr('target'));
}

第三步:修改kindeditor.js

第1处:

找到 createlink: function (title, url, type) { //其中title参数是另加的

第2处:

var html = '<a href="' + _escape(url) + '" data-ke-src="' + _escape(url) + '" title="' + _escape(title) + '"';

第3处:

if (range.collapsed) {
                html += '>' + _escape(title) + '</a>'; // 原先是_escape(url)
                return self.inserthtml(html);
}

第4处:

K('a[href="__kindeditor_temp_url__"]', doc).each(function () {
                K(this).attr('href', url).attr('data-ke-src', url).attr('title', title); //增加处
                if (type) {
                    K(this).attr('target', type);
                } else {
                    K(this).removeAttr('target');
                }
            });

 

到此完成

 

 

发表新帖 发表回复