social_stream-events 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ //= require jquery.watermark
2
+ //
1
3
  //= require social_stream-base
2
4
  //
3
5
  //= require_self
@@ -0,0 +1,98 @@
1
+ //= require jquery.tipsy
2
+
3
+ SocialStream.Calendar = (function(SS, $, undefined){
4
+ var elementRegExp = new RegExp('sidebar_day_(..?)_(..?)_(..?.?.?)');
5
+ var eventsPath;
6
+
7
+ var elementMatch = function(el){
8
+ return elementRegExp.exec(el.id);
9
+ }
10
+
11
+ var elementDate = function(el) {
12
+ var m = elementMatch(el);
13
+
14
+ if(m == null) return;
15
+
16
+ return new Date(m[3], (m[2]-1), m[1], 23, 59, 59);
17
+ }
18
+
19
+ var eventElement = function(date) {
20
+ return $('#sidebar_day_' + date.getDate() + '_' + (date.getMonth()+1) + '_' + date.getFullYear())
21
+ }
22
+
23
+ var init = function(options){
24
+ eventsPath = options["eventsPath"]
25
+
26
+ var now = new Date();
27
+
28
+ eventElement(now).addClass('today');
29
+
30
+
31
+ $('#sidebar_calendar td').each(function(index, domEl){
32
+ var d = elementDate(domEl)
33
+
34
+ if(d < now) $(domEl).addClass('past');
35
+ if(d.getMonth() != now.getMonth() && d > now) $(domEl).addClass('next_month');
36
+ });
37
+
38
+ $.ajax({
39
+ dataType: 'json',
40
+ cache: false,
41
+ url: eventsPath,
42
+ data: {
43
+ start: options["start"],
44
+ end: options["end"]
45
+ },
46
+
47
+ success: initBusyEvents
48
+ });
49
+ }
50
+
51
+ var initBusyEvents = function(events) {
52
+ $.map(events, function(event) {
53
+ var start = new Date(event.start); // This applies TZ
54
+ var end = new Date(event.end);
55
+
56
+ for(loopTime=start.getTime(); loopTime <= end.getTime(); loopTime+=86400000) {
57
+ var d = new Date(loopTime);
58
+ var domEl = eventElement(d);
59
+
60
+ domEl.addClass("busy");
61
+ domEl.tipsy({
62
+ title: busyTipsy,
63
+ html: true,
64
+ fade: true,
65
+ hoverable: true,
66
+ gravity: 'ne',
67
+ opacity: 0.95
68
+ });
69
+ }
70
+ })
71
+ }
72
+
73
+ var busyTipsy = function(){
74
+ var startDate = elementDate(this)
75
+ startDate.setHours(0);
76
+ startDate.setMinutes(0);
77
+ startDate.setSeconds(0);
78
+ var endDate = elementDate(this)
79
+
80
+ $.ajax({
81
+ dataType: "script",
82
+ url: eventsPath,
83
+ data: {
84
+ // use UNIX timestamps
85
+ start: Math.round(startDate.getTime() / 1000),
86
+ end: Math.round(endDate.getTime() / 1000),
87
+ tipsy: this.id
88
+ }
89
+ });
90
+
91
+ return '<div id="tipsy-' + this.id + '" class="tipsy-sidebar_calendar"><img src="<%= asset_path('loading.gif') %>"></div>';
92
+ }
93
+
94
+ return {
95
+ init: init
96
+ }
97
+
98
+ })(SocialStream, jQuery);
@@ -0,0 +1,17 @@
1
+ SocialStream.Event = (function(SS, $, undefined) {
2
+ var indexCallbacks = [];
3
+
4
+ var addIndexCallback = function(callback){
5
+ indexCallbacks.push(callback);
6
+ }
7
+
8
+ var index = function(){
9
+ $.each(indexCallbacks, function(i, callback){ callback(); });
10
+ }
11
+
12
+ return {
13
+ addIndexCallback: addIndexCallback,
14
+ index: index
15
+ }
16
+
17
+ })(SocialStream, jQuery);
@@ -13,6 +13,7 @@ SocialStream.Events.Poster = (function(SS, $, undefined){
13
13
  }
14
14
 
15
15
  SS.Timeline.addInitCallback(init);
16
+ SS.Event.addIndexCallback(init);
16
17
 
17
18
  return {
18
19
  init: init
@@ -7,22 +7,6 @@
7
7
  #= require sprintf
8
8
  #= require scheduler
9
9
 
10
- SocialStream.Events.create = (start, end, allDay) ->
11
- title = prompt('Event Title:');
12
- if title
13
- $.post(SocialStream.Events.current.eventsPath,
14
- {
15
- event: {
16
- title: title,
17
- start_at: start.toString(),
18
- end_at: end.toString(),
19
- all_day: allDay,
20
- _contact_id: SocialStream.Events.current.contactId
21
- }
22
- },
23
- undefined,
24
- "script");
25
-
26
10
  SocialStream.Events.tools = {}
27
11
 
28
12
  SocialStream.Events.tools.currentRGB = () ->
@@ -4,6 +4,7 @@
4
4
  //
5
5
  //= require fullcalendar
6
6
  //= require boxy
7
+ //= require tipsy
7
8
 
8
9
  @import "colors";
9
10
 
@@ -95,6 +96,7 @@ div.event_date {
95
96
 
96
97
  #sidebar_calendar td {
97
98
  height: 25px;
99
+ padding: 1px;
98
100
  }
99
101
 
100
102
  #sidebar_calendar td.past {
@@ -113,6 +115,23 @@ div.event_date {
113
115
  #sidebar_calendar td.busy {
114
116
  font-weight: bold;
115
117
  }
118
+
119
+ #sidebar_calendar td.busy:hover {
120
+ font-weight: bold;
121
+ color: $main-color;
122
+ background: $secondary-color;
123
+ border: $main-color 1px solid;
124
+ padding: 0px;
125
+ }
126
+
127
+ #sidebar_calendar td.busy.today {
128
+ padding: 0px;
129
+ }
130
+
131
+ #sidebar_calendar td.busy:hover a {
132
+ color: $main-color;
133
+ }
134
+
116
135
  .sidebar_calendar_month {
117
136
  text-align: center;
118
137
  padding: 5px;
@@ -145,3 +164,17 @@ div.event_date {
145
164
  #scheduler-options {
146
165
  padding: 2px 10px;
147
166
  }
167
+
168
+ .tipsy-sidebar_calendar {
169
+ min-width: 300px;
170
+ width: 300px;
171
+ border: solid $separation-color 1px;
172
+ padding: 10px;
173
+ background-color: #FFF;
174
+ opacity: 1;
175
+ border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px;
176
+ }
177
+
178
+ .tipsy-inner {
179
+ max-width: 500px;
180
+ }
@@ -7,18 +7,16 @@ class EventsController < ApplicationController
7
7
 
8
8
  def index
9
9
  index! do |format|
10
+ format.js {
11
+ events_with_start_and_end
12
+ }
13
+
10
14
  format.json {
11
- start_time = Time.at(params[:start].to_i)
12
- end_time = Time.at(params[:end].to_i)
13
- @activities =
14
- collection.
15
- joins(:activity_objects => :event).
16
- merge(Event.between(start_time, end_time))
15
+ events_with_start_and_end
17
16
 
18
17
  render :json =>
19
- @activities.
20
- map(&:direct_object).
21
- map{ |e| e.to_json(:start => start_time, :end => end_time) }.flatten.to_json
18
+ @events.
19
+ map{ |e| e.to_json(:start => @start_time, :end => @end_time) }.flatten.to_json
22
20
  }
23
21
  end
24
22
  end
@@ -37,4 +35,16 @@ class EventsController < ApplicationController
37
35
  :for => current_subject,
38
36
  :object_type => :Event)
