1 if (typeof Object.create !== "function") {
2 Object.create = function(obj) {
10 (function($, window, document) {
22 init: function(options, el) {
26 base.$content = $('.newstape-content', base.$elem);
28 base.options = $.extend({}, $.fn.newstape.options, base.$elem.data(), options);
30 var heightRefresh = function() {
31 base.height = base.$elem.outerHeight();
32 base.contentHeight = base.$content.outerHeight();
35 if (base.options.heightSpy) {
36 setInterval(heightRefresh, 1000);
41 var play = function() {
42 base.timer = setInterval(function() {
44 }, base.options.period);
47 base.$elem.bind('mouseover.newstape', function() {
48 clearInterval(base.timer);
51 base.$elem.bind('mouseout.newstape', function() {
55 if (base.options.mousewheel) {
56 base.$elem.bind('mousewheel.newstape', function(e) {
58 base.pos = (e.deltaY > 0) ? base.pos + base.options.mousewheelRate : base.pos - base.options.mousewheelRate;
63 $('a', base.$elem).focus(function(e) {
64 base.$elem.scrollTop(0);
65 base.pos = base.height - $(this).position().top - $(this).outerHeight();
69 if (base.options.dragable) {
70 base.$elem.bind('dragstart.newstape', function(e, dd) {
72 base.dragDeltaYReduce = 0;
73 base.dragstartPos = base.pos;
74 base.$elem.addClass('newstape-drag');
75 }).bind('drag.newstape', function(e, dd) {
76 base.dragDeltaY = dd.deltaY;
77 base.pos = base.dragstartPos + (dd.deltaY - base.dragDeltaYReduce);
79 }).bind('dragend.newstape', function(e, dd) {
80 base.$elem.removeClass('newstape-drag');
89 var dragUpdate = function() {
90 base.dragstartPos = base.pos;
91 base.dragDeltaYReduce = base.dragDeltaY;
95 if (base.pos <= base.contentHeight * -1) {
96 base.pos = base.height;
100 if (base.pos >= base.height + base.options.offset) {
101 base.pos = base.contentHeight * -1;
105 if (!base.$elem.hasClass('newstape-drag')) {
106 base.pos = base.pos - base.options.offset;
109 base.$content.css('top', parseInt(base.pos) + 'px');
113 $.fn.newstape = function(options) {
114 return this.each(function() {
115 if ($(this).data("newstape-init") === true) {
119 $(this).data("newstape-init", true);
120 var newstape = Object.create(Newstape);
121 newstape.init(options, this);
122 $.data(this, "newstape", newstape);
126 $.fn.newstape.options = {
135 }(jQuery, window, document));