diff --git a/www/pad/mediatag-plugin-dialog.js b/www/pad/mediatag-plugin-dialog.js index 472525edd..44503af9b 100644 --- a/www/pad/mediatag-plugin-dialog.js +++ b/www/pad/mediatag-plugin-dialog.js @@ -1,5 +1,19 @@ CKEDITOR.dialog.add('mediatag', function (editor) { var Messages = CKEDITOR._mediatagTranslations; + var isReadOnly = function (el) { + if (!el) { return; } + var parent = el; + while (parent) { + if (parent.nodeName.toUpperCase() === 'BODY') { + // I'm not sure why "false" is a string and not a boolean here + // but that's how it is and I'm scared to touch it + // --ansuz + return parent.getAttribute("contenteditable") === 'false'; + } + parent = parent.parentElement; + } + }; + return { title: Messages.title, minWidth: 400, @@ -118,6 +132,14 @@ CKEDITOR.dialog.add('mediatag', function (editor) { update(); }); + // disable all of the dialog's inputs if it is opened while in read-only mode + if (isReadOnly(element && element.$)) { + Array.prototype.slice.call(inputs).forEach(function (node) { + node.setAttribute('disabled', true); + }); + return; + } + setTimeout(update); }, onOk: function() {