upjs-rails 0.17.0 → 0.18.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +46 -1
- data/dist/up.js +929 -374
- data/dist/up.min.js +2 -2
- data/lib/assets/javascripts/up/browser.js.coffee +31 -14
- data/lib/assets/javascripts/up/bus.js.coffee +87 -22
- data/lib/assets/javascripts/up/flow.js.coffee +119 -43
- data/lib/assets/javascripts/up/form.js.coffee +188 -57
- data/lib/assets/javascripts/up/link.js.coffee +57 -21
- data/lib/assets/javascripts/up/modal.js.coffee +77 -63
- data/lib/assets/javascripts/up/motion.js.coffee +10 -9
- data/lib/assets/javascripts/up/popup.js.coffee +54 -40
- data/lib/assets/javascripts/up/proxy.js.coffee +46 -17
- data/lib/assets/javascripts/up/rails.js.coffee +22 -4
- data/lib/assets/javascripts/up/syntax.js.coffee +2 -2
- data/lib/assets/javascripts/up/util.js.coffee +100 -16
- data/lib/upjs/rails/inspector.rb +3 -3
- data/lib/upjs/rails/version.rb +1 -1
- data/spec_app/Gemfile.lock +1 -4
- data/spec_app/app/controllers/test_controller.rb +2 -2
- data/spec_app/spec/controllers/test_controller_spec.rb +5 -5
- data/spec_app/spec/javascripts/helpers/browser_switches.js.coffee +9 -0
- data/spec_app/spec/javascripts/helpers/knife.js.coffee +0 -1
- data/spec_app/spec/javascripts/helpers/reset_path.js.coffee +4 -5
- data/spec_app/spec/javascripts/helpers/to_be_present.js.coffee +5 -0
- data/spec_app/spec/javascripts/helpers/to_have_request_method.js.coffee +8 -0
- data/spec_app/spec/javascripts/up/bus_spec.js.coffee +26 -0
- data/spec_app/spec/javascripts/up/flow_spec.js.coffee +203 -91
- data/spec_app/spec/javascripts/up/form_spec.js.coffee +244 -49
- data/spec_app/spec/javascripts/up/history_spec.js.coffee +8 -2
- data/spec_app/spec/javascripts/up/link_spec.js.coffee +83 -30
- data/spec_app/spec/javascripts/up/modal_spec.js.coffee +23 -17
- data/spec_app/spec/javascripts/up/motion_spec.js.coffee +4 -4
- data/spec_app/spec/javascripts/up/navigation_spec.js.coffee +1 -1
- data/spec_app/spec/javascripts/up/popup_spec.js.coffee +26 -16
- data/spec_app/spec/javascripts/up/proxy_spec.js.coffee +45 -13
- data/spec_app/spec/javascripts/up/rails_spec.js.coffee +48 -0
- data/spec_app/spec/javascripts/up/util_spec.js.coffee +48 -0
- metadata +5 -2
| @@ -14,7 +14,7 @@ describe 'up.history', -> | |
| 14 14 |  | 
| 15 15 | 
             
                describe '[up-back]', ->
         | 
| 16 16 |  | 
| 17 | 
            -
                   | 
| 17 | 
            +
                  describeCapability 'canPushState', ->
         | 
| 18 18 |  | 
| 19 19 | 
             
                    it 'sets an [up-href] attribute to the previous URL and sets the up-restore-scroll attribute to "true"', ->
         | 
| 20 20 | 
             
                      up.history.push('/one')
         | 
| @@ -29,9 +29,15 @@ describe 'up.history', -> | |
| 29 29 |  | 
| 30 30 | 
             
                  it 'does not set an up-href attribute if there is no previous URL'
         | 
| 31 31 |  | 
| 32 | 
            +
                describeFallback 'canPushState', ->
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                  it 'does not change the element', ->
         | 
| 35 | 
            +
                    $element = up.hello(affix('a[href="/three"][up-back]').text('text'))
         | 
| 36 | 
            +
                    expect($element.attr('up-href')).toBeUndefined()
         | 
| 37 | 
            +
             | 
| 32 38 | 
             
                describe 'scroll restauration', ->
         | 
| 33 39 |  | 
| 34 | 
            -
                   | 
| 40 | 
            +
                  describeCapability 'canPushState', ->
         | 
| 35 41 |  | 
| 36 42 | 
             
                    afterEach ->
         | 
| 37 43 | 
             
                      $('.viewport').remove()
         | 
| @@ -5,8 +5,8 @@ describe 'up.link', -> | |
| 5 5 | 
             
              describe 'Javascript functions', ->
         | 