39
37
  end
38
+
39
+ def events_with_start_and_end
40
+ @start_time = Time.at(params[:start].to_i)
41
+ @end_time = Time.at(params[:end].to_i)
42
+
43
+ @activities =
44
+ collection.
45
+ joins(:activity_objects => :event).
46
+ merge(Event.between(@start_time, @end_time))
47
+
48
+ @events = @activities.map(&:direct_object)
49
+ end
40
50
  end
@@ -40,6 +40,11 @@
40
40
  <div class="title">
41
41
  <%= link_to event.title, event %>
42
42
  </div>
43
+
44
+ <div class="description">
45
+ <%= simple_format auto_link(event.description) %>
46
+ </div>
47
+
43
48
  </div>
44
49
  <% end %>
45
50
 
@@ -26,34 +26,12 @@
26
26
  </table>
27
27
 
28
28
  <%= javascript_tag do %>
29
- var now = new Date();
30
- $('#sidebar_day_' + now.getDate() + '_' + (now.getMonth()+1) + '_' + now.getFullYear()).addClass('today');
31
- var re = new RegExp('sidebar_day_(..?)_(..?)_(..?.?.?)');
32
- $('#sidebar_calendar td').each(function(index, domEl){
33
- var m = re.exec(domEl.id);
34
- if(m == null) return;
35
- var d = new Date(m[3], (m[2]-1), m[1], 23, 59, 59);
36
- if(d < now) $(domEl).addClass('past');
37
- if(m[2] != (now.getMonth()+1) && d > now) $(domEl).addClass('next_month');
38
- });
39
- $.ajax({
40
- dataType: 'json',
41
- cache: false,
42
- url: "<%= escape_javascript polymorphic_path([@current_subject, Event.new]) %>",
43
- data: {
44
- start: <%= bow.to_i %>,
45
- end: <%= (bow + 28.days).to_i %>
46
- },
47
- success: function(events) {
48
- $.map(events, function(event) {
49
- var start = new Date(event.start); // This applies TZ
50
- var end = new Date(event.end);
51
- for(loopTime=start.getTime(); loopTime <= end.getTime(); loopTime+=86400000) {
52
- var d = new Date(loopTime);
53
- $('#sidebar_day_'+ d.getDate() + '_' + (d.getMonth()+1) + '_' + d.getFullYear()).addClass("busy");
54
- }
55
- })
56
- }
29
+ $(function(){
30
+ SocialStream.Calendar.init({
31
+ eventsPath: "<%= escape_javascript polymorphic_path([@current_subject, Event.new]) %>",
32
+ start: "<%= bow.to_i %>",
33
+ end: "<%= (bow + 28.days).to_i %>"
34
+ });
57
35
  });
58
36
  <% end %>
59
37
 
@@ -0,0 +1,3 @@
1
+ $("#tipsy-<%= params[:tipsy] %>").html("<%= escape_javascript render(@events) %>");
2
+
3
+ SocialStream.Event.index();
@@ -26,6 +26,6 @@
26
26
 
27
27
  <%= javascript_tag do %>
28
28
  $(function(){
29
- $('#room_name').Watermark("<%= escape_javascript t('room.watermark.name') %>");
29
+ $('#room_name').watermark("<%= escape_javascript t('room.watermark.name') %>");
30
30
  });
31
31
  <% end %>
@@ -1,7 +1,7 @@
1
1
  <% if @room.valid? %>
2
2
  $('#rooms').replaceWith("<%= escape_javascript render(:partial => 'index') %>");
3
3
  $('#room_name').val("");
4
- $('#room_name').Watermark("<%= escape_javascript t('room.watermark.name') %>");
4
+ $('#room_name').watermark("<%= escape_javascript t('room.watermark.name') %>");
5
5
  <% else %>
6
6
  $('#new_room').replaceWith("<%= escape_javascript render(:partial => 'form') %>");
7
7
  <% end %>
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Events
3
- VERSION = "0.9.1".freeze
3
+ VERSION = "0.9.2".freeze
4
4
  end
5
5
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.files = `git ls-files`.split("\n")
13
13
 
14
14
  # Gem dependencies
15
- s.add_runtime_dependency('social_stream-base', '~> 0.17.1')
15
+ s.add_runtime_dependency('social_stream-base', '~> 0.17.2')
16
16
  s.add_runtime_dependency('rails-scheduler', '~> 0.0.6')
17
17
  s.add_runtime_dependency('coffee-rails', '>= 3.1.0')
18
18
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_stream-events
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,22 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-03-07 00:00:00.000000000Z
13
+ date: 2012-03-12 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: social_stream-base
17
- requirement: &70584250 !ruby/object:Gem::Requirement
17
+ requirement: &86141060 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
21
21
  - !ruby/object:Gem::Version
22
- version: 0.17.1
22
+ version: 0.17.2
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70584250
25
+ version_requirements: *86141060
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rails-scheduler
28
- requirement: &70583230 !ruby/object:Gem::Requirement
28
+ requirement: &86140600 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 0.0.6
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70583230
36
+ version_requirements: *86140600
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: coffee-rails
39
- requirement: &70582000 !ruby/object:Gem::Requirement
39
+ requirement: &86140300 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 3.1.0
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *70582000
47
+ version_requirements: *86140300
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: sqlite3-ruby
50
- requirement: &70581250 !ruby/object:Gem::Requirement
50
+ requirement: &86140030 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,7 +55,7 @@ dependencies:
55
55
  version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *70581250
58
+ version_requirements: *86140030
59
59
  description: ! 'Social Stream is a Ruby on Rails engine providing your application
60
60
  with social networking features and activity streams.
61
61
 
@@ -72,9 +72,11 @@ files:
72
72
  - README.rdoc
73
73
  - Rakefile
74
74
  - app/assets/images/poster.png
75
- - app/assets/javascripts/events.js.coffee
76
75
  - app/assets/javascripts/social_stream-events.js
76
+ - app/assets/javascripts/social_stream.calendar.js.erb
77
+ - app/assets/javascripts/social_stream.event.js
77
78
  - app/assets/javascripts/social_stream.events.poster.js
79
+ - app/assets/javascripts/social_stream.events.tools.js.coffee
78
80
  - app/assets/stylesheets/events.css.scss
79
81
  - app/assets/stylesheets/social_stream-events.css
80
82
  - app/controllers/events_controller.rb
@@ -92,6 +94,7 @@ files:
92
94
  - app/views/events/destroy.js.erb
93
95
  - app/views/events/edit.js.erb
94
96
  - app/views/events/index.html.erb
97
+ - app/views/events/index.js.erb
95
98
  - app/views/rooms/_form.html.erb
96
99
  - app/views/rooms/_index.html.erb
97
100
  - app/views/rooms/_settings.html.erb