clndr-rails 1.2.10.1 → 1.4.6.1.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +10 -10
- data/lib/clndr-rails.rb +230 -230
- data/lib/clndr-rails/config.rb +114 -114
- data/lib/clndr-rails/errors.rb +19 -19
- data/lib/clndr-rails/templates.rb +94 -94
- data/lib/clndr-rails/version.rb +1 -1
- data/test/dummy/config/initializers/clndr.rb +27 -27
- data/test/dummy/log/test.log +372 -16927
- data/test/dummy/spec/controllers/base_controller_spec.rb +12 -12
- data/test/dummy/spec/spec_helper.rb +93 -93
- data/test/spec/clndr-rails_spec.rb +28 -28
- data/test/spec/configuration_spec.rb +136 -136
- data/test/spec/events_spec.rb +62 -62
- data/test/spec/html_spec.rb +199 -199
- data/test/spec/spec_helper.rb +15 -15
- data/test/spec/templates_spec.rb +70 -70
- data/vendor/assets/javascripts/clndr-rails/clndr.min.js +2 -2
- metadata +26 -246
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/log/development (/320/232/320/276/320/275/321/204/320/273/320/270/320/272/321/202/321/203/321/216/321/211/320/260/321/217 /320/272/320/276/320/277/320/270/321/217 /321/201 /320/272/320/276/320/274/320/277/321/214/321/216/321/202/320/265/321/200/320/260 DELTAPC2 2014-12-25).log" +0 -19726
- data/test/dummy/log/development.log +0 -22099
- data/test/dummy/tmp/cache/assets/development/sass/7c98d0fae9192743d8c55a5e8e53de41ac6246a9/clndr-rails.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/003c68cd1f3ba2d6344147bb52d8fd1a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/02c5e1a21d4a4605f8b34eca639a1f70 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0687b70ce11a7e80dcd39da365dd5a8a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/08b993c8e83ad57a4ecb8d753b4620d5 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/1223ac7ac3a460c3f9ce66e828acdc67 +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/1d658adc7cb09c209c423c9138dbacee +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/460632c7db14d41cf7371b6b4bb64157 +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/4ad6cd41e5b645f9ceef10b1e3baea77 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/4b2e05f2b06345dfee1d683a3fdd29e7 +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/58dc697381035be4d343e2b19720c10c +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/643ff98d256ca160a0cb4ca0fc83ffdb +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/684604af0ae58f9e55f2992fe9c466d7 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6b158f7584f499d82165f5ccaf303d16 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6c33e774b86f9ef5ba24ffbe52bed674 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6c9c1cfb50b40b88dd14926792400890 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6f78527844795b9b46156d0576fffe63 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/73938775f2e5bebe09996667ea3dd302 +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/7b51783beb0f6f17617f87ef5d2688e3 +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/83ed9f0dcdd68efbed721b2b10fcda6b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9123d280fa9cc0d16a1ec96a3e44bcc1 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/93120bd88f1e2293fc55c191aeab678a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9334f44096c23e8904784b524e6ae750 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/954c1c7328e5b9c43abd84f4981286c7 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9bd8392ddf2b52be4b455e52a628d169 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9c89c900cca1bf92a5f29c304d323256 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9e158358644b7e1cbee43defd7d7b449 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a086b63b827c2bdef684cc4985c925fc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a4ce04494de7990c1b23b8498b2fb743 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a62be18dea33018456ea9b72b4a9e10b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a780ea7d8044a1786c8bfd4b3df13491 +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/ad861213dbd41ab02600f740c9bb1dee +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ae0ae68c837285b67a4fc1df4dddb939 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/b419fd5d14fd53ae2fffa3026f0f4aa4 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/b6c986125db42513425f8a84e0021579 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/b85bb5a9001b8d932b99e152afc282b9 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/bb2f6a70a78dd0eb8181c7f495e82f57 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/bd28ee35f981cb10b9740ee6e6686b6d +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/c4a0410f3ca8e859238c3b5a24ef0d98 +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/cc517e4ba5ef452b08d1ab48925b952d +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/dc767a0bb27fb390899cd7e6ff34b310 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/dd041a66875b6a140cf105a32e88980b +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/e101b6a9f9eb86d3591c6075a3f59be4 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e59e1f3e795e9486fffbc3b4ad0baaca +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e7296c70ca399cdcc73806b4a9481fde +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/efbbf60292a32f735cfdcbd98f0a0dcb +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/f56ceda2003be471c5e7a5ec2e355c9e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/fb5e937723a7579bee0be03b0c5d9052 +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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2b1ac50979abe5b3132854c71f2234cb721bbb6
|
4
|
+
data.tar.gz: ed2737e444082f86dc5b95e1354beaee46badbe7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25d09e47bdf86987b680a6e3c2c4b627b685f3531ae207fa0cc3e900d7856b8984c870142da4e8d7909b99cb8f21df5657ab91320911d3e02270cfa127101596
|
7
|
+
data.tar.gz: 1c8d8d862f42eb0172e663aee0640cb6d83dbfca40f06448f076c9bf1e21a5254e34c2728200f9dec52cd77564f634c7776eccf2eafe41899f3cd9cff9211dfe
|
data/Rakefile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require 'bundler/gem_tasks'
|
2
|
-
|
3
|
-
require 'rake'
|
4
|
-
require 'rspec/core/rake_task'
|
5
|
-
|
6
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
7
|
-
t.pattern = Dir.glob('test/spec/**/*_spec.rb')
|
8
|
-
t.rspec_opts = '--format documentation --color'
|
9
|
-
|
10
|
-
end
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
|
3
|
+
require 'rake'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
7
|
+
t.pattern = Dir.glob('test/spec/**/*_spec.rb')
|
8
|
+
t.rspec_opts = '--format documentation --color'
|
9
|
+
|
10
|
+
end
|
11
11
|
task :default => :spec
|
data/lib/clndr-rails.rb
CHANGED
@@ -1,230 +1,230 @@
|
|
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
|
-
|
18
|
-
include ActionView::Helpers
|
19
|
-
include ActionView::Context
|
20
|
-
include ActiveSupport::Inflector
|
21
|
-
@@calendar_basket = {}
|
22
|
-
cattr_reader :calendar_basket
|
23
|
-
|
24
|
-
class << self
|
25
|
-
|
26
|
-
# return calendar from calendars bean
|
27
|
-
def get_calendar(calendar)
|
28
|
-
clndr = @@calendar_basket[calendar.to_sym]
|
29
|
-
if clndr.class == Clndr
|
30
|
-
clndr
|
31
|
-
else
|
32
|
-
raise Clndr::Error::CalendarNotFound, "Calendar with name #{calendar} not found. Use Clndr.new(:#{calendar}) to create them"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
attr_accessor :template, :week_offset, :days_of_the_week,
|
38
|
-
:show_adjacent_months, :adjacent_days_change_month,
|
39
|
-
:done_rendering, :force_six_rows, :start_with_month
|
40
|
-
attr_reader :name, :events
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
def initialize(name)
|
45
|
-
@name = name.to_sym
|
46
|
-
@template = @@template
|
47
|
-
@week_offset = @@week_offset
|
48
|
-
@start_with_month =@@start_with_month
|
49
|
-
@days_of_the_week = @@days_of_the_week
|
50
|
-
@click_events = @@click_events.clone
|
51
|
-
@targets= @@targets.clone
|
52
|
-
@show_adjacent_months= @@show_adjacent_months
|
53
|
-
@adjacent_days_change_month = @@adjacent_days_change_month
|
54
|
-
@done_rendering = @@done_rendering
|
55
|
-
@constraints =@@constraints
|
56
|
-
@force_six_rows =@@force_six_rows
|
57
|
-
@custom_classes = @@custom_classes
|
58
|
-
@has_multiday= false
|
59
|
-
@events =[]
|
60
|
-
@@calendar_basket.merge! Hash[@name,self]
|
61
|
-
end
|
62
|
-
|
63
|
-
# return html of calendar
|
64
|
-
def view(args=nil)
|
65
|
-
|
66
|
-
case @template
|
67
|
-
when Clndr::Template::FULL
|
68
|
-
css_class = 'full-clndr-template'
|
69
|
-
when Clndr::Template::MINI
|
70
|
-
css_class = 'mini-clndr-template'
|
71
|
-
when Clndr::Template::SIMPLE
|
72
|
-
css_class = 'simple-clndr-template'
|
73
|
-
else
|
74
|
-
css_class = 'blank-clndr-template'
|
75
|
-
end
|
76
|
-
|
77
|
-
content_tag(:div,nil,args)do
|
78
|
-
content_tag(:div,nil,id:"#{@name}-clndr",class:"clearfix #{css_class}")+
|
79
|
-
javascript_tag("var #{@name} = $('##{@name}-clndr').clndr({
|
80
|
-
#{'template:'+@template+',' unless @template.nil?}
|
81
|
-
#{'weekOffset:'+@week_offset.to_s+',' if @week_offset==1}
|
82
|
-
#{'startWithMonth:\''+@start_with_month.to_s+'\',' unless @start_with_month.nil?}
|
83
|
-
#{'daysOfTheWeek:'+@days_of_the_week.to_s+',' unless @days_of_the_week.nil?}
|
84
|
-
#{build_from_hash(@click_events,'clickEvents')}
|
85
|
-
#{build_from_hash(@targets,'targets',true)}
|
86
|
-
#{'showAdjacentMonths:'+@show_adjacent_months.to_s+',' unless @show_adjacent_months}
|
87
|
-
#{'adjacentDaysChangeMonth:'+@adjacent_days_change_month.to_s+',' if @adjacent_days_change_month}
|
88
|
-
#{'doneRendering:'+@done_rendering+',' unless @done_rendering.nil?}
|
89
|
-
#{'forceSixRows:'+@force_six_rows.to_s+',' if @force_six_rows}
|
90
|
-
#{build_from_hash(@custom_classes, 'classes',true)}
|
91
|
-
#{ if @constraints.length >0
|
92
|
-
build_from_hash @constraints, 'constraints', true
|
93
|
-
end}
|
94
|
-
#{if @has_multiday
|
95
|
-
"multiDayEvents: {
|
96
|
-
startDate: 'startDate',
|
97
|
-
endDate: 'endDate',
|
98
|
-
singleDay: 'date'
|
99
|
-
},"
|
100
|
-
end}
|
101
|
-
#{if @events.length > 0
|
102
|
-
'events:['+build_events+']'
|
103
|
-
end}
|
104
|
-
});".gsub(/\n\s*\n/,"\n"))
|
105
|
-
|
106
|
-
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def week_offset=(boolean)
|
111
|
-
if boolean
|
112
|
-
@week_offset=1
|
113
|
-
else
|
114
|
-
@week_offset =0
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
# if date is instance of Time convert to "YYYY-MM-DD" format
|
119
|
-
def start_with_month=(date)
|
120
|
-
@start_with_month = Clndr.date_format date
|
121
|
-
end
|
122
|
-
|
123
|
-
# access to click_events hash
|
124
|
-
def click_event
|
125
|
-
@click_events
|
126
|
-
end
|
127
|
-
|
128
|
-
# access to targets hash
|
129
|
-
def target
|
130
|
-
@targets
|
131
|
-
end
|
132
|
-
|
133
|
-
def constraints_start
|
134
|
-
@constraints[:startDate]
|
135
|
-
end
|
136
|
-
|
137
|
-
def constraints_start=(date)
|
138
|
-
@constraints[:startDate] = Clndr.date_format date
|
139
|
-
end
|
140
|
-
|
141
|
-
def constraints_end
|
142
|
-
@constraints[:endDate]
|
143
|
-
end
|
144
|
-
|
145
|
-
def constraints_end=(date)
|
146
|
-
@constraints[:endDate] = Clndr.date_format date
|
147
|
-
end
|
148
|
-
|
149
|
-
def custom_classes
|
150
|
-
@custom_classes
|
151
|
-
end
|
152
|
-
|
153
|
-
def custom_today_class=(css_class)
|
154
|
-
@custom_classes[:today]=css_class
|
155
|
-
end
|
156
|
-
|
157
|
-
def custom_event_class=(css_class)
|
158
|
-
@custom_classes[:event]=css_class
|
159
|
-
end
|
160
|
-
def custom_past_class=(css_class)
|
161
|
-
@custom_classes[:past]=css_class
|
162
|
-
end
|
163
|
-
|
164
|
-
def custom_last_month_class=(css_class)
|
165
|
-
@custom_classes[:lastMonth]=css_class
|
166
|
-
end
|
167
|
-
|
168
|
-
def custom_next_month_class=(css_class)
|
169
|
-
@custom_classes[:nextMonth]=css_class
|
170
|
-
end
|
171
|
-
|
172
|
-
def custom_adjacent_month_class=(css_class)
|
173
|
-
@custom_classes[:adjacentMonth]=css_class
|
174
|
-
end
|
175
|
-
|
176
|
-
def custom_inactive_class=(css_class)
|
177
|
-
@custom_classes[:inactive]=css_class
|
178
|
-
end
|
179
|
-
|
180
|
-
# add event to events array
|
181
|
-
# *other_data some data for tour access in template
|
182
|
-
def add_event(date,title,*other_data)
|
183
|
-
date = Clndr.date_format date
|
184
|
-
event = {date: date,title:title}
|
185
|
-
event.merge! *other_data if other_data.length>0
|
186
|
-
@events.push event
|
187
|
-
|
188
|
-
end
|
189
|
-
|
190
|
-
# add multiday event
|
191
|
-
def add_multiday_event(start_date,end_date,title,*other_data)
|
192
|
-
start_date = Clndr.date_format start_date
|
193
|
-
end_date = Clndr.date_format end_date
|
194
|
-
event = {start_date:start_date,end_date:end_date,title:title}
|
195
|
-
event.merge! *other_data if other_data.length >0
|
196
|
-
@has_multiday ||= true
|
197
|
-
@events.push event
|
198
|
-
end
|
199
|
-
|
200
|
-
private
|
201
|
-
|
202
|
-
# build string from hash to parameter
|
203
|
-
# this unsafe method use only for function or true/false value
|
204
|
-
# if you need generate js string (eg param:'some value') use
|
205
|
-
# .build_from_hash_safety
|
206
|
-
def build_from_hash(hash, parameter,safety=false)
|
207
|
-
if hash.length > 0
|
208
|
-
"#{parameter}: {#{hash.map { |k, v| "#{k}:#{'\'' if safety}#{v}#{'\'' if safety}," }.join}},"
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
|
213
|
-
# generate events array from @event
|
214
|
-
def build_events
|
215
|
-
list_of_events=''
|
216
|
-
@events.delete_if do |event|
|
217
|
-
list_of_events +="{
|
218
|
-
#{'date:\''+event.delete(:date)+'\',' unless event[:date].nil?}
|
219
|
-
#{'startDate: \''+event.delete(:start_date)+'\','+
|
220
|
-
'endDate: \'' + event.delete(:end_date)+'\',' unless event[:start_date].nil?}
|
221
|
-
title: '#{event.delete(:title).gsub("'",""")}',
|
222
|
-
#{event.map{|k,v| "#{k}:'#{v.gsub("'",""")}'"}.join(',')}},".gsub(/\n\s*\n/,"\n")
|
223
|
-
|
224
|
-
end
|
225
|
-
|
226
|
-
# return string with events
|
227
|
-
list_of_events
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
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
|
+
|
18
|
+
include ActionView::Helpers
|
19
|
+
include ActionView::Context
|
20
|
+
include ActiveSupport::Inflector
|
21
|
+
@@calendar_basket = {}
|
22
|
+
cattr_reader :calendar_basket
|
23
|
+
|
24
|
+
class << self
|
25
|
+
|
26
|
+
# return calendar from calendars bean
|
27
|
+
def get_calendar(calendar)
|
28
|
+
clndr = @@calendar_basket[calendar.to_sym]
|
29
|
+
if clndr.class == Clndr
|
30
|
+
clndr
|
31
|
+
else
|
32
|
+
raise Clndr::Error::CalendarNotFound, "Calendar with name #{calendar} not found. Use Clndr.new(:#{calendar}) to create them"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
attr_accessor :template, :week_offset, :days_of_the_week,
|
38
|
+
:show_adjacent_months, :adjacent_days_change_month,
|
39
|
+
:done_rendering, :force_six_rows, :start_with_month
|
40
|
+
attr_reader :name, :events
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
def initialize(name)
|
45
|
+
@name = name.to_sym
|
46
|
+
@template = @@template
|
47
|
+
@week_offset = @@week_offset
|
48
|
+
@start_with_month =@@start_with_month
|
49
|
+
@days_of_the_week = @@days_of_the_week
|
50
|
+
@click_events = @@click_events.clone
|
51
|
+
@targets= @@targets.clone
|
52
|
+
@show_adjacent_months= @@show_adjacent_months
|
53
|
+
@adjacent_days_change_month = @@adjacent_days_change_month
|
54
|
+
@done_rendering = @@done_rendering
|
55
|
+
@constraints =@@constraints
|
56
|
+
@force_six_rows =@@force_six_rows
|
57
|
+
@custom_classes = @@custom_classes
|
58
|
+
@has_multiday= false
|
59
|
+
@events =[]
|
60
|
+
@@calendar_basket.merge! Hash[@name,self]
|
61
|
+
end
|
62
|
+
|
63
|
+
# return html of calendar
|
64
|
+
def view(args=nil)
|
65
|
+
|
66
|
+
case @template
|
67
|
+
when Clndr::Template::FULL
|
68
|
+
css_class = 'full-clndr-template'
|
69
|
+
when Clndr::Template::MINI
|
70
|
+
css_class = 'mini-clndr-template'
|
71
|
+
when Clndr::Template::SIMPLE
|
72
|
+
css_class = 'simple-clndr-template'
|
73
|
+
else
|
74
|
+
css_class = 'blank-clndr-template'
|
75
|
+
end
|
76
|
+
|
77
|
+
content_tag(:div,nil,args)do
|
78
|
+
content_tag(:div,nil,id:"#{@name}-clndr",class:"clearfix #{css_class}")+
|
79
|
+
javascript_tag("var #{@name} = $('##{@name}-clndr').clndr({
|
80
|
+
#{'template:'+@template+',' unless @template.nil?}
|
81
|
+
#{'weekOffset:'+@week_offset.to_s+',' if @week_offset==1}
|
82
|
+
#{'startWithMonth:\''+@start_with_month.to_s+'\',' unless @start_with_month.nil?}
|
83
|
+
#{'daysOfTheWeek:'+@days_of_the_week.to_s+',' unless @days_of_the_week.nil?}
|
84
|
+
#{build_from_hash(@click_events,'clickEvents')}
|
85
|
+
#{build_from_hash(@targets,'targets',true)}
|
86
|
+
#{'showAdjacentMonths:'+@show_adjacent_months.to_s+',' unless @show_adjacent_months}
|
87
|
+
#{'adjacentDaysChangeMonth:'+@adjacent_days_change_month.to_s+',' if @adjacent_days_change_month}
|
88
|
+
#{'doneRendering:'+@done_rendering+',' unless @done_rendering.nil?}
|
89
|
+
#{'forceSixRows:'+@force_six_rows.to_s+',' if @force_six_rows}
|
90
|
+
#{build_from_hash(@custom_classes, 'classes',true)}
|
91
|
+
#{ if @constraints.length >0
|
92
|
+
build_from_hash @constraints, 'constraints', true
|
93
|
+
end}
|
94
|
+
#{if @has_multiday
|
95
|
+
"multiDayEvents: {
|
96
|
+
startDate: 'startDate',
|
97
|
+
endDate: 'endDate',
|
98
|
+
singleDay: 'date'
|
99
|
+
},"
|
100
|
+
end}
|
101
|
+
#{if @events.length > 0
|
102
|
+
'events:['+build_events+']'
|
103
|
+
end}
|
104
|
+
});".gsub(/\n\s*\n/,"\n"))
|
105
|
+
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def week_offset=(boolean)
|
111
|
+
if boolean
|
112
|
+
@week_offset=1
|
113
|
+
else
|
114
|
+
@week_offset =0
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# if date is instance of Time convert to "YYYY-MM-DD" format
|
119
|
+
def start_with_month=(date)
|
120
|
+
@start_with_month = Clndr.date_format date
|
121
|
+
end
|
122
|
+
|
123
|
+
# access to click_events hash
|
124
|
+
def click_event
|
125
|
+
@click_events
|
126
|
+
end
|
127
|
+
|
128
|
+
# access to targets hash
|
129
|
+
def target
|
130
|
+
@targets
|
131
|
+
end
|
132
|
+
|
133
|
+
def constraints_start
|
134
|
+
@constraints[:startDate]
|
135
|
+
end
|
136
|
+
|
137
|
+
def constraints_start=(date)
|
138
|
+
@constraints[:startDate] = Clndr.date_format date
|
139
|
+
end
|
140
|
+
|
141
|
+
def constraints_end
|
142
|
+
@constraints[:endDate]
|
143
|
+
end
|
144
|
+
|
145
|
+
def constraints_end=(date)
|
146
|
+
@constraints[:endDate] = Clndr.date_format date
|
147
|
+
end
|
148
|
+
|
149
|
+
def custom_classes
|
150
|
+
@custom_classes
|
151
|
+
end
|
152
|
+
|
153
|
+
def custom_today_class=(css_class)
|
154
|
+
@custom_classes[:today]=css_class
|
155
|
+
end
|
156
|
+
|
157
|
+
def custom_event_class=(css_class)
|
158
|
+
@custom_classes[:event]=css_class
|
159
|
+
end
|
160
|
+
def custom_past_class=(css_class)
|
161
|
+
@custom_classes[:past]=css_class
|
162
|
+
end
|
163
|
+
|
164
|
+
def custom_last_month_class=(css_class)
|
165
|
+
@custom_classes[:lastMonth]=css_class
|
166
|
+
end
|
167
|
+
|
168
|
+
def custom_next_month_class=(css_class)
|
169
|
+
@custom_classes[:nextMonth]=css_class
|
170
|
+
end
|
171
|
+
|
172
|
+
def custom_adjacent_month_class=(css_class)
|
173
|
+
@custom_classes[:adjacentMonth]=css_class
|
174
|
+
end
|
175
|
+
|
176
|
+
def custom_inactive_class=(css_class)
|
177
|
+
@custom_classes[:inactive]=css_class
|
178
|
+
end
|
179
|
+
|
180
|
+
# add event to events array
|
181
|
+
# *other_data some data for tour access in template
|
182
|
+
def add_event(date,title,*other_data)
|
183
|
+
date = Clndr.date_format date
|
184
|
+
event = {date: date,title:title}
|
185
|
+
event.merge! *other_data if other_data.length>0
|
186
|
+
@events.push event
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
# add multiday event
|
191
|
+
def add_multiday_event(start_date,end_date,title,*other_data)
|
192
|
+
start_date = Clndr.date_format start_date
|
193
|
+
end_date = Clndr.date_format end_date
|
194
|
+
event = {start_date:start_date,end_date:end_date,title:title}
|
195
|
+
event.merge! *other_data if other_data.length >0
|
196
|
+
@has_multiday ||= true
|
197
|
+
@events.push event
|
198
|
+
end
|
199
|
+
|
200
|
+
private
|
201
|
+
|
202
|
+
# build string from hash to parameter
|
203
|
+
# this unsafe method use only for function or true/false value
|
204
|
+
# if you need generate js string (eg param:'some value') use
|
205
|
+
# .build_from_hash_safety
|
206
|
+
def build_from_hash(hash, parameter,safety=false)
|
207
|
+
if hash.length > 0
|
208
|
+
"#{parameter}: {#{hash.map { |k, v| "#{k}:#{'\'' if safety}#{v}#{'\'' if safety}," }.join}},"
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
|
213
|
+
# generate events array from @event
|
214
|
+
def build_events
|
215
|
+
list_of_events=''
|
216
|
+
@events.delete_if do |event|
|
217
|
+
list_of_events +="{
|
218
|
+
#{'date:\''+event.delete(:date)+'\',' unless event[:date].nil?}
|
219
|
+
#{'startDate: \''+event.delete(:start_date)+'\','+
|
220
|
+
'endDate: \'' + event.delete(:end_date)+'\',' unless event[:start_date].nil?}
|
221
|
+
title: '#{event.delete(:title).gsub("'",""")}',
|
222
|
+
#{event.map{|k,v| "#{k}:'#{v.gsub("'",""")}'"}.join(',')}},".gsub(/\n\s*\n/,"\n")
|
223
|
+
|
224
|
+
end
|
225
|
+
|
226
|
+
# return string with events
|
227
|
+
list_of_events
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|