|
|
/// <reference path="../Scripts/MicrosoftAjax.js" />
|
|
|
/// <reference path="../Scripts/jquery.min.js" />
|
|
|
/// <reference path="jquery.easyui.min.js" />
|
|
|
|
|
|
|
|
|
|
|
|
TextBoxEdit = function () {
|
|
|
|
|
|
this.ControlID = "div_edit";
|
|
|
this.ControlID1 = "div_img";
|
|
|
this.ControlID2 = "div_video";
|
|
|
this.WebControl = "div_webhtml";
|
|
|
this.DelButton = false;
|
|
|
var My = this;
|
|
|
var obj = null;
|
|
|
var obj1 = null;
|
|
|
var obj2 = null;
|
|
|
this.ParentElement = null; //要加入的父容器
|
|
|
var textareaclass = "tea_content";
|
|
|
var Host = "";
|
|
|
//#region 加载
|
|
|
this.Load = function () {
|
|
|
Init();
|
|
|
GetWebHtmlUrl();
|
|
|
$("#" + My.ControlID).hide();
|
|
|
$("#" + My.ControlID1).hide();
|
|
|
$("#" + My.ControlID2).hide();
|
|
|
// $(document.body).click(function() {
|
|
|
|
|
|
|
|
|
// });
|
|
|
$('div[name="imgdiv"]').live("click", function () {
|
|
|
obj1 = $(this);
|
|
|
$("#" + My.ControlID).hide();
|
|
|
$("#" + My.ControlID2).hide();
|
|
|
$("#" + My.ControlID1).show();
|
|
|
var position = $(this).offset();
|
|
|
var top = position.top - 25;
|
|
|
var left = position.left;
|
|
|
$("#" + My.ControlID1).css("top", top).css("left", left);
|
|
|
});
|
|
|
|
|
|
|
|
|
$('div[name="Videodiv"]').live("click", function () {
|
|
|
obj2 = $(this);
|
|
|
$("#" + My.ControlID).hide();
|
|
|
$("#" + My.ControlID1).hide();
|
|
|
$("#" + My.ControlID2).show();
|
|
|
var position = $(this).offset();
|
|
|
var top = position.top - 50;
|
|
|
var left = position.left;
|
|
|
$("#" + My.ControlID2).css("top", top).css("left", left);
|
|
|
|
|
|
});
|
|
|
|
|
|
setuplod();
|
|
|
$("#fileUpload1").bind("change", function () {
|
|
|
ajaxFileUpload_fileToUploadImagenew();
|
|
|
});
|
|
|
|
|
|
$(".a_del2").bind("click", function () {
|
|
|
|
|
|
if (obj == null) return;
|
|
|
obj.parent("div").remove();
|
|
|
$("#" + My.ControlID).hide();
|
|
|
|
|
|
});
|
|
|
|
|
|
$(".a_del1").bind("click", function () {
|
|
|
|
|
|
if (obj1 == null) return;
|
|
|
obj1.remove();
|
|
|
$("#" + My.ControlID1).hide();
|
|
|
});
|
|
|
$(".a_del3").bind("click", function () {
|
|
|
|
|
|
if (obj2 == null) return;
|
|
|
obj2.remove();
|
|
|
$("#" + My.ControlID2).hide();
|
|
|
|
|
|
});
|
|
|
$(".a_delimg").bind("click", function () {
|
|
|
|
|
|
if (obj1 == null) return;
|
|
|
obj1.children(".divimg").attr("src", "../image/uploadimg.gif");
|
|
|
|
|
|
|
|
|
});
|
|
|
$(".a_delvideo").bind("click", function () {
|
|
|
obj2 = $('div[name="Videodiv"]');
|
|
|
if (obj2 == null) return;
|
|
|
obj2.html("<div id='VideoID' style='width:100%;height:100%'> <img src='bp/bp_ClassInfo/spsc.jpg' class='divimg' style='width:100%;height:100%'/></div>");
|
|
|
removeFLV('VideoID');
|
|
|
});
|
|
|
$("." + textareaclass).live("click", function () {
|
|
|
obj = $(this);
|
|
|
$("#" + My.ControlID1).hide();
|
|
|
$("#" + My.ControlID2).hide();
|
|
|
$("#" + My.ControlID).show();
|
|
|
var position = $(this).offset();
|
|
|
var top = position.top - 25;
|
|
|
var left = position.left;
|
|
|
if ($(this).css("color") != null && $(this).css("color") != "") {
|
|
|
$(".fontcolor").val($(this).css("color"));
|
|
|
}
|
|
|
else
|
|
|
$(".fontcolor").val("0");
|
|
|
|
|
|
if ($(this).css("font-size") != null && $(this).css("font-size") != "") {
|
|
|
$(".fontsize").val($(this).css("font-size"));
|
|
|
}
|
|
|
else
|
|
|
$(".fontsize").val("0");
|
|
|
|
|
|
|
|
|
if ($(this).css("font-family") != null && $(this).css("font-family") != "") {
|
|
|
$(".fontstyle").val($(this).css("font-family"));
|
|
|
}
|
|
|
else
|
|
|
$(".fontstyle").val("0");
|
|
|
|
|
|
$("#" + My.ControlID).css("top", top).css("left", left);
|
|
|
});
|
|
|
|
|
|
$(".fontsize").live("change", function () {
|
|
|
if (obj == null) return;
|
|
|
if ($(this).val() == 0) {
|
|
|
obj.css("font-size", "");
|
|
|
}
|
|
|
else {
|
|
|
obj.css("font-size", $(this).val());
|
|
|
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
$(".fontcolor").live("change", function () {
|
|
|
if (obj == null) return;
|
|
|
if ($(this).val() == 0) {
|
|
|
obj.css("color", "");
|
|
|
}
|
|
|
else {
|
|
|
obj.css("color", $(this).val());
|
|
|
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$(".a_fontstyle").live("click", function () {
|
|
|
if (obj == null) return;
|
|
|
if (obj.css("font-style") == "italic") {
|
|
|
obj.css("font-style", "");
|
|
|
}
|
|
|
else {
|
|
|
obj.css("font-style", "italic");
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
$(".a_underline").live("click", function () {
|
|
|
if (obj == null) return;
|
|
|
if (obj.css("text-decoration") == "underline") {
|
|
|
obj.css("text-decoration", "");
|
|
|
}
|
|
|
else {
|
|
|
obj.css("text-decoration", "underline");
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
$(".fontstyle").live("change", function () {
|
|
|
if (obj == null) return;
|
|
|
if ($(this).val() == 0) {
|
|
|
obj.css("font-family", "");
|
|
|
}
|
|
|
else {
|
|
|
obj.css("font-family", $(this).val());
|
|
|
|
|
|
}
|
|
|
});
|
|
|
$(".a_fontweight").live("click", function () {
|
|
|
if (obj == null) return;
|
|
|
if (obj.css("font-weight") == "Bold" || obj.css("font-weight") == "700") {
|
|
|
obj.css("font-weight", "normal");
|
|
|
}
|
|
|
else {
|
|
|
obj.css("font-weight", "Bold");
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
$(".a_align").live("click", function () {
|
|
|
if (obj == null) return;
|
|
|
if (obj.css("text-align") == "center") {
|
|
|
obj.css("text-align", "left");
|
|
|
}
|
|
|
else {
|
|
|
obj.css("text-align", "center");
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
function setuplod() {
|
|
|
//#region 上传视频
|
|
|
$('#fuContainer').uploadify({
|
|
|
langFile: "../Scripts/uploadify-lang-zh_CN.js",
|
|
|
swf: '../Scripts/uploadify.swf',
|
|
|
uploader: '../GlobalAshx/AjaxFileUpLoad.ashx?BoxName=BanPai/Bp&DirectoryName=bp_ClassInfo&ItemNo=11',
|
|
|
checkExisting: '../GlobalAshx/UploadifyCheck.ashx',
|
|
|
cancelImage: '../themes/default/images/tabs_close.gif',
|
|
|
buttonText: '选择视频',
|
|
|
method: 'post',
|
|
|
requeueErrors: true,
|
|
|
auto: true,
|
|
|
multi: false, //是否允许多文件上传
|
|
|
sizeLimit: 200000000, //控制上传文件的大小,单位byte
|
|
|
fileTypeDesc: '*.flv',
|
|
|
fileTypeExts: '*.flv',
|
|
|
height: 40, //浏览按钮高
|
|
|
uploadLimit: 999, //同时上传多小个文件
|
|
|
queueSizeLimit: 999, //队列允许的文件总数
|
|
|
successTimeout: 999,
|
|
|
removeCompleted: true, //当上传成功后是否将该Item删除
|
|
|
// 'scriptData': {'name':'ssd','id':'123'},
|
|
|
// 'folder':'1',
|
|
|
onUploadSuccess: function (event, response, status) {
|
|
|
if (response == "") return;
|
|
|
var Shtm = new Sys.StringBuilder();
|
|
|
var DataModel = Sys.Serialization.JavaScriptSerializer.deserialize(response);
|
|
|
if (obj2 == null) return;
|
|
|
|
|
|
//ModelImg.Id = data.Id;
|
|
|
//setvideo('bp/bp_ClassInfo/' + DataModel.FileName);
|
|
|
|
|
|
// $('#' + My.ControlID2).hide();
|
|
|
videoplay('bp/bp_ClassInfo/' + DataModel.FileName);
|
|
|
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
function videoplay(VideoUrl) {
|
|
|
|
|
|
var vodwidth = parseInt(obj2.css('width'));
|
|
|
|
|
|
var vodheight = parseInt(obj2.css('height'));
|
|
|
// var Host = $("#" + My.WebControl).html();
|
|
|
webvideoplay(Host, '/banpai/' + VideoUrl, vodwidth, vodheight, 'false', 'VideoID');
|
|
|
}
|
|
|
|
|
|
function GetWebHtmlUrl() {
|
|
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
url: "../banpai/BanPaiService.asmx/GetWebHtmlUrl",
|
|
|
// data: Sys.Serialization.JavaScriptSerializer.serialize(param),
|
|
|
dataType: "json",
|
|
|
async: false,
|
|
|
success: function (data) {
|
|
|
|
|
|
|
|
|
if (data.d != null) {
|
|
|
Host = data.d;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
function setvideo(url) {
|
|
|
var vodwidth = parseInt(obj2.css('width'));
|
|
|
|
|
|
var vodheight = parseInt(obj2.css('height'));
|
|
|
|
|
|
// var htmlstr = '<object id='videoobj' width='100%' height='100%' classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95'><param name='filename' value='' + url + '' /><param name='AutoStart' value='true'> <param name='LOOP' value='true' /><embed width='700' height='299' type='application/x-mplayer2' src='' + url + ''></embed></object>';
|
|
|
//var htmlstr = '<div id='VideoID'></div>';
|
|
|
// htmlstr = "<embed name='single' width='" + vodwidth + "' height='" + vodheight + "' id='single' src='flvplayer.swf' type='application/x-shockwave-flash' flashvars='file=" + url + "&image=preview.jpg&width=" + vodwidth + "&height=" + vodheight + "' allowfullscreen='true' quality='high' /><div vodurl='" + url + "' style='display:none'></div>";
|
|
|
// var htmlstr = "<div id='VideoID' width='" + vodwidth + "' height='" + vodheight + "'></div>";
|
|
|
obj2.html(htmlstr);
|
|
|
|
|
|
//$('#videoobj').show();
|
|
|
|
|
|
//document.videoobj.filename = url;
|
|
|
// document.getElementsByClassName('videoobj').filename = url;
|
|
|
// $('div[name='Videodiv'] img').hide();
|
|
|
// obj2.html(htmlstr);
|
|
|
// setuplod();
|
|
|
}
|
|
|
//#region 检测文件是否是图片类型
|
|
|
function IsImage(filename) {
|
|
|
var extStart = filename.lastIndexOf(".");
|
|
|
var ext = filename.substring(extStart, filename.length).toUpperCase();
|
|
|
if (ext != ".BMP" && ext != ".PNG" && ext != ".GIF" && ext != ".JPG" && ext != ".JPEG") {
|
|
|
return false;
|
|
|
} else {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
//#region 上传图片
|
|
|
function ajaxFileUpload_fileToUploadImagenew() {
|
|
|
var filename = $("#fileUpload1").val();
|
|
|
if (filename == "" || filename == undefined) return;
|
|
|
if (IsImage(filename) == false) { alert("上传文件格式只限于bmp,png,gif,jpeg,jpg格式"); return; }
|
|
|
var fileToUploadid1 = 'fileUpload1';
|
|
|
WindowLoadModel.Show();
|
|
|
$.ajaxFileUpload({
|
|
|
url: '../GlobalAshx/AjaxFileUpLoad.ashx?BoxName=BanPai/Bp&DirectoryName=bp_ClassInfo&ItemNo=11',
|
|
|
secureuri: false,
|
|
|
fileElementId: fileToUploadid1,
|
|
|
dataType: 'json',
|
|
|
success: function (data, status) {
|
|
|
// WindowLoadModel.Hide();
|
|
|
|
|
|
var Imgurl = "bp/bp_ClassInfo/" + data.FileName;
|
|
|
if (obj1 == null) return;
|
|
|
|
|
|
//ModelImg.Id = data.Id;
|
|
|
obj1.children(".divimg").attr("src", Imgurl);
|
|
|
|
|
|
$("#fileUpload1").bind("change", function () {
|
|
|
ajaxFileUpload_fileToUploadImagenew();
|
|
|
});
|
|
|
WindowLoadModel.Hide();
|
|
|
},
|
|
|
error: function (data, status, e) {
|
|
|
alert(e);
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
//#endregion
|
|
|
//#region 初始化
|
|
|
function Init() {
|
|
|
if (My.ParentElement == null) My.ParentElement = $(document.body);
|
|
|
if ($("#" + My.ControlID, My.ParentElement).length > 0) return;
|
|
|
var Shtm = new Sys.StringBuilder();
|
|
|
Shtm.append("<div id='" + My.ControlID + "' style='position: absolute;'><select class='fontstyle' style='width:80px'");
|
|
|
Shtm.append("<option value='0'>字体</option>");
|
|
|
Shtm.append("<option value='宋体'>宋体</option>");
|
|
|
Shtm.append("<option value='仿宋'>仿宋</option>");
|
|
|
Shtm.append("<option value='黑体'>黑体</option>");
|
|
|
Shtm.append("<option value='幼圆'>幼圆</option>");
|
|
|
Shtm.append("<option value='楷体'>楷体</option>");
|
|
|
Shtm.append("<option value='隶书'>隶书</option>");
|
|
|
Shtm.append("</select>");
|
|
|
Shtm.append("<select class='fontsize' style='width:50px'>");
|
|
|
Shtm.append("<option value='0'>大小</option>");
|
|
|
Shtm.append("<option value='7px'>7px</option>");
|
|
|
Shtm.append("<option value='8px'>8px</option>");
|
|
|
Shtm.append("<option value='9px'>9px</option>");
|
|
|
Shtm.append("<option value='10px'>10px</option>");
|
|
|
Shtm.append("<option value='11px'>11px</option>");
|
|
|
Shtm.append("<option value='12px'>12px</option>");
|
|
|
Shtm.append("<option value='13px'>13px</option>");
|
|
|
Shtm.append("<option value='14px'>14px</option>");
|
|
|
Shtm.append("<option value='15px'>15px</option>");
|
|
|
Shtm.append("<option value='16px'>16px</option>");
|
|
|
Shtm.append("<option value='17px'>17px</option>");
|
|
|
Shtm.append("<option value='18px'>18px</option>");
|
|
|
Shtm.append("<option value='19px'>19px</option>");
|
|
|
Shtm.append("<option value='20px'>20px</option>");
|
|
|
Shtm.append("<option value='21px'>21px</option>");
|
|
|
Shtm.append("<option value='22px'>22px</option>");
|
|
|
Shtm.append("<option value='23px'>23px</option>");
|
|
|
Shtm.append("<option value='24px'>24px</option>");
|
|
|
Shtm.append("<option value='25px'>25px</option>");
|
|
|
Shtm.append("<option value='26px'>26px</option>");
|
|
|
Shtm.append("<option value='27px'>27px</option>");
|
|
|
Shtm.append("<option value='28px'>28px</option>");
|
|
|
Shtm.append("<option value='29px'>29px</option>");
|
|
|
Shtm.append("<option value='30px'>30px</option>");
|
|
|
Shtm.append("<option value='31px'>31px</option>");
|
|
|
Shtm.append("<option value='32px'>32px</option>");
|
|
|
Shtm.append("<option value='33px'>33px</option>");
|
|
|
Shtm.append("<option value='34px'>34px</option>");
|
|
|
Shtm.append("<option value='35px'>35px</option>");
|
|
|
Shtm.append("</select>");
|
|
|
Shtm.append("<select class='fontcolor' style='left:100px;width:60px'>");
|
|
|
Shtm.append("<option value='#000000'>颜色</option>");
|
|
|
Shtm.append("<option value='Black'>黑</option>");
|
|
|
Shtm.append("<option value='White'>白</option>");
|
|
|
Shtm.append("<option value='Red'>红</option>");
|
|
|
Shtm.append("<option value='Blue'>蓝</option>");
|
|
|
Shtm.append("<option value='Yellow'>黄</option>");
|
|
|
Shtm.append("<option value='Green'>绿</option>");
|
|
|
Shtm.append("</select>");
|
|
|
Shtm.append("<a class='a_fontweight' style='cursor:pointer' title='加粗'><img src='../image/qj3.gif' /></a> <a class='a_fontstyle' style='cursor:pointer' title='斜体'><img src='../image/qj4.gif' /></a> <a class='a_underline' style='cursor:pointer' title='下划线'><img src='../image/qj5.gif' /></a> <a class='a_align' style='cursor:pointer' title='居中'><img src='../image/qj6.gif' /></a>");
|
|
|
if (My.DelButton == true)
|
|
|
Shtm.append("<a class='a_del2' style='color:Blue;text-decoration:underline;cursor:pointer'>移除</a>");
|
|
|
Shtm.append("</div>");
|
|
|
Shtm.append("<div id='" + My.ControlID1 + "' style='position: absolute;'><input id='fileUpload1' class='fileUpload' name='fileToUpload1' type='file' /><a class='a_delimg' style='color:Blue;text-decoration:underline;cursor:pointer'>清除图片</a> ");
|
|
|
if (My.DelButton == true)
|
|
|
Shtm.append("<a class='a_del1' style='color:Blue;text-decoration:underline;cursor:pointer'>移除编辑器</a>");
|
|
|
Shtm.append("</div>");
|
|
|
Shtm.append("<div id='" + My.ControlID2 + "' style='position: absolute;'> <input id='fuContainer' type='file' value='选择' /><font color='red'>注:仅限flv格式</font><a class='a_delvideo' style='color:Blue;text-decoration:underline;cursor:pointer'>清除视频</a> ");
|
|
|
if (My.DelButton == true)
|
|
|
Shtm.append("<a class='a_del3' style='color:Blue;text-decoration:underline;cursor:pointer'>移除编辑器</a>");
|
|
|
Shtm.append("</div>");
|
|
|
My.ParentElement.append(Shtm.toString());
|
|
|
|
|
|
}
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|