epi_js 0.0.21 → 0.0.22

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: 92548e2a9cb43b50c4d16c6e75264219403fba2f
4
- data.tar.gz: 017ca7d01de9abd91e0a7de5060813ef1830d97e
3
+ metadata.gz: bc857a298975eee6bc9d4d434d705b7e4e3a2e79
4
+ data.tar.gz: ca18662bf2e10f370660b61d527a80442dab5ede
5
5
  SHA512:
6
- metadata.gz: eb859b9a19725f569a416aa8eb0137c9e60a65393530f127cfbc1015352caadf5cc70236f3be9395b621897cf18de2b89c03e142fd7968c99f67b39815c7a498
7
- data.tar.gz: 80ba2a932d8516f8967c82c3607fe793d80101ae5f85364eeea92830f869734d1a9534ffdbbd690b663ee8d0070222dbfb4c3ada1ff49ea2140b03c613e70a96
6
+ metadata.gz: c715d378e65f514b37093f7e83300cf30850284db1f8a233f2e26381d9338554a951cdf219de6e94f3a951ea8d2ef50e3f1a690cf05fa543ff9dde8e081feed2
7
+ data.tar.gz: cd59faeed5a3071313c8c860a8082abe4ba8a2963f8f2e86166b0b56ca54b6698775d8d6400396592ec4af93bcb0ce1ec9826408e4af0993b2aa3b0a3976aaa4
data/README.md CHANGED
@@ -25,42 +25,84 @@ Or install it yourself as:
25
25
  ### AJAX Modal
26
26
  Add to your `app/assets/javascripts/application.js`
27
27
 
28
- //= require ajax_modal
28
+ //= require ajax_modal
29
+
30
+ #### Via data attribute
31
+ Add `data-toggle=ajax-modal` to your link
29
32
  #### Via class
30
33
  Add `ajax-modal` class to your link
31
34
  #### Via JavaScript
32
- $.ajaxModal(url);
35
+
36
+ $.ajaxModal(url);
33
37
 
34
38
  ### Flash Message
35
39
  Add to your `app/assets/javascripts/application.js`
36
40
 
37
- //= require flash_message
38
- And to your `app/assets/stylesheets/application.css`
41
+ //= require flash_message
39
42
 
40
- *= require flash_message
41
43
  #### For Rails flash fessage
42
44
  Wrap your flash message in a div with `.flash_messages` class, e.g.
43
45
 
44
- .flash-messages
46
+ .flash-messages
45
47
  - unless flash.blank?
46
48
  - flash.each do |name, msg|
47
49
  .alert.fade{ class: "alert-#{ name == :notice ? 'success' : 'error' }" }
48
50
  %a.close{ data: { dismiss: :alert } } ×
49
51
  = msg
52
+
50
53
  #### Via JavaScript
51
- $.flashAlert(message, alert_class);
54
+
55
+ $.flashAlert(message, alert_class);
56
+
52
57
  `alert_class` is `alert-notice` etc.
53
58
 
59
+ #### Customisation
60
+ You can change the markup of the dismiss link by setting the following variable:
61
+
62
+ $.flashAlert.defaults.dismissLink
63
+
64
+ ### Option Filter
65
+ Add to your `app/assets/javascripts/application.js`
66
+
67
+ //= require option_filter
68
+
69
+ #### Via data attributes
70
+ Add the jQuery selector of the target input as `data-option-filter-target` to the source input, e.g.
71
+
72
+ data-option-filter-target="#input-box-1"
73
+
74
+ To show an option in the target input when an option is selected in the source input, add the value of the source input as `data-option-filter-value`, e.g.
75
+
76
+ data-option-filter-value="1"
77
+
78
+ When the option with value 1 is selected in source input, only options with `data-option-filter-value="1"` will be displayed.
79
+
80
+ You can also add `data-option-filter-disable-empty` to the source input, so that when there is no options available for the current value, the target input will be disabled.
81
+
82
+ ### Responsive Table
83
+
84
+ Add to your `app/assets/javascripts/application.js`
85
+
86
+ //= require responsive_table
87
+
88
+ And to your `app/assets/stylesheets/application.css`
89
+
90
+ *= require responsive_table
91
+
92
+ Then add `.table-responsive-xs` or `.table-responsive-sm` to tables.
93
+ You can override the label for each table cell by adding `data-label` to the `td` element.
94
+
54
95
  ### Visibility Map
55
96
  Add to your `app/assets/javascripts/application.js`
56
97
 
57
- //= require visibility_map
98
+ //= require visibility_map
99
+
58
100
  #### Via data attributes
59
- Set `data-visibility-map` of a select box or radio button group to a JSON string, e.g.
60
-
61
- data-visibility-map='{"foo":"#foo","bar":"#bar"}'
101
+ Set `data-visibility-map` of a select box, radio button group or check boxes to a JSON string, e.g.
102
+
103
+ data-visibility-map='{"foo":"#foo","bar":"#bar"}'
62
104
  Or for SimpleForm, use:
63
-
64
- f.input :some_select, input_html: {data: {visibility_map: {foo: '#foo', bar: '#bar'}}}
65
-
105
+
106
+ f.input :some_select, input_html: {data: {visibility_map: {foo: '#foo', bar: '#bar'}}}
107
+
66
108
  When the value of the input element is `foo`, the element `#foo` will be visible and `#bar` will be hidden, and vice versa. The value of the JSON key value pair can be any jQuery selectors.
@@ -1,3 +1,3 @@
1
1
  module EpiJs
2
- VERSION = "0.0.21"
2
+ VERSION = "0.0.22"
3
3
  end
@@ -1,4 +1,5 @@
1
1
  (($) ->
2
+ 'use strict'
2
3
  $.ajaxModal = (url, params) ->
3
4
  $.get url, params, (data) ->
4
5
  $modal = if $('#modalWindow').size() > 0 then $('#modalWindow') else $('<div>').addClass('modal fade').attr('id', 'modalWindow')
@@ -19,9 +20,9 @@
19
20
  .on 'shown.bs.modal shown', (e) ->
20
21
  setTimeout("$('#modalWindow [autofocus]').first().focus()", 0)
21
22
  $(document).trigger('ajax-modal-shown')
22
- ) jQuery
23
-
24
- $ ->
25
- $(document.body).on 'click', 'a.ajax-modal', (e) ->
26
- e.preventDefault()
27
- $.ajaxModal $(@).attr('href'), $(@).data('params')
23
+
24
+ $ ->
25
+ $(document.body).on 'click', 'a.ajax-modal, a[data-toggle="ajax-modal"]', (e) ->
26
+ e.preventDefault()
27
+ $.ajaxModal $(@).attr('href'), $(@).data('params')
28
+ ) jQuery
@@ -1,4 +1,5 @@
1
1
  (($) ->
2
+ 'use strict'
2
3
  $.flashAlert = (message, type, timeout = 6000, dismissLink) ->
3
4
  dismissLink ?= $.flashAlert.defaults.dismissLink
4
5
  $alert = $('<div>').addClass("alert fade in #{type}").append(message).append(dismissLink)
@@ -11,10 +12,18 @@
11
12
  true
12
13
  $.flashAlert.defaults = {
13
14
  dismissLink: '<a href="#" title="Hide this message" data-dismiss="alert" class="dismiss-flash">Dismiss</a>'
15
+ affix: false
14
16
  }
17
+
18
+ $ ->
19
+ if $.flashAlert.defaults.affix and $('.navbar-static-top').size() > 0
20
+ $('.flash-messages').affix
21
+ offset:
22
+ top: ->
23
+ $('.navbar-static-top').outerHeight(true)
24
+
25
+ if $('.flash-messages .alert').size() > 0
26
+ $('.flash-messages .alert').addClass('in')
27
+ setTimeout("$('.flash-messages .alert').alert('close');", 6000)
15
28
  ) jQuery
16
29
 
17
- $ ->
18
- if $('.flash-messages .alert').size() > 0
19
- $('.flash-messages .alert').addClass('in')
20
- setTimeout("$('.flash-messages .alert').alert('close');", 6000)
@@ -0,0 +1,39 @@
1
+ (($) ->
2
+ 'use strict'
3
+ class OptionFilter
4
+ constructor: (element) ->
5
+ @element = element
6
+ @filterTarget = $(@element.data('option-filter-target'))
7
+ @allOptions = $('[data-option-filter-value]', @filterTarget)
8
+
9
+ @disableEmpty = @element.data('option-filter-disable-empty')?
10
+
11
+ filter: ->
12
+ valueSelected = @element.val().toString()
13
+
14
+ filteredOptionsCount = 0
15
+
16
+ if valueSelected is ''
17
+ @allOptions.hide()
18
+ else
19
+ $toShow = @allOptions.filter("[data-option-filter-value='#{valueSelected}']").show()
20
+ @allOptions.not($toShow).hide()
21
+ filteredOptionsCount = $toShow.size()
22
+
23
+ @filterTarget.val('').trigger('change.option-filter')
24
+ @filterTarget.prop('disabled', @disableEmpty and (filteredOptionsCount is 0))
25
+
26
+ $.fn.optionFilter = ->
27
+ @each ->
28
+ data = $(this).data('option-filter')
29
+ unless data?
30
+ $(this).data('option-filter', data = new OptionFilter $(this))
31
+ data.filter()
32
+
33
+ $ ->
34
+ $('[data-option-filter-target]').optionFilter()
35
+
36
+ $(document.body).on 'change', '[data-option-filter-target]', (e) ->
37
+ $(this).optionFilter()
38
+
39
+ ) jQuery
@@ -0,0 +1,11 @@
1
+ (($) ->
2
+ 'use strict'
3
+ $(document).on('set-label', 'table.table-responsive-xs, .table-responsive-sm', ->
4
+ $('thead th', $(this)).each (index) ->
5
+ label = if $(this).data('label')? then $(this).data('label') else $(this).text()
6
+ $("tr td:nth-child(#{index + 1})", $(this).closest('thead').next('tbody')).attr('data-label', label)
7
+ )
8
+
9
+ $('table.table-responsive-xs, table..table-responsive-sm').each ->
10
+ $(this).trigger('set-label')
11
+ ) jQuery
@@ -0,0 +1,37 @@
1
+ @import 'bootstrap/variables'
2
+
3
+ @mixin responsive-margins-and-paddings($gap-size, $screen-size-suffix: '')
4
+ $positions: top right bottom left
5
+ @each $position in $positions
6
+ .margin-#{$position}-#{$gap-size}#{$screen-size-suffix}
7
+ margin-#{$position}: #{$gap-size}px !important
8
+
9
+ .padding-#{$position}-#{$gap-size}#{$screen-size-suffix}
10
+ padding-#{$position}: #{$gap-size}px !important
11
+
12
+ @for $i from 0 through 12
13
+ @include responsive-margins-and-paddings(($i * 5))
14
+ @media (max-width: $screen-xs-max)
15
+ @include responsive-margins-and-paddings(($i * 5), '-xs')
16
+ @media (min-width: $screen-sm-min) and (max-width: $screen-sm-max)
17
+ @include responsive-margins-and-paddings(($i * 5), '-sm')
18
+ @media (min-width: $screen-md-min) and (max-width: $screen-md-max)
19
+ @include responsive-margins-and-paddings(($i * 5), '-md')
20
+ @media (min-width: $screen-lg-min)
21
+ @include responsive-margins-and-paddings(($i * 5), '-lg')
22
+
23
+ .mini
24
+ width: 1px
25
+
26
+ .nowrap
27
+ white-space: nowrap
28
+
29
+ .display-none
30
+ display: none
31
+
32
+ @media print
33
+ .no-print
34
+ &:before
35
+ content: 'This page cannot be printed. Please view the document online.'
36
+ *
37
+ display: none !important
@@ -0,0 +1,41 @@
1
+ @import 'bootstrap/variables'
2
+
3
+ @mixin responsive-table()
4
+ &, thead, tbody, th, td, tr
5
+ display: block
6
+ td
7
+ border: none
8
+ thead
9
+ position: absolute
10
+ top: -9999px
11
+ left: -9999px
12
+ border: none
13
+ tr
14
+ border: none
15
+ td, th
16
+ border: none
17
+ tbody
18
+ tr
19
+ border: 1px solid $table-border-color
20
+ & + tr
21
+ margin-top: 5px
22
+ td, th
23
+ border-top: none
24
+ text-align: left
25
+ width: 100% !important
26
+ & + td
27
+ border-top: 1px dotted lighten($table-border-color, 8%)
28
+ &:before
29
+ display: block
30
+ white-space: nowrap
31
+ font-weight: bold
32
+ text-transform: uppercase
33
+ content: attr(data-label)
34
+
35
+ @media (max-width: $screen-xs-max)
36
+ table.table-responsive-xs
37
+ @include responsive-table()
38
+
39
+ @media (max-width: $screen-sm-max)
40
+ table.table-responsive-sm
41
+ @include responsive-table()
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epi_js
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.21
4
+ version: 0.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shuo Chen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-24 00:00:00.000000000 Z
11
+ date: 2016-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: coffee-rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '3.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: sass-rails
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bootstrap-sass
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '1.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rails
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '3.0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.0'
97
97
  description: jQuery scripts used in various projects
@@ -101,7 +101,7 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
- - .gitignore
104
+ - ".gitignore"
105
105
  - Gemfile
106
106
  - LICENSE.txt
107
107
  - README.md
@@ -113,8 +113,12 @@ files:
113
113
  - lib/epi_js/version.rb
114
114
  - vendor/assets/javascripts/ajax_modal.coffee
115
115
  - vendor/assets/javascripts/flash_message.coffee
116
+ - vendor/assets/javascripts/option_filter.coffee
117
+ - vendor/assets/javascripts/responsive_table.coffee
116
118
  - vendor/assets/javascripts/visibility_map.coffee
119
+ - vendor/assets/stylesheets/epi_utilities.sass
117
120
  - vendor/assets/stylesheets/flash_message.sass
121
+ - vendor/assets/stylesheets/responsive_table.sass
118
122
  homepage: ''
119
123
  licenses: []
120
124
  metadata: {}
@@ -124,17 +128,17 @@ require_paths:
124
128
  - lib
125
129
  required_ruby_version: !ruby/object:Gem::Requirement
126
130
  requirements:
127
- - - '>='
131
+ - - ">="
128
132
  - !ruby/object:Gem::Version
129
133
  version: '0'
130
134
  required_rubygems_version: !ruby/object:Gem::Requirement
131
135
  requirements:
132
- - - '>='
136
+ - - ">="
133
137
  - !ruby/object:Gem::Version
134
138
  version: '0'
135
139
  requirements: []
136
140
  rubyforge_project:
137
- rubygems_version: 2.4.6
141
+ rubygems_version: 2.4.8
138
142
  signing_key:
139
143
  specification_version: 4
140
144
  summary: jQuery scripts used in various projects