$(document).ready(function() {
var msie = (navigator.appVersion.indexOf("MSIE") != -1);
var version = (msie) ? parseFloat(navigator.appVersion.split("MSIE")[1]) : 0;
if (Modernizr.draganddrop && (!msie || (msie && version > 9))) {
// Browser supports HTML5 drag & drop
// initialize uploadr and use native HTML5 implementation
var ${name} = $('.${classname}[name=${name}]').uploadr({
onStart: function(file) { ${handlers.onStart} },
onProgress: function(file, domObj, percentage) { ${handlers.onProgress} },
onSuccess: function(file, domObj, callback) { ${handlers.onSuccess} },
onLike: function(file, domObj, callback) { ${handlers.onLike} },
onUnlike: function(file, domObj, callback) { ${handlers.onUnlike} },
onChangeColor: function(file, domObj, color) { ${handlers.onChangeColor} },
onFailure: function(file, domObj) {
${handlers.onFailure}
},
onAbort: function(file, domObj) {
${handlers.onAbort}
},
onView: function(file, domObj) { ${handlers.onView}
// open a modal dialog to view the file contents
var width = 640;
var height= 400;
$( '' ).dialog({
title : 'viewing ${fileName}',
position : 'center',
autoOpen : true,
width : width,
height : height,
modal : true,
buttons : {
close: function() { $(this).dialog('close'); }
}
}).width(width - 10).height(height).animate({ top: '0' });
},
onDelete: function(file, domObj) { ${handlers.onDelete}
var a = $.ajax(
'',
{
async: false,
headers: {
'X-File-Name': file.fileName,
'X-Uploadr-Name': this.id
}
}
);
return (a.status == 200);
},
onDownload: function(file, domObj) { ${handlers.onDownload}
// redirect to file, not that the backend should implement
// authentication and authorization to asure the user has
// access to this file
window.open('?uploadr=' + escape('${name}') + '&file='+escape(file.fileName));
},
dropableClass: '${classname}-dropable',
hoverClass: '${classname}-hover',
uri: '${uri}',
notificationSound: '${resource(plugin: 'uploadr', dir:'sounds', file:'notify.wav')}',
errorSound: '${resource(plugin: 'uploadr', dir:'sounds', file:'error.wav')}',
deleteSound: '${resource(plugin: 'uploadr', dir:'sounds', file:'delete.wav')}',
labelDone: '',
labelFailed: '',
labelAborted: '',
fileSelectText: '${fileselect}',
placeholderText: '${placeholder}',
fileDeleteText: '',
fileDeleteConfirm: '',
fileAbortText: '',
fileAbortConfirm: '',
fileDownloadText: '',
fileViewText: '',
fileTooLargeText: '',
labelFileTooLarge: '',
likeText: '',
removeFromViewText: '',
unlikeText: '',
badgeTooltipSingular: '',
badgeTooltipPlural: '',
colorPickerText: '',
maxVisible: ${maxVisible},
rating: ${rating as String},
voting: ${voting as String},
colorPicker: ${colorPicker as String},
deletable: ${deletable as String},
viewable: ${viewable as String},
downloadable: ${downloadable as String},
insertDirection: '${direction}',
id: '${name}',
files: {
${s} : {
deletable : ${file.deletable},
fileName : '${file.name.replaceAll("'","\\\\'")}',
fileSize : ${file.size},
fileId : '${file.id.replaceAll("'","\\\\'")}',
fileDate : ${file.modified},
fileColor : '${file.color}',
fileRating : ${file.rating},
fileRatingText : '${file.ratingText.replaceAll("'","\\\\'")}',
fileInfo : [
'${info}',
]
},
},
maxSize: ${maxSize}
});
} else {
// Show warning
$('.${classname}[name=${name}]').load('${unsupported}');
}
});