补充文件
This commit is contained in:
787
public/static/mobile/edit/js/common.js
Normal file
787
public/static/mobile/edit/js/common.js
Normal file
@@ -0,0 +1,787 @@
|
||||
|
||||
$(function(){
|
||||
|
||||
//
|
||||
//
|
||||
$(document).on("pageInit", "#page-upimages", function(e, pageId, $page) {
|
||||
|
||||
var Options = {
|
||||
width : 300,
|
||||
height : 300,
|
||||
cutWidth : 300,
|
||||
cutHeight : 300,
|
||||
cutMinSize : 50,//裁剪框最小尺寸,即最小可以缩放到这个size,width及height任意一个都无法小于这个值。
|
||||
|
||||
//--系统自带,运行时自动运算,请不要修改。
|
||||
cropViewWidth : 0,//在画布里面显示的最大宽度
|
||||
cropViewHeight : 0,//在画布里面显示的最大高度
|
||||
cropLeft : 0,
|
||||
cropTop : 0,
|
||||
//--裁剪框
|
||||
cutViewWidth : 0, //当前宽度,
|
||||
cutViewHeight : 0,//当前高度
|
||||
cutMaxWidth : 0, //裁剪框最大宽度。
|
||||
cutMaxHeight : 0,//裁剪框最大高度。
|
||||
//--四象限。用于判断距离。
|
||||
cutBoxLimitX1 : 0,
|
||||
cutBoxLimitX2 : 0,
|
||||
cutBoxLimitY1 : 0,
|
||||
cutBoxLimitY2 : 0,
|
||||
cutLeft : 0,//裁剪框绝对定位,左侧距离。
|
||||
cutTop : 0,//裁剪框绝对定位,离顶部距离。
|
||||
initStatus : false
|
||||
//当前组件是否已经初始化了。
|
||||
};
|
||||
var Options_image = {
|
||||
width : 0,
|
||||
height : 0,
|
||||
imgData : ""
|
||||
}
|
||||
|
||||
var input_browseFile = document.getElementById("browseFile");
|
||||
var img_preview = document.getElementById("imgPreview");
|
||||
var cutBox = document.getElementById("cutBox");
|
||||
var tipBox = document.getElementById("tipBox");
|
||||
var _cropper = document.getElementById("cropper");
|
||||
var mainCutter = document.getElementById("mainCutter");
|
||||
var tips2 = $("#tips2");
|
||||
var wrapper = document.getElementById("wrapper");
|
||||
var component_box = document.getElementById("component_box");
|
||||
|
||||
var ctx = _cropper.getContext('2d');//ctx.drawImage(myImage, 50, 50);
|
||||
|
||||
function previewInImage(file) {
|
||||
//通过file.size可以取得图片大小
|
||||
var reader = new FileReader();
|
||||
LoadingImage();
|
||||
|
||||
reader.onload = function(evt) {
|
||||
img_preview.src = evt.target.result;
|
||||
}
|
||||
Options_image.imgData = reader.readAsDataURL(file);
|
||||
}
|
||||
img_preview.onload = function() {
|
||||
Options_image.width = img_preview.width;
|
||||
Options_image.height = img_preview.height;
|
||||
_initCropAndCut();
|
||||
}
|
||||
function LoadingImage() {
|
||||
$(img_preview).css({
|
||||
"width" : "",
|
||||
"height" : ""
|
||||
});
|
||||
}
|
||||
function _initCropAndCut() {
|
||||
//--计算比例,将其放到canvas里面。
|
||||
|
||||
var scale = Math.max(Options_image.width / Options.width,
|
||||
Options_image.height / Options.height);
|
||||
if (scale > 1) {
|
||||
Options.cropViewWidth = parseInt(Math.floor(Options_image.width
|
||||
/ scale));
|
||||
Options.cropViewHeight = parseInt(Math.floor(Options_image.height
|
||||
/ scale));
|
||||
} else {
|
||||
Options.cropViewWidth = Options_image.width;
|
||||
Options.cropViewHeight = Options_image.height;
|
||||
}
|
||||
//--计算画布里面的图像的位置。
|
||||
Options.cropLeft = parseInt((Options.width - Options.cropViewWidth) / 2);
|
||||
Options.cropTop = parseInt((Options.height - Options.cropViewHeight) / 2);
|
||||
//--计算裁剪框实际大小及实际位置。
|
||||
//计算裁剪框的位置。
|
||||
|
||||
var scale_2 = Math.max(Options.cutWidth / Options.cropViewWidth,
|
||||
Options.cutHeight / Options.cropViewHeight);
|
||||
if (scale_2 > 1) {
|
||||
Options.cutViewWidth = parseInt(Math.floor(Options.cutWidth
|
||||
/ scale_2));
|
||||
Options.cutViewHeight = parseInt(Math.floor(Options.cutHeight
|
||||
/ scale_2));
|
||||
} else {
|
||||
Options.cutViewHeight = Options.cutHeight;
|
||||
Options.cutViewWidth = Options.cutWidth;
|
||||
}
|
||||
Options.cutMaxWidth = Options.cutViewWidth;
|
||||
Options.cutMaxHeight = Options.cutViewHeight;
|
||||
|
||||
Options.cutLeft = parseInt(Math
|
||||
.floor((Options.cropViewWidth - Options.cutViewWidth)) / 2);
|
||||
Options.cutTop = parseInt(Math
|
||||
.floor((Options.cropViewHeight - Options.cutViewHeight)) / 2);
|
||||
//-四象限。
|
||||
Options.cutBoxLimitX1 = 0;
|
||||
Options.cutBoxLimitX2 = Options.cropViewWidth;
|
||||
Options.cutBoxLimitY1 = 0;
|
||||
Options.cutBoxLimitY2 = Options.cropViewHeight;
|
||||
|
||||
//获取x、y坐标!!!
|
||||
$("#x").val(Options.cutLeft);
|
||||
$("#y").val(Options.cutTop);
|
||||
//获取图片长宽!!!
|
||||
$("#h").val(Options.cropViewHeight);
|
||||
$("#w").val(Options.cropViewWidth);
|
||||
//获取剪切框长宽!!!
|
||||
$("#hh").val(Options.cutViewHeight);
|
||||
$("#ww").val(Options.cutViewWidth);
|
||||
//获取图片实际长宽!!!
|
||||
$("#imgh").val(Options.cutViewHeight);
|
||||
$("#imgw").val(Options.cutViewWidth);
|
||||
$("#scale").val(scale);
|
||||
|
||||
$(cutBox).css({
|
||||
"display" : "block",
|
||||
"width" : Options.cutViewWidth + "px",
|
||||
"height" : Options.cutViewHeight + "px",
|
||||
"left" : Options.cutLeft + "px",
|
||||
"top" : Options.cutTop + "px"
|
||||
});
|
||||
//$(cutBox).css({"display":"block","left":Options.cutLeft+"px","top":Options.cutTop+"px"});
|
||||
$(img_preview).css({
|
||||
"width" : Options.cropViewWidth + "px",
|
||||
"height" : Options.cropViewHeight + "px"
|
||||
});
|
||||
$(mainCutter).css({
|
||||
"display" : "block",
|
||||
"width" : Options.cropViewWidth + "px",
|
||||
"height" : Options.cropViewHeight + "px",
|
||||
"left" : Options.cropLeft + "px",
|
||||
"top" : Options.cropTop + "px"
|
||||
});
|
||||
//ctx.drawImage(img_preview,Options.cropLeft,Options.cropTop,Options.cropViewWidth,Options.cropViewHeight);
|
||||
//ctx.drawImage(img_preview, 0, 0, Options_image.width,Options_image.height, Options.cropLeft, Options.cropTop, Options.cropViewWidth, Options.cropViewHeight );
|
||||
|
||||
Options.initStatus = true;
|
||||
Options_process.initStatus = true;
|
||||
Options_process.percent = 100;
|
||||
Options_process.pointX = Options_process.barWidth;
|
||||
_resizeProcessBar();
|
||||
}
|
||||
|
||||
input_browseFile.addEventListener("change", function() {
|
||||
//通过 this.files 取到 FileList ,这里只有一个
|
||||
previewInImage(this.files[0]);
|
||||
|
||||
$.popup('.popup-caiface');
|
||||
|
||||
}, false);
|
||||
//--添加缩放功能。
|
||||
Options_zoom = {
|
||||
beginX1 : 0,
|
||||
beginY1 : 0,
|
||||
beginX2 : 0,
|
||||
beginY2 : 0,
|
||||
endX1 : 0,
|
||||
endY1 : 0,
|
||||
endX2 : 0,
|
||||
endY2 : 0
|
||||
};
|
||||
//--添加裁剪框移动功能
|
||||
Options_move = {
|
||||
beginX1 : 0,
|
||||
beginY1 : 0,
|
||||
endX1 : 0,
|
||||
endY1 : 0
|
||||
};
|
||||
|
||||
/**
|
||||
* 拖动裁剪框的逻辑处理。
|
||||
* */
|
||||
cutBox.addEventListener("touchstart", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
Options_move = {
|
||||
beginX1 : 0,
|
||||
beginY1 : 0,
|
||||
endX1 : 0,
|
||||
endY1 : 0
|
||||
};
|
||||
var beginX = event.changedTouches[0].pageX;
|
||||
var beginY = event.changedTouches[0].pageY;
|
||||
Options_move.beginX1 = beginX;
|
||||
Options_move.beginY1 = beginY;
|
||||
|
||||
}, false);
|
||||
cutBox.addEventListener("touchmove", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
//--
|
||||
var beginX = event.changedTouches[0].pageX;
|
||||
var beginY = event.changedTouches[0].pageY;
|
||||
Options_move.endX1 = beginX;
|
||||
Options_move.endY1 = beginY;
|
||||
//--计算是否发生位移,根据位移来定位裁剪框位置。
|
||||
//位移量。
|
||||
var _d_x = Options_move.endX1 - Options_move.beginX1;
|
||||
var _d_y = Options_move.endY1 - Options_move.beginY1;
|
||||
//--当前裁剪框原始位置。
|
||||
var _new_x = Options.cutLeft;
|
||||
var _new_y = Options.cutTop;
|
||||
_new_x += _d_x;
|
||||
_new_y += _d_y;
|
||||
//--判断是否在矩形边框,假如超出去,那么就取最终点。
|
||||
//--注意,判断相关点的范围。
|
||||
|
||||
if (_new_x < Options.cutBoxLimitX1) {
|
||||
_new_x = Options.cutBoxLimitX1;
|
||||
} else if (_new_x > Options.cutBoxLimitX2) {
|
||||
_new_x = Options.cutBoxLimitX2;
|
||||
}
|
||||
//--顺便判断,加上宽度后,是否超过了范围。
|
||||
if ((_new_x + Options.cutViewWidth) > Options.cutBoxLimitX2) {
|
||||
_new_x = Options.cutBoxLimitX2 - Options.cutViewWidth;
|
||||
}
|
||||
if (_new_y < Options.cutBoxLimitY1) {
|
||||
_new_y = Options.cutBoxLimitY1;
|
||||
} else if (_new_y > Options.cutBoxLimitY2) {
|
||||
_new_y = Options.cutBoxLimitY2;
|
||||
}
|
||||
//--顺便判断,加上裁剪框高度后,是否超过下限。
|
||||
if ((_new_y + Options.cutViewHeight) > Options.cutBoxLimitY2) {
|
||||
_new_y = Options.cutBoxLimitY2 - Options.cutViewHeight;
|
||||
}
|
||||
|
||||
//获取x、y坐标!!!
|
||||
$("#x").val(_new_x);
|
||||
$("#y").val(_new_y);
|
||||
|
||||
Options.cutLeft = _new_x;
|
||||
Options.cutTop = _new_y;
|
||||
_resizeCutBox();
|
||||
//---将这一点的放回前一点。
|
||||
Options_move.beginX1 = Options_move.endX1;
|
||||
Options_move.beginY1 = Options_move.endY1;
|
||||
|
||||
}, false);
|
||||
cutBox.addEventListener("touchend", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return;
|
||||
|
||||
}, false);
|
||||
/**
|
||||
* 根据相关参数重新resize裁剪框
|
||||
* */
|
||||
function _resizeCutBox() {
|
||||
|
||||
//$(cutBox).css({"left":Options.cutLeft+"px","top":Options.cutTop+"px"});
|
||||
$(cutBox).css({
|
||||
"width" : Options.cutViewWidth + "px",
|
||||
"height" : Options.cutViewHeight + "px",
|
||||
"left" : Options.cutLeft + "px",
|
||||
"top" : Options.cutTop + "px"
|
||||
});
|
||||
}
|
||||
function _getCutImageData() {
|
||||
var output = document.createElement("canvas");
|
||||
//--坐标换算。
|
||||
var scale_x = Options_image.width / Options.cropViewWidth;
|
||||
var scale_y = Options_image.height / Options.cropViewHeight;
|
||||
var _o_x = parseInt((scale_x) * Options.cutLeft);
|
||||
var _o_y = parseInt((scale_y) * Options.cutTop);
|
||||
//--长度换算
|
||||
var _o_width = parseInt(scale_x * Options.cutViewWidth);
|
||||
var _o_height = parseInt(scale_y * Options.cutViewHeight);
|
||||
|
||||
output.width = Options.cutWidth;
|
||||
output.height = Options.cutHeight;
|
||||
output.getContext("2d").drawImage(img_preview, _o_x, _o_y, _o_width,
|
||||
_o_height, 0, 0, output.width, output.height);
|
||||
return output.toDataURL("image/jpeg");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 图片剪切提交方法
|
||||
*/
|
||||
function saveImage() {
|
||||
var imgData = _getCutImageData();
|
||||
var img=imgData.substr(23, imgData.length);
|
||||
$.post(url+'Img/index',{img:img},function(r){
|
||||
if(r){
|
||||
$.hidePreloader();
|
||||
xface=r;
|
||||
$.closeModal();
|
||||
history.go(-1);
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
/**
|
||||
* processBar 进度条相关操作。
|
||||
* */
|
||||
|
||||
Options_process = {
|
||||
beginX : 0,//触摸时候起始点
|
||||
beginY : 0,//触摸时候起始点
|
||||
endX : 0,//触摸时候终点
|
||||
endY : 0,//触摸时候终点
|
||||
barWidth : 280,//进度条长度
|
||||
pointX : 0,//当前指示点位置
|
||||
pointY : 0,
|
||||
percent : 0,//百分比值。
|
||||
initStatus : false
|
||||
};
|
||||
var processBar = document.getElementById("processBar");
|
||||
var processPoint = document.getElementById("processPoint");
|
||||
|
||||
//--添加触屏事件,监控相关动作。
|
||||
//开始触摸
|
||||
processBar.addEventListener("touchstart", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
if (!Options_process.initStatus) {
|
||||
return;
|
||||
}
|
||||
var beginX = event.changedTouches[0].pageX;
|
||||
var beginY = event.changedTouches[0].pageY;
|
||||
Options_process.beginX = beginX;
|
||||
Options_process.beginY = beginY;
|
||||
}, false);
|
||||
//--移动中
|
||||
processBar.addEventListener("touchmove", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
if (!Options_process.initStatus) {
|
||||
return;
|
||||
}
|
||||
var beginX = event.changedTouches[0].pageX;
|
||||
var beginY = event.changedTouches[0].pageY;
|
||||
Options_process.endX = beginX;
|
||||
Options_process.endY = beginY;
|
||||
//--计算比分比。
|
||||
var _d_x = Options_process.endX - Options_process.beginX;
|
||||
Options_process.percent += parseInt(_d_x * 100/Options_process.barWidth);
|
||||
if (Options_process.percent < 0) {
|
||||
Options_process.percent = 0;
|
||||
} else if (Options_process.percent > 100) {
|
||||
Options_process.percent = 100;
|
||||
}
|
||||
//--计算那个指示点位置。
|
||||
Options_process.pointX = parseInt(Options_process.barWidth
|
||||
* (Options_process.percent / 100));
|
||||
_resizeProcessBar();
|
||||
//--根据百分比,设置裁剪框大小。
|
||||
var _o_cut_x = Options.cutLeft;
|
||||
var _o_cut_y = Options.cutTop;
|
||||
var _o_cut_width = Options.cutViewWidth;
|
||||
var _new_cut_width = parseInt(Options.cutMaxWidth
|
||||
* (Options_process.percent / 100));
|
||||
var _new_cut_height = parseInt(Options.cutMaxHeight
|
||||
* (Options_process.percent / 100));
|
||||
|
||||
//最小裁剪框尺寸
|
||||
var cutMinSize = Options.cutMinSize;
|
||||
if (_new_cut_width < cutMinSize) {
|
||||
_new_cut_width = _new_cut_height = cutMinSize;
|
||||
}
|
||||
|
||||
if (_new_cut_width > _o_cut_width) {
|
||||
//--扩大了。
|
||||
//--计算当前坐标
|
||||
var _d_x_2 = _new_cut_width - Options.cutViewWidth;
|
||||
var _d_y_2 = _new_cut_height - Options.cutViewHeight;
|
||||
|
||||
Options.cutLeft = Options.cutLeft - parseInt(_d_x_2 / 2);
|
||||
Options.cutTop = Options.cutTop - parseInt(_d_y_2 / 2);
|
||||
Options.cutViewWidth = _new_cut_width;
|
||||
Options.cutViewHeight = _new_cut_height;
|
||||
_resizeCutBox();
|
||||
|
||||
} else if (_new_cut_width < _o_cut_width) {
|
||||
//--缩小了。
|
||||
var _d_x_2 = Options.cutViewWidth - _new_cut_width;
|
||||
var _d_y_2 = Options.cutViewHeight - _new_cut_height;
|
||||
Options.cutLeft = Options.cutLeft + parseInt(_d_x_2 / 2);
|
||||
Options.cutTop = Options.cutTop + parseInt(_d_y_2 / 2);
|
||||
Options.cutViewWidth = _new_cut_width;
|
||||
Options.cutViewHeight = _new_cut_height;
|
||||
_resizeCutBox();
|
||||
|
||||
}
|
||||
|
||||
//获取剪切框长宽!!!
|
||||
$("#hh").val(_new_cut_height);
|
||||
$("#ww").val(_new_cut_width);
|
||||
|
||||
//--后续处理。
|
||||
Options_process.beginX = Options_process.endX;
|
||||
Options_process.endY = Options_process.endY;
|
||||
|
||||
}, false);
|
||||
//--结束
|
||||
processBar.addEventListener("touchend", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
if (!Options_process.initStatus) {
|
||||
return;
|
||||
}
|
||||
}, false);
|
||||
|
||||
function _resizeProcessBar() {
|
||||
var lefe_x = Options_process.pointX;
|
||||
var left_w = parseInt(lefe_x + 5)
|
||||
$(processPoint).css("left", lefe_x + "px");
|
||||
$("#leftBar").css("width", left_w + "px");
|
||||
}
|
||||
|
||||
$("#saveimg").click(function() {
|
||||
if (Options.initStatus == false) {
|
||||
alert("请先选择图片!");
|
||||
return;
|
||||
}
|
||||
$.showPreloader('上传中...');
|
||||
saveImage();
|
||||
});
|
||||
|
||||
|
||||
//
|
||||
})
|
||||
|
||||
|
||||
|
||||
//设置
|
||||
|
||||
$(document).on("pageInit", "#page-set", function(e, pageId, $page) {
|
||||
if(xface){
|
||||
$('.uface_img').attr('src',imgUrl+'face/'+xface);
|
||||
}
|
||||
//
|
||||
//
|
||||
var liclick;
|
||||
$('.list-block .item-link').click(function(){
|
||||
|
||||
liclick=$(this);
|
||||
var t=liclick.attr('pid');
|
||||
if(t!=''){
|
||||
|
||||
$.popup('.popup-'+t);
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
||||
//
|
||||
$('.pull-right').click(function(){
|
||||
|
||||
var n=$(this).attr('pid');
|
||||
var v=$('input[name='+n+']').val();
|
||||
if(v==''){
|
||||
|
||||
$.toast('该项不能为空');
|
||||
return false;
|
||||
}
|
||||
|
||||
$.post(url+'UserSet/info',{name:n,val:v},function(r){
|
||||
|
||||
if(r){
|
||||
|
||||
$.toast('修改成功');
|
||||
liclick.children().children('.item-after').html(v);
|
||||
|
||||
if(n=='name'){
|
||||
xname=v;
|
||||
}
|
||||
$('input[name='+n+']').val(v);
|
||||
$.closeModal();
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
$('.ewm').click(function(){
|
||||
document.querySelector('#file').addEventListener('change', function () {
|
||||
lrz(this.files[0])
|
||||
.then(function (rst) {
|
||||
|
||||
$.post(url+'Img/ewm',{img:rst.base64},function(r){
|
||||
|
||||
$('.ewm').html('<img src=\"'+imgUrl+'wxewm/'+r+'\">');
|
||||
})
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
|
||||
})
|
||||
//
|
||||
$("#city-picker").cityPicker({
|
||||
toolbarTemplate: '<header class="bar bar-nav">\
|
||||
<button class="button button-link pull-right close-picker">确定</button>\
|
||||
<h1 class="title">选择城市</h1>\
|
||||
</header>'
|
||||
});
|
||||
//
|
||||
$('#savepwd').click(function(){
|
||||
|
||||
var opwd=$('input[name=opwd]').val();
|
||||
var npwd=$('input[name=npwd]').val();
|
||||
var npwd2=$('input[name=npwd2]').val();
|
||||
if(opwd==''){
|
||||
$.toast('旧密码不能为空');
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
if(npwd==''){
|
||||
|
||||
$.toast('新密码不能为空');
|
||||
return false;
|
||||
|
||||
}
|
||||
if(npwd.length<6){
|
||||
$.toast('新密码不能小于6位');
|
||||
return false;
|
||||
|
||||
}
|
||||
if(npwd2==''){
|
||||
|
||||
$.toast('确认密码不能为空');
|
||||
return false;
|
||||
}
|
||||
if(npwd2!=npwd){
|
||||
$.toast('两次密码输入不一致');
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
$.post(url+'UserSet/pwd',{opwd:opwd,npwd:npwd},function(r){
|
||||
if(r.s){
|
||||
$.toast('密码修改成功,请牢记!');
|
||||
$('input[name=opwd]').val('');
|
||||
$('input[name=npwd]').val('');
|
||||
$('input[name=npwd2]').val('');
|
||||
setTimeout(function() {
|
||||
$.closeModal();
|
||||
}, 2000);
|
||||
}else{
|
||||
|
||||
$.toast(r.info);
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
|
||||
//
|
||||
$('.close').click(function(){
|
||||
|
||||
$.get(url+'/Login/close',function(r){
|
||||
|
||||
location.href= url+'Index/login';
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
||||
// 发布文章
|
||||
$(document).on("pageInit", "#page-wzadd", function(e, pageId, $page) {
|
||||
colseimg();
|
||||
var on=Get('on');
|
||||
item=false;
|
||||
var winwidth=$(document).width();
|
||||
$('.fixedDiv').css({width:winwidth+"px",marginLeft:-winwidth/2+"px"});
|
||||
file();
|
||||
/* 文章设置 */
|
||||
$('#wzadd').click(function(){
|
||||
$.popup('.popup-set');
|
||||
})
|
||||
/* 直接插入文字 */
|
||||
$('#addword').click(function(){
|
||||
|
||||
word(1);
|
||||
})
|
||||
/* 插入文字面板 */
|
||||
$('.tinsert_hl ul li').click(function(){
|
||||
|
||||
var pid=$(this).attr('pid');
|
||||
textsub(parseInt(pid));
|
||||
})
|
||||
/* 插入文字面板清空 */
|
||||
$('.text_reset').click(function(){
|
||||
textsub(0);
|
||||
})
|
||||
// 取消插入或者修改文字
|
||||
$('.boxNo').click(function(){
|
||||
var pid=$(this).attr('pid');
|
||||
hidebox(pid);
|
||||
})
|
||||
//提交插入或者修改文字
|
||||
$('.boxYes').click(function(){
|
||||
instrd(parseInt($(this).attr('pid')))
|
||||
})
|
||||
// 颜色 背景颜色 字体大小
|
||||
$('.bgcolor ul li,.color ul li,.check_size ul li').click(function(){
|
||||
textstyle(parseInt($(this).parent('ul').attr('pid')),$(this));
|
||||
})
|
||||
|
||||
|
||||
//清空
|
||||
$('.text_tit_r').click(function(){
|
||||
|
||||
var i=$(this).attr('pid');
|
||||
|
||||
if(i==1){
|
||||
$('.text_word').css('color','');
|
||||
$('.text_color').hide();
|
||||
}else{
|
||||
|
||||
$('.text_word').css('background','');
|
||||
$('.text_bgcolor').hide();
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
$('#addimg').click(function(){
|
||||
$('.text_img').show();
|
||||
$('.mask').show();
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
$('#wzcon').on("click",'a,span,div,em,p,img,section,fieldset,table,td,tr',function(){
|
||||
if(item){
|
||||
return false;
|
||||
}
|
||||
item=$(this);
|
||||
//调操作面板
|
||||
showpanel();
|
||||
var a1=item.height()+item.position().top+$('.tedit_tool').height()+$('nav').height()+10;
|
||||
var a2=$(window).height()-$('header').height();
|
||||
var a3=$('#wzcon').position().top;
|
||||
if(a1>a2){
|
||||
$('.content').scrollTop(-(a3-(a1-a2)));
|
||||
}
|
||||
|
||||
return false;
|
||||
})//*****点击处理 end!
|
||||
$('#wzcon').on('click','.t_link',function(){
|
||||
var pid=$(this).attr('pid');
|
||||
panelclick(pid);
|
||||
|
||||
})
|
||||
//
|
||||
$('#wxstyle').click(function(){
|
||||
if(($('#wxcon').html()=='')){
|
||||
$.get("/ajax/modelstyle",function(data){
|
||||
var str='';
|
||||
if(data.code==1){
|
||||
$('#wxcon').html(data.msg);
|
||||
}
|
||||
});
|
||||
};
|
||||
$.popup('.popup-style');
|
||||
});
|
||||
//
|
||||
//
|
||||
$('#wxcon').on("click",'.card',function(){
|
||||
var str=$(this).children().children('.card-content-inner').html();
|
||||
$('#wzcon').append(str);
|
||||
$.closeModal();
|
||||
})
|
||||
//
|
||||
|
||||
$('#addvideo').click(function(){
|
||||
$('.text_video').show();
|
||||
$('.mask').show();
|
||||
})
|
||||
//
|
||||
var addbtn=false;
|
||||
$('#fbtext').click(function(){
|
||||
var content=$('#wzcon').html();
|
||||
var title=$('input[name=title]').val();
|
||||
var jianjie=$('.jianjie').val();
|
||||
var imgsrc=$('.lstimg img').attr('pid');
|
||||
var imgthumb=$('.lstimg img').attr('src');
|
||||
if(content.length<255){
|
||||
$.toast('您未填写内容,或者内容不足一篇文章');
|
||||
return false;
|
||||
}
|
||||
// if(title==''||jianjie==''){
|
||||
if(1){
|
||||
addbtn=true;
|
||||
$.toast('请先设置文章信息');
|
||||
setTimeout(function(){
|
||||
$.popup('.popup-set');
|
||||
},1600)
|
||||
}else{
|
||||
addwz(title,jianjie,imgsrc,imgthumb,content);
|
||||
}
|
||||
})
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
//上传略缩图
|
||||
//
|
||||
$('.lstbox').click(function(){
|
||||
$('.text_img').show();
|
||||
$('.mask').show();
|
||||
thumb=true;
|
||||
})
|
||||
//
|
||||
//
|
||||
//
|
||||
$('#addbtn').click(function(){
|
||||
var title=$('input[name=title]').val();
|
||||
var jianjie=$('.jianjie').val();
|
||||
var imgsrc=$('.lstimg img').attr('pid');
|
||||
var imgthumb=$('.lstimg img').attr('src');
|
||||
if(title==''){
|
||||
$.toast('文章标题不能为空');
|
||||
return false;
|
||||
}
|
||||
if(jianjie==''){
|
||||
$.toast('文章简介不能为空');
|
||||
return false;
|
||||
}
|
||||
// if(imgsrc==undefined){
|
||||
// $.toast('文章略缩图不能为空');
|
||||
// return false;
|
||||
// }
|
||||
if(addbtn){
|
||||
addwz(title,jianjie,imgsrc,imgthumb,$('#wzcon').html());
|
||||
$.showPreloader('正在发布,请稍后...')
|
||||
}else{
|
||||
$.closeModal();
|
||||
}
|
||||
|
||||
})
|
||||
//
|
||||
function addwz(a,b,c,d,e){
|
||||
var editid=$("#editid").val();
|
||||
var url='/Article/edit';
|
||||
if(editid=="0"){
|
||||
url='/Article/add';
|
||||
}
|
||||
$.post(url,{title:a,description:b,storage_id:c,thumb:d,content:e,id:editid},function(r){
|
||||
$.hidePreloader();
|
||||
if(r['code']==1){
|
||||
$.closeModal();
|
||||
$.alert('发布成功',function(){
|
||||
location.href=r['url'];
|
||||
})
|
||||
}else{
|
||||
$.toast(r['msg']);
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
$.init();
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user