abstracted 0.3.3 → 0.3.4

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: aff5b25e98fbac0db0277def4b26dac60ade157e
4
- data.tar.gz: 900baf74932298877889d24f5398b07cc60f217f
3
+ metadata.gz: 5bb946be423371961e8d08aeb8322b863a94b07f
4
+ data.tar.gz: 225bbee0f0f7cc8703670d17f6de1ba02d8692e0
5
5
  SHA512:
6
- metadata.gz: f6b21d0f05200e511c0545614298932effbdac83fd6a8c18199d92be0957c8c50acd1156a7f3411648f80def83139c0d3466a9c22e3d988e72fb46e08cf0be1f
7
- data.tar.gz: b04bfc2af2be21c664f698dacf1a894711cc42934e03d2850c2f056998649d5352c4a109e92bd9c55edd3a279b452fb8c59293e0d6bae62daa05d8028c2ac560
6
+ metadata.gz: d7c3791294abecbea359ef6a9286d2b1cd98798979aa05c5d4c005de178757ca57f39e1208afbf3a60891f69fb5c74b98f11027c4aa60bb359f969e8c60466c3
7
+ data.tar.gz: ba5b34ee89bc44fc856cea2f961cf5aac00afff73bd647a2479a891672c52a48ff1faddcc44a5b300f43d5d236c6eec14567c616a4d0cf266aefebc09ca20d9d
data/.gitignore CHANGED
@@ -1,9 +1,10 @@
1
1
  .bundle/
