From d0ff724cb4627dc01af2de09f3de7121f03b6273 Mon Sep 17 00:00:00 2001 From: Vyatcheslav Suharnikov Date: Mon, 17 Nov 2014 15:53:37 +0300 Subject: [PATCH 1/2] Fixed formatting --- .gitignore | 0 jquery.doubleScroll.js | 42 +++++++++++++++++++++--------------------- 2 files changed, 21 insertions(+), 21 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/jquery.doubleScroll.js b/jquery.doubleScroll.js index 139c4ff..8acc534 100644 --- a/jquery.doubleScroll.js +++ b/jquery.doubleScroll.js @@ -10,28 +10,28 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html */ - -(function($){ + +(function ($) { $.widget("suwala.doubleScroll", { - options: { + options: { contentElement: undefined, // Widest element, if not specified first child element will be used - topScrollBarMarkup: '
', - topScrollBarInnerSelector: '.suwala-doubleScroll-scroll', - scrollCss: { - 'overflow-x': 'scroll', - 'overflow-y':'hidden' + topScrollBarMarkup: '
', + topScrollBarInnerSelector: '.suwala-doubleScroll-scroll', + scrollCss: { + 'overflow-x': 'scroll', + 'overflow-y': 'hidden' }, - contentCss: { - 'overflow-x': 'scroll', - 'overflow-y':'hidden' - } - }, - _create : function() { + contentCss: { + 'overflow-x': 'scroll', + 'overflow-y': 'hidden' + } + }, + _create: function () { var self = this; - var contentElement; + var contentElement; // add div that will act as an upper scroll - var topScrollBar = $($(self.options.topScrollBarMarkup)); + var topScrollBar = $($(self.options.topScrollBarMarkup)); self.element.before(topScrollBar); // find the content element (should be the widest one) @@ -43,12 +43,12 @@ } // bind upper scroll to bottom scroll - topScrollBar.scroll(function(){ + topScrollBar.scroll(function () { self.element.scrollLeft(topScrollBar.scrollLeft()); }); - + // bind bottom scroll to upper scroll - self.element.scroll(function(){ + self.element.scroll(function () { topScrollBar.scrollLeft(self.element.scrollLeft()); }); @@ -60,11 +60,11 @@ $(self.options.topScrollBarInnerSelector, topScrollBar).width(contentElement[0].scrollWidth); topScrollBar.width(self.element[0].clientWidth); }, - refresh: function(){ + refresh: function () { // this should be called if the content of the inner element changed. // i.e. After AJAX data load var self = this; - var contentElement; + var contentElement; var topScrollBar = self.element.parent().find('.suwala-doubleScroll-scroll-wrapper'); // find the content element (should be the widest one) From 671932a7fa9e3208bddc4924b1e374be4177afd6 Mon Sep 17 00:00:00 2001 From: Vyatcheslav Suharnikov Date: Mon, 17 Nov 2014 15:55:58 +0300 Subject: [PATCH 2/2] AMD support --- jquery.doubleScroll.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/jquery.doubleScroll.js b/jquery.doubleScroll.js index 8acc534..23b4605 100644 --- a/jquery.doubleScroll.js +++ b/jquery.doubleScroll.js @@ -11,7 +11,15 @@ * http://www.gnu.org/licenses/gpl.html */ -(function ($) { +(function (factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['jquery'], factory); + } else { + // Browser globals + factory(jQuery); + } +}(function ($) { $.widget("suwala.doubleScroll", { options: { contentElement: undefined, // Widest element, if not specified first child element will be used @@ -80,4 +88,4 @@ topScrollBar.width(self.element[0].clientWidth); } }); -})(jQuery); +}));