backboneAX 0.0.18 → 0.1.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.
data/README.md CHANGED
@@ -8,9 +8,9 @@ This is a set of backbone extensions that have help make my backbone projects ea
8
8
 
9
9
  Extends the Backbone.Model class to let me know the connection state of the class
10
10
 
11
- ### Bx.Collection.Base
11
+ ### Bx.Collection.Base
12
12
 
13
- - Extends the Backbone.Collection class to let me know the connection state of the class.
13
+ - Extends the Backbone.Collection class to let me know the connection state of the class.
14
14
  - Supports fetchOnce which will not retry a fetch if one has already been called
15
15
 
16
16
 
@@ -18,9 +18,9 @@ Extends the Backbone.Model class to let me know the connection state of the clas
18
18
 
19
19
  - Pagination.
20
20
 
21
- ### Bx.View.Base
21
+ ### Bx.View.Base
22
22
 
23
- - Manages child view creation and releasing.
23
+ - Manages child view creation and releasing.
24
24
  - Setting data from models to views of templates
25
25
  - Setting and getting of form data
26
26
 
@@ -29,4 +29,4 @@ Extends the Backbone.Model class to let me know the connection state of the clas
29
29
  - Bx.Pool.Hash
30
30
  - Bx.Pool.Array
31
31
  - Bx.Pool.Model
32
- - Bx.Pool.Collection
32
+ - Bx.Pool.Collection
@@ -1,3 +1,3 @@
1
1
  module BackboneAX
2
- VERSION = "0.0.18"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/backboneAX.rb CHANGED
@@ -2,6 +2,6 @@ require "backboneAX/version"
2
2
 
3
3
  if defined? Rails
4
4
  if Rails.version.to_f >= 3.1
5
- require "backboneAX/engine"
5
+ require "backboneAX/engine"
6
6
  end
7
7
  end
@@ -4,9 +4,9 @@ class Bx.Collection.Base extends Backbone.Collection
4
4
  super(models, options)
5
5
  # @models = []
6
6
  @fetchCalled = false
7
-
7
+
8
8
  fetch: (options = {}) ->
9
- @fetchCalled = true
9
+ @fetchCalled = true
10
10
  @_connState("connected")
11
11
 
12
12
  optionsSuccess = options.success
@@ -18,17 +18,17 @@ class Bx.Collection.Base extends Backbone.Collection
18
18
  options.error = (collection, response) =>
19
19
  @_connState("error")
20
20
  optionsError(collection, response) if optionsError
21
-
21
+
22
22
  super(options)
23
23
 
24
24
  fetchOnce: (options = {}) ->
25
25
  return if @fetchCalled
26
26
  @fetch(options)
27
-
27
+
28
28
  _connState: (state = "") ->
29
29
  @_conn_state = state
30
- @trigger("connection")
31
-
30
+ @trigger("connection")
31
+
32
32
  isConnected: ()->
33
33
  @_conn_state == "connected"
34
34
 
@@ -6,12 +6,12 @@ class Bx.Collection.Paginate extends Bx.Collection.Base
6
6
  @pageCurrent = options.pageCurrent ? 0
7
7
  @pageTotal = options.pageTotal ? 1
8
8
  @current = options.current ? null
9
-
9
+
10
10
  parse: (response) ->
11
11
  @pageCurrent = if response.pagination then response.pagination.current ? 1 else 1
12
12
  @pageTotal = if response.pagination then response.pagination.total ? 1 else 1
13
13
  response.items || []
14
-
14
+
15
15
  fetch: (options = {}) ->
16
16
  options.data = $.extend(options.data || {}, {page: @pageCurrent, pageSize: @pageSize})
17
17
 
@@ -21,12 +21,12 @@ class Bx.Collection.Paginate extends Bx.Collection.Base
21
21
  first = collection.first()
22
22
  @currentSet(first.id) if first?
23
23
  optionsSuccess(collection, response) if optionsSuccess
24
-
24
+
25
25
  super(options)
26
26
 
27
27
  # RESTART THE SEARCH
28
28
  restart: (options = {}) ->
29
- options.add = false
29
+ options.add = false
30
30
  @pageCurrent = 1
31
31
  @fetch(options)
32
32
 
@@ -62,7 +62,7 @@ class Bx.Collection.Paginate extends Bx.Collection.Base
62
62
  if @current? && @current.id != parseInt(id, 10)
63
63
  @current.set({id: id}, {silent: true})
64
64
  @current.fetch();
65
-
65
+
66
66
  currentPrev: () ->
67
67
  return unless @current?
68
68
  index = @indexOf(@current.id)
@@ -81,9 +81,9 @@ class Bx.Collection.Paginate extends Bx.Collection.Base
81
81
  @currentSet(@at(index + 1).id)
82
82
  else
83
83
  @more()
