clndr-rails 1.2.5.1
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +2 -0
- data/config/routes.rb +2 -0
- data/lib/clndr-rails.rb +171 -0
- data/lib/clndr-rails/config.rb +92 -0
- data/lib/clndr-rails/engine.rb +9 -0
- data/lib/clndr-rails/errors.rb +13 -0
- data/lib/clndr-rails/helpers.rb +37 -0
- data/lib/clndr-rails/templates.rb +92 -0
- data/lib/clndr-rails/version.rb +5 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +17 -0
- data/test/dummy/app/assets/javascripts/base.js +2 -0
- data/test/dummy/app/assets/stylesheets/application.css +16 -0
- data/test/dummy/app/assets/stylesheets/base.css +0 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/base_controller.rb +31 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/base_helper.rb +2 -0
- data/test/dummy/app/views/base/index.html.erb +3 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +78 -0
- data/test/dummy/config/environments/test.rb +39 -0
- data/test/dummy/config/initializers/assets.rb +8 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/clndr.rb +27 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +6 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +19612 -0
- data/test/dummy/log/test.log +171 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/spec/controllers/base_controller_spec.rb +12 -0
- data/test/dummy/spec/helpers/base_helper_spec.rb +15 -0
- data/test/dummy/spec/rails_helper.rb +50 -0
- data/test/dummy/spec/spec_helper.rb +93 -0
- data/test/dummy/spec/views/base/index.html.erb_spec.rb +19 -0
- data/test/dummy/test/controllers/base_controller_test.rb +9 -0
- data/test/dummy/test/helpers/base_helper_test.rb +4 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c98d0fae9192743d8c55a5e8e53de41ac6246a9/clndr-rails.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0687b70ce11a7e80dcd39da365dd5a8a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/1cc60160d9e0a352994b8eb6b8313b1a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/28cfd59c37a42a9ea808d622b0177c86 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2aeab94961f3936633223fba03e2a6ed +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2be3a826c076d8c8854c94ebc3a6d773 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2e471d0b6fa1aa6817c6d3e773648a43 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/3b526052e48eb4ad5375fb6432761828 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/4069980b5689edf29f7bc438d62f44e9 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/42927f6bcf2f320e08ea8ff02d5c8209 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/433724373619c6185a095523fd7c7fe0 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/486f42c6c97c7a42b88dc91fc2d5a864 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/4a9158fb3a677a8253fa2a7e93551175 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/51408facf1bc7598eedca202daf4ba96 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/53eedf0ac9053fc3d462eabaf534bd05 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/580892b79dd41de64c62d07404cd1a12 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5a6cb5cfc573c611e29c2ac98103701f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5f78b3457def1d02bd3fb75d4e0cfb63 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/684604af0ae58f9e55f2992fe9c466d7 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6c33e774b86f9ef5ba24ffbe52bed674 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6f78527844795b9b46156d0576fffe63 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/74efa8b198344d1b86c6531144584f3e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/78573c83ee7596aaed9105a0ed816f5d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7b60bb572e6a268c62e728ed79fb2cda +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/82eac1b4407ccfbc517558b830c67a53 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/8329b2874924fc312c31e87ef69a88bb +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9123d280fa9cc0d16a1ec96a3e44bcc1 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a4ce04494de7990c1b23b8498b2fb743 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a7f1637ae79393f95fd20936e91d62d0 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ab8a19b4c942c018374d61f4f99235dc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/b6c986125db42513425f8a84e0021579 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/bb2f6a70a78dd0eb8181c7f495e82f57 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/be9637deb767f91f0193d4b0573f954e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c0f2a7bdc7a73db8bacf633cef4ec428 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c744c093e347d6c90bc75206f502a48e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c7effad0605334daea2929e656094580 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c8fc1f981896d3bc3650f6dc2cdc3981 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cbc61fb8910e489328c2cbf64a73c6ca +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d9282682f846f5b479288a298788e6c7 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/de1001d906d7f009cc8b325d53aed152 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/de79a0cce913cf585100d02ad7b13bd2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/eabe02c282ba47d5bef91a603f0e8ddc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/edf2dce367a4fbd2628ceef059dab88f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f1829681b5124c696fef4fd62c36f101 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f34be083c250d77494ecd0d35fd1099f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f3c1e7e2d789b88a0b3e967365eefda2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/1cc60160d9e0a352994b8eb6b8313b1a +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/28cfd59c37a42a9ea808d622b0177c86 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2aeab94961f3936633223fba03e2a6ed +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/42927f6bcf2f320e08ea8ff02d5c8209 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/53eedf0ac9053fc3d462eabaf534bd05 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/580892b79dd41de64c62d07404cd1a12 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/5a6cb5cfc573c611e29c2ac98103701f +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/5f78b3457def1d02bd3fb75d4e0cfb63 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/684604af0ae58f9e55f2992fe9c466d7 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/6c33e774b86f9ef5ba24ffbe52bed674 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/6f78527844795b9b46156d0576fffe63 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/74efa8b198344d1b86c6531144584f3e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/bb2f6a70a78dd0eb8181c7f495e82f57 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/c8fc1f981896d3bc3650f6dc2cdc3981 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/de79a0cce913cf585100d02ad7b13bd2 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f1829681b5124c696fef4fd62c36f101 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/pids/server.pid +1 -0
- metadata +389 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9f4e08bd446aef87926fe037c230a154f6005d34
|
4
|
+
data.tar.gz: bf1c82662950f69dcf29c3822376673caae502c8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cc1455a0d01001920d0c521644331f7d1ba120c72677d4fa1e5988d9b6bf9a00fabf007e2f5765f05ae719116b48f302345c3a832c4a805a7e64ee0c090cdae6
|
7
|
+
data.tar.gz: 4238d1826dbc1cfd0a2a786c9c20196e59187dba8acb9cc29b6838a05bd8c8f9bd2626a095800bd3118184cbe6c44e569e17bb0cdf2e128d8e29857af81321cd
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/config/routes.rb
ADDED
data/lib/clndr-rails.rb
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
require 'clndr-rails/engine'
|
2
|
+
require "clndr-rails/version"
|
3
|
+
require 'clndr-rails/errors'
|
4
|
+
|
5
|
+
|
6
|
+
require 'momentjs-rails'
|
7
|
+
require 'jquery-rails'
|
8
|
+
require 'underscore-rails'
|
9
|
+
|
10
|
+
class Clndr
|
11
|
+
|
12
|
+
autoload :Helpers, 'clndr-rails/helpers'
|
13
|
+
autoload :Template, 'clndr-rails/templates'
|
14
|
+
require 'clndr-rails/config'
|
15
|
+
|
16
|
+
|
17
|
+
include ActionView::Helpers
|
18
|
+
include ActionView::Context
|
19
|
+
include ActiveSupport::Inflector
|
20
|
+
@@calendar_bean = {}
|
21
|
+
|
22
|
+
class << self
|
23
|
+
|
24
|
+
attr_accessor :calendar_bean
|
25
|
+
|
26
|
+
# return calendar from calendars bean
|
27
|
+
def get_calendar(calendar)
|
28
|
+
clndr = @@calendar_bean[calendar.to_sym]
|
29
|
+
if clndr.class == Clndr
|
30
|
+
clndr
|
31
|
+
else
|
32
|
+
raise Clndr::Error::CalendarNotFound, "Calndear with name #{calendar} not found. Use Clndr.new(:#{calendar}) to create them"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
attr_accessor :template, :weak_offset, :days_of_the_weak,:show_adjacent_months, :adjacent_days_change_month, :done_rendering, :events, :constraints
|
38
|
+
attr_reader :name
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
def initialize(name)
|
43
|
+
@name = name.to_sym
|
44
|
+
@template = @@template
|
45
|
+
@weak_offset = @@weak_offset
|
46
|
+
@start_with_month =@@start_with_month
|
47
|
+
@days_of_the_weak = @@days_of_the_weak
|
48
|
+
@click_events = @@click_events.clone
|
49
|
+
@targets= @@targets.clone
|
50
|
+
@show_adjacent_months= @@show_adjacent_months
|
51
|
+
@adjacent_days_change_month = @@adjacent_days_change_month
|
52
|
+
@done_rendering = @done_rendering
|
53
|
+
@constraints =@@constraints
|
54
|
+
@force_six_rows =@@force_six_rows
|
55
|
+
@has_multiday= false
|
56
|
+
@events =[]
|
57
|
+
@@calendar_bean.merge! Hash[@name,self]
|
58
|
+
end
|
59
|
+
|
60
|
+
# return html of calendar
|
61
|
+
def view(args)
|
62
|
+
if @template == Clndr::Template::Full
|
63
|
+
css_class = 'full-clndr-template'
|
64
|
+
elsif @template == Clndr::Template::Mini
|
65
|
+
css_class = 'mini-clndr-template'
|
66
|
+
elsif @template == Clndr::Template::Simple
|
67
|
+
css_class = 'simple-clndr-template'
|
68
|
+
end
|
69
|
+
content_tag(:div,nil,args)do
|
70
|
+
content_tag(:div,nil,id:"#{@name}-clndr",class:"clearfix #{css_class}")+
|
71
|
+
javascript_tag("var #{@name} = $('##{@name}-clndr').clndr({
|
72
|
+
#{'template:'+@template+',' if !@template.nil?}
|
73
|
+
#{'weekOffset:'+@weak_offset.to_s+',' if @weak_offset}
|
74
|
+
#{'startWithMonth:\''+@start_with_month.to_s+'\',' if !@start_with_month.nil?}
|
75
|
+
#{'daysOfTheWeek:'+@days_of_the_weak.to_s+',' if !@days_of_the_weak.nil?}
|
76
|
+
#{build_from_hash(@click_events,'clickEvents')}
|
77
|
+
#{build_from_hash_safety(@targets,'targets')}
|
78
|
+
#{'showAdjacentMonths:'+@show_adjacent_months.to_s+',' if !@show_adjacent_months}
|
79
|
+
#{'adjacentDaysChangeMonth:'+@adjacent_days_change_month.to_s+',' if @adjacent_days_change_month}
|
80
|
+
#{'doneRendering:'+@done_rendering+',' if !@done_rendering.nil?}
|
81
|
+
#{'forceSixRows:'+@force_six_rows.to_s+',' if @force_six_rows}
|
82
|
+
#{ if @constraints.length >0
|
83
|
+
build_from_hash_safety @constraints, 'constraints'
|
84
|
+
end}
|
85
|
+
#{if @has_multiday
|
86
|
+
"multiDayEvents: {
|
87
|
+
startDate: 'startDate',
|
88
|
+
endDate: 'endDate'
|
89
|
+
},"
|
90
|
+
end}
|
91
|
+
#{if @events.length > 0
|
92
|
+
'events:['+build_events(@events)+']'
|
93
|
+
end}
|
94
|
+
});")
|
95
|
+
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# if date is instance of Time convert to "YYYY-MM-DD" формат
|
101
|
+
def start_with_month=(date)
|
102
|
+
if date.class == Time
|
103
|
+
@start_with_month= date.strftime("%F")
|
104
|
+
else
|
105
|
+
@start_with_month = date
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def click_event
|
110
|
+
@click_events
|
111
|
+
end
|
112
|
+
|
113
|
+
def target
|
114
|
+
@targets
|
115
|
+
end
|
116
|
+
|
117
|
+
def add_event(date,title,*other_data)
|
118
|
+
date = format_date date
|
119
|
+
event = {date: date,title:title}
|
120
|
+
event.merge! *other_data if other_data.length>0
|
121
|
+
@events.push event
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
def add_multiday_event(start_date,end_date,title,*other_data)
|
126
|
+
start_date = format_date start_date
|
127
|
+
end_date = format_date end_date
|
128
|
+
event = {start_date:start_date,end_date:end_date,title:title}
|
129
|
+
event.merge! *other_data if other_data.length >0
|
130
|
+
@has_multiday ||= true
|
131
|
+
@events.push event
|
132
|
+
end
|
133
|
+
|
134
|
+
private
|
135
|
+
|
136
|
+
def build_from_hash(hash, parametr)
|
137
|
+
if hash.length > 0
|
138
|
+
"#{parametr}: {#{hash.map{|k,v|"#{k}:#{v},"}.join()}},"
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def build_from_hash_safety(hash, parametr)
|
143
|
+
if hash.length > 0
|
144
|
+
"#{parametr}: {#{hash.map{|k,v|"#{k}:'#{v}',"}.join()}},"
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def build_events(array_of_events)
|
149
|
+
list_of_events=''
|
150
|
+
array_of_events.each do |event|
|
151
|
+
list_of_events +="{#{'date:\''+event.delete(:date)+'\',' if !event[:date].nil?}
|
152
|
+
#{'startDate: \''+event.delete(:start_date)+'\','+
|
153
|
+
'endDate: \'' + event.delete(:end_date)+'\','if !event[:start_date].nil?}
|
154
|
+
title: '#{event.delete(:title)}',
|
155
|
+
#{event.map{|k,v| "#{k}:'#{v}'"}.join(',')}},"
|
156
|
+
end
|
157
|
+
# @events = nil
|
158
|
+
list_of_events
|
159
|
+
end
|
160
|
+
|
161
|
+
def format_date(date)
|
162
|
+
if date.class == Time
|
163
|
+
date.strftime("%F")
|
164
|
+
elsif date.match(/\d{4}\-\d{2}\-\d{2}/)
|
165
|
+
date
|
166
|
+
else
|
167
|
+
raise Clndr::Error::WrongDateFormat
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
class Clndr
|
2
|
+
|
3
|
+
# default config
|
4
|
+
@@template = Clndr::Template::Blank
|
5
|
+
@@weak_offset = true
|
6
|
+
@@start_with_month = nil
|
7
|
+
@@days_of_the_week = nil
|
8
|
+
@@click_events={}
|
9
|
+
@@targets={}
|
10
|
+
@@show_adjacent_months= true
|
11
|
+
@@adjacent_days_change_month=false
|
12
|
+
@@done_rendering=nil
|
13
|
+
@@constraints ={}
|
14
|
+
@@force_six_rows= true
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
def self.configure
|
19
|
+
yield self
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.template=(template)
|
23
|
+
@@template ||= template
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.weak_offset=(offset)
|
27
|
+
if offset
|
28
|
+
@@weak_offset = 1
|
29
|
+
else
|
30
|
+
@@weak_offset = 0
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.start_with_month=(date)
|
35
|
+
if date.class == Time
|
36
|
+
@@start_with_month=date.strftime("%F")
|
37
|
+
elsif date.match(/\d{4}\-\d{2}\-\d{2}/)
|
38
|
+
@@start_with_month = date
|
39
|
+
else
|
40
|
+
raise Clndr::Error::WrongDateFormat
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.days_of_the_weak=(array_of_days)
|
45
|
+
@@days_of_the_weak=array_of_days
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.show_adjacent_months=(boolean)
|
49
|
+
@@show_adjacent_months = boolean
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.click_events
|
53
|
+
yield @@click_events
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.targets
|
57
|
+
yield @@targets
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.adjacent_days_change_month=(boolean)
|
61
|
+
@@adjacent_days_change_month= boolean
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.done_rendering=(jsfnction)
|
65
|
+
@@done_rendering = jsfnction
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.constraints_start=(date)
|
69
|
+
if date.class == Time
|
70
|
+
@@constraints[:startDate]=date.strftime("%F")
|
71
|
+
elsif date.match(/\d{4}\-\d{2}\-\d{2}/)
|
72
|
+
@@constraints[:startDate]=date
|
73
|
+
else
|
74
|
+
raise Clndr::Error::WrongDateFormat
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.constraints_end=(date)
|
79
|
+
if date.class == Time
|
80
|
+
@@constraints[:endDate]=date.strftime("%F")
|
81
|
+
elsif date.match(/\d{4}\-\d{2}\-\d{2}/)
|
82
|
+
@@constraints[:endDate]=date
|
83
|
+
else
|
84
|
+
raise Clndr::Error::WrongDateFormat
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def forceSixRows=(boolean)
|
89
|
+
@@force_six_rows= boolean
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Helpers
|
2
|
+
include ActionView::Helpers::UrlHelper
|
3
|
+
def show_calendar(scope,*args)
|
4
|
+
options = {}
|
5
|
+
args.map{|x| options.merge! x}
|
6
|
+
Clndr.get_calendar(scope.to_sym).view(options)
|
7
|
+
end
|
8
|
+
|
9
|
+
def next_month_link(scope,name,*args,&block)
|
10
|
+
args.push(:onclick => "#{Clndr.get_calendar(scope.to_sym).name}.forward(#{'{withCallbacks: true}' if block_given?}); return false")
|
11
|
+
options = {}
|
12
|
+
args.map{|x| options.merge! x}
|
13
|
+
link_to(name, '#', options )
|
14
|
+
end
|
15
|
+
|
16
|
+
def previous_month_link(scope,name,*args,&block)
|
17
|
+
args.push(:onclick => "#{Clndr.get_calendar(scope.to_sym).name}.back(#{'{withCallbacks: true}' if block_given?}); return false")
|
18
|
+
options = {}
|
19
|
+
args.map{|x| options.merge! x}
|
20
|
+
link_to(name, '#', options )
|
21
|
+
end
|
22
|
+
|
23
|
+
def next_year_link(scope,name,*args,&block)
|
24
|
+
args.push(:onclick => "#{Clndr.get_calendar(scope.to_sym).name}.nextYear(#{'{withCallbacks: true}' if block_given?}); return false")
|
25
|
+
options = {}
|
26
|
+
args.map{|x| options.merge! x}
|
27
|
+
link_to(name, '#', options )
|
28
|
+
end
|
29
|
+
|
30
|
+
def previous_year_link(scope,name,*args,&block)
|
31
|
+
args.push(:onclick => "#{Clndr.get_calendar(scope.to_sym).name}.previousYear(#{'{withCallbacks: true}' if block_given?}); return false")
|
32
|
+
options = {}
|
33
|
+
args.map{|x| options.merge! x}
|
34
|
+
link_to(name, '#', options )
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
class Clndr
|
2
|
+
module Template
|
3
|
+
|
4
|
+
extend ActionView::Helpers::TagHelper
|
5
|
+
extend ActionView::Context
|
6
|
+
|
7
|
+
# full template
|
8
|
+
Full = "'#{
|
9
|
+
content_tag(:div,nil,class:'clndr-controls') do
|
10
|
+
content_tag(:div,'<',class:"clndr-previous-button")+
|
11
|
+
content_tag(:div,'>',class:"clndr-next-button")+
|
12
|
+
content_tag(:div,'<%= month %> <%= year %>'.html_safe,class:"current-month")
|
13
|
+
end+
|
14
|
+
content_tag(:div,nil,class:'clndr-grid') do
|
15
|
+
content_tag(:div,nil, class:'days-of-the-week clearfix') do
|
16
|
+
'<% _.each(daysOfTheWeek, function(day) { %>'.html_safe+
|
17
|
+
content_tag(:div,'<%= day %>'.html_safe,class:'header-day')+"<% }); %>".html_safe
|
18
|
+
end+
|
19
|
+
content_tag(:div,nil,class:'days')do
|
20
|
+
"<% _.each(days, function(day) { %>".html_safe+
|
21
|
+
'<div class=\"<%= day.classes %>\" id=\"<%= day.id %>\"><span class=\"day-number\"><%= day.day %></span></div> <% }); %>'.html_safe
|
22
|
+
end
|
23
|
+
end+
|
24
|
+
content_tag(:div,nil,class:'event-listing') do
|
25
|
+
content_tag(:div,"EVENTS THIS MONTH", class:"event-listing-title")+
|
26
|
+
"<% _.each(eventsThisMonth, function(event) { %>".html_safe+
|
27
|
+
content_tag(:div,nil,class:"event-item") do
|
28
|
+
content_tag(:div,"<%= event.title %>".html_safe, class:"event-item-name")+
|
29
|
+
content_tag(:div,"<%= event.location %>".html_safe, class:"event-item-location")
|
30
|
+
end+
|
31
|
+
"<% }); %>".html_safe
|
32
|
+
end
|
33
|
+
}'"
|
34
|
+
|
35
|
+
Blank=nil
|
36
|
+
|
37
|
+
Mini = "'#{
|
38
|
+
content_tag(:div,class:'controls') do
|
39
|
+
content_tag(:div,"<", class:"clndr-previous-button")+
|
40
|
+
content_tag(:div,"<%= month %>".html_safe, class:"month")+
|
41
|
+
content_tag(:div,'>',class:"clndr-next-button")
|
42
|
+
end+
|
43
|
+
content_tag(:div,class:"days-container") do
|
44
|
+
content_tag(:div,class:"days") do
|
45
|
+
content_tag(:div, class:"headers") do
|
46
|
+
"<% _.each(daysOfTheWeek, function(day) { %>".html_safe+
|
47
|
+
content_tag(:div,"<%= day %>".html_safe, class:"day-header")+
|
48
|
+
"<% }); %>".html_safe+
|
49
|
+
'<% _.each(days, function(day) { %><div class="<%= day.classes %>" id="<%= day.id %>"><%= day.day %></div><% }); %>'.html_safe
|
50
|
+
end
|
51
|
+
end+
|
52
|
+
content_tag(:div,class:"events") do
|
53
|
+
content_tag(:div,class:"headers") do
|
54
|
+
content_tag(:div,'x',class:"x-button")+
|
55
|
+
content_tag(:div,'EVENTS',class:"event-header")
|
56
|
+
end+
|
57
|
+
content_tag(:div,class:"events-list") do
|
58
|
+
'<% _.each(eventsThisMonth, function(event) { %>'.html_safe+
|
59
|
+
content_tag(:div,class:"event") do
|
60
|
+
'<a href="<%= event.url %>"><%= moment(event.date).format("MMMM Do") %>: <%= event.title %></a>'.html_safe
|
61
|
+
end+
|
62
|
+
'<% }); %>'.html_safe
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
}'"
|
69
|
+
|
70
|
+
Simple="'#{
|
71
|
+
content_tag(:div,'<%= month %>'.html_safe,class:"month-bar")+
|
72
|
+
content_tag(:div,class:"clndr-grid")do
|
73
|
+
content_tag(:div, class:"days-of-the-week clearfix") do
|
74
|
+
'<% _.each(daysOfTheWeek, function(day) { %>'.html_safe+
|
75
|
+
content_tag(:div,'<%= day %>'.html_safe,class:"header-day")+
|
76
|
+
'<% }); %>'.html_safe
|
77
|
+
end+
|
78
|
+
content_tag(:div,class:"days clearfix") do
|
79
|
+
'<% _.each(days, function(day) { %>'.html_safe+
|
80
|
+
'<div class="<%= day.classes %>" id="<%= day.id %>"><span class="day-number"><%= day.day %></span></div>'.html_safe+
|
81
|
+
'<% }); %>'.html_safe
|
82
|
+
end
|
83
|
+
end
|
84
|
+
}'"
|
85
|
+
|
86
|
+
|
87
|
+
def self.from_html(selector)
|
88
|
+
"$(\"#{selector}\").html()".html_safe
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|