upjs-rails 0.11.1 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +50 -0
  3. data/dist/up-bootstrap.js +9 -17
  4. data/dist/up-bootstrap.min.js +1 -1
  5. data/dist/up.js +384 -458
  6. data/dist/up.min.js +2 -2
  7. data/lib/assets/javascripts/up/boot.js.coffee +2 -2
  8. data/lib/assets/javascripts/up/browser.js.coffee +2 -2
  9. data/lib/assets/javascripts/up/bus.js.coffee +39 -88
  10. data/lib/assets/javascripts/up/flow.js.coffee +25 -33
  11. data/lib/assets/javascripts/up/form.js.coffee +2 -2
  12. data/lib/assets/javascripts/up/history.js.coffee +8 -7
  13. data/lib/assets/javascripts/up/layout.js.coffee +19 -18
  14. data/lib/assets/javascripts/up/link.js.coffee +2 -2
  15. data/lib/assets/javascripts/up/magic.js.coffee +41 -27
  16. data/lib/assets/javascripts/up/modal.js.coffee +74 -57
  17. data/lib/assets/javascripts/up/motion.js.coffee +11 -10
  18. data/lib/assets/javascripts/up/navigation.js.coffee +11 -10
  19. data/lib/assets/javascripts/up/popup.js.coffee +19 -16
  20. data/lib/assets/javascripts/up/proxy.js.coffee +17 -16
  21. data/lib/assets/javascripts/up/tooltip.js.coffee +28 -14
  22. data/lib/assets/javascripts/up/util.js.coffee +14 -22
  23. data/lib/assets/javascripts/up-bootstrap/layout-ext.js.coffee +5 -6
  24. data/lib/assets/javascripts/up-bootstrap/modal-ext.js.coffee +8 -8
  25. data/lib/assets/javascripts/up-bootstrap/navigation-ext.js.coffee +2 -5
  26. data/lib/assets/javascripts/up.js.coffee +0 -1
  27. data/lib/upjs/rails/version.rb +1 -1
  28. data/spec_app/Gemfile.lock +1 -1
  29. data/spec_app/spec/javascripts/up/bus_spec.js.coffee +43 -6
  30. data/spec_app/spec/javascripts/up/flow_spec.js.coffee +1 -1
  31. data/spec_app/spec/javascripts/up/history_spec.js.coffee +3 -3
  32. data/spec_app/spec/javascripts/up/layout_spec.js.coffee +9 -11
  33. data/spec_app/spec/javascripts/up/link_spec.js.coffee +7 -9
  34. data/spec_app/spec/javascripts/up/magic_spec.js.coffee +5 -5
  35. data/spec_app/spec/javascripts/up/modal_spec.js.coffee +8 -10
  36. data/spec_app/spec/javascripts/up/navigation_spec.js.coffee +13 -13
  37. data/spec_app/spec/javascripts/up/popup_spec.js.coffee +1 -5
  38. data/spec_app/spec/javascripts/up/proxy_spec.js.coffee +51 -52
  39. data/spec_app/spec/javascripts/up/tooltip_spec.js.coffee +19 -5
  40. data/spec_app/spec/javascripts/up/util_spec.js.coffee +14 -23
  41. metadata +1 -3
  42. data/lib/assets/javascripts/up/slot.js.coffee +0 -63
  43. data/spec_app/spec/javascripts/up/slot_spec.js.coffee +0 -16
@@ -21,16 +21,17 @@ We need to work on this page:
21
21
 
22
22
  @class up.popup
23
23
  ###
