$(document).ready(function(){ var ctx = $("#ctx").val();//获取服务器地址 /*************************** 广告位列表页 ***************************/ //获取尺寸 if($("#size").val() == 0 || $("#size").val() == ""){ $("#selectBar_size a:first").addClass("selectBar_change"); } $("#selectBar_size a").each(function(){ var value = $(this).attr("value"); if($("#size").val() == value){ $(this).addClass("selectBar_change").siblings('.selectBar_change').removeClass('selectBar_change'); } }); $("#selectBar_size a").click(function(){ $("#size").val($(this).attr("value")); if($(this).attr("value") != ""){ var _size = $(this).attr("value").split('X',2); $("#width").val(_size[0]); $("#height").val(_size[1]); }else{ $("#width").val(""); $("#height").val(""); } refreshData(); }); //类型 if($("#device").val() == -1 || $("#device").val() == ""){ $("#selectBar_type a:first").addClass("selectBar_change"); } $("#selectBar_type a").each(function(){ var value = $(this).attr("value"); if($("#device").val() == value){ $(this).addClass("selectBar_change").siblings('.selectBar_change').removeClass('selectBar_change'); } }); $("#selectBar_type a").click(function(){ $("#device").val($(this).attr("value")); refreshData(); }); //获取创意尺寸 if($("#position").val() == -1 || $("#position").val() == ""){ $("#selectBar_position a:first").addClass("selectBar_change"); } $("#selectBar_position a").each(function(){ var value = $(this).attr("value"); if($("#position").val() == value){ $(this).addClass("selectBar_change").siblings('.selectBar_change').removeClass('selectBar_change'); } }); $("#selectBar_position a").click(function(){ $("#position").val($(this).attr("value")); refreshData(); }); //状态全部、开启、停用 if($("#status").val() == -1 || $("#status").val() == ""){ $("#selectBar_status a:first").addClass("selectBar_change"); } $("#selectBar_status a").each(function(){ var value = $(this).attr("value"); if($("#status").val() == value){ $(this).addClass("selectBar_change").siblings('.selectBar_change').removeClass('selectBar_change'); } }); $("#selectBar_status a").click(function(){ $("#status").val($(this).attr("value")); refreshData(); }); //开启,暂停 $("#btn-enable,#btn-disable,#btn-delete").click(function(){ if($(this).attr("id") == "btn-enable"){ url = ctx+"/operator/main/ad/zone/enable"; }else if($(this).attr("id") == "btn-disable"){ url = ctx+"/operator/main/ad/zone/disable"; }else if($(this).attr("id") == "btn-delete"){ url = ctx+"/operator/main/ad/zone/delete"; } singleOper($(this),url); }); //批量开启,批量暂停 $("#all-btn-enable,#all-btn-disable,#all-btn-delete").click(function(){ if($(this).attr("id") == "all-btn-enable"){ url = ctx+"/operator/main/ad/zone/enable"; }else if($(this).attr("id") == "all-btn-disable"){ url = ctx+"/operator/main/ad/zone/disable"; }else if($(this).attr("id") == "all-btn-delete"){ url = ctx+"/operator/main/ad/zone/delete"; } batchOpear($(this),url); }); //取代码 $("#btn-getcode,#btn-getcode2").click(function(){ alert(1); var zoneId = $(this).attr("value"); var url = ctx+"/operator/main/ad/zone/getCode?zoneId="+zoneId; $.getJSON(url, function(data) { var data_1 = data; $('.bootbox-body').text(data_1); }); bootbox.dialog({ message:"代码为:", title: "该广告位的代码", locale: 'zh_CN', buttons: { success: { label: "复制", className: "btn-success", callback: function() { var _content = $('.bootbox-body').text(); } }, main: { label: "关闭", className: "btn-primary", callback: function() { } } } }); //以下代码实现复制功能,利用ZeroClipboard插件实现 var client = new ZeroClipboard($('.modal-footer .btn-success')); client.on('ready', function(event) { // console.log( 'movie is loaded' ); client.on('copy', function(event) { event.clipboardData.setData('text/plain', $('.bootbox-body').text()); }); client.on('aftercopy', function(event) { console.log('Copied text to clipboard: ' + event.data['text/plain']); }); }); client.on('error', function(event) { // console.log( 'ZeroClipboard error of type "' + event.name + '": ' + event.message ); ZeroClipboard.destroy(); }); }); //取代码 $("#btn-getcode3,#btn-getcode4").click(function(){ alert(1); var zoneId = $(this).attr("value"); var url = ctx+"/operator/main/ad/zone/getCodeStatistics?zoneId="+zoneId; $.getJSON(url, function(data) { var data_1 = data; $('.bootbox-body').text(data_1); }); bootbox.dialog({ message:"代码为:", title: "该广告位的代码", locale: 'zh_CN', buttons: { success: { label: "复制", className: "btn-success", callback: function() { var _content = $('.bootbox-body').text(); } }, main: { label: "关闭", className: "btn-primary", callback: function() { } } } }); //以下代码实现复制功能,利用ZeroClipboard插件实现 var client = new ZeroClipboard($('.modal-footer .btn-success')); client.on('ready', function(event) { // console.log( 'movie is loaded' ); client.on('copy', function(event) { event.clipboardData.setData('text/plain', $('.bootbox-body').text()); }); client.on('aftercopy', function(event) { console.log('Copied text to clipboard: ' + event.data['text/plain']); }); }); client.on('error', function(event) { // console.log( 'ZeroClipboard error of type "' + event.name + '": ' + event.message ); ZeroClipboard.destroy(); }); }); /*************************** 创建,编辑广告主 ***************************/ //初始化加载上传控件 if($("#filepicture_picture").html()){ if($("#uploadfilehidden").val() !=""){ $("#imgDivs").css("display","block"); }else{ $("#imgDivs").css("display","none"); } initFile($("#uploadfile"),$("#pictureName").val()); $('#uploadfilestr').unbind('click').click(function() { getUploadFile(); }); } //选中右移 $("#all_industry li").live("click",function() { var mychoice = this.innerHTML; $(this).remove(); var ul = document.getElementById("blacklist"); $(ul).append("
  • " + mychoice + "
  • "); //将黑名单数据传入后端,格式“***,***,***” if($("#industry_blacklist").val() == ""){ $("#industry_blacklist").val($(this).attr("value")); }else{ $("#industry_blacklist").val($("#industry_blacklist").val()+","+$(this).attr("value")); } }); //选中左移 $('#blacklist li input.movedel').live("click",function() { var mychoice = $(this).parents("li").text(); var mychoicevalue = $(this).parents("li").attr("value"); $(this).parents("li").remove(); var ul = document.getElementById("all_industry"); $(ul).append("
  • " + mychoice + "
  • "); //左移黑名单删除传值 var industryArr = $("#industry_blacklist").val().split(","); for(var i=0;i" + mychoice + ""); if($("#industry_blacklist").val() == ""){ $("#industry_blacklist").val(mychoicevalue); }else{ $("#industry_blacklist").val($("#industry_blacklist").val()+","+mychoicevalue); } } //传值同步添加全部 // document.getElementById("industry_blacklist").value = industry_blackname; }); //清空全部 $('#clear_all').live("click",function() { var lis = $('#blacklist li'); var len = lis.length; var ul = document.getElementById("all_industry"); for(var i=0; i" + mychoice +""); } $("#industry_blacklist").val(""); //传值同步清空 // document.getElementById("industry_blacklist").value =""; }); //网站添加黑名单 var web_blackname = ""; var glo_web_blacklist = $('#web_blacklist li'); for(var counts=0;counts" + blackname + ""); $('#blackname').val(""); //黑名单传值 if($("#web_blacklistvalue").val() == ""){ $("#web_blacklistvalue").val(blackname); }else{ $("#web_blacklistvalue").val($("#web_blacklistvalue").val()+","+blackname); } }); //删除黑名单 $('#web_blacklist li input.movedel').live("click",function() { $(this).parents("li").remove(); var mychoice = $(this).parents("li").text(); var blacknameArr = $("#web_blacklistvalue").val().split(","); for(var i=0;i'); $("#enlarge_images").css("top",document.body.scrollTop + event.clientY - 300 + "px"); $("#enlarge_images").css("left",document.body.scrollLeft + event.clientX - 660 + "px"); }); $("#son_imgDiv").mouseout(function(event){ $("#enlarge_images").html(""); $("#enlarge_images").css("display","none"); }); }); function exportExcel_list(){ var searchValue = $("#searchValue").val(); if(searchValue == "请输入关键字"){ searchValue = ""; } var param = "?width="+$("#width").val()+"&height="+$("#height").val()+"&device="+$("#device").val()+"&position="+$("#position").val()+"&status="+$("#status").val()+"&searchValue="+searchValue; $("#exportExcel").attr("href",$("#ctx").val()+"/operator/main/ad/zone/exportDataReportExcel"+param); return false; } //初始化选择文件框 function initFile(obj,pictureName){ var name = ""; if(pictureName == "" || pictureName == null || pictureName == "noFiles"){ name = "No File ..."; }else{ name = pictureName.substring(pictureName.lastIndexOf("\\")+1,pictureName.length); } obj.ace_file_input({ no_file:name, btn_choose:'选择', btn_change:'改变', droppable:false, onchange:null, thumbnail:false }); } //文件上传ajax文件上传 function getUploadFile(){ var _href = $("#uploadfilestr").attr('href'); $.ajaxFileUpload({ url:_href, secureuri:false, fileElementId:"uploadfile", dataType: 'json', success: function (result, status) { var path = result.data['url']; removeFile("uploadfile","filepicture_picture","uploadfilehidden",result); if (result.status == 'ok') { var orgImg = path.substring(0,path.indexOf(",")); var smallImg = path.substring(path.indexOf(",")+1); $("#uploadfilehidden").val(orgImg); $("#smallImg").attr("src",smallImg); $("#default_path_small").val(smallImg); $("#imgDivs").css("display","block"); var result = 0; removeFile("uploadfile","filepicture_picture","uploadfilehidden",result); bootbox.alert("上传成功!"); }else if (result.status == 'error') { $("#uploadfilehidden").val(""); $("#smallImg").attr("src",""); $("#default_path_small").val(""); $("#imgDivs").css("display","none"); bootbox.alert(result.msg); } }, error: function (data, status, e) { $("#uploadfilehidden").val(""); $("#smallImg").attr("src",""); $("#default_path_small").val(""); $("#imgDivs").css("display","none"); removeFile("uploadfile","filepicture_picture","uploadfilehidden"); console.log(e); } }); return false; } //上传文件时conle file 删除 file function removeFile(_elemId,_removeId,picPathId,result){ var filename = $('#'+_elemId).parent().find("span").attr("data-title"); var isChrome = navigator.userAgent.toLowerCase().match(/chrome/) != null;//判断是否是谷歌浏览器 if(filename==null || filename==''){ filename = "No File ..."; } var option = {}; var defaultOptions = { no_file:'No File ...', btn_choose:'选择', btn_change:'改变', droppable:false, onchange:null, thumbnail:false }; if(isChrome && result == 0){ option = {no_file:filename }; }else if(isChrome && result == 1){ option = {no_file:'No File ...' }; }else{ option = {no_file:filename }; } var opts = $.extend(defaultOptions,option); var newfile = $("#"+_elemId).clone(); $("#"+_removeId).find(".ace-file-input").remove(); $("#"+_removeId+" #"+picPathId).after(newfile); $("#"+_elemId).ace_file_input(opts); }