baidu_umeditor_rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/app/assets/javascripts/umeditor.js +2 -0
- data/baidu_umeditor_rails.gemspec +23 -0
- data/lib/baidu_umeditor_rails/asset_installer.rb +64 -0
- data/lib/baidu_umeditor_rails/asset_manifest.rb +120 -0
- data/lib/baidu_umeditor_rails/engine.rb +20 -0
- data/lib/baidu_umeditor_rails/version.rb +4 -0
- data/lib/baidu_umeditor_rails.rb +3 -0
- data/lib/tasks/baidu_umeditor_rails_tasks.rake +15 -0
- data/vendor/assets/javascripts/umeditor/dialogs/emotion/emotion.css +87 -0
- data/vendor/assets/javascripts/umeditor/dialogs/emotion/emotion.js +272 -0
- data/vendor/assets/javascripts/umeditor/dialogs/emotion/images/0.gif +0 -0
- data/vendor/assets/javascripts/umeditor/dialogs/emotion/images/bface.gif +0 -0
- data/vendor/assets/javascripts/umeditor/dialogs/emotion/images/cface.gif +0 -0
- data/vendor/assets/javascripts/umeditor/dialogs/emotion/images/fface.gif +0 -0
- data/vendor/assets/javascripts/umeditor/dialogs/emotion/images/jxface2.gif +0 -0
- data/vendor/assets/javascripts/umeditor/dialogs/emotion/images/neweditor-tab-bg.png +0 -0
- data/vendor/assets/javascripts/umeditor/dialogs/emotion/images/tface.gif +0 -0
- data/vendor/assets/javascripts/umeditor/dialogs/emotion/images/wface.gif +0 -0
- data/vendor/assets/javascripts/umeditor/dialogs/emotion/images/yface.gif +0 -0
- data/vendor/assets/javascripts/umeditor/dialogs/formula/formula.css +32 -0
- data/vendor/assets/javascripts/umeditor/dialogs/formula/formula.html +212 -0
- data/vendor/assets/javascripts/umeditor/dialogs/formula/formula.js +124 -0
- data/vendor/assets/javascripts/umeditor/dialogs/formula/images/formula.png +0 -0
- data/vendor/assets/javascripts/umeditor/dialogs/image/image.css +42 -0
- data/vendor/assets/javascripts/umeditor/dialogs/image/image.js +445 -0
- data/vendor/assets/javascripts/umeditor/dialogs/image/images/close.png +0 -0
- data/vendor/assets/javascripts/umeditor/dialogs/image/images/upload1.png +0 -0
- data/vendor/assets/javascripts/umeditor/dialogs/image/images/upload2.png +0 -0
- data/vendor/assets/javascripts/umeditor/dialogs/link/link.js +73 -0
- data/vendor/assets/javascripts/umeditor/dialogs/map/map.html +148 -0
- data/vendor/assets/javascripts/umeditor/dialogs/map/map.js +263 -0
- data/vendor/assets/javascripts/umeditor/dialogs/video/images/center_focus.jpg +0 -0
- data/vendor/assets/javascripts/umeditor/dialogs/video/images/left_focus.jpg +0 -0
- data/vendor/assets/javascripts/umeditor/dialogs/video/images/none_focus.jpg +0 -0
- data/vendor/assets/javascripts/umeditor/dialogs/video/images/right_focus.jpg +0 -0
- data/vendor/assets/javascripts/umeditor/dialogs/video/video.css +59 -0
- data/vendor/assets/javascripts/umeditor/dialogs/video/video.js +282 -0
- data/vendor/assets/javascripts/umeditor/index.html +277 -0
- data/vendor/assets/javascripts/umeditor/lang/en/en.js +150 -0
- data/vendor/assets/javascripts/umeditor/lang/en/images/addimage.png +0 -0
- data/vendor/assets/javascripts/umeditor/lang/en/images/alldeletebtnhoverskin.png +0 -0
- data/vendor/assets/javascripts/umeditor/lang/en/images/alldeletebtnupskin.png +0 -0
- data/vendor/assets/javascripts/umeditor/lang/en/images/background.png +0 -0
- data/vendor/assets/javascripts/umeditor/lang/en/images/button.png +0 -0
- data/vendor/assets/javascripts/umeditor/lang/en/images/copy.png +0 -0
- data/vendor/assets/javascripts/umeditor/lang/en/images/deletedisable.png +0 -0
- data/vendor/assets/javascripts/umeditor/lang/en/images/deleteenable.png +0 -0
- data/vendor/assets/javascripts/umeditor/lang/en/images/imglabel.png +0 -0
- data/vendor/assets/javascripts/umeditor/lang/en/images/listbackground.png +0 -0
- data/vendor/assets/javascripts/umeditor/lang/en/images/localimage.png +0 -0
- data/vendor/assets/javascripts/umeditor/lang/en/images/music.png +0 -0
- data/vendor/assets/javascripts/umeditor/lang/en/images/rotateleftdisable.png +0 -0
- data/vendor/assets/javascripts/umeditor/lang/en/images/rotateleftenable.png +0 -0
- data/vendor/assets/javascripts/umeditor/lang/en/images/rotaterightdisable.png +0 -0
- data/vendor/assets/javascripts/umeditor/lang/en/images/rotaterightenable.png +0 -0
- data/vendor/assets/javascripts/umeditor/lang/en/images/upload.png +0 -0
- data/vendor/assets/javascripts/umeditor/lang/zh-cn/images/copy.png +0 -0
- data/vendor/assets/javascripts/umeditor/lang/zh-cn/images/imglabel.png +0 -0
- data/vendor/assets/javascripts/umeditor/lang/zh-cn/images/localimage.png +0 -0
- data/vendor/assets/javascripts/umeditor/lang/zh-cn/images/music.png +0 -0
- data/vendor/assets/javascripts/umeditor/lang/zh-cn/images/upload.png +0 -0
- data/vendor/assets/javascripts/umeditor/lang/zh-cn/zh-cn.js +150 -0
- data/vendor/assets/javascripts/umeditor/themes/default/css/umeditor.css +773 -0
- data/vendor/assets/javascripts/umeditor/themes/default/css/umeditor.min.css +8 -0
- data/vendor/assets/javascripts/umeditor/themes/default/images/caret.png +0 -0
- data/vendor/assets/javascripts/umeditor/themes/default/images/close.png +0 -0
- data/vendor/assets/javascripts/umeditor/themes/default/images/icons.gif +0 -0
- data/vendor/assets/javascripts/umeditor/themes/default/images/icons.png +0 -0
- data/vendor/assets/javascripts/umeditor/themes/default/images/ok.gif +0 -0
- data/vendor/assets/javascripts/umeditor/themes/default/images/pop-bg.png +0 -0
- data/vendor/assets/javascripts/umeditor/themes/default/images/spacer.gif +0 -0
- data/vendor/assets/javascripts/umeditor/themes/default/images/videologo.gif +0 -0
- data/vendor/assets/javascripts/umeditor/third-party/jquery.min.js +6 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/font/Symbola.eot +0 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/font/Symbola.otf +0 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/font/Symbola.svg +5102 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/font/Symbola.ttf +0 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/font/Symbola.woff +0 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/font/stixgeneral-bundle/STIXFontLicense2010.txt +103 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/font/stixgeneral-bundle/stixgeneral-webfont.eot +0 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/font/stixgeneral-bundle/stixgeneral-webfont.svg +3318 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/font/stixgeneral-bundle/stixgeneral-webfont.ttf +0 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/font/stixgeneral-bundle/stixgeneral-webfont.woff +0 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/font/stixgeneral-bundle/stixgeneralbol-webfont.eot +0 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/font/stixgeneral-bundle/stixgeneralbol-webfont.svg +1738 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/font/stixgeneral-bundle/stixgeneralbol-webfont.ttf +0 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/font/stixgeneral-bundle/stixgeneralbol-webfont.woff +0 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/font/stixgeneral-bundle/stixgeneralbolita-webfont.eot +0 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/font/stixgeneral-bundle/stixgeneralbolita-webfont.svg +1137 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/font/stixgeneral-bundle/stixgeneralbolita-webfont.ttf +0 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/font/stixgeneral-bundle/stixgeneralbolita-webfont.woff +0 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/font/stixgeneral-bundle/stixgeneralitalic-webfont.eot +0 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/font/stixgeneral-bundle/stixgeneralitalic-webfont.svg +1089 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/font/stixgeneral-bundle/stixgeneralitalic-webfont.ttf +0 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/font/stixgeneral-bundle/stixgeneralitalic-webfont.woff +0 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/mathquill.css +357 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/mathquill.js +3888 -0
- data/vendor/assets/javascripts/umeditor/third-party/mathquill/mathquill.min.js +2 -0
- data/vendor/assets/javascripts/umeditor/umeditor.config.js +249 -0
- data/vendor/assets/javascripts/umeditor/umeditor.js +10923 -0
- data/vendor/assets/javascripts/umeditor/umeditor.min.js +264 -0
- metadata +179 -0
@@ -0,0 +1,272 @@
|
|
1
|
+
(function(){
|
2
|
+
|
3
|
+
var editor = null;
|
4
|
+
|
5
|
+
UM.registerWidget('emotion',{
|
6
|
+
|
7
|
+
tpl: "<link type=\"text/css\" rel=\"stylesheet\" href=\"<%=emotion_url%>emotion.css\">" +
|
8
|
+
"<div class=\"edui-emotion-tab-Jpanel edui-emotion-wrapper\">" +
|
9
|
+
"<ul class=\"edui-emotion-Jtabnav edui-tab-nav\">" +
|
10
|
+
"<li class=\"edui-tab-item\"><a data-context=\".edui-emotion-Jtab0\" hideFocus=\"true\" class=\"edui-tab-text\"><%=lang_input_choice%></a></li>" +
|
11
|
+
"<li class=\"edui-tab-item\"><a data-context=\".edui-emotion-Jtab1\" class=\"edui-tab-text\"><%=lang_input_Tuzki%></a></li>" +
|
12
|
+
"<li class=\"edui-tab-item\"><a data-context=\".edui-emotion-Jtab2\" hideFocus=\"true\" class=\"edui-tab-text\"><%=lang_input_lvdouwa%></a></li>" +
|
13
|
+
"<li class=\"edui-tab-item\"><a data-context=\".edui-emotion-Jtab3\" hideFocus=\"true\" class=\"edui-tab-text\"><%=lang_input_BOBO%></a></li>" +
|
14
|
+
"<li class=\"edui-tab-item\"><a data-context=\".edui-emotion-Jtab4\" hideFocus=\"true\" class=\"edui-tab-text\"><%=lang_input_babyCat%></a></li>" +
|
15
|
+
"<li class=\"edui-tab-item\"><a data-context=\".edui-emotion-Jtab5\" hideFocus=\"true\" class=\"edui-tab-text\"><%=lang_input_bubble%></a></li>" +
|
16
|
+
"<li class=\"edui-tab-item\"><a data-context=\".edui-emotion-Jtab6\" hideFocus=\"true\" class=\"edui-tab-text\"><%=lang_input_youa%></a></li>" +
|
17
|
+
"<li class=\"edui-emotion-tabs\"></li>" +
|
18
|
+
"</ul>" +
|
19
|
+
"<div class=\"edui-tab-content edui-emotion-JtabBodys\">" +
|
20
|
+
"<div class=\"edui-emotion-Jtab0 edui-tab-pane\"></div>" +
|
21
|
+
"<div class=\"edui-emotion-Jtab1 edui-tab-pane\"></div>" +
|
22
|
+
"<div class=\"edui-emotion-Jtab2 edui-tab-pane\"></div>" +
|
23
|
+
"<div class=\"edui-emotion-Jtab3 edui-tab-pane\"></div>" +
|
24
|
+
"<div class=\"edui-emotion-Jtab4 edui-tab-pane\"></div>" +
|
25
|
+
"<div class=\"edui-emotion-Jtab5 edui-tab-pane\"></div>" +
|
26
|
+
"<div class=\"edui-emotion-Jtab6 edui-tab-pane\"></div>" +
|
27
|
+
"</div>" +
|
28
|
+
"<div class=\"edui-emotion-JtabIconReview edui-emotion-preview-box\">" +
|
29
|
+
"<img src=\"<%=cover_img%>\" class=\'edui-emotion-JfaceReview edui-emotion-preview-img\'/>" +
|
30
|
+
"</div>",
|
31
|
+
|
32
|
+
sourceData: {
|
33
|
+
emotion: {
|
34
|
+
tabNum:7, //切换面板数量
|
35
|
+
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] }, //图片前缀名
|
36
|
+
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/'}, //图片对应文件夹路径
|
37
|
+
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类名
|
38
|
+
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}, //图片偏移
|
39
|
+
SmileyInfor:{
|
40
|
+
'edui-emotion-Jtab0':['Kiss', 'Love', 'Yeah', '啊!', '背扭', '顶', '抖胸', '88', '汗', '瞌睡', '鲁拉', '拍砖', '揉脸', '生日快乐', '大笑', '瀑布汗~', '惊讶', '臭美', '傻笑', '抛媚眼', '发怒', '打酱油', '俯卧撑', '气愤', '?', '吻', '怒', '胜利', 'HI', 'KISS', '不说', '不要', '扯花', '大心', '顶', '大惊', '飞吻', '鬼脸', '害羞', '口水', '狂哭', '来', '发财了', '吃西瓜', '套牢', '害羞', '庆祝', '我来了', '敲打', '晕了', '胜利', '臭美', '被打了', '贪吃', '迎接', '酷', '微笑', '亲吻', '调皮', '惊恐', '耍酷', '发火', '害羞', '汗水', '大哭', '', '加油', '困', '你NB', '晕倒', '开心', '偷笑', '大哭', '滴汗', '叹气', '超赞', '??', '飞吻', '天使', '撒花', '生气', '被砸', '吓傻', '随意吐'],
|
41
|
+
'edui-emotion-Jtab1':['Kiss', 'Love', 'Yeah', '啊!', '背扭', '顶', '抖胸', '88', '汗', '瞌睡', '鲁拉', '拍砖', '揉脸', '生日快乐', '摊手', '睡觉', '瘫坐', '无聊', '星星闪', '旋转', '也不行', '郁闷', '正Music', '抓墙', '撞墙至死', '歪头', '戳眼', '飘过', '互相拍砖', '砍死你', '扔桌子', '少林寺', '什么?', '转头', '我爱牛奶', '我踢', '摇晃', '晕厥', '在笼子里', '震荡'],
|
42
|
+
'edui-emotion-Jtab2':['大笑', '瀑布汗~', '惊讶', '臭美', '傻笑', '抛媚眼', '发怒', '我错了', 'money', '气愤', '挑逗', '吻', '怒', '胜利', '委屈', '受伤', '说啥呢?', '闭嘴', '不', '逗你玩儿', '飞吻', '眩晕', '魔法', '我来了', '睡了', '我打', '闭嘴', '打', '打晕了', '刷牙', '爆揍', '炸弹', '倒立', '刮胡子', '邪恶的笑', '不要不要', '爱恋中', '放大仔细看', '偷窥', '超高兴', '晕', '松口气', '我跑', '享受', '修养', '哭', '汗', '啊~', '热烈欢迎', '打酱油', '俯卧撑', '?'],
|
43
|
+
'edui-emotion-Jtab3':['HI', 'KISS', '不说', '不要', '扯花', '大心', '顶', '大惊', '飞吻', '鬼脸', '害羞', '口水', '狂哭', '来', '泪眼', '流泪', '生气', '吐舌', '喜欢', '旋转', '再见', '抓狂', '汗', '鄙视', '拜', '吐血', '嘘', '打人', '蹦跳', '变脸', '扯肉', '吃To', '吃花', '吹泡泡糖', '大变身', '飞天舞', '回眸', '可怜', '猛抽', '泡泡', '苹果', '亲', '', '骚舞', '烧香', '睡', '套娃娃', '捅捅', '舞倒', '西红柿', '爱慕', '摇', '摇摆', '杂耍', '招财', '被殴', '被球闷', '大惊', '理想', '欧打', '呕吐', '碎', '吐痰'],
|
44
|
+
'edui-emotion-Jtab4':['发财了', '吃西瓜', '套牢', '害羞', '庆祝', '我来了', '敲打', '晕了', '胜利', '臭美', '被打了', '贪吃', '迎接', '酷', '顶', '幸运', '爱心', '躲', '送花', '选择'],
|
45
|
+
'edui-emotion-Jtab5':['微笑', '亲吻', '调皮', '惊讶', '耍酷', '发火', '害羞', '汗水', '大哭', '得意', '鄙视', '困', '夸奖', '晕倒', '疑问', '媒婆', '狂吐', '青蛙', '发愁', '亲吻', '', '爱心', '心碎', '玫瑰', '礼物', '哭', '奸笑', '可爱', '得意', '呲牙', '暴汗', '楚楚可怜', '困', '哭', '生气', '惊讶', '口水', '彩虹', '夜空', '太阳', '钱钱', '灯泡', '咖啡', '蛋糕', '音乐', '爱', '胜利', '赞', '鄙视', 'OK'],
|
46
|
+
'edui-emotion-Jtab6':['男兜', '女兜', '开心', '乖乖', '偷笑', '大笑', '抽泣', '大哭', '无奈', '滴汗', '叹气', '狂晕', '委屈', '超赞', '??', '疑问', '飞吻', '天使', '撒花', '生气', '被砸', '口水', '泪奔', '吓傻', '吐舌头', '点头', '随意吐', '旋转', '困困', '鄙视', '狂顶', '篮球', '再见', '欢迎光临', '恭喜发财', '稍等', '我在线', '恕不议价', '库房有货', '货在路上']
|
47
|
+
}
|
48
|
+
}
|
49
|
+
},
|
50
|
+
initContent:function( _editor, $widget ){
|
51
|
+
|
52
|
+
var me = this,
|
53
|
+
emotion = me.sourceData.emotion,
|
54
|
+
lang = _editor.getLang( 'emotion' )['static'],
|
55
|
+
emotionUrl = UMEDITOR_CONFIG.UMEDITOR_HOME_URL + 'dialogs/emotion/',
|
56
|
+
options = $.extend( {}, lang, {
|
57
|
+
emotion_url: emotionUrl
|
58
|
+
}),
|
59
|
+
$root = me.root();
|
60
|
+
|
61
|
+
if( me.inited ) {
|
62
|
+
me.preventDefault();
|
63
|
+
this.switchToFirst();
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
|
67
|
+
me.inited = true;
|
68
|
+
|
69
|
+
editor = _editor;
|
70
|
+
this.widget = $widget;
|
71
|
+
|
72
|
+
emotion.SmileyPath = _editor.options.emotionLocalization === true ? emotionUrl + 'images/' : "http://img.baidu.com/hi/";
|
73
|
+
emotion.SmileyBox = me.createTabList( emotion.tabNum );
|
74
|
+
emotion.tabExist = me.createArr( emotion.tabNum );
|
75
|
+
|
76
|
+
options['cover_img'] = emotion.SmileyPath + (editor.options.emotionLocalization ? '0.gif' : 'default/0.gif');
|
77
|
+
|
78
|
+
$root.html( $.parseTmpl( me.tpl, options ) );
|
79
|
+
|
80
|
+
me.tabs = $.eduitab({selector:".edui-emotion-tab-Jpanel"});
|
81
|
+
|
82
|
+
//缓存预览对象
|
83
|
+
me.previewBox = $root.find(".edui-emotion-JtabIconReview");
|
84
|
+
me.previewImg = $root.find(".edui-emotion-JfaceReview");
|
85
|
+
|
86
|
+
me.initImgName();
|
87
|
+
|
88
|
+
},
|
89
|
+
initEvent:function(){
|
90
|
+
|
91
|
+
var me = this;
|
92
|
+
|
93
|
+
//防止点击过后关闭popup
|
94
|
+
me.root().on('click', function(e){
|
95
|
+
return false;
|
96
|
+
});
|
97
|
+
|
98
|
+
//移动预览
|
99
|
+
me.root().delegate( 'td', 'mouseover mouseout', function( evt ){
|
100
|
+
|
101
|
+
var $td = $( this),
|
102
|
+
url = $td.attr('data-surl') || null;
|
103
|
+
|
104
|
+
if( url ) {
|
105
|
+
me[evt.type]( this, url , $td.attr('data-posflag') );
|
106
|
+
}
|
107
|
+
|
108
|
+
return false;
|
109
|
+
|
110
|
+
} );
|
111
|
+
|
112
|
+
//点击选中
|
113
|
+
me.root().delegate( 'td', 'click', function( evt ){
|
114
|
+
|
115
|
+
var $td = $( this),
|
116
|
+
realUrl = $td.attr('data-realurl') || null;
|
117
|
+
|
118
|
+
if( realUrl ) {
|
119
|
+
me.insertSmiley( realUrl.replace( /'/g, "\\'" ), evt );
|
120
|
+
}
|
121
|
+
|
122
|
+
return false;
|
123
|
+
|
124
|
+
} );
|
125
|
+
|
126
|
+
//更新模板
|
127
|
+
me.tabs.edui().on("beforeshow", function( evt ){
|
128
|
+
|
129
|
+
var contentId = $(evt.target).attr('data-context').replace( /^.*\.(?=[^\s]*$)/, '' );
|
130
|
+
|
131
|
+
evt.stopPropagation();
|
132
|
+
|
133
|
+
me.updateTab( contentId );
|
134
|
+
|
135
|
+
});
|
136
|
+
|
137
|
+
this.switchToFirst();
|
138
|
+
|
139
|
+
},
|
140
|
+
initImgName: function() {
|
141
|
+
|
142
|
+
var emotion = this.sourceData.emotion;
|
143
|
+
|
144
|
+
for ( var pro in emotion.SmilmgName ) {
|
145
|
+
var tempName = emotion.SmilmgName[pro],
|
146
|
+
tempBox = emotion.SmileyBox[pro],
|
147
|
+
tempStr = "";
|
148
|
+
|
149
|
+
if ( tempBox.length ) return;
|
150
|
+
|
151
|
+
for ( var i = 1; i <= tempName[1]; i++ ) {
|
152
|
+
tempStr = tempName[0];
|
153
|
+
if ( i < 10 ) tempStr = tempStr + '0';
|
154
|
+
tempStr = tempStr + i + '.gif';
|
155
|
+
tempBox.push( tempStr );
|
156
|
+
}
|
157
|
+
}
|
158
|
+
|
159
|
+
},
|
160
|
+
/**
|
161
|
+
* 切换到第一个tab
|
162
|
+
*/
|
163
|
+
switchToFirst: function(){
|
164
|
+
this.root().find(".edui-emotion-Jtabnav .edui-tab-text:first").trigger('click');
|
165
|
+
},
|
166
|
+
updateTab: function( contentBoxId ) {
|
167
|
+
|
168
|
+
var me = this,
|
169
|
+
emotion = me.sourceData.emotion;
|
170
|
+
|
171
|
+
me.autoHeight( contentBoxId );
|
172
|
+
|
173
|
+
if ( !emotion.tabExist[ contentBoxId ] ) {
|
174
|
+
|
175
|
+
emotion.tabExist[ contentBoxId ] = true;
|
176
|
+
me.createTab( contentBoxId );
|
177
|
+
|
178
|
+
}
|
179
|
+
|
180
|
+
},
|
181
|
+
autoHeight: function( ) {
|
182
|
+
this.widget.height(this.root() + 2);
|
183
|
+
},
|
184
|
+
createTabList: function( tabNum ) {
|
185
|
+
var obj = {};
|
186
|
+
for ( var i = 0; i < tabNum; i++ ) {
|
187
|
+
obj["edui-emotion-Jtab" + i] = [];
|
188
|
+
}
|
189
|
+
return obj;
|
190
|
+
},
|
191
|
+
mouseover: function( td, srcPath, posFlag ) {
|
192
|
+
|
193
|
+
posFlag -= 0;
|
194
|
+
|
195
|
+
$(td).css( 'backgroundColor', '#ACCD3C' );
|
196
|
+
|
197
|
+
this.previewImg.css( "backgroundImage", "url(" + srcPath + ")" );
|
198
|
+
posFlag && this.previewBox.addClass('edui-emotion-preview-left');
|
199
|
+
this.previewBox.show();
|
200
|
+
|
201
|
+
},
|
202
|
+
mouseout: function( td ) {
|
203
|
+
$(td).css( 'backgroundColor', 'transparent' );
|
204
|
+
this.previewBox.removeClass('edui-emotion-preview-left').hide();
|
205
|
+
},
|
206
|
+
insertSmiley: function( url, evt ) {
|
207
|
+
var obj = {
|
208
|
+
src: url
|
209
|
+
};
|
210
|
+
obj._src = obj.src;
|
211
|
+
editor.execCommand( 'insertimage', obj );
|
212
|
+
if ( !evt.ctrlKey ) {
|
213
|
+
//关闭预览
|
214
|
+
this.previewBox.removeClass('edui-emotion-preview-left').hide();
|
215
|
+
this.widget.edui().hide();
|
216
|
+
}
|
217
|
+
},
|
218
|
+
createTab: function( contentBoxId ) {
|
219
|
+
|
220
|
+
var faceVersion = "?v=1.1", //版本号
|
221
|
+
me = this,
|
222
|
+
$contentBox = this.root().find("."+contentBoxId),
|
223
|
+
emotion = me.sourceData.emotion,
|
224
|
+
imagePath = emotion.SmileyPath + emotion.imageFolders[ contentBoxId ], //获取显示表情和预览表情的路径
|
225
|
+
positionLine = 11 / 2, //中间数
|
226
|
+
iWidth = iHeight = 35, //图片长宽
|
227
|
+
iColWidth = 3, //表格剩余空间的显示比例
|
228
|
+
tableCss = emotion.imageCss[ contentBoxId ],
|
229
|
+
cssOffset = emotion.imageCssOffset[ contentBoxId ],
|
230
|
+
textHTML = ['<table border="1" class="edui-emotion-smileytable">'],
|
231
|
+
i = 0, imgNum = emotion.SmileyBox[ contentBoxId ].length, imgColNum = 11, faceImage,
|
232
|
+
sUrl, realUrl, posflag, offset, infor;
|
233
|
+
|
234
|
+
for ( ; i < imgNum; ) {
|
235
|
+
textHTML.push( '<tr>' );
|
236
|
+
for ( var j = 0; j < imgColNum; j++, i++ ) {
|
237
|
+
faceImage = emotion.SmileyBox[ contentBoxId ][i];
|
238
|
+
if ( faceImage ) {
|
239
|
+
sUrl = imagePath + faceImage + faceVersion;
|
240
|
+
realUrl = imagePath + faceImage;
|
241
|
+
posflag = j < positionLine ? 0 : 1;
|
242
|
+
offset = cssOffset * i * (-1) - 1;
|
243
|
+
infor = emotion.SmileyInfor[ contentBoxId ][i];
|
244
|
+
|
245
|
+
textHTML.push( '<td class="edui-emotion-' + tableCss + '" data-surl="'+ sUrl +'" data-realurl="'+ realUrl +'" data-posflag="'+ posflag +'" align="center">' );
|
246
|
+
textHTML.push( '<span>' );
|
247
|
+
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>' );
|
248
|
+
textHTML.push( '</span>' );
|
249
|
+
} else {
|
250
|
+
textHTML.push( '<td bgcolor="#FFFFFF">' );
|
251
|
+
}
|
252
|
+
textHTML.push( '</td>' );
|
253
|
+
}
|
254
|
+
textHTML.push( '</tr>' );
|
255
|
+
}
|
256
|
+
textHTML.push( '</table>' );
|
257
|
+
textHTML = textHTML.join( "" );
|
258
|
+
$contentBox.html( textHTML );
|
259
|
+
},
|
260
|
+
createArr: function( tabNum ) {
|
261
|
+
var arr = [];
|
262
|
+
for ( var i = 0; i < tabNum; i++ ) {
|
263
|
+
arr[i] = 0;
|
264
|
+
}
|
265
|
+
return arr;
|
266
|
+
},
|
267
|
+
width:603,
|
268
|
+
height:400
|
269
|
+
});
|
270
|
+
|
271
|
+
})();
|
272
|
+
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,32 @@
|
|
1
|
+
.edui-popup-formula .edui-formula-wrapper {
|
2
|
+
padding: 15px;
|
3
|
+
}
|
4
|
+
.edui-popup-formula .edui-formula-wrapper .edui-tab-nav{
|
5
|
+
height: auto;
|
6
|
+
*height: 31px;
|
7
|
+
}
|
8
|
+
.edui-popup-formula .edui-formula-wrapper .edui-tab-text {
|
9
|
+
font-size: 12px;
|
10
|
+
}
|
11
|
+
.edui-popup-formula .edui-formula-wrapper .edui-formula-clearboth {
|
12
|
+
clear: both;
|
13
|
+
width: 0;
|
14
|
+
height: 0;
|
15
|
+
}
|
16
|
+
.edui-popup-formula .edui-formula-wrapper .edui-tab-pane ul {
|
17
|
+
margin: 0px;
|
18
|
+
padding: 0px;
|
19
|
+
}
|
20
|
+
.edui-popup-formula .edui-formula-wrapper .edui-tab-content {
|
21
|
+
padding: 5px 0px 0px 0px;
|
22
|
+
}
|
23
|
+
.edui-popup-formula .edui-formula-wrapper .edui-tab-pane .edui-formula-latex-item {
|
24
|
+
display: block;
|
25
|
+
float: left;
|
26
|
+
margin: 0px 3px 3px 0px;
|
27
|
+
width: 30px;
|
28
|
+
height: 30px;
|
29
|
+
border:1px solid #cccccc;
|
30
|
+
background-image: url("images/formula.png");
|
31
|
+
cursor: pointer;
|
32
|
+
}
|
@@ -0,0 +1,212 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8">
|
5
|
+
<title>Document</title>
|
6
|
+
<link rel="stylesheet" href="../../third-party/mathquill/mathquill.css"/>
|
7
|
+
<style>
|
8
|
+
html, body, .main{
|
9
|
+
margin: 0;
|
10
|
+
padding: 0;
|
11
|
+
overflow: hidden;
|
12
|
+
}
|
13
|
+
.main{
|
14
|
+
width:1024px;
|
15
|
+
height:1024px;
|
16
|
+
}
|
17
|
+
.mathquill-editable,
|
18
|
+
.mathquill-rendered-math{
|
19
|
+
border: 0px;
|
20
|
+
padding: 0px;
|
21
|
+
margin:4px;
|
22
|
+
}
|
23
|
+
</style>
|
24
|
+
</head>
|
25
|
+
<body>
|
26
|
+
|
27
|
+
<div class="main">
|
28
|
+
<div class="mathquill-editable"></div>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<div>
|
32
|
+
<input id="blurHelper" />
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<script src="../../third-party/jquery.min.js"></script>
|
36
|
+
<script src="../../third-party/mathquill/mathquill.js"></script>
|
37
|
+
<script>
|
38
|
+
$(function(){
|
39
|
+
|
40
|
+
var UM = parent.UM,
|
41
|
+
$iframe = $(getSelfIframe()),
|
42
|
+
editorId = $iframe.parents('.edui-body-container').attr('id'),
|
43
|
+
editor = UM.getEditor(editorId),
|
44
|
+
timer;
|
45
|
+
|
46
|
+
/* 获得当前公式所在的iframe节点 */
|
47
|
+
function getSelfIframe(){
|
48
|
+
var iframes = parent.document.getElementsByTagName('iframe');
|
49
|
+
for (var key in iframes) {
|
50
|
+
if (iframes[key].contentWindow == window) {
|
51
|
+
return iframes[key];
|
52
|
+
}
|
53
|
+
}
|
54
|
+
return null;
|
55
|
+
}
|
56
|
+
/* 获得当前url上的hash存储的参数值 */
|
57
|
+
function getLatex() {
|
58
|
+
return $iframe.attr('data-latex') || '';
|
59
|
+
}
|
60
|
+
/* 保存场景 */
|
61
|
+
function saveScene(){
|
62
|
+
timer && clearTimeout(timer);
|
63
|
+
timer = setTimeout(function(){
|
64
|
+
editor.fireEvent('savescene');
|
65
|
+
editor.fireEvent('contentchange');
|
66
|
+
editor.fireEvent('selectionchange');
|
67
|
+
timer = null;
|
68
|
+
}, 300);
|
69
|
+
}
|
70
|
+
/* 设置编辑器可编辑 */
|
71
|
+
function enableEditor(){
|
72
|
+
if(editor.body.contentEditable == 'false') {
|
73
|
+
editor.setEnabled();
|
74
|
+
}
|
75
|
+
}
|
76
|
+
/* 设置编辑器不可编辑 */
|
77
|
+
function disableEditor(){
|
78
|
+
if(editor.body.contentEditable == 'true') {
|
79
|
+
editor.setDisabled(['undo', 'redo', 'preview', 'formula'], true);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
/* 公式 */
|
84
|
+
var Formula = function(){
|
85
|
+
var _this = this,
|
86
|
+
latex = getLatex();
|
87
|
+
|
88
|
+
this.isFocus = false;
|
89
|
+
this.isDisabled = false;
|
90
|
+
|
91
|
+
/* 加载公式内容 */
|
92
|
+
this.$mathquill = $('.mathquill-editable').mathquill('latex', latex);
|
93
|
+
|
94
|
+
/* 设置活动状态的公式iframe */
|
95
|
+
this.$mathquill.on('mousedown', function(){
|
96
|
+
/* 编辑器不可用时,公式也不可用 */
|
97
|
+
if(_this.disabled) return false;
|
98
|
+
|
99
|
+
/* 第一次点击当前公式,设置公式活动 */
|
100
|
+
if(!$iframe.hasClass('edui-formula-active')) {
|
101
|
+
disableEditor();
|
102
|
+
editor.blur();
|
103
|
+
editor.$body.find('iframe').not($iframe).each(function(k, v){
|
104
|
+
v.contentWindow.formula.blur();
|
105
|
+
});
|
106
|
+
if(_this.$mathquill.find('.cursor').css('display') == 'none') {
|
107
|
+
_this.refresh();
|
108
|
+
_this.$mathquill.addClass('hasCursor');
|
109
|
+
}
|
110
|
+
}
|
111
|
+
_this.focus();
|
112
|
+
});
|
113
|
+
editor.addListener('click', function(){
|
114
|
+
_this.blur();
|
115
|
+
enableEditor();
|
116
|
+
});
|
117
|
+
|
118
|
+
/* 里面focus,编辑器也判断为focus */
|
119
|
+
editor.addListener('isFocus', function(){
|
120
|
+
return _this.isFocus;
|
121
|
+
});
|
122
|
+
/* um不可用,公式也不可编辑 */
|
123
|
+
editor.addListener('setDisabled', function(type, except){
|
124
|
+
if (!(except && except.join(' ').indexOf('formula') != -1) && _this.isDisabled != true ) {
|
125
|
+
_this.setDisabled();
|
126
|
+
}
|
127
|
+
});
|
128
|
+
editor.addListener('setEnabled', function(){
|
129
|
+
if (_this.isDisabled != false) {
|
130
|
+
_this.setEnabled();
|
131
|
+
}
|
132
|
+
});
|
133
|
+
|
134
|
+
/* 设置更新外层iframe的大小和属性 */
|
135
|
+
$(document.body).on('keydown', function(){
|
136
|
+
_this.updateIframe();
|
137
|
+
}).on('keyup', function(){
|
138
|
+
_this.updateIframe();
|
139
|
+
});
|
140
|
+
|
141
|
+
/* 清除初始化的高亮状态 */
|
142
|
+
this.$mathquill.removeClass('hasCursor');
|
143
|
+
|
144
|
+
/* 初始化后延迟刷新外层iframe大小 */
|
145
|
+
setTimeout(function(){
|
146
|
+
_this.updateIframe();
|
147
|
+
}, 300);
|
148
|
+
};
|
149
|
+
|
150
|
+
Formula.prototype = {
|
151
|
+
focus:function(){
|
152
|
+
$iframe.addClass('edui-formula-active');
|
153
|
+
this.isFocus = true;
|
154
|
+
},
|
155
|
+
blur:function(){
|
156
|
+
$iframe.removeClass('edui-formula-active');
|
157
|
+
this.removeCursor();
|
158
|
+
this.isFocus = false;
|
159
|
+
},
|
160
|
+
removeCursor: function(){
|
161
|
+
this.$mathquill.find('span.cursor').hide();
|
162
|
+
this.$mathquill.parent().find('.hasCursor').removeClass('hasCursor');
|
163
|
+
},
|
164
|
+
updateIframe: function(){
|
165
|
+
$iframe.width(this.$mathquill.width()+8).height(this.$mathquill.height()+8);
|
166
|
+
var latex = $iframe.attr('data-latex'),
|
167
|
+
newLatex = this.getLatex();
|
168
|
+
if(latex != newLatex) {
|
169
|
+
$iframe.attr('data-latex', this.getLatex());
|
170
|
+
saveScene();
|
171
|
+
}
|
172
|
+
},
|
173
|
+
insertLatex: function(latex){
|
174
|
+
this.$mathquill.mathquill('write', latex);
|
175
|
+
this.updateIframe();
|
176
|
+
this.removeCursor();
|
177
|
+
},
|
178
|
+
setLatex: function(latex){
|
179
|
+
this.$mathquill.mathquill('latex', latex);
|
180
|
+
this.updateIframe();
|
181
|
+
},
|
182
|
+
getLatex: function(){
|
183
|
+
return this.$mathquill.mathquill('latex');
|
184
|
+
},
|
185
|
+
redraw: function(){
|
186
|
+
this.$mathquill.mathquill('redraw');
|
187
|
+
},
|
188
|
+
setDisabled: function(){
|
189
|
+
this.blur();
|
190
|
+
var latex = this.getLatex();
|
191
|
+
this.$mathquill.mathquill('revert').text(latex).mathquill();
|
192
|
+
this.updateIframe();
|
193
|
+
this.isDisabled = true;
|
194
|
+
},
|
195
|
+
setEnabled: function(){
|
196
|
+
this.$mathquill.removeClass('mathquill-rendered-math');
|
197
|
+
this.refresh();
|
198
|
+
this.isDisabled = false;
|
199
|
+
},
|
200
|
+
refresh: function(){
|
201
|
+
var latex = this.getLatex();
|
202
|
+
this.$mathquill.mathquill('revert').text(latex).mathquill('editable');
|
203
|
+
this.updateIframe();
|
204
|
+
}
|
205
|
+
};
|
206
|
+
|
207
|
+
/* 绑定到window上,给上级window调用 */
|
208
|
+
window.formula = new Formula();
|
209
|
+
});
|
210
|
+
</script>
|
211
|
+
</body>
|
212
|
+
</html>
|