Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-34221 disabledIf support for filemanager and filepicker elements

  • Loading branch information...
commit 9ff506d165b5e7c05529f8e70f889bb5507e1272 1 parent 252bd18
Marina Glancy marinaglancy authored samhemelryk committed
2  lib/form/dndupload.js
@@ -170,7 +170,7 @@ M.form_dndupload.init = function(Y, options) {
170 170 * @return bool - true if disabled
171 171 */
172 172 is_disabled: function() {
173   - return this.container.hasClass('disabled');
  173 + return (this.container.ancestor('.fitem.disabled') != null);
174 174 },
175 175
176 176 /**
21 lib/form/filemanager.js
@@ -255,6 +255,9 @@ M.form_filemanager.init = function(Y, options) {
255 255 this.msg_dlg_node.one('.fp-msg-text').setContent(msg);
256 256 this.msg_dlg.show();
257 257 },
  258 + is_disabled: function() {
  259 + return this.filemanager.ancestor('.fitem.disabled') != null;
  260 + },
258 261 setup_buttons: function() {
259 262 var button_download = this.filemanager.one('.fp-btn-download');
260 263 var button_create = this.filemanager.one('.fp-btn-mkdir');
@@ -272,6 +275,9 @@ M.form_filemanager.init = function(Y, options) {
272 275 if (this.options.subdirs) {
273 276 button_create.on('click',function(e) {
274 277 e.preventDefault();
  278 + if (this.is_disabled()) {
  279 + return;
  280 + }
275 281 var scope = this;
276 282 // a function used to perform an ajax request
277 283 var perform_action = function(e) {
@@ -325,6 +331,9 @@ M.form_filemanager.init = function(Y, options) {
325 331 // setup 'download this folder' button
326 332 button_download.on('click',function(e) {
327 333 e.preventDefault();
  334 + if (this.is_disabled()) {
  335 + return;
  336 + }
328 337 var scope = this;
329 338 // perform downloaddir ajax request
330 339 this.request({
@@ -351,7 +360,7 @@ M.form_filemanager.init = function(Y, options) {
351 360 on('click', function(e) {
352 361 e.preventDefault();
353 362 var viewbar = this.filemanager.one('.fp-viewbar')
354   - if (!viewbar || !viewbar.hasClass('disabled')) {
  363 + if (!this.is_disabled() && (!viewbar || !viewbar.hasClass('disabled'))) {
355 364 this.filemanager.all('.fp-vb-icons,.fp-vb-tree,.fp-vb-details').removeClass('checked')
356 365 if (e.currentTarget.hasClass('fp-vb-tree')) {
357 366 this.viewmode = 2;
@@ -369,6 +378,9 @@ M.form_filemanager.init = function(Y, options) {
369 378 show_filepicker: function (e) {
370 379 // if maxfiles == -1, the no limit
371 380 e.preventDefault();
  381 + if (this.is_disabled()) {
  382 + return;
  383 + }
372 384 var options = this.filepicker_options;
373 385 options.formcallback = this.filepicker_callback;
374 386 // XXX: magic here, to let filepicker use filemanager scope
@@ -400,7 +412,9 @@ M.form_filemanager.init = function(Y, options) {
400 412 el.one('.fp-path-folder-name').setContent(p[i].name).
401 413 on('click', function(e, path) {
402 414 e.preventDefault();
403   - this.refresh(path);
  415 + if (!this.is_disabled()) {
  416 + this.refresh(path);
  417 + }
404 418 }, this, p[i].path);
405 419 }
406 420 this.pathbar.removeClass('empty');
@@ -873,6 +887,9 @@ M.form_filemanager.init = function(Y, options) {
873 887 return node.filepath;
874 888 },
875 889 select_file: function(node) {
  890 + if (this.is_disabled()) {
  891 + return;
  892 + }
876 893 var selectnode = this.selectnode;
877 894 selectnode.removeClass('loading').removeClass('fp-folder').
878 895 removeClass('fp-file').removeClass('fp-zip').removeClass('fp-cansetmain');
4 lib/form/filepicker.js
@@ -32,7 +32,9 @@ M.form_filepicker.init = function(Y, options) {
32 32 }
33 33 Y.on('click', function(e, client_id) {
34 34 e.preventDefault();
35   - M.core_filepicker.instances[client_id].show();
  35 + if (this.ancestor('.fitem.disabled') == null) {
  36 + M.core_filepicker.instances[client_id].show();
  37 + }
36 38 }, '#filepicker-button-'+options.client_id, null, options.client_id);
37 39
38 40 var item = document.getElementById('nonjs-filepicker-'+options.client_id);
22 lib/form/form.js
@@ -207,20 +207,14 @@ M.form.initFormDependencies = function(Y, formid, dependencies) {
207 207 this.removeAttribute('disabled');
208 208 }
209 209
210   - // Extra code to disable a filepicker
211   - if (this.getAttribute('class') == 'filepickerhidden'){
212   - var pickerbuttons = form.elementsByName(name + 'choose');
213   - pickerbuttons.each(function(){
214   - var clientid = this.get('id').split('-')[2];
215   - var filepicker = Y.one('#file_info_'+clientid);
216   - if (disabled){
217   - this.setAttribute('disabled','disabled');
218   - filepicker.addClass('disabled');
219   - } else {
220   - this.removeAttribute('disabled');
221   - filepicker.removeClass('disabled');
222   - }
223   - });
  210 + // Extra code to disable filepicker or filemanager form elements
  211 + var fitem = this.ancestor('.fitem');
  212 + if (fitem && (fitem.hasClass('fitem_ffilemanager') || fitem.hasClass('fitem_ffilepicker'))) {
  213 + if (disabled){
  214 + fitem.addClass('disabled');
  215 + } else {
  216 + fitem.removeClass('disabled');
  217 + }
224 218 }
225 219 })
226 220 },
2  lib/outputrenderers.php
@@ -2050,7 +2050,7 @@ public function render_file_picker(file_picker $fp) {
2050 2050 </div>
2051 2051 <div id="filepicker-wrapper-{$client_id}" class="mdl-left" style="display:none">
2052 2052 <div>
2053   - <input type="button" id="filepicker-button-{$client_id}" value="{$straddfile}"{$buttonname}/>
  2053 + <input type="button" class="fp-btn-choose" id="filepicker-button-{$client_id}" value="{$straddfile}"{$buttonname}/>
2054 2054 <span> $maxsize </span>
2055 2055 </div>
2056 2056 EOD;
12 theme/base/style/filemanager.css
@@ -275,6 +275,10 @@ a.ygtvspacer:hover {color: transparent;text-decoration: none;}
275 275 .filemanager.fm-updating .filemanager-updating {display:block;margin-top: 37px;}
276 276 .filemanager.fm-updating .fm-content-wrapper {display:none;}
277 277 .filemanager.fm-nomkdir .fp-btn-mkdir {display:none;}
  278 +.fitem.disabled .filemanager .filemanager-toolbar,
  279 +.fitem.disabled .filemanager .fp-pathbar,
  280 +.fitem.disabled .filemanager .fp-restrictions,
  281 +.fitem.disabled .filemanager .fm-content-wrapper {display:none;}
278 282
279 283 /*
280 284 * File Manager layout
@@ -292,6 +296,9 @@ a.ygtvspacer:hover {color: transparent;text-decoration: none;}
292 296 .filemanager-container ul li a{padding:0}*/
293 297 .filemanager .fp-content{overflow: auto;max-height: 472px;min-height: 157px;}
294 298 .filemanager-container, .filepicker-filelist {overflow:hidden;}
  299 +.fitem.disabled .filepicker-filelist, .fitem.disabled .filemanager-container {background-color:#EBEBE4;}
  300 +.fitem.disabled .fp-btn-choose {color:graytext;}
  301 +.fitem.disabled .filepicker-filelist .filepicker-filename {display:none;}
295 302
296 303 /*
297 304 * Icon view (File Manager only)
@@ -324,10 +331,8 @@ a.ygtvspacer:hover {color: transparent;text-decoration: none;}
324 331 .filemanager .fp-tableview .fp-folder.fp-hascontextmenu .fp-contextmenu {display: inline;position: absolute;left: 14px;margin-right: -20px;top: 6px;}
325 332
326 333 /*
327   - * Drag and drop support (File Manager only)
  334 + * Drag and drop support (filemanager and filepicker form elements)
328 335 */
329   -.filepicker-filelist.disabled {background-color:#ddd;}
330   -.filepicker-filelist.disabled .filepicker-filename {display:none;}
331 336 .filepicker-filelist .filepicker-container,
332 337 .filemanager.fm-noitems .fm-empty-container {display:block;position:absolute;top:10px;bottom:10px;left:10px;right:10px;border: 2px dashed #BBBBBB;padding-top:85px;text-align:center;z-index: 3000;}
333 338 .filepicker-filelist .dndupload-target,
@@ -341,6 +346,7 @@ a.ygtvspacer:hover {color: transparent;text-decoration: none;}
341 346 .dndupload-uploadinprogress {display:none;text-align:center;}
342 347 .dndupload-uploading .dndupload-uploadinprogress {display:block;}
343 348 .dndupload-arrow {background:url([[pix:theme|fp/dnd_arrow]]) center no-repeat;width:60px;height:80px;position:absolute;margin-left: -28px;top: 5px;}
  349 +.fitem.disabled .filepicker-container, .fitem.disabled .fm-empty-container {display:none;}
344 350
345 351 /*
346 352 * Select Dialogue (File Manager only)

0 comments on commit 9ff506d

Please sign in to comment.
Something went wrong with that request. Please try again.