// 禁止复制 function iesc(){ return false; } function irec(){ return true; } function diablecopy(){ document.ondragstart=iesc; document.oncontextmenu=iesc; if (typeof document.onselectstart !="undefined") document.onselectstart=iesc; else{ document.onmousedown=iesc; document.onmouseup=irec; } } /* 图片等比缩放 */ function scaleimg(){ $(".scalebox").each(function(){ $(this).find("img").jqthumb({ width: $(this).outerwidth(), height: $(this).outerheight(), after: function(imgobj){ imgobj.css('opacity', 1).animate({opacity: 1},1000); } }); }) } //去除内容区img标签的属性(防止图片因设置宽、高而变形) function clearimgstyle(){ $(".articlebox img").each(function() { $(this).removeattr("style"); $(this).removeattr("width"); $(this).removeattr("height"); $(this).parent().removeattr("style"); $(this).parent().css("padding-bottom","5px"); }); } /* 选项卡(带更多的) */ function tablist(tabtitle, tab_content, tabmore, event) { var hoverindex,hovertabhref,tablength=$(tabtitle).length; for(var i=0;itexth){ $(text).height(pich) }else{ $(pic).height(texth) } } /* 拆分div中的文本改变样式 */ function divcolor(divname, start, end) { $(divname).each(function() { var str1 = $(this).text().trim().replace(/\s/g, "").substring(0, start); var str2 = $(this).text().trim().replace(/\s/g, "").substring(start, end); var str3 = $(this).text().trim().replace(/\s/g, "").substring(end); var str = str1 + "" + str2 + "" + str3; $(this).html(str); }) } //单选按钮、多选按钮 function checkbox(divclass){ $(divclass).each(function(index, element) { var type=$(this).attr("rel") if(type=="radio"){ //单选 $(this).addclass("onchoice") } }); $(divclass).find("div.choicebox").click(function(){ var type=$(this).parents("dl").attr("rel") if(type=="radio"){ //单选 $(this).addclass("onchoice") $(this).find("em").addclass("selected") $(this).parent().siblings().find("em").removeclass("selected") }else{ //多选 var hassel=$(this).find("em").hasclass("selected") if(hassel){ $(this).find("em").removeclass("selected") $(this).siblings("div.writebox").find("input").val("") $(this).siblings("div.writebox").find("input").blur() }else{ $(this).find("em").addclass("selected") $(this).siblings("div.writebox").find("input").focus() } var datenum=$(this).parents("dl").attr("date-num") if(datenum){ var hassellength=$(this).parents("dl").find("em.selected").length if(hassellength<=datenum){ $(this).parents("dl").find("div.writebox input").blur() }else{ $(this).find("em").removeclass("selected") alert("不能超过"+datenum+"个") $(this).parents("dl").find("div.writebox input").blur() } } } }) //输入框焦点处理 $(divclass).each(function(index, element) { $(this).find("div.writebox input").focus(function(){ var datenum2=$(this).parents("dl").attr("date-num") if(datenum2){ $(this).parent().siblings("div.choicebox").find("em").addclass("selected") var hassel2=$(this).parents("dl").find("em.selected").length if(hassel2<=datenum2){ }else{ alert("不能超过"+datenum2+"个") $(this).blur() $(this).parent().siblings("div.choicebox").find("em").removeclass("selected") } }else{ $(this).parent().siblings("div.choicebox").find("em").addclass("selected") } }) $(this).find("div.writebox input").blur(function(){ var val=$(this).attr("value") $(this).parent().siblings("div.choicebox").find("input").attr("value",val) }) }); } $(function(){ checkbox(".questiondl") }) /* aos 同一行 元素延迟加载 */ function aosdelay(box,row,delaytime){ $(box).children().each(function(index){ for(var i = 0;i
" if($(".mvbox1").length<=0){ $("body").append(newbox) } var videourl = $(obj).data('url');//根据id得到值 var videopic = $(obj).data('img');//根据id得到值 var videoobject = { container: '.mvbox1', //视频容器 poster:videopic,//封面图片 autoplay:true, menu:[ { title:'aykj', link:'http://www.aykj.net' }, ], video:videourl//视频地址 }; var player=new ckplayer(videoobject)//调用播放器并赋值给变量player layer.open({ title: '', type: 1, skin:'aykj-videopop', area: ['755px', '425px'], //宽高 content: $(".mvbox1"), cancel: function(index, layero) { //$(".mvbox1").find("video")[0].pause() },end:function(){ $(".mvbox1").remove() } }); return false; } //此方法用于截取视频第一帧做为视频封面 function initialize(viderurl,obj) { var video, container; video= document.createelement("video") video.src=viderurl container = document.getelementbyid("container"); video.setattribute('crossorigin', 'anonymous') // 处理跨域 $(video).css({width:0,height:0,position:"fixed",left:0,top:0})//宽高用于隐藏视频,定位用于解决视频第一帧图片要在可视区域才会显示的问题 obj.appendchild(video) video.addeventlistener('loadeddata', function(){ settimeout(function(){ var canvas = document.createelement("canvas"); canvas.getcontext('2d').drawimage(video, 0, 0, canvas.width, canvas.height); $(obj).find(".pic img").attr("src",canvas.todataurl("image/png")) $(video).remove() },500) }); }; /* 导航效果 */ (function(e) { e.fn.menu = function(a) { var b = $.extend({}, { type: 0,//0--无滑块(默认);1--有滑块 defaultindex: 0, height: 5,//滑块高度 background: "red",//滑块背景色 bottom: 0,//滑块距离导航底部距离 animateease: "linear",//滑块的运动贝塞尔曲线 time: 500,//滑块的运动时间 zindex: -1, margin: 0,//滑块左右间距 average:false,//dd平均分开关 antcomplete: !0,//滑块动画完成后调函数(默认) startfun: null,//滑块进入后回调方法 endfun: null//滑块离开后回调方法 }, a); a = b.type; var c = b.height, d = b.background, f = b.bottom, g = b.animateease, n = b.time, w = b.zindex, v = b.margin, vpj = b.average, p = 0, q = 0, r = 0, t = 0, l = "", h = this; e(this); var m = parseint(b.defaultindex), x = b.antcomplete, current=null, u = function() { e.isfunction(b.startfun) && b.startfun(m,current) }, k = h.children(); switch (a) { case 1: h.parent().css({ position: "relative", "z-index": 9 }); h.parent().append(''); h.siblings(".menuicon").css({ height: c, bottom: f, "z-index": w }); h.siblings(".menuicon").find("div").css({ height: c, background: d, marginleft: v, marginright: v }); if(vpj){ k.width(($(this).width())/(k.length)) } k.each(function(a) { $(this).hasclass("hover") && (r = $(this).outerwidth(), t = $(this).position().left, l = $(this).index(), h.siblings(".menuicon").stop(!0, !1).animate({ width: r, left: t }, { duration: n, easing: g })); $(this).hover(function() { current=$(this) m = $(this).index(); p = $(this).outerwidth(); q = $(this).position().left; switch (x) { case !0: h.siblings(".menuicon").stop(!0, !1).animate({ width: p, left: q }, n, g, u); break; case !1: h.siblings(".menuicon").stop(!0, !1).animate({ width: p, left: q }, { duration: n, easing: g }), u() } $(this).addclass("hover").siblings().removeclass("hover") }, function() { e.isfunction(b.endfun) && b.endfun(m,current) }) }); k.hover(function() {}, function() { h.siblings(".menuicon").stop(!0, !1).animate({ width: r, left: t }, { duration: n, easing: g }); "" === l ? k.removeclass("hover") : k.eq(l).addclass("hover").siblings().removeclass("hover") }); break; case 0: k.each(function(a) { $(this).hasclass("hover") && (l = $(this).index()); $(this).hover(function() { current=$(this) m = $(this).index(); u(); $(this).addclass("hover").siblings().removeclass("hover") }, function() { e.isfunction(b.endfun) && b.endfun(m,current) }) }), k.hover(function() {}, function() { "" === l ? k.removeclass("hover") : k.eq(l).addclass("hover").siblings().removeclass("hover") }) } } })(jquery); jquery.easing.jswing = jquery.easing.swing, jquery.extend(jquery.easing, { def: "easeoutquad", swing: function(a, b, c, d, e) { return jquery.easing[jquery.easing.def](a, b, c, d, e) }, easeinquad: function(a, b, c, d, e) { return d * (b /= e) * b + c }, easeoutquad: function(a, b, c, d, e) { return - d * (b /= e) * (b - 2) + c }, easeinoutquad: function(a, b, c, d, e) { return 1 > (b /= e / 2) ? d / 2 * b * b + c: -d / 2 * (--b * (b - 2) - 1) + c }, easeincubic: function(a, b, c, d, e) { return d * (b /= e) * b * b + c }, easeoutcubic: function(a, b, c, d, e) { return d * ((b = b / e - 1) * b * b + 1) + c }, easeinoutcubic: function(a, b, c, d, e) { return 1 > (b /= e / 2) ? d / 2 * b * b * b + c: d / 2 * ((b -= 2) * b * b + 2) + c }, easeinquart: function(a, b, c, d, e) { return d * (b /= e) * b * b * b + c }, easeoutquart: function(a, b, c, d, e) { return - d * ((b = b / e - 1) * b * b * b - 1) + c }, easeinoutquart: function(a, b, c, d, e) { return 1 > (b /= e / 2) ? d / 2 * b * b * b * b + c: -d / 2 * ((b -= 2) * b * b * b - 2) + c }, easeinquint: function(a, b, c, d, e) { return d * (b /= e) * b * b * b * b + c }, easeoutquint: function(a, b, c, d, e) { return d * ((b = b / e - 1) * b * b * b * b + 1) + c }, easeinoutquint: function(a, b, c, d, e) { return 1 > (b /= e / 2) ? d / 2 * b * b * b * b * b + c: d / 2 * ((b -= 2) * b * b * b * b + 2) + c }, easeinsine: function(a, b, c, d, e) { return - d * math.cos(b / e * (math.pi / 2)) + d + c }, easeoutsine: function(a, b, c, d, e) { return d * math.sin(b / e * (math.pi / 2)) + c }, easeinoutsine: function(a, b, c, d, e) { return - d / 2 * (math.cos(math.pi * b / e) - 1) + c }, easeinexpo: function(a, b, c, d, e) { return 0 == b ? c: d * math.pow(2, 10 * (b / e - 1)) + c }, easeoutexpo: function(a, b, c, d, e) { return b == e ? c + d: d * ( - math.pow(2, -10 * b / e) + 1) + c }, easeinoutexpo: function(a, b, c, d, e) { return 0 == b ? c: b == e ? c + d: 1 > (b /= e / 2) ? d / 2 * math.pow(2, 10 * (b - 1)) + c: d / 2 * ( - math.pow(2, -10 * --b) + 2) + c }, easeincirc: function(a, b, c, d, e) { return - d * (math.sqrt(1 - (b /= e) * b) - 1) + c }, easeoutcirc: function(a, b, c, d, e) { return d * math.sqrt(1 - (b = b / e - 1) * b) + c }, easeinoutcirc: function(a, b, c, d, e) { return 1 > (b /= e / 2) ? -d / 2 * (math.sqrt(1 - b * b) - 1) + c: d / 2 * (math.sqrt(1 - (b -= 2) * b) + 1) + c }, easeinelastic: function(a, b, c, d, e) { var f = 1.70158, g = 0, h = d; if (0 == b) return c; if (1 == (b /= e)) return c + d; if (g || (g = .3 * e), math.abs(d) > h) { h = d; var f = g / 4 } else var f = g / (2 * math.pi) * math.asin(d / h); return - (h * math.pow(2, 10 * (b -= 1)) * math.sin((b * e - f) * 2 * math.pi / g)) + c }, easeoutelastic: function(a, b, c, d, e) { var f = 1.70158, g = 0, h = d; if (0 == b) return c; if (1 == (b /= e)) return c + d; if (g || (g = .3 * e), math.abs(d) > h) { h = d; var f = g / 4 } else var f = g / (2 * math.pi) * math.asin(d / h); return h * math.pow(2, -10 * b) * math.sin((b * e - f) * 2 * math.pi / g) + d + c }, easeinoutelastic: function(a, b, c, d, e) { var f = 1.70158, g = 0, h = d; if (0 == b) return c; if (2 == (b /= e / 2)) return c + d; if (g || (g = e * .3 * 1.5), math.abs(d) > h) { h = d; var f = g / 4 } else var f = g / (2 * math.pi) * math.asin(d / h); return 1 > b ? -.5 * h * math.pow(2, 10 * (b -= 1)) * math.sin((b * e - f) * 2 * math.pi / g) + c: .5 * h * math.pow(2, -10 * (b -= 1)) * math.sin((b * e - f) * 2 * math.pi / g) + d + c }, easeinback: function(a, b, c, d, e, f) { return void 0 == f && (f = 1.70158), d * (b /= e) * b * ((f + 1) * b - f) + c }, easeoutback: function(a, b, c, d, e, f) { return void 0 == f && (f = 1.70158), d * ((b = b / e - 1) * b * ((f + 1) * b + f) + 1) + c }, easeinoutback: function(a, b, c, d, e, f) { return void 0 == f && (f = 1.70158), 1 > (b /= e / 2) ? d / 2 * b * b * (((f *= 1.525) + 1) * b - f) + c: d / 2 * ((b -= 2) * b * (((f *= 1.525) + 1) * b + f) + 2) + c }, easeinbounce: function(a, b, c, d, e) { return d - jquery.easing.easeoutbounce(a, e - b, 0, d, e) + c }, easeoutbounce: function(a, b, c, d, e) { return 1 / 2.75 > (b /= e) ? d * 7.5625 * b * b + c: 2 / 2.75 > b ? d * (7.5625 * (b -= 1.5 / 2.75) * b + .75) + c: 2.5 / 2.75 > b ? d * (7.5625 * (b -= 2.25 / 2.75) * b + .9375) + c: d * (7.5625 * (b -= 2.625 / 2.75) * b + .984375) + c }, easeinoutbounce: function(a, b, c, d, e) { return e / 2 > b ? .5 * jquery.easing.easeinbounce(a, 2 * b, 0, d, e) + c: .5 * jquery.easing.easeoutbounce(a, 2 * b - e, 0, d, e) + .5 * d + c } }); //原生js移除同级方法扩展 element.prototype.siblings = function(callback){ var siblingelement = []; var parentallelement = []; if( ! this.parentnode ){ return siblingelement; }; parentallelement = this.parentnode.getelementsbytagname(this.tagname); for( var i = 0; i < parentallelement.length ; i++ ){ if( parentallelement[i] != this ){ siblingelement.push(parentallelement[i]); typeof callback == "function" && callback.call(parentallelement[i]); } } return siblingelement; };