Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'wip-MDL-34221-master' of git://github.com/marinaglancy/…

…moodle
  • Loading branch information...
commit fc994304a224ddaa29356b362c4666d5d553d8af 2 parents 87608b3 + c81f332
@samhemelryk samhemelryk authored
View
14 lib/form/dndupload.js
@@ -166,10 +166,21 @@ M.form_dndupload.init = function(Y, options) {
},
/**
+ * Check if the filemanager / filepicker is disabled
+ * @return bool - true if disabled
+ */
+ is_disabled: function() {
+ return (this.container.ancestor('.fitem.disabled') != null);
+ },
+
+ /**
* Show the 'drop files here' message when file(s) are dragged
* onto the page
*/
drag_enter_page: function(e) {
+ if (this.is_disabled()) {
+ return false;
+ }
if (!this.has_files(e)) {
return false;
}
@@ -210,6 +221,9 @@ M.form_dndupload.init = function(Y, options) {
* @return boolean true if a valid file drag event
*/
check_drag: function(e) {
+ if (this.is_disabled()) {
+ return false;
+ }
if (!this.has_files(e)) {
return false;
}
View
21 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');
View
4 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);
View
18 lib/form/form.js
@@ -207,16 +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(){
- if (disabled){
- this.setAttribute('disabled','disabled');
- } else {
- this.removeAttribute('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');
+ }
}
})
},
View
2  lib/outputrenderers.php
@@ -2050,7 +2050,7 @@ public function render_file_picker(file_picker $fp) {
</div>
<div id="filepicker-wrapper-{$client_id}" class="mdl-left" style="display:none">
<div>
- <input type="button" id="filepicker-button-{$client_id}" value="{$straddfile}"{$buttonname}/>
+ <input type="button" class="fp-btn-choose" id="filepicker-button-{$client_id}" value="{$straddfile}"{$buttonname}/>
<span> $maxsize </span>
</div>
EOD;
View
10 theme/base/style/filemanager.css
@@ -275,6 +275,10 @@ a.ygtvspacer:hover {color: transparent;text-decoration: none;}
.filemanager.fm-updating .filemanager-updating {display:block;margin-top: 37px;}
.filemanager.fm-updating .fm-content-wrapper {display:none;}
.filemanager.fm-nomkdir .fp-btn-mkdir {display:none;}
+.fitem.disabled .filemanager .filemanager-toolbar,
+.fitem.disabled .filemanager .fp-pathbar,
+.fitem.disabled .filemanager .fp-restrictions,
+.fitem.disabled .filemanager .fm-content-wrapper {display:none;}
/*
* File Manager layout
@@ -292,6 +296,9 @@ a.ygtvspacer:hover {color: transparent;text-decoration: none;}
.filemanager-container ul li a{padding:0}*/
.filemanager .fp-content{overflow: auto;max-height: 472px;min-height: 157px;}
.filemanager-container, .filepicker-filelist {overflow:hidden;}
+.fitem.disabled .filepicker-filelist, .fitem.disabled .filemanager-container {background-color:#EBEBE4;}
+.fitem.disabled .fp-btn-choose {color:graytext;}
+.fitem.disabled .filepicker-filelist .filepicker-filename {display:none;}
/*
* Icon view (File Manager only)
@@ -324,7 +331,7 @@ a.ygtvspacer:hover {color: transparent;text-decoration: none;}
.filemanager .fp-tableview .fp-folder.fp-hascontextmenu .fp-contextmenu {display: inline;position: absolute;left: 14px;margin-right: -20px;top: 6px;}
/*
- * Drag and drop support (File Manager only)
+ * Drag and drop support (filemanager and filepicker form elements)
*/
.filepicker-filelist .filepicker-container,
.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;}
@@ -339,6 +346,7 @@ a.ygtvspacer:hover {color: transparent;text-decoration: none;}
.dndupload-uploadinprogress {display:none;text-align:center;}
.dndupload-uploading .dndupload-uploadinprogress {display:block;}
.dndupload-arrow {background:url([[pix:theme|fp/dnd_arrow]]) center no-repeat;width:60px;height:80px;position:absolute;margin-left: -28px;top: 5px;}
+.fitem.disabled .filepicker-container, .fitem.disabled .fm-empty-container {display:none;}
/*
* Select Dialogue (File Manager only)
Please sign in to comment.
Something went wrong with that request. Please try again.