﻿(function(a) { function c(b) { var c = [].slice.call(arguments, 1), d = 0, e = true; b = a.event.fix(b || window.event); b.type = "mousewheel"; if (b.wheelDelta) d = b.wheelDelta / 120; if (b.detail) d = -b.detail / 3; c.unshift(b, d); return a.event.handle.apply(this, c) } var b = ["DOMMouseScroll", "mousewheel"]; a.event.special.mousewheel = { setup: function() { if (this.addEventListener) for (var a = b.length; a; ) this.addEventListener(b[--a], c, false); else this.onmousewheel = c }, teardown: function() { if (this.removeEventListener) for (var a = b.length; a; ) this.removeEventListener(b[--a], c, false); else this.onmousewheel = null } }; a.fn.extend({ mousewheel: function(a) { return a ? this.bind("mousewheel", a) : this.trigger("mousewheel") }, unmousewheel: function(a) { return this.unbind("mousewheel", a) } }) })(jQuery); (function($) { $.fn.lofJSidernews = function(a) { return this.each(function() { new $.lofSidernews(this, a) }) }; $.lofSidernews = function(a, b) { this.settings = { direction: "", mainItemSelector: "li", navInnerSelector: "ul", navSelector: "li", navigatorEvent: "click", wapperSelector: ".lof-main-wapper", interval: 4e3, auto: true, maxItemDisplay: 3, startItem: 0, navPosition: "vertical", navigatorHeight: 100, navigatorWidth: 293, duration: 600, navItemsSelector: ".lof-navigator li", navOuterSelector: ".lof-navigator-outer", isPreloaded: true, easing: "easeInOutQuad" }; $.extend(this.settings, b || {}); this.nextNo = null; this.previousNo = null; this.maxWidth = this.settings.mainWidth || 600; this.wrapper = $(a).find(this.settings.wapperSelector); this.slides = this.wrapper.find(this.settings.mainItemSelector); if (!this.wrapper.length || !this.slides.length) return; if (this.settings.maxItemDisplay > this.slides.length) { this.settings.maxItemDisplay = this.slides.length } this.currentNo = isNaN(this.settings.startItem) || this.settings.startItem > this.slides.length ? 0 : this.settings.startItem; this.navigatorOuter = $(a).find(this.settings.navOuterSelector); this.navigatorItems = $(a).find(this.settings.navItemsSelector); this.navigatorInner = this.navigatorOuter.find(this.settings.navInnerSelector); if (this.settings.navPosition == "horizontal") { this.navigatorInner.width(this.slides.length * this.settings.navigatorWidth); this.navigatorOuter.width(this.settings.maxItemDisplay * this.settings.navigatorWidth); this.navigatorOuter.height(this.settings.navigatorHeight) } else { this.navigatorInner.height(this.slides.length * this.settings.navigatorHeight); this.navigatorOuter.height(this.settings.maxItemDisplay * this.settings.navigatorHeight); this.navigatorOuter.width(this.settings.navigatorWidth) } this.navigratorStep = this.__getPositionMode(this.settings.navPosition); this.directionMode = this.__getDirectionMode(); if (this.settings.direction == "opacity") { this.wrapper.addClass("lof-opacity"); $(this.slides).css("opacity", 0).eq(this.currentNo).css("opacity", 1) } else { this.wrapper.css({ left: "-" + this.currentNo * this.maxSize + "px", width: this.maxWidth * this.slides.length }) } if (this.settings.isPreloaded) { this.preLoadImage(this.onComplete) } else { this.onComplete() } }; $.lofSidernews.fn = $.lofSidernews.prototype; $.lofSidernews.fn.extend = $.lofSidernews.extend = $.extend; $.lofSidernews.fn.extend({ startUp: function(a, b) { seft = this; this.navigatorItems.each(function(a, b) { $(b).click(function() { seft.jumping(a, true); seft.setNavActive(a, b) }); $(b).css({ height: seft.settings.navigatorHeight, width: seft.settings.navigatorWidth }) }); this.registerWheelHandler(this.navigatorOuter, this); this.setNavActive(this.currentNo); if (this.settings.buttons && typeof this.settings.buttons == "object") { this.registerButtonsControl("click", this.settings.buttons, this) } if (this.settings.auto) this.play(this.settings.interval, "next", true); return this }, onComplete: function() { setTimeout(function() { $(".preload").fadeOut(900) }, 400); this.startUp() }, preLoadImage: function(a) { var b = this; var c = this.wrapper.find("img"); var d = 0; c.each(function(a, e) { if (!e.complete) { e.onload = function() { d++; if (d >= c.length) { b.onComplete() } }; e.onerror = function() { d++; if (d >= c.length) { b.onComplete() } } } else { d++; if (d >= c.length) { b.onComplete() } } }) }, navivationAnimate: function(currentIndex) { if (currentIndex <= this.settings.startItem || currentIndex - this.settings.startItem >= this.settings.maxItemDisplay - 1) { this.settings.startItem = currentIndex - this.settings.maxItemDisplay + 2; if (this.settings.startItem < 0) this.settings.startItem = 0; if (this.settings.startItem > this.slides.length - this.settings.maxItemDisplay) { this.settings.startItem = this.slides.length - this.settings.maxItemDisplay } } this.navigatorInner.stop().animate(eval("({" + this.navigratorStep[0] + ":-" + this.settings.startItem * this.navigratorStep[1] + "})"), { duration: 500, easing: "easeInOutQuad" }) }, setNavActive: function(a, b) { if (this.navigatorItems) { this.navigatorItems.removeClass("active"); $(this.navigatorItems.get(a)).addClass("active"); this.navivationAnimate(this.currentNo) } }, __getPositionMode: function(a) { if (a == "horizontal") { return ["left", this.settings.navigatorWidth] } return ["top", this.settings.navigatorHeight] }, __getDirectionMode: function() { switch (this.settings.direction) { case "opacity": this.maxSize = 0; return ["opacity", "opacity"]; default: this.maxSize = this.maxWidth; return ["left", "width"] } }, registerWheelHandler: function(a, b) { a.bind("mousewheel", function(a, c) { var d = c > 0 ? "Up" : "Down", e = Math.abs(c); if (c > 0) { b.previous(true) } else { b.next(true) } return false }) }, registerButtonsControl: function(a, b, c) { for (var d in b) { switch (d.toString()) { case "next": b[d].click(function() { c.next(true) }); break; case "previous": b[d].click(function() { c.previous(true) }); break } } return this }, onProcessing: function(a, b, c) { this.previousNo = this.currentNo + (this.currentNo > 0 ? -1 : this.slides.length - 1); this.nextNo = this.currentNo + (this.currentNo < this.slides.length - 1 ? 1 : 1 - this.slides.length); return this }, finishFx: function(a) { if (a) this.stop(); if (a && this.settings.auto) { this.play(this.settings.interval, "next", true) } this.setNavActive(this.currentNo) }, getObjectDirection: function(start, end) { return eval("({'" + this.directionMode[0] + "':-" + this.currentNo * start + "})") }, fxStart: function(a, b, c) { if (this.settings.direction == "opacity") { $(this.slides).stop().animate({ opacity: 0 }, { duration: this.settings.duration, easing: this.settings.easing }); $(this.slides).eq(a).stop().animate({ opacity: 1 }, { duration: this.settings.duration, easing: this.settings.easing }) } else { this.wrapper.stop().animate(b, { duration: this.settings.duration, easing: this.settings.easing }) } return this }, jumping: function(no, manual) { this.stop(); if (this.currentNo == no) return; var obj = eval("({'" + this.directionMode[0] + "':-" + this.maxSize * no + "})"); this.onProcessing(null, manual, 0, this.maxSize).fxStart(no, obj, this).finishFx(manual); this.currentNo = no }, next: function(a, b) { this.currentNo += this.currentNo < this.slides.length - 1 ? 1 : 1 - this.slides.length; this.onProcessing(b, a, 0, this.maxSize).fxStart(this.currentNo, this.getObjectDirection(this.maxSize), this).finishFx(a) }, previous: function(a, b) { this.currentNo += this.currentNo > 0 ? -1 : this.slides.length - 1; this.onProcessing(b, a).fxStart(this.currentNo, this.getObjectDirection(this.maxSize), this).finishFx(a) }, play: function(a, b, c) { this.stop(); if (!c) { this[b](false) } var d = this; this.isRun = setTimeout(function() { d[b](true) }, a) }, stop: function() { if (this.isRun == null) return; clearTimeout(this.isRun); this.isRun = null } }) })(jQuery)
