quick_script 0.11.11 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,7 +20,7 @@ module QuickScript
20
20
  end
21
21
  end
22
22
 
23
- def json_resp(data, meta, opts = {})
23
+ def json_resp(data, meta=true, opts = {})
24
24
  meta = 200 if meta == true
25
25
  meta = 404 if meta == false
26
26
  opts[:data] = data
@@ -1,3 +1,3 @@
1
1
  module QuickScript
2
- VERSION = "0.11.11"
2
+ VERSION = "0.12.0"
3
3
  end
@@ -15,6 +15,14 @@
15
15
  shouldDisplay = ko.utils.unwrapObservable(valueAccessor())
16
16
  if shouldDisplay then $(element).slideDown('slow') else $(element).slideUp()
17
17
 
18
+ ko.bindingHandlers.dim =
19
+ init : (element, valueAccessor) ->
20
+ shouldDim = ko.utils.unwrapObservable(valueAccessor())
21
+ if shouldDim then $(element).css({opacity : 0.3}) else $(element).css({opacity: 1.0})
22
+ update : (element, valueAccessor) ->
23
+ shouldDim = ko.utils.unwrapObservable(valueAccessor())
24
+ if shouldDim then $(element).animate({opacity : 0.3}) else $(element).animate({opacity: 1.0})
25
+
18
26
  # buttonStatus - [is_loading, ready_str, loading_str, icon_classes]
19
27
  ko.bindingHandlers.buttonStatus =
20
28
  update : (element, valueAccessor) ->
@@ -34,27 +42,22 @@
34
42
  ko.bindingHandlers.listStatus =
35
43
  init : (element, valueAccessor) ->
36
44
  opts = ko.utils.unwrapObservable(valueAccessor())
37
- if opts[0].is_loading()
38
- $(element).html(opts[2])
39
- $(element).show()
40
- else
41
- if opts[0].hasItems()
42
- $(element).hide()
43
- else
44
- $(element).show()
45
- $(element).html(opts[1])
46
- update : (element, valueAccessor) ->
47
- opts = ko.utils.unwrapObservable(valueAccessor())
48
- opts[0].is_loading.subscribe ->
49
- if opts[0].is_loading()
50
- $(element).html(opts[2])
51
- $(element).show()
45
+ opts = {list : opts[0], empty_str : opts[1], loading_str : opts[2]} if opts instanceof Array
46
+ fn = ->
47
+ if opts.list.is_loading()
48
+ if opts.loading_img?
49
+ $(element).html("<img src='#{opts.loading_img}'/>")
50
+ else
51
+ $(element).html(opts.loading_str)
52
+ $(element).show('fast')
52
53
  else
53
- if opts[0].hasItems()
54
- $(element).hide()
54
+ if opts.list.hasItems()
55
+ $(element).hide('fast')
55
56
  else
56
57
  $(element).show()
57
- $(element).html(opts[1])
58
+ $(element).html(opts.empty_str)
59
+ #fn()
60
+ opts.list.is_loading.subscribe(fn)
58
61
 
59
62
  ko.bindingHandlers.viewOptions =
60
63
  update : (element, valueAccessor) ->
@@ -410,12 +413,14 @@ jQuery.fn.extend
410
413
  this.css("top", (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() + "px")
411
414
  this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + "px")
412
415
  return this
413
- koBind : (viewModel) ->
416
+ koBind : (viewModel, tmpl) ->
414
417
  this.each ->
415
- ko.cleanNode(this)
418
+ $(this).koClean()
419
+ $(this).attr('data-bind', "template : '#{tmpl}'") if tmpl?
416
420
  ko.applyBindings(viewModel, this)
417
421
  koClean : ->
418
422
  this.each ->
423
+ $(this).removeAttr('data-bind')
419
424
  ko.cleanNode(this)
420
425
 
421
426
  jQuery.ajax_qs = (opts)->
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 11
8
- - 11
9
- version: 0.11.11
7
+ - 12
8
+ - 0
9
+ version: 0.12.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Alan Graham
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-11-12 00:00:00 -05:00
17
+ date: 2012-11-15 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies: []
20
20