/************************************************************************************************** 文件: js/global.js 说明: phpok默认模板中涉及到的js 版本: 4.0 网站: www.phpok.com 作者: qinggan 日期: 2014年9月1日 ***************************************************************************************************/ function top_search() { var title = $("#top-keywords").val(); if(!title) { alert('请输入要搜索的关键字'); return false; } return true; } // 退出 function logout(t) { var q = confirm("您好,【"+t+"】,确定要退出吗?"); if(q == '0') { return false; } $.phpok.go(get_url('logout')); } ;(function($){ /** * 会员相关操作 **/ $.user = { login: function(title){ var url = get_url('login','open'); $.dialog.open(url,{ 'title':title, 'lock':true, 'width':'500px', 'height':'400px' }); }, logout: function(title){ $.dialog.confirm('您好,'+title+',您确定要退出吗?',function(){ $.phpok.go(get_url('logout')); }); } }; /** * 评论相关操作 **/ $.comment = { post:function() { $("#comment-post").ajaxsubmit({ 'url':api_url('comment','save'), 'type':'post', 'datatype':'json', 'success':function(rs){ if(rs.status == 'ok'){ $.dialog.alert('感谢您提交的评论',function(){ $.phpok.reload(); },'succeed'); return true; } $.dialog.alert(rs.content); return false; } }); return false; } } })(jquery); function fav_add(id,obj) { var val = ($(obj).val()).trim(); if(val == '已收藏'){ $.dialog.alert('已收藏过,不能重复执行'); return false; } var url = api_url('fav','add','id='+id); $.phpok.json(url,function(rs){ if(rs.status == 'ok'){ $(obj).val('加入收藏成功'); window.settimeout(function(){ $(obj).val('已收藏') }, 1000); }else{ $.dialog.alert(rs.content); return false; } }); } $(document).ready(function(){ //返回顶部 /*if ($("meta[name=totop]").attr("content") == "true") { $("
").appendto('body'); $("#totop").css({ width: '50px', height: '50px', bottom: '10px', right: '15px', position: 'fixed', cursor: 'pointer', zindex: '999999' }); if ($(this).scrolltop() == 0) { $("#totop").hide(); } $(window).scroll(function(event) { if ($(this).scrolltop() == 0) { $("#totop").hide(); } if ($(this).scrolltop() != 0) { $("#totop").show(); } }); $("#totop").click(function(event) { $("html,body").animate({ scrolltop: "0px" }, 666) }); }*/ if($("#comment-post").length > 0){ //提交评论 $("#comment-post").submit(function(){ $.comment.post(); return false; }); $(document).keypress(function(e){ if(e.ctrlkey && e.which == 13 || e.which == 10) { save_comment(); return false; } }); } });