PluginProbe
Virtue/Ascend/Pinnacle Toolkit / 1.8
Virtue/Ascend/Pinnacle Toolkit v1.8
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 / columns / columns_shortgen.js

columns_shortgen.js in Virtue/Ascend/Pinnacle Toolkit 1.8, at shortcodes/columns/columns_shortgen.js

123 lines 3.6 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.kadcolumns', {
3 init : function(ed, url) {
4 // Register commands
5 var t = this;
6 ed.addCommand('mcekadcolumns', function() {
7 ed.windowManager.open({
8 file: ajaxurl + '?action=kadcolumns_tinymce',
9 width : 350 + parseInt(ed.getLang('button.delta_width', 0)), // size of our window
10 height : 380 + parseInt(ed.getLang('button.delta_height', 0)), // size of our window
11 inline : 1
12 }, {
13 plugin_url : url
14 });
15 });
16
17 // Register buttons
18 ed.addButton('kadcolumns', {title : 'Insert Columns', cmd : 'mcekadcolumns', image: url + '/img/columns.png' });
19 ed.onBeforeSetContent.add(function(ed, o) {
20 o.content = t._do_column(o.content, url);
21 });
22 ed.onBeforeSetContent.add(function(ed, o) {
23 o.content = t._do_columnstart(o.content, url);
24 });
25 ed.onBeforeSetContent.add(function(ed, o) {
26 o.content = t._do_columnend(o.content, url);
27 });
28
29 ed.onPostProcess.add(function(ed, o) {
30 if (o.get)
31 o.content = t._get_column(o.content);
32 });
33 ed.onPostProcess.add(function(ed, o) {
34 if (o.get)
35 o.content = t._get_columnstart(o.content);
36 });
37 ed.onPostProcess.add(function(ed, o) {
38 if (o.get)
39 o.content = t._get_columnend(o.content);
40 });
41 },
42 _do_column : function(co, url) {
43 return co.replace(/\[columnhelper([^\]]*)\]/g, function(a,b){
44 return '<img src="'+url+'/img/t.gif" class="columnhelper '+tinymce.DOM.encode(b)+' mceItem" title="columnhelper'+tinymce.DOM.encode(b)+'" />';
45 });
46 },
47 _do_columnstart : function(co, url) {
48 return co.replace(/\[hcolumns([^\]]*)\]/g, function(a,b){
49 return '<img src="'+url+'/img/t.gif" class="columnstart mceItem" title="hcolumns" />';
50 });
51 },
52 _do_columnend : function(co, url) {
53 return co.replace(/\[\/hcolumns([^\]]*)\]/g, function(a,b){
54 return '<img src="'+url+'/img/t.gif" class="columnend mceItem" title="/hcolumns" />';
55 });
56 },
57
58 _get_column : function(co) {
59
60 function getAttr(s, n) {
61 n = new RegExp(n + '=\"([^\"]+)\"', 'g').exec(s);
62 return n ? tinymce.DOM.decode(n[1]) : '';
63 };
64
65 return co.replace(/(?:<p[^>]*>)*(<img[^>]+>)(?:<\/p>)*/g, function(a,im) {
66 var cls = getAttr(im, 'class');
67
68 if ( cls.indexOf('columnhelper') != -1 )
69 return '<p>['+tinymce.trim(getAttr(im, 'title'))+']</p>';
70
71 return a;
72 });
73 },
74 _get_columnstart : function(co) {
75
76 function getAttr(s, n) {
77 n = new RegExp(n + '=\"([^\"]+)\"', 'g').exec(s);
78 return n ? tinymce.DOM.decode(n[1]) : '';
79 };
80
81 return co.replace(/(?:<p[^>]*>)*(<img[^>]+>)(?:<\/p>)*/g, function(a,im) {
82 var cls = getAttr(im, 'class');
83
84 if ( cls.indexOf('columnstart') != -1 )
85 return '<p>['+tinymce.trim(getAttr(im, 'title'))+']</p>';
86
87 return a;
88 });
89 },
90 _get_columnend : function(co) {
91
92 function getAttr(s, n) {
93 n = new RegExp(n + '=\"([^\"]+)\"', 'g').exec(s);
94 return n ? tinymce.DOM.decode(n[1]) : '';
95 };
96
97 return co.replace(/(?:<p[^>]*>)*(<img[^>]+>)(?:<\/p>)*/g, function(a,im) {
98 var cls = getAttr(im, 'class');
99
100 if ( cls.indexOf('columnend') != -1 )
101 return '<p>['+tinymce.trim(getAttr(im, 'title'))+']</p>';
102
103 return a;
104 });
105 },
106
107 getInfo : function() {
108 return {
109 longname : 'Insert Columns',
110 author : 'Benjamin Ritner',
111 authorurl : 'http://kadencethemes.com',
112 infourl : 'http://kadencethemes.com',
113 version : tinymce.majorVersion + "." + tinymce.minorVersion
114 };
115 }
116 });
117
118 // Register plugin
119 // first parameter is the button ID and must match ID elsewhere
120 // second parameter must match the first parameter of the tinymce.create() function above
121 tinymce.PluginManager.add('kadcolumns', tinymce.plugins.kadcolumns);
122
123 })();