1 /* vi: set et sw=4 ts=4 si: */
2 (function($, undefined) {
5 var ChSimpleScrollable = function(element, options) {
6 $.fn.ch_widget.Constructor(element, options);
7 this.$element = $(element);
8 this.options = $.extend(
10 $.fn.ch_widget.defaults,
15 ChSimpleScrollable.prototype = $.extend(
17 $.fn.ch_widget.Constructor.prototype,
19 constructor: ChSimpleScrollable,
23 $this = self.$element,
24 $up = $('<div/>').addClass('ch-simple-scrollable-up'),
25 $dn = $('<div/>').addClass('ch-simple-scrollable-dn'),
26 $child = $this.find('ul, ol, div, p'),
29 $child.addClass('ch-simple-scrollable-content');
30 $child.height($child.parent().height() - 160);
31 scrollAmount = $child.height() - 40;
34 $up.css({top: $child.offset().top});
36 $up.html('<a href="#"><i class="icon-chevron-up"></i></a>');
37 $dn.html('<a href="#"><i class="icon-chevron-down"></i></a>');
39 $dn.click(function() {
41 scrollTop: $child.scrollTop() + scrollAmount
45 $up.click(function() {
47 scrollTop: $child.scrollTop() - scrollAmount
52 $up.insertBefore($child);
53 $dn.insertAfter($child);
58 $.fn.ch_simple_scrollable = function(option) {
59 return this.each(function() {
61 data = $this.data('ch_simple_scrollable'),
62 options = typeof option == 'object' && option;
65 $this.data('ch_simple_scrollable', (data = new ChSimpleScrollable(this, options)));
69 if(typeof option == 'string')
74 $.fn.ch_simple_scrollable.Constructor = ChSimpleScrollable;
76 /* CHSIMPLESCROLLABLE DATA-API
77 * ================= */
79 $('div.ch-simple-scrollable').ch_simple_scrollable('enable');