2024年3月31日发(作者:)
一、添加"你好"插件
1. 定义['hello'] = "你好"。
['hello'] = "您好";
2. 定义n['hello'],所有逻辑都在这个对象里,点击图标时默认执行click方法。
n['hello'] = {
click : function(id) {
alert("您好");
}
};
3. 页面里添加图标定义CSS。
.ke-icon-hello {
background-image: url(./skins/defau);
background-position: 0px -672px;
width: 16px;
height: 16px;
}
4. 最后调用编辑器时items数组里添加hello。
({
id : 'content1',
items : ['hello']
});
演示地址:在新窗口打开
二、添加插入远程图片的插件
1. 定义['remote_image'] = "插入远程图片"。
['remote_image'] = "插入远程图片";
2. 定义n['remote_image']。
n['remote_image'] = {
click : function(id) {
tion(id);
var dialog = new g({
id : id,
cmd : 'remote_image',
width : 310,
height : 90,
title : ['image'],
yesButton : ['yes'],
noButton : ['no']
});
dialo();
},
check : function(id) {
var dialogDoc = rameDoc(KE.g[id].dialog);
var url = KE.$('url', dialogDoc).value;
var title = KE.$('imgTitle', dialogDoc).value;
var width = KE.$('imgWidth', dialogDoc).value;
var height = KE.$('imgHeight', dialogDoc).value;
var border = KE.$('imgBorder', dialogDoc).value;
if ((/.(jpg|jpeg|gif|bmp|png)$/i) == null) {
alert(['invalidImg']);
windo();
KE.g[id].yesBu();
return false;
}
if (width.match(/^d+$/) == null) {
alert(['invalidWidth']);
windo();
KE.g[id].yesBu();
return false;
}
if (heigh(/^d+$/) == null) {
alert(['invalidHeight']);
windo();
KE.g[id].yesBu();
return false;
}
if (borde(/^d+$/) == null) {
alert(['invalidBorder']);
windo();
KE.g[id].yesBu();
return false;
}
return true;
},
exec : function(id) {
t(id);
var iframeDoc = KE.g[id].iframeDoc;
var dialogDoc = rameDoc(KE.g[id].dialog);
if (!(id)) return false;
var url = KE.$('url', dialogDoc).value;
var title = KE.$('imgTitle', dialogDoc).value;
var width = KE.$('imgWidth', dialogDoc).value;
var height = KE.$('imgHeight', dialogDoc).value;
var border = KE.$('imgBorder', dialogDoc).value;
t(id, url, title, width, height, border);
},
insert : function(id, url, title, width, height, border) {
var html = '
if (width > 0) html += 'width="' + width + '" ';
if (height > 0) html += 'height="' + height + '" ';
if (title) html += 'title="' + title + '" ';
html += 'alt="' + title + '" ';
html += 'border="' + border + '" />';
tHtml(id, html);
(id);
(id);
}
};
3. 页面里添加图标定义CSS。
.ke-icon-remote_image {
background-image: url(./skins/defau);
background-position: 0px -496px;
width: 16px;
height: 16px;
}
4. 最后调用编辑器时items数组里添加remote_image。
({
id : 'content1',
items : ['remote_image']
});


发布评论