24
- up.popup = (->
24
+ up.popup = (($) ->
25
25
 
26
26
  u = up.util
27
27
 
28
28
  currentSource = undefined
29
29
 
30
30
  ###*
31
- @method up.popup.defaults
32
- @param {String} options.animation
33
- @param {String} options.position
31
+ @method up.popup.config
32
+ @param {String} config.openAnimation
33
+ @param {String} config.closeAnimation
34
+ @param {String} config.position
34
35
  ###
35
36
  config = u.config
36
37
  openAnimation: 'fade-in'
@@ -114,9 +115,9 @@ up.popup = (->
114
115
  up.animate($popup, animation, animateOptions)
115
116
 
116
117
  ###*
117
- Opens a popup overlay.
118
+ Attaches a popup overlay to the given element or selector.
118
119
 
119
- @method up.popup.open
120
+ @method up.popup.attach
120
121
  @param {Element|jQuery|String} elementOrSelector
121
122
  @param {String} [options.url]
122
123
  @param {String} [options.position='bottom-right']
@@ -133,7 +134,7 @@ up.popup = (->
133
134
  open even if the page changes in the background.
134
135
  @param {Object} [options.history=false]
135
136
  ###
136
- open = (linkOrSelector, options) ->
137
+ attach = (linkOrSelector, options) ->
137
138
  $link = $(linkOrSelector)
138
139
 
139
140
  options = u.options(options)
@@ -204,9 +205,9 @@ up.popup = (->
204
205
  $element.closest('.up-popup').length > 0
205
206
 
206
207
  ###*
207
- Opens the target of this link in a popup overlay:
208
+ Opens this link's destination of in a popup overlay:
208
209
 
209
- <a href="/decks" up-modal=".deck_list">Switch deck</a>
210
+ <a href="/decks" up-popup=".deck_list">Switch deck</a>
210
211
 
211
212
  If the `up-sticky` attribute is set, the dialog does not auto-close
212
213
  if a page fragment below the popup overlay updates:
@@ -224,7 +225,7 @@ up.popup = (->
224
225
  if $link.is('.up-current')
225
226
  close()
226
227
  else
227
- open($link)
228
+ attach($link)
228
229
  )
229
230
 
230
231
  # Close the popup when someone clicks outside the popup
@@ -235,7 +236,7 @@ up.popup = (->
235
236
  close()
236
237
  )
237
238
 
238
- up.bus.on('fragment:ready', ($fragment) ->
239
+ up.on('up:fragment:inserted', (event, $fragment) ->
239
240
  if contains($fragment)
240
241
  if newSource = $fragment.attr('up-source')
241
242
  currentSource = newSource
@@ -263,12 +264,14 @@ up.popup = (->
263
264
  )
264
265
 
265
266
  # The framework is reset between tests
266
- up.bus.on 'framework:reset', reset
267
+ up.on 'up:framework:reset', reset
267
268
 
268
- open: open
269
+ attach: attach
269
270
  close: close
270
271
  source: source
271
- defaults: config.update
272
+ config: config
273
+ defaults: -> u.error('up.popup.defaults(...) no longer exists. Set values on he up.popup.config property instead.')
272
274
  contains: contains
273
-
274
- )()
275
+ open: -> up.warn('up.popup.open no longer exists. Please use up.popup.attach instead.')
276
+
277
+ )(jQuery)
@@ -3,8 +3,8 @@ Caching and preloading
3
3
  ======================
4
4
 
5
5
  All HTTP requests go through the Up.js proxy.
6
- It caches a [limited](/up.proxy#up.proxy.defaults) number of server responses
7
- for a [limited](/up.proxy#up.proxy.defaults) amount of time,
6
+ It caches a [limited](/up.proxy#up.proxy.config) number of server responses
7
+ for a [limited](/up.proxy#up.proxy.config) amount of time,
8
8
  making requests to these URLs return insantly.
9
9
 
10
10
  The cache is cleared whenever the user makes a non-`GET` request
@@ -45,11 +45,11 @@ The `proxy:busy` event will be emitted after a delay of 300 ms
45
45
  to prevent the spinner from flickering on and off.
46
46
  You can change (or remove) this delay like this:
47
47
 
48
- up.proxy.defaults({ busyDelay: 150 });
48
+ up.proxy.config.busyDelay = 150;
49
49
 
50
50
  @class up.proxy
51
51
  ###
52
- up.proxy = (->
52
+ up.proxy = (($) ->
53
53
 
54
54
  u = up.util
55
55
 
@@ -60,17 +60,17 @@ up.proxy = (->
60
60
  busyEventEmitted = undefined
61
61
 
62
62
  ###*
63
- @method up.proxy.defaults
64
- @param {Number} [options.preloadDelay=75]
63
+ @method up.proxy.config
64
+ @param {Number} [config.preloadDelay=75]
65
65
  The number of milliseconds to wait before [`[up-preload]`](#up-preload)
66
66
  starts preloading.
67
- @param {Number} [options.cacheSize=70]
67
+ @param {Number} [config.cacheSize=70]
68
68
  The maximum number of responses to cache.
69
69
  If the size is exceeded, the oldest items will be dropped from the cache.
70
- @param {Number} [options.cacheExpiry=300000]
70
+ @param {Number} [config.cacheExpiry=300000]
71
71
  The number of milliseconds until a cache entry expires.
72
72
  Defaults to 5 minutes.
73
- @param {Number} [options.busyDelay=300]
73
+ @param {Number} [config.busyDelay=300]
74
74
  How long the proxy waits until emitting the `proxy:busy` [event](/up.bus).
75
75
  Use this to prevent flickering of spinners.
76
76
  ###
@@ -243,7 +243,7 @@ up.proxy = (->
243
243
  if wasIdle
244
244
  emission = ->
245
245
  if busy() # a fast response might have beaten the delay
246
- up.bus.emit('proxy:busy')
246
+ up.bus.emit('up:proxy:busy')
247
247
  busyEventEmitted = true
248
248
  if config.busyDelay > 0
249
249
  busyDelayTimer = setTimeout(emission, config.busyDelay)
@@ -253,14 +253,14 @@ up.proxy = (->
253
253
  loadEnded = ->
254
254
  pendingCount -= 1
255
255
  if idle() && busyEventEmitted
256
- up.bus.emit('proxy:idle')
256
+ up.bus.emit('up:proxy:idle')
257
257
  busyEventEmitted = false
258
258
 
259
259
  load = (request) ->
260
260
  u.debug('Loading URL %o', request.url)
261
- up.bus.emit('proxy:load', request)
261
+ up.bus.emit('up:proxy:load', request)
262
262
  promise = u.ajax(request)
263
- promise.always -> up.bus.emit('proxy:receive', request)
263
+ promise.always -> up.bus.emit('up:proxy:receive', request)
264
264
  promise
265
265
 
266
266
  isIdempotent = (request) ->
@@ -320,7 +320,7 @@ up.proxy = (->
320
320
  unless up.link.childClicked(event, $element)
321
321
  checkPreload($element)
322
322
 
323
- up.bus.on 'framework:reset', reset
323
+ up.on 'up:framework:reset', reset
324
324
 
325
325
  preload: preload
326
326
  ajax: ajax
@@ -330,6 +330,7 @@ up.proxy = (->
330
330
  remove: remove
331
331
  idle: idle
332
332
  busy: busy
333
- defaults: config.update
333
+ config: config
334
+ defaults: -> u.error('up.proxy.defaults(...) no longer exists. Set values on he up.proxy.config property instead.')
334
335
 
335
- )()
336
+ )(jQuery)
@@ -16,7 +16,7 @@ We need to work on this page:
16
16
 
17
17
  @class up.tooltip
18
18
  ###
19
- up.tooltip = (->
19
+ up.tooltip = (($) ->
20
20
 
21
21
  u = up.util
22
22
 
@@ -35,10 +35,14 @@ up.tooltip = (->
35
35
  $tooltip.attr('up-position', position)
36
36
  $tooltip.css(css)
37
37
 
38
- createElement = (html) ->
39
- u.$createElementFromSelector('.up-tooltip')
40
- .html(html)
41
- .appendTo(document.body)
38
+ createElement = (options) ->
39
+ $element = u.$createElementFromSelector('.up-tooltip')
40
+ if u.isGiven(options.text)
41
+ $element.text(options.text)
42
+ else
43
+ $element.html(options.html)
44
+ $element.appendTo(document.body)
45
+ $element
42
46
 
43
47
  ###*
44
48
  Opens a tooltip over the given element.
@@ -47,7 +51,7 @@ up.tooltip = (->
47
51
  html: 'Enter multiple words or phrases'
48
52
  });
49
53
 
50
- @method up.tooltip.open
54
+ @method up.tooltip.attach
51
55
  @param {Element|jQuery|String} elementOrSelector
52
56
  @param {String} [options.html]
53
57
  The HTML to display in the tooltip.
@@ -56,14 +60,15 @@ up.tooltip = (->
56
60
  @param {String} [options.animation]
57
61
  The animation to use when opening the tooltip.
58
62
  ###
59
- open = (linkOrSelector, options = {}) ->
63
+ attach = (linkOrSelector, options = {}) ->
60
64
  $link = $(linkOrSelector)
61
- html = u.option(options.html, $link.attr('up-tooltip'), $link.attr('title'))
65
+ html = u.option(options.html, $link.attr('up-tooltip-html'))
66
+ text = u.option(options.text, $link.attr('up-tooltip'), $link.attr('title'))
62
67
  position = u.option(options.position, $link.attr('up-position'), 'top')
63
68
  animation = u.option(options.animation, u.castedAttr($link, 'up-animation'), 'fade-in')
64
69
  animateOptions = up.motion.animateOptions(options, $link)
65
70
  close()
66
- $tooltip = createElement(html)
71
+ $tooltip = createElement(text: text, html: html)
67
72
  setPosition($link, $tooltip, position)
68
73
  up.animate($tooltip, animation, animateOptions)
69
74
 
@@ -83,7 +88,7 @@ up.tooltip = (->
83
88
  up.destroy($tooltip, options)
84
89
 
85
90
  ###*
86
- Displays a tooltip when hovering the mouse over this element:
91
+ Displays a tooltip with text content when hovering the mouse over this element:
87
92
 
88
93
  <a href="/decks" up-tooltip="Show all decks">Decks</a>
89
94
 
@@ -94,7 +99,15 @@ up.tooltip = (->
94
99
  @method [up-tooltip]
95
100
  @ujs
96
101
  ###
97
- up.compiler('[up-tooltip]', ($link) ->
102
+ ###*
103
+ Displays a tooltip with HTML content when hovering the mouse over this element:
104
+
105
+ <a href="/decks" up-tooltip="Show &lt;b&gt;all&lt;/b&gt; decks">Decks</a>
106
+
107
+ @method [up-tooltip-html]
108
+ @ujs
109
+ ###
110
+ up.compiler('[up-tooltip], [up-tooltip-html]', ($link) ->
98
111
  # Don't register these events on document since *every*
99
112
  # mouse move interaction bubbles up to the document.
100
113
  $link.on('mouseover', -> open($link))
@@ -108,12 +121,13 @@ up.tooltip = (->
108
121
 
109
122
  # The framework is reset between tests, so also close
110
123
  # a currently open tooltip.
111
- up.bus.on 'framework:reset', close
124
+ up.on 'up:framework:reset', close
112
125
 
113
126
  # Close the tooltip when the user presses ESC.
114
127
  up.magic.onEscape(-> close())
115
128
 
116
- open: open
129
+ attach: attach
117
130
  close: close
131
+ open: -> u.error('up.tooltip.open no longer exists. Use up.tooltip.attach instead.')
118
132
 
119
- )()
133
+ )(jQuery)
@@ -10,7 +10,7 @@ If you use them in your own code, you will get hurt.
10
10
  @protected
11
11
  @class up.util
12
12
  ###
13
- up.util = (->
13
+ up.util = (($) ->
14
14
 
15
15
  memoize = (func) ->
16
16
  cache = undefined
@@ -847,27 +847,10 @@ up.util = (->
847
847
  keys: keys
848
848
 
849
849
  config = (factoryOptions = {}) ->
850
- hash =
851
- ensureKeyExists: (key) ->
852
- factoryOptions.hasOwnProperty(key) or error("Unknown setting %o", key)
853
- reset: ->
854
- ownKeys = copy(Object.getOwnPropertyNames(hash))
855
- for key in ownKeys
856
- delete hash[key] unless contains(apiKeys, key)
857
- hash.update copy(factoryOptions)
858
- update: (options) ->
859
- if options
860
- if isString(options)
861
- hash.ensureKeyExists(options)
862
- hash[options]
863
- else
864
- for key, value of options
865
- hash.ensureKeyExists(key)
866
- hash[key] = value
867
- else
868
- hash
869
- apiKeys = Object.getOwnPropertyNames(hash)
850
+ hash = {}
851
+ hash.reset = -> extend(hash, factoryOptions)
870
852
  hash.reset()
853
+ Object.preventExtensions(hash)
871
854
  hash
872
855
 
873
856
  unwrapElement = (wrapper) ->
@@ -902,6 +885,15 @@ up.util = (->
902
885
  right: ''
903
886
  bottom: ''
904
887
 
888
+ argNames = (fun) ->
889
+ code = fun.toString()
890
+ pattern = new RegExp('\\(([^\\)]*)\\)')
891
+ if match = code.match(pattern)
892
+ match[1].split(/\s*,\s*/)
893
+ else
894
+ error('Could not parse argument names of %o', fun)
895
+
896
+ argNames: argNames
905
897
  offsetParent: offsetParent
906
898
  fixedToAbsolute: fixedToAbsolute
907
899
  presentAttr: presentAttr
@@ -987,7 +979,7 @@ up.util = (->
987
979
  emptyJQuery: emptyJQuery
988
980
  evalConsoleTemplate: evalConsoleTemplate
989
981
 
990
- )()
982
+ )($)
991
983
 
992
984
  up.error = up.util.error
993
985
  up.warn = up.util.warn
@@ -1,6 +1,5 @@
1
- defaults = up.layout.defaults()
2
-
3
- up.layout.defaults
4
- fixedTop: defaults.fixedTop.concat(['.navbar-fixed-top'])
5
- fixedBottom: defaults.fixedBottom.concat(['.navbar-fixed-bottom'])
6
- anchoredRight: defaults.anchoredRight.concat(['.navbar-fixed-top', '.navbar-fixed-bottom', '.footer'])
1
+ up.layout.config.fixedTop.push('.navbar-fixed-top')
2
+ up.layout.config.fixedBottom.push('.navbar-fixed-bottom')
3
+ up.layout.config.anchoredRight.push('.navbar-fixed-top')
4
+ up.layout.config.anchoredRight.push('.navbar-fixed-bottom')
5
+ up.layout.config.anchoredRight.push('.footer')
@@ -1,11 +1,11 @@
1
1
  # Use BS `modal-dialog` and `modal-content` classes.
2
2
  # Also don't show a close button by default, since BS
3
3
  # expects user to add this manually within the content block.
4
- up.modal.defaults
5
- template: """
6
- <div class="up-modal">
7
- <div class="up-modal-dialog modal-dialog">
8
- <div class="up-modal-content modal-content"></div>
9
- </div>
10
- </div>
11
- """
4
+ up.modal.config.template =
5
+ """
6
+ <div class="up-modal">
7
+ <div class="up-modal-dialog modal-dialog">
8
+ <div class="up-modal-content modal-content"></div>
9
+ </div>
10
+ </div>
11
+ """
@@ -1,6 +1,3 @@
1
- defaults = up.navigation.defaults()
2
-
3
- # BS use the class `active` to highlight the current section
1
+ # Bootstrap uses the class `active` to highlight the current section
4
2
  # of a navigation bar.
5
- up.navigation.defaults
6
- currentClasses: defaults.currentClasses.concat(['active'])
3
+ up.navigation.config.currentClasses.push('active')
@@ -14,5 +14,4 @@
14
14
  #= require up/modal
15
15
  #= require up/tooltip
16
16
  #= require up/navigation
17
- #= require up/slot
18
17
  #= require up/boot
@@ -1,5 +1,5 @@
1
1
  module Upjs
2
2
  module Rails
3
- VERSION = '0.11.1'
3
+ VERSION = '0.12.0'
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- upjs-rails (0.10.2)
4
+ upjs-rails (0.11.1)
5
5
  rails (>= 3)
6
6
 
7
7
  GEM
@@ -2,11 +2,48 @@ describe 'up.bus', ->
2
2
 
3
3
  describe 'Javascript functions', ->
4
4
 
5
- describe 'up.bus.on', ->
6
-
7
- it 'should have tests'
8
-
9
5
  describe 'up.bus.emit', ->
10
6
 
11
- it 'should have tests'
12
-
7
+ it 'triggers an event on the document', ->
8
+ emittedEvent = undefined
9
+ emitted$Target = undefined
10
+
11
+ up.on 'foo', (event, $target) ->
12
+ emittedEvent = event
13
+ emitted$Target = $target
14
+
15
+ expect(emittedEvent).toBeUndefined()
16
+ expect(emitted$Target).toBeUndefined()
17
+
18
+ up.bus.emit('foo')
19
+
20
+ expect(emittedEvent).toBeDefined()
21
+ expect(emittedEvent.preventDefault).toBeDefined()
22
+ expect(emitted$Target).toEqual($(document))
23
+
24
+ it 'accepts custom event properties', ->
25
+ emittedEvent = undefined
26
+
27
+ up.on 'foo', (event) ->
28
+ emittedEvent = event
29
+
30
+ up.bus.emit('foo', { customField: 'custom-value' })
31
+
32
+ expect(emittedEvent.customField).toEqual('custom-value')
33
+
34
+ it 'triggers an event on an element given as .$element event property', ->
35
+ emittedEvent = undefined
36
+ emitted$Target = undefined
37
+
38
+ $element = affix('.element').text('foo')
39
+
40
+ up.on 'foo', (event, $target) ->
41
+ emittedEvent = event
42
+ emitted$Target = $target
43
+
44
+ up.bus.emit('foo', $element: $element)
45
+
46
+ expect(emittedEvent).toBeDefined()
47
+ expect(emitted$Target).toEqual($element)
48
+
49
+ expect(emittedEvent.$element).toEqual($element)
@@ -241,7 +241,7 @@ describe 'up.flow', ->
241
241
  it 'calls destructors for custom elements', ->
242
242
  up.compiler('.element', ($element) -> destructor)
243
243
  destructor = jasmine.createSpy('destructor')
244
- up.ready(affix('.element'))
244
+ up.hello(affix('.element'))
245
245
  up.destroy('.element')
246
246
  expect(destructor).toHaveBeenCalled()
247
247
 
@@ -19,7 +19,7 @@ describe 'up.history', ->
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')
21
21
  up.history.push('/two')
22
- $element = up.ready(affix('a[href="/three"][up-back]').text('text'))
22
+ $element = up.hello(affix('a[href="/three"][up-back]').text('text'))
23
23
  expect($element.attr('href')).toEndWith('/three')
24
24
  expect($element.attr('up-href')).toEndWith('/one')
25
25
  expect($element.attr('up-restore-scroll')).toBe('')
@@ -52,8 +52,8 @@ describe 'up.history', ->
52
52
 
53
53
  $viewport = $(longContentHtml).appendTo(document.body)
54
54
 
55
- up.layout.defaults(viewports: ['.viewport'])
56
- up.history.defaults(popTargets: ['.viewport'])
55
+ up.layout.config.viewports = ['.viewport']
56
+ up.history.config.popTargets = ['.viewport']
57
57
 
58
58
  $viewport.append(longContentHtml)
59
59
 
@@ -7,10 +7,9 @@ describe 'up.layout', ->
7
7
  describe 'up.reveal', ->
8
8
 
9
9
  beforeEach ->
10
- up.layout.defaults
11
- snap: 0
12
- substance: 99999
13
- viewports: [document]
10
+ up.layout.config.snap = 0
11
+ up.layout.config.substance = 99999
12
+ up.layout.config.viewports = [document]
14
13
 
15
14
  describe 'when the viewport is the document', ->
16
15
 
@@ -57,7 +56,7 @@ describe 'up.layout', ->
57
56
 
58
57
  it 'snaps to the top if the space above the future-visible area is smaller than the value of config.snap', ->
59
58
 
60
- up.layout.defaults(snap: 30)
59
+ up.layout.config.snap = 30
61
60
 
62
61
  @$elements[0].css(height: '20px')
63
62
 
@@ -235,8 +234,7 @@ describe 'up.layout', ->
235
234
 
236
235
  it 'only reveals the top number of pixels defined in config.substance', ->
237
236
 
238
- up.layout.defaults
239
- substance: 20
237
+ up.layout.config.substance = 20
240
238
 
241
239
  $viewport = affix('div').css
242
240
  'position': 'absolute'
@@ -291,26 +289,26 @@ describe 'up.layout', ->
291
289
  describe 'up.layout.viewportsOf', ->
292
290
 
293
291
  it 'seeks upwards from the given element', ->
294
- up.layout.defaults(viewports: ['.viewport1', '.viewport2'])
292
+ up.layout.config.viewports = ['.viewport1', '.viewport2']
295
293
  $viewport1 = affix('.viewport1')
296
294
  $viewport2 = affix('.viewport2')
297
295
  $element = affix('div').appendTo($viewport2)
298
296
  expect(up.layout.viewportOf($element)).toEqual($viewport2)
299
297
 
300
298
  it 'returns the given element if it is a configured viewport itself', ->
301
- up.layout.defaults(viewports: ['.viewport'])
299
+ up.layout.config.viewports = ['.viewport']
302
300
  $viewport = affix('.viewport')
303
301
  expect(up.layout.viewportOf($viewport)).toEqual($viewport)
304
302
 
305
303
  it 'finds the document if the viewport is the document', ->
306
304
  # This actually tests that the hierarchy returned by `$.parent`
307
305
  # is $element => ... => $('body') => $('html') => $(document)
308
- up.layout.defaults(viewports: [document])
306
+ up.layout.config.viewports = [document]
309
307
  $element = affix('div')
310
308
  expect(up.layout.viewportOf($element)).toEqual($(document))
311
309
 
312
310
  it 'throws an error if no viewport could be found', ->
313
- up.layout.defaults(viewports: ['.does-not-exist'])
311
+ up.layout.config.viewports = ['.does-not-exist']
314
312
  $element = affix('div')
315
313
  lookup = -> up.layout.viewportOf($element)
316
314
  expect(lookup).toThrowError(/Could not find viewport/i)
@@ -43,9 +43,7 @@ describe 'up.link', ->
43
43
  # By default, up.history will replace the <body> tag when
44
44
  # the user presses the back-button. We reconfigure this
45
45
  # so we don't lose the Jasmine runner interface.
46
- up.history.defaults
47
- popTargets: ['.container']
48
-
46
+ up.history.config.popTargets = ['.container']
49
47
 
50
48
  respondWith = (html) =>
51
49
  @lastRequest().respondWith
@@ -121,7 +119,7 @@ describe 'up.link', ->
121
119
 
122
120
  it 'does not follow a form with up-target attribute (bugfix)', ->
123
121
  $form = affix('form[up-target]')
124
- up.ready($form)
122
+ up.hello($form)
125
123
  followSpy = up.link.knife.mock('follow')
126
124
  $form.click()
127
125
  expect(followSpy).not.toHaveBeenCalled()
@@ -131,7 +129,7 @@ describe 'up.link', ->
131
129
  it "calls up.follow with the clicked link", ->
132
130
  followSpy = up.link.knife.mock('follow')
133
131
  $link = affix('a[href="/path"][up-follow]')
134
- up.ready($link)
132
+ up.hello($link)
135
133
  $link.click()
136
134
  expect(followSpy).toHaveBeenCalledWith($link)
137
135
 
@@ -139,24 +137,24 @@ describe 'up.link', ->
139
137
 
140
138
  it 'copies up-related attributes of a contained link', ->
141
139
  $area = affix('div[up-expand] a[href="/path"][up-target="selector"][up-instant][up-preload]')
142
- up.ready($area)
140
+ up.hello($area)
143
141
  expect($area.attr('up-target')).toEqual('selector')
144
142
  expect($area.attr('up-instant')).toEqual('')
145
143
  expect($area.attr('up-preload')).toEqual('')
146
144
 
147
145
  it "renames a contained link's href attribute to up-href so the container is considered a link", ->
148
146
  $area = affix('div[up-expand] a[up-follow][href="/path"]')
149
- up.ready($area)
147
+ up.hello($area)
150
148
  expect($area.attr('up-href')).toEqual('/path')
151
149
 
152
150
  it "copies an contained non-link element with up-href attribute", ->
153
151
  $area = affix('div[up-expand] span[up-follow][up-href="/path"]')
154
- up.ready($area)
152
+ up.hello($area)
155
153
  expect($area.attr('up-href')).toEqual('/path')
156
154
 
157
155
  it 'adds an up-follow attribute if the contained link has neither up-follow nor up-target attributes', ->
158
156
  $area = affix('div[up-expand] a[href="/path"]')
159
- up.ready($area)
157
+ up.hello($area)
160
158
  expect($area.attr('up-follow')).toEqual('')
161
159
 
162
160
  describe '[up-instant]', ->
@@ -25,7 +25,7 @@ describe 'up.magic', ->
25
25
  up.compiler '.child', ($element) ->
26
26
  observeClass($element.attr('class'))
27
27
 
28
- up.ready(affix('.container .child'))
28
+ up.hello(affix('.container .child'))
29
29
 
30
30
  expect(observeClass).not.toHaveBeenCalledWith('container')
31
31
  expect(observeClass).toHaveBeenCalledWith('child')
@@ -36,7 +36,7 @@ describe 'up.magic', ->
36
36
  up.compiler '.child', ($element) ->
37
37
  destructor
38
38
 
39
- up.ready(affix('.container .child'))
39
+ up.hello(affix('.container .child'))
40
40
  expect(destructor).not.toHaveBeenCalled()
41
41
 
42
42
  up.destroy('.container')
@@ -51,7 +51,7 @@ describe 'up.magic', ->
51
51
  data = { key1: 'value1', key2: 'value2' }
52
52
 
53
53
  $tag = affix(".child").attr('up-data', JSON.stringify(data))
54
- up.ready($tag)
54
+ up.hello($tag)
55
55
 
56
56
  expect(observeArgs).toHaveBeenCalledWith('child', data)
57
57
 
@@ -61,12 +61,12 @@ describe 'up.magic', ->
61
61
  up.compiler '.child', ($element, data) ->
62
62
  observeArgs($element.attr('class'), data)
63
63
 
64
- up.ready(affix(".child"))
64
+ up.hello(affix(".child"))
65
65
 
66
66
  expect(observeArgs).toHaveBeenCalledWith('child', {})
67
67
 
68
68
 
69
- describe 'up.ready', ->
69
+ describe 'up.hello', ->
70
70
 
71
71
  it 'should have tests'
72
72