equal
deleted
inserted
replaced
26 ["Video"], |
26 ["Video"], |
27 ["EmbeddedAudio"], |
27 ["EmbeddedAudio"], |
28 ["Audio"] |
28 ["Audio"] |
29 ]; |
29 ]; |
30 |
30 |
|
31 function normalizeSize(size) { |
|
32 return typeof(size) == "string" ? size.replace(/[^0-9%]/g, '') : size; |
|
33 } |
|
34 |
31 function toArray(obj) { |
35 function toArray(obj) { |
32 var undef, out, i; |
36 var undef, out, i; |
33 |
37 |
34 if (obj && !obj.splice) { |
38 if (obj && !obj.splice) { |
35 out = []; |
39 out = []; |
256 src : self.editor.theme.url + '/img/trans.gif', |
260 src : self.editor.theme.url + '/img/trans.gif', |
257 'class' : 'mceItemMedia mceItem' + self.getType(data.type).name, |
261 'class' : 'mceItemMedia mceItem' + self.getType(data.type).name, |
258 'data-mce-json' : JSON.serialize(data, "'") |
262 'data-mce-json' : JSON.serialize(data, "'") |
259 }); |
263 }); |
260 |
264 |
261 img.width = data.width || (data.type == 'audio' ? "300" : "320"); |
265 img.width = data.width = normalizeSize(data.width || (data.type == 'audio' ? "300" : "320")); |
262 img.height = data.height || (data.type == 'audio' ? "32" : "240"); |
266 img.height = data.height = normalizeSize(data.height || (data.type == 'audio' ? "32" : "240")); |
263 |
267 |
264 return img; |
268 return img; |
265 }, |
269 }, |
266 |
270 |
267 /** |
271 /** |
376 return; |
380 return; |
377 |
381 |
378 data = JSON.parse(data); |
382 data = JSON.parse(data); |
379 typeItem = this.getType(node.attr('class')); |
383 typeItem = this.getType(node.attr('class')); |
380 |
384 |
381 style = node.attr('data-mce-style') |
385 style = node.attr('data-mce-style'); |
382 if (!style) { |
386 if (!style) { |
383 style = node.attr('style'); |
387 style = node.attr('style'); |
384 |
388 |
385 if (style) |
389 if (style) |
386 style = editor.dom.serializeStyle(editor.dom.parseStyle(style, 'img')); |
390 style = editor.dom.serializeStyle(editor.dom.parseStyle(style, 'img')); |
387 } |
391 } |
|
392 |
|
393 // Use node width/height to override the data width/height when the placeholder is resized |
|
394 data.width = node.attr('width') || data.width; |
|
395 data.height = node.attr('height') || data.height; |
388 |
396 |
389 // Handle iframe |
397 // Handle iframe |
390 if (typeItem.name === 'Iframe') { |
398 if (typeItem.name === 'Iframe') { |
391 replacement = new Node('iframe', 1); |
399 replacement = new Node('iframe', 1); |
392 |
400 |
432 // Add HTML5 video element |
440 // Add HTML5 video element |
433 if (typeItem.name === 'Video' && data.video.sources[0]) { |
441 if (typeItem.name === 'Video' && data.video.sources[0]) { |
434 // Create new object element |
442 // Create new object element |
435 video = new Node('video', 1).attr(tinymce.extend({ |
443 video = new Node('video', 1).attr(tinymce.extend({ |
436 id : node.attr('id'), |
444 id : node.attr('id'), |
437 width: node.attr('width'), |
445 width: normalizeSize(node.attr('width')), |
438 height: node.attr('height'), |
446 height: normalizeSize(node.attr('height')), |
439 style : style |
447 style : style |
440 }, data.video.attrs)); |
448 }, data.video.attrs)); |
441 |
449 |
442 // Get poster source and use that for flash fallback |
450 // Get poster source and use that for flash fallback |
443 if (data.video.attrs) |
451 if (data.video.attrs) |
471 // Add HTML5 audio element |
479 // Add HTML5 audio element |
472 if (typeItem.name === 'Audio' && data.video.sources[0]) { |
480 if (typeItem.name === 'Audio' && data.video.sources[0]) { |
473 // Create new object element |
481 // Create new object element |
474 audio = new Node('audio', 1).attr(tinymce.extend({ |
482 audio = new Node('audio', 1).attr(tinymce.extend({ |
475 id : node.attr('id'), |
483 id : node.attr('id'), |
476 width: node.attr('width'), |
484 width: normalizeSize(node.attr('width')), |
477 height: node.attr('height'), |
485 height: normalizeSize(node.attr('height')), |
478 style : style |
486 style : style |
479 }, data.video.attrs)); |
487 }, data.video.attrs)); |
480 |
488 |
481 // Get poster source and use that for flash fallback |
489 // Get poster source and use that for flash fallback |
482 if (data.video.attrs) |
490 if (data.video.attrs) |
500 if (typeItem.name === 'EmbeddedAudio') { |
508 if (typeItem.name === 'EmbeddedAudio') { |
501 embed = new Node('embed', 1); |
509 embed = new Node('embed', 1); |
502 embed.shortEnded = true; |
510 embed.shortEnded = true; |
503 embed.attr({ |
511 embed.attr({ |
504 id: node.attr('id'), |
512 id: node.attr('id'), |
505 width: node.attr('width'), |
513 width: normalizeSize(node.attr('width')), |
506 height: node.attr('height'), |
514 height: normalizeSize(node.attr('height')), |
507 style : style, |
515 style : style, |
508 type: node.attr('type') |
516 type: node.attr('type') |
509 }); |
517 }); |
510 |
518 |
511 for (name in data.params) |
519 for (name in data.params) |
529 data.params.src = editor.documentBaseURI.toAbsolute(data.params.src); |
537 data.params.src = editor.documentBaseURI.toAbsolute(data.params.src); |
530 |
538 |
531 // Create new object element |
539 // Create new object element |
532 object = new Node('object', 1).attr({ |
540 object = new Node('object', 1).attr({ |
533 id : node.attr('id'), |
541 id : node.attr('id'), |
534 width: node.attr('width'), |
542 width: normalizeSize(node.attr('width')), |
535 height: node.attr('height'), |
543 height: normalizeSize(node.attr('height')), |
536 style : style |
544 style : style |
537 }); |
545 }); |
538 |
546 |
539 tinymce.each(rootAttributes, function(name) { |
547 tinymce.each(rootAttributes, function(name) { |
540 var value = data[name]; |
548 var value = data[name]; |
574 |
582 |
575 embed = new Node('embed', 1); |
583 embed = new Node('embed', 1); |
576 embed.shortEnded = true; |
584 embed.shortEnded = true; |
577 embed.attr({ |
585 embed.attr({ |
578 id: node.attr('id'), |
586 id: node.attr('id'), |
579 width: node.attr('width'), |
587 width: normalizeSize(node.attr('width')), |
580 height: node.attr('height'), |
588 height: normalizeSize(node.attr('height')), |
581 style : style, |
589 style : style, |
582 type: typeItem.mimes[0] |
590 type: typeItem.mimes[0] |
583 }); |
591 }); |
584 |
592 |
585 for (name in data.params) |
593 for (name in data.params) |
791 } |
799 } |
792 } |
800 } |
793 |
801 |
794 if (iframe) { |
802 if (iframe) { |
795 // Get width/height |
803 // Get width/height |
796 width = iframe.attr('width'); |
804 width = normalizeSize(iframe.attr('width')); |
797 height = iframe.attr('height'); |
805 height = normalizeSize(iframe.attr('height')); |
798 style = style || iframe.attr('style'); |
806 style = style || iframe.attr('style'); |
799 id = iframe.attr('id'); |
807 id = iframe.attr('id'); |
800 hspace = iframe.attr('hspace'); |
808 hspace = iframe.attr('hspace'); |
801 vspace = iframe.attr('vspace'); |
809 vspace = iframe.attr('vspace'); |
802 align = iframe.attr('align'); |
810 align = iframe.attr('align'); |