twine-rails 1.2.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8b1f18347a673c2da36ccab84449031136b661d8184beb2cad56ea81e471a87
4
- data.tar.gz: e64ca56b6851cb8f7dc692e31812d0745b2ccb9a7f7594f254ff6f1c1b339717
3
+ metadata.gz: 7245233240a25c03d7714bbeab59980acd3a0743118611db224c5eacaf52f7c8
4
+ data.tar.gz: e91b4658d70df7a8106b7ef6705429681819da11f411ea7fc4cd3e9fdfb18300
5
5
  SHA512:
6
- metadata.gz: 23a2c7c69017ab0f289549aae0cd53d40ee09dfc04b956db63f4d9c4e5f26e0a20b9a56d996764b4e0b8a1b153d44fa8d1e44d52a6be82551dc82f61f293a34c
7
- data.tar.gz: 5055a680b4b0a996b3c52c0f38a062e28427ff31a018c75a4d34ec49e846a8b58ccd3eeaa9052a6bea18fd5dab6d2d60b0ecf41f5e84365c42a3e4ae149c05b5
6
+ metadata.gz: 1cc8f28bdd59879b679ea684021b5b500540e1d3928593b550488ae0cb9bd75a761bdc631ff70223028797812e9095e69c43ab9c2d77b2671a059be61d20a0a1
7
+ data.tar.gz: c8f4f398ef794db3e6062208f4d3ef8496d84f64968032bef0150b1a4b6f3f8044119bc362f182f0a0d15f09e4ea7818ed99a1ba62cb330e104ece89ff9a5f49
@@ -1,15 +1,11 @@
1
1
  ((root, factory) ->
2
2
  if typeof root.define == 'function' && root.define.amd
3
- root.define(['jquery'], factory)
3
+ root.define([], factory)
4
4
  else if typeof module == 'object' && module.exports
5
- jQuery = if typeof window != 'undefined'
6
- then require('jquery')
7
- else require('jquery')(root)
8
-
9
- module.exports = factory(jQuery)
5
+ module.exports = factory()
10
6
  else
11
- root.Twine = factory(root.jQuery)
12
- )(this, (jQuery) ->
7
+ root.Twine = factory()
8
+ )(this, ->
13
9
  Twine = {}
14
10
  Twine.shouldDiscardEvent = {}
15
11
 
@@ -362,13 +358,14 @@
362
358
  refreshContext()
363
359
 
364
360
  if twoWayBinding
361
+ events = ['input', 'keyup', 'change']
365
362
  changeHandler = ->
366
363
  return if getValue(context, keypath) == this[valueProp]
367
364
  refreshContext()
368
365
  Twine.refreshImmediately()
369
- jQuery(node).on 'input keyup change', changeHandler
366
+ node.addEventListener(eventName, changeHandler) for eventName in events
370
367
  teardown = ->
371
- jQuery(node).off 'input keyup change', changeHandler
368
+ node.removeEventListener(eventName, changeHandler) for eventName in events
372
369
 
373
370
  {refresh, teardown}
374
371
 
@@ -378,28 +375,23 @@
378
375
  return refresh: ->
379
376
  newValue = !fn.call(node, context, rootContext, arrayPointersForNode(node, context))
380
377
  return if newValue == lastValue
381
- jQuery(node).toggleClass('hide', lastValue = newValue)
378
+ node.classList.toggle('hide', lastValue = newValue)
382
379
 
383
380
  'bind-class': (node, context, definition) ->
384
381
  fn = wrapFunctionString(definition, '$context,$root,$arrayPointers', node)
385
382
  lastValues = {}
386
- $node = jQuery(node)
387
383
  return refresh: ->
388
384
  newValues = fn.call(node, context, rootContext, arrayPointersForNode(node, context))
389
- additions = []
390
- removals = []
391
385
 
392
386
  for key, value of newValues
393
387
  newValue = newValues[key] = !!newValues[key]
394
- currValue = lastValues[key] ? $node.hasClass(key)
388
+ currValue = lastValues[key] ? node.classList.contains(key)
395
389
  if currValue != newValue
396
390
  if newValue
397
- additions.push(key)
391
+ node.classList.add(key)
398
392
  else
399
- removals.push(key)
393
+ node.classList.remove(key)
400
394
 
401
- $node.removeClass(removals.join(' ')) if removals.length
402
- $node.addClass(additions.join(' ')) if additions.length
403
395
  lastValues = newValues
404
396
 
405
397
  'bind-attribute': (node, context, definition) ->
@@ -408,7 +400,10 @@
408
400
  return refresh: ->
409
401
  newValue = fn.call(node, context, rootContext, arrayPointersForNode(node, context))
410
402
  for key, value of newValue when lastValue[key] != value
411
- jQuery(node).attr(key, value || null)
403
+ if (!value)
404
+ node.removeAttribute(key)
405
+ else
406
+ node.setAttribute(key, value)
412
407
  lastValue = newValue
413
408
 
414
409
  define: (node, context, definition) ->
@@ -462,7 +457,7 @@
462
457
 
463
458
  setupEventBinding = (eventName) ->
464
459
  Twine.bindingTypes["bind-event-#{eventName}"] = (node, context, definition) ->
465
- onEventHandler = (event, data) ->
460
+ onEventHandler = (event, data = event.detail) ->
466
461
  discardEvent = Twine.shouldDiscardEvent[eventName]?(event)
467
462
  if discardEvent || preventDefaultForEvent(event)
468
463
  event.preventDefault()
@@ -471,10 +466,10 @@
471
466
 
472
467
  wrapFunctionString(definition, '$context,$root,$arrayPointers,event,data', node).call(node, context, rootContext, arrayPointersForNode(node, context), event, data)
473
468
  Twine.refreshImmediately()
474
- jQuery(node).on eventName, onEventHandler
469
+ node.addEventListener(eventName, onEventHandler)
475
470
 
476
471
  return teardown: ->
477
- jQuery(node).off eventName, onEventHandler
472
+ node.removeEventListener(eventName, onEventHandler)
478
473
 
479
474
  for eventName in ['click', 'dblclick', 'mouseenter', 'mouseleave', 'mouseover', 'mouseout', 'mousedown', 'mouseup',
480
475
  'submit', 'dragenter', 'dragleave', 'dragover', 'drop', 'drag', 'change', 'keypress', 'keydown', 'keyup', 'input',
@@ -1,3 +1,3 @@
1
1
  module TwineRails
2
- VERSION = '1.2.2'
2
+ VERSION = '2.0.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twine-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Li
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-10-24 00:00:00.000000000 Z
13
+ date: 2021-02-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: coffee-rails
@@ -83,7 +83,11 @@ files:
83
83
  homepage: https://github.com/Shopify/twine
84
84
  licenses:
85
85
  - MIT
86
- metadata: {}
86
+ metadata:
87
+ bug_tracker_uri: https://github.com/Shopify/twine/issues
88
+ changelog_uri: https://github.com/Shopify/twine/releases
89
+ source_code_uri: https://github.com/Shopify/twine
90
+ allowed_push_host: https://rubygems.org
87
91
  post_install_message:
88
92
  rdoc_options: []
89
93
  require_paths:
@@ -99,8 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
103
  - !ruby/object:Gem::Version
100
104
  version: '0'
101
105
  requirements: []
102
- rubyforge_project:
103
- rubygems_version: 2.7.6
106
+ rubygems_version: 3.0.3
104
107
  signing_key:
105
108
  specification_version: 4
106
109
  summary: Minimalistic two-way bindings