Файл: static/js/custom/photos.js
Строк: 88
<?php
var n=0;var max_n=0;var e=10;$("#page_photos").on("click","#delete",function(){$.get("/modules/photos_category_delete/?id="+category,function(){load_photos(n,true);load_categories(true)})});$("#page_photos").on("taphold","#categories li",function(){if((!$("#page_photos").attr("data-auth")&&$("#categories").attr("data-user")!=$("#page_photos").attr("data-user"))||!$("#page_photos").attr("data-admin")){return}category=$(this).attr("data-id");$("#page_photos #popup").popup("open",{positionTo:"window",transition:"flip"})});$("#page_photos").bind("pageshow",function(){e=parseInt($("#photos_last").attr("data-e"));load_photos(n,true);load_categories(true)});$("#page_photos").bind("pagehide",function(){$("#page_photos").remove()});$("#page_photos").on("click","#next",next_page);$("#page_photos").on("click","#back",back_page);$("#page_photos").on("swipeleft","#photos_last",back_page);$("#page_photos").on("swiperight","#photos_last",next_page);function load_categories(a){if($("#page_photos").attr("data-auth")==0&&$("#categories").attr("data-user")!=$("#page_photos").attr("data-auth")){return}if(a){$.mobile.showPageLoadingMsg()}$.getJSON("/modules/photos_category_get/?user="+$("#categories").attr("data-user"),function(c){if(c=="false"){if(a){$.mobile.hidePageLoadingMsg()}return}var b="";b+='<ul data-role="listview" data-inset="true"><li data-role="list-divider">Категории</li>';$.each(c,function(d,f){b+='<li data-icon="false" data-id="'+f.id+'"><a href="/photos_category/?category='+f.id+"&user="+f.user+'"><h3>'+f.name+"</h3>";if(f.about!=""){b+="<p>"+f.about+"</p>"}b+='<span class="ui-li-count">'+f.count+"</span></a></li>"});b+="</ul>";$("#categories").html(b).trigger("create").trigger("refresh");if(a){$.mobile.hidePageLoadingMsg()}})}function load_photos(b,a){if(a){$.mobile.showPageLoadingMsg()}$.getJSON("/modules/photos_last/?user="+$("#photos_last").attr("data-user")+"&n="+b,function(d){var c="";$.each(d,function(f,g){if(f==0){c+='<ul data-role="listview" id="photos_list" data-inset="true" data-max="'+g+'"><li data-role="list-divider">Записи</li>';max_n=g}else{c+='<li data-id="'+g.id+'" data-icon="false"><a href="'+g.url+'"><img class="image-radius" src="/modules/photo_download/?id='+g.id+'&size=preview" alt=""><h3 style="font-size: 14px">'+g.name+"</h3><p>"+g.description+'</p><p class="ui-li-aside">'+g.date+"</p></a></li>"}});if(max_n==0){c+="<li>Фотографий нет.</li>"}c+="</ul>";$("#photos_last").html(c).trigger("create").trigger("refresh");update_navigation();if(a){$.mobile.hidePageLoadingMsg()}})}function next_page(){if((n-e)<0){return}n=n-e;load_photos(n,true)}function back_page(){if((n+e)>=max_n){return}n=parseInt(n+e);load_photos(n,true)};
?>