var $=require("jquery"),Base=require("basePC"),Dialog=require("./../lib/js/dialogPC.js"),UIkit=require("./../uikit/uikit.js"),Util=require("./../lib/js/util.js"),CommonSelectDialog=require("./../lib/js/commonSelectDialog.js"),Convenient=require("./../lib/js/convenient.js"),JqueryTimeago=require("./../lib/js/jqueryTimeago.js"),Share=require("./../share.js/share.js"),Lazyload=require("./../lib/js/jqueryLazyload.js");$.timeago.settings.allowFuture=!0,$(function(){$("[datetime]").timeago(),$("[data-src]").lazyload({data_attribute:"src"}),Share.init()});var apiInit=function(){window.api={},window.api.dialog=Dialog,window.api.base=Base,window.api.util=Util},callbackInit=function(){window.callback={},window.callback.wangEditorUploadImage=function(o){new CommonSelectDialog($.extend({server:"/data/image_select_dialog"},{callback:function(a){o(a)}}),Dialog).show()},window.callback.mdeditorUploadImage=function(o){new CommonSelectDialog($.extend({server:"/data/image_select_dialog"},{callback:function(a){o(a)}}),Dialog).show()}},commonInit=function(){$(document).on("click","[data-member-image-upload]",function(){var o=$(this).attr("data-member-image-upload");new CommonSelectDialog($.extend({server:"/data/image_select_dialog"},{callback:function(a){a.length&&($("[data-member-image-upload-preview="+o+"]").attr("src",a[0]).show(),$("[data-member-image-upload-value="+o+"]").val(a[0]))}}),Dialog).show()}),$(window).on("scroll",function(){$(window).scrollTop()>100?$(".pb-footer-toolbox > .top").fadeIn().css("display","block"):$(".pb-footer-toolbox > .top").fadeOut()})},noteSnsInit=function(){if($(document).on("click",".topic-follow-box",function(){var o=$(this).attr("data-topic-id");$.post("/topic/follow",{topicId:o},function(a){Base.defaultFormCallback(a,{success:function(a){"followed"==a.data.action?($(".topic-follow-box[data-topic-id="+o+"] .follow").removeClass("show"),$(".topic-follow-box[data-topic-id="+o+"] .unfollow").addClass("show")):($(".topic-follow-box[data-topic-id="+o+"] .unfollow").removeClass("show"),$(".topic-follow-box[data-topic-id="+o+"] .follow").addClass("show"))}})})}),$(document).on("click",".user-follow-box",function(){var o=$(this).attr("data-user-id");$.post("/member/follow",{memberUserId:o},function(a){Base.defaultFormCallback(a,{success:function(a){"followed"==a.data.action?($(".user-follow-box[data-user-id="+o+"] .follow").removeClass("show"),$(".user-follow-box[data-user-id="+o+"] .unfollow").addClass("show")):($(".user-follow-box[data-user-id="+o+"] .unfollow").removeClass("show"),$(".user-follow-box[data-user-id="+o+"] .follow").addClass("show"))}})})}),$(document).on("click",".note-like-box",function(){$.post("/note/like",{noteId:$(this).attr("data-note-id")},function(o){Base.defaultFormCallback(o,{success:function(o){"liked"==o.data.action?$(".note-like-box").addClass("liked"):$(".note-like-box").removeClass("liked"),$(".note-like-box .count").html(o.data.count)}})})}),$("[data-member-notification-count]").length){var o=$("[data-member-notification-count]"),a=window.document.title,e=function(){setTimeout(function(){$.post("/member/message_notification",{},function(t){Base.defaultFormCallback(t,{success:function(e){o.html(e.data.count),e.data.count>0?(o.addClass("show"),window.document.title="有"+e.data.count+"条新消息 | "+a):(o.removeClass("show"),window.document.title=a)}}),e()})},3e4)};e()}};module.exports={init:function(){Base.init(),Convenient.init(Dialog),apiInit(),callbackInit(),commonInit(),noteSnsInit()},Base:Base,Dialog:Dialog,Util:Util};