jquery-bootstrap-pagination 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
    
        data/Gemfile
    CHANGED
    
    
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            PATH
         | 
| 2 2 | 
             
              remote: .
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                jquery-bootstrap-pagination (0.0 | 
| 4 | 
            +
                jquery-bootstrap-pagination (1.0.0)
         | 
| 5 5 |  | 
| 6 6 | 
             
            GEM
         | 
| 7 7 | 
             
              remote: https://rubygems.org/
         | 
| @@ -55,6 +55,7 @@ GEM | |
| 55 55 | 
             
                  slop (~> 3.3.1)
         | 
| 56 56 | 
             
                rack (1.4.1)
         | 
| 57 57 | 
             
                rainbow (1.1.4)
         | 
| 58 | 
            +
                rb-fsevent (0.9.2)
         | 
| 58 59 | 
             
                rspec (2.12.0)
         | 
| 59 60 | 
             
                  rspec-core (~> 2.12.0)
         | 
| 60 61 | 
             
                  rspec-expectations (~> 2.12.0)
         | 
| @@ -88,3 +89,4 @@ DEPENDENCIES | |
| 88 89 | 
             
              jasmine
         | 
| 89 90 | 
             
              jasmine-headless-webkit
         | 
| 90 91 | 
             
              jquery-bootstrap-pagination!
         | 
| 92 | 
            +
              rb-fsevent
         | 
| @@ -93,6 +93,12 @@ describe "pagination", -> | |
| 93 93 | 
             
                    </div>
         | 
| 94 94 | 
             
                  """)
         | 
| 95 95 |  | 
| 96 | 
            +
                it "renders nothing if there is only 1 page", ->
         | 
| 97 | 
            +
                  @view.settings.total_pages = 1
         | 
| 98 | 
            +
                  @view.settings.current_page = 1
         | 
| 99 | 
            +
                  @view.render()
         | 
| 100 | 
            +
                  expect(@page.html()).toEqual("")
         | 
| 101 | 
            +
             | 
| 96 102 | 
             
                it "adds 'active' to the current page", ->
         | 
| 97 103 | 
             
                  @view.settings.current_page = 2
         | 
| 98 104 | 
             
                  @view.render()
         | 
| @@ -40,6 +40,8 @@ | |
| 40 40 | 
             
                    last: false
         | 
| 41 41 | 
             
                    # how many links before truncation happens:
         | 
| 42 42 | 
             
                    display_max: 8
         | 
| 43 | 
            +
                    # render nothing if there is only 1 page:
         | 
| 44 | 
            +
                    ignore_single_page: true
         | 
| 43 45 |  | 
| 44 46 | 
             
                  # merge defaults with passed in options:
         | 
| 45 47 | 
             
                  @settings = $.extend(defaults, options)
         | 
| @@ -130,6 +132,12 @@ | |
| 130 132 | 
             
                # renders the pagination links to the element. the
         | 
| 131 133 | 
             
                # element is cleared of all of it's HTML in this process.
         | 
| 132 134 | 
             
                render: =>
         | 
| 135 | 
            +
                  # if there is only 1 page and the 'ignore_single_page' flag
         | 
| 136 | 
            +
                  # is 'true' then render nothing.
         | 
| 137 | 
            +
                  if @settings.total_pages is 1 and @settings.ignore_single_page
         | 
| 138 | 
            +
                    @el.html("")
         | 
| 139 | 
            +
                    return
         | 
| 140 | 
            +
                  # render all of the pages:
         | 
| 133 141 | 
             
                  html = ["<div class='jquery-bootstrap-pagination'>"]
         | 
| 134 142 | 
             
                  html.push "<ul>"
         | 
| 135 143 | 
             
                  for link in @buildLinks()
         | 
| @@ -45,7 +45,8 @@ | |
| 45 45 | 
             
                      prev: "<",
         | 
| 46 46 | 
             
                      first: false,
         | 
| 47 47 | 
             
                      last: false,
         | 
| 48 | 
            -
                      display_max: 8
         | 
| 48 | 
            +
                      display_max: 8,
         | 
| 49 | 
            +
                      ignore_single_page: true
         | 
| 49 50 | 
             
                    };
         | 
| 50 51 | 
             
                    this.settings = $.extend(defaults, options);
         | 
| 51 52 | 
             
                    $("a", this.el).live("click", this.clicked);
         | 
| @@ -132,6 +133,10 @@ | |
| 132 133 |  | 
| 133 134 | 
             
                  PaginationView.prototype.render = function() {
         | 
| 134 135 | 
             
                    var html, link, _i, _len, _ref;
         | 
| 136 | 
            +
                    if (this.settings.total_pages === 1 && this.settings.ignore_single_page) {
         | 
| 137 | 
            +
                      this.el.html("");
         | 
| 138 | 
            +
                      return;
         | 
| 139 | 
            +
                    }
         | 
| 135 140 | 
             
                    html = ["<div class='jquery-bootstrap-pagination'>"];
         | 
| 136 141 | 
             
                    html.push("<ul>");
         | 
| 137 142 | 
             
                    _ref = this.buildLinks();
         |