333
@@ -0,0 +1,87 @@
|
||||
.edui-popup-emotion .edui-emotion-jd img{
|
||||
background:transparent url(images/jxface2.gif?v=1.1) no-repeat scroll left top;
|
||||
cursor:pointer;width:35px;height:35px;display:block;
|
||||
}
|
||||
.edui-popup-emotion .edui-emotion-pp img{
|
||||
background:transparent url(images/fface.gif?v=1.1) no-repeat scroll left top;
|
||||
cursor:pointer;width:25px;height:25px;display:block;
|
||||
}
|
||||
|
||||
.edui-popup-emotion .edui-emotion-ldw img{
|
||||
background:transparent url(images/wface.gif?v=1.1) no-repeat scroll left top;
|
||||
cursor:pointer;width:35px;height:35px;display:block;
|
||||
}
|
||||
|
||||
.edui-popup-emotion .edui-emotion-tsj img{
|
||||
background:transparent url(images/tface.gif?v=1.1) no-repeat scroll left top;
|
||||
cursor:pointer;width:35px;height:35px;display:block;
|
||||
}
|
||||
|
||||
.edui-popup-emotion .edui-emotion-cat img{
|
||||
background:transparent url(images/cface.gif?v=1.1) no-repeat scroll left top;
|
||||
cursor:pointer;width:35px;height:35px;display:block;
|
||||
}
|
||||
|
||||
.edui-popup-emotion .edui-emotion-bb img{
|
||||
background:transparent url(images/bface.gif?v=1.1) no-repeat scroll left top;
|
||||
cursor:pointer;width:35px;height:35px;display:block;
|
||||
}
|
||||
|
||||
.edui-popup-emotion .edui-emotion-youa img{
|
||||
background:transparent url(images/yface.gif?v=1.1) no-repeat scroll left top;
|
||||
cursor:pointer;width:35px;height:35px;display:block;
|
||||
}
|
||||
|
||||
.edui-popup-emotion .edui-emotion-smileytable {
|
||||
width: 100%;
|
||||
border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
.edui-popup-emotion .edui-emotion-wrapper {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.edui-popup-emotion .edui-tab-nav{
|
||||
height: auto;
|
||||
*height: 31px;
|
||||
}
|
||||
.edui-popup-emotion .edui-emotion-tabs{
|
||||
clear: both;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.edui-popup-emotion .edui-tab-content {
|
||||
padding: 15px 0;
|
||||
}
|
||||
|
||||
.edui-popup-emotion .edui-emotion-preview-box {
|
||||
width:90px;
|
||||
height:76px;
|
||||
border:2px solid #9cb945;
|
||||
background:#FFFFFF;
|
||||
background-position:center;
|
||||
background-repeat:no-repeat;
|
||||
position: absolute;
|
||||
top: 67px;
|
||||
left: 494px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.edui-popup-emotion .edui-tab-text {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.edui-popup-emotion .edui-emotion-preview-left {
|
||||
left: 15px;
|
||||
}
|
||||
|
||||
.edui-popup-emotion .edui-emotion-preview-img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center center;
|
||||
}
|
||||
@@ -0,0 +1,272 @@
|
||||
(function(){
|
||||
|
||||
var editor = null;
|
||||
|
||||
UM.registerWidget('emotion',{
|
||||
|
||||
tpl: "<link type=\"text/css\" rel=\"stylesheet\" href=\"<%=emotion_url%>emotion.css\">" +
|
||||
"<div class=\"edui-emotion-tab-Jpanel edui-emotion-wrapper\">" +
|
||||
"<ul class=\"edui-emotion-Jtabnav edui-tab-nav\">" +
|
||||
"<li class=\"edui-tab-item\"><a data-context=\".edui-emotion-Jtab0\" hideFocus=\"true\" class=\"edui-tab-text\"><%=lang_input_choice%></a></li>" +
|
||||
"<li class=\"edui-tab-item\"><a data-context=\".edui-emotion-Jtab1\" class=\"edui-tab-text\"><%=lang_input_Tuzki%></a></li>" +
|
||||
"<li class=\"edui-tab-item\"><a data-context=\".edui-emotion-Jtab2\" hideFocus=\"true\" class=\"edui-tab-text\"><%=lang_input_lvdouwa%></a></li>" +
|
||||
"<li class=\"edui-tab-item\"><a data-context=\".edui-emotion-Jtab3\" hideFocus=\"true\" class=\"edui-tab-text\"><%=lang_input_BOBO%></a></li>" +
|
||||
"<li class=\"edui-tab-item\"><a data-context=\".edui-emotion-Jtab4\" hideFocus=\"true\" class=\"edui-tab-text\"><%=lang_input_babyCat%></a></li>" +
|
||||
"<li class=\"edui-tab-item\"><a data-context=\".edui-emotion-Jtab5\" hideFocus=\"true\" class=\"edui-tab-text\"><%=lang_input_bubble%></a></li>" +
|
||||
"<li class=\"edui-tab-item\"><a data-context=\".edui-emotion-Jtab6\" hideFocus=\"true\" class=\"edui-tab-text\"><%=lang_input_youa%></a></li>" +
|
||||
"<li class=\"edui-emotion-tabs\"></li>" +
|
||||
"</ul>" +
|
||||
"<div class=\"edui-tab-content edui-emotion-JtabBodys\">" +
|
||||
"<div class=\"edui-emotion-Jtab0 edui-tab-pane\"></div>" +
|
||||
"<div class=\"edui-emotion-Jtab1 edui-tab-pane\"></div>" +
|
||||
"<div class=\"edui-emotion-Jtab2 edui-tab-pane\"></div>" +
|
||||
"<div class=\"edui-emotion-Jtab3 edui-tab-pane\"></div>" +
|
||||
"<div class=\"edui-emotion-Jtab4 edui-tab-pane\"></div>" +
|
||||
"<div class=\"edui-emotion-Jtab5 edui-tab-pane\"></div>" +
|
||||
"<div class=\"edui-emotion-Jtab6 edui-tab-pane\"></div>" +
|
||||
"</div>" +
|
||||
"<div class=\"edui-emotion-JtabIconReview edui-emotion-preview-box\">" +
|
||||
"<img src=\"<%=cover_img%>\" class=\'edui-emotion-JfaceReview edui-emotion-preview-img\'/>" +
|
||||
"</div>",
|
||||
|
||||
sourceData: {
|
||||
emotion: {
|
||||
tabNum:7, //切换面板数量
|
||||
SmilmgName:{ 'edui-emotion-Jtab0':['j_00', 84], 'edui-emotion-Jtab1':['t_00', 40], 'edui-emotion-Jtab2':['w_00', 52], 'edui-emotion-Jtab3':['B_00', 63], 'edui-emotion-Jtab4':['C_00', 20], 'edui-emotion-Jtab5':['i_f', 50], 'edui-emotion-Jtab6':['y_00', 40] }, //图片前缀名
|
||||
imageFolders:{ 'edui-emotion-Jtab0':'jx2/', 'edui-emotion-Jtab1':'tsj/', 'edui-emotion-Jtab2':'ldw/', 'edui-emotion-Jtab3':'bobo/', 'edui-emotion-Jtab4':'babycat/', 'edui-emotion-Jtab5':'face/', 'edui-emotion-Jtab6':'youa/'}, //图片对应文件夹路径
|
||||
imageCss:{'edui-emotion-Jtab0':'jd', 'edui-emotion-Jtab1':'tsj', 'edui-emotion-Jtab2':'ldw', 'edui-emotion-Jtab3':'bb', 'edui-emotion-Jtab4':'cat', 'edui-emotion-Jtab5':'pp', 'edui-emotion-Jtab6':'youa'}, //图片css类名
|
||||
imageCssOffset:{'edui-emotion-Jtab0':35, 'edui-emotion-Jtab1':35, 'edui-emotion-Jtab2':35, 'edui-emotion-Jtab3':35, 'edui-emotion-Jtab4':35, 'edui-emotion-Jtab5':25, 'edui-emotion-Jtab6':35}, //图片偏移
|
||||
SmileyInfor:{
|
||||
'edui-emotion-Jtab0':['Kiss', 'Love', 'Yeah', '啊!', '背扭', '顶', '抖胸', '88', '汗', '瞌睡', '鲁拉', '拍砖', '揉脸', '生日快乐', '大笑', '瀑布汗~', '惊讶', '臭美', '傻笑', '抛媚眼', '发怒', '打酱油', '俯卧撑', '气愤', '?', '吻', '怒', '胜利', 'HI', 'KISS', '不说', '不要', '扯花', '大心', '顶', '大惊', '飞吻', '鬼脸', '害羞', '口水', '狂哭', '来', '发财了', '吃西瓜', '套牢', '害羞', '庆祝', '我来了', '敲打', '晕了', '胜利', '臭美', '被打了', '贪吃', '迎接', '酷', '微笑', '亲吻', '调皮', '惊恐', '耍酷', '发火', '害羞', '汗水', '大哭', '', '加油', '困', '你NB', '晕倒', '开心', '偷笑', '大哭', '滴汗', '叹气', '超赞', '??', '飞吻', '天使', '撒花', '生气', '被砸', '吓傻', '随意吐'],
|
||||
'edui-emotion-Jtab1':['Kiss', 'Love', 'Yeah', '啊!', '背扭', '顶', '抖胸', '88', '汗', '瞌睡', '鲁拉', '拍砖', '揉脸', '生日快乐', '摊手', '睡觉', '瘫坐', '无聊', '星星闪', '旋转', '也不行', '郁闷', '正Music', '抓墙', '撞墙至死', '歪头', '戳眼', '飘过', '互相拍砖', '砍死你', '扔桌子', '少林寺', '什么?', '转头', '我爱牛奶', '我踢', '摇晃', '晕厥', '在笼子里', '震荡'],
|
||||
'edui-emotion-Jtab2':['大笑', '瀑布汗~', '惊讶', '臭美', '傻笑', '抛媚眼', '发怒', '我错了', 'money', '气愤', '挑逗', '吻', '怒', '胜利', '委屈', '受伤', '说啥呢?', '闭嘴', '不', '逗你玩儿', '飞吻', '眩晕', '魔法', '我来了', '睡了', '我打', '闭嘴', '打', '打晕了', '刷牙', '爆揍', '炸弹', '倒立', '刮胡子', '邪恶的笑', '不要不要', '爱恋中', '放大仔细看', '偷窥', '超高兴', '晕', '松口气', '我跑', '享受', '修养', '哭', '汗', '啊~', '热烈欢迎', '打酱油', '俯卧撑', '?'],
|
||||
'edui-emotion-Jtab3':['HI', 'KISS', '不说', '不要', '扯花', '大心', '顶', '大惊', '飞吻', '鬼脸', '害羞', '口水', '狂哭', '来', '泪眼', '流泪', '生气', '吐舌', '喜欢', '旋转', '再见', '抓狂', '汗', '鄙视', '拜', '吐血', '嘘', '打人', '蹦跳', '变脸', '扯肉', '吃To', '吃花', '吹泡泡糖', '大变身', '飞天舞', '回眸', '可怜', '猛抽', '泡泡', '苹果', '亲', '', '骚舞', '烧香', '睡', '套娃娃', '捅捅', '舞倒', '西红柿', '爱慕', '摇', '摇摆', '杂耍', '招财', '被殴', '被球闷', '大惊', '理想', '欧打', '呕吐', '碎', '吐痰'],
|
||||
'edui-emotion-Jtab4':['发财了', '吃西瓜', '套牢', '害羞', '庆祝', '我来了', '敲打', '晕了', '胜利', '臭美', '被打了', '贪吃', '迎接', '酷', '顶', '幸运', '爱心', '躲', '送花', '选择'],
|
||||
'edui-emotion-Jtab5':['微笑', '亲吻', '调皮', '惊讶', '耍酷', '发火', '害羞', '汗水', '大哭', '得意', '鄙视', '困', '夸奖', '晕倒', '疑问', '媒婆', '狂吐', '青蛙', '发愁', '亲吻', '', '爱心', '心碎', '玫瑰', '礼物', '哭', '奸笑', '可爱', '得意', '呲牙', '暴汗', '楚楚可怜', '困', '哭', '生气', '惊讶', '口水', '彩虹', '夜空', '太阳', '钱钱', '灯泡', '咖啡', '蛋糕', '音乐', '爱', '胜利', '赞', '鄙视', 'OK'],
|
||||
'edui-emotion-Jtab6':['男兜', '女兜', '开心', '乖乖', '偷笑', '大笑', '抽泣', '大哭', '无奈', '滴汗', '叹气', '狂晕', '委屈', '超赞', '??', '疑问', '飞吻', '天使', '撒花', '生气', '被砸', '口水', '泪奔', '吓傻', '吐舌头', '点头', '随意吐', '旋转', '困困', '鄙视', '狂顶', '篮球', '再见', '欢迎光临', '恭喜发财', '稍等', '我在线', '恕不议价', '库房有货', '货在路上']
|
||||
}
|
||||
}
|
||||
},
|
||||
initContent:function( _editor, $widget ){
|
||||
|
||||
var me = this,
|
||||
emotion = me.sourceData.emotion,
|
||||
lang = _editor.getLang( 'emotion' )['static'],
|
||||
emotionUrl = UMEDITOR_CONFIG.UMEDITOR_HOME_URL + 'dialogs/emotion/',
|
||||
options = $.extend( {}, lang, {
|
||||
emotion_url: emotionUrl
|
||||
}),
|
||||
$root = me.root();
|
||||
|
||||
if( me.inited ) {
|
||||
me.preventDefault();
|
||||
this.switchToFirst();
|
||||
return;
|
||||
}
|
||||
|
||||
me.inited = true;
|
||||
|
||||
editor = _editor;
|
||||
this.widget = $widget;
|
||||
|
||||
emotion.SmileyPath = _editor.options.emotionLocalization === true ? emotionUrl + 'images/' : "http://img.baidu.com/hi/";
|
||||
emotion.SmileyBox = me.createTabList( emotion.tabNum );
|
||||
emotion.tabExist = me.createArr( emotion.tabNum );
|
||||
|
||||
options['cover_img'] = emotion.SmileyPath + (editor.options.emotionLocalization ? '0.gif' : 'default/0.gif');
|
||||
|
||||
$root.html( $.parseTmpl( me.tpl, options ) );
|
||||
|
||||
me.tabs = $.eduitab({selector:".edui-emotion-tab-Jpanel"});
|
||||
|
||||
//缓存预览对象
|
||||
me.previewBox = $root.find(".edui-emotion-JtabIconReview");
|
||||
me.previewImg = $root.find(".edui-emotion-JfaceReview");
|
||||
|
||||
me.initImgName();
|
||||
|
||||
},
|
||||
initEvent:function(){
|
||||
|
||||
var me = this;
|
||||
|
||||
//防止点击过后关闭popup
|
||||
me.root().on('click', function(e){
|
||||
return false;
|
||||
});
|
||||
|
||||
//移动预览
|
||||
me.root().delegate( 'td', 'mouseover mouseout', function( evt ){
|
||||
|
||||
var $td = $( this),
|
||||
url = $td.attr('data-surl') || null;
|
||||
|
||||
if( url ) {
|
||||
me[evt.type]( this, url , $td.attr('data-posflag') );
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
} );
|
||||
|
||||
//点击选中
|
||||
me.root().delegate( 'td', 'click', function( evt ){
|
||||
|
||||
var $td = $( this),
|
||||
realUrl = $td.attr('data-realurl') || null;
|
||||
|
||||
if( realUrl ) {
|
||||
me.insertSmiley( realUrl.replace( /'/g, "\\'" ), evt );
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
} );
|
||||
|
||||
//更新模板
|
||||
me.tabs.edui().on("beforeshow", function( evt ){
|
||||
|
||||
var contentId = $(evt.target).attr('data-context').replace( /^.*\.(?=[^\s]*$)/, '' );
|
||||
|
||||
evt.stopPropagation();
|
||||
|
||||
me.updateTab( contentId );
|
||||
|
||||
});
|
||||
|
||||
this.switchToFirst();
|
||||
|
||||
},
|
||||
initImgName: function() {
|
||||
|
||||
var emotion = this.sourceData.emotion;
|
||||
|
||||
for ( var pro in emotion.SmilmgName ) {
|
||||
var tempName = emotion.SmilmgName[pro],
|
||||
tempBox = emotion.SmileyBox[pro],
|
||||
tempStr = "";
|
||||
|
||||
if ( tempBox.length ) return;
|
||||
|
||||
for ( var i = 1; i <= tempName[1]; i++ ) {
|
||||
tempStr = tempName[0];
|
||||
if ( i < 10 ) tempStr = tempStr + '0';
|
||||
tempStr = tempStr + i + '.gif';
|
||||
tempBox.push( tempStr );
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
/**
|
||||
* 切换到第一个tab
|
||||
*/
|
||||
switchToFirst: function(){
|
||||
this.root().find(".edui-emotion-Jtabnav .edui-tab-text:first").trigger('click');
|
||||
},
|
||||
updateTab: function( contentBoxId ) {
|
||||
|
||||
var me = this,
|
||||
emotion = me.sourceData.emotion;
|
||||
|
||||
me.autoHeight( contentBoxId );
|
||||
|
||||
if ( !emotion.tabExist[ contentBoxId ] ) {
|
||||
|
||||
emotion.tabExist[ contentBoxId ] = true;
|
||||
me.createTab( contentBoxId );
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
autoHeight: function( ) {
|
||||
this.widget.height(this.root() + 2);
|
||||
},
|
||||
createTabList: function( tabNum ) {
|
||||
var obj = {};
|
||||
for ( var i = 0; i < tabNum; i++ ) {
|
||||
obj["edui-emotion-Jtab" + i] = [];
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
mouseover: function( td, srcPath, posFlag ) {
|
||||
|
||||
posFlag -= 0;
|
||||
|
||||
$(td).css( 'backgroundColor', '#ACCD3C' );
|
||||
|
||||
this.previewImg.css( "backgroundImage", "url(" + srcPath + ")" );
|
||||
posFlag && this.previewBox.addClass('edui-emotion-preview-left');
|
||||
this.previewBox.show();
|
||||
|
||||
},
|
||||
mouseout: function( td ) {
|
||||
$(td).css( 'backgroundColor', 'transparent' );
|
||||
this.previewBox.removeClass('edui-emotion-preview-left').hide();
|
||||
},
|
||||
insertSmiley: function( url, evt ) {
|
||||
var obj = {
|
||||
src: url
|
||||
};
|
||||
obj._src = obj.src;
|
||||
editor.execCommand( 'insertimage', obj );
|
||||
if ( !evt.ctrlKey ) {
|
||||
//关闭预览
|
||||
this.previewBox.removeClass('edui-emotion-preview-left').hide();
|
||||
this.widget.edui().hide();
|
||||
}
|
||||
},
|
||||
createTab: function( contentBoxId ) {
|
||||
|
||||
var faceVersion = "?v=1.1", //版本号
|
||||
me = this,
|
||||
$contentBox = this.root().find("."+contentBoxId),
|
||||
emotion = me.sourceData.emotion,
|
||||
imagePath = emotion.SmileyPath + emotion.imageFolders[ contentBoxId ], //获取显示表情和预览表情的路径
|
||||
positionLine = 11 / 2, //中间数
|
||||
iWidth = iHeight = 35, //图片长宽
|
||||
iColWidth = 3, //表格剩余空间的显示比例
|
||||
tableCss = emotion.imageCss[ contentBoxId ],
|
||||
cssOffset = emotion.imageCssOffset[ contentBoxId ],
|
||||
textHTML = ['<table border="1" class="edui-emotion-smileytable">'],
|
||||
i = 0, imgNum = emotion.SmileyBox[ contentBoxId ].length, imgColNum = 11, faceImage,
|
||||
sUrl, realUrl, posflag, offset, infor;
|
||||
|
||||
for ( ; i < imgNum; ) {
|
||||
textHTML.push( '<tr>' );
|
||||
for ( var j = 0; j < imgColNum; j++, i++ ) {
|
||||
faceImage = emotion.SmileyBox[ contentBoxId ][i];
|
||||
if ( faceImage ) {
|
||||
sUrl = imagePath + faceImage + faceVersion;
|
||||
realUrl = imagePath + faceImage;
|
||||
posflag = j < positionLine ? 0 : 1;
|
||||
offset = cssOffset * i * (-1) - 1;
|
||||
infor = emotion.SmileyInfor[ contentBoxId ][i];
|
||||
|
||||
textHTML.push( '<td class="edui-emotion-' + tableCss + '" data-surl="'+ sUrl +'" data-realurl="'+ realUrl +'" data-posflag="'+ posflag +'" align="center">' );
|
||||
textHTML.push( '<span>' );
|
||||
textHTML.push( '<img style="background-position:left ' + offset + 'px;" title="' + infor + '" src="' + emotion.SmileyPath + (editor.options.emotionLocalization ? '0.gif" width="' : 'default/0.gif" width="') + iWidth + '" height="' + iHeight + '"></img>' );
|
||||
textHTML.push( '</span>' );
|
||||
} else {
|
||||
textHTML.push( '<td bgcolor="#FFFFFF">' );
|
||||
}
|
||||
textHTML.push( '</td>' );
|
||||
}
|
||||
textHTML.push( '</tr>' );
|
||||
}
|
||||
textHTML.push( '</table>' );
|
||||
textHTML = textHTML.join( "" );
|
||||
$contentBox.html( textHTML );
|
||||
},
|
||||
createArr: function( tabNum ) {
|
||||
var arr = [];
|
||||
for ( var i = 0; i < tabNum; i++ ) {
|
||||
arr[i] = 0;
|
||||
}
|
||||
return arr;
|
||||
},
|
||||
width:603,
|
||||
height:400
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
|
After Width: | Height: | Size: 43 B |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 8.4 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 216 B |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 28 KiB |
@@ -0,0 +1,32 @@
|
||||
.edui-popup-formula .edui-formula-wrapper {
|
||||
padding: 15px;
|
||||
}
|
||||
.edui-popup-formula .edui-formula-wrapper .edui-tab-nav{
|
||||
height: auto;
|
||||
*height: 31px;
|
||||
}
|
||||
.edui-popup-formula .edui-formula-wrapper .edui-tab-text {
|
||||
font-size: 12px;
|
||||
}
|
||||
.edui-popup-formula .edui-formula-wrapper .edui-formula-clearboth {
|
||||
clear: both;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
.edui-popup-formula .edui-formula-wrapper .edui-tab-pane ul {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
.edui-popup-formula .edui-formula-wrapper .edui-tab-content {
|
||||
padding: 5px 0px 0px 0px;
|
||||
}
|
||||
.edui-popup-formula .edui-formula-wrapper .edui-tab-pane .edui-formula-latex-item {
|
||||
display: block;
|
||||
float: left;
|
||||
margin: 0px 3px 3px 0px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border:1px solid #cccccc;
|
||||
background-image: url("images/formula.png");
|
||||
cursor: pointer;
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Document</title>
|
||||
<link rel="stylesheet" href="../../third-party/mathquill/mathquill.css"/>
|
||||
<style>
|
||||
html, body, .main{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
.main{
|
||||
width:1024px;
|
||||
height:1024px;
|
||||
}
|
||||
.mathquill-editable,
|
||||
.mathquill-rendered-math{
|
||||
border: 0px;
|
||||
padding: 0px;
|
||||
margin:4px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="main">
|
||||
<div class="mathquill-editable"></div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<input id="blurHelper" />
|
||||
</div>
|
||||
|
||||
<script src="../../third-party/jquery.min.js"></script>
|
||||
<script src="../../third-party/mathquill/mathquill.js"></script>
|
||||
<script>
|
||||
$(function(){
|
||||
|
||||
var UM = parent.UM,
|
||||
$iframe = $(getSelfIframe()),
|
||||
editorId = $iframe.parents('.edui-body-container').attr('id'),
|
||||
editor = UM.getEditor(editorId),
|
||||
timer;
|
||||
|
||||
/* 获得当前公式所在的iframe节点 */
|
||||
function getSelfIframe(){
|
||||
var iframes = parent.document.getElementsByTagName('iframe');
|
||||
for (var key in iframes) {
|
||||
if (iframes[key].contentWindow == window) {
|
||||
return iframes[key];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/* 获得当前url上的hash存储的参数值 */
|
||||
function getLatex() {
|
||||
return $iframe.attr('data-latex') || '';
|
||||
}
|
||||
/* 保存场景 */
|
||||
function saveScene(){
|
||||
timer && clearTimeout(timer);
|
||||
timer = setTimeout(function(){
|
||||
editor.fireEvent('savescene');
|
||||
editor.fireEvent('contentchange');
|
||||
editor.fireEvent('selectionchange');
|
||||
timer = null;
|
||||
}, 300);
|
||||
}
|
||||
/* 设置编辑器可编辑 */
|
||||
function enableEditor(){
|
||||
if(editor.body.contentEditable == 'false') {
|
||||
editor.setEnabled();
|
||||
}
|
||||
}
|
||||
/* 设置编辑器不可编辑 */
|
||||
function disableEditor(){
|
||||
if(editor.body.contentEditable == 'true') {
|
||||
editor.setDisabled(['undo', 'redo', 'preview', 'formula'], true);
|
||||
}
|
||||
}
|
||||
|
||||
/* 公式 */
|
||||
var Formula = function(){
|
||||
var _this = this,
|
||||
latex = getLatex();
|
||||
|
||||
this.isFocus = false;
|
||||
this.isDisabled = false;
|
||||
|
||||
/* 加载公式内容 */
|
||||
this.$mathquill = $('.mathquill-editable').mathquill('latex', latex);
|
||||
|
||||
/* 设置活动状态的公式iframe */
|
||||
this.$mathquill.on('mousedown', function(){
|
||||
/* 编辑器不可用时,公式也不可用 */
|
||||
if(_this.disabled) return false;
|
||||
|
||||
/* 第一次点击当前公式,设置公式活动 */
|
||||
if(!$iframe.hasClass('edui-formula-active')) {
|
||||
disableEditor();
|
||||
editor.blur();
|
||||
editor.$body.find('iframe').not($iframe).each(function(k, v){
|
||||
v.contentWindow.formula.blur();
|
||||
});
|
||||
if(_this.$mathquill.find('.cursor').css('display') == 'none') {
|
||||
_this.refresh();
|
||||
_this.$mathquill.addClass('hasCursor');
|
||||
}
|
||||
}
|
||||
_this.focus();
|
||||
});
|
||||
editor.addListener('click', function(){
|
||||
_this.blur();
|
||||
enableEditor();
|
||||
});
|
||||
|
||||
/* 里面focus,编辑器也判断为focus */
|
||||
editor.addListener('isFocus', function(){
|
||||
return _this.isFocus;
|
||||
});
|
||||
/* um不可用,公式也不可编辑 */
|
||||
editor.addListener('setDisabled', function(type, except){
|
||||
if (!(except && except.join(' ').indexOf('formula') != -1) && _this.isDisabled != true ) {
|
||||
_this.setDisabled();
|
||||
}
|
||||
});
|
||||
editor.addListener('setEnabled', function(){
|
||||
if (_this.isDisabled != false) {
|
||||
_this.setEnabled();
|
||||
}
|
||||
});
|
||||
|
||||
/* 设置更新外层iframe的大小和属性 */
|
||||
$(document.body).on('keydown', function(){
|
||||
_this.updateIframe();
|
||||
}).on('keyup', function(){
|
||||
_this.updateIframe();
|
||||
});
|
||||
|
||||
/* 清除初始化的高亮状态 */
|
||||
this.$mathquill.removeClass('hasCursor');
|
||||
|
||||
/* 初始化后延迟刷新外层iframe大小 */
|
||||
setTimeout(function(){
|
||||
_this.updateIframe();
|
||||
}, 300);
|
||||
};
|
||||
|
||||
Formula.prototype = {
|
||||
focus:function(){
|
||||
$iframe.addClass('edui-formula-active');
|
||||
this.isFocus = true;
|
||||
},
|
||||
blur:function(){
|
||||
$iframe.removeClass('edui-formula-active');
|
||||
this.removeCursor();
|
||||
this.isFocus = false;
|
||||
},
|
||||
removeCursor: function(){
|
||||
this.$mathquill.find('span.cursor').hide();
|
||||
this.$mathquill.parent().find('.hasCursor').removeClass('hasCursor');
|
||||
},
|
||||
updateIframe: function(){
|
||||
$iframe.width(this.$mathquill.width()+8).height(this.$mathquill.height()+8);
|
||||
var latex = $iframe.attr('data-latex'),
|
||||
newLatex = this.getLatex();
|
||||
if(latex != newLatex) {
|
||||
$iframe.attr('data-latex', this.getLatex());
|
||||
saveScene();
|
||||
}
|
||||
},
|
||||
insertLatex: function(latex){
|
||||
this.$mathquill.mathquill('write', latex);
|
||||
this.updateIframe();
|
||||
this.removeCursor();
|
||||
},
|
||||
setLatex: function(latex){
|
||||
this.$mathquill.mathquill('latex', latex);
|
||||
this.updateIframe();
|
||||
},
|
||||
getLatex: function(){
|
||||
return this.$mathquill.mathquill('latex');
|
||||
},
|
||||
redraw: function(){
|
||||
this.$mathquill.mathquill('redraw');
|
||||
},
|
||||
setDisabled: function(){
|
||||
this.blur();
|
||||
var latex = this.getLatex();
|
||||
this.$mathquill.mathquill('revert').text(latex).mathquill();
|
||||
this.updateIframe();
|
||||
this.isDisabled = true;
|
||||
},
|
||||
setEnabled: function(){
|
||||
this.$mathquill.removeClass('mathquill-rendered-math');
|
||||
this.refresh();
|
||||
this.isDisabled = false;
|
||||
},
|
||||
refresh: function(){
|
||||
var latex = this.getLatex();
|
||||
this.$mathquill.mathquill('revert').text(latex).mathquill('editable');
|
||||
this.updateIframe();
|
||||
}
|
||||
};
|
||||
|
||||
/* 绑定到window上,给上级window调用 */
|
||||
window.formula = new Formula();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,124 @@
|
||||
(function () {
|
||||
|
||||
var editor = null;
|
||||
|
||||
UM.registerWidget('formula', {
|
||||
|
||||
tpl: "<link type=\"text/css\" rel=\"stylesheet\" href=\"<%=formula_url%>formula.css\">" +
|
||||
"<div class=\"edui-formula-wrapper\">" +
|
||||
"<ul class=\"edui-tab-nav\"></ul>" +
|
||||
"<div class=\"edui-tab-content\"></div>" +
|
||||
"</div>",
|
||||
|
||||
sourceData: {
|
||||
formula: {
|
||||
'common': [
|
||||
"{/}frac{ }{ }", "^{ }/_{ }", "x^{ }", "x_{ }", "x^{ }_{ }", "{/}bar{ }", "{/}sqrt{ }", "{/}nthroot{ }{ }",
|
||||
"{/}sum^{ }_{n=}", "{/}sum", "{/}log_{ }", "{/}ln", "{/}int_{ }^{ }", "{/}oint_{ }^{ }"
|
||||
],
|
||||
'symbol': [
|
||||
"+", "-", "{/}pm", "{/}times", "{/}ast", "{/}div", "/", "{/}bigtriangleup",
|
||||
"=", "{/}ne", "{/}approx", ">", "<", "{/}ge", "{/}le", "{/}infty",
|
||||
"{/}cap", "{/}cup", "{/}because", "{/}therefore", "{/}subset", "{/}supset", "{/}subseteq", "{/}supseteq",
|
||||
"{/}nsubseteq", "{/}nsupseteq", "{/}in", "{/}ni", "{/}notin", "{/}mapsto", "{/}leftarrow", "{/}rightarrow",
|
||||
"{/}Leftarrow", "{/}Rightarrow", "{/}leftrightarrow", "{/}Leftrightarrow"
|
||||
],
|
||||
'letter': [
|
||||
"{/}alpha", "{/}beta", "{/}gamma", "{/}delta", "{/}varepsilon", "{/}varphi", "{/}lambda", "{/}mu",
|
||||
"{/}rho", "{/}sigma", "{/}omega", "{/}Gamma", "{/}Delta", "{/}Theta", "{/}Lambda", "{/}Xi",
|
||||
"{/}Pi", "{/}Sigma", "{/}Upsilon", "{/}Phi", "{/}Psi", "{/}Omega"
|
||||
]
|
||||
}
|
||||
},
|
||||
initContent: function (_editor, $widget) {
|
||||
|
||||
var me = this,
|
||||
formula = me.sourceData.formula,
|
||||
lang = _editor.getLang('formula').static,
|
||||
formulaUrl = UMEDITOR_CONFIG.UMEDITOR_HOME_URL + 'dialogs/formula/',
|
||||
options = $.extend({}, lang, { 'formula_url': formulaUrl }),
|
||||
$root = me.root();
|
||||
|
||||
if (me.inited) {
|
||||
me.preventDefault();
|
||||
return;
|
||||
}
|
||||
me.inited = true;
|
||||
|
||||
editor = _editor;
|
||||
me.$widget = $widget;
|
||||
|
||||
$root.html($.parseTmpl(me.tpl, options));
|
||||
me.tabs = $.eduitab({selector: "#edui-formula-tab-Jpanel"});
|
||||
|
||||
/* 初始化popup的内容 */
|
||||
var headHtml = [], xMax = 0, yMax = 0,
|
||||
$tabContent = me.root().find('.edui-tab-content');
|
||||
$.each(formula, function (k, v) {
|
||||
var contentHtml = [];
|
||||
$.each(v, function (i, f) {
|
||||
contentHtml.push('<li class="edui-formula-latex-item" data-latex="' + f + '" style="background-position:-' + (xMax * 30) + 'px -' + (yMax * 30) + 'px"></li>');
|
||||
if (++xMax >=8) {
|
||||
++yMax; xMax = 0;
|
||||
}
|
||||
});
|
||||
yMax++; xMax = 0;
|
||||
$tabContent.append('<div class="edui-tab-pane"><ul>' + contentHtml.join('') + '</ul>');
|
||||
headHtml.push('<li class="edui-tab-item"><a href="javascript:void(0);" class="edui-tab-text">' + lang['lang_tab_' + k] + '</a></li>');
|
||||
});
|
||||
headHtml.push('<li class="edui-formula-clearboth"></li>');
|
||||
$root.find('.edui-tab-nav').html(headHtml.join(''));
|
||||
$root.find('.edui-tab-content').append('<div class="edui-formula-clearboth"></div>');
|
||||
|
||||
/* 选中第一个tab */
|
||||
me.switchTab(0);
|
||||
},
|
||||
initEvent: function () {
|
||||
var me = this;
|
||||
|
||||
//防止点击过后关闭popup
|
||||
me.root().on('click', function (e) {
|
||||
return false;
|
||||
});
|
||||
|
||||
//点击tab切换菜单
|
||||
me.root().find('.edui-tab-nav').delegate('.edui-tab-item', 'click', function (evt) {
|
||||
me.switchTab(this);
|
||||
return false;
|
||||
});
|
||||
|
||||
//点击选中公式
|
||||
me.root().find('.edui-tab-pane').delegate('.edui-formula-latex-item', 'click', function (evt) {
|
||||
var $item = $(this),
|
||||
latex = $item.attr('data-latex') || '';
|
||||
|
||||
if (latex) {
|
||||
me.insertLatex(latex.replace("{/}", "\\"));
|
||||
}
|
||||
me.$widget.edui().hide();
|
||||
return false;
|
||||
});
|
||||
},
|
||||
switchTab:function(index){
|
||||
var me = this,
|
||||
$root = me.root(),
|
||||
index = $.isNumeric(index) ? index:$.inArray(index, $root.find('.edui-tab-nav .edui-tab-item'));
|
||||
|
||||
$root.find('.edui-tab-nav .edui-tab-item').removeClass('edui-active').eq(index).addClass('edui-active');
|
||||
$root.find('.edui-tab-content .edui-tab-pane').removeClass('edui-active').eq(index).addClass('edui-active');
|
||||
|
||||
/* 自动长高 */
|
||||
me.autoHeight(0);
|
||||
},
|
||||
autoHeight: function () {
|
||||
this.$widget.height(this.root() + 2);
|
||||
},
|
||||
insertLatex: function (latex) {
|
||||
editor.execCommand('formula', latex );
|
||||
},
|
||||
width: 350,
|
||||
height: 400
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
|
After Width: | Height: | Size: 19 KiB |
@@ -0,0 +1,42 @@
|
||||
.edui-dialog-image .edui-image-wrapper{font-size: 12px;margin: 15px;}
|
||||
|
||||
/*upload*/
|
||||
.edui-dialog-image .edui-image-upload1{position: absolute;top:50%;left:50%;width:44px;height:38px;margin-top:-19px; margin-left: -22px;}
|
||||
.edui-dialog-image .edui-image-upload2{position:relative;float:left;width:120px;height:120px;margin:5px 0 0 5px;}
|
||||
|
||||
.edui-dialog-image .edui-image-form{position: absolute;left: 0px;top: 0px;width: 100%;height: 100%;opacity: 0;cursor: pointer;}
|
||||
.edui-dialog-image .edui-image-form .edui-image-file{width: 100%;height:100%;filter: alpha(opacity=0)}
|
||||
|
||||
.edui-dialog-image .edui-image-upload1 .edui-image-icon{display: inline-block;width:44px;height:38px;background-image: url('images/upload1.png')}
|
||||
.edui-dialog-image .edui-image-upload1 .edui-image-icon.hover{background-position: -50px 0;}
|
||||
.edui-dialog-image .edui-image-upload2 .edui-image-icon{display: inline-block;width:120px;height:120px;background-image: url('images/upload2.png')}
|
||||
|
||||
.edui-dialog-image .edui-image-dragTip{position: absolute;display:none;top:50%;left:50%;margin-top:30px;margin-left: -60px;
|
||||
color: #222;font-size:14px;text-shadow: 0px 2px 3px #555;}
|
||||
|
||||
.edui-dialog-image .edui-image-content{height:330px;width:100%;position: relative;}
|
||||
|
||||
.edui-dialog-image .edui-image-mask{display: none;position: absolute;top:0;left:0;width: 100%; height: 100%;background-color:#fff;
|
||||
text-align: center;line-height:300px;color:#000;font-size:14px;font-weight:bold;opacity: 0.6;filter: alpha(opacity=60);}
|
||||
.edui-dialog-image .edui-image-mask.edui-active{display: block;}
|
||||
|
||||
/*network*/
|
||||
.edui-dialog-image .edui-image-searchBar{margin: 10px;}
|
||||
.edui-dialog-image .edui-image-searchBar .edui-image-searchTxt{display: inline-block !important;*display: inline !important;*zoom:1;width:400px; border: 1px solid #c5d2ff; height: 20px; line-height: 18px; font-size: 14px; padding: 3px; margin: 0;outline:0;}
|
||||
.edui-dialog-image .edui-image-searchBar .edui-image-searchAdd{display: inline-block !important;*display: inline !important;*zoom:1;
|
||||
width:60px; text-align:center;height: 25px;text-align: center;line-height: 25px;
|
||||
background-color: #ffffff;padding: 0; border: 1px solid #ababab;margin-left: 20px;cursor: pointer;
|
||||
}
|
||||
.edui-dialog-image .edui-image-searchBar .edui-image-searchAdd.hover{
|
||||
background-color: #d5e1f2;
|
||||
padding: 0;
|
||||
border: 1px solid #a3bde3;
|
||||
}
|
||||
.edui-dialog-image .edui-image-searchRes{height:280px;overflow:auto;}
|
||||
|
||||
|
||||
/*common*/
|
||||
.edui-dialog-image .edui-image-item{position:relative;float:left;width:120px;height:120px;border: 1px solid #CCC;cursor: default;margin: 5px 0 0 5px;}
|
||||
.edui-dialog-image .edui-image-item .edui-image-pic{position: absolute;left:-9999px;}
|
||||
.edui-dialog-image .edui-image-item .edui-image-close{position:absolute;right:0;background: url('images/close.png');width:17px;height:17px;cursor:pointer;z-index:1}
|
||||
.edui-dialog-image .edui-image-item.hover .edui-image-close{display: block;}
|
||||
@@ -0,0 +1,445 @@
|
||||
(function () {
|
||||
|
||||
var utils = UM.utils,
|
||||
browser = UM.browser,
|
||||
Base = {
|
||||
checkURL: function (url) {
|
||||
if(!url) return false;
|
||||
url = utils.trim(url);
|
||||
if (url.length <= 0) {
|
||||
return false;
|
||||
}
|
||||
if (url.search(/http:\/\/|https:\/\//) !== 0) {
|
||||
url += 'http://';
|
||||
}
|
||||
|
||||
url=url.replace(/\?[\s\S]*$/,"");
|
||||
|
||||
if (!/(.gif|.jpg|.jpeg|.png)$/i.test(url)) {
|
||||
return false;
|
||||
}
|
||||
return url;
|
||||
},
|
||||
getAllPic: function (sel, $w, editor) {
|
||||
var me = this,
|
||||
arr = [],
|
||||
$imgs = $(sel, $w);
|
||||
|
||||
$.each($imgs, function (index, node) {
|
||||
$(node).removeAttr("width").removeAttr("height");
|
||||
|
||||
// if (node.width > editor.options.initialFrameWidth) {
|
||||
// me.scale(node, editor.options.initialFrameWidth -
|
||||
// parseInt($(editor.body).css("padding-left")) -
|
||||
// parseInt($(editor.body).css("padding-right")));
|
||||
// }
|
||||
|
||||
return arr.push({
|
||||
_src: node.src,
|
||||
src: node.src
|
||||
});
|
||||
});
|
||||
|
||||
return arr;
|
||||
},
|
||||
scale: function (img, max, oWidth, oHeight) {
|
||||
var width = 0, height = 0, percent, ow = img.width || oWidth, oh = img.height || oHeight;
|
||||
if (ow > max || oh > max) {
|
||||
if (ow >= oh) {
|
||||
if (width = ow - max) {
|
||||
percent = (width / ow).toFixed(2);
|
||||
img.height = oh - oh * percent;
|
||||
img.width = max;
|
||||
}
|
||||
} else {
|
||||
if (height = oh - max) {
|
||||
percent = (height / oh).toFixed(2);
|
||||
img.width = ow - ow * percent;
|
||||
img.height = max;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
close: function ($img) {
|
||||
|
||||
$img.css({
|
||||
top: ($img.parent().height() - $img.height()) / 2,
|
||||
left: ($img.parent().width()-$img.width())/2
|
||||
}).prev().on("click",function () {
|
||||
|
||||
if ( $(this).parent().remove().hasClass("edui-image-upload-item") ) {
|
||||
//显示图片计数-1
|
||||
Upload.showCount--;
|
||||
Upload.updateView();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return this;
|
||||
},
|
||||
createImgBase64: function (img, file, $w) {
|
||||
if (browser.webkit) {
|
||||
//Chrome8+
|
||||
img.src = window.webkitURL.createObjectURL(file);
|
||||
} else if (browser.gecko) {
|
||||
//FF4+
|
||||
img.src = window.URL.createObjectURL(file);
|
||||
} else {
|
||||
//实例化file reader对象
|
||||
var reader = new FileReader();
|
||||
reader.onload = function (e) {
|
||||
img.src = this.result;
|
||||
$w.append(img);
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
},
|
||||
callback: function (editor, $w, url, state) {
|
||||
|
||||
if (state == "SUCCESS") {
|
||||
//显示图片计数+1
|
||||
Upload.showCount++;
|
||||
var $img = $("<img src='" + editor.options.imagePath + url + "' class='edui-image-pic' />"),
|
||||
$item = $("<div class='edui-image-item edui-image-upload-item'><div class='edui-image-close'></div></div>").append($img);
|
||||
|
||||
if ($(".edui-image-upload2", $w).length < 1) {
|
||||
$(".edui-image-content", $w).append($item);
|
||||
|
||||
Upload.render(".edui-image-content", 2)
|
||||
.config(".edui-image-upload2");
|
||||
} else {
|
||||
$(".edui-image-upload2", $w).before($item).show();
|
||||
}
|
||||
|
||||
$img.on("load", function () {
|
||||
Base.scale(this, 120);
|
||||
Base.close($(this));
|
||||
$(".edui-image-content", $w).focus();
|
||||
});
|
||||
|
||||
} else {
|
||||
currentDialog.showTip( state );
|
||||
window.setTimeout( function () {
|
||||
|
||||
currentDialog.hideTip();
|
||||
|
||||
}, 3000 );
|
||||
}
|
||||
|
||||
Upload.toggleMask();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* 本地上传
|
||||
* */
|
||||
var Upload = {
|
||||
showCount: 0,
|
||||
uploadTpl: '<div class="edui-image-upload%%">' +
|
||||
'<span class="edui-image-icon"></span>' +
|
||||
'<form class="edui-image-form" method="post" enctype="multipart/form-data" target="up">' +
|
||||
'<input style=\"filter: alpha(opacity=0);\" class="edui-image-file" type="file" hidefocus name="upfile" accept="image/gif,image/jpeg,image/png,image/jpg,image/bmp"/>' +
|
||||
'</form>' +
|
||||
|
||||
'</div>',
|
||||
init: function (editor, $w) {
|
||||
var me = this;
|
||||
|
||||
me.editor = editor;
|
||||
me.dialog = $w;
|
||||
me.render(".edui-image-local", 1);
|
||||
me.config(".edui-image-upload1");
|
||||
me.submit();
|
||||
me.drag();
|
||||
|
||||
$(".edui-image-upload1").hover(function () {
|
||||
$(".edui-image-icon", this).toggleClass("hover");
|
||||
});
|
||||
|
||||
if (!(UM.browser.ie && UM.browser.version <= 9)) {
|
||||
$(".edui-image-dragTip", me.dialog).css("display", "block");
|
||||
}
|
||||
|
||||
|
||||
return me;
|
||||
},
|
||||
render: function (sel, t) {
|
||||
var me = this;
|
||||
|
||||
$(sel, me.dialog).append($(me.uploadTpl.replace(/%%/g, t)));
|
||||
|
||||
return me;
|
||||
},
|
||||
config: function (sel) {
|
||||
var me = this,
|
||||
url=me.editor.options.imageUrl;
|
||||
|
||||
url=url + (url.indexOf("?") == -1 ? "?" : "&") + "editorid="+me.editor.id;//初始form提交地址;
|
||||
|
||||
$("form", $(sel, me.dialog)).attr("action", url);
|
||||
|
||||
return me;
|
||||
},
|
||||
uploadComplete: function(r){
|
||||
var me = this;
|
||||
try{
|
||||
var json = eval('('+r+')');
|
||||
Base.callback(me.editor, me.dialog, json.url, json.state);
|
||||
}catch (e){
|
||||
var lang = me.editor.getLang('image');
|
||||
Base.callback(me.editor, me.dialog, '', (lang && lang.uploadError) || 'Error!');
|
||||
}
|
||||
},
|
||||
submit: function (callback) {
|
||||
|
||||
var me = this,
|
||||
input = $( '<input style="filter: alpha(opacity=0);" class="edui-image-file" type="file" hidefocus="" name="upfile" accept="image/gif,image/jpeg,image/png,image/jpg,image/bmp">'),
|
||||
input = input[0];
|
||||
|
||||
$(me.dialog).delegate( ".edui-image-file", "change", function ( e ) {
|
||||
|
||||
if ( !this.parentNode ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$('<iframe name="up" style="display: none"></iframe>').insertBefore(me.dialog).on('load', function(){
|
||||
var r = this.contentWindow.document.body.innerHTML;
|
||||
if(r == '')return;
|
||||
me.uploadComplete(r);
|
||||
$(this).unbind('load');
|
||||
$(this).remove();
|
||||
|
||||
});
|
||||
|
||||
$(this).parent()[0].submit();
|
||||
Upload.updateInput( input );
|
||||
me.toggleMask("Loading....");
|
||||
callback && callback();
|
||||
|
||||
});
|
||||
|
||||
return me;
|
||||
},
|
||||
//更新input
|
||||
updateInput: function ( inputField ) {
|
||||
|
||||
$( ".edui-image-file", this.dialog ).each( function ( index, ele ) {
|
||||
|
||||
ele.parentNode.replaceChild( inputField.cloneNode( true ), ele );
|
||||
|
||||
} );
|
||||
|
||||
},
|
||||
//更新上传框
|
||||
updateView: function () {
|
||||
|
||||
if ( Upload.showCount !== 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$(".edui-image-upload2", this.dialog).hide();
|
||||
$(".edui-image-dragTip", this.dialog).show();
|
||||
$(".edui-image-upload1", this.dialog).show();
|
||||
|
||||
},
|
||||
drag: function () {
|
||||
var me = this;
|
||||
//做拽上传的支持
|
||||
if (!UM.browser.ie9below) {
|
||||
me.dialog.find('.edui-image-content').on('drop',function (e) {
|
||||
|
||||
//获取文件列表
|
||||
var fileList = e.originalEvent.dataTransfer.files;
|
||||
var img = document.createElement('img');
|
||||
var hasImg = false;
|
||||
$.each(fileList, function (i, f) {
|
||||
if (/^image/.test(f.type)) {
|
||||
//创建图片的base64
|
||||
Base.createImgBase64(img, f, me.dialog);
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("post", me.editor.getOpt('imageUrl') + "?type=ajax", true);
|
||||
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
|
||||
|
||||
//模拟数据
|
||||
var fd = new FormData();
|
||||
fd.append(me.editor.getOpt('imageFieldName'), f);
|
||||
|
||||
xhr.send(fd);
|
||||
xhr.addEventListener('load', function (e) {
|
||||
var r = e.target.response, json;
|
||||
me.uploadComplete(r);
|
||||
if (i == fileList.length - 1) {
|
||||
$(img).remove()
|
||||
}
|
||||
});
|
||||
hasImg = true;
|
||||
}
|
||||
});
|
||||
if (hasImg) {
|
||||
e.preventDefault();
|
||||
me.toggleMask("Loading....");
|
||||
}
|
||||
|
||||
}).on('dragover', function (e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
},
|
||||
toggleMask: function (html) {
|
||||
var me = this;
|
||||
|
||||
var $mask = $(".edui-image-mask", me.dialog);
|
||||
if (html) {
|
||||
if (!(UM.browser.ie && UM.browser.version <= 9)) {
|
||||
$(".edui-image-dragTip", me.dialog).css( "display", "none" );
|
||||
}
|
||||
$(".edui-image-upload1", me.dialog).css( "display", "none" );
|
||||
$mask.addClass("edui-active").html(html);
|
||||
} else {
|
||||
|
||||
$mask.removeClass("edui-active").html();
|
||||
|
||||
if ( Upload.showCount > 0 ) {
|
||||
return me;
|
||||
}
|
||||
|
||||
if (!(UM.browser.ie && UM.browser.version <= 9) ){
|
||||
$(".edui-image-dragTip", me.dialog).css("display", "block");
|
||||
}
|
||||
$(".edui-image-upload1", me.dialog).css( "display", "block" );
|
||||
}
|
||||
|
||||
return me;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* 网络图片
|
||||
* */
|
||||
var NetWork = {
|
||||
init: function (editor, $w) {
|
||||
var me = this;
|
||||
|
||||
me.editor = editor;
|
||||
me.dialog = $w;
|
||||
|
||||
me.initEvt();
|
||||
},
|
||||
initEvt: function () {
|
||||
var me = this,
|
||||
url,
|
||||
$ele = $(".edui-image-searchTxt", me.dialog);
|
||||
|
||||
$(".edui-image-searchAdd", me.dialog).on("click", function () {
|
||||
url = Base.checkURL($ele.val());
|
||||
|
||||
if (url) {
|
||||
|
||||
$("<img src='" + url + "' class='edui-image-pic' />").on("load", function () {
|
||||
|
||||
|
||||
|
||||
var $item = $("<div class='edui-image-item'><div class='edui-image-close'></div></div>").append(this);
|
||||
|
||||
$(".edui-image-searchRes", me.dialog).append($item);
|
||||
|
||||
Base.scale(this, 120);
|
||||
|
||||
$item.width($(this).width());
|
||||
|
||||
Base.close($(this));
|
||||
|
||||
$ele.val("");
|
||||
});
|
||||
}
|
||||
})
|
||||
.hover(function () {
|
||||
$(this).toggleClass("hover");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var $tab = null,
|
||||
currentDialog = null;
|
||||
|
||||
UM.registerWidget('image', {
|
||||
tpl: "<link rel=\"stylesheet\" type=\"text/css\" href=\"<%=image_url%>image.css\">" +
|
||||
"<div class=\"edui-image-wrapper\">" +
|
||||
"<ul class=\"edui-tab-nav\">" +
|
||||
"<li class=\"edui-tab-item edui-active\"><a data-context=\".edui-image-local\" class=\"edui-tab-text\"><%=lang_tab_local%></a></li>" +
|
||||
"<li class=\"edui-tab-item\"><a data-context=\".edui-image-JimgSearch\" class=\"edui-tab-text\"><%=lang_tab_imgSearch%></a></li>" +
|
||||
"</ul>" +
|
||||
"<div class=\"edui-tab-content\">" +
|
||||
"<div class=\"edui-image-local edui-tab-pane edui-active\">" +
|
||||
"<div class=\"edui-image-content\"></div>" +
|
||||
"<div class=\"edui-image-mask\"></div>" +
|
||||
"<div class=\"edui-image-dragTip\"><%=lang_input_dragTip%></div>" +
|
||||
"</div>" +
|
||||
"<div class=\"edui-image-JimgSearch edui-tab-pane\">" +
|
||||
"<div class=\"edui-image-searchBar\">" +
|
||||
"<table><tr><td><input class=\"edui-image-searchTxt\" type=\"text\"></td>" +
|
||||
"<td><div class=\"edui-image-searchAdd\"><%=lang_btn_add%></div></td></tr></table>" +
|
||||
"</div>" +
|
||||
"<div class=\"edui-image-searchRes\"></div>" +
|
||||
"</div>" +
|
||||
"</div>" +
|
||||
"</div>",
|
||||
initContent: function (editor, $dialog) {
|
||||
var lang = editor.getLang('image')["static"],
|
||||
opt = $.extend({}, lang, {
|
||||
image_url: UMEDITOR_CONFIG.UMEDITOR_HOME_URL + 'dialogs/image/'
|
||||
});
|
||||
|
||||
Upload.showCount = 0;
|
||||
|
||||
if (lang) {
|
||||
var html = $.parseTmpl(this.tpl, opt);
|
||||
}
|
||||
|
||||
currentDialog = $dialog.edui();
|
||||
|
||||
this.root().html(html);
|
||||
|
||||
},
|
||||
initEvent: function (editor, $w) {
|
||||
$tab = $.eduitab({selector: ".edui-image-wrapper"})
|
||||
.edui().on("beforeshow", function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
Upload.init(editor, $w);
|
||||
|
||||
NetWork.init(editor, $w);
|
||||
},
|
||||
buttons: {
|
||||
'ok': {
|
||||
exec: function (editor, $w) {
|
||||
var sel = "",
|
||||
index = $tab.activate();
|
||||
|
||||
if (index == 0) {
|
||||
sel = ".edui-image-content .edui-image-pic";
|
||||
} else if (index == 1) {
|
||||
sel = ".edui-image-searchRes .edui-image-pic";
|
||||
}
|
||||
|
||||
var list = Base.getAllPic(sel, $w, editor);
|
||||
|
||||
if (index != -1) {
|
||||
editor.execCommand('insertimage', list);
|
||||
}
|
||||
}
|
||||
},
|
||||
'cancel': {}
|
||||
},
|
||||
width: 700,
|
||||
height: 408
|
||||
}, function (editor, $w, url, state) {
|
||||
Base.callback(editor, $w, url, state)
|
||||
})
|
||||
})();
|
||||
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 848 B |
|
After Width: | Height: | Size: 1.9 KiB |
@@ -0,0 +1,73 @@
|
||||
(function(){
|
||||
var utils = UM.utils;
|
||||
function hrefStartWith(href, arr) {
|
||||
href = href.replace(/^\s+|\s+$/g, '');
|
||||
for (var i = 0, ai; ai = arr[i++];) {
|
||||
if (href.indexOf(ai) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
UM.registerWidget('link', {
|
||||
tpl: "<style type=\"text/css\">" +
|
||||
".edui-dialog-link .edui-link-table{font-size: 12px;margin: 10px;line-height: 30px}" +
|
||||
".edui-dialog-link .edui-link-txt{width:300px;height:21px;line-height:21px;border:1px solid #d7d7d7;}" +
|
||||
"</style>" +
|
||||
"<table class=\"edui-link-table\">" +
|
||||
"<tr>" +
|
||||
"<td><label for=\"href\"><%=lang_input_url%></label></td>" +
|
||||
"<td><input class=\"edui-link-txt\" id=\"edui-link-Jhref\" type=\"text\" /></td>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
"<td><label for=\"title\"><%=lang_input_title%></label></td>" +
|
||||
"<td><input class=\"edui-link-txt\" id=\"edui-link-Jtitle\" type=\"text\"/></td>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
"<td colspan=\"2\">" +
|
||||
"<label for=\"target\"><%=lang_input_target%></label>" +
|
||||
"<input id=\"edui-link-Jtarget\" type=\"checkbox\"/>" +
|
||||
"</td>" +
|
||||
"</tr>" +
|
||||
// "<tr>" +
|
||||
// "<td colspan=\"2\" id=\"edui-link-Jmsg\"></td>" +
|
||||
// "</tr>" +
|
||||
"</table>",
|
||||
initContent: function (editor) {
|
||||
var lang = editor.getLang('link');
|
||||
if (lang) {
|
||||
var html = $.parseTmpl(this.tpl, lang.static);
|
||||
}
|
||||
this.root().html(html);
|
||||
},
|
||||
initEvent: function (editor, $w) {
|
||||
var link = editor.queryCommandValue('link');
|
||||
if(link){
|
||||
$('#edui-link-Jhref',$w).val(utils.html($(link).attr('href')));
|
||||
$('#edui-link-Jtitle',$w).val($(link).attr('title'));
|
||||
$(link).attr('target') == '_blank' && $('#edui-link-Jtarget').attr('checked',true)
|
||||
}
|
||||
$('#edui-link-Jhref',$w).focus();
|
||||
},
|
||||
buttons: {
|
||||
'ok': {
|
||||
exec: function (editor, $w) {
|
||||
var href = $('#edui-link-Jhref').val().replace(/^\s+|\s+$/g, '');
|
||||
|
||||
if (href) {
|
||||
editor.execCommand('link', {
|
||||
'href': href,
|
||||
'target': $("#edui-link-Jtarget:checked").length ? "_blank" : '_self',
|
||||
'title': $("#edui-link-Jtitle").val().replace(/^\s+|\s+$/g, ''),
|
||||
'_href': href
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
'cancel':{}
|
||||
},
|
||||
width: 400
|
||||
})
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="keywords" content="百度地图,百度地图API,百度地图自定义工具,百度地图所见即所得工具"/>
|
||||
<meta name="description" content="百度地图API自定义地图,帮助用户在可视化操作下生成百度地图"/>
|
||||
<title>百度地图API自定义地图</title>
|
||||
<!--引用百度地图API-->
|
||||
<style type="text/css">
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript" src="http://api.map.baidu.com/api?key=&v=2.0&ak=6b6c1a67eaa7db1ca6d6da28e590e343&services=true"></script>
|
||||
</head>
|
||||
|
||||
<body onload="initMap();">
|
||||
<!--百度地图容器-->
|
||||
<div style="width:697px;height:550px;border:#ccc solid 1px;" id="dituContent"></div>
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
function getParam(name) {
|
||||
return location.href.match(new RegExp('[?#&]' + name + '=([^?#&]+)', 'i')) ? RegExp.$1 : '';
|
||||
}
|
||||
var map, marker;
|
||||
var centerParam = getParam('center');
|
||||
var zoomParam = getParam('zoom');
|
||||
var widthParam = getParam('width');
|
||||
var heightParam = getParam('height');
|
||||
var markersParam = getParam('markers');
|
||||
var markerStylesParam = getParam('markerStyles');
|
||||
var iframe = getSelfIframe();
|
||||
var UM = parent.UM;
|
||||
var editor = getEditor();
|
||||
|
||||
//创建和初始化地图函数:
|
||||
function initMap() {
|
||||
// [FF]切换模式后报错
|
||||
if (!window.BMap) {
|
||||
return;
|
||||
}
|
||||
var dituContent = document.getElementById('dituContent');
|
||||
dituContent.style.width = widthParam + 'px';
|
||||
dituContent.style.height = heightParam + 'px';
|
||||
|
||||
createMap();//创建地图
|
||||
setMapEvent();//设置地图事件
|
||||
addMapControl();//向地图添加控件
|
||||
|
||||
// 创建标注
|
||||
var markersArr = markersParam.split(',');
|
||||
var point = new BMap.Point(markersArr[0], markersArr[1]);
|
||||
marker = new BMap.Marker(point);
|
||||
marker.enableDragging();
|
||||
map.addOverlay(marker); // 将标注添加到地图中
|
||||
|
||||
if(iframe && UM && editor) { //在编辑状态下
|
||||
setMapListener();//地图改变修改外层的iframe标签src属性
|
||||
} else {
|
||||
document.focus();
|
||||
}
|
||||
}
|
||||
|
||||
//创建地图函数:
|
||||
function createMap() {
|
||||
map = new BMap.Map("dituContent");//在百度地图容器中创建一个地图
|
||||
var centerArr = centerParam.split(',');
|
||||
var point = new BMap.Point(parseFloat(centerArr[0]), parseFloat(centerArr[1]));//定义一个中心点坐标
|
||||
map.centerAndZoom(point, parseInt(zoomParam));//设定地图的中心点和坐标并将地图显示在地图容器中
|
||||
}
|
||||
|
||||
//地图事件设置函数:
|
||||
function setMapEvent() {
|
||||
map.enableDragging();//启用地图拖拽事件,默认启用(可不写)
|
||||
map.enableScrollWheelZoom();//启用地图滚轮放大缩小
|
||||
map.enableDoubleClickZoom();//启用鼠标双击放大,默认启用(可不写)
|
||||
map.enableKeyboard();//启用键盘上下左右键移动地图
|
||||
}
|
||||
|
||||
//地图控件添加函数:
|
||||
function addMapControl() {
|
||||
//向地图中添加缩放控件
|
||||
var ctrl_nav = new BMap.NavigationControl({anchor: BMAP_ANCHOR_TOP_LEFT, type: BMAP_NAVIGATION_CONTROL_LARGE});
|
||||
map.addControl(ctrl_nav);
|
||||
//向地图中添加缩略图控件
|
||||
var ctrl_ove = new BMap.OverviewMapControl({anchor: BMAP_ANCHOR_BOTTOM_RIGHT, isOpen: 1});
|
||||
map.addControl(ctrl_ove);
|
||||
//向地图中添加比例尺控件
|
||||
var ctrl_sca = new BMap.ScaleControl({anchor: BMAP_ANCHOR_BOTTOM_LEFT});
|
||||
map.addControl(ctrl_sca);
|
||||
}
|
||||
|
||||
function setMapListener() {
|
||||
var timer;
|
||||
|
||||
map.addEventListener('moveend', mapListenerHandler);
|
||||
map.addEventListener('zoomend', mapListenerHandler);
|
||||
marker.addEventListener('dragend', mapListenerHandler);
|
||||
|
||||
function mapListenerHandler() {
|
||||
var zoom = map.getZoom(),
|
||||
center = map.getCenter(),
|
||||
marker = window.marker.P;
|
||||
|
||||
iframe.src = iframe.src.
|
||||
replace(new RegExp('([?#&])center=([^?#&]+)', 'i'), '$1center=' + center.lng + ',' + center.lat).
|
||||
replace(new RegExp('([?#&])markers=([^?#&]+)', 'i'), '$1markers=' + marker.lng + ',' + marker.lat).
|
||||
replace(new RegExp('([?#&])zoom=([^?#&]+)', 'i'), '$1zoom=' + zoom);
|
||||
editor.fireEvent('saveScene');
|
||||
saveScene(editor);
|
||||
}
|
||||
|
||||
function saveScene(){
|
||||
if(!timer) {
|
||||
timer = setTimeout(function(){
|
||||
editor.fireEvent('savescene');
|
||||
editor.fireEvent('contentchange');
|
||||
timer = null;
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getSelfIframe(){
|
||||
var iframes = parent.document.getElementsByTagName('iframe');
|
||||
for (var key in iframes) {
|
||||
if (iframes[key].contentWindow == window) {
|
||||
return iframes[key];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function getEditor(){
|
||||
var parentNode = iframe.parentNode;
|
||||
while (parentNode && parentNode.tagName && parentNode.tagName.toLowerCase() != 'body') {
|
||||
if (parentNode.className && parentNode.className.indexOf('edui-body-container')!=-1) {
|
||||
return UM.getEditor(parentNode.id);
|
||||
}
|
||||
parentNode = parentNode.parentNode;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
@@ -0,0 +1,263 @@
|
||||
(function () {
|
||||
|
||||
var widgetName = 'map';
|
||||
|
||||
UM.registerWidget(widgetName, {
|
||||
|
||||
tpl: "<style type=\"text/css\">" +
|
||||
".edui-dialog-map .edui-map-content{width:530px; height: 350px;margin: 10px auto;}" +
|
||||
".edui-dialog-map .edui-map-content table{width: 100%}" +
|
||||
".edui-dialog-map .edui-map-content table td{vertical-align: middle;}" +
|
||||
".edui-dialog-map .edui-map-button { border: 1px solid #ccc; float: left; cursor: default; height: 23px; width: 70px; cursor: pointer; margin: 0; font-size: 12px; line-height: 24px; text-align: center; }" +
|
||||
".edui-dialog-map .edui-map-button:hover {background:#eee;}" +
|
||||
".edui-dialog-map .edui-map-city,.edui-dialog-map .edui-map-address{height:21px;background: #FFF;border:1px solid #d7d7d7; line-height: 21px;}" +
|
||||
".edui-dialog-map .edui-map-city{width:90px}" +
|
||||
".edui-dialog-map .edui-map-address{width:150px}" +
|
||||
".edui-dialog-map .edui-map-dynamic-label span{vertical-align:middle;margin: 3px 0px 3px 3px;}" +
|
||||
".edui-dialog-map .edui-map-dynamic-label input{vertical-align:middle;margin: 3px;}" +
|
||||
"</style>" +
|
||||
"<div class=\"edui-map-content\">" +
|
||||
"<table>" +
|
||||
"<tr>" +
|
||||
"<td><%=lang_city%>:</td>" +
|
||||
"<td><input class=\"edui-map-city\" type=\"text\" value=\"<%=city.value%>\"/></td>" +
|
||||
"<td><%=lang_address%>:</td>" +
|
||||
"<td><input class=\"edui-map-address\" type=\"text\" value=\"\" /></td>" +
|
||||
"<td><a class=\"edui-map-button\"><%=lang_search%></a></td>" +
|
||||
"<td><label class=\"edui-map-dynamic-label\"><input class=\"edui-map-dynamic\" type=\"checkbox\" name=\"edui-map-dynamic\" /><span><%=lang_dynamicmap%></span></label></td>"+
|
||||
"</tr>" +
|
||||
"</table>" +
|
||||
"<div style=\"width:100%;height:340px;margin:5px auto;border:1px solid gray\" class=\"edui-map-container\"></div>" +
|
||||
"</div>" +
|
||||
"<script class=\"edui-tpl-container\" type=\"text/plain\">" +
|
||||
"<!DOCTYPE html>" +
|
||||
"<html>" +
|
||||
"<head>" +
|
||||
"<title></title>" +
|
||||
"</head>" +
|
||||
"<body>" +
|
||||
"<scr_ipt>" +
|
||||
"window.onload = function(){" +
|
||||
"var scripts = document.scripts || document.getElementsByTagName(\"script\")," +
|
||||
"src = [];" +
|
||||
"for( var i = 1, len = scripts.length; i<len; i++ ) {" +
|
||||
"src.push( scripts[i].src );" +
|
||||
"}" +
|
||||
"parent.UM.getEditor(<<id>>).getWidgetData(\'map\').requestMapApi( src );" +
|
||||
"};" +
|
||||
"function mapReadyStateChange ( state ) { " +
|
||||
" if ( state === 'complete' || state === 'loaded' ) {" +
|
||||
" document.close(); " +
|
||||
" } }" +
|
||||
"</scr_ipt>" +
|
||||
"<scr_ipt onreadystatechange='mapReadyStateChange(this.readyState);' onload='mapReadyStateChange(\"loaded\");' src=\"http://api.map.baidu.com/api?v=2.0&ak=6b6c1a67eaa7db1ca6d6da28e590e343&services=true\"></scr_ipt>" +
|
||||
"</body>" +
|
||||
"</html>" +
|
||||
"</script>",
|
||||
initContent: function (editor, $widget) {
|
||||
|
||||
var me = this,
|
||||
lang = editor.getLang(widgetName),
|
||||
theme_url = editor.options.themePath + editor.options.theme;
|
||||
|
||||
if( me.inited ) {
|
||||
me.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
||||
me.inited = true;
|
||||
|
||||
me.lang = lang;
|
||||
me.editor = editor;
|
||||
|
||||
me.root().html($.parseTmpl(me.tpl, $.extend({}, lang['static'], {
|
||||
'theme_url': theme_url
|
||||
})));
|
||||
|
||||
me.initRequestApi();
|
||||
|
||||
},
|
||||
/**
|
||||
* 初始化请求API
|
||||
*/
|
||||
initRequestApi: function () {
|
||||
|
||||
var $ifr = null;
|
||||
|
||||
//已经初始化过, 不用再次初始化
|
||||
if (window.BMap && window.BMap.Map) {
|
||||
this.initBaiduMap();
|
||||
} else {
|
||||
|
||||
$ifr = $('<iframe style="display: none;"></iframe>');
|
||||
$ifr.appendTo( this.root() );
|
||||
|
||||
$ifr = $ifr[ 0 ].contentWindow.document;
|
||||
|
||||
$ifr.open();
|
||||
$ifr.write( this.root().find(".edui-tpl-container").html().replace( /scr_ipt/g, 'script').replace('<<id>>',"'" + this.editor.id + "'") );
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
requestMapApi: function (src) {
|
||||
|
||||
var me = this;
|
||||
|
||||
if (src.length) {
|
||||
|
||||
var _src = src[0];
|
||||
|
||||
src = src.slice(1);
|
||||
|
||||
if (_src) {
|
||||
$.getScript(_src, function () {
|
||||
me.requestMapApi(src);
|
||||
});
|
||||
} else {
|
||||
me.requestMapApi(src);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
me.initBaiduMap();
|
||||
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
initBaiduMap: function () {
|
||||
|
||||
var $root = this.root(),
|
||||
map = new BMap.Map($root.find(".edui-map-container")[0]),
|
||||
me = this,
|
||||
marker,
|
||||
point,
|
||||
imgcss,
|
||||
img = $(me.editor.selection.getRange().getClosedNode());
|
||||
|
||||
map.enableInertialDragging();
|
||||
map.enableScrollWheelZoom();
|
||||
map.enableContinuousZoom();
|
||||
|
||||
if (img.length && /api[.]map[.]baidu[.]com/ig.test(img.attr("src"))) {
|
||||
var url = img.attr("src"),
|
||||
centerPos = me.getPars(url, "center").split(","),
|
||||
markerPos = me.getPars(url, "markers").split(",");
|
||||
point = new BMap.Point(Number(centerPos[0]), Number(centerPos[1]));
|
||||
marker = new BMap.Marker(new BMap.Point(Number(markerPos[0]), Number(markerPos[1])));
|
||||
map.addControl(new BMap.NavigationControl());
|
||||
map.centerAndZoom(point, Number(me.getPars(url, "zoom")));
|
||||
imgcss = img.attr('style');
|
||||
} else {
|
||||
point = new BMap.Point(116.404, 39.915); // 创建点坐标
|
||||
marker = new BMap.Marker(point);
|
||||
map.addControl(new BMap.NavigationControl());
|
||||
map.centerAndZoom(point, 10); // 初始化地图,设置中心点坐标和地图级别。
|
||||
}
|
||||
marker.enableDragging();
|
||||
map.addOverlay(marker);
|
||||
|
||||
me.map = map;
|
||||
me.marker = marker;
|
||||
me.imgcss = imgcss;
|
||||
},
|
||||
doSearch: function () {
|
||||
var me = this,
|
||||
city = me.root().find('.edui-map-city').val(),
|
||||
address = me.root().find('.edui-map-address').val();
|
||||
|
||||
if (!city) {
|
||||
alert(me.lang.cityMsg);
|
||||
return;
|
||||
}
|
||||
var search = new BMap.LocalSearch(city, {
|
||||
onSearchComplete: function (results) {
|
||||
if (results && results.getNumPois()) {
|
||||
var points = [];
|
||||
for (var i = 0; i < results.getCurrentNumPois(); i++) {
|
||||
points.push(results.getPoi(i).point);
|
||||
}
|
||||
if (points.length > 1) {
|
||||
me.map.setViewport(points);
|
||||
} else {
|
||||
me.map.centerAndZoom(points[0], 13);
|
||||
}
|
||||
point = me.map.getCenter();
|
||||
me.marker.setPoint(point);
|
||||
} else {
|
||||
alert(me.lang.errorMsg);
|
||||
}
|
||||
}
|
||||
});
|
||||
search.search(address || city);
|
||||
},
|
||||
getPars: function (str, par) {
|
||||
var reg = new RegExp(par + "=((\\d+|[.,])*)", "g");
|
||||
return reg.exec(str)[1];
|
||||
},
|
||||
reset: function(){
|
||||
this.map && this.map.reset();
|
||||
},
|
||||
initEvent: function () {
|
||||
var me = this,
|
||||
$root = me.root();
|
||||
|
||||
$root.find('.edui-map-address').on('keydown', function (evt) {
|
||||
evt = evt || event;
|
||||
if (evt.keyCode == 13) {
|
||||
me.doSearch();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$root.find(".edui-map-button").on('click', function (evt) {
|
||||
me.doSearch();
|
||||
});
|
||||
|
||||
$root.find(".edui-map-address").focus();
|
||||
|
||||
$root.on( "mousewheel DOMMouseScroll", function ( e ) {
|
||||
return false;
|
||||
} );
|
||||
|
||||
},
|
||||
width: 580,
|
||||
height: 408,
|
||||
buttons: {
|
||||
ok: {
|
||||
exec: function (editor) {
|
||||
var widget = editor.getWidgetData(widgetName),
|
||||
center = widget.map.getCenter(),
|
||||
zoom = widget.map.getZoom(),
|
||||
size = widget.map.getSize(),
|
||||
point = widget.marker.P;
|
||||
|
||||
if (widget.root().find(".edui-map-dynamic")[0].checked) {
|
||||
var URL = editor.getOpt('UMEDITOR_HOME_URL'),
|
||||
url = [URL + (/\/$/.test(URL) ? '':'/') + "dialogs/map/map.html" +
|
||||
'#center=' + center.lng + ',' + center.lat,
|
||||
'&zoom=' + zoom,
|
||||
'&width=' + size.width,
|
||||
'&height=' + size.height,
|
||||
'&markers=' + point.lng + ',' + point.lat].join('');
|
||||
editor.execCommand('inserthtml', '<iframe class="ueditor_baidumap" src="' + url + '" frameborder="0" width="' + (size.width+4) + '" height="' + (size.height+4) + '"></iframe>');
|
||||
} else {
|
||||
url = "http://api.map.baidu.com/staticimage?center=" + center.lng + ',' + center.lat +
|
||||
"&zoom=" + zoom + "&width=" + size.width + '&height=' + size.height + "&markers=" + point.lng + ',' + point.lat;
|
||||
editor.execCommand('inserthtml', '<img width="' + size.width + '"height="' + size.height + '" src="' + url + '"' + (widget.imgcss ? ' style="' + widget.imgcss + '"' : '') + '/>', true);
|
||||
}
|
||||
|
||||
widget.reset();
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
exec: function(editor){
|
||||
editor.getWidgetData(widgetName).reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 11 KiB |
@@ -0,0 +1,59 @@
|
||||
@charset "utf-8";
|
||||
.edui-dialog-video .edui-video-wrapper{ width: 570px;_width:575px;margin: 10px auto; zoom:1;position: relative}
|
||||
.edui-dialog-video .edui-video-tabbody{height:335px;}
|
||||
.edui-dialog-video .edui-video-panel { position: absolute;width:100%; height:100%;background: #fff;}
|
||||
.edui-dialog-video .edui-video-panel table td{vertical-align: middle;}
|
||||
.edui-dialog-video #eduiVideoUrl {
|
||||
width: 470px;
|
||||
height: 21px;
|
||||
line-height: 21px;
|
||||
margin: 8px 5px;
|
||||
background: #FFF;
|
||||
border: 1px solid #d7d7d7;
|
||||
}
|
||||
.edui-dialog-video #eduiVideoSearchTxt{margin-left:15px;background: #FFF;width:200px;height:21px;line-height:21px;border: 1px solid #d7d7d7;}
|
||||
.edui-dialog-video #searchList{width: 570px;overflow: auto;zoom:1;height: 270px;}
|
||||
.edui-dialog-video #searchList div{float: left;width: 120px;height: 135px;margin: 5px 15px;}
|
||||
.edui-dialog-video #searchList img{margin: 2px 8px;cursor: pointer;border: 2px solid #fff} /*不用缩略图*/
|
||||
.edui-dialog-video #searchList p{margin-left: 10px;}
|
||||
.edui-dialog-video #eduiVideoType{
|
||||
width: 65px;
|
||||
height: 23px;
|
||||
line-height: 22px;
|
||||
border: 1px solid #d7d7d7;
|
||||
}
|
||||
.edui-dialog-video #eduiVideoSearchBtn,.edui-dialog-video #eduiVideoSearchReset{
|
||||
/*width: 80px;*/
|
||||
height: 25px;
|
||||
line-height: 25px;
|
||||
background: #eee;
|
||||
border: 1px solid #d7d7d7;
|
||||
cursor: pointer;
|
||||
padding: 0 5px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.edui-dialog-video #eduiVideoPreview{width: 420px; margin-left: 10px; _margin-left:5px; height: 280px;background-color: #ddd;float: left}
|
||||
.edui-dialog-video #eduiVideoInfo {width: 120px;float: left;margin-left: 10px;_margin-left:7px;}
|
||||
.edui-dialog-video .edui-video-wrapper fieldset{
|
||||
border: 1px solid #ddd;
|
||||
padding-left: 5px;
|
||||
margin-bottom: 20px;
|
||||
padding-bottom: 5px;
|
||||
width: 115px;
|
||||
}
|
||||
.edui-dialog-video .edui-video-wrapper fieldset legend{font-weight: bold;}
|
||||
.edui-dialog-video .edui-video-wrapper fieldset p{line-height: 30px;}
|
||||
.edui-dialog-video .edui-video-wrapper fieldset input.edui-video-txt{
|
||||
width: 65px;
|
||||
height: 21px;
|
||||
line-height: 21px;
|
||||
margin: 8px 5px;
|
||||
background: #FFF;
|
||||
border: 1px solid #d7d7d7;
|
||||
}
|
||||
.edui-dialog-video .edui-video-wrapper label.edui-video-url{font-weight: bold;margin-left: 5px;color: #06c;}
|
||||
.edui-dialog-video #eduiVideoFloat div{cursor:pointer;opacity: 0.5;filter: alpha(opacity = 50);margin:9px;_margin:5px;width:38px;height:36px;float:left;}
|
||||
.edui-dialog-video #eduiVideoFloat .edui-video-focus{opacity: 1;filter: alpha(opacity = 100)}
|
||||
.edui-dialog-video .edui-video-wrapper span.edui-video-view{display: inline-block;width: 30px;float: right;cursor: pointer;color: blue}
|
||||
@@ -0,0 +1,282 @@
|
||||
|
||||
(function(){
|
||||
var domUtils = UM.dom.domUtils;
|
||||
var widgetName = 'video';
|
||||
|
||||
UM.registerWidget( widgetName,{
|
||||
|
||||
tpl: "<link rel=\"stylesheet\" type=\"text/css\" href=\"<%=video_url%>video.css\" />" +
|
||||
"<div class=\"edui-video-wrapper\">" +
|
||||
"<div id=\"eduiVideoTab\">" +
|
||||
"<div id=\"eduiVideoTabHeads\" class=\"edui-video-tabhead\">" +
|
||||
"<span tabSrc=\"video\" class=\"edui-video-focus\"><%=lang_tab_insertV%></span>" +
|
||||
"</div>" +
|
||||
"<div id=\"eduiVideoTabBodys\" class=\"edui-video-tabbody\">" +
|
||||
"<div id=\"eduiVideoPanel\" class=\"edui-video-panel\">" +
|
||||
"<table><tr><td><label for=\"eduiVideoUrl\" class=\"edui-video-url\"><%=lang_video_url%></label></td><td><input id=\"eduiVideoUrl\" type=\"text\"></td></tr></table>" +
|
||||
"<div id=\"eduiVideoPreview\"></div>" +
|
||||
"<div id=\"eduiVideoInfo\">" +
|
||||
"<fieldset>" +
|
||||
"<legend><%=lang_video_size%></legend>" +
|
||||
"<table>" +
|
||||
"<tr><td><label for=\"eduiVideoWidth\"><%=lang_videoW%></label></td><td><input class=\"edui-video-txt\" id=\"eduiVideoWidth\" type=\"text\"/></td></tr>" +
|
||||
"<tr><td><label for=\"eduiVideoHeight\"><%=lang_videoH%></label></td><td><input class=\"edui-video-txt\" id=\"eduiVideoHeight\" type=\"text\"/></td></tr>" +
|
||||
"</table>" +
|
||||
"</fieldset>" +
|
||||
"<fieldset>" +
|
||||
"<legend><%=lang_alignment%></legend>" +
|
||||
"<div id=\"eduiVideoFloat\"></div>" +
|
||||
"</fieldset>" +
|
||||
"</div>" +
|
||||
"</div>" +
|
||||
"</div>" +
|
||||
"</div>" +
|
||||
"</div>",
|
||||
initContent:function( editor, $widget ){
|
||||
|
||||
var me = this,
|
||||
lang = editor.getLang( widgetName),
|
||||
video_url = UMEDITOR_CONFIG.UMEDITOR_HOME_URL + 'dialogs/video/';
|
||||
|
||||
me.lang = lang;
|
||||
me.editor = editor;
|
||||
me.$widget = $widget;
|
||||
me.root().html( $.parseTmpl( me.tpl, $.extend( { video_url: video_url }, lang['static'] ) ) );
|
||||
|
||||
me.initController( lang );
|
||||
|
||||
},
|
||||
initEvent:function(){
|
||||
|
||||
var me = this,
|
||||
url = $("#eduiVideoUrl", me.$widget)[0];
|
||||
|
||||
if( 'oninput' in url ) {
|
||||
url.oninput = function(){
|
||||
me.createPreviewVideo( this.value );
|
||||
};
|
||||
} else {
|
||||
url.onpropertychange = function () {
|
||||
me.createPreviewVideo( this.value );
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
initController: function( lang ){
|
||||
|
||||
var me = this,
|
||||
img = me.editor.selection.getRange().getClosedNode(),
|
||||
url;
|
||||
|
||||
me.createAlignButton( ["eduiVideoFloat"] );
|
||||
|
||||
//编辑视频时初始化相关信息
|
||||
if(img && img.className == "edui-faked-video"){
|
||||
$("#eduiVideoUrl", me.$widget)[0].value = url = img.getAttribute("_url");
|
||||
$("#eduiVideoWidth", me.$widget)[0].value = img.width;
|
||||
$("#eduiVideoHeight", me.$widget)[0].value = img.height;
|
||||
var align = domUtils.getComputedStyle(img,"float"),
|
||||
parentAlign = domUtils.getComputedStyle(img.parentNode,"text-align");
|
||||
me.updateAlignButton(parentAlign==="center"?"center":align);
|
||||
}
|
||||
me.createPreviewVideo(url);
|
||||
|
||||
},
|
||||
/**
|
||||
* 根据url生成视频预览
|
||||
*/
|
||||
createPreviewVideo: function(url){
|
||||
|
||||
if ( !url )return;
|
||||
|
||||
var me = this,
|
||||
lang = me.lang,
|
||||
conUrl = me.convert_url(url);
|
||||
|
||||
if(!me.endWith(conUrl,[".swf",".flv",".wmv"])){
|
||||
$("#eduiVideoPreview", me.$widget).html( lang.urlError );
|
||||
return;
|
||||
}
|
||||
$("#eduiVideoPreview", me.$widget)[0].innerHTML = '<embed type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"' +
|
||||
' src="' + url + '"' +
|
||||
' width="' + 420 + '"' +
|
||||
' height="' + 280 + '"' +
|
||||
' wmode="transparent" play="true" loop="false" menu="false" allowscriptaccess="never" allowfullscreen="true" ></embed>';
|
||||
|
||||
},
|
||||
/**
|
||||
* 将单个视频信息插入编辑器中
|
||||
*/
|
||||
insertSingle: function(){
|
||||
|
||||
var me = this,
|
||||
width = $("#eduiVideoWidth", me.$widget)[0],
|
||||
height = $("#eduiVideoHeight", me.$widget)[0],
|
||||
url=$('#eduiVideoUrl', me.$widget)[0].value,
|
||||
align = this.findFocus("eduiVideoFloat","name");
|
||||
|
||||
if(!url) return false;
|
||||
if ( !me.checkNum( [width, height] ) ) return false;
|
||||
this.editor.execCommand('insertvideo', {
|
||||
url: me.convert_url(url),
|
||||
width: width.value,
|
||||
height: height.value,
|
||||
align: align
|
||||
});
|
||||
|
||||
},
|
||||
/**
|
||||
* URL转换
|
||||
*/
|
||||
convert_url: function(url){
|
||||
if ( !url ) return '';
|
||||
var matches = url.match(/youtu.be\/(\w+)$/) ||
|
||||
url.match(/youtube\.com\/watch\?v=(\w+)/) ||
|
||||
url.match(/youtube.com\/v\/(\w+)/),
|
||||
youku = url.match(/youku\.com\/v_show\/id_(\w+)/),
|
||||
youkuPlay = /player\.youku\.com/ig.test(url);
|
||||
|
||||
if(youkuPlay){
|
||||
url = url.replace(/\?f=.*/, "");
|
||||
} else if (matches){
|
||||
url = "https://www.youtube.com/v/" + matches[1] + "?version=3&feature=player_embedded";
|
||||
}else if(youku){
|
||||
url = "http://player.youku.com/player.php/sid/"+youku[1]+"/v.swf"
|
||||
} else {
|
||||
url = url.replace(/http:\/\/www\.tudou\.com\/programs\/view\/([\w\-]+)\/?/i, "http://www.tudou.com/v/$1")
|
||||
.replace(/http:\/\/www\.youtube\.com\/watch\?v=([\w\-]+)/i, "http://www.youtube.com/v/$1")
|
||||
.replace(/http:\/\/v\.youku\.com\/v_show\/id_([\w\-=]+)\.html/i, "http://player.youku.com/player.php/sid/$1")
|
||||
.replace(/http:\/\/www\.56\.com\/u\d+\/v_([\w\-]+)\.html/i, "http://player.56.com/v_$1.swf")
|
||||
.replace(/http:\/\/www.56.com\/w\d+\/play_album\-aid\-\d+_vid\-([^.]+)\.html/i, "http://player.56.com/v_$1.swf")
|
||||
.replace(/http:\/\/v\.ku6\.com\/.+\/([^.]+)\.html/i, "http://player.ku6.com/refer/$1/v.swf")
|
||||
.replace(/\?f=.*/, "");
|
||||
}
|
||||
return url;
|
||||
},
|
||||
/**
|
||||
* 检测传入的所有input框中输入的长宽是否是正数
|
||||
*/
|
||||
checkNum: function checkNum( nodes ) {
|
||||
|
||||
var me = this;
|
||||
|
||||
for ( var i = 0, ci; ci = nodes[i++]; ) {
|
||||
var value = ci.value;
|
||||
if ( !me.isNumber( value ) && value) {
|
||||
alert( me.lang.numError );
|
||||
ci.value = "";
|
||||
ci.focus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
/**
|
||||
* 数字判断
|
||||
* @param value
|
||||
*/
|
||||
isNumber: function( value ) {
|
||||
return /(0|^[1-9]\d*$)/.test( value );
|
||||
},
|
||||
updateAlignButton: function( align ) {
|
||||
var aligns = $( "#eduiVideoFloat", this.$widget )[0].children;
|
||||
|
||||
for ( var i = 0, ci; ci = aligns[i++]; ) {
|
||||
if ( ci.getAttribute( "name" ) == align ) {
|
||||
if ( ci.className !="edui-video-focus" ) {
|
||||
ci.className = "edui-video-focus";
|
||||
}
|
||||
} else {
|
||||
if ( ci.className =="edui-video-focus" ) {
|
||||
ci.className = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
/**
|
||||
* 创建图片浮动选择按钮
|
||||
* @param ids
|
||||
*/
|
||||
createAlignButton: function( ids ) {
|
||||
var lang = this.lang,
|
||||
vidoe_home = UMEDITOR_CONFIG.UMEDITOR_HOME_URL + 'dialogs/video/';
|
||||
|
||||
for ( var i = 0, ci; ci = ids[i++]; ) {
|
||||
var floatContainer = $( "#" + ci, this.$widget ) [0],
|
||||
nameMaps = {"none":lang['default'], "left":lang.floatLeft, "right":lang.floatRight};
|
||||
for ( var j in nameMaps ) {
|
||||
var div = document.createElement( "div" );
|
||||
div.setAttribute( "name", j );
|
||||
if ( j == "none" ) div.className="edui-video-focus";
|
||||
div.style.cssText = "background:url("+ vidoe_home +"images/" + j + "_focus.jpg);";
|
||||
div.setAttribute( "title", nameMaps[j] );
|
||||
floatContainer.appendChild( div );
|
||||
}
|
||||
this.switchSelect( ci );
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 选择切换
|
||||
*/
|
||||
switchSelect: function( selectParentId ) {
|
||||
var selects = $( "#" + selectParentId, this.$widget )[0].children;
|
||||
for ( var i = 0, ci; ci = selects[i++]; ) {
|
||||
$(ci).on("click", function () {
|
||||
for ( var j = 0, cj; cj = selects[j++]; ) {
|
||||
cj.className = "";
|
||||
cj.removeAttribute && cj.removeAttribute( "class" );
|
||||
}
|
||||
this.className = "edui-video-focus";
|
||||
} )
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 找到id下具有focus类的节点并返回该节点下的某个属性
|
||||
* @param id
|
||||
* @param returnProperty
|
||||
*/
|
||||
findFocus: function( id, returnProperty ) {
|
||||
var tabs = $( "#" + id , this.$widget)[0].children,
|
||||
property;
|
||||
for ( var i = 0, ci; ci = tabs[i++]; ) {
|
||||
if ( ci.className=="edui-video-focus" ) {
|
||||
property = ci.getAttribute( returnProperty );
|
||||
break;
|
||||
}
|
||||
}
|
||||
return property;
|
||||
},
|
||||
/**
|
||||
* 末尾字符检测
|
||||
*/
|
||||
endWith: function(str,endStrArr){
|
||||
for(var i=0,len = endStrArr.length;i<len;i++){
|
||||
var tmp = endStrArr[i];
|
||||
if(str.length - tmp.length<0) return false;
|
||||
|
||||
if(str.substring(str.length-tmp.length)==tmp){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
width:610,
|
||||
height:498,
|
||||
buttons: {
|
||||
ok: {
|
||||
exec: function( editor, $w ){
|
||||
$("#eduiVideoPreview", $w).html("");
|
||||
editor.getWidgetData(widgetName).insertSingle();
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
exec: function(){
|
||||
//清除视频
|
||||
$("#eduiVideoPreview").html("");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
||||