Файл: static/js/custom/photos_category_edit.js
Строк: 89
<?php
var n=0;var max_n=0;var e=10;$("#page_photos_category_edit").bind("pageshow",function(){e=parseInt($("#photos").attr("data-e"));load_photos(0,true)});$("#page_photos_category_edit").on("change","input,textarea",function(){var c=$(this).attr("data-id");var b=$(this).attr("name");var a=$(this).val();if((b=="name"&&a!="")||b=="description"){if(b=="name"){$("li#"+c+" h3").html(a).trigger("create").trigger("refresh");$("li#"+c).prev().html(a).trigger("create").trigger("refresh")}if(b=="description"){$("li#"+c).find("p#about").html(a).trigger("create").trigger("refresh")}$.ajax({url:"/modules/photo_update/",type:"POST",cache:false,dataType:"json",data:{field:b,value:a,id:c},success:show_result})}});$("#page_photos_category_edit").bind("pagehide",function(){$("#page_photos_category_edit").remove()});$("#page_photos_category_edit #next").on("click",next_page);$("#page_photos_category_edit #back").on("click",back_page);$("#page_photos_category_edit").on("swipeleft","#photos",back_page);$("#page_photos_category_edit").on("swiperight","#photos",next_page);$("#page_photos_category_edit").on("focusin","input,textarea",function(){$("#page_photos_category_edit").off("swipeleft");$("#page_photos_category_edit").off("swiperight")});$("#page_photos_category_edit").on("focusout","input,textarea",function(){$("#page_photos_category_edit").on("swipeleft","#photos",back_page);$("#page_photos_category_edit").on("swiperight","#photos",next_page)});function load_photos(b,a){if(a){$.mobile.showPageLoadingMsg()}$.getJSON("/modules/photos_get_edit/?category="+$("#photos").attr("data-category")+"&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+'">';max_n=g}else{c+='<li data-role="list-divider">'+g.name+'</li><li id="'+g.id+'" data-icon="false"><img class="image-radius" src="/modules/photo_download/?id='+g.id+'&size=preview" alt=""><h3 style="font-size: 14px">'+g.name+'</h3><p id="about"></p><p class="ui-li-aside">'+g.date+'</p></li><li><input data-id="'+g.id+'" type="text" name="name" id="name" value="'+g.name+'" placeholder="Имя фотографии"/></li><li><textarea data-id="'+g.id+'" name="description" id="description" placeholder="Описание фотографии">'+g.description+"</textarea></li>"}});if(max_n==0){c+="<li>Фотографий нет.</li>"}c+="</ul>";$("#photos").html(c).trigger("create").trigger("refresh");update_navigation();if(a){$.mobile.hidePageLoadingMsg()}})}function show_result(a){if(a!="true"){alert_message(a,"information",3)}}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=n+e;load_photos(n,true)};
?>