| 6 6 |  | 
| 7 7 | 
             
                describe 'up.follow', ->
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                   | 
| 8 | 
            +
             | 
| 9 | 
            +
                  describeCapability 'canPushState', ->
         | 
| 10 10 |  | 
| 11 11 | 
             
                    it 'loads the given link via AJAX and replaces the response in the given target', (done) ->
         | 
| 12 12 | 
             
                      affix('.before').text('old-before')
         | 
| @@ -32,7 +32,7 @@ describe 'up.link', -> | |
| 32 32 | 
             
                      $link = affix('a[href="/path"][data-method="PUT"]')
         | 
| 33 33 | 
             
                      up.follow($link)
         | 
| 34 34 | 
             
                      request = @lastRequest()
         | 
| 35 | 
            -
                      expect(request | 
| 35 | 
            +
                      expect(request).toHaveRequestMethod('PUT')
         | 
| 36 36 |  | 
| 37 37 | 
             
                    it 'allows to refer to the link itself as "&" in the CSS selector', ->
         | 
| 38 38 | 
             
                      $container = affix('div')
         | 
| @@ -142,7 +142,26 @@ describe 'up.link', -> | |
| 142 142 | 
             
            #
         | 
| 143 143 | 
             
            #          it "doesn't make a request and reveals the target of a #hash in the URL"
         | 
| 144 144 |  | 
| 145 | 
            -
             | 
| 145 | 
            +
                    describe 'with { confirm } option', ->
         | 
| 146 | 
            +
             | 
| 147 | 
            +
                      it 'follows the link after the user OKs a confirmation dialog', ->
         | 
| 148 | 
            +
                        deferred = $.Deferred()
         | 
| 149 | 
            +
                        spyOn(up.browser, 'confirm').and.returnValue(deferred)
         | 
| 150 | 
            +
                        spyOn(up, 'replace')
         | 
| 151 | 
            +
                        $link = affix('a[href="/danger"][up-target=".middle"]')
         | 
| 152 | 
            +
                        up.follow($link, confirm: 'Do you really want to go there?')
         | 
| 153 | 
            +
                        expect(up.browser.confirm).toHaveBeenCalledWith('Do you really want to go there?')
         | 
| 154 | 
            +
                        expect(up.replace).not.toHaveBeenCalled()
         | 
| 155 | 
            +
                        deferred.resolve()
         | 
| 156 | 
            +
                        expect(up.replace).toHaveBeenCalled()
         | 
| 157 | 
            +
             | 
| 158 | 
            +
                      it 'does not show a confirmation dialog if the option is not a present string', ->
         | 
| 159 | 
            +
                        spyOn(up, 'replace')
         | 
| 160 | 
            +
                        $link = affix('a[href="/danger"][up-target=".middle"]')
         | 
| 161 | 
            +
                        up.follow($link, confirm: '')
         | 
| 162 | 
            +
                        expect(up.replace).toHaveBeenCalled()
         | 
| 163 | 
            +
             | 
| 164 | 
            +
                  describeFallback 'canPushState', ->
         | 
| 146 165 |  | 
| 147 166 | 
             
                    it 'follows the given link', ->
         | 
| 148 167 | 
             
                      $link = affix('a[href="/path"]')
         | 
| @@ -172,23 +191,25 @@ describe 'up.link', -> | |
| 172 191 | 
             
                    $form.click()
         | 
| 173 192 | 
             
                    expect(followSpy).not.toHaveBeenCalled()
         | 
| 174 193 |  | 
| 175 | 
            -
                   | 
| 176 | 
            -
             | 
| 177 | 
            -
                     | 
| 178 | 
            -
             | 
| 179 | 
            -
             | 
| 180 | 
            -
             | 
| 181 | 
            -
             | 
| 182 | 
            -
             | 
| 183 | 
            -
             | 
| 184 | 
            -
             | 
| 185 | 
            -
                     | 
| 186 | 
            -
             | 
| 187 | 
            -
             | 
| 188 | 
            -
                       | 
| 189 | 
            -
                       | 
| 190 | 
            -
             | 
| 191 | 
            -
             | 
| 194 | 
            +
                  describeCapability 'canPushState', ->
         | 
| 195 | 
            +
             | 
| 196 | 
            +
                    it 'adds a history entry', ->
         | 
| 197 | 
            +
                      affix('.target')
         | 
| 198 | 
            +
                      $link = affix('a[href="/path"][up-target=".target"]')
         | 
| 199 | 
            +
                      $link.click()
         | 
| 200 | 
            +
                      @respondWith('<div class="target">new text</div>')
         | 
| 201 | 
            +
                      expect($('.target')).toHaveText('new text')
         | 
| 202 | 
            +
                      expect(location.pathname).toEqual('/path')
         | 
| 203 | 
            +
             | 
| 204 | 
            +
                    it 'respects a X-Up-Location header that the server sends in case of a redirect', ->
         | 
| 205 | 
            +
                      affix('.target')
         | 
| 206 | 
            +
                      $link = affix('a[href="/path"][up-target=".target"]')
         | 
| 207 | 
            +
                      $link.click()
         | 
| 208 | 
            +
                      @respondWith
         | 
| 209 | 
            +
                        responseText: '<div class="target">new text</div>'
         | 
| 210 | 
            +
                        responseHeaders: { 'X-Up-Location': '/other/path' }
         | 
| 211 | 
            +
                      expect($('.target')).toHaveText('new text')
         | 
| 212 | 
            +
                      expect(location.pathname).toEqual('/other/path')
         | 
| 192 213 |  | 
| 193 214 | 
             
                  it 'does not add a history entry when an up-history attribute is set to "false"', ->
         | 
| 194 215 | 
             
                    oldPathname = location.pathname
         | 
| @@ -212,9 +233,11 @@ describe 'up.link', -> | |
| 212 233 | 
             
                    Trigger.click(@$link)
         | 
| 213 234 | 
             
                    expect(@followSpy).toHaveBeenCalledWith(@$link)
         | 
| 214 235 |  | 
| 215 | 
            -
                   | 
| 216 | 
            -
             | 
| 217 | 
            -
                     | 
| 236 | 
            +
                  # IE does not call Javascript and always performs the default action on right clicks
         | 
| 237 | 
            +
                  unless navigator.userAgent.match(/Trident/)
         | 
| 238 | 
            +
                    it 'does nothing if the right mouse button is used', ->
         | 
| 239 | 
            +
                      Trigger.click(@$link, button: 2)
         | 
| 240 | 
            +
                      expect(@followSpy).not.toHaveBeenCalled()
         | 
| 218 241 |  | 
| 219 242 | 
             
                  it 'does nothing if shift is pressed during the click', ->
         | 
| 220 243 | 
             
                    Trigger.click(@$link, shiftKey: true)
         | 
| @@ -224,9 +247,9 @@ describe 'up.link', -> | |
| 224 247 | 
             
                    Trigger.click(@$link, ctrlKey: true)
         | 
| 225 248 | 
             
                    expect(@followSpy).not.toHaveBeenCalled()
         | 
| 226 249 |  | 
| 227 | 
            -
             | 
| 228 | 
            -
             | 
| 229 | 
            -
             | 
| 250 | 
            +
                  it 'does nothing if meta is pressed during the click', ->
         | 
| 251 | 
            +
                    Trigger.click(@$link, metaKey: true)
         | 
| 252 | 
            +
                    expect(@followSpy).not.toHaveBeenCalled()
         | 
| 230 253 |  | 
| 231 254 | 
             
                  describe 'with [up-instant] modifier', ->
         | 
| 232 255 |  | 
| @@ -245,9 +268,11 @@ describe 'up.link', -> | |
| 245 268 | 
             
                      Trigger.click(@$link)
         | 
| 246 269 | 
             
                      expect(@followSpy).not.toHaveBeenCalled()
         | 
| 247 270 |  | 
| 248 | 
            -
                     | 
| 249 | 
            -
             | 
| 250 | 
            -
                       | 
| 271 | 
            +
                    # IE does not call Javascript and always performs the default action on right clicks
         | 
| 272 | 
            +
                    unless navigator.userAgent.match(/Trident/)
         | 
| 273 | 
            +
                      it 'does nothing if the right mouse button is pressed down', ->
         | 
| 274 | 
            +
                        Trigger.mousedown(@$link, button: 2)
         | 
| 275 | 
            +
                        expect(@followSpy).not.toHaveBeenCalled()
         | 
| 251 276 |  | 
| 252 277 | 
             
                    it 'does nothing if shift is pressed during mousedown', ->
         | 
| 253 278 | 
             
                      Trigger.mousedown(@$link, shiftKey: true)
         | 
| @@ -275,6 +300,13 @@ describe 'up.link', -> | |
| 275 300 | 
             
                    up.hello($area)
         | 
| 276 301 | 
             
                    expect($area.attr('up-href')).toEqual('/path')
         | 
| 277 302 |  | 
| 303 | 
            +
                  it 'copies attributes from the first link if there are multiple links', ->
         | 
| 304 | 
            +
                    $area = affix('div[up-expand]')
         | 
| 305 | 
            +
                    $link1 = $area.affix('a[href="/path1"]')
         | 
| 306 | 
            +
                    $link2 = $area.affix('a[href="/path2"]')
         | 
| 307 | 
            +
                    up.hello($area)
         | 
| 308 | 
            +
                    expect($area.attr('up-href')).toEqual('/path1')
         | 
| 309 | 
            +
             | 
| 278 310 | 
             
                  it "copies an contained non-link element with up-href attribute", ->
         | 
| 279 311 | 
             
                    $area = affix('div[up-expand] span[up-follow][up-href="/path"]')
         | 
| 280 312 | 
             
                    up.hello($area)
         | 
| @@ -285,3 +317,24 @@ describe 'up.link', -> | |
| 285 317 | 
             
                    up.hello($area)
         | 
| 286 318 | 
             
                    expect($area.attr('up-follow')).toEqual('')
         | 
| 287 319 |  | 
| 320 | 
            +
                  describe 'with a CSS selector in the property value', ->
         | 
| 321 | 
            +
             | 
| 322 | 
            +
                    it "expands the contained link that matches the selector", ->
         | 
| 323 | 
            +
                      $area = affix('div[up-expand=".second"]')
         | 
| 324 | 
            +
                      $link1 = $area.affix('a.first[href="/path1"]')
         | 
| 325 | 
            +
                      $link2 = $area.affix('a.second[href="/path2"]')
         | 
| 326 | 
            +
                      up.hello($area)
         | 
| 327 | 
            +
                      expect($area.attr('up-href')).toEqual('/path2')
         | 
| 328 | 
            +
             | 
| 329 | 
            +
                    it 'does nothing if no contained link matches the selector', ->
         | 
| 330 | 
            +
                      $area = affix('div[up-expand=".foo"]')
         | 
| 331 | 
            +
                      $link = $area.affix('a[href="/path1"]')
         | 
| 332 | 
            +
                      up.hello($area)
         | 
| 333 | 
            +
                      expect($area.attr('up-href')).toBeUndefined()
         | 
| 334 | 
            +
             | 
| 335 | 
            +
                    it 'does not match an element that is not a descendant', ->
         | 
| 336 | 
            +
                      $area = affix('div[up-expand=".second"]')
         | 
| 337 | 
            +
                      $link1 = $area.affix('a.first[href="/path1"]')
         | 
| 338 | 
            +
                      $link2 = affix('a.second[href="/path2"]') # not a child of $area
         | 
| 339 | 
            +
                      up.hello($area)
         | 
| 340 | 
            +
                      expect($area.attr('up-href')).toBeUndefined()
         | 
| @@ -75,15 +75,17 @@ describe 'up.modal', -> | |
| 75 75 |  | 
| 76 76 | 
             
                describe 'up.modal.coveredUrl', ->
         | 
| 77 77 |  | 
| 78 | 
            -
                   | 
| 79 | 
            -
             | 
| 80 | 
            -
                     | 
| 81 | 
            -
             | 
| 82 | 
            -
                    @respondWith('<div class="container">text</div>')
         | 
| 83 | 
            -
                    expect(up.modal.coveredUrl()).toEndWith('/foo')
         | 
| 84 | 
            -
                    up.modal.close().then ->
         | 
| 78 | 
            +
                  describeCapability 'canPushState', ->
         | 
| 79 | 
            +
             | 
| 80 | 
            +
                    it 'returns the URL behind the modal overlay', (done) ->
         | 
| 81 | 
            +
                      up.history.replace('/foo')
         | 
| 85 82 | 
             
                      expect(up.modal.coveredUrl()).toBeUndefined()
         | 
| 86 | 
            -
                       | 
| 83 | 
            +
                      up.modal.visit('/bar', target: '.container')
         | 
| 84 | 
            +
                      @respondWith('<div class="container">text</div>')
         | 
| 85 | 
            +
                      expect(up.modal.coveredUrl()).toEndWith('/foo')
         | 
| 86 | 
            +
                      up.modal.close().then ->
         | 
| 87 | 
            +
                        expect(up.modal.coveredUrl()).toBeUndefined()
         | 
| 88 | 
            +
                        done()
         | 
| 87 89 |  | 
| 88 90 |  | 
| 89 91 | 
             
                describe 'up.modal.close', ->
         | 
| @@ -109,9 +111,11 @@ describe 'up.modal', -> | |
| 109 111 | 
             
                    Trigger.click(@$link)
         | 
| 110 112 | 
             
                    expect(@followSpy).toHaveBeenCalledWith(@$link)
         | 
| 111 113 |  | 
| 112 | 
            -
                   | 
| 113 | 
            -
             | 
| 114 | 
            -
                     | 
| 114 | 
            +
                  # IE does not call Javascript and always performs the default action on right clicks
         | 
| 115 | 
            +
                  unless navigator.userAgent.match(/Trident/)
         | 
| 116 | 
            +
                    it 'does nothing if the right mouse button is used', ->
         | 
| 117 | 
            +
                      Trigger.click(@$link, button: 2)
         | 
| 118 | 
            +
                      expect(@followSpy).not.toHaveBeenCalled()
         | 
| 115 119 |  | 
| 116 120 | 
             
                  it 'does nothing if shift is pressed during the click', ->
         | 
| 117 121 | 
             
                    Trigger.click(@$link, shiftKey: true)
         | 
| @@ -121,9 +125,9 @@ describe 'up.modal', -> | |
| 121 125 | 
             
                    Trigger.click(@$link, ctrlKey: true)
         | 
| 122 126 | 
             
                    expect(@followSpy).not.toHaveBeenCalled()
         | 
| 123 127 |  | 
| 124 | 
            -
             | 
| 125 | 
            -
             | 
| 126 | 
            -
             | 
| 128 | 
            +
                  it 'does nothing if meta is pressed during the click', ->
         | 
| 129 | 
            +
                    Trigger.click(@$link, metaKey: true)
         | 
| 130 | 
            +
                    expect(@followSpy).not.toHaveBeenCalled()
         | 
| 127 131 |  | 
| 128 132 | 
             
                  describe 'with [up-instant] modifier', ->
         | 
| 129 133 |  | 
| @@ -142,9 +146,11 @@ describe 'up.modal', -> | |
| 142 146 | 
             
                      Trigger.click(@$link)
         | 
| 143 147 | 
             
                      expect(@followSpy).not.toHaveBeenCalled()
         | 
| 144 148 |  | 
| 145 | 
            -
                     | 
| 146 | 
            -
             | 
| 147 | 
            -
                       | 
| 149 | 
            +
                    # IE does not call Javascript and always performs the default action on right clicks
         | 
| 150 | 
            +
                    unless navigator.userAgent.match(/Trident/)
         | 
| 151 | 
            +
                      it 'does nothing if the right mouse button is pressed down', ->
         | 
| 152 | 
            +
                        Trigger.mousedown(@$link, button: 2)
         | 
| 153 | 
            +
                        expect(@followSpy).not.toHaveBeenCalled()
         | 
| 148 154 |  | 
| 149 155 | 
             
                    it 'does nothing if shift is pressed during mousedown', ->
         | 
| 150 156 | 
             
                      Trigger.mousedown(@$link, shiftKey: true)
         | 
| @@ -4,7 +4,7 @@ describe 'up.motion', -> | |
| 4 4 |  | 
| 5 5 | 
             
                describe 'up.animate', ->
         | 
| 6 6 |  | 
| 7 | 
            -
                   | 
| 7 | 
            +
                  describeCapability 'canCssTransition', ->
         | 
| 8 8 |  | 
| 9 9 | 
             
                    it 'animates the given element', (done) ->
         | 
| 10 10 | 
             
                      $element = affix('.element').text('content')
         | 
| @@ -35,7 +35,7 @@ describe 'up.motion', -> | |
| 35 35 | 
             
                        up.animate($element, { 'font-size': '40px' }, duration: 10000, easing: 'linear')
         | 
| 36 36 | 
             
                        expect($element.css('font-size')).toEqual('40px')
         | 
| 37 37 |  | 
| 38 | 
            -
                   | 
| 38 | 
            +
                  describeFallback 'canCssTransition', ->
         | 
| 39 39 |  | 
| 40 40 | 
             
                    it "doesn't animate and directly sets the last frame instead", ->
         | 
| 41 41 | 
             
                      $element = affix('.element').text('content')
         | 
| @@ -45,7 +45,7 @@ describe 'up.motion', -> | |
| 45 45 |  | 
| 46 46 | 
             
                describe 'up.morph', ->
         | 
| 47 47 |  | 
| 48 | 
            -
                   | 
| 48 | 
            +
                  describeCapability 'canCssTransition', ->
         | 
| 49 49 |  | 
| 50 50 | 
             
                    it 'transitions between two element by animating two copies while keeping the originals in the background', (done) ->
         | 
| 51 51 |  | 
| @@ -209,7 +209,7 @@ describe 'up.motion', -> | |
| 209 209 | 
             
                        expect($new).toBeVisible()
         | 
| 210 210 | 
             
                        expect($new.css('opacity')).toEqual('1')
         | 
| 211 211 |  | 
| 212 | 
            -
                   | 
| 212 | 
            +
                  describeFallback 'canCssTransition', ->
         | 
| 213 213 |  | 
| 214 214 | 
             
                    it "doesn't animate and hides the old element instead", ->
         | 
| 215 215 | 
             
                      $old = affix('.old').text('old content')
         | 
| @@ -44,7 +44,7 @@ describe 'up.navigation', -> | |
| 44 44 | 
             
                  $currentLink = up.hello(affix('a[href="/foo"]'))
         | 
| 45 45 | 
             
                  expect($currentLink).toHaveClass('highlight up-current')
         | 
| 46 46 |  | 
| 47 | 
            -
                 | 
| 47 | 
            +
                describeCapability 'canPushState', ->
         | 
| 48 48 |  | 
| 49 49 | 
             
                  it 'marks a link as .up-current if it links to the current URL, but is missing a trailing slash', ->
         | 
| 50 50 | 
             
                    $link = affix('a[href="/foo"][up-target=".main"]')
         | 
| @@ -45,17 +45,19 @@ describe 'up.popup', -> | |
| 45 45 |  | 
| 46 46 | 
             
                describe 'up.popup.coveredUrl', ->
         | 
| 47 47 |  | 
| 48 | 
            -
                   | 
| 49 | 
            -
             | 
| 50 | 
            -
                     | 
| 51 | 
            -
             | 
| 52 | 
            -
                    $popupLink = affix('a[href="/bar"][up-popup=".container"]')
         | 
| 53 | 
            -
                    $popupLink.click()
         | 
| 54 | 
            -
                    @respondWith('<div class="container">text</div>')
         | 
| 55 | 
            -
                    expect(up.popup.coveredUrl()).toEndWith('/foo')
         | 
| 56 | 
            -
                    up.popup.close().then ->
         | 
| 48 | 
            +
                  describeCapability 'canPushState', ->
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                    it 'returns the URL behind the popup', (done) ->
         | 
| 51 | 
            +
                      up.history.replace('/foo')
         | 
| 57 52 | 
             
                      expect(up.popup.coveredUrl()).toBeUndefined()
         | 
| 58 | 
            -
             | 
| 53 | 
            +
             | 
| 54 | 
            +
                      $popupLink = affix('a[href="/bar"][up-popup=".container"]')
         | 
| 55 | 
            +
                      $popupLink.click()
         | 
| 56 | 
            +
                      @respondWith('<div class="container">text</div>')
         | 
| 57 | 
            +
                      expect(up.popup.coveredUrl()).toEndWith('/foo')
         | 
| 58 | 
            +
                      up.popup.close().then ->
         | 
| 59 | 
            +
                        expect(up.popup.coveredUrl()).toBeUndefined()
         | 
| 60 | 
            +
                        done()
         | 
| 59 61 |  | 
| 60 62 | 
             
                describe 'up.popup.close', ->
         | 
| 61 63 |  | 
| @@ -78,9 +80,11 @@ describe 'up.popup', -> | |
| 78 80 | 
             
                    Trigger.click(@$link)
         | 
| 79 81 | 
             
                    expect(@attachSpy).toHaveBeenCalledWith(@$link)
         | 
| 80 82 |  | 
| 81 | 
            -
                   | 
| 82 | 
            -
             | 
| 83 | 
            -
                     | 
| 83 | 
            +
                  # IE does not call Javascript and always performs the default action on right clicks
         | 
| 84 | 
            +
                  unless navigator.userAgent.match(/Trident/)
         | 
| 85 | 
            +
                    it 'does nothing if the right mouse button is used', ->
         | 
| 86 | 
            +
                      Trigger.click(@$link, button: 2)
         | 
| 87 | 
            +
                      expect(@attachSpy).not.toHaveBeenCalled()
         | 
| 84 88 |  | 
| 85 89 | 
             
                  it 'does nothing if shift is pressed during the click', ->
         | 
| 86 90 | 
             
                    Trigger.click(@$link, shiftKey: true)
         | 
| @@ -90,6 +94,10 @@ describe 'up.popup', -> | |
| 90 94 | 
             
                    Trigger.click(@$link, ctrlKey: true)
         | 
| 91 95 | 
             
                    expect(@attachSpy).not.toHaveBeenCalled()
         | 
| 92 96 |  | 
| 97 | 
            +
                  it 'does nothing if meta is pressed during the click', ->
         | 
| 98 | 
            +
                    Trigger.click(@$link, metaKey: true)
         | 
| 99 | 
            +
                    expect(@attachSpy).not.toHaveBeenCalled()
         | 
| 100 | 
            +
             | 
| 93 101 | 
             
                  describe 'with [up-instant] modifier', ->
         | 
| 94 102 |  | 
| 95 103 | 
             
                    beforeEach ->
         | 
| @@ -107,9 +115,11 @@ describe 'up.popup', -> | |
| 107 115 | 
             
                      Trigger.click(@$link)
         | 
| 108 116 | 
             
                      expect(@attachSpy).not.toHaveBeenCalled()
         | 
| 109 117 |  | 
| 110 | 
            -
                     | 
| 111 | 
            -
             | 
| 112 | 
            -
                       | 
| 118 | 
            +
                    # IE does not call Javascript and always performs the default action on right clicks
         | 
| 119 | 
            +
                    unless navigator.userAgent.match(/Trident/)
         | 
| 120 | 
            +
                      it 'does nothing if the right mouse button is pressed down', ->
         | 
| 121 | 
            +
                        Trigger.mousedown(@$link, button: 2)
         | 
| 122 | 
            +
                        expect(@attachSpy).not.toHaveBeenCalled()
         | 
| 113 123 |  | 
| 114 124 | 
             
                    it 'does nothing if shift is pressed during mousedown', ->
         | 
| 115 125 | 
             
                      Trigger.mousedown(@$link, shiftKey: true)
         | 
| @@ -41,26 +41,26 @@ describe 'up.proxy', -> | |
| 41 41 | 
             
                    expect(responses).toEqual(['foo', 'foo', 'bar'])
         | 
| 42 42 |  | 
| 43 43 | 
             
                  it "doesn't reuse responses when asked for the same path, but different selectors", ->
         | 
| 44 | 
            -
                    up.proxy.ajax(url: '/path',  | 
| 45 | 
            -
                    up.proxy.ajax(url: '/path',  | 
| 44 | 
            +
                    up.proxy.ajax(url: '/path', target: '.a')
         | 
| 45 | 
            +
                    up.proxy.ajax(url: '/path', target: '.b')
         | 
| 46 46 | 
             
                    expect(jasmine.Ajax.requests.count()).toEqual(2)
         | 
| 47 47 |  | 
| 48 48 | 
             
                  it "reuses a response for an 'html' selector when asked for the same path and any other selector", ->
         | 
| 49 | 
            -
                    up.proxy.ajax(url: '/path',  | 
| 50 | 
            -
                    up.proxy.ajax(url: '/path',  | 
| 51 | 
            -
                    up.proxy.ajax(url: '/path',  | 
| 52 | 
            -
                    up.proxy.ajax(url: '/path',  | 
| 49 | 
            +
                    up.proxy.ajax(url: '/path', target: 'html')
         | 
| 50 | 
            +
                    up.proxy.ajax(url: '/path', target: 'body')
         | 
| 51 | 
            +
                    up.proxy.ajax(url: '/path', target: 'p')
         | 
| 52 | 
            +
                    up.proxy.ajax(url: '/path', target: '.klass')
         | 
| 53 53 | 
             
                    expect(jasmine.Ajax.requests.count()).toEqual(1)
         | 
| 54 54 |  | 
| 55 55 | 
             
                  it "reuses a response for a 'body' selector when asked for the same path and any other selector other than 'html'", ->
         | 
| 56 | 
            -
                    up.proxy.ajax(url: '/path',  | 
| 57 | 
            -
                    up.proxy.ajax(url: '/path',  | 
| 58 | 
            -
                    up.proxy.ajax(url: '/path',  | 
| 56 | 
            +
                    up.proxy.ajax(url: '/path', target: 'body')
         | 
| 57 | 
            +
                    up.proxy.ajax(url: '/path', target: 'p')
         | 
| 58 | 
            +
                    up.proxy.ajax(url: '/path', target: '.klass')
         | 
| 59 59 | 
             
                    expect(jasmine.Ajax.requests.count()).toEqual(1)
         | 
| 60 60 |  | 
| 61 61 | 
             
                  it "doesn't reuse a response for a 'body' selector when asked for the same path but an 'html' selector", ->
         | 
| 62 | 
            -
                    up.proxy.ajax(url: '/path',  | 
| 63 | 
            -
                    up.proxy.ajax(url: '/path',  | 
| 62 | 
            +
                    up.proxy.ajax(url: '/path', target: 'body')
         | 
| 63 | 
            +
                    up.proxy.ajax(url: '/path', target: 'html')
         | 
| 64 64 | 
             
                    expect(jasmine.Ajax.requests.count()).toEqual(2)
         | 
| 65 65 |  | 
| 66 66 | 
             
                  it "doesn't reuse responses for different paths", ->
         | 
| @@ -101,11 +101,43 @@ describe 'up.proxy', -> | |
| 101 101 |  | 
| 102 102 | 
             
                    expect(jasmine.Ajax.requests.count()).toEqual(2)
         | 
| 103 103 |  | 
| 104 | 
            +
                  describe 'with config.wrapMethods set', ->
         | 
| 105 | 
            +
             | 
| 106 | 
            +
                    it 'should be set by default', ->
         | 
| 107 | 
            +
                      expect(up.proxy.config.wrapMethods).toBePresent()
         | 
| 108 | 
            +
             | 
| 109 | 
            +
            #        beforeEach ->
         | 
| 110 | 
            +
            #          @oldWrapMethod = up.proxy.config.wrapMethod
         | 
| 111 | 
            +
            #          up.proxy.config.wrapMethod = true
         | 
| 112 | 
            +
            #
         | 
| 113 | 
            +
            #        afterEach ->
         | 
| 114 | 
            +
            #          up.proxy.config.wrapMethod = @oldWrapMetod
         | 
| 115 | 
            +
             | 
| 116 | 
            +
                    u.each ['GET', 'POST', 'HEAD', 'OPTIONS'], (method) ->
         | 
| 117 | 
            +
             | 
| 118 | 
            +
                      it "does not change the method of a #{method} request", ->
         | 
| 119 | 
            +
                        up.proxy.ajax(url: '/foo', method: method)
         | 
| 120 | 
            +
                        request = @lastRequest()
         | 
| 121 | 
            +
                        expect(request.method).toEqual(method)
         | 
| 122 | 
            +
                        expect(request.data()['_method']).toBeUndefined()
         | 
| 123 | 
            +
             | 
| 124 | 
            +
                    u.each ['PUT', 'PATCH', 'DELETE'], (method) ->
         | 
| 125 | 
            +
             | 
| 126 | 
            +
                      it "turns a #{method} request into a POST request and sends the actual method as a { _method } param", ->
         | 
| 127 | 
            +
                        up.proxy.ajax(url: '/foo', method: method)
         | 
| 128 | 
            +
                        request = @lastRequest()
         | 
| 129 | 
            +
                        expect(request.method).toEqual('POST')
         | 
| 130 | 
            +
                        expect(request.data()['_method']).toEqual([method])
         | 
| 131 | 
            +
             | 
| 104 132 | 
             
                  describe 'with config.maxRequests set', ->
         | 
| 105 133 |  | 
| 106 134 | 
             
                    beforeEach ->
         | 
| 135 | 
            +
                      @oldMaxRequests = up.proxy.config.maxRequests
         | 
| 107 136 | 
             
                      up.proxy.config.maxRequests = 1
         | 
| 108 137 |  | 
| 138 | 
            +
                    afterEach ->
         | 
| 139 | 
            +
                      up.proxy.config.maxRequests = @oldMaxRequests
         | 
| 140 | 
            +
             | 
| 109 141 | 
             
                    it 'limits the number of concurrent requests', ->
         | 
| 110 142 | 
             
                      responses = []
         | 
| 111 143 | 
             
                      up.proxy.ajax(url: '/foo').then (html) -> responses.push(html)
         | 
| @@ -283,7 +315,7 @@ describe 'up.proxy', -> | |
| 283 315 |  | 
| 284 316 | 
             
                describe 'up.proxy.preload', ->
         | 
| 285 317 |  | 
| 286 | 
            -
                   | 
| 318 | 
            +
                  describeCapability 'canPushState', ->
         | 
| 287 319 |  | 
| 288 320 | 
             
                    it "loads and caches the given link's destination", ->
         | 
| 289 321 | 
             
                      $link = affix('a[href="/path"]')
         | 
| @@ -295,7 +327,7 @@ describe 'up.proxy', -> | |
| 295 327 | 
             
                      up.proxy.preload($link)
         | 
| 296 328 | 
             
                      expect(up.proxy.get(url: '/path')).toBeUndefined()
         | 
| 297 329 |  | 
| 298 | 
            -
                   | 
| 330 | 
            +
                  describeFallback 'canPushState', ->
         | 
| 299 331 |  | 
| 300 332 | 
             
                    it "does nothing", ->
         | 
| 301 333 | 
             
                      $link = affix('a[href="/path"]')
         |