event_calendar 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ .DS_Store
2
+ *.sw?
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ sandbox
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Sean Huber (shuber@huberry.com)
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/README.rdoc ADDED
@@ -0,0 +1,29 @@
1
+ = event_calendar
2
+
3
+ Generates HTML event calendars with ruby
4
+
5
+ INCOMPLETE
6
+
7
+ == Installation
8
+
9
+ gem install event_calendar --source http://gemcutter.org
10
+
11
+ == Usage
12
+
13
+ @calendar = Calendar.new(2009, 10, :events => Event.all)
14
+ puts @calendar.to_html
15
+
16
+ == Note on Patches/Pull Requests
17
+
18
+ * Fork the project.
19
+ * Make your feature addition or bug fix.
20
+ * Add tests for it. This is important so I don't break it in a
21
+ future version unintentionally.
22
+ * Commit, do not mess with rakefile, version, or history.
23
+ (if you want to have your own version, that is fine but
24
+ bump version in a commit by itself I can ignore when I pull)
25
+ * Send me a pull request. Bonus points for topic branches.
26
+
27
+ == Copyright
28
+
29
+ Copyright (c) 2009 Sean Huber. See MIT-LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,62 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = 'event_calendar'
8
+ gem.summary = 'Generates HTML event calendars'
9
+ gem.description = 'Generates HTML event calendars'
10
+ gem.email = 'shuber@huberry.com'
11
+ gem.homepage = 'http://github.com/shuber/event_calendar'
12
+ gem.authors = ['Sean Huber']
13
+ gem.add_dependency 'activesupport'
14
+ gem.add_dependency 'markaby'
15
+ gem.add_dependency 'haml'
16
+ gem.add_development_dependency 'shoulda'
17
+ gem.add_development_dependency 'timecop'
18
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
19
+ end
20
+ rescue LoadError
21
+ puts 'Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler'
22
+ end
23
+
24
+ require 'rake/testtask'
25
+ Rake::TestTask.new(:test) do |test|
26
+ test.libs << 'lib' << 'test'
27
+ test.pattern = 'test/**/*_test.rb'
28
+ test.verbose = true
29
+ end
30
+
31
+ begin
32
+ require 'rcov/rcovtask'
33
+ Rcov::RcovTask.new do |test|
34
+ test.libs << 'test'
35
+ test.pattern = 'test/**/*_test.rb'
36
+ test.verbose = true
37
+ end
38
+ rescue LoadError
39
+ task :rcov do
40
+ abort 'RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov'
41
+ end
42
+ end
43
+
44
+ task :test => :check_dependencies
45
+
46
+ task :default => :test
47
+
48
+ require 'rake/rdoctask'
49
+ Rake::RDocTask.new do |rdoc|
50
+ if File.exist?('VERSION')
51
+ version = File.read('VERSION')
52
+ else
53
+ version = ""
54
+ end
55
+
56
+ rdoc.rdoc_dir = 'rdoc'
57
+ rdoc.title = "event_calendar #{version}"
58
+ rdoc.rdoc_files.include('README*')
59
+ rdoc.rdoc_files.include('lib/**/*.rb')
60
+ end
61
+
62
+ Dir[File.join(File.dirname(__FILE__), 'lib', 'tasks', '*.rake')].each { |file| load file }
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
@@ -0,0 +1,55 @@
1
+ var Calendar = Class.create({
2
+
3
+ options: $H({
4
+ events_css_path: '.event',
5
+ event_fields_css_path: '.fields span',
6
+ event_hover_class: 'hover'
7
+ }),
8
+
9
+ initialize: function(element, options) {
10
+ this.element = element;
11
+ this.options = this.options.merge(options || {});
12
+ this.events = $$('#' + this.element.id + ' ' + this.options.get('events_css_path'));
13
+
14
+ this.events.each(function(event) {
15
+ this.add_fields_to_event(event);
16
+ this.add_hover_behavior_to_event(event);
17
+ }.bind(this));
18
+
19
+ Calendar.instances.push(this);
20
+ },
21
+
22
+ add_fields_to_event: function(event) {
23
+ event.fields = $$('#' + event.id + ' ' + this.options.get('event_fields_css_path')).inject({}, function(fields, element) {
24
+ fields[element.title] = element.innerHTML;
25
+ return fields;
26
+ });
27
+ },
28
+
29
+ add_hover_behavior_to_event: function(event) {
30
+ var hover_class_name = this.options.get('event_hover_class');
31
+ var related_events = this.related_events_for(event);
32
+
33
+ event.observe('mouseover', function() {
34
+ related_events.each(function(related_event) {
35
+ related_event.addClassName(hover_class_name);
36
+ });
37
+ });
38
+
39
+ event.observe('mouseout', function() {
40
+ related_events.each(function(related_event) {
41
+ related_event.removeClassName(hover_class_name);
42
+ });
43
+ });
44
+ },
45
+
46
+ related_events_for: function(event) {
47
+ var regex = new RegExp('^' + event.id.replace(/(\d+)_(\d+)/, '$1'));
48
+ return this.events.select(function(related_event) {
49
+ return event != related_event && regex.test(related_event.id);
50
+ });
51
+ }
52
+
53
+ });
54
+
55
+ Calendar.instances = [];