init commit
This commit is contained in:
15
public/javascripts/about.js
Normal file
15
public/javascripts/about.js
Normal file
@@ -0,0 +1,15 @@
|
||||
$(function () {
|
||||
$(".my-nav-pills li:contains('关于')").addClass("active").siblings().removeClass("active");
|
||||
|
||||
$("#job-title").cycleText();
|
||||
|
||||
$(".fa-qrcode").mouseenter(function () {
|
||||
$(".profile-img").hide();
|
||||
$(".wechat-img").show();
|
||||
});
|
||||
|
||||
$(".fa-qrcode").mouseleave(function () {
|
||||
$(".wechat-img").hide();
|
||||
$(".profile-img").show();
|
||||
});
|
||||
});
|
||||
36
public/javascripts/aboutmanage.js
Normal file
36
public/javascripts/aboutmanage.js
Normal file
@@ -0,0 +1,36 @@
|
||||
$(function () {
|
||||
$("#side-menu>li:eq(5)").addClass("active");
|
||||
|
||||
$(".fileupload").fileupload({
|
||||
url: "/admin/uploadimg",
|
||||
dataType: "json",
|
||||
done: function (e, data) {
|
||||
$(this).prev("img").attr("src", data.result.files[0].url);
|
||||
$(this).next(":hidden").val('/images/' + data.result.files[0].name);
|
||||
}
|
||||
});
|
||||
|
||||
$('#btnSave').on('click', function () {
|
||||
$.ajax({
|
||||
url: $('#formAbout')[0].action,
|
||||
type: $('#formAbout')[0].method,
|
||||
data: $('#formAbout').serialize(),
|
||||
success: function () {
|
||||
swal({
|
||||
title: "保存成功!",
|
||||
type: "success",
|
||||
showConfirmButton: false,
|
||||
timer: 2000
|
||||
});
|
||||
},
|
||||
error: function () {
|
||||
swal({
|
||||
title: "保存失败!",
|
||||
type: "error",
|
||||
showConfirmButton: false,
|
||||
timer: 2000
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
75
public/javascripts/account.js
Normal file
75
public/javascripts/account.js
Normal file
@@ -0,0 +1,75 @@
|
||||
$(function () {
|
||||
$.supersized({
|
||||
slide_interval: 3000, // Length between transitions
|
||||
transition: 1, // 0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
|
||||
transition_speed: 3000, // Speed of transition
|
||||
performance: 1, // 0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed // (Only works for Firefox/IE, not Webkit)
|
||||
// Size & Position
|
||||
min_width: 0, // Min width allowed (in pixels)
|
||||
min_height: 0, // Min height allowed (in pixels)
|
||||
vertical_center: 1, // Vertically center background
|
||||
horizontal_center: 1, // Horizontally center background
|
||||
fit_always: 0, // Image will never exceed browser width or height (Ignores min. dimensions)
|
||||
fit_portrait: 1, // Portrait images will not exceed browser height
|
||||
fit_landscape: 0, // Landscape images will not exceed browser width
|
||||
// Components
|
||||
slide_links: 'blank', // Individual links for each slide (Options: false, 'num', 'name', 'blank')
|
||||
thumbnail_navigation: 0, // Thumbnail navigation
|
||||
slides: [ // Slideshow Images
|
||||
{image: "/images/s1.jpg"},
|
||||
{image: "/images/s2.jpg"},
|
||||
{image: "/images/s3.jpg"}
|
||||
],
|
||||
progress_bar: 1 // Timer for each slide
|
||||
});
|
||||
|
||||
$("#txtUserName").focus();
|
||||
|
||||
$("#btnLogin").on("click", function () {
|
||||
verify();
|
||||
});
|
||||
|
||||
$(document).on({
|
||||
keypress: function (e) {
|
||||
if (e.which === 13 || e.which === 10) {
|
||||
verify();
|
||||
}
|
||||
}
|
||||
}, "#txtUserName, #txtPwd");
|
||||
});
|
||||
|
||||
function verify() {
|
||||
var userName = $("#txtUserName").val();
|
||||
var password = $("#txtPwd").val();
|
||||
if (!userName) {
|
||||
$("#txtUserName").focus();
|
||||
return;
|
||||
}
|
||||
if (!password) {
|
||||
$("#txtPwd").focus();
|
||||
return;
|
||||
}
|
||||
password = md5(password);
|
||||
var $btn = $("#btnLogin");
|
||||
$btn.find("i").removeClass("fa-sign-in").addClass("fa-circle-o-notch fa-spin");
|
||||
$btn.attr("disabled", "disabled");
|
||||
$.ajax({
|
||||
url: "/login",
|
||||
type: "Post",
|
||||
data: {UserName: userName, Password: password},
|
||||
success: function (data) {
|
||||
if (data.valid === true) {
|
||||
window.location.href = data.returnTo;
|
||||
} else {
|
||||
swal({
|
||||
title: data.message,
|
||||
type: "error",
|
||||
showConfirmButton: false,
|
||||
timer: 2000
|
||||
});
|
||||
$btn.find("i").removeClass("fa-circle-o-notch fa-spin").addClass("fa-sign-in");
|
||||
$btn.removeAttr("disabled");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
140
public/javascripts/admin.js
Normal file
140
public/javascripts/admin.js
Normal file
@@ -0,0 +1,140 @@
|
||||
// Custom scripts
|
||||
$(document).ready(function () {
|
||||
|
||||
// MetsiMenu
|
||||
$('#side-menu').metisMenu();
|
||||
|
||||
// Collapse ibox function
|
||||
$('.collapse-link').click(function () {
|
||||
var ibox = $(this).closest('div.ibox');
|
||||
var button = $(this).find('i');
|
||||
var content = ibox.find('div.ibox-content');
|
||||
content.slideToggle(200);
|
||||
button.toggleClass('fa-chevron-up').toggleClass('fa-chevron-down');
|
||||
ibox.toggleClass('').toggleClass('border-bottom');
|
||||
setTimeout(function () {
|
||||
ibox.resize();
|
||||
ibox.find('[id^=map-]').resize();
|
||||
}, 50);
|
||||
});
|
||||
|
||||
// Close ibox function
|
||||
$('.close-link').click(function () {
|
||||
var content = $(this).closest('div.ibox');
|
||||
content.remove();
|
||||
});
|
||||
|
||||
// Small todo handler
|
||||
$('.check-link').click(function () {
|
||||
var button = $(this).find('i');
|
||||
var label = $(this).next('span');
|
||||
button.toggleClass('fa-check-square').toggleClass('fa-square-o');
|
||||
label.toggleClass('todo-completed');
|
||||
return false;
|
||||
});
|
||||
|
||||
// Append config box / Only for demo purpose
|
||||
//$.get("skin-config.html", function (data) {
|
||||
// $('body').append(data);
|
||||
//});
|
||||
|
||||
// minimalize menu
|
||||
$('.navbar-minimalize').click(function () {
|
||||
$("body").toggleClass("mini-navbar");
|
||||
SmoothlyMenu();
|
||||
})
|
||||
|
||||
// tooltips
|
||||
$('.tooltip-demo').tooltip({
|
||||
selector: "[data-toggle=tooltip]",
|
||||
container: "body"
|
||||
})
|
||||
|
||||
// Move modal to body
|
||||
// Fix Bootstrap backdrop issu with animation.css
|
||||
$('.modal').appendTo("body")
|
||||
|
||||
// Full height of sidebar
|
||||
function fix_height() {
|
||||
var heightWithoutNavbar = $("body > #wrapper").height() - 61;
|
||||
$(".sidebard-panel").css("min-height", heightWithoutNavbar + "px");
|
||||
}
|
||||
|
||||
fix_height();
|
||||
|
||||
// Fixed Sidebar
|
||||
// unComment this only whe you have a fixed-sidebar
|
||||
// $(window).bind("load", function() {
|
||||
// if($("body").hasClass('fixed-sidebar')) {
|
||||
// $('.sidebar-collapse').slimScroll({
|
||||
// height: 'auto',
|
||||
// railOpacity: 0.9,
|
||||
// });
|
||||
// }
|
||||
// })
|
||||
|
||||
$(window).bind("load resize click scroll", function () {
|
||||
if (!$("body").hasClass('body-small')) {
|
||||
fix_height();
|
||||
}
|
||||
})
|
||||
|
||||
$("[data-toggle=popover]")
|
||||
.popover();
|
||||
|
||||
var innerli = $('#side-menu a[href="' + window.location.pathname + '"]').parent();
|
||||
innerli.addClass("active");
|
||||
if (innerli.parent('ul.nav-second-level').length > 0) {
|
||||
innerli.parent('ul.nav-second-level').addClass('in').parent().addClass('active');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// For demo purpose - animation css script
|
||||
function animationHover(element, animation) {
|
||||
element = $(element);
|
||||
element.hover(
|
||||
function () {
|
||||
element.addClass('animated ' + animation);
|
||||
},
|
||||
function () {
|
||||
//wait for animation to finish before removing classes
|
||||
window.setTimeout(function () {
|
||||
element.removeClass('animated ' + animation);
|
||||
}, 2000);
|
||||
});
|
||||
};
|
||||
|
||||
// Minimalize menu when screen is less than 768px
|
||||
$(function () {
|
||||
$(window).bind("load resize", function () {
|
||||
if ($(this).width() < 769) {
|
||||
$('body').addClass('body-small')
|
||||
} else {
|
||||
$('body').removeClass('body-small')
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
function SmoothlyMenu() {
|
||||
if (!$('body').hasClass('mini-navbar') || $('body').hasClass('body-small')) {
|
||||
// Hide menu in order to smoothly turn on when maximize menu
|
||||
$('#side-menu').hide();
|
||||
// For smoothly turn on menu
|
||||
setTimeout(
|
||||
function () {
|
||||
$('#side-menu').fadeIn(500);
|
||||
}, 100);
|
||||
} else if ($('body').hasClass('fixed-sidebar')) {
|
||||
$('#side-menu').hide();
|
||||
setTimeout(
|
||||
function () {
|
||||
$('#side-menu').fadeIn(500);
|
||||
}, 300);
|
||||
} else {
|
||||
// Remove all inline style from jquery fadeIn function to reset menu state
|
||||
$('#side-menu').removeAttr('style');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
61
public/javascripts/article.js
Normal file
61
public/javascripts/article.js
Normal file
@@ -0,0 +1,61 @@
|
||||
$(function () {
|
||||
$(".my-nav-pills li:eq(0)").addClass("active").siblings().removeClass("active");
|
||||
|
||||
//如果目录默认为收起状态,则重新计算显示目录按钮的位置
|
||||
if (expandMenu === 'false') {
|
||||
$(".btn-menu").css("margin-left", $(".post-content").width() + 31 + "px");
|
||||
$(".btn-menu").show();
|
||||
}
|
||||
|
||||
//代码高亮
|
||||
var pres = $('#main-context pre');
|
||||
pres.each(function (i, pre) {
|
||||
$(pre).html($('<code></code>').html($(pre).html()))
|
||||
});
|
||||
hljs.initHighlightingOnLoad();
|
||||
|
||||
//将img套上a标签,以使用lightbox显示图片
|
||||
$("#main-context").find("img").wrap(function (i) {
|
||||
return "<a href=\"" + this.src + "\" data-lightbox=\"" + i + "\"></a>"
|
||||
});
|
||||
|
||||
//正常目录
|
||||
$("#main-context").scrollNav({
|
||||
sections: "h2", //一级目录的元素
|
||||
subSections: "h3", //二级目录的元素
|
||||
showHeadline: true,
|
||||
headlineText: "文章目录",
|
||||
showTopLink: false,
|
||||
scrollOffset: 70,
|
||||
arrowKeys: true,
|
||||
insertTarget: "#control-wrap",
|
||||
insertLocation: "prependTo"
|
||||
});
|
||||
|
||||
//收起目录
|
||||
$(".close-menu").on("click", function () {
|
||||
$("#control-wrap").hide();
|
||||
$(".post-content").removeClass("col-md-9").addClass("col-md-12");
|
||||
//CSS动画完成后再执行
|
||||
$(".post-content").on('transitionend webkitTransitionEnd oTransitionEnd', function () {
|
||||
$(".btn-menu").css("margin-left", $(".post-content").width() + 31 + "px");
|
||||
$(".btn-menu").show();
|
||||
});
|
||||
});
|
||||
|
||||
//显示目录
|
||||
$(".btn-menu").on("click", function () {
|
||||
$(".btn-menu").hide();
|
||||
$(".post-content").removeClass("col-md-12").addClass("col-md-9");
|
||||
//CSS动画完成后再执行
|
||||
$(".post-content").on('transitionend webkitTransitionEnd oTransitionEnd', function () {
|
||||
$(".btn-menu").hide(); //TODO:需隐藏2次,否则显示不正常,待研究~
|
||||
$("#control-wrap").show();
|
||||
});
|
||||
});
|
||||
|
||||
//改变窗口大小后,重置目录,以修正各标题的定位
|
||||
$(window).on("resize", function () {
|
||||
$.fn.scrollNav("resetPos");
|
||||
});
|
||||
});
|
||||
251
public/javascripts/articlemanage.js
Normal file
251
public/javascripts/articlemanage.js
Normal file
@@ -0,0 +1,251 @@
|
||||
var $table = $("#articles"),
|
||||
$remove = $("#remove"),
|
||||
selections = [];
|
||||
|
||||
$(function () {
|
||||
$("#side-menu>li:eq(2)").addClass("active").find("ul").addClass("in").find("li:eq(2)").addClass("active");
|
||||
|
||||
if (selections.length == 0) {
|
||||
$remove.attr("disabled", "disabled");
|
||||
}
|
||||
|
||||
$table.bootstrapTable({
|
||||
url: "/admin/getArticles",
|
||||
method: "post",
|
||||
pagination: true,
|
||||
paginationFirstText: "<i class=\"fa fa-angle-double-left\"></i>",
|
||||
paginationPreText: "<i class=\"fa fa-angle-left\"></i>",
|
||||
paginationNextText: "<i class=\"fa fa-angle-right\"></i>",
|
||||
paginationLastText: "<i class=\"fa fa-angle-double-right\"></i>",
|
||||
queryParamsType: "pageIndex",
|
||||
sidePagination: "server",
|
||||
pageList: [10, 25, 50, 100, "All"],
|
||||
search: true,
|
||||
sortName: "CreateTime",
|
||||
sortOrder: "desc",
|
||||
toolbar: "#toolbar",
|
||||
showRefresh: true,
|
||||
showColumns: true,
|
||||
iconsPrefix: "fa",
|
||||
icons: {
|
||||
refresh: "fa-refresh",
|
||||
columns: "fa-th-list"
|
||||
},
|
||||
idField: "UniqueId",
|
||||
filterControl: true,
|
||||
responseHandler: responseHandler,
|
||||
columns: [{
|
||||
field: "state",
|
||||
checkbox: true,
|
||||
align: "center",
|
||||
valign: "middle"
|
||||
}, {
|
||||
field: "CateName",
|
||||
title: "分类",
|
||||
halign: "center",
|
||||
valign: "middle",
|
||||
width: "140px",
|
||||
filterControl: "select",
|
||||
filterData: "url:/admin/getCateFilter",
|
||||
formatter: function (value, row) {
|
||||
if (row.CategoryAlias) {
|
||||
return "<a href=\"/blog/" + row.CategoryAlias + "\" target=\"_blank\">" + value + "</a>";
|
||||
}
|
||||
}
|
||||
}, {
|
||||
field: "UniqueId",
|
||||
title: "ID",
|
||||
align: "center",
|
||||
valign: "middle",
|
||||
width: "180px",
|
||||
filterControl: "input",
|
||||
visible: false
|
||||
}, {
|
||||
field: "Title",
|
||||
title: "标题",
|
||||
halign: "center",
|
||||
valign: "middle",
|
||||
formatter: function (value, row) {
|
||||
var link = !row.IsActive ? '<span class="label label-danger" title="该文章已删除">已删除</span> ' : '';
|
||||
link += row.IsDraft ? '<span class="label label-primary" title="这是一篇草稿">草稿</span> ' : '';
|
||||
if (row.Source === '1') {
|
||||
link += "<a href=\"" + row.Url + "\" target=\"_blank\"><i class=\"fa fa-link\"></i> " + value + "</a>";
|
||||
} else {
|
||||
if (row.CategoryAlias) {
|
||||
link += "<a href=\"/blog/" + row.CategoryAlias + "/" + row.Alias + "\" target=\"_blank\">" + value + "</a>";
|
||||
}
|
||||
}
|
||||
return link;
|
||||
},
|
||||
filterControl: "input"
|
||||
}, {
|
||||
field: "CreateTime",
|
||||
title: "发布时间",
|
||||
align: "center",
|
||||
valign: "middle",
|
||||
width: "180px",
|
||||
sortable: true
|
||||
}, {
|
||||
field: "ModifyTime",
|
||||
title: "修改时间",
|
||||
align: "center",
|
||||
valign: "middle",
|
||||
width: "180px",
|
||||
sortable: true
|
||||
}, {
|
||||
field: "ViewCount",
|
||||
title: "浏览次数",
|
||||
align: "center",
|
||||
valign: "middle",
|
||||
width: "120px",
|
||||
sortable: true,
|
||||
formatter: function (value, row) {
|
||||
if (row.Source == 1) {
|
||||
return "-";
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
field: "operate",
|
||||
title: "操作",
|
||||
align: "center",
|
||||
valign: "middle",
|
||||
width: "120px",
|
||||
events: {
|
||||
"click .remove": function (e, value, row, index) {
|
||||
swal({
|
||||
title: "确定要删除该文章吗?",
|
||||
text: "文章标题:" + row.Title,
|
||||
html: true,
|
||||
type: "warning",
|
||||
allowOutsideClick: true,
|
||||
showCancelButton: true,
|
||||
cancelButtonText: "取消",
|
||||
confirmButtonColor: "#d9534f",
|
||||
confirmButtonText: "确认删除",
|
||||
closeOnConfirm: false
|
||||
},
|
||||
function () {
|
||||
$(".sweet-alert .confirm").text("提交中...");
|
||||
$(".sweet-alert .confirm").attr("disabled", "disabled");
|
||||
deleteArticle(row.UniqueId);
|
||||
});
|
||||
},
|
||||
"click .undo": function (e, value, row, index) {
|
||||
swal({
|
||||
title: "确定要恢复该文章吗?",
|
||||
text: "文章标题:" + row.Title,
|
||||
html: true,
|
||||
type: "warning",
|
||||
allowOutsideClick: true,
|
||||
showCancelButton: true,
|
||||
cancelButtonText: "取消",
|
||||
confirmButtonText: "确认恢复",
|
||||
closeOnConfirm: false
|
||||
},
|
||||
function () {
|
||||
$(".sweet-alert .confirm").text("提交中...");
|
||||
$(".sweet-alert .confirm").attr("disabled", "disabled");
|
||||
undoArticle(row.UniqueId);
|
||||
});
|
||||
}
|
||||
},
|
||||
formatter: function (value, row) {
|
||||
if (row.IsActive) {
|
||||
return "<a class=\"edit btn btn-white\" title=\"编辑\" href=\"/admin/editarticle/" + row.UniqueId + "\"><i class=\"fa fa-pencil\"></i></a> "
|
||||
+ "<button type=\"button\" class=\"remove btn btn-white\" title=\"删除\"><i class=\"fa fa-trash-o\"></i></button>";
|
||||
} else {
|
||||
return "<a class=\"edit btn btn-white\" title=\"编辑\" href=\"/admin/editarticle/" + row.UniqueId + "\"><i class=\"fa fa-pencil\"></i></a> "
|
||||
+ "<button type=\"button\" class=\"undo btn btn-white\" title=\"恢复\"><i class=\"fa fa-undo\"></i></button>";
|
||||
}
|
||||
}
|
||||
}]
|
||||
});
|
||||
|
||||
$table.on('check.bs.table check-all.bs.table ' +
|
||||
'uncheck.bs.table uncheck-all.bs.table', function (e, rows) {
|
||||
var ids = $.map(!$.isArray(rows) ? [rows] : rows, function (row) {
|
||||
if (row.IsActive) {
|
||||
return row.UniqueId;
|
||||
}
|
||||
}),
|
||||
func = $.inArray(e.type, ['check', 'check-all']) > -1 ? 'union' : 'difference';
|
||||
selections = _[func](selections, ids);
|
||||
var selectionLength = selections.length;
|
||||
if (selectionLength > 0) {
|
||||
$remove.find(".badge").html(selectionLength);
|
||||
$remove.find(".badge").show();
|
||||
} else {
|
||||
$remove.find(".badge").html("");
|
||||
$remove.find(".badge").hide();
|
||||
}
|
||||
$remove.prop('disabled', !selectionLength);
|
||||
});
|
||||
|
||||
$remove.click(function () {
|
||||
swal({
|
||||
title: "确定要删除这 " + selections.length + " 篇文章吗?",
|
||||
html: true,
|
||||
type: "warning",
|
||||
allowOutsideClick: true,
|
||||
showCancelButton: true,
|
||||
cancelButtonText: "取消",
|
||||
confirmButtonColor: "#d9534f",
|
||||
confirmButtonText: "确认删除",
|
||||
closeOnConfirm: false
|
||||
},
|
||||
function () {
|
||||
$(".sweet-alert .confirm").text("提交中...");
|
||||
$(".sweet-alert .confirm").attr("disabled", "disabled");
|
||||
deleteArticle(selections.join(","));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function deleteArticle(ids) {
|
||||
$remove.prop("disabled", true);
|
||||
$.ajax({
|
||||
url: "/admin/deleteArticles",
|
||||
type: "post",
|
||||
data: "ids=" + ids,
|
||||
complete: function () {
|
||||
selections = [];
|
||||
$table.bootstrapTable('selectPage', 1);
|
||||
$remove.find(".badge").html("");
|
||||
$remove.find(".badge").hide();
|
||||
$(".sweet-alert .confirm").removeAttr("disabled");
|
||||
swal({
|
||||
title: "删除成功!",
|
||||
type: "success",
|
||||
showConfirmButton: false,
|
||||
timer: 1000
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function undoArticle(id){
|
||||
$.ajax({
|
||||
url: "/admin/undoArticle",
|
||||
type: "post",
|
||||
data: "id=" + id,
|
||||
complete: function () {
|
||||
$table.bootstrapTable('selectPage', 1);
|
||||
$(".sweet-alert .confirm").removeAttr("disabled");
|
||||
swal({
|
||||
title: "恢复成功!",
|
||||
type: "success",
|
||||
showConfirmButton: false,
|
||||
timer: 1000
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function responseHandler(res) {
|
||||
$.each(res.rows, function (i, row) {
|
||||
row.state = $.inArray(row.UniqueId, selections) !== -1;
|
||||
});
|
||||
return res;
|
||||
}
|
||||
66
public/javascripts/cachemanage.js
Normal file
66
public/javascripts/cachemanage.js
Normal file
@@ -0,0 +1,66 @@
|
||||
$(function () {
|
||||
$("#side-menu>li:eq(6)").addClass("active");
|
||||
|
||||
$('#keyinput').on('changed.fu.combobox', function (evt, data) {
|
||||
if (data.value) {
|
||||
$('#cacheKey').val(data.value);
|
||||
}
|
||||
});
|
||||
|
||||
$("#btnQuery").on("click", function () {
|
||||
var key = $("#cacheKey").val();
|
||||
if (key) {
|
||||
$.ajax({
|
||||
url: "/admin/getcache",
|
||||
type: "Post",
|
||||
data: {
|
||||
key: key
|
||||
},
|
||||
success: function (data) {
|
||||
var json = data ? JSON.stringify(data, null, 2) : '';
|
||||
$("#cacheContent").html(json);
|
||||
$("#cacheContent").focus();
|
||||
},
|
||||
error: function () {
|
||||
swal({
|
||||
title: "获取失败!",
|
||||
type: "error",
|
||||
showConfirmButton: false,
|
||||
timer: 2000
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("#btnClear").on("click", function () {
|
||||
var key = $("#cacheKey").val();
|
||||
if (key) {
|
||||
$.ajax({
|
||||
url: "/admin/clearcache",
|
||||
type: "Post",
|
||||
data: {
|
||||
key: key
|
||||
},
|
||||
success: function () {
|
||||
swal({
|
||||
title: "成功清除!",
|
||||
type: "success",
|
||||
showConfirmButton: false,
|
||||
timer: 2000
|
||||
});
|
||||
$("#cacheContent").html("");
|
||||
$("#cacheContent").focus();
|
||||
},
|
||||
error: function () {
|
||||
swal({
|
||||
title: "清除失败!",
|
||||
type: "error",
|
||||
showConfirmButton: false,
|
||||
timer: 2000
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
378
public/javascripts/category.js
Normal file
378
public/javascripts/category.js
Normal file
@@ -0,0 +1,378 @@
|
||||
var home_loading_timeout = 2000;
|
||||
var isLoading = false;
|
||||
var timeout = 1000;
|
||||
var contentTimeout = 1500;
|
||||
var begin = new Date();
|
||||
var contentBegin = new Date();
|
||||
var pageCount;
|
||||
var tooltip_timeout = 1500;
|
||||
$(function () {
|
||||
$(".my-nav-pills li:eq(0)").addClass("active").siblings().removeClass("active");
|
||||
$("#load-list").show();
|
||||
$("#PageIndex").val(1);
|
||||
requestData();
|
||||
|
||||
$(".category-list").mCustomScrollbar({
|
||||
axis: "y",
|
||||
theme: "dark-3"
|
||||
});
|
||||
|
||||
$(window).scroll(function () {
|
||||
$("[data-toggle='tooltip']").tooltip("hide");
|
||||
});
|
||||
|
||||
$("[data-toggle='tooltip']").tooltip({
|
||||
container: "body"
|
||||
});
|
||||
|
||||
$(document).on({
|
||||
click: function () {
|
||||
$(this).remove();
|
||||
begin = new Date();
|
||||
$("#load-list").show();
|
||||
isLoading = true;
|
||||
$("#PageIndex").val(parseInt($("#PageIndex").val()) + 1);
|
||||
requestData();
|
||||
}
|
||||
}, "#btn-load");
|
||||
|
||||
$(document).on({
|
||||
click: function () {
|
||||
var index = $(this).attr("page");
|
||||
var pageItem = $("#page" + index);
|
||||
$("html,body").animate({scrollTop: $(pageItem).offset().top - 90}, 1000);
|
||||
}
|
||||
}, "#page-nav a");
|
||||
|
||||
$(document).on({
|
||||
click: function () {
|
||||
$(".bd_weixin_popup").hide();
|
||||
$(".bd_weixin_popup_bg").hide();
|
||||
$(".post-cover").fadeIn();
|
||||
$("body").addClass("modal-open");
|
||||
var title = $(this).siblings("h4").children("a").html();
|
||||
var uid = $(this).parent().attr("uid");
|
||||
$(".post-modal .modal-header h4").html(title);
|
||||
$("#btnFullMode").attr("href", "/" + uid);
|
||||
$(".sk-cube-grid").show();
|
||||
$(".post-content div").hide();
|
||||
var comments = $(this).parent().find(".cy_cmt_count").text();
|
||||
$("#modal-comments").text(comments);
|
||||
$(".post-modal").css("right", 0);
|
||||
contentBegin = new Date();
|
||||
$.ajax({
|
||||
url: "/blog/getPreviewContent",
|
||||
type: "Post",
|
||||
data: {alias: uid},
|
||||
success: function (data) {
|
||||
var end = new Date();
|
||||
if (end - contentBegin > contentTimeout) {
|
||||
appendContent(data);
|
||||
} else {
|
||||
var timespan = contentTimeout - (end - contentBegin);
|
||||
setTimeout(function () {
|
||||
appendContent(data);
|
||||
}, timespan);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, ".preview-link");
|
||||
|
||||
$(".post-modal .modal-body").mCustomScrollbar({
|
||||
theme: "dark-3",
|
||||
scrollButtons: {
|
||||
enable: true
|
||||
}
|
||||
});
|
||||
|
||||
$(".post-cover").on("click", function () {
|
||||
closeModal();
|
||||
});
|
||||
|
||||
$("#btnCloseModal").on("click", function () {
|
||||
closeModal();
|
||||
});
|
||||
|
||||
$("#btnFullMode").on("click", function () {
|
||||
setTimeout(closeModal, 800);
|
||||
});
|
||||
|
||||
$(".list-top-left a").on("click", function () {
|
||||
if (!$(this).hasClass("current")) {
|
||||
$(this).addClass("current").siblings().removeClass("current");
|
||||
$(".list-wrap ol").html("");
|
||||
$("[data-toggle='tooltip']").tooltip("hide");
|
||||
$("#page-nav").html("");
|
||||
$("#btn-load").remove();
|
||||
$("#no-more").remove();
|
||||
begin = new Date();
|
||||
$("#load-list").show();
|
||||
$("#SortBy").val($(this).attr("sort"));
|
||||
$("#PageIndex").val(1);
|
||||
requestData();
|
||||
}
|
||||
});
|
||||
|
||||
$("#Keyword").on("keypress", function (e) {
|
||||
if (e.which == 13 || e.which == 10) {
|
||||
searchPost();
|
||||
}
|
||||
});
|
||||
|
||||
$("#btnFilter").on("click", function () {
|
||||
searchPost();
|
||||
});
|
||||
|
||||
$(".selectlist").on("changed.fu.selectlist", function (e, data) {
|
||||
$(this).find("li").removeClass("active");
|
||||
$(this).find("li[data-value=" + data.value + "]").addClass("active");
|
||||
});
|
||||
});
|
||||
|
||||
function requestData() {
|
||||
$.ajax({
|
||||
url: $('#filterForm')[0].action,
|
||||
type: $('#filterForm')[0].method,
|
||||
data: $('#filterForm').serialize(),
|
||||
success: function (result) {
|
||||
var end = new Date();
|
||||
var data = result.posts;
|
||||
pageCount = result.pageCount;
|
||||
if (end - begin > timeout) {
|
||||
addPage($("#PageIndex").val(), data);
|
||||
} else {
|
||||
var timespan = timeout - (end - begin);
|
||||
setTimeout(function () {
|
||||
addPage($("#PageIndex").val(), data);
|
||||
}, timespan);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function appendContent(data) {
|
||||
$(".sk-cube-grid").hide();
|
||||
$(".post-content div").html(data.Content);
|
||||
|
||||
var labels = JSON.parse(data.Labels);
|
||||
$.each(labels, function (key, value) {
|
||||
$("#label-foot").append("<span title=\"" + value.text + "\" class=\"post-label\">" + value.text + "</span>");
|
||||
});
|
||||
$(".post-modal .modal-body").mCustomScrollbar("scrollTo", "top", {
|
||||
scrollInertia: 0
|
||||
});
|
||||
$(".post-content div").fadeIn();
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
$(".post-modal").css("right", "-1200px");
|
||||
$(".post-cover").fadeOut();
|
||||
$("body").removeClass("modal-open");
|
||||
resetModal();
|
||||
}
|
||||
|
||||
function resetModal() {
|
||||
$(".post-modal .modal-header h4").empty();
|
||||
$(".post-content div").empty();
|
||||
$("#label-foot").empty();
|
||||
}
|
||||
|
||||
function searchPost() {
|
||||
$(".list-wrap ol").html("");
|
||||
$("[data-toggle='tooltip']").tooltip("hide");
|
||||
$("#page-nav").html("");
|
||||
$("#btn-load").remove();
|
||||
$("#no-more").remove();
|
||||
begin = new Date();
|
||||
$("#load-list").show();
|
||||
$("#PageIndex").val(1);
|
||||
requestData();
|
||||
}
|
||||
|
||||
function addPage(index, data) {
|
||||
$("#load-list").hide();
|
||||
if (data.length > 0) {
|
||||
$(".list-wrap ol").append("<li id=\"page" + index + "\"></li>");
|
||||
$.each(data, function (key, value) {
|
||||
var itemHtml;
|
||||
if (value.Source == "1") {
|
||||
itemHtml = "<div uid=\""
|
||||
+ value.Alias
|
||||
+ "\" class=\"blog-item " + ($(".home-loading").length > 0 ? "" : "animated fadeIn") + "\">"
|
||||
+ " <h4>"
|
||||
+ " <a title=\""
|
||||
+ value.Title
|
||||
+ "\" target=\"_blank\" href=\""
|
||||
+ value.Url
|
||||
+ "\">"
|
||||
+ "<i class=\"fa fa-link\"></i> " + value.Title
|
||||
+ " <\/a>"
|
||||
+ " <\/h4>"
|
||||
+ " <span title=\"文章分类\">"
|
||||
+ " <i class=\"fa fa-tasks\">"
|
||||
+ " <\/i>"
|
||||
+ " "
|
||||
+ "<a href=\"/blog/category/" + value.CategoryAlias + "\" target=\"_blank\">" + value.CateName + "</a>"
|
||||
+ " <\/span>"
|
||||
+ " <span title=\"发布时间\" class=\"margin-left-20\">"
|
||||
+ " <i class=\"fa fa-clock-o\">"
|
||||
+ " <\/i>"
|
||||
+ " "
|
||||
+ value.PublishDate
|
||||
+ " <\/span>"
|
||||
+ " <a title=\""
|
||||
+ value.Host
|
||||
+ "\" target=\"_blank\" href=\""
|
||||
+ value.Url.substring(0, value.Url.indexOf("://") + 3) + value.Host
|
||||
+ "\" class=\"pull-right margin-left-20 hidden-xs\">"
|
||||
+ " "
|
||||
+ "<i class=\"fa fa-globe\"></i> " + value.Host
|
||||
+ " <\/a>"
|
||||
+ " <div class=\"clearfix\">"
|
||||
+ " <\/div>"
|
||||
+ " <p>"
|
||||
+ " "
|
||||
+ encodeHtml(value.Summary)
|
||||
+ " <\/p>"
|
||||
+ "<\/div>"
|
||||
+ "<div class=\"hr-line-dashed\"></div>";
|
||||
} else {
|
||||
itemHtml = "<div class=\"blog-item " + ($(".home-loading").length > 0 ? "" : "animated fadeIn") + "\" uid=\"" + value.Alias + "\"><a class=\"preview-link\"></a><h4><a href=\"/blog/" + value.CategoryAlias + "/" + value.Alias + "\" target=\"_blank\" title=\"" + value.Title + "\">" + value.Title + "</a></h4><span title=\"文章分类\"><i class=\"fa fa-tasks\"></i> " + "<a href=\"/blog/" + value.CategoryAlias + "\" target=\"_blank\">" + value.CateName + "</a>" + "</span> <span class=\"margin-left-20\" title=\"发布时间\"><i class=\"fa fa-clock-o\"></i> " + value.PublishDate + "</span><span class=\"pull-right margin-left-20 hidden-xs\" title=\"评论人数\"><i class=\"fa fa-comments-o\"></i> <span id = \"sourceId::" + value.UniqueId + "\" class = \"cy_cmt_count\" ></span></span><span class=\"pull-right hidden-xs\" title=\"浏览次数\"><i class=\"fa fa-eye\"></i> " + value.ViewCount + "</span><div class=\"clearfix\"></div><p>" + encodeHtml(value.Summary) + "</p></div><div class=\"hr-line-dashed\"></div>";
|
||||
}
|
||||
$("#page" + index).append(itemHtml);
|
||||
});
|
||||
$("body").append("<script id=\"cy_cmt_num\" src=\"http://changyan.sohu.com/upload/plugins/plugins.list.count.js?clientId=cyrUoGjWj\"><\/script>");
|
||||
var item = $("<li><a href=\"javascript:void(0)\" page=\"" + index + "\" data-toggle=\"tooltip\" data-placement=\"right\" title=\"第" + index + "页\"></a></li>");
|
||||
item.appendTo($("#page-nav"));
|
||||
var percent = 100 / index;
|
||||
$("#page-nav li").css("height", percent + "%");
|
||||
$("[data-toggle='tooltip']:visible").tooltip({
|
||||
container: "body"
|
||||
});
|
||||
item.find("a").tooltip("show");
|
||||
setTimeout(function () {
|
||||
item.find("a").tooltip("hide");
|
||||
}, tooltip_timeout);
|
||||
if ($("#PageIndex").val() == pageCount) {
|
||||
if (pageCount != 1) {
|
||||
$(".list-wrap").append("<div id=\"no-more\" class=\"text-muted text-center\">没有更多数据<\/div>");
|
||||
}
|
||||
} else {
|
||||
$(".list-wrap").append("<button id=\"btn-load\" class=\"btn btn-white btn-block\">下一页</button>");
|
||||
}
|
||||
} else {
|
||||
$(".list-wrap ol").append("<li id=\"page" + index + "\"></li>");
|
||||
$("#page" + index).append("<div class=\"text-center text-muted\">暂无数据</div>");
|
||||
}
|
||||
isLoading = false;
|
||||
if ($(".home-loading").length > 0) {
|
||||
var home_loading_end = new Date();
|
||||
$("[data-toggle='tooltip']").tooltip("hide");
|
||||
if (home_loading_end - home_loading_begin > home_loading_timeout) {
|
||||
$(".home-loading").remove();
|
||||
document.body.style.overflow = "auto";
|
||||
} else {
|
||||
var home_loading_timespan = home_loading_timeout - (home_loading_end - home_loading_begin);
|
||||
setTimeout(function () {
|
||||
$(".home-loading").remove();
|
||||
document.body.style.overflow = "auto";
|
||||
}, home_loading_timespan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function encodeHtml(s) {
|
||||
return (typeof s != "string") ? s :
|
||||
s.replace(/"|&|'|<|>|[\x00-\x20]|[\x7F-\xFF]|[\u0100-\u2700]/g,
|
||||
function ($0) {
|
||||
var c = $0.charCodeAt(0), r = ["&#"];
|
||||
c = (c == 0x20) ? 0xA0 : c;
|
||||
r.push(c);
|
||||
r.push(";");
|
||||
return r.join("");
|
||||
});
|
||||
};
|
||||
|
||||
//Fixed Tool
|
||||
$(function () {
|
||||
$(window).scroll(function () {
|
||||
var scrollTop = $(window).scrollTop();
|
||||
if (scrollTop > 0) {
|
||||
$("#scrollTop").show();
|
||||
$(".qrcontain").css("top", "-57px");
|
||||
$(".qrcontain .arrow").css("top", "52%");
|
||||
} else {
|
||||
$("#scrollTop").hide();
|
||||
$(".qrcontain").css("top", "-107px");
|
||||
$(".qrcontain .arrow").css("top", "86%");
|
||||
}
|
||||
});
|
||||
|
||||
$("#qrBtn").on("click", function () {
|
||||
if ($("#ss_toggle").hasClass("close")) {
|
||||
$("#share-menu").css("transition", "none");
|
||||
$("#ss_toggle").click();
|
||||
}
|
||||
if ($(".qrcontain").is(":hidden")) {
|
||||
$(".qrcontain").removeClass("fadeOutLeft").addClass("fadeInLeft");
|
||||
$(".qrcontain").show();
|
||||
$("#qrBtn").addClass("opened");
|
||||
} else {
|
||||
$(".qrcontain").removeClass("fadeInLeft").addClass("fadeOutLeft");
|
||||
$(".qrcontain").one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function () {
|
||||
$(".qrcontain").hide();
|
||||
});
|
||||
$("#qrBtn").removeClass("opened");
|
||||
}
|
||||
$("#share-menu").css("transition", "all 1s ease 0s");
|
||||
});
|
||||
|
||||
$("#scrollTop a").on("click", function () {
|
||||
$("html,body").animate({scrollTop: 0}, 1000);
|
||||
});
|
||||
|
||||
var toggle = $('#ss_toggle');
|
||||
var menu = $('#share-menu');
|
||||
var rot;
|
||||
$('#ss_toggle').on('click', function (ev) {
|
||||
if (!$(".qrcontain").is(":hidden")) {
|
||||
$(".qrcontain").hide();
|
||||
$("#qrBtn").removeClass("opened");
|
||||
}
|
||||
rot = parseInt($(this).data('rot')) - 180;
|
||||
if (rot / 180 % 2 == 0) {
|
||||
menu.css('transform', 'rotate(' + rot + 'deg)');
|
||||
menu.css('webkitTransform', 'rotate(' + rot + 'deg)');
|
||||
toggle.parent().addClass('ss_active');
|
||||
toggle.addClass('close');
|
||||
} else {
|
||||
menu.css('transform', 'rotate(' + parseInt(rot - 30) + 'deg)');
|
||||
menu.css('webkitTransform', 'rotate(' + parseInt(rot - 30) + 'deg)');
|
||||
toggle.parent().removeClass('ss_active');
|
||||
toggle.removeClass('close');
|
||||
}
|
||||
$(this).data('rot', rot);
|
||||
});
|
||||
menu.on('transitionend webkitTransitionEnd oTransitionEnd', function () {
|
||||
if (rot / 180 % 2 == 0) {
|
||||
$("#share-menu i.fa").addClass('bounce');
|
||||
} else {
|
||||
$("#share-menu i.fa").removeClass('bounce');
|
||||
}
|
||||
});
|
||||
|
||||
var img = document.createElement("img");
|
||||
img.src = logoPath;
|
||||
img.onload = function () {
|
||||
$("#qrcode").qrcode({
|
||||
text: window.location.href,
|
||||
size: "100",
|
||||
ecLevel: 'H',
|
||||
minVersion: 4,
|
||||
mode: 4,
|
||||
image: img,
|
||||
mSize: 0.3
|
||||
});
|
||||
}
|
||||
});
|
||||
245
public/javascripts/categorymanage.js
Normal file
245
public/javascripts/categorymanage.js
Normal file
@@ -0,0 +1,245 @@
|
||||
$(function () {
|
||||
getData();
|
||||
|
||||
var adjustment;
|
||||
var group = $("#cate-list").sortable({
|
||||
group: 'cate-list',
|
||||
handle: 'i.fa-arrows',
|
||||
pullPlaceholder: false,
|
||||
onDrop: function ($item, container, _super) {
|
||||
var $clonedItem = $('<li/>').css({height: 0});
|
||||
$item.before($clonedItem);
|
||||
$clonedItem.animate({'height': $item.height()});
|
||||
|
||||
$item.animate($clonedItem.position(), function () {
|
||||
$clonedItem.detach();
|
||||
_super($item, container);
|
||||
});
|
||||
},
|
||||
onDragStart: function ($item, container, _super) {
|
||||
var offset = $item.offset(),
|
||||
pointer = container.rootGroup.pointer;
|
||||
|
||||
adjustment = {
|
||||
left: pointer.left - offset.left,
|
||||
top: pointer.top - offset.top
|
||||
};
|
||||
|
||||
_super($item, container);
|
||||
},
|
||||
onDrag: function ($item, position) {
|
||||
$item.css({
|
||||
left: position.left - adjustment.left,
|
||||
top: position.top - adjustment.top
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on({
|
||||
change: function () {
|
||||
var $input = $(this).parent().parent().next("input");
|
||||
if ($(this).prop("checked")) {
|
||||
$input.removeAttr("disabled");
|
||||
$(this).parents(".list-group-item").data("link", $input.val());
|
||||
} else {
|
||||
$input.attr("disabled", "disabled");
|
||||
$(this).parents(".list-group-item").data("link", "");
|
||||
}
|
||||
}
|
||||
}, "input:checkbox");
|
||||
|
||||
$(document).on({
|
||||
change: function (event) {
|
||||
var val = $(this).val();
|
||||
if ($(event.target).hasClass("txtName")) {
|
||||
$(this).parents(".list-group-item").data("catename", val);
|
||||
$(this).parents(".list-group-item").attr("data-catename", val);
|
||||
} else if ($(event.target).hasClass("txtAlias")) {
|
||||
$(this).parents(".list-group-item").data("alias", val);
|
||||
$(this).parents(".list-group-item").attr("data-alias", val);
|
||||
} else {
|
||||
$(this).parents(".list-group-item").data("link", val);
|
||||
$(this).parents(".list-group-item").attr("data-link", val);
|
||||
}
|
||||
}
|
||||
}, ".txtName, .txtAlias, .txtLink");
|
||||
|
||||
$(document).on({
|
||||
click: function () {
|
||||
$(this).parents(".list-group-item").slideUp("normal", function () {
|
||||
$(this).remove();
|
||||
});
|
||||
}
|
||||
}, ".btn-del-cate");
|
||||
|
||||
$(document).on({
|
||||
click: function () {
|
||||
var cate = $("<li class=\"list-group-item\" data-uniqueid=\"" + "" + "\" data-catename=\"" + "" + "\" data-alias=\"" + "" + "\" data-img=\"" + "" + "\" data-link=\"" + "" + "\">"
|
||||
+ "<div class=\"row\">"
|
||||
+ "<div class=\"col-md-2\">"
|
||||
+ "<i class=\"fa fa-arrows\"></i> "
|
||||
+ "<span class=\"fileinput-button\">"
|
||||
+ "<img src=\"" + "" + "\"/>"
|
||||
+ "<input type=\"file\" class=\"fileupload\" name=\"file\">"
|
||||
+ "</span>"
|
||||
+ "</div>"
|
||||
+ "<div class=\"col-md-2\">"
|
||||
+ "<input class=\"form-control txtName\" type=\"text\" value=\"" + "" + "\" placeholder=\"分类名称\"/>"
|
||||
+ "</div>"
|
||||
+ "<div class=\"col-md-2\">"
|
||||
+ "<input class=\"form-control txtAlias\" type=\"text\" value=\"" + "" + "\" placeholder=\"分类alias\"/>"
|
||||
+ "</div>"
|
||||
+ "<div class=\"col-md-5\">"
|
||||
+ "<div class=\"input-group cate-link\">"
|
||||
+ "<span class=\"input-group-addon\"><label>"
|
||||
+ "<input type=\"checkbox\"/> 链接"
|
||||
+ "</label></span>"
|
||||
+ "<input type=\"text\" class=\"form-control txtLink\" value=\"" + "" + "\" disabled=\"disabled\">"
|
||||
+ "</div>"
|
||||
+ "</div>"
|
||||
+ "<div class=\"col-md-1\">"
|
||||
+ "<button class=\"btn btn-link btn-del-cate\" title=\"移除分类\"><i class=\"fa fa-times\"></i></button>"
|
||||
+ "</div>"
|
||||
+ "</div>"
|
||||
+ "</li>");
|
||||
cate.appendTo($("#cate-list"));
|
||||
bindFileUpload();
|
||||
}
|
||||
}, "#btnNew");
|
||||
|
||||
$(document).on({
|
||||
click: function () {
|
||||
if (isValidData()) {
|
||||
var $this = $(this);
|
||||
$this.attr("disabled", "disabled");
|
||||
$this.find(".fa").removeClass("fa-cloud-upload").addClass("fa-circle-o-notch fa-spin");
|
||||
var gdata = group.sortable("serialize").get();
|
||||
var json = JSON.stringify(gdata);
|
||||
$.ajax({
|
||||
url: "/admin/saveCategories",
|
||||
type: "Post",
|
||||
data: {json: json},
|
||||
success: function () {
|
||||
swal({
|
||||
title: "保存成功!",
|
||||
type: "success",
|
||||
showConfirmButton: false,
|
||||
timer: 2000
|
||||
});
|
||||
},
|
||||
error: function () {
|
||||
swal({
|
||||
title: "操作失败!",
|
||||
type: "error",
|
||||
showConfirmButton: false,
|
||||
timer: 2000
|
||||
});
|
||||
},
|
||||
complete: function () {
|
||||
$this.removeAttr("disabled");
|
||||
$this.find(".fa").removeClass("fa-circle-o-notch fa-spin").addClass("fa-cloud-upload");
|
||||
getData();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}, "#btnSave");
|
||||
});
|
||||
|
||||
function getData() {
|
||||
$.ajax({
|
||||
url: "/admin/getCategories",
|
||||
type: "Post",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
$("#cate-list").empty();
|
||||
$.each(data, function (key, value) {
|
||||
var cate = $("<li class=\"list-group-item\" data-uniqueid=\"" + value._id + "\" data-catename=\"" + value.CateName + "\" data-alias=\"" + value.Alias + "\" data-img=\"" + value.Img + "\" data-link=\"" + value.Link + "\">"
|
||||
+ "<div class=\"row\">"
|
||||
+ "<div class=\"col-md-2\">"
|
||||
+ "<i class=\"fa fa-arrows\"></i> "
|
||||
+ "<span class=\"fileinput-button\">"
|
||||
+ "<img src=\"" + value.Img + "\"/>"
|
||||
+ "<input type=\"file\" class=\"fileupload\" name=\"file\">"
|
||||
+ "</span>"
|
||||
+ "</div>"
|
||||
+ "<div class=\"col-md-2\">"
|
||||
+ "<input class=\"form-control txtName\" type=\"text\" value=\"" + value.CateName + "\" placeholder=\"分类名称\"/>"
|
||||
+ "</div>"
|
||||
+ "<div class=\"col-md-2\">"
|
||||
+ "<input class=\"form-control txtAlias\" type=\"text\" value=\"" + value.Alias + "\" placeholder=\"分类alias\"/>"
|
||||
+ "</div>"
|
||||
+ "<div class=\"col-md-5\">"
|
||||
+ "<div class=\"input-group cate-link\">"
|
||||
+ "<span class=\"input-group-addon\"><label>"
|
||||
+ "<input type=\"checkbox\" " + (value.Link != "" ? "checked=\"checked\"" : "") + "/> 链接"
|
||||
+ "</label></span>"
|
||||
+ "<input type=\"text\" class=\"form-control txtLink\" value=\"" + value.Link + "\" " + (value.Link == "" ? "disabled=\"disabled\"" : "") + ">"
|
||||
+ "</div>"
|
||||
+ "</div>"
|
||||
+ "<div class=\"col-md-1\">"
|
||||
+ "<button class=\"btn btn-link btn-del-cate\" title=\"移除分类\"><i class=\"fa fa-times\"></i></button>"
|
||||
+ "</div>"
|
||||
+ "</div>"
|
||||
+ "</li>");
|
||||
cate.appendTo($("#cate-list"));
|
||||
});
|
||||
},
|
||||
complete: function () {
|
||||
bindFileUpload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function bindFileUpload() {
|
||||
$(".fileupload").fileupload({
|
||||
url: "/admin/uploadimg",
|
||||
dataType: "text",
|
||||
done: function (e, data) {
|
||||
$(this).prev().attr("src", '/images/' + data.files[0].name);
|
||||
$(this).parent().parent().parent().parent().data("img", '/images/' + data.files[0].name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function isValidData() {
|
||||
var result = true;
|
||||
var items = $("#cate-list li");
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var cateName = $(items[i]).data("catename");
|
||||
var cateAlias = $(items[i]).data("alias");
|
||||
if (cateName === "" || cateAlias === "") {
|
||||
swal({
|
||||
title: "分类名称、分类alias都不能为空!",
|
||||
type: "warning",
|
||||
showConfirmButton: false,
|
||||
timer: 2000
|
||||
});
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if ($("#cate-list li[data-catename='" + cateName + "']").length > 1) {
|
||||
swal({
|
||||
title: "分类名称 \"" + cateName + "\" 不唯一!",
|
||||
type: "warning",
|
||||
showConfirmButton: false,
|
||||
timer: 2000
|
||||
});
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if ($("#cate-list li[data-alias='" + cateAlias + "']").length > 1) {
|
||||
swal({
|
||||
title: "分类alias \"" + cateAlias + "\" 不唯一!",
|
||||
type: "warning",
|
||||
showConfirmButton: false,
|
||||
timer: 2000
|
||||
});
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
26
public/javascripts/dateFormat.js
Normal file
26
public/javascripts/dateFormat.js
Normal file
@@ -0,0 +1,26 @@
|
||||
Date.prototype.dateFormat = function (fmt) {
|
||||
return getDateStr(this, fmt);
|
||||
};
|
||||
|
||||
String.prototype.jsonDateFormat = function (fmt) {
|
||||
var date = new Date(parseInt(this.replace("/Date(", "").replace(")/", ""), 10));
|
||||
return getDateStr(date, fmt);
|
||||
};
|
||||
|
||||
function getDateStr(date, fmt) {
|
||||
var o = {
|
||||
"M+": date.getMonth() + 1, //月份
|
||||
"d+": date.getDate(), //日
|
||||
"H+": date.getHours(), //小时
|
||||
"m+": date.getMinutes(), //分
|
||||
"s+": date.getSeconds(), //秒
|
||||
"q+": Math.floor((date.getMonth() + 3) / 3), //季度
|
||||
"S": date.getMilliseconds() //毫秒
|
||||
};
|
||||
if (/(y+)/.test(fmt))
|
||||
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
|
||||
for (var k in o)
|
||||
if (new RegExp("(" + k + ")").test(fmt))
|
||||
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
|
||||
return fmt;
|
||||
}
|
||||
248
public/javascripts/editarticle.js
Normal file
248
public/javascripts/editarticle.js
Normal file
@@ -0,0 +1,248 @@
|
||||
$(function () {
|
||||
$("#side-menu>li:eq(2)").addClass("active").find("ul").addClass("in").find("li:eq(2)").addClass("active");
|
||||
|
||||
refreshCate();
|
||||
|
||||
if (source == "1") {
|
||||
$("#soruceLink").radio("check")
|
||||
} else {
|
||||
$("#soruceLocal").radio("check")
|
||||
}
|
||||
$("#myPillbox").pillbox("addItems", 0, JSON.parse($('#Labels').val()));
|
||||
|
||||
var editor = UE.getEditor("editor", {
|
||||
allowDivTransToP: false,
|
||||
initialFrameHeight: 300,
|
||||
textarea: "Content"
|
||||
});
|
||||
|
||||
editor.ready(function () {
|
||||
$("[data-toggle=tooltip]").tooltip({
|
||||
container: "body"
|
||||
});
|
||||
});
|
||||
|
||||
$(".btn-alias").on("click", function () {
|
||||
var appid,
|
||||
key,
|
||||
salt,
|
||||
query = $("#Title").val(),
|
||||
from,
|
||||
to,
|
||||
str1,
|
||||
sign;
|
||||
if (query) {
|
||||
var that = this;
|
||||
$(that).addClass("disabled");
|
||||
appid = '20151219000008011';
|
||||
key = translateKey;
|
||||
salt = (new Date).getTime();
|
||||
from = 'zh';
|
||||
to = 'en';
|
||||
str1 = appid + query + salt + key;
|
||||
sign = md5(str1);
|
||||
$.ajax({
|
||||
url: 'http://api.fanyi.baidu.com/api/trans/vip/translate',
|
||||
type: 'get',
|
||||
dataType: 'jsonp',
|
||||
data: {
|
||||
q: query,
|
||||
appid: appid,
|
||||
salt: salt,
|
||||
from: from,
|
||||
to: to,
|
||||
sign: sign
|
||||
},
|
||||
success: function (data) {
|
||||
var en = data.trans_result[0].dst;
|
||||
var result = en.trim().toLowerCase().split(' ').join('-');
|
||||
$("#Alias").val(result).focus();
|
||||
$('#postForm').formValidation('revalidateField', 'Alias');
|
||||
},
|
||||
complete: function () {
|
||||
$(that).removeClass("disabled");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("#postForm").on('init.field.fv', function (e, data) {
|
||||
var $parent = data.element.parents('.form-group'),
|
||||
$icon = $parent.find('.form-control-feedback[data-fv-icon-for="' + data.field + '"]');
|
||||
$icon.on('click.clearing', function () {
|
||||
if ($icon.hasClass('fa-remove')) {
|
||||
data.fv.resetField(data.element);
|
||||
}
|
||||
});
|
||||
}).formValidation({
|
||||
framework: 'bootstrap',
|
||||
icon: {
|
||||
valid: 'fa fa-check',
|
||||
invalid: 'fa fa-remove',
|
||||
validating: 'fa fa-refresh'
|
||||
},
|
||||
err: {
|
||||
container: 'tooltip'
|
||||
},
|
||||
fields: {
|
||||
Title: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: '标题不能为空'
|
||||
}
|
||||
}
|
||||
},
|
||||
Alias: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: 'Alias不能为空'
|
||||
},
|
||||
remote: {
|
||||
url: '/admin/checkArticleAlias',
|
||||
type: 'POST',
|
||||
data: '{"uid":"' + $('#UniqueId').val() + '"}',
|
||||
delay: 1000,
|
||||
message: 'Alias不唯一'
|
||||
}
|
||||
}
|
||||
},
|
||||
Summary: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: '摘要不能为空'
|
||||
}
|
||||
}
|
||||
},
|
||||
Url: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: 'Url不能为空'
|
||||
},
|
||||
uri: {
|
||||
message: 'Url地址不正确'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.on('err.field.fv', function (e, data) {
|
||||
data.fv.disableSubmitButtons(false);
|
||||
})
|
||||
.on('success.field.fv', function (e, data) {
|
||||
data.fv.disableSubmitButtons(false);
|
||||
})
|
||||
.on('success.form.fv', function (e) {
|
||||
var isPublish = $('#btnPublish').length > 0;
|
||||
e.preventDefault();
|
||||
$("#Labels").val(JSON.stringify($("#myPillbox").pillbox("items")));
|
||||
$('#IsDraft').val('False');
|
||||
swal({
|
||||
title: isPublish ? '确定要发布该文章吗?' : '确定提交更新吗?',
|
||||
text: $("#CategoryId").val() === "other" ? "<span style='color:#d9534f;'>注意:当前选择的文章分类为\"未分类\"</span>" : null,
|
||||
html: true,
|
||||
type: "warning",
|
||||
allowOutsideClick: true,
|
||||
showCancelButton: true,
|
||||
cancelButtonText: "取消",
|
||||
confirmButtonColor: "#d9534f",
|
||||
confirmButtonText: isPublish ? '确定发布' : '确定提交',
|
||||
closeOnConfirm: false
|
||||
},
|
||||
function () {
|
||||
$(".sweet-alert .confirm").text(isPublish ? '发布中...' : '提交中...');
|
||||
$(".sweet-alert .confirm").attr("disabled", "disabled");
|
||||
$.ajax({
|
||||
url: $("#postForm")[0].action,
|
||||
type: $("#postForm")[0].method,
|
||||
data: $("#postForm").serialize(),
|
||||
success: function () {
|
||||
if (isPublish) {
|
||||
swal({
|
||||
title: '发布成功!',
|
||||
type: "success",
|
||||
showConfirmButton: false,
|
||||
timer: 2000
|
||||
}, function () {
|
||||
window.location.href = "/admin/articlemanage";
|
||||
});
|
||||
} else {
|
||||
swal({
|
||||
title: '更新成功!',
|
||||
type: "success",
|
||||
showConfirmButton: false,
|
||||
timer: 2000
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
swal({
|
||||
title: isPublish ? '发布失败!' : '更新失败!',
|
||||
type: "error",
|
||||
showConfirmButton: false,
|
||||
timer: 2000
|
||||
});
|
||||
},
|
||||
complete: function () {
|
||||
$(".sweet-alert .confirm").removeAttr("disabled");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$('#btnSave').on('click', function () {
|
||||
var $this = $(this);
|
||||
$("#Labels").val(JSON.stringify($("#myPillbox").pillbox("items")));
|
||||
$('#IsDraft').val('True');
|
||||
$this.attr('disabled', 'disabled');
|
||||
$.ajax({
|
||||
url: $("#postForm")[0].action,
|
||||
type: $("#postForm")[0].method,
|
||||
data: $("#postForm").serialize(),
|
||||
success: function () {
|
||||
swal({
|
||||
title: '草稿保存成功!',
|
||||
type: 'success',
|
||||
showConfirmButton: false,
|
||||
timer: 2000
|
||||
});
|
||||
},
|
||||
error: function () {
|
||||
swal({
|
||||
title: "草稿保存失败!",
|
||||
type: "error",
|
||||
showConfirmButton: false,
|
||||
timer: 2000
|
||||
});
|
||||
},
|
||||
complete: function () {
|
||||
$this.removeAttr("disabled");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(".selectlist").on("changed.fu.selectlist", function (e, data) {
|
||||
$(this).find("li").removeClass("active");
|
||||
$(this).find("li[data-value=" + data.value + "]").addClass("active");
|
||||
});
|
||||
});
|
||||
|
||||
function refreshCate() {
|
||||
$.ajax({
|
||||
url: "/admin/getCategories",
|
||||
type: "Post",
|
||||
success: function (data) {
|
||||
$("#Categorylist ul").html("");
|
||||
$.each(data, function (key, value) {
|
||||
if (!value.Link) {
|
||||
$("#Categorylist ul").append("<li data-value=\"" + value._id + "\">"
|
||||
+ "<a href=\"#\">" + value.CateName + "</a>"
|
||||
+ "</li>");
|
||||
}
|
||||
});
|
||||
$("#Categorylist ul").append("<li data-value=\"other\"><a href=\"#\">未分类</a></li>");
|
||||
$("#Categorylist").selectlist("enable");
|
||||
$("#Categorylist").selectlist("selectByValue", categoryId);
|
||||
$("#Categorylist li[data-value=" + categoryId + "]").addClass("active");
|
||||
}
|
||||
});
|
||||
}
|
||||
67
public/javascripts/exception.js
Normal file
67
public/javascripts/exception.js
Normal file
@@ -0,0 +1,67 @@
|
||||
var $table = $("#exceptions");
|
||||
|
||||
$(function () {
|
||||
$("#side-menu>li:eq(7)").addClass("active");
|
||||
|
||||
$table.bootstrapTable({
|
||||
url: "/admin/getExceptions",
|
||||
method: "post",
|
||||
pagination: true,
|
||||
paginationFirstText: "<i class=\"fa fa-angle-double-left\"></i>",
|
||||
paginationPreText: "<i class=\"fa fa-angle-left\"></i>",
|
||||
paginationNextText: "<i class=\"fa fa-angle-right\"></i>",
|
||||
paginationLastText: "<i class=\"fa fa-angle-double-right\"></i>",
|
||||
queryParamsType: "pageIndex",
|
||||
sidePagination: "server",
|
||||
pageList: [10, 25, 50, 100, "All"],
|
||||
sortName: "timestamp",
|
||||
sortOrder: "desc",
|
||||
showRefresh: true,
|
||||
showColumns: true,
|
||||
iconsPrefix: "fa",
|
||||
icons: {
|
||||
refresh: "fa-refresh",
|
||||
columns: "fa-th-list",
|
||||
detailOpen: "fa-plus",
|
||||
detailClose: "fa-minus"
|
||||
},
|
||||
idField: "_id",
|
||||
detailView: true,
|
||||
detailFormatter: function (index, row) {
|
||||
return '<div style="white-space:pre-wrap;">' + JSON.stringify(row.meta, null, 2) + '</div>';
|
||||
},
|
||||
columns: [{
|
||||
field: "meta.os.hostname",
|
||||
title: "主机名",
|
||||
align: "center",
|
||||
valign: "middle",
|
||||
width: "120px",
|
||||
}, {
|
||||
field: "meta.code",
|
||||
title: "Code",
|
||||
align: "center",
|
||||
valign: "middle",
|
||||
width: "80px",
|
||||
}, {
|
||||
field: "message",
|
||||
title: "异常信息",
|
||||
halign: "center",
|
||||
valign: "middle"
|
||||
}, {
|
||||
field: "time",
|
||||
title: "记录时间",
|
||||
align: "center",
|
||||
valign: "middle",
|
||||
width: "200px",
|
||||
sortable: true
|
||||
}, {
|
||||
field: "level",
|
||||
title: "等级",
|
||||
align: "center",
|
||||
valign: "middle",
|
||||
width: "120px",
|
||||
sortable: true
|
||||
}]
|
||||
})
|
||||
;
|
||||
});
|
||||
3
public/javascripts/guestbook.js
Normal file
3
public/javascripts/guestbook.js
Normal file
@@ -0,0 +1,3 @@
|
||||
$(function () {
|
||||
$(".my-nav-pills li:contains('留言')").addClass("active").siblings().removeClass("active");
|
||||
});
|
||||
2
public/javascripts/highlight.pack.js
Normal file
2
public/javascripts/highlight.pack.js
Normal file
File diff suppressed because one or more lines are too long
309
public/javascripts/index.js
Normal file
309
public/javascripts/index.js
Normal file
@@ -0,0 +1,309 @@
|
||||
var home_loading_timeout = 2000;
|
||||
var isLoading = false;
|
||||
var timeout = 1000;
|
||||
var contentTimeout = 1500;
|
||||
var begin = new Date();
|
||||
var contentBegin = new Date();
|
||||
var pageCount;
|
||||
var tooltip_timeout = 1500;
|
||||
$(function () {
|
||||
$(".my-nav-pills li:eq(0)").addClass("active").siblings().removeClass("active");
|
||||
$("#load-list").show();
|
||||
$("#PageIndex").val(1);
|
||||
requestData();
|
||||
|
||||
$(".category-list").mCustomScrollbar({
|
||||
axis: "y",
|
||||
theme: "dark-3"
|
||||
});
|
||||
|
||||
$(window).scroll(function () {
|
||||
$("[data-toggle='tooltip']").tooltip("hide");
|
||||
});
|
||||
|
||||
$("[data-toggle='tooltip']").tooltip({
|
||||
container: "body"
|
||||
});
|
||||
|
||||
$(document).on({
|
||||
click: function () {
|
||||
$(this).remove();
|
||||
begin = new Date();
|
||||
$("#load-list").show();
|
||||
isLoading = true;
|
||||
$("#PageIndex").val(parseInt($("#PageIndex").val()) + 1);
|
||||
requestData();
|
||||
}
|
||||
}, "#btn-load");
|
||||
|
||||
$(document).on({
|
||||
click: function () {
|
||||
var index = $(this).attr("page");
|
||||
var pageItem = $("#page" + index);
|
||||
$("html,body").animate({scrollTop: $(pageItem).offset().top - 90}, 1000);
|
||||
}
|
||||
}, "#page-nav a");
|
||||
|
||||
$(document).on({
|
||||
click: function () {
|
||||
var $this = $(this);
|
||||
$(".bd_weixin_popup").hide();
|
||||
$(".bd_weixin_popup_bg").hide();
|
||||
$(".post-cover").fadeIn();
|
||||
$("body").addClass("modal-open");
|
||||
$(".post-modal").css("right", 0);
|
||||
var alias = $(this).parent().attr("uid");
|
||||
if ($('body').data('preview') === alias) {
|
||||
return;
|
||||
}
|
||||
resetModal();
|
||||
var title = $(this).siblings("h4").children("a").html();
|
||||
$(".post-modal .modal-header h4").html(title);
|
||||
$("#btnFullMode").attr("href", $(this).next('h4').children('a').attr('href'));
|
||||
$(".post-content div").hide();
|
||||
var previewData = $this.data('preview-data');
|
||||
if (previewData) {
|
||||
appendContent(previewData);
|
||||
return;
|
||||
}
|
||||
$(".sk-cube-grid").show();
|
||||
contentBegin = new Date();
|
||||
$.ajax({
|
||||
url: "/blog/getPreviewContent",
|
||||
type: "Post",
|
||||
data: {alias: alias},
|
||||
success: function (data) {
|
||||
var end = new Date();
|
||||
$this.data('preview-data', data);
|
||||
if (end - contentBegin > contentTimeout) {
|
||||
appendContent(data);
|
||||
} else {
|
||||
var timespan = contentTimeout - (end - contentBegin);
|
||||
setTimeout(function () {
|
||||
appendContent(data);
|
||||
}, timespan);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, ".preview-link");
|
||||
|
||||
$(".post-modal .modal-body").mCustomScrollbar({
|
||||
theme: "dark-3",
|
||||
scrollButtons: {
|
||||
enable: true
|
||||
}
|
||||
});
|
||||
|
||||
$(".post-cover").on("click", function () {
|
||||
closeModal();
|
||||
});
|
||||
|
||||
$("#btnCloseModal").on("click", function () {
|
||||
closeModal();
|
||||
});
|
||||
|
||||
$("#btnFullMode").on("click", function () {
|
||||
setTimeout(closeModal, 800);
|
||||
});
|
||||
|
||||
$(".list-top-left a").on("click", function () {
|
||||
if (!$(this).hasClass("current")) {
|
||||
$(this).addClass("current").siblings().removeClass("current");
|
||||
$(".list-wrap ol").html("");
|
||||
$("[data-toggle='tooltip']").tooltip("hide");
|
||||
$("#page-nav").html("");
|
||||
$("#btn-load").remove();
|
||||
$("#no-more").remove();
|
||||
begin = new Date();
|
||||
$("#load-list").show();
|
||||
$("#SortBy").val($(this).attr("sort"));
|
||||
$("#PageIndex").val(1);
|
||||
requestData();
|
||||
}
|
||||
});
|
||||
|
||||
$("#Keyword").on("keypress", function (e) {
|
||||
if (e.which == 13 || e.which == 10) {
|
||||
searchPost();
|
||||
}
|
||||
});
|
||||
|
||||
$("#btnFilter").on("click", function () {
|
||||
searchPost();
|
||||
});
|
||||
|
||||
$(".selectlist").on("changed.fu.selectlist", function (e, data) {
|
||||
$(this).find("li").removeClass("active");
|
||||
$(this).find("li[data-value=" + data.value + "]").addClass("active");
|
||||
});
|
||||
});
|
||||
|
||||
function requestData() {
|
||||
$.ajax({
|
||||
url: $('#filterForm')[0].action,
|
||||
type: $('#filterForm')[0].method,
|
||||
data: $('#filterForm').serialize(),
|
||||
success: function (result) {
|
||||
var end = new Date();
|
||||
var data = result.posts;
|
||||
pageCount = result.pageCount;
|
||||
if (end - begin > timeout) {
|
||||
addPage($("#PageIndex").val(), data);
|
||||
} else {
|
||||
var timespan = timeout - (end - begin);
|
||||
setTimeout(function () {
|
||||
addPage($("#PageIndex").val(), data);
|
||||
}, timespan);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function appendContent(data) {
|
||||
$(".sk-cube-grid").hide();
|
||||
$(".post-content div").html(data.Content);
|
||||
|
||||
var labels = JSON.parse(data.Labels);
|
||||
$.each(labels, function (key, value) {
|
||||
$("#label-foot").append("<span title=\"" + value.text + "\" class=\"post-label\">" + value.text + "</span>");
|
||||
});
|
||||
$(".post-modal .modal-body").mCustomScrollbar("scrollTo", "top", {
|
||||
scrollInertia: 0
|
||||
});
|
||||
$(".post-content div").fadeIn();
|
||||
var pres = $('.post-content pre');
|
||||
pres.each(function (i, pre) {
|
||||
$(pre).html($('<code></code>').html($(pre).html()));
|
||||
hljs.highlightBlock($(pre).children('code')[0]);
|
||||
});
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
$(".post-modal").css("right", "-1200px");
|
||||
$(".post-cover").fadeOut();
|
||||
$("body").removeClass("modal-open");
|
||||
}
|
||||
|
||||
function resetModal() {
|
||||
$(".post-modal .modal-header h4").empty();
|
||||
$(".post-content div").empty();
|
||||
$("#label-foot").empty();
|
||||
}
|
||||
|
||||
function searchPost() {
|
||||
$(".list-wrap ol").html("");
|
||||
$("[data-toggle='tooltip']").tooltip("hide");
|
||||
$("#page-nav").html("");
|
||||
$("#btn-load").remove();
|
||||
$("#no-more").remove();
|
||||
begin = new Date();
|
||||
$("#load-list").show();
|
||||
$("#PageIndex").val(1);
|
||||
requestData();
|
||||
}
|
||||
|
||||
function addPage(index, data) {
|
||||
$("#load-list").hide();
|
||||
if (data.length > 0) {
|
||||
$(".list-wrap ol").append("<li id=\"page" + index + "\"></li>");
|
||||
$.each(data, function (key, value) {
|
||||
var itemHtml;
|
||||
if (value.Source == "1") {
|
||||
itemHtml = "<div uid=\""
|
||||
+ value.Alias
|
||||
+ "\" class=\"blog-item " + ($(".home-loading").length > 0 ? "" : "animated fadeIn") + "\">"
|
||||
+ " <h4>"
|
||||
+ " <a title=\""
|
||||
+ value.Title
|
||||
+ "\" target=\"_blank\" href=\""
|
||||
+ value.Url
|
||||
+ "\">"
|
||||
+ "<i class=\"fa fa-link\"></i> " + value.Title
|
||||
+ " <\/a>"
|
||||
+ " <\/h4>"
|
||||
+ " <span title=\"文章分类\">"
|
||||
+ " <i class=\"fa fa-map-signs\">"
|
||||
+ " <\/i>"
|
||||
+ " "
|
||||
+ "<a href=\"/blog/" + value.CategoryAlias + "\" target=\"_blank\">" + value.CateName + "</a>"
|
||||
+ " <\/span>"
|
||||
+ " <span title=\"发布时间\" class=\"margin-left-20\">"
|
||||
+ " <i class=\"fa fa-clock-o\">"
|
||||
+ " <\/i>"
|
||||
+ " "
|
||||
+ value.PublishDate
|
||||
+ " <\/span>"
|
||||
+ " <a title=\""
|
||||
+ value.Host
|
||||
+ "\" target=\"_blank\" href=\""
|
||||
+ value.Url.substring(0, value.Url.indexOf("://") + 3) + value.Host
|
||||
+ "\" class=\"pull-right margin-left-20 hidden-xs\">"
|
||||
+ " "
|
||||
+ "<i class=\"fa fa-globe\"></i> " + value.Host
|
||||
+ " <\/a>"
|
||||
+ " <div class=\"clearfix\">"
|
||||
+ " <\/div>"
|
||||
+ " <p>"
|
||||
+ " "
|
||||
+ encodeHtml(value.Summary)
|
||||
+ " <\/p>"
|
||||
+ "<\/div>"
|
||||
+ "<div class=\"hr-line-dashed\"></div>";
|
||||
} else {
|
||||
itemHtml = "<div class=\"blog-item " + ($(".home-loading").length > 0 ? "" : "animated fadeIn") + "\" uid=\"" + value.Alias + "\"><a class=\"preview-link\" title=\"点击预览\"></a><h4><a href=\"/blog/"
|
||||
+ value.CategoryAlias + "/" + value.Alias + "\" target=\"_blank\" title=\"" + value.Title + "\">" + value.Title + "</a></h4><span title=\"文章分类\"><i class=\"fa fa-map-signs\"></i> " + "<a href=\"/blog/" + value.CategoryAlias + "\" target=\"_blank\">" + value.CateName + "</a>" + "</span> <span class=\"margin-left-20\" title=\"发布时间\"><i class=\"fa fa-clock-o\"></i> " + value.PublishDate + "</span><div class=\"clearfix\"></div><p>" + encodeHtml(value.Summary) + "</p></div><div class=\"hr-line-dashed\"></div>";
|
||||
}
|
||||
$("#page" + index).append(itemHtml);
|
||||
});
|
||||
$("body").append("<script id=\"cy_cmt_num\" src=\"http://changyan.sohu.com/upload/plugins/plugins.list.count.js?clientId=cyrUoGjWj\"><\/script>");
|
||||
var item = $("<li><a href=\"javascript:void(0)\" page=\"" + index + "\" data-toggle=\"tooltip\" data-placement=\"right\" title=\"第" + index + "页\"></a></li>");
|
||||
item.appendTo($("#page-nav"));
|
||||
var percent = 100 / index;
|
||||
$("#page-nav li").css("height", percent + "%");
|
||||
$("[data-toggle='tooltip']:visible").tooltip({
|
||||
container: "body"
|
||||
});
|
||||
item.find("a").tooltip("show");
|
||||
setTimeout(function () {
|
||||
item.find("a").tooltip("hide");
|
||||
}, tooltip_timeout);
|
||||
if ($("#PageIndex").val() == pageCount) {
|
||||
if (pageCount != 1) {
|
||||
$(".list-wrap").append("<div id=\"no-more\" class=\"text-muted text-center\">没有更多数据<\/div>");
|
||||
}
|
||||
} else {
|
||||
$(".list-wrap").append("<button id=\"btn-load\" class=\"btn btn-white btn-block\">下一页</button>");
|
||||
}
|
||||
} else {
|
||||
$(".list-wrap ol").append("<li id=\"page" + index + "\"></li>");
|
||||
$("#page" + index).append("<div class=\"text-center text-muted\">暂无数据</div>");
|
||||
}
|
||||
isLoading = false;
|
||||
if ($(".home-loading").length > 0) {
|
||||
var home_loading_end = new Date();
|
||||
$("[data-toggle='tooltip']").tooltip("hide");
|
||||
if (home_loading_end - home_loading_begin > home_loading_timeout) {
|
||||
$(".home-loading").remove();
|
||||
document.body.style.overflow = "auto";
|
||||
} else {
|
||||
var home_loading_timespan = home_loading_timeout - (home_loading_end - home_loading_begin);
|
||||
setTimeout(function () {
|
||||
$(".home-loading").remove();
|
||||
document.body.style.overflow = "auto";
|
||||
}, home_loading_timespan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function encodeHtml(s) {
|
||||
return (typeof s != "string") ? s :
|
||||
s.replace(/"|&|'|<|>|[\x00-\x20]|[\x7F-\xFF]|[\u0100-\u2700]/g,
|
||||
function ($0) {
|
||||
var c = $0.charCodeAt(0), r = ["&#"];
|
||||
c = (c == 0x20) ? 0xA0 : c;
|
||||
r.push(c);
|
||||
r.push(";");
|
||||
return r.join("");
|
||||
});
|
||||
};
|
||||
237
public/javascripts/newarticle.js
Normal file
237
public/javascripts/newarticle.js
Normal file
@@ -0,0 +1,237 @@
|
||||
$(function () {
|
||||
$("#side-menu>li:eq(2)").addClass("active").find("ul").addClass("in").find("li:eq(0)").addClass("active");
|
||||
|
||||
$("#Title").focus();
|
||||
|
||||
refreshCate();
|
||||
|
||||
var editor = UE.getEditor("editor", {
|
||||
allowDivTransToP: false,
|
||||
initialFrameHeight: 300,
|
||||
initialContent: "请输入文章正文",
|
||||
autoClearinitialContent: true,
|
||||
textarea: "Content"
|
||||
});
|
||||
|
||||
editor.ready(function () {
|
||||
$("[data-toggle=tooltip]").tooltip({
|
||||
container: "body"
|
||||
});
|
||||
});
|
||||
|
||||
$(".btn-alias").on("click", function () {
|
||||
var appid,
|
||||
key,
|
||||
salt,
|
||||
query = $("#Title").val(),
|
||||
from,
|
||||
to,
|
||||
str1,
|
||||
sign;
|
||||
if (query) {
|
||||
var that = this;
|
||||
$(that).addClass("disabled");
|
||||
appid = '20151219000008011';
|
||||
key = translateKey;
|
||||
salt = (new Date).getTime();
|
||||
from = 'zh';
|
||||
to = 'en';
|
||||
str1 = appid + query + salt + key;
|
||||
sign = md5(str1);
|
||||
$.ajax({
|
||||
url: 'http://api.fanyi.baidu.com/api/trans/vip/translate',
|
||||
type: 'get',
|
||||
dataType: 'jsonp',
|
||||
data: {
|
||||
q: query,
|
||||
appid: appid,
|
||||
salt: salt,
|
||||
from: from,
|
||||
to: to,
|
||||
sign: sign
|
||||
},
|
||||
success: function (data) {
|
||||
var en = data.trans_result[0].dst;
|
||||
var result = en.trim().toLowerCase().split(' ').join('-');
|
||||
$("#Alias").val(result).focus();
|
||||
$('#postForm').formValidation('revalidateField', 'Alias');
|
||||
},
|
||||
complete: function () {
|
||||
$(that).removeClass("disabled");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("#postForm").on('init.field.fv', function (e, data) {
|
||||
var $parent = data.element.parents('.form-group'),
|
||||
$icon = $parent.find('.form-control-feedback[data-fv-icon-for="' + data.field + '"]');
|
||||
$icon.on('click.clearing', function () {
|
||||
if ($icon.hasClass('fa-remove')) {
|
||||
data.fv.resetField(data.element);
|
||||
}
|
||||
});
|
||||
}).formValidation({
|
||||
framework: 'bootstrap',
|
||||
icon: {
|
||||
valid: 'fa fa-check',
|
||||
invalid: 'fa fa-remove',
|
||||
validating: 'fa fa-refresh'
|
||||
},
|
||||
err: {
|
||||
container: 'tooltip'
|
||||
},
|
||||
fields: {
|
||||
Title: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: '标题不能为空'
|
||||
}
|
||||
}
|
||||
},
|
||||
Alias: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: 'Alias不能为空'
|
||||
},
|
||||
remote: {
|
||||
url: '/admin/checkArticleAlias',
|
||||
type: 'POST',
|
||||
data: '{"uid":"' + $('#UniqueId').val() + '"}',
|
||||
delay: 1000,
|
||||
message: 'Alias不唯一'
|
||||
}
|
||||
}
|
||||
},
|
||||
Summary: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: '摘要不能为空'
|
||||
}
|
||||
}
|
||||
},
|
||||
Url: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: 'Url不能为空'
|
||||
},
|
||||
uri: {
|
||||
message: 'Url地址不正确'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.on('err.field.fv', function (e, data) {
|
||||
data.fv.disableSubmitButtons(false);
|
||||
})
|
||||
.on('success.field.fv', function (e, data) {
|
||||
data.fv.disableSubmitButtons(false);
|
||||
})
|
||||
.on('success.form.fv', function (e) {
|
||||
e.preventDefault();
|
||||
$("#Labels").val(JSON.stringify($("#myPillbox").pillbox("items")));
|
||||
$('#IsDraft').val('False');
|
||||
swal({
|
||||
title: "确定要发布该文章吗?",
|
||||
text: $("#CategoryId").val() === "other" ? "<span style='color:#d9534f;'>注意:当前选择的文章分类为\"未分类\"</span>" : null,
|
||||
html: true,
|
||||
type: "warning",
|
||||
allowOutsideClick: true,
|
||||
showCancelButton: true,
|
||||
cancelButtonText: "取消",
|
||||
confirmButtonColor: "#d9534f",
|
||||
confirmButtonText: "确定发布",
|
||||
closeOnConfirm: false
|
||||
},
|
||||
function () {
|
||||
$(".sweet-alert .confirm").text("发布中...");
|
||||
$(".sweet-alert .confirm").attr("disabled", "disabled");
|
||||
$.ajax({
|
||||
url: $("#postForm")[0].action,
|
||||
type: $("#postForm")[0].method,
|
||||
data: $("#postForm").serialize(),
|
||||
success: function () {
|
||||
swal({
|
||||
title: "发布成功!",
|
||||
type: "success",
|
||||
showConfirmButton: false,
|
||||
timer: 2000
|
||||
}, function () {
|
||||
window.location.href = "/admin/articlemanage";
|
||||
});
|
||||
},
|
||||
error: function () {
|
||||
swal({
|
||||
title: "发布失败!",
|
||||
type: "error",
|
||||
showConfirmButton: false,
|
||||
timer: 2000
|
||||
});
|
||||
},
|
||||
complete: function () {
|
||||
$(".sweet-alert .confirm").removeAttr("disabled");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$('#btnSave').on('click', function () {
|
||||
var $this = $(this);
|
||||
$("#Labels").val(JSON.stringify($("#myPillbox").pillbox("items")));
|
||||
$('#IsDraft').val('True');
|
||||
$this.attr('disabled', 'disabled');
|
||||
$.ajax({
|
||||
url: $("#postForm")[0].action,
|
||||
type: $("#postForm")[0].method,
|
||||
data: $("#postForm").serialize(),
|
||||
success: function () {
|
||||
swal({
|
||||
title: '草稿保存成功!',
|
||||
type: 'success',
|
||||
showConfirmButton: false,
|
||||
timer: 2000
|
||||
}, function () {
|
||||
window.location.href = '/admin/editarticle/' + $('#UniqueId').val();
|
||||
});
|
||||
},
|
||||
error: function () {
|
||||
swal({
|
||||
title: "草稿保存失败!",
|
||||
type: "error",
|
||||
showConfirmButton: false,
|
||||
timer: 2000
|
||||
});
|
||||
},
|
||||
complete: function () {
|
||||
$this.removeAttr("disabled");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(".selectlist").on("changed.fu.selectlist", function (e, data) {
|
||||
$(this).find("li").removeClass("active");
|
||||
$(this).find("li[data-value=" + data.value + "]").addClass("active");
|
||||
});
|
||||
});
|
||||
|
||||
function refreshCate() {
|
||||
$.ajax({
|
||||
url: "/admin/getCategories",
|
||||
type: "Post",
|
||||
success: function (data) {
|
||||
$("#Categorylist ul").html("");
|
||||
$.each(data, function (key, value) {
|
||||
if (!value.Link) {
|
||||
$("#Categorylist ul").append("<li data-value=\"" + value._id + "\">"
|
||||
+ "<a href=\"#\">" + value.CateName + "</a>"
|
||||
+ "</li>");
|
||||
}
|
||||
});
|
||||
$("#Categorylist ul").append("<li data-value=\"other\"><a href=\"#\">未分类</a></li>");
|
||||
$("#Categorylist").selectlist("enable");
|
||||
$("#Categorylist").selectlist("selectByValue", "other");
|
||||
$("#Categorylist li[data-value=other]").addClass("active");
|
||||
}
|
||||
});
|
||||
}
|
||||
288
public/javascripts/selectlist.js
Normal file
288
public/javascripts/selectlist.js
Normal file
@@ -0,0 +1,288 @@
|
||||
/*
|
||||
* Fuel UX Selectlist
|
||||
* https://github.com/ExactTarget/fuelux
|
||||
*
|
||||
* Copyright (c) 2014 ExactTarget
|
||||
* Licensed under the BSD New license.
|
||||
*/
|
||||
|
||||
// -- BEGIN UMD WRAPPER PREFACE --
|
||||
|
||||
// For more information on UMD visit:
|
||||
// https://github.com/umdjs/umd/blob/master/jqueryPlugin.js
|
||||
|
||||
(function (factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// if AMD loader is available, register as an anonymous module.
|
||||
define(['jquery'], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node/CommonJS
|
||||
module.exports = factory(require('jquery'));
|
||||
} else {
|
||||
// OR use browser globals if AMD is not present
|
||||
factory(jQuery);
|
||||
}
|
||||
}(function ($) {
|
||||
// -- END UMD WRAPPER PREFACE --
|
||||
|
||||
// -- BEGIN MODULE CODE HERE --
|
||||
|
||||
var old = $.fn.selectlist;
|
||||
// SELECT CONSTRUCTOR AND PROTOTYPE
|
||||
|
||||
var Selectlist = function (element, options) {
|
||||
this.$element = $(element);
|
||||
this.options = $.extend({}, $.fn.selectlist.defaults, options);
|
||||
|
||||
|
||||
this.$button = this.$element.find('.btn.dropdown-toggle');
|
||||
this.$hiddenField = this.$element.find('.hidden-field');
|
||||
this.$label = this.$element.find('.selected-label');
|
||||
this.$dropdownMenu = this.$element.find('.dropdown-menu');
|
||||
|
||||
this.$element.on('click.fu.selectlist', '.dropdown-menu a', $.proxy(this.itemClicked, this));
|
||||
this.setDefaultSelection();
|
||||
|
||||
if (options.resize === 'auto' || this.$element.attr('data-resize') === 'auto') {
|
||||
this.resize();
|
||||
}
|
||||
|
||||
// if selectlist is empty or is one item, disable it
|
||||
var items = this.$dropdownMenu.children('li');
|
||||
if (items.length === 0) {
|
||||
this.disable();
|
||||
this.doSelect($(this.options.emptyLabelHTML));
|
||||
}
|
||||
|
||||
// support jumping focus to first letter in dropdown when key is pressed
|
||||
this.$element.on('shown.bs.dropdown', function () {
|
||||
var $this = $(this);
|
||||
// attach key listener when dropdown is shown
|
||||
$(document).on('keypress.fu.selectlist', function (e) {
|
||||
|
||||
// get the key that was pressed
|
||||
var key = String.fromCharCode(e.which);
|
||||
// look the items to find the first item with the first character match and set focus
|
||||
$this.find("li").each(function (idx, item) {
|
||||
if ($(item).text().charAt(0).toLowerCase() === key) {
|
||||
$(item).children('a').focus();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
// unbind key event when dropdown is hidden
|
||||
this.$element.on('hide.bs.dropdown', function () {
|
||||
$(document).off('keypress.fu.selectlist');
|
||||
});
|
||||
};
|
||||
|
||||
Selectlist.prototype = {
|
||||
|
||||
constructor: Selectlist,
|
||||
|
||||
destroy: function () {
|
||||
this.$element.remove();
|
||||
// any external bindings
|
||||
// [none]
|
||||
// empty elements to return to original markup
|
||||
// [none]
|
||||
// returns string of markup
|
||||
return this.$element[0].outerHTML;
|
||||
},
|
||||
|
||||
doSelect: function ($item) {
|
||||
var $selectedItem;
|
||||
this.$selectedItem = $selectedItem = $item;
|
||||
|
||||
this.$hiddenField.val(this.$selectedItem.attr('data-value'));
|
||||
this.$label.html($(this.$selectedItem.children()[0]).html());
|
||||
|
||||
// clear and set selected item to allow declarative init state
|
||||
// unlike other controls, selectlist's value is stored internal, not in an input
|
||||
this.$element.find('li').each(function () {
|
||||
if ($selectedItem.is($(this))) {
|
||||
$(this).attr('data-selected', true);
|
||||
} else {
|
||||
$(this).removeData('selected').removeAttr('data-selected');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
itemClicked: function (e) {
|
||||
this.$element.trigger('clicked.fu.selectlist', this.$selectedItem);
|
||||
|
||||
e.preventDefault();
|
||||
// ignore if a disabled item is clicked
|
||||
if ($(e.currentTarget).parent('li').is('.disabled, :disabled')) { return; }
|
||||
|
||||
// is clicked element different from currently selected element?
|
||||
if (!($(e.target).parent().is(this.$selectedItem))) {
|
||||
this.itemChanged(e);
|
||||
}
|
||||
|
||||
// return focus to control after selecting an option
|
||||
this.$element.find('.dropdown-toggle').focus();
|
||||
},
|
||||
|
||||
itemChanged: function (e) {
|
||||
//selectedItem needs to be <li> since the data is stored there, not in <a>
|
||||
this.doSelect($(e.target).closest('li'));
|
||||
|
||||
// pass object including text and any data-attributes
|
||||
// to onchange event
|
||||
var data = this.selectedItem();
|
||||
// trigger changed event
|
||||
this.$element.trigger('changed.fu.selectlist', data);
|
||||
},
|
||||
|
||||
resize: function () {
|
||||
var width = 0;
|
||||
var newWidth = 0;
|
||||
var sizer = $('<div/>').addClass('selectlist-sizer');
|
||||
|
||||
|
||||
if (Boolean($(document).find('html').hasClass('fuelux'))) {
|
||||
// default behavior for fuel ux setup. means fuelux was a class on the html tag
|
||||
$(document.body).append(sizer);
|
||||
} else {
|
||||
// fuelux is not a class on the html tag. So we'll look for the first one we find so the correct styles get applied to the sizer
|
||||
$('.fuelux:first').append(sizer);
|
||||
}
|
||||
|
||||
sizer.append(this.$element.clone());
|
||||
|
||||
this.$element.find('a').each(function () {
|
||||
sizer.find('.selected-label').text($(this).text());
|
||||
newWidth = sizer.find('.selectlist').outerWidth();
|
||||
newWidth = newWidth + sizer.find('.sr-only').outerWidth();
|
||||
if (newWidth > width) {
|
||||
width = newWidth;
|
||||
}
|
||||
});
|
||||
|
||||
if (width <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.$button.css('width', width);
|
||||
this.$dropdownMenu.css('width', width);
|
||||
|
||||
sizer.remove();
|
||||
},
|
||||
|
||||
selectedItem: function () {
|
||||
var txt = this.$selectedItem.text();
|
||||
return $.extend({
|
||||
text: txt
|
||||
}, this.$selectedItem.data());
|
||||
},
|
||||
|
||||
selectByText: function (text) {
|
||||
var $item = $([]);
|
||||
this.$element.find('li').each(function () {
|
||||
if ((this.textContent || this.innerText || $(this).text() || '').toLowerCase() === (text || '').toLowerCase()) {
|
||||
$item = $(this);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
this.doSelect($item);
|
||||
},
|
||||
|
||||
selectByValue: function (value) {
|
||||
var selector = 'li[data-value="' + value + '"]';
|
||||
this.selectBySelector(selector);
|
||||
},
|
||||
|
||||
selectByIndex: function (index) {
|
||||
// zero-based index
|
||||
var selector = 'li:eq(' + index + ')';
|
||||
this.selectBySelector(selector);
|
||||
},
|
||||
|
||||
selectBySelector: function (selector) {
|
||||
var $item = this.$element.find(selector);
|
||||
this.doSelect($item);
|
||||
},
|
||||
|
||||
setDefaultSelection: function () {
|
||||
var $item = this.$element.find('li[data-selected=true]').eq(0);
|
||||
|
||||
if ($item.length === 0) {
|
||||
$item = this.$element.find('li').has('a').eq(0);
|
||||
}
|
||||
|
||||
this.doSelect($item);
|
||||
},
|
||||
|
||||
enable: function () {
|
||||
this.$element.removeClass('disabled');
|
||||
this.$button.removeClass('disabled');
|
||||
},
|
||||
|
||||
disable: function () {
|
||||
this.$element.addClass('disabled');
|
||||
this.$button.addClass('disabled');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// SELECT PLUGIN DEFINITION
|
||||
|
||||
$.fn.selectlist = function (option) {
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
var methodReturn;
|
||||
|
||||
var $set = this.each(function () {
|
||||
var $this = $(this);
|
||||
var data = $this.data('fu.selectlist');
|
||||
var options = typeof option === 'object' && option;
|
||||
|
||||
if (!data) {
|
||||
$this.data('fu.selectlist', (data = new Selectlist(this, options)));
|
||||
}
|
||||
|
||||
if (typeof option === 'string') {
|
||||
methodReturn = data[option].apply(data, args);
|
||||
}
|
||||
});
|
||||
|
||||
return (methodReturn === undefined) ? $set : methodReturn;
|
||||
};
|
||||
|
||||
$.fn.selectlist.defaults = {
|
||||
emptyLabelHTML: '<li data-value=""><a href="#">No items</a></li>'
|
||||
};
|
||||
|
||||
$.fn.selectlist.Constructor = Selectlist;
|
||||
|
||||
$.fn.selectlist.noConflict = function () {
|
||||
$.fn.selectlist = old;
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// DATA-API
|
||||
|
||||
$(document).on('mousedown.fu.selectlist.data-api', '[data-initialize=selectlist]', function (e) {
|
||||
var $control = $(e.target).closest('.selectlist');
|
||||
if (!$control.data('fu.selectlist')) {
|
||||
$control.selectlist($control.data());
|
||||
}
|
||||
});
|
||||
|
||||
// Must be domReady for AMD compatibility
|
||||
$(function () {
|
||||
$('[data-initialize=selectlist]').each(function () {
|
||||
var $this = $(this);
|
||||
if (!$this.data('fu.selectlist')) {
|
||||
$this.selectlist($this.data());
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// -- BEGIN UMD WRAPPER AFTERWORD --
|
||||
}));
|
||||
// -- END UMD WRAPPER AFTERWORD --
|
||||
52
public/javascripts/settings.js
Normal file
52
public/javascripts/settings.js
Normal file
@@ -0,0 +1,52 @@
|
||||
$(function () {
|
||||
$("#side-menu>li:eq(8)").addClass("active");
|
||||
|
||||
var elems = Array.prototype.slice.call(document.querySelectorAll('.js-switch'));
|
||||
elems.forEach(function (el) {
|
||||
var switchery = new Switchery(el, { color: '#1AB394' });
|
||||
});
|
||||
|
||||
$(document).on({
|
||||
change: function () {
|
||||
$(this).prev(":hidden").val(this.checked);
|
||||
}
|
||||
}, ".js-switch");
|
||||
|
||||
$(".fileupload").fileupload({
|
||||
url: "/admin/uploadimg",
|
||||
dataType: "text",
|
||||
done: function (e, data) {
|
||||
$(this).prev("img").attr("src", data.result);
|
||||
$(this).next(":hidden").val(data.result);
|
||||
}
|
||||
});
|
||||
|
||||
$('#btnSave').on('click', function () {
|
||||
var $this = $(this);
|
||||
$this.attr('disabled', 'disabled');
|
||||
$.ajax({
|
||||
url: $("#postForm")[0].action,
|
||||
type: $("#postForm")[0].method,
|
||||
data: $("#postForm").serialize(),
|
||||
success: function () {
|
||||
swal({
|
||||
title: '保存成功!',
|
||||
type: 'success',
|
||||
showConfirmButton: false,
|
||||
timer: 2000
|
||||
});
|
||||
},
|
||||
error: function () {
|
||||
swal({
|
||||
title: "保存失败!",
|
||||
type: "error",
|
||||
showConfirmButton: false,
|
||||
timer: 2000
|
||||
});
|
||||
},
|
||||
complete: function () {
|
||||
$this.removeAttr("disabled");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
92
public/javascripts/top.js
Normal file
92
public/javascripts/top.js
Normal file
@@ -0,0 +1,92 @@
|
||||
$(function () {
|
||||
var shows = window.tools || [0, 1, 2],
|
||||
toggle = $('#ss_toggle'),
|
||||
menu = $('#share-menu'),
|
||||
rot,
|
||||
img;
|
||||
if (shows.indexOf(0) >= 0) {
|
||||
$('ul.fixed-tool li.share-li').show();
|
||||
$('#ss_toggle').on('click', function () {
|
||||
if (!$(".qrcontain").is(":hidden")) {
|
||||
$(".qrcontain").hide();
|
||||
$("#qrBtn").removeClass("opened");
|
||||
}
|
||||
rot = parseInt($(this).data('rot')) - 180;
|
||||
if (rot / 180 % 2 == 0) {
|
||||
menu.css('transform', 'rotate(' + rot + 'deg)');
|
||||
menu.css('webkitTransform', 'rotate(' + rot + 'deg)');
|
||||
toggle.parent().addClass('ss_active');
|
||||
toggle.addClass('close');
|
||||
} else {
|
||||
menu.css('transform', 'rotate(' + parseInt(rot - 30) + 'deg)');
|
||||
menu.css('webkitTransform', 'rotate(' + parseInt(rot - 30) + 'deg)');
|
||||
toggle.parent().removeClass('ss_active');
|
||||
toggle.removeClass('close');
|
||||
}
|
||||
$(this).data('rot', rot);
|
||||
});
|
||||
menu.on('transitionend webkitTransitionEnd oTransitionEnd', function () {
|
||||
if (rot / 180 % 2 == 0) {
|
||||
$("#share-menu i.fa").addClass('bounce');
|
||||
} else {
|
||||
$("#share-menu i.fa").removeClass('bounce');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (shows.indexOf(1) >= 0) {
|
||||
$('ul.fixed-tool li.qr-li').show();
|
||||
$("#qrBtn").on("click", function () {
|
||||
if ($("#ss_toggle").hasClass("close")) {
|
||||
$("#share-menu").css("transition", "none");
|
||||
$("#ss_toggle").click();
|
||||
}
|
||||
if ($(".qrcontain").is(":hidden")) {
|
||||
$(".qrcontain").removeClass("fadeOutLeft").addClass("fadeInLeft");
|
||||
$(".qrcontain").show();
|
||||
$("#qrBtn").addClass("opened");
|
||||
} else {
|
||||
$(".qrcontain").removeClass("fadeInLeft").addClass("fadeOutLeft");
|
||||
$(".qrcontain").one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function () {
|
||||
$(".qrcontain").hide();
|
||||
});
|
||||
$("#qrBtn").removeClass("opened");
|
||||
}
|
||||
$("#share-menu").css("transition", "all 1s ease 0s");
|
||||
});
|
||||
|
||||
img = document.createElement("img");
|
||||
img.src = logoPath;
|
||||
img.onload = function () {
|
||||
$("#qrcode").qrcode({
|
||||
text: window.location.href,
|
||||
size: "100",
|
||||
ecLevel: 'H',
|
||||
minVersion: 4,
|
||||
mode: 4,
|
||||
image: img,
|
||||
mSize: 0.3
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
if (shows.indexOf(2) >= 0) {
|
||||
$('ul.fixed-tool li.top-li').show();
|
||||
$(window).scroll(function () {
|
||||
var scrollTop = $(window).scrollTop();
|
||||
if (scrollTop > 0) {
|
||||
$("#scrollTop").show();
|
||||
$(".qrcontain").css("top", "-57px");
|
||||
$(".qrcontain .arrow").css("top", "52%");
|
||||
} else {
|
||||
$("#scrollTop").hide();
|
||||
$(".qrcontain").css("top", "-107px");
|
||||
$(".qrcontain .arrow").css("top", "86%");
|
||||
}
|
||||
});
|
||||
|
||||
$("#scrollTop a").on("click", function () {
|
||||
$("html,body").animate({scrollTop: 0}, 800);
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user