");
- // Remove canvas
- $this.remove();
- }else{
- var data = [];
- for (var key in tmp) {
- data.push(tmp[key]);
- }
-
- var ctx = $this.get(0).getContext("2d");
- new Chart(ctx).Doughnut(data, options);
- }
- }
-
- function get_animation(options, animation){
- if (!animation){
- options.animation = false;
- } else {
- options.animation = true;
- }
- return options;
- }
-
- function draw_line_chart(animation, $canvas){
- var options = get_animation({}, animation);
- var chart_data = create_dataset($canvas);
- var weeks = $canvas.parent().data('weeks');
- var data = {
- labels : weeks,
- datasets : chart_data
- }
-
- var ctx = $canvas.get(0).getContext("2d");
- new Chart(ctx).Line(data, options);
- }
-
- function create_dataset($canvas){
- var selected = getSelectedConferences($canvas);
- var chart_data = $canvas.parent().data('chart');
- var conferences = $canvas.parent().data('conferences');
- var result = [];
-
- for(var i in conferences){
- if(selected.indexOf(conferences[i].short_title) >= 0){
- var options = {};
- options.fillColor = "rgba(255,255,255,0.0)";
- options.strokeColor = conferences[i].color;
- options.data = chart_data[conferences[i].short_title];
- if(options.data == null || options.data.length == 0){
- options.data = [0];
- }
- result.push(options)
- }
- }
- return result
- }
-
- function getSelectedConferences($canvas){
- var name = $canvas.data('name');
- var id = '#' + name + 'Checkboxes'
- var selected = [];
- var $checkboxes = $(id + ' input');
- // If there are checkboxes -> get selected
- // Else -> use the active conference
- if($checkboxes.length){
- $(id + ' input').each(function(){
- if($(this).is(":checked")) {
- selected.push($(this).attr('name'));
- }
- });
- }else{
- var active = $canvas.parent().data('active');
- for(i in active){
- selected.push(active[i].short_title)
- }
- }
- return selected;
- }
-
- $('.conferenceCheckboxes input').change(function(){
- var chart_name = $(this).parent().data('chart');
- var $canvas = $('#line_chart_' + chart_name);
- draw_line_chart(false, $canvas);
- });
-
- $(window).on('resize', function(){
- size(false);
- });
-
- $('#doughnut_tabs a').click(function (e) {
- e.preventDefault();
- $(this).tab('show');
- size(false);
- });
-
- size(true);
-});
diff --git a/app/assets/javascripts/date.format.js b/app/assets/javascripts/date.format.js
deleted file mode 100644
index 3992c50f..00000000
--- a/app/assets/javascripts/date.format.js
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Date Format 1.2.3
- * (c) 2007-2009 Steven Levithan
- * MIT license
- *
- * Includes enhancements by Scott Trenda
- * and Kris Kowal
- *
- * Accepts a date, a mask, or a date and a mask.
- * Returns a formatted version of the given date.
- * The date defaults to the current date/time.
- * The mask defaults to dateFormat.masks.default.
- */
-
-var dateFormat = function () {
- var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
- timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
- timezoneClip = /[^-+\dA-Z]/g,
- pad = function (val, len) {
- val = String(val);
- len = len || 2;
- while (val.length < len) val = "0" + val;
- return val;
- };
-
- // Regexes and supporting functions are cached through closure
- return function (date, mask, utc) {
- var dF = dateFormat;
-
- // You can't provide utc if you skip other args (use the "UTC:" mask prefix)
- if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
- mask = date;
- date = undefined;
- }
-
- // Passing date through Date applies Date.parse, if necessary
- date = date ? new Date(date) : new Date;
- if (isNaN(date)) throw SyntaxError("invalid date");
-
- mask = String(dF.masks[mask] || mask || dF.masks["default"]);
-
- // Allow setting the utc argument via the mask
- if (mask.slice(0, 4) == "UTC:") {
- mask = mask.slice(4);
- utc = true;
- }
-
- var _ = utc ? "getUTC" : "get",
- d = date[_ + "Date"](),
- D = date[_ + "Day"](),
- m = date[_ + "Month"](),
- y = date[_ + "FullYear"](),
- H = date[_ + "Hours"](),
- M = date[_ + "Minutes"](),
- s = date[_ + "Seconds"](),
- L = date[_ + "Milliseconds"](),
- o = utc ? 0 : date.getTimezoneOffset(),
- flags = {
- d: d,
- dd: pad(d),
- ddd: dF.i18n.dayNames[D],
- dddd: dF.i18n.dayNames[D + 7],
- m: m + 1,
- mm: pad(m + 1),
- mmm: dF.i18n.monthNames[m],
- mmmm: dF.i18n.monthNames[m + 12],
- yy: String(y).slice(2),
- yyyy: y,
- h: H % 12 || 12,
- hh: pad(H % 12 || 12),
- H: H,
- HH: pad(H),
- M: M,
- MM: pad(M),
- s: s,
- ss: pad(s),
- l: pad(L, 3),
- L: pad(L > 99 ? Math.round(L / 10) : L),
- t: H < 12 ? "a" : "p",
- tt: H < 12 ? "am" : "pm",
- T: H < 12 ? "A" : "P",
- TT: H < 12 ? "AM" : "PM",
- Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
- o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
- S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
- };
-
- return mask.replace(token, function ($0) {
- return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
- });
- };
-}();
-
-// Some common format strings
-dateFormat.masks = {
- "default": "ddd mmm dd yyyy HH:MM:ss",
- shortDate: "m/d/yy",
- mediumDate: "mmm d, yyyy",
- longDate: "mmmm d, yyyy",
- fullDate: "dddd, mmmm d, yyyy",
- shortTime: "h:MM TT",
- mediumTime: "h:MM:ss TT",
- longTime: "h:MM:ss TT Z",
- isoDate: "yyyy-mm-dd",
- isoTime: "HH:MM:ss",
- isoDateTime: "yyyy-mm-dd'T'HH:MM:ss",
- isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
-};
-
-// Internationalization strings
-dateFormat.i18n = {
- dayNames: [
- "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
- "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
- ],
- monthNames: [
- "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
- "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
- ]
-};
-
-// For convenience...
-Date.prototype.format = function (mask, utc) {
- return dateFormat(this, mask, utc);
-};
-
diff --git a/app/assets/javascripts/osem-datepickers.js b/app/assets/javascripts/osem-datepickers.js
index efac362e..b7ef12d8 100644
--- a/app/assets/javascripts/osem-datepickers.js
+++ b/app/assets/javascripts/osem-datepickers.js
@@ -1,18 +1,12 @@
$(function () {
- $("#registration-arrival-datepicker").datetimepicker({
- pickTime: true,
- useCurrent: false,
- minuteStepping: 15,
- sideBySide: true,
- format: "YYYY-MM-DD HH:mm"
- });
- $("#registration-departure-datepicker").datetimepicker({
+ $("#registration-arrival-datepicker, #registration-departure-datepicker").datetimepicker({
pickTime: true,
useCurrent: false,
minuteStepping: 15,
sideBySide: true,
format: "YYYY-MM-DD HH:mm"
});
+
$("#registration-arrival-datepicker").on("dp.change",function (e) {
console.log (e.date)
$('#registration-departure-datepicker').data("DateTimePicker").setDate(e.date);
@@ -23,16 +17,14 @@ $(function () {
});
- $("#conference-start-datepicker").datetimepicker({
- pickTime: false,
- useCurrent: false,
- format: "YYYY-MM-DD"
- });
- $("#conference-end-datepicker").datetimepicker({
+ const $datetimepickers = $("#conference-start-datepicker, #conference-end-datepicker, #registration-period-start-datepicker, #registration-period-end-datepicker");
+
+ $datetimepickers.datetimepicker({
pickTime: false,
useCurrent: false,
format: "YYYY-MM-DD"
});
+
$("#conference-start-datepicker").on("dp.change",function (e) {
console.log (e.date)
$('#conference-end-datepicker').data("DateTimePicker").setDate(e.date);
@@ -42,16 +34,6 @@ $(function () {
$('#conference-start-datepicker').data("DateTimePicker").setMaxDate(e.date);
});
- $("#registration-period-start-datepicker").datetimepicker({
- format: "YYYY-MM-DD",
- pickTime: false,
- pickSeconds: false
- });
- $("#registration-period-end-datepicker").datetimepicker({
- format: "YYYY-MM-DD",
- pickTime: false,
- pickSeconds: false
- });
$("#registration-period-start-datepicker").on("dp.change",function (e) {
console.log (e.date)
$('#registration-period-end-datepicker').data("DateTimePicker").setDate(e.date);
diff --git a/app/assets/javascripts/smoothscroll.js b/app/assets/javascripts/smoothscroll.js
deleted file mode 100644
index 93ca76ef..00000000
--- a/app/assets/javascripts/smoothscroll.js
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * SmoothScroll
- * This helper script created by DWUser.com. Copyright 2013 DWUser.com.
- * Dual-licensed under the GPL and MIT licenses.
- * All individual scripts remain property of their copyrighters.
- * Date: 10-Sep-2013
- * Version: 1.0.1
- */
-if (!window['jQuery']) alert('The jQuery library must be included before the smoothscroll.js file. The plugin will not work propery.');
-
-/**
- * jQuery.ScrollTo - Easy element scrolling using jQuery.
- * Copyright (c) 2007-2013 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
- * Dual licensed under MIT and GPL.
- * @author Ariel Flesler
- * @version 1.4.3.1
- */
-;(function($){var h=$.scrollTo=function(a,b,c){$(window).scrollTo(a,b,c)};h.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1,limit:true};h.window=function(a){return $(window)._scrollable()};$.fn._scrollable=function(){return this.map(function(){var a=this,isWin=!a.nodeName||$.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!isWin)return a;var b=(a.contentWindow||a).document||a.ownerDocument||a;return/webkit/i.test(navigator.userAgent)||b.compatMode=='BackCompat'?b.body:b.documentElement})};$.fn.scrollTo=function(e,f,g){if(typeof f=='object'){g=f;f=0}if(typeof g=='function')g={onAfter:g};if(e=='max')e=9e9;g=$.extend({},h.defaults,g);f=f||g.duration;g.queue=g.queue&&g.axis.length>1;if(g.queue)f/=2;g.offset=both(g.offset);g.over=both(g.over);return this._scrollable().each(function(){if(e==null)return;var d=this,$elem=$(d),targ=e,toff,attr={},win=$elem.is('html,body');switch(typeof targ){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(targ)){targ=both(targ);break}targ=$(targ,this);if(!targ.length)return;case'object':if(targ.is||targ.style)toff=(targ=$(targ)).offset()}$.each(g.axis.split(''),function(i,a){var b=a=='x'?'Left':'Top',pos=b.toLowerCase(),key='scroll'+b,old=d[key],max=h.max(d,a);if(toff){attr[key]=toff[pos]+(win?0:old-$elem.offset()[pos]);if(g.margin){attr[key]-=parseInt(targ.css('margin'+b))||0;attr[key]-=parseInt(targ.css('border'+b+'Width'))||0}attr[key]+=g.offset[pos]||0;if(g.over[pos])attr[key]+=targ[a=='x'?'width':'height']()*g.over[pos]}else{var c=targ[pos];attr[key]=c.slice&&c.slice(-1)=='%'?parseFloat(c)/100*max:c}if(g.limit&&/^\d+$/.test(attr[key]))attr[key]=attr[key]<=0?0:Math.min(attr[key],max);if(!i&&g.queue){if(old!=attr[key])animate(g.onAfterFirst);delete attr[key]}});animate(g.onAfter);function animate(a){$elem.animate(attr,f,g.easing,a&&function(){a.call(this,e,g)})}}).end()};h.max=function(a,b){var c=b=='x'?'Width':'Height',scroll='scroll'+c;if(!$(a).is('html,body'))return a[scroll]-$(a)[c.toLowerCase()]();var d='client'+c,html=a.ownerDocument.documentElement,body=a.ownerDocument.body;return Math.max(html[scroll],body[scroll])-Math.min(html[d],body[d])};function both(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
-
-/**
- * jQuery.LocalScroll
- * Copyright (c) 2007-2010 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
- * Dual licensed under MIT and GPL.
- * Date: 05/31/2010
- * @author Ariel Flesler
- * @version 1.2.8b
- **/
-;(function(b){function g(a,e,d){var h=e.hash.slice(1),f=document.getElementById(h)||document.getElementsByName(h)[0];if(f){a&&a.preventDefault();var c=b(d.target);if(!(d.lock&&c.is(":animated")||d.onBefore&&!1===d.onBefore(a,f,c))){d.stop&&c._scrollable().stop(!0);if(d.hash){var a=f.id==h?"id":"name",g=b("").attr(a,h).css({position:"absolute",top:b(window).scrollTop(),left:b(window).scrollLeft()});f[a]="";b("body").prepend(g);location=e.hash;g.remove();f[a]=h}c.scrollTo(f,d).trigger("notify.serialScroll",
-[f])}}}var i=location.href.replace(/#.*/,""),c=b.localScroll=function(a){b("body").localScroll(a)};c.defaults={duration:1E3,axis:"y",event:"click",stop:!0,target:window,reset:!0};c.hash=function(a){if(location.hash){a=b.extend({},c.defaults,a);a.hash=!1;if(a.reset){var e=a.duration;delete a.duration;b(a.target).scrollTo(0,a);a.duration=e}g(0,location,a)}};b.fn.localScroll=function(a){function e(){return!!this.href&&!!this.hash&&this.href.replace(this.hash,"")==i&&(!a.filter||b(this).is(a.filter))}
-a=b.extend({},c.defaults,a);return a.lazy?this.bind(a.event,function(d){var c=b([d.target,d.target.parentNode]).filter(e)[0];c&&g(d,c,a)}):this.find("a,area").filter(e).bind(a.event,function(b){g(b,this,a)}).end().end()}})(jQuery);
-
-// Initialize all .smoothScroll links
-jQuery(function($){ $.localScroll({filter:'.smoothScroll'}); });
diff --git a/app/assets/javascripts/spectrum.js b/app/assets/javascripts/spectrum.js
deleted file mode 100644
index 15abcc94..00000000
--- a/app/assets/javascripts/spectrum.js
+++ /dev/null
@@ -1,1693 +0,0 @@
-// Spectrum Colorpicker v1.0.2
-// https://github.com/bgrins/spectrum
-// Author: Brian Grinstead
-// License: MIT
-
-(function (window, $, undefined) {
- var defaultOpts = {
-
- // Events
- beforeShow: noop,
- move: noop,
- change: noop,
- show: noop,
- hide: noop,
-
- // Options
- color: false,
- flat: false,
- showInput: false,
- showButtons: true,
- clickoutFiresChange: false,
- showInitial: false,
- showPalette: false,
- showPaletteOnly: false,
- showSelectionPalette: true,
- localStorageKey: false,
- maxSelectionSize: 7,
- cancelText: "cancel",
- chooseText: "choose",
- preferredFormat: false,
- className: "",
- showAlpha: false,
- theme: "sp-light",
- palette: ['fff', '000'],
- selectionPalette: [],
- disabled: false
- },
- spectrums = [],
- IE = !!/msie/i.exec( window.navigator.userAgent ),
- rgbaSupport = (function() {
- function contains( str, substr ) {
- return !!~('' + str).indexOf(substr);
- }
-
- var elem = document.createElement('div');
- var style = elem.style;
- style.cssText = 'background-color:rgba(0,0,0,.5)';
- return contains(style.backgroundColor, 'rgba') || contains(style.backgroundColor, 'hsla');
- })(),
- replaceInput = [
- "
",
- "
",
- "
▼
",
- "
"
- ].join(''),
- markup = (function () {
-
- // IE does not support gradients with multiple stops, so we need to simulate
- // that for the rainbow slider with 8 divs that each have a single gradient
- var gradientFix = "";
- if (IE) {
- for (var i = 1; i <= 6; i++) {
- gradientFix += "";
- }
- }
-
- return [
- "
",
- "
",
- "",
- "
",
- "
",
- "
",
- "",
- "
",
- "
",
- "
",
- "
",
- "",
- "
",
- "
",
- "
",
- "
",
- "",
- gradientFix,
- "
",
- "
",
- "
",
- "
",
- "
",
- "",
- "
",
- "",
- "
",
- "",
- "",
- "
",
- "
",
- "
"
- ].join("");
- })();
-
- function paletteTemplate (p, color, className) {
- var html = [];
- for (var i = 0; i < p.length; i++) {
- var tiny = tinycolor(p[i]);
- var c = tiny.toHsl().l < 0.5 ? "sp-thumb-el sp-thumb-dark" : "sp-thumb-el sp-thumb-light";
- c += (tinycolor.equals(color, p[i])) ? " sp-thumb-active" : "";
-
- var swatchStyle = rgbaSupport ? ("background-color:" + tiny.toRgbString()) : "filter:" + tiny.toFilter();
- html.push('');
- }
- return "
" + html.join('') + "
";
- }
-
- function hideAll() {
- for (var i = 0; i < spectrums.length; i++) {
- if (spectrums[i]) {
- spectrums[i].hide();
- }
- }
- }
-
- function instanceOptions(o, callbackContext) {
- var opts = $.extend({}, defaultOpts, o);
- opts.callbacks = {
- 'move': bind(opts.move, callbackContext),
- 'change': bind(opts.change, callbackContext),
- 'show': bind(opts.show, callbackContext),
- 'hide': bind(opts.hide, callbackContext),
- 'beforeShow': bind(opts.beforeShow, callbackContext)
- };
-
- return opts;
- }
-
- function spectrum(element, o) {
-
- var opts = instanceOptions(o, element),
- flat = opts.flat,
- showPaletteOnly = opts.showPaletteOnly,
- showPalette = opts.showPalette || showPaletteOnly,
- showInitial = opts.showInitial && !flat,
- showInput = opts.showInput,
- showAlpha = opts.showAlpha,
- showSelectionPalette = opts.showSelectionPalette,
- localStorageKey = opts.localStorageKey,
- theme = opts.theme,
- callbacks = opts.callbacks,
- resize = throttle(reflow, 10),
- visible = false,
- dragWidth = 0,
- dragHeight = 0,
- dragHelperHeight = 0,
- slideHeight = 0,
- slideWidth = 0,
- alphaWidth = 0,
- alphaSlideHelperWidth = 0,
- slideHelperHeight = 0,
- currentHue = 0,
- currentSaturation = 0,
- currentValue = 0,
- currentAlpha = 1,
- palette = opts.palette.slice(0),
- paletteArray = $.isArray(palette[0]) ? palette : [palette],
- selectionPalette = opts.selectionPalette.slice(0),
- draggingClass = "sp-dragging";
-
- var doc = element.ownerDocument,
- body = doc.body,
- boundElement = $(element),
- disabled = boundElement.is(":disabled") || (opts.disabled === true),
- container = $(markup, doc).addClass(theme),
- dragger = container.find(".sp-color"),
- dragHelper = container.find(".sp-dragger"),
- slider = container.find(".sp-hue"),
- slideHelper = container.find(".sp-slider"),
- alphaSliderInner = container.find(".sp-alpha-inner"),
- alphaSlider = container.find(".sp-alpha"),
- alphaSlideHelper = container.find(".sp-alpha-handle"),
- textInput = container.find(".sp-input"),
- paletteContainer = container.find(".sp-palette"),
- initialColorContainer = container.find(".sp-initial"),
- cancelButton = container.find(".sp-cancel"),
- chooseButton = container.find(".sp-choose"),
- isInput = boundElement.is("input"),
- shouldReplace = isInput && !flat,
- replacer = (shouldReplace) ? $(replaceInput).addClass(theme) : $([]),
- offsetElement = (shouldReplace) ? replacer : boundElement,
- previewElement = replacer.find(".sp-preview-inner"),
- initialColor = opts.color || (isInput && boundElement.val()),
- colorOnShow = false,
- preferredFormat = opts.preferredFormat,
- currentPreferredFormat = preferredFormat,
- clickoutFiresChange = !opts.showButtons || opts.clickoutFiresChange;
-
- chooseButton.text(opts.chooseText);
- cancelButton.text(opts.cancelText);
- if(opts.disabled) disable();
-
- function initialize() {
-
- if (IE) {
- container.find("*:not(input)").attr("unselectable", "on");
- }
-
- container.toggleClass("sp-flat", flat);
- container.toggleClass("sp-input-disabled", !showInput);
- container.toggleClass("sp-alpha-enabled", showAlpha);
- container.toggleClass("sp-buttons-disabled", !opts.showButtons || flat);
- container.toggleClass("sp-palette-disabled", !showPalette);
- container.toggleClass("sp-palette-only", showPaletteOnly);
- container.toggleClass("sp-initial-disabled", !showInitial);
- container.addClass(opts.className);
-
- if (shouldReplace) {
- boundElement.hide().after(replacer);
- }
-
- if (flat) {
- boundElement.after(container).hide();
- }
- else {
- $(body).append(container.hide());
- }
- if (localStorageKey && window.localStorage) {
- try {
- selectionPalette = window.localStorage[localStorageKey].split(",");
- }
- catch (e) {
-
- }
- }
-
- offsetElement.bind("click.spectrum touchstart.spectrum", function (e) {
- if (!disabled) {
- toggle();
- }
-
- e.stopPropagation();
-
- if (!$(e.target).is("input")) {
- e.preventDefault();
- }
- });
-
- if (disabled) {
- offsetElement.addClass("sp-disabled");
- }
-
- // Prevent clicks from bubbling up to document. This would cause it to be hidden.
- container.click(stopPropagation);
-
- // Handle user typed input
- textInput.change(setFromTextInput);
- textInput.bind("paste", function () {
- setTimeout(setFromTextInput, 1);
- });
- textInput.keydown(function (e) { if (e.keyCode == 13) { setFromTextInput(); } });
-
- cancelButton.bind("click.spectrum", function (e) {
- e.stopPropagation();
- e.preventDefault();
- hide("cancel");
- });
-
- chooseButton.bind("click.spectrum", function (e) {
- e.stopPropagation();
- e.preventDefault();
-
- if (isValid()) {
- updateOriginalInput(true);
- hide();
- }
- });
-
- draggable(alphaSlider, function (dragX, dragY, e) {
- currentAlpha = (dragX / alphaWidth);
- if (e.shiftKey) {
- currentAlpha = Math.round(currentAlpha * 10) / 10;
- }
-
- move();
- });
-
- draggable(slider, function (dragX, dragY) {
- currentHue = (dragY / slideHeight);
- move();
- }, dragStart, dragStop);
-
- draggable(dragger, function (dragX, dragY) {
- currentSaturation = dragX / dragWidth;
- currentValue = (dragHeight - dragY) / dragHeight;
- move();
- }, dragStart, dragStop);
-
- if (!!initialColor) {
- set(initialColor);
-
- // In case color was black - update the preview UI and set the format
- // since the set function will not run (default color is black).
- updateUI();
- currentPreferredFormat = preferredFormat || tinycolor(initialColor).format;
-
- addColorToSelectionPalette(initialColor);
- }
- else {
- updateUI();
- }
-
- if (flat) {
- show();
- }
-
- function palletElementClick(e) {
- if (e.data && e.data.ignore) {
- set($(this).data("color"));
- move();
- }
- else {
- set($(this).data("color"));
- updateOriginalInput(true);
- move();
- hide();
- }
-
- return false;
- }
-
- var paletteEvent = IE ? "mousedown.spectrum" : "click.spectrum touchstart.spectrum";
- paletteContainer.delegate(".sp-thumb-el", paletteEvent, palletElementClick);
- initialColorContainer.delegate(".sp-thumb-el::nth-child(1)", paletteEvent, { ignore: true }, palletElementClick);
- }
- function addColorToSelectionPalette(color) {
- if (showSelectionPalette) {
- selectionPalette.push(tinycolor(color).toHexString());
- if (localStorageKey && window.localStorage) {
- window.localStorage[localStorageKey] = selectionPalette.join(",");
- }
- }
- }
-
- function getUniqueSelectionPalette() {
- var unique = [];
- var p = selectionPalette;
- var paletteLookup = {};
- var hex;
-
- if (showPalette) {
-
- for (var i = 0; i < paletteArray.length; i++) {
- for (var j = 0; j < paletteArray[i].length; j++) {
- hex = tinycolor(paletteArray[i][j]).toHexString();
- paletteLookup[hex] = true;
- }
- }
-
- for (i = 0; i < p.length; i++) {
- var color = tinycolor(p[i]);
- hex = color.toHexString();
-
- if (!paletteLookup.hasOwnProperty(hex)) {
- unique.push(p[i]);
- paletteLookup[hex] = true;
- }
- }
- }
-
- return unique.reverse().slice(0, opts.maxSelectionSize);
- }
- function drawPalette() {
-
- var currentColor = get();
-
- var html = $.map(paletteArray, function (palette, i) {
- return paletteTemplate(palette, currentColor, "sp-palette-row sp-palette-row-" + i);
- });
-
- if (selectionPalette) {
- html.push(paletteTemplate(getUniqueSelectionPalette(), currentColor, "sp-palette-row sp-palette-row-selection"));
- }
-
- paletteContainer.html(html.join(""));
- }
- function drawInitial() {
- if (showInitial) {
- var initial = colorOnShow;
- var current = get();
- initialColorContainer.html(paletteTemplate([initial, current], current, "sp-palette-row-initial"));
- }
- }
- function dragStart() {
- if (dragHeight === 0 || dragWidth === 0 || slideHeight === 0) {
- reflow();
- }
- container.addClass(draggingClass);
- }
- function dragStop() {
- container.removeClass(draggingClass);
- }
- function setFromTextInput() {
- var tiny = tinycolor(textInput.val());
- if (tiny.ok) {
- set(tiny);
- }
- else {
- textInput.addClass("sp-validation-error");
- }
- }
-
- function toggle() {
- if (visible) {
- hide();
- }
- else {
- show();
- }
- }
-
- function show() {
- if (visible) {
- reflow();
- return;
- }
- if (callbacks.beforeShow(get()) === false) return;
-
- hideAll();
- visible = true;
-
- $(doc).bind("click.spectrum", hide);
- $(window).bind("resize.spectrum", resize);
- replacer.addClass("sp-active");
- container.show();
-
- if (showPalette) {
- drawPalette();
- }
- reflow();
- updateUI();
-
- colorOnShow = get();
-
- drawInitial();
- callbacks.show(colorOnShow);
- }
-
- function hide(e) {
-
- // Return on right click
- if (e && e.type == "click" && e.button == 2) { return; }
-
- // Return if hiding is unnecessary
- if (!visible || flat) { return; }
- visible = false;
-
- $(doc).unbind("click.spectrum", hide);
- $(window).unbind("resize.spectrum", resize);
-
- replacer.removeClass("sp-active");
- container.hide();
-
- var colorHasChanged = !tinycolor.equals(get(), colorOnShow);
-
- if (colorHasChanged) {
- if (clickoutFiresChange && e !== "cancel") {
- updateOriginalInput(true);
- }
- else {
- revert();
- }
- }
-
- callbacks.hide(get());
- }
-
- function revert() {
- set(colorOnShow, true);
- }
-
- function set(color, ignoreFormatChange) {
- if (tinycolor.equals(color, get())) {
- return;
- }
-
- var newColor = tinycolor(color);
- var newHsv = newColor.toHsv();
-
- currentHue = newHsv.h;
- currentSaturation = newHsv.s;
- currentValue = newHsv.v;
- currentAlpha = newHsv.a;
-
- updateUI();
-
- if (!ignoreFormatChange) {
- currentPreferredFormat = preferredFormat || newColor.format;
- }
- }
-
- function get() {
- return tinycolor.fromRatio({ h: currentHue, s: currentSaturation, v: currentValue, a: Math.round(currentAlpha * 100) / 100 });
- }
-
- function isValid() {
- return !textInput.hasClass("sp-validation-error");
- }
-
- function move() {
- updateUI();
-
- callbacks.move(get());
- }
-
- function updateUI() {
-
- textInput.removeClass("sp-validation-error");
-
- updateHelperLocations();
-
- // Update dragger background color (gradients take care of saturation and value).
- var flatColor = tinycolor({ h: currentHue, s: "1.0", v: "1.0" });
- dragger.css("background-color", flatColor.toHexString());
-
- // Get a format that alpha will be included in (hex and names ignore alpha)
- var format = currentPreferredFormat;
- if (currentAlpha < 1) {
- if (format === "hex" || format === "name") {
- format = "rgb";
- }
- }
-
- var realColor = get(),
- realHex = realColor.toHexString(),
- realRgb = realColor.toRgbString();
-
-
- // Update the replaced elements background color (with actual selected color)
- if (rgbaSupport || realColor.alpha === 1) {
- previewElement.css("background-color", realRgb);
- }
- else {
- previewElement.css("background-color", "transparent");
- previewElement.css("filter", realColor.toFilter());
- }
-
- if (showAlpha) {
- var rgb = realColor.toRgb();
- rgb.a = 0;
- var realAlpha = tinycolor(rgb).toRgbString();
- var gradient = "linear-gradient(left, " + realAlpha + ", " + realHex + ")";
-
- if (IE) {
- alphaSliderInner.css("filter", tinycolor(realAlpha).toFilter({ gradientType: 1 }, realHex));
- }
- else {
- alphaSliderInner.css("background", "-webkit-" + gradient);
- alphaSliderInner.css("background", "-moz-" + gradient);
- alphaSliderInner.css("background", "-ms-" + gradient);
- alphaSliderInner.css("background", gradient);
- }
- }
-
-
- // Update the text entry input as it changes happen
- if (showInput) {
- if (currentAlpha < 1) {
- if (format === "hex" || format === "name") {
- format = "rgb";
- }
- }
- textInput.val(realColor.toString(format));
- }
-
- if (showPalette) {
- drawPalette();
- }
-
- drawInitial();
- }
-
- function updateHelperLocations() {
- var s = currentSaturation;
- var v = currentValue;
-
- // Where to show the little circle in that displays your current selected color
- var dragX = s * dragWidth;
- var dragY = dragHeight - (v * dragHeight);
- dragX = Math.max(
- -dragHelperHeight,
- Math.min(dragWidth - dragHelperHeight, dragX - dragHelperHeight)
- );
- dragY = Math.max(
- -dragHelperHeight,
- Math.min(dragHeight - dragHelperHeight, dragY - dragHelperHeight)
- );
- dragHelper.css({
- "top": dragY,
- "left": dragX
- });
-
- var alphaX = currentAlpha * alphaWidth;
- alphaSlideHelper.css({
- "left": alphaX - (alphaSlideHelperWidth / 2)
- });
-
- // Where to show the bar that displays your current selected hue
- var slideY = (currentHue) * slideHeight;
- slideHelper.css({
- "top": slideY - slideHelperHeight
- });
- }
-
- function updateOriginalInput(fireCallback) {
- var color = get();
-
- if (isInput) {
- boundElement.val(color.toString(currentPreferredFormat)).change();
- }
-
- var hasChanged = !tinycolor.equals(color, colorOnShow);
- colorOnShow = color;
-
- // Update the selection palette with the current color
- addColorToSelectionPalette(color);
- if (fireCallback && hasChanged) {
- callbacks.change(color);
- }
- }
-
- function reflow() {
- dragWidth = dragger.width();
- dragHeight = dragger.height();
- dragHelperHeight = dragHelper.height();
- slideWidth = slider.width();
- slideHeight = slider.height();
- slideHelperHeight = slideHelper.height();
- alphaWidth = alphaSlider.width();
- alphaSlideHelperWidth = alphaSlideHelper.width();
-
- if (!flat) {
- container.offset(getOffset(container, offsetElement));
- }
-
- updateHelperLocations();
- }
-
- function destroy() {
- boundElement.show();
- offsetElement.unbind("click.spectrum touchstart.spectrum");
- container.remove();
- replacer.remove();
- spectrums[spect.id] = null;
- }
-
- function enable() {
- disabled = false;
- boundElement.attr("disabled", false);
- offsetElement.removeClass("sp-disabled");
- }
-
- function disable() {
- disabled = true;
- boundElement.attr("disabled", true);
- offsetElement.addClass("sp-disabled");
- }
-
- initialize();
-
- var spect = {
- show: show,
- hide: hide,
- toggle: toggle,
- reflow: reflow,
- enable: enable,
- disable: disable,
- set: function (c) {
- set(c);
- updateOriginalInput();
- },
- get: get,
- destroy: destroy,
- container: container
- };
-
- spect.id = spectrums.push(spect) - 1;
-
- return spect;
- }
-
- /**
- * checkOffset - get the offset below/above and left/right element depending on screen position
- * Thanks https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.datepicker.js
- */
- function getOffset(picker, input) {
- var extraY = 0;
- var dpWidth = picker.outerWidth();
- var dpHeight = picker.outerHeight();
- var inputHeight = input.outerHeight();
- var doc = picker[0].ownerDocument;
- var docElem = doc.documentElement;
- var viewWidth = docElem.clientWidth + $(doc).scrollLeft();
- var viewHeight = docElem.clientHeight + $(doc).scrollTop();
- var offset = input.offset();
- offset.top += inputHeight;
-
- offset.left -=
- Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
- Math.abs(offset.left + dpWidth - viewWidth) : 0);
-
- offset.top -=
- Math.min(offset.top, ((offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
- Math.abs(dpHeight + inputHeight - extraY) : extraY));
-
- return offset;
- }
-
- /**
- * noop - do nothing
- */
- function noop() {
-
- }
-
- /**
- * stopPropagation - makes the code only doing this a little easier to read in line
- */
- function stopPropagation(e) {
- e.stopPropagation();
- }
-
- /**
- * Create a function bound to a given object
- * Thanks to underscore.js
- */
- function bind(func, obj) {
- var slice = Array.prototype.slice;
- var args = slice.call(arguments, 2);
- return function () {
- return func.apply(obj, args.concat(slice.call(arguments)));
- };
- }
-
- /**
- * Lightweight drag helper. Handles containment within the element, so that
- * when dragging, the x is within [0,element.width] and y is within [0,element.height]
- */
- function draggable(element, onmove, onstart, onstop) {
- onmove = onmove || function () { };
- onstart = onstart || function () { };
- onstop = onstop || function () { };
- var doc = element.ownerDocument || document;
- var dragging = false;
- var offset = {};
- var maxHeight = 0;
- var maxWidth = 0;
- var hasTouch = ('ontouchstart' in window);
-
- var duringDragEvents = {};
- duringDragEvents["selectstart"] = prevent;
- duringDragEvents["dragstart"] = prevent;
- duringDragEvents[(hasTouch ? "touchmove" : "mousemove")] = move;
- duringDragEvents[(hasTouch ? "touchend" : "mouseup")] = stop;
-
- function prevent(e) {
- if (e.stopPropagation) {
- e.stopPropagation();
- }
- if (e.preventDefault) {
- e.preventDefault();
- }
- e.returnValue = false;
- }
-
- function move(e) {
- if (dragging) {
- // Mouseup happened outside of window
- if (IE && document.documentMode < 9 && !e.button) {
- return stop();
- }
-
- var touches = e.originalEvent.touches;
- var pageX = touches ? touches[0].pageX : e.pageX;
- var pageY = touches ? touches[0].pageY : e.pageY;
-
- var dragX = Math.max(0, Math.min(pageX - offset.left, maxWidth));
- var dragY = Math.max(0, Math.min(pageY - offset.top, maxHeight));
-
- if (hasTouch) {
- // Stop scrolling in iOS
- prevent(e);
- }
-
- onmove.apply(element, [dragX, dragY, e]);
- }
- }
- function start(e) {
- var rightclick = (e.which) ? (e.which == 3) : (e.button == 2);
- var touches = e.originalEvent.touches;
-
- if (!rightclick && !dragging) {
- if (onstart.apply(element, arguments) !== false) {
- dragging = true;
- maxHeight = $(element).height();
- maxWidth = $(element).width();
- offset = $(element).offset();
-
- $(doc).bind(duringDragEvents);
- $(doc.body).addClass("sp-dragging");
-
- if (!hasTouch) {
- move(e);
- }
-
- prevent(e);
- }
- }
- }
- function stop() {
- if (dragging) {
- $(doc).unbind(duringDragEvents);
- $(doc.body).removeClass("sp-dragging");
- onstop.apply(element, arguments);
- }
- dragging = false;
- }
-
- $(element).bind(hasTouch ? "touchstart" : "mousedown", start);
- }
-
- function throttle(func, wait, debounce) {
- var timeout;
- return function () {
- var context = this, args = arguments;
- var throttler = function () {
- timeout = null;
- func.apply(context, args);
- };
- if (debounce) clearTimeout(timeout);
- if (debounce || !timeout) timeout = setTimeout(throttler, wait);
- };
- }
-
-
- /**
- * Define a jQuery plugin
- */
- var dataID = "spectrum.id";
- $.fn.spectrum = function (opts, extra) {
- if (typeof opts == "string") {
- if (opts == "get") {
- return spectrums[this.eq(0).data(dataID)].get();
- } else if (opts == "container") {
- return spectrums[$(this).data(dataID)].container;
- }
-
- return this.each(function () {
- var spect = spectrums[$(this).data(dataID)];
- if (spect) {
- if (opts == "show") { spect.show(); }
- if (opts == "hide") { spect.hide(); }
- if (opts == "toggle") { spect.toggle(); }
- if (opts == "reflow") { spect.reflow(); }
- if (opts == "set") { spect.set(extra); }
- if (opts == 'enable') { spect.enable(); }
- if (opts == 'disable') { spect.disable(); }
- if (opts == "destroy") {
- spect.destroy();
- $(this).removeData(dataID);
- }
- }
- });
- }
-
- // Initializing a new one
- return this.spectrum("destroy").each(function () {
- var spect = spectrum(this, opts);
- $(this).data(dataID, spect.id);
- });
- };
-
- $.fn.spectrum.load = true;
- $.fn.spectrum.loadOpts = {};
- $.fn.spectrum.draggable = draggable;
- $.fn.spectrum.defaults = defaultOpts;
-
- $.fn.spectrum.processNativeColorInputs = function () {
- var colorInput = $("")[0];
- var supportsColor = colorInput.type === "color" && colorInput.value != "!";
-
- if (!supportsColor) {
- $("input[type=color]").spectrum({
- preferredFormat: "hex6"
- });
- }
- };
-
- // TinyColor.js - - 2011 Brian Grinstead - v0.5
-
- (function (window) {
-
- var trimLeft = /^[\s,#]+/,
- trimRight = /\s+$/,
- tinyCounter = 0,
- math = Math,
- mathRound = math.round,
- mathMin = math.min,
- mathMax = math.max,
- mathRandom = math.random,
- parseFloat = window.parseFloat;
-
- function tinycolor(color, opts) {
-
- // If input is already a tinycolor, return itself
- if (typeof color == "object" && color.hasOwnProperty("_tc_id")) {
- return color;
- }
-
- var rgb = inputToRGB(color);
- var r = rgb.r, g = rgb.g, b = rgb.b, a = parseFloat(rgb.a), format = rgb.format;
-
- return {
- ok: rgb.ok,
- format: format,
- _tc_id: tinyCounter++,
- alpha: a,
- toHsv: function () {
- var hsv = rgbToHsv(r, g, b);
- return { h: hsv.h, s: hsv.s, v: hsv.v, a: a };
- },
- toHsvString: function () {
- var hsv = rgbToHsv(r, g, b);
- var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), v = mathRound(hsv.v * 100);
- return (a == 1) ?
- "hsv(" + h + ", " + s + "%, " + v + "%)" :
- "hsva(" + h + ", " + s + "%, " + v + "%, " + a + ")";
- },
- toHsl: function () {
- var hsl = rgbToHsl(r, g, b);
- return { h: hsl.h, s: hsl.s, l: hsl.l, a: a };
- },
- toHslString: function () {
- var hsl = rgbToHsl(r, g, b);
- var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), l = mathRound(hsl.l * 100);
- return (a == 1) ?
- "hsl(" + h + ", " + s + "%, " + l + "%)" :
- "hsla(" + h + ", " + s + "%, " + l + "%, " + a + ")";
- },
- toHex: function () {
- return rgbToHex(r, g, b);
- },
- toHexString: function (force6Char) {
- return '#' + rgbToHex(r, g, b, force6Char);
- },
- toRgb: function () {
- return { r: mathRound(r), g: mathRound(g), b: mathRound(b), a: a };
- },
- toRgbString: function () {
- return (a == 1) ?
- "rgb(" + mathRound(r) + ", " + mathRound(g) + ", " + mathRound(b) + ")" :
- "rgba(" + mathRound(r) + ", " + mathRound(g) + ", " + mathRound(b) + ", " + a + ")";
- },
- toName: function () {
- return hexNames[rgbToHex(r, g, b)] || false;
- },
- toFilter: function (opts, secondColor) {
-
- var hex = rgbToHex(r, g, b, true);
- var secondHex = hex;
- var alphaHex = Math.round(parseFloat(a) * 255).toString(16);
- var secondAlphaHex = alphaHex;
- var gradientType = opts && opts.gradientType ? "GradientType = 1, " : "";
-
- if (secondColor) {
- var s = tinycolor(secondColor);
- secondHex = s.toHex();
- secondAlphaHex = Math.round(parseFloat(s.alpha) * 255).toString(16);
- }
-
- return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr=#" + pad2(alphaHex) + hex + ",endColorstr=#" + pad2(secondAlphaHex) + secondHex + ")";
- },
- toString: function (format) {
- format = format || this.format;
- var formattedString = false;
- if (format === "rgb") {
- formattedString = this.toRgbString();
- }
- if (format === "hex") {
- formattedString = this.toHexString();
- }
- if (format === "hex6") {
- formattedString = this.toHexString(true);
- }
- if (format === "name") {
- formattedString = this.toName();
- }
- if (format === "hsl") {
- formattedString = this.toHslString();
- }
- if (format === "hsv") {
- formattedString = this.toHsvString();
- }
-
- return formattedString || this.toHexString(true);
- }
- };
- }
-
- // If input is an object, force 1 into "1.0" to handle ratios properly
- // String input requires "1.0" as input, so 1 will be treated as 1
- tinycolor.fromRatio = function (color) {
-
- if (typeof color == "object") {
- for (var i in color) {
- if (color[i] === 1) {
- color[i] = "1.0";
- }
- }
- }
-
- return tinycolor(color);
-
- };
-
- // Given a string or object, convert that input to RGB
- // Possible string inputs:
- //
- // "red"
- // "#f00" or "f00"
- // "#ff0000" or "ff0000"
- // "rgb 255 0 0" or "rgb (255, 0, 0)"
- // "rgb 1.0 0 0" or "rgb (1, 0, 0)"
- // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
- // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
- // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
- // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
- // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
- //
- function inputToRGB(color) {
-
- var rgb = { r: 0, g: 0, b: 0 };
- var a = 1;
- var ok = false;
- var format = false;
-
- if (typeof color == "string") {
- color = stringInputToObject(color);
- }
-
- if (typeof color == "object") {
- if (color.hasOwnProperty("r") && color.hasOwnProperty("g") && color.hasOwnProperty("b")) {
- rgb = rgbToRgb(color.r, color.g, color.b);
- ok = true;
- format = "rgb";
- }
- else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("v")) {
- rgb = hsvToRgb(color.h, color.s, color.v);
- ok = true;
- format = "hsv";
- }
- else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("l")) {
- rgb = hslToRgb(color.h, color.s, color.l);
- ok = true;
- format = "hsl";
- }
-
- if (color.hasOwnProperty("a")) {
- a = color.a;
- }
- }
-
- rgb.r = mathMin(255, mathMax(rgb.r, 0));
- rgb.g = mathMin(255, mathMax(rgb.g, 0));
- rgb.b = mathMin(255, mathMax(rgb.b, 0));
-
-
- // Don't let the range of [0,255] come back in [0,1].
- // Potentially lose a little bit of precision here, but will fix issues where
- // .5 gets interpreted as half of the total, instead of half of 1.
- // If it was supposed to be 128, this was already taken care of in the conversion function
- if (rgb.r < 1) { rgb.r = mathRound(rgb.r); }
- if (rgb.g < 1) { rgb.g = mathRound(rgb.g); }
- if (rgb.b < 1) { rgb.b = mathRound(rgb.b); }
-
- return {
- ok: ok,
- format: (color && color.format) || format,
- r: rgb.r,
- g: rgb.g,
- b: rgb.b,
- a: a
- };
- }
-
-
-
- // Conversion Functions
- // --------------------
-
- // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
- //
-
- // `rgbToRgb`
- // Handle bounds / percentage checking to conform to CSS color spec
- //
- // *Assumes:* r, g, b in [0, 255] or [0, 1]
- // *Returns:* { r, g, b } in [0, 255]
- function rgbToRgb(r, g, b) {
- return {
- r: bound01(r, 255) * 255,
- g: bound01(g, 255) * 255,
- b: bound01(b, 255) * 255
- };
- }
-
- // `rgbToHsl`
- // Converts an RGB color value to HSL.
- // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
- // *Returns:* { h, s, l } in [0,1]
- function rgbToHsl(r, g, b) {
-
- r = bound01(r, 255);
- g = bound01(g, 255);
- b = bound01(b, 255);
-
- var max = mathMax(r, g, b), min = mathMin(r, g, b);
- var h, s, l = (max + min) / 2;
-
- if (max == min) {
- h = s = 0; // achromatic
- }
- else {
- var d = max - min;
- s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
- switch (max) {
- case r: h = (g - b) / d + (g < b ? 6 : 0); break;
- case g: h = (b - r) / d + 2; break;
- case b: h = (r - g) / d + 4; break;
- }
-
- h /= 6;
- }
-
- return { h: h, s: s, l: l };
- }
-
- // `hslToRgb`
- // Converts an HSL color value to RGB.
- // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
- // *Returns:* { r, g, b } in the set [0, 255]
- function hslToRgb(h, s, l) {
- var r, g, b;
-
- h = bound01(h, 360);
- s = bound01(s, 100);
- l = bound01(l, 100);
-
- function hue2rgb(p, q, t) {
- if (t < 0) t += 1;
- if (t > 1) t -= 1;
- if (t < 1 / 6) return p + (q - p) * 6 * t;
- if (t < 1 / 2) return q;
- if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
- return p;
- }
-
- if (s === 0) {
- r = g = b = l; // achromatic
- }
- else {
- var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
- var p = 2 * l - q;
- r = hue2rgb(p, q, h + 1 / 3);
- g = hue2rgb(p, q, h);
- b = hue2rgb(p, q, h - 1 / 3);
- }
-
- return { r: r * 255, g: g * 255, b: b * 255 };
- }
-
- // `rgbToHsv`
- // Converts an RGB color value to HSV
- // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
- // *Returns:* { h, s, v } in [0,1]
- function rgbToHsv(r, g, b) {
-
- r = bound01(r, 255);
- g = bound01(g, 255);
- b = bound01(b, 255);
-
- var max = mathMax(r, g, b), min = mathMin(r, g, b);
- var h, s, v = max;
-
- var d = max - min;
- s = max === 0 ? 0 : d / max;
-
- if (max == min) {
- h = 0; // achromatic
- }
- else {
- switch (max) {
- case r: h = (g - b) / d + (g < b ? 6 : 0); break;
- case g: h = (b - r) / d + 2; break;
- case b: h = (r - g) / d + 4; break;
- }
- h /= 6;
- }
- return { h: h, s: s, v: v };
- }
-
- // `hsvToRgb`
- // Converts an HSV color value to RGB.
- // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
- // *Returns:* { r, g, b } in the set [0, 255]
- function hsvToRgb(h, s, v) {
- h = bound01(h, 360) * 6;
- s = bound01(s, 100);
- v = bound01(v, 100);
-
- var i = math.floor(h),
- f = h - i,
- p = v * (1 - s),
- q = v * (1 - f * s),
- t = v * (1 - (1 - f) * s),
- mod = i % 6,
- r = [v, q, p, p, t, v][mod],
- g = [t, v, v, q, p, p][mod],
- b = [p, p, t, v, v, q][mod];
-
- return { r: r * 255, g: g * 255, b: b * 255 };
- }
-
- // `rgbToHex`
- // Converts an RGB color to hex
- // Assumes r, g, and b are contained in the set [0, 255]
- // Returns a 3 or 6 character hex
- function rgbToHex(r, g, b, force6Char) {
-
- var hex = [
- pad2(mathRound(r).toString(16)),
- pad2(mathRound(g).toString(16)),
- pad2(mathRound(b).toString(16))
- ];
-
- // Return a 3 character hex if possible
- if (!force6Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {
- return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
- }
-
- return hex.join("");
- }
-
- // `equals`
- // Can be called with any tinycolor input
- tinycolor.equals = function (color1, color2) {
- if (!color1 || !color2) { return false; }
- return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
- };
- tinycolor.random = function () {
- return tinycolor.fromRatio({
- r: mathRandom(),
- g: mathRandom(),
- b: mathRandom()
- });
- };
-
-
- // Modification Functions
- // ----------------------
- // Thanks to less.js for some of the basics here
- //
-
-
- tinycolor.desaturate = function (color, amount) {
- var hsl = tinycolor(color).toHsl();
- hsl.s -= ((amount || 10) / 100);
- hsl.s = clamp01(hsl.s);
- return tinycolor(hsl);
- };
- tinycolor.saturate = function (color, amount) {
- var hsl = tinycolor(color).toHsl();
- hsl.s += ((amount || 10) / 100);
- hsl.s = clamp01(hsl.s);
- return tinycolor(hsl);
- };
- tinycolor.greyscale = function (color) {
- return tinycolor.desaturate(color, 100);
- };
- tinycolor.lighten = function (color, amount) {
- var hsl = tinycolor(color).toHsl();
- hsl.l += ((amount || 10) / 100);
- hsl.l = clamp01(hsl.l);
- return tinycolor(hsl);
- };
- tinycolor.darken = function (color, amount) {
- var hsl = tinycolor(color).toHsl();
- hsl.l -= ((amount || 10) / 100);
- hsl.l = clamp01(hsl.l);
- return tinycolor(hsl);
- };
- tinycolor.complement = function (color) {
- var hsl = tinycolor(color).toHsl();
- hsl.h = (hsl.h + 0.5) % 1;
- return tinycolor(hsl);
- };
-
-
- // Combination Functions
- // ---------------------
- // Thanks to jQuery xColor for some of the ideas behind these
- //
-
- tinycolor.triad = function (color) {
- var hsl = tinycolor(color).toHsl();
- var h = hsl.h * 360;
- return [
- tinycolor(color),
- tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }),
- tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l })
- ];
- };
- tinycolor.tetrad = function (color) {
- var hsl = tinycolor(color).toHsl();
- var h = hsl.h * 360;
- return [
- tinycolor(color),
- tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }),
- tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }),
- tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l })
- ];
- };
- tinycolor.splitcomplement = function (color) {
- var hsl = tinycolor(color).toHsl();
- var h = hsl.h * 360;
- return [
- tinycolor(color),
- tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l }),
- tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l })
- ];
- };
- tinycolor.analogous = function (color, results, slices) {
- results = results || 6;
- slices = slices || 30;
-
- var hsl = tinycolor(color).toHsl();
- var part = 360 / slices;
- var ret = [tinycolor(color)];
-
- hsl.h *= 360;
-
- for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) {
- hsl.h = (hsl.h + part) % 360;
- ret.push(tinycolor(hsl));
- }
- return ret;
- };
- tinycolor.monochromatic = function (color, results) {
- results = results || 6;
- var hsv = tinycolor(color).toHsv();
- var h = hsv.h, s = hsv.s, v = hsv.v;
- var ret = [];
- var modification = 1 / results;
-
- while (results--) {
- ret.push(tinycolor({ h: h, s: s, v: v }));
- v = (v + modification) % 1;
- }
-
- return ret;
- };
- tinycolor.readable = function (color1, color2) {
- var a = tinycolor(color1).toRgb(), b = tinycolor(color2).toRgb();
- return (
- (b.r - a.r) * (b.r - a.r) +
- (b.g - a.g) * (b.g - a.g) +
- (b.b - a.b) * (b.b - a.b)
- ) > 0x28A4;
- };
-
- // Big List of Colors
- // ---------
- //
- var names = tinycolor.names = {
- aliceblue: "f0f8ff",
- antiquewhite: "faebd7",
- aqua: "0ff",
- aquamarine: "7fffd4",
- azure: "f0ffff",
- beige: "f5f5dc",
- bisque: "ffe4c4",
- black: "000",
- blanchedalmond: "ffebcd",
- blue: "00f",
- blueviolet: "8a2be2",
- brown: "a52a2a",
- burlywood: "deb887",
- burntsienna: "ea7e5d",
- cadetblue: "5f9ea0",
- chartreuse: "7fff00",
- chocolate: "d2691e",
- coral: "ff7f50",
- cornflowerblue: "6495ed",
- cornsilk: "fff8dc",
- crimson: "dc143c",
- cyan: "0ff",
- darkblue: "00008b",
- darkcyan: "008b8b",
- darkgoldenrod: "b8860b",
- darkgray: "a9a9a9",
- darkgreen: "006400",
- darkgrey: "a9a9a9",
- darkkhaki: "bdb76b",
- darkmagenta: "8b008b",
- darkolivegreen: "556b2f",
- darkorange: "ff8c00",
- darkorchid: "9932cc",
- darkred: "8b0000",
- darksalmon: "e9967a",
- darkseagreen: "8fbc8f",
- darkslateblue: "483d8b",
- darkslategray: "2f4f4f",
- darkslategrey: "2f4f4f",
- darkturquoise: "00ced1",
- darkviolet: "9400d3",
- deeppink: "ff1493",
- deepskyblue: "00bfff",
- dimgray: "696969",
- dimgrey: "696969",
- dodgerblue: "1e90ff",
- firebrick: "b22222",
- floralwhite: "fffaf0",
- forestgreen: "228b22",
- fuchsia: "f0f",
- gainsboro: "dcdcdc",
- ghostwhite: "f8f8ff",
- gold: "ffd700",
- goldenrod: "daa520",
- gray: "808080",
- green: "008000",
- greenyellow: "adff2f",
- grey: "808080",
- honeydew: "f0fff0",
- hotpink: "ff69b4",
- indianred: "cd5c5c",
- indigo: "4b0082",
- ivory: "fffff0",
- khaki: "f0e68c",
- lavender: "e6e6fa",
- lavenderblush: "fff0f5",
- lawngreen: "7cfc00",
- lemonchiffon: "fffacd",
- lightblue: "add8e6",
- lightcoral: "f08080",
- lightcyan: "e0ffff",
- lightgoldenrodyellow: "fafad2",
- lightgray: "d3d3d3",
- lightgreen: "90ee90",
- lightgrey: "d3d3d3",
- lightpink: "ffb6c1",
- lightsalmon: "ffa07a",
- lightseagreen: "20b2aa",
- lightskyblue: "87cefa",
- lightslategray: "789",
- lightslategrey: "789",
- lightsteelblue: "b0c4de",
- lightyellow: "ffffe0",
- lime: "0f0",
- limegreen: "32cd32",
- linen: "faf0e6",
- magenta: "f0f",
- maroon: "800000",
- mediumaquamarine: "66cdaa",
- mediumblue: "0000cd",
- mediumorchid: "ba55d3",
- mediumpurple: "9370db",
- mediumseagreen: "3cb371",
- mediumslateblue: "7b68ee",
- mediumspringgreen: "00fa9a",
- mediumturquoise: "48d1cc",
- mediumvioletred: "c71585",
- midnightblue: "191970",
- mintcream: "f5fffa",
- mistyrose: "ffe4e1",
- moccasin: "ffe4b5",
- navajowhite: "ffdead",
- navy: "000080",
- oldlace: "fdf5e6",
- olive: "808000",
- olivedrab: "6b8e23",
- orange: "ffa500",
- orangered: "ff4500",
- orchid: "da70d6",
- palegoldenrod: "eee8aa",
- palegreen: "98fb98",
- paleturquoise: "afeeee",
- palevioletred: "db7093",
- papayawhip: "ffefd5",
- peachpuff: "ffdab9",
- peru: "cd853f",
- pink: "ffc0cb",
- plum: "dda0dd",
- powderblue: "b0e0e6",
- purple: "800080",
- red: "f00",
- rosybrown: "bc8f8f",
- royalblue: "4169e1",
- saddlebrown: "8b4513",
- salmon: "fa8072",
- sandybrown: "f4a460",
- seagreen: "2e8b57",
- seashell: "fff5ee",
- sienna: "a0522d",
- silver: "c0c0c0",
- skyblue: "87ceeb",
- slateblue: "6a5acd",
- slategray: "708090",
- slategrey: "708090",
- snow: "fffafa",
- springgreen: "00ff7f",
- steelblue: "4682b4",
- tan: "d2b48c",
- teal: "008080",
- thistle: "d8bfd8",
- tomato: "ff6347",
- turquoise: "40e0d0",
- violet: "ee82ee",
- wheat: "f5deb3",
- white: "fff",
- whitesmoke: "f5f5f5",
- yellow: "ff0",
- yellowgreen: "9acd32"
- };
-
- // Make it easy to access colors via `hexNames[hex]`
- var hexNames = tinycolor.hexNames = flip(names);
-
-
- // Utilities
- // ---------
-
- // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`
- function flip(o) {
- var flipped = {};
- for (var i in o) {
- if (o.hasOwnProperty(i)) {
- flipped[o[i]] = i;
- }
- }
- return flipped;
- }
-
- // Take input from [0, n] and return it as [0, 1]
- function bound01(n, max) {
- if (isOnePointZero(n)) { n = "100%"; }
-
- var processPercent = isPercentage(n);
- n = mathMin(max, mathMax(0, parseFloat(n)));
-
- // Automatically convert percentage into number
- if (processPercent) {
- n = n * (max / 100);
- }
-
- // Handle floating point rounding errors
- if (math.abs(n - max) < 0.000001) {
- return 1;
- }
- else if (n >= 1) {
- return (n % max) / parseFloat(max);
- }
- return n;
- }
-
- // Force a number between 0 and 1
- function clamp01(val) {
- return mathMin(1, mathMax(0, val));
- }
-
- // Parse an integer into hex
- function parseHex(val) {
- return parseInt(val, 16);
- }
-
- // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
- //
- function isOnePointZero(n) {
- return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1;
- }
-
- // Check to see if string passed in is a percentage
- function isPercentage(n) {
- return typeof n === "string" && n.indexOf('%') != -1;
- }
-
- // Force a hex value to have 2 characters
- function pad2(c) {
- return c.length == 1 ? '0' + c : '' + c;
- }
-
- var matchers = (function () {
-
- //
- var CSS_INTEGER = "[-\\+]?\\d+%?";
-
- //
- var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
-
- // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
- var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
-
- // Actual matching.
- // Parentheses and commas are optional, but not required.
- // Whitespace can take the place of commas or opening paren
- var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
- var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
-
- return {
- rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
- rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
- hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
- hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
- hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
- hex3: /^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
- hex6: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
- };
- })();
-
- // `stringInputToObject`
- // Permissive string parsing. Take in a number of formats, and output an object
- // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
- function stringInputToObject(color) {
-
- color = color.replace(trimLeft, '').replace(trimRight, '').toLowerCase();
- var named = false;
- if (names[color]) {
- color = names[color];
- named = true;
- }
- else if (color == 'transparent') {
- return { r: 0, g: 0, b: 0, a: 0 };
- }
-
- // Try to match string input using regular expressions.
- // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
- // Just return an object and let the conversion functions handle that.
- // This way the result will be the same whether the tinycolor is initialized with string or object.
- var match;
- if ((match = matchers.rgb.exec(color))) {
- return { r: match[1], g: match[2], b: match[3] };
- }
- if ((match = matchers.rgba.exec(color))) {
- return { r: match[1], g: match[2], b: match[3], a: match[4] };
- }
- if ((match = matchers.hsl.exec(color))) {
- return { h: match[1], s: match[2], l: match[3] };
- }
- if ((match = matchers.hsla.exec(color))) {
- return { h: match[1], s: match[2], l: match[3], a: match[4] };
- }
- if ((match = matchers.hsv.exec(color))) {
- return { h: match[1], s: match[2], v: match[3] };
- }
- if ((match = matchers.hex6.exec(color))) {
- return {
- r: parseHex(match[1]),
- g: parseHex(match[2]),
- b: parseHex(match[3]),
- format: named ? "name" : "hex"
- };
- }
- if ((match = matchers.hex3.exec(color))) {
- return {
- r: parseHex(match[1] + '' + match[1]),
- g: parseHex(match[2] + '' + match[2]),
- b: parseHex(match[3] + '' + match[3]),
- format: named ? "name" : "hex"
- };
- }
-
- return false;
- }
-
- // Everything is ready, expose to window
- window.tinycolor = tinycolor;
-
- })(this);
-
- $(function () {
- if ($.fn.spectrum.load) {
- $.fn.spectrum.processNativeColorInputs();
- }
- });
-
-})(window, jQuery);
diff --git a/app/assets/javascripts/tinycolor.js b/app/assets/javascripts/tinycolor.js
deleted file mode 100644
index d7ff1131..00000000
--- a/app/assets/javascripts/tinycolor.js
+++ /dev/null
@@ -1,1112 +0,0 @@
-// TinyColor v1.1.0
-// https://github.com/bgrins/TinyColor
-// Brian Grinstead, MIT License
-
-(function() {
-
-var trimLeft = /^[\s,#]+/,
- trimRight = /\s+$/,
- tinyCounter = 0,
- math = Math,
- mathRound = math.round,
- mathMin = math.min,
- mathMax = math.max,
- mathRandom = math.random;
-
-var tinycolor = function tinycolor (color, opts) {
-
- color = (color) ? color : '';
- opts = opts || { };
-
- // If input is already a tinycolor, return itself
- if (color instanceof tinycolor) {
- return color;
- }
- // If we are called as a function, call using new instead
- if (!(this instanceof tinycolor)) {
- return new tinycolor(color, opts);
- }
-
- var rgb = inputToRGB(color);
- this._originalInput = color,
- this._r = rgb.r,
- this._g = rgb.g,
- this._b = rgb.b,
- this._a = rgb.a,
- this._roundA = mathRound(100*this._a) / 100,
- this._format = opts.format || rgb.format;
- this._gradientType = opts.gradientType;
-
- // Don't let the range of [0,255] come back in [0,1].
- // Potentially lose a little bit of precision here, but will fix issues where
- // .5 gets interpreted as half of the total, instead of half of 1
- // If it was supposed to be 128, this was already taken care of by `inputToRgb`
- if (this._r < 1) { this._r = mathRound(this._r); }
- if (this._g < 1) { this._g = mathRound(this._g); }
- if (this._b < 1) { this._b = mathRound(this._b); }
-
- this._ok = rgb.ok;
- this._tc_id = tinyCounter++;
-};
-
-tinycolor.prototype = {
- isDark: function() {
- return this.getBrightness() < 128;
- },
- isLight: function() {
- return !this.isDark();
- },
- isValid: function() {
- return this._ok;
- },
- getOriginalInput: function() {
- return this._originalInput;
- },
- getFormat: function() {
- return this._format;
- },
- getAlpha: function() {
- return this._a;
- },
- getBrightness: function() {
- var rgb = this.toRgb();
- return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
- },
- setAlpha: function(value) {
- this._a = boundAlpha(value);
- this._roundA = mathRound(100*this._a) / 100;
- return this;
- },
- toHsv: function() {
- var hsv = rgbToHsv(this._r, this._g, this._b);
- return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a };
- },
- toHsvString: function() {
- var hsv = rgbToHsv(this._r, this._g, this._b);
- var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), v = mathRound(hsv.v * 100);
- return (this._a == 1) ?
- "hsv(" + h + ", " + s + "%, " + v + "%)" :
- "hsva(" + h + ", " + s + "%, " + v + "%, "+ this._roundA + ")";
- },
- toHsl: function() {
- var hsl = rgbToHsl(this._r, this._g, this._b);
- return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a };
- },
- toHslString: function() {
- var hsl = rgbToHsl(this._r, this._g, this._b);
- var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), l = mathRound(hsl.l * 100);
- return (this._a == 1) ?
- "hsl(" + h + ", " + s + "%, " + l + "%)" :
- "hsla(" + h + ", " + s + "%, " + l + "%, "+ this._roundA + ")";
- },
- toHex: function(allow3Char) {
- return rgbToHex(this._r, this._g, this._b, allow3Char);
- },
- toHexString: function(allow3Char) {
- return '#' + this.toHex(allow3Char);
- },
- toHex8: function() {
- return rgbaToHex(this._r, this._g, this._b, this._a);
- },
- toHex8String: function() {
- return '#' + this.toHex8();
- },
- toRgb: function() {
- return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a };
- },
- toRgbString: function() {
- return (this._a == 1) ?
- "rgb(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ")" :
- "rgba(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ", " + this._roundA + ")";
- },
- toPercentageRgb: function() {
- return { r: mathRound(bound01(this._r, 255) * 100) + "%", g: mathRound(bound01(this._g, 255) * 100) + "%", b: mathRound(bound01(this._b, 255) * 100) + "%", a: this._a };
- },
- toPercentageRgbString: function() {
- return (this._a == 1) ?
- "rgb(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%)" :
- "rgba(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")";
- },
- toName: function() {
- if (this._a === 0) {
- return "transparent";
- }
-
- if (this._a < 1) {
- return false;
- }
-
- return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
- },
- toFilter: function(secondColor) {
- var hex8String = '#' + rgbaToHex(this._r, this._g, this._b, this._a);
- var secondHex8String = hex8String;
- var gradientType = this._gradientType ? "GradientType = 1, " : "";
-
- if (secondColor) {
- var s = tinycolor(secondColor);
- secondHex8String = s.toHex8String();
- }
-
- return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")";
- },
- toString: function(format) {
- var formatSet = !!format;
- format = format || this._format;
-
- var formattedString = false;
- var hasAlpha = this._a < 1 && this._a >= 0;
- var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "name");
-
- if (needsAlphaFormat) {
- // Special case for "transparent", all other non-alpha formats
- // will return rgba when there is transparency.
- if (format === "name" && this._a === 0) {
- return this.toName();
- }
- return this.toRgbString();
- }
- if (format === "rgb") {
- formattedString = this.toRgbString();
- }
- if (format === "prgb") {
- formattedString = this.toPercentageRgbString();
- }
- if (format === "hex" || format === "hex6") {
- formattedString = this.toHexString();
- }
- if (format === "hex3") {
- formattedString = this.toHexString(true);
- }
- if (format === "hex8") {
- formattedString = this.toHex8String();
- }
- if (format === "name") {
- formattedString = this.toName();
- }
- if (format === "hsl") {
- formattedString = this.toHslString();
- }
- if (format === "hsv") {
- formattedString = this.toHsvString();
- }
-
- return formattedString || this.toHexString();
- },
-
- _applyModification: function(fn, args) {
- var color = fn.apply(null, [this].concat([].slice.call(args)));
- this._r = color._r;
- this._g = color._g;
- this._b = color._b;
- this.setAlpha(color._a);
- return this;
- },
- lighten: function() {
- return this._applyModification(lighten, arguments);
- },
- brighten: function() {
- return this._applyModification(brighten, arguments);
- },
- darken: function() {
- return this._applyModification(darken, arguments);
- },
- desaturate: function() {
- return this._applyModification(desaturate, arguments);
- },
- saturate: function() {
- return this._applyModification(saturate, arguments);
- },
- greyscale: function() {
- return this._applyModification(greyscale, arguments);
- },
- spin: function() {
- return this._applyModification(spin, arguments);
- },
-
- _applyCombination: function(fn, args) {
- return fn.apply(null, [this].concat([].slice.call(args)));
- },
- analogous: function() {
- return this._applyCombination(analogous, arguments);
- },
- complement: function() {
- return this._applyCombination(complement, arguments);
- },
- monochromatic: function() {
- return this._applyCombination(monochromatic, arguments);
- },
- splitcomplement: function() {
- return this._applyCombination(splitcomplement, arguments);
- },
- triad: function() {
- return this._applyCombination(triad, arguments);
- },
- tetrad: function() {
- return this._applyCombination(tetrad, arguments);
- }
-};
-
-// If input is an object, force 1 into "1.0" to handle ratios properly
-// String input requires "1.0" as input, so 1 will be treated as 1
-tinycolor.fromRatio = function(color, opts) {
- if (typeof color == "object") {
- var newColor = {};
- for (var i in color) {
- if (color.hasOwnProperty(i)) {
- if (i === "a") {
- newColor[i] = color[i];
- }
- else {
- newColor[i] = convertToPercentage(color[i]);
- }
- }
- }
- color = newColor;
- }
-
- return tinycolor(color, opts);
-};
-
-// Given a string or object, convert that input to RGB
-// Possible string inputs:
-//
-// "red"
-// "#f00" or "f00"
-// "#ff0000" or "ff0000"
-// "#ff000000" or "ff000000"
-// "rgb 255 0 0" or "rgb (255, 0, 0)"
-// "rgb 1.0 0 0" or "rgb (1, 0, 0)"
-// "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
-// "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
-// "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
-// "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
-// "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
-//
-function inputToRGB(color) {
-
- var rgb = { r: 0, g: 0, b: 0 };
- var a = 1;
- var ok = false;
- var format = false;
-
- if (typeof color == "string") {
- color = stringInputToObject(color);
- }
-
- if (typeof color == "object") {
- if (color.hasOwnProperty("r") && color.hasOwnProperty("g") && color.hasOwnProperty("b")) {
- rgb = rgbToRgb(color.r, color.g, color.b);
- ok = true;
- format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
- }
- else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("v")) {
- color.s = convertToPercentage(color.s);
- color.v = convertToPercentage(color.v);
- rgb = hsvToRgb(color.h, color.s, color.v);
- ok = true;
- format = "hsv";
- }
- else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("l")) {
- color.s = convertToPercentage(color.s);
- color.l = convertToPercentage(color.l);
- rgb = hslToRgb(color.h, color.s, color.l);
- ok = true;
- format = "hsl";
- }
-
- if (color.hasOwnProperty("a")) {
- a = color.a;
- }
- }
-
- a = boundAlpha(a);
-
- return {
- ok: ok,
- format: color.format || format,
- r: mathMin(255, mathMax(rgb.r, 0)),
- g: mathMin(255, mathMax(rgb.g, 0)),
- b: mathMin(255, mathMax(rgb.b, 0)),
- a: a
- };
-}
-
-
-// Conversion Functions
-// --------------------
-
-// `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
-//
-
-// `rgbToRgb`
-// Handle bounds / percentage checking to conform to CSS color spec
-//
-// *Assumes:* r, g, b in [0, 255] or [0, 1]
-// *Returns:* { r, g, b } in [0, 255]
-function rgbToRgb(r, g, b){
- return {
- r: bound01(r, 255) * 255,
- g: bound01(g, 255) * 255,
- b: bound01(b, 255) * 255
- };
-}
-
-// `rgbToHsl`
-// Converts an RGB color value to HSL.
-// *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
-// *Returns:* { h, s, l } in [0,1]
-function rgbToHsl(r, g, b) {
-
- r = bound01(r, 255);
- g = bound01(g, 255);
- b = bound01(b, 255);
-
- var max = mathMax(r, g, b), min = mathMin(r, g, b);
- var h, s, l = (max + min) / 2;
-
- if(max == min) {
- h = s = 0; // achromatic
- }
- else {
- var d = max - min;
- s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
- switch(max) {
- case r: h = (g - b) / d + (g < b ? 6 : 0); break;
- case g: h = (b - r) / d + 2; break;
- case b: h = (r - g) / d + 4; break;
- }
-
- h /= 6;
- }
-
- return { h: h, s: s, l: l };
-}
-
-// `hslToRgb`
-// Converts an HSL color value to RGB.
-// *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
-// *Returns:* { r, g, b } in the set [0, 255]
-function hslToRgb(h, s, l) {
- var r, g, b;
-
- h = bound01(h, 360);
- s = bound01(s, 100);
- l = bound01(l, 100);
-
- function hue2rgb(p, q, t) {
- if(t < 0) t += 1;
- if(t > 1) t -= 1;
- if(t < 1/6) return p + (q - p) * 6 * t;
- if(t < 1/2) return q;
- if(t < 2/3) return p + (q - p) * (2/3 - t) * 6;
- return p;
- }
-
- if(s === 0) {
- r = g = b = l; // achromatic
- }
- else {
- var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
- var p = 2 * l - q;
- r = hue2rgb(p, q, h + 1/3);
- g = hue2rgb(p, q, h);
- b = hue2rgb(p, q, h - 1/3);
- }
-
- return { r: r * 255, g: g * 255, b: b * 255 };
-}
-
-// `rgbToHsv`
-// Converts an RGB color value to HSV
-// *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
-// *Returns:* { h, s, v } in [0,1]
-function rgbToHsv(r, g, b) {
-
- r = bound01(r, 255);
- g = bound01(g, 255);
- b = bound01(b, 255);
-
- var max = mathMax(r, g, b), min = mathMin(r, g, b);
- var h, s, v = max;
-
- var d = max - min;
- s = max === 0 ? 0 : d / max;
-
- if(max == min) {
- h = 0; // achromatic
- }
- else {
- switch(max) {
- case r: h = (g - b) / d + (g < b ? 6 : 0); break;
- case g: h = (b - r) / d + 2; break;
- case b: h = (r - g) / d + 4; break;
- }
- h /= 6;
- }
- return { h: h, s: s, v: v };
-}
-
-// `hsvToRgb`
-// Converts an HSV color value to RGB.
-// *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
-// *Returns:* { r, g, b } in the set [0, 255]
- function hsvToRgb(h, s, v) {
-
- h = bound01(h, 360) * 6;
- s = bound01(s, 100);
- v = bound01(v, 100);
-
- var i = math.floor(h),
- f = h - i,
- p = v * (1 - s),
- q = v * (1 - f * s),
- t = v * (1 - (1 - f) * s),
- mod = i % 6,
- r = [v, q, p, p, t, v][mod],
- g = [t, v, v, q, p, p][mod],
- b = [p, p, t, v, v, q][mod];
-
- return { r: r * 255, g: g * 255, b: b * 255 };
-}
-
-// `rgbToHex`
-// Converts an RGB color to hex
-// Assumes r, g, and b are contained in the set [0, 255]
-// Returns a 3 or 6 character hex
-function rgbToHex(r, g, b, allow3Char) {
-
- var hex = [
- pad2(mathRound(r).toString(16)),
- pad2(mathRound(g).toString(16)),
- pad2(mathRound(b).toString(16))
- ];
-
- // Return a 3 character hex if possible
- if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {
- return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
- }
-
- return hex.join("");
-}
- // `rgbaToHex`
- // Converts an RGBA color plus alpha transparency to hex
- // Assumes r, g, b and a are contained in the set [0, 255]
- // Returns an 8 character hex
- function rgbaToHex(r, g, b, a) {
-
- var hex = [
- pad2(convertDecimalToHex(a)),
- pad2(mathRound(r).toString(16)),
- pad2(mathRound(g).toString(16)),
- pad2(mathRound(b).toString(16))
- ];
-
- return hex.join("");
- }
-
-// `equals`
-// Can be called with any tinycolor input
-tinycolor.equals = function (color1, color2) {
- if (!color1 || !color2) { return false; }
- return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
-};
-tinycolor.random = function() {
- return tinycolor.fromRatio({
- r: mathRandom(),
- g: mathRandom(),
- b: mathRandom()
- });
-};
-
-
-// Modification Functions
-// ----------------------
-// Thanks to less.js for some of the basics here
-//
-
-function desaturate(color, amount) {
- amount = (amount === 0) ? 0 : (amount || 10);
- var hsl = tinycolor(color).toHsl();
- hsl.s -= amount / 100;
- hsl.s = clamp01(hsl.s);
- return tinycolor(hsl);
-}
-
-function saturate(color, amount) {
- amount = (amount === 0) ? 0 : (amount || 10);
- var hsl = tinycolor(color).toHsl();
- hsl.s += amount / 100;
- hsl.s = clamp01(hsl.s);
- return tinycolor(hsl);
-}
-
-function greyscale(color) {
- return tinycolor(color).desaturate(100);
-}
-
-function lighten (color, amount) {
- amount = (amount === 0) ? 0 : (amount || 10);
- var hsl = tinycolor(color).toHsl();
- hsl.l += amount / 100;
- hsl.l = clamp01(hsl.l);
- return tinycolor(hsl);
-}
-
-function brighten(color, amount) {
- amount = (amount === 0) ? 0 : (amount || 10);
- var rgb = tinycolor(color).toRgb();
- rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100))));
- rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100))));
- rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100))));
- return tinycolor(rgb);
-}
-
-function darken (color, amount) {
- amount = (amount === 0) ? 0 : (amount || 10);
- var hsl = tinycolor(color).toHsl();
- hsl.l -= amount / 100;
- hsl.l = clamp01(hsl.l);
- return tinycolor(hsl);
-}
-
-// Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
-// Values outside of this range will be wrapped into this range.
-function spin(color, amount) {
- var hsl = tinycolor(color).toHsl();
- var hue = (mathRound(hsl.h) + amount) % 360;
- hsl.h = hue < 0 ? 360 + hue : hue;
- return tinycolor(hsl);
-}
-
-// Combination Functions
-// ---------------------
-// Thanks to jQuery xColor for some of the ideas behind these
-//
-
-function complement(color) {
- var hsl = tinycolor(color).toHsl();
- hsl.h = (hsl.h + 180) % 360;
- return tinycolor(hsl);
-}
-
-function triad(color) {
- var hsl = tinycolor(color).toHsl();
- var h = hsl.h;
- return [
- tinycolor(color),
- tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }),
- tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l })
- ];
-}
-
-function tetrad(color) {
- var hsl = tinycolor(color).toHsl();
- var h = hsl.h;
- return [
- tinycolor(color),
- tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }),
- tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }),
- tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l })
- ];
-}
-
-function splitcomplement(color) {
- var hsl = tinycolor(color).toHsl();
- var h = hsl.h;
- return [
- tinycolor(color),
- tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}),
- tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l})
- ];
-}
-
-function analogous(color, results, slices) {
- results = results || 6;
- slices = slices || 30;
-
- var hsl = tinycolor(color).toHsl();
- var part = 360 / slices;
- var ret = [tinycolor(color)];
-
- for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) {
- hsl.h = (hsl.h + part) % 360;
- ret.push(tinycolor(hsl));
- }
- return ret;
-}
-
-function monochromatic(color, results) {
- results = results || 6;
- var hsv = tinycolor(color).toHsv();
- var h = hsv.h, s = hsv.s, v = hsv.v;
- var ret = [];
- var modification = 1 / results;
-
- while (results--) {
- ret.push(tinycolor({ h: h, s: s, v: v}));
- v = (v + modification) % 1;
- }
-
- return ret;
-}
-
-// Utility Functions
-// ---------------------
-
-tinycolor.mix = function(color1, color2, amount) {
- amount = (amount === 0) ? 0 : (amount || 50);
-
- var rgb1 = tinycolor(color1).toRgb();
- var rgb2 = tinycolor(color2).toRgb();
-
- var p = amount / 100;
- var w = p * 2 - 1;
- var a = rgb2.a - rgb1.a;
-
- var w1;
-
- if (w * a == -1) {
- w1 = w;
- } else {
- w1 = (w + a) / (1 + w * a);
- }
-
- w1 = (w1 + 1) / 2;
-
- var w2 = 1 - w1;
-
- var rgba = {
- r: rgb2.r * w1 + rgb1.r * w2,
- g: rgb2.g * w1 + rgb1.g * w2,
- b: rgb2.b * w1 + rgb1.b * w2,
- a: rgb2.a * p + rgb1.a * (1 - p)
- };
-
- return tinycolor(rgba);
-};
-
-
-// Readability Functions
-// ---------------------
-//
-
-// `readability`
-// Analyze the 2 colors and returns an object with the following properties:
-// `brightness`: difference in brightness between the two colors
-// `color`: difference in color/hue between the two colors
-tinycolor.readability = function(color1, color2) {
- var c1 = tinycolor(color1);
- var c2 = tinycolor(color2);
- var rgb1 = c1.toRgb();
- var rgb2 = c2.toRgb();
- var brightnessA = c1.getBrightness();
- var brightnessB = c2.getBrightness();
- var colorDiff = (
- Math.max(rgb1.r, rgb2.r) - Math.min(rgb1.r, rgb2.r) +
- Math.max(rgb1.g, rgb2.g) - Math.min(rgb1.g, rgb2.g) +
- Math.max(rgb1.b, rgb2.b) - Math.min(rgb1.b, rgb2.b)
- );
-
- return {
- brightness: Math.abs(brightnessA - brightnessB),
- color: colorDiff
- };
-};
-
-// `readable`
-// http://www.w3.org/TR/AERT#color-contrast
-// Ensure that foreground and background color combinations provide sufficient contrast.
-// *Example*
-// tinycolor.isReadable("#000", "#111") => false
-tinycolor.isReadable = function(color1, color2) {
- var readability = tinycolor.readability(color1, color2);
- return readability.brightness > 125 && readability.color > 500;
-};
-
-// `mostReadable`
-// Given a base color and a list of possible foreground or background
-// colors for that base, returns the most readable color.
-// *Example*
-// tinycolor.mostReadable("#123", ["#fff", "#000"]) => "#000"
-tinycolor.mostReadable = function(baseColor, colorList) {
- var bestColor = null;
- var bestScore = 0;
- var bestIsReadable = false;
- for (var i=0; i < colorList.length; i++) {
-
- // We normalize both around the "acceptable" breaking point,
- // but rank brightness constrast higher than hue.
-
- var readability = tinycolor.readability(baseColor, colorList[i]);
- var readable = readability.brightness > 125 && readability.color > 500;
- var score = 3 * (readability.brightness / 125) + (readability.color / 500);
-
- if ((readable && ! bestIsReadable) ||
- (readable && bestIsReadable && score > bestScore) ||
- ((! readable) && (! bestIsReadable) && score > bestScore)) {
- bestIsReadable = readable;
- bestScore = score;
- bestColor = tinycolor(colorList[i]);
- }
- }
- return bestColor;
-};
-
-
-// Big List of Colors
-// ------------------
-//
-var names = tinycolor.names = {
- aliceblue: "f0f8ff",
- antiquewhite: "faebd7",
- aqua: "0ff",
- aquamarine: "7fffd4",
- azure: "f0ffff",
- beige: "f5f5dc",
- bisque: "ffe4c4",
- black: "000",
- blanchedalmond: "ffebcd",
- blue: "00f",
- blueviolet: "8a2be2",
- brown: "a52a2a",
- burlywood: "deb887",
- burntsienna: "ea7e5d",
- cadetblue: "5f9ea0",
- chartreuse: "7fff00",
- chocolate: "d2691e",
- coral: "ff7f50",
- cornflowerblue: "6495ed",
- cornsilk: "fff8dc",
- crimson: "dc143c",
- cyan: "0ff",
- darkblue: "00008b",
- darkcyan: "008b8b",
- darkgoldenrod: "b8860b",
- darkgray: "a9a9a9",
- darkgreen: "006400",
- darkgrey: "a9a9a9",
- darkkhaki: "bdb76b",
- darkmagenta: "8b008b",
- darkolivegreen: "556b2f",
- darkorange: "ff8c00",
- darkorchid: "9932cc",
- darkred: "8b0000",
- darksalmon: "e9967a",
- darkseagreen: "8fbc8f",
- darkslateblue: "483d8b",
- darkslategray: "2f4f4f",
- darkslategrey: "2f4f4f",
- darkturquoise: "00ced1",
- darkviolet: "9400d3",
- deeppink: "ff1493",
- deepskyblue: "00bfff",
- dimgray: "696969",
- dimgrey: "696969",
- dodgerblue: "1e90ff",
- firebrick: "b22222",
- floralwhite: "fffaf0",
- forestgreen: "228b22",
- fuchsia: "f0f",
- gainsboro: "dcdcdc",
- ghostwhite: "f8f8ff",
- gold: "ffd700",
- goldenrod: "daa520",
- gray: "808080",
- green: "008000",
- greenyellow: "adff2f",
- grey: "808080",
- honeydew: "f0fff0",
- hotpink: "ff69b4",
- indianred: "cd5c5c",
- indigo: "4b0082",
- ivory: "fffff0",
- khaki: "f0e68c",
- lavender: "e6e6fa",
- lavenderblush: "fff0f5",
- lawngreen: "7cfc00",
- lemonchiffon: "fffacd",
- lightblue: "add8e6",
- lightcoral: "f08080",
- lightcyan: "e0ffff",
- lightgoldenrodyellow: "fafad2",
- lightgray: "d3d3d3",
- lightgreen: "90ee90",
- lightgrey: "d3d3d3",
- lightpink: "ffb6c1",
- lightsalmon: "ffa07a",
- lightseagreen: "20b2aa",
- lightskyblue: "87cefa",
- lightslategray: "789",
- lightslategrey: "789",
- lightsteelblue: "b0c4de",
- lightyellow: "ffffe0",
- lime: "0f0",
- limegreen: "32cd32",
- linen: "faf0e6",
- magenta: "f0f",
- maroon: "800000",
- mediumaquamarine: "66cdaa",
- mediumblue: "0000cd",
- mediumorchid: "ba55d3",
- mediumpurple: "9370db",
- mediumseagreen: "3cb371",
- mediumslateblue: "7b68ee",
- mediumspringgreen: "00fa9a",
- mediumturquoise: "48d1cc",
- mediumvioletred: "c71585",
- midnightblue: "191970",
- mintcream: "f5fffa",
- mistyrose: "ffe4e1",
- moccasin: "ffe4b5",
- navajowhite: "ffdead",
- navy: "000080",
- oldlace: "fdf5e6",
- olive: "808000",
- olivedrab: "6b8e23",
- orange: "ffa500",
- orangered: "ff4500",
- orchid: "da70d6",
- palegoldenrod: "eee8aa",
- palegreen: "98fb98",
- paleturquoise: "afeeee",
- palevioletred: "db7093",
- papayawhip: "ffefd5",
- peachpuff: "ffdab9",
- peru: "cd853f",
- pink: "ffc0cb",
- plum: "dda0dd",
- powderblue: "b0e0e6",
- purple: "800080",
- rebeccapurple: "663399",
- red: "f00",
- rosybrown: "bc8f8f",
- royalblue: "4169e1",
- saddlebrown: "8b4513",
- salmon: "fa8072",
- sandybrown: "f4a460",
- seagreen: "2e8b57",
- seashell: "fff5ee",
- sienna: "a0522d",
- silver: "c0c0c0",
- skyblue: "87ceeb",
- slateblue: "6a5acd",
- slategray: "708090",
- slategrey: "708090",
- snow: "fffafa",
- springgreen: "00ff7f",
- steelblue: "4682b4",
- tan: "d2b48c",
- teal: "008080",
- thistle: "d8bfd8",
- tomato: "ff6347",
- turquoise: "40e0d0",
- violet: "ee82ee",
- wheat: "f5deb3",
- white: "fff",
- whitesmoke: "f5f5f5",
- yellow: "ff0",
- yellowgreen: "9acd32"
-};
-
-// Make it easy to access colors via `hexNames[hex]`
-var hexNames = tinycolor.hexNames = flip(names);
-
-
-// Utilities
-// ---------
-
-// `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`
-function flip(o) {
- var flipped = { };
- for (var i in o) {
- if (o.hasOwnProperty(i)) {
- flipped[o[i]] = i;
- }
- }
- return flipped;
-}
-
-// Return a valid alpha value [0,1] with all invalid values being set to 1
-function boundAlpha(a) {
- a = parseFloat(a);
-
- if (isNaN(a) || a < 0 || a > 1) {
- a = 1;
- }
-
- return a;
-}
-
-// Take input from [0, n] and return it as [0, 1]
-function bound01(n, max) {
- if (isOnePointZero(n)) { n = "100%"; }
-
- var processPercent = isPercentage(n);
- n = mathMin(max, mathMax(0, parseFloat(n)));
-
- // Automatically convert percentage into number
- if (processPercent) {
- n = parseInt(n * max, 10) / 100;
- }
-
- // Handle floating point rounding errors
- if ((math.abs(n - max) < 0.000001)) {
- return 1;
- }
-
- // Convert into [0, 1] range if it isn't already
- return (n % max) / parseFloat(max);
-}
-
-// Force a number between 0 and 1
-function clamp01(val) {
- return mathMin(1, mathMax(0, val));
-}
-
-// Parse a base-16 hex value into a base-10 integer
-function parseIntFromHex(val) {
- return parseInt(val, 16);
-}
-
-// Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
-//
-function isOnePointZero(n) {
- return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1;
-}
-
-// Check to see if string passed in is a percentage
-function isPercentage(n) {
- return typeof n === "string" && n.indexOf('%') != -1;
-}
-
-// Force a hex value to have 2 characters
-function pad2(c) {
- return c.length == 1 ? '0' + c : '' + c;
-}
-
-// Replace a decimal with it's percentage value
-function convertToPercentage(n) {
- if (n <= 1) {
- n = (n * 100) + "%";
- }
-
- return n;
-}
-
-// Converts a decimal to a hex value
-function convertDecimalToHex(d) {
- return Math.round(parseFloat(d) * 255).toString(16);
-}
-// Converts a hex value to a decimal
-function convertHexToDecimal(h) {
- return (parseIntFromHex(h) / 255);
-}
-
-var matchers = (function() {
-
- //
- var CSS_INTEGER = "[-\\+]?\\d+%?";
-
- //
- var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
-
- // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
- var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
-
- // Actual matching.
- // Parentheses and commas are optional, but not required.
- // Whitespace can take the place of commas or opening paren
- var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
- var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
-
- return {
- rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
- rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
- hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
- hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
- hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
- hex3: /^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
- hex6: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
- hex8: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
- };
-})();
-
-// `stringInputToObject`
-// Permissive string parsing. Take in a number of formats, and output an object
-// based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
-function stringInputToObject(color) {
-
- color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase();
- var named = false;
- if (names[color]) {
- color = names[color];
- named = true;
- }
- else if (color == 'transparent') {
- return { r: 0, g: 0, b: 0, a: 0, format: "name" };
- }
-
- // Try to match string input using regular expressions.
- // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
- // Just return an object and let the conversion functions handle that.
- // This way the result will be the same whether the tinycolor is initialized with string or object.
- var match;
- if ((match = matchers.rgb.exec(color))) {
- return { r: match[1], g: match[2], b: match[3] };
- }
- if ((match = matchers.rgba.exec(color))) {
- return { r: match[1], g: match[2], b: match[3], a: match[4] };
- }
- if ((match = matchers.hsl.exec(color))) {
- return { h: match[1], s: match[2], l: match[3] };
- }
- if ((match = matchers.hsla.exec(color))) {
- return { h: match[1], s: match[2], l: match[3], a: match[4] };
- }
- if ((match = matchers.hsv.exec(color))) {
- return { h: match[1], s: match[2], v: match[3] };
- }
- if ((match = matchers.hex8.exec(color))) {
- return {
- a: convertHexToDecimal(match[1]),
- r: parseIntFromHex(match[2]),
- g: parseIntFromHex(match[3]),
- b: parseIntFromHex(match[4]),
- format: named ? "name" : "hex8"
- };
- }
- if ((match = matchers.hex6.exec(color))) {
- return {
- r: parseIntFromHex(match[1]),
- g: parseIntFromHex(match[2]),
- b: parseIntFromHex(match[3]),
- format: named ? "name" : "hex"
- };
- }
- if ((match = matchers.hex3.exec(color))) {
- return {
- r: parseIntFromHex(match[1] + '' + match[1]),
- g: parseIntFromHex(match[2] + '' + match[2]),
- b: parseIntFromHex(match[3] + '' + match[3]),
- format: named ? "name" : "hex"
- };
- }
-
- return false;
-}
-
-// Node: Export function
-if (typeof module !== "undefined" && module.exports) {
- module.exports = tinycolor;
-}
-// AMD/requirejs: Define the module
-else if (typeof define === 'function' && define.amd) {
- define(function () {return tinycolor;});
-}
-// Browser: Expose to window
-else {
- window.tinycolor = tinycolor;
-}
-
-})();
diff --git a/app/assets/javascripts/trianglify.min.js b/app/assets/javascripts/trianglify.min.js
deleted file mode 100644
index ef30d5e3..00000000
--- a/app/assets/javascripts/trianglify.min.js
+++ /dev/null
@@ -1 +0,0 @@
-function Trianglify(f){function e(f,e){return"undefined"!=typeof f?f:e}"undefined"==typeof f&&(f={}),this.options={cellsize:e(f.cellsize,150),bleed:e(f.cellsize,150),cellpadding:e(f.cellpadding,.1*f.cellsize||15),noiseIntensity:e(f.noiseIntensity,0),x_gradient:e(f.x_gradient,Trianglify.randomColor()),format:e(f.format,"svg"),fillOpacity:e(f.fillOpacity,1),strokeOpacity:e(f.strokeOpacity,1)},this.options.y_gradient=f.y_gradient||this.options.x_gradient.map(function(f){return d3.rgb(f).brighter(.5)})}"undefined"!=typeof module&&module.exports&&(d3=require("d3"),jsdom=require("jsdom"),document=new(jsdom.level(1,"core").Document),XMLSerializer=require("xmldom").XMLSerializer,btoa=require("btoa"),module.exports=Trianglify),Trianglify.randomColor=function(){var f=Object.keys(Trianglify.colorbrewer),e=Trianglify.colorbrewer[f[Math.floor(Math.random()*f.length)]];f=Object.keys(e);var d=e[f[Math.floor(Math.random()*f.length)]];return d},Trianglify.prototype.generate=function(f,e){return new Trianglify.Pattern(this.options,f,e)},Trianglify.Pattern=function(f,e,d){this.options=f,this.width=e,this.height=d,this.polys=this.generatePolygons(),this.svg=this.generateSVG();var a=new XMLSerializer;this.svgString=a.serializeToString(this.svg),this.base64=btoa(this.svgString),this.dataUri="data:image/svg+xml;base64,"+this.base64,this.dataUrl="url("+this.dataUri+")"},Trianglify.Pattern.prototype.append=function(){document.body.appendChild(this.svg)},Trianglify.Pattern.gradient_2d=function(f,e,d,a){return function(c,b){var t=d3.scale.linear().range(f).domain(d3.range(0,d,d/f.length)),i=d3.scale.linear().range(e).domain(d3.range(0,a,a/e.length));return d3.interpolateRgb(t(c),i(b))(.5)}},Trianglify.Pattern.prototype.generatePolygons=function(){var f=this.options,e=Math.ceil((this.width+2*f.bleed)/f.cellsize),d=Math.ceil((this.height+2*f.bleed)/f.cellsize),a=d3.range(e*d).map(function(d){var a=d%e,c=Math.floor(d/e),b=Math.round(-f.bleed+a*f.cellsize+Math.random()*(f.cellsize-2*f.cellpadding)+f.cellpadding),t=Math.round(-f.bleed+c*f.cellsize+Math.random()*(f.cellsize-2*f.cellpadding)+f.cellpadding);return[b,t]});return d3.geom.voronoi().triangles(a)},Trianglify.Pattern.prototype.generateSVG=function(){var f=this.options,e=Trianglify.Pattern.gradient_2d(f.x_gradient,f.y_gradient,this.width,this.height),d=document.createElementNS("http://www.w3.org/2000/svg","svg"),a=d3.select(d);a.attr("width",this.width),a.attr("height",this.height),a.attr("xmlns","http://www.w3.org/2000/svg");var c=a.append("g");if(f.noiseIntensity>.01){var b=a.append("filter").attr("id","noise");b.append("feTurbulence").attr("type","fractalNoise").attr("in","fillPaint").attr("fill","#F00").attr("baseFrequency",.7).attr("numOctaves","3").attr("stitchTiles","stitch");var t=b.append("feComponentTransfer");t.append("feFuncR").attr("type","linear").attr("slope","2").attr("intercept","-.5"),t.append("feFuncG").attr("type","linear").attr("slope","2").attr("intercept","-.5"),t.append("feFuncB").attr("type","linear").attr("slope","2").attr("intercept","-.5"),b.append("feColorMatrix").attr("type","matrix").attr("values","0.3333 0.3333 0.3333 0 0 \n 0.3333 0.3333 0.3333 0 0 \n 0.3333 0.3333 0.3333 0 0 \n 0 0 0 1 0"),a.append("rect").attr("opacity",f.noiseIntensity).attr("width","100%").attr("height","100%").attr("filter","url(#noise)")}return this.polys.forEach(function(d){var a=(d[0][0]+d[1][0]+d[2][0])/3,b=(d[0][1]+d[1][1]+d[2][1])/3,t=e(a,b),i=c.append("path").attr("d","M"+d.join("L")+"Z").attr({fill:t,stroke:t});1!=f.fillOpacity&&i.attr("fill-opacity",f.fillOpacity),1!=f.strokeOpacity&&i.attr("stroke-opacity",f.strokeOpacity)}),a.node()},Trianglify.Pattern.prototype.append=function(){document.body.appendChild(this.svg)},Trianglify.colorbrewer={YlGn:{3:["#f7fcb9","#addd8e","#31a354"],4:["#ffffcc","#c2e699","#78c679","#238443"],5:["#ffffcc","#c2e699","#78c679","#31a354","#006837"],6:["#ffffcc","#d9f0a3","#addd8e","#78c679","#31a354","#006837"],7:["#ffffcc","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#005a32"],8:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#005a32"],9:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"]},YlGnBu:{3:["#edf8b1","#7fcdbb","#2c7fb8"],4:["#ffffcc","#a1dab4","#41b6c4","#225ea8"],5:["#ffffcc","#a1dab4","#41b6c4","#2c7fb8","#253494"],6:["#ffffcc","#c7e9b4","#7fcdbb","#41b6c4","#2c7fb8","#253494"],7:["#ffffcc","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#0c2c84"],8:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#0c2c84"],9:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"]},GnBu:{3:["#e0f3db","#a8ddb5","#43a2ca"],4:["#f0f9e8","#bae4bc","#7bccc4","#2b8cbe"],5:["#f0f9e8","#bae4bc","#7bccc4","#43a2ca","#0868ac"],6:["#f0f9e8","#ccebc5","#a8ddb5","#7bccc4","#43a2ca","#0868ac"],7:["#f0f9e8","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#08589e"],8:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#08589e"],9:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"]},BuGn:{3:["#e5f5f9","#99d8c9","#2ca25f"],4:["#edf8fb","#b2e2e2","#66c2a4","#238b45"],5:["#edf8fb","#b2e2e2","#66c2a4","#2ca25f","#006d2c"],6:["#edf8fb","#ccece6","#99d8c9","#66c2a4","#2ca25f","#006d2c"],7:["#edf8fb","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#005824"],8:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#005824"],9:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"]},PuBuGn:{3:["#ece2f0","#a6bddb","#1c9099"],4:["#f6eff7","#bdc9e1","#67a9cf","#02818a"],5:["#f6eff7","#bdc9e1","#67a9cf","#1c9099","#016c59"],6:["#f6eff7","#d0d1e6","#a6bddb","#67a9cf","#1c9099","#016c59"],7:["#f6eff7","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016450"],8:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016450"],9:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"]},PuBu:{3:["#ece7f2","#a6bddb","#2b8cbe"],4:["#f1eef6","#bdc9e1","#74a9cf","#0570b0"],5:["#f1eef6","#bdc9e1","#74a9cf","#2b8cbe","#045a8d"],6:["#f1eef6","#d0d1e6","#a6bddb","#74a9cf","#2b8cbe","#045a8d"],7:["#f1eef6","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#034e7b"],8:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#034e7b"],9:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"]},BuPu:{3:["#e0ecf4","#9ebcda","#8856a7"],4:["#edf8fb","#b3cde3","#8c96c6","#88419d"],5:["#edf8fb","#b3cde3","#8c96c6","#8856a7","#810f7c"],6:["#edf8fb","#bfd3e6","#9ebcda","#8c96c6","#8856a7","#810f7c"],7:["#edf8fb","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#6e016b"],8:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#6e016b"],9:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"]},RdPu:{3:["#fde0dd","#fa9fb5","#c51b8a"],4:["#feebe2","#fbb4b9","#f768a1","#ae017e"],5:["#feebe2","#fbb4b9","#f768a1","#c51b8a","#7a0177"],6:["#feebe2","#fcc5c0","#fa9fb5","#f768a1","#c51b8a","#7a0177"],7:["#feebe2","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177"],8:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177"],9:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"]},PuRd:{3:["#e7e1ef","#c994c7","#dd1c77"],4:["#f1eef6","#d7b5d8","#df65b0","#ce1256"],5:["#f1eef6","#d7b5d8","#df65b0","#dd1c77","#980043"],6:["#f1eef6","#d4b9da","#c994c7","#df65b0","#dd1c77","#980043"],7:["#f1eef6","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#91003f"],8:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#91003f"],9:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"]},OrRd:{3:["#fee8c8","#fdbb84","#e34a33"],4:["#fef0d9","#fdcc8a","#fc8d59","#d7301f"],5:["#fef0d9","#fdcc8a","#fc8d59","#e34a33","#b30000"],6:["#fef0d9","#fdd49e","#fdbb84","#fc8d59","#e34a33","#b30000"],7:["#fef0d9","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#990000"],8:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#990000"],9:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"]},YlOrRd:{3:["#ffeda0","#feb24c","#f03b20"],4:["#ffffb2","#fecc5c","#fd8d3c","#e31a1c"],5:["#ffffb2","#fecc5c","#fd8d3c","#f03b20","#bd0026"],6:["#ffffb2","#fed976","#feb24c","#fd8d3c","#f03b20","#bd0026"],7:["#ffffb2","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#b10026"],8:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#b10026"],9:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"]},YlOrBr:{3:["#fff7bc","#fec44f","#d95f0e"],4:["#ffffd4","#fed98e","#fe9929","#cc4c02"],5:["#ffffd4","#fed98e","#fe9929","#d95f0e","#993404"],6:["#ffffd4","#fee391","#fec44f","#fe9929","#d95f0e","#993404"],7:["#ffffd4","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#8c2d04"],8:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#8c2d04"],9:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"]},Purples:{3:["#efedf5","#bcbddc","#756bb1"],4:["#f2f0f7","#cbc9e2","#9e9ac8","#6a51a3"],5:["#f2f0f7","#cbc9e2","#9e9ac8","#756bb1","#54278f"],6:["#f2f0f7","#dadaeb","#bcbddc","#9e9ac8","#756bb1","#54278f"],7:["#f2f0f7","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#4a1486"],8:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#4a1486"],9:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]},Blues:{3:["#deebf7","#9ecae1","#3182bd"],4:["#eff3ff","#bdd7e7","#6baed6","#2171b5"],5:["#eff3ff","#bdd7e7","#6baed6","#3182bd","#08519c"],6:["#eff3ff","#c6dbef","#9ecae1","#6baed6","#3182bd","#08519c"],7:["#eff3ff","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#084594"],8:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#084594"],9:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]},Greens:{3:["#e5f5e0","#a1d99b","#31a354"],4:["#edf8e9","#bae4b3","#74c476","#238b45"],5:["#edf8e9","#bae4b3","#74c476","#31a354","#006d2c"],6:["#edf8e9","#c7e9c0","#a1d99b","#74c476","#31a354","#006d2c"],7:["#edf8e9","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#005a32"],8:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#005a32"],9:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]},Oranges:{3:["#fee6ce","#fdae6b","#e6550d"],4:["#feedde","#fdbe85","#fd8d3c","#d94701"],5:["#feedde","#fdbe85","#fd8d3c","#e6550d","#a63603"],6:["#feedde","#fdd0a2","#fdae6b","#fd8d3c","#e6550d","#a63603"],7:["#feedde","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#8c2d04"],8:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#8c2d04"],9:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]},Reds:{3:["#fee0d2","#fc9272","#de2d26"],4:["#fee5d9","#fcae91","#fb6a4a","#cb181d"],5:["#fee5d9","#fcae91","#fb6a4a","#de2d26","#a50f15"],6:["#fee5d9","#fcbba1","#fc9272","#fb6a4a","#de2d26","#a50f15"],7:["#fee5d9","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#99000d"],8:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#99000d"],9:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]},Greys:{3:["#f0f0f0","#bdbdbd","#636363"],4:["#f7f7f7","#cccccc","#969696","#525252"],5:["#f7f7f7","#cccccc","#969696","#636363","#252525"],6:["#f7f7f7","#d9d9d9","#bdbdbd","#969696","#636363","#252525"],7:["#f7f7f7","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525"],8:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525"],9:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]},PuOr:{3:["#f1a340","#f7f7f7","#998ec3"],4:["#e66101","#fdb863","#b2abd2","#5e3c99"],5:["#e66101","#fdb863","#f7f7f7","#b2abd2","#5e3c99"],6:["#b35806","#f1a340","#fee0b6","#d8daeb","#998ec3","#542788"],7:["#b35806","#f1a340","#fee0b6","#f7f7f7","#d8daeb","#998ec3","#542788"],8:["#b35806","#e08214","#fdb863","#fee0b6","#d8daeb","#b2abd2","#8073ac","#542788"],9:["#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788"],10:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],11:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"]},BrBG:{3:["#d8b365","#f5f5f5","#5ab4ac"],4:["#a6611a","#dfc27d","#80cdc1","#018571"],5:["#a6611a","#dfc27d","#f5f5f5","#80cdc1","#018571"],6:["#8c510a","#d8b365","#f6e8c3","#c7eae5","#5ab4ac","#01665e"],7:["#8c510a","#d8b365","#f6e8c3","#f5f5f5","#c7eae5","#5ab4ac","#01665e"],8:["#8c510a","#bf812d","#dfc27d","#f6e8c3","#c7eae5","#80cdc1","#35978f","#01665e"],9:["#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e"],10:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],11:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]},PRGn:{3:["#af8dc3","#f7f7f7","#7fbf7b"],4:["#7b3294","#c2a5cf","#a6dba0","#008837"],5:["#7b3294","#c2a5cf","#f7f7f7","#a6dba0","#008837"],6:["#762a83","#af8dc3","#e7d4e8","#d9f0d3","#7fbf7b","#1b7837"],7:["#762a83","#af8dc3","#e7d4e8","#f7f7f7","#d9f0d3","#7fbf7b","#1b7837"],8:["#762a83","#9970ab","#c2a5cf","#e7d4e8","#d9f0d3","#a6dba0","#5aae61","#1b7837"],9:["#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837"],10:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],11:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]},PiYG:{3:["#e9a3c9","#f7f7f7","#a1d76a"],4:["#d01c8b","#f1b6da","#b8e186","#4dac26"],5:["#d01c8b","#f1b6da","#f7f7f7","#b8e186","#4dac26"],6:["#c51b7d","#e9a3c9","#fde0ef","#e6f5d0","#a1d76a","#4d9221"],7:["#c51b7d","#e9a3c9","#fde0ef","#f7f7f7","#e6f5d0","#a1d76a","#4d9221"],8:["#c51b7d","#de77ae","#f1b6da","#fde0ef","#e6f5d0","#b8e186","#7fbc41","#4d9221"],9:["#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221"],10:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],11:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]},RdBu:{3:["#ef8a62","#f7f7f7","#67a9cf"],4:["#ca0020","#f4a582","#92c5de","#0571b0"],5:["#ca0020","#f4a582","#f7f7f7","#92c5de","#0571b0"],6:["#b2182b","#ef8a62","#fddbc7","#d1e5f0","#67a9cf","#2166ac"],7:["#b2182b","#ef8a62","#fddbc7","#f7f7f7","#d1e5f0","#67a9cf","#2166ac"],8:["#b2182b","#d6604d","#f4a582","#fddbc7","#d1e5f0","#92c5de","#4393c3","#2166ac"],9:["#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac"],10:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],11:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]},RdGy:{3:["#ef8a62","#ffffff","#999999"],4:["#ca0020","#f4a582","#bababa","#404040"],5:["#ca0020","#f4a582","#ffffff","#bababa","#404040"],6:["#b2182b","#ef8a62","#fddbc7","#e0e0e0","#999999","#4d4d4d"],7:["#b2182b","#ef8a62","#fddbc7","#ffffff","#e0e0e0","#999999","#4d4d4d"],8:["#b2182b","#d6604d","#f4a582","#fddbc7","#e0e0e0","#bababa","#878787","#4d4d4d"],9:["#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d"],10:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],11:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"]},RdYlBu:{3:["#fc8d59","#ffffbf","#91bfdb"],4:["#d7191c","#fdae61","#abd9e9","#2c7bb6"],5:["#d7191c","#fdae61","#ffffbf","#abd9e9","#2c7bb6"],6:["#d73027","#fc8d59","#fee090","#e0f3f8","#91bfdb","#4575b4"],7:["#d73027","#fc8d59","#fee090","#ffffbf","#e0f3f8","#91bfdb","#4575b4"],8:["#d73027","#f46d43","#fdae61","#fee090","#e0f3f8","#abd9e9","#74add1","#4575b4"],9:["#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4"],10:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],11:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]},Spectral:{3:["#fc8d59","#ffffbf","#99d594"],4:["#d7191c","#fdae61","#abdda4","#2b83ba"],5:["#d7191c","#fdae61","#ffffbf","#abdda4","#2b83ba"],6:["#d53e4f","#fc8d59","#fee08b","#e6f598","#99d594","#3288bd"],7:["#d53e4f","#fc8d59","#fee08b","#ffffbf","#e6f598","#99d594","#3288bd"],8:["#d53e4f","#f46d43","#fdae61","#fee08b","#e6f598","#abdda4","#66c2a5","#3288bd"],9:["#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd"],10:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],11:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]},RdYlGn:{3:["#fc8d59","#ffffbf","#91cf60"],4:["#d7191c","#fdae61","#a6d96a","#1a9641"],5:["#d7191c","#fdae61","#ffffbf","#a6d96a","#1a9641"],6:["#d73027","#fc8d59","#fee08b","#d9ef8b","#91cf60","#1a9850"],7:["#d73027","#fc8d59","#fee08b","#ffffbf","#d9ef8b","#91cf60","#1a9850"],8:["#d73027","#f46d43","#fdae61","#fee08b","#d9ef8b","#a6d96a","#66bd63","#1a9850"],9:["#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850"],10:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],11:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]}};
\ No newline at end of file
diff --git a/app/assets/javascripts/waypoints.js b/app/assets/javascripts/waypoints.js
deleted file mode 100644
index 4f9a33b2..00000000
--- a/app/assets/javascripts/waypoints.js
+++ /dev/null
@@ -1,517 +0,0 @@
-// Generated by CoffeeScript 1.6.2
-/*!
-jQuery Waypoints - v2.0.5
-Copyright (c) 2011-2014 Caleb Troughton
-Licensed under the MIT license.
-https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt
-*/
-
-
-(function() {
- var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
- __slice = [].slice;
-
- (function(root, factory) {
- if (typeof define === 'function' && define.amd) {
- return define('waypoints', ['jquery'], function($) {
- return factory($, root);
- });
- } else {
- return factory(root.jQuery, root);
- }
- })(window, function($, window) {
- var $w, Context, Waypoint, allWaypoints, contextCounter, contextKey, contexts, isTouch, jQMethods, methods, resizeEvent, scrollEvent, waypointCounter, waypointKey, wp, wps;
-
- $w = $(window);
- isTouch = __indexOf.call(window, 'ontouchstart') >= 0;
- allWaypoints = {
- horizontal: {},
- vertical: {}
- };
- contextCounter = 1;
- contexts = {};
- contextKey = 'waypoints-context-id';
- resizeEvent = 'resize.waypoints';
- scrollEvent = 'scroll.waypoints';
- waypointCounter = 1;
- waypointKey = 'waypoints-waypoint-ids';
- wp = 'waypoint';
- wps = 'waypoints';
- Context = (function() {
- function Context($element) {
- var _this = this;
-
- this.$element = $element;
- this.element = $element[0];
- this.didResize = false;
- this.didScroll = false;
- this.id = 'context' + contextCounter++;
- this.oldScroll = {
- x: $element.scrollLeft(),
- y: $element.scrollTop()
- };
- this.waypoints = {
- horizontal: {},
- vertical: {}
- };
- this.element[contextKey] = this.id;
- contexts[this.id] = this;
- $element.bind(scrollEvent, function() {
- var scrollHandler;
-
- if (!(_this.didScroll || isTouch)) {
- _this.didScroll = true;
- scrollHandler = function() {
- _this.doScroll();
- return _this.didScroll = false;
- };
- return window.setTimeout(scrollHandler, $[wps].settings.scrollThrottle);
- }
- });
- $element.bind(resizeEvent, function() {
- var resizeHandler;
-
- if (!_this.didResize) {
- _this.didResize = true;
- resizeHandler = function() {
- $[wps]('refresh');
- return _this.didResize = false;
- };
- return window.setTimeout(resizeHandler, $[wps].settings.resizeThrottle);
- }
- });
- }
-
- Context.prototype.doScroll = function() {
- var axes,
- _this = this;
-
- axes = {
- horizontal: {
- newScroll: this.$element.scrollLeft(),
- oldScroll: this.oldScroll.x,
- forward: 'right',
- backward: 'left'
- },
- vertical: {
- newScroll: this.$element.scrollTop(),
- oldScroll: this.oldScroll.y,
- forward: 'down',
- backward: 'up'
- }
- };
- if (isTouch && (!axes.vertical.oldScroll || !axes.vertical.newScroll)) {
- $[wps]('refresh');
- }
- $.each(axes, function(aKey, axis) {
- var direction, isForward, triggered;
-
- triggered = [];
- isForward = axis.newScroll > axis.oldScroll;
- direction = isForward ? axis.forward : axis.backward;
- $.each(_this.waypoints[aKey], function(wKey, waypoint) {
- var _ref, _ref1;
-
- if ((axis.oldScroll < (_ref = waypoint.offset) && _ref <= axis.newScroll)) {
- return triggered.push(waypoint);
- } else if ((axis.newScroll < (_ref1 = waypoint.offset) && _ref1 <= axis.oldScroll)) {
- return triggered.push(waypoint);
- }
- });
- triggered.sort(function(a, b) {
- return a.offset - b.offset;
- });
- if (!isForward) {
- triggered.reverse();
- }
- return $.each(triggered, function(i, waypoint) {
- if (waypoint.options.continuous || i === triggered.length - 1) {
- return waypoint.trigger([direction]);
- }
- });
- });
- return this.oldScroll = {
- x: axes.horizontal.newScroll,
- y: axes.vertical.newScroll
- };
- };
-
- Context.prototype.refresh = function() {
- var axes, cOffset, isWin,
- _this = this;
-
- isWin = $.isWindow(this.element);
- cOffset = this.$element.offset();
- this.doScroll();
- axes = {
- horizontal: {
- contextOffset: isWin ? 0 : cOffset.left,
- contextScroll: isWin ? 0 : this.oldScroll.x,
- contextDimension: this.$element.width(),
- oldScroll: this.oldScroll.x,
- forward: 'right',
- backward: 'left',
- offsetProp: 'left'
- },
- vertical: {
- contextOffset: isWin ? 0 : cOffset.top,
- contextScroll: isWin ? 0 : this.oldScroll.y,
- contextDimension: isWin ? $[wps]('viewportHeight') : this.$element.height(),
- oldScroll: this.oldScroll.y,
- forward: 'down',
- backward: 'up',
- offsetProp: 'top'
- }
- };
- return $.each(axes, function(aKey, axis) {
- return $.each(_this.waypoints[aKey], function(i, waypoint) {
- var adjustment, elementOffset, oldOffset, _ref, _ref1;
-
- adjustment = waypoint.options.offset;
- oldOffset = waypoint.offset;
- elementOffset = $.isWindow(waypoint.element) ? 0 : waypoint.$element.offset()[axis.offsetProp];
- if ($.isFunction(adjustment)) {
- adjustment = adjustment.apply(waypoint.element);
- } else if (typeof adjustment === 'string') {
- adjustment = parseFloat(adjustment);
- if (waypoint.options.offset.indexOf('%') > -1) {
- adjustment = Math.ceil(axis.contextDimension * adjustment / 100);
- }
- }
- waypoint.offset = elementOffset - axis.contextOffset + axis.contextScroll - adjustment;
- if ((waypoint.options.onlyOnScroll && (oldOffset != null)) || !waypoint.enabled) {
- return;
- }
- if (oldOffset !== null && (oldOffset < (_ref = axis.oldScroll) && _ref <= waypoint.offset)) {
- return waypoint.trigger([axis.backward]);
- } else if (oldOffset !== null && (oldOffset > (_ref1 = axis.oldScroll) && _ref1 >= waypoint.offset)) {
- return waypoint.trigger([axis.forward]);
- } else if (oldOffset === null && axis.oldScroll >= waypoint.offset) {
- return waypoint.trigger([axis.forward]);
- }
- });
- });
- };
-
- Context.prototype.checkEmpty = function() {
- if ($.isEmptyObject(this.waypoints.horizontal) && $.isEmptyObject(this.waypoints.vertical)) {
- this.$element.unbind([resizeEvent, scrollEvent].join(' '));
- return delete contexts[this.id];
- }
- };
-
- return Context;
-
- })();
- Waypoint = (function() {
- function Waypoint($element, context, options) {
- var idList, _ref;
-
- if (options.offset === 'bottom-in-view') {
- options.offset = function() {
- var contextHeight;
-
- contextHeight = $[wps]('viewportHeight');
- if (!$.isWindow(context.element)) {
- contextHeight = context.$element.height();
- }
- return contextHeight - $(this).outerHeight();
- };
- }
- this.$element = $element;
- this.element = $element[0];
- this.axis = options.horizontal ? 'horizontal' : 'vertical';
- this.callback = options.handler;
- this.context = context;
- this.enabled = options.enabled;
- this.id = 'waypoints' + waypointCounter++;
- this.offset = null;
- this.options = options;
- context.waypoints[this.axis][this.id] = this;
- allWaypoints[this.axis][this.id] = this;
- idList = (_ref = this.element[waypointKey]) != null ? _ref : [];
- idList.push(this.id);
- this.element[waypointKey] = idList;
- }
-
- Waypoint.prototype.trigger = function(args) {
- if (!this.enabled) {
- return;
- }
- if (this.callback != null) {
- this.callback.apply(this.element, args);
- }
- if (this.options.triggerOnce) {
- return this.destroy();
- }
- };
-
- Waypoint.prototype.disable = function() {
- return this.enabled = false;
- };
-
- Waypoint.prototype.enable = function() {
- this.context.refresh();
- return this.enabled = true;
- };
-
- Waypoint.prototype.destroy = function() {
- delete allWaypoints[this.axis][this.id];
- delete this.context.waypoints[this.axis][this.id];
- return this.context.checkEmpty();
- };
-
- Waypoint.getWaypointsByElement = function(element) {
- var all, ids;
-
- ids = element[waypointKey];
- if (!ids) {
- return [];
- }
- all = $.extend({}, allWaypoints.horizontal, allWaypoints.vertical);
- return $.map(ids, function(id) {
- return all[id];
- });
- };
-
- return Waypoint;
-
- })();
- methods = {
- init: function(f, options) {
- var _ref;
-
- options = $.extend({}, $.fn[wp].defaults, options);
- if ((_ref = options.handler) == null) {
- options.handler = f;
- }
- this.each(function() {
- var $this, context, contextElement, _ref1;
-
- $this = $(this);
- contextElement = (_ref1 = options.context) != null ? _ref1 : $.fn[wp].defaults.context;
- if (!$.isWindow(contextElement)) {
- contextElement = $this.closest(contextElement);
- }
- contextElement = $(contextElement);
- context = contexts[contextElement[0][contextKey]];
- if (!context) {
- context = new Context(contextElement);
- }
- return new Waypoint($this, context, options);
- });
- $[wps]('refresh');
- return this;
- },
- disable: function() {
- return methods._invoke.call(this, 'disable');
- },
- enable: function() {
- return methods._invoke.call(this, 'enable');
- },
- destroy: function() {
- return methods._invoke.call(this, 'destroy');
- },
- prev: function(axis, selector) {
- return methods._traverse.call(this, axis, selector, function(stack, index, waypoints) {
- if (index > 0) {
- return stack.push(waypoints[index - 1]);
- }
- });
- },
- next: function(axis, selector) {
- return methods._traverse.call(this, axis, selector, function(stack, index, waypoints) {
- if (index < waypoints.length - 1) {
- return stack.push(waypoints[index + 1]);
- }
- });
- },
- _traverse: function(axis, selector, push) {
- var stack, waypoints;
-
- if (axis == null) {
- axis = 'vertical';
- }
- if (selector == null) {
- selector = window;
- }
- waypoints = jQMethods.aggregate(selector);
- stack = [];
- this.each(function() {
- var index;
-
- index = $.inArray(this, waypoints[axis]);
- return push(stack, index, waypoints[axis]);
- });
- return this.pushStack(stack);
- },
- _invoke: function(method) {
- this.each(function() {
- var waypoints;
-
- waypoints = Waypoint.getWaypointsByElement(this);
- return $.each(waypoints, function(i, waypoint) {
- waypoint[method]();
- return true;
- });
- });
- return this;
- }
- };
- $.fn[wp] = function() {
- var args, method;
-
- method = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
- if (methods[method]) {
- return methods[method].apply(this, args);
- } else if ($.isFunction(method)) {
- return methods.init.apply(this, arguments);
- } else if ($.isPlainObject(method)) {
- return methods.init.apply(this, [null, method]);
- } else if (!method) {
- return $.error("jQuery Waypoints needs a callback function or handler option.");
- } else {
- return $.error("The " + method + " method does not exist in jQuery Waypoints.");
- }
- };
- $.fn[wp].defaults = {
- context: window,
- continuous: true,
- enabled: true,
- horizontal: false,
- offset: 0,
- triggerOnce: false
- };
- jQMethods = {
- refresh: function() {
- return $.each(contexts, function(i, context) {
- return context.refresh();
- });
- },
- viewportHeight: function() {
- var _ref;
-
- return (_ref = window.innerHeight) != null ? _ref : $w.height();
- },
- aggregate: function(contextSelector) {
- var collection, waypoints, _ref;
-
- collection = allWaypoints;
- if (contextSelector) {
- collection = (_ref = contexts[$(contextSelector)[0][contextKey]]) != null ? _ref.waypoints : void 0;
- }
- if (!collection) {
- return [];
- }
- waypoints = {
- horizontal: [],
- vertical: []
- };
- $.each(waypoints, function(axis, arr) {
- $.each(collection[axis], function(key, waypoint) {
- return arr.push(waypoint);
- });
- arr.sort(function(a, b) {
- return a.offset - b.offset;
- });
- waypoints[axis] = $.map(arr, function(waypoint) {
- return waypoint.element;
- });
- return waypoints[axis] = $.unique(waypoints[axis]);
- });
- return waypoints;
- },
- above: function(contextSelector) {
- if (contextSelector == null) {
- contextSelector = window;
- }
- return jQMethods._filter(contextSelector, 'vertical', function(context, waypoint) {
- return waypoint.offset <= context.oldScroll.y;
- });
- },
- below: function(contextSelector) {
- if (contextSelector == null) {
- contextSelector = window;
- }
- return jQMethods._filter(contextSelector, 'vertical', function(context, waypoint) {
- return waypoint.offset > context.oldScroll.y;
- });
- },
- left: function(contextSelector) {
- if (contextSelector == null) {
- contextSelector = window;
- }
- return jQMethods._filter(contextSelector, 'horizontal', function(context, waypoint) {
- return waypoint.offset <= context.oldScroll.x;
- });
- },
- right: function(contextSelector) {
- if (contextSelector == null) {
- contextSelector = window;
- }
- return jQMethods._filter(contextSelector, 'horizontal', function(context, waypoint) {
- return waypoint.offset > context.oldScroll.x;
- });
- },
- enable: function() {
- return jQMethods._invoke('enable');
- },
- disable: function() {
- return jQMethods._invoke('disable');
- },
- destroy: function() {
- return jQMethods._invoke('destroy');
- },
- extendFn: function(methodName, f) {
- return methods[methodName] = f;
- },
- _invoke: function(method) {
- var waypoints;
-
- waypoints = $.extend({}, allWaypoints.vertical, allWaypoints.horizontal);
- return $.each(waypoints, function(key, waypoint) {
- waypoint[method]();
- return true;
- });
- },
- _filter: function(selector, axis, test) {
- var context, waypoints;
-
- context = contexts[$(selector)[0][contextKey]];
- if (!context) {
- return [];
- }
- waypoints = [];
- $.each(context.waypoints[axis], function(i, waypoint) {
- if (test(context, waypoint)) {
- return waypoints.push(waypoint);
- }
- });
- waypoints.sort(function(a, b) {
- return a.offset - b.offset;
- });
- return $.map(waypoints, function(waypoint) {
- return waypoint.element;
- });
- }
- };
- $[wps] = function() {
- var args, method;
-
- method = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
- if (jQMethods[method]) {
- return jQMethods[method].apply(null, args);
- } else {
- return jQMethods.aggregate.call(null, method);
- }
- };
- $[wps].settings = {
- resizeThrottle: 100,
- scrollThrottle: 30
- };
- return $w.on('load.waypoints', function() {
- return $[wps]('refresh');
- });
- });
-
-}).call(this);
diff --git a/app/views/admin/call_for_papers/_form.html.haml b/app/views/admin/call_for_papers/_form.html.haml
deleted file mode 100644
index f18e6a07..00000000
--- a/app/views/admin/call_for_papers/_form.html.haml
+++ /dev/null
@@ -1,14 +0,0 @@
-.row
- .col-md-12
- .page-header
- %h1 Call for Papers
-.row
- .col-md-8
- = semantic_form_for(@call_for_paper, :url => admin_conference_call_for_paper_path(@conference.short_title),:html => {:multipart => true}) do |f|
- = f.input :start_date, :as => :string, :input_html => { :id => "conference-start-datepicker", :readonly => "readonly" }
- = f.input :end_date, :as => :string, :input_html => { :id => "conference-end-datepicker", :readonly => "readonly" }
- = f.input :schedule_public, label: "Show Schedule on the home and splash page"
- = f.input :schedule_changes, label: "Allow submitters to change their event after it is scheduled"
- = f.input :rating, :hint => "Enter the number of different rating levels you want to have for voting on proposals. Enter 0 if you do not want to vote on proposals."
- %p.text-right
- = f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}
diff --git a/app/views/admin/call_for_papers/show.html.haml b/app/views/admin/call_for_papers/show.html.haml
deleted file mode 100644
index a2aacfb2..00000000
--- a/app/views/admin/call_for_papers/show.html.haml
+++ /dev/null
@@ -1,58 +0,0 @@
-.row
- .col-md-12
- .page-header
- %h1 Call for Papers
- %p.text-muted
- Call for people to submit events to your conference
-- if @call_for_paper
- .row
- .col-md-8
- %dl.dl-horizontal
- %dt
- Start Date:
- %dd#start_date
- = @call_for_paper.start_date.strftime('%A, %B %-d. %Y')
- %dt
- End Date:
- %dd#end_date
- = @call_for_paper.end_date.strftime('%A, %B %-d. %Y')
- %dt
- Days Left:
- %dd
- = pluralize(@call_for_paper.remaining_days, 'day')
- %dt
- Event types:
- %dd
- = event_types(@conference)
- %dt
- Tracks:
- %dd
- = tracks(@conference)
- %dt
- Public Schedule
- %dd#schedule_public
- - if @call_for_paper.schedule_public
- Yes
- - else
- No
- %dt
- Schedule changeable?
- %dd#schedule_changes
- - if @call_for_paper.schedule_changes
- Yes
- - else
- No
- %dt
- Rating Levels
- %dd#rating
- = @call_for_paper.rating
- .row
- .col-md-12.text-right
- = link_to(edit_admin_conference_call_for_paper_path(@conference.short_title), class: 'btn btn-primary') do
- Edit
- = link_to(admin_conference_call_for_paper_path(@conference.short_title), method: 'delete', class: 'btn btn-danger') do
- Delete
--else
- .row
- .col-md-12.text-right
- = link_to 'Create Call for Papers', new_admin_conference_call_for_paper_path(@conference.short_title), class: 'btn btn-primary'
diff --git a/config/application.rb b/config/application.rb
index 91ac6591..6f863991 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -60,5 +60,9 @@ module Osem
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
+
+ # Errors raised within `after_rollback`/`after_commit` propagate normally
+ # like in other Active Record callbacks.
+ config.active_record.raise_in_transactional_callbacks = true
end
end
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 69c7f9de..97bb10d6 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -15,7 +15,7 @@ Osem::Application.configure do
config.eager_load = true
# Disable Rails's static asset server (Apache or nginx will already do this)
- config.serve_static_assets = false
+ config.serve_static_files = false
# Compress JavaScripts and CSS
config.assets.compress = true
diff --git a/config/environments/test.rb b/config/environments/test.rb
index d33fbc31..42d753ee 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -8,7 +8,7 @@ Osem::Application.configure do
config.cache_classes = true
# Configure static asset server for tests with Cache-Control for performance
- config.serve_static_assets = true
+ config.serve_static_files = true
config.static_cache_control = 'public, max-age=3600'
# Do not eager load code on boot.
diff --git a/config/initializers/formtastic.rb b/config/initializers/formtastic.rb
index 4374676b..f21da2e7 100644
--- a/config/initializers/formtastic.rb
+++ b/config/initializers/formtastic.rb
@@ -66,14 +66,48 @@ Formtastic::FormBuilder.required_string = proc { Formtastic::Util.html_safe(%{&n
# specifying that class here. Defaults to Formtastic::FormBuilder.
# Formtastic::Helpers::FormHelper.builder = MyCustomBuilder
+# All formtastic forms have a class that indicates that they are just that. You
+# can change it to any class you want.
+# Formtastic::Helpers::FormHelper.default_form_class = 'formtastic'
+
+# Formtastic will infer a class name from the model, array, string ot symbol you pass to the
+# form builder. You can customize the way that class is presented by overriding
+# this proc.
+# Formtastic::Helpers::FormHelper.default_form_model_class_proc = proc { |model_class_name| model_class_name }
+
+# Allows to set a custom field_error_proc wrapper. By default this wrapper
+# is disabled since `formtastic` already adds an error class to the LI tag
+# containing the input.
+# Formtastic::Helpers::FormHelper.formtastic_field_error_proc = proc { |html_tag, instance_tag| html_tag }
+
# You can opt-in to Formtastic's use of the HTML5 `required` attribute on ``, `