$j(_this.editForm).append('<input type="hidden" name="format" value="jsonfm">');
//map the form vars to api vars:
- $j(_this.editForm).find('#wpUploadFile').attr('name', 'file');
- $j(_this.editForm).find('#wpDestFile').attr('name', 'filename');
- $j(_this.editForm).find('#wpUploadDescription').attr('name', 'comment');
- $j(_this.editForm).find('#wpEditToken').attr('name', 'token');
- $j(_this.editForm).find('#wpIgnoreWarning').attr('name', 'ignorewarnings');
- $j(_this.editForm).find('#wpWatchthis').attr('name', 'watch');
+ $j(_this.editForm).find("[name='wpUploadFile']").attr('name', 'file');
+ $j(_this.editForm).find("[name='wpDestFile']").attr('name', 'filename');
+ $j(_this.editForm).find("[name='wpUploadDescription']").attr('name', 'comment');
+ $j(_this.editForm).find("[name='wpEditToken']").attr('name', 'token');
+ $j(_this.editForm).find("[name='wpIgnoreWarning']").attr('name', 'ignorewarnings');
+ $j(_this.editForm).find("[name='wpWatchthis']").attr('name', 'watch');
//update the status to 100% progress bar (no status in iframe submit)
$j('#up-progressbar' ).progressbar('value', parseInt( 100 ) );
//js_log('getResourceFromId:' + rid );
//strip out /res/ if preset:
rid = rid.replace(/res_/, '');
- js_log("looking at: " + rid);
+ //js_log("looking at: " + rid);
p = rid.split('_');
var cp_id = p[0];
var rid = p[1];
$j('#wpUploadBtn').attr('disabled', 'disabled');
}
});
-
+ //do destination fill:
+ //@@should integrate with doDestinationFill on upload page
+ $j("[name='wpUploadFile']").change(function(){
+ var path = $j(this).val();
+ // Find trailing part
+ var slash = path.lastIndexOf('/');
+ var backslash = path.lastIndexOf('\\');
+ var fname;
+ if (slash == -1 && backslash == -1) {
+ fname = path;
+ } else if (slash > backslash) {
+ fname = path.substring(slash+1, 10000);
+ } else {
+ fname = path.substring(backslash+1, 10000);
+ }
+ fname = fname.charAt(0).toUpperCase().concat(fname.substring(1,10000)).replace(/ /g, '_');
+ // Output result
+ $j("[name='wpDestFile']").val( fname );
+ //do destination check
+ $j("[name='wpDestFile']").doDestCheck({
+ 'warn_target':'#wpDestFile-warning'
+ });
+ });
+
+
+ //do destination check:
+ $j("[name='wpDestFile']").change(function(){
+ $j(this).doDestCheck({
+ 'warn_target':'#wpDestFile-warning'
+ });
+ });
+
if(typeof opt.ondone_cb == 'undefined')
opt.ondone_cb = false;