$(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("