/* * jquery bootstrap news box v1.0.1 * * copyright 2014, dragan mitrovic * email: gagi270683@gmail.com * free to use and abuse under the mit license. * http://www.opensource.org/licenses/mit-license.php */ if (typeof object.create !== "function") { object.create = function (e) { function t() { } t.prototype = e; return new t } } (function (e, t, n, r) { var i = { init: function (t, n) { var r = this; r.elem = n; r.$elem = e(n); r.newstagname = r.$elem.find(":first-child").prop("tagname"); r.newsclassname = r.$elem.find(":first-child").attr("class"); r.timer = null; r.resizetimer = null; r.animationstarted = false; r.ishovered = false; if (typeof t === "string") { if (console) { console.error("string property override is not supported") } throw "string property override is not supported" } else { r.options = e.extend({}, e.fn.bootstrapnews.options, t); r.preparelayout(); if (r.options.autoplay) { r.animate() } if (r.options.navigation) { r.buildnavigation() } if (typeof r.options.ontodo === "function") { r.options.ontodo.apply(r, arguments) } } }, preparelayout: function () { var n = this; e(n.elem).find("." + n.newsclassname).on("mouseenter", function () { n.onreset(true) }); e(n.elem).find("." + n.newsclassname).on("mouseout", function () { n.onreset(false) }); e.map(n.$elem.find(n.newstagname), function (t, r) { if (r > n.options.newsperpage - 1) { e(t).hide() } else { e(t).show() } }); if (n.$elem.find(n.newstagname).length < n.options.newsperpage) { n.options.newsperpage = n.$elem.find(n.newstagname).length } var r = 0; e.map(n.$elem.find(n.newstagname), function (t, i) { if (i < n.options.newsperpage) { r = parseint(r) + parseint(e(t).height()) + 10 } }); e(n.elem).css({ "overflow-y": "hidden", height: r }); e(t).resize(function () { if (n.resizetimer !== null) { cleartimeout(n.resizetimer) } n.resizetimer = settimeout(function () { n.preparelayout() }, 200) }) }, findpanelobject: function () { var e = this.$elem; while (e.parent() !== r) { e = e.parent(); if (e.parent().hasclass("panel")) { return e.parent() } } return r }, buildnavigation: function () { var t = this.findpanelobject(); if (t) { var n = '
'; var r = e(t).find(".panel-footer")[0]; if (r) { e(r).append(n) } else { e(t).append('") } var i = this; e(t).find(".prev").on("click", function (e) { e.preventdefault(); i.onprev() }); e(t).find(".next").on("click", function (e) { e.preventdefault(); i.onnext() }) } }, onstop: function () { }, onpause: function () { var e = this; e.ishovered = true; if (this.options.autoplay && e.timer) { cleartimeout(e.timer) } }, onreset: function (e) { var t = this; if (t.timer) { cleartimeout(t.timer) } if (t.options.autoplay) { t.ishovered = e; t.animate() } }, animate: function () { var e = this; e.timer = settimeout(function () { if (!e.options.pauseonhover) { e.ishovered = false } if (!e.ishovered) { if (e.options.direction === "up") { e.onnext() } else { e.onprev() } } }, e.options.newstickerinterval) }, onprev: function () { var t = this; if (t.animationstarted) { return false } t.animationstarted = true; var n = "<" + t.newstagname + ' style="display:none;" class="' + t.newsclassname + '">' + e(t.$elem).find(t.newstagname).last().html() + ""; e(t.$elem).prepend(n); e(t.$elem).find(t.newstagname).first().slidedown(t.options.animationspeed, function () { e(t.$elem).find(t.newstagname).last().remove() }); e(t.$elem).find(t.newstagname + ":nth-child(" + parseint(t.options.newsperpage + 1) + ")").slideup(t.options.animationspeed, function () { t.animationstarted = false; t.onreset(t.ishovered) }); e(t.elem).find("." + t.newsclassname).on("mouseenter", function () { t.onreset(true) }); e(t.elem).find("." + t.newsclassname).on("mouseout", function () { t.onreset(false) }) }, onnext: function () { var t = this; if (t.animationstarted) { return false } t.animationstarted = true; var n = "<" + t.newstagname + ' style="display:none;" class=' + t.newsclassname + ">" + e(t.$elem).find(t.newstagname).first().html() + ""; e(t.$elem).append(n); e(t.$elem).find(t.newstagname).first().slideup(t.options.animationspeed, function () { e(this).remove() }); e(t.$elem).find(t.newstagname + ":nth-child(" + parseint(t.options.newsperpage + 1) + ")").slidedown(t.options.animationspeed, function () { t.animationstarted = false; t.onreset(t.ishovered) }); e(t.elem).find("." + t.newsclassname).on("mouseenter", function () { t.onreset(true) }); e(t.elem).find("." + t.newsclassname).on("mouseout", function () { t.onreset(false) }) } }; e.fn.bootstrapnews = function (e) { return this.each(function () { var t = object.create(i); t.init(e, this) }) }; e.fn.bootstrapnews.options = { newsperpage: 4, navigation: true, autoplay: true, direction: "up", animationspeed: "normal", newstickerinterval: 4e3, pauseonhover: true, onstop: null, onpause: null, onreset: null, onprev: null, onnext: null, ontodo: null} })(jquery, window, document)