Compare commits

...

2 Commits

Author SHA1 Message Date
邱博亞 e2ab04b95c Fix z-index bug. 2022-12-21 11:15:29 +08:00
邱博亞 6f2e378030 Replace html to text in title and note fields. 2022-12-21 11:15:02 +08:00
5 changed files with 119 additions and 5 deletions

View File

@ -136,6 +136,8 @@
}
#view_holder {
position: relative;
z-index: 0; //z-index can be set when position other than static.
clear: both;
}
@ -697,9 +699,12 @@
& > .modal-content {
h3 {
margin: 0;
white-space: pre;
}
& > .modal-body {
white-space: pre;
}
}
.event_summary {
margin-right: -15px;
margin-bottom: 15px;
@ -755,4 +760,10 @@
-webkit-box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}
}
.fc-event-title{
white-space: pre;
}
div[contentEditable=true]{
white-space: pre;
}

View File

@ -479,6 +479,7 @@ a.fc-event:hover {
/* ---------------------------------------------------------------------------------------------------- */
.fc-event .fc-event-main {
position: relative;
z-index: 2;
}
/* dragging */
/* ---------------------------------------------------------------------------------------------------- */
@ -707,7 +708,7 @@ A HORIZONTAL event
display: table; }
.fc .fc-daygrid-body { /* a <div> that wraps the table */
position: relative;
/* container inner z-index's because <tr>s can't do it */
z-index: 1; /* container inner z-index's because <tr>s can't do it */
}
.fc .fc-daygrid-day.fc-day-today {
background-color: rgba(255, 220, 40, 0.15);
@ -736,6 +737,7 @@ A HORIZONTAL event
}
.fc .fc-daygrid-day-number {
position: relative;
z-index: 4;
padding: 4px;
}
.fc {
@ -798,9 +800,11 @@ A HORIZONTAL event
}
.fc .fc-daygrid-event {
z-index: 6;
margin-top: 1px;
}
.fc .fc-daygrid-event.fc-event-mirror {
z-index: 7;
}
.fc {
@ -817,6 +821,7 @@ A HORIZONTAL event
display: table; }
.fc .fc-daygrid-more-link {
position: relative;
z-index: 4;
cursor: pointer;
}
.fc {
@ -826,6 +831,7 @@ A HORIZONTAL event
}
.fc .fc-daygrid-week-number {
position: absolute;
z-index: 5;
top: 0;
padding: 2px;
min-width: 1.5em;
@ -1042,14 +1048,14 @@ A VERTICAL event
bottom: calc(var(--fc-event-resizer-dot-total-width, 8px) / -2);
}
.fc .fc-timegrid .fc-daygrid-body { /* the all-day daygrid within the timegrid view */
/* put above the timegrid-body so that more-popover is above everything. TODO: better solution */
z-index: 2; /* put above the timegrid-body so that more-popover is above everything. TODO: better solution */
}
.fc .fc-timegrid-divider {
padding: 0 0 2px; /* browsers get confused when you set height. use padding instead */
}
.fc .fc-timegrid-body {
position: relative;
/* scope the z-indexes of slots and cols */
z-index: 1; /* scope the z-indexes of slots and cols */
min-height: 100%; /* fill height always, even when slat table doesn't grow */
}
.fc .fc-timegrid-axis-chunk { /* for advanced ScrollGrid */
@ -1062,6 +1068,7 @@ A VERTICAL event
}
.fc .fc-timegrid-slots {
position: relative;
z-index: 1;
}
.fc .fc-timegrid-slot { /* a <td> */
height: 1.5em;

View File

@ -356,4 +356,52 @@ class Event
recurring = recurring.concat(events)
recurring
end
def self.convertToText(str)
# Ensure string.
value = str.to_s
# Convert encoding.
value = value.gsub(/&nbsp;/i, ' ')
value = value.gsub(/&amp;/i, '&')
# Replace `<br>`.
value = value.gsub(/<br>/i, "\n")
# Replace `<div>` (from Chrome).
value = value.gsub(/<div>/i, "\n")
# Replace `<p>` (from IE).
value = value.gsub(/<p>/i, "\n")
# Remove extra tags.
value = value.gsub(/<(.*?)>/, '')
# Trim each line.
value = value.split("\n").map{|line| line.strip}.join("\n")
# No more than 2x newline, per "paragraph".
value = value.gsub(/\n\n+/, "\n\n")
# Clean up spaces.
value = value.gsub(/[ ]+/, ' ')
value = value.strip
# Expose string.
return value
end
def self.fix_all_white_spaces
self.all.each do |event|
new_attrs = {}
localize_fields = ["title", "note"]
localize_fields.each do |f|
f_trans = "#{f}_translations"
new_attrs[f] = self.convertToText(event[f])
new_attrs[f_trans] = {}
event[f_trans].each do |l, s|
new_attrs[f_trans][l] = self.convertToText(s)
end
end
Event.where(:id=>event.id).update_all(new_attrs)
end
end
end

View File

@ -226,12 +226,50 @@
return indexed_array;
}
function convertToText(str){
// Ensure string.
var value = String(str);
// Convert encoding.
value = value.replace(/&nbsp;/gi, ' ');
value = value.replace(/&amp;/gi, '&');
// Replace `<br>`.
value = value.replace(/<br>/gi, '\n');
// Replace `<div>` (from Chrome).
value = value.replace(/<div>/gi, '\n');
// Replace `<p>` (from IE).
value = value.replace(/<p>/gi, '\n');
// Remove extra tags.
value = value.replace(/<(.*?)>/g, '');
// Trim each line.
value = value
.split('\n')
.map((line = '') => {
return line.trim();
})
.join('\n');
// No more than 2x newline, per "paragraph".
value = value.replace(/\n\n+/g, '\n\n');
// Clean up spaces.
value = value.replace(/[ ]+/g, ' ');
value = value.trim();
// Expose string.
return value;
};
function before_submit(ele){
var self = $(ele).parents('form')
var content_editables = self.find('*[contenteditable="true"]');
for (var i=0,length = content_editables.length; i<length; i++){
var tp1 = content_editables.eq(i);
tp1.siblings('input[type="hidden"]').val(tp1.html());
tp1.siblings('input[type="hidden"]').val(convertToText(tp1.html()));
}
self.submit();
}

View File

@ -7,6 +7,7 @@ Rails.application.routes.draw do
update_flag = s.respond_to?(:tmp_flags)
need_update = !update_flag || !(s.tmp_flags.include?('cf2'))
need_update2 = !update_flag || !(s.tmp_flags.include?('cf3'))
need_update3 = !update_flag || !(s.tmp_flags.include?('cf4'))
calendar_setting = CalendarSetting.first
calendar_setting = CalendarSetting.create if calendar_setting.nil?
if need_update
@ -48,6 +49,15 @@ Rails.application.routes.draw do
end
puts "Calendar fix!"
end
if need_update3
Event.fix_all_white_spaces
if update_flag
s = Site.first
s.tmp_flags << 'cf4'
s.save
end
puts "Calendar fix!"
end
end
end
scope "(:locale)", locale: Regexp.new(locales.join("|")) do