lib/assets/javascripts/bindings.js.coffee in kolo-0.3.3 vs lib/assets/javascripts/bindings.js.coffee in kolo-0.4.0
- old
+ new
@@ -44,6 +44,108 @@
if !appear
$(element).slideDown(duration)
else
$(element).slideUp(duration)
+ko.bindingHandlers.slideleftif =
+ init: (element, valueAccessor)->
+ value = ko.utils.unwrapObservable valueAccessor()
+ if !value
+ $(element).hide()
+ $(element).transition({ x: '10000px' }, 1)
+ else
+ $(element).show()
+ update: (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext)->
+ appear = ko.utils.unwrapObservable valueAccessor()
+ duration = allBindingsAccessor().duration || 1000
+ if appear
+ $(element).show()
+ $(element).transition({ x: 0 }, duration)
+ else
+ $(element).transition({ x: '10000px' }, duration, ->
+ $(element).hide()
+ )
+
+ko.bindingHandlers.slideleftifnot =
+ init: (element, valueAccessor)->
+ value = ko.utils.unwrapObservable valueAccessor()
+ if value
+ $(element).hide()
+ $(element).transition({ x: '10000px' }, 1)
+ else
+ $(element).show()
+
+ update: (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext)->
+ appear = ko.utils.unwrapObservable valueAccessor()
+ duration = allBindingsAccessor().duration || 1000
+ if !appear
+ $(element).show()
+ $(element).transition({ x: 0 }, duration)
+ else
+ $(element).transition({ x: '10000px' }, duration, ->
+ $(element).hide()
+ )
+
+ko.bindingHandlers.sliderightif =
+ init: (element, valueAccessor)->
+ value = ko.utils.unwrapObservable valueAccessor()
+ if !value
+ $(element).hide()
+ $(element).transition({ x: '-10000px' }, 1)
+ else
+ $(element).show()
+
+ update: (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext)->
+ appear = ko.utils.unwrapObservable valueAccessor()
+ duration = allBindingsAccessor().duration || 1000
+ if appear
+ $(element).show()
+ $(element).transition({ x: 0 }, duration)
+ else
+ $(element).transition({ x: '-10000px' }, duration, ->
+ $(element).hide()
+ )
+
+ko.bindingHandlers.sliderightifnot =
+ init: (element, valueAccessor)->
+ value = ko.utils.unwrapObservable valueAccessor()
+ if value
+ $(element).hide()
+ $(element).transition({ x: '-10000px' }, 1)
+ else
+ $(element).show()
+
+ update: (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext)->
+ appear = ko.utils.unwrapObservable valueAccessor()
+ duration = allBindingsAccessor().duration || 1000
+ if !appear
+ $(element).show()
+ $(element).transition({ x: 0 }, duration)
+ else
+ $(element).transition({ x: '-10000px' }, duration, ->
+ $(element).hide()
+ )
+
+ko.bindingHandlers.swipeleft =
+ init: (element, valueAccessor)->
+ Hammer(element).on 'swipeleft', (event)->
+ value = valueAccessor()
+ value(event)
+
+ko.bindingHandlers.swiperight =
+ init: (element, valueAccessor)->
+ Hammer(element).on 'swiperight', (event)->
+ value = valueAccessor()
+ value(event)
+
+ko.bindingHandlers.swipeup =
+ init: (element, valueAccessor)->
+ Hammer(element).on 'swipeup', (event)->
+ value = valueAccessor()
+ value(event)
+
+ko.bindingHandlers.swipedown =
+ init: (element, valueAccessor)->
+ Hammer(element).on 'swipedown', (event)->
+ value = valueAccessor()
+ value(event)