1 /* vi: set et sw=4 ts=4 si: */
2 (function($, undefined) {
3 var ChSimpleScrollable = function(element, options) {
4 $.fn.ch_widget.Constructor(element, options);
5 this.$element = $(element);
6 this.options = $.extend(
8 $.fn.ch_widget.defaults,
13 ChSimpleScrollable.prototype = $.extend(
15 $.fn.ch_widget.Constructor.prototype,
17 constructor: ChSimpleScrollable,
21 $this = self.$element,
22 $up = $('<div/>').addClass('ch-simple-scrollable-up'),
23 $dn = $('<div/>').addClass('ch-simple-scrollable-dn'),
24 $child = $this.find('ul, ol, div, p'),
27 $child.addClass('ch-simple-scrollable-content');
28 $child.height($child.parent().height() - 160);
29 scrollAmount = $child.height() - 40;
32 $up.css({top: $child.offset().top});
34 $up.html('<a href="#"><i class="icon-chevron-up"></i></a>');
35 $dn.html('<a href="#"><i class="icon-chevron-down"></i></a>');
37 $dn.click(function() {
39 scrollTop: $child.scrollTop() + scrollAmount
43 $up.click(function() {
45 scrollTop: $child.scrollTop() - scrollAmount
50 $up.insertBefore($child);
51 $dn.insertAfter($child);
57 /* CHSIMPLESCROLLABLE PLUGIN DEFINITION
58 * ==================================== */
60 var old = $.fn.ch_simple_scrollable;
62 $.fn.ch_simple_scrollable = function(option) {
63 return this.each(function() {
65 data = $this.data('ch_simple_scrollable'),
66 options = typeof option == 'object' && option;
69 $this.data('ch_simple_scrollable', (data = new ChSimpleScrollable(this, options)));
73 if(typeof option == 'string')
78 $.fn.ch_simple_scrollable.Constructor = ChSimpleScrollable;
81 /* CHSIMPLESCROLLABLE NO CONFLICT
82 * ============================== */
84 $.fn.ch_simple_scrollable.noConflict = function() {
85 $.fn.ch_simple_scrollable = old;
90 /* CHSIMPLESCROLLABLE DATA-API
91 * =========================== */
94 $('div.ch-simple-scrollable').ch_simple_scrollable('enable');