Pick default colors for the calendar based on start time
This commit is contained in:
parent
13f62cc118
commit
e1d5126e8b
|
@ -1042,7 +1042,7 @@ SQL;
|
||||||
if (!empty($show["background_color"])) {
|
if (!empty($show["background_color"])) {
|
||||||
$event["color"] = "#" . $show["background_color"];
|
$event["color"] = "#" . $show["background_color"];
|
||||||
} else {
|
} else {
|
||||||
$event["color"] = "#" . DEFAULT_SHOW_COLOR;
|
$event["color"] = "#" . self::getDefaultBackgroundColor($startsDT);//DEFAULT_SHOW_COLOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($options as $key => $value) {
|
foreach ($options as $key => $value) {
|
||||||
|
@ -1054,6 +1054,22 @@ SQL;
|
||||||
return $events;
|
return $events;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get a palettized colour for the show. */
|
||||||
|
private static function getDefaultBackgroundColor($date) {
|
||||||
|
|
||||||
|
$palette = [['42d5a1', '56bd99', '65ab93', '7b938b'],
|
||||||
|
['42a4d5', '569bbd', '6594ab', '7b8b93'],
|
||||||
|
['4264d5', '566fbd', '6576ab', '7b8193']];
|
||||||
|
|
||||||
|
//$hashValue = (md5($date->format('d'))[0] % $cols) + ((intval($date->format('h'))/24) % $rows);
|
||||||
|
$row = intval($date->format('d')) % sizeof($palette);
|
||||||
|
$foo = $date->format('H');
|
||||||
|
$col = intval(intval($date->format('H'))/24.0 * sizeof($palette[0]));
|
||||||
|
//$color = $palette[$hashValue % sizeof($palette)];
|
||||||
|
$color = $palette[$row][$col];
|
||||||
|
return $color;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the percentage of a show scheduled given the start and end times in date/time format
|
* Calculates the percentage of a show scheduled given the start and end times in date/time format
|
||||||
* and the time_filled as the total time the schow is scheduled for in time format.
|
* and the time_filled as the total time the schow is scheduled for in time format.
|
||||||
|
|
|
@ -606,7 +606,7 @@ table.fc-border-separate {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
opacity: .3;
|
opacity: 0.3;
|
||||||
filter: alpha(opacity=30);
|
filter: alpha(opacity=30);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,10 +75,17 @@ function setupStartTimeWidgets() {
|
||||||
$('#add_show_start_date').removeProp('disabled');
|
$('#add_show_start_date').removeProp('disabled');
|
||||||
$('#add_show_start_time').removeProp('disabled');
|
$('#add_show_start_time').removeProp('disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function calculateShowColor() {
|
||||||
|
var bgColorEle = $("#add_show_background_color");
|
||||||
|
var textColorEle = $("#add_show_color");
|
||||||
|
var colorCode = stringToColor($('#add_show_start_time').val());//$(this).val());
|
||||||
|
//bgColorEle.val(colorCode);
|
||||||
|
//textColorEle.val(getContrastYIQ(colorCode));
|
||||||
|
}
|
||||||
|
|
||||||
//$el is DOM element #add-show-form
|
//$el is DOM element #add-show-form
|
||||||
//form is the new form contents to append to $el
|
//form is the new form contents to append to $el
|
||||||
function redrawAddShowForm($el, form) {
|
function redrawAddShowForm($el, form) {
|
||||||
|
@ -226,7 +233,10 @@ function intToRGB(i){
|
||||||
|
|
||||||
function stringToColor(s)
|
function stringToColor(s)
|
||||||
{
|
{
|
||||||
var palette = ['d56f42', 'aad542', '7242d5', '42d563', 'd542be'];
|
var palette = ['42d5a1', '56bd99', '65ab93', '7b938b',
|
||||||
|
'42a4d5', '569bbd', '6594ab', '7b8b93',
|
||||||
|
'4264d5', '566fbd', '6576ab', '7b8193'];
|
||||||
|
//var palette = ['d56f42', 'aad542', '7242d5', '42d563', 'd542be'];
|
||||||
return palette[Math.abs(hashCode(s)) % palette.length];
|
return palette[Math.abs(hashCode(s)) % palette.length];
|
||||||
//return intToRGB(hashCode(s));
|
//return intToRGB(hashCode(s));
|
||||||
}
|
}
|
||||||
|
@ -943,13 +953,12 @@ function setAddShowEvents(form) {
|
||||||
|
|
||||||
// Since Zend's setAttrib won't apply through the wrapper, set accept=image/* here
|
// Since Zend's setAttrib won't apply through the wrapper, set accept=image/* here
|
||||||
$("#add_show_logo").prop("accept", "image/*");
|
$("#add_show_logo").prop("accept", "image/*");
|
||||||
var bgColorEle = $("#add_show_background_color");
|
|
||||||
var textColorEle = $("#add_show_color");
|
//$('#add_show_name').bind('input', 'change', function(){
|
||||||
$('#add_show_name').bind('input', 'change', function(){
|
$('#add_show_start_time').bind('input', 'change', function(){
|
||||||
var colorCode = stringToColor($(this).val());
|
calculateShowColor();
|
||||||
bgColorEle.val(colorCode);
|
|
||||||
textColorEle.val(getContrastYIQ(colorCode));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function showErrorSections() {
|
function showErrorSections() {
|
||||||
|
|
|
@ -112,6 +112,7 @@ function dayClick(date, allDay, jsEvent, view){
|
||||||
$("#add_show_start_time").val(startTime_string)
|
$("#add_show_start_time").val(startTime_string)
|
||||||
$("#add_show_end_time").val(endTimeString)
|
$("#add_show_end_time").val(endTimeString)
|
||||||
}
|
}
|
||||||
|
calculateShowColor();
|
||||||
$("#schedule-show-when").show();
|
$("#schedule-show-when").show();
|
||||||
|
|
||||||
openAddShowForm();
|
openAddShowForm();
|
||||||
|
|
Loading…
Reference in New Issue