diff --git a/lib/form/dndupload.js b/lib/form/dndupload.js index 0cdeeee21fd..bbadd5c03f6 100644 --- a/lib/form/dndupload.js +++ b/lib/form/dndupload.js @@ -170,7 +170,7 @@ M.form_dndupload.init = function(Y, options) { * @return bool - true if disabled */ is_disabled: function() { - return this.container.hasClass('disabled'); + return (this.container.ancestor('.fitem.disabled') != null); }, /** diff --git a/lib/form/filemanager.js b/lib/form/filemanager.js index 164c6834a4b..cbd528a71d5 100644 --- a/lib/form/filemanager.js +++ b/lib/form/filemanager.js @@ -255,6 +255,9 @@ M.form_filemanager.init = function(Y, options) { this.msg_dlg_node.one('.fp-msg-text').setContent(msg); this.msg_dlg.show(); }, + is_disabled: function() { + return this.filemanager.ancestor('.fitem.disabled') != null; + }, setup_buttons: function() { var button_download = this.filemanager.one('.fp-btn-download'); var button_create = this.filemanager.one('.fp-btn-mkdir'); @@ -272,6 +275,9 @@ M.form_filemanager.init = function(Y, options) { if (this.options.subdirs) { button_create.on('click',function(e) { e.preventDefault(); + if (this.is_disabled()) { + return; + } var scope = this; // a function used to perform an ajax request var perform_action = function(e) { @@ -325,6 +331,9 @@ M.form_filemanager.init = function(Y, options) { // setup 'download this folder' button button_download.on('click',function(e) { e.preventDefault(); + if (this.is_disabled()) { + return; + } var scope = this; // perform downloaddir ajax request this.request({ @@ -351,7 +360,7 @@ M.form_filemanager.init = function(Y, options) { on('click', function(e) { e.preventDefault(); var viewbar = this.filemanager.one('.fp-viewbar') - if (!viewbar || !viewbar.hasClass('disabled')) { + if (!this.is_disabled() && (!viewbar || !viewbar.hasClass('disabled'))) { this.filemanager.all('.fp-vb-icons,.fp-vb-tree,.fp-vb-details').removeClass('checked') if (e.currentTarget.hasClass('fp-vb-tree')) { this.viewmode = 2; @@ -369,6 +378,9 @@ M.form_filemanager.init = function(Y, options) { show_filepicker: function (e) { // if maxfiles == -1, the no limit e.preventDefault(); + if (this.is_disabled()) { + return; + } var options = this.filepicker_options; options.formcallback = this.filepicker_callback; // XXX: magic here, to let filepicker use filemanager scope @@ -400,7 +412,9 @@ M.form_filemanager.init = function(Y, options) { el.one('.fp-path-folder-name').setContent(p[i].name). on('click', function(e, path) { e.preventDefault(); - this.refresh(path); + if (!this.is_disabled()) { + this.refresh(path); + } }, this, p[i].path); } this.pathbar.removeClass('empty'); @@ -873,6 +887,9 @@ M.form_filemanager.init = function(Y, options) { return node.filepath; }, select_file: function(node) { + if (this.is_disabled()) { + return; + } var selectnode = this.selectnode; selectnode.removeClass('loading').removeClass('fp-folder'). removeClass('fp-file').removeClass('fp-zip').removeClass('fp-cansetmain'); diff --git a/lib/form/filepicker.js b/lib/form/filepicker.js index e372a23c086..b2811a25dbc 100644 --- a/lib/form/filepicker.js +++ b/lib/form/filepicker.js @@ -32,7 +32,9 @@ M.form_filepicker.init = function(Y, options) { } Y.on('click', function(e, client_id) { e.preventDefault(); - M.core_filepicker.instances[client_id].show(); + if (this.ancestor('.fitem.disabled') == null) { + M.core_filepicker.instances[client_id].show(); + } }, '#filepicker-button-'+options.client_id, null, options.client_id); var item = document.getElementById('nonjs-filepicker-'+options.client_id); diff --git a/lib/form/form.js b/lib/form/form.js index 2dd75f498f0..b49d76a0437 100644 --- a/lib/form/form.js +++ b/lib/form/form.js @@ -207,20 +207,14 @@ M.form.initFormDependencies = function(Y, formid, dependencies) { this.removeAttribute('disabled'); } - // Extra code to disable a filepicker - if (this.getAttribute('class') == 'filepickerhidden'){ - var pickerbuttons = form.elementsByName(name + 'choose'); - pickerbuttons.each(function(){ - var clientid = this.get('id').split('-')[2]; - var filepicker = Y.one('#file_info_'+clientid); - if (disabled){ - this.setAttribute('disabled','disabled'); - filepicker.addClass('disabled'); - } else { - this.removeAttribute('disabled'); - filepicker.removeClass('disabled'); - } - }); + // Extra code to disable filepicker or filemanager form elements + var fitem = this.ancestor('.fitem'); + if (fitem && (fitem.hasClass('fitem_ffilemanager') || fitem.hasClass('fitem_ffilepicker'))) { + if (disabled){ + fitem.addClass('disabled'); + } else { + fitem.removeClass('disabled'); + } } }) }, diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index b2d0e491005..e800b8f21e2 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -2050,7 +2050,7 @@ $icon_progress