2
2
  log/*.log
3
3
  pkg/
4
- test/dummy/db/*.sqlite3
5
- test/dummy/db/*.sqlite3-journal
6
- test/dummy/log/*.log
4
+ test/dummy/db/*
5
+ test/dummy/log/*
7
6
  test/dummy/tmp/
8
7
  test/dummy/.sass-cache
8
+ spec/dummy/db/*
9
+ spec/dummy/log/*
9
10
  *gem
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- abstracted (0.0.10)
4
+ abstracted (0.3.3)
5
5
  kaminari
6
6
  pundit
7
7
  rails (~> 4.1)
@@ -60,6 +60,7 @@ GEM
60
60
  activesupport (>= 3.0.0)
61
61
  railties (>= 3.0.0)
62
62
  thor (>= 0.14.6)
63
+ concurrent-ruby (1.0.0)
63
64
  database_cleaner (1.4.1)
64
65
  diff-lcs (1.2.5)
65
66
  erubis (2.7.0)
@@ -120,7 +121,7 @@ GEM
120
121
  pry-remote (0.1.8)
121
122
  pry (~> 0.9)
122
123
  slop (~> 3.0)
123
- pundit (1.0.1)
124
+ pundit (1.1.0)
124
125
  activesupport (>= 3.0.0)
125
126
  rack (1.6.0)
126
127
  rack-test (0.6.3)
@@ -153,8 +154,8 @@ GEM
153
154
  rb-fsevent (0.9.4)
154
155
  rb-inotify (0.9.5)
155
156
  ffi (>= 0.5.0)
156
- responders (2.1.0)
157
- railties (>= 4.2.0, < 5)
157
+ responders (2.1.1)
158
+ railties (>= 4.2.0, < 5.1)
158
159
  rspec (3.2.0)
159
160
  rspec-core (~> 3.2.0)
160
161
  rspec-expectations (~> 3.2.0)
@@ -181,12 +182,13 @@ GEM
181
182
  rspec-support (3.2.2)
182
183
  shellany (0.0.1)
183
184
  slop (3.6.0)
184
- sprockets (3.2.0)
185
- rack (~> 1.0)
186
- sprockets-rails (2.3.2)
187
- actionpack (>= 3.0)
188
- activesupport (>= 3.0)
189
- sprockets (>= 2.8, < 4.0)
185
+ sprockets (3.5.2)
186
+ concurrent-ruby (~> 1.0)
187
+ rack (> 1, < 3)
188
+ sprockets-rails (3.0.0)
189
+ actionpack (>= 4.0)
190
+ activesupport (>= 4.0)
191
+ sprockets (>= 3.0.0)
190
192
  sqlite3 (1.3.10)
191
193
  terminal-notifier (1.6.2)
192
194
  thor (0.19.1)
@@ -7,7 +7,6 @@
7
7
  // require_tree .
8
8
  //= require init
9
9
  //= require triggers
10
- //= require pagescrolling
11
10
  //= require_tree ./abstracted
12
11
 
13
12
 
@@ -2,7 +2,7 @@ class App.fabDelete
2
2
 
3
3
  constructor: (@el) ->
4
4
  # initialize some stuff
5
-
5
+
6
6
  #
7
7
  # deletePost handles deleting records
8
8
  #
@@ -29,30 +29,6 @@ class App.fabDelete
29
29
 
30
30
  catch error
31
31
  swal "Hmmm", "Most unexpected! \n#{error}", "error"
32
- #
33
- # statusCode:
34
- #
35
- # 200: (response,textStatus,jqXHR) ->
36
- # closeSweetAlert()
37
- # tellResponse response.responseText
38
- #
39
- #
40
- # 301: () ->
41
- # $elem.show()
42
- # closeSweetAlert()
43
- # swal "Ikke slettet!", "Posten blev ikke slettet - årsagen ikke kendt", "warning"
44
- #
45
- # 401: (response) ->
46
- # tellResponse response.responseText
47
- # closeSweetAlert()
48
- #
49
- # 409: (response) ->
50
- # tellResponse response.responseText
51
- # closeSweetAlert()
52
- #
53
- # 412: () ->
54
- # closeSweetAlert()
55
- # swal "Øv!", "Et eller andet gik galt!", "error"
56
32
 
57
33
 
58
34
 
@@ -63,6 +39,7 @@ class App.fabDelete
63
39
  handleFABLinks: (e) =>
64
40
  e.preventDefault()
65
41
  e.stopPropagation()
42
+
66
43
  elem = $(e.currentTarget)
67
44
  if elem.data('browser')=='new'
68
45
  window.open elem.data('url')
@@ -121,7 +98,7 @@ class App.fabDelete
121
98
  confirmButtonColor: "#ec6c62",
122
99
  (confirmed) =>
123
100
  if !confirmed
124
- @closeSweetAlert($elem)
101
+ App.shared.closeSweetAlert($elem)
125
102
  else
126
103
  @deletePost($elem)
127
104
  return false
@@ -2,7 +2,7 @@ class App.Materialize
2
2
  constructor: (@el) ->
3
3
  # initialize some stuff
4
4
 
5
- prepare: ->
5
+ prepare: =>
6
6
 
7
7
  try
8
8
  #
@@ -21,12 +21,26 @@ class App.Materialize
21
21
  #
22
22
  $(".dropdown-button").dropdown()
23
23
 
24
+ #
25
+ # watch out for tooltipped
26
+
27
+ #
28
+ $('.tooltipped').tooltip({delay: 50})
29
+
24
30
  #
25
31
  # prepare for tabbed display of tabbed UL's
26
32
  #
27
33
  $('ul.tabs').tabs()
28
34
  $('.materialboxed').materialbox()
29
35
 
36
+ #
37
+ # Initialize SELECT's
38
+ #
39
+ $('select').each () ->
40
+ # remove span.caret's from previous 'runs' - however that happens
41
+ $(this).parent().parent().find('span.caret').remove()
42
+ $(this).material_select()
43
+
30
44
  catch error
31
45
  alert 'App.Materialize did not prepare!'
32
46
  console.log error
@@ -0,0 +1,143 @@
1
+ class App.PageScrolling
2
+
3
+ constructor: () ->
4
+ # initialize some stuff
5
+ @table=null
6
+ @loadingPage = false
7
+ # currentPage = 0
8
+ # totalPages = 0
9
+ @navPaginator = ''
10
+ @lastPage = 0
11
+ @nextPage = 0
12
+ @pageUrl = ''
13
+ @contxt = null
14
+ @scrollTimeout = false
15
+ @_me = 0
16
+
17
+ spinWhileLoading: () =>
18
+ if @loadingPage
19
+ App.shared.releaseLoader()
20
+ @loadingPage=false
21
+ else
22
+ loader = '<div class="preloader-wrapper small active"> <div class="spinner-layer spinner-blue-only"> <div class="circle-clipper left"> <div class="circle"></div> </div><div class="gap-patch"> <div class="circle"></div> </div><div class="circle-clipper right"> <div class="circle"></div> </div> </div> </div>'
23
+ loaded_element = $('.fixed-action-btn')
24
+ App.shared.setLoader( loaded_element,loader )
25
+ @loadingPage=true
26
+
27
+ evalPageNumber: (elem) =>
28
+ if elem
29
+ try
30
+ pn = elem[0].href
31
+ .split('?')[1]
32
+ .split('&')
33
+ .filter (el,i,array) ->
34
+ if el.match /^page/
35
+ return el
36
+ .join('')
37
+ .split('=')[1]
38
+ parseInt(pn)
39
+ catch error
40
+ pn = 0
41
+
42
+ #
43
+ # setVariables prepares for a great scrolling experience
44
+ #
45
+ setVariables: (elem) =>
46
+ return if $('nav.pagination').size() < 1
47
+ @navPaginator = $('nav.pagination')
48
+ try
49
+ @pageUrl = @navPaginator.find('a[rel=next]')[0].href.replace( '?', '.js?scrolling=true&')
50
+ @lastPage = @evalPageNumber @navPaginator.find('span.last a')
51
+ @nextPage = @evalPageNumber @navPaginator.find('a[rel=next]')
52
+ @contxt = $(elem)
53
+ if @nextPage > 1
54
+ @nextPage = 1
55
+ true
56
+
57
+ catch error
58
+ console.log error
59
+ return false
60
+
61
+ #
62
+ # setPaginationHandler prepares to handle all clicks on
63
+ # the nav.pagination links
64
+ #
65
+ # setPaginationHandler: () =>
66
+ # $(document.body).on 'click.pagination', '.first > a, .previous > a, .page > a, .next > a, .last > a', (e) =>
67
+ # @paginate(e)
68
+ #
69
+ # paginate: (e) =>
70
+ # e.preventDefault()
71
+ # e.stopPropagation()
72
+ # @nextPage = e.currentTarget.href.match(/page=(\d*)&/)[1]
73
+ # wurl = window.location.href.replace /#!$/, ''
74
+ # if !@pageUrl.split("?")[0].split(".js")[0].match wurl.split("?")[0]
75
+ # clearTimeout( @scrollTimeout )
76
+ # return false
77
+ # clearTimeout( @scrollTimeout )
78
+ # @loadNextPage @pageUrl.replace( /page=\d*&/, 'page=' + @nextPage + '&'), true
79
+
80
+
81
+ #
82
+ # closeToBottom checks to see if you're close to the bottom of the screen
83
+ #
84
+ closeToBottom: () =>
85
+ return false if @navPaginator.size() == 0
86
+ return ($(window).scrollTop() - parseInt($(document).height()) + parseInt($(window).height())) > -200
87
+
88
+ findNextPageToLoad: () =>
89
+ @nextPage += 1
90
+ if @nextPage > @lastPage
91
+ clearTimeout( @scrollTimeout )
92
+ return false
93
+ wurl = window.location.href.replace /#!$/, ''
94
+ if !@pageUrl.split("?")[0].split(".js")[0].match wurl.split("?")[0]
95
+ clearTimeout( @scrollTimeout )
96
+ return false
97
+ @pageUrl
98
+ .replace /page=\d*&/, 'page=' + @nextPage + '&'
99
+
100
+
101
+ loadNextPage: (url,replace=false) =>
102
+ if !@loadingPage
103
+ # url = @findNextPageToLoad()
104
+ if url
105
+ @spinWhileLoading()
106
+ jqxhr = $.ajax
107
+ url: url
108
+ type: 'GET'
109
+ dataType: 'html'
110
+ .done (data) =>
111
+ if replace
112
+ @contxt.find('tbody').html(data)
113
+ else
114
+ @contxt.find('tbody').append(data)
115
+ App.trigger('app:pageload')
116
+ @spinWhileLoading()
117
+ .fail (data) =>
118
+ @loadingPage = false
119
+ console.log 'err'
120
+ #
121
+ # scroll a list - behind the scenes calling in extra pages of content
122
+ #
123
+ scrollTable: (elem) =>
124
+ return if $(elem)[0] == undefined || App.currentPage == $(elem)[0].id
125
+ App.currentPage = $(elem)[0].id
126
+ return unless @setVariables(elem)
127
+ if @lastPage > @nextPage && @nextPage < 3
128
+ App.shared.callToast 'Der er mere end én side resultater - scroll ned for at se flere!'
129
+
130
+ # pagination is hidden as of 8/3/2016
131
+ # @setPaginationHandler()
132
+ @table=elem
133
+ if @nextPage > 0
134
+ scrollHandler = () =>
135
+ clearTimeout( @scrollTimeout )
136
+ if @closeToBottom()
137
+ $.when @loadNextPage(@findNextPageToLoad())
138
+ .then @scrollTimeout = setTimeout( scrollHandler, 250)
139
+ .then @navPaginator.hide()
140
+ else
141
+ setTimeout( scrollHandler, 250)
142
+
143
+ @scrollTimeout = setTimeout( scrollHandler, 250)
@@ -20,13 +20,6 @@ class App.ResourceForm
20
20
 
21
21
  try
22
22
 
23
- #
24
- # Initialize SELECT's
25
- #
26
- $('select').each () ->
27
- # remove span.caret's from previous 'runs' - however that happens
28
- $(this).parent().parent().find('span.caret').remove()
29
- $(this).material_select()
30
23
 
31
24
  #
32
25
  # make labels on fields with content move out of the way
@@ -247,11 +247,12 @@ class App.ResourcesList
247
247
 
248
248
  prepare: =>
249
249
 
250
+ @searchForm = $('#list-search-form')[0]
251
+
250
252
  try
251
253
  $(document.body).unbind('click.print')
252
- $(document.body).unbind('click.attach')
253
- $(document.body).unbind('click.activate')
254
- $(document.body).unbind('click.prefer')
254
+ $(document.body).unbind('keydown.search')
255
+ $(document.body).unbind('click.search')
255
256
 
256
257
  $(document.body).on 'click.print', 'a.print_post_link, a.print_item', @handlePrintLinks
257
258
  $(document.body).on 'keydown.search', 'input.search-list', @searchKey
@@ -261,10 +262,12 @@ class App.ResourcesList
261
262
  # If this page has a resources_list
262
263
  #
263
264
  $('table.resources_table').map (k,t) =>
265
+ $(document.body).unbind('click.attach')
266
+ $(document.body).unbind('click.activate')
267
+ $(document.body).unbind('click.prefer')
264
268
  $(document.body).on 'click.attach', 'a.attached, a.detached', @handleAttachLinks
265
269
  $(document.body).on 'click.activate', 'a.activated, a.deactivated', @handleActivateLinks
266
270
  $(document.body).on 'click.prefer', 'a.preferred, a.deferred', @handlePreferredLinks
267
- scrollTable(t)
268
271
 
269
272
  catch error
270
273
  alert 'App.ResourcesList did not prepare!'
@@ -15,6 +15,9 @@ class App.Shared
15
15
  getCurrentForm: =>
16
16
  @currentForm
17
17
 
18
+ callToast: (msg,time=3000,style="rounded") =>
19
+ Materialize.toast(msg, time,style)
20
+
18
21
  getDownload: (xhr,data) =>
19
22
  # Check if a filename is existing on the response headers.
20
23
  filename = ""
@@ -3,10 +3,7 @@
3
3
  #
4
4
  # reacts to 'app.something' events
5
5
  #
6
- window.App ||= { name: 'App', shared: null, cf: null }
7
-
8
- App.shared = ->
9
- @shared
6
+ window.App ||= { name: 'App', shared: null, cf: null, ps: null, _me: 0, page: null, sweet: null, resourceslist: null, resourceform: null, fab: null, currentPage: null }
10
7
 
11
8
  App.currentForm = (val) ->
12
9
  @shared.setCurrentForm(val)
@@ -21,19 +18,43 @@ App.trigger = (event) ->
21
18
  # signal App
22
19
  App.init = ->
23
20
 
24
- @shared = new App.Shared()
25
- #
26
- App.trigger('app:init')
27
- #
28
- # Try to keep users from double-clicking submit's
29
- #
30
- # document.addEventListener('DOMContentLoaded', disableMultipleSubmits, false);
21
+ @_me += 1
22
+
23
+ if @_me < 2
24
+
25
+ unless App.sweet
26
+ App.sweet = new App.SweetAlert()
27
+
28
+ unless App.resourceslist
29
+ App.resourceslist = new App.ResourcesList($('form'))
30
+
31
+ unless App.resourceform
32
+ App.resourceform = new App.ResourceForm()
33
+
34
+ unless App.fab
35
+ App.fab = new App.fabDelete()
36
+
37
+ unless @page
38
+ @page = new App.Materialize()
39
+
40
+ unless @shared
41
+ @shared = new App.Shared()
42
+
43
+ unless @ps
44
+ @ps = new App.PageScrolling()
31
45
 
32
- #
33
- # Prepare close-notice's for acting on clicks to remove div
34
- #
35
- $(document.body).unbind('click.close_notice')
36
- $(document.body).on 'click.close_notice', 'a.close-notice', App.closeNotice
46
+ #
47
+ App.trigger('app:init')
48
+ #
49
+ # Try to keep users from double-clicking submit's
50
+ #
51
+ # document.addEventListener('DOMContentLoaded', disableMultipleSubmits, false);
52
+
53
+ #
54
+ # Prepare close-notice's for acting on clicks to remove div
55
+ #
56
+ $(document.body).unbind('click.close_notice')
57
+ $(document.body).on 'click.close_notice', 'a.close-notice', App.closeNotice
37
58
 
38
59
 
39
60
  #
@@ -41,10 +62,29 @@ App.init = ->
41
62
  App.pageload = ->
42
63
  App.trigger('app:pageload')
43
64
 
65
+ App.pageunload = ->
66
+ App.trigger('app:pageunload')
44
67
 
45
68
  #
46
69
  # closeNotice
47
70
  # will close the notice DIV
48
71
  App.closeNotice = (e) ->
49
- shared = new App.Shared()
50
- shared.fadeItOut $(e).closest('.alert') #.remove()
72
+ App.shared.fadeItOut $(e.currentTarget).closest('.alert') #.remove()
73
+
74
+
75
+
76
+ #
77
+ # PageOnChange really just calls a pageload - as of now 19-06-15
78
+ # fixed elements like SELECT's, Materialized's elements, et al.
79
+ #
80
+ # @pageOnChange = () ->
81
+ # console.log 'page changed '
82
+ # pageOnLoad()
83
+ #
84
+ # call the App.pageload
85
+ $(document).on 'page:change', ->
86
+ App.pageload()
87
+ #
88
+ # $(window).on 'page:unload', ->
89
+ # alert 'fisk'
90
+ # App.pageunload()