File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -705,6 +705,8 @@ var open_event_edit_dialog = function open_event_edit_dialog(event) {
705
705
706
706
// Initialize color picker
707
707
$ ( 'input.pick_color' ) . colorPicker ( ) ;
708
+ // Show the reset button from the color picker
709
+ $ ( '#color_selector' ) . find ( '#reset_color' ) . show ( ) ;
708
710
709
711
if ( is_new ) {
710
712
// Initialize color picker with the calendar color for new events
@@ -732,6 +734,7 @@ var open_event_edit_dialog = function open_event_edit_dialog(event) {
732
734
return calendar . calendar === selectedCalendarId ;
733
735
} ) ;
734
736
if ( selectedCalendar ) {
737
+ $ . fn . colorPicker . calendarColor = selectedCalendar . color ; // for reset button
735
738
$ ( 'input.pick_color' ) . next ( '.color_picker' ) . css ( 'background-color' , $ . fn . colorPicker . calendarColor ) ;
736
739
}
737
740
} ) ;
@@ -982,6 +985,8 @@ var calendar_modify_dialog = function calendar_modify_dialog(calendar_obj) {
982
985
width : 500 ,
983
986
pre_func : function ( ) {
984
987
$ ( 'input.pick_color' ) . colorPicker ( ) ;
988
+ // Hide the reset button from the color picker
989
+ $ ( '#color_selector' ) . find ( '#reset_color' ) . hide ( ) ;
985
990
986
991
if ( AgenDAVConf . enable_calendar_sharing === true && data . is_shared !== true ) {
987
992
shares_manager ( ) ;
Original file line number Diff line number Diff line change 65
65
if ( event . keyCode == 27 ) { toggleSelector ( ) }
66
66
} ) ;
67
67
68
- $ ( "<div id='color_custom'></div>" ) . append ( color_field ) . appendTo ( selector ) ;
68
+ //add reset button
69
+ reset_button = $ ( "<button type='button' id='reset_color'>Reset color</button>" ) ;
70
+ reset_button . bind ( "mouseover" , function ( e ) {
71
+ var defaultColor = $ . fn . colorPicker . calendarColor || '#FFFFFF' ;
72
+ $ ( "input#color_value" ) . val ( defaultColor ) ;
73
+ } ) ;
74
+ reset_button . bind ( "mouseout" , function ( e ) {
75
+ var currentColor = $ ( selectorOwner ) . prev ( "input" ) . val ( ) ;
76
+ $ ( "input#color_value" ) . val ( currentColor ) ;
77
+ } ) ;
78
+ reset_button . bind ( "click" , function ( e ) { resetColor ( ) ; } ) ;
79
+
80
+ $ ( "<div id='color_custom'></div>" ) . append ( color_field ) . append ( reset_button ) . appendTo ( selector ) ;
69
81
70
82
$ ( "body" ) . append ( selector ) ;
71
83
selector . hide ( ) ;
120
132
hideSelector ( ) ;
121
133
} ;
122
134
135
+ resetColor = function ( ) {
136
+ var defaultColor = $ . fn . colorPicker . calendarColor || '#FFFFFF' ; // Use the calendar color or fallback to white
137
+ $ ( selectorOwner ) . prev ( "input" ) . val ( null ) . change ( ) ;
138
+ $ ( selectorOwner ) . css ( "background-color" , defaultColor ) ;
139
+
140
+ // Update the color value input field
141
+ $ ( "input#color_value" ) . val ( defaultColor ) ;
142
+
143
+ //close the selector
144
+ hideSelector ( ) ;
145
+ } ;
146
+
123
147
//public methods
124
148
$ . fn . colorPicker . addColors = function ( colorArray ) {
125
149
$ . fn . colorPicker . defaultColors = $ . fn . colorPicker . defaultColors . concat ( colorArray ) ;
You can’t perform that action at this time.
0 commit comments