diff --git a/includes/media.browser.inc b/includes/media.browser.inc
index 626fc00..1ac3c81 100644
--- a/includes/media.browser.inc
+++ b/includes/media.browser.inc
@@ -77,8 +77,8 @@ function media_browser($selected = NULL) {
continue;
}
- // We need to get a submit and cancel button on each tab. If the plugin
- // is not returning a form element we need to add a submit button.
+ // We need to ensure that a submit button is available on each tab. If the
+ // plugin is not returning a form element we need to add a submit button.
// This is a fairly broad assumption.
if (empty($plugin_output[$key]['#form']) && !empty($plugin_output[$key]['#markup'])) {
$fake_buttons = '
';
@@ -87,34 +87,9 @@ function media_browser($selected = NULL) {
'class' => array('button', 'button-yes', 'fake-submit', $key),
),
));
- $fake_buttons .= l(t('Cancel'), '', array(
- 'attributes' => array(
- 'class' => array('button', 'button-no', 'fake-cancel', $key),
- ),
- ));
$fake_buttons .= '
';
$plugin_output[$key]['#markup'] .= $fake_buttons;
}
-
- // I'm not sure if it is ever the case that a plugin form will ever have
- // the correct cancel button so we add it here. Put it inline with the
- // current submit button. This is a fairly broad assumption.
- if (!empty($plugin_output[$key]['form']['actions']) && !isset($plugin_output[$key]['form']['actions']['cancel'])) {
- $plugin_output[$key]['form']['actions']['cancel'] = array(
- '#type' => 'link',
- '#title' => t('Cancel'),
- '#href' => '',
- '#attributes' => array(
- 'class' => array(
- 'button',
- 'button-no',
- 'fake-cancel',
- $key,
- ),
- ),
- '#weight' => 100,
- );
- }
}
// Allow modules to change the tab names or whatever else they want to change
@@ -162,10 +137,6 @@ function media_browser($selected = NULL) {
drupal_add_js($settings, 'setting');
- $output['title'] = array(
- '#markup' => t('Select a file')
- );
-
$output['tabset']['tabs'] = array(
'#theme' => 'menu_local_tasks',
'#attributes' => array('class' => array('tabs', 'primary')),
diff --git a/js/media.browser.js b/js/media.browser.js
index 236df27..4c40946 100644
--- a/js/media.browser.js
+++ b/js/media.browser.js
@@ -45,17 +45,16 @@ Drupal.media.browser.launch = function () {
Drupal.media.browser.validateButtons = function() {
// The media browser runs in an IFRAME. The Drupal.media.popups.mediaBrowser()
- // function sets up the IFRAME and "OK" and "Cancel" buttons that are outside
- // of the IFRAME, so that their click handlers can destroy the IFRAME while
- // retaining information about what media items were selected. However,
- // Drupal UI convention is to place all action buttons on the same "line"
- // at the bottom of the form, so if the form within the IFRAME contains a
- // "Submit" button or other action buttons, then the "OK" and "Cancel"
- // buttons below the IFRAME break this convention and confuse the user.
- // Therefore, we add "Submit" and "Cancel" buttons inside the IFRAME, and
- // have their click action trigger the click action of the corresonding
- // "OK" and "Cancel" buttons that are outside the IFRAME. media.css contains
- // CSS rules that hide the outside buttons.
+ // function sets up the IFRAME and an "OK" button that is outside of the
+ // IFRAME, so that its click handlers can destroy the IFRAME while retaining
+ // information about what media items were selected. However, Drupal UI
+ // convention is to place all action buttons on the same "line" at the bottom
+ // of the form, so if the form within the IFRAME contains a "Submit" button or
+ // other action buttons, then the "OK" button will appear below the IFRAME
+ // which breaks this convention and is confusing to the user. Therefore, we
+ // add a "Submit" button inside the IFRAME, and have its click action trigger
+ // the click action of the corresponding "OK" button that is outside the
+ // IFRAME. media.css contains CSS rules that hide the outside buttons.
// If a submit button is present, another round-trip to the server is needed
// before the user's selection is finalized. For these cases, when the form's
@@ -65,24 +64,18 @@ Drupal.media.browser.validateButtons = function() {
// Drupal.media.popups.mediaBrowser.mediaBrowserOnLoad() auto-triggers the
// "OK" button action to finalize the selection and remove the IFRAME.
- // We need to check for the fake submit/cancel buttons that are used on
- // non-form based pane content. On these items we need to bind the clicks
- // so that media can be selected or the window can be closed. This is still a
- // hacky approach, but it is a step in the right direction.
+ // We need to check for the fake submit button that is used on non-form based
+ // pane content. On these items we need to bind the clicks so that media can
+ // be selected or the window can be closed. This is still a hacky approach,
+ // but it is a step in the right direction.
$('a.button.fake-submit', this).once().bind('click', Drupal.media.browser.submit);
- $('a.button.fake-cancel', this).once().bind('click', Drupal.media.browser.submit);
};
Drupal.media.browser.submit = function () {
// @see Drupal.media.browser.validateButtons().
var buttons = $(parent.window.document.body).find('#mediaBrowser').parent('.ui-dialog').find('.ui-dialog-buttonpane button');
- if ($(this).hasClass('fake-cancel')) {
- buttons[1].click();
- }
- else {
- buttons[0].click();
- }
+ buttons[0].click();
// Return false to prevent the fake link "click" from continuing.
return false;
diff --git a/js/media.popups.js b/js/media.popups.js
index 46af675..0aad651 100644
--- a/js/media.popups.js
+++ b/js/media.popups.js
@@ -63,12 +63,10 @@ Drupal.media.popups.mediaBrowser = function (onSelect, globalOptions, pluginOpti
*/
var ok = 'OK';
- var cancel = 'Cancel';
var notSelected = 'You have not selected anything!';
if (Drupal && Drupal.t) {
ok = Drupal.t(ok);
- cancel = Drupal.t(cancel);
notSelected = Drupal.t(notSelected);
}
@@ -85,15 +83,8 @@ Drupal.media.popups.mediaBrowser = function (onSelect, globalOptions, pluginOpti
$(this).dialog("close");
};
- dialogOptions.buttons[cancel] = function () {
- $(this).dialog("close");
- };
-
var dialog = mediaIframe.dialog(dialogOptions);
- // Remove the title bar.
- dialog.parents(".ui-dialog").find(".ui-dialog-titlebar").remove();
-
Drupal.media.popups.sizeDialog(dialog);
Drupal.media.popups.resizeDialog(dialog);
Drupal.media.popups.scrollDialog(dialog);
@@ -166,12 +157,10 @@ Drupal.media.popups.mediaStyleSelector = function (mediaFile, onSelect, options)
* Set up the button text
*/
var ok = 'OK';
- var cancel = 'Cancel';
var notSelected = 'Very sorry, there was an unknown error embedding media.';
if (Drupal && Drupal.t) {
ok = Drupal.t(ok);
- cancel = Drupal.t(cancel);
notSelected = Drupal.t(notSelected);
}
@@ -189,15 +178,8 @@ Drupal.media.popups.mediaStyleSelector = function (mediaFile, onSelect, options)
$(this).dialog("close");
};
- dialogOptions.buttons[cancel] = function () {
- $(this).dialog("close");
- };
-
var dialog = mediaIframe.dialog(dialogOptions);
- // Remove the title bar.
- dialog.parents(".ui-dialog").find(".ui-dialog-titlebar").remove();
-
Drupal.media.popups.sizeDialog(dialog);
Drupal.media.popups.resizeDialog(dialog);
Drupal.media.popups.scrollDialog(dialog);
@@ -247,12 +229,10 @@ Drupal.media.popups.mediaFieldEditor = function (fid, onSelect, options) {
* Set up the button text
*/
var ok = 'OK';
- var cancel = 'Cancel';
var notSelected = 'Very sorry, there was an unknown error embedding media.';
if (Drupal && Drupal.t) {
ok = Drupal.t(ok);
- cancel = Drupal.t(cancel);
notSelected = Drupal.t(notSelected);
}
@@ -269,15 +249,8 @@ Drupal.media.popups.mediaFieldEditor = function (fid, onSelect, options) {
$(this).dialog("close");
};
- dialogOptions.buttons[cancel] = function () {
- $(this).dialog("close");
- };
-
var dialog = mediaIframe.dialog(dialogOptions);
- // Remove the title bar.
- dialog.parents(".ui-dialog").find(".ui-dialog-titlebar").remove();
-
Drupal.media.popups.sizeDialog(dialog);
Drupal.media.popups.resizeDialog(dialog);
Drupal.media.popups.scrollDialog(dialog);
@@ -308,6 +281,7 @@ Drupal.media.popups.mediaFieldEditor.getDefaults = function () {
*/
Drupal.media.popups.getDialogOptions = function () {
return {
+ title: Drupal.t('Media browser'),
buttons: {},
dialogClass: 'media-wrapper',
modal: true,
diff --git a/modules/media_wysiwyg/js/media_wysiwyg.format_form.js b/modules/media_wysiwyg/js/media_wysiwyg.format_form.js
index 23413a8..4a6c05e 100644
--- a/modules/media_wysiwyg/js/media_wysiwyg.format_form.js
+++ b/modules/media_wysiwyg/js/media_wysiwyg.format_form.js
@@ -12,15 +12,13 @@ Drupal.media.mediaFormatSelected = {};
Drupal.behaviors.mediaFormatForm = {
attach: function (context, settings) {
-
- // Add "Submit" and "Cancel" buttons inside the IFRAME that trigger the
- // behavior of the hidden "OK" and "Cancel" buttons that are outside the
- // IFRAME. See Drupal.media.browser.validateButtons() for more details.
+ // Add the "Submit" button inside the IFRAME that trigger the behavior of
+ // the hidden "OK" button that is outside the IFRAME.
+ // @see Drupal.media.browser.validateButtons() for more details.
// @note I think this should be handled in media.browser.js in
- // Drupal.media.browser.validateButtons but I'm not sure how crufty
- // this particular functionality is. We should evaluate if it is still
- // needed.
+ // Drupal.media.browser.validateButtons but I'm not sure how crufty this
+ // particular functionality is. We should evaluate if it is still needed.
// @TODO can these be added to the content being displayed via form_alter?
@@ -28,7 +26,6 @@ Drupal.behaviors.mediaFormatForm = {
// buttons from being added if part of the form is updated via AJAX
$('#media-wysiwyg-format-form').once('format', function() {
$('' + Drupal.t('Submit') + '').appendTo($('#media-wysiwyg-format-form')).bind('click', Drupal.media.formatForm.submit);
- $('' + Drupal.t('Cancel') + '').appendTo($('#media-wysiwyg-format-form')).bind('click', Drupal.media.formatForm.submit);
});
}
};
@@ -47,11 +44,7 @@ Drupal.media.formatForm.getFormattedMedia = function () {
Drupal.media.formatForm.submit = function () {
// @see Drupal.behaviors.mediaFormatForm.attach().
var buttons = $(parent.window.document.body).find('#mediaStyleSelector').parent('.ui-dialog').find('.ui-dialog-buttonpane button');
- if ($(this).hasClass('fake-cancel')) {
- buttons[1].click();
- } else {
- buttons[0].click();
- }
+ buttons[0].click();
}
})(jQuery);