2 * $Id: editor_plugin_src.js 126 2006-10-22 16:19:55Z spocke $
5 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
8 /* Import plugin specific language pack */
9 tinyMCE
.importPluginLanguagePack('advimage');
11 var TinyMCE_AdvancedImagePlugin
= {
12 getInfo : function() {
14 longname
: 'Advanced image',
15 author
: 'Moxiecode Systems AB',
16 authorurl
: 'http://tinymce.moxiecode.com',
17 infourl
: 'http://tinymce.moxiecode.com/tinymce/docs/plugin_advimage.html',
18 version
: tinyMCE
.majorVersion
+ "." + tinyMCE
.minorVersion
22 getControlHTML : function(cn
) {
25 return tinyMCE
.getButtonHTML(cn
, 'lang_image_desc', '{$themeurl}/images/image.gif', 'mceAdvImage');
31 execCommand : function(editor_id
, element
, command
, user_interface
, value
) {
34 var template
= new Array();
36 template
['file'] = '../../plugins/advimage/image.htm';
37 template
['width'] = 480;
38 template
['height'] = 380;
40 // Language specific width and height addons
41 template
['width'] += tinyMCE
.getLang('lang_advimage_delta_width', 0);
42 template
['height'] += tinyMCE
.getLang('lang_advimage_delta_height', 0);
44 var inst
= tinyMCE
.getInstanceById(editor_id
);
45 var elm
= inst
.getFocusElement();
47 if (elm
!= null && tinyMCE
.getAttrib(elm
, 'class').indexOf('mceItem') != -1)
50 tinyMCE
.openWindow(template
, {editor_id
: editor_id
, inline
: "yes"});
58 cleanup : function(type
, content
) {
60 case "insert_to_editor_dom":
61 var imgs
= content
.getElementsByTagName("img"), src
, i
;
62 for (i
=0; i
<imgs
.length
; i
++) {
63 var onmouseover
= tinyMCE
.cleanupEventStr(tinyMCE
.getAttrib(imgs
[i
], 'onmouseover'));
64 var onmouseout
= tinyMCE
.cleanupEventStr(tinyMCE
.getAttrib(imgs
[i
], 'onmouseout'));
66 if ((src
= this._getImageSrc(onmouseover
)) != "") {
67 if (tinyMCE
.getParam('convert_urls'))
68 src
= tinyMCE
.convertRelativeToAbsoluteURL(tinyMCE
.settings
['base_href'], src
);
70 imgs
[i
].setAttribute('onmouseover', "this.src='" + src
+ "';");
73 if ((src
= this._getImageSrc(onmouseout
)) != "") {
74 if (tinyMCE
.getParam('convert_urls'))
75 src
= tinyMCE
.convertRelativeToAbsoluteURL(tinyMCE
.settings
['base_href'], src
);
77 imgs
[i
].setAttribute('onmouseout', "this.src='" + src
+ "';");
82 case "get_from_editor_dom":
83 var imgs
= content
.getElementsByTagName("img");
84 for (var i
=0; i
<imgs
.length
; i
++) {
85 var onmouseover
= tinyMCE
.cleanupEventStr(tinyMCE
.getAttrib(imgs
[i
], 'onmouseover'));
86 var onmouseout
= tinyMCE
.cleanupEventStr(tinyMCE
.getAttrib(imgs
[i
], 'onmouseout'));
88 if ((src
= this._getImageSrc(onmouseover
)) != "") {
89 if (tinyMCE
.getParam('convert_urls'))
90 src
= eval(tinyMCE
.settings
['urlconverter_callback'] + "(src, null, true);");
92 imgs
[i
].setAttribute('onmouseover', "this.src='" + src
+ "';");
95 if ((src
= this._getImageSrc(onmouseout
)) != "") {
96 if (tinyMCE
.getParam('convert_urls'))
97 src
= eval(tinyMCE
.settings
['urlconverter_callback'] + "(src, null, true);");
99 imgs
[i
].setAttribute('onmouseout', "this.src='" + src
+ "';");
108 handleNodeChange : function(editor_id
, node
, undo_index
, undo_levels
, visual_aid
, any_selection
) {
113 if (node
.nodeName
== "IMG" && tinyMCE
.getAttrib(node
, 'class').indexOf('mceItem') == -1) {
114 tinyMCE
.switchClass(editor_id
+ '_advimage', 'mceButtonSelected');
117 } while ((node
= node
.parentNode
));
119 tinyMCE
.switchClass(editor_id
+ '_advimage', 'mceButtonNormal');
125 * Returns the image src from a scripted mouse over image str.
127 * @param {string} s String to get real src from.
128 * @return Image src from a scripted mouse over image str.
131 _getImageSrc : function(s
) {
137 if ((p
= s
.indexOf('this.src=')) != -1) {
138 sr
= s
.substring(p
+ 10);
139 sr
= sr
.substring(0, sr
.indexOf('\''));
148 tinyMCE
.addPlugin("advimage", TinyMCE_AdvancedImagePlugin
);