84
-
84
+
85
85
  hasCurrentNext: () ->
86
86
  return false unless @current?
87
87
  index = @indexOf(@current.id)
88
88
  return (index < @size - 1) || @hasMore()
89
-
89
+
@@ -1,12 +1,12 @@
1
1
  class Bx.Model.Base extends Backbone.Model
2
2
  constructor: (attributes, options) ->
3
- super(attributes, options)
3
+ super(attributes, options)
4
4
  # allow overriding of the "contructed" method
5
5
  @constructed(attributes) if @constructed?
6
-
6
+
7
7
  fetch: (options = {}) ->
8
8
  @_connState("connected")
9
-
9
+
10
10
  optionsSuccess = options.success
11
11
  options.success = (model, response) =>
12
12
  @_connState()
@@ -16,12 +16,12 @@ class Bx.Model.Base extends Backbone.Model
16
16
  options.error = (model, response) =>
17
17
  @_connState("error")
18
18
  optionsError(model, response) if optionsError
19
-
19
+
20
20
  super(options)
21
21
 
22
22
  save: (attr, options = {}) ->
23
23
  @_connState("connected")
24
-
24
+
25
25
  optionsSuccess = options.success
26
26
  options.success = (model, response) =>
27
27
  @_connState()
@@ -30,8 +30,8 @@ class Bx.Model.Base extends Backbone.Model
30
30
  optionsError = options.error
31
31
  options.error = (model, response) =>
32
32
  @_connState("error")
33
- optionsError(model, response) if optionsError
34
-
33
+ optionsError(model, response) if optionsError
34
+
35
35
  super(attr, options)
36
36
 
37
37
  destroy: (options = {}) ->
@@ -46,16 +46,16 @@ class Bx.Model.Base extends Backbone.Model
46
46
  options.error = (model, response) =>
47
47
  @_connState("error")
48
48
  optionsError(model, response) if optionsError
49
-
49
+
50
50
  super(options)
51
51
 
52
52
  _connState: (state = "") ->
53
53
  @_conn_state = state
54
- @trigger("connection", @)
54
+ @trigger("connection", @)
55
55
 
56
56
  isError: ()->
57
57
  @_conn_state == "error"
58
-
58
+
59
59
  isConnected: () ->
60
60
  @_conn_state == "connected"
61
-
61
+
@@ -1,7 +1,7 @@
1
1
  class Bx.Pool.Base
2
2
  @reset: (name) ->
3
3
  return unless @_data?
4
- if name?
4
+ if name?
5
5
  @_data[name] = null
6
6
  else
7
7
  @_data = {}
@@ -15,7 +15,7 @@ class Bx.Pool.Base
15
15
  if !@_data[name]? || reset
16
16
  @_data[name] = @_create(name)
17
17
  @_data[name]
18
-
18
+
19
19
  @_create: (name) ->
20
20
  "should be overridden"
21
-
21
+
@@ -1,4 +1,4 @@
1
1
  class Bx.Pool.Array extends Bx.Pool.Base
2
-
2
+
3
3
  @_create: (name) ->
4
4
  []
@@ -1,4 +1,4 @@
1
1
  class Bx.Pool.Collection extends Bx.Pool.Base
2
-
2
+
3
3
  @_create: (name) ->
4
4
  new Backbone.Collection
@@ -1,4 +1,4 @@
1
1
  class Bx.Pool.Hash extends Bx.Pool.Base
2
-
2
+
3
3
  @_create: (name) ->
4
4
  {}
@@ -1,5 +1,5 @@
1
1
  class Bx.Pool.Model extends Bx.Pool.Base
2
-
2
+
3
3
  @_create: (name) ->
4
4
  new Backbone.Model
5
-
5
+
@@ -1,10 +1,10 @@
1
1
  class Bx.View.Base extends Backbone.View
2
-
2
+
3
3
  constructor: (options) ->
4
4
  super(options)
5
5
  # allow overriding of the "contructed" method
6
6
  @constructed(options) if @constructed?
7
-
7
+
8
8
  remove: () ->
9
9
  super()
10
10
  # allow overriding of the "removed" method
@@ -14,48 +14,48 @@ class Bx.View.Base extends Backbone.View
14
14
  formSetText: (fieldName, modelOrValue, attrName) ->
15
15
  field = @$("##{fieldName}")
16
16
  value = if @_isModel(modelOrValue) then modelOrValue.get(attrName ? fieldName) else modelOrValue
17
-
17
+
18
18
  field.attr('value', value)
19
19
 
20
20
  formGetText: (fieldName, model, attrName) ->
21
21
  field = @$("##{fieldName}")
22
22
  value = field.attr('value')
23
-
23
+
24
24
  if model?
25
25
  options = {}
26
- options[attrName ? fieldName] = value
26
+ options[attrName ? fieldName] = value
27
27
  model.set(options, {silent: true})
28
28
  return value
29
29
 
30
30
  formSetSelect: (fieldName, modelOrValue, attrName) ->
31
31
  field = @$("##{fieldName}")
32
32
  value = if @_isModel(modelOrValue) then modelOrValue.get(attrName ? fieldName) else modelOrValue
33
-
33
+
34
34
  field.find("option").removeAttr('selected')
35
35
  field.find("option[value='#{value}']").attr('selected', true)
36
-
36
+
37
37
  formGetSelect: (fieldName, model, attrName) ->
38
38
  field = @$("##{fieldName}")
39
39
  value = field.find('option:selected').val()
40
40
 
41
41
  if model?
42
42
  options = {}
43
- options[attrName ? fieldName] = value
43
+ options[attrName ? fieldName] = value
44
44
  model.set(options, {silent: true})
45
45
  return value
46
-
46
+
47
47
  formSetSelectMultiple: (fieldName, modelOrValue, attrName) ->
48
48
  field = @$("##{fieldName}")
49
- values = if @_isModel(modelOrValue) then modelOrValue.get(attrName ? fieldName) else modelOrValue
50
-
49
+ values = if @_isModel(modelOrValue) then modelOrValue.get(attrName ? fieldName) else modelOrValue
50
+
51
51
  field.find("option").removeAttr('selected')
52
52
  if values?
53
53
  _.each values, (value) ->
54
54
  field.find("option[value='#{value}']").attr('selected', true)
55
-
55
+
56
56
  formGetSelectMultiple: (fieldName, model, attrName) ->
57
57
  field = @$("##{fieldName}")
58
-
58
+
59
59
  values = []
60
60
  _.each field.find('option'), (option) ->
61
61
  if $(option).is(':selected')
@@ -63,38 +63,38 @@ class Bx.View.Base extends Backbone.View
63
63
 
64
64
  if model?
65
65
  options = {}
66
- options[attrName ? fieldName] = values
66
+ options[attrName ? fieldName] = values
67
67
  model.set(options, {silent: true})
68
68
  return values
69
69
 
70
70
  formSetCheckbox: (fieldName, modelOrValue, attrName) ->
71
71
  field = @$("##{fieldName}")
72
72
  value = if @_isModel(modelOrValue) then modelOrValue.get(attrName ? fieldName) else modelOrValue
73
-
73
+
74
74
  if value == true
75
75
  field.attr('checked', true)
76
76
  else
77
- field.removeAttr('checked')
78
-
77
+ field.removeAttr('checked')
78
+
79
79
  formGetCheckbox: (fieldName, model, attrName) ->
80
80
  field = @$("##{fieldName}")
81
81
  value = field.is(':checked')
82
82
 
83
83
  if model?
84
84
  options = {}
85
- options[attrName ? fieldName] = value
86
- model.set(options, {silent: true})
85
+ options[attrName ? fieldName] = value
86
+ model.set(options, {silent: true})
87
87
  return value
88
88
 
89
89
  # SET TEMPLATE VALUES
90
90
  setTemplate: (model, $scope = null) ->
91
91
  fields = if $scope? then $("*[data-setter]", $scope) else @$("*[data-setter]")
92
- _.each fields, (field) =>
92
+ _.each fields, (field) =>
93
93
  $field = $(field)
94
94
  setters= $field.attr("data-setter").split(";");
95
95
  _.each setters, (setter) =>
96
96
  setdata = setter.split(',')
97
- setdata.push("text") if (setdata.length == 1 )
97
+ setdata.push("text") if (setdata.length == 1 )
98
98
  switch $.trim(setdata[1])
99
99
  when "id"
100
100
  @setTemplateId($.trim(setdata[0]), model, $scope, $field)
@@ -111,29 +111,29 @@ class Bx.View.Base extends Backbone.View
111
111
  when "img"
112
112
  @setTemplateImg($.trim(setdata[0]), model, $scope, $field)
113
113
  when "href"
114
- @setTemplateHref($.trim(setdata[0]), model, $scope, $field)
114
+ @setTemplateHref($.trim(setdata[0]), model, $scope, $field)
115
115
  when "data"
116
- @setTemplateData($.trim(setdata[0]), model, $scope, $field)
116
+ @setTemplateData($.trim(setdata[0]), model, $scope, $field)
117
117
  else
118
118
  @setTemplateOther?($.trim(setdata[1]), $.trim(setdata[0]), model, $scope, $field)
119
119
 
120
120
  setTemplateId: (fieldName, modelOrValue, $scope, $field) ->
121
121
  value = if @_isModel(modelOrValue) then modelOrValue.get(fieldName) else modelOrValue
122
122
  field = if $field? then $field else if $scope? then $("##{fieldName}", $scope) else @$("##{fieldName}")
123
-
123
+
124
124
  field.attr(id, value)
125
-
125
+
126
126
  setTemplateText: (fieldName, modelOrValue, $scope, $field) ->
127
127
  value = if @_isModel(modelOrValue) then modelOrValue.get(fieldName) else modelOrValue
128
128
  field = if $field? then $field else if $scope? then $("##{fieldName}", $scope) else @$("##{fieldName}")
129
-
129
+
130
130
  field.html(value)
131
131
 
132
132
  setTemplateBool: (fieldName, modelOrValue, $scope, $field) ->
133
133
  value = if @_isModel(modelOrValue) then modelOrValue.get(fieldName) else modelOrValue
134
134
  field = if $field? then $field else if $scope? then $("##{fieldName}", $scope) else @$("##{fieldName}")
135
-
136
- if value == true
135
+
136
+ if value == true
137
137
  field.addClass('truthy').removeClass('falsy')
138
138
  else
139
139
  field.addClass('falsy').removeClass('truthy')
@@ -141,19 +141,19 @@ class Bx.View.Base extends Backbone.View
141
141
  setTemplateArray: (fieldName, modelOrValue, $scope, $field) ->
142
142
  values = if @_isModel(modelOrValue) then modelOrValue.get(fieldName) else modelOrValue
143
143
  field = if $field? then $field else if $scope? then $("##{fieldName}", $scope) else @$("##{fieldName}")
144
-
144
+
145
145
  result = ""
146
146
  if values?
147
- _.each values, (value)->
147
+ _.each values, (value)->
148
148
  if result.length > 0 then result += ", "
149
149
  result += value
150
-
150
+
151
151
  field.html(result)
152
-
152
+
153
153
  setTemplateShow: (fieldName, modelOrValue, $scope, $field) ->
154
154
  value = if @_isModel(modelOrValue) then modelOrValue.get(fieldName) else modelOrValue
155
155
  field = if $field? then $field else if $scope? then $("##{fieldName}", $scope) else @$("##{fieldName}")
156
-
156
+
157
157
  field.toggle(value == true)
158
158
  if value == true
159
159
  field.removeClass('hide')
@@ -163,29 +163,29 @@ class Bx.View.Base extends Backbone.View
163
163
  setTemplateHide: (fieldName, modelOrValue, $scope, $field) ->
164
164
  value = if @_isModel(modelOrValue) then modelOrValue.get(fieldName) else modelOrValue
165
165
  field = if $field? then $field else if $scope? then $("##{fieldName}", $scope) else @$("##{fieldName}")
166
-
166
+
167
167
  field.toggle(value != true)
168
168
  if value == true
169
169
  field.addClass('hide')
170
170
  else
171
171
  field.removeClass('hide')
172
-
172
+
173
173
  setTemplateImg: (fieldName, modelOrValue, $scope, $field) ->
174
174
  value = if @_isModel(modelOrValue) then modelOrValue.get(fieldName) else modelOrValue
175
175
  field = if $field? then $field else if $scope? then $("##{fieldName}", $scope) else @$("##{fieldName}")
176
-
176
+
177
177
  field.attr('src', value)
178
178
 
179
179
  setTemplateHref: (fieldName, modelOrValue, $scope, $field) ->
180
180
  value = if @_isModel(modelOrValue) then modelOrValue.get(fieldName) else modelOrValue
181
181
  field = if $field? then $field else if $scope? then $("##{fieldName}", $scope) else @$("##{fieldName}")
182
-
182
+
183
183
  field.attr('href', value)
184
184
 
185
185
  setTemplateData: (fieldName, modelOrValue, $scope, $field) ->
186
186
  value = if @_isModel(modelOrValue) then modelOrValue.get(fieldName) else modelOrValue
187
187
  field = if $field? then $field else if $scope? then $("##{fieldName}", $scope) else @$("##{fieldName}")
188
-
188
+
189
189
  field.attr("data-#{fieldName}", value)
190
190
  # MODEL OR VALUE
191
191
  _isModel: (model) ->
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backboneAX
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-01 00:00:00.000000000 Z
12
+ date: 2013-03-21 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: backbone Application Extensions for cleaner application development
15
15
  email:
@@ -51,7 +51,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
51
51
  version: '0'
52
52
  segments:
53
53
  - 0
54
- hash: -2017538596574378435
54
+ hash: -614484520966720426
55
55
  required_rubygems_version: !ruby/object:Gem::Requirement
56
56
  none: false
57
57
  requirements:
@@ -60,10 +60,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  version: '0'
61
61
  segments:
62
62
  - 0
63
- hash: -2017538596574378435
63
+ hash: -614484520966720426
64
64
  requirements: []
65
65
  rubyforge_project: backboneAX
66
- rubygems_version: 1.8.24
66
+ rubygems_version: 1.8.25
67
67
  signing_key:
68
68
  specification_version: 3
69
69
  summary: backbone Application Extensions