{combine_script id='jquery.jgrowl' load='footer' require='jquery' path='themes/default/js/plugins/jquery.jgrowl_minimized.js'}
{combine_script id='jquery.plupload' load='footer' require='jquery' path='themes/default/js/plugins/plupload/plupload.full.min.js'}
{combine_script id='jquery.plupload.queue' load='footer' require='jquery' path='themes/default/js/plugins/plupload/jquery.plupload.queue/jquery.plupload.queue.min.js'}
{combine_script id='jquery.ui.progressbar' load='footer'}
{combine_css path="themes/default/js/plugins/jquery.jgrowl.css"}
{combine_css path="themes/default/js/plugins/plupload/jquery.plupload.queue/css/jquery.plupload.queue.css"}
{include file='include/colorbox.inc.tpl'}
{include file='include/add_album.inc.tpl'}
{combine_script id='LocalStorageCache' load='footer' path='admin/themes/default/js/LocalStorageCache.js'}
{combine_script id='jquery.selectize' load='footer' path='themes/default/js/plugins/selectize.min.js'}
{combine_css id='jquery.selectize' path="themes/default/js/plugins/selectize.default.css"}
{footer_script}
{* *}
var categoriesCache = new CategoriesCache({
serverKey: '{$CACHE_KEYS.categories}',
serverId: '{$CACHE_KEYS._hash}',
rootUrl: '{$ROOT_URL}'
});
categoriesCache.selectize(jQuery('[data-selectize=categories]'), {
filter: function(categories, options) {
if (categories.length > 0) {
jQuery("#albumSelection").show();
options.default = categories[0].id;
}
return categories;
}
});
jQuery('[data-add-album]').pwgAddAlbum({ cache: categoriesCache });
var uploadify_path = '{$uploadify_path}';
var upload_id = '{$upload_id}';
var session_id = '{$session_id}';
var pwg_token = '{$pwg_token}';
var buttonText = "{'Select files'|@translate}";
var sizeLimit = Math.round({$upload_max_filesize} / 1024); /* in KBytes */
{literal}
jQuery(document).ready(function(){
function checkUploadStart() {
var nbErrors = 0;
jQuery("#formErrors").hide();
jQuery("#formErrors li").hide();
if (jQuery("select[name=category]").val() == '') {
jQuery("#formErrors #noAlbum").show();
nbErrors++;
}
var nbFiles = 0;
if (jQuery("#uploadBoxes").size() == 1) {
jQuery("input[name^=image_upload]").each(function() {
if (jQuery(this).val() != "") {
nbFiles++;
}
});
}
else {
nbFiles = jQuery(".uploadifyQueueItem").size();
}
if (nbFiles == 0) {
jQuery("#formErrors #noPhoto").show();
nbErrors++;
}
if (nbErrors != 0) {
jQuery("#formErrors").show();
return false;
}
else {
return true;
}
}
function humanReadableFileSize(bytes) {
var byteSize = Math.round(bytes / 1024 * 100) * .01;
var suffix = 'KB';
if (byteSize > 1000) {
byteSize = Math.round(byteSize *.001 * 100) * .01;
suffix = 'MB';
}
var sizeParts = byteSize.toString().split('.');
if (sizeParts.length > 1) {
byteSize = sizeParts[0] + '.' + sizeParts[1].substr(0,2);
}
else {
byteSize = sizeParts[0];
}
return byteSize+suffix;
}
jQuery("#hideErrors").click(function() {
jQuery("#formErrors").hide();
return false;
});
jQuery("#uploadWarningsSummary a.showInfo").click(function() {
jQuery("#uploadWarningsSummary").hide();
jQuery("#uploadWarnings").show();
return false;
});
jQuery("#showPermissions").click(function() {
jQuery(this).parent(".showFieldset").hide();
jQuery("#permissions").show();
return false;
});
jQuery("#uploader").pluploadQueue({
// General settings
// runtimes : 'html5,flash,silverlight,html4',
runtimes : 'html5',
// url : '../upload.php',
url : 'ws.php?method=pwg.images.upload&format=json',
// User can upload no more then 20 files in one go (sets multiple_queues to false)
max_file_count: 100,
chunk_size: '500kb',
filters : {
// Maximum file size
max_file_size : '1000mb',
// Specify what files to browse for
mime_types: [
{title : "Image files", extensions : "jpeg,jpg,gif,png"},
{title : "Zip files", extensions : "zip"}
]
},
// Rename files by clicking on their titles
// rename: true,
// Sort files
sortable: true,
// Enable ability to drag'n'drop files onto the widget (currently only HTML5 supports that)
dragdrop: true,
init : {
BeforeUpload: function(up, file) {
console.log('[BeforeUpload]', file);
// You can override settings before the file is uploaded
// up.setOption('url', 'upload.php?id=' + file.id);
up.setOption(
'multipart_params',
{
category : jQuery("select[name=category] option:selected").val(),
level : jQuery("select[name=level] option:selected").val(),
pwg_token : pwg_token
// name : file.name
}
);
},
FileUploaded: function(up, file, info) {
// Called when file has finished uploading
console.log('[FileUploaded] File:', file, "Info:", info);
var data = jQuery.parseJSON(info.response);
jQuery("#uploadedPhotos").parent("fieldset").show();
html = '';
html += '';
html += ' ';
jQuery("#uploadedPhotos").prepend(html);
}
}
});
{/literal}
});
{/footer_script}