Plugin Directory

Changeset 1943949


Ignore:
Timestamp:
09/19/2018 09:27:22 PM (8 years ago)
Author:
martindrapeau
Message:

Ensure text color of events on the calendar is black on bright colored events

Location:
amilia-store/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • amilia-store/trunk/amilia-store-calendar.php

    r1943878 r1943949  
    137137            return removeColorFromActivityName(event.ExtraInformation) || event.ActivityName;
    138138        }
     139        function invertColor(hex) {
     140            if (hex.indexOf('#') === 0) hex = hex.slice(1);
     141            if (hex.length === 3) hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
     142            if (hex.length !== 6) return '#FFFFFF';
     143            var r = parseInt(hex.slice(0, 2), 16),
     144                g = parseInt(hex.slice(2, 4), 16),
     145                b = parseInt(hex.slice(4, 6), 16);
     146            return (r * 0.299 + g * 0.587 + b * 0.114) > 186 ? '#000000' : '#FFFFFF';
     147        }
    139148
    140149        function render() {
     
    192201                            var event = data[i];
    193202                            event.color = getColorFromActivityName(event.ExtraInformation) || '#46aaf8';
     203                            event.textColor = invertColor(event.color);
    194204                            event.title = getDisplayNameFromEvent(event);
    195205                        }
  • amilia-store/trunk/amilia-store.php

    r1943878 r1943949  
    66Author: Martin Drapeau <martin.drapeau@amilia.com>
    77Copyright: 2014-2018 Amilia
    8 Version: 2.6.4
     8Version: 2.6.5
    99Author URI: http://www.amilia.com/
    1010License: Apache License 2.0
Note: See TracChangeset for help on using the changeset viewer.