39 if (/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/.test(dom.getAttrib(n, 'onmouseover'))) |
39 if (/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/.test(dom.getAttrib(n, 'onmouseover'))) |
40 nl.onmouseoversrc.value = dom.getAttrib(n, 'onmouseover').replace(/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/, '$1'); |
40 nl.onmouseoversrc.value = dom.getAttrib(n, 'onmouseover').replace(/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/, '$1'); |
41 |
41 |
42 if (/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/.test(dom.getAttrib(n, 'onmouseout'))) |
42 if (/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/.test(dom.getAttrib(n, 'onmouseout'))) |
43 nl.onmouseoutsrc.value = dom.getAttrib(n, 'onmouseout').replace(/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/, '$1'); |
43 nl.onmouseoutsrc.value = dom.getAttrib(n, 'onmouseout').replace(/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/, '$1'); |
|
44 |
|
45 if (ed.settings.inline_styles) { |
|
46 // Move attribs to styles |
|
47 if (dom.getAttrib(n, 'align')) |
|
48 this.updateStyle('align'); |
|
49 |
|
50 if (dom.getAttrib(n, 'hspace')) |
|
51 this.updateStyle('hspace'); |
|
52 |
|
53 if (dom.getAttrib(n, 'border')) |
|
54 this.updateStyle('border'); |
|
55 |
|
56 if (dom.getAttrib(n, 'vspace')) |
|
57 this.updateStyle('vspace'); |
|
58 } |
44 } |
59 } |
45 |
60 |
46 // Setup browse button |
61 // Setup browse button |
47 document.getElementById('srcbrowsercontainer').innerHTML = getBrowserHTML('srcbrowser','src','image','theme_advanced_image'); |
62 document.getElementById('srcbrowsercontainer').innerHTML = getBrowserHTML('srcbrowser','src','image','theme_advanced_image'); |
48 if (isVisible('srcbrowser')) |
63 if (isVisible('srcbrowser')) |
67 this.setSwapImage(true); |
82 this.setSwapImage(true); |
68 else |
83 else |
69 this.setSwapImage(false); |
84 this.setSwapImage(false); |
70 |
85 |
71 this.changeAppearance(); |
86 this.changeAppearance(); |
72 this.updateStyle(); |
|
73 this.showPreviewImage(nl.src.value, 1); |
87 this.showPreviewImage(nl.src.value, 1); |
74 }, |
88 }, |
75 |
89 |
76 insert : function(file, title) { |
90 insert : function(file, title) { |
77 var t = this; |
91 var ed = tinyMCEPopup.editor, t = this, f = document.forms[0]; |
|
92 |
|
93 if (f.src.value === '') { |
|
94 ed.dom.remove(ed.selection.getNode()); |
|
95 ed.execCommand('mceRepaint'); |
|
96 tinyMCEPopup.close(); |
|
97 return; |
|
98 } |
78 |
99 |
79 if (tinyMCEPopup.getParam("accessibility_warnings", 1)) { |
100 if (tinyMCEPopup.getParam("accessibility_warnings", 1)) { |
80 if (!document.forms[0].alt.value) { |
101 if (!f.alt.value) { |
81 tinyMCEPopup.editor.windowManager.confirm(tinyMCEPopup.getLang('advimage_dlg.missing_alt'), function(s) { |
102 tinyMCEPopup.editor.windowManager.confirm(tinyMCEPopup.getLang('advimage_dlg.missing_alt'), function(s) { |
82 if (s) |
103 if (s) |
83 t.insertAndClose(); |
104 t.insertAndClose(); |
84 }); |
105 }); |
85 |
106 |
96 // Fixes crash in Safari |
117 // Fixes crash in Safari |
97 if (tinymce.isWebKit) |
118 if (tinymce.isWebKit) |
98 ed.getWin().focus(); |
119 ed.getWin().focus(); |
99 |
120 |
100 if (!ed.settings.inline_styles) { |
121 if (!ed.settings.inline_styles) { |
101 args = tinymce.extend(args, { |
122 args = { |
102 vspace : nl.vspace.value, |
123 vspace : nl.vspace.value, |
103 hspace : nl.hspace.value, |
124 hspace : nl.hspace.value, |
104 border : nl.border.value, |
125 border : nl.border.value, |
105 align : getSelectValue(f, 'align') |
126 align : getSelectValue(f, 'align') |
106 }); |
127 }; |
|
128 } else { |
|
129 // Remove deprecated values |
|
130 args = { |
|
131 vspace : '', |
|
132 hspace : '', |
|
133 border : '', |
|
134 align : '' |
|
135 }; |
107 } |
136 } |
108 |
137 |
109 tinymce.extend(args, { |
138 tinymce.extend(args, { |
110 src : nl.src.value, |
139 src : nl.src.value, |
111 width : nl.width.value, |
140 width : nl.width.value, |
119 lang : nl.lang.value, |
148 lang : nl.lang.value, |
120 usemap : nl.usemap.value, |
149 usemap : nl.usemap.value, |
121 longdesc : nl.longdesc.value |
150 longdesc : nl.longdesc.value |
122 }); |
151 }); |
123 |
152 |
124 if (nl.onmouseoversrc.value) |
153 args.onmouseover = args.onmouseout = ''; |
125 args.onmouseover = "this.src='" + nl.onmouseoversrc.value + "';"; |
154 |
126 |
155 if (f.onmousemovecheck.checked) { |
127 if (nl.onmouseoutsrc.value) |
156 if (nl.onmouseoversrc.value) |
128 args.onmouseout = "this.src='" + nl.onmouseoutsrc.value + "';"; |
157 args.onmouseover = "this.src='" + nl.onmouseoversrc.value + "';"; |
|
158 |
|
159 if (nl.onmouseoutsrc.value) |
|
160 args.onmouseout = "this.src='" + nl.onmouseoutsrc.value + "';"; |
|
161 } |
129 |
162 |
130 el = ed.selection.getNode(); |
163 el = ed.selection.getNode(); |
131 |
164 |
132 if (el && el.nodeName == 'IMG') { |
165 if (el && el.nodeName == 'IMG') { |
133 ed.dom.setAttribs(el, args); |
166 ed.dom.setAttribs(el, args); |
289 |
323 |
290 changeHeight : function() { |
324 changeHeight : function() { |
291 var f = document.forms[0], tp, t = this; |
325 var f = document.forms[0], tp, t = this; |
292 |
326 |
293 if (!f.constrain.checked || !t.preloadImg) { |
327 if (!f.constrain.checked || !t.preloadImg) { |
294 t.updateStyle(); |
|
295 return; |
328 return; |
296 } |
329 } |
297 |
330 |
298 if (f.width.value == "" || f.height.value == "") |
331 if (f.width.value == "" || f.height.value == "") |
299 return; |
332 return; |
300 |
333 |
301 tp = (parseInt(f.width.value) / parseInt(t.preloadImg.width)) * t.preloadImg.height; |
334 tp = (parseInt(f.width.value) / parseInt(t.preloadImg.width)) * t.preloadImg.height; |
302 f.height.value = tp.toFixed(0); |
335 f.height.value = tp.toFixed(0); |
303 t.updateStyle(); |
|
304 }, |
336 }, |
305 |
337 |
306 changeWidth : function() { |
338 changeWidth : function() { |
307 var f = document.forms[0], tp, t = this; |
339 var f = document.forms[0], tp, t = this; |
308 |
340 |
309 if (!f.constrain.checked || !t.preloadImg) { |
341 if (!f.constrain.checked || !t.preloadImg) { |
310 t.updateStyle(); |
|
311 return; |
342 return; |
312 } |
343 } |
313 |
344 |
314 if (f.width.value == "" || f.height.value == "") |
345 if (f.width.value == "" || f.height.value == "") |
315 return; |
346 return; |
316 |
347 |
317 tp = (parseInt(f.height.value) / parseInt(t.preloadImg.height)) * t.preloadImg.width; |
348 tp = (parseInt(f.height.value) / parseInt(t.preloadImg.height)) * t.preloadImg.width; |
318 f.width.value = tp.toFixed(0); |
349 f.width.value = tp.toFixed(0); |
319 t.updateStyle(); |
350 }, |
320 }, |
351 |
321 |
352 updateStyle : function(ty) { |
322 updateStyle : function() { |
353 var dom = tinyMCEPopup.dom, st, v, f = document.forms[0], img = dom.create('img', {style : dom.get('style').value}); |
323 var dom = tinyMCEPopup.dom, st, v, f = document.forms[0]; |
|
324 |
354 |
325 if (tinyMCEPopup.editor.settings.inline_styles) { |
355 if (tinyMCEPopup.editor.settings.inline_styles) { |
326 st = tinyMCEPopup.dom.parseStyle(dom.get('style').value); |
|
327 |
|
328 // Handle align |
356 // Handle align |
329 v = getSelectValue(f, 'align'); |
357 if (ty == 'align') { |
330 if (v) { |
358 dom.setStyle(img, 'float', ''); |
331 if (v == 'left' || v == 'right') { |
359 dom.setStyle(img, 'vertical-align', ''); |
332 st['float'] = v; |
360 |
333 delete st['vertical-align']; |
361 v = getSelectValue(f, 'align'); |
334 } else { |
362 if (v) { |
335 st['vertical-align'] = v; |
363 if (v == 'left' || v == 'right') |
336 delete st['float']; |
364 dom.setStyle(img, 'float', v); |
|
365 else |
|
366 img.style.verticalAlign = v; |
337 } |
367 } |
338 } else { |
|
339 delete st['float']; |
|
340 delete st['vertical-align']; |
|
341 } |
368 } |
342 |
369 |
343 // Handle border |
370 // Handle border |
344 v = f.border.value; |
371 if (ty == 'border') { |
345 if (v || v == '0') { |
372 dom.setStyle(img, 'border', ''); |
346 if (v == '0') |
373 |
347 st['border'] = '0'; |
374 v = f.border.value; |
348 else |
375 if (v || v == '0') { |
349 st['border'] = v + 'px solid black'; |
376 if (v == '0') |
350 } else |
377 img.style.border = ''; |
351 delete st['border']; |
378 else |
|
379 img.style.border = v + 'px solid black'; |
|
380 } |
|
381 } |
352 |
382 |
353 // Handle hspace |
383 // Handle hspace |
354 v = f.hspace.value; |
384 if (ty == 'hspace') { |
355 if (v) { |
385 dom.setStyle(img, 'marginLeft', ''); |
356 delete st['margin']; |
386 dom.setStyle(img, 'marginRight', ''); |
357 st['margin-left'] = v + 'px'; |
387 |
358 st['margin-right'] = v + 'px'; |
388 v = f.hspace.value; |
359 } else { |
389 if (v) { |
360 delete st['margin-left']; |
390 img.style.marginLeft = v + 'px'; |
361 delete st['margin-right']; |
391 img.style.marginRight = v + 'px'; |
|
392 } |
362 } |
393 } |
363 |
394 |
364 // Handle vspace |
395 // Handle vspace |
365 v = f.vspace.value; |
396 if (ty == 'vspace') { |
366 if (v) { |
397 dom.setStyle(img, 'marginTop', ''); |
367 delete st['margin']; |
398 dom.setStyle(img, 'marginBottom', ''); |
368 st['margin-top'] = v + 'px'; |
399 |
369 st['margin-bottom'] = v + 'px'; |
400 v = f.vspace.value; |
370 } else { |
401 if (v) { |
371 delete st['margin-top']; |
402 img.style.marginTop = v + 'px'; |
372 delete st['margin-bottom']; |
403 img.style.marginBottom = v + 'px'; |
|
404 } |
373 } |
405 } |
374 |
406 |
375 // Merge |
407 // Merge |
376 st = tinyMCEPopup.dom.parseStyle(dom.serializeStyle(st)); |
408 dom.get('style').value = dom.serializeStyle(dom.parseStyle(img.style.cssText)); |
377 dom.get('style').value = dom.serializeStyle(st); |
|
378 } |
409 } |
379 }, |
410 }, |
380 |
411 |
381 changeMouseMove : function() { |
412 changeMouseMove : function() { |
382 }, |
413 }, |