Dotclear

source: admin/js/tiny_mce/plugins/dcControls/editor_plugin.js @ 424:b887a17cfafe

Revision 424:b887a17cfafe, 3.6 KB checked in by Tomtom33 <tbouron@…>, 14 years ago (diff)

Fixed various bugs

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               var popup_web_media_url = 'popup_web_media.php';
9               
10               t.editor = ed;
11               
12               // Register commands
13               ed.addCommand('dcCode', function() {
14                    ed.formatter.toggle('inlinecode');
15               });
16               ed.addCommand('dcQuote', function() {
17                    ed.formatter.toggle('quote');
18               });
19               ed.addCommand('dcLink', function() {
20                    var se = ed.selection;
21                   
22                    // No selection and not in link
23                    if (se.isCollapsed() && !ed.dom.getParent(se.getNode(), 'A'))
24                         return;
25                   
26                    var url = popup_link_url;
27                    var node = ed.dom.getParent(se.getNode(), 'A');
28                   
29                    if (node.nodeName == 'A') {
30                         var href= node.href || '';
31                         var title = node.title || '';
32                         var hreflang = node.hreflang || '';
33                         url += '?href='+href+'&hreflang='+hreflang+'&title='+title;
34                    }
35                    ed.windowManager.open({
36                         file: url,
37                         width: 760,
38                         height: 500,
39                         inline: 1,
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                         dc_popup: '',
59                         alwaysRaised: 'yes',
60                         dependent: 'yes',
61                         toolbar: 'yes',
62                         menubar: 'no',
63                         resizable: 'yes',
64                         scrollbars: 'yes',
65                         status: 'no'
66                    }, {
67                         plugin_url : url
68                    });
69               });
70               ed.addCommand('dcWebMedia', function() {
71                    ed.windowManager.open({
72                         file: popup_web_media_url,
73                         width: 800,
74                         height: 650,
75                         inline: 1,
76                         dc_popup: '',
77                         alwaysRaised: 'yes',
78                         dependent: 'yes',
79                         toolbar: 'yes',
80                         menubar: 'no',
81                         resizable: 'yes',
82                         scrollbars: 'yes',
83                         status: 'no'
84                    }, {
85                         plugin_url : url
86                    });
87               });
88               
89               // Register buttons
90               ed.addButton('inlinecode', {
91                    title: 'dcControls.inlinecode_desc',
92                    cmd: 'dcCode'
93               });
94               ed.addButton('quote', {
95                    title: 'dcControls.quote_desc',
96                    cmd: 'dcQuote'
97               });
98               ed.addButton('link', {
99                    title: 'advanced.link_desc',
100                    cmd: 'dcLink'
101               });
102               ed.addButton('media', {
103                    title: 'dcControls.media_desc',
104                    cmd: 'dcMedia'
105               });
106               ed.addButton('webmedia', {
107                    title: 'dcControls.webmedia_desc',
108                    cmd: 'dcWebMedia'
109               });
110               
111               // Register shortcuts
112               ed.addShortcut('alt+shift+c', 'dcControls.inlinecode_desc', 'dcCode');
113               ed.addShortcut('alt+shift+q', 'dcControls.quote_desc', 'dcQuote');
114               ed.addShortcut('alt+shift+l', 'dcControls.link_desc', 'dcLink');
115               ed.addShortcut('alt+shift+i', 'dcControls.imglink_desc', 'dcImgLink');
116               ed.addShortcut('alt+shift+m', 'dcControls.media_desc', 'dcMedia');
117               ed.addShortcut('alt+shift+w', 'dcControls.media_desc', 'dcWebMedia');
118               
119               // Register changes management
120               ed.onNodeChange.add(function(ed, cm, n, co) {
121                    cm.setActive('inlinecode', n.nodeName == 'CODE' || ed.dom.getParent(n,'CODE'));
122                    cm.setActive('quote', n.nodeName == 'Q' || ed.dom.getParent(n,'Q'));
123               });
124          },
125         
126          getInfo: function() {
127               return {
128                    longname: 'Dotclear custom controls',
129                    author: 'Tomtom for dotclear',
130                    authorurl: 'http://dotclear.org',
131                    infourl: '',
132                    version: tinymce.majorVersion + "." + tinymce.minorVersion
133               };
134          }
135     });
136     
137     // Register plugin
138     tinymce.PluginManager.add('dcControls',tinymce.plugins.dcControls);
139})();
Note: See TracBrowser for help on using the repository browser.

Sites map