(function () { $(function () { //视频播放功能js。 $("video.edui-upload-video") .each(function () { var $this = $(this), width = $this.attr('width'), height = $this.attr('height'), src = $this.prop('src'), swfpath = "/content/_common/base/swf/powerplayback.swf", video = '' + '' + '' + '' + ''; $this.replacewith($(video)); }); }); $(function () { var powerplaybacks = $("div[data-power-ui='powerplayback']"); if (powerplaybacks.length > 0) { $.getscript('/content/_common/assets/scripts/swfobject.js') .done(function () { powerplaybacks.each(function () { var src = $(this).attr('data-url'); var title = $(this).attr('data-title'); var height = $(this).attr('data-height'); var width = $(this).attr('data-width'); var autoplay = $(this).attr('data-autoplay'); var random = parseint(math.random() * (99999 - 10000 + 1) + 10000); var id = 'powerplay' + random; $(this).attr('id', id); var parameters = { src: src, autoplay: autoplay, title: title, controlbarautohide: "false", scalemode: "liveorrecorded" }; swfobject.embedswf("/content/_common/base/swf/powerplayback.swf", id, width, height, "10.1.0", {}, parameters, { allowfullscreen: "true", wmode: "opaque" }, { name: "powerplayback" } ); }); }); } }); $(function () { audiojs.events.ready(function () { var as = audiojs.createall(); }); }); //广告。 $(function () { /** * 广告漂浮版位。 */ function advertisementfloat(floatpositions) { //var floatpositions = $("div[data-power-ui='advertisement_float']"); floatpositions.each(function () { var width = $(this).data().width; //版位宽度 var height = $(this).data().height; //版位高度 //计算关闭按钮的位置 var close = $(this).children(".close"); switch ($(this).data().closebuttonposition) { case "upperright": close.css("left", width - 20); break; case "lowerright": close.css("left", width - 20).css("top", height - 20); break; case "noshow": close.hide(); break; } //定时关闭版位 var time = $(this).data().stoptime; if (time > 0) { settimeout(function () { $(this).hide(); }, time * 1000); } }); return floatpositions; } var floatpositionsinfo = $("div[data-power-ui='advertisement_float']"); var floatpositions = advertisementfloat(floatpositionsinfo); floatpositions.each(function () { var floatposition = $(this); //计算版位的坐标 var ypos = positioncoordinate($(this)); //广告随滚动条滚动 if (floatposition.data().enablescroll.tolowercase() === "true") { floatposition.css("top", $(this).scrolltop() + ypos); $(window) .scroll(function () { floatposition.css("top", $(this).scrolltop() + ypos); }); } }); //浏览器窗口大小改变时 window.onresize = function () { var floatpositionsinfo = $("div[data-power-ui='advertisement_float']"); var floatpositions = advertisementfloat(floatpositionsinfo); floatpositions.each(function () { var floatposition = $(this); //计算版位的坐标 var ypos = positioncoordinate($(this)); //广告随滚动条滚动 if (floatposition.data().enablescroll.tolowercase() === "true") { $(window) .scroll(function () { floatposition.css("top", $(this).scrolltop() + ypos); }); } }); }; //计算版位的坐标 function positioncoordinate(floatposition) { var xpos = 0; var ypos = 0; var width = floatposition.data().width; //版位宽度 var height = floatposition.data().height; //版位高度 var availwidth = document.documentelement.clientwidth; //浏览器窗口可见宽度 var availheight = document.documentelement.clientheight; //浏览器窗口可见高度 var verticalmargin = floatposition.data().verticalmargin / 100; var horizontalmargin = floatposition.data().horizontalmargin / 100; switch (floatposition.data().datummark) { case "upperleft": xpos = availwidth * verticalmargin; xpos = xpos === availwidth ? xpos - width : xpos; ypos = availheight * horizontalmargin; ypos = ypos === availheight ? ypos - height : ypos; break; case "lowerright": xpos = (availwidth - width) - (availwidth * verticalmargin); xpos = xpos < 0 ? 0 : xpos; ypos = (availheight - height) - (availheight * horizontalmargin); ypos = ypos < 0 ? 0 : ypos; break; case "middle": var halfwidth = availwidth / 2; var halfheight = availheight / 2; xpos = halfwidth + (halfwidth * verticalmargin); xpos = xpos === availwidth ? xpos - width : xpos; ypos = halfheight + (halfheight * horizontalmargin); ypos = ypos === height ? ypos - height : ypos; break; } floatposition.css("z-index", 99).css("left", xpos); return ypos; } /** * 广告固定板块。 */ var fixedcount = 0, fixedlength = $("div[data-power-ui='advertisement_fixed']").find(".fixedposition a").length; $("div[data-power-ui='advertisement_fixed']") .find(".fixedcount a") .click(function () { $(this).addclass("seld").siblings().removeclass("seld"); var index = $(this).index(); $("div[data-power-ui='advertisement_fixed']") .find(".fixedposition > a") .eq(index) .fadein(300) .siblings() .fadeout(300); }); function showauto() { fixedcount = fixedcount >= (fixedlength - 1) ? 0 : ++fixedcount; $("div[data-power-ui='advertisement_fixed']").find(".fixedcount a").eq(fixedcount).trigger('click'); } var fixedcounttime = setinterval(showauto, 2000); $("div[data-power-ui='advertisement_fixed']") .hover(function () { clearinterval(fixedcounttime) }, function () { fixedcounttime = setinterval(showauto, 2000); }); }); // ajax调用分部视图。 $(function () { function getfunction(code, argnames) { var fn = window, parts = (code || "").split("."); while (fn && parts.length) { fn = fn[parts.shift()]; } if (typeof (fn) === "function") { return fn; } argnames.push(code); return function.constructor.apply(null, argnames); } function loaddata($data, pageid) { var url = $data.ajaxurl; if (pageid) { url = url + '?pageid=' + pageid; } $.ajax({ url: url, type: $data.ajaxmethod, cache: !!$data.ajaxcache, data: { partialviewname: $data.ajaxpartialviewname, parameters: json.stringify($data.ajaxparameter) }, beforesend: function (xhr) { getfunction($data.ajaxbegin, ["xhr"]).apply(null, arguments); }, complete: function () { getfunction($data.ajaxcomplete, ["xhr", "status"]).apply(null, arguments); }, success: function (response, status, xhr) { var fn = window, parts = ($data.ajaxsuccess || "").split("."); while (fn && parts.length) { fn = fn[parts.shift()]; } if (typeof (fn) === "function") { getfunction($data.ajaxsuccess, ["response", "status", "xhr"]).apply(null, arguments); } else { if (response.page) { $data.ajaxdatacount = response.page.datacount; $data.ajaxpageindex = response.page.pageindex; $data.ajaxpagesize = response.page.pagesize; $data.ajaxpagingurl = response.page.pagingurl; } $('[data-ajax-data="' + $data.ajaxid + '"]') .each(function () { $(this).trigger('ajaxcontrolhandler', [response, $data]); }); var mode = ($data.ajaxmode || "").touppercase(); $($data.ajaxupdate) .each(function (i, update) { var top; switch (mode) { case "before": top = update.firstchild; $("
") .html(response.html) .contents() .each(function () { update.insertbefore(this, top); }); break; case "after": $("
") .html(response.html) .contents() .each(function () { update.appendchild(this); }); break; case "replace-with": $(update).replacewith(response.html); break; default: $(update).html(response.html); break; } }); } }, error: function (xhr, textstatus, errorthrown) { getfunction($data.ajaxfailure, ["xhr", "status", "error"]).apply(null, arguments); } }); } // ajaxpartial 初始化 $('[data-ui-type="ajaxpartial"]') .each(function () { var $data = $(this).data(); $data.ajaxloaddata = loaddata; loaddata($data); }); // ajaxbutton 初始化 function ajaxbuttoncontrolhandler(response, $data) { $('[data-ajax-data="' + $data.ajaxid + '"]') .each(function () { if (response.page.pageindex >= response.page.pagecount) { $(this).hide(); } }); } $('[data-ui-type="ajaxbutton"]') .each(function () { var $this = $(this); function getdata(element) { var id = $(element).data().ajaxdata; var input = $('#' + id); var $data = input.data(); var pageid = 1; if ($data.ajaxpageindex) { pageid = $data.ajaxpageindex + 1; } $data.ajaxloaddata($data, pageid); } $this.on('ajaxcontrolhandler', function (event, response, $data) { ajaxbuttoncontrolhandler(response, $data); }); $this.on('click', function () { getdata(this); }); }); }); }());