Вход Регистрация
Файл: static/js/custom/avatar.js
Строк: 64
<?php
var count=0;var max_files=1;var error_add=false;var uploader=new plupload.Uploader({runtimes:"html5,html4",browse_button:"pickfiles",container:"container",url:"/modules/upload_avatar/",filters:[{title:"Image files",extensions:"jpg,gif,png,jpeg"}],resize:{width:1024,height:1024,quality:90}});$("#page_avatar").bind("pageshow",function(){uploader.bind("Init",function(a,b){});$("#uploadfiles").click(function(a){uploader.start();a.preventDefault()});uploader.init();uploader.bind("FilesAdded",function(a,c){if(count==0){$("#filelist").html("").trigger("create").trigger("refresh")}var d="";var b=0;$.each(c,function(){b++});$.each(c,function(f,e){if(count+1>max_files){a.removeFile(e);error_add=true}else{if(count==0){d+='<ul data-role="listview" data-inset="true" id="files"><li data-role="list-divider">Файлы</li>'}d+='<li id="'+e.id+'"><h3>'+e.name+"</h3><p>"+plupload.formatSize(e.size)+'</p> <span class="ui-li-count">0%</span></li>';if(b-1==f){d+="</ul>"}count++}});if(error_add){alert_message("Нельзя добавлять более "+max_files+" "+word(max_files,"файла","файлов","файлов")+".","information",3)}div_text=$("#filelist").html().replace("</ul>","")+d;$("#filelist").html(div_text).trigger("create").trigger("refresh");a.refresh()});uploader.bind("UploadProgress",function(a,b){$("#"+b.id+" span").html(b.percent+"%")});uploader.bind("FileUploaded",function(a,c,b){b=jQuery.parseJSON(b.response);if(b.error.code>0){$("#"+c.id+" p").html(b.error.message)}$("#"+c.id+" span").html("100%")})});uploader.bind("UploadComplete",function(a,b){alert_message("Загрузка завершена.","information",3)});$("#page_avatar").bind("pagehide",function(){uploader.destroy()});$("#page_avatar").on("click","#clean",function(){uploader.splice();count=0;error_add=false;$("#filelist").html("").trigger("create").trigger("refresh")});
?>
Онлайн: 2
Реклама