X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/41578db67d72562346e4dbb2a14889b23d522813..a9fa37e08fa731c7bd108a175c24876823bc071b:/wp-includes/js/tinymce/plugins/media/plugin.js
diff --git a/wp-includes/js/tinymce/plugins/media/plugin.js b/wp-includes/js/tinymce/plugins/media/plugin.js
index a97d5a06..21a2c8cf 100644
--- a/wp-includes/js/tinymce/plugins/media/plugin.js
+++ b/wp-includes/js/tinymce/plugins/media/plugin.js
@@ -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
@@ -14,13 +14,20 @@
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: /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: 560, h: 314, url: '//www.youtube.com/embed/$1', allowFullscreen: true},
+ {regex: /youtube\.com(.+)v=([^&]+)/, type: 'iframe', w: 560, h: 314, url: '//www.youtube.com/embed/$2', allowFullscreen: true},
+ {regex: /youtube.com\/embed\/([a-z0-9\-_]+)/i, type: 'iframe', w: 560, h: 314, url: '//www.youtube.com/embed/$1', 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},
+ {regex: /dailymotion\.com\/video\/([^_]+)/, type: 'iframe', w: 480, h: 270, url: '//www.dailymotion.com/embed/video/$1', allowFullscreen: true}
];
+ 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';
}
@@ -62,8 +69,21 @@ tinymce.PluginManager.add('media', function(editor, url) {
function showDialog() {
var win, width, height, data;
+
var generalFormItems = [
- {name: 'source1', type: 'filepicker', filetype: 'media', size: 40, autofocus: true, label: 'Source'}
+ {
+ name: 'source1',
+ type: 'filepicker',
+ filetype: 'media',
+ size: 40,
+ autofocus: true,
+ label: 'Source',
+ onchange: function(e) {
+ tinymce.each(e.meta, function(value, key) {
+ win.find('#' + key).value(value);
+ });
+ }
+ }
];
function recalcSize(e) {
@@ -78,10 +98,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);
+ }
}
}
@@ -105,9 +131,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'}
]
});
@@ -117,6 +143,23 @@ tinymce.PluginManager.add('media', function(editor, url) {
width = data.width;
height = data.height;
+ var embedTextBox = {
+ id: 'mcemediasource',
+ type: 'textbox',
+ flex: 1,
+ name: 'embed',
+ value: getSource(),
+ multiline: true,
+ label: 'Source'
+ };
+
+ function updateValueOnChange() {
+ data = htmlToData(this.value());
+ this.parent().parent().fromJSON(data);
+ }
+
+ embedTextBox[embedChange] = updateValueOnChange;
+
win = editor.windowManager.open({
title: 'Insert/edit video',
data: data,
@@ -134,7 +177,7 @@ tinymce.PluginManager.add('media', function(editor, url) {
{
title: 'Embed',
- type: "panel",
+ type: "container",
layout: 'flex',
direction: 'column',
align: 'stretch',
@@ -149,20 +192,28 @@ tinymce.PluginManager.add('media', function(editor, url) {
text: 'Paste your embed code below:',
forId: 'mcemediasource'
},
- {
- id: 'mcemediasource',
- type: 'textbox',
- flex: 1,
- name: 'embed',
- value: getSource(),
- multiline: true,
- label: 'Source'
- }
+ embedTextBox
]
}
],
onSubmit: function() {
+ var beforeObjects, afterObjects, i, y;
+
+ beforeObjects = editor.dom.select('img[data-mce-object]');
editor.insertContent(dataToHtml(this.toJSON()));
+ afterObjects = editor.dom.select('img[data-mce-object]');
+
+ // Find new image placeholder so we can select it
+ for (i = 0; i < beforeObjects.length; i++) {
+ for (y = afterObjects.length - 1; y >= 0; y--) {
+ if (beforeObjects[i] == afterObjects[y]) {
+ afterObjects.splice(y, 1);
+ }
+ }
+ }
+
+ editor.selection.select(afterObjects[0]);
+ editor.nodeChanged();
}
});
}
@@ -200,30 +251,31 @@ tinymce.PluginManager.add('media', function(editor, url) {
data.poster = editor.convertURL(data.poster, "poster");
data.flashPlayerUrl = editor.convertURL(url + '/moxieplayer.swf', "movie");
- if (data.embed) {
- html = updateHtml(data.embed, data, true);
- } else {
- tinymce.each(urlPatterns, function(pattern) {
- var match, i, url;
+ tinymce.each(urlPatterns, function(pattern) {
+ var match, i, url;
- if ((match = pattern.regex.exec(data.source1))) {
- url = pattern.url;
+ if ((match = pattern.regex.exec(data.source1))) {
+ url = pattern.url;
- for (i = 0; match[i]; i++) {
- /*jshint loopfunc:true*/
- /*eslint no-loop-func:0 */
- url = url.replace('$' + i, function() {
- return match[i];
- });
- }
-
- data.source1 = url;
- data.type = pattern.type;
- data.width = data.width || pattern.w;
- data.height = data.height || pattern.h;
+ for (i = 0; match[i]; i++) {
+ /*jshint loopfunc:true*/
+ /*eslint no-loop-func:0 */
+ url = url.replace('$' + i, function() {
+ return match[i];
+ });
}
- });
+ data.source1 = url;
+ data.type = pattern.type;
+ data.allowFullscreen = pattern.allowFullscreen;
+ data.width = data.width || pattern.w;
+ data.height = data.height || pattern.h;
+ }
+ });
+
+ if (data.embed) {
+ html = updateHtml(data.embed, data, true);
+ } else {
var videoScript = getVideoScriptMatch(data.source1);
if (videoScript) {
data.type = 'script';
@@ -239,7 +291,8 @@ tinymce.PluginManager.add('media', function(editor, url) {
});
if (data.type == "iframe") {
- html += '';
+ var allowFullscreen = data.allowFullscreen ? ' allowFullscreen="1"' : '';
+ html += '';
} else if (data.source1mime == "application/x-shockwave-flash") {
html += '