]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/tinymce/plugins/media/plugin.js
WordPress 4.4
[autoinstalls/wordpress.git] / wp-includes / js / tinymce / plugins / media / plugin.js
index 3739f7051568a0a81804f965ae08b0cac68d0f03..d0baf7334cf2c4d9d11d3efa2fcf17bc9897c29b 100644 (file)
@@ -1,8 +1,8 @@
 /**
  * plugin.js
  *
- * Copyright, Moxiecode Systems AB
  * Released under LGPL License.
+ * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
  *
  * License: http://www.tinymce.com/license
  * Contributing: http://www.tinymce.com/contributing
 
 tinymce.PluginManager.add('media', function(editor, url) {
        var urlPatterns = [
-               {regex: /youtu\.be\/([\w\-.]+)/, type: 'iframe', w: 425, h: 350, url: '//www.youtube.com/embed/$1'},
-               {regex: /youtube\.com(.+)v=([^&]+)/, type: 'iframe', w: 425, h: 350, url: '//www.youtube.com/embed/$2'},
-               {regex: /vimeo\.com\/([0-9]+)/, type: 'iframe', w: 425, h: 350, url: '//player.vimeo.com/video/$1?title=0&byline=0&portrait=0&color=8dc7dc'},
-               {regex: /vimeo\.com\/(.*)\/([0-9]+)/, type: "iframe", w: 425, h: 350, url: "//player.vimeo.com/video/$2?title=0&byline=0"},
-               {regex: /maps\.google\.([a-z]{2,3})\/maps\/(.+)msid=(.+)/, type: 'iframe', w: 425, h: 350, url: '//maps.google.com/maps/ms?msid=$2&output=embed"'}
+               {regex: /youtu\.be\/([\w\-.]+)/, type: 'iframe', w: 425, h: 350, url: '//www.youtube.com/embed/$1', allowFullscreen: true},
+               {regex: /youtube\.com(.+)v=([^&]+)/, type: 'iframe', w: 425, h: 350, url: '//www.youtube.com/embed/$2', allowFullscreen: true},
+               {regex: /vimeo\.com\/([0-9]+)/, type: 'iframe', w: 425, h: 350, url: '//player.vimeo.com/video/$1?title=0&byline=0&portrait=0&color=8dc7dc', allowfullscreen: true},
+               {regex: /vimeo\.com\/(.*)\/([0-9]+)/, type: "iframe", w: 425, h: 350, url: "//player.vimeo.com/video/$2?title=0&byline=0", allowfullscreen: true},
+               {regex: /maps\.google\.([a-z]{2,3})\/maps\/(.+)msid=(.+)/, type: 'iframe', w: 425, h: 350, url: '//maps.google.com/maps/ms?msid=$2&output=embed"', allowFullscreen: false}
        ];
 
        var embedChange = (tinymce.Env.ie && tinymce.Env.ie <= 8) ? 'onChange' : 'onInput';
 
        function guessMime(url) {
+               url = url.toLowerCase();
+
                if (url.indexOf('.mp3') != -1) {
                        return 'audio/mpeg';
                }
@@ -94,10 +96,16 @@ tinymce.PluginManager.add('media', function(editor, url) {
                        if (win.find('#constrain')[0].checked() && width && height && newWidth && newHeight) {
                                if (e.control == widthCtrl) {
                                        newHeight = Math.round((newWidth / width) * newHeight);
-                                       heightCtrl.value(newHeight);
+
+                                       if (!isNaN(newHeight)) {
+                                               heightCtrl.value(newHeight);
+                                       }
                                } else {
                                        newWidth = Math.round((newHeight / height) * newWidth);
-                                       widthCtrl.value(newWidth);
+
+                                       if (!isNaN(newWidth)) {
+                                               widthCtrl.value(newWidth);
+                                       }
                                }
                        }
 
@@ -121,9 +129,9 @@ tinymce.PluginManager.add('media', function(editor, url) {
                                align: 'center',
                                spacing: 5,
                                items: [
-                                       {name: 'width', type: 'textbox', maxLength: 3, size: 3, onchange: recalcSize},
+                                       {name: 'width', type: 'textbox', maxLength: 5, size: 3, onchange: recalcSize, ariaLabel: 'Width'},
                                        {type: 'label', text: 'x'},
-                                       {name: 'height', type: 'textbox', maxLength: 3, size: 3, onchange: recalcSize},
+                                       {name: 'height', type: 'textbox', maxLength: 5, size: 3, onchange: recalcSize, ariaLabel: 'Height'},
                                        {name: 'constrain', type: 'checkbox', checked: true, text: 'Constrain proportions'}
                                ]
                        });
@@ -167,7 +175,7 @@ tinymce.PluginManager.add('media', function(editor, url) {
 
                                {
                                        title: 'Embed',
-                                       type: "panel",
+                                       type: "container",
                                        layout: 'flex',
                                        direction: 'column',
                                        align: 'stretch',
@@ -257,6 +265,7 @@ tinymce.PluginManager.add('media', function(editor, url) {
 
                                data.source1 = url;
                                data.type = pattern.type;
+                               data.allowFullscreen = pattern.allowFullscreen;
                                data.width = data.width || pattern.w;
                                data.height = data.height || pattern.h;
                        }
@@ -280,7 +289,8 @@ tinymce.PluginManager.add('media', function(editor, url) {
                        });
 
                        if (data.type == "iframe") {
-                               html += '<iframe src="' + data.source1 + '" width="' + data.width + '" height="' + data.height + '"></iframe>';
+                               var allowFullscreen = data.allowFullscreen ? ' allowFullscreen="1"' : '';
+                               html += '<iframe src="' + data.source1 + '" width="' + data.width + '" height="' + data.height + '"' + allowFullscreen + '></iframe>';
                        } else if (data.source1mime == "application/x-shockwave-flash") {
                                html += '<object data="' + data.source1 + '" width="' + data.width + '" height="' + data.height + '" type="application/x-shockwave-flash">';
 
@@ -386,7 +396,7 @@ tinymce.PluginManager.add('media', function(editor, url) {
                        return html;
                }
 
-               var writer = new tinymce.html.Writer();
+               var writer = new tinymce.html.Writer(), blocked;
 
                new tinymce.html.SaxParser({
                        validate: false,
@@ -406,6 +416,8 @@ tinymce.PluginManager.add('media', function(editor, url) {
                        },
 
                        start: function(name, attrs, empty) {
+                               blocked = true;
+
                                if (name == 'script' || name == 'noscript') {
                                        return;
                                }
@@ -414,13 +426,18 @@ tinymce.PluginManager.add('media', function(editor, url) {
                                        if (attrs[i].name.indexOf('on') === 0) {
                                                return;
                                        }
+
+                                       if (attrs[i].name == 'style') {
+                                               attrs[i].value = editor.dom.serializeStyle(editor.dom.parseStyle(attrs[i].value), name);
+                                       }
                                }
 
                                writer.start(name, attrs, empty);
+                               blocked = false;
                        },
 
                        end: function(name) {
-                               if (name == 'script' || name == 'noscript') {
+                               if (blocked) {
                                        return;
                                }
 
@@ -766,9 +783,13 @@ tinymce.PluginManager.add('media', function(editor, url) {
 
        editor.addMenuItem('media', {
                icon: 'media',
-               text: 'Insert video',
+               text: 'Insert/edit video',
                onclick: showDialog,
                context: 'insert',
                prependToContext: true
        });
+
+       editor.addCommand('mceMedia', showDialog);
+
+       this.showDialog = showDialog;
 });