PluginProbe
Virtue/Ascend/Pinnacle Toolkit / 1.5
Virtue/Ascend/Pinnacle Toolkit v1.5
4.9.12.2 trunk 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.7 All 48 releases
virtue-toolkit / shortcodes / video / video_shortgen.js

video_shortgen.js in Virtue/Ascend/Pinnacle Toolkit 1.5, at shortcodes/video/video_shortgen.js

98 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function() {
2 tinymce.create('tinymce.plugins.kadvideo', {
3 init : function(ed, url) {
4 var t = this;
5 // Register commands
6 ed.addCommand('mcekadvideo', function() {
7 ed.windowManager.open({
8 file: ajaxurl + '?action=kadvideo_tinymce',
9 width : 350 + ed.getLang('button.delta_width', 0), // size of our window
10 height : 250 + ed.getLang('button.delta_height', 0), // size of our window
11 inline : 1
12 }, {
13 plugin_url : url
14 });
15 });
16 ed.onNodeChange.add(function(ed, cm, n) {
17 cm.setActive('kadvideo', n.nodeName == 'IMG');
18 });
19
20 // Register buttons
21 ed.addButton('kadvideo', {title : 'Insert video', cmd : 'mcekadvideo', image: url + '/img/video.png' });
22 ed.onBeforeSetContent.add(function(ed, o) {
23 o.content = t._do_video(o.content);
24 });
25 ed.onBeforeSetContent.add(function(ed, o) {
26 o.content = t._do_videoend(o.content);
27 });
28
29 ed.onPostProcess.add(function(ed, o) {
30 if (o.get)
31 o.content = t._get_video(o.content);
32 });
33 ed.onPostProcess.add(function(ed, o) {
34 if (o.get)
35 o.content = t._get_videoend(o.content);
36 });
37 },
38
39 _do_video : function(co) {
40 return co.replace(/\[video([^\]]*)\]/g, function(a,b){
41 return '<img src="'+tinymce.baseURL+'/plugins/wpgallery/img/t.gif" class="kadvideo mceItem" title="video'+tinymce.DOM.encode(b)+'" />';
42 });
43 },
44 _do_videoend : function(co) {
45 return co.replace(/\[\/video([^\]]*)\]/g, function(a,b){
46 return '<img src="'+tinymce.baseURL+'/plugins/wpgallery/img/t.gif" class="kadvideoend mceItem" title="/video" />';
47 });
48 },
49
50 _get_video : function(co) {
51
52 function getAttr(s, n) {
53 n = new RegExp(n + '=\"([^\"]+)\"', 'g').exec(s);
54 return n ? tinymce.DOM.decode(n[1]) : '';
55 };
56
57 return co.replace(/(?:<p[^>]*>)*(<img[^>]+>)(?:<\/p>)*/g, function(a,im) {
58 var cls = getAttr(im, 'class');
59
60 if ( cls.indexOf('kadvideo') != -1 )
61 return '<p>['+tinymce.trim(getAttr(im, 'title'))+']</p>';
62
63 return a;
64 });
65 },
66 _get_videoend : function(co) {
67
68 function getAttr(s, n) {
69 n = new RegExp(n + '=\"([^\"]+)\"', 'g').exec(s);
70 return n ? tinymce.DOM.decode(n[1]) : '';
71 };
72
73 return co.replace(/(?:<p[^>]*>)*(<img[^>]+>)(?:<\/p>)*/g, function(a,im) {
74 var cls = getAttr(im, 'class');
75
76 if ( cls.indexOf('kadvideoend') != -1 )
77 return '<p>['+tinymce.trim(getAttr(im, 'title'))+']</p>';
78
79 return a;
80 });
81 },
82 getInfo : function() {
83 return {
84 longname : 'Insert video',
85 author : 'Benjamin Ritner',
86 authorurl : 'http://kadencethemes.com',
87 infourl : 'http://kadencethemes.com',
88 version : tinymce.majorVersion + "." + tinymce.minorVersion
89 };
90 }
91 });
92
93 // Register plugin
94 // first parameter is the button ID and must match ID elsewhere
95 // second parameter must match the first parameter of the tinymce.create() function above
96 tinymce.PluginManager.add('kadvideo', tinymce.plugins.kadvideo);
97
98 })();