recurring_select 3.0.0 → 4.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -19
- data/Rakefile +1 -1
- data/app/assets/javascripts/defaults.js +31 -0
- data/app/assets/javascripts/jquery-mobile-rs.js +20 -0
- data/app/assets/javascripts/recurring_select/{fr.js.coffee → fr.js} +2 -2
- data/app/assets/javascripts/recurring_select.js +96 -0
- data/app/assets/javascripts/recurring_select_dialog.js.erb +447 -0
- data/app/assets/javascripts/utils.js +70 -0
- data/app/assets/stylesheets/recurring_select.scss +37 -9
- data/lib/helpers/recurring_select_helper.rb +10 -8
- data/lib/recurring_select/engine.rb +1 -0
- data/lib/recurring_select/version.rb +1 -1
- data/lib/recurring_select.rb +1 -1
- metadata +18 -43
- data/app/assets/javascripts/jquery-mobile-rs.js.coffee +0 -15
- data/app/assets/javascripts/recurring_select.js.coffee +0 -105
- data/app/assets/javascripts/recurring_select_dialog.js.coffee.erb +0 -372
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recurring_select
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jobber
|
8
8
|
- Forrest Zeisler
|
9
9
|
- Nathan Youngman
|
10
|
+
- Gregory Schmit
|
10
11
|
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
|
-
date:
|
14
|
+
date: 2024-09-09 00:00:00.000000000 Z
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: rails
|
@@ -18,28 +19,14 @@ dependencies:
|
|
18
19
|
requirements:
|
19
20
|
- - ">="
|
20
21
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
22
|
+
version: '6.1'
|
22
23
|
type: :runtime
|
23
24
|
prerelease: false
|
24
25
|
version_requirements: !ruby/object:Gem::Requirement
|
25
26
|
requirements:
|
26
27
|
- - ">="
|
27
28
|
- !ruby/object:Gem::Version
|
28
|
-
version: '
|
29
|
-
- !ruby/object:Gem::Dependency
|
30
|
-
name: jquery-rails
|
31
|
-
requirement: !ruby/object:Gem::Requirement
|
32
|
-
requirements:
|
33
|
-
- - ">="
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: '3.0'
|
36
|
-
type: :runtime
|
37
|
-
prerelease: false
|
38
|
-
version_requirements: !ruby/object:Gem::Requirement
|
39
|
-
requirements:
|
40
|
-
- - ">="
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: '3.0'
|
29
|
+
version: '6.1'
|
43
30
|
- !ruby/object:Gem::Dependency
|
44
31
|
name: ice_cube
|
45
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,28 +47,14 @@ dependencies:
|
|
60
47
|
requirements:
|
61
48
|
- - ">="
|
62
49
|
- !ruby/object:Gem::Version
|
63
|
-
version: '
|
64
|
-
type: :runtime
|
65
|
-
prerelease: false
|
66
|
-
version_requirements: !ruby/object:Gem::Requirement
|
67
|
-
requirements:
|
68
|
-
- - ">="
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
version: '4.0'
|
71
|
-
- !ruby/object:Gem::Dependency
|
72
|
-
name: coffee-rails
|
73
|
-
requirement: !ruby/object:Gem::Requirement
|
74
|
-
requirements:
|
75
|
-
- - ">="
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '3.1'
|
50
|
+
version: '5.0'
|
78
51
|
type: :runtime
|
79
52
|
prerelease: false
|
80
53
|
version_requirements: !ruby/object:Gem::Requirement
|
81
54
|
requirements:
|
82
55
|
- - ">="
|
83
56
|
- !ruby/object:Gem::Version
|
84
|
-
version: '
|
57
|
+
version: '5.0'
|
85
58
|
- !ruby/object:Gem::Dependency
|
86
59
|
name: bundler
|
87
60
|
requirement: !ruby/object:Gem::Requirement
|
@@ -141,7 +114,7 @@ dependencies:
|
|
141
114
|
description: This gem provides a useful interface for creating recurring rules for
|
142
115
|
the ice_cube gem.
|
143
116
|
email:
|
144
|
-
-
|
117
|
+
- schmitgreg@gmail.com
|
145
118
|
executables: []
|
146
119
|
extensions: []
|
147
120
|
extra_rdoc_files: []
|
@@ -151,10 +124,12 @@ files:
|
|
151
124
|
- Rakefile
|
152
125
|
- app/assets/images/recurring_select/cancel.png
|
153
126
|
- app/assets/images/recurring_select/throbber_13x13.gif
|
154
|
-
- app/assets/javascripts/
|
155
|
-
- app/assets/javascripts/
|
156
|
-
- app/assets/javascripts/recurring_select
|
157
|
-
- app/assets/javascripts/
|
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
|
158
133
|
- app/assets/stylesheets/jquery-mobile-rs.scss
|
159
134
|
- app/assets/stylesheets/recurring_select.scss
|
160
135
|
- app/assets/stylesheets/utilities.scss
|
@@ -167,7 +142,7 @@ files:
|
|
167
142
|
- lib/recurring_select.rb
|
168
143
|
- lib/recurring_select/engine.rb
|
169
144
|
- lib/recurring_select/version.rb
|
170
|
-
homepage: http://github.com/
|
145
|
+
homepage: http://github.com/gregschmit/recurring_select
|
171
146
|
licenses:
|
172
147
|
- MIT
|
173
148
|
metadata: {}
|
@@ -182,11 +157,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
182
157
|
version: '0'
|
183
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
159
|
requirements:
|
185
|
-
- - "
|
160
|
+
- - ">"
|
186
161
|
- !ruby/object:Gem::Version
|
187
|
-
version:
|
162
|
+
version: 1.3.1
|
188
163
|
requirements: []
|
189
|
-
rubygems_version: 3.
|
164
|
+
rubygems_version: 3.4.10
|
190
165
|
signing_key:
|
191
166
|
specification_version: 4
|
192
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
|
-
}
|
@@ -1,372 +0,0 @@
|
|
1
|
-
window.RecurringSelectDialog =
|
2
|
-
class RecurringSelectDialog
|
3
|
-
constructor: (@recurring_selector) ->
|
4
|
-
@current_rule = @recurring_selector.recurring_select('current_rule')
|
5
|
-
@initDialogBox()
|
6
|
-
if not @current_rule.hash? or not @current_rule.hash.rule_type?
|
7
|
-
@freqChanged()
|
8
|
-
else
|
9
|
-
setTimeout @positionDialogVert, 10 # allow initial render
|
10
|
-
|
11
|
-
initDialogBox: ->
|
12
|
-
$(".rs_dialog_holder").remove()
|
13
|
-
|
14
|
-
open_in = $("body")
|
15
|
-
open_in = $(".ui-page-active") if $(".ui-page-active").length
|
16
|
-
open_in.append @template()
|
17
|
-
@outer_holder = $(".rs_dialog_holder")
|
18
|
-
@inner_holder = @outer_holder.find ".rs_dialog"
|
19
|
-
@content = @outer_holder.find ".rs_dialog_content"
|
20
|
-
@positionDialogVert(true)
|
21
|
-
@mainEventInit()
|
22
|
-
@freqInit()
|
23
|
-
@summaryInit()
|
24
|
-
@outer_holder.trigger "recurring_select:dialog_opened"
|
25
|
-
@freq_select.focus()
|
26
|
-
|
27
|
-
positionDialogVert: (initial_positioning) =>
|
28
|
-
window_height = $(window).height()
|
29
|
-
window_width = $(window).width()
|
30
|
-
dialog_height = @content.outerHeight()
|
31
|
-
if dialog_height < 80
|
32
|
-
dialog_height = 80
|
33
|
-
margin_top = (window_height - dialog_height)/2 - 30
|
34
|
-
margin_top = 10 if margin_top < 10
|
35
|
-
# if dialog_height > window_height - 20
|
36
|
-
# dialog_height = window_height - 20
|
37
|
-
|
38
|
-
new_style_hash =
|
39
|
-
"margin-top" : margin_top+"px"
|
40
|
-
"min-height" : dialog_height+"px"
|
41
|
-
|
42
|
-
if initial_positioning?
|
43
|
-
@inner_holder.css new_style_hash
|
44
|
-
@inner_holder.trigger "recurring_select:dialog_positioned"
|
45
|
-
else
|
46
|
-
@inner_holder.addClass "animated"
|
47
|
-
@inner_holder.animate new_style_hash, 200, =>
|
48
|
-
@inner_holder.removeClass "animated"
|
49
|
-
@content.css {"width": "auto"}
|
50
|
-
@inner_holder.trigger "recurring_select:dialog_positioned"
|
51
|
-
|
52
|
-
cancel: =>
|
53
|
-
@outer_holder.remove()
|
54
|
-
@recurring_selector.recurring_select('cancel')
|
55
|
-
|
56
|
-
outerCancel: (event) =>
|
57
|
-
if $(event.target).hasClass("rs_dialog_holder")
|
58
|
-
@cancel()
|
59
|
-
|
60
|
-
save: =>
|
61
|
-
return if !@current_rule.str?
|
62
|
-
@outer_holder.remove()
|
63
|
-
@recurring_selector.recurring_select('save', @current_rule)
|
64
|
-
|
65
|
-
# ========================= Init Methods ===============================
|
66
|
-
|
67
|
-
mainEventInit: ->
|
68
|
-
# Tap hooks are for jQueryMobile
|
69
|
-
@outer_holder.on 'click tap', @outerCancel
|
70
|
-
@content.on 'click tap', 'h1 a', @cancel
|
71
|
-
@save_button = @content.find('input.rs_save').on "click tap", @save
|
72
|
-
@content.find('input.rs_cancel').on "click tap", @cancel
|
73
|
-
|
74
|
-
freqInit: ->
|
75
|
-
@freq_select = @outer_holder.find ".rs_frequency"
|
76
|
-
if @current_rule.hash? && (rule_type = @current_rule.hash.rule_type)?
|
77
|
-
if rule_type.search(/Weekly/) != -1
|
78
|
-
@freq_select.prop('selectedIndex', 1)
|
79
|
-
@initWeeklyOptions()
|
80
|
-
else if rule_type.search(/Monthly/) != -1
|
81
|
-
@freq_select.prop('selectedIndex', 2)
|
82
|
-
@initMonthlyOptions()
|
83
|
-
else if rule_type.search(/Yearly/) != -1
|
84
|
-
@freq_select.prop('selectedIndex', 3)
|
85
|
-
@initYearlyOptions()
|
86
|
-
else
|
87
|
-
@initDailyOptions()
|
88
|
-
@freq_select.on "change", @freqChanged
|
89
|
-
|
90
|
-
initDailyOptions: ->
|
91
|
-
section = @content.find('.daily_options')
|
92
|
-
interval_input = section.find('.rs_daily_interval')
|
93
|
-
interval_input.val(@current_rule.hash.interval)
|
94
|
-
interval_input.on "change keyup", @intervalChanged
|
95
|
-
section.show()
|
96
|
-
|
97
|
-
initWeeklyOptions: ->
|
98
|
-
section = @content.find('.weekly_options')
|
99
|
-
|
100
|
-
# connect the interval field
|
101
|
-
interval_input = section.find('.rs_weekly_interval')
|
102
|
-
interval_input.val(@current_rule.hash.interval)
|
103
|
-
interval_input.on "change keyup", @intervalChanged
|
104
|
-
|
105
|
-
# clear selected days
|
106
|
-
section.find(".day_holder a").each (index, element) ->
|
107
|
-
$(element).removeClass("selected")
|
108
|
-
|
109
|
-
# connect the day fields
|
110
|
-
if @current_rule.hash.validations? && @current_rule.hash.validations.day?
|
111
|
-
$(@current_rule.hash.validations.day).each (index, val) ->
|
112
|
-
section.find(".day_holder a[data-value='"+val+"']").addClass("selected")
|
113
|
-
|
114
|
-
section.off('click', '.day_holder a').on "click", ".day_holder a", @daysChanged
|
115
|
-
|
116
|
-
section.show()
|
117
|
-
|
118
|
-
initMonthlyOptions: ->
|
119
|
-
section = @content.find('.monthly_options')
|
120
|
-
interval_input = section.find('.rs_monthly_interval')
|
121
|
-
interval_input.val(@current_rule.hash.interval)
|
122
|
-
interval_input.on "change keyup", @intervalChanged
|
123
|
-
|
124
|
-
@current_rule.hash.validations ||= {}
|
125
|
-
@current_rule.hash.validations.day_of_month ||= []
|
126
|
-
@current_rule.hash.validations.day_of_week ||= {}
|
127
|
-
@init_calendar_days(section)
|
128
|
-
@init_calendar_weeks(section)
|
129
|
-
|
130
|
-
in_week_mode = Object.keys(@current_rule.hash.validations.day_of_week).length > 0
|
131
|
-
section.find(".monthly_rule_type_week").prop("checked", in_week_mode)
|
132
|
-
section.find(".monthly_rule_type_day").prop("checked", !in_week_mode)
|
133
|
-
@toggle_month_view()
|
134
|
-
section.find("input[name=monthly_rule_type]").on "change", @toggle_month_view
|
135
|
-
section.show()
|
136
|
-
|
137
|
-
initYearlyOptions: ->
|
138
|
-
section = @content.find('.yearly_options')
|
139
|
-
interval_input = section.find('.rs_yearly_interval')
|
140
|
-
interval_input.val(@current_rule.hash.interval)
|
141
|
-
interval_input.on "change keyup", @intervalChanged
|
142
|
-
section.show()
|
143
|
-
|
144
|
-
|
145
|
-
summaryInit: ->
|
146
|
-
@summary = @outer_holder.find(".rs_summary")
|
147
|
-
@summaryUpdate()
|
148
|
-
|
149
|
-
# ========================= render methods ===============================
|
150
|
-
|
151
|
-
summaryUpdate: (new_string) =>
|
152
|
-
@summary.width @content.width()
|
153
|
-
if @current_rule.hash? && @current_rule.str?
|
154
|
-
@summary.removeClass "fetching"
|
155
|
-
@save_button.removeClass("disabled")
|
156
|
-
rule_str = @current_rule.str.replace("*", "")
|
157
|
-
if rule_str.length < 20
|
158
|
-
rule_str = "#{$.fn.recurring_select.texts["summary"]}: "+rule_str
|
159
|
-
@summary.find("span").html rule_str
|
160
|
-
else
|
161
|
-
@summary.addClass "fetching"
|
162
|
-
@save_button.addClass("disabled")
|
163
|
-
@summary.find("span").html ""
|
164
|
-
@summaryFetch()
|
165
|
-
|
166
|
-
summaryFetch: ->
|
167
|
-
return if !(@current_rule.hash? && (rule_type = @current_rule.hash.rule_type)?)
|
168
|
-
@current_rule.hash['week_start'] = $.fn.recurring_select.texts["first_day_of_week"]
|
169
|
-
$.ajax
|
170
|
-
url: "<%= Rails.application.config.action_controller.relative_url_root %>/recurring_select/translate/#{$.fn.recurring_select.texts["locale_iso_code"]}",
|
171
|
-
type: "POST",
|
172
|
-
data: @current_rule.hash
|
173
|
-
success: @summaryFetchSuccess
|
174
|
-
|
175
|
-
summaryFetchSuccess: (data) =>
|
176
|
-
@current_rule.str = data
|
177
|
-
@summaryUpdate()
|
178
|
-
@content.css {"width": "auto"}
|
179
|
-
|
180
|
-
init_calendar_days: (section) =>
|
181
|
-
monthly_calendar = section.find(".rs_calendar_day")
|
182
|
-
monthly_calendar.html ""
|
183
|
-
for num in [1..31]
|
184
|
-
monthly_calendar.append (day_link = $(document.createElement("a")).text(num))
|
185
|
-
if $.inArray(num, @current_rule.hash.validations.day_of_month) != -1
|
186
|
-
day_link.addClass("selected")
|
187
|
-
|
188
|
-
# add last day of month button
|
189
|
-
monthly_calendar.append (end_of_month_link = $(document.createElement("a")).text($.fn.recurring_select.texts["last_day"]))
|
190
|
-
end_of_month_link.addClass("end_of_month")
|
191
|
-
if $.inArray(-1, @current_rule.hash.validations.day_of_month) != -1
|
192
|
-
end_of_month_link.addClass("selected")
|
193
|
-
|
194
|
-
monthly_calendar.find("a").on "click tap", @dateOfMonthChanged
|
195
|
-
|
196
|
-
init_calendar_weeks: (section) =>
|
197
|
-
monthly_calendar = section.find(".rs_calendar_week")
|
198
|
-
monthly_calendar.html ""
|
199
|
-
row_labels = $.fn.recurring_select.texts["order"]
|
200
|
-
show_row = $.fn.recurring_select.options["monthly"]["show_week"]
|
201
|
-
cell_str = $.fn.recurring_select.texts["days_first_letter"]
|
202
|
-
|
203
|
-
for num, index in [1, 2, 3, 4, 5, -1]
|
204
|
-
if show_row[index]
|
205
|
-
monthly_calendar.append "<span>#{row_labels[num - 1]}</span>"
|
206
|
-
for day_of_week in [$.fn.recurring_select.texts["first_day_of_week"]...(7 + $.fn.recurring_select.texts["first_day_of_week"])]
|
207
|
-
day_of_week = day_of_week % 7
|
208
|
-
day_link = $("<a>", {text: cell_str[day_of_week] })
|
209
|
-
day_link.attr("day", day_of_week)
|
210
|
-
day_link.attr("instance", num)
|
211
|
-
monthly_calendar.append day_link
|
212
|
-
|
213
|
-
$.each @current_rule.hash.validations.day_of_week, (key, value) ->
|
214
|
-
$.each value, (index, instance) ->
|
215
|
-
section.find("a[day='#{key}'][instance='#{instance}']").addClass("selected")
|
216
|
-
monthly_calendar.find("a").on "click tap", @weekOfMonthChanged
|
217
|
-
|
218
|
-
toggle_month_view: =>
|
219
|
-
week_mode = @content.find(".monthly_rule_type_week").prop("checked")
|
220
|
-
@content.find(".rs_calendar_week").toggle(week_mode)
|
221
|
-
@content.find(".rs_calendar_day").toggle(!week_mode)
|
222
|
-
|
223
|
-
# ========================= Change callbacks ===============================
|
224
|
-
|
225
|
-
freqChanged: =>
|
226
|
-
@current_rule.hash = null unless $.isPlainObject(@current_rule.hash) # for custom values
|
227
|
-
|
228
|
-
@current_rule.hash ||= {}
|
229
|
-
@current_rule.hash.interval = 1
|
230
|
-
@current_rule.hash.until = null
|
231
|
-
@current_rule.hash.count = null
|
232
|
-
@current_rule.hash.validations = null
|
233
|
-
@content.find(".freq_option_section").hide();
|
234
|
-
@content.find("input[type=radio], input[type=checkbox]").prop("checked", false)
|
235
|
-
switch @freq_select.val()
|
236
|
-
when "Weekly"
|
237
|
-
@current_rule.hash.rule_type = "IceCube::WeeklyRule"
|
238
|
-
@current_rule.str = $.fn.recurring_select.texts["weekly"]
|
239
|
-
@initWeeklyOptions()
|
240
|
-
when "Monthly"
|
241
|
-
@current_rule.hash.rule_type = "IceCube::MonthlyRule"
|
242
|
-
@current_rule.str = $.fn.recurring_select.texts["monthly"]
|
243
|
-
@initMonthlyOptions()
|
244
|
-
when "Yearly"
|
245
|
-
@current_rule.hash.rule_type = "IceCube::YearlyRule"
|
246
|
-
@current_rule.str = $.fn.recurring_select.texts["yearly"]
|
247
|
-
@initYearlyOptions()
|
248
|
-
else
|
249
|
-
@current_rule.hash.rule_type = "IceCube::DailyRule"
|
250
|
-
@current_rule.str = $.fn.recurring_select.texts["daily"]
|
251
|
-
@initDailyOptions()
|
252
|
-
@summaryUpdate()
|
253
|
-
@positionDialogVert()
|
254
|
-
|
255
|
-
intervalChanged: (event) =>
|
256
|
-
@current_rule.str = null
|
257
|
-
@current_rule.hash ||= {}
|
258
|
-
@current_rule.hash.interval = parseInt($(event.currentTarget).val())
|
259
|
-
if @current_rule.hash.interval < 1 || isNaN(@current_rule.hash.interval)
|
260
|
-
@current_rule.hash.interval = 1
|
261
|
-
@summaryUpdate()
|
262
|
-
|
263
|
-
daysChanged: (event) =>
|
264
|
-
$(event.currentTarget).toggleClass("selected")
|
265
|
-
@current_rule.str = null
|
266
|
-
@current_rule.hash ||= {}
|
267
|
-
@current_rule.hash.validations = {}
|
268
|
-
raw_days = @content.find(".day_holder a.selected").map -> parseInt($(this).data("value"))
|
269
|
-
@current_rule.hash.validations.day = raw_days.get()
|
270
|
-
@summaryUpdate()
|
271
|
-
false # this prevents default and propogation
|
272
|
-
|
273
|
-
dateOfMonthChanged: (event) =>
|
274
|
-
$(event.currentTarget).toggleClass("selected")
|
275
|
-
@current_rule.str = null
|
276
|
-
@current_rule.hash ||= {}
|
277
|
-
@current_rule.hash.validations = {}
|
278
|
-
raw_days = @content.find(".monthly_options .rs_calendar_day a.selected").map ->
|
279
|
-
res = if $(this).text() == $.fn.recurring_select.texts["last_day"] then -1 else parseInt($(this).text())
|
280
|
-
res
|
281
|
-
@current_rule.hash.validations.day_of_week = {}
|
282
|
-
@current_rule.hash.validations.day_of_month = raw_days.get()
|
283
|
-
@summaryUpdate()
|
284
|
-
false
|
285
|
-
|
286
|
-
weekOfMonthChanged: (event) =>
|
287
|
-
$(event.currentTarget).toggleClass("selected")
|
288
|
-
@current_rule.str = null
|
289
|
-
@current_rule.hash ||= {}
|
290
|
-
@current_rule.hash.validations = {}
|
291
|
-
@current_rule.hash.validations.day_of_month = []
|
292
|
-
@current_rule.hash.validations.day_of_week = {}
|
293
|
-
@content.find(".monthly_options .rs_calendar_week a.selected").each (index, elm) =>
|
294
|
-
day = parseInt($(elm).attr("day"))
|
295
|
-
instance = parseInt($(elm).attr("instance"))
|
296
|
-
@current_rule.hash.validations.day_of_week[day] ||= []
|
297
|
-
@current_rule.hash.validations.day_of_week[day].push instance
|
298
|
-
@summaryUpdate()
|
299
|
-
false
|
300
|
-
|
301
|
-
# ========================= Change callbacks ===============================
|
302
|
-
|
303
|
-
template: () ->
|
304
|
-
str = "
|
305
|
-
<div class='rs_dialog_holder'>
|
306
|
-
<div class='rs_dialog'>
|
307
|
-
<div class='rs_dialog_content'>
|
308
|
-
<h1>#{$.fn.recurring_select.texts["repeat"]} <a href='#' title='#{$.fn.recurring_select.texts["cancel"]}' Alt='#{$.fn.recurring_select.texts["cancel"]}'></a> </h1>
|
309
|
-
<p class='frequency-select-wrapper'>
|
310
|
-
<label for='rs_frequency'>#{$.fn.recurring_select.texts["frequency"]}:</label>
|
311
|
-
<select data-wrapper-class='ui-recurring-select' id='rs_frequency' class='rs_frequency' name='rs_frequency'>
|
312
|
-
<option value='Daily'>#{$.fn.recurring_select.texts["daily"]}</option>
|
313
|
-
<option value='Weekly'>#{$.fn.recurring_select.texts["weekly"]}</option>
|
314
|
-
<option value='Monthly'>#{$.fn.recurring_select.texts["monthly"]}</option>
|
315
|
-
<option value='Yearly'>#{$.fn.recurring_select.texts["yearly"]}</option>
|
316
|
-
</select>
|
317
|
-
</p>
|
318
|
-
|
319
|
-
<div class='daily_options freq_option_section'>
|
320
|
-
<p>
|
321
|
-
#{$.fn.recurring_select.texts["every"]}
|
322
|
-
<input type='text' data-wrapper-class='ui-recurring-select' name='rs_daily_interval' class='rs_daily_interval rs_interval' value='1' size='2' />
|
323
|
-
#{$.fn.recurring_select.texts["days"]}
|
324
|
-
</p>
|
325
|
-
</div>
|
326
|
-
<div class='weekly_options freq_option_section'>
|
327
|
-
<p>
|
328
|
-
#{$.fn.recurring_select.texts["every"]}
|
329
|
-
<input type='text' data-wrapper-class='ui-recurring-select' name='rs_weekly_interval' class='rs_weekly_interval rs_interval' value='1' size='2' />
|
330
|
-
#{$.fn.recurring_select.texts["weeks_on"]}:
|
331
|
-
</p>
|
332
|
-
<div class='day_holder'>
|
333
|
-
"
|
334
|
-
for day_of_week in [$.fn.recurring_select.texts["first_day_of_week"]...(7 + $.fn.recurring_select.texts["first_day_of_week"])]
|
335
|
-
day_of_week = day_of_week % 7
|
336
|
-
str += "<a href='#' data-value='#{day_of_week}'>#{$.fn.recurring_select.texts["days_first_letter"][day_of_week]}</a>"
|
337
|
-
|
338
|
-
str += "
|
339
|
-
</div>
|
340
|
-
<span style='clear:both; visibility:hidden; height:1px;'>.</span>
|
341
|
-
</div>
|
342
|
-
<div class='monthly_options freq_option_section'>
|
343
|
-
<p>
|
344
|
-
#{$.fn.recurring_select.texts["every"]}
|
345
|
-
<input type='text' data-wrapper-class='ui-recurring-select' name='rs_monthly_interval' class='rs_monthly_interval rs_interval' value='1' size='2' />
|
346
|
-
#{$.fn.recurring_select.texts["months"]}:
|
347
|
-
</p>
|
348
|
-
<p class='monthly_rule_type'>
|
349
|
-
<span><label for='monthly_rule_type_day'>#{$.fn.recurring_select.texts["day_of_month"]}</label><input type='radio' class='monthly_rule_type_day' name='monthly_rule_type' id='monthly_rule_type_day' value='true' /></span>
|
350
|
-
<span><label for='monthly_rule_type_week'>#{$.fn.recurring_select.texts["day_of_week"]}</label><input type='radio' class='monthly_rule_type_week' name='monthly_rule_type' id='monthly_rule_type_week' value='true' /></span>
|
351
|
-
</p>
|
352
|
-
<p class='rs_calendar_day'></p>
|
353
|
-
<p class='rs_calendar_week'></p>
|
354
|
-
</div>
|
355
|
-
<div class='yearly_options freq_option_section'>
|
356
|
-
<p>
|
357
|
-
#{$.fn.recurring_select.texts["every"]}
|
358
|
-
<input type='text' data-wrapper-class='ui-recurring-select' name='rs_yearly_interval' class='rs_yearly_interval rs_interval' value='1' size='2' />
|
359
|
-
#{$.fn.recurring_select.texts["years"]}
|
360
|
-
</p>
|
361
|
-
</div>
|
362
|
-
<p class='rs_summary'>
|
363
|
-
<span></span>
|
364
|
-
</p>
|
365
|
-
<div class='controls'>
|
366
|
-
<input type='button' data-wrapper-class='ui-recurring-select' class='rs_save' value='#{$.fn.recurring_select.texts["ok"]}' />
|
367
|
-
<input type='button' data-wrapper-class='ui-recurring-select' class='rs_cancel' value='#{$.fn.recurring_select.texts["cancel"]}' />
|
368
|
-
</div>
|
369
|
-
</div>
|
370
|
-
</div>
|
371
|
-
</div>
|
372
|
-
"
|