Permalink
Browse files

MDL-31901: filemanager/picker.js - match coding style

* No inline ifs
* Spacing between ternary operators
* Missing ;'s
  • Loading branch information...
danpoltawski committed May 16, 2012
1 parent 7d44f9c commit 6a0d7194f7dc30cc26f810b4d0306cbbc311cdc8
Showing with 124 additions and 59 deletions.
  1. +50 −21 lib/form/filemanager.js
  2. +74 −38 repository/filepicker.js
View
@@ -193,11 +193,17 @@ M.form_filemanager.init = function(Y, options) {
}
},
check_buttons: function() {
if (this.filecount>0) {this.filemanager.removeClass('fm-nofiles');}
else {this.filemanager.addClass('fm-nofiles');}
if (this.filecount >= this.maxfiles && this.maxfiles!=-1)
{this.filemanager.addClass('fm-maxfiles');}
else {this.filemanager.removeClass('fm-maxfiles');}
if (this.filecount>0) {
this.filemanager.removeClass('fm-nofiles');
} else {
this.filemanager.addClass('fm-nofiles');
}
if (this.filecount >= this.maxfiles && this.maxfiles!=-1) {
this.filemanager.addClass('fm-maxfiles');
}
else {
this.filemanager.removeClass('fm-maxfiles');
}
},
refresh: function(filepath) {
var scope = this;
@@ -372,9 +378,19 @@ M.form_filemanager.init = function(Y, options) {
for(var i = 0; i < p.length; i++) {
var el = this.pathnode.cloneNode(true);
this.pathbar.appendChild(el);
if (i == 0) {el.addClass('first');}
if (i == p.length-1) {el.addClass('last');}
if (i%2) {el.addClass('even');} else {el.addClass('odd');}
if (i == 0) {
el.addClass('first');
}
if (i == p.length-1) {
el.addClass('last');
}
if (i%2) {
el.addClass('even');
} else {
el.addClass('odd');
}
el.one('.fp-path-folder-name').setContent(p[i].name).
on('click', function(e, path) {
e.preventDefault();
@@ -420,8 +436,8 @@ M.form_filemanager.init = function(Y, options) {
scope.currentpath = node.path?node.path:'/';
}
node.highlight(false);
node.origlist = obj.list?obj.list:null;
node.origpath = obj.path?obj.path:null;
node.origlist = obj.list ? obj.list : null;
node.origpath = obj.path ? obj.path : null;
node.children = [];
for(k in list) {
if (list[k].type == 'folder' && retrieved_children[list[k].filepath]) {
@@ -546,12 +562,16 @@ M.form_filemanager.init = function(Y, options) {
}
};
}
if (!this.lazyloading) {this.lazyloading={};}
if (!this.lazyloading) {
this.lazyloading={};
}
this.filemanager.one('.fp-content').fp_display_filelist(options, list, this.lazyloading);
this.content_scrolled();
},
populate_licenses_select: function(node) {
if (!node) {return;}
if (!node) {
return;
}
node.setContent('');
var licenses = this.options.licenses;
for (var i in licenses) {
@@ -674,7 +694,7 @@ M.form_filemanager.init = function(Y, options) {
buttons : {}
});
this.confirm_dlg.plug(Y.Plugin.Drag,{handles:['#'+node.get('id')+' .yui3-widget-hd']});
var handleConfirm = function(ev) {
var handle_confirm = function(ev) {
var dlgopt = this.confirm_dlg.dlgopt;
ev.preventDefault();
this.confirm_dlg.hide();
@@ -686,12 +706,12 @@ M.form_filemanager.init = function(Y, options) {
}
}
}
var handleCancel = function(ev) {
var handle_cancel = function(ev) {
ev.preventDefault();
this.confirm_dlg.hide();
}
node.one('.fp-dlg-butconfirm').on('click', handleConfirm, this);
node.one('.fp-dlg-butcancel').on('click', handleCancel, this);
node.one('.fp-dlg-butconfirm').on('click', handle_confirm, this);
node.one('.fp-dlg-butcancel').on('click', handle_cancel, this);
}
this.confirm_dlg.dlgopt = dialog_options;
this.confirm_dlg_node.one('.fp-dlg-text').setContent(dialog_options.message);
@@ -823,18 +843,25 @@ M.form_filemanager.init = function(Y, options) {
}, this);
},
get_parent_folder_name: function(node) {
if (node.type != 'folder' || node.filepath.length < node.fullname.length+1) { return node.filepath; }
if (node.type != 'folder' || node.filepath.length < node.fullname.length+1) {
return node.filepath;
}
var basedir = node.filepath.substr(0, node.filepath.length - node.fullname.length - 1);
var lastdir = node.filepath.substr(node.filepath.length - node.fullname.length - 2);
if (lastdir == '/' + node.fullname + '/') { return basedir; }
if (lastdir == '/' + node.fullname + '/') {
return basedir;
}
return node.filepath;
},
select_file: function(node) {
var selectnode = this.selectnode;
selectnode.removeClass('loading').removeClass('fp-folder').
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 (node.type == 'folder' || node.type == 'zip') {
selectnode.addClass('fp-'+node.type);
} else {
selectnode.addClass('fp-file');
}
if (this.enablemainfile && (node.sortorder != 1) && node.type == 'file') {
selectnode.addClass('fp-cansetmain');
}
@@ -846,7 +873,9 @@ M.form_filemanager.init = function(Y, options) {
selectnode.all('.fp-license select option[value='+node.license+']').set('selected', true);
selectnode.all('.fp-path select option[selected]').set('selected', false);
selectnode.all('.fp-path select option').each(function(el){
if (el.get('value') == foldername) {el.set('selected', true);}
if (el.get('value') == foldername) {
el.set('selected', true);
}
});
selectnode.all('.fp-author input, .fp-license select').set('disabled',(node.type == 'folder')?'disabled':'');
// display static information about a file (when known)
Oops, something went wrong.

0 comments on commit 6a0d719

Please sign in to comment.