Skip to content
Permalink
Browse files

MDL-31901: Highlighting main file in FileManager

  • Loading branch information...
marinaglancy committed May 4, 2012
1 parent c092681 commit 6c2367ccf1923e9dcff3d363bd43994e875b5e2a
Showing with 43 additions and 26 deletions.
  1. +24 −3 lib/form/filemanager.js
  2. +18 −23 repository/filepicker.js
  3. +1 −0 theme/base/style/filemanager.css
@@ -468,6 +468,13 @@ M.form_filemanager.init = function(Y, options) {
rightclickcallback : function(e, node) {
if (e.preventDefault) { e.preventDefault(); }
this.select_file(node);
},
classnamecallback : function(node) {
var classname = '';
if (node.type == 'folder') { classname = classname + ' fp-folder';}
if (node.filepath) { classname = classname + ' fp-hascontextmenu';}
if (node.sortorder == 1) { classname = classname + ' fp-mainfile';}
return Y.Lang.trim(classname);
}
};
if (this.viewmode == 2) {
@@ -606,7 +613,9 @@ M.form_filemanager.init = function(Y, options) {
}, this);
selectnode.one('.fp-file-download').on('click', function(e) {
e.preventDefault();
window.open(this.selectui.fileinfo.url, 'fm-download-file');
if (this.selectui.fileinfo.type != 'folder') {
window.open(this.selectui.fileinfo.url, 'fm-download-file');
}
}, this);
selectnode.one('.fp-file-delete').on('click', function(e) {
e.preventDefault();
@@ -644,6 +653,10 @@ M.form_filemanager.init = function(Y, options) {
e.preventDefault();
var params = {};
var fileinfo = this.selectui.fileinfo;
if (fileinfo.type != 'folder') {
// this button should not even be shown
return;
}
params['filepath'] = fileinfo.filepath;
params['filename'] = '.';
selectnode.addClass('loading');
@@ -661,6 +674,10 @@ M.form_filemanager.init = function(Y, options) {
e.preventDefault();
var params = {};
var fileinfo = this.selectui.fileinfo;
if (fileinfo.type != 'zip') {
// this button should not even be shown
return;
}
params['filepath'] = fileinfo.filepath;
params['filename'] = fileinfo.fullname;
selectnode.addClass('loading');
@@ -678,6 +695,10 @@ M.form_filemanager.init = function(Y, options) {
e.preventDefault();
var params = {};
var fileinfo = this.selectui.fileinfo;
if (fileinfo.type == 'folder') {
// this button should not even be shown for folders
return;
}
params['filepath'] = fileinfo.filepath;
params['filename'] = fileinfo.fullname;
selectnode.addClass('loading');
@@ -687,7 +708,7 @@ M.form_filemanager.init = function(Y, options) {
params: params,
callback: function(id, obj, args) {
args.scope.selectui.hide();
args.scope.refresh(obj.filepath);
args.scope.refresh(fileinfo.filepath);
}
});
}, this);
@@ -710,7 +731,7 @@ M.form_filemanager.init = function(Y, options) {
removeClass('fp-file').removeClass('fp-zip').removeClass('fp-cansetmain');
if (node.type == 'folder' || node.type == 'zip') {selectnode.addClass('fp-'+node.type);}
else {selectnode.addClass('fp-file');}
if (this.enablemainfile && (node.sortorder != 1)) {
if (this.enablemainfile && (node.sortorder != 1) && node.type == 'file') {
selectnode.addClass('fp-cansetmain');
}
this.selectui.fileinfo = node;
@@ -82,12 +82,12 @@ YUI.add('moodle-core_filepicker', function(Y) {
* filenode : Node element that contains template for displaying one file
* callback : On click callback. The element of the fileslist array will be passed as argument
* rightclickcallback : On right click callback (optional).
* norootrightclick : No right click for top element in the tree
* callbackcontext : context where callbacks are executed
* sortable : whether content may be sortable (in table mode)
* dynload : allow dynamic load for tree view
* filepath : for pre-building of tree view - the path to the current directory in filepicker format
* treeview_dynload : callback to ...
* treeview_dynload : callback to function to dynamically load the folder in tree view
* classnamecallback : callback to function that returns the class name for an element
* @param array fileslist array of files to show, each array element may have attributes:
* title or fullname : file name
* shorttitle (optional) : display file name
@@ -129,14 +129,8 @@ YUI.add('moodle-core_filepicker', function(Y) {

el.one('.fp-filename').setContent(file_get_displayname(node));
// TODO add tooltip with node.title or node.thumbnail_title
var tmpnodedata = {className:''};
if (file_is_folder(node)) {
el.get('children').addClass('fp-folder');
tmpnodedata.className = tmpnodedata.className + ' fp-folder';
}
if (options.rightclickcallback && !node.nocontextmenu) {
tmpnodedata.className = tmpnodedata.className + ' fp-hascontextmenu';
}
var tmpnodedata = {className:options.classnamecallback(node)};
el.get('children').addClass(tmpnodedata.className);
if (node.icon) {
el.one('.fp-icon').appendChild(Y.Node.create('<img/>').set('src', node.icon));
if (node.realicon) {
@@ -179,9 +173,6 @@ YUI.add('moodle-core_filepicker', function(Y) {
for (var i in options.filepath) {
if (mytreeel == null) {
mytreeel = mytree;
if (options.norootrightclick) {
mytreeel.nocontextmenu = true;
}
} else {
mytreeel.children = [{}];
mytreeel = mytreeel.children[0];
@@ -243,9 +234,7 @@ YUI.add('moodle-core_filepicker', function(Y) {
var formatTitle = function(o) {
var el = Y.Node.create('<div/>');
el.appendChild(options.filenode.cloneNode(true)); // TODO not node but string!
if (o.data['isfolder']) {
el.get('children').addClass('fp-folder');
}
el.get('children').addClass(o.data['classname']);
el.one('.fp-filename').setContent(o.value);
if (o.data['icon']) {
el.one('.fp-icon').appendChild(Y.Node.create('<img/>').set('src', o.data['icon']));
@@ -304,6 +293,7 @@ YUI.add('moodle-core_filepicker', function(Y) {
// to speed up sorting and formatting
fileslist[k].displayname = file_get_displayname(fileslist[k]);
fileslist[k].isfolder = file_is_folder(fileslist[k]);
fileslist[k].classname = options.classnamecallback(fileslist[k]);
}
scope.tableview.addRows(fileslist);
scope.tableview.sortable = options.sortable ? true : false;
@@ -331,12 +321,7 @@ YUI.add('moodle-core_filepicker', function(Y) {
var node = fileslist[k];
var element = options.filenode.cloneNode(true);
parent.appendChild(element);
if (file_is_folder(node)) {
element.addClass('fp-folder');
}
if (options.rightclickcallback) {
element.addClass('fp-hascontextmenu');
}
element.addClass(options.classnamecallback(node));
var filenamediv = element.one('.fp-filename');
filenamediv.setContent(file_get_displayname(node));
var imgdiv = element.one('.fp-thumbnail'), width, height, src;
@@ -858,6 +843,9 @@ M.core_filepicker.init = function(Y, options) {
this.content_scrolled();
}
},
classnamecallback : function(node) {
return node.children ? 'fp-folder' : '';
},
dynload : this.active_repo.dynload,
filepath : this.filepath,
treeview_dynload : this.treeview_dynload
@@ -893,6 +881,9 @@ M.core_filepicker.init = function(Y, options) {
} else {
this.select_file(node);
}
},
classnamecallback : function(node) {
return node.children ? 'fp-folder' : '';
}
};
this.fpnode.one('.fp-content').fp_display_filelist(options, list, this.lazyloading);
@@ -927,6 +918,9 @@ M.core_filepicker.init = function(Y, options) {
} else {
this.select_file(node);
}
},
classnamecallback : function(node) {
return node.children ? 'fp-folder' : '';
}
};
this.fpnode.one('.fp-content').fp_display_filelist(options, list, this.lazyloading);
@@ -1144,7 +1138,6 @@ M.core_filepicker.init = function(Y, options) {
set('id', 'filepicker-'+client_id);
var fpselectnode = Y.Node.create(M.core_filepicker.templates.selectlayout);
Y.one(document.body).appendChild(this.fpnode);
this.fpnode.appendChild(fpselectnode);
this.mainui = new Y.Panel({
srcNode : this.fpnode,
headerContent: M.str.repository.filepicker,
@@ -1161,7 +1154,9 @@ M.core_filepicker.init = function(Y, options) {
// allow to move the panel dragging it by it's header:
this.mainui.plug(Y.Plugin.Drag,{handles:['.yui3-widget-hd']});
this.mainui.show();
if (this.mainui.get('y')<0) {this.mainui.set('y', 0);}
// create panel for selecting a file (initially hidden)
this.fpnode.appendChild(fpselectnode);
this.selectui = new Y.Panel({
srcNode : fpselectnode,
zIndex : 600000,
@@ -237,6 +237,7 @@ background: #CCC!important;filter: progid:DXImageTransform.Microsoft.gradient(st
.filemanager .fp-iconview .fp-file {float:left;text-align:center;}
.filemanager .fp-iconview .fp-file div {overflow: hidden;}
.filemanager .fp-iconview .fp-file .fp-filename {height:48px;text-align:center;min-width:50px;}
.filemanager .fp-mainfile .fp-filename {font-weight:bold;}

.filemanager .fp-contextmenu {display:none;}
.filemanager .fp-iconview .fp-folder.fp-hascontextmenu .fp-contextmenu {display:block;position:absolute;right:0px;top:0px;}

0 comments on commit 6c2367c

Please sign in to comment.
You can’t perform that action at this time.