Dotclear

source: admin/js/tiny_mce/plugins/dcControls/editor_plugin.js @ 381:3fa9e98942e2

Revision 381:3fa9e98942e2, 3.7 KB checked in by Tomtom33 <tbouron@…>, 14 years ago (diff)

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

Sites map