183 lines
8.9 KiB
JavaScript
183 lines
8.9 KiB
JavaScript
/**
|
||
* Created by cxt on 2017/4/18.
|
||
*/
|
||
//---------------侧边固定提示功能---------------//
|
||
$(function(){
|
||
var $desc = $("<div class='-task-desc'></div>").appendTo("body");
|
||
$(".-task-sidebar>div").hover(function(){
|
||
var $tool = $(this).attr("tooltips");
|
||
$desc.html($tool+"<div><img src='../images/edu_user/jt.png'></div>");
|
||
$desc.css({
|
||
left:$(this).offset().left - $desc.width()-30,
|
||
opacity:0,
|
||
top:$(this).offset().top
|
||
}).stop().animate({
|
||
left:$(this).offset().left - $desc.width()-5,
|
||
opacity:1
|
||
},400);
|
||
},function(){
|
||
$desc.stop().animate({
|
||
left:$(this).offset().left - $desc.width()-30,
|
||
opacity:0
|
||
},200);
|
||
});
|
||
$(".gotop").click(function(){
|
||
$("html,body").scrollTop(0);
|
||
});
|
||
});
|
||
|
||
//------------------弹框相关--------------------//
|
||
function hideModal(el) {
|
||
if($("#popupWrap").length > 0){
|
||
$("#popupWrap").remove();
|
||
}
|
||
else{
|
||
var modal;
|
||
if (el) {
|
||
modal = $(el).parents('.ui-dialog-content');
|
||
} else {
|
||
modal = $('#ajax-modal');
|
||
}
|
||
modal.dialog("close");
|
||
}
|
||
}
|
||
|
||
// 公共弹框样式
|
||
// 建议左右栏的:Width:460,Height:190
|
||
// 建议宽屏对应值:Width:760,Height:500
|
||
function pop_box_new(value, Width, Height){
|
||
w = ($(window).width() - Width)/2;
|
||
h = ($(window).height() - Height)/2;
|
||
var container =$('<div></div>');
|
||
container.attr('id','popupWrap');
|
||
$(document.body).append(container);
|
||
$("#popupWrap").html(value);
|
||
$("#popupWrap").show();
|
||
$('#popupWrap').css({"top": h+"px","left": w+"px","padding":"0","border":"none","position":"fixed","z-index":"99999","background-color":"#fff"});
|
||
$('#popupWrap').find("a[class*='close']").click(function(){
|
||
$("#popupWrap").hide();
|
||
});
|
||
// w = ($(window).width() - Width)/2;
|
||
// h = ($(window).height() - Height)/2;
|
||
// $("#ajax-modal").html(value);
|
||
// showModal('ajax-modal', Width + 'px');
|
||
// $('#ajax-modal').siblings().remove();
|
||
// $('#ajax-modal').parent().css({"top": h+"px","left": w+"px","padding":"0","border":"none","position":"fixed"});
|
||
// $('#ajax-modal').parent().removeClass("resourceUploadPopup popbox_polls popbox");
|
||
// $('#ajax-modal').css({"padding":"0","overflow":"hidden"});
|
||
// $('#ajax-modal').parent().attr("id","popupWrap");
|
||
|
||
//拖拽
|
||
function Drag(id) {
|
||
this.div = document.getElementById(id);
|
||
if (this.div) {
|
||
this.div.style.cursor = "move";
|
||
this.div.style.position = "fixed";
|
||
}
|
||
this.disX = 0;
|
||
this.disY = 0;
|
||
var _this = this;
|
||
this.div.onmousedown = function (evt) {
|
||
_this.getDistance(evt);
|
||
document.onmousemove = function (evt) {
|
||
_this.setPosition(evt);
|
||
};
|
||
_this.div.onmouseup = function () {
|
||
_this.clearEvent();
|
||
}
|
||
}
|
||
}
|
||
Drag.prototype.getDistance = function (evt) {
|
||
var oEvent = evt || event;
|
||
this.disX = oEvent.clientX - this.div.offsetLeft;
|
||
this.disY = oEvent.clientY - this.div.offsetTop;
|
||
};
|
||
Drag.prototype.setPosition = function (evt) {
|
||
var oEvent = evt || event;
|
||
var l = oEvent.clientX - this.disX;
|
||
var t = oEvent.clientY - this.disY;
|
||
if (l <= 0) {
|
||
l = 0;
|
||
}
|
||
else if (l >= document.documentElement.clientWidth - this.div.offsetWidth) {
|
||
l = document.documentElement.clientWidth - this.div.offsetWidth;
|
||
}
|
||
if (t <= 0) {
|
||
t = 0;
|
||
}
|
||
else if (t >= document.documentElement.clientHeight - this.div.offsetHeight) {
|
||
t = document.documentElement.clientHeight - this.div.offsetHeight;
|
||
}
|
||
this.div.style.left = l + "px";
|
||
this.div.style.top = t + "px";
|
||
};
|
||
Drag.prototype.clearEvent = function () {
|
||
this.div.onmouseup = null;
|
||
document.onmousemove = null;
|
||
};
|
||
|
||
new Drag("popupWrap");
|
||
|
||
$("#popupWrap input, #popupWrap textarea, #popupWrap ul, #popupWrap a").mousedown(function(event){
|
||
event.stopPropagation();
|
||
new Drag("popupWrap");
|
||
});
|
||
}
|
||
|
||
//点击删除时的确认弹框: 不走destroy方法
|
||
function delete_confirm_box(url, str){
|
||
var htmlvalue = '<div class="task-popup" style="width:300px;"><div class="task-popup-title clearfix"><h3 class="fl color-grey">提示</h3><a href="javascript:void(0);" class="pop_close"><i class="fa fa-times-circle font-18 link-color-grey fr mt5"></i></a></div>'+
|
||
'<div class="task-popup-content"><p class="task-popup-text-center font-16">' + str + '</p></div><div class="task-popup-submit clearfix"><a href="javascript:void(0);" onclick="hideModal();" class="task-btn fl">取消</a>'+
|
||
'<a href="'+ url +'" class="task-btn task-btn-blue fr" data-remote="true">确定</a></div></div>';
|
||
pop_box_new(htmlvalue, 300, 140);
|
||
}
|
||
|
||
//点击删除时的确认弹框: 走destroy方法,remote为true
|
||
function delete_confirm_box_2(url, str){
|
||
var htmlvalue = '<div class="task-popup" style="width:300px;"><div class="task-popup-title clearfix"><h3 class="fl color-grey">提示</h3><a href="javascript:void(0);" class="pop_close"><i class="fa fa-times-circle font-18 link-color-grey fr mt5"></i></a></div>'+
|
||
'<div class="task-popup-content"><p class="task-popup-text-center font-16">' + str + '</p></div><div class="task-popup-submit clearfix"><a href="javascript:void(0);" onclick="hideModal();" class="task-btn fl">取消</a>'+
|
||
'<a href="'+ url +'" class="task-btn task-btn-blue fr" data-method="delete" data-remote="true">确定</a></div></div>';
|
||
pop_box_new(htmlvalue, 300, 140);
|
||
}
|
||
|
||
//点击删除时的确认弹框: 走destroy方法
|
||
function delete_confirm_box_3(url, str){
|
||
var htmlvalue = '<div class="task-popup" style="width:300px;"><div class="task-popup-title clearfix"><h3 class="fl color-grey">提示</h3><a href="javascript:void(0);" class="pop_close"><i class="fa fa-times-circle font-18 link-color-grey fr mt5"></i></a></div>'+
|
||
'<div class="task-popup-content"><p class="task-popup-text-center font-16">' + str + '</p></div><div class="task-popup-submit clearfix"><a href="javascript:void(0);" onclick="hideModal();" class="task-btn fl">取消</a>'+
|
||
'<a href="'+ url +'" class="task-btn task-btn-blue fr" data-method="delete">确定</a></div></div>';
|
||
pop_box_new(htmlvalue, 300, 140);
|
||
}
|
||
|
||
//提示框:只有一个按钮,点击关闭弹框
|
||
function notice_sure_box(str){
|
||
var htmlvalue = '<div class="task-popup" style="width:350px;"><div class="task-popup-title clearfix"><h3 class="fl color-grey">提示</h3><a href="javascript:void(0);" class="pop_close"><i class="fa fa-times-circle font-18 link-color-grey fr mt5"></i></a></div>'+
|
||
'<div class="task-popup-content"><p class="task-popup-text-center font-16">' + str + '</p></div><div class="task-popup-sure clearfix">'+
|
||
'<a href="javascript:void(0);" class="task-btn task-btn-blue" onclick="hideModal();">知道了</a></div></div>';
|
||
pop_box_new(htmlvalue, 350, 140);
|
||
}
|
||
|
||
//提示框:只有一个确定按钮,点击关闭弹框
|
||
function notice_box(str){
|
||
var htmlvalue = '<div class="task-popup" style="width:300px;"><div class="task-popup-title clearfix"><h3 class="fl color-grey">提示</h3><a href="javascript:void(0);" class="pop_close"><i class="fa fa-times-circle font-18 link-color-grey fr mt5"></i></a></div>'+
|
||
'<div class="task-popup-content"><p class="task-popup-text-center font-16">' + str + '</p></div><div class="task-popup-sure clearfix">'+
|
||
'<a href="javascript:void(0);" class="task-btn task-btn-blue" onclick="hideModal();">确定</a></div></div>';
|
||
pop_box_new(htmlvalue, 300, 140);
|
||
}
|
||
|
||
|
||
// 长提示框:只有一个确定按钮,点击关闭弹框
|
||
function long_notice_box(str){
|
||
var htmlvalue = '<div class="task-popup" style="width:380px;"><div class="task-popup-title clearfix"><h3 class="fl color-grey">提示</h3><a href="javascript:void(0);" class="pop_close"><i class="fa fa-times-circle font-18 link-color-grey fr mt5"></i></a></div>'+
|
||
'<div class="task-popup-content"><p class="task-popup-text-center font-16">' + str + '</p></div><div class="task-popup-sure clearfix">'+
|
||
'<a href="javascript:void(0);" class="task-btn task-btn-blue" onclick="hideModal();">确定</a></div></div>';
|
||
pop_box_new(htmlvalue, 380, 140);
|
||
}
|
||
|
||
//提示框:只有一个确定按钮,点击跳转
|
||
function notice_box_redirect(url, str){
|
||
var htmlvalue = '<div class="task-popup" style="width:300px;"><div class="task-popup-title clearfix"><h3 class="fl color-grey">提示</h3><a href="'+ url +'" class="pop_close"><i class="fa fa-times-circle font-18 link-color-grey fr mt5"></i></a></div>'+
|
||
'<div class="task-popup-content"><p class="task-popup-text-center font-16">' + str + '</p></div><div class="task-popup-sure clearfix">'+
|
||
'<a href="'+ url +'" class="task-btn task-btn-blue">确定</a></div></div>';
|
||
pop_box_new(htmlvalue, 300, 140);
|
||
}
|