diff --git a/app/coffeescripts/calendar/Calendar.coffee b/app/coffeescripts/calendar/Calendar.coffee index 3c160809324..d4ec866d10e 100644 --- a/app/coffeescripts/calendar/Calendar.coffee +++ b/app/coffeescripts/calendar/Calendar.coffee @@ -652,7 +652,7 @@ define [ $styleContainer = $('
').appendTo('body') colorizeContexts: => - colors = colorSlicer.getColors(@contextCodes.length, 275) + colors = colorSlicer.getColors(@contextCodes.length, 275, {unsafe: !ENV.SETTINGS.use_high_contrast}) html = for contextCode, index in @contextCodes color = colors[index] ".group_#{contextCode}{ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 829a0a05301..f7ef5efcb61 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -108,7 +108,8 @@ class ApplicationController < ActionController::Base :files_domain => HostUrl.file_host(@domain_root_account || Account.default, request.host_with_port), :DOMAIN_ROOT_ACCOUNT_ID => @domain_root_account.try(:global_id), :SETTINGS => { - open_registration: @domain_root_account.try(:open_registration?) + open_registration: @domain_root_account.try(:open_registration?), + use_high_contrast: @current_user.try(:prefers_high_contrast?) } } @js_env[:lolcalize] = true if ENV['LOLCALIZE'] diff --git a/bower.json b/bower.json index b0217c0302f..40f7162df77 100644 --- a/bower.json +++ b/bower.json @@ -9,7 +9,7 @@ "ic-ajax": "~2.0.1", "ic-menu": "0.1.11", "ic-styled": "1.1.6", - "color-slicer": "0.4.0", + "color-slicer": "0.8.0", "k5uploader": "0.0.3", "ember-qunit": "~0.1.7", "ic-tabs": "0.1.3", diff --git a/public/javascripts/bower/color-slicer/.bower.json b/public/javascripts/bower/color-slicer/.bower.json index 2fb050da26b..06627d90c28 100644 --- a/public/javascripts/bower/color-slicer/.bower.json +++ b/public/javascripts/bower/color-slicer/.bower.json @@ -1,6 +1,6 @@ { "name": "color-slicer", - "version": "0.7.0", + "version": "0.8.0", "authors": [ "Braden Anderson " ], @@ -20,13 +20,13 @@ ], "devDependencies": {}, "homepage": "https://github.com/instructure/color-slicer", - "_release": "0.7.0", + "_release": "0.8.0", "_resolution": { "type": "version", - "tag": "v0.7.0", - "commit": "74a52e7e6867943ac67f715c54fd8e643e482ae1" + "tag": "v0.8.0", + "commit": "48b337a8fec31d118f47524a04347a674751de00" }, "_source": "git://github.com/instructure/color-slicer.git", - "_target": "~0.7.0", + "_target": "0.8.0", "_originalSource": "color-slicer" } \ No newline at end of file diff --git a/public/javascripts/bower/color-slicer/bower.json b/public/javascripts/bower/color-slicer/bower.json index c385c039bad..0948461efe8 100644 --- a/public/javascripts/bower/color-slicer/bower.json +++ b/public/javascripts/bower/color-slicer/bower.json @@ -1,6 +1,6 @@ { "name": "color-slicer", - "version": "0.7.0", + "version": "0.8.0", "authors": [ "Braden Anderson " ], diff --git a/public/javascripts/bower/color-slicer/dist/color-slicer.js b/public/javascripts/bower/color-slicer/dist/color-slicer.js index e4e139ee4cf..b069a050ab0 100644 --- a/public/javascripts/bower/color-slicer/dist/color-slicer.js +++ b/public/javascripts/bower/color-slicer/dist/color-slicer.js @@ -14,19 +14,26 @@ module.exports = { var l, c; if (options.l) { l = options.l; - c = options.c; } else if (options.bright) { l = 74; - c = 41; + } else if (options.unsafe) { + l = 60; } else { l = 49; - c = 29; + } + if (options.c) { + c = options.c; + } else { + c = 3 + l / 2; // vary chroma to roughly match boundary of RGB-expressible colors - var delta = 17; + var delta = 5 + l/4; var most_constrained_hue = 210; var hr = (h - most_constrained_hue) / 360 * 2 * Math.PI; - c += delta - Math.round(delta * Math.cos(hr)); + c += Math.floor(delta - delta * Math.cos(hr)); + + var overpower = Math.max(Math.floor(160 - (l * 8 / 5)), 0); + c = Math.min(c, overpower); } return [l, c, h] }, diff --git a/public/javascripts/bower/color-slicer/dist/example.html b/public/javascripts/bower/color-slicer/dist/example.html index 190402a8e96..1023bdad8a0 100644 --- a/public/javascripts/bower/color-slicer/dist/example.html +++ b/public/javascripts/bower/color-slicer/dist/example.html @@ -21,11 +21,12 @@ var generate = function() { var lightness = parseInt(document.getElementById('lightness').value, 10); var chroma = parseInt(document.getElementById('chroma').value, 10); var bright = document.getElementById('bright').checked; + var unsafe = document.getElementById('unsafe').checked; document.body.style.color = bright ? '#fff' : '#000'; document.body.style.backgroundColor = bright ? '#000' : '#fff'; - var colors = colorSlicer.getLchColors(count, start, {l: lightness, c: chroma, bright: bright}); + var colors = colorSlicer.getLchColors(count, start, {l: lightness, c: chroma, bright: bright, unsafe: unsafe}); var output = document.getElementById('output'); output.innerHTML = ''; for (var i = 0; i < colors.length; i++) { @@ -59,6 +60,7 @@ window.addEventListener('load', function() {
+
    diff --git a/public/javascripts/bower/color-slicer/index.js b/public/javascripts/bower/color-slicer/index.js index 64bf15422ec..2c89c825af7 100644 --- a/public/javascripts/bower/color-slicer/index.js +++ b/public/javascripts/bower/color-slicer/index.js @@ -13,19 +13,27 @@ module.exports = { var l, c; if (options.l) { l = options.l; - c = options.c; } else if (options.bright) { l = 74; - c = 41; + } else if (options.unsafe) { + l = 60; } else { l = 49; - c = 29; + } + if (options.c) { + c = options.c; + } else { + c = 3 + l / 2; - // vary chroma to roughly match boundary of RGB-expressible colors - var delta = 17; + // vary chroma to roughly match boundary of darkest RGB-expressible colors + var delta = 5 + l/4; var most_constrained_hue = 210; var hr = (h - most_constrained_hue) / 360 * 2 * Math.PI; - c += delta - Math.round(delta * Math.cos(hr)); + c += Math.floor(delta - delta * Math.cos(hr)); + + // constrain chroma by lightest RGB-expressible colors + var overpower = Math.max(Math.floor(160 - (l * 8 / 5)), 0); + c = Math.min(c, overpower); } return [l, c, h] }, diff --git a/public/javascripts/bower/color-slicer/package.json b/public/javascripts/bower/color-slicer/package.json index d94a39937b4..08a0f151494 100644 --- a/public/javascripts/bower/color-slicer/package.json +++ b/public/javascripts/bower/color-slicer/package.json @@ -1,6 +1,6 @@ { "name": "color-slicer", - "version": "0.7.0", + "version": "0.8.0", "description": "Generate lists of readable text colors.", "main": "index.js", "scripts": {