{if $upload_mode eq 'multiple'} {combine_script id='jquery.jgrowl' load='footer' require='jquery' path='themes/default/js/plugins/jquery.jgrowl_minimized.js' } {combine_script id='swfobject' load='footer' path='admin/include/uploadify/swfobject.js'} {combine_script id='jquery.uploadify' load='footer' require='jquery' path='admin/include/uploadify/jquery.uploadify.v2.1.0.min.js' } {combine_css path="admin/themes/default/uploadify.jGrowl.css"} {combine_css path="admin/include/uploadify/uploadify.css"} {/if} {include file='include/colorbox.inc.tpl'} {footer_script}{literal} jQuery(document).ready(function(){ function checkUploadStart() { var nbErrors = 0; jQuery("#formErrors").hide(); jQuery("#formErrors li").hide(); 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; } function fillCategoryListbox(selectId, selectedValue) { jQuery.getJSON( "ws.php?format=json&method=pwg.categories.getList", { recursive: true, fullname: true, format: "json", }, function(data) { jQuery.each( data.result.categories, function(i,category) { var selected = ""; if (category.id == selectedValue) { selected = "selected"; } jQuery("") .attr("value", category.id) .attr("selected", selected) .text(category.name) .appendTo("#"+selectId) ; } ); } ); } /* jQuery("#albumSelect").find("option").remove(); fillCategoryListbox("albumSelect"); fillCategoryListbox("category_parent"); */ jQuery(".addAlbumOpen").colorbox({inline:true, href:"#addAlbumForm"}); jQuery("#addAlbumForm form").submit(function(){ jQuery("#categoryNameError").text(""); jQuery.ajax({ url: "ws.php?format=json&method=pwg.categories.add", data: { parent: jQuery("select[name=category_parent] option:selected").val(), name: jQuery("input[name=category_name]").val(), }, beforeSend: function() { jQuery("#albumCreationLoading").show(); }, success:function(html) { jQuery("#albumCreationLoading").hide(); var newAlbum = jQuery.parseJSON(html).result.id; jQuery(".addAlbumOpen").colorbox.close(); jQuery("#albumSelect").find("option").remove(); fillCategoryListbox("albumSelect", newAlbum); /* we refresh the album creation form, in case the user wants to create another album */ jQuery("#category_parent").find("option").remove(); fillCategoryListbox("category_parent", newAlbum); jQuery("#addAlbumForm form input[name=category_name]").val(''); return true; }, error:function(XMLHttpRequest, textStatus, errorThrows) { jQuery("#albumCreationLoading").hide(); jQuery("#categoryNameError").text(errorThrows).css("color", "red"); } }); return false; }); jQuery("#hideErrors").click(function() { jQuery("#formErrors").hide(); return false; }); {/literal} {if $upload_mode eq 'html'} {literal} function addUploadBox() { var uploadBox = '
'; jQuery(uploadBox).appendTo("#uploadBoxes"); } addUploadBox(); jQuery("#addUploadBox A").click(function () { addUploadBox(); }); jQuery("#uploadForm").submit(function() { return checkUploadStart(); }); {/literal} {elseif $upload_mode eq 'multiple'} var uploadify_path = '{$uploadify_path}'; var upload_id = '{$upload_id}'; var session_id = '{$session_id}'; var pwg_token = '{$pwg_token}'; var buttonText = 'Browse'; var sizeLimit = {$upload_max_filesize}; {literal} jQuery("#uploadify").uploadify({ 'uploader' : uploadify_path + '/uploadify.swf', 'script' : uploadify_path + '/uploadify.php', 'scriptData' : { 'upload_id' : upload_id, 'session_id' : session_id, 'pwg_token' : pwg_token, }, 'cancelImg' : uploadify_path + '/cancel.png', 'queueID' : 'fileQueue', 'auto' : false, 'buttonText' : buttonText, 'multi' : true, 'fileDesc' : 'Photo files (*.jpg,*.jpeg,*.png)', 'fileExt' : '*.jpg;*.JPG;*.jpeg;*.JPEG;*.png;*.PNG', 'sizeLimit' : sizeLimit, 'onAllComplete' : function(event, data) { if (data.errors) { return false; } else { jQuery("input[name=submit_upload]").click(); } }, onError: function (event, queueID ,fileObj, errorObj) { var msg; if (errorObj.type === "HTTP") { if (errorObj.info === 404) { alert('Could not find upload script.'); msg = 'Could not find upload script.'; } else { msg = errorObj.type+": "+errorObj.info; } } else if (errorObj.type ==="File Size") { msg = "File too big"; msg = msg + '