social_stream-base 0.16.4 → 0.17.0
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.
- data/app/assets/javascripts/activities.js.erb +0 -85
- data/app/assets/javascripts/social_stream.comments.js +63 -0
- data/app/assets/javascripts/social_stream.objects.js +23 -0
- data/app/assets/javascripts/social_stream.timeline.js +37 -10
- data/app/assets/javascripts/social_stream.wall.js.erb +135 -118
- data/app/assets/stylesheets/cheesecake.css.scss +6 -3
- data/app/models/activity_object.rb +18 -0
- data/app/models/activity_object_property.rb +5 -0
- data/app/views/activities/_new.html.erb +1 -1
- data/app/views/activities/_wall.html.erb +1 -1
- data/app/views/cheesecake/_cheesecake.html.erb +44 -10
- data/app/views/cheesecake/_index.html.erb +18 -130
- data/app/views/cheesecake/_sector_form.html.erb +176 -17
- data/app/views/comments/_new.html.erb +0 -14
- data/app/views/objects/_show.html.erb +6 -0
- data/app/views/toolbar/_home.html.erb +1 -1
- data/app/views/toolbar/_messages.html.erb +1 -1
- data/app/views/toolbar/_profile.html.erb +1 -1
- data/config/locales/es.yml +7 -0
- data/db/migrate/20120302215722_activity_object_properties.rb +24 -0
- data/lib/social_stream/ability/base.rb +2 -2
- data/lib/social_stream/base/version.rb +1 -1
- metadata +70 -66
@@ -46,7 +46,7 @@
|
|
46
46
|
padding: 0px;
|
47
47
|
margin: 0px;
|
48
48
|
overflow: hidden;
|
49
|
-
height:
|
49
|
+
height: 425px;
|
50
50
|
}
|
51
51
|
#contacts_filter {
|
52
52
|
width: 290px;
|
@@ -219,7 +219,7 @@
|
|
219
219
|
width: 24px;
|
220
220
|
height: 24px;
|
221
221
|
float: left;
|
222
|
-
padding: 2px 2px
|
222
|
+
padding: 2px 2px 2px 2px;
|
223
223
|
background-color: $fill-color;
|
224
224
|
}
|
225
225
|
#contacts_grid_selected .actor img {
|
@@ -274,6 +274,7 @@
|
|
274
274
|
}
|
275
275
|
#sector_form {
|
276
276
|
width: 300px;
|
277
|
+
height: 425px;
|
277
278
|
float: right;
|
278
279
|
}
|
279
280
|
#sector_form .title {
|
@@ -314,7 +315,8 @@
|
|
314
315
|
color: $main-color;
|
315
316
|
background: $auxiliar-color;
|
316
317
|
width: 260px;
|
317
|
-
height:
|
318
|
+
height: 14px;
|
319
|
+
line-height: 12px;
|
318
320
|
text-align: center;
|
319
321
|
font-size: 15px;
|
320
322
|
font-weight: bold;
|
@@ -328,6 +330,7 @@
|
|
328
330
|
text-align: center;
|
329
331
|
font-size: 11px;
|
330
332
|
padding: 5px 0px 5px 0px;
|
333
|
+
cursor: pointer;
|
331
334
|
}
|
332
335
|
#sector_form .subsector .title .edited_subsector_name {
|
333
336
|
font-size: 11px;
|
@@ -20,6 +20,19 @@ class ActivityObject < ActiveRecord::Base
|
|
20
20
|
has_many :activity_object_activities, :dependent => :destroy
|
21
21
|
has_many :activities, :through => :activity_object_activities
|
22
22
|
|
23
|
+
has_many :activity_object_properties,
|
24
|
+
:dependent => :destroy
|
25
|
+
has_many :object_properties,
|
26
|
+
:through => :activity_object_properties,
|
27
|
+
:source => :property
|
28
|
+
has_many :activity_object_holders,
|
29
|
+
:class_name => "ActivityObjectProperty",
|
30
|
+
:foreign_key => :property_id,
|
31
|
+
:dependent => :destroy
|
32
|
+
has_many :object_holders,
|
33
|
+
:through => :activity_object_holders,
|
34
|
+
:source => :activity_object
|
35
|
+
|
23
36
|
validates_presence_of :object_type
|
24
37
|
|
25
38
|
scope :authored_by, lambda { |subject|
|
@@ -42,4 +55,9 @@ class ActivityObject < ActiveRecord::Base
|
|
42
55
|
def acts_as_actor?
|
43
56
|
object_type == "Actor"
|
44
57
|
end
|
58
|
+
|
59
|
+
def object_holder_hash
|
60
|
+
|
61
|
+
end
|
62
|
+
|
45
63
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
$(function(){
|
2
|
+
//Cheesecake settings
|
2
3
|
var cheesecakeData = {
|
3
4
|
container: {
|
4
5
|
id: "contacts_cheesecake",
|
@@ -33,10 +34,14 @@ $(function(){
|
|
33
34
|
rMax : 200,
|
34
35
|
center: {x : 220, y : 220}
|
35
36
|
};
|
37
|
+
//Adding Cheesecake settings the sectors and users information from social_stream
|
36
38
|
cheesecakeData.sectors = <%= raw(current_subject.cheesecake_json) %>.sectors;
|
39
|
+
//Cheesecake is created
|
37
40
|
var cheese = new socialCheesecake.Cheesecake(cheesecakeData);
|
41
|
+
//We dont use synchronized callbacks for focus
|
38
42
|
cheese.syncSectorFocusCallbacks = false;
|
39
|
-
|
43
|
+
//Callback when a sector focusing begins
|
44
|
+
socialCheesecake.eventCallbackHandlers.onSectorFocusBegin = function(cheesecake,callback){
|
40
45
|
if((cheese.highlightedSector)&&(cheese.highlightedSector.auxiliar)){
|
41
46
|
$("#sector_editor").data("prepare")(cheese);
|
42
47
|
$("#sector_editor").data("show")();
|
@@ -44,7 +49,8 @@ $(function(){
|
|
44
49
|
$("#contacts_grid_available").fadeOut("fast", callback);
|
45
50
|
}
|
46
51
|
};
|
47
|
-
|
52
|
+
//Callback when a sector focusing ends
|
53
|
+
socialCheesecake.eventCallbackHandlers.onSectorFocusEnd = function(cheesecake){
|
48
54
|
if((cheese.highlightedSector)&&(cheese.highlightedSector.auxiliar)){
|
49
55
|
|
50
56
|
}else{
|
@@ -53,7 +59,8 @@ $(function(){
|
|
53
59
|
$("#edit_sector_button").fadeIn("fast");
|
54
60
|
}
|
55
61
|
};
|
56
|
-
|
62
|
+
//Callback when a sector unfocusing begins
|
63
|
+
socialCheesecake.eventCallbackHandlers.onSectorUnfocusBegin = function(cheesecake,callback){
|
57
64
|
if((cheese.highlightedSector)&&(cheese.highlightedSector.auxiliar)){
|
58
65
|
|
59
66
|
}else{
|
@@ -62,7 +69,8 @@ $(function(){
|
|
62
69
|
$("#edit_sector_button").fadeOut("fast");
|
63
70
|
}
|
64
71
|
};
|
65
|
-
|
72
|
+
//Callback when a sector unfocusing ends
|
73
|
+
socialCheesecake.eventCallbackHandlers.onSectorUnfocusEnd = function(cheesecake){
|
66
74
|
if((cheese.highlightedSector)&&(cheese.highlightedSector.auxiliar)){
|
67
75
|
|
68
76
|
}else{
|
@@ -73,14 +81,40 @@ $(function(){
|
|
73
81
|
$("#sector_editor").data("hide")();
|
74
82
|
}
|
75
83
|
};
|
76
|
-
|
77
|
-
|
84
|
+
//Callback when adding a new subsector begins
|
85
|
+
socialCheesecake.eventCallbackHandlers.onSubsectorAddedBegin = function(subsector){
|
86
|
+
var cheesecake = subsector.getCheesecake();
|
87
|
+
$("#edit_sector_button").off("click.edit");
|
88
|
+
$("#edit_sector_button").fadeOut("fast",function(){
|
89
|
+
$("#edit_sector_button").html("<%= escape_javascript image_tag "btn/cheese_close_edit.png" %>");
|
90
|
+
$("#edit_sector_button").fadeIn("fast");
|
91
|
+
});
|
92
|
+
$("#sector_editor").data("prepare")(cheesecake, subsector, true);
|
93
|
+
$("#sector_editor").data("show")(function(){
|
94
|
+
$("#edit_sector_button").on("click.close_edit", cheesecake, $("#edit_sector_button").data("close_edit_sector_click"));
|
95
|
+
});
|
96
|
+
$(".subsector .content").each(function(){
|
97
|
+
if($(this).is(':visible')){
|
98
|
+
$(this).stop().slideToggle(500);
|
99
|
+
}
|
100
|
+
});
|
101
|
+
$("#sector_editor").data("prepare")(cheesecake,subsector,false);
|
102
|
+
$(".add_subsector").each(function(){
|
103
|
+
$(this).off("click");
|
104
|
+
});
|
105
|
+
};
|
106
|
+
//Callback when adding a new subsector ends
|
107
|
+
socialCheesecake.eventCallbackHandlers.onSubsectorAddedEnd = function(subsector){
|
108
|
+
$("#sector_editor").data("prepare")(subsector.getCheesecake(),subsector,false);
|
78
109
|
};
|
79
110
|
$("#contacts_filter_input").keyup(function(){
|
80
111
|
cheese.filter($("#contacts_filter_input").val());
|
81
112
|
//TODO: Make users unfiltered visible again
|
82
113
|
});
|
83
|
-
|
114
|
+
//Callback when any change is made (added peopel, removed, edited or added secto, etc)
|
115
|
+
//This updates the changes hiddend field (sent when saving changes) and the detailed
|
116
|
+
//changes display
|
117
|
+
socialCheesecake.eventCallbackHandlers.onChange = function(cheesecake){
|
84
118
|
var initial = cheesecake.getInitialState();
|
85
119
|
var changes = cheesecake.getChanges();
|
86
120
|
if((changes.actors)&&(changes.actors.length==0)&&(changes.sectors)&&(changes.sectors.length==0)&&(changes.subsectors)&&(changes.subsectors.length==0)){
|
@@ -162,7 +196,8 @@ $(function(){
|
|
162
196
|
}
|
163
197
|
}
|
164
198
|
$("#contacts_changes_details").html(changes_html);
|
165
|
-
}
|
199
|
+
}
|
200
|
+
//Tipsy for displaying detailed changes
|
166
201
|
$('#contacts_changes_button').tipsy({
|
167
202
|
delayIn: 0,
|
168
203
|
delayOut: 0,
|
@@ -178,8 +213,7 @@ $(function(){
|
|
178
213
|
});
|
179
214
|
$("#contacts_save_changes").val(JSON.stringify(cheese.getChanges()));
|
180
215
|
$("#contacts_save_form").off("submit.disable");
|
181
|
-
$("#contacts_save_form").on("submit.disable",function(){
|
182
|
-
|
216
|
+
$("#contacts_save_form").on("submit.disable",function(){
|
183
217
|
if($(".contacts_changes_tipsy_menu").length != 0){
|
184
218
|
$("#contacts_changes_button").tipsy("hide");
|
185
219
|
}
|
@@ -24,16 +24,6 @@
|
|
24
24
|
<% end %>
|
25
25
|
</div>
|
26
26
|
</div>
|
27
|
-
<div id="contacts_changes_button" style="display:none;">
|
28
|
-
<%= t('cheesecake.changes.details') %> (<span id="contacts_changes_button_total">0</span>)
|
29
|
-
</div>
|
30
|
-
<div id="contacts_save" style="display:none;">
|
31
|
-
<form action="<%= update_cheesecake_path %>" method="get" data-remote="true" id="contacts_save_form">
|
32
|
-
<input type="submit" id="contacts_save_button" value="<%= t('cheesecake.changes.save') %>">
|
33
|
-
<input type="hidden" id="contacts_save_changes" name="contacts_save_changes">
|
34
|
-
</form>
|
35
|
-
</div>
|
36
|
-
<br class="clearfloat">
|
37
27
|
<div id="contacts_changes">
|
38
28
|
<div id="contacts_changes_title">
|
39
29
|
<%= t('cheesecake.changes.details') %>
|
@@ -43,16 +33,23 @@
|
|
43
33
|
</div>
|
44
34
|
</div>
|
45
35
|
</div>
|
36
|
+
<div id="contacts_changes_button" style="display:none;">
|
37
|
+
<%= t('cheesecake.changes.details') %> (<span id="contacts_changes_button_total">0</span>)
|
38
|
+
</div>
|
39
|
+
<div id="contacts_save" style="display:none;">
|
40
|
+
<form action="<%= update_cheesecake_path %>" method="get" data-remote="true" id="contacts_save_form">
|
41
|
+
<input type="submit" id="contacts_save_button" value="<%= t('cheesecake.changes.save') %>">
|
42
|
+
<input type="hidden" id="contacts_save_changes" name="contacts_save_changes">
|
43
|
+
</form>
|
44
|
+
</div>
|
45
|
+
<br class="clearfloat">
|
46
46
|
<%= javascript_tag do %>
|
47
|
+
//Tweak to remove right bar
|
47
48
|
$("#center_body").css("width","782px");
|
48
49
|
$("#center_body").css("max-width","782px");
|
49
50
|
$("#content").css("width","782px");
|
50
51
|
$("#contacts_filter_input").Watermark("<%= escape_javascript(I18n.t('search.name')) %>");
|
51
|
-
|
52
|
-
$("#contacts_grid").css("overflow-y","scroll");
|
53
|
-
$("#contacts_grid").scrollTo("+=308px", 800, {axis:'y'});
|
54
|
-
$("#contacts_grid_extra").css("opacity",0);
|
55
|
-
});
|
52
|
+
//When clicking an unselected actor
|
56
53
|
var unselected_actor_click = function(){
|
57
54
|
var clone = $(this).clone();
|
58
55
|
clone.attr("id",$(this).attr("id") + "_selected");
|
@@ -72,6 +69,7 @@
|
|
72
69
|
$(this).fadeIn("fast");
|
73
70
|
});
|
74
71
|
};
|
72
|
+
//When clicking an selected actor
|
75
73
|
var selected_actor_click = function(){
|
76
74
|
var clone = $("#" + $(this).attr("id") + "_selected");
|
77
75
|
$(this).fadeOut("fast",function(){
|
@@ -89,6 +87,7 @@
|
|
89
87
|
clone.remove();
|
90
88
|
});
|
91
89
|
};
|
90
|
+
//Unselecting all actors
|
92
91
|
$("#contacts_selector_clear").on("click",function(){
|
93
92
|
$("#contacts_grid_selected .actor").each(function(){
|
94
93
|
var evt = document.createEvent("MouseEvents");
|
@@ -98,6 +97,7 @@
|
|
98
97
|
});
|
99
98
|
});
|
100
99
|
$(".actor").on("click.unselected_actor",unselected_actor_click);
|
100
|
+
//Detailed changes display
|
101
101
|
$("#contacts_changes_button").click(function(){
|
102
102
|
if($(".contacts_changes_tipsy_menu").length != 0){
|
103
103
|
$("#contacts_changes_button").tipsy("hide");
|
@@ -112,120 +112,7 @@
|
|
112
112
|
});
|
113
113
|
}
|
114
114
|
});
|
115
|
-
|
116
|
-
$("#contacts_explorer").stop().animate({width: 0},500);
|
117
|
-
$("#sector_editor").stop().animate({width: 300},500, function(){
|
118
|
-
if(callback) callback();
|
119
|
-
});
|
120
|
-
});
|
121
|
-
$("#sector_editor").data("hide", function(callback){
|
122
|
-
$("#sector_editor").stop().animate({width: 0},500);
|
123
|
-
$("#contacts_explorer").stop().animate({width: 300},500, function(){
|
124
|
-
if(callback) callback();
|
125
|
-
});
|
126
|
-
});
|
127
|
-
$("#sector_editor").data("prepare", function(cheese, newSubsector){
|
128
|
-
var sector = cheese.getFocusedSector();
|
129
|
-
var newIndex = -1;
|
130
|
-
if(newSubsector){
|
131
|
-
newIndex = newSubsector.getIndex();
|
132
|
-
}
|
133
|
-
if(sector){
|
134
|
-
var subsector_count = sector.subsectors.length;
|
135
|
-
var maxReached = (subsector_count==4);
|
136
|
-
$("#form_sector_name").val(sector.label);
|
137
|
-
$("#edited_sector_name").html(sector.label);
|
138
|
-
$("#form_sector_name").off("keyup");
|
139
|
-
$("#form_sector_name").on("keyup",function(){
|
140
|
-
$("#edited_sector_name").html($("#form_sector_name").val());
|
141
|
-
sector.changeLabel($("#form_sector_name").val());
|
142
|
-
});
|
143
|
-
if(maxReached){
|
144
|
-
$(".add_subsector").each(function(){
|
145
|
-
if($(this).is(':visible')){
|
146
|
-
$(this).slideToggle();
|
147
|
-
}
|
148
|
-
})
|
149
|
-
}
|
150
|
-
for(var i = 3; i >= 0; i--){
|
151
|
-
(function(){
|
152
|
-
var subsector = sector.subsectors[i];
|
153
|
-
var index = i;
|
154
|
-
var recentlyCreated = (newIndex != -1)&&(newIndex == index);
|
155
|
-
if(subsector){
|
156
|
-
if(!$("#subsector_" + i).is(':visible')){
|
157
|
-
$("#subsector_" + i).slideToggle();
|
158
|
-
}
|
159
|
-
if(recentlyCreated || ((newIndex == -1)&&(i == 0))){
|
160
|
-
if(!$("#subsector_" + i).find(".content").is(':visible')){
|
161
|
-
$("#subsector_" + i).find(".content").slideToggle();
|
162
|
-
}
|
163
|
-
}else{
|
164
|
-
if($("#subsector_" + i).find(".content").is(':visible')){
|
165
|
-
$("#subsector_" + i).find(".content").slideToggle();
|
166
|
-
}
|
167
|
-
}
|
168
|
-
if(!maxReached){
|
169
|
-
if(sector.subsectors[i+1]==undefined){
|
170
|
-
$("#add_subsector_" + (i+1)).off("click");
|
171
|
-
if(!$("#add_subsector_" + (i+1)).is(':visible')){
|
172
|
-
$("#add_subsector_" + (i+1)).slideToggle();
|
173
|
-
}
|
174
|
-
$("#add_subsector_" + (i+1)).on("click",function(){
|
175
|
-
cheese.addNewSubsector(index+1);
|
176
|
-
$(".subsector .content").each(function(){
|
177
|
-
if($(this).is(':visible')){
|
178
|
-
$(this).slideToggle();
|
179
|
-
}
|
180
|
-
});
|
181
|
-
});
|
182
|
-
}
|
183
|
-
$("#add_subsector_" + i).off("click");
|
184
|
-
if(!$("#add_subsector_" + i).is(':visible')){
|
185
|
-
$("#add_subsector_" + i).slideToggle();
|
186
|
-
}
|
187
|
-
$("#add_subsector_" + i).on("click",function(){
|
188
|
-
cheese.addNewSubsector(index);
|
189
|
-
$(".subsector .content").each(function(){
|
190
|
-
if($(this).is(':visible')){
|
191
|
-
$(this).slideToggle();
|
192
|
-
}
|
193
|
-
});
|
194
|
-
});
|
195
|
-
}
|
196
|
-
$("#form_subsector_name_" + i).val(subsector.label);
|
197
|
-
$("#edited_subsector_name_" + i).html(subsector.label);
|
198
|
-
$("#form_subsector_name_" + i).off("keyup");
|
199
|
-
$("#form_subsector_name_" + i).on("keyup", [i,subsector],function(event){
|
200
|
-
$("#edited_subsector_name_" + event.data[0]).html($("#form_subsector_name_" + event.data[0]).val());
|
201
|
-
event.data[1].changeLabel($("#form_subsector_name_" + event.data[0]).val());
|
202
|
-
});
|
203
|
-
$("#subsector_" + i).find(".permissions_field .permission").each(function(){
|
204
|
-
var permission_field = $(this);
|
205
|
-
var update_state = function(){
|
206
|
-
var label_class = permission_field.attr("id").replace("form_", "edited_");
|
207
|
-
if(permission_field.is(":checked")){
|
208
|
-
$("." + label_class).removeClass("negative").addClass("positive");
|
209
|
-
$("." + label_class).find(".negative_message").hide();
|
210
|
-
$("." + label_class).find(".positive_message").show();
|
211
|
-
}else{
|
212
|
-
$("." + label_class).removeClass("positive").addClass("negative");
|
213
|
-
$("." + label_class).find(".positive_message").hide();
|
214
|
-
$("." + label_class).find(".negative_message").show();
|
215
|
-
}
|
216
|
-
}
|
217
|
-
update_state();
|
218
|
-
permission_field.on("change",update_state);
|
219
|
-
});
|
220
|
-
}else{
|
221
|
-
$("#subsector_" + i).hide();
|
222
|
-
$("#add_subsector_" + i).off("click");
|
223
|
-
$("#add_subsector_" + i).hide();
|
224
|
-
}
|
225
|
-
})();
|
226
|
-
}
|
227
|
-
}
|
228
|
-
});
|
115
|
+
//Opening editing sector form
|
229
116
|
$("#edit_sector_button").data("edit_sector_click", function(event){
|
230
117
|
var cheese = event.data;
|
231
118
|
$("#edit_sector_button").off("click.edit");
|
@@ -233,11 +120,12 @@
|
|
233
120
|
$("#edit_sector_button").html("<%= escape_javascript image_tag "btn/cheese_close_edit.png" %>");
|
234
121
|
$("#edit_sector_button").fadeIn("fast");
|
235
122
|
});
|
236
|
-
$("#sector_editor").data("prepare")(cheese);
|
123
|
+
$("#sector_editor").data("prepare")(cheese, null, false);
|
237
124
|
$("#sector_editor").data("show")(function(){
|
238
125
|
$("#edit_sector_button").on("click.close_edit", cheese, $("#edit_sector_button").data("close_edit_sector_click"));
|
239
126
|
});
|
240
127
|
});
|
128
|
+
//Closing editing sector form
|
241
129
|
$("#edit_sector_button").data("close_edit_sector_click", function(event){
|
242
130
|
var cheese = event.data;
|
243
131
|
$("#edit_sector_button").off("click.close_edit");
|
@@ -68,7 +68,7 @@
|
|
68
68
|
</div>
|
69
69
|
</div>
|
70
70
|
<div class="form_row less_padding">
|
71
|
-
<div class="add_subsector" id="add_subsector_<%= i %>">
|
71
|
+
<div class="add_subsector" id="add_subsector_<%= i %>" style="display:none;">
|
72
72
|
+
|
73
73
|
</div>
|
74
74
|
</div>
|
@@ -78,6 +78,7 @@
|
|
78
78
|
|
79
79
|
<%= javascript_tag do %>
|
80
80
|
$(function(){
|
81
|
+
//Toggling between subsectors forms
|
81
82
|
$(".subsector .title").off("click.toggle");
|
82
83
|
$(".subsector .title").on("click.toggle",function(){
|
83
84
|
if(!$(this).parent().find(".content").is(':visible')){
|
@@ -89,22 +90,180 @@
|
|
89
90
|
$(this).parent().find(".content").slideToggle();
|
90
91
|
}
|
91
92
|
})
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
93
|
+
//Tipsy for permission fields
|
94
|
+
$(".permissions_field").each(function(){
|
95
|
+
$(this).tipsy({
|
96
|
+
delayIn: 500,
|
97
|
+
delayOut: 200,
|
98
|
+
gravity: 'e',
|
99
|
+
offset: 100,
|
100
|
+
opacity: 1,
|
101
|
+
className: 'permissions_explanation_tipsy_menu',
|
102
|
+
html: true,
|
103
|
+
hoverable: true,
|
104
|
+
title: function(){
|
105
|
+
var html = $(this).parent().find('.permissions_explanation').html();
|
106
|
+
var relation = $(this).parent().parent().find('.form_subsector_name').val();
|
107
|
+
return html.replace(/%RELATION_NAME%/g, relation);
|
108
|
+
}
|
109
|
+
});
|
110
|
+
});
|
111
|
+
//Showing form
|
112
|
+
$("#sector_editor").data("show", function(callback){
|
113
|
+
$("#contacts_explorer").stop().animate({width: 0},500);
|
114
|
+
$("#sector_editor").stop().animate({width: 300},500, function(){
|
115
|
+
if(callback) callback();
|
116
|
+
});
|
117
|
+
});
|
118
|
+
//Hidding form
|
119
|
+
$("#sector_editor").data("hide", function(callback){
|
120
|
+
$("#sector_editor").stop().animate({width: 0},500);
|
121
|
+
$("#contacts_explorer").stop().animate({width: 300},500, function(){
|
122
|
+
if(callback) callback();
|
123
|
+
});
|
124
|
+
});
|
125
|
+
//Preparing form
|
126
|
+
$("#sector_editor").data("prepare", function(cheese, newSubsector, noAdding){
|
127
|
+
var sector = cheese.getFocusedSector();
|
128
|
+
var newIndex = -1;
|
129
|
+
var defaultPermissions = "true,true,true,false,false";
|
130
|
+
if(newSubsector != undefined){
|
131
|
+
//newSubsector is used when we prepare the form just after creating a subsector
|
132
|
+
newIndex = newSubsector.getIndex();
|
133
|
+
}
|
134
|
+
if(noAdding == undefined){
|
135
|
+
//noAdding tweat when creating a subsector
|
136
|
+
noAdding = false;
|
107
137
|
}
|
138
|
+
if(sector){
|
139
|
+
var subsector_count = sector.subsectors.length;
|
140
|
+
var maxReached = (subsector_count==4);
|
141
|
+
$("#form_sector_name").val(sector.label);
|
142
|
+
$("#edited_sector_name").html(sector.label);
|
143
|
+
$("#form_sector_name").off("keyup");
|
144
|
+
$("#form_sector_name").on("keyup",function(){
|
145
|
+
$("#edited_sector_name").html($("#form_sector_name").val());
|
146
|
+
sector.changeLabel($("#form_sector_name").val());
|
147
|
+
});
|
148
|
+
if(maxReached){
|
149
|
+
$(".add_subsector").each(function(){
|
150
|
+
/*if($(this).is(':visible')){
|
151
|
+
$(this).slideToggle();
|
152
|
+
}*/
|
153
|
+
$(this).hide();
|
154
|
+
})
|
155
|
+
}
|
156
|
+
for(var i = 3; i >= 0; i--){
|
157
|
+
(function(){
|
158
|
+
var subsector = sector.subsectors[i];
|
159
|
+
var index = i;
|
160
|
+
var recentlyCreated = (newIndex != -1)&&(newIndex == index);
|
161
|
+
if(subsector){
|
162
|
+
if(noAdding && (newIndex != -1)){
|
163
|
+
//Tweat to move permissions fields when a subsector is created below
|
164
|
+
if(i > newIndex){
|
165
|
+
$("#subsector_" + i).find(".permissions_field").data("fromString")($("#subsector_" + (i-1)).find(".permissions_field").data("toString")());
|
166
|
+
}else if(i == newIndex){
|
167
|
+
$("#subsector_" + i).find(".permissions_field").data("fromString")(defaultPermissions);
|
168
|
+
}
|
169
|
+
}
|
170
|
+
//Sliding content with different times as Cheesecake animation durations change
|
171
|
+
if(!noAdding && (recentlyCreated || ((newIndex == -1)&&(i == 0)))){
|
172
|
+
if(!$("#subsector_" + i).find(".content").is(':visible')){
|
173
|
+
var time = 1000;
|
174
|
+
if(subsector_count==2){
|
175
|
+
time = 2200;
|
176
|
+
}else if(subsector_count==3){
|
177
|
+
time = 1000;
|
178
|
+
}else if(subsector_count==4){
|
179
|
+
time = 650;
|
180
|
+
}
|
181
|
+
$("#subsector_" + i).find(".content").stop().slideToggle(time);
|
182
|
+
}
|
183
|
+
}else{
|
184
|
+
$("#subsector_" + i).find(".content").hide();
|
185
|
+
}
|
186
|
+
$("#subsector_" + i).stop().show();
|
187
|
+
//Adding buttons are only shonw if the maximum was not reached
|
188
|
+
if(!maxReached){
|
189
|
+
if(sector.subsectors[i+1]==undefined){
|
190
|
+
$("#add_subsector_" + (i+1)).off("click");
|
191
|
+
if(!$("#add_subsector_" + (i+1)).is(':visible')){
|
192
|
+
$("#add_subsector_" + (i+1)).stop().slideToggle();
|
193
|
+
}
|
194
|
+
if(!noAdding){
|
195
|
+
$("#add_subsector_" + (i+1)).on("click",function(){
|
196
|
+
$("#add_subsector_" + (index+1)).off("click");
|
197
|
+
cheese.addNewSubsector(index+1);
|
198
|
+
});
|
199
|
+
}
|
200
|
+
}
|
201
|
+
$("#add_subsector_" + i).off("click");
|
202
|
+
if(!$("#add_subsector_" + i).is(':visible')){
|
203
|
+
$("#add_subsector_" + i).stop().slideToggle();
|
204
|
+
}
|
205
|
+
if(!noAdding){
|
206
|
+
$("#add_subsector_" + i).on("click",function(){
|
207
|
+
$("#add_subsector_" + index).off("click");
|
208
|
+
cheese.addNewSubsector(index);
|
209
|
+
});
|
210
|
+
}
|
211
|
+
}
|
212
|
+
$("#form_subsector_name_" + i).val(subsector.label);
|
213
|
+
$("#edited_subsector_name_" + i).html(subsector.label);
|
214
|
+
$("#form_subsector_name_" + i).off("keyup");
|
215
|
+
$("#form_subsector_name_" + i).on("keyup", [i,subsector],function(event){
|
216
|
+
$("#edited_subsector_name_" + event.data[0]).html($("#form_subsector_name_" + event.data[0]).val());
|
217
|
+
event.data[1].changeLabel($("#form_subsector_name_" + event.data[0]).val());
|
218
|
+
});
|
219
|
+
$("#subsector_" + i).find(".permissions_field .permission").each(function(){
|
220
|
+
var permission_field = $(this);
|
221
|
+
var update_state = function(){
|
222
|
+
var label_class = permission_field.attr("id").replace("form_", "edited_");
|
223
|
+
if(permission_field.is(":checked")){
|
224
|
+
$("." + label_class).removeClass("negative").addClass("positive");
|
225
|
+
$("." + label_class).find(".negative_message").hide();
|
226
|
+
$("." + label_class).find(".positive_message").show();
|
227
|
+
}else{
|
228
|
+
$("." + label_class).find(".positive_message").hide();
|
229
|
+
$("." + label_class).find(".negative_message").show();
|
230
|
+
}
|
231
|
+
}
|
232
|
+
update_state();
|
233
|
+
permission_field.on("change",update_state);
|
234
|
+
});
|
235
|
+
}else{
|
236
|
+
$("#subsector_" + i).hide();
|
237
|
+
//$("#add_subsector_" + i).off("click");
|
238
|
+
//$("#add_subsector_" + i).hide();
|
239
|
+
}
|
240
|
+
})();
|
241
|
+
}
|
242
|
+
}
|
243
|
+
});
|
244
|
+
// toString and fromString methods for permissions fields
|
245
|
+
// to move permissions fileds from one sector to another
|
246
|
+
$(".permissions_field").each(function(){
|
247
|
+
var permissionsField = $(this)
|
248
|
+
permissionsField.data("toString", function(){
|
249
|
+
var permissions = []
|
250
|
+
permissionsField.find("input").each(function(){
|
251
|
+
permissions.push($(this).is(":checked"));
|
252
|
+
});
|
253
|
+
return permissions.toString();
|
254
|
+
});
|
108
255
|
});
|
109
|
-
|
256
|
+
$(".permissions_field").each(function(){
|
257
|
+
var permissionsField = $(this)
|
258
|
+
permissionsField.data("fromString", function(values){
|
259
|
+
var permissions = values.split(",");
|
260
|
+
for(var i in permissions){
|
261
|
+
permissions[i] = (permissions[i] === "true");
|
262
|
+
permissionsField.find("input").eq(i).attr('checked', permissions[i]);
|
263
|
+
}
|
264
|
+
console.log(permissions);
|
265
|
+
});
|
266
|
+
});
|
267
|
+
});
|
268
|
+
|
110
269
|
<% end %>
|