manage 1.3.16 → 1.3.17

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: 30ec0072b74bcd1b231ed401d4ab0d405687f910
4
- data.tar.gz: 2532f2f95389700c852630a617b8f8b5ff6c6ff4
3
+ metadata.gz: 5fd80e9d3d9ab5d861f685a5d6934a301657cfb0
4
+ data.tar.gz: 42d1059cd76b1f9dcb0982aaba39240d87eb4cf0
5
5
  SHA512:
6
- metadata.gz: 63674f53aa4d30dd20ee7c60b005cf000ce4af94eb7b47e857e74d4875db53657948b6e62615fa76b092fa989b93a52391ca3de23d53250184a0ed98f41a830d
7
- data.tar.gz: f87bd42879b4070669fedd5276def3dff2cdb45b7adc753dfbfe6bd7a997dd570fc4e4bb83d56660092e9fd56576b6487d18f6cb3d7d57697e3e33818afe1db6
6
+ metadata.gz: 7a3bb285c64acf2249e6bd585ca1fb23a1c4dfdb7f9f88177535949d22c0aa9ee2e19285dbee8e3e38548bfe9724ce12a13c8f5e5af0abe0e0d1c560e32b258e
7
+ data.tar.gz: f769cc66a9adefc10a78073c24a78d1114a0ef8fc3caf2aa5199e2695dfabc0806b38264e0d4ee39d74558b99bc1241f9153e3f2531ff6fef6d8e713a6e6b128
@@ -2,3 +2,8 @@
2
2
  //= require jquery_ujs
3
3
  //= require foundation
4
4
  //= require manage/init
5
+ //= require manage/custom
6
+ //= require manage/handlers
7
+ //= require manage/table_checkboxes
8
+ //= require manage/collection_actions
9
+
@@ -0,0 +1,28 @@
1
+ class CollectionActions
2
+ constructor: (el) ->
3
+ $el = $(el)
4
+
5
+ $el.on 'click', 'a', (e) ->
6
+ e.stopPropagation()
7
+ e.preventDefault()
8
+
9
+ url = $(@).attr('href')
10
+ requestType = $(@).data('method')
11
+
12
+ # TODO : fetch search form params
13
+ dataParams = []
14
+ $('.rs:checked').each ->
15
+ dataParams.push($(@).attr('value'))
16
+
17
+ if dataParams.length == 0
18
+ alert 'Няма направвен избор'
19
+ return false
20
+
21
+ $.ajax(
22
+ url: url
23
+ type: requestType
24
+ data: { selected_ids: dataParams }
25
+ ).fail ->
26
+ alert('Възникна грешка')
27
+
28
+ Handlers.register 'CollectionActions', CollectionActions
@@ -0,0 +1,46 @@
1
+ class @Handlers
2
+ @handlers = {}
3
+
4
+ @register: (handler, registeredClass) ->
5
+ throw "No constructor on " + handler unless registeredClass.constructor
6
+ @handlers[handler] = registeredClass
7
+
8
+ @instantiate: (handlers, element) ->
9
+ handlers = handlers.replace(/\s/g, '').split(',')
10
+ element.handlers = []
11
+ $.each handlers, (index, handler) =>
12
+ if @handlers[handler]
13
+ instance = new @handlers[handler](element)
14
+ element.handlers.push instance
15
+ else
16
+ throw "Unknown handler " + handler
17
+
18
+ @destroy: (instances) ->
19
+ $.each instances, (index, instance) ->
20
+ instance.destroy() if instance.destroy
21
+
22
+ @unregisterAll: ->
23
+ @handlers = {}
24
+
25
+ $(document).on 'handlers:pageChanged', ->
26
+ $('[data-handler]').each ->
27
+ Handlers.instantiate $(this).attr('data-handler'), this
28
+
29
+ $(document).on 'handlers:pageUpdated', (event, scope) ->
30
+ $(scope).find('[data-handler]').each ->
31
+ Handlers.instantiate $(this).attr('data-handler'), this
32
+
33
+ $(document).on 'handlers:pageUpdating', (event, scope) ->
34
+ $(scope).find('[data-handler]').each ->
35
+ Handlers.destroy @handlers if @handlers
36
+ delete @handlers if @handlers
37
+
38
+ if typeof(Turbolinks) != undefined
39
+ $(document).on 'page:fetch', ->
40
+ $(document).trigger 'handlers:pageUpdating', 'body'
41
+
42
+ $(document).on 'page:change', ->
43
+ $(document).trigger 'handlers:pageUpdated', 'body'
44
+
45
+ $ ->
46
+ $(document).trigger 'handlers:pageChanged'
@@ -0,0 +1,12 @@
1
+ class TableCheckboxes
2
+ constructor: (el) ->
3
+ $el = $(el)
4
+ $mainContainer = $el.closest('table')
5
+
6
+ $el.on 'click', (event, element)->
7
+ check = if $el.is(':checked') then true else false
8
+
9
+ $mainContainer.find('.rs').each ->
10
+ $(@).prop('checked', check)
11
+
12
+ Handlers.register 'TableCheckboxes', TableCheckboxes
@@ -1,3 +1,3 @@
1
1
  - if collection.count > 0 and collection_actions(collection).present?
2
- .panel.collection_actions
2
+ .panel.collection_actions data-handler='CollectionActions'
3
3
  = collection_actions(collection)
@@ -1,3 +1,3 @@
1
1
  module Manage
2
- VERSION = "1.3.16"
2
+ VERSION = "1.3.17"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manage
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.16
4
+ version: 1.3.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Empower United
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-28 00:00:00.000000000 Z
12
+ date: 2014-01-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -272,7 +272,11 @@ files:
272
272
  - app/views/manage/sessions/new.html.slim
273
273
  - app/views/manage/admin_users/_form.html.slim
274
274
  - app/models/admin_user.rb
275
+ - app/assets/javascripts/manage/collection_actions.js.coffee
276
+ - app/assets/javascripts/manage/handlers.js.coffee
277
+ - app/assets/javascripts/manage/custom.js.coffee
275
278
  - app/assets/javascripts/manage/application.js
279
+ - app/assets/javascripts/manage/table_checkboxes.js.coffee
276
280
  - app/assets/javascripts/manage/init.js.coffee
277
281
  - app/assets/stylesheets/manage/application.css.scss
278
282
  - app/assets/stylesheets/manage/custom.css.scss