Skip to content

Add rfc7986 color support for VEVENT objects #327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add support for resetting color
  • Loading branch information
ghsioux committed Feb 19, 2025
commit 656bdc474cf3494298c819ae2dbb825155cf9681
5 changes: 5 additions & 0 deletions assets/js/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,8 @@ var open_event_edit_dialog = function open_event_edit_dialog(event) {

// Initialize color picker
$('input.pick_color').colorPicker();
// Show the reset button from the color picker
$('#color_selector').find('#reset_color').show();

if (is_new) {
// Initialize color picker with the calendar color for new events
Expand Down Expand Up @@ -732,6 +734,7 @@ var open_event_edit_dialog = function open_event_edit_dialog(event) {
return calendar.calendar === selectedCalendarId;
});
if (selectedCalendar) {
$.fn.colorPicker.calendarColor = selectedCalendar.color; // for reset button
$('input.pick_color').next('.color_picker').css('background-color', $.fn.colorPicker.calendarColor);
}
});
Expand Down Expand Up @@ -982,6 +985,8 @@ var calendar_modify_dialog = function calendar_modify_dialog(calendar_obj) {
width: 500,
pre_func: function() {
$('input.pick_color').colorPicker();
// Hide the reset button from the color picker
$('#color_selector').find('#reset_color').hide();

if (AgenDAVConf.enable_calendar_sharing === true && data.is_shared !== true) {
shares_manager();
Expand Down
26 changes: 25 additions & 1 deletion assets/js/other/jquery.colorPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,19 @@
if(event.keyCode == 27) {toggleSelector()}
});

$("<div id='color_custom'></div>").append(color_field).appendTo(selector);
//add reset button
reset_button = $("<button type='button' id='reset_color'>Reset color</button>");
reset_button.bind("mouseover", function(e){
var defaultColor = $.fn.colorPicker.calendarColor || '#FFFFFF';
$("input#color_value").val(defaultColor);
});
reset_button.bind("mouseout", function(e){
var currentColor = $(selectorOwner).prev("input").val();
$("input#color_value").val(currentColor);
});
reset_button.bind("click", function(e){ resetColor(); });

$("<div id='color_custom'></div>").append(color_field).append(reset_button).appendTo(selector);

$("body").append(selector);
selector.hide();
Expand Down Expand Up @@ -120,6 +132,18 @@
hideSelector();
};

resetColor = function(){
var defaultColor = $.fn.colorPicker.calendarColor || '#FFFFFF'; // Use the calendar color or fallback to white
$(selectorOwner).prev("input").val(null).change();
$(selectorOwner).css("background-color", defaultColor);

// Update the color value input field
$("input#color_value").val(defaultColor);

//close the selector
hideSelector();
};

//public methods
$.fn.colorPicker.addColors = function(colorArray){
$.fn.colorPicker.defaultColors = $.fn.colorPicker.defaultColors.concat(colorArray);
Expand Down