recurring_select 3.0.1 → 4.0.0.rc1

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.
@@ -0,0 +1,70 @@
1
+ function css(el, styles) {
2
+ for (let rule in styles) {
3
+ el.style[rule] = styles[rule]
4
+ }
5
+ }
6
+
7
+ function trigger(el, eventName) {
8
+ el.dispatchEvent(new CustomEvent(eventName))
9
+ }
10
+
11
+ function isPlainObject(obj) {
12
+ return obj && obj.toString() === "[object Object]"
13
+ }
14
+
15
+ const eventHandlerRefsExpando = '__recurring_select_events'
16
+
17
+ function on(el, events, sel, handler) {
18
+ let eventHandler = sel
19
+ if (handler) {
20
+ eventHandler = (e) => {
21
+ if (e.target.matches(sel)) {
22
+ if (handler.call(this, e) === false) {
23
+ e.preventDefault()
24
+ e.stopPropagation()
25
+ }
26
+ }
27
+ }
28
+ }
29
+
30
+ el[eventHandlerRefsExpando] = el[eventHandlerRefsExpando] || []
31
+
32
+ events.trim().split(/ +/).forEach(type => {
33
+ el[eventHandlerRefsExpando].push([ type, eventHandler ])
34
+ el.addEventListener(type, eventHandler)
35
+ })
36
+ }
37
+
38
+ function off(el, events) {
39
+ const types = events.trim().split(/ +/)
40
+
41
+ el[eventHandlerRefsExpando] = (el[eventHandlerRefsExpando] || [])
42
+ .filter(([t, h], i) => {
43
+ if (types.includes(t)) {
44
+ el.removeEventListener(t, h)
45
+ return false
46
+ }
47
+ return true
48
+ })
49
+ }
50
+
51
+ function serialize(params, prefix) {
52
+ const query = Object.keys(params).map((key) => {
53
+ const value = params[key];
54
+
55
+ if (params.constructor === Array)
56
+ key = `${prefix}[]`;
57
+ else if (params.constructor === Object)
58
+ key = (prefix ? `${prefix}[${key}]` : key);
59
+
60
+ if (value === null)
61
+ return `${key}=`
62
+
63
+ if (typeof value === 'object')
64
+ return serialize(value, key);
65
+ else
66
+ return `${key}=${encodeURIComponent(value)}`;
67
+ });
68
+
69
+ return [].concat.apply([], query).join('&');
70
+ }
@@ -2,7 +2,9 @@
2
2
 
3
3
  /* -------- resets ---------------*/
4
4
 
5
- .rs_dialog_holder { font-size:14px; color:black;
5
+ .rs_dialog_holder {
6
+ font-size:14px;
7
+ color:black;
6
8
  a {color:black;}
7
9
  input[type=button] {
8
10
  font: small/normal Arial,sans-serif;
@@ -28,10 +30,29 @@ select {
28
30
  option.bold {font-weight:bold; color:red;}
29
31
  }
30
32
 
31
- .rs_dialog_holder { position:fixed; left:0px; right:0px; top:0px; bottom:0px; padding-left:50%; background-color:rgba(255,255,255,0.2); z-index:50;
32
- .rs_dialog { background-color:#f6f6f6; border:1px solid #acacac; @include shadows(1px, 3px, 8px, rgba(0,0,0,0.25)); @include rounded_corners(7px);
33
- display:inline-block; min-width:200px; margin-left:-125px; overflow:hidden; position:relative;
34
- .rs_dialog_content { padding:10px;
33
+ .rs_dialog_holder {
34
+ display: flex;
35
+ justify-content: center;
36
+ align-items: center;
37
+ position: fixed;
38
+ left:0px;
39
+ right:0px;
40
+ top:0px;
41
+ bottom:0px;
42
+ background-color:rgba(255,255,255,0.2);
43
+ z-index:50;
44
+
45
+ .rs_dialog {
46
+ background-color:#f6f6f6;
47
+ border:1px solid #acacac;
48
+ @include shadows(1px, 3px, 8px, rgba(0,0,0,0.25));
49
+ @include rounded_corners(7px);
50
+ min-width:200px;
51
+ overflow:hidden;
52
+
53
+ .rs_dialog_content {
54
+ padding:10px;
55
+
35
56
  h1 { font-size:16px; padding:0px; margin:0 0 10px 0;
36
57
  a {float:right; display:inline-block; height:16px; width:16px; background-image:image-url("recurring_select/cancel.png"); background-position:center; background-repeat:no-repeat;}
37
58
  }
@@ -42,7 +63,8 @@ select {
42
63
 
43
64
  a { -moz-box-sizing: content-box; -webkit-box-sizing: content-box; box-sizing: content-box; }
44
65
 
45
- .freq_option_section { display:none;
66
+ .freq_option_section {
67
+ display:none;
46
68
  label { font-weight: bold; }
47
69
  .rs_interval {width:30px; text-align:center; display: inline-block;}
48
70
 
@@ -77,7 +99,10 @@ select {
77
99
  }
78
100
 
79
101
 
80
- .rs_summary { padding:0px; margin-top:15px; border-top:1px solid #ccc;
102
+ .rs_summary {
103
+ padding: 0px;
104
+ margin-top: 15px;
105
+ border-top: 1px solid #ccc;
81
106
  span {font-weight:bold; border-top:1px solid #fff; display:block; padding:10px 0 5px 0;}
82
107
  &.fetching {color:#999;
83
108
  span {background-image:image-url("recurring_select/throbber_13x13.gif"); background-position:center; background-repeat:no-repeat; display:inline-block; height:13px; width:13px; margin-top:-4px; padding-right:5px;}
@@ -85,8 +110,11 @@ select {
85
110
  label {font-weight:normal;}
86
111
  }
87
112
 
88
- .controls { padding:10px 0px 5px 0px; min-width:170px; text-align:center;
89
- input[type=button] { margin:0px 5px; width:70px;
113
+ .controls {
114
+ padding:10px 0px 5px 0px;
115
+ min-width:170px;
116
+ text-align:center;
117
+ input[type=button] { margin:0px 5px;
90
118
  &.rs_save {color:#333; }
91
119
  &.rs_cancel {color:#666;}
92
120
  &.disabled {color:#aaa; }
@@ -6,6 +6,12 @@ module RecurringSelectHelper
6
6
  RecurringSelectTag.new(object, method, self, default_schedules, options, html_options).render
7
7
  end
8
8
  end
9
+
10
+ module FormTagHelper
11
+ def select_recurring_tag(name, default_schedules = nil, options = {}, html_options = {})
12
+ RecurringSelectTag.new(nil, name, self, default_schedules, options, html_options).render
13
+ end
14
+ end
9
15
 
10
16
  module FormBuilder
11
17
  def select_recurring(method, default_schedules = nil, options = {}, html_options = {})
@@ -65,7 +71,7 @@ module RecurringSelectHelper
65
71
  ar = [rule.to_s, rule.to_hash.to_json]
66
72
 
67
73
  if custom
68
- ar[0] << "*"
74
+ ar[0] += "*"
69
75
  ar << {"data-custom" => true}
70
76
  end
71
77
 
@@ -90,20 +96,15 @@ module RecurringSelectHelper
90
96
  end
91
97
  end
92
98
 
93
- class RecurringSelectTag < ActionView::Helpers::Tags::Base
99
+ class RecurringSelectTag < ActionView::Helpers::Tags::Select
94
100
  include RecurringSelectHelper::FormOptionsHelper
95
101
  include SelectHTMLOptions
96
102
 
97
103
  def initialize(object, method, template_object, default_schedules = nil, options = {}, html_options = {})
98
104
  @default_schedules = default_schedules
99
- @choices = @choices.to_a if @choices.is_a?(Range)
100
- @method_name = method.to_s
101
- @object_name = object.to_s
102
- @html_options = recurring_select_html_options(html_options)
103
- @template_object = template_object
104
- add_default_name_and_id(@html_options)
105
-
106
- super(object, method, template_object, options)
105
+ html_options = recurring_select_html_options(html_options)
106
+
107
+ super(object, method, template_object, @default_schedules, options, html_options)
107
108
  end
108
109
 
109
110
  def render
@@ -6,6 +6,7 @@ module RecurringSelect
6
6
 
7
7
  initializer "recurring_select.extending_form_builder" do |app|
8
8
  ActionView::Helpers::FormHelper.send(:include, RecurringSelectHelper::FormHelper)
9
+ ActionView::Helpers::FormTagHelper.send(:include, RecurringSelectHelper::FormTagHelper)
9
10
  ActionView::Helpers::FormOptionsHelper.send(:include, RecurringSelectHelper::FormOptionsHelper)
10
11
  ActionView::Helpers::FormBuilder.send(:include, RecurringSelectHelper::FormBuilder)
11
12
  end
@@ -1,3 +1,3 @@
1
1
  module RecurringSelect
2
- VERSION = "3.0.1"
2
+ VERSION = "4.0.0.rc1"
3
3
  end
@@ -59,7 +59,7 @@ module RecurringSelect
59
59
  # this is soooooo ugly
60
60
  if params[:validations][:day_of_week]
61
61
  params[:validations][:day_of_week] ||= {}
62
- if params[:validations][:day_of_week].length > 0 and not params[:validations][:day_of_week].keys.first =~ /\d/
62
+ if params[:validations][:day_of_week].length > 0 and not params[:validations][:day_of_week].keys.first.to_s =~ /\d/
63
63
  params[:validations][:day_of_week].symbolize_keys!
64
64
  else
65
65
  originals = params[:validations][:day_of_week].dup
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recurring_select
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 4.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jobber
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2023-02-04 00:00:00.000000000 Z
14
+ date: 2024-09-09 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -19,28 +19,14 @@ dependencies:
19
19
  requirements:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: '5.2'
22
+ version: '6.1'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '5.2'
30
- - !ruby/object:Gem::Dependency
31
- name: jquery-rails
32
- requirement: !ruby/object:Gem::Requirement
33
- requirements:
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: '3.0'
37
- type: :runtime
38
- prerelease: false
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: '3.0'
29
+ version: '6.1'
44
30
  - !ruby/object:Gem::Dependency
45
31
  name: ice_cube
46
32
  requirement: !ruby/object:Gem::Requirement
@@ -61,28 +47,14 @@ dependencies:
61
47
  requirements:
62
48
  - - ">="
63
49
  - !ruby/object:Gem::Version
64
- version: '4.0'
65
- type: :runtime
66
- prerelease: false
67
- version_requirements: !ruby/object:Gem::Requirement
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- version: '4.0'
72
- - !ruby/object:Gem::Dependency
73
- name: coffee-rails
74
- requirement: !ruby/object:Gem::Requirement
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
78
- version: '3.1'
50
+ version: '5.0'
79
51
  type: :runtime
80
52
  prerelease: false
81
53
  version_requirements: !ruby/object:Gem::Requirement
82
54
  requirements:
83
55
  - - ">="
84
56
  - !ruby/object:Gem::Version
85
- version: '3.1'
57
+ version: '5.0'
86
58
  - !ruby/object:Gem::Dependency
87
59
  name: bundler
88
60
  requirement: !ruby/object:Gem::Requirement
@@ -152,10 +124,12 @@ files:
152
124
  - Rakefile
153
125
  - app/assets/images/recurring_select/cancel.png
154
126
  - app/assets/images/recurring_select/throbber_13x13.gif
155
- - app/assets/javascripts/jquery-mobile-rs.js.coffee
156
- - app/assets/javascripts/recurring_select.js.coffee
157
- - app/assets/javascripts/recurring_select/fr.js.coffee
158
- - app/assets/javascripts/recurring_select_dialog.js.coffee.erb
127
+ - app/assets/javascripts/defaults.js
128
+ - app/assets/javascripts/jquery-mobile-rs.js
129
+ - app/assets/javascripts/recurring_select.js
130
+ - app/assets/javascripts/recurring_select/fr.js
131
+ - app/assets/javascripts/recurring_select_dialog.js.erb
132
+ - app/assets/javascripts/utils.js
159
133
  - app/assets/stylesheets/jquery-mobile-rs.scss
160
134
  - app/assets/stylesheets/recurring_select.scss
161
135
  - app/assets/stylesheets/utilities.scss
@@ -168,7 +142,7 @@ files:
168
142
  - lib/recurring_select.rb
169
143
  - lib/recurring_select/engine.rb
170
144
  - lib/recurring_select/version.rb
171
- homepage: http://github.com/getjobber/recurring_select
145
+ homepage: http://github.com/gregschmit/recurring_select
172
146
  licenses:
173
147
  - MIT
174
148
  metadata: {}
@@ -183,11 +157,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
183
157
  version: '0'
184
158
  required_rubygems_version: !ruby/object:Gem::Requirement
185
159
  requirements:
186
- - - ">="
160
+ - - ">"
187
161
  - !ruby/object:Gem::Version
188
- version: '0'
162
+ version: 1.3.1
189
163
  requirements: []
190
- rubygems_version: 3.0.9
164
+ rubygems_version: 3.4.10
191
165
  signing_key:
192
166
  specification_version: 4
193
167
  summary: A select helper which gives you magical powers to generate ice_cube rules.
@@ -1,15 +0,0 @@
1
- #= require recurring_select
2
- #= require_self
3
-
4
- $ ->
5
- $(document).on "recurring_select:cancel recurring_select:save", ".recurring_select", ->
6
- $(this).selectmenu('refresh')
7
-
8
- $(document).on "recurring_select:dialog_opened", ".rs_dialog_holder", ->
9
- $(this).find("select").attr("data-theme", $('.recurring_select').data("theme")).attr("data-mini", true).selectmenu()
10
- $(this).find("input[type=text]").textinput()
11
-
12
- $(this).on "recurring_select:dialog_positioned", ".rs_dialog", ->
13
- $(this).css
14
- "top" : $(window).scrollTop()+"px"
15
-
@@ -1,105 +0,0 @@
1
- #= require recurring_select_dialog
2
- #= require_self
3
-
4
- $ = jQuery
5
- $ ->
6
- $(document).on "focus", ".recurring_select", ->
7
- $(this).recurring_select('set_initial_values')
8
-
9
- $(document).on "change", ".recurring_select", ->
10
- $(this).recurring_select('changed')
11
-
12
- methods =
13
- set_initial_values: ->
14
- @data 'initial-value-hash', @val()
15
- @data 'initial-value-str', $(@find("option").get()[@.prop("selectedIndex")]).text()
16
-
17
- changed: ->
18
- if @val() == "custom"
19
- methods.open_custom.apply(@)
20
- else
21
- methods.set_initial_values.apply(@)
22
-
23
- open_custom: ->
24
- @data "recurring-select-active", true
25
- new RecurringSelectDialog(@)
26
- @blur()
27
-
28
- save: (new_rule) ->
29
- @find("option[data-custom]").remove()
30
- new_json_val = JSON.stringify(new_rule.hash)
31
-
32
- # TODO: check for matching name, and replace that value if found
33
-
34
- if $.inArray(new_json_val, @find("option").map -> $(@).val()) == -1
35
- methods.insert_option.apply @, [new_rule.str, new_json_val]
36
-
37
- @val new_json_val
38
- methods.set_initial_values.apply @
39
- @.trigger "recurring_select:save"
40
-
41
- current_rule: ->
42
- str: @data("initial-value-str")
43
- hash: $.parseJSON(@data("initial-value-hash"))
44
-
45
- cancel: ->
46
- @val @data("initial-value-hash")
47
- @data "recurring-select-active", false
48
- @.trigger "recurring_select:cancel"
49
-
50
-
51
- insert_option: (new_rule_str, new_rule_json) ->
52
- separator = @find("option:disabled")
53
- if separator.length == 0
54
- separator = @find("option")
55
- separator = separator.last()
56
-
57
- new_option = $(document.createElement("option"))
58
- new_option.attr "data-custom", true
59
-
60
- if new_rule_str.substr(new_rule_str.length - 1) != "*"
61
- new_rule_str+="*"
62
-
63
- new_option.text new_rule_str
64
- new_option.val new_rule_json
65
- new_option.insertBefore separator
66
-
67
- methods: ->
68
- methods
69
-
70
- $.fn.recurring_select = (method) ->
71
- if method of methods
72
- return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ) );
73
- else
74
- $.error( "Method #{method} does not exist on jQuery.recurring_select" );
75
-
76
- $.fn.recurring_select.options = {
77
- monthly: {
78
- show_week: [true, true, true, true, false, false]
79
- }
80
- }
81
-
82
- $.fn.recurring_select.texts = {
83
- locale_iso_code: "en"
84
- repeat: "Repeat"
85
- last_day: "Last Day"
86
- frequency: "Frequency"
87
- daily: "Daily"
88
- weekly: "Weekly"
89
- monthly: "Monthly"
90
- yearly: "Yearly"
91
- every: "Every"
92
- days: "day(s)"
93
- weeks_on: "week(s) on"
94
- months: "month(s)"
95
- years: "year(s)"
96
- day_of_month: "Day of month"
97
- day_of_week: "Day of week"
98
- cancel: "Cancel"
99
- ok: "OK"
100
- summary: "Summary"
101
- first_day_of_week: 0
102
- days_first_letter: ["S", "M", "T", "W", "T", "F", "S" ]
103
- order: ["1st", "2nd", "3rd", "4th", "5th", "Last"]
104
- show_week: [true, true, true, true, false, false]
105
- }