Dotclear

source: admin/js/tiny_mce/plugins/dcControls/editor_plugin.js @ 445:c8fca536a9fb

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

Fixed encoding entities bug + initialize shortcuts

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 == null) {
30                         node = se.getNode();
31                    }
32                   
33                    if (node.nodeName == 'A') {
34                         var href= node.href || '';
35                         var title = node.title || '';
36                         var hreflang = node.hreflang || '';
37                         url += '?href='+href+'&hreflang='+hreflang+'&title='+title;
38                    }
39                    ed.windowManager.open({
40                         file: url,
41                         width: 760,
42                         height: 500,
43                         inline: 1,
44                         dc_popup: '',
45                         alwaysRaised: 'yes',
46                         dependent: 'yes',
47                         toolbar: 'yes',
48                         menubar: 'no',
49                         resizable: 'yes',
50                         scrollbars: 'yes',
51                         status: 'no'
52                    }, {
53                         plugin_url : url
54                    });
55               });
56               ed.addCommand('dcMedia', function() {
57                    ed.windowManager.open({
58                         file: popup_media_url,
59                         width: 760,
60                         height: 500,
61                         inline: 1,
62                         dc_popup: '',
63                         alwaysRaised: 'yes',
64                         dependent: 'yes',
65                         toolbar: 'yes',
66                         menubar: 'no',
67                         resizable: 'yes',
68                         scrollbars: 'yes',
69                         status: 'no'
70                    }, {
71                         plugin_url : url
72                    });
73               });
74               ed.addCommand('dcWebMedia', function() {
75                    ed.windowManager.open({
76                         file: popup_web_media_url,
77                         width: 800,
78                         height: 650,
79                         inline: 1,
80                         dc_popup: '',
81                         alwaysRaised: 'yes',
82                         dependent: 'yes',
83                         toolbar: 'yes',
84                         menubar: 'no',
85                         resizable: 'yes',
86                         scrollbars: 'yes',
87                         status: 'no'
88                    }, {
89                         plugin_url : url
90                    });
91               });
92               
93               // Register buttons
94               ed.addButton('inlinecode', {
95                    title: 'dcControls.inlinecode_desc',
96                    cmd: 'dcCode'
97               });
98               ed.addButton('quote', {
99                    title: 'dcControls.quote_desc',
100                    cmd: 'dcQuote'
101               });
102               ed.addButton('link', {
103                    title: 'advanced.link_desc',
104                    cmd: 'dcLink'
105               });
106               ed.addButton('media', {
107                    title: 'dcControls.media_desc',
108                    cmd: 'dcMedia'
109               });
110               ed.addButton('webmedia', {
111                    title: 'dcControls.webmedia_desc',
112                    cmd: 'dcWebMedia'
113               });
114               
115               // Init shortcuts
116               for (var s in ed.shortcuts) {
117                    delete ed.shortcuts[s];
118               }
119               // Register shortcuts
120               ed.addShortcut('ctrl+alt+l', 'dcControls.link_desc', 'dcLink');
121               ed.addShortcut('ctrl+alt+m', 'dcControls.media_desc', 'dcMedia');
122               ed.addShortcut('ctrl+alt+w', 'dcControls.media_desc', 'dcWebMedia');
123               
124               // Register changes management
125               ed.onNodeChange.add(function(ed, cm, n, co) {
126                    cm.setActive('inlinecode', n.nodeName == 'CODE' || ed.dom.getParent(n,'CODE'));
127                    cm.setActive('quote', n.nodeName == 'Q' || ed.dom.getParent(n,'Q'));
128               });
129          },
130         
131          getInfo: function() {
132               return {
133                    longname: 'Dotclear custom controls',
134                    author: 'Tomtom for dotclear',
135                    authorurl: 'http://dotclear.org',
136                    infourl: '',
137                    version: tinymce.majorVersion + "." + tinymce.minorVersion
138               };
139          }
140     });
141     
142     // Register plugin
143     tinymce.PluginManager.add('dcControls',tinymce.plugins.dcControls);
144})();
Note: See TracBrowser for help on using the repository browser.

Sites map