diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-01-27 20:47:19 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-01-27 20:47:19 +0400 |
commit | ce0ec05c6371e055e9cc90e6239cafc015a6a69b (patch) | |
tree | d0a9cbc2000c12d492ee992ff9b236e813ebd09c /app/assets/javascripts | |
parent | e3c3c67b25e2601194293885818ff4dfb39885cd (diff) |
Pager.js to coffee
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r-- | app/assets/javascripts/pager.js | 56 | ||||
-rw-r--r-- | app/assets/javascripts/pager.js.coffee | 42 |
2 files changed, 42 insertions, 56 deletions
diff --git a/app/assets/javascripts/pager.js b/app/assets/javascripts/pager.js deleted file mode 100644 index 7edd6bd6186..00000000000 --- a/app/assets/javascripts/pager.js +++ /dev/null @@ -1,56 +0,0 @@ -var Pager = { - limit:0, - offset:0, - disable:false, - - init: - function(limit, preload) { - this.limit=limit; - - if(preload) { - this.offset = 0; - this.getOld(); - } else { - this.offset = limit; - } - - this.initLoadMore(); - }, - - getOld: - function() { - $('.loading').show(); - $.ajax({ - type: "GET", - url: location.href, - data: "limit=" + this.limit + "&offset=" + this.offset, - complete: function(){ $('.loading').hide()}, - dataType: "script"}); - }, - - append: - function(count, html) { - $(".content_list").append(html); - if(count > 0) { - this.offset += count; - } else { - this.disable = true; - } - }, - - initLoadMore: - function() { - $(document).endlessScroll({ - bottomPixels: 400, - fireDelay: 1000, - fireOnce:true, - ceaseFire: function() { - return Pager.disable; - }, - callback: function(i) { - $('.loading').show(); - Pager.getOld(); - } - }); - } -} diff --git a/app/assets/javascripts/pager.js.coffee b/app/assets/javascripts/pager.js.coffee new file mode 100644 index 00000000000..5f606acdf9c --- /dev/null +++ b/app/assets/javascripts/pager.js.coffee @@ -0,0 +1,42 @@ +@Pager = + limit: 0 + offset: 0 + disable: false + init: (limit, preload) -> + @limit = limit + if preload + @offset = 0 + @getOld() + else + @offset = limit + @initLoadMore() + + getOld: -> + $(".loading").show() + $.ajax + type: "GET" + url: location.href + data: "limit=" + @limit + "&offset=" + @offset + complete: -> + $(".loading").hide() + + dataType: "script" + + append: (count, html) -> + $(".content_list").append html + if count > 0 + @offset += count + else + @disable = true + + initLoadMore: -> + $(document).endlessScroll + bottomPixels: 400 + fireDelay: 1000 + fireOnce: true + ceaseFire: -> + Pager.disable + + callback: (i) -> + $(".loading").show() + Pager.getOld() |