material_raingular 0.0.1.alpha → 0.0.2.alpha

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc8b3fde9153d728b103515e331213214f7d8869
4
- data.tar.gz: be9370ebe8c6d33b766c9ecb3d8fe46186948a58
3
+ metadata.gz: c6b89dcb5aaed8e1ccb5bc7b31f826165201b73f
4
+ data.tar.gz: fc3af078ed0d7119fac7523948286765c587dd51
5
5
  SHA512:
6
- metadata.gz: bbbc21e4a0d5d4b1888844258afeb510eecad05f7e6e37c3495b496ca8414dc6fcef56cfae64f5649c9126d0be6bc5a9bea345b50efe50873d4841a9d049c970
7
- data.tar.gz: 9762463d29da0434cfa4790e1a9bf9e8e41893890e66e2059849ca94d1096d89ab2a1ec033cce48a0d6677b03cfc7d7a821e4064763b2b01a53b705361e89255
6
+ metadata.gz: 73e7a544ba217cf5b909897ffd4efc2a6d9b7c1710c444f85c596cc21da791a631e6ba68306a4592de9b6cc755e6eb4d03987c7cf8c492f51ae8c7794e01d85d
7
+ data.tar.gz: f7c1e8316babc822e13807960c4b96a93779959aa51bb6516bbd833bcca463024a7082944aa83262abfa2dfbd027d9d0d794c28caf4adacddfe271d7e98ee00d
@@ -7,7 +7,6 @@ angular.factories
7
7
  response: (response) -> response
8
8
  responseError: (rejection) ->
9
9
  $rootScope.xhr_errors = []
10
- for k,v of rejection.data
11
- for description in v
12
- $rootScope.xhr_errors.push(k + ' ' + ' ' + description)
10
+ for error in rejection.data.errors
11
+ $rootScope.xhr_errors.push(error)
13
12
  rejection
@@ -1,18 +1,4 @@
1
- class DateParser
2
- constructor: (object)->
3
- @object = object
4
- evaluate: ->
5
- for i of @object
6
- if @object[i] != null and typeof @object[i] == 'object'
7
- new DateParser(@object[i]).evaluate()
8
- else if @object[i] != null and typeof @object[i] == 'string'
9
- if !!@object[i].match(/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/)
10
- time = new Date(@object[i])
11
- time.setTime( time.getTime() + time.getTimezoneOffset()*60*1000 ) #offset timezone
12
- @object[i] = time
13
- else if !!@object[i].match(/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])T[0-9]{2}\:[0-9]{2}\:[0-9]{2}\.[0-9]{3}[A-Z]$/)
14
- @object[i] = new Date(@object[i])
15
- return
1
+ # //= require dateparser
16
2
  angular.factories
17
3
  .factory 'DateConverterInterceptor', ($q, $rootScope) ->
18
4
  request: (config) -> config
@@ -0,0 +1,21 @@
1
+ root = exports ? this
2
+ class root.DateParser
3
+ constructor: (object)->
4
+ @object = object
5
+ formatDate: (date)->
6
+ date.getFullYear() + '-' + ('0' + (date.getMonth() + 1))[-2..-1] + '-' + ( '0' + date.getDate())[-2..-1]
7
+ to_s: ->
8
+ @evaluate(true)
9
+ evaluate: (string_flag)->
10
+ for i of @object
11
+ if @object[i] != null and typeof @object[i] == 'object'
12
+ new DateParser(@object[i]).evaluate()
13
+ else if @object[i] != null and typeof @object[i] == 'string'
14
+ if !!@object[i].match(/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/)
15
+ time = new Date(@object[i])
16
+ time.setTime( time.getTime() + time.getTimezoneOffset()*60*1000 ) #offset timezone
17
+ @object[i] = if string_flag then @formatDate(time) else time
18
+ else if !!@object[i].match(/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])T[0-9]{2}\:[0-9]{2}\:[0-9]{2}\.[0-9]{3}[A-Z]$/)
19
+ time = new Date(@object[i])
20
+ @object[i] = if string_flag then @formatDate(time) else time
21
+ return
@@ -1,7 +1,8 @@
1
1
  angular.module 'NgBoolean', ['Factories', 'FactoryName']
2
2
 
3
- .directive 'ngBoolean', ($timeout, $compile) ->
3
+ .directive 'ngBoolean', ($injector,factoryName) ->
4
4
  restrict: 'A'
5
+ require: 'ngModel'
5
6
 
6
7
  link: (scope, element, attributes, ngModelCtrl) ->
7
8
  model = attributes.ngModel
@@ -9,10 +10,8 @@ angular.module 'NgBoolean', ['Factories', 'FactoryName']
9
10
  callFunction += ';' + attributes.ngCallback if attributes.ngCallback
10
11
  element.attr("call-function", callFunction)
11
12
  element.bind 'click', ->
12
- scope.$eval(element.attr("call-function"))
13
-
14
- controller: ($scope, $injector,factoryName) ->
15
- $scope.update = (modelName)->
13
+ scope.$eval(element.attr("call-function")) unless attributes.disabled
14
+ scope.update = (modelName)->
16
15
  input = modelName.split(',')
17
16
  trackby = input.pop() if input.length > 1
18
17
  trackby = trackby.split(';') if trackby
@@ -20,15 +19,15 @@ angular.module 'NgBoolean', ['Factories', 'FactoryName']
20
19
  data = input.splice(0,1)[0].split('.')
21
20
  functions = input.join(',').split(')')
22
21
  factory = factoryName(data[0])
23
- object = {id: $scope[data[0]]['id']}
24
- object[data[0]] = {id: $scope[data[0]]['id']}
25
- object[data[0]][data[1]] = $scope[data[0]][data[1]]
22
+ object = {id: scope[data[0]]['id']}
23
+ object[data[0]] = {id: scope[data[0]]['id']}
24
+ object[data[0]][data[1]] = scope[data[0]][data[1]]
26
25
  list = $injector.get(factory)
27
26
  list.update object, (returnData) ->
28
27
  for tracked in trackby
29
- $scope[data[0]][tracked] = returnData[tracked]
30
- $scope[data[0]][data[1]] = returnData[data[1]] if $scope[data[0]][data[1]] == object[data[0]][data[1]]
28
+ scope[data[0]][tracked] = returnData[tracked]
29
+ ngModelCtrl.$setViewValue(returnData[data[1]]) if ngModelCtrl.$modelValue == object[data[0]][data[1]]
31
30
  callFunctions = []
32
31
  for callFunction in functions
33
32
  callFunctions.push(callFunction + ',' + JSON.stringify(returnData) + ')') if callFunction.length > 0
34
- $scope.$eval( callFunctions.join('') ) if callFunctions.join('').length > 0
33
+ scope.$eval( callFunctions.join('') ) if callFunctions.join('').length > 0
@@ -5,10 +5,11 @@ angular.module 'NgCreate', ['Factories', 'FactoryName']
5
5
  link: (scope, element, attributes) ->
6
6
  element.bind 'click', (event) ->
7
7
  [parentName, listName] = attributes.ngContext.split('.') if attributes.ngContext
8
- attr = eval('(' + attributes.ngAttributes + ')') || {}
8
+ attr = scope.$eval('(' + attributes.ngAttributes + ')') || {}
9
9
  scope.create(attributes.ngCreate,parentName,listName,attr)
10
- controller: ($scope, $injector, factoryName) ->
10
+ controller: ($scope, $injector, factoryName, $element) ->
11
11
  $scope.create = (modelName,parentName,listName,attributes) ->
12
+ addTo = $element[0].attributes['ng-add-to'].value if $element[0].attributes['ng-add-to']
12
13
  factory = factoryName(modelName)
13
14
  list = $injector.get(factory)
14
15
  object = {}
@@ -17,6 +18,8 @@ angular.module 'NgCreate', ['Factories', 'FactoryName']
17
18
  object[parentName] = $scope[parentName] unless parentName.indexOf('_id') < 0
18
19
  object[parentName + '_id'] = $scope[parentName].id if parentName.indexOf('_id') < 0
19
20
  list.create object, (returnData) ->
21
+ if addTo
22
+ $scope[addTo].push(returnData)
20
23
  if listName
21
24
  scope = if $scope[parentName] then $scope else $scope.$parent
22
25
  scope[parentName] = {} unless scope[parentName]
@@ -60,3 +60,79 @@ angular.module 'NgUpdate', ['Factories', 'FactoryName']
60
60
  for callFunction in functions
61
61
  callFunctions.push(callFunction + ',' + JSON.stringify(returnData) + ')') if callFunction.length > 0
62
62
  $scope.$eval( callFunctions.join('') ) if callFunctions.join('').length > 0
63
+
64
+ .directive 'mdUpdate', ($timeout, factoryName, $injector) ->
65
+ restrict: 'A'
66
+ require: 'ngModel'
67
+
68
+ link: (scope, element, attributes, ngModelCtrl) ->
69
+ modelName = attributes.ngModel
70
+ watcher = ->
71
+ scope.$watch modelName, (updated,old) ->
72
+ update(updated) unless updated == old
73
+ equiv = (left,right) ->
74
+ return true if left == right
75
+ return true if (!!left && !!right) == false
76
+ false
77
+
78
+ update = (value) ->
79
+ override = if attributes.ngOverride then attributes.ngOverride.split('.') else []
80
+ functions = if attributes.ngCallback then attributes.ngCallback.split(';') else []
81
+ trackby = if attributes.ngTrackBy then attributes.ngTrackBy.split(';') else []
82
+ data = modelName.split('.')
83
+ factory = factoryName(override[0] || data[0])
84
+ if override[1]
85
+ object = {id: scope.$eval(override[0]).id}
86
+ object[override[1]] = scope.$eval(override[1])
87
+ else
88
+ object = {id: scope[data[0]]['id']}
89
+ object[data[0]] = {id: scope[data[0]]['id']}
90
+ object[data[0]][data[1]] = scope[data[0]][data[1]]
91
+ list = $injector.get(factory)
92
+
93
+ list.update object, (returnData) ->
94
+ for tracked in trackby
95
+ scope[data[0]][tracked] = returnData[tracked]
96
+ scope[data[0]][data[1]] = returnData[data[1]] if equiv(scope[data[0]][data[1]], object[data[0]][data[1]]) && !equiv(scope[data[0]][data[1]], returnData[data[1]])
97
+ scope[data[0]].errors = returnData.errors
98
+ callFunctions = []
99
+ for callFunction in functions
100
+ [match,func,args] = callFunction.match(/(.*)\((.*)\)/)
101
+ if typeof scope[func] == 'function'
102
+ scope[func](args,returnData)
103
+ else if typeof window[func] == 'function'
104
+ window[func](args,returnData)
105
+ if element[0].tagName == 'INPUT'
106
+ if attributes.type == 'radio' || attributes.type == 'checkbox' || attributes.type == 'date'
107
+ element.bind 'input', (event) ->
108
+ return unless ngModelCtrl.$valid
109
+ update(element.val())
110
+ else if attributes.type == 'hidden'
111
+ watcher()
112
+ else
113
+ oldValue = null
114
+ element.bind 'focus', ->
115
+ scope.$apply ->
116
+ oldValue = element.val()
117
+ element.bind 'blur', (event) ->
118
+ delay = if element.hasClass('autocomplete') then 300 else 0
119
+ $timeout ->
120
+ scope.$apply ->
121
+ newValue = element.val()
122
+ update(newValue) if (newValue != oldValue)
123
+ , delay
124
+ else if element[0].tagName == 'TEXTAREA'
125
+ element.bind 'keyup', ->
126
+ $timeout.cancel(scope.debounce)
127
+ scope.debounce = $timeout ->
128
+ update(element.val())
129
+ ,750
130
+ else
131
+ watcher()
132
+ if element[0].attributes['placeholder']
133
+ placeholder = element[0].attributes['placeholder'].value
134
+ else
135
+ placeholder = ''
136
+ for word in modelName.split('.').pop().split('_')
137
+ placeholder += word[0].toUpperCase() + word[1..-1].toLowerCase() + ' '
138
+ element.attr('placeholder',placeholder)
@@ -0,0 +1,8 @@
1
+ angular.factories
2
+ .factory 'IdentifierInterceptor', ($q, $rootScope) ->
3
+ request: (config) ->
4
+ config.headers.angular = true
5
+ config
6
+ requestError: (rejection) -> rejection
7
+ response: (response) -> response
8
+ responseError: (rejection) -> rejection
@@ -1,6 +1,7 @@
1
1
  # //= require angular
2
2
  # //= require angular-route
3
3
  # //= require angular-resource
4
+ # //= require angular-messages
4
5
  # //= require angular-animate
5
6
  # //= require angular-aria
6
7
  # //= require angular-material.min
@@ -10,8 +11,10 @@
10
11
  # //= require js-routes
11
12
  # //= require dateconverter
12
13
  # //= require ajax_errors
14
+ # //= require identifier_interceptor
13
15
 
14
16
  angular.module('materialRaingular', ['AutoComplete', 'NgDownload', 'NgChangeOnBlur', 'NgDrag', 'NgAuthorize'
15
17
  'NgRepeatList', 'NgUpdate', 'NgPopup', 'NgBoolean', 'Table', 'NgWatchShow'
16
18
  'NgUpload', 'NgDestroy', 'NgCreate', 'Video','NgAuthorize', 'TextArea'
17
- 'NgSlide', 'NgMatches','NgFade','NgSwipe', 'NgLoad', 'NgWatchContent'])
19
+ 'NgSlide', 'NgMatches','NgFade','NgSwipe', 'NgLoad', 'NgWatchContent'
20
+ 'ngRoute', 'ngMaterial', 'ngMessages', 'ngResource'])
@@ -1,3 +1,3 @@
1
1
  module MaterialRaingular
2
- VERSION = "0.0.1.alpha"
2
+ VERSION = "0.0.2.alpha"
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.0.1.alpha
4
+ version: 0.0.2.alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Moody
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-23 00:00:00.000000000 Z
11
+ date: 2015-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -69,6 +69,7 @@ files:
69
69
  - Rakefile
70
70
  - lib/assets/javascripts/ajax_errors.js.coffee
71
71
  - lib/assets/javascripts/dateconverter.coffee
72
+ - lib/assets/javascripts/dateparser.coffee
72
73
  - lib/assets/javascripts/directives/ngauthorize.js.coffee
73
74
  - lib/assets/javascripts/directives/ngautocomplete.js.coffee
74
75
  - lib/assets/javascripts/directives/ngboolean.js.coffee
@@ -92,6 +93,7 @@ files:
92
93
  - lib/assets/javascripts/directives/textarea.coffee
93
94
  - lib/assets/javascripts/directives/video.js.coffee
94
95
  - lib/assets/javascripts/factory_name.js.coffee
96
+ - lib/assets/javascripts/identifier_interceptor.js.coffee
95
97
  - lib/assets/javascripts/material_raingular.js.coffee
96
98
  - lib/material_raingular.rb
97
99
  - lib/material_raingular/version.rb