Dotclear

source: admin/js/tiny_mce/plugins/dcControls/editor_plugin.js @ 328:134b65a90d17

Revision 328:134b65a90d17, 3.1 KB checked in by Tomtom33 <tbouron@…>, 14 years ago (diff)

Merge popup_link.php and popup_posts.php for TinyMCE popup

Line 
1(function() {
2     tinymce.create('tinymce.plugins.dcControls',{
3          // Init.
4          init: function(ed, url) {
5               var t = this;
6               var popup_link_url = 'popup_link.php';
7               var popup_media_url = 'media.php?popup=1';
8               
9               t.editor = ed;
10               
11               // Register commands
12               ed.addCommand('dcCode', function() {
13                    ed.formatter.toggle('inlinecode');
14               });
15               ed.addCommand('dcQuote', function() {
16                    ed.formatter.toggle('quote');
17               });
18               ed.addCommand('dcLink', function() {
19                    var se = ed.selection;
20                   
21                    // No selection and not in link
22                    if (se.isCollapsed() && !ed.dom.getParent(se.getNode(), 'A'))
23                         return;
24                   
25                    var url = popup_link_url;
26                    var node = se.getNode();
27                   
28                    if (node.nodeName == 'A') {
29                         var href= node.href || '';
30                         var title = node.title || '';
31                         var hreflang = node.hreflang || '';
32                         url += '?href='+href+'&hreflang='+hreflang+'&title='+title;
33                    }
34                    ed.windowManager.open({
35                         file: url,
36                         width: 760,
37                         height: 500,
38                         inline: 1,
39                         popup_css : false,
40                         dc_popup: '',
41                         alwaysRaised: 'yes',
42                         dependent: 'yes',
43                         toolbar: 'yes',
44                         menubar: 'no',
45                         resizable: 'yes',
46                         scrollbars: 'yes',
47                         status: 'no'
48                    }, {
49                         plugin_url : url
50                    });
51               });
52               ed.addCommand('dcMedia', function() {
53                    ed.windowManager.open({
54                         file: popup_media_url,
55                         width: 760,
56                         height: 500,
57                         inline: 1,
58                         popup_css : false,
59                         dc_popup: '',
60                         alwaysRaised: 'yes',
61                         dependent: 'yes',
62                         toolbar: 'yes',
63                         menubar: 'no',
64                         resizable: 'yes',
65                         scrollbars: 'yes',
66                         status: 'no'
67                    }, {
68                         plugin_url : url
69                    });
70               });
71               
72               // Register buttons
73               ed.addButton('inlinecode', {
74                    title: 'dcControls.inlinecode_desc',
75                    cmd: 'dcCode',
76                    image: url + '/img/code.png'
77               });
78               ed.addButton('quote', {
79                    title: 'dcControls.quote_desc',
80                    cmd: 'dcQuote',
81                    image: url + '/img/quote.png'
82               });
83               ed.addButton('link', {
84                    title: 'dcControls.link_desc',
85                    cmd: 'dcLink'
86               });
87               ed.addButton('media', {
88                    title: 'dcControls.media_desc',
89                    cmd: 'dcMedia',
90                    image: url + '/img/media.png'
91               });
92               
93               // Register shortcuts
94               ed.addShortcut('alt+shift+c', 'dcControls.inlinecode_desc', 'dcCode');
95               ed.addShortcut('alt+shift+q', 'dcControls.quote_desc', 'dcQuote');
96               ed.addShortcut('alt+shift+l', 'dcControls.link_desc', 'dcLink');
97               ed.addShortcut('alt+shift+m', 'dcControls.media_desc', 'dcMedia');
98               
99               // Register changes management
100               ed.onNodeChange.add(function(ed, cm, n, co) {
101                    cm.setActive('inlinecode', n.nodeName == 'CODE' || ed.dom.getParent(n,'CODE'));
102                    cm.setActive('quote', n.nodeName == 'Q' || ed.dom.getParent(n,'Q'));
103               });
104          },
105         
106          getInfo: function() {
107               return {
108                    longname: 'Dotclear custom controls',
109                    author: 'Tomtom for dotclear',
110                    authorurl: 'http://dotclear.org',
111                    infourl: '',
112                    version: tinymce.majorVersion + "." + tinymce.minorVersion
113               };
114          }
115     });
116     
117     // Register plugin
118     tinymce.PluginManager.add('dcControls',tinymce.plugins.dcControls);
119})();
Note: See TracBrowser for help on using the repository browser.

Sites map