var frontpublic_slideshow01 = function () { //变量初始化 this.ce_slide_effect_style = null; //展示效果类型 1:左右移动 2:右左移动 3:上下移动 4:下上移动 5:渐隐切换 this.ce_slide_index = 0; //文章索引值存储器 this.ce_slide_pic_temple = null; //内容临时存储器 this.ce_slide_open_type = null; //链接打开方式 this.ce_slide_show_title = null; //是否显示标题 1:显示 0:不显示 this.ce_slide_show_content = null; //是否显示内容 1:显示 0:不显示 this.ce_slide_tag_style = null; //展示样式类型 0:缩略图展示 1:纯文字标签 this.ce_slide_recursion_times = null; //轮播延时时间 this.ce_slide_id = ""; // 幻灯片块唯一id this.ce_requestdatafilepath = ""; this.ce_slide_settimeout = null; this.ce_slide_autoplay = null; //是否自动播放 0:不自动播放 1:自动播放 this.ce_slide_totle = null; //幻灯片总数 //ui界面参数 所有ui参数单位为px this.ce_slide_img_width = null; //主图宽度 this.ce_slide_img_height = null; //主图高度 this.ce_slide_thumbnail_width = null; //缩略图宽度 this.ce_slide_thumbnail_height = null; //缩略图高度 this.ce_slide_tag_text_width = 16; //幻灯片数字页签宽度 this.ce_slide_tag_text_height = 16; //幻灯片数字页签高度 this.ce_slide_info_mark_height = 60; //文章信息区遮罩层高度 this.ce_slide_thumbnail_max_width = 0; //缩略图列表总长度 this.ce_slide_thumbnail_show_width = 0; //展示区域宽度 this.ce_slide_thumbnail_pages = 1; //幻灯片页数 this.ce_slide_thumbnail_groups = 0; //幻灯片分页组宽度 this.ce_slide_thumbnail_tmp = 0; //翻页计数器 //数据容器 this.ce_slide_contes_obj = object(); //内容数据对象 this.ce_slide_imgs = new array(); //主图数据 this.ce_slide_imgs_hrefs = new array(); //文章链接数据 this.ce_slide_thumbnails = new array(); //缩略图数据 this.ce_slide_titles = new array(); //文章标题数据 this.ce_slide_memos = new array(); //文章摘要数据 //dom对象数据 this.ce_slide_frame = null; //幻灯片主体对象 this.ce_slide_contente = null; //幻灯片主区域对象 this.ce_slide_pic = null; //主图区域对象 this.ce_slide_tag_thumbnail = null; //缩略图区域对象 this.ce_slide_thumbnail_list = null; //缩略图区域外层容器对象 this.ce_slide_thumbnail_arrowhead = null; //缩略图翻页按钮对象 this.ce_slide_tag_text = null; //文字页区域对象 this.ce_slide_info_mark = null; //透明遮罩层对象 this.ce_slide_info = null; //文章信息内容区对象 this.ce_slide_info_title = null; //文章信息区-标题对象 this.ce_slide_text_memo = null; //说明文信息区-概要对象 this.ce_slide_arrowhead_left = null; //缩略图翻页左 this.ce_slide_arrowhead_right = null; //缩略图翻页右 this.frontpublic_slideshow01_tempsettimeout = null; //时间 /* * 幻灯片初始化方法 * 参数说明: * setjsondata 是通过jsp赋值获取放有幻灯片配置参数的字符串,通过 this.ce_slide_strtojson() 方法解析并转换成json数据 * querysegment 为展示内容数据请求时的url参数片断 */ this.ce_slide_init = function (setjsondata, querysegment,tempdata) { //初始化函数 //this.ce_slide_frame.css("width",this.ce_slide_img_width); //根据需求该处暂时关 //将所有dom对象进行初始化 window.cleartimeout(this.frontpublic_slideshow01_tempsettimeout); if (setjsondata) { var setjsondata = this.ce_slide_strtojson(setjsondata); this.ce_slide_open_type = setjsondata.opentype; this.ce_slide_tag_style = setjsondata.showtype; this.ce_slide_recursion_times = setjsondata.changetimes; this.ce_slide_show_title = setjsondata.isshowslidetitle; this.ce_slide_show_content = setjsondata.isshowslidecontent; this.ce_requestdatafilepath = setjsondata.requestdatafilepath; this.ce_slide_id = this.ce_requestdatafilepath.replace("/comp-frontslide_listjson01", "frontpublic_slideshow01"); //外部数据 //var tempdata = getjquerydata(setjsondata.requestdatafilepath, querysegment); var d = new date(); var t = ""+d.getfullyear()+d.getmonth()+d.getdate(); /* var tempdata = $.ajax({ type: "post", url: setjsondata.requestdatafilepath+"?"+t, data: querysegment, async: false }).responsetext; */ // this.ce_slide_contes_obj = eval("(" + tempdata + ")"); this.ce_slide_contes_obj =tempdata; this.ce_slide_frame = $("#" + this.ce_slide_id + ""); //alert("csfh" + this.ce_slide_frame.height()); this.ce_slide_contente = $("#" + this.ce_slide_id + " .slide-contente"); //alert(this.ce_slide_contente.height()); this.ce_slide_pic = $("#" + this.ce_slide_id + " .slide-pic ul"); this.ce_slide_tag_thumbnail = $("#" + this.ce_slide_id + " .slide-tag-thumbnail ul"); this.ce_slide_thumbnail_list = $("#" + this.ce_slide_id + " .thumbnail-list"); this.ce_slide_thumbnail_arrowhead = $("#" + this.ce_slide_id + " .slide-tag-thumbnail .arrowhead"); this.ce_slide_tag_text = $("#" + this.ce_slide_id + " .slide-tag-text ul"); this.ce_slide_info_mark = $("#" + this.ce_slide_id + " .slide-info-mark"); this.ce_slide_info = $("#" + this.ce_slide_id + " .slide-info"); this.ce_slide_info_title = $("#" + this.ce_slide_id + " .slide-info h3"); this.ce_slide_text_memo = $("#" + this.ce_slide_id + " .slide-text"); this.ce_slide_arrowhead_left = $("#" + this.ce_slide_id + " .arrowhead-left"); this.ce_slide_arrowhead_right = $("#" + this.ce_slide_id + " .arrowhead-right"); this.ce_slide_totle = this.ce_slide_contes_obj["contents"].length; this.ce_slide_contents_init(); this.ce_slide_tag_init(); this.ce_slide_img_init(); this.ce_slide_run(); //alert(this.ce_slide_frame.attr("id")); //alert($("#" + this.ce_slide_id + " .slide-tag-text").attr("class")); //alert(this.ce_slide_id); var thise = this; // 控制鼠标移入大图停止自动播放。 this.ce_slide_pic.hover( function (event) { window.cleartimeout(thise.frontpublic_slideshow01_tempsettimeout); }, function (event) { thise.ce_slide_loop(); } ); } }; /* * 展示内容文字区域内容初始化方法 */ this.ce_slide_contents_init = function () { this.ce_slide_effect_style = this.ce_slide_contes_obj["setdata"].changestyle; this.ce_slide_autoplay = this.ce_slide_contes_obj["setdata"].isplaysset; for (var i = 0; i < this.ce_slide_totle; i++) { this.ce_slide_imgs[i] = this.ce_slide_contes_obj["contents"][i].bigpicpath; this.ce_slide_imgs[i] = this.ce_slide_contes_obj["contents"][i].bigpicpath; this.ce_slide_imgs_hrefs[i] = this.ce_slide_contes_obj["contents"][i].plink; this.ce_slide_thumbnails[i] = this.ce_slide_contes_obj["contents"][i].smallpicpath; this.ce_slide_titles[i] = this.ce_slide_contes_obj["contents"][i].slidename; this.ce_slide_memos[i] = this.ce_slide_contes_obj["contents"][i].description; } }; /* * 文字页签初始化 */ this.ce_slide_tag_text_init = function () { for (var i = 0; i < this.ce_slide_totle; i++) { if (i == 0) { this.ce_slide_tag_text.append("
  • " + (i + 1) + "
  • "); } else { this.ce_slide_tag_text.append("
  • " + (i + 1) + "
  • "); } } //关闭js控制样式规格 //this.ce_slide_tag_text.find("ul").find("li").width(this.ce_slide_tag_text_width); //this.ce_slide_tag_text.find("ul").find("li").height(this.ce_slide_tag_text_height); }; /* * 缩略图页签初始化方法 * 在初始化过程中检查缩略图的列表的总长度是否超出了缩略图展示区域的长度,如果超出则显示在缩略图列表左右增加左右翻页按钮 */ this.ce_slide_tag_thumbnail_init = function () { //缩略图页签初始化 if (this.ce_slide_thumbnails.length) { for (var i = 0; i < this.ce_slide_totle; i++) { this.ce_slide_tag_thumbnail.append("
  • "); } /* 根据需求该处暂时关闭 this.ce_slide_tag_thumbnail.find("img").width(this.ce_slide_thumbnail_width); this.ce_slide_tag_thumbnail.find("img").height(this.ce_slide_thumbnail_height); */ } //检查缩略图列表总长度是否超出,展示区域长度 //计算缩略图总长度,总长度的计算方式为 li_width + margin-left + margin-right + padding-left + padding-right this.ce_slide_thumbnail_max_width += parseint(this.ce_slide_tag_thumbnail.find("li").width()); this.ce_slide_thumbnail_max_width += parseint(this.ce_slide_tag_thumbnail.find("li").css("margin-left").replace("px", "")); this.ce_slide_thumbnail_max_width += parseint(this.ce_slide_tag_thumbnail.find("li").css("margin-right").replace("px", "")); this.ce_slide_thumbnail_max_width += parseint(this.ce_slide_tag_thumbnail.find("li").css("padding-left").replace("px", "")); this.ce_slide_thumbnail_max_width += parseint(this.ce_slide_tag_thumbnail.find("li").css("padding-right").replace("px", "")); this.ce_slide_thumbnail_max_width = parseint(this.ce_slide_thumbnail_max_width * this.ce_slide_totle); //对比缩略图总长度是否超出幻灯片总长度 if (parseint(this.ce_slide_frame.width()) < this.ce_slide_thumbnail_max_width) { //如果超出则展示左右翻页按钮 //计算展示区域宽度 this.ce_slide_thumbnail_show_width = this.ce_slide_frame.width() - parseint(this.ce_slide_tag_thumbnail.parent().parent().find(".arrowhead").width() * 2); this.ce_slide_tag_thumbnail.parent().width(this.ce_slide_thumbnail_show_width); //计算缩略图列表总宽度并赋值 this.ce_slide_tag_thumbnail.width(this.ce_slide_thumbnail_max_width); //计算分页页数 this.ce_slide_thumbnail_groups = this.ce_slide_thumbnail_max_width / this.ce_slide_thumbnail_show_width; this.ce_slide_thumbnail_groups = (math.floor(this.ce_slide_thumbnail_groups) > 0) ? parseint(this.ce_slide_thumbnail_groups) + 1 : this.ce_slide_thumbnail_groups; this.ce_slide_arrowhead_left.addclass("no-arrowhead"); } else { //根据缩略图数量计算平均长度 平均长度 = 幻灯长度 / 图片长度 同时清除li表内所有margin和padding var li_width = parseint(this.ce_slide_frame.width()) / parseint(this.ce_slide_totle); li_width = li_width / parseint(this.ce_slide_frame.width()) * 100; //清除margin和padding this.ce_slide_tag_thumbnail.find("li").attr("style", "padding:0px;margin:0px;width:" + li_width + "%"); this.ce_slide_tag_thumbnail.width(parseint(this.ce_slide_frame.width())); this.ce_slide_tag_thumbnail.parent().width(parseint(this.ce_slide_frame.width())); this.ce_slide_thumbnail_arrowhead.attr("style", "display:none"); } }; /* * 缩略图和数字页签展示效果初始化 */ this.ce_slide_tag_init = function () { switch (parseint(this.ce_slide_tag_style)) { case 1: this.ce_slide_tag_text.parent().css("display", "block"); this.ce_slide_tag_text_init(); break; case 0: this.ce_slide_tag_thumbnail.parent().parent().css("display", "block"); this.ce_slide_tag_thumbnail_init(); break; } }; /* * 页签翻页效果方法 */ this.ce_slide_tag_changestyle = function () { //页签轮播变换样式 var nowobj = null; if (this.ce_slide_tag_text.length) { //如果页签数据存在 this.ce_slide_tag_text.find("li").removeclass(); nowobj = this.ce_slide_tag_text.find("li:eq(" + this.ce_slide_index + ")"); nowobj.addclass("slide-hover"); } if (this.ce_slide_thumbnails.length) { //如果缩略图数据存在 this.ce_slide_tag_thumbnail.find("li").removeclass(); nowobj = this.ce_slide_tag_thumbnail.find("li:eq(" + this.ce_slide_index + ")") nowobj.addclass("slide-hover"); } }; /* * 大图内容展示区初始化方法 */ this.ce_slide_img_init = function () { this.ce_slide_pic.html(""); this.ce_slide_contente.css("height", this.ce_slide_img_height); //alert(this.ce_slide_img_height); for (var i = 0; i < this.ce_slide_totle; i++) { if (parseint(this.ce_slide_imgs_hrefs[i].length) > 0) { this.ce_slide_pic.append("
  • "); } else if (parseint(this.ce_slide_imgs_hrefs[i].length) <= 0) { this.ce_slide_pic.append("
  • "); } } }; /* * 根据后台参数赋予的参数值来初始化指定的切换效果, * 参数名为: style * 参数值: 1 淡出淡入效果 * 2 向右滚动效果 * 3 向左滚动效果 * 4 向下滚动效果 * 5 向上滚动效果 */ this.ce_slide_effect_init = function (style) { //效果类型选择 switch (style) { case 1: //淡出淡入效果 if (!this.ce_slide_pic_temple) { //如果存储器为空,则表明幻灯为第一次显示 this.ce_slide_pic_temple = this.ce_slide_pic.find("li:eq(" + (this.ce_slide_imgs.length - 1) + ")"); } this.ce_slide_effect_gradual(); break; case 2: //向右滚动效果 this.ce_slide_pic_temple = (this.ce_slide_pic_temple) ? this.ce_slide_pic_temple : 1; this.ce_slide_pic_temple = (this.ce_slide_index == null) ? this.ce_slide_pic_temple : (this.ce_slide_index + 1); this.ce_slide_effect_aspect_x("right"); break; case 3: //向左滚动效果 this.ce_slide_pic_temple = (this.ce_slide_pic_temple) ? this.ce_slide_pic_temple : 1; this.ce_slide_pic_temple = (this.ce_slide_index == null) ? this.ce_slide_pic_temple : (this.ce_slide_index + 1); this.ce_slide_effect_aspect_x("left"); break; case 4: //向下滚动效果 this.ce_slide_pic_temple = (this.ce_slide_pic_temple) ? this.ce_slide_pic_temple : 1; this.ce_slide_pic_temple = (this.ce_slide_index == null) ? this.ce_slide_pic_temple : (this.ce_slide_index + 1); this.ce_slide_effect_aspect_y("bottom"); break; case 5: //向上滚动效果 this.ce_slide_pic_temple = (this.ce_slide_pic_temple) ? this.ce_slide_pic_temple : 1; this.ce_slide_pic_temple = (this.ce_slide_index == null) ? this.ce_slide_pic_temple : (this.ce_slide_index + 1); this.ce_slide_effect_aspect_y("top"); break; } }; /* * 水平切换效果,其中 aspect 参数为指定的某一个水平方向,参数值分别为: left 和 right */ this.ce_slide_effect_aspect_x = function (aspect) { var aspect_float; var slide_pic_width = this.ce_slide_frame.width() * this.ce_slide_imgs.length; var now_position; if (aspect == "left") { aspect_float = "right"; now_position = -(slide_pic_width - this.ce_slide_frame.width() * this.ce_slide_pic_temple); } if (aspect == "right") { aspect_float = "left"; now_position = (this.ce_slide_pic_temple == 1) ? 0 : -(this.ce_slide_frame.width() * (this.ce_slide_pic_temple - 1)); } this.ce_slide_pic.css("position", "absolute"); this.ce_slide_pic.css("width", slide_pic_width); this.ce_slide_pic.animate({ left: now_position }, "slow"); this.ce_slide_pic.find("li").css("float", aspect_float); this.ce_slide_pic_temple = (this.ce_slide_pic_temple >= this.ce_slide_imgs.length) ? 1 : this.ce_slide_pic_temple + 1; }; /* * 垂直切换效果,其中 aspect 参数为指定的某一个水平方向,参数值分别为: left 和 right */ this.ce_slide_effect_aspect_y = function (aspect) { if (aspect == "top") { //从上到下 this.ce_slide_pic.html(""); this.ce_slide_pic.css("position", "absolute"); for (var i = this.ce_slide_imgs.length - 1; i >= 0; i--) { if (parseint(this.ce_slide_imgs_hrefs[i].length)) this.ce_slide_pic.append("
  • "); else this.ce_slide_pic.append("
  • "); } var now_position = -(this.ce_slide_pic.height() - this.ce_slide_pic.find("li").height() * this.ce_slide_pic_temple); this.ce_slide_pic.animate({ top: now_position }, "slow"); } if (aspect == "bottom") { //从下到上 this.ce_slide_pic.css("position", "absolute"); var now_position = (this.ce_slide_pic_temple == 1) ? 0 : -(this.ce_slide_pic.find("li").height() * (this.ce_slide_pic_temple - 1)); this.ce_slide_pic.animate({ top: now_position }, "slow"); } this.ce_slide_pic_temple = (this.ce_slide_pic_temple >= this.ce_slide_imgs.length) ? 1 : this.ce_slide_pic_temple + 1; }; /* * 淡出淡入效果,初始化方法 */ this.ce_slide_effect_gradual = function () { //alert("{{{{:" + this.ce_slide_recursion_times); //alert("ce_slide_pic}}}}}}}:" + this.ce_slide_pic.parent().parent().parent().attr("id")); this.ce_slide_pic.find("li").css("position", "absolute"); this.ce_slide_pic.find("li").css("top", "0"); this.ce_slide_pic.find("li").css("left", "0"); this.ce_slide_pic.find("li").css("display", "none"); var nowobj = this.ce_slide_pic.find("li:eq(" + this.ce_slide_index + ")"); nowobj.fadein("slow"); }; /* * 在页面输出展示内容的方法 */ this.ce_slide_show = function () { this.ce_slide_effect_init(this.ce_slide_effect_style); //同步缩略图主展示区宽度 this.ce_slide_contente.width(this.ce_slide_frame.width()); //同步幻灯片宽度与大图宽度 this.ce_slide_pic.find("img").width(this.ce_slide_frame.width()); //同步幻灯片展示区域高度与大图区域的高度 this.ce_slide_pic.find("img").height(this.ce_slide_contente.height()); this.ce_slide_pic.parent().width(this.ce_slide_frame.width()); //alert(this.ce_slide_frame.height()); //文章信息展示 //原始数据清理 this.ce_slide_info_title.html(""); this.ce_slide_text_memo.html(""); this.ce_slide_tag_changestyle(); //页签轮播变换样式 if (parseint(this.ce_slide_show_title)) { this.ce_slide_info_title.html(this.ce_slide_titles[this.ce_slide_index]); //更新文章标题 } if (parseint(this.ce_slide_show_content)) { this.ce_slide_text_memo.html(this.ce_slide_memos[this.ce_slide_index]); //更新文章摘要 } //蒙版初始化 蒙板暂时为固定高 所以暂时关闭 //var mark_height = (this.ce_slide_info_mark_height)?this.ce_slide_info_mark_height:(this.ce_slide_info.height()+this.ce_slide_tag_text_height); //this.ce_slide_info_mark.height(mark_height+"px"); this.ce_slide_index = (this.ce_slide_index >= (this.ce_slide_imgs.length - 1)) ? 0 : (this.ce_slide_index + 1); }; /* * 自动轮播方法 */ this.ce_slide_loop = function () { this.ce_slide_show(); // ce_slide.ce_slide_settimeout = settimeout("ce_slide.ce_slide_loop()",ce_slide.ce_slide_recursion_times); var thise = this; if (this.ce_slide_autoplay) { thise.frontpublic_slideshow01_tempsettimeout = settimeout ( function () { thise.ce_slide_loop(); }, thise.ce_slide_recursion_times ); } }; /* * 鼠标点击某一个内容块的事情处理方法,参数 obj 为鼠标点击到的某一个对象 */ this.ce_slide_hover_init = function (obj, thise) { obj.click(function () { thise.ce_slide_index = obj.index(this); thise.ce_slide_show(); if (this.ce_slide_autoplay) { window.cleartimeout(thise.frontpublic_slideshow01_tempsettimeout); thise = settimeout(function () { thise.ce_slide_loop(); }, thise.ce_slide_recursion_times); } }); }; /* * 鼠标点击按钮,根据按钮的class名来执行左移动或右移动的事件 */ this.ce_slide_arrowhead_click_init = function (obj, thise) { obj.click(function () { var arrowhead = $(this).attr("class").split(" "); switch (arrowhead[0].replace(/(^\s*)|(\s*$)/g, "")) { case "arrowhead-left": if (thise.ce_slide_thumbnail_pages > 1 && thise.ce_slide_thumbnail_pages != 1) { thise.ce_slide_thumbnail_tmp += thise.ce_slide_thumbnail_show_width; thise.ce_slide_tag_thumbnail.animate({ left: thise.ce_slide_thumbnail_tmp }, "slow"); thise.ce_slide_thumbnail_pages = ((thise.ce_slide_thumbnail_pages - 1) < 0) ? 0 : (thise.ce_slide_thumbnail_pages - 1); } if (thise.ce_slide_thumbnail_pages <= 1) { $(this).addclass("no-arrowhead"); thise.ce_slide_arrowhead_right.removeclass("no-arrowhead"); } if (thise.ce_slide_thumbnail_pages < thise.ce_slide_thumbnail_groups) { thise.ce_slide_arrowhead_right.removeclass("no-arrowhead"); } break; case "arrowhead-right": if (thise.ce_slide_thumbnail_pages < thise.ce_slide_thumbnail_groups) { thise.ce_slide_thumbnail_tmp -= thise.ce_slide_thumbnail_show_width; thise.ce_slide_tag_thumbnail.animate({ left: thise.ce_slide_thumbnail_tmp }, "slow"); thise.ce_slide_thumbnail_pages += 1; } if (thise.ce_slide_thumbnail_pages >= thise.ce_slide_thumbnail_groups) { $(this).addclass("no-arrowhead"); thise.ce_slide_arrowhead_left.removeclass("no-arrowhead"); } if (thise.ce_slide_thumbnail_pages > 1 && thise.ce_slide_thumbnail_pages != 1) { thise.ce_slide_arrowhead_left.removeclass("no-arrowhead"); } break; } }) }; /* * 主体内容初始化完毕后,执行幻灯展示的方法 */ this.ce_slide_run = function () { //执行 var arrowhead_h; //临时悬浮记录器 this.ce_slide_hover_init(this.ce_slide_tag_thumbnail.find("li"), this); this.ce_slide_hover_init(this.ce_slide_tag_text.find("li"), this); //分页箭头操作 this.ce_slide_arrowhead_click_init(this.ce_slide_tag_thumbnail.parent().parent().find(".arrowhead"), this); var thise = this; this.ce_slide_tag_thumbnail.parent().parent().find(".arrowhead").hover ( function () { arrowhead_h = $(this).attr("class").split(" "); switch (arrowhead_h[0].replace(/(^\s*)|(\s*$)/g, "")) { case "arrowhead-left": if (thise.ce_slide_thumbnail_pages > 1) $(this).addclass("arrowhead-left-hover"); break; case "arrowhead-right": if (thise.ce_slide_thumbnail_pages < thise.ce_slide_thumbnail_groups) $(this).addclass("arrowhead-right-hover"); break; } }, function () { arrowhead_h = $(this).attr("class").split(" "); switch (arrowhead_h[0].replace(/(^\s*)|(\s*$)/g, "")) { case "arrowhead-left": $(this).removeclass("arrowhead-left-hover"); break; case "arrowhead-right": $(this).removeclass("arrowhead-right-hover"); break; } } ); this.ce_slide_loop(); }; this.d5_slide = function(userw,userh){ var swidth = $("#slider_name").width(); $("#slider_name").width(userw); $("#slider_name").height(userh); var len = $("#slider_name .silder_panel").length; var index = 0; var pictimer; var btn = ""; $("#slider_name").append(btn); $("#slider_name .silder_nav li").css({"opacity":"0.6","filter":"alpha(opacity=60)"}).mouseover(function() { index = $("#slider_name .silder_nav li").index(this); showpics(index); }).eq(0).trigger("mouseover"); $("#slider_name .prev,#slider_name .next").css({"opacity":"0.2","filter":"alpha(opacity=20)"}).hover(function(){ $(this).stop(true,false).animate({"opacity":"0.6","filter":"alpha(opacity=60)"},300); },function() { $(this).stop(true,false).animate({"opacity":"0.2","filter":"alpha(opacity=20)"},300); }); // prev $("#slider_name .prev").click(function() { index -= 1; if(index == -1) {index = len - 1;} showpics(index); }); // next $("#slider_name .next").click(function() { index += 1; if(index == len) {index = 0;} showpics(index); }); // $("#slider_name .silder_con").css("width",swidth * (len)); // mouse $("#slider_name").hover(function() { clearinterval(pictimer); },function() { pictimer = setinterval(function() { showpics(index); index++; if(index == len) {index = 0;} },3000); }).trigger("mouseleave"); // showpics function showpics(index) { var nowleft = -index*swidth; $("#slider_name .silder_con").stop(true,false).animate({"left":nowleft},300); $("#slider_name .silder_nav li").removeclass("current").eq(index).addclass("current"); $("#slider_name .silder_nav li").stop(true,false).animate({"opacity":"0.5"},300).eq(index).stop(true,false).animate({"opacity":"1"},300); }; }; /* * 将url参数形式的字符串转化成json数据的数据格式化方法。参数值str 为参数的url字符串 */ this.ce_slide_strtojson = function (str) { segs = str.match(/=/g).length; for (var i = 0; i < segs; i++) { str = str.replace("=", ":'").replace("&", "',"); } str += "'"; return eval("str = {" + str + "};"); }; }; /* ==== slider namespace ==== */ var frontpublic_slideshow02 = function() { /* ==== private methods ==== */ function getelementsbyclass(object, tag, classname) { var o = object.getelementsbytagname(tag); for ( var i = 0, n = o.length, ret = []; i < n; i++) { if (o[i].classname == classname) ret.push(o[i]); } if (ret.length == 1) ret = ret[0]; return ret; } function setopacity (obj,o) { if (obj.filters) obj.filters.alpha.opacity = math.round(o); else obj.style.opacity = o / 100; } /* ==== slider constructor ==== */ function slider(ocont, speed, iw, ih, op) { this.slides = []; this.over = false; this.s = this.s0 = speed; this.iw = iw; this.ih = ih; this.op = op; this.oc = document.getelementbyid(ocont); this.frm = getelementsbyclass(this.oc, 'div', 'slide'); this.nf = this.frm.length; this.resize(); for (var i = 0; i < this.nf; i++) { this.slides[i] = new slide(this, i); } this.oc.parent = this; this.view = this.slides[0]; this.z = this.mx; /* ==== on mouse out event ==== */ this.oc.onmouseout = function () { this.parent.mouseout(); return false; } } slider.prototype = { /* ==== animation loop ==== */ run : function () { this.z += this.over ? (this.mn - this.z) * .5 : (this.mx - this.z) * .5; this.view.calc(); var i = this.nf; while (i--) this.slides[i].move(); }, /* ==== resize ==== */ resize : function () { this.wh = this.oc.clientwidth; this.ht = this.oc.clientheight; this.wr = this.wh * this.iw; this.r = this.ht / this.wr; this.mx = this.wh / this.nf; this.mn = (this.wh * (1 - this.iw)) / (this.nf - 1); }, /* ==== rest ==== */ mouseout : function () { this.over = false; setopacity(this.view.img, this.op); } } /* ==== slide constructor ==== */ slide = function (parent, n) { this.parent = parent; this.n = n; this.x0 = this.x1 = n * parent.mx; this.v = 0; this.loaded = false; this.cpt = 0; this.start = new date(); this.obj = parent.frm[n]; this.img = getelementsbyclass(this.obj, 'img', 'diapo'); /* this.bkg = document.createelement('div'); this.bkg.classname = 'backgroundtext'; this.obj.insertbefore(this.bkg);*/ if (n == 0) this.obj.style.borderleft = 'none'; this.obj.style.left = math.floor(this.x0) + 'px'; setopacity(this.img, parent.op); /* ==== mouse events ==== */ this.obj.parent = this; this.obj.onmouseover = function() { this.parent.over(); return false; } } slide.prototype = { /* ==== target positions ==== */ calc : function() { var that = this.parent; // left slides for (var i = 0; i <= this.n; i++) { that.slides[i].x1 = i * that.z; } // right slides for (var i = this.n + 1; i < that.nf; i++) { that.slides[i].x1 = that.wh - (that.nf - i) * that.z; } }, /* ==== html animation : move slides ==== */ move : function() { var that = this.parent; var s = (this.x1 - this.x0) / that.s; /* ==== lateral slide ==== */ if (this.n && math.abs(s) > .5) { this.obj.style.left = math.floor(this.x0 += s) + 'px'; } /* ==== vertical text ==== */ var v = (this.n < that.nf - 1) ? that.slides[this.n + 1].x0 - this.x0 : that.wh - this.x0; if (math.abs(v - this.v) > .5) { //this.bkg.style.top = math.floor(2 + that.ht - (v - that.z) * that.ih * that.r) + 'px'; this.v = v; this.cpt++; } else { if (!this.pro) { /* ==== adjust speed ==== */ this.pro = true; var tps = new date() - this.start; if(this.cpt > 1) { that.s = math.max(2, (28 / (tps / this.cpt)) * that.s0); } } } if (!this.loaded) { if (this.img.complete) { this.img.style.visibility = 'visible'; this.loaded = true; } } }, /* ==== light ==== */ over : function () { this.parent.resize(); this.parent.over = true; setopacity(this.parent.view.img, this.parent.op); this.parent.view = this; this.start = new date(); this.cpt = 0; this.pro = false; this.calc(); setopacity(this.img, 100); } } /* ==== public method - script initialization ==== */ return { init : function(speed) { // create instances of sliders here // parameters : htmlcontainer name, speed (2 fast - 20 slow), horizontal ratio, vertical text ratio, opacity this.s1 = new slider("slider", speed, 1.84/3, 1/3.2, 70); setinterval("frontpublic_slideshow02.s1.run();", speed); } } }();