Вход Регистрация
Файл: static/js/custom/guestbook.js
Строк: 101
<?php
var n=0;var max_n=0;var e=10;$("#page_guestbook").bind("pageshow",function(){e=parseInt($("#guestbook").attr("data-e"));$("#guestbook_send").sisyphus({timeout:sisyphus_time});load_guestbook(0,true)});$("#page_guestbook").bind("pagehide",function(){$("#page_guestbook").remove()});$("#page_guestbook #next").on("click",next_page);$("#page_guestbook #back").on("click",back_page);$("#page_guestbook").on("swipeleft","#guestbook",function(){if(is_PC()){return}back_page()});$("#page_guestbook").on("swiperight","#guestbook",function(){if(is_PC()){return}next_page()});$("#page_guestbook").on("click","#submit",function(){$("#guestbook_send").addClass("ui-disabled").trigger("updatelayout");$.ajax({type:"POST",url:"/modules/guestbook_add/",cache:false,dataType:"json",data:$("#guestbook_send").serialize(),success:success_send,complete:$("#guestbook_send").removeClass("ui-disabled").trigger("updatelayout")});return false});$("#page_guestbook").on("taphold","#guestbook_list li",function(){if($("#page_guestbook").attr("data-admin")==0||altKey){return}message=$(this).attr("data-id");$("#page_guestbook #popup").popup("open",{positionTo:"window",transition:"flip"})});$("#guestbook_list li").live("click",function(){$("#text").focus().attr("value",$(this).attr("data-user")+", ")});$("#page_guestbook").on("click","#delete",function(){$.get("/modules/guestbook_delete/?id="+message,function(){load_guestbook(n,true)});alert_message("Запись удалена.","information",3);message=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_guestbook(n,true);$("#guestbook_send").find("textarea").val("");return true}function load_guestbook(b,a){if(a){$.mobile.showPageLoadingMsg()}$.getJSON("/modules/guestbook/?n="+b,function(d){var c="";$.each(d,function(f,g){if(f==0){c+='<ul data-role="listview" id="guestbook_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+'&amp;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>";$("#guestbook").html(c).trigger("create").trigger("refresh");update_navigation();if(a){$.mobile.hidePageLoadingMsg()}})}function next_page(){if((n-e)<0){return}n=n-e;load_guestbook(n,true)}function back_page(){if((n+e)>=max_n){return}n=n+e;load_guestbook(n,true)};
?>
Онлайн: 1
Реклама