material_raingular 0.1.0 → 0.1.1

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
  SHA1:
3
- metadata.gz: 7420a6e01c283917cb97615df004d13474b5388a
4
- data.tar.gz: dcab33fe3307b14c36b1e4f895c67d5983faccee
3
+ metadata.gz: ca25f62ed20ba508fe00801587895b28329ad328
4
+ data.tar.gz: 818e8b319126d6f5cb154e5ca04c598db286acc1
5
5
  SHA512:
6
- metadata.gz: 0d0ea8125a33948cf5f406cd27110305ceb2e0475f1516784828599a45bd73eeac94e5c21b500906271938fd805a5c9a73e0c50642d1382202e7e6c9ea4eb39c
7
- data.tar.gz: 30fb7edfd244066b7dd091bf405c9e470abfa6575650e4e5b0e178b3218635a21d5624e39eead40a13b290357ed0f009f3d561e66c193e8fcf336527d33e18bf
6
+ metadata.gz: 4cf7d64d6dfc4921db568f48de7956fb111c5de8f70d82da582755ac80e5469b9c59b528e00e7e94b26fcf3aea18d4e2cdf9e441b6eead9a2e867a5756c5432d
7
+ data.tar.gz: c38201d4f38f35a97bda236dea815e03c4b7c76468ccb60540b888bb3a204d515b847c6c388004ea061aa857fa9ecaf908091dd5e9c8809255825ee13d3cf77d
@@ -116,9 +116,11 @@ class EventFunctions
116
116
 
117
117
  inputFunction: (search,typeAhead,event) =>
118
118
  location = search[0].selectionStart
119
- if location > 3
119
+ if location > (@options.minLength || 4) - 1
120
120
  if @functions.viewValueFn(@filteredList()[0])
121
- search.val(@functions.viewValueFn(@filteredList()[0]).replace(/^\s+/g,''))
121
+ search.val(search.val()[0..location - 1])
122
+ unless [8,46].includes(@keyholder)
123
+ search.val(@functions.viewValueFn(@filteredList()[0]).replace(/^\s+/g,'')) if search.val().toLowerCase() == @functions.viewValueFn(@filteredList()[0]).replace(/^\s+/g,'')[0..location - 1].toLowerCase()
122
124
  else
123
125
  search.val(search.val()[0..location - 1].replace(/^\s+/g,''))
124
126
  search[0].setSelectionRange(location,location)
@@ -140,15 +142,21 @@ class EventFunctions
140
142
  template.removeClass('focused')
141
143
  @setTypeAheadScroll(search,typeAhead)
142
144
  if search.val().length < (@options.minLength || 4)
143
- search.val('')
145
+ @updateValue('')
144
146
  else
145
- obj={}
146
- obj[@functions.viewValue] = search.val()
147
- val = @filter('filter')(@functions.collection(@scope), obj)[0]
147
+ if @functions.isPrimative
148
+ obj = search.val()
149
+ else
150
+ obj={}
151
+ obj[@functions.viewValue] = search.val()
152
+ collection = @functions.collection(@scope)
153
+ if @options.allowNew
154
+ collection.push(obj) unless collection.includes(obj)
155
+ val = @filter('filter')(collection, obj, !!@options.allowNew)[0]
148
156
  @updateValue @functions.modelValueFn(val)
149
- search.val(@functions.viewValueFn(val).replace(/^\s+/g,''))
150
157
 
151
158
  keydownFunction: (search,typeAhead,template,input) =>
159
+ @keyholder = input.keyCode
152
160
  @setTypeAheadScroll(search,typeAhead)
153
161
  keypress = (direction) ->
154
162
  index = if direction == 'next' then 0 else template.find('a').length - 1
@@ -203,6 +211,7 @@ angular.module('FilteredSelect', [])
203
211
  .directive 'ngFilteredSelect', ($parse,$filter,$timeout)->
204
212
  require: 'ngModel'
205
213
  link: (scope,element,attrs,ngModel) ->
214
+ viewOptions = JSON.parse(attrs.filterOptions || '{}')
206
215
  equiv = (left,right) ->
207
216
  return true if left == right
208
217
  return true if (!!left && !!right) == false
@@ -220,7 +229,8 @@ angular.module('FilteredSelect', [])
220
229
  obj={}
221
230
  obj[functions.viewValue] = elements.search.val()[0..location - 1].replace(/^\s+/g,'') || ''
222
231
  return unless functions.collection(scope)
223
- fList = $filter('orderBy')($filter('filter')(functions.collection(scope), obj,bool), functions.viewValue)
232
+ fList = $filter('orderBy')($filter('filter')(functions.collection(scope), obj,bool), viewOptions.orderBy || functions.viewValue)
233
+ console.dir fList
224
234
  for filter in options.filters
225
235
  [filterType,value] = filter.replace(/\s+/,'').split(':')
226
236
  fList = $filter(filterType)(fList, value)
@@ -243,6 +253,7 @@ angular.module('FilteredSelect', [])
243
253
  elements.template.append(li)
244
254
  setInitialValue = ->
245
255
  unless isMobile
256
+ val = ''
246
257
  if model = scope.$eval(attrs.ngModel)
247
258
  if functions.isPrimative
248
259
  obj = model
@@ -251,8 +262,9 @@ angular.module('FilteredSelect', [])
251
262
  obj[functions.modelValue] = model
252
263
  list = $filter('filter')(functions.collection(scope), obj,equiv)
253
264
  viewScope = list[0] if list
254
- elements.search.val(if viewScope then functions.viewValueFn(viewScope).replace(/^\s+/g,'') else '')
255
- elements.typeAhead.html(elements.search.val())
265
+ val = if viewScope then functions.viewValueFn(viewScope).replace(/^\s+/g,'') else ''
266
+ elements.search.val(val)
267
+ elements.typeAhead.html(elements.search.val())
256
268
  else
257
269
  unless model = scope.$eval(attrs.ngModel)
258
270
  view = attrs.placeholder
@@ -272,7 +284,7 @@ angular.module('FilteredSelect', [])
272
284
 
273
285
  updateValue = (model) ->
274
286
  scope.$apply ->
275
- ngModel.$setViewValue(model)
287
+ ngModel.$setViewValue(model || '')
276
288
  elements.tempHolder.removeClass('active')
277
289
  setInitialValue()
278
290
  disabled = ->
@@ -295,7 +307,6 @@ angular.module('FilteredSelect', [])
295
307
  return true if form.disabled
296
308
  return false
297
309
 
298
- viewOptions = JSON.parse(attrs.filterOptions || '{}')
299
310
  options = new SelectOptions(attrs.ngSelectOptions,element[0].outerHTML)
300
311
  functions = new SelectFunctions(options.match,$parse)
301
312
  eFunctions = new EventFunctions(functions,buildTemplate,updateValue,filteredList,$filter,$timeout,$parse,scope,disabled,viewOptions)
@@ -13,7 +13,7 @@ class ElementUpdate
13
13
  @timeout = timeout
14
14
  @bindInput() if @isInput
15
15
  @bindElement() unless @isInput
16
- @setPlaceholder() unless @placeholder
16
+ @setPlaceholder() if typeof @placeholder == 'undefined'
17
17
  watcher: ->
18
18
  eu = @
19
19
  @scope.$watch @modelVal, (updated,old) ->
@@ -1,3 +1,3 @@
1
1
  module MaterialRaingular
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: material_raingular
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Moody
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-09 00:00:00.000000000 Z
11
+ date: 2016-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler