Файл: static/js/custom/news_read.js
Строк: 158
<?php
var n=0;var max_n=0;var e=10;$("#page_news_read").on("click","#delete",function(){$.get("/modules/news_delete/?id="+$(this).attr("data-id"),function(){});$.mobile.changePage("/news_category/?category="+$(this).attr("data-category"),{transition:"flip",reloadPage:true})});$("#page_news_read").bind("pageshow",function(){e=parseInt($("#comments").attr("data-e"));$("#comments_send").sisyphus({timeout:sisyphus_time});if(e>0){load_comments(0,true)}});$("#page_news_read").bind("pagehide",function(){$("#page_news_read").remove()});$("#page_news_read #next").on("click",next_page);$("#page_news_read #back").on("click",back_page);$("#page_news_read").on("swipeleft","#comments",function(){if(is_PC()){return}back_page()});$("#page_news_read").on("swiperight","#comments",function(){if(is_PC()){return}next_page()});$("#page_news_read").on("click","#submit",function(){$("#comments_send").addClass("ui-disabled").trigger("updatelayout");$.ajax({type:"POST",url:"/modules/comments_add/?id="+$("#comments").attr("data-news")+"&type=news",cache:false,dataType:"json",data:$("#comments_send").serialize(),success:success_send,complete:$("#comments_send").removeClass("ui-disabled").trigger("updatelayout")});return false});$("#page_news_read").on("taphold","#comments li",function(){if($("#page_news_read").attr("data-admin")==0||altKey){return}comment=$(this).attr("data-id");$("#page_news_read #popup_comment").popup("open",{positionTo:"window",transition:"flip"})});$("#comments_list li").live("click",function(){if($("#page_news_read").attr("data-auth")==0){return}$("#text").focus().attr("value",$(this).attr("data-user")+", ")});$("#page_news_read").on("click","#delete_comment",function(){$.get("/modules/comments_delete/?id="+comment,function(){load_comments(n,true)});alert_message("Комментарий удален.","information",3);comment=0});$("#text").keydown(function(a){if(a.ctrlKey&&a.keyCode==13){$("#submit").click()}});function success_send(a){if(a!="true"){return alert_message(a,"information",3)}n=0;load_comments(n,true);$("#comments_send").find("textarea").val("");return true}function load_comments(b,a){if(a){$.mobile.showPageLoadingMsg()}$.getJSON("/modules/comments_get/?id="+$("#comments").attr("data-news")+"&n="+b+"&type=news",function(d){var c="";$.each(d,function(f,g){if(f==0){c+='<ul data-role="listview" id="comments_list" data-inset="true" data-max="'+g+'"><li data-role="list-divider">Комментарии</li>';max_n=g}else{c+='<li data-id="'+g.id+'" data-user="'+g.username+'" data-icon="false"><img id="user_avatar" data-user="'+g.user_id+'" class="image-radius" style="opacity: 1.0" src="/modules/get_avatar/?id='+g.user_id+'&size=2" alt=""><h3 style="font-size: 14px">'+g.username+"</h3><p>"+g.message+'</p><p class="ui-li-aside">'+g.date+"</p></li>"}});if(max_n==0){c+="<li>Комментариев нет.</li>"}c+="</ul>";$("#comments").html(c).trigger("create").trigger("refresh");update_navigation();if(a){$.mobile.hidePageLoadingMsg()}})}function next_page(){if((n-e)<0){return}n=n-e;load_comments(n,true)}function back_page(){if((n+e)>=max_n){return}n=n+e;load_comments(n,true)};
?>