Permalink
Browse files

Merge branch 'wip-MDL-33303-m23' of git://github.com/samhemelryk/mood…

…le into MOODLE_23_STABLE
  • Loading branch information...
2 parents a5f68fb + e5c2bbd commit b41f914927f7128e7426aede4bfaf59f1403ebda @stronk7 stronk7 committed Jul 3, 2012
Showing with 67 additions and 7 deletions.
  1. +14 −3 files/renderer.php
  2. +49 −2 lib/form/filemanager.js
  3. +4 −2 theme/base/style/filemanager.css
View
17 files/renderer.php
@@ -107,7 +107,7 @@ public function render_form_filemanager($fm) {
$module = array(
'name'=>'form_filemanager',
'fullpath'=>'/lib/form/filemanager.js',
- 'requires' => array('core_filepicker', 'base', 'io-base', 'node', 'json', 'core_dndupload', 'panel', 'resize-plugin', 'dd-plugin'),
+ 'requires' => array('core_filepicker', 'base', 'io-base', 'node', 'json', 'core_dndupload', 'panel', 'resize-plugin', 'dd-plugin', 'resize'),
'strings' => array(
array('error', 'moodle'), array('info', 'moodle'), array('confirmdeletefile', 'repository'),
array('draftareanofiles', 'repository'), array('entername', 'repository'), array('enternewname', 'repository'),
@@ -123,6 +123,7 @@ public function render_form_filemanager($fm) {
array($this->filemanager_js_templates()), true, $module);
}
$this->page->requires->js_init_call('M.form_filemanager.init', array($fm->options), true, $module);
+ user_preference_allow_ajax_update('filemanagerresizedto', PARAM_SEQUENCE);
// non javascript file manager
$html .= '<noscript>';
@@ -192,8 +193,17 @@ private function fm_print_generallayout($fm) {
$strdndenabledinbox = get_string('dndenabled_inbox', 'moodle');
$loading = get_string('loading', 'repository');
+ $resizedto = get_user_preferences('filemanagerresizedto', null);
+ $filemanagerstyle = '';
+ $containerstyletag = '';
+ if (!is_null($resizedto) && preg_match('#^\d+,\d+$#', $resizedto)) {
+ list($width, $height) = explode(',', $resizedto, 2);
+ $filemanagerstyle = " style='width:{$width}px;'";
+ $containerstyletag = " style='height:{$height}px;'";
+ }
+
$html = '
-<div id="filemanager-'.$client_id.'" class="filemanager fm-loading">
+<div id="filemanager-'.$client_id.'" class="filemanager fm-loading"'.$filemanagerstyle.'>
<div class="fp-restrictions">
'.$restrictions.'
<span class="dndupload-message"> - '.$strdndenabled.' </span>
@@ -216,7 +226,7 @@ private function fm_print_generallayout($fm) {
</div>
</div>
<div class="filemanager-loading mdl-align">'.$icon_progress.'</div>
- <div class="filemanager-container" >
+ <div class="filemanager-container"'.$containerstyletag.'>
<div class="fm-content-wrapper">
<div class="fp-content"></div>
<div class="fm-empty-container <!--mdl-align-->">
@@ -227,6 +237,7 @@ private function fm_print_generallayout($fm) {
</div>
<div class="filemanager-updating">'.$icon_progress.'</div>
</div>
+ <div class="fp-statusbar"></div>
</div>';
return preg_replace('/\{\!\}/', '', $html);
}
View
51 lib/form/filemanager.js
@@ -83,6 +83,14 @@ M.form_filemanager.init = function(Y, options) {
} else {
this.filecount = 0;
}
+
+ this.publish('filemanager:content-changed', {
+ context : this,
+ prefix : 'filemanager',
+ preventable : false,
+ type : 'content-changed'
+ });
+
// prepare filemanager for drag-and-drop upload
this.filemanager = Y.one('#filemanager-'+options.client_id);
if (this.filemanager.hasClass('filemanager-container') || !this.filemanager.one('.filemanager-container')) {
@@ -122,6 +130,44 @@ M.form_filemanager.init = function(Y, options) {
this.filemanager.all('.fp-vb-icons,.fp-vb-tree,.fp-vb-details').removeClass('checked')
this.filemanager.all('.fp-vb-icons').addClass('checked')
this.refresh(this.currentpath); // MDL-31113 get latest list from server
+
+ // Make sure that the filemanager is at least shown within the constraints of the page
+ if ((this.filemanager.get('offsetWidth') + this.filemanager.getX()) > this.filemanager.get('docWidth')) {
+ this.filemanager.setStyle('width', Math.round(this.filemanager.get('docWidth') - this.filemanager.getX()));
+ }
+
+ if (Y.Resize) {
+ // We only do this is the YUI resize component is loaded
+ var resize = new Y.Resize({
+ node: this.dndcontainer,
+ wrap : true,
+ handles : ['br']
+ }).plug(Y.Plugin.ResizeConstrained, {
+ minWidth : 410,
+ maxWidth : this.dndcontainer.ancestor('.ffilemanager').get('offsetWidth') || 1600,
+ minHeight : 160,
+ maxHeight : 1024
+ });
+ // When it resizes we need to correct the width and height of other elements.
+ resize.on('resize:resize', function(e) {
+ this.filemanager.setStyle('width', e.info.offsetWidth);
+ var fmcw = this.filemanager.one('.fp-content');
+ if (fmcw) {
+ fmcw.setStyle('height', this.dndcontainer.get('offsetHeight'));
+ }
+ }, this);
+ // After resizing we update the user preference so that we always show them the file manager at the same size.
+ resize.on('resize:end', function(e){
+ M.util.set_user_preference('filemanagerresizedto', Math.round(e.info.offsetWidth).toString()+','+Math.round(e.info.offsetHeight).toString());
+ });
+ // When content gets updated by the filemanager we need to auto-update the height of the resizeable area to include it.
+ this.on('filemanager:content-changed', function(){
+ var fmcw = this.filemanager.one('.fp-content');
+ if (fmcw) {
+ fmcw.setStyle('height', this.dndcontainer.get('offsetHeight'));
+ }
+ }, this);
+ }
},
wait: function() {
@@ -511,15 +557,15 @@ M.form_filemanager.init = function(Y, options) {
filenode : element_template,
callbackcontext : this,
callback : function(e, node) {
- if (e.preventDefault) { e.preventDefault(); }
+ if (e.preventDefault) {e.preventDefault();}
if (node.type == 'folder') {
this.refresh(node.filepath);
} else {
this.select_file(node);
}
},
rightclickcallback : function(e, node) {
- if (e.preventDefault) { e.preventDefault(); }
+ if (e.preventDefault) {e.preventDefault();}
this.select_file(node);
},
classnamecallback : function(node) {
@@ -606,6 +652,7 @@ M.form_filemanager.init = function(Y, options) {
node.appendChild(Y.Node.create('<option/>').
set('value', list[i]).setContent(list[i]))
}
+ this.fire('filemanager:content-changed');
},
update_file: function(confirmed) {
var selectnode = this.selectnode;
View
6 theme/base/style/filemanager.css
@@ -1,7 +1,7 @@
/**
* File Picker and File Manager
*/
-
+.filemanager {width: 680px; min-width: 410px;}
.filemanager, .file-picker {font-size:11px;color: #555555;letter-spacing: .2px;}
.filemanager a, .file-picker a {color:#555555;}
.filemanager a:hover, .file-picker a:hover {color:#555555;text-decoration: none;}
@@ -287,8 +287,10 @@ a.ygtvspacer:hover {color: transparent;text-decoration: none;}
/*.filemanager-container ul{margin:0;padding:0;}
.filemanager-container ul li{white-space:nowrap;list-style-type:none;}
.filemanager-container ul li a{padding:0}*/
-.filemanager .fp-content{overflow: auto;max-height: 472px;}
+.filemanager .fp-content{overflow: auto;}
.filemanager-container, .filepicker-filelist {overflow:hidden;}
+.filemanager.fm-loaded .fp-statusbar {background: #F2F2F2;border: 1px solid #BBB;border-top:0;min-height:2em;margin-bottom:5px;padding-right:2em;}
+.filemanager .yui3-resize-handle-inner-br {bottom:-2em;}
/*
* Icon view (File Manager only)

0 comments on commit b41f914

Please sign in to comment.