diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..1216ffe --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,34 @@ +{ + "env": { + "browser": false, + "commonjs": true, + "es6": true, + "node": true + }, + "extends": "eslint:recommended", + "globals": { + "Atomics": "readonly", + "SharedArrayBuffer": "readonly" + }, + "parserOptions": { + "ecmaVersion": 2018 + }, + "rules": { + "indent": [ + "error", + 4 + ], + "linebreak-style": [ + "error", + "unix" + ], + "quotes": [ + "error", + "single" + ], + "semi": [ + "error", + "always" + ] + } +} diff --git a/build.js b/build.js index eacc0df..933fbba 100644 --- a/build.js +++ b/build.js @@ -1,93 +1,59 @@ -var fs = require('fs-extra'); -var hbs = require('handlebars'); -var glob = require("glob"); -var sass = require("sass"); -var path = require("path"); -var gulp = require('gulp'); -var include = require('gulp-include'); +const fs = require('fs'); +const path = require('path'); +const gulp = require('gulp'); +const include = require('gulp-include'); +const hb = require('gulp-hb'); +const sass = require('gulp-sass'); +const rename = require('gulp-rename'); -const BUILDDIR = './build'; +const hb_svg = require('handlebars-helper-svg'); + +const BUILDDIR = process.argv[2] || './build/'; const SLUG = 'pixel-editor'; console.log('Building Pixel Editor'); -hbs.registerHelper('svg', require('handlebars-helper-svg')); -require('hbs-register-helpers')(hbs,'./_ext/modules/hbs/helpers/**/*.js'); -require('hbs-register-partials')(hbs,'./_ext/modules/hbs/_*.hbs'); -//empty the build folder, or create it -fs.emptyDirSync(BUILDDIR); +function copy_images(){ + gulp.src('./images/') + .pipe(gulp.dest(path.join(BUILDDIR, SLUG))); +} + +function render_js(){ + gulp.src('./js/*.js') + .pipe(include({includePaths: [ + '_ext/scripts', + 'js', + '!js/_*.js', + ]})) + .on('error', console.log) + .pipe(gulp.dest(path.join(BUILDDIR, SLUG))); +} -//copy images -fs.copySync('./images','./build/'+SLUG); +function render_css(){ + gulp.src('css/*.scss') + .pipe(sass({includePaths: ['css', '_ext/sass', '_ext/modules/css']})) + .pipe(gulp.dest(path.join(BUILDDIR, SLUG))); +} -//render js -gulp.src('./js/*.js') - .pipe(include({includePaths: [ - '_ext/scripts', - 'js', - '!js/_*.js', - ]})) - .on('error', console.log) - .pipe(gulp.dest('build/'+SLUG)); +function compile_page(){ + gulp.src(path.join('./views/', SLUG + '.hbs')) + .pipe(hb({encoding: 'utf8'}) + .partials('./_ext/modules/_*.hbs') + .helpers({ svg: hb_svg }) + .helpers('./_ext/modules/hbs/helpers/**/*.js') + .data({ + projectSlug: SLUG, + title: 'Lospec Pixel Editor', + layout: false, + })) + .pipe(rename('index.htm')) + .pipe(gulp.dest(BUILDDIR)); +} -//render css -var sassFiles = glob.sync('css/*.scss'); - -sassFiles.forEach((s) => { - - var f = sass.renderSync({file: s, outFile: 'test.css', includePaths: ['css', '_ext/sass', '_ext/modules/css']}); - - console.log('compiling:',path.basename(f.stats.entry)) - fs.writeFileSync('build/'+SLUG+'/'+path.basename(f.stats.entry,'scss')+'css', f.css); -}); - - -//compile page -var pageTemplate = hbs.compile(fs.readFileSync('./views/'+SLUG+'.hbs',{encoding: 'utf8'})); -var page = pageTemplate({ - projectSlug: SLUG, - title: 'Lospec Pixel Editor', - layout: false, -}); - -//save output -fs.writeFileSync('./build/index.htm',page); - - -//server -const express = require('express'); -const app = express(); - - -//ROUTE - index.htm -app.get('/', (req, res) => { - res.sendFile(path.join(__dirname+'/build/index.htm'), {}, function (err) { - if (err) console.log('error sending file',err); - else { - setTimeout(()=>{ - console.log('closing server') - server.close(); - process.exit(); - },1000*10); - } - }); -}); - -//ROUTE - other files -app.use(express.static(path.join(__dirname, 'build'))); - -//start server -var server = app.listen(3000, () => { - console.log('\nTemp server started at http://localhost:3000!'); - //console.log('press ctrl+c to stop '); - - var opn = require('opn'); - - // opens the url in the default browser - opn('http://localhost:3000'); - - -}); +// empty the build folder, or create it +fs.rmdirSync(BUILDDIR, { recursive: true }); +fs.mkdirSync(BUILDDIR); +gulp.parallel(copy_images, render_js, render_css, compile_page)(); diff --git a/js/.eslintrc.json b/js/.eslintrc.json new file mode 100644 index 0000000..2df1a38 --- /dev/null +++ b/js/.eslintrc.json @@ -0,0 +1,34 @@ +{ + "env": { + "browser": true, + "es6": true + }, + "globals": { + "Atomics": "readonly", + "SharedArrayBuffer": "readonly" + }, + "parserOptions": { + "ecmaVersion": 2018 + }, + "rules": { + "indent": [ + "error", + 4, + { + "SwitchCase": 1 + } + ], + "linebreak-style": [ + "error", + "unix" + ], + "quotes": [ + "error", + "single" + ], + "semi": [ + "error", + "always" + ] + } +} diff --git a/js/_addColor.js b/js/_addColor.js index a3f5fa6..54f3534 100644 --- a/js/_addColor.js +++ b/js/_addColor.js @@ -2,48 +2,48 @@ //input hex color string //returns list item element function addColor (newColor) { - - //add # at beginning if not present - if (newColor.charAt(0) != '#') - newColor = '#' + newColor; - - //create list item - var listItem = document.createElement("li"); - - //create button - var button = document.createElement("button"); - button.classList.add("color-button"); - button.style.backgroundColor = newColor; - button.addEventListener("mouseup", clickedColor); - listItem.appendChild(button); - - /* - //create input to hold color value - var colorValue = document.createElement("input"); - colorValue.classList.add("color-value"); - listItem.appendChild(colorValue); - */ - - //insert new listItem element at the end of the colors menu (right before add button) - colorsMenu.insertBefore(listItem, colorsMenu.children[colorsMenu.children.length-1]); - - //add jscolor functionality - initColor(button); - - //add edit button - var editButtonTemplate = document.getElementsByClassName('color-edit-button')[0]; - newEditButton = editButtonTemplate.cloneNode(true); - listItem.appendChild(newEditButton); - - //when you click the edit button - on('click', newEditButton, function (event, button) { - - //hide edit button - button.parentElement.lastChild.classList.add('hidden'); - - //show jscolor picker - button.parentElement.firstChild.jscolor.show(); - }); - - return listItem; -} \ No newline at end of file + + //add # at beginning if not present + if (newColor.charAt(0) != '#') + newColor = '#' + newColor; + + //create list item + var listItem = document.createElement('li'); + + //create button + var button = document.createElement('button'); + button.classList.add('color-button'); + button.style.backgroundColor = newColor; + button.addEventListener('mouseup', clickedColor); + listItem.appendChild(button); + + /* + //create input to hold color value + var colorValue = document.createElement("input"); + colorValue.classList.add("color-value"); + listItem.appendChild(colorValue); + */ + + //insert new listItem element at the end of the colors menu (right before add button) + colorsMenu.insertBefore(listItem, colorsMenu.children[colorsMenu.children.length-1]); + + //add jscolor functionality + initColor(button); + + //add edit button + var editButtonTemplate = document.getElementsByClassName('color-edit-button')[0]; + newEditButton = editButtonTemplate.cloneNode(true); + listItem.appendChild(newEditButton); + + //when you click the edit button + on('click', newEditButton, function (event, button) { + + //hide edit button + button.parentElement.lastChild.classList.add('hidden'); + + //show jscolor picker + button.parentElement.firstChild.jscolor.show(); + }); + + return listItem; +} diff --git a/js/_addColorButton.js b/js/_addColorButton.js index b5124ae..16f7c56 100644 --- a/js/_addColorButton.js +++ b/js/_addColorButton.js @@ -1,59 +1,59 @@ //add color button on('click', 'add-color-button', function(){ - if (!documentCreated) return; + if (!documentCreated) return; - var colorCheckingStyle = ` + var colorCheckingStyle = ` color: white; background: #3c4cc2; `; - - var colorIsUnique = true - do { - //console.log('%cchecking for unique colors', colorCheckingStyle) - //generate random color - var hue = Math.floor(Math.random()*255); - var sat = 130+Math.floor(Math.random()*100); - var lit = 70+Math.floor(Math.random()*100); - var newColorRgb = hslToRgb(hue,sat,lit) - var newColor = rgbToHex(newColorRgb.r,newColorRgb.g,newColorRgb.b) - - var newColorHex = newColor; - - //check if color has been used before - colors = document.getElementsByClassName('color-button'); - colorCheckingLoop: for (var i = 0; i < colors.length; i++) { - //console.log('%c'+newColorHex +' '+ colors[i].jscolor.toString(), colorCheckingStyle) - - //if generated color matches this color - if (newColorHex == colors[i].jscolor.toString()) { - //console.log('%ccolor already exists', colorCheckingStyle) - - //start loop again - colorIsUnique = false; - - //exit - break colorCheckingLoop; - } + + var colorIsUnique = true; + do { + //console.log('%cchecking for unique colors', colorCheckingStyle) + //generate random color + var hue = Math.floor(Math.random()*255); + var sat = 130+Math.floor(Math.random()*100); + var lit = 70+Math.floor(Math.random()*100); + var newColorRgb = hslToRgb(hue,sat,lit); + var newColor = rgbToHex(newColorRgb.r,newColorRgb.g,newColorRgb.b); + + var newColorHex = newColor; + + //check if color has been used before + colors = document.getElementsByClassName('color-button'); + colorCheckingLoop: for (var i = 0; i < colors.length; i++) { + //console.log('%c'+newColorHex +' '+ colors[i].jscolor.toString(), colorCheckingStyle) + + //if generated color matches this color + if (newColorHex == colors[i].jscolor.toString()) { + //console.log('%ccolor already exists', colorCheckingStyle) + + //start loop again + colorIsUnique = false; + + //exit + break colorCheckingLoop; + } + } } - } - while (colorIsUnique == false); - - //remove current color selection - document.querySelector("#colors-menu li.selected").classList.remove("selected"); - - //add new color and make it selected - var addedColor = addColor(newColor); - addedColor.classList.add('selected'); - context.fillStyle = '#' + newColor; - - //add history state - //saveHistoryState({type: 'addcolor', colorValue: addedColor.firstElementChild.jscolor.toString()}); - new HistoryStateAddColor(addedColor.firstElementChild.jscolor.toString()); - - //show color picker - addedColor.firstElementChild.jscolor.show(); - console.log("showing picker"); - - //hide edit button - addedColor.lastChild.classList.add('hidden'); -}, false); \ No newline at end of file + while (colorIsUnique == false); + + //remove current color selection + document.querySelector('#colors-menu li.selected').classList.remove('selected'); + + //add new color and make it selected + var addedColor = addColor(newColor); + addedColor.classList.add('selected'); + context.fillStyle = '#' + newColor; + + //add history state + //saveHistoryState({type: 'addcolor', colorValue: addedColor.firstElementChild.jscolor.toString()}); + new HistoryStateAddColor(addedColor.firstElementChild.jscolor.toString()); + + //show color picker + addedColor.firstElementChild.jscolor.show(); + console.log('showing picker'); + + //hide edit button + addedColor.lastChild.classList.add('hidden'); +}, false); diff --git a/js/_changeTool.js b/js/_changeTool.js index 25ebcf3..e0c118c 100644 --- a/js/_changeTool.js +++ b/js/_changeTool.js @@ -1,21 +1,21 @@ function changeTool (selectedTool) { - // Ending any selection in progress - if (currentTool.includes("select") && !selectedTool.includes("select") && !selectionCanceled) { - endSelection(); + // Ending any selection in progress + if (currentTool.includes('select') && !selectedTool.includes('select') && !selectionCanceled) { + endSelection(); } //set tool and temp tje tje tpp; currentTool = selectedTool; - currentToolTemp = selectedTool; - - var tools = document.getElementById("tools-menu").children; - - for (var i = 0; i < tools.length; i++) { - tools[i].classList.remove("selected"); - } - + currentToolTemp = selectedTool; + + var tools = document.getElementById('tools-menu').children; + + for (var i = 0; i < tools.length; i++) { + tools[i].classList.remove('selected'); + } + //give the button of the selected tool the .selected class - document.getElementById(selectedTool+"-button").parentNode.classList.add("selected"); - - //change cursor - updateCursor(); -} \ No newline at end of file + document.getElementById(selectedTool+'-button').parentNode.classList.add('selected'); + + //change cursor + updateCursor(); +} diff --git a/js/_changeZoom.js b/js/_changeZoom.js index 57eb42f..c32a96f 100644 --- a/js/_changeZoom.js +++ b/js/_changeZoom.js @@ -1,32 +1,30 @@ - function changeZoom (layer, direction, cursorLocation) { - var oldWidth = canvasSize[0] * zoom; - var oldHeight = canvasSize[1] * zoom; - var newWidth, newHeight; - - //change zoom level - //if you want to zoom out, and the zoom isnt already at the smallest level - if (direction == 'out' && zoom > 1) { - zoom -= Math.ceil(zoom / 10); - newWidth = canvasSize[0] * zoom; - newHeight = canvasSize[1] * zoom; - - //adjust canvas position - setCanvasOffset(layer.canvas, layer.canvas.offsetLeft + (oldWidth - newWidth) *cursorLocation[0]/oldWidth, layer.canvas.offsetTop + (oldHeight - newHeight) *cursorLocation[1]/oldWidth) - } - //if you want to zoom in - else if (direction == 'in' && zoom + Math.ceil(zoom/10) < window.innerHeight/4){ - zoom += Math.ceil(zoom/10); - newWidth = canvasSize[0] * zoom; - newHeight = canvasSize[1] * zoom; - - //adjust canvas position - setCanvasOffset(layer.canvas, layer.canvas.offsetLeft - Math.round((newWidth - oldWidth)*cursorLocation[0]/oldWidth), layer.canvas.offsetTop - Math.round((newHeight - oldHeight)*cursorLocation[1]/oldHeight)) - } - - //resize canvas - layer.resize(); + var oldWidth = canvasSize[0] * zoom; + var oldHeight = canvasSize[1] * zoom; + var newWidth, newHeight; - // adjust brush size - updateCursor(); -} \ No newline at end of file + //change zoom level + //if you want to zoom out, and the zoom isnt already at the smallest level + if (direction == 'out' && zoom > 1) { + zoom -= Math.ceil(zoom / 10); + newWidth = canvasSize[0] * zoom; + newHeight = canvasSize[1] * zoom; + + //adjust canvas position + setCanvasOffset(layer.canvas, layer.canvas.offsetLeft + (oldWidth - newWidth) *cursorLocation[0]/oldWidth, layer.canvas.offsetTop + (oldHeight - newHeight) *cursorLocation[1]/oldWidth); + } else if (direction == 'in' && zoom + Math.ceil(zoom/10) < window.innerHeight/4){ + //if you want to zoom in + zoom += Math.ceil(zoom/10); + newWidth = canvasSize[0] * zoom; + newHeight = canvasSize[1] * zoom; + + //adjust canvas position + setCanvasOffset(layer.canvas, layer.canvas.offsetLeft - Math.round((newWidth - oldWidth)*cursorLocation[0]/oldWidth), layer.canvas.offsetTop - Math.round((newHeight - oldHeight)*cursorLocation[1]/oldHeight)); + } + + //resize canvas + layer.resize(); + + // adjust brush size + updateCursor(); +} diff --git a/js/_checkCompatibility.js b/js/_checkCompatibility.js index 39201c8..9edfb11 100644 --- a/js/_checkCompatibility.js +++ b/js/_checkCompatibility.js @@ -1,20 +1,19 @@ - /////=include libraries/bowser.js function closeCompatibilityWarning () { - document.getElementById('compatibility-warning').style.visibility = 'hidden'; + document.getElementById('compatibility-warning').style.visibility = 'hidden'; } -console.log('checking compatibility') +console.log('checking compatibility'); //check browser/version -if ( (bowser.msie && bowser.version < 11) || - (bowser.firefox && bowser.version < 28) || - (bowser.chrome && bowser.version < 29) || - (bowser.msedge && bowser.version < 12) || - (bowser.safari && bowser.version < 9) || - (bowser.opera && bowser.version < 17) ) - //show warning - document.getElementById('compatibility-warning').style.visibility = 'visible'; +if ((bowser.msie && bowser.version < 11) || + (bowser.firefox && bowser.version < 28) || + (bowser.chrome && bowser.version < 29) || + (bowser.msedge && bowser.version < 12) || + (bowser.safari && bowser.version < 9) || + (bowser.opera && bowser.version < 17) ) + //show warning + document.getElementById('compatibility-warning').style.visibility = 'visible'; -else alert(bowser.name+' '+bowser.version+' is fine!') \ No newline at end of file +else alert(bowser.name+' '+bowser.version+' is fine!'); diff --git a/js/_checkerboard.js b/js/_checkerboard.js index 9c4b7dc..1e42c77 100644 --- a/js/_checkerboard.js +++ b/js/_checkerboard.js @@ -1,59 +1,59 @@ -// This script contains all the functions used to manage the checkboard - -// Setting current colour (each square has a different colour -var currentColor = firstCheckerBoardColor; -// Saving number of squares filled until now -var nSquaresFilled = 0; - -function fillCheckerboard() { - // Getting checkerboard context - var context = checkerBoard.context; - - // Cycling through the canvas (using it as a matrix) - for (var i=0; i 0) { - colors[0].parentElement.remove(); - } - - var lightestColor = '#000000'; - var darkestColor = '#ffffff'; - - for (var i = 0; i < selectedPalette.length; i++) { - var newColor = selectedPalette[i]; - var newColorElement = addColor(newColor); + //remove current palette + colors = document.getElementsByClassName('color-button'); + while (colors.length > 0) { + colors[0].parentElement.remove(); + } - var newColorHex = hexToRgb(newColor); + var lightestColor = '#000000'; + var darkestColor = '#ffffff'; - var lightestColorHex = hexToRgb(lightestColor); - if (newColorHex.r + newColorHex.g + newColorHex.b > lightestColorHex.r + lightestColorHex.g + lightestColorHex.b) - lightestColor = newColor; + for (var i = 0; i < selectedPalette.length; i++) { + var newColor = selectedPalette[i]; + var newColorElement = addColor(newColor); - var darkestColorHex = hexToRgb(darkestColor); - if (newColorHex.r + newColorHex.g + newColorHex.b < darkestColorHex.r + darkestColorHex.g + darkestColorHex.b) { - - //remove current color selection - var selectedColor = document.querySelector("#colors-menu li.selected") - if (selectedColor) selectedColor.classList.remove("selected"); - - //set as current color - newColorElement.classList.add('selected'); - - darkestColor = newColor; - } - - } - - //fill bg with lightest color - if (fillBackground) { - currentLayer.context.fillStyle = lightestColor; - currentLayer.context.fillRect(0, 0, canvasSize[0], canvasSize[1]); - } - - //set as current color - currentLayer.context.fillStyle = darkestColor; -} \ No newline at end of file + var newColorHex = hexToRgb(newColor); + + var lightestColorHex = hexToRgb(lightestColor); + if (newColorHex.r + newColorHex.g + newColorHex.b > lightestColorHex.r + lightestColorHex.g + lightestColorHex.b) + lightestColor = newColor; + + var darkestColorHex = hexToRgb(darkestColor); + if (newColorHex.r + newColorHex.g + newColorHex.b < darkestColorHex.r + darkestColorHex.g + darkestColorHex.b) { + + //remove current color selection + var selectedColor = document.querySelector('#colors-menu li.selected'); + if (selectedColor) selectedColor.classList.remove('selected'); + + //set as current color + newColorElement.classList.add('selected'); + + darkestColor = newColor; + } + + } + + //fill bg with lightest color + if (fillBackground) { + currentLayer.context.fillStyle = lightestColor; + currentLayer.context.fillRect(0, 0, canvasSize[0], canvasSize[1]); + } + + //set as current color + currentLayer.context.fillStyle = darkestColor; +} diff --git a/js/_deleteColor.js b/js/_deleteColor.js index fac8214..1abb9dd 100644 --- a/js/_deleteColor.js +++ b/js/_deleteColor.js @@ -3,82 +3,82 @@ //called when the delete button is pressed on color picker //input color button or hex string function deleteColor (color) { - const logStyle = 'background: #913939; color: white; padding: 5px;'; - - //console.log('%c'+'deleting color', logStyle); - - //if color is a string, then find the corresponding button - if (typeof color === 'string') { - console.log('trying to find ',color) - //get all colors in palette - colors = document.getElementsByClassName('color-button'); - - //loop through colors - for (var i = 0; i < colors.length; i++) { - console.log(color,'=',colors[i].jscolor.toString()) - - if (color == colors[i].jscolor.toString()) { - console.log('match') - //set color to the color button - color = colors[i]; - console.log('found color', color); - - //exit loop - break; - } - } - - //if the color wasn't found - if (typeof color === 'string') { - console.log('color not found'); - //exit function - return; - } - - } - - //hide color picker - color.jscolor.hide(); - - - //find lightest color in palette - var colors = document.getElementsByClassName('color-button'); - var lightestColor = [0,null]; - for (var i = 0; i < colors.length; i++) { - - //get colors lightness - var lightness = rgbToHsl(colors[i].jscolor.toRgb()).l; - //console.log('%c'+lightness, logStyle) - - //if not the color we're deleting - if (colors[i] != color) { - - //if lighter than the current lightest, set as the new lightest - if (lightness > lightestColor[0]) { - lightestColor[0] = lightness; - lightestColor[1] = colors[i]; - } - } - } - - //console.log('%c'+'replacing with lightest color: '+lightestColor[1].jscolor.toString(), logStyle) - - //replace deleted color with lightest color - replaceAllOfColor(color.jscolor.toString(),lightestColor[1].jscolor.toString()); - - - //if the color you are deleting is the currently selected color - if (color.parentElement.classList.contains('selected')) { - //console.log('%c'+'deleted color is currently selected', logStyle); - - //set current color TO LIGHTEST COLOR - lightestColor[1].parentElement.classList.add('selected'); - currentLayer.context.fillStyle = '#'+lightestColor[1].jscolor.toString(); - } - - //delete the element - colorsMenu.removeChild(color.parentElement); - + const logStyle = 'background: #913939; color: white; padding: 5px;'; - -} \ No newline at end of file + //console.log('%c'+'deleting color', logStyle); + + //if color is a string, then find the corresponding button + if (typeof color === 'string') { + console.log('trying to find ',color); + //get all colors in palette + colors = document.getElementsByClassName('color-button'); + + //loop through colors + for (var i = 0; i < colors.length; i++) { + console.log(color,'=',colors[i].jscolor.toString()); + + if (color == colors[i].jscolor.toString()) { + console.log('match'); + //set color to the color button + color = colors[i]; + console.log('found color', color); + + //exit loop + break; + } + } + + //if the color wasn't found + if (typeof color === 'string') { + console.log('color not found'); + //exit function + return; + } + + } + + //hide color picker + color.jscolor.hide(); + + + //find lightest color in palette + var colors = document.getElementsByClassName('color-button'); + var lightestColor = [0,null]; + for (var i = 0; i < colors.length; i++) { + + //get colors lightness + var lightness = rgbToHsl(colors[i].jscolor.toRgb()).l; + //console.log('%c'+lightness, logStyle) + + //if not the color we're deleting + if (colors[i] != color) { + + //if lighter than the current lightest, set as the new lightest + if (lightness > lightestColor[0]) { + lightestColor[0] = lightness; + lightestColor[1] = colors[i]; + } + } + } + + //console.log('%c'+'replacing with lightest color: '+lightestColor[1].jscolor.toString(), logStyle) + + //replace deleted color with lightest color + replaceAllOfColor(color.jscolor.toString(),lightestColor[1].jscolor.toString()); + + + //if the color you are deleting is the currently selected color + if (color.parentElement.classList.contains('selected')) { + //console.log('%c'+'deleted color is currently selected', logStyle); + + //set current color TO LIGHTEST COLOR + lightestColor[1].parentElement.classList.add('selected'); + currentLayer.context.fillStyle = '#'+lightestColor[1].jscolor.toString(); + } + + //delete the element + colorsMenu.removeChild(color.parentElement); + + + +} diff --git a/js/_dialogue.js b/js/_dialogue.js index bc2f4f9..ba3a741 100644 --- a/js/_dialogue.js +++ b/js/_dialogue.js @@ -1,36 +1,36 @@ function showDialogue (dialogueName, trackEvent) { if (typeof trackEvent === 'undefined') trackEvent = true; - - dialogueOpen = true; - popUpContainer.style.display = 'block'; - - document.getElementById(dialogueName).style.display = 'block'; - + + dialogueOpen = true; + popUpContainer.style.display = 'block'; + + document.getElementById(dialogueName).style.display = 'block'; + //track google event if (trackEvent) ga('send', 'event', 'Palette Editor Dialogue', dialogueName); /*global ga*/ } function closeDialogue () { - popUpContainer.style.display = 'none'; - - var popups = popUpContainer.children; - for (var i = 0; i < popups.length; i++) { - popups[i].style.display = 'none'; - } - - dialogueOpen = false; + popUpContainer.style.display = 'none'; + + var popups = popUpContainer.children; + for (var i = 0; i < popups.length; i++) { + popups[i].style.display = 'none'; + } + + dialogueOpen = false; } -popUpContainer.addEventListener("click", function (e) { - if (e.target == popUpContainer) - closeDialogue(); +popUpContainer.addEventListener('click', function (e) { + if (e.target == popUpContainer) + closeDialogue(); }); //add click handlers for all cancel buttons var cancelButtons = popUpContainer.getElementsByClassName('close-button'); for (var i = 0; i < cancelButtons.length; i++) { - cancelButtons[i].addEventListener('click', function () { - closeDialogue(); - }); -} \ No newline at end of file + cancelButtons[i].addEventListener('click', function () { + closeDialogue(); + }); +} diff --git a/js/_drawLine.js b/js/_drawLine.js index 455cffe..a2741c3 100644 --- a/js/_drawLine.js +++ b/js/_drawLine.js @@ -1,55 +1,55 @@ //draw a line between two points on canvas -function line(x0,y0,x1,y1, brushSize) { - - var dx = Math.abs(x1-x0); - var dy = Math.abs(y1-y0); - var sx = (x0 < x1 ? 1 : -1); - var sy = (y0 < y1 ? 1 : -1); - var err = dx-dy; +function line(x0, y0, x1, y1, brushSize) { - while (true) { - //set pixel - // If the current tool is the brush - if (currentTool == 'pencil' || currentTool == 'rectangle') { - // I fill the rect - currentLayer.context.fillRect(x0-Math.floor(brushSize/2), y0-Math.floor(brushSize/2), brushSize, brushSize); - } else if (currentTool == 'eraser') { - // In case I'm using the eraser I must clear the rect + var dx = Math.abs(x1-x0); + var dy = Math.abs(y1-y0); + var sx = (x0 < x1 ? 1 : -1); + var sy = (y0 < y1 ? 1 : -1); + var err = dx-dy; + + while (true) { + //set pixel + // If the current tool is the brush + if (currentTool == 'pencil' || currentTool == 'rectangle') { + // I fill the rect + currentLayer.context.fillRect(x0-Math.floor(brushSize/2), y0-Math.floor(brushSize/2), brushSize, brushSize); + } else if (currentTool == 'eraser') { + // In case I'm using the eraser I must clear the rect currentLayer.context.clearRect(x0-Math.floor(eraserSize/2), y0-Math.floor(eraserSize/2), eraserSize, eraserSize); - } - - //if we've reached the end goal, exit the loop - if ((x0==x1) && (y0==y1)) break; - var e2 = 2*err; - if (e2 >-dy) {err -=dy; x0+=sx;} - if (e2 < dx) {err +=dx; y0+=sy;} - } + } + + //if we've reached the end goal, exit the loop + if ((x0==x1) && (y0==y1)) break; + var e2 = 2*err; + if (e2 >-dy) {err -=dy; x0+=sx;} + if (e2 < dx) {err +=dx; y0+=sy;} + } } -//draw a line between two points on canvas -function lineOnLayer(x0,y0,x1,y1, brushSize, context) { - - var dx = Math.abs(x1-x0); - var dy = Math.abs(y1-y0); - var sx = (x0 < x1 ? 1 : -1); - var sy = (y0 < y1 ? 1 : -1); - var err = dx-dy; +// draw a line between two points on canvas +function lineOnLayer(x0, y0, x1, y1, brushSize, context) { - while (true) { - //set pixel - // If the current tool is the brush - if (currentTool == 'pencil' || currentTool == 'rectangle') { - // I fill the rect - context.fillRect(x0-Math.floor(brushSize/2), y0-Math.floor(brushSize/2), brushSize, brushSize); - } else if (currentTool == 'eraser') { - // In case I'm using the eraser I must clear the rect + var dx = Math.abs(x1-x0); + var dy = Math.abs(y1-y0); + var sx = (x0 < x1 ? 1 : -1); + var sy = (y0 < y1 ? 1 : -1); + var err = dx-dy; + + while (true) { + //set pixel + // If the current tool is the brush + if (currentTool == 'pencil' || currentTool == 'rectangle') { + // I fill the rect + context.fillRect(x0-Math.floor(brushSize/2), y0-Math.floor(brushSize/2), brushSize, brushSize); + } else if (currentTool == 'eraser') { + // In case I'm using the eraser I must clear the rect context.clearRect(x0-Math.floor(eraserSize/2), y0-Math.floor(eraserSize/2), eraserSize, eraserSize); - } - - //if we've reached the end goal, exit the loop - if ((x0==x1) && (y0==y1)) break; - var e2 = 2*err; - if (e2 >-dy) {err -=dy; x0+=sx;} - if (e2 < dx) {err +=dx; y0+=sy;} - } -} \ No newline at end of file + } + + // if we've reached the end goal, exit the loop + if ((x0==x1) && (y0==y1)) break; + var e2 = 2*err; + if (e2 >-dy) {err -=dy; x0+=sx;} + if (e2 < dx) {err +=dx; y0+=sy;} + } +} diff --git a/js/_fileMenu.js b/js/_fileMenu.js index 54f3b32..494af19 100644 --- a/js/_fileMenu.js +++ b/js/_fileMenu.js @@ -1,18 +1,18 @@ -var mainMenuItems = document.getElementById("main-menu").children; +var mainMenuItems = document.getElementById('main-menu').children; //for each button in main menu (starting at 1 to avoid logo) for (var i = 1; i < mainMenuItems.length; i++) { - //get the button that's in the list item - var menuItem = mainMenuItems[i]; - var menuButton = menuItem.children[0]; + //get the button that's in the list item + var menuItem = mainMenuItems[i]; + var menuButton = menuItem.children[0]; - console.log(mainMenuItems) + console.log(mainMenuItems); //when you click a main menu items button on('click', menuButton, function (e, button) { - console.log('parent ', button.parentElement) - select(button.parentElement); + console.log('parent ', button.parentElement); + select(button.parentElement); }); var subMenu = menuItem.children[1]; @@ -23,114 +23,114 @@ for (var i = 1; i < mainMenuItems.length; i++) { //when you click an item within a menu button for (var j = 0; j < subMenuItems.length; j++) { - var subMenuItem = subMenuItems[j]; - var subMenuButton = subMenuItem.children[0]; + var subMenuItem = subMenuItems[j]; + var subMenuButton = subMenuItem.children[0]; - subMenuButton.addEventListener("click", function (e) { + subMenuButton.addEventListener('click', function (e) { - switch(this.textContent) { + switch(this.textContent) { - //File Menu - case 'New': - showDialogue('new-pixel'); - break; - case 'Open': + //File Menu + case 'New': + showDialogue('new-pixel'); + break; + case 'Open': - //if a document exists - if (documentCreated) { - //check if the user wants to overwrite - if (confirm('Opening a pixel will discard your current one. Are you sure you want to do that?')) - //open file selection dialog - document.getElementById("open-image-browse-holder").click(); - } - else - //open file selection dialog - document.getElementById("open-image-browse-holder").click(); + //if a document exists + if (documentCreated) { + //check if the user wants to overwrite + if (confirm('Opening a pixel will discard your current one. Are you sure you want to do that?')) + //open file selection dialog + document.getElementById('open-image-browse-holder').click(); + } + else + //open file selection dialog + document.getElementById('open-image-browse-holder').click(); - break; + break; - case 'Save as...': - if (documentCreated) { + case 'Save as...': + if (documentCreated) { - //create name - var selectedPalette = getText('palette-button'); - if (selectedPalette != 'Choose a palette...'){ - var paletteAbbreviation = palettes[selectedPalette].abbreviation; - var fileName = 'pixel-'+paletteAbbreviation+'-'+canvasSize[0]+'x'+canvasSize[1]+'.png'; - } else { - var fileName = 'pixel-'+canvasSize[0]+'x'+canvasSize[1]+'.png'; - selectedPalette = 'none'; - } + //create name + var selectedPalette = getText('palette-button'); + if (selectedPalette != 'Choose a palette...'){ + var paletteAbbreviation = palettes[selectedPalette].abbreviation; + var fileName = 'pixel-'+paletteAbbreviation+'-'+canvasSize[0]+'x'+canvasSize[1]+'.png'; + } else { + var fileName = 'pixel-'+canvasSize[0]+'x'+canvasSize[1]+'.png'; + selectedPalette = 'none'; + } - //set download link - var linkHolder = document.getElementById("save-image-link-holder"); - linkHolder.href = canvas.toDataURL(); - linkHolder.download = fileName; + //set download link + var linkHolder = document.getElementById('save-image-link-holder'); + linkHolder.href = canvas.toDataURL(); + linkHolder.download = fileName; - linkHolder.click(); + linkHolder.click(); - //track google event + //track google event ga('send', 'event', 'Pixel Editor Save', selectedPalette, canvasSize[0]+'/'+canvasSize[1]); /*global ga*/ - } + } - break; + break; - case 'Exit': + case 'Exit': - console.log('exit') - //if a document exists, make sure they want to delete it - if (documentCreated) { + console.log('exit'); + //if a document exists, make sure they want to delete it + if (documentCreated) { - //ask user if they want to leave - if (confirm('Exiting will discard your current pixel. Are you sure you want to do that?')) - //skip onbeforeunload prompt - window.onbeforeunload = null; - else - e.preventDefault(); - } + //ask user if they want to leave + if (confirm('Exiting will discard your current pixel. Are you sure you want to do that?')) + //skip onbeforeunload prompt + window.onbeforeunload = null; + else + e.preventDefault(); + } - break; - //Edit Menu - case 'Undo': - undo(); - break; - case 'Redo': - redo(); - break; + break; + //Edit Menu + case 'Undo': + undo(); + break; + case 'Redo': + redo(); + break; - //Palette Menu - case 'Add color': - addColor('#eeeeee'); - break; - //Help Menu - case 'Settings': + //Palette Menu + case 'Add color': + addColor('#eeeeee'); + break; + //Help Menu + case 'Settings': - //fill form with current settings values - setValue('setting-numberOfHistoryStates', settings.numberOfHistoryStates); + //fill form with current settings values + setValue('setting-numberOfHistoryStates', settings.numberOfHistoryStates); - showDialogue('settings'); - break; - //Help Menu - case 'Help': - showDialogue('help'); - break; - case 'About': - showDialogue('about'); - break; - case 'Changelog': - showDialogue('changelog'); - break; - } + showDialogue('settings'); + break; + //Help Menu + case 'Help': + showDialogue('help'); + break; + case 'About': + showDialogue('about'); + break; + case 'Changelog': + showDialogue('changelog'); + break; + } - closeMenu(); - }); - } + closeMenu(); + }); + } } function closeMenu () { - //remove .selected class from all menu buttons - for (var i = 0; i < mainMenuItems.length; i++) { - deselect(mainMenuItems[i]); - } -} \ No newline at end of file + //remove .selected class from all menu buttons + for (var i = 0; i < mainMenuItems.length; i++) { + deselect(mainMenuItems[i]); + } +} diff --git a/js/_fill.js b/js/_fill.js index f248a77..aa8a7d9 100644 --- a/js/_fill.js +++ b/js/_fill.js @@ -1,110 +1,110 @@ function fill(cursorLocation) { - - //changes a pixels color - function colorPixel(tempImage, pixelPos, fillColor) { - //console.log('colorPixel:',pixelPos); - tempImage.data[pixelPos] = fillColor.r; - tempImage.data[pixelPos + 1] = fillColor.g; - tempImage.data[pixelPos + 2] = fillColor.b; - tempImage.data[pixelPos + 3] = 255; - /* - tempImage.data[pixelPos] = fillColor.r; - tempImage.data[pixelPos + 1] = fillColor.g; - tempImage.data[pixelPos + 2] = fillColor.b; - */ - } - - //change x y to color value passed from the function and use that as the original color - function matchStartColor(tempImage, pixelPos, color) { - //console.log('matchPixel:',x,y) - - var r = tempImage.data[pixelPos]; - var g = tempImage.data[pixelPos + 1]; - var b = tempImage.data[pixelPos + 2]; - //console.log(r == color[0] && g == color[1] && b == color[2]); - return (r == color[0] && g == color[1] && b == color[2]); - } - - //save history state - new HistoryStateEditCanvas(); - //saveHistoryState({type: 'canvas', canvas: context.getImageData(0, 0, canvasSize[0], canvasSize[1])}); - //console.log('filling at '+ Math.floor(cursorLocation[0]/zoom) + ','+ Math.floor(cursorLocation[1]/zoom)); - //temporary image holds the data while we change it - var tempImage = currentLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]); + //changes a pixels color + function colorPixel(tempImage, pixelPos, fillColor) { + //console.log('colorPixel:',pixelPos); + tempImage.data[pixelPos] = fillColor.r; + tempImage.data[pixelPos + 1] = fillColor.g; + tempImage.data[pixelPos + 2] = fillColor.b; + tempImage.data[pixelPos + 3] = 255; + /* + tempImage.data[pixelPos] = fillColor.r; + tempImage.data[pixelPos + 1] = fillColor.g; + tempImage.data[pixelPos + 2] = fillColor.b; + */ + } - //this is an array that holds all of the pixels at the top of the cluster - var topmostPixelsArray = [[Math.floor(cursorLocation[0]/zoom), Math.floor(cursorLocation[1]/zoom)]]; - //console.log('topmostPixelsArray:',topmostPixelsArray) + //change x y to color value passed from the function and use that as the original color + function matchStartColor(tempImage, pixelPos, color) { + //console.log('matchPixel:',x,y) - //the offset of the pixel in the temp image data to start with - var startingPosition = (topmostPixelsArray[0][1] * canvasSize[0] + topmostPixelsArray[0][0]) * 4; + var r = tempImage.data[pixelPos]; + var g = tempImage.data[pixelPos + 1]; + var b = tempImage.data[pixelPos + 2]; + //console.log(r == color[0] && g == color[1] && b == color[2]); + return (r == color[0] && g == color[1] && b == color[2]); + } - //the color of the cluster that is being filled - var clusterColor = [tempImage.data[startingPosition],tempImage.data[startingPosition+1],tempImage.data[startingPosition+2]]; + //save history state + new HistoryStateEditCanvas(); + //saveHistoryState({type: 'canvas', canvas: context.getImageData(0, 0, canvasSize[0], canvasSize[1])}); + //console.log('filling at '+ Math.floor(cursorLocation[0]/zoom) + ','+ Math.floor(cursorLocation[1]/zoom)); - //the new color to fill with - var fillColor = hexToRgb(currentLayer.context.fillStyle); + //temporary image holds the data while we change it + var tempImage = currentLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]); - //if you try to fill with the same color that's already there, exit the function - if (clusterColor[0] == fillColor.r && - clusterColor[1] == fillColor.g && - clusterColor[2] == fillColor.b ) - return; + //this is an array that holds all of the pixels at the top of the cluster + var topmostPixelsArray = [[Math.floor(cursorLocation[0]/zoom), Math.floor(cursorLocation[1]/zoom)]]; + //console.log('topmostPixelsArray:',topmostPixelsArray) - //loop until there are no more values left in this array - while (topmostPixelsArray.length) { - var reachLeft, reachRight; + //the offset of the pixel in the temp image data to start with + var startingPosition = (topmostPixelsArray[0][1] * canvasSize[0] + topmostPixelsArray[0][0]) * 4; - //move the most recent pixel from the array and set it as our current working pixels - var currentPixel = topmostPixelsArray.pop(); + //the color of the cluster that is being filled + var clusterColor = [tempImage.data[startingPosition],tempImage.data[startingPosition+1],tempImage.data[startingPosition+2]]; - //set the values of this pixel to x/y variables just for readability - var x = currentPixel[0]; - var y = currentPixel[1]; + //the new color to fill with + var fillColor = hexToRgb(currentLayer.context.fillStyle); - //this variable holds the index of where the starting values for the current pixel are in the data array - //we multiply the number of rows down (y) times the width of each row, then add x. at the end we multiply by 4 because - //each pixel has 4 values, rgba - var pixelPos = (y * canvasSize[0] + x) * 4; + //if you try to fill with the same color that's already there, exit the function + if (clusterColor[0] == fillColor.r && + clusterColor[1] == fillColor.g && + clusterColor[2] == fillColor.b ) + return; - //move up in the image until you reach the top or the pixel you hit was not the right color - while (y-- >= 0 && matchStartColor(tempImage, pixelPos, clusterColor)) { - pixelPos -= canvasSize[0] * 4; - } - pixelPos += canvasSize[0] * 4; - ++y; - reachLeft = false; - reachRight = false; - while (y++ < canvasSize[1] - 1 && matchStartColor(tempImage, pixelPos, clusterColor)) { - colorPixel(tempImage, pixelPos, fillColor); - if (x > 0) { - if (matchStartColor(tempImage, pixelPos - 4, clusterColor)) { - if (!reachLeft) { - topmostPixelsArray.push([x - 1, y]); - reachLeft = true; - } - } - else if (reachLeft) { - reachLeft = false; - } - } + //loop until there are no more values left in this array + while (topmostPixelsArray.length) { + var reachLeft, reachRight; - if (x < canvasSize[0] - 1) { - if (matchStartColor(tempImage, pixelPos + 4, clusterColor)) { - if (!reachRight) { - topmostPixelsArray.push([x + 1, y]); - reachRight = true; - } - } - else if (reachRight) { - reachRight = false; - } - } + //move the most recent pixel from the array and set it as our current working pixels + var currentPixel = topmostPixelsArray.pop(); - pixelPos += canvasSize[0] * 4; - } - } + //set the values of this pixel to x/y variables just for readability + var x = currentPixel[0]; + var y = currentPixel[1]; + + //this variable holds the index of where the starting values for the current pixel are in the data array + //we multiply the number of rows down (y) times the width of each row, then add x. at the end we multiply by 4 because + //each pixel has 4 values, rgba + var pixelPos = (y * canvasSize[0] + x) * 4; + + //move up in the image until you reach the top or the pixel you hit was not the right color + while (y-- >= 0 && matchStartColor(tempImage, pixelPos, clusterColor)) { + pixelPos -= canvasSize[0] * 4; + } + pixelPos += canvasSize[0] * 4; + ++y; + reachLeft = false; + reachRight = false; + while (y++ < canvasSize[1] - 1 && matchStartColor(tempImage, pixelPos, clusterColor)) { + colorPixel(tempImage, pixelPos, fillColor); + if (x > 0) { + if (matchStartColor(tempImage, pixelPos - 4, clusterColor)) { + if (!reachLeft) { + topmostPixelsArray.push([x - 1, y]); + reachLeft = true; + } + } + else if (reachLeft) { + reachLeft = false; + } + } + + if (x < canvasSize[0] - 1) { + if (matchStartColor(tempImage, pixelPos + 4, clusterColor)) { + if (!reachRight) { + topmostPixelsArray.push([x + 1, y]); + reachRight = true; + } + } + else if (reachRight) { + reachRight = false; + } + } + + pixelPos += canvasSize[0] * 4; + } + } currentLayer.context.putImageData(tempImage, 0, 0); - //console.log('done filling') -} \ No newline at end of file + //console.log('done filling') +} diff --git a/js/_getCursorPosition.js b/js/_getCursorPosition.js index 5855409..49aad58 100644 --- a/js/_getCursorPosition.js +++ b/js/_getCursorPosition.js @@ -1,21 +1,21 @@ //get cursor position relative to canvas function getCursorPosition(e) { - var x; - var y; + var x; + var y; - if (e.pageX != undefined && e.pageY != undefined) { - x = e.pageX; - y = e.pageY; - } - else { - x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; - y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; - } + if (e.pageX != undefined && e.pageY != undefined) { + x = e.pageX; + y = e.pageY; + } + else { + x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; + y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; + } - x -= canvas.offsetLeft; - y -= canvas.offsetTop; + x -= canvas.offsetLeft; + y -= canvas.offsetTop; - return [x,y]; + return [x,y]; } // TODO: apply the function below to every getCursorPosition call @@ -24,20 +24,20 @@ function getCursorPosition(e) { //get cursor position relative to canvas function getCursorPositionRelative(e, layer) { - var x; - var y; - - if (e.pageX != undefined && e.pageY != undefined) { - x = e.pageX; - y = e.pageY; - } - else { - x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; - y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; - } + var x; + var y; - x -= layer.canvas.offsetLeft; - y -= layer.canvas.offsetTop; + if (e.pageX != undefined && e.pageY != undefined) { + x = e.pageX; + y = e.pageY; + } + else { + x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; + y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; + } - return [x,y]; -} \ No newline at end of file + x -= layer.canvas.offsetLeft; + y -= layer.canvas.offsetTop; + + return [x,y]; +} diff --git a/js/_history.js b/js/_history.js index db20302..f1f1453 100644 --- a/js/_history.js +++ b/js/_history.js @@ -5,194 +5,194 @@ const undoLogStyle = 'background: #87ff1c; color: black; padding: 5px;'; //prototype for undoing canvas changes function HistoryStateEditCanvas () { - this.canvas = currentLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]); - - this.undo = function () { - var currentCanvas = currentLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]); - currentLayer.context.putImageData(this.canvas, 0, 0); - - this.canvas = currentCanvas; - redoStates.push(this); - } - - this.redo = function () { - var currentCanvas = currentLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]); - currentLayer.context.putImageData(this.canvas, 0, 0); - - this.canvas = currentCanvas; - undoStates.push(this); - } - - //add self to undo array - saveHistoryState(this); + this.canvas = currentLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]); + + this.undo = function () { + var currentCanvas = currentLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]); + currentLayer.context.putImageData(this.canvas, 0, 0); + + this.canvas = currentCanvas; + redoStates.push(this); + }; + + this.redo = function () { + var currentCanvas = currentLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]); + currentLayer.context.putImageData(this.canvas, 0, 0); + + this.canvas = currentCanvas; + undoStates.push(this); + }; + + //add self to undo array + saveHistoryState(this); } //prototype for undoing added colors function HistoryStateAddColor (colorValue) { - this.colorValue = colorValue; - - this.undo = function () { - redoStates.push(this); - deleteColor(this.colorValue); - } - - this.redo = function () { - addColor(this.colorValue); - undoStates.push(this); - } - - //add self to undo array - saveHistoryState(this); + this.colorValue = colorValue; + + this.undo = function () { + redoStates.push(this); + deleteColor(this.colorValue); + }; + + this.redo = function () { + addColor(this.colorValue); + undoStates.push(this); + }; + + //add self to undo array + saveHistoryState(this); } //prototype for undoing deleted colors function HistoryStateDeleteColor (colorValue) { - this.colorValue = colorValue; - this.canvas = currentLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]); - - this.undo = function () { - var currentCanvas = currentLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]); - currentLayer.context.putImageData(this.canvas, 0, 0); - - addColor(this.colorValue); - - this.canvas = currentCanvas; - redoStates.push(this); - } - - this.redo = function () { - var currentCanvas = currentLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]); - currentLayer.context.putImageData(this.canvas, 0, 0); - - deleteColor(this.colorValue); - - this.canvas = currentCanvas; - undoStates.push(this); - } - - //add self to undo array - saveHistoryState(this); + this.colorValue = colorValue; + this.canvas = currentLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]); + + this.undo = function () { + var currentCanvas = currentLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]); + currentLayer.context.putImageData(this.canvas, 0, 0); + + addColor(this.colorValue); + + this.canvas = currentCanvas; + redoStates.push(this); + }; + + this.redo = function () { + var currentCanvas = currentLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]); + currentLayer.context.putImageData(this.canvas, 0, 0); + + deleteColor(this.colorValue); + + this.canvas = currentCanvas; + undoStates.push(this); + }; + + //add self to undo array + saveHistoryState(this); } //prototype for undoing colors edits function HistoryStateEditColor (newColorValue, oldColorValue) { - this.newColorValue = newColorValue; - this.oldColorValue = oldColorValue; - this.canvas = currentLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]); - - this.undo = function () { - var currentCanvas = currentLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]); - currentLayer.context.putImageData(this.canvas, 0, 0); - - //find new color in palette and change it back to old color - var colors = document.getElementsByClassName('color-button'); - for (var i = 0; i < colors.length; i++) { - console.log(newColorValue, '==', colors[i].jscolor.toString()) - if (newColorValue == colors[i].jscolor.toString()) { - colors[i].jscolor.fromString(oldColorValue); - break; - } - } - - this.canvas = currentCanvas; - redoStates.push(this); - } - - this.redo = function () { - var currentCanvas = currentLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]); - currentLayer.context.putImageData(this.canvas, 0, 0); - - //find old color in palette and change it back to new color - var colors = document.getElementsByClassName('color-button'); - for (var i = 0; i < colors.length; i++) { - console.log(oldColorValue, '==', colors[i].jscolor.toString()) - if (oldColorValue == colors[i].jscolor.toString()) { - colors[i].jscolor.fromString(newColorValue); - break; - } - } - - this.canvas = currentCanvas; - undoStates.push(this); - } - - //add self to undo array - saveHistoryState(this); + this.newColorValue = newColorValue; + this.oldColorValue = oldColorValue; + this.canvas = currentLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]); + + this.undo = function () { + var currentCanvas = currentLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]); + currentLayer.context.putImageData(this.canvas, 0, 0); + + //find new color in palette and change it back to old color + var colors = document.getElementsByClassName('color-button'); + for (var i = 0; i < colors.length; i++) { + console.log(newColorValue, '==', colors[i].jscolor.toString()); + if (newColorValue == colors[i].jscolor.toString()) { + colors[i].jscolor.fromString(oldColorValue); + break; + } + } + + this.canvas = currentCanvas; + redoStates.push(this); + }; + + this.redo = function () { + var currentCanvas = currentLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]); + currentLayer.context.putImageData(this.canvas, 0, 0); + + //find old color in palette and change it back to new color + var colors = document.getElementsByClassName('color-button'); + for (var i = 0; i < colors.length; i++) { + console.log(oldColorValue, '==', colors[i].jscolor.toString()); + if (oldColorValue == colors[i].jscolor.toString()) { + colors[i].jscolor.fromString(newColorValue); + break; + } + } + + this.canvas = currentCanvas; + undoStates.push(this); + }; + + //add self to undo array + saveHistoryState(this); } //rename to add undo state function saveHistoryState (state) { - console.log('%csaving history state', undoLogStyle) - console.log(state) + console.log('%csaving history state', undoLogStyle); + console.log(state); - //get current canvas data and save to undoStates array - undoStates.push(state); - - //limit the number of states to settings.numberOfHistoryStates - if (undoStates.length > settings.numberOfHistoryStates) { - undoStates = undoStates.splice(-settings.numberOfHistoryStates, settings.numberOfHistoryStates); - } - - //there is now definitely at least 1 undo state, so the button shouldnt be disabled - document.getElementById('undo-button').classList.remove('disabled'); - - //there should be no redoStates after an undoState is saved - redoStates = []; - - console.log(undoStates) - console.log(redoStates) + //get current canvas data and save to undoStates array + undoStates.push(state); + + //limit the number of states to settings.numberOfHistoryStates + if (undoStates.length > settings.numberOfHistoryStates) { + undoStates = undoStates.splice(-settings.numberOfHistoryStates, settings.numberOfHistoryStates); + } + + //there is now definitely at least 1 undo state, so the button shouldnt be disabled + document.getElementById('undo-button').classList.remove('disabled'); + + //there should be no redoStates after an undoState is saved + redoStates = []; + + console.log(undoStates); + console.log(redoStates); } function undo () { - console.log('%cundo', undoLogStyle); - - //if there are any states saved to undo - if (undoStates.length > 0) { + console.log('%cundo', undoLogStyle); - document.getElementById('redo-button').classList.remove('disabled'); - - //get state - var undoState = undoStates[undoStates.length-1]; - console.log(undoState); - - //restore the state - undoState.undo(); - - //remove from the undo list - undoStates.splice(undoStates.length-1,1); - - //if theres none left to undo, disable the option - if (undoStates.length == 0) - document.getElementById('undo-button').classList.add('disabled'); - } - - console.log(undoStates) - console.log(redoStates) + //if there are any states saved to undo + if (undoStates.length > 0) { + + document.getElementById('redo-button').classList.remove('disabled'); + + //get state + var undoState = undoStates[undoStates.length-1]; + console.log(undoState); + + //restore the state + undoState.undo(); + + //remove from the undo list + undoStates.splice(undoStates.length-1,1); + + //if theres none left to undo, disable the option + if (undoStates.length == 0) + document.getElementById('undo-button').classList.add('disabled'); + } + + console.log(undoStates); + console.log(redoStates); } function redo () { - console.log('%credo', undoLogStyle); + console.log('%credo', undoLogStyle); - if (redoStates.length > 0) { + if (redoStates.length > 0) { - //enable undo button - document.getElementById('undo-button').classList.remove('disabled'); - - //get state - var redoState = redoStates[redoStates.length-1]; - console.log(redoState); - - //restore the state - redoState.redo(); - - //remove from redo array - redoStates.splice(redoStates.length-1,1); - - //if theres none left to redo, disable the option - if (redoStates.length == 0) - document.getElementById('redo-button').classList.add('disabled'); - } - console.log(undoStates) - console.log(redoStates) -} \ No newline at end of file + //enable undo button + document.getElementById('undo-button').classList.remove('disabled'); + + //get state + var redoState = redoStates[redoStates.length-1]; + console.log(redoState); + + //restore the state + redoState.redo(); + + //remove from redo array + redoStates.splice(redoStates.length-1,1); + + //if theres none left to redo, disable the option + if (redoStates.length == 0) + document.getElementById('redo-button').classList.add('disabled'); + } + console.log(undoStates); + console.log(redoStates); +} diff --git a/js/_hotkeyListener.js b/js/_hotkeyListener.js index 13021d4..ffca780 100644 --- a/js/_hotkeyListener.js +++ b/js/_hotkeyListener.js @@ -1,92 +1,91 @@ var spacePressed = false; function KeyPress(e) { - var keyboardEvent = window.event? event : e; + var keyboardEvent = window.event? event : e; - //if the user is typing in an input field, ignore these hotkeys - if (document.activeElement.tagName == 'INPUT') return; + //if the user is typing in an input field, ignore these hotkeys + if (document.activeElement.tagName == 'INPUT') return; - //if no document has been created yet, - //orthere is a dialog box open - //ignore hotkeys - if (!documentCreated || dialogueOpen) return; + //if no document has been created yet, + //orthere is a dialog box open + //ignore hotkeys + if (!documentCreated || dialogueOpen) return; - // - if (e.key === "Escape") { - if (!selectionCanceled) { - endSelection(); - changeTool('pencil'); - } - } - else { - switch (keyboardEvent.keyCode) { - //pencil tool - 1, b - case 49: case 66: - changeTool('pencil'); - break; - //fill tool - 2, f - case 50: case 70: - changeTool('fill'); - break; - //eyedropper - 3, e - case 51: case 69: - changeTool('eyedropper'); - break; - //pan - 4, p, - case 52: case 80: - changeTool('pan'); - break; - //zoom - 5 - case 53: - changeTool('zoom'); - break; - // eraser -6, r - case 54: case 82: - console.log("Pressed r"); - changeTool('eraser'); - break; - // Rectangular selection - case 77: case 109: - changeTool('rectselect'); - break; - //Z - case 90: - console.log('PRESSED Z ', keyboardEvent.ctrlKey) - //CTRL+ALT+Z redo - if (keyboardEvent.altKey && keyboardEvent.ctrlKey) - redo(); - if (!selectionCanceled) { - endSelection(); - changeTool('pencil'); - } - //CTRL+Z undo - else if (keyboardEvent.ctrlKey) { - undo(); - if (!selectionCanceled) { - endSelection(); - changeTool('pencil'); - } - } - //Z switch to zoom tool - else - changeTool('zoom'); - break; - //redo - ctrl y - case 89: - if (keyboardEvent.ctrlKey) - redo(); - break; - case 32: - spacePressed=true; - break; - } - } + // + if (e.key === 'Escape') { + if (!selectionCanceled) { + endSelection(); + changeTool('pencil'); + } + } else { + switch (keyboardEvent.keyCode) { + //pencil tool - 1, b + case 49: case 66: + changeTool('pencil'); + break; + //fill tool - 2, f + case 50: case 70: + changeTool('fill'); + break; + //eyedropper - 3, e + case 51: case 69: + changeTool('eyedropper'); + break; + //pan - 4, p, + case 52: case 80: + changeTool('pan'); + break; + //zoom - 5 + case 53: + changeTool('zoom'); + break; + // eraser -6, r + case 54: case 82: + console.log('Pressed r'); + changeTool('eraser'); + break; + // Rectangular selection + case 77: case 109: + changeTool('rectselect'); + break; + //Z + case 90: + console.log('PRESSED Z ', keyboardEvent.ctrlKey); + //CTRL+ALT+Z redo + if (keyboardEvent.altKey && keyboardEvent.ctrlKey) + redo(); + if (!selectionCanceled) { + endSelection(); + changeTool('pencil'); + } + //CTRL+Z undo + else if (keyboardEvent.ctrlKey) { + undo(); + if (!selectionCanceled) { + endSelection(); + changeTool('pencil'); + } + } + //Z switch to zoom tool + else + changeTool('zoom'); + break; + //redo - ctrl y + case 89: + if (keyboardEvent.ctrlKey) + redo(); + break; + case 32: + spacePressed=true; + break; + } + } } document.onkeydown = KeyPress; -window.addEventListener("keyup", function (e) { - - if (e.keyCode == 32) spacePressed = false; +window.addEventListener('keyup', function (e) { + + if (e.keyCode == 32) spacePressed = false; }); diff --git a/js/_initColor.js b/js/_initColor.js index b333751..955abf4 100644 --- a/js/_initColor.js +++ b/js/_initColor.js @@ -1,23 +1,23 @@ //format a color button function initColor (colorElement) { - //console.log('initColor()'); - //console.log(document.getElementById('jscolor-hex-input')) - - - //add jscolor picker for this color - colorElement.jscolor = new jscolor(colorElement.parentElement, { - valueElement: null, //if you dont set this to null, it turns the button (colorElement) into text, we set it when you open the picker - styleElement: colorElement, - width:151, - position: 'left', - padding:0, - borderWidth:14, - borderColor: '#332f35', - backgroundColor: '#332f35', - insetColor: 'transparent', - value: colorElement.style.backgroundColor, - deleteButton: true, - }); - + //console.log('initColor()'); + //console.log(document.getElementById('jscolor-hex-input')) + + + //add jscolor picker for this color + colorElement.jscolor = new jscolor(colorElement.parentElement, { + valueElement: null, //if you dont set this to null, it turns the button (colorElement) into text, we set it when you open the picker + styleElement: colorElement, + width:151, + position: 'left', + padding:0, + borderWidth:14, + borderColor: '#332f35', + backgroundColor: '#332f35', + insetColor: 'transparent', + value: colorElement.style.backgroundColor, + deleteButton: true, + }); + } diff --git a/js/_jscolor.js b/js/_jscolor.js index d2ef234..e6c8c3b 100644 --- a/js/_jscolor.js +++ b/js/_jscolor.js @@ -1,1964 +1,1965 @@ -/** - * jscolor - JavaScript Color Picker - * - * @link http://jscolor.com - * @license For open source use: GPLv3 - * For commercial use: JSColor Commercial License - * @author Jan Odvarko - * @version 2.0.4 - * - * See usage examples at http://jscolor.com/examples/ - */ - - //Ive made changes to this script. ctrl+f [lospec] - //skeddles variables [lospec] -var colorPickerBottomAdded; -var newjsColorPickerBottom; -"use strict"; - - -if (!window.jscolor) { window.jscolor = (function () { - - -var jsc = { - - - register : function () { - jsc.attachDOMReadyEvent(jsc.init); - jsc.attachEvent(document, 'mousedown', jsc.onDocumentMouseDown); - jsc.attachEvent(document, 'touchstart', jsc.onDocumentTouchStart); - jsc.attachEvent(window, 'resize', jsc.onWindowResize); - }, - - - init : function () { - //console.log('init()') - if (jsc.jscolor.lookupClass) { - jsc.jscolor.installByClassName(jsc.jscolor.lookupClass); - } - }, - - - tryInstallOnElements : function (elms, className) { - var matchClass = new RegExp('(^|\\s)(' + className + ')(\\s*(\\{[^}]*\\})|\\s|$)', 'i'); - - for (var i = 0; i < elms.length; i += 1) { - if (elms[i].type !== undefined && elms[i].type.toLowerCase() == 'color') { - if (jsc.isColorAttrSupported) { - // skip inputs of type 'color' if supported by the browser - continue; - } - } - var m; - if (!elms[i].jscolor && elms[i].className && (m = elms[i].className.match(matchClass))) { - var targetElm = elms[i]; - var optsStr = null; - - var dataOptions = jsc.getDataAttr(targetElm, 'jscolor'); - if (dataOptions !== null) { - optsStr = dataOptions; - } else if (m[4]) { - optsStr = m[4]; - } - - var opts = {}; - if (optsStr) { - try { - opts = (new Function ('return (' + optsStr + ')'))(); - } catch(eParseError) { - jsc.warn('Error parsing jscolor options: ' + eParseError + ':\n' + optsStr); - } - } - targetElm.jscolor = new jsc.jscolor(targetElm, opts); - } - } - }, - - - isColorAttrSupported : (function () { - var elm = document.createElement('input'); - if (elm.setAttribute) { - elm.setAttribute('type', 'color'); - if (elm.type.toLowerCase() == 'color') { - return true; - } - } - return false; - })(), - - - isCanvasSupported : (function () { - var elm = document.createElement('canvas'); - return !!(elm.getContext && elm.getContext('2d')); - })(), - - - fetchElement : function (mixed) { - return typeof mixed === 'string' ? document.getElementById(mixed) : mixed; - }, - - - isElementType : function (elm, type) { - return elm.nodeName.toLowerCase() === type.toLowerCase(); - }, - - - getDataAttr : function (el, name) { - var attrName = 'data-' + name; - var attrValue = el.getAttribute(attrName); - if (attrValue !== null) { - return attrValue; - } - return null; - }, - - - attachEvent : function (el, evnt, func) { - if (el.addEventListener) { - el.addEventListener(evnt, func, false); - } else if (el.attachEvent) { - el.attachEvent('on' + evnt, func); - } - }, - - - detachEvent : function (el, evnt, func) { - if (el.removeEventListener) { - el.removeEventListener(evnt, func, false); - } else if (el.detachEvent) { - el.detachEvent('on' + evnt, func); - } - }, - - - _attachedGroupEvents : {}, - - - attachGroupEvent : function (groupName, el, evnt, func) { - if (!jsc._attachedGroupEvents.hasOwnProperty(groupName)) { - jsc._attachedGroupEvents[groupName] = []; - } - jsc._attachedGroupEvents[groupName].push([el, evnt, func]); - jsc.attachEvent(el, evnt, func); - }, - - - detachGroupEvents : function (groupName) { - if (jsc._attachedGroupEvents.hasOwnProperty(groupName)) { - for (var i = 0; i < jsc._attachedGroupEvents[groupName].length; i += 1) { - var evt = jsc._attachedGroupEvents[groupName][i]; - jsc.detachEvent(evt[0], evt[1], evt[2]); - } - delete jsc._attachedGroupEvents[groupName]; - } - }, - - - attachDOMReadyEvent : function (func) { - var fired = false; - var fireOnce = function () { - if (!fired) { - fired = true; - func(); - } - }; - - if (document.readyState === 'complete') { - setTimeout(fireOnce, 1); // async - return; - } - - if (document.addEventListener) { - document.addEventListener('DOMContentLoaded', fireOnce, false); - - // Fallback - window.addEventListener('load', fireOnce, false); - - } else if (document.attachEvent) { - // IE - document.attachEvent('onreadystatechange', function () { - if (document.readyState === 'complete') { - document.detachEvent('onreadystatechange', arguments.callee); - fireOnce(); - } - }) - - // Fallback - window.attachEvent('onload', fireOnce); - - // IE7/8 - if (document.documentElement.doScroll && window == window.top) { - var tryScroll = function () { - if (!document.body) { return; } - try { - document.documentElement.doScroll('left'); - fireOnce(); - } catch (e) { - setTimeout(tryScroll, 1); - } - }; - tryScroll(); - } - } - }, - - - warn : function (msg) { - if (window.console && window.console.warn) { - window.console.warn(msg); - } - }, - - - preventDefault : function (e) { - if (e.preventDefault) { e.preventDefault(); } - e.returnValue = false; - }, - - - captureTarget : function (target) { - // IE - if (target.setCapture) { - jsc._capturedTarget = target; - jsc._capturedTarget.setCapture(); - } - }, - - - releaseTarget : function () { - // IE - if (jsc._capturedTarget) { - jsc._capturedTarget.releaseCapture(); - jsc._capturedTarget = null; - } - }, - - - fireEvent : function (el, evnt) { - if (!el) { - return; - } - if (document.createEvent) { - var ev = document.createEvent('HTMLEvents'); - ev.initEvent(evnt, true, true); - el.dispatchEvent(ev); - } else if (document.createEventObject) { - var ev = document.createEventObject(); - el.fireEvent('on' + evnt, ev); - } else if (el['on' + evnt]) { // alternatively use the traditional event model - el['on' + evnt](); - } - }, - - - classNameToList : function (className) { - return className.replace(/^\s+|\s+$/g, '').split(/\s+/); - }, - - - // The className parameter (str) can only contain a single class name - hasClass : function (elm, className) { - if (!className) { - return false; - } - return -1 != (' ' + elm.className.replace(/\s+/g, ' ') + ' ').indexOf(' ' + className + ' '); - }, - - - // The className parameter (str) can contain multiple class names separated by whitespace - setClass : function (elm, className) { - var classList = jsc.classNameToList(className); - for (var i = 0; i < classList.length; i += 1) { - if (!jsc.hasClass(elm, classList[i])) { - elm.className += (elm.className ? ' ' : '') + classList[i]; - } - } - }, - - - // The className parameter (str) can contain multiple class names separated by whitespace - unsetClass : function (elm, className) { - var classList = jsc.classNameToList(className); - for (var i = 0; i < classList.length; i += 1) { - var repl = new RegExp( - '^\\s*' + classList[i] + '\\s*|' + - '\\s*' + classList[i] + '\\s*$|' + - '\\s+' + classList[i] + '(\\s+)', - 'g' - ); - elm.className = elm.className.replace(repl, '$1'); - } - }, - - - getStyle : function (elm) { - return window.getComputedStyle ? window.getComputedStyle(elm) : elm.currentStyle; - }, - - - setStyle : (function () { - var helper = document.createElement('div'); - var getSupportedProp = function (names) { - for (var i = 0; i < names.length; i += 1) { - if (names[i] in helper.style) { - return names[i]; - } - } - }; - var props = { - borderRadius: getSupportedProp(['borderRadius', 'MozBorderRadius', 'webkitBorderRadius']), - boxShadow: getSupportedProp(['boxShadow', 'MozBoxShadow', 'webkitBoxShadow']) - }; - return function (elm, prop, value) { - switch (prop.toLowerCase()) { - case 'opacity': - var alphaOpacity = Math.round(parseFloat(value) * 100); - elm.style.opacity = value; - elm.style.filter = 'alpha(opacity=' + alphaOpacity + ')'; - break; - default: - elm.style[props[prop]] = value; - break; - } - }; - })(), - - - setBorderRadius : function (elm, value) { - jsc.setStyle(elm, 'borderRadius', value || '0'); - }, - - - setBoxShadow : function (elm, value) { - jsc.setStyle(elm, 'boxShadow', value || 'none'); - }, - - - getElementPos : function (e, relativeToViewport) { - var x=0, y=0; - var rect = e.getBoundingClientRect(); - x = rect.left; - y = rect.top; - if (!relativeToViewport) { - var viewPos = jsc.getViewPos(); - x += viewPos[0]; - y += viewPos[1]; - } - return [x, y]; - }, - - - getElementSize : function (e) { - return [e.offsetWidth, e.offsetHeight]; - }, - - - // get pointer's X/Y coordinates relative to viewport - getAbsPointerPos : function (e) { - if (!e) { e = window.event; } - var x = 0, y = 0; - if (typeof e.changedTouches !== 'undefined' && e.changedTouches.length) { - // touch devices - x = e.changedTouches[0].clientX; - y = e.changedTouches[0].clientY; - } else if (typeof e.clientX === 'number') { - x = e.clientX; - y = e.clientY; - } - return { x: x, y: y }; - }, - - - // get pointer's X/Y coordinates relative to target element - getRelPointerPos : function (e) { - if (!e) { e = window.event; } - var target = e.target || e.srcElement; - var targetRect = target.getBoundingClientRect(); - - var x = 0, y = 0; - - var clientX = 0, clientY = 0; - if (typeof e.changedTouches !== 'undefined' && e.changedTouches.length) { - // touch devices - clientX = e.changedTouches[0].clientX; - clientY = e.changedTouches[0].clientY; - } else if (typeof e.clientX === 'number') { - clientX = e.clientX; - clientY = e.clientY; - } - - x = clientX - targetRect.left; - y = clientY - targetRect.top; - return { x: x, y: y }; - }, - - - getViewPos : function () { - var doc = document.documentElement; - return [ - (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0), - (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0) - ]; - }, - - - getViewSize : function () { - var doc = document.documentElement; - return [ - (window.innerWidth || doc.clientWidth), - (window.innerHeight || doc.clientHeight), - ]; - }, - - - redrawPosition : function () { - - if (jsc.picker && jsc.picker.owner) { - var thisObj = jsc.picker.owner; - - var tp, vp; - - if (thisObj.fixed) { - // Fixed elements are positioned relative to viewport, - // therefore we can ignore the scroll offset - tp = jsc.getElementPos(thisObj.targetElement, true); // target pos - vp = [0, 0]; // view pos - } else { - tp = jsc.getElementPos(thisObj.targetElement); // target pos - vp = jsc.getViewPos(); // view pos - } - - var ts = jsc.getElementSize(thisObj.targetElement); // target size - var vs = jsc.getViewSize(); // view size - var ps = jsc.getPickerOuterDims(thisObj); // picker size - var a, b, c; - switch (thisObj.position.toLowerCase()) { - case 'left': a=1; b=0; c=-1; break; - case 'right':a=1; b=0; c=1; break; - case 'top': a=0; b=1; c=-1; break; - default: a=0; b=1; c=1; break; - } - var l = (ts[b]+ps[b])/2; - - // compute picker position - if (!thisObj.smartPosition) { - var pp = [ - tp[a], - tp[b]+ts[b]-l+l*c - ]; - } else { - var pp = [ - -vp[a]+tp[a]+ps[a] > vs[a] ? - (-vp[a]+tp[a]+ts[a]/2 > vs[a]/2 && tp[a]+ts[a]-ps[a] >= 0 ? tp[a]+ts[a]-ps[a] : tp[a]) : - tp[a], - -vp[b]+tp[b]+ts[b]+ps[b]-l+l*c > vs[b] ? - (-vp[b]+tp[b]+ts[b]/2 > vs[b]/2 && tp[b]+ts[b]-l-l*c >= 0 ? tp[b]+ts[b]-l-l*c : tp[b]+ts[b]-l+l*c) : - (tp[b]+ts[b]-l+l*c >= 0 ? tp[b]+ts[b]-l+l*c : tp[b]+ts[b]-l-l*c) - ]; - } - - var x = pp[a]; - var y = pp[b]; - var positionValue = thisObj.fixed ? 'fixed' : 'absolute'; - var contractShadow = - (pp[0] + ps[0] > tp[0] || pp[0] < tp[0] + ts[0]) && - (pp[1] + ps[1] < tp[1] + ts[1]); - - jsc._drawPosition(thisObj, x, y, positionValue, contractShadow); - } - }, - - - _drawPosition : function (thisObj, x, y, positionValue, contractShadow) { - var vShadow = contractShadow ? 0 : thisObj.shadowBlur; // px - - jsc.picker.wrap.style.position = positionValue; - jsc.picker.wrap.style.left = x + 'px'; - jsc.picker.wrap.style.top = y + 'px'; - - jsc.setBoxShadow( - jsc.picker.boxS, - thisObj.shadow ? - new jsc.BoxShadow(0, vShadow, thisObj.shadowBlur, 0, thisObj.shadowColor) : - null); - }, - - - getPickerDims : function (thisObj) { - var displaySlider = !!jsc.getSliderComponent(thisObj); - var dims = [ - 2 * thisObj.insetWidth + 2 * thisObj.padding + thisObj.width + - (displaySlider ? 2 * thisObj.insetWidth + jsc.getPadToSliderPadding(thisObj) + thisObj.sliderSize : 0), - 2 * thisObj.insetWidth + 2 * thisObj.padding + thisObj.height + - (thisObj.closable ? 2 * thisObj.insetWidth + thisObj.padding + thisObj.buttonHeight : 0) - ]; - return dims; - }, - - - getPickerOuterDims : function (thisObj) { - var dims = jsc.getPickerDims(thisObj); - return [ - dims[0] + 2 * thisObj.borderWidth, - dims[1] + 2 * thisObj.borderWidth - ]; - }, - - - getPadToSliderPadding : function (thisObj) { - return Math.max(thisObj.padding, 1.5 * (2 * thisObj.pointerBorderWidth + thisObj.pointerThickness)); - }, - - - getPadYComponent : function (thisObj) { - switch (thisObj.mode.charAt(1).toLowerCase()) { - case 'v': return 'v'; break; - } - return 's'; - }, - - - getSliderComponent : function (thisObj) { - if (thisObj.mode.length > 2) { - switch (thisObj.mode.charAt(2).toLowerCase()) { - case 's': return 's'; break; - case 'v': return 'v'; break; - } - } - return null; - }, - - - onDocumentMouseDown : function (e) { - //console.log(e) - - if (!e) { e = window.event; } - var target = e.target || e.srcElement; - - if (target._jscLinkedInstance) { - if (target._jscLinkedInstance.showOnClick) { - target._jscLinkedInstance.show(); - } - } else if (target._jscControlName) { - jsc.onControlPointerStart(e, target, target._jscControlName, 'mouse'); - } else { - // Mouse is outside the picker controls -> hide the color picker! - if (jsc.picker && jsc.picker.owner) { - //console.log(e.target,'=====================================') - //if they clicked on the delete button [lospec] - if (e.target.className == 'delete-color-button') { - //saveHistoryState({type: 'deletecolor', colorValue: jsc.picker.owner.toString(), canvas: canvas.context.getImageData(0, 0, canvasSize[0], canvasSize[1])}); - new HistoryStateDeleteColor(jsc.picker.owner.toString()); - - deleteColor(jsc.picker.owner.styleElement); - } - else if (e.target.className == 'jscolor-picker-bottom') { - //console.log('clicked color picker bottom') - } - else if (e.target.parentElement.classList.contains('jscolor-picker-bottom')) { - //console.log('clicked element in color picker bottom') - } - else { - //console.log('clicked outside of color picker') - //unhide hidden edit button [lospec] - var hiddenButton = document.querySelector(".color-edit-button.hidden") - if (hiddenButton) hiddenButton.classList.remove("hidden"); - - //close color picker - jsc.picker.owner.hide(); - - } - } - } - }, - - - onDocumentTouchStart : function (e) { - if (!e) { e = window.event; } - var target = e.target || e.srcElement; - - if (target._jscLinkedInstance) { - if (target._jscLinkedInstance.showOnClick) { - target._jscLinkedInstance.show(); - } - } else if (target._jscControlName) { - jsc.onControlPointerStart(e, target, target._jscControlName, 'touch'); - } else { - if (jsc.picker && jsc.picker.owner) { - jsc.picker.owner.hide(); - } - } - }, - - - onWindowResize : function (e) { - jsc.redrawPosition(); - }, - - - onParentScroll : function (e) { - // hide the picker when one of the parent elements is scrolled - if (jsc.picker && jsc.picker.owner) { - jsc.picker.owner.hide(); - } - }, - - - _pointerMoveEvent : { - mouse: 'mousemove', - touch: 'touchmove' - }, - _pointerEndEvent : { - mouse: 'mouseup', - touch: 'touchend' - }, - - - _pointerOrigin : null, - _capturedTarget : null, - - - onControlPointerStart : function (e, target, controlName, pointerType) { - var thisObj = target._jscInstance; - - jsc.preventDefault(e); - jsc.captureTarget(target); - - var registerDragEvents = function (doc, offset) { - jsc.attachGroupEvent('drag', doc, jsc._pointerMoveEvent[pointerType], - jsc.onDocumentPointerMove(e, target, controlName, pointerType, offset)); - jsc.attachGroupEvent('drag', doc, jsc._pointerEndEvent[pointerType], - jsc.onDocumentPointerEnd(e, target, controlName, pointerType)); - }; - - registerDragEvents(document, [0, 0]); - - if (window.parent && window.frameElement) { - var rect = window.frameElement.getBoundingClientRect(); - var ofs = [-rect.left, -rect.top]; - registerDragEvents(window.parent.window.document, ofs); - } - - var abs = jsc.getAbsPointerPos(e); - var rel = jsc.getRelPointerPos(e); - jsc._pointerOrigin = { - x: abs.x - rel.x, - y: abs.y - rel.y - }; - - switch (controlName) { - case 'pad': - // if the slider is at the bottom, move it up - switch (jsc.getSliderComponent(thisObj)) { - case 's': if (thisObj.hsv[1] === 0) { thisObj.fromHSV(null, 100, null); }; break; - case 'v': if (thisObj.hsv[2] === 0) { thisObj.fromHSV(null, null, 100); }; break; - } - jsc.setPad(thisObj, e, 0, 0); - break; - - case 'sld': - jsc.setSld(thisObj, e, 0); - break; - } - - jsc.dispatchFineChange(thisObj); - }, - - - onDocumentPointerMove : function (e, target, controlName, pointerType, offset) { - return function (e) { - var thisObj = target._jscInstance; - switch (controlName) { - case 'pad': - if (!e) { e = window.event; } - jsc.setPad(thisObj, e, offset[0], offset[1]); - jsc.dispatchFineChange(thisObj); - break; - - case 'sld': - if (!e) { e = window.event; } - jsc.setSld(thisObj, e, offset[1]); - jsc.dispatchFineChange(thisObj); - break; - } - } - }, - - - onDocumentPointerEnd : function (e, target, controlName, pointerType) { - return function (e) { - var thisObj = target._jscInstance; - jsc.detachGroupEvents('drag'); - jsc.releaseTarget(); - // Always dispatch changes after detaching outstanding mouse handlers, - // in case some user interaction will occur in user's onchange callback - // that would intrude with current mouse events - jsc.dispatchChange(thisObj); - }; - }, - - - dispatchChange : function (thisObj) { - if (thisObj.valueElement) { - if (jsc.isElementType(thisObj.valueElement, 'input')) { - jsc.fireEvent(thisObj.valueElement, 'change'); - } - } - }, - - - dispatchFineChange : function (thisObj) { - if (thisObj.onFineChange) { - var callback; - if (typeof thisObj.onFineChange === 'string') { - callback = new Function (thisObj.onFineChange); - } else { - callback = thisObj.onFineChange; - } - callback.call(thisObj); - } - }, - - - setPad : function (thisObj, e, ofsX, ofsY) { - var pointerAbs = jsc.getAbsPointerPos(e); - var x = ofsX + pointerAbs.x - jsc._pointerOrigin.x - thisObj.padding - thisObj.insetWidth; - var y = ofsY + pointerAbs.y - jsc._pointerOrigin.y - thisObj.padding - thisObj.insetWidth; - - var xVal = x * (360 / (thisObj.width - 1)); - var yVal = 100 - (y * (100 / (thisObj.height - 1))); - - switch (jsc.getPadYComponent(thisObj)) { - case 's': thisObj.fromHSV(xVal, yVal, null, jsc.leaveSld); break; - case 'v': thisObj.fromHSV(xVal, null, yVal, jsc.leaveSld); break; - } - }, - - - setSld : function (thisObj, e, ofsY) { - var pointerAbs = jsc.getAbsPointerPos(e); - var y = ofsY + pointerAbs.y - jsc._pointerOrigin.y - thisObj.padding - thisObj.insetWidth; - - var yVal = 100 - (y * (100 / (thisObj.height - 1))); - - switch (jsc.getSliderComponent(thisObj)) { - case 's': thisObj.fromHSV(null, yVal, null, jsc.leavePad); break; - case 'v': thisObj.fromHSV(null, null, yVal, jsc.leavePad); break; - } - }, - - - _vmlNS : 'jsc_vml_', - _vmlCSS : 'jsc_vml_css_', - _vmlReady : false, - - - initVML : function () { - if (!jsc._vmlReady) { - // init VML namespace - var doc = document; - if (!doc.namespaces[jsc._vmlNS]) { - doc.namespaces.add(jsc._vmlNS, 'urn:schemas-microsoft-com:vml'); - } - if (!doc.styleSheets[jsc._vmlCSS]) { - var tags = ['shape', 'shapetype', 'group', 'background', 'path', 'formulas', 'handles', 'fill', 'stroke', 'shadow', 'textbox', 'textpath', 'imagedata', 'line', 'polyline', 'curve', 'rect', 'roundrect', 'oval', 'arc', 'image']; - var ss = doc.createStyleSheet(); - ss.owningElement.id = jsc._vmlCSS; - for (var i = 0; i < tags.length; i += 1) { - ss.addRule(jsc._vmlNS + '\\:' + tags[i], 'behavior:url(#default#VML);'); - } - } - jsc._vmlReady = true; - } - }, - - - createPalette : function () { - - var paletteObj = { - elm: null, - draw: null - }; - - if (jsc.isCanvasSupported) { - // Canvas implementation for modern browsers - - var canvas = document.createElement('canvas'); - var ctx = canvas.getContext('2d'); - - var drawFunc = function (width, height, type) { - canvas.width = width; - canvas.height = height; - - ctx.clearRect(0, 0, canvas.width, canvas.height); - - var hGrad = ctx.createLinearGradient(0, 0, canvas.width, 0); - hGrad.addColorStop(0 / 6, '#F00'); - hGrad.addColorStop(1 / 6, '#FF0'); - hGrad.addColorStop(2 / 6, '#0F0'); - hGrad.addColorStop(3 / 6, '#0FF'); - hGrad.addColorStop(4 / 6, '#00F'); - hGrad.addColorStop(5 / 6, '#F0F'); - hGrad.addColorStop(6 / 6, '#F00'); - - ctx.fillStyle = hGrad; - ctx.fillRect(0, 0, canvas.width, canvas.height); - - var vGrad = ctx.createLinearGradient(0, 0, 0, canvas.height); - switch (type.toLowerCase()) { - case 's': - vGrad.addColorStop(0, 'rgba(255,255,255,0)'); - vGrad.addColorStop(1, 'rgba(255,255,255,1)'); - break; - case 'v': - vGrad.addColorStop(0, 'rgba(0,0,0,0)'); - vGrad.addColorStop(1, 'rgba(0,0,0,1)'); - break; - } - ctx.fillStyle = vGrad; - ctx.fillRect(0, 0, canvas.width, canvas.height); - }; - - paletteObj.elm = canvas; - paletteObj.draw = drawFunc; - - } else { - // VML fallback for IE 7 and 8 - - jsc.initVML(); - - var vmlContainer = document.createElement('div'); - vmlContainer.style.position = 'relative'; - vmlContainer.style.overflow = 'hidden'; - - var hGrad = document.createElement(jsc._vmlNS + ':fill'); - hGrad.type = 'gradient'; - hGrad.method = 'linear'; - hGrad.angle = '90'; - hGrad.colors = '16.67% #F0F, 33.33% #00F, 50% #0FF, 66.67% #0F0, 83.33% #FF0' - - var hRect = document.createElement(jsc._vmlNS + ':rect'); - hRect.style.position = 'absolute'; - hRect.style.left = -1 + 'px'; - hRect.style.top = -1 + 'px'; - hRect.stroked = false; - hRect.appendChild(hGrad); - vmlContainer.appendChild(hRect); - - var vGrad = document.createElement(jsc._vmlNS + ':fill'); - vGrad.type = 'gradient'; - vGrad.method = 'linear'; - vGrad.angle = '180'; - vGrad.opacity = '0'; - - var vRect = document.createElement(jsc._vmlNS + ':rect'); - vRect.style.position = 'absolute'; - vRect.style.left = -1 + 'px'; - vRect.style.top = -1 + 'px'; - vRect.stroked = false; - vRect.appendChild(vGrad); - vmlContainer.appendChild(vRect); - - var drawFunc = function (width, height, type) { - vmlContainer.style.width = width + 'px'; - vmlContainer.style.height = height + 'px'; - - hRect.style.width = - vRect.style.width = - (width + 1) + 'px'; - hRect.style.height = - vRect.style.height = - (height + 1) + 'px'; - - // Colors must be specified during every redraw, otherwise IE won't display - // a full gradient during a subsequential redraw - hGrad.color = '#F00'; - hGrad.color2 = '#F00'; - - switch (type.toLowerCase()) { - case 's': - vGrad.color = vGrad.color2 = '#FFF'; - break; - case 'v': - vGrad.color = vGrad.color2 = '#000'; - break; - } - }; - - paletteObj.elm = vmlContainer; - paletteObj.draw = drawFunc; - } - - return paletteObj; - }, - - - createSliderGradient : function () { - - var sliderObj = { - elm: null, - draw: null - }; - - if (jsc.isCanvasSupported) { - // Canvas implementation for modern browsers - - var canvas = document.createElement('canvas'); - var ctx = canvas.getContext('2d'); - - var drawFunc = function (width, height, color1, color2) { - canvas.width = width; - canvas.height = height; - - ctx.clearRect(0, 0, canvas.width, canvas.height); - - var grad = ctx.createLinearGradient(0, 0, 0, canvas.height); - grad.addColorStop(0, color1); - grad.addColorStop(1, color2); - - ctx.fillStyle = grad; - ctx.fillRect(0, 0, canvas.width, canvas.height); - }; - - sliderObj.elm = canvas; - sliderObj.draw = drawFunc; - - } else { - // VML fallback for IE 7 and 8 - - jsc.initVML(); - - var vmlContainer = document.createElement('div'); - vmlContainer.style.position = 'relative'; - vmlContainer.style.overflow = 'hidden'; - - var grad = document.createElement(jsc._vmlNS + ':fill'); - grad.type = 'gradient'; - grad.method = 'linear'; - grad.angle = '180'; - - var rect = document.createElement(jsc._vmlNS + ':rect'); - rect.style.position = 'absolute'; - rect.style.left = -1 + 'px'; - rect.style.top = -1 + 'px'; - rect.stroked = false; - rect.appendChild(grad); - vmlContainer.appendChild(rect); - - var drawFunc = function (width, height, color1, color2) { - vmlContainer.style.width = width + 'px'; - vmlContainer.style.height = height + 'px'; - - rect.style.width = (width + 1) + 'px'; - rect.style.height = (height + 1) + 'px'; - - grad.color = color1; - grad.color2 = color2; - }; - - sliderObj.elm = vmlContainer; - sliderObj.draw = drawFunc; - } - - return sliderObj; - }, - - - leaveValue : 1<<0, - leaveStyle : 1<<1, - leavePad : 1<<2, - leaveSld : 1<<3, - - - BoxShadow : (function () { - var BoxShadow = function (hShadow, vShadow, blur, spread, color, inset) { - this.hShadow = hShadow; - this.vShadow = vShadow; - this.blur = blur; - this.spread = spread; - this.color = color; - this.inset = !!inset; - }; - - BoxShadow.prototype.toString = function () { - var vals = [ - Math.round(this.hShadow) + 'px', - Math.round(this.vShadow) + 'px', - Math.round(this.blur) + 'px', - Math.round(this.spread) + 'px', - this.color - ]; - if (this.inset) { - vals.push('inset'); - } - return vals.join(' '); - }; - - return BoxShadow; - })(), - - - // - // Usage: - // var myColor = new jscolor( [, ]) - // - - jscolor : function (targetElement, options) { - - // General options - // - this.value = null; // initial HEX color. To change it later, use methods fromString(), fromHSV() and fromRGB() - this.valueElement = targetElement; // element that will be used to display and input the color code - this.styleElement = targetElement; // element that will preview the picked color using CSS backgroundColor - this.required = true; // whether the associated text can be left empty - this.refine = true; // whether to refine the entered color code (e.g. uppercase it and remove whitespace) - this.hash = false; // whether to prefix the HEX color code with # symbol - this.uppercase = true; // whether to uppercase the color code - this.onFineChange = null; // called instantly every time the color changes (value can be either a function or a string with javascript code) - this.activeClass = 'jscolor-active'; // class to be set to the target element when a picker window is open on it - this.minS = 0; // min allowed saturation (0 - 100) - this.maxS = 100; // max allowed saturation (0 - 100) - this.minV = 0; // min allowed value (brightness) (0 - 100) - this.maxV = 100; // max allowed value (brightness) (0 - 100) - - // Accessing the picked color - // - this.hsv = [0, 0, 100]; // read-only [0-360, 0-100, 0-100] - this.rgb = [255, 255, 255]; // read-only [0-255, 0-255, 0-255] - - // Color Picker options - // - this.width = 181; // width of color palette (in px) - this.height = 101; // height of color palette (in px) - this.showOnClick = true; // whether to display the color picker when user clicks on its target element - this.mode = 'HSV'; // HSV | HVS | HS | HV - layout of the color picker controls - this.position = 'bottom'; // left | right | top | bottom - position relative to the target element - this.smartPosition = true; // automatically change picker position when there is not enough space for it - this.sliderSize = 16; // px - this.crossSize = 8; // px - this.closable = false; // whether to display the Close button - this.closeText = 'Close'; - this.buttonColor = '#000000'; // CSS color - this.buttonHeight = 18; // px - this.padding = 12; // px - this.backgroundColor = '#FFFFFF'; // CSS color - this.borderWidth = 1; // px - this.borderColor = '#BBBBBB'; // CSS color - this.borderRadius = 8; // px - this.insetWidth = 1; // px - this.insetColor = '#BBBBBB'; // CSS color - this.shadow = true; // whether to display shadow - this.shadowBlur = 15; // px - this.shadowColor = 'rgba(0,0,0,0.2)'; // CSS color - this.pointerColor = '#4C4C4C'; // px - this.pointerBorderColor = '#FFFFFF'; // px - this.pointerBorderWidth = 1; // px - this.pointerThickness = 2; // px - this.zIndex = 1000; - this.container = null; // where to append the color picker (BODY element by default) - - - for (var opt in options) { - if (options.hasOwnProperty(opt)) { - this[opt] = options[opt]; - } - } - - - this.hide = function () { - ///console.log(this.styleElement) - if (isPickerOwner()) { - - //console.log('color picker hidden') - - //set the color to old color, in case the color is a duplicate that hasn't been resolved yet [lospec] - var hexInput = document.getElementById('jscolor-hex-input'); - var oldColor = '#'+rgbToHex(hexInput.oldColor); - this.fromString(oldColor) - document.getElementById('duplicate-color-warning').style.visibility = 'hidden'; - - //dialog is closed - dialogueOpen = false; - - detachPicker(); - } - }; - - //show the color picker - this.show = function () { - drawPicker(); - - //a dialog is open - dialogueOpen = true; - - //[lospec] - //find the hex input element - var hexInput = document.getElementById('jscolor-hex-input'); - - //set the value element to the hex input - this.valueElement = hexInput - - //update hex code - this.exportColor(); - - //set old color for updating colors on canvas - hexInput.oldColor = hexToRgb(hexInput.value); - - //set the color element to the clicked button - hexInput.colorElement = this.styleElement; - - //disable delete button if last color - var colors = document.getElementsByClassName('color-button'); - var deleteButton = document.getElementsByClassName('delete-color-button')[0]; - if(colors.length == 1) - deleteButton.classList.add('disabled'); - else - deleteButton.classList.remove('disabled'); - - //hide duplicate color warning - var duplicateColorWarning = document.getElementById("duplicate-color-warning"); - duplicateColorWarning.style.visibility = 'hidden'; - }; - - - this.redraw = function () { - if (isPickerOwner()) { - drawPicker(); - } - }; - - - this.importColor = function () { - if (!this.valueElement) { - this.exportColor(); - } else { - if (jsc.isElementType(this.valueElement, 'input')) { - if (!this.refine) { - if (!this.fromString(this.valueElement.value, jsc.leaveValue)) { - if (this.styleElement) { - this.styleElement.style.backgroundImage = this.styleElement._jscOrigStyle.backgroundImage; - this.styleElement.style.backgroundColor = this.styleElement._jscOrigStyle.backgroundColor; - this.styleElement.style.color = this.styleElement._jscOrigStyle.color; - } - this.exportColor(jsc.leaveValue | jsc.leaveStyle); - } - } else if (!this.required && /^\s*$/.test(this.valueElement.value)) { - this.valueElement.value = ''; - if (this.styleElement) { - this.styleElement.style.backgroundImage = this.styleElement._jscOrigStyle.backgroundImage; - this.styleElement.style.backgroundColor = this.styleElement._jscOrigStyle.backgroundColor; - this.styleElement.style.color = this.styleElement._jscOrigStyle.color; - } - this.exportColor(jsc.leaveValue | jsc.leaveStyle); - - } else if (this.fromString(this.valueElement.value)) { - // managed to import color successfully from the value -> OK, don't do anything - } else { - this.exportColor(); - } - } else { - // not an input element -> doesn't have any value - this.exportColor(); - } - } - }; - - - this.exportColor = function (flags) { - if (!(flags & jsc.leaveValue) && this.valueElement) { - var value = this.toString(); - if (this.uppercase) { value = value.toUpperCase(); } - if (this.hash) { value = '#' + value; } - - if (jsc.isElementType(this.valueElement, 'input')) { - //console.log('SETTING VALUE') - //this sets the value element's value - this.valueElement.value = value; - } else { - this.valueElement.innerHTML = value; - } - } - if (!(flags & jsc.leaveStyle)) { - if (this.styleElement) { - this.styleElement.style.backgroundImage = 'none'; - this.styleElement.style.backgroundColor = '#' + this.toString(); - this.styleElement.style.color = this.isLight() ? '#000' : '#FFF'; - } - } - if (!(flags & jsc.leavePad) && isPickerOwner()) { - redrawPad(); - } - if (!(flags & jsc.leaveSld) && isPickerOwner()) { - redrawSld(); - } - }; - - - // h: 0-360 - // s: 0-100 - // v: 0-100 - // - this.fromHSV = function (h, s, v, flags) { // null = don't change - if (h !== null) { - if (isNaN(h)) { return false; } - h = Math.max(0, Math.min(360, h)); - } - if (s !== null) { - if (isNaN(s)) { return false; } - s = Math.max(0, Math.min(100, this.maxS, s), this.minS); - } - if (v !== null) { - if (isNaN(v)) { return false; } - v = Math.max(0, Math.min(100, this.maxV, v), this.minV); - } - - this.rgb = HSV_RGB( - h===null ? this.hsv[0] : (this.hsv[0]=h), - s===null ? this.hsv[1] : (this.hsv[1]=s), - v===null ? this.hsv[2] : (this.hsv[2]=v) - ); - - this.exportColor(flags); - }; - - - // r: 0-255 - // g: 0-255 - // b: 0-255 - // - this.fromRGB = function (r, g, b, flags) { // null = don't change - if (r !== null) { - if (isNaN(r)) { return false; } - r = Math.max(0, Math.min(255, r)); - } - if (g !== null) { - if (isNaN(g)) { return false; } - g = Math.max(0, Math.min(255, g)); - } - if (b !== null) { - if (isNaN(b)) { return false; } - b = Math.max(0, Math.min(255, b)); - } - - var hsv = RGB_HSV( - r===null ? this.rgb[0] : r, - g===null ? this.rgb[1] : g, - b===null ? this.rgb[2] : b - ); - if (hsv[0] !== null) { - this.hsv[0] = Math.max(0, Math.min(360, hsv[0])); - } - if (hsv[2] !== 0) { - this.hsv[1] = hsv[1]===null ? null : Math.max(0, this.minS, Math.min(100, this.maxS, hsv[1])); - } - this.hsv[2] = hsv[2]===null ? null : Math.max(0, this.minV, Math.min(100, this.maxV, hsv[2])); - - // update RGB according to final HSV, as some values might be trimmed - var rgb = HSV_RGB(this.hsv[0], this.hsv[1], this.hsv[2]); - this.rgb[0] = rgb[0]; - this.rgb[1] = rgb[1]; - this.rgb[2] = rgb[2]; - - this.exportColor(flags); - }; - - - this.fromString = function (str, flags) { - var m; - if (m = str.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i)) { - // HEX notation - // - - if (m[1].length === 6) { - // 6-char notation - this.fromRGB( - parseInt(m[1].substr(0,2),16), - parseInt(m[1].substr(2,2),16), - parseInt(m[1].substr(4,2),16), - flags - ); - } else { - // 3-char notation - this.fromRGB( - parseInt(m[1].charAt(0) + m[1].charAt(0),16), - parseInt(m[1].charAt(1) + m[1].charAt(1),16), - parseInt(m[1].charAt(2) + m[1].charAt(2),16), - flags - ); - } - return true; - - } else if (m = str.match(/^\W*rgba?\(([^)]*)\)\W*$/i)) { - var params = m[1].split(','); - var re = /^\s*(\d*)(\.\d+)?\s*$/; - var mR, mG, mB; - if ( - params.length >= 3 && - (mR = params[0].match(re)) && - (mG = params[1].match(re)) && - (mB = params[2].match(re)) - ) { - var r = parseFloat((mR[1] || '0') + (mR[2] || '')); - var g = parseFloat((mG[1] || '0') + (mG[2] || '')); - var b = parseFloat((mB[1] || '0') + (mB[2] || '')); - this.fromRGB(r, g, b, flags); - return true; - } - } - return false; - }; - - - this.toString = function () { - return ( - (0x100 | Math.round(this.rgb[0])).toString(16).substr(1) + - (0x100 | Math.round(this.rgb[1])).toString(16).substr(1) + - (0x100 | Math.round(this.rgb[2])).toString(16).substr(1) - ); - }; - - - this.toHEXString = function () { - return '#' + this.toString().toUpperCase(); - }; - - - this.toRGBString = function () { - return ('rgb(' + - Math.round(this.rgb[0]) + ',' + - Math.round(this.rgb[1]) + ',' + - Math.round(this.rgb[2]) + ')' - ); - }; - - //returns rgb color object [lospec] - this.toRgb = function () { - return { - r: Math.round(this.rgb[0]), - g: Math.round(this.rgb[1]), - b: Math.round(this.rgb[2]) - }; - }; - - - this.isLight = function () { - return ( - 0.213 * this.rgb[0] + - 0.715 * this.rgb[1] + - 0.072 * this.rgb[2] > - 255 / 2 - ); - }; - - - this._processParentElementsInDOM = function () { - if (this._linkedElementsProcessed) { return; } - this._linkedElementsProcessed = true; - - var elm = this.targetElement; - do { - // If the target element or one of its parent nodes has fixed position, - // then use fixed positioning instead - // - // Note: In Firefox, getComputedStyle returns null in a hidden iframe, - // that's why we need to check if the returned style object is non-empty - var currStyle = jsc.getStyle(elm); - if (currStyle && currStyle.position.toLowerCase() === 'fixed') { - this.fixed = true; - } - - if (elm !== this.targetElement) { - // Ensure to attach onParentScroll only once to each parent element - // (multiple targetElements can share the same parent nodes) - // - // Note: It's not just offsetParents that can be scrollable, - // that's why we loop through all parent nodes - if (!elm._jscEventsAttached) { - jsc.attachEvent(elm, 'scroll', jsc.onParentScroll); - elm._jscEventsAttached = true; - } - } - } while ((elm = elm.parentNode) && !jsc.isElementType(elm, 'body')); - }; - - - // r: 0-255 - // g: 0-255 - // b: 0-255 - // - // returns: [ 0-360, 0-100, 0-100 ] - // - function RGB_HSV (r, g, b) { - r /= 255; - g /= 255; - b /= 255; - var n = Math.min(Math.min(r,g),b); - var v = Math.max(Math.max(r,g),b); - var m = v - n; - if (m === 0) { return [ null, 0, 100 * v ]; } - var h = r===n ? 3+(b-g)/m : (g===n ? 5+(r-b)/m : 1+(g-r)/m); - return [ - 60 * (h===6?0:h), - 100 * (m/v), - 100 * v - ]; - } - - - // h: 0-360 - // s: 0-100 - // v: 0-100 - // - // returns: [ 0-255, 0-255, 0-255 ] - // - function HSV_RGB (h, s, v) { - var u = 255 * (v / 100); - - if (h === null) { - return [ u, u, u ]; - } - - h /= 60; - s /= 100; - - var i = Math.floor(h); - var f = i%2 ? h-i : 1-(h-i); - var m = u * (1 - s); - var n = u * (1 - s * f); - switch (i) { - case 6: - case 0: return [u,n,m]; - case 1: return [n,u,m]; - case 2: return [m,u,n]; - case 3: return [m,n,u]; - case 4: return [n,m,u]; - case 5: return [u,m,n]; - } - } - - //this is called when the picker is closed - function detachPicker () { - jsc.unsetClass(THIS.targetElement, THIS.activeClass); - jsc.picker.wrap.parentNode.removeChild(jsc.picker.wrap); - delete jsc.picker.owner; - } - - - function drawPicker () { - - //console.log('drawPicker ()') - // At this point, when drawing the picker, we know what the parent elements are - // and we can do all related DOM operations, such as registering events on them - // or checking their positioning - THIS._processParentElementsInDOM(); - - if (!jsc.picker) { - jsc.picker = { - owner: null, - wrap : document.createElement('div'), - box : document.createElement('div'), - boxS : document.createElement('div'), // shadow area - boxB : document.createElement('div'), // border - pad : document.createElement('div'), - padB : document.createElement('div'), // border - padM : document.createElement('div'), // mouse/touch area - padPal : jsc.createPalette(), - cross : document.createElement('div'), - crossBY : document.createElement('div'), // border Y - crossBX : document.createElement('div'), // border X - crossLY : document.createElement('div'), // line Y - crossLX : document.createElement('div'), // line X - sld : document.createElement('div'), - sldB : document.createElement('div'), // border - sldM : document.createElement('div'), // mouse/touch area - sldGrad : jsc.createSliderGradient(), - sldPtrS : document.createElement('div'), // slider pointer spacer - sldPtrIB : document.createElement('div'), // slider pointer inner border - sldPtrMB : document.createElement('div'), // slider pointer middle border - sldPtrOB : document.createElement('div'), // slider pointer outer border - btn : document.createElement('div'), - btnT : document.createElement('span') // text - }; - - jsc.picker.pad.appendChild(jsc.picker.padPal.elm); - jsc.picker.padB.appendChild(jsc.picker.pad); - jsc.picker.cross.appendChild(jsc.picker.crossBY); - jsc.picker.cross.appendChild(jsc.picker.crossBX); - jsc.picker.cross.appendChild(jsc.picker.crossLY); - jsc.picker.cross.appendChild(jsc.picker.crossLX); - jsc.picker.padB.appendChild(jsc.picker.cross); - jsc.picker.box.appendChild(jsc.picker.padB); - jsc.picker.box.appendChild(jsc.picker.padM); - - jsc.picker.sld.appendChild(jsc.picker.sldGrad.elm); - jsc.picker.sldB.appendChild(jsc.picker.sld); - jsc.picker.sldB.appendChild(jsc.picker.sldPtrOB); - jsc.picker.sldPtrOB.appendChild(jsc.picker.sldPtrMB); - jsc.picker.sldPtrMB.appendChild(jsc.picker.sldPtrIB); - jsc.picker.sldPtrIB.appendChild(jsc.picker.sldPtrS); - jsc.picker.box.appendChild(jsc.picker.sldB); - jsc.picker.box.appendChild(jsc.picker.sldM); - - jsc.picker.btn.appendChild(jsc.picker.btnT); - jsc.picker.box.appendChild(jsc.picker.btn); - - jsc.picker.boxB.appendChild(jsc.picker.box); - jsc.picker.wrap.appendChild(jsc.picker.boxS); - jsc.picker.wrap.appendChild(jsc.picker.boxB); - } - - var p = jsc.picker; - - var displaySlider = !!jsc.getSliderComponent(THIS); - var dims = jsc.getPickerDims(THIS); - var crossOuterSize = (2 * THIS.pointerBorderWidth + THIS.pointerThickness + 2 * THIS.crossSize); - var padToSliderPadding = jsc.getPadToSliderPadding(THIS); - var borderRadius = Math.min( - THIS.borderRadius, - Math.round(THIS.padding * Math.PI)); // px - var padCursor = 'crosshair'; - - // wrap - p.wrap.classList.add('jscolor-wrap'); - p.wrap.style.clear = 'both'; - p.wrap.style.width = (dims[0] + 2 * THIS.borderWidth) + 'px'; - p.wrap.style.height = (dims[1] + 2 * THIS.borderWidth) + 'px'; - p.wrap.style.zIndex = THIS.zIndex; - - - // picker - p.box.classList.add('jscolor-box'); - p.box.style.width = dims[0] + 'px'; - p.box.style.height = (dims[1]+25) + 'px'; //added 25 for trash icon - - p.boxS.style.position = 'absolute'; - p.boxS.style.left = '0'; - p.boxS.style.top = '0'; - p.boxS.style.width = '100%'; - p.boxS.style.height = '100%'; - jsc.setBorderRadius(p.boxS, borderRadius + 'px'); - - // picker border - p.wrap.classList.add('jscolor-boxB'); - p.boxB.style.position = 'relative'; - p.boxB.style.border = THIS.borderWidth + 'px solid'; - p.boxB.style.borderColor = THIS.borderColor; - p.boxB.style.background = THIS.backgroundColor; - jsc.setBorderRadius(p.boxB, borderRadius + 'px'); - - // IE hack: - // If the element is transparent, IE will trigger the event on the elements under it, - // e.g. on Canvas or on elements with border - p.padM.style.background = - p.sldM.style.background = - '#FFF'; - jsc.setStyle(p.padM, 'opacity', '0'); - jsc.setStyle(p.sldM, 'opacity', '0'); - - // pad - p.pad.classList.add('jscolor-pad'); - p.pad.style.position = 'relative'; - p.pad.style.width = THIS.width + 'px'; - p.pad.style.height = THIS.height + 'px'; - - // pad palettes (HSV and HVS) - p.padPal.draw(THIS.width, THIS.height, jsc.getPadYComponent(THIS)); - - // pad border - p.padB.classList.add('jscolor-padB'); - p.padB.style.position = 'absolute'; - p.padB.style.left = THIS.padding + 'px'; - p.padB.style.top = THIS.padding + 'px'; - p.padB.style.border = THIS.insetWidth + 'px solid'; - p.padB.style.borderColor = THIS.insetColor; - - // pad mouse area - p.padM.classList.add('jscolor-padM'); - p.padM._jscInstance = THIS; - p.padM._jscControlName = 'pad'; - p.padM.style.position = 'absolute'; - p.padM.style.left = '0'; - p.padM.style.top = '0'; - p.padM.style.width = (THIS.padding + 2 * THIS.insetWidth + THIS.width + padToSliderPadding / 2) + 'px'; - p.padM.style.height = dims[1] + 'px'; - p.padM.style.cursor = padCursor; - - // pad cross - p.cross.classList.add('jscolor-cross'); - p.cross.style.position = 'absolute'; - p.cross.style.left = - p.cross.style.top = - '0'; - p.cross.style.width = - p.cross.style.height = - crossOuterSize + 'px'; - - // pad cross border Y and X - p.crossBY.style.position = - p.crossBX.style.position = - 'absolute'; - p.crossBY.style.background = - p.crossBX.style.background = - THIS.pointerBorderColor; - p.crossBY.style.width = - p.crossBX.style.height = - (2 * THIS.pointerBorderWidth + THIS.pointerThickness) + 'px'; - p.crossBY.style.height = - p.crossBX.style.width = - crossOuterSize + 'px'; - p.crossBY.style.left = - p.crossBX.style.top = - (Math.floor(crossOuterSize / 2) - Math.floor(THIS.pointerThickness / 2) - THIS.pointerBorderWidth) + 'px'; - p.crossBY.style.top = - p.crossBX.style.left = - '0'; - - // pad cross line Y and X - p.crossLY.style.position = - p.crossLX.style.position = - 'absolute'; - p.crossLY.style.background = - p.crossLX.style.background = - THIS.pointerColor; - p.crossLY.style.height = - p.crossLX.style.width = - (crossOuterSize - 2 * THIS.pointerBorderWidth) + 'px'; - p.crossLY.style.width = - p.crossLX.style.height = - THIS.pointerThickness + 'px'; - p.crossLY.style.left = - p.crossLX.style.top = - (Math.floor(crossOuterSize / 2) - Math.floor(THIS.pointerThickness / 2)) + 'px'; - p.crossLY.style.top = - p.crossLX.style.left = - THIS.pointerBorderWidth + 'px'; - - // slider - p.sld.classList.add('jscolor-sld'); - p.sld.style.overflow = 'hidden'; - p.sld.style.width = THIS.sliderSize + 'px'; - p.sld.style.height = THIS.height + 'px'; - - // slider gradient - p.sldGrad.draw(THIS.sliderSize, THIS.height, '#000', '#000'); - - // slider border - p.sldB.style.display = displaySlider ? 'block' : 'none'; - p.sldB.style.position = 'absolute'; - p.sldB.style.right = THIS.padding + 'px'; - p.sldB.style.top = THIS.padding + 'px'; - p.sldB.style.border = THIS.insetWidth + 'px solid'; - p.sldB.style.borderColor = THIS.insetColor; - - // slider mouse area - p.sldM._jscInstance = THIS; - p.sldM._jscControlName = 'sld'; - p.sldM.style.display = displaySlider ? 'block' : 'none'; - p.sldM.style.position = 'absolute'; - p.sldM.style.right = '0'; - p.sldM.style.top = '0'; - p.sldM.style.width = (THIS.sliderSize + padToSliderPadding / 2 + THIS.padding + 2 * THIS.insetWidth) + 'px'; - p.sldM.style.height = dims[1] + 'px'; - p.sldM.style.cursor = 'default'; - - // slider pointer inner and outer border - p.sldPtrIB.style.border = - p.sldPtrOB.style.border = - THIS.pointerBorderWidth + 'px solid ' + THIS.pointerBorderColor; - - // slider pointer outer border - p.sldPtrOB.style.position = 'absolute'; - p.sldPtrOB.style.left = -(2 * THIS.pointerBorderWidth + THIS.pointerThickness) + 'px'; - p.sldPtrOB.style.top = '0'; - - // slider pointer middle border - p.sldPtrMB.style.border = THIS.pointerThickness + 'px solid ' + THIS.pointerColor; - - // slider pointer spacer - p.sldPtrS.style.width = THIS.sliderSize + 'px'; - p.sldPtrS.style.height = sliderPtrSpace + 'px'; - -/* REMOVED CLOSE BUTTON [lospec] - // the Close button - p.btn.classList.add('jscolor-btn'); - function setBtnBorder () { - var insetColors = THIS.insetColor.split(/\s+/); - var outsetColor = insetColors.length < 2 ? insetColors[0] : insetColors[1] + ' ' + insetColors[0] + ' ' + insetColors[0] + ' ' + insetColors[1]; - p.btn.style.borderColor = outsetColor; - } - p.btn.style.display = THIS.closable ? 'block' : 'none'; - p.btn.style.position = 'absolute'; - p.btn.style.left = THIS.padding + 'px'; - p.btn.style.bottom = THIS.padding + 'px'; - p.btn.style.padding = '0 15px'; - p.btn.style.height = THIS.buttonHeight + 'px'; - p.btn.style.border = THIS.insetWidth + 'px solid'; - setBtnBorder(); - p.btn.style.color = THIS.buttonColor; - p.btn.style.font = '12px sans-serif'; - p.btn.style.textAlign = 'center'; - try { - p.btn.style.cursor = 'pointer'; - } catch(eOldIE) { - p.btn.style.cursor = 'hand'; - } - p.btn.onmousedown = function () { - THIS.hide(); - }; - p.btnT.style.lineHeight = THIS.buttonHeight + 'px'; - p.btnT.innerHTML = ''; - p.btnT.appendChild(document.createTextNode(THIS.closeText)); -*/ - - //CUSTOM PICKER BOTTOM - [lospec] - //when first initialized, we will want to move the colorPickerBottom - //to the bottom of the color picker box - if (colorPickerBottomAdded != true) { - //get color picker bottom - var jsColorPickerBottom = document.getElementsByClassName('jscolor-picker-bottom')[0]; - - //move it to the picker box - p.box.appendChild(jsColorPickerBottom); - - //unhide element - jsColorPickerBottom.style.display = 'block'; - - //set flag to only do this once - colorPickerBottomAdded = true; - - } - - // place pointers - redrawPad(); - redrawSld(); - - // If we are changing the owner without first closing the picker, - // make sure to first deal with the old owner - if (jsc.picker.owner && jsc.picker.owner !== THIS) { - jsc.unsetClass(jsc.picker.owner.targetElement, THIS.activeClass); - } - - // Set the new picker owner - jsc.picker.owner = THIS; - - // The redrawPosition() method needs picker.owner to be set, that's why we call it here, - // after setting the owner - if (jsc.isElementType(container, 'body')) { - jsc.redrawPosition(); - } else { - jsc._drawPosition(THIS, 0, 0, 'relative', false); - } - - if (p.wrap.parentNode != container) { - container.appendChild(p.wrap); - } - - jsc.setClass(THIS.targetElement, THIS.activeClass); - } - - - function redrawPad () { - // redraw the pad pointer - switch (jsc.getPadYComponent(THIS)) { - case 's': var yComponent = 1; break; - case 'v': var yComponent = 2; break; - } - var x = Math.round((THIS.hsv[0] / 360) * (THIS.width - 1)); - var y = Math.round((1 - THIS.hsv[yComponent] / 100) * (THIS.height - 1)); - var crossOuterSize = (2 * THIS.pointerBorderWidth + THIS.pointerThickness + 2 * THIS.crossSize); - var ofs = -Math.floor(crossOuterSize / 2); - jsc.picker.cross.style.left = (x + ofs) + 'px'; - jsc.picker.cross.style.top = (y + ofs) + 'px'; - - // redraw the slider - switch (jsc.getSliderComponent(THIS)) { - case 's': - var rgb1 = HSV_RGB(THIS.hsv[0], 100, THIS.hsv[2]); - var rgb2 = HSV_RGB(THIS.hsv[0], 0, THIS.hsv[2]); - var color1 = 'rgb(' + - Math.round(rgb1[0]) + ',' + - Math.round(rgb1[1]) + ',' + - Math.round(rgb1[2]) + ')'; - var color2 = 'rgb(' + - Math.round(rgb2[0]) + ',' + - Math.round(rgb2[1]) + ',' + - Math.round(rgb2[2]) + ')'; - jsc.picker.sldGrad.draw(THIS.sliderSize, THIS.height, color1, color2); - break; - case 'v': - var rgb = HSV_RGB(THIS.hsv[0], THIS.hsv[1], 100); - var color1 = 'rgb(' + - Math.round(rgb[0]) + ',' + - Math.round(rgb[1]) + ',' + - Math.round(rgb[2]) + ')'; - var color2 = '#000'; - jsc.picker.sldGrad.draw(THIS.sliderSize, THIS.height, color1, color2); - break; - } - } - - - function redrawSld () { - var sldComponent = jsc.getSliderComponent(THIS); - if (sldComponent) { - // redraw the slider pointer - switch (sldComponent) { - case 's': var yComponent = 1; break; - case 'v': var yComponent = 2; break; - } - var y = Math.round((1 - THIS.hsv[yComponent] / 100) * (THIS.height - 1)); - jsc.picker.sldPtrOB.style.top = (y - (2 * THIS.pointerBorderWidth + THIS.pointerThickness) - Math.floor(sliderPtrSpace / 2)) + 'px'; - } - } - - - function isPickerOwner () { - return jsc.picker && jsc.picker.owner === THIS; - } - - - function blurValue () { - //console.log('blurValue()') - THIS.importColor(); - } - - - // Find the target element - if (typeof targetElement === 'string') { - var id = targetElement; - var elm = document.getElementById(id); - if (elm) { - this.targetElement = elm; - } else { - jsc.warn('Could not find target element with ID \'' + id + '\''); - } - } else if (targetElement) { - this.targetElement = targetElement; - } else { - jsc.warn('Invalid target element: \'' + targetElement + '\''); - } - - if (this.targetElement._jscLinkedInstance) { - jsc.warn('Cannot link jscolor twice to the same element. Skipping.'); - return; - } - this.targetElement._jscLinkedInstance = this; - - // Find the value element - this.valueElement = jsc.fetchElement(this.valueElement); - // Find the style element - this.styleElement = jsc.fetchElement(this.styleElement); - - //console.log('VALUE ELEMENT: ', this.valueElement) - - var THIS = this; - var container = - this.container ? - jsc.fetchElement(this.container) : - document.getElementsByTagName('body')[0]; - var sliderPtrSpace = 3; // px - - // For BUTTON elements it's important to stop them from sending the form when clicked - // (e.g. in Safari) - if (jsc.isElementType(this.targetElement, 'button')) { - if (this.targetElement.onclick) { - var origCallback = this.targetElement.onclick; - this.targetElement.onclick = function (evt) { - origCallback.call(this, evt); - return false; - }; - } else { - this.targetElement.onclick = function () { return false; }; - } - } - - /* - var elm = this.targetElement; - do { - // If the target element or one of its offsetParents has fixed position, - // then use fixed positioning instead - // - // Note: In Firefox, getComputedStyle returns null in a hidden iframe, - // that's why we need to check if the returned style object is non-empty - var currStyle = jsc.getStyle(elm); - if (currStyle && currStyle.position.toLowerCase() === 'fixed') { - this.fixed = true; - } - - if (elm !== this.targetElement) { - // attach onParentScroll so that we can recompute the picker position - // when one of the offsetParents is scrolled - if (!elm._jscEventsAttached) { - jsc.attachEvent(elm, 'scroll', jsc.onParentScroll); - elm._jscEventsAttached = true; - } - } - } while ((elm = elm.offsetParent) && !jsc.isElementType(elm, 'body')); - */ - - // valueElement - if (this.valueElement) { - - if (jsc.isElementType(this.valueElement, 'input')) { - var updateField = function () { - //console.log('updateField()') - THIS.fromString(THIS.valueElement.value, jsc.leaveValue); - jsc.dispatchFineChange(THIS); - }; - jsc.attachEvent(this.valueElement, 'keyup', updateField); - jsc.attachEvent(this.valueElement, 'input', updateField); - jsc.attachEvent(this.valueElement, 'blur', blurValue); - this.valueElement.setAttribute('autocomplete', 'off'); - } - } - - // styleElement - if (this.styleElement) { - this.styleElement._jscOrigStyle = { - backgroundImage : this.styleElement.style.backgroundImage, - backgroundColor : this.styleElement.style.backgroundColor, - color : this.styleElement.style.color - }; - } - - if (this.value) { - // Try to set the color from the .value option and if unsuccessful, - // export the current color - this.fromString(this.value) || this.exportColor(); - } else { - this.importColor(); - } - } - -}; - - -//================================ -// Public properties and methods -//================================ - - -// By default, search for all elements with class="jscolor" and install a color picker on them. -// -// You can change what class name will be looked for by setting the property jscolor.lookupClass -// anywhere in your HTML document. To completely disable the automatic lookup, set it to null. -// -jsc.jscolor.lookupClass = 'jscolor'; - - -jsc.jscolor.installByClassName = function (className) { - var inputElms = document.getElementsByTagName('input'); - var buttonElms = document.getElementsByTagName('button'); - - jsc.tryInstallOnElements(inputElms, className); - jsc.tryInstallOnElements(buttonElms, className); -}; - - -jsc.register(); - - -return jsc.jscolor; - - -})(); } +/** + * jscolor - JavaScript Color Picker + * + * @link http://jscolor.com + * @license For open source use: GPLv3 + * For commercial use: JSColor Commercial License + * @author Jan Odvarko + * @version 2.0.4 + * + * See usage examples at http://jscolor.com/examples/ + */ + +//Ive made changes to this script. ctrl+f [lospec] +//skeddles variables [lospec] +/* eslint-disable */ +var colorPickerBottomAdded; +var newjsColorPickerBottom; +'use strict'; + + +if (!window.jscolor) { window.jscolor = (function () { + + + var jsc = { + + + register : function () { + jsc.attachDOMReadyEvent(jsc.init); + jsc.attachEvent(document, 'mousedown', jsc.onDocumentMouseDown); + jsc.attachEvent(document, 'touchstart', jsc.onDocumentTouchStart); + jsc.attachEvent(window, 'resize', jsc.onWindowResize); + }, + + + init : function () { + //console.log('init()') + if (jsc.jscolor.lookupClass) { + jsc.jscolor.installByClassName(jsc.jscolor.lookupClass); + } + }, + + + tryInstallOnElements : function (elms, className) { + var matchClass = new RegExp('(^|\\s)(' + className + ')(\\s*(\\{[^}]*\\})|\\s|$)', 'i'); + + for (var i = 0; i < elms.length; i += 1) { + if (elms[i].type !== undefined && elms[i].type.toLowerCase() == 'color') { + if (jsc.isColorAttrSupported) { + // skip inputs of type 'color' if supported by the browser + continue; + } + } + var m; + if (!elms[i].jscolor && elms[i].className && (m = elms[i].className.match(matchClass))) { + var targetElm = elms[i]; + var optsStr = null; + + var dataOptions = jsc.getDataAttr(targetElm, 'jscolor'); + if (dataOptions !== null) { + optsStr = dataOptions; + } else if (m[4]) { + optsStr = m[4]; + } + + var opts = {}; + if (optsStr) { + try { + opts = (new Function ('return (' + optsStr + ')'))(); + } catch(eParseError) { + jsc.warn('Error parsing jscolor options: ' + eParseError + ':\n' + optsStr); + } + } + targetElm.jscolor = new jsc.jscolor(targetElm, opts); + } + } + }, + + + isColorAttrSupported : (function () { + var elm = document.createElement('input'); + if (elm.setAttribute) { + elm.setAttribute('type', 'color'); + if (elm.type.toLowerCase() == 'color') { + return true; + } + } + return false; + })(), + + + isCanvasSupported : (function () { + var elm = document.createElement('canvas'); + return !!(elm.getContext && elm.getContext('2d')); + })(), + + + fetchElement : function (mixed) { + return typeof mixed === 'string' ? document.getElementById(mixed) : mixed; + }, + + + isElementType : function (elm, type) { + return elm.nodeName.toLowerCase() === type.toLowerCase(); + }, + + + getDataAttr : function (el, name) { + var attrName = 'data-' + name; + var attrValue = el.getAttribute(attrName); + if (attrValue !== null) { + return attrValue; + } + return null; + }, + + + attachEvent : function (el, evnt, func) { + if (el.addEventListener) { + el.addEventListener(evnt, func, false); + } else if (el.attachEvent) { + el.attachEvent('on' + evnt, func); + } + }, + + + detachEvent : function (el, evnt, func) { + if (el.removeEventListener) { + el.removeEventListener(evnt, func, false); + } else if (el.detachEvent) { + el.detachEvent('on' + evnt, func); + } + }, + + + _attachedGroupEvents : {}, + + + attachGroupEvent : function (groupName, el, evnt, func) { + if (!jsc._attachedGroupEvents.hasOwnProperty(groupName)) { + jsc._attachedGroupEvents[groupName] = []; + } + jsc._attachedGroupEvents[groupName].push([el, evnt, func]); + jsc.attachEvent(el, evnt, func); + }, + + + detachGroupEvents : function (groupName) { + if (jsc._attachedGroupEvents.hasOwnProperty(groupName)) { + for (var i = 0; i < jsc._attachedGroupEvents[groupName].length; i += 1) { + var evt = jsc._attachedGroupEvents[groupName][i]; + jsc.detachEvent(evt[0], evt[1], evt[2]); + } + delete jsc._attachedGroupEvents[groupName]; + } + }, + + + attachDOMReadyEvent : function (func) { + var fired = false; + var fireOnce = function () { + if (!fired) { + fired = true; + func(); + } + }; + + if (document.readyState === 'complete') { + setTimeout(fireOnce, 1); // async + return; + } + + if (document.addEventListener) { + document.addEventListener('DOMContentLoaded', fireOnce, false); + + // Fallback + window.addEventListener('load', fireOnce, false); + + } else if (document.attachEvent) { + // IE + document.attachEvent('onreadystatechange', function () { + if (document.readyState === 'complete') { + document.detachEvent('onreadystatechange', arguments.callee); + fireOnce(); + } + }); + + // Fallback + window.attachEvent('onload', fireOnce); + + // IE7/8 + if (document.documentElement.doScroll && window == window.top) { + var tryScroll = function () { + if (!document.body) { return; } + try { + document.documentElement.doScroll('left'); + fireOnce(); + } catch (e) { + setTimeout(tryScroll, 1); + } + }; + tryScroll(); + } + } + }, + + + warn : function (msg) { + if (window.console && window.console.warn) { + window.console.warn(msg); + } + }, + + + preventDefault : function (e) { + if (e.preventDefault) { e.preventDefault(); } + e.returnValue = false; + }, + + + captureTarget : function (target) { + // IE + if (target.setCapture) { + jsc._capturedTarget = target; + jsc._capturedTarget.setCapture(); + } + }, + + + releaseTarget : function () { + // IE + if (jsc._capturedTarget) { + jsc._capturedTarget.releaseCapture(); + jsc._capturedTarget = null; + } + }, + + + fireEvent : function (el, evnt) { + if (!el) { + return; + } + if (document.createEvent) { + var ev = document.createEvent('HTMLEvents'); + ev.initEvent(evnt, true, true); + el.dispatchEvent(ev); + } else if (document.createEventObject) { + var ev = document.createEventObject(); + el.fireEvent('on' + evnt, ev); + } else if (el['on' + evnt]) { // alternatively use the traditional event model + el['on' + evnt](); + } + }, + + + classNameToList : function (className) { + return className.replace(/^\s+|\s+$/g, '').split(/\s+/); + }, + + + // The className parameter (str) can only contain a single class name + hasClass : function (elm, className) { + if (!className) { + return false; + } + return -1 != (' ' + elm.className.replace(/\s+/g, ' ') + ' ').indexOf(' ' + className + ' '); + }, + + + // The className parameter (str) can contain multiple class names separated by whitespace + setClass : function (elm, className) { + var classList = jsc.classNameToList(className); + for (var i = 0; i < classList.length; i += 1) { + if (!jsc.hasClass(elm, classList[i])) { + elm.className += (elm.className ? ' ' : '') + classList[i]; + } + } + }, + + + // The className parameter (str) can contain multiple class names separated by whitespace + unsetClass : function (elm, className) { + var classList = jsc.classNameToList(className); + for (var i = 0; i < classList.length; i += 1) { + var repl = new RegExp( + '^\\s*' + classList[i] + '\\s*|' + + '\\s*' + classList[i] + '\\s*$|' + + '\\s+' + classList[i] + '(\\s+)', + 'g' + ); + elm.className = elm.className.replace(repl, '$1'); + } + }, + + + getStyle : function (elm) { + return window.getComputedStyle ? window.getComputedStyle(elm) : elm.currentStyle; + }, + + + setStyle : (function () { + var helper = document.createElement('div'); + var getSupportedProp = function (names) { + for (var i = 0; i < names.length; i += 1) { + if (names[i] in helper.style) { + return names[i]; + } + } + }; + var props = { + borderRadius: getSupportedProp(['borderRadius', 'MozBorderRadius', 'webkitBorderRadius']), + boxShadow: getSupportedProp(['boxShadow', 'MozBoxShadow', 'webkitBoxShadow']) + }; + return function (elm, prop, value) { + switch (prop.toLowerCase()) { + case 'opacity': + var alphaOpacity = Math.round(parseFloat(value) * 100); + elm.style.opacity = value; + elm.style.filter = 'alpha(opacity=' + alphaOpacity + ')'; + break; + default: + elm.style[props[prop]] = value; + break; + } + }; + })(), + + + setBorderRadius : function (elm, value) { + jsc.setStyle(elm, 'borderRadius', value || '0'); + }, + + + setBoxShadow : function (elm, value) { + jsc.setStyle(elm, 'boxShadow', value || 'none'); + }, + + + getElementPos : function (e, relativeToViewport) { + var x=0, y=0; + var rect = e.getBoundingClientRect(); + x = rect.left; + y = rect.top; + if (!relativeToViewport) { + var viewPos = jsc.getViewPos(); + x += viewPos[0]; + y += viewPos[1]; + } + return [x, y]; + }, + + + getElementSize : function (e) { + return [e.offsetWidth, e.offsetHeight]; + }, + + + // get pointer's X/Y coordinates relative to viewport + getAbsPointerPos : function (e) { + if (!e) { e = window.event; } + var x = 0, y = 0; + if (typeof e.changedTouches !== 'undefined' && e.changedTouches.length) { + // touch devices + x = e.changedTouches[0].clientX; + y = e.changedTouches[0].clientY; + } else if (typeof e.clientX === 'number') { + x = e.clientX; + y = e.clientY; + } + return { x: x, y: y }; + }, + + + // get pointer's X/Y coordinates relative to target element + getRelPointerPos : function (e) { + if (!e) { e = window.event; } + var target = e.target || e.srcElement; + var targetRect = target.getBoundingClientRect(); + + var x = 0, y = 0; + + var clientX = 0, clientY = 0; + if (typeof e.changedTouches !== 'undefined' && e.changedTouches.length) { + // touch devices + clientX = e.changedTouches[0].clientX; + clientY = e.changedTouches[0].clientY; + } else if (typeof e.clientX === 'number') { + clientX = e.clientX; + clientY = e.clientY; + } + + x = clientX - targetRect.left; + y = clientY - targetRect.top; + return { x: x, y: y }; + }, + + + getViewPos : function () { + var doc = document.documentElement; + return [ + (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0), + (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0) + ]; + }, + + + getViewSize : function () { + var doc = document.documentElement; + return [ + (window.innerWidth || doc.clientWidth), + (window.innerHeight || doc.clientHeight), + ]; + }, + + + redrawPosition : function () { + + if (jsc.picker && jsc.picker.owner) { + var thisObj = jsc.picker.owner; + + var tp, vp; + + if (thisObj.fixed) { + // Fixed elements are positioned relative to viewport, + // therefore we can ignore the scroll offset + tp = jsc.getElementPos(thisObj.targetElement, true); // target pos + vp = [0, 0]; // view pos + } else { + tp = jsc.getElementPos(thisObj.targetElement); // target pos + vp = jsc.getViewPos(); // view pos + } + + var ts = jsc.getElementSize(thisObj.targetElement); // target size + var vs = jsc.getViewSize(); // view size + var ps = jsc.getPickerOuterDims(thisObj); // picker size + var a, b, c; + switch (thisObj.position.toLowerCase()) { + case 'left': a=1; b=0; c=-1; break; + case 'right':a=1; b=0; c=1; break; + case 'top': a=0; b=1; c=-1; break; + default: a=0; b=1; c=1; break; + } + var l = (ts[b]+ps[b])/2; + + // compute picker position + if (!thisObj.smartPosition) { + var pp = [ + tp[a], + tp[b]+ts[b]-l+l*c + ]; + } else { + var pp = [ + -vp[a]+tp[a]+ps[a] > vs[a] ? + (-vp[a]+tp[a]+ts[a]/2 > vs[a]/2 && tp[a]+ts[a]-ps[a] >= 0 ? tp[a]+ts[a]-ps[a] : tp[a]) : + tp[a], + -vp[b]+tp[b]+ts[b]+ps[b]-l+l*c > vs[b] ? + (-vp[b]+tp[b]+ts[b]/2 > vs[b]/2 && tp[b]+ts[b]-l-l*c >= 0 ? tp[b]+ts[b]-l-l*c : tp[b]+ts[b]-l+l*c) : + (tp[b]+ts[b]-l+l*c >= 0 ? tp[b]+ts[b]-l+l*c : tp[b]+ts[b]-l-l*c) + ]; + } + + var x = pp[a]; + var y = pp[b]; + var positionValue = thisObj.fixed ? 'fixed' : 'absolute'; + var contractShadow = + (pp[0] + ps[0] > tp[0] || pp[0] < tp[0] + ts[0]) && + (pp[1] + ps[1] < tp[1] + ts[1]); + + jsc._drawPosition(thisObj, x, y, positionValue, contractShadow); + } + }, + + + _drawPosition : function (thisObj, x, y, positionValue, contractShadow) { + var vShadow = contractShadow ? 0 : thisObj.shadowBlur; // px + + jsc.picker.wrap.style.position = positionValue; + jsc.picker.wrap.style.left = x + 'px'; + jsc.picker.wrap.style.top = y + 'px'; + + jsc.setBoxShadow( + jsc.picker.boxS, + thisObj.shadow ? + new jsc.BoxShadow(0, vShadow, thisObj.shadowBlur, 0, thisObj.shadowColor) : + null); + }, + + + getPickerDims : function (thisObj) { + var displaySlider = !!jsc.getSliderComponent(thisObj); + var dims = [ + 2 * thisObj.insetWidth + 2 * thisObj.padding + thisObj.width + + (displaySlider ? 2 * thisObj.insetWidth + jsc.getPadToSliderPadding(thisObj) + thisObj.sliderSize : 0), + 2 * thisObj.insetWidth + 2 * thisObj.padding + thisObj.height + + (thisObj.closable ? 2 * thisObj.insetWidth + thisObj.padding + thisObj.buttonHeight : 0) + ]; + return dims; + }, + + + getPickerOuterDims : function (thisObj) { + var dims = jsc.getPickerDims(thisObj); + return [ + dims[0] + 2 * thisObj.borderWidth, + dims[1] + 2 * thisObj.borderWidth + ]; + }, + + + getPadToSliderPadding : function (thisObj) { + return Math.max(thisObj.padding, 1.5 * (2 * thisObj.pointerBorderWidth + thisObj.pointerThickness)); + }, + + + getPadYComponent : function (thisObj) { + switch (thisObj.mode.charAt(1).toLowerCase()) { + case 'v': return 'v'; break; + } + return 's'; + }, + + + getSliderComponent : function (thisObj) { + if (thisObj.mode.length > 2) { + switch (thisObj.mode.charAt(2).toLowerCase()) { + case 's': return 's'; break; + case 'v': return 'v'; break; + } + } + return null; + }, + + + onDocumentMouseDown : function (e) { + //console.log(e) + + if (!e) { e = window.event; } + var target = e.target || e.srcElement; + + if (target._jscLinkedInstance) { + if (target._jscLinkedInstance.showOnClick) { + target._jscLinkedInstance.show(); + } + } else if (target._jscControlName) { + jsc.onControlPointerStart(e, target, target._jscControlName, 'mouse'); + } else { + // Mouse is outside the picker controls -> hide the color picker! + if (jsc.picker && jsc.picker.owner) { + //console.log(e.target,'=====================================') + //if they clicked on the delete button [lospec] + if (e.target.className == 'delete-color-button') { + //saveHistoryState({type: 'deletecolor', colorValue: jsc.picker.owner.toString(), canvas: canvas.context.getImageData(0, 0, canvasSize[0], canvasSize[1])}); + new HistoryStateDeleteColor(jsc.picker.owner.toString()); + + deleteColor(jsc.picker.owner.styleElement); + } + else if (e.target.className == 'jscolor-picker-bottom') { + //console.log('clicked color picker bottom') + } + else if (e.target.parentElement.classList.contains('jscolor-picker-bottom')) { + //console.log('clicked element in color picker bottom') + } + else { + //console.log('clicked outside of color picker') + //unhide hidden edit button [lospec] + var hiddenButton = document.querySelector('.color-edit-button.hidden'); + if (hiddenButton) hiddenButton.classList.remove('hidden'); + + //close color picker + jsc.picker.owner.hide(); + + } + } + } + }, + + + onDocumentTouchStart : function (e) { + if (!e) { e = window.event; } + var target = e.target || e.srcElement; + + if (target._jscLinkedInstance) { + if (target._jscLinkedInstance.showOnClick) { + target._jscLinkedInstance.show(); + } + } else if (target._jscControlName) { + jsc.onControlPointerStart(e, target, target._jscControlName, 'touch'); + } else { + if (jsc.picker && jsc.picker.owner) { + jsc.picker.owner.hide(); + } + } + }, + + + onWindowResize : function (e) { + jsc.redrawPosition(); + }, + + + onParentScroll : function (e) { + // hide the picker when one of the parent elements is scrolled + if (jsc.picker && jsc.picker.owner) { + jsc.picker.owner.hide(); + } + }, + + + _pointerMoveEvent : { + mouse: 'mousemove', + touch: 'touchmove' + }, + _pointerEndEvent : { + mouse: 'mouseup', + touch: 'touchend' + }, + + + _pointerOrigin : null, + _capturedTarget : null, + + + onControlPointerStart : function (e, target, controlName, pointerType) { + var thisObj = target._jscInstance; + + jsc.preventDefault(e); + jsc.captureTarget(target); + + var registerDragEvents = function (doc, offset) { + jsc.attachGroupEvent('drag', doc, jsc._pointerMoveEvent[pointerType], + jsc.onDocumentPointerMove(e, target, controlName, pointerType, offset)); + jsc.attachGroupEvent('drag', doc, jsc._pointerEndEvent[pointerType], + jsc.onDocumentPointerEnd(e, target, controlName, pointerType)); + }; + + registerDragEvents(document, [0, 0]); + + if (window.parent && window.frameElement) { + var rect = window.frameElement.getBoundingClientRect(); + var ofs = [-rect.left, -rect.top]; + registerDragEvents(window.parent.window.document, ofs); + } + + var abs = jsc.getAbsPointerPos(e); + var rel = jsc.getRelPointerPos(e); + jsc._pointerOrigin = { + x: abs.x - rel.x, + y: abs.y - rel.y + }; + + switch (controlName) { + case 'pad': + // if the slider is at the bottom, move it up + switch (jsc.getSliderComponent(thisObj)) { + case 's': if (thisObj.hsv[1] === 0) { thisObj.fromHSV(null, 100, null); } break; + case 'v': if (thisObj.hsv[2] === 0) { thisObj.fromHSV(null, null, 100); } break; + } + jsc.setPad(thisObj, e, 0, 0); + break; + + case 'sld': + jsc.setSld(thisObj, e, 0); + break; + } + + jsc.dispatchFineChange(thisObj); + }, + + + onDocumentPointerMove : function (e, target, controlName, pointerType, offset) { + return function (e) { + var thisObj = target._jscInstance; + switch (controlName) { + case 'pad': + if (!e) { e = window.event; } + jsc.setPad(thisObj, e, offset[0], offset[1]); + jsc.dispatchFineChange(thisObj); + break; + + case 'sld': + if (!e) { e = window.event; } + jsc.setSld(thisObj, e, offset[1]); + jsc.dispatchFineChange(thisObj); + break; + } + }; + }, + + + onDocumentPointerEnd : function (e, target, controlName, pointerType) { + return function (e) { + var thisObj = target._jscInstance; + jsc.detachGroupEvents('drag'); + jsc.releaseTarget(); + // Always dispatch changes after detaching outstanding mouse handlers, + // in case some user interaction will occur in user's onchange callback + // that would intrude with current mouse events + jsc.dispatchChange(thisObj); + }; + }, + + + dispatchChange : function (thisObj) { + if (thisObj.valueElement) { + if (jsc.isElementType(thisObj.valueElement, 'input')) { + jsc.fireEvent(thisObj.valueElement, 'change'); + } + } + }, + + + dispatchFineChange : function (thisObj) { + if (thisObj.onFineChange) { + var callback; + if (typeof thisObj.onFineChange === 'string') { + callback = new Function (thisObj.onFineChange); + } else { + callback = thisObj.onFineChange; + } + callback.call(thisObj); + } + }, + + + setPad : function (thisObj, e, ofsX, ofsY) { + var pointerAbs = jsc.getAbsPointerPos(e); + var x = ofsX + pointerAbs.x - jsc._pointerOrigin.x - thisObj.padding - thisObj.insetWidth; + var y = ofsY + pointerAbs.y - jsc._pointerOrigin.y - thisObj.padding - thisObj.insetWidth; + + var xVal = x * (360 / (thisObj.width - 1)); + var yVal = 100 - (y * (100 / (thisObj.height - 1))); + + switch (jsc.getPadYComponent(thisObj)) { + case 's': thisObj.fromHSV(xVal, yVal, null, jsc.leaveSld); break; + case 'v': thisObj.fromHSV(xVal, null, yVal, jsc.leaveSld); break; + } + }, + + + setSld : function (thisObj, e, ofsY) { + var pointerAbs = jsc.getAbsPointerPos(e); + var y = ofsY + pointerAbs.y - jsc._pointerOrigin.y - thisObj.padding - thisObj.insetWidth; + + var yVal = 100 - (y * (100 / (thisObj.height - 1))); + + switch (jsc.getSliderComponent(thisObj)) { + case 's': thisObj.fromHSV(null, yVal, null, jsc.leavePad); break; + case 'v': thisObj.fromHSV(null, null, yVal, jsc.leavePad); break; + } + }, + + + _vmlNS : 'jsc_vml_', + _vmlCSS : 'jsc_vml_css_', + _vmlReady : false, + + + initVML : function () { + if (!jsc._vmlReady) { + // init VML namespace + var doc = document; + if (!doc.namespaces[jsc._vmlNS]) { + doc.namespaces.add(jsc._vmlNS, 'urn:schemas-microsoft-com:vml'); + } + if (!doc.styleSheets[jsc._vmlCSS]) { + var tags = ['shape', 'shapetype', 'group', 'background', 'path', 'formulas', 'handles', 'fill', 'stroke', 'shadow', 'textbox', 'textpath', 'imagedata', 'line', 'polyline', 'curve', 'rect', 'roundrect', 'oval', 'arc', 'image']; + var ss = doc.createStyleSheet(); + ss.owningElement.id = jsc._vmlCSS; + for (var i = 0; i < tags.length; i += 1) { + ss.addRule(jsc._vmlNS + '\\:' + tags[i], 'behavior:url(#default#VML);'); + } + } + jsc._vmlReady = true; + } + }, + + + createPalette : function () { + + var paletteObj = { + elm: null, + draw: null + }; + + if (jsc.isCanvasSupported) { + // Canvas implementation for modern browsers + + var canvas = document.createElement('canvas'); + var ctx = canvas.getContext('2d'); + + var drawFunc = function (width, height, type) { + canvas.width = width; + canvas.height = height; + + ctx.clearRect(0, 0, canvas.width, canvas.height); + + var hGrad = ctx.createLinearGradient(0, 0, canvas.width, 0); + hGrad.addColorStop(0 / 6, '#F00'); + hGrad.addColorStop(1 / 6, '#FF0'); + hGrad.addColorStop(2 / 6, '#0F0'); + hGrad.addColorStop(3 / 6, '#0FF'); + hGrad.addColorStop(4 / 6, '#00F'); + hGrad.addColorStop(5 / 6, '#F0F'); + hGrad.addColorStop(6 / 6, '#F00'); + + ctx.fillStyle = hGrad; + ctx.fillRect(0, 0, canvas.width, canvas.height); + + var vGrad = ctx.createLinearGradient(0, 0, 0, canvas.height); + switch (type.toLowerCase()) { + case 's': + vGrad.addColorStop(0, 'rgba(255,255,255,0)'); + vGrad.addColorStop(1, 'rgba(255,255,255,1)'); + break; + case 'v': + vGrad.addColorStop(0, 'rgba(0,0,0,0)'); + vGrad.addColorStop(1, 'rgba(0,0,0,1)'); + break; + } + ctx.fillStyle = vGrad; + ctx.fillRect(0, 0, canvas.width, canvas.height); + }; + + paletteObj.elm = canvas; + paletteObj.draw = drawFunc; + + } else { + // VML fallback for IE 7 and 8 + + jsc.initVML(); + + var vmlContainer = document.createElement('div'); + vmlContainer.style.position = 'relative'; + vmlContainer.style.overflow = 'hidden'; + + var hGrad = document.createElement(jsc._vmlNS + ':fill'); + hGrad.type = 'gradient'; + hGrad.method = 'linear'; + hGrad.angle = '90'; + hGrad.colors = '16.67% #F0F, 33.33% #00F, 50% #0FF, 66.67% #0F0, 83.33% #FF0'; + + var hRect = document.createElement(jsc._vmlNS + ':rect'); + hRect.style.position = 'absolute'; + hRect.style.left = -1 + 'px'; + hRect.style.top = -1 + 'px'; + hRect.stroked = false; + hRect.appendChild(hGrad); + vmlContainer.appendChild(hRect); + + var vGrad = document.createElement(jsc._vmlNS + ':fill'); + vGrad.type = 'gradient'; + vGrad.method = 'linear'; + vGrad.angle = '180'; + vGrad.opacity = '0'; + + var vRect = document.createElement(jsc._vmlNS + ':rect'); + vRect.style.position = 'absolute'; + vRect.style.left = -1 + 'px'; + vRect.style.top = -1 + 'px'; + vRect.stroked = false; + vRect.appendChild(vGrad); + vmlContainer.appendChild(vRect); + + var drawFunc = function (width, height, type) { + vmlContainer.style.width = width + 'px'; + vmlContainer.style.height = height + 'px'; + + hRect.style.width = + vRect.style.width = + (width + 1) + 'px'; + hRect.style.height = + vRect.style.height = + (height + 1) + 'px'; + + // Colors must be specified during every redraw, otherwise IE won't display + // a full gradient during a subsequential redraw + hGrad.color = '#F00'; + hGrad.color2 = '#F00'; + + switch (type.toLowerCase()) { + case 's': + vGrad.color = vGrad.color2 = '#FFF'; + break; + case 'v': + vGrad.color = vGrad.color2 = '#000'; + break; + } + }; + + paletteObj.elm = vmlContainer; + paletteObj.draw = drawFunc; + } + + return paletteObj; + }, + + + createSliderGradient : function () { + + var sliderObj = { + elm: null, + draw: null + }; + + if (jsc.isCanvasSupported) { + // Canvas implementation for modern browsers + + var canvas = document.createElement('canvas'); + var ctx = canvas.getContext('2d'); + + var drawFunc = function (width, height, color1, color2) { + canvas.width = width; + canvas.height = height; + + ctx.clearRect(0, 0, canvas.width, canvas.height); + + var grad = ctx.createLinearGradient(0, 0, 0, canvas.height); + grad.addColorStop(0, color1); + grad.addColorStop(1, color2); + + ctx.fillStyle = grad; + ctx.fillRect(0, 0, canvas.width, canvas.height); + }; + + sliderObj.elm = canvas; + sliderObj.draw = drawFunc; + + } else { + // VML fallback for IE 7 and 8 + + jsc.initVML(); + + var vmlContainer = document.createElement('div'); + vmlContainer.style.position = 'relative'; + vmlContainer.style.overflow = 'hidden'; + + var grad = document.createElement(jsc._vmlNS + ':fill'); + grad.type = 'gradient'; + grad.method = 'linear'; + grad.angle = '180'; + + var rect = document.createElement(jsc._vmlNS + ':rect'); + rect.style.position = 'absolute'; + rect.style.left = -1 + 'px'; + rect.style.top = -1 + 'px'; + rect.stroked = false; + rect.appendChild(grad); + vmlContainer.appendChild(rect); + + var drawFunc = function (width, height, color1, color2) { + vmlContainer.style.width = width + 'px'; + vmlContainer.style.height = height + 'px'; + + rect.style.width = (width + 1) + 'px'; + rect.style.height = (height + 1) + 'px'; + + grad.color = color1; + grad.color2 = color2; + }; + + sliderObj.elm = vmlContainer; + sliderObj.draw = drawFunc; + } + + return sliderObj; + }, + + + leaveValue : 1<<0, + leaveStyle : 1<<1, + leavePad : 1<<2, + leaveSld : 1<<3, + + + BoxShadow : (function () { + var BoxShadow = function (hShadow, vShadow, blur, spread, color, inset) { + this.hShadow = hShadow; + this.vShadow = vShadow; + this.blur = blur; + this.spread = spread; + this.color = color; + this.inset = !!inset; + }; + + BoxShadow.prototype.toString = function () { + var vals = [ + Math.round(this.hShadow) + 'px', + Math.round(this.vShadow) + 'px', + Math.round(this.blur) + 'px', + Math.round(this.spread) + 'px', + this.color + ]; + if (this.inset) { + vals.push('inset'); + } + return vals.join(' '); + }; + + return BoxShadow; + })(), + + + // + // Usage: + // var myColor = new jscolor( [, ]) + // + + jscolor : function (targetElement, options) { + + // General options + // + this.value = null; // initial HEX color. To change it later, use methods fromString(), fromHSV() and fromRGB() + this.valueElement = targetElement; // element that will be used to display and input the color code + this.styleElement = targetElement; // element that will preview the picked color using CSS backgroundColor + this.required = true; // whether the associated text can be left empty + this.refine = true; // whether to refine the entered color code (e.g. uppercase it and remove whitespace) + this.hash = false; // whether to prefix the HEX color code with # symbol + this.uppercase = true; // whether to uppercase the color code + this.onFineChange = null; // called instantly every time the color changes (value can be either a function or a string with javascript code) + this.activeClass = 'jscolor-active'; // class to be set to the target element when a picker window is open on it + this.minS = 0; // min allowed saturation (0 - 100) + this.maxS = 100; // max allowed saturation (0 - 100) + this.minV = 0; // min allowed value (brightness) (0 - 100) + this.maxV = 100; // max allowed value (brightness) (0 - 100) + + // Accessing the picked color + // + this.hsv = [0, 0, 100]; // read-only [0-360, 0-100, 0-100] + this.rgb = [255, 255, 255]; // read-only [0-255, 0-255, 0-255] + + // Color Picker options + // + this.width = 181; // width of color palette (in px) + this.height = 101; // height of color palette (in px) + this.showOnClick = true; // whether to display the color picker when user clicks on its target element + this.mode = 'HSV'; // HSV | HVS | HS | HV - layout of the color picker controls + this.position = 'bottom'; // left | right | top | bottom - position relative to the target element + this.smartPosition = true; // automatically change picker position when there is not enough space for it + this.sliderSize = 16; // px + this.crossSize = 8; // px + this.closable = false; // whether to display the Close button + this.closeText = 'Close'; + this.buttonColor = '#000000'; // CSS color + this.buttonHeight = 18; // px + this.padding = 12; // px + this.backgroundColor = '#FFFFFF'; // CSS color + this.borderWidth = 1; // px + this.borderColor = '#BBBBBB'; // CSS color + this.borderRadius = 8; // px + this.insetWidth = 1; // px + this.insetColor = '#BBBBBB'; // CSS color + this.shadow = true; // whether to display shadow + this.shadowBlur = 15; // px + this.shadowColor = 'rgba(0,0,0,0.2)'; // CSS color + this.pointerColor = '#4C4C4C'; // px + this.pointerBorderColor = '#FFFFFF'; // px + this.pointerBorderWidth = 1; // px + this.pointerThickness = 2; // px + this.zIndex = 1000; + this.container = null; // where to append the color picker (BODY element by default) + + + for (var opt in options) { + if (options.hasOwnProperty(opt)) { + this[opt] = options[opt]; + } + } + + + this.hide = function () { + ///console.log(this.styleElement) + if (isPickerOwner()) { + + //console.log('color picker hidden') + + //set the color to old color, in case the color is a duplicate that hasn't been resolved yet [lospec] + var hexInput = document.getElementById('jscolor-hex-input'); + var oldColor = '#'+rgbToHex(hexInput.oldColor); + this.fromString(oldColor); + document.getElementById('duplicate-color-warning').style.visibility = 'hidden'; + + //dialog is closed + dialogueOpen = false; + + detachPicker(); + } + }; + + //show the color picker + this.show = function () { + drawPicker(); + + //a dialog is open + dialogueOpen = true; + + //[lospec] + //find the hex input element + var hexInput = document.getElementById('jscolor-hex-input'); + + //set the value element to the hex input + this.valueElement = hexInput; + + //update hex code + this.exportColor(); + + //set old color for updating colors on canvas + hexInput.oldColor = hexToRgb(hexInput.value); + + //set the color element to the clicked button + hexInput.colorElement = this.styleElement; + + //disable delete button if last color + var colors = document.getElementsByClassName('color-button'); + var deleteButton = document.getElementsByClassName('delete-color-button')[0]; + if(colors.length == 1) + deleteButton.classList.add('disabled'); + else + deleteButton.classList.remove('disabled'); + + //hide duplicate color warning + var duplicateColorWarning = document.getElementById('duplicate-color-warning'); + duplicateColorWarning.style.visibility = 'hidden'; + }; + + + this.redraw = function () { + if (isPickerOwner()) { + drawPicker(); + } + }; + + + this.importColor = function () { + if (!this.valueElement) { + this.exportColor(); + } else { + if (jsc.isElementType(this.valueElement, 'input')) { + if (!this.refine) { + if (!this.fromString(this.valueElement.value, jsc.leaveValue)) { + if (this.styleElement) { + this.styleElement.style.backgroundImage = this.styleElement._jscOrigStyle.backgroundImage; + this.styleElement.style.backgroundColor = this.styleElement._jscOrigStyle.backgroundColor; + this.styleElement.style.color = this.styleElement._jscOrigStyle.color; + } + this.exportColor(jsc.leaveValue | jsc.leaveStyle); + } + } else if (!this.required && /^\s*$/.test(this.valueElement.value)) { + this.valueElement.value = ''; + if (this.styleElement) { + this.styleElement.style.backgroundImage = this.styleElement._jscOrigStyle.backgroundImage; + this.styleElement.style.backgroundColor = this.styleElement._jscOrigStyle.backgroundColor; + this.styleElement.style.color = this.styleElement._jscOrigStyle.color; + } + this.exportColor(jsc.leaveValue | jsc.leaveStyle); + + } else if (this.fromString(this.valueElement.value)) { + // managed to import color successfully from the value -> OK, don't do anything + } else { + this.exportColor(); + } + } else { + // not an input element -> doesn't have any value + this.exportColor(); + } + } + }; + + + this.exportColor = function (flags) { + if (!(flags & jsc.leaveValue) && this.valueElement) { + var value = this.toString(); + if (this.uppercase) { value = value.toUpperCase(); } + if (this.hash) { value = '#' + value; } + + if (jsc.isElementType(this.valueElement, 'input')) { + //console.log('SETTING VALUE') + //this sets the value element's value + this.valueElement.value = value; + } else { + this.valueElement.innerHTML = value; + } + } + if (!(flags & jsc.leaveStyle)) { + if (this.styleElement) { + this.styleElement.style.backgroundImage = 'none'; + this.styleElement.style.backgroundColor = '#' + this.toString(); + this.styleElement.style.color = this.isLight() ? '#000' : '#FFF'; + } + } + if (!(flags & jsc.leavePad) && isPickerOwner()) { + redrawPad(); + } + if (!(flags & jsc.leaveSld) && isPickerOwner()) { + redrawSld(); + } + }; + + + // h: 0-360 + // s: 0-100 + // v: 0-100 + // + this.fromHSV = function (h, s, v, flags) { // null = don't change + if (h !== null) { + if (isNaN(h)) { return false; } + h = Math.max(0, Math.min(360, h)); + } + if (s !== null) { + if (isNaN(s)) { return false; } + s = Math.max(0, Math.min(100, this.maxS, s), this.minS); + } + if (v !== null) { + if (isNaN(v)) { return false; } + v = Math.max(0, Math.min(100, this.maxV, v), this.minV); + } + + this.rgb = HSV_RGB( + h===null ? this.hsv[0] : (this.hsv[0]=h), + s===null ? this.hsv[1] : (this.hsv[1]=s), + v===null ? this.hsv[2] : (this.hsv[2]=v) + ); + + this.exportColor(flags); + }; + + + // r: 0-255 + // g: 0-255 + // b: 0-255 + // + this.fromRGB = function (r, g, b, flags) { // null = don't change + if (r !== null) { + if (isNaN(r)) { return false; } + r = Math.max(0, Math.min(255, r)); + } + if (g !== null) { + if (isNaN(g)) { return false; } + g = Math.max(0, Math.min(255, g)); + } + if (b !== null) { + if (isNaN(b)) { return false; } + b = Math.max(0, Math.min(255, b)); + } + + var hsv = RGB_HSV( + r===null ? this.rgb[0] : r, + g===null ? this.rgb[1] : g, + b===null ? this.rgb[2] : b + ); + if (hsv[0] !== null) { + this.hsv[0] = Math.max(0, Math.min(360, hsv[0])); + } + if (hsv[2] !== 0) { + this.hsv[1] = hsv[1]===null ? null : Math.max(0, this.minS, Math.min(100, this.maxS, hsv[1])); + } + this.hsv[2] = hsv[2]===null ? null : Math.max(0, this.minV, Math.min(100, this.maxV, hsv[2])); + + // update RGB according to final HSV, as some values might be trimmed + var rgb = HSV_RGB(this.hsv[0], this.hsv[1], this.hsv[2]); + this.rgb[0] = rgb[0]; + this.rgb[1] = rgb[1]; + this.rgb[2] = rgb[2]; + + this.exportColor(flags); + }; + + + this.fromString = function (str, flags) { + var m; + if (m = str.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i)) { + // HEX notation + // + + if (m[1].length === 6) { + // 6-char notation + this.fromRGB( + parseInt(m[1].substr(0,2),16), + parseInt(m[1].substr(2,2),16), + parseInt(m[1].substr(4,2),16), + flags + ); + } else { + // 3-char notation + this.fromRGB( + parseInt(m[1].charAt(0) + m[1].charAt(0),16), + parseInt(m[1].charAt(1) + m[1].charAt(1),16), + parseInt(m[1].charAt(2) + m[1].charAt(2),16), + flags + ); + } + return true; + + } else if (m = str.match(/^\W*rgba?\(([^)]*)\)\W*$/i)) { + var params = m[1].split(','); + var re = /^\s*(\d*)(\.\d+)?\s*$/; + var mR, mG, mB; + if ( + params.length >= 3 && + (mR = params[0].match(re)) && + (mG = params[1].match(re)) && + (mB = params[2].match(re)) + ) { + var r = parseFloat((mR[1] || '0') + (mR[2] || '')); + var g = parseFloat((mG[1] || '0') + (mG[2] || '')); + var b = parseFloat((mB[1] || '0') + (mB[2] || '')); + this.fromRGB(r, g, b, flags); + return true; + } + } + return false; +}; + + +this.toString = function () { + return ( + (0x100 | Math.round(this.rgb[0])).toString(16).substr(1) + + (0x100 | Math.round(this.rgb[1])).toString(16).substr(1) + + (0x100 | Math.round(this.rgb[2])).toString(16).substr(1) + ); +}; + + +this.toHEXString = function () { + return '#' + this.toString().toUpperCase(); +}; + + +this.toRGBString = function () { + return ('rgb(' + + Math.round(this.rgb[0]) + ',' + + Math.round(this.rgb[1]) + ',' + + Math.round(this.rgb[2]) + ')' + ); +}; + +//returns rgb color object [lospec] +this.toRgb = function () { + return { + r: Math.round(this.rgb[0]), + g: Math.round(this.rgb[1]), + b: Math.round(this.rgb[2]) + }; +}; + + +this.isLight = function () { + return ( + 0.213 * this.rgb[0] + + 0.715 * this.rgb[1] + + 0.072 * this.rgb[2] > + 255 / 2 + ); +}; + + +this._processParentElementsInDOM = function () { + if (this._linkedElementsProcessed) { return; } + this._linkedElementsProcessed = true; + + var elm = this.targetElement; + do { + // If the target element or one of its parent nodes has fixed position, + // then use fixed positioning instead + // + // Note: In Firefox, getComputedStyle returns null in a hidden iframe, + // that's why we need to check if the returned style object is non-empty + var currStyle = jsc.getStyle(elm); + if (currStyle && currStyle.position.toLowerCase() === 'fixed') { + this.fixed = true; + } + + if (elm !== this.targetElement) { + // Ensure to attach onParentScroll only once to each parent element + // (multiple targetElements can share the same parent nodes) + // + // Note: It's not just offsetParents that can be scrollable, + // that's why we loop through all parent nodes + if (!elm._jscEventsAttached) { + jsc.attachEvent(elm, 'scroll', jsc.onParentScroll); + elm._jscEventsAttached = true; + } + } + } while ((elm = elm.parentNode) && !jsc.isElementType(elm, 'body')); +}; + + +// r: 0-255 +// g: 0-255 +// b: 0-255 +// +// returns: [ 0-360, 0-100, 0-100 ] +// +function RGB_HSV (r, g, b) { + r /= 255; + g /= 255; + b /= 255; + var n = Math.min(Math.min(r,g),b); + var v = Math.max(Math.max(r,g),b); + var m = v - n; + if (m === 0) { return [ null, 0, 100 * v ]; } + var h = r===n ? 3+(b-g)/m : (g===n ? 5+(r-b)/m : 1+(g-r)/m); + return [ + 60 * (h===6?0:h), + 100 * (m/v), + 100 * v + ]; +} + + +// h: 0-360 +// s: 0-100 +// v: 0-100 +// +// returns: [ 0-255, 0-255, 0-255 ] +// +function HSV_RGB (h, s, v) { + var u = 255 * (v / 100); + + if (h === null) { + return [ u, u, u ]; + } + + h /= 60; + s /= 100; + + var i = Math.floor(h); + var f = i%2 ? h-i : 1-(h-i); + var m = u * (1 - s); + var n = u * (1 - s * f); + switch (i) { + case 6: + case 0: return [u,n,m]; + case 1: return [n,u,m]; + case 2: return [m,u,n]; + case 3: return [m,n,u]; + case 4: return [n,m,u]; + case 5: return [u,m,n]; + } +} + +//this is called when the picker is closed +function detachPicker () { + jsc.unsetClass(THIS.targetElement, THIS.activeClass); + jsc.picker.wrap.parentNode.removeChild(jsc.picker.wrap); + delete jsc.picker.owner; +} + + +function drawPicker () { + + //console.log('drawPicker ()') + // At this point, when drawing the picker, we know what the parent elements are + // and we can do all related DOM operations, such as registering events on them + // or checking their positioning + THIS._processParentElementsInDOM(); + + if (!jsc.picker) { + jsc.picker = { + owner: null, + wrap : document.createElement('div'), + box : document.createElement('div'), + boxS : document.createElement('div'), // shadow area + boxB : document.createElement('div'), // border + pad : document.createElement('div'), + padB : document.createElement('div'), // border + padM : document.createElement('div'), // mouse/touch area + padPal : jsc.createPalette(), + cross : document.createElement('div'), + crossBY : document.createElement('div'), // border Y + crossBX : document.createElement('div'), // border X + crossLY : document.createElement('div'), // line Y + crossLX : document.createElement('div'), // line X + sld : document.createElement('div'), + sldB : document.createElement('div'), // border + sldM : document.createElement('div'), // mouse/touch area + sldGrad : jsc.createSliderGradient(), + sldPtrS : document.createElement('div'), // slider pointer spacer + sldPtrIB : document.createElement('div'), // slider pointer inner border + sldPtrMB : document.createElement('div'), // slider pointer middle border + sldPtrOB : document.createElement('div'), // slider pointer outer border + btn : document.createElement('div'), + btnT : document.createElement('span') // text + }; + + jsc.picker.pad.appendChild(jsc.picker.padPal.elm); + jsc.picker.padB.appendChild(jsc.picker.pad); + jsc.picker.cross.appendChild(jsc.picker.crossBY); + jsc.picker.cross.appendChild(jsc.picker.crossBX); + jsc.picker.cross.appendChild(jsc.picker.crossLY); + jsc.picker.cross.appendChild(jsc.picker.crossLX); + jsc.picker.padB.appendChild(jsc.picker.cross); + jsc.picker.box.appendChild(jsc.picker.padB); + jsc.picker.box.appendChild(jsc.picker.padM); + + jsc.picker.sld.appendChild(jsc.picker.sldGrad.elm); + jsc.picker.sldB.appendChild(jsc.picker.sld); + jsc.picker.sldB.appendChild(jsc.picker.sldPtrOB); + jsc.picker.sldPtrOB.appendChild(jsc.picker.sldPtrMB); + jsc.picker.sldPtrMB.appendChild(jsc.picker.sldPtrIB); + jsc.picker.sldPtrIB.appendChild(jsc.picker.sldPtrS); + jsc.picker.box.appendChild(jsc.picker.sldB); + jsc.picker.box.appendChild(jsc.picker.sldM); + + jsc.picker.btn.appendChild(jsc.picker.btnT); + jsc.picker.box.appendChild(jsc.picker.btn); + + jsc.picker.boxB.appendChild(jsc.picker.box); + jsc.picker.wrap.appendChild(jsc.picker.boxS); + jsc.picker.wrap.appendChild(jsc.picker.boxB); + } + + var p = jsc.picker; + + var displaySlider = !!jsc.getSliderComponent(THIS); + var dims = jsc.getPickerDims(THIS); + var crossOuterSize = (2 * THIS.pointerBorderWidth + THIS.pointerThickness + 2 * THIS.crossSize); + var padToSliderPadding = jsc.getPadToSliderPadding(THIS); + var borderRadius = Math.min( + THIS.borderRadius, + Math.round(THIS.padding * Math.PI)); // px + var padCursor = 'crosshair'; + + // wrap + p.wrap.classList.add('jscolor-wrap'); + p.wrap.style.clear = 'both'; + p.wrap.style.width = (dims[0] + 2 * THIS.borderWidth) + 'px'; + p.wrap.style.height = (dims[1] + 2 * THIS.borderWidth) + 'px'; + p.wrap.style.zIndex = THIS.zIndex; + + + // picker + p.box.classList.add('jscolor-box'); + p.box.style.width = dims[0] + 'px'; + p.box.style.height = (dims[1]+25) + 'px'; //added 25 for trash icon + + p.boxS.style.position = 'absolute'; + p.boxS.style.left = '0'; + p.boxS.style.top = '0'; + p.boxS.style.width = '100%'; + p.boxS.style.height = '100%'; + jsc.setBorderRadius(p.boxS, borderRadius + 'px'); + + // picker border + p.wrap.classList.add('jscolor-boxB'); + p.boxB.style.position = 'relative'; + p.boxB.style.border = THIS.borderWidth + 'px solid'; + p.boxB.style.borderColor = THIS.borderColor; + p.boxB.style.background = THIS.backgroundColor; + jsc.setBorderRadius(p.boxB, borderRadius + 'px'); + + // IE hack: + // If the element is transparent, IE will trigger the event on the elements under it, + // e.g. on Canvas or on elements with border + p.padM.style.background = + p.sldM.style.background = + '#FFF'; + jsc.setStyle(p.padM, 'opacity', '0'); + jsc.setStyle(p.sldM, 'opacity', '0'); + + // pad + p.pad.classList.add('jscolor-pad'); + p.pad.style.position = 'relative'; + p.pad.style.width = THIS.width + 'px'; + p.pad.style.height = THIS.height + 'px'; + + // pad palettes (HSV and HVS) + p.padPal.draw(THIS.width, THIS.height, jsc.getPadYComponent(THIS)); + + // pad border + p.padB.classList.add('jscolor-padB'); + p.padB.style.position = 'absolute'; + p.padB.style.left = THIS.padding + 'px'; + p.padB.style.top = THIS.padding + 'px'; + p.padB.style.border = THIS.insetWidth + 'px solid'; + p.padB.style.borderColor = THIS.insetColor; + + // pad mouse area + p.padM.classList.add('jscolor-padM'); + p.padM._jscInstance = THIS; + p.padM._jscControlName = 'pad'; + p.padM.style.position = 'absolute'; + p.padM.style.left = '0'; + p.padM.style.top = '0'; + p.padM.style.width = (THIS.padding + 2 * THIS.insetWidth + THIS.width + padToSliderPadding / 2) + 'px'; + p.padM.style.height = dims[1] + 'px'; + p.padM.style.cursor = padCursor; + + // pad cross + p.cross.classList.add('jscolor-cross'); + p.cross.style.position = 'absolute'; + p.cross.style.left = + p.cross.style.top = + '0'; + p.cross.style.width = + p.cross.style.height = + crossOuterSize + 'px'; + + // pad cross border Y and X + p.crossBY.style.position = + p.crossBX.style.position = + 'absolute'; + p.crossBY.style.background = + p.crossBX.style.background = + THIS.pointerBorderColor; + p.crossBY.style.width = + p.crossBX.style.height = + (2 * THIS.pointerBorderWidth + THIS.pointerThickness) + 'px'; + p.crossBY.style.height = + p.crossBX.style.width = + crossOuterSize + 'px'; + p.crossBY.style.left = + p.crossBX.style.top = + (Math.floor(crossOuterSize / 2) - Math.floor(THIS.pointerThickness / 2) - THIS.pointerBorderWidth) + 'px'; + p.crossBY.style.top = + p.crossBX.style.left = + '0'; + + // pad cross line Y and X + p.crossLY.style.position = + p.crossLX.style.position = + 'absolute'; + p.crossLY.style.background = + p.crossLX.style.background = + THIS.pointerColor; + p.crossLY.style.height = + p.crossLX.style.width = + (crossOuterSize - 2 * THIS.pointerBorderWidth) + 'px'; + p.crossLY.style.width = + p.crossLX.style.height = + THIS.pointerThickness + 'px'; + p.crossLY.style.left = + p.crossLX.style.top = + (Math.floor(crossOuterSize / 2) - Math.floor(THIS.pointerThickness / 2)) + 'px'; + p.crossLY.style.top = + p.crossLX.style.left = + THIS.pointerBorderWidth + 'px'; + + // slider + p.sld.classList.add('jscolor-sld'); + p.sld.style.overflow = 'hidden'; + p.sld.style.width = THIS.sliderSize + 'px'; + p.sld.style.height = THIS.height + 'px'; + + // slider gradient + p.sldGrad.draw(THIS.sliderSize, THIS.height, '#000', '#000'); + + // slider border + p.sldB.style.display = displaySlider ? 'block' : 'none'; + p.sldB.style.position = 'absolute'; + p.sldB.style.right = THIS.padding + 'px'; + p.sldB.style.top = THIS.padding + 'px'; + p.sldB.style.border = THIS.insetWidth + 'px solid'; + p.sldB.style.borderColor = THIS.insetColor; + + // slider mouse area + p.sldM._jscInstance = THIS; + p.sldM._jscControlName = 'sld'; + p.sldM.style.display = displaySlider ? 'block' : 'none'; + p.sldM.style.position = 'absolute'; + p.sldM.style.right = '0'; + p.sldM.style.top = '0'; + p.sldM.style.width = (THIS.sliderSize + padToSliderPadding / 2 + THIS.padding + 2 * THIS.insetWidth) + 'px'; + p.sldM.style.height = dims[1] + 'px'; + p.sldM.style.cursor = 'default'; + + // slider pointer inner and outer border + p.sldPtrIB.style.border = + p.sldPtrOB.style.border = + THIS.pointerBorderWidth + 'px solid ' + THIS.pointerBorderColor; + + // slider pointer outer border + p.sldPtrOB.style.position = 'absolute'; + p.sldPtrOB.style.left = -(2 * THIS.pointerBorderWidth + THIS.pointerThickness) + 'px'; + p.sldPtrOB.style.top = '0'; + + // slider pointer middle border + p.sldPtrMB.style.border = THIS.pointerThickness + 'px solid ' + THIS.pointerColor; + + // slider pointer spacer + p.sldPtrS.style.width = THIS.sliderSize + 'px'; + p.sldPtrS.style.height = sliderPtrSpace + 'px'; + + /* REMOVED CLOSE BUTTON [lospec] + // the Close button + p.btn.classList.add('jscolor-btn'); + function setBtnBorder () { + var insetColors = THIS.insetColor.split(/\s+/); + var outsetColor = insetColors.length < 2 ? insetColors[0] : insetColors[1] + ' ' + insetColors[0] + ' ' + insetColors[0] + ' ' + insetColors[1]; + p.btn.style.borderColor = outsetColor; + } + p.btn.style.display = THIS.closable ? 'block' : 'none'; + p.btn.style.position = 'absolute'; + p.btn.style.left = THIS.padding + 'px'; + p.btn.style.bottom = THIS.padding + 'px'; + p.btn.style.padding = '0 15px'; + p.btn.style.height = THIS.buttonHeight + 'px'; + p.btn.style.border = THIS.insetWidth + 'px solid'; + setBtnBorder(); + p.btn.style.color = THIS.buttonColor; + p.btn.style.font = '12px sans-serif'; + p.btn.style.textAlign = 'center'; + try { + p.btn.style.cursor = 'pointer'; + } catch(eOldIE) { + p.btn.style.cursor = 'hand'; + } + p.btn.onmousedown = function () { + THIS.hide(); + }; + p.btnT.style.lineHeight = THIS.buttonHeight + 'px'; + p.btnT.innerHTML = ''; + p.btnT.appendChild(document.createTextNode(THIS.closeText)); + */ + + //CUSTOM PICKER BOTTOM - [lospec] + //when first initialized, we will want to move the colorPickerBottom + //to the bottom of the color picker box + if (colorPickerBottomAdded != true) { + //get color picker bottom + var jsColorPickerBottom = document.getElementsByClassName('jscolor-picker-bottom')[0]; + + //move it to the picker box + p.box.appendChild(jsColorPickerBottom); + + //unhide element + jsColorPickerBottom.style.display = 'block'; + + //set flag to only do this once + colorPickerBottomAdded = true; + + } + + // place pointers + redrawPad(); + redrawSld(); + + // If we are changing the owner without first closing the picker, + // make sure to first deal with the old owner + if (jsc.picker.owner && jsc.picker.owner !== THIS) { + jsc.unsetClass(jsc.picker.owner.targetElement, THIS.activeClass); + } + + // Set the new picker owner + jsc.picker.owner = THIS; + + // The redrawPosition() method needs picker.owner to be set, that's why we call it here, + // after setting the owner + if (jsc.isElementType(container, 'body')) { + jsc.redrawPosition(); + } else { + jsc._drawPosition(THIS, 0, 0, 'relative', false); + } + + if (p.wrap.parentNode != container) { + container.appendChild(p.wrap); + } + + jsc.setClass(THIS.targetElement, THIS.activeClass); +} + + +function redrawPad () { + // redraw the pad pointer + switch (jsc.getPadYComponent(THIS)) { + case 's': var yComponent = 1; break; + case 'v': var yComponent = 2; break; + } + var x = Math.round((THIS.hsv[0] / 360) * (THIS.width - 1)); + var y = Math.round((1 - THIS.hsv[yComponent] / 100) * (THIS.height - 1)); + var crossOuterSize = (2 * THIS.pointerBorderWidth + THIS.pointerThickness + 2 * THIS.crossSize); + var ofs = -Math.floor(crossOuterSize / 2); + jsc.picker.cross.style.left = (x + ofs) + 'px'; + jsc.picker.cross.style.top = (y + ofs) + 'px'; + + // redraw the slider + switch (jsc.getSliderComponent(THIS)) { + case 's': + var rgb1 = HSV_RGB(THIS.hsv[0], 100, THIS.hsv[2]); + var rgb2 = HSV_RGB(THIS.hsv[0], 0, THIS.hsv[2]); + var color1 = 'rgb(' + + Math.round(rgb1[0]) + ',' + + Math.round(rgb1[1]) + ',' + + Math.round(rgb1[2]) + ')'; + var color2 = 'rgb(' + + Math.round(rgb2[0]) + ',' + + Math.round(rgb2[1]) + ',' + + Math.round(rgb2[2]) + ')'; + jsc.picker.sldGrad.draw(THIS.sliderSize, THIS.height, color1, color2); + break; + case 'v': + var rgb = HSV_RGB(THIS.hsv[0], THIS.hsv[1], 100); + var color1 = 'rgb(' + + Math.round(rgb[0]) + ',' + + Math.round(rgb[1]) + ',' + + Math.round(rgb[2]) + ')'; + var color2 = '#000'; + jsc.picker.sldGrad.draw(THIS.sliderSize, THIS.height, color1, color2); + break; + } +} + + +function redrawSld () { + var sldComponent = jsc.getSliderComponent(THIS); + if (sldComponent) { + // redraw the slider pointer + switch (sldComponent) { + case 's': var yComponent = 1; break; + case 'v': var yComponent = 2; break; + } + var y = Math.round((1 - THIS.hsv[yComponent] / 100) * (THIS.height - 1)); + jsc.picker.sldPtrOB.style.top = (y - (2 * THIS.pointerBorderWidth + THIS.pointerThickness) - Math.floor(sliderPtrSpace / 2)) + 'px'; + } +} + + +function isPickerOwner () { + return jsc.picker && jsc.picker.owner === THIS; +} + + +function blurValue () { + //console.log('blurValue()') + THIS.importColor(); +} + + +// Find the target element +if (typeof targetElement === 'string') { + var id = targetElement; + var elm = document.getElementById(id); + if (elm) { + this.targetElement = elm; + } else { + jsc.warn('Could not find target element with ID \'' + id + '\''); + } +} else if (targetElement) { + this.targetElement = targetElement; +} else { + jsc.warn('Invalid target element: \'' + targetElement + '\''); +} + +if (this.targetElement._jscLinkedInstance) { + jsc.warn('Cannot link jscolor twice to the same element. Skipping.'); + return; +} +this.targetElement._jscLinkedInstance = this; + +// Find the value element +this.valueElement = jsc.fetchElement(this.valueElement); +// Find the style element +this.styleElement = jsc.fetchElement(this.styleElement); + +//console.log('VALUE ELEMENT: ', this.valueElement) + +var THIS = this; +var container = + this.container ? + jsc.fetchElement(this.container) : + document.getElementsByTagName('body')[0]; +var sliderPtrSpace = 3; // px + +// For BUTTON elements it's important to stop them from sending the form when clicked +// (e.g. in Safari) +if (jsc.isElementType(this.targetElement, 'button')) { + if (this.targetElement.onclick) { + var origCallback = this.targetElement.onclick; + this.targetElement.onclick = function (evt) { + origCallback.call(this, evt); + return false; + }; + } else { + this.targetElement.onclick = function () { return false; }; + } +} + +/* + var elm = this.targetElement; +do { + // If the target element or one of its offsetParents has fixed position, + // then use fixed positioning instead + // + // Note: In Firefox, getComputedStyle returns null in a hidden iframe, + // that's why we need to check if the returned style object is non-empty + var currStyle = jsc.getStyle(elm); + if (currStyle && currStyle.position.toLowerCase() === 'fixed') { + this.fixed = true; + } + + if (elm !== this.targetElement) { + // attach onParentScroll so that we can recompute the picker position + // when one of the offsetParents is scrolled + if (!elm._jscEventsAttached) { + jsc.attachEvent(elm, 'scroll', jsc.onParentScroll); + elm._jscEventsAttached = true; + } + } +} while ((elm = elm.offsetParent) && !jsc.isElementType(elm, 'body')); +*/ + + // valueElement + if (this.valueElement) { + + if (jsc.isElementType(this.valueElement, 'input')) { + var updateField = function () { + //console.log('updateField()') + THIS.fromString(THIS.valueElement.value, jsc.leaveValue); + jsc.dispatchFineChange(THIS); + }; + jsc.attachEvent(this.valueElement, 'keyup', updateField); + jsc.attachEvent(this.valueElement, 'input', updateField); + jsc.attachEvent(this.valueElement, 'blur', blurValue); + this.valueElement.setAttribute('autocomplete', 'off'); + } + } + +// styleElement +if (this.styleElement) { + this.styleElement._jscOrigStyle = { + backgroundImage : this.styleElement.style.backgroundImage, + backgroundColor : this.styleElement.style.backgroundColor, + color : this.styleElement.style.color + }; +} + +if (this.value) { + // Try to set the color from the .value option and if unsuccessful, + // export the current color + this.fromString(this.value) || this.exportColor(); +} else { + this.importColor(); +} +} + +}; + + +//================================ +// Public properties and methods +//================================ + + +// By default, search for all elements with class="jscolor" and install a color picker on them. +// +// You can change what class name will be looked for by setting the property jscolor.lookupClass +// anywhere in your HTML document. To completely disable the automatic lookup, set it to null. +// +jsc.jscolor.lookupClass = 'jscolor'; + + +jsc.jscolor.installByClassName = function (className) { + var inputElms = document.getElementsByTagName('input'); + var buttonElms = document.getElementsByTagName('button'); + + jsc.tryInstallOnElements(inputElms, className); + jsc.tryInstallOnElements(buttonElms, className); +}; + + +jsc.register(); + + +return jsc.jscolor; + + +})(); } diff --git a/js/_layer.js b/js/_layer.js index 614b25d..fcf4c46 100644 --- a/js/_layer.js +++ b/js/_layer.js @@ -15,9 +15,9 @@ * @param canvas HTML canvas element */ function Layer(width, height, canvas) { - this.canvasSize = [width, height], - this.canvas = canvas, - this.context = this.canvas.getContext("2d"), + this.canvasSize = [width, height]; + this.canvas = canvas; + this.context = this.canvas.getContext('2d'); // Initializes the canvas this.initialize = function() { var maxHorizontalZoom = Math.floor(window.innerWidth/this.canvasSize[0]*0.75); @@ -38,10 +38,10 @@ function Layer(width, height, canvas) { //center canvas in window this.canvas.style.left = 64+canvasView.clientWidth/2-(this.canvasSize[0]*zoom/2)+'px'; this.canvas.style.top = 48+canvasView.clientHeight/2-(this.canvasSize[1]*zoom/2)+'px'; - + this.context.imageSmoothingEnabled = false; this.context.mozImageSmoothingEnabled = false; - }, + }; // Resizes canvas this.resize = function() { let newWidth = (this.canvas.width * zoom) + 'px'; @@ -49,7 +49,7 @@ function Layer(width, height, canvas) { this.canvas.style.width = newWidth; this.canvas.style.height = newHeight; - }, + }; // Copies the otherCanvas' position and size this.copyData = function(otherCanvas) { this.canvas.style.width = otherCanvas.canvas.style.width; @@ -57,5 +57,5 @@ function Layer(width, height, canvas) { this.canvas.style.left = otherCanvas.canvas.style.left; this.canvas.style.top = otherCanvas.canvas.style.top; - } -} \ No newline at end of file + }; +} diff --git a/js/_loadImage.js b/js/_loadImage.js index 8ba192b..310490b 100644 --- a/js/_loadImage.js +++ b/js/_loadImage.js @@ -1,61 +1,61 @@ document.getElementById('open-image-browse-holder').addEventListener('change', function () { - if (this.files && this.files[0]) { - - //make sure file is allowed filetype - var fileContentType = this.files[0].type; - if (fileContentType == 'image/png' || fileContentType == 'image/gif') { - - //load file - var fileReader = new FileReader(); - fileReader.onload = function(e) { - var img = new Image(); - img.onload = function() { - - //create a new pixel with the images dimentions - newPixel(this.width, this.height, []); - - //draw the image onto the canvas - currentLayer.context.drawImage(img, 0, 0); - - var colorPalette = {}; - var imagePixelData = currentLayer.context.getImageData(0,0,this.width, this.height).data; - - var imagePixelDataLength = imagePixelData.length; - - console.log(imagePixelData) - for (var i = 0; i < imagePixelDataLength; i += 4) { - var color = imagePixelData[i]+','+imagePixelData[i + 1]+','+imagePixelData[i + 2]; - if (!colorPalette[color]) { - colorPalette[color] = {r:imagePixelData[i],g:imagePixelData[i + 1],b:imagePixelData[i + 2]}; - - //don't allow more than 256 colors to be added - if (Object.keys(colorPalette).length >= settings.maxColorsOnImportedImage) { - alert('The image loaded seems to have more than '+settings.maxColorsOnImportedImage+' colors.') - break; - } - } - } - - //create array out of colors object - var colorPaletteArray = []; - for (var color in colorPalette) { - if( colorPalette.hasOwnProperty(color) ) { - colorPaletteArray.push('#'+rgbToHex(colorPalette[color])); - } - } - console.log('COLOR PALETTE ARRAY', colorPaletteArray) - - //create palette form colors array - createColorPalette(colorPaletteArray, false); - - //track google event - ga('send', 'event', 'Pixel Editor Load', colorPalette.length, this.width+'/'+this.height); /*global ga*/ + if (this.files && this.files[0]) { - }; - img.src = e.target.result; - }; - fileReader.readAsDataURL(this.files[0]); - } - else alert('Only PNG and GIF files are allowed at this time.'); - } -}); \ No newline at end of file + //make sure file is allowed filetype + var fileContentType = this.files[0].type; + if (fileContentType == 'image/png' || fileContentType == 'image/gif') { + + //load file + var fileReader = new FileReader(); + fileReader.onload = function(e) { + var img = new Image(); + img.onload = function() { + + //create a new pixel with the images dimentions + newPixel(this.width, this.height, []); + + //draw the image onto the canvas + currentLayer.context.drawImage(img, 0, 0); + + var colorPalette = {}; + var imagePixelData = currentLayer.context.getImageData(0,0,this.width, this.height).data; + + var imagePixelDataLength = imagePixelData.length; + + console.log(imagePixelData); + for (var i = 0; i < imagePixelDataLength; i += 4) { + var color = imagePixelData[i]+','+imagePixelData[i + 1]+','+imagePixelData[i + 2]; + if (!colorPalette[color]) { + colorPalette[color] = {r:imagePixelData[i],g:imagePixelData[i + 1],b:imagePixelData[i + 2]}; + + //don't allow more than 256 colors to be added + if (Object.keys(colorPalette).length >= settings.maxColorsOnImportedImage) { + alert('The image loaded seems to have more than '+settings.maxColorsOnImportedImage+' colors.'); + break; + } + } + } + + //create array out of colors object + var colorPaletteArray = []; + for (var color in colorPalette) { + if( colorPalette.hasOwnProperty(color) ) { + colorPaletteArray.push('#'+rgbToHex(colorPalette[color])); + } + } + console.log('COLOR PALETTE ARRAY', colorPaletteArray); + + //create palette form colors array + createColorPalette(colorPaletteArray, false); + + //track google event + ga('send', 'event', 'Pixel Editor Load', colorPalette.length, this.width+'/'+this.height); /*global ga*/ + + }; + img.src = e.target.result; + }; + fileReader.readAsDataURL(this.files[0]); + } + else alert('Only PNG and GIF files are allowed at this time.'); + } +}); diff --git a/js/_loadPalette.js b/js/_loadPalette.js index cbe9418..a12d2b5 100644 --- a/js/_loadPalette.js +++ b/js/_loadPalette.js @@ -1,50 +1,50 @@ //this is called when a user picks a file after selecting "load palette" from the new pixel dialogue document.getElementById('load-palette-browse-holder').addEventListener('change', function () { - if (this.files && this.files[0]) { - - //make sure file is allowed filetype - var fileContentType = this.files[0].type; - if (fileContentType == 'image/png' || fileContentType == 'image/gif') { - - //load file - var fileReader = new FileReader(); - fileReader.onload = function(e) { - var img = new Image(); - img.onload = function() { - - //draw image onto the temporary canvas - var loadPaletteCanvas = document.getElementById("load-palette-canvas-holder"); - var loadPaletteContext = loadPaletteCanvas.getContext("2d"); - - loadPaletteCanvas.width = img.width; - loadPaletteCanvas.height = img.height; - - loadPaletteContext.drawImage(img, 0, 0); - - //create array to hold found colors - var colorPalette = []; - var imagePixelData = loadPaletteContext.getImageData(0,0,this.width, this.height).data; - - console.log(imagePixelData) - - //loop through pixels looking for colors to add to palette - for (var i = 0; i < imagePixelData.length; i += 4) { - var color = '#'+rgbToHex(imagePixelData[i],imagePixelData[i + 1],imagePixelData[i + 2]); - if (colorPalette.indexOf(color) == -1) { - colorPalette.push(color); - } - } - - //add to palettes so that it can be loaded when they click okay - palettes['Loaded palette'] = {}; - palettes['Loaded palette'].colors = colorPalette; - setText('palette-button', 'Loaded palette'); - }; - img.src = e.target.result; - }; - fileReader.readAsDataURL(this.files[0]); - } - else alert('Only PNG and GIF files are supported at this time.'); - } -}); \ No newline at end of file + if (this.files && this.files[0]) { + + //make sure file is allowed filetype + var fileContentType = this.files[0].type; + if (fileContentType == 'image/png' || fileContentType == 'image/gif') { + + //load file + var fileReader = new FileReader(); + fileReader.onload = function(e) { + var img = new Image(); + img.onload = function() { + + //draw image onto the temporary canvas + var loadPaletteCanvas = document.getElementById('load-palette-canvas-holder'); + var loadPaletteContext = loadPaletteCanvas.getContext('2d'); + + loadPaletteCanvas.width = img.width; + loadPaletteCanvas.height = img.height; + + loadPaletteContext.drawImage(img, 0, 0); + + //create array to hold found colors + var colorPalette = []; + var imagePixelData = loadPaletteContext.getImageData(0,0,this.width, this.height).data; + + console.log(imagePixelData); + + //loop through pixels looking for colors to add to palette + for (var i = 0; i < imagePixelData.length; i += 4) { + var color = '#'+rgbToHex(imagePixelData[i],imagePixelData[i + 1],imagePixelData[i + 2]); + if (colorPalette.indexOf(color) == -1) { + colorPalette.push(color); + } + } + + //add to palettes so that it can be loaded when they click okay + palettes['Loaded palette'] = {}; + palettes['Loaded palette'].colors = colorPalette; + setText('palette-button', 'Loaded palette'); + }; + img.src = e.target.result; + }; + fileReader.readAsDataURL(this.files[0]); + } + else alert('Only PNG and GIF files are supported at this time.'); + } +}); diff --git a/js/_mouseEvents.js b/js/_mouseEvents.js index a590d36..da22efb 100644 --- a/js/_mouseEvents.js +++ b/js/_mouseEvents.js @@ -3,196 +3,213 @@ var currentMouseEvent; var lastMousePos; //mousedown - start drawing -window.addEventListener("mousedown", function (mouseEvent) { - // Saving the event in case something else needs it - currentMouseEvent = mouseEvent; - canDraw = true; - - //if no document has been created yet, or this is a dialog open - if (!documentCreated || dialogueOpen) return; - //prevent right mouse clicks and such, which will open unwanted menus - //mouseEvent.preventDefault(); - - lastPos = getCursorPosition(mouseEvent); - - dragging = true; - //left or right click ? - if (mouseEvent.which == 1) { - if (spacePressed) - currentTool = 'pan'; - else if (mouseEvent.altKey) - currentTool = 'eyedropper'; - else if (mouseEvent.target.className == 'drawingCanvas' && - (currentTool == 'pencil' || currentTool == 'eraser' || currentTool == 'rectangle')) - new HistoryStateEditCanvas(); - else if (currentTool == 'moveselection') { - if (!cursorInSelectedArea()) { - changeTool('pencil'); - canDraw = false; - } - } - //saveHistoryState({type: 'canvas', canvas: context.getImageData(0, 0, canvasSize[0], canvasSize[1])}); - - updateCursor(); - - if (canDraw) { - draw(mouseEvent); - } - } - else if (currentTool == 'pencil' && mouseEvent.which == 3) { - currentTool = 'resize-brush'; - prevBrushSize = pencilSize; - } - else if (currentTool == 'eraser' && mouseEvent.which == 3) { - currentTool = 'resize-eraser'; - prevEraserSize = eraserSize; - } - else if (currentTool == 'rectangle' && mouseEvent.which == 3) { - currentTool = 'resize-rectangle'; - prevRectangleSize = rectangleSize; - } +window.addEventListener('mousedown', function (mouseEvent) { + // Saving the event in case something else needs it + currentMouseEvent = mouseEvent; + canDraw = true; - if (currentTool == 'eyedropper' && mouseEvent.target.className == 'drawingCanvas') - eyedropperPreview.style.display = 'block'; - - return false; + //if no document has been created yet, or this is a dialog open + if (!documentCreated || dialogueOpen) return; + //prevent right mouse clicks and such, which will open unwanted menus + //mouseEvent.preventDefault(); + + lastPos = getCursorPosition(mouseEvent); + + dragging = true; + // left or right click ? + if (mouseEvent.which == 1) { + if (spacePressed) + currentTool = 'pan'; + else if (mouseEvent.altKey) + currentTool = 'eyedropper'; + else if (mouseEvent.target.className == 'drawingCanvas' && + (currentTool == 'pencil' || currentTool == 'eraser' || currentTool == 'rectangle')) + new HistoryStateEditCanvas(); + else if (currentTool == 'moveselection') { + if (!cursorInSelectedArea()) { + changeTool('pencil'); + canDraw = false; + } + } + //saveHistoryState({type: 'canvas', canvas: context.getImageData(0, 0, canvasSize[0], canvasSize[1])}); + + updateCursor(); + + if (canDraw) { + draw(mouseEvent); + } + } + else if (currentTool == 'pencil' && mouseEvent.which == 3) { + currentTool = 'resize-brush'; + prevBrushSize = pencilSize; + } + else if (currentTool == 'eraser' && mouseEvent.which == 3) { + currentTool = 'resize-eraser'; + prevEraserSize = eraserSize; + } + else if (currentTool == 'rectangle' && mouseEvent.which == 3) { + currentTool = 'resize-rectangle'; + prevRectangleSize = rectangleSize; + } + + if (currentTool == 'eyedropper' && mouseEvent.target.className == 'drawingCanvas') + eyedropperPreview.style.display = 'block'; + + return false; }, false); //mouseup - end drawing -window.addEventListener("mouseup", function (mouseEvent) { - // Saving the event in case something else needs it - currentMouseEvent = mouseEvent; +window.addEventListener('mouseup', function (mouseEvent) { + // Saving the event in case something else needs it + currentMouseEvent = mouseEvent; - closeMenu(); - - if (!documentCreated || dialogueOpen) return; - - if (currentTool == 'eyedropper' && mouseEvent.target.className == 'drawingCanvas') { - var cursorLocation = getCursorPosition(mouseEvent); - var selectedColor = context.getImageData(Math.floor(cursorLocation[0]/zoom),Math.floor(cursorLocation[1]/zoom),1,1); - var newColor = rgbToHex(selectedColor.data[0],selectedColor.data[1],selectedColor.data[2]); + closeMenu(); - currentGlobalColor = "#" + newColor; - - var colors = document.getElementsByClassName('color-button'); - for (var i = 0; i < colors.length; i++) { - console.log(colors[i].jscolor.toString()); - - //if picked color matches this color - if (newColor == colors[i].jscolor.toString()) { - console.log('color found'); - - //remove current color selection - var selectedColor = document.querySelector("#colors-menu li.selected") - if (selectedColor) selectedColor.classList.remove("selected"); - - //set current color - context.fillStyle = '#'+newColor; - - //make color selected - colors[i].parentElement.classList.add('selected'); - - //hide eyedropper - eyedropperPreview.style.display = 'none'; - } - } - } - else if (currentTool == 'fill' && mouseEvent.target.className == 'drawingCanvas') { - console.log('filling') - - //get cursor postion - var cursorLocation = getCursorPosition(mouseEvent); - - //offset to match cursor point - cursorLocation[0] += 2; - cursorLocation[1] += 12; - - //fill starting at the location - fill(cursorLocation); - } - else if (currentTool == 'zoom' && mouseEvent.target.className == 'drawingCanvas') { - let mode; - if (mouseEvent.which == 1){ - mode = "in"; + if (!documentCreated || dialogueOpen) return; + + if (currentTool == 'eyedropper' && mouseEvent.target.className == 'drawingCanvas') { + var cursorLocation = getCursorPosition(mouseEvent); + var selectedColor = context.getImageData(Math.floor(cursorLocation[0]/zoom),Math.floor(cursorLocation[1]/zoom),1,1); + var newColor = rgbToHex(selectedColor.data[0],selectedColor.data[1],selectedColor.data[2]); + + currentGlobalColor = '#' + newColor; + + var colors = document.getElementsByClassName('color-button'); + for (var i = 0; i < colors.length; i++) { + console.log(colors[i].jscolor.toString()); + + //if picked color matches this color + if (newColor == colors[i].jscolor.toString()) { + console.log('color found'); + + //remove current color selection + var selectedColor = document.querySelector('#colors-menu li.selected'); + if (selectedColor) selectedColor.classList.remove('selected'); + + //set current color + context.fillStyle = '#'+newColor; + + //make color selected + colors[i].parentElement.classList.add('selected'); + + //hide eyedropper + eyedropperPreview.style.display = 'none'; + } } - else if (mouseEvent.which == 3){ - mode = "out"; + } + else if (currentTool == 'fill' && mouseEvent.target.className == 'drawingCanvas') { + console.log('filling'); + //if you clicked on anything but the canvas, do nothing + if (!mouseEvent.target == currentLayer.canvas) return; + + //get cursor postion + var cursorLocation = getCursorPosition(mouseEvent); + + //offset to match cursor point + cursorLocation[0] += 2; + cursorLocation[1] += 12; + + //fill starting at the location + fill(cursorLocation); + } + else if (currentTool == 'zoom' && mouseEvent.target.className == 'drawingCanvas') { + let mode; + if (mouseEvent.which == 1){ + mode = 'in'; + } + else if (mouseEvent.which == 3){ + mode = 'out'; } changeZoom(layers[0], mode, getCursorPosition(mouseEvent)); for (let i=1; i127) brushPreview.classList.remove('dark'); - else brushPreview.classList.add('dark'); - } - // Decided to write a different implementation in case of differences between the brush and the eraser tool - else if (currentTool == 'eraser') { - // Uses the same preview as the brush + //if a document hasnt yet been created, exit this function + if (!documentCreated || dialogueOpen) return; + + + eyedropperPreview.style.display = 'none'; + + if (currentTool == 'pencil') { //move the brush preview - brushPreview.style.left = cursorLocation[0] + canvas.offsetLeft - eraserSize * zoom / 2 + 'px'; - brushPreview.style.top = cursorLocation[1] + canvas.offsetTop - eraserSize * zoom / 2 + 'px'; + setPreviewPosition(brushPreview, cursorLocation, pencilSize); + + //hide brush preview outside of canvas / canvas view + if (mouseEvent.target.className == 'drawingCanvas'|| mouseEvent.target.className == 'drawingCanvas') + brushPreview.style.visibility = 'visible'; + else + brushPreview.style.visibility = 'hidden'; + + //draw line to current pixel + if (dragging) { + if (mouseEvent.target.className == 'drawingCanvas' || mouseEvent.target.className == 'drawingCanvas') { + line( + Math.floor(lastPos[0]/zoom), Math.floor(lastPos[1]/zoom), + Math.floor(cursorLocation[0]/zoom), Math.floor(cursorLocation[1]/zoom), + pencilSize + ); + lastPos = cursorLocation; + } + } + + //get lightness value of color + var selectedColor = context.getImageData(Math.floor(cursorLocation[0]/zoom),Math.floor(cursorLocation[1]/zoom),1,1).data; + var colorLightness = Math.max(selectedColor[0],selectedColor[1],selectedColor[2]); + + //for the darkest 50% of colors, change the brush preview to dark mode + if (colorLightness>127) brushPreview.classList.remove('dark'); + else brushPreview.classList.add('dark'); + } + // Decided to write a different implementation in case of differences between the brush and the eraser tool + else if (currentTool == 'eraser') { + // Uses the same preview as the brush + //move the brush preview + setPreviewPosition(brushPreview, cursorLocation, eraserSize); //hide brush preview outside of canvas / canvas view if (mouseEvent.target.className == 'drawingCanvas' || mouseEvent.target.className == 'drawingCanvas') @@ -203,34 +220,37 @@ function draw (mouseEvent) { //draw line to current pixel if (dragging) { if (mouseEvent.target.className == 'drawingCanvas' || mouseEvent.target.className == 'drawingCanvas') { - line(Math.floor(lastPos[0]/zoom),Math.floor(lastPos[1]/zoom),Math.floor(cursorLocation[0]/zoom),Math.floor(cursorLocation[1]/zoom), eraserSize); + line( + Math.floor(lastPos[0]/zoom), Math.floor(lastPos[1]/zoom), + Math.floor(cursorLocation[0]/zoom), Math.floor(cursorLocation[1]/zoom), + eraserSize + ); lastPos = cursorLocation; } } - } - else if (currentTool == 'rectangle') - { - //move the brush preview - brushPreview.style.left = cursorLocation[0] + currentLayer.canvas.offsetLeft - rectangleSize * zoom / 2 + 'px'; - brushPreview.style.top = cursorLocation[1] + currentLayer.canvas.offsetTop - rectangleSize * zoom / 2 + 'px'; + } + else if (currentTool == 'rectangle') + { + //move the brush preview + setPreviewPosition(brushPreview, cursorLocation, rectangleSize) - //hide brush preview outside of canvas / canvas view - if (mouseEvent.target.className == 'drawingCanvas'|| mouseEvent.target.className == 'drawingCanvas') - brushPreview.style.visibility = 'visible'; - else - brushPreview.style.visibility = 'hidden'; + //hide brush preview outside of canvas / canvas view + if (mouseEvent.target.className == 'drawingCanvas'|| mouseEvent.target.className == 'drawingCanvas') + brushPreview.style.visibility = 'visible'; + else + brushPreview.style.visibility = 'hidden'; - if (!isDrawingRect && dragging) { - startRectDrawing(mouseEvent); - } - else if (dragging){ - updateRectDrawing(mouseEvent); - } - } - else if (currentTool == 'pan' && dragging) { - // Setting first layer position + if (!isDrawingRect && dragging) { + startRectDrawing(mouseEvent); + } + else if (dragging){ + updateRectDrawing(mouseEvent); + } + } + else if (currentTool == 'pan' && dragging) { + // Setting first layer position setCanvasOffset(layers[0].canvas, layers[0].canvas.offsetLeft + (cursorLocation[0] - lastPos[0]), layers[0].canvas.offsetTop + (cursorLocation[1] - lastPos[1])); - // Copying that position to the other layers + // Copying that position to the other layers for (let i=1; i127) eyedropperPreview.classList.remove('dark'); - else eyedropperPreview.classList.add('dark'); + if (colorLightness>127) eyedropperPreview.classList.remove('dark'); + else eyedropperPreview.classList.add('dark'); } else if (currentTool == 'resize-brush' && dragging) { //get new brush size based on x distance from original clicking location @@ -259,11 +279,10 @@ function draw (mouseEvent) { var newBrushSize = prevBrushSize + brushSizeChange; //set the brush to the new size as long as its bigger than 1 - pencilSize = Math.max(1,newBrushSize); + pencilSize = Math.max(1, newBrushSize); //fix offset so the cursor stays centered - brushPreview.style.left = lastPos[0] + currentLayer.canvas.offsetLeft - pencilSize * zoom / 2 + 'px'; - brushPreview.style.top = lastPos[1] + currentLayer.canvas.offsetTop - pencilSize * zoom / 2 + 'px'; + setPreviewPosition(brushPreview, cursorLocation, pencilSize); updateCursor(); } @@ -279,13 +298,12 @@ function draw (mouseEvent) { eraserSize = Math.max(1,newEraserSizeChange); //fix offset so the cursor stays centered - brushPreview.style.left = lastPos[0] + currentLayer.canvas.offsetLeft - eraserSize * zoom / 2 + 'px'; - brushPreview.style.top = lastPos[1] + currentLayer.canvas.offsetTop - eraserSize * zoom / 2 + 'px'; + setPreviewPosition(brushPreview, cursorLocation, eraserSize); updateCursor(); } else if (currentTool == 'resize-rectangle' && dragging) { - //get new brush size based on x distance from original clicking location + //get new brush size based on x distance from original clicking location var distanceFromClick = cursorLocation[0] - lastPos[0]; //var roundingAmount = 20 - Math.round(distanceFromClick/10); //this doesnt work in reverse... because... it's not basing it off of the brush size which it should be @@ -296,54 +314,53 @@ function draw (mouseEvent) { rectangleSize = Math.max(1,newRectangleSize); //fix offset so the cursor stays centered - brushPreview.style.left = lastPos[0] + currentLayer.canvas.offsetLeft - rectangleSize * zoom / 2 + 'px'; - brushPreview.style.top = lastPos[1] + currentLayer.canvas.offsetTop - rectangleSize * zoom / 2 + 'px'; + setPreviewPosition(brushPreview, cursorLocation, rectangleSize); updateCursor(); } else if (currentTool == 'rectselect') { - if (dragging && !isRectSelecting && mouseEvent.target.className == 'drawingCanvas') { - isRectSelecting = true; - console.log("cominciata selezione su " + mouseEvent.target.className); - startRectSelection(mouseEvent); - } - else if (dragging && isRectSelecting) { - updateRectSelection(mouseEvent); - } - else if (isRectSelecting) { - endRectSelection(); - } + if (dragging && !isRectSelecting && mouseEvent.target.className == 'drawingCanvas') { + isRectSelecting = true; + console.log('cominciata selezione su ' + mouseEvent.target.className); + startRectSelection(mouseEvent); + } + else if (dragging && isRectSelecting) { + updateRectSelection(mouseEvent); + } + else if (isRectSelecting) { + endRectSelection(); + } } else if (currentTool == 'moveselection') { - // Updating the cursor (move if inside rect, cross if not) - updateCursor(); + // Updating the cursor (move if inside rect, cross if not) + updateCursor(); - // If I'm dragging, I move the preview - if (dragging && cursorInSelectedArea()) { - updateMovePreview(mouseEvent); - } + // If I'm dragging, I move the preview + if (dragging && cursorInSelectedArea()) { + updateMovePreview(mouseEvent); + } } } //mousewheel scrroll -canvasView.addEventListener("wheel", function(mouseEvent){ - - if (currentTool == 'zoom' || mouseEvent.altKey) { - let mode; - if (mouseEvent.deltaY < 0){ - mode = 'in'; +canvasView.addEventListener('wheel', function(mouseEvent){ + + if (currentTool == 'zoom' || mouseEvent.altKey) { + let mode; + if (mouseEvent.deltaY < 0){ + mode = 'in'; } - else if (mouseEvent.deltaY > 0) { - mode = 'out'; + else if (mouseEvent.deltaY > 0) { + mode = 'out'; } // Changing zoom and position of the first layer - changeZoom(layers[0], mode, getCursorPosition(mouseEvent)) + changeZoom(layers[0], mode, getCursorPosition(mouseEvent)); for (let i=1; i 0) { - colors[0].parentElement.remove(); - } - - //add colors from selected palette - var selectedPalette = getText('palette-button'); - if (selectedPalette != 'Choose a palette...') { - - //if this palette isnt the one specified in the url, then reset the url - if (!palettes[selectedPalette].specified) - history.pushState(null, null, '/pixel-editor/app'); - - //fill the palette with specified palette - createColorPalette(palettes[selectedPalette].colors,true); - } - else { - //this wasn't a specified palette, so reset the url - history.pushState(null, null, '/pixel-editor/app'); - - //generate default colors - var fg = hslToRgb(Math.floor(Math.random()*255), 230,70); - var bg = hslToRgb(Math.floor(Math.random()*255), 230,170); - - //convert colors to hex - var defaultForegroundColor = rgbToHex(fg.r,fg.g,fg.b); - var defaultBackgroundColor = rgbToHex(bg.r,bg.g,bg.b); - - //add colors to paletee - addColor(defaultForegroundColor).classList.add('selected'); - addColor(defaultBackgroundColor); - - //fill background of canvas with bg color - fillCheckerboard(); - /* - currentLayer.context.fillStyle = '#'+defaultBackgroundColor; - currentLayer.context.fillRect(0, 0, canvasSize[0], canvasSize[1]); - - console.log('#'+defaultBackgroundColor) - */ - - //set current drawing color as foreground color - currentLayer.context.fillStyle = '#'+defaultForegroundColor; - currentGlobalColor = '#' + defaultForegroundColor; - selectedPalette = 'none'; - } - - //reset undo and redo states - undoStates = []; - redoStates = []; - - closeDialogue(); - updateCursor(); - - document.getElementById('save-as-button').classList.remove('disabled'); - documentCreated = true; - -} \ No newline at end of file + // Adding the first layer and the checkerboard to the list of layers + layers.push(VFXLayer); + layers.push(TMPLayer); + layers.push(currentLayer); + layers.push(checkerBoard); + + //remove current palette + colors = document.getElementsByClassName('color-button'); + while (colors.length > 0) { + colors[0].parentElement.remove(); + } + + //add colors from selected palette + var selectedPalette = getText('palette-button'); + if (selectedPalette != 'Choose a palette...') { + + //if this palette isnt the one specified in the url, then reset the url + if (!palettes[selectedPalette].specified) + history.pushState(null, null, '/pixel-editor/app'); + + //fill the palette with specified palette + createColorPalette(palettes[selectedPalette].colors,true); + } + else { + //this wasn't a specified palette, so reset the url + history.pushState(null, null, '/pixel-editor/app'); + + //generate default colors + var fg = hslToRgb(Math.floor(Math.random()*255), 230,70); + var bg = hslToRgb(Math.floor(Math.random()*255), 230,170); + + //convert colors to hex + var defaultForegroundColor = rgbToHex(fg.r,fg.g,fg.b); + var defaultBackgroundColor = rgbToHex(bg.r,bg.g,bg.b); + + //add colors to paletee + addColor(defaultForegroundColor).classList.add('selected'); + addColor(defaultBackgroundColor); + + //fill background of canvas with bg color + fillCheckerboard(); + /* + currentLayer.context.fillStyle = '#'+defaultBackgroundColor; + currentLayer.context.fillRect(0, 0, canvasSize[0], canvasSize[1]); + + console.log('#'+defaultBackgroundColor) + */ + + //set current drawing color as foreground color + currentLayer.context.fillStyle = '#'+defaultForegroundColor; + currentGlobalColor = '#' + defaultForegroundColor; + selectedPalette = 'none'; + } + + //reset undo and redo states + undoStates = []; + redoStates = []; + + closeDialogue(); + updateCursor(); + + document.getElementById('save-as-button').classList.remove('disabled'); + documentCreated = true; + +} diff --git a/js/_onLoad.js b/js/_onLoad.js index e4c9e18..bb891ca 100644 --- a/js/_onLoad.js +++ b/js/_onLoad.js @@ -1,12 +1,12 @@ //when the page is donw loading, you can get ready to start window.onload = function(){ - updateCursor(); - - //if the user specified dimentions - if (specifiedDimentions) - //create a new pixel - newPixel(getValue('size-width'),getValue('size-height'),''); - else - //otherwise show the new pixel dialog - showDialogue('new-pixel', false); -}; \ No newline at end of file + updateCursor(); + + //if the user specified dimentions + if (specifiedDimentions) + //create a new pixel + newPixel(getValue('size-width'),getValue('size-height'),''); + else + //otherwise show the new pixel dialog + showDialogue('new-pixel', false); +}; diff --git a/js/_onbeforeunload.js b/js/_onbeforeunload.js index bfeef40..ab4b920 100644 --- a/js/_onbeforeunload.js +++ b/js/_onbeforeunload.js @@ -1,7 +1,7 @@ //prevent user from leaving page with unsaved data window.onbeforeunload = function() { - if (documentCreated) - return 'You will lose your pixel if it\'s not saved!'; - - else return; -} \ No newline at end of file + if (documentCreated) + return 'You will lose your pixel if it\'s not saved!'; + + else return; +}; diff --git a/js/_palettes.js b/js/_palettes.js index d0c0e9e..164b861 100644 --- a/js/_palettes.js +++ b/js/_palettes.js @@ -1,62 +1,62 @@ //populate palettes list in new pixel menu Object.keys(palettes).forEach(function(paletteName,index) { - - var palettesMenu = document.getElementById("palette-menu"); + + var palettesMenu = document.getElementById('palette-menu'); //create button - var button = document.createElement("button"); + var button = document.createElement('button'); button.appendChild(document.createTextNode(paletteName)); - - //insert new element - palettesMenu.appendChild(button); - - //if the palette was specified by the user, change the dropdown to it - if (palettes[paletteName].specified == true) { - setText('palette-button', paletteName); - //Show empty palette option - document.getElementById('no-palette-button').style.display = 'block'; - } - on('click', button, function() { + //insert new element + palettesMenu.appendChild(button); - //hide the dropdown menu - deselect('palette-menu'); - deselect('palette-button'); - - //show empty palette option - document.getElementById('no-palette-button').style.display = 'block'; - - //set the text of the dropdown to the newly selected preset - setText('palette-button', paletteName); - }); + //if the palette was specified by the user, change the dropdown to it + if (palettes[paletteName].specified == true) { + setText('palette-button', paletteName); + //Show empty palette option + document.getElementById('no-palette-button').style.display = 'block'; + } + + on('click', button, function() { + + //hide the dropdown menu + deselect('palette-menu'); + deselect('palette-button'); + + //show empty palette option + document.getElementById('no-palette-button').style.display = 'block'; + + //set the text of the dropdown to the newly selected preset + setText('palette-button', paletteName); + }); }); //select no palette on('click', 'no-palette-button', function () { - document.getElementById('no-palette-button').style.display = 'none'; - setText('palette-button', 'Choose a palette...'); + document.getElementById('no-palette-button').style.display = 'none'; + setText('palette-button', 'Choose a palette...'); }); //select load palette on('click', 'load-palette-button', function () { - document.getElementById("load-palette-browse-holder").click(); + document.getElementById('load-palette-browse-holder').click(); }); on('click', 'palette-button', function (e){ - toggle('palette-button'); - toggle('palette-menu'); - - deselect('preset-button'); - deselect('preset-menu'); - e.stopPropagation(); + toggle('palette-button'); + toggle('palette-menu'); + + deselect('preset-button'); + deselect('preset-menu'); + e.stopPropagation(); }); on('click', 'new-pixel', function (){ - deselect('preset-button'); - deselect('preset-menu'); - deselect('palette-button'); - deselect('palette-menu'); -}); \ No newline at end of file + deselect('preset-button'); + deselect('preset-menu'); + deselect('palette-button'); + deselect('palette-menu'); +}); diff --git a/js/_pixelEditorUtility.js b/js/_pixelEditorUtility.js index 67874f1..52a2f10 100644 --- a/js/_pixelEditorUtility.js +++ b/js/_pixelEditorUtility.js @@ -1,7 +1,7 @@ function isPixelEmpty(pixel) { - if ((pixel[0] == 0 && pixel[1] == 0 && pixel[2] == 0) || pixel[3] == 0) { - return true; - } + if ((pixel[0] == 0 && pixel[1] == 0 && pixel[2] == 0) || pixel[3] == 0) { + return true; + } - return false; + return false; } \ No newline at end of file diff --git a/js/_presets.js b/js/_presets.js index e93364d..87790bd 100644 --- a/js/_presets.js +++ b/js/_presets.js @@ -1,64 +1,64 @@ //prests var presets = { - 'Gameboy Color': { - width: 240, - height: 203, - palette: 'Gameboy Color' - }, - 'PICO-8': { - width: 128, - height: 128, - palette: 'PICO-8', - }, - 'Commodore 64': { - width: 40, - height: 80, - palette: 'Commodore 64' - } + 'Gameboy Color': { + width: 240, + height: 203, + palette: 'Gameboy Color' + }, + 'PICO-8': { + width: 128, + height: 128, + palette: 'PICO-8', + }, + 'Commodore 64': { + width: 40, + height: 80, + palette: 'Commodore 64' + } }; //populate preset list in new pixel menu Object.keys(presets).forEach(function(presetName,index) { - - var presetsMenu = document.getElementById("preset-menu"); + + var presetsMenu = document.getElementById('preset-menu'); //create button - var button = document.createElement("button"); + var button = document.createElement('button'); button.appendChild(document.createTextNode(presetName)); - - //insert new element - presetsMenu.appendChild(button); - - //add click event listener - on('click', button, function() { - //change dimentions on new pixel form - setValue('size-width', presets[presetName].width); - setValue('size-height', presets[presetName].height); + //insert new element + presetsMenu.appendChild(button); - //set the text of the dropdown to the newly selected preset - setText('palette-button', presets[presetName].palette); + //add click event listener + on('click', button, function() { - //hide the dropdown menu - deselect('preset-menu'); - deselect('preset-button'); + //change dimentions on new pixel form + setValue('size-width', presets[presetName].width); + setValue('size-height', presets[presetName].height); - //set the text of the dropdown to the newly selected preset - setText('preset-button', presetName); - }); + //set the text of the dropdown to the newly selected preset + setText('palette-button', presets[presetName].palette); + + //hide the dropdown menu + deselect('preset-menu'); + deselect('preset-button'); + + //set the text of the dropdown to the newly selected preset + setText('preset-button', presetName); + }); }); on('click', 'preset-button', function (e){ - //open or close the preset menu - toggle('preset-button'); - toggle('preset-menu'); - - //close the palette menu - deselect('palette-button'); - deselect('palette-menu'); - - //stop the click from propogating to the parent element - e.stopPropagation(); + //open or close the preset menu + toggle('preset-button'); + toggle('preset-menu'); + + //close the palette menu + deselect('palette-button'); + deselect('palette-menu'); + + //stop the click from propogating to the parent element + e.stopPropagation(); }); diff --git a/js/_rectSelect.js b/js/_rectSelect.js index 74c02f0..2c300c5 100644 --- a/js/_rectSelect.js +++ b/js/_rectSelect.js @@ -5,147 +5,147 @@ let endX; let endY; function startRectSelection(mouseEvent) { - // Saving the canvas - new HistoryStateEditCanvas(); - // Putting the vfx layer on top of everything - VFXCanvas.style.zIndex = MAX_Z_INDEX; + // Saving the canvas + new HistoryStateEditCanvas(); + // Putting the vfx layer on top of everything + VFXCanvas.style.zIndex = MAX_Z_INDEX; - // Saving the start coords of the rect - let cursorPos = getCursorPosition(mouseEvent); - startX = Math.round(cursorPos[0] / zoom) - 0.5; - startY = Math.round(cursorPos[1] / zoom) - 0.5; + // Saving the start coords of the rect + let cursorPos = getCursorPosition(mouseEvent); + startX = Math.round(cursorPos[0] / zoom) - 0.5; + startY = Math.round(cursorPos[1] / zoom) - 0.5; - // Avoiding external selections - if (startX < 0) { - startX = 0; - } - else if (startX > currentLayer.canvas.width) { - startX = currentLayer.canvas.width; - } + // Avoiding external selections + if (startX < 0) { + startX = 0; + } + else if (startX > currentLayer.canvas.width) { + startX = currentLayer.canvas.width; + } - if (startY < 0) { - startY = 0; - } - else if (startY > currentLayer.canvas.height) { - startY = currentLayer.canvas.height; - } + if (startY < 0) { + startY = 0; + } + else if (startY > currentLayer.canvas.height) { + startY = currentLayer.canvas.height; + } - // Drawing the rect - drawRect(startX, startY); - selectionCanceled = false; + // Drawing the rect + drawRect(startX, startY); + selectionCanceled = false; } function updateRectSelection(mouseEvent) { - let pos = getCursorPosition(mouseEvent); + let pos = getCursorPosition(mouseEvent); - // Drawing the rect - drawRect(Math.round(pos[0] / zoom) + 0.5, Math.round(pos[1] / zoom) + 0.5); + // Drawing the rect + drawRect(Math.round(pos[0] / zoom) + 0.5, Math.round(pos[1] / zoom) + 0.5); } function endRectSelection(mouseEvent) { - // Getting the end position - let currentPos = getCursorPosition(mouseEvent); - endX = Math.round(currentPos[0] / zoom) + 0.5; - endY = Math.round(currentPos[1] / zoom) + 0.5; + // Getting the end position + let currentPos = getCursorPosition(mouseEvent); + endX = Math.round(currentPos[0] / zoom) + 0.5; + endY = Math.round(currentPos[1] / zoom) + 0.5; - // Inverting end and start (start must always be the top left corner) - if (endX < startX) { - let tmp = endX; - endX = startX; - startX = tmp; - } - // Same for the y - if (endY < startY) { - let tmp = endY; - endY = startY; - startY = tmp; - } + // Inverting end and start (start must always be the top left corner) + if (endX < startX) { + let tmp = endX; + endX = startX; + startX = tmp; + } + // Same for the y + if (endY < startY) { + let tmp = endY; + endY = startY; + startY = tmp; + } - // Selecting the move tool - currentTool = 'moveselection'; - currentToolTemp = currentTool; + // Selecting the move tool + currentTool = 'moveselection'; + currentToolTemp = currentTool; - // Resetting this - isRectSelecting = false; + // Resetting this + isRectSelecting = false; - // Updating the cursor - updateCursor(); + // Updating the cursor + updateCursor(); } function cutSelection(mouseEvent) { - console.log("Coordinate: start x, y: " + startX + ", " + startY + " end x, y: " + endX + ", " + endY); - // Getting the selected pixels - imageDataToMove = currentLayer.context.getImageData(startX, startY, endX - startX + 1, endY - startY + 1); + console.log('Coordinate: start x, y: ' + startX + ', ' + startY + ' end x, y: ' + endX + ', ' + endY); + // Getting the selected pixels + imageDataToMove = currentLayer.context.getImageData(startX, startY, endX - startX + 1, endY - startY + 1); - currentLayer.context.clearRect(startX - 0.5, startY - 0.5, endX - startX + 1, endY - startY + 1); - // Moving those pixels from the current layer to the tmp layer - TMPLayer.context.putImageData(imageDataToMove, startX + 1, startY); + currentLayer.context.clearRect(startX - 0.5, startY - 0.5, endX - startX + 1, endY - startY + 1); + // Moving those pixels from the current layer to the tmp layer + TMPLayer.context.putImageData(imageDataToMove, startX + 1, startY); - //originalDataPosition = [currentPos[0], currentPos[1]]; + //originalDataPosition = [currentPos[0], currentPos[1]]; } function drawRect(x, y) { - // Getting the vfx context - let vfxContext = VFXCanvas.getContext("2d"); + // Getting the vfx context + let vfxContext = VFXCanvas.getContext('2d'); - // Clearing the vfx canvas - vfxContext.clearRect(0, 0, VFXCanvas.width, VFXCanvas.height); - vfxContext.lineWidth = 1; - vfxContext.strokeStyle = "black"; - vfxContext.setLineDash([4]); + // Clearing the vfx canvas + vfxContext.clearRect(0, 0, VFXCanvas.width, VFXCanvas.height); + vfxContext.lineWidth = 1; + vfxContext.strokeStyle = 'black'; + vfxContext.setLineDash([4]); - // Drawing the rect - vfxContext.beginPath(); - vfxContext.rect(startX, startY, x - startX, y - startY); + // Drawing the rect + vfxContext.beginPath(); + vfxContext.rect(startX, startY, x - startX, y - startY); - vfxContext.stroke(); + vfxContext.stroke(); - // TODO: make the rect blink from black to white in case of dark backgrounds + // TODO: make the rect blink from black to white in case of dark backgrounds } function applyChanges() { - VFXCanvas.style.zIndex = MIN_Z_INDEX; + VFXCanvas.style.zIndex = MIN_Z_INDEX; } // Checks whether the pointer is inside the selected area or not function cursorInSelectedArea() { - let cursorPos = getCursorPosition(currentMouseEvent); - let x = cursorPos[0] / zoom; - let y = cursorPos[1] / zoom; + let cursorPos = getCursorPosition(currentMouseEvent); + let x = cursorPos[0] / zoom; + let y = cursorPos[1] / zoom; - let leftX = Math.min(startX, endX); - let rightX = Math.max(startX, endX); - let topY = Math.max(startY, endY); - let bottomY = Math.min(startY, endY); + let leftX = Math.min(startX, endX); + let rightX = Math.max(startX, endX); + let topY = Math.max(startY, endY); + let bottomY = Math.min(startY, endY); - if (leftX <= x && x <= rightX) { - if (bottomY <= y && y <= topY) { - return true; - } + if (leftX <= x && x <= rightX) { + if (bottomY <= y && y <= topY) { + return true; + } - return false; - } + return false; + } - return false; + return false; } function moveSelection(x, y, width, height) { - // Getting the vfx context - let vfxContext = VFXCanvas.getContext("2d"); + // Getting the vfx context + let vfxContext = VFXCanvas.getContext('2d'); - // Clearing the vfx canvas - vfxContext.clearRect(0, 0, VFXCanvas.width, VFXCanvas.height); - vfxContext.lineWidth = 1; - vfxContext.setLineDash([4]); + // Clearing the vfx canvas + vfxContext.clearRect(0, 0, VFXCanvas.width, VFXCanvas.height); + vfxContext.lineWidth = 1; + vfxContext.setLineDash([4]); - startX = Math.round(Math.round(x) - Math.round(width / 2)) + 0.5; - startY = Math.round(Math.round(y) - Math.round(height / 2)) + 0.5; - endX = startX + Math.round(width); - endY = startY + Math.round(height); + startX = Math.round(Math.round(x) - Math.round(width / 2)) + 0.5; + startY = Math.round(Math.round(y) - Math.round(height / 2)) + 0.5; + endX = startX + Math.round(width); + endY = startY + Math.round(height); - // Drawing the rect - vfxContext.beginPath(); - vfxContext.rect(startX, startY, width, height); + // Drawing the rect + vfxContext.beginPath(); + vfxContext.rect(startX, startY, width, height); - vfxContext.stroke(); + vfxContext.stroke(); } \ No newline at end of file diff --git a/js/_rectangle.js b/js/_rectangle.js index 3249ce4..62a2bdb 100644 --- a/js/_rectangle.js +++ b/js/_rectangle.js @@ -1,7 +1,7 @@ var rectangleSize = 1; var prevRectangleSie = rectangleSize; -var emptySVG = document.getElementById("empty-button-svg"); -var fullSVG = document.getElementById("full-button-svg"); +var emptySVG = document.getElementById('empty-button-svg'); +var fullSVG = document.getElementById('full-button-svg'); var drawMode = 'empty'; var isDrawingRect = false; @@ -13,109 +13,109 @@ let endRectY; function startRectDrawing(mouseEvent) { - // Putting the vfx layer on top of everything - VFXCanvas.style.zIndex = MAX_Z_INDEX; - // Updating flag - isDrawingRect = true; + // Putting the vfx layer on top of everything + VFXCanvas.style.zIndex = MAX_Z_INDEX; + // Updating flag + isDrawingRect = true; - // Saving the start coords of the rect - let cursorPos = getCursorPosition(mouseEvent); - startRectX = Math.round(cursorPos[0] / zoom) - 0.5; - startRectY = Math.round(cursorPos[1] / zoom) - 0.5; + // Saving the start coords of the rect + let cursorPos = getCursorPosition(mouseEvent); + startRectX = Math.floor(cursorPos[0] / zoom) + 0.5; + startRectY = Math.floor(cursorPos[1] / zoom) + 0.5; - drawRectangle(startRectX, startRectY); + drawRectangle(startRectX, startRectY); } function updateRectDrawing(mouseEvent) { - let pos = getCursorPosition(mouseEvent); + let pos = getCursorPosition(mouseEvent); - // Drawing the rect - drawRectangle(Math.round(pos[0] / zoom) + 0.5, Math.round(pos[1] / zoom) + 0.5); + // Drawing the rect + drawRectangle(Math.floor(pos[0] / zoom) + 0.5, Math.floor(pos[1] / zoom) + 0.5); } function endRectDrawing(mouseEvent) { - // Getting the end position - let currentPos = getCursorPosition(mouseEvent); - let vfxContext = VFXCanvas.getContext("2d"); + // Getting the end position + let cursorPos = getCursorPosition(mouseEvent); + let vfxContext = VFXCanvas.getContext('2d'); - endRectX = Math.round(currentPos[0] / zoom) + 0.5; - endRectY = Math.round(currentPos[1] / zoom) + 0.5; + endRectX = Math.floor(cursorPos[0] / zoom) + 0.5; + endRectY = Math.floor(cursorPos[1] / zoom) + 0.5; - // Inverting end and start (start must always be the top left corner) - if (endRectX < startRectX) { - let tmp = endRectX; - endRectX = startRectX; - startRectX = tmp; - } - // Same for the y - if (endRectY < startRectY) { - let tmp = endRectY; - endRectY = startRectY; - startRectY = tmp; - } + // Inverting end and start (start must always be the top left corner) + if (endRectX < startRectX) { + let tmp = endRectX; + endRectX = startRectX; + startRectX = tmp; + } + // Same for the y + if (endRectY < startRectY) { + let tmp = endRectY; + endRectY = startRectY; + startRectY = tmp; + } - let hexColor = hexToRgb(currentLayer.context.fillStyle); + let hexColor = hexToRgb(currentLayer.context.fillStyle); - // Resetting this - isDrawingRect = false; - // Drawing the rect - startRectY -= 0.5; - endRectY -= 0.5; - endRectX -= 0.5; - startRectX -= 0.5; + // Resetting this + isDrawingRect = false; + // Drawing the rect + startRectY -= 0.5; + endRectY -= 0.5; + endRectX -= 0.5; + startRectX -= 0.5; - currentLayer.context.lineWidth = rectangleSize; - currentLayer.context.fillStyle = currentGlobalColor; + currentLayer.context.lineWidth = rectangleSize; + currentLayer.context.fillStyle = currentGlobalColor; - line(startRectX, startRectY, endRectX, startRectY, rectangleSize); - line(endRectX, startRectY, endRectX, endRectY, rectangleSize); - line(endRectX, endRectY, startRectX, endRectY, rectangleSize); - line(startRectX, endRectY, startRectX, startRectY, rectangleSize); + line(startRectX, startRectY, endRectX, startRectY, rectangleSize); + line(endRectX, startRectY, endRectX, endRectY, rectangleSize); + line(endRectX, endRectY, startRectX, endRectY, rectangleSize); + line(startRectX, endRectY, startRectX, startRectY, rectangleSize); - if (drawMode == 'fill') { - currentLayer.context.fillRect(startRectX, startRectY, endRectX - startRectX, endRectY - startRectY); - } + if (drawMode == 'fill') { + currentLayer.context.fillRect(startRectX, startRectY, endRectX - startRectX, endRectY - startRectY); + } - // Clearing the vfx canvas - vfxContext.clearRect(0, 0, VFXCanvas.width, VFXCanvas.height); + // Clearing the vfx canvas + vfxContext.clearRect(0, 0, VFXCanvas.width, VFXCanvas.height); } function drawRectangle(x, y) { - // Getting the vfx context - let vfxContext = VFXCanvas.getContext("2d"); + // Getting the vfx context + let vfxContext = VFXCanvas.getContext('2d'); - // Clearing the vfx canvas - vfxContext.clearRect(0, 0, VFXCanvas.width, VFXCanvas.height); + // Clearing the vfx canvas + vfxContext.clearRect(0, 0, VFXCanvas.width, VFXCanvas.height); - // Drawing the rect - vfxContext.lineWidth = rectangleSize; - vfxContext.strokeStyle = currentGlobalColor; + // Drawing the rect + vfxContext.lineWidth = rectangleSize; + vfxContext.strokeStyle = currentGlobalColor; - // Drawing the rect - vfxContext.beginPath(); - if ((rectangleSize % 2 ) == 0) { - vfxContext.rect(startRectX - 0.5, startRectY - 0.5, x - startRectX, y - startRectY); - } - else { - vfxContext.rect(startRectX, startRectY, x - startRectX, y - startRectY); - } + // Drawing the rect + vfxContext.beginPath(); + if ((rectangleSize % 2 ) == 0) { + vfxContext.rect(startRectX - 0.5, startRectY - 0.5, x - startRectX, y - startRectY); + } + else { + vfxContext.rect(startRectX, startRectY, x - startRectX, y - startRectY); + } - vfxContext.setLineDash([]); + vfxContext.setLineDash([]); - vfxContext.stroke(); + vfxContext.stroke(); } function setRectToolSvg() { - if (drawMode == 'empty') { - emptySVG.setAttribute("display", "visible"); - fullSVG.setAttribute("display", "none"); - } - else { - emptySVG.setAttribute("display", "none"); - fullSVG.setAttribute("display", "visible"); - } + if (drawMode == 'empty') { + emptySVG.setAttribute('display', 'visible'); + fullSVG.setAttribute('display', 'none'); + } + else { + emptySVG.setAttribute('display', 'none'); + fullSVG.setAttribute('display', 'visible'); + } } function applyChanges() { - VFXCanvas.style.zIndex = MIN_Z_INDEX; -} \ No newline at end of file + VFXCanvas.style.zIndex = MIN_Z_INDEX; +} diff --git a/js/_replaceAllOfColor.js b/js/_replaceAllOfColor.js index b6c7b6d..4ae8c44 100644 --- a/js/_replaceAllOfColor.js +++ b/js/_replaceAllOfColor.js @@ -1,25 +1,25 @@ //replaces all of a single color on the canvas with a different color //input two rgb color objects {r:0,g:0,b:0} function replaceAllOfColor (oldColor, newColor) { - - //convert strings to objects if nessesary - if (typeof oldColor === 'string') oldColor = hexToRgb(oldColor); - if (typeof newColor === 'string') newColor = hexToRgb(newColor); - - //create temporary image from canvas to search through - var tempImage = currentLayer.context.getImageData(0, 0, canvasSize[0], canvasSize[1]); - - //loop through all pixels - for (var i=0;i maxXOffset) - canvas.style.left = maxXOffset +'px'; - else - canvas.style.left = offsetLeft +'px'; - - //vertical offset - var minYOffset = -canvasSize[1]*zoom + 164; - var maxYOffset = window.innerHeight-100; - - if (offsetTop < minYOffset) - canvas.style.top = minYOffset +'px'; - else if (offsetTop > maxYOffset) - canvas.style.top = maxYOffset +'px'; - else - canvas.style.top = offsetTop +'px'; -} \ No newline at end of file + //horizontal offset + var minXOffset = -canvasSize[0]*zoom+ 164; + var maxXOffset = window.innerWidth - 148; + + if (offsetLeft < minXOffset) + canvas.style.left = minXOffset +'px'; + else if (offsetLeft > maxXOffset) + canvas.style.left = maxXOffset +'px'; + else + canvas.style.left = offsetLeft +'px'; + + //vertical offset + var minYOffset = -canvasSize[1]*zoom + 164; + var maxYOffset = window.innerHeight-100; + + if (offsetTop < minYOffset) + canvas.style.top = minYOffset +'px'; + else if (offsetTop > maxYOffset) + canvas.style.top = maxYOffset +'px'; + else + canvas.style.top = offsetTop +'px'; +} diff --git a/js/_settings.js b/js/_settings.js index fabcd75..198d3f3 100644 --- a/js/_settings.js +++ b/js/_settings.js @@ -1,45 +1,45 @@ var settings; if (!Cookies.enabled) { - document.getElementById('cookies-disabled-warning').style.display = 'block'; + document.getElementById('cookies-disabled-warning').style.display = 'block'; } //try to load settings from cookie var settingsFromCookie = Cookies.get('pixelEditorSettings'); if(!settingsFromCookie) { - console.log('settings cookie not found') - settings = { - switchToChangedColor: true, - enableDynamicCursorOutline: true, //unused - performance - enableBrushPreview: true, //unused - performance - enableEyedropperPreview: true, //unused - performance - numberOfHistoryStates: 20, - maxColorsOnImportedImage: 128 - }; + console.log('settings cookie not found'); + settings = { + switchToChangedColor: true, + enableDynamicCursorOutline: true, //unused - performance + enableBrushPreview: true, //unused - performance + enableEyedropperPreview: true, //unused - performance + numberOfHistoryStates: 20, + maxColorsOnImportedImage: 128 + }; } else{ - console.log('settings cookie found'); - console.log(settingsFromCookie); - var settings = JSON.parse(settingsFromCookie); + console.log('settings cookie found'); + console.log(settingsFromCookie); + var settings = JSON.parse(settingsFromCookie); } console.log(settings); //on clicking the save button in the settings dialog on('click', 'save-settings', function (){ - - //check if values are valid - if (isNaN(getValue('setting-numberOfHistoryStates'))) { - alert('Invalid value for numberOfHistoryStates') - return; - } - //save new settings to settings object - settings.numberOfHistoryStates = getValue('setting-numberOfHistoryStates'); - - //save settings object to cookie - var cookieValue = JSON.stringify(settings); - Cookies.set('pixelEditorSettings', cookieValue, { expires: Infinity }); - - //close window - closeDialogue(); -}); \ No newline at end of file + //check if values are valid + if (isNaN(getValue('setting-numberOfHistoryStates'))) { + alert('Invalid value for numberOfHistoryStates'); + return; + } + + //save new settings to settings object + settings.numberOfHistoryStates = getValue('setting-numberOfHistoryStates'); + + //save settings object to cookie + var cookieValue = JSON.stringify(settings); + Cookies.set('pixelEditorSettings', cookieValue, { expires: Infinity }); + + //close window + closeDialogue(); +}); diff --git a/js/_toolButtons.js b/js/_toolButtons.js index 6c846d1..f278453 100644 --- a/js/_toolButtons.js +++ b/js/_toolButtons.js @@ -1,39 +1,39 @@ //pencil -on('click',"pencil-button", function(){ +on('click','pencil-button', function(){ changeTool('pencil'); }, false); //pencil bigger -on('click',"pencil-bigger-button", function(){ - brushSize++; +on('click','pencil-bigger-button', function(){ + pencilSize++; updateCursor(); }, false); //pencil smaller -on('click',"pencil-smaller-button", function(){ - if(brushSize > 1) brushSize--; +on('click','pencil-smaller-button', function(){ + if(pencilSize > 1) pencilSize--; updateCursor(); }, false); //eraser -on('click',"eraser-button", function(){ +on('click','eraser-button', function(){ changeTool('eraser'); }, false); //eraser bigger -on('click',"eraser-bigger-button", function(){ +on('click','eraser-bigger-button', function(){ eraserSize++; updateCursor(); }, false); //eraser smaller -on('click',"eraser-smaller-button", function(e){ +on('click','eraser-smaller-button', function(e){ if(eraserSize > 1) eraserSize--; updateCursor(); }, false); // rectangle -on('click',"rectangle-button", function(){ +on('click','rectangle-button', function(){ // If the user clicks twice on the button, they change the draw mode if (currentTool == 'rectangle') { if (drawMode == 'empty') { @@ -51,40 +51,40 @@ on('click',"rectangle-button", function(){ }, false); // rectangle bigger -on('click',"rectangle-bigger-button", function(){ +on('click','rectangle-bigger-button', function(){ rectangleSize++; updateCursor(); }, false); // rectangle smaller -on('click',"rectangle-smaller-button", function(e){ +on('click','rectangle-smaller-button', function(e){ if(rectangleSize > 1) rectangleSize--; updateCursor(); }, false); //fill -on('click',"fill-button", function(){ +on('click','fill-button', function(){ changeTool('fill'); }, false); //pan -on('click',"pan-button", function(){ +on('click','pan-button', function(){ changeTool('pan'); }, false); //eyedropper -on('click',"eyedropper-button", function(){ - changeTool('eyedropper'); +on('click','eyedropper-button', function(){ + changeTool('eyedropper'); }, false); //zoom tool button -on('click',"zoom-button", function(){ - changeTool('zoom'); +on('click','zoom-button', function(){ + changeTool('zoom'); }, false); //zoom in button -on('click',"zoom-in-button", function(){ - //changeZoom('in',[window.innerWidth/2-canvas.offsetLeft,window.innerHeight/2-canvas.offsetTop]); +on('click','zoom-in-button', function(){ + //changeZoom('in',[window.innerWidth/2-canvas.offsetLeft,window.innerHeight/2-canvas.offsetTop]); changeZoom(layers[0],'in', [canvasSize[0] * zoom / 2, canvasSize[1] * zoom / 2]); for (let i=1; i=0.5 0", + "rimraf": "2" + } + }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, + "gauge": { + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", + "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", + "requires": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + } + } + }, + "gaze": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/gaze/-/gaze-1.1.3.tgz", + "integrity": "sha512-BRdNm8hbWzFzWHERTrejLqwHDfS4GibPoq5wjTPIoJHoBtKGPg3xAFfxmM+9ztbXelxcf2hwQcaz1PtmFeue8g==", + "requires": { + "globule": "^1.0.0" + } + }, "get-caller-file": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", @@ -1704,10 +2194,18 @@ "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=" }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "requires": { + "assert-plus": "^1.0.0" + } + }, "glob": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", - "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -1724,16 +2222,6 @@ "requires": { "is-glob": "^3.1.0", "path-dirname": "^1.0.0" - }, - "dependencies": { - "is-glob": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", - "requires": { - "is-extglob": "^2.1.0" - } - } } }, "glob-stream": { @@ -1751,6 +2239,35 @@ "remove-trailing-separator": "^1.0.1", "to-absolute-glob": "^2.0.0", "unique-stream": "^2.0.2" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + } } }, "glob-watcher": { @@ -1788,6 +2305,28 @@ "which": "^1.2.14" } }, + "globby": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", + "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", + "requires": { + "array-union": "^1.0.1", + "glob": "^7.0.3", + "object-assign": "^4.0.1", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" + } + }, + "globule": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/globule/-/globule-1.3.1.tgz", + "integrity": "sha512-OVyWOHgw29yosRHCHo7NncwR1hW5ew0W/UrvtwvjefVJeQ26q4/8r8FmPsSF1hJ93IgWkyv16pCTz6WblMzm/g==", + "requires": { + "glob": "~7.1.1", + "lodash": "~4.17.12", + "minimatch": "~3.0.2" + } + }, "glogg": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/glogg/-/glogg-1.0.2.tgz", @@ -1797,25 +2336,25 @@ } }, "graceful-fs": { - "version": "4.1.15", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", - "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==" + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", + "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==" }, "gulp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/gulp/-/gulp-4.0.0.tgz", - "integrity": "sha1-lXZsYB2t5Kd+0+eyttwDiBtZY2Y=", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/gulp/-/gulp-4.0.2.tgz", + "integrity": "sha512-dvEs27SCZt2ibF29xYgmnwwCYZxdxhQ/+LFWlbAW8y7jt68L/65402Lz3+CKy0Ov4rOs+NERmDq7YlZaDqUIfA==", "requires": { - "glob-watcher": "^5.0.0", - "gulp-cli": "^2.0.0", - "undertaker": "^1.0.0", + "glob-watcher": "^5.0.3", + "gulp-cli": "^2.2.0", + "undertaker": "^1.2.1", "vinyl-fs": "^3.0.0" }, "dependencies": { "gulp-cli": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/gulp-cli/-/gulp-cli-2.1.0.tgz", - "integrity": "sha512-txzgdFVlEPShBZus6JJyGyKJoBVDq6Do0ZQgIgx5RAsmhNVTDjymmOxpQvo3c20m66FldilS68ZXj2Q9w5dKbA==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/gulp-cli/-/gulp-cli-2.2.0.tgz", + "integrity": "sha512-rGs3bVYHdyJpLqR0TUBnlcZ1O5O++Zs4bA0ajm+zr3WFCfiSLjGwoCBqFs18wzN+ZxahT9DkOK5nDf26iDsWjA==", "requires": { "ansi-colors": "^1.0.1", "archy": "^1.0.0", @@ -1839,95 +2378,110 @@ } } }, - "gulp-include": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/gulp-include/-/gulp-include-2.3.1.tgz", - "integrity": "sha1-8eDtPw/QdMNHx+WfnPA409vbPjA=", + "gulp-hb": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/gulp-hb/-/gulp-hb-8.0.0.tgz", + "integrity": "sha512-0tu+rhfm+Q9cUVjCxJMHf5yFwF0CIE6+eRKBA/XV7+CaJJGSkyNQQGvOIdgLPscNrhjJjqcxeKMJ74mkzw5xhg==", "requires": { - "event-stream": "~3.1.0", - "glob": "^5.0.12", - "gulp-util": "~2.2.10", - "source-map": "^0.5.1", + "ansi-gray": "^0.1.1", + "ansi-green": "^0.1.1", + "cli-columns": "^3.1.2", + "handlebars": "^4.1.0", + "handlebars-wax": "^6.1.0", + "plugin-error": "^1.0.1", + "through2": "^3.0.0" + } + }, + "gulp-include": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/gulp-include/-/gulp-include-2.4.1.tgz", + "integrity": "sha512-ARF7H6CD/CCavOcvlLhs6sAY+turxI72Gwp+5X/sMNUha8eJXFloDaZ93nnSKIh0K8VR7b7PURHdXrIhFhQ9gg==", + "requires": { + "ansi-colors": "^3.2.4", + "event-stream": "^4.0.1", + "glob": "^7.1.3", + "plugin-error": "^1.0.1", + "source-map": "^0.7.3", "strip-bom": "^2.0.0", - "vinyl-sourcemaps-apply": "^0.2.0" + "vinyl": "^2.2.0", + "vinyl-sourcemaps-apply": "^0.2.1" }, "dependencies": { - "glob": { - "version": "5.0.15", - "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", - "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", - "requires": { - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "2 || 3", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } + "ansi-colors": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.4.tgz", + "integrity": "sha512-hHUXGagefjN2iRrID63xckIvotOXOojhQKWIPUZ4mNUZ9nLZW+7FMNoE1lOkEhNWYsx/7ysGIuJYCiMAA9FnrA==" + }, + "source-map": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", + "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==" } } }, - "gulp-util": { - "version": "2.2.20", - "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-2.2.20.tgz", - "integrity": "sha1-1xRuVyiRC9jwR6awseVJvCLb1kw=", + "gulp-rename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-2.0.0.tgz", + "integrity": "sha512-97Vba4KBzbYmR5VBs9mWmK+HwIf5mj+/zioxfZhOKeXtx5ZjBk57KFlePf5nxq9QsTtFl0ejnHE3zTC9MHXqyQ==" + }, + "gulp-sass": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/gulp-sass/-/gulp-sass-4.0.2.tgz", + "integrity": "sha512-q8psj4+aDrblJMMtRxihNBdovfzGrXJp1l4JU0Sz4b/Mhsi2DPrKFYCGDwjIWRENs04ELVHxdOJQ7Vs98OFohg==", "requires": { - "chalk": "^0.5.0", - "dateformat": "^1.0.7-1.2.3", - "lodash._reinterpolate": "^2.4.1", - "lodash.template": "^2.4.1", - "minimist": "^0.2.0", - "multipipe": "^0.1.0", - "through2": "^0.5.0", - "vinyl": "^0.2.1" + "chalk": "^2.3.0", + "lodash.clonedeep": "^4.3.2", + "node-sass": "^4.8.3", + "plugin-error": "^1.0.1", + "replace-ext": "^1.0.0", + "strip-ansi": "^4.0.0", + "through2": "^2.0.0", + "vinyl-sourcemaps-apply": "^0.2.0" }, "dependencies": { - "clone-stats": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz", - "integrity": "sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE=" - }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", "requires": { "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" } }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "requires": { + "ansi-regex": "^3.0.0" + } }, "through2": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.5.1.tgz", - "integrity": "sha1-390BLrnHAOIyP9M084rGIqs3Lac=", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", "requires": { - "readable-stream": "~1.0.17", - "xtend": "~3.0.0" + "readable-stream": "~2.3.6", + "xtend": "~4.0.1" } - }, - "vinyl": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.2.3.tgz", - "integrity": "sha1-vKk4IJWC7FpJrVOKAPofEl5RMlI=", - "requires": { - "clone-stats": "~0.0.1" - } - }, - "xtend": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-3.0.0.tgz", - "integrity": "sha1-XM50B7r2Qsunvs2laBEcST9ZZlo=" } } }, @@ -1940,21 +2494,15 @@ } }, "handlebars": { - "version": "4.0.13", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.13.tgz", - "integrity": "sha512-uydY0jy4Z3wy/iGXsi64UtLD4t1fFJe16c/NFxsYE4WdQis8ZCzOXUZaPQNG0e5bgtLQV41QTfqBindhEjnpyQ==", + "version": "4.7.6", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.6.tgz", + "integrity": "sha512-1f2BACcBfiwAfStCKZNrUCgqNZkGsAT7UM3kkYtXuLo0KnaVfjKOyf7PRzB6++aK9STyT1Pd2ZCPe3EGOXleXA==", "requires": { - "async": "^2.5.0", - "optimist": "^0.6.1", + "minimist": "^1.2.5", + "neo-async": "^2.6.0", "source-map": "^0.6.1", - "uglify-js": "^3.1.4" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" - } + "uglify-js": "^3.1.4", + "wordwrap": "^1.0.0" } }, "handlebars-helper-svg": { @@ -1965,25 +2513,58 @@ "resolve": "^1.1.7" } }, - "has-ansi": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-0.1.0.tgz", - "integrity": "sha1-hPJlqujA5qiKEtcCKJS3VoiUxi4=", + "handlebars-wax": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/handlebars-wax/-/handlebars-wax-6.1.0.tgz", + "integrity": "sha1-nZqJnmxnuUbHdCzht9G/WPK6FyI=", "requires": { - "ansi-regex": "^0.2.0" + "object-assign": "^4.1.1", + "require-glob": "^3.2.0" + } + }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" + }, + "har-validator": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", + "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", + "requires": { + "ajv": "^6.5.5", + "har-schema": "^2.0.0" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "requires": { + "ansi-regex": "^2.0.0" }, "dependencies": { "ansi-regex": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz", - "integrity": "sha1-DY6UaWej2BQ/k+JOKYUl/BsiNfk=" + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" } } }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, "has-symbols": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", - "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=" + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==" + }, + "has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" }, "has-value": { "version": "1.0.0", @@ -2014,32 +2595,6 @@ } } }, - "hbs": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/hbs/-/hbs-4.0.3.tgz", - "integrity": "sha512-u8AAbtYUWqNATGEruLdlyAbN+lOtKED+mn38t/13ZkeaKy5BObknFuL1Gtmj0QwXgcSizQ68FHOP1ZST/HP+dg==", - "requires": { - "handlebars": "4.0.13", - "walk": "2.3.9" - } - }, - "hbs-register-helpers": { - "version": "git+https://skeddles@bitbucket.org/skeddles/hbs-register-helpers.git#e1b4688039cdbe7a175902357ffda5679837664c", - "from": "git+https://skeddles@bitbucket.org/skeddles/hbs-register-helpers.git", - "requires": { - "glob": "^7.1.3", - "hbs": "^4.0.3", - "path": "^0.12.7" - } - }, - "hbs-register-partials": { - "version": "git+https://skeddles@bitbucket.org/skeddles/hbs-register-partials.git#7618436ae3ea2d9536bcef3e64027729689f9ad3", - "from": "git+https://skeddles@bitbucket.org/skeddles/hbs-register-partials.git", - "requires": { - "glob": "^7.1.3", - "hbs": "^4.0.3" - } - }, "homedir-polyfill": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", @@ -2049,29 +2604,52 @@ } }, "hosted-git-info": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz", - "integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==" + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", + "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==" }, "http-errors": { - "version": "1.6.3", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", - "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", + "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", "requires": { "depd": "~1.1.2", "inherits": "2.0.3", - "setprototypeof": "1.1.0", - "statuses": ">= 1.4.0 < 2" + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + }, + "dependencies": { + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + } + } + }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" } }, "iconv-lite": { - "version": "0.4.23", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", - "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", "requires": { "safer-buffer": ">= 2.1.2 < 3" } }, + "in-publish": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/in-publish/-/in-publish-2.0.1.tgz", + "integrity": "sha512-oDM0kUSNFC31ShNxHKUyfZKy8ZeXZBWMjMdZHKLOk13uvT27VTL/QzRGfRUcevJhpkZAvlhPYuXkF7eNWrtyxQ==" + }, "indent-string": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", @@ -2090,9 +2668,9 @@ } }, "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "ini": { "version": "1.3.5", @@ -2110,9 +2688,9 @@ "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=" }, "ipaddr.js": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.8.0.tgz", - "integrity": "sha1-6qM9bd16zo9/b+DJygRA5wZzix4=" + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==" }, "is-absolute": { "version": "1.0.0", @@ -2195,9 +2773,12 @@ } }, "is-extendable": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=" + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "requires": { + "is-plain-object": "^2.0.4" + } }, "is-extglob": { "version": "2.1.1", @@ -2205,27 +2786,21 @@ "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=" }, "is-finite": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", - "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", - "requires": { - "number-is-nan": "^1.0.0" - } + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.1.0.tgz", + "integrity": "sha512-cdyMtqX/BOqqNBBiKlIVkytNHm49MtMlYyn1zxzvJKWmFMlGzm+ry5BBfYyeY9YmNKbRSo/o7OX9w9ale0wg3w==" }, "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "requires": { - "number-is-nan": "^1.0.0" - } + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" }, "is-glob": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.0.tgz", - "integrity": "sha1-lSHHaEXMJhCoUgPd8ICpWML/q8A=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", + "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", "requires": { - "is-extglob": "^2.1.1" + "is-extglob": "^2.1.0" } }, "is-negated-glob": { @@ -2267,6 +2842,11 @@ "is-unc-path": "^1.0.0" } }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" + }, "is-unc-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-1.0.0.tgz", @@ -2310,11 +2890,41 @@ "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + }, + "js-base64": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.5.2.tgz", + "integrity": "sha512-Vg8czh0Q7sFBSUMWWArX/miJeBWYBPpdU/3M/DKSaekLMqrqVPaedp+5mZhie/r0lgrcaYBfwXatEew6gwgiQQ==" + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" + }, "json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=" }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" + }, "jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", @@ -2323,15 +2933,26 @@ "graceful-fs": "^4.1.6" } }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + } + }, "just-debounce": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/just-debounce/-/just-debounce-1.0.0.tgz", "integrity": "sha1-h/zPrv/AtozRnVX2cilD+SnqNeo=" }, "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==" }, "last-run": { "version": "1.1.1", @@ -2348,6 +2969,35 @@ "integrity": "sha1-9plf4PggOS9hOWvolGJAe7dxaOQ=", "requires": { "readable-stream": "^2.0.5" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + } } }, "lcid": { @@ -2394,127 +3044,14 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" }, - "lodash._escapehtmlchar": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._escapehtmlchar/-/lodash._escapehtmlchar-2.4.1.tgz", - "integrity": "sha1-32fDu2t+jh6DGrSL+geVuSr+iZ0=", - "requires": { - "lodash._htmlescapes": "~2.4.1" - } - }, - "lodash._escapestringchar": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._escapestringchar/-/lodash._escapestringchar-2.4.1.tgz", - "integrity": "sha1-7P4iYYoq3lC/7qQ5N+Ud9m8O23I=" - }, - "lodash._htmlescapes": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._htmlescapes/-/lodash._htmlescapes-2.4.1.tgz", - "integrity": "sha1-MtFL8IRLbeb4tioFG09nwii2JMs=" - }, - "lodash._isnative": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._isnative/-/lodash._isnative-2.4.1.tgz", - "integrity": "sha1-PqZAS3hKe+g2x7V1gOHN95sUgyw=" - }, - "lodash._objecttypes": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._objecttypes/-/lodash._objecttypes-2.4.1.tgz", - "integrity": "sha1-fAt/admKH3ZSn4kLDNsbTf7BHBE=" - }, - "lodash._reinterpolate": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-2.4.1.tgz", - "integrity": "sha1-TxInqlqHEfxjL1sHofRgequLMiI=" - }, - "lodash._reunescapedhtml": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._reunescapedhtml/-/lodash._reunescapedhtml-2.4.1.tgz", - "integrity": "sha1-dHxPxAED6zu4oJduVx96JlnpO6c=", - "requires": { - "lodash._htmlescapes": "~2.4.1", - "lodash.keys": "~2.4.1" - } - }, - "lodash._shimkeys": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._shimkeys/-/lodash._shimkeys-2.4.1.tgz", - "integrity": "sha1-bpzJZm/wgfC1psl4uD4kLmlJ0gM=", - "requires": { - "lodash._objecttypes": "~2.4.1" - } - }, - "lodash.defaults": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-2.4.1.tgz", - "integrity": "sha1-p+iIXwXmiFEUS24SqPNngCa8TFQ=", - "requires": { - "lodash._objecttypes": "~2.4.1", - "lodash.keys": "~2.4.1" - } - }, - "lodash.escape": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-2.4.1.tgz", - "integrity": "sha1-LOEsXghNsKV92l5dHu659dF1o7Q=", - "requires": { - "lodash._escapehtmlchar": "~2.4.1", - "lodash._reunescapedhtml": "~2.4.1", - "lodash.keys": "~2.4.1" - } - }, - "lodash.isobject": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash.isobject/-/lodash.isobject-2.4.1.tgz", - "integrity": "sha1-Wi5H/mmVPx7mMafrof5k0tBlWPU=", - "requires": { - "lodash._objecttypes": "~2.4.1" - } - }, - "lodash.keys": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-2.4.1.tgz", - "integrity": "sha1-SN6kbfj/djKxDXBrissmWR4rNyc=", - "requires": { - "lodash._isnative": "~2.4.1", - "lodash._shimkeys": "~2.4.1", - "lodash.isobject": "~2.4.1" - } - }, - "lodash.template": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-2.4.1.tgz", - "integrity": "sha1-nmEQB+32KRKal0qzxIuBez4c8g0=", - "requires": { - "lodash._escapestringchar": "~2.4.1", - "lodash._reinterpolate": "~2.4.1", - "lodash.defaults": "~2.4.1", - "lodash.escape": "~2.4.1", - "lodash.keys": "~2.4.1", - "lodash.templatesettings": "~2.4.1", - "lodash.values": "~2.4.1" - } - }, - "lodash.templatesettings": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz", - "integrity": "sha1-6nbHXRHrhtTb6JqDiTu4YZKaxpk=", - "requires": { - "lodash._reinterpolate": "~2.4.1", - "lodash.escape": "~2.4.1" - } - }, - "lodash.values": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash.values/-/lodash.values-2.4.1.tgz", - "integrity": "sha1-q/UUQ2s8twUAFieXjLzzCxKA7qQ=", - "requires": { - "lodash.keys": "~2.4.1" - } + "lodash.clonedeep": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=" }, "loud-rejection": { "version": "1.6.0", @@ -2525,12 +3062,21 @@ "signal-exit": "^3.0.0" } }, - "ltx": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/ltx/-/ltx-2.8.1.tgz", - "integrity": "sha512-l4H1FS9I6IVqwvIpUHsSgyxE6t2jP7qd/2MeVG1UhmVK6vlHsQpfm2KNUcbdImeE0ai04vl1qTCF4CPCJqhknQ==", + "lru-cache": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", "requires": { - "inherits": "^2.0.1" + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + } + }, + "ltx": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/ltx/-/ltx-2.9.2.tgz", + "integrity": "sha512-llB7HflFhlfsYYT1SAe80elCBO5C20ryLdwPB/A/BZk38hhVeZztDlWQ9uTyvKNPX4aK6sA+JfS1f/mfzp5cxA==", + "requires": { + "inherits": "^2.0.4" } }, "make-iterator": { @@ -2552,9 +3098,9 @@ "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=" }, "map-stream": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", - "integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=" + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.0.7.tgz", + "integrity": "sha1-ih8HiW2CsQkmvTdEokIACfiJdKg=" }, "map-visit": { "version": "1.0.0", @@ -2585,14 +3131,6 @@ "micromatch": "^3.0.4", "resolve-dir": "^1.0.1" } - }, - "is-glob": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", - "requires": { - "is-extglob": "^2.1.0" - } } } }, @@ -2616,13 +3154,6 @@ "read-pkg-up": "^1.0.1", "redent": "^1.0.0", "trim-newlines": "^1.0.0" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - } } }, "merge-descriptors": { @@ -2656,21 +3187,21 @@ } }, "mime": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", - "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" }, "mime-db": { - "version": "1.38.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.38.0.tgz", - "integrity": "sha512-bqVioMFFzc2awcdJZIzR3HjZFX20QhilVS7hytkKrv7xFAn8bM1gzc/FOX2awLISvWe0PV8ptFKcon+wZ5qYkg==" + "version": "1.43.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz", + "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==" }, "mime-types": { - "version": "2.1.22", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.22.tgz", - "integrity": "sha512-aGl6TZGnhm/li6F7yx82bJiBZwgiEa4Hf6CNr8YO+r5UHr53tSTYZb102zyU50DOWWKeOv0uQLRL0/9EiKWCog==", + "version": "2.1.26", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz", + "integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==", "requires": { - "mime-db": "~1.38.0" + "mime-db": "1.43.0" } }, "minimatch": { @@ -2682,27 +3213,25 @@ } }, "minimist": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.2.0.tgz", - "integrity": "sha1-Tf/lJdriuGTGbC4jxicdev3s784=" + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" }, "mixin-deep": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", - "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", + "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", "requires": { "for-in": "^1.0.2", "is-extendable": "^1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "requires": { - "is-plain-object": "^2.0.4" - } - } + } + }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "requires": { + "minimist": "^1.2.5" } }, "ms": { @@ -2710,24 +3239,15 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, - "multipipe": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz", - "integrity": "sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s=", - "requires": { - "duplexer2": "0.0.2" - } - }, "mute-stdout": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mute-stdout/-/mute-stdout-1.0.1.tgz", "integrity": "sha512-kDcwXR4PS7caBpuRYYBUz9iVixUk3anO3f5OYFiIPwK/20vCzKCHyKoulbiDY1S53zD2bxUpxN/IJ+TnXjfvxg==" }, "nan": { - "version": "2.13.2", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.13.2.tgz", - "integrity": "sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw==", - "optional": true + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==" }, "nanomatch": { "version": "1.2.13", @@ -2748,15 +3268,102 @@ } }, "negotiator": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", - "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", + "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" + }, + "neo-async": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz", + "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==" }, "next-tick": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=" }, + "node-gyp": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-3.8.0.tgz", + "integrity": "sha512-3g8lYefrRRzvGeSowdJKAKyks8oUpLEd/DyPV4eMhVlhJ0aNaZqIrNUIPuEWWTAoPqyFkfGrM67MC69baqn6vA==", + "requires": { + "fstream": "^1.0.0", + "glob": "^7.0.3", + "graceful-fs": "^4.1.2", + "mkdirp": "^0.5.0", + "nopt": "2 || 3", + "npmlog": "0 || 1 || 2 || 3 || 4", + "osenv": "0", + "request": "^2.87.0", + "rimraf": "2", + "semver": "~5.3.0", + "tar": "^2.0.0", + "which": "1" + }, + "dependencies": { + "semver": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", + "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=" + } + } + }, + "node-sass": { + "version": "4.13.1", + "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.13.1.tgz", + "integrity": "sha512-TTWFx+ZhyDx1Biiez2nB0L3YrCZ/8oHagaDalbuBSlqXgUPsdkUSzJsVxeDO9LtPB49+Fh3WQl3slABo6AotNw==", + "requires": { + "async-foreach": "^0.1.3", + "chalk": "^1.1.1", + "cross-spawn": "^3.0.0", + "gaze": "^1.0.0", + "get-stdin": "^4.0.1", + "glob": "^7.0.3", + "in-publish": "^2.0.0", + "lodash": "^4.17.15", + "meow": "^3.7.0", + "mkdirp": "^0.5.1", + "nan": "^2.13.2", + "node-gyp": "^3.8.0", + "npmlog": "^4.0.0", + "request": "^2.88.0", + "sass-graph": "^2.2.4", + "stdout-stream": "^1.4.0", + "true-case-path": "^1.0.2" + }, + "dependencies": { + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" + } + } + }, + "nopt": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "requires": { + "abbrev": "1" + } + }, "normalize-package-data": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", @@ -2777,18 +3384,34 @@ } }, "now-and-later": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/now-and-later/-/now-and-later-2.0.0.tgz", - "integrity": "sha1-vGHLtFbXnLMiB85HygUTb/Ln1u4=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/now-and-later/-/now-and-later-2.0.1.tgz", + "integrity": "sha512-KGvQ0cB70AQfg107Xvs/Fbu+dGmZoTRJp2TaPwcwQm3/7PteUyN2BCgk8KBMPGBUXZdVwyWS8fDCGFygBm19UQ==", "requires": { "once": "^1.3.2" } }, + "npmlog": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", + "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", + "requires": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" + } + }, "number-is-nan": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" + }, "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -2823,9 +3446,9 @@ } }, "object-keys": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.0.tgz", - "integrity": "sha512-6OO5X1+2tYkNyNEx6TsCxEqFfRWaqx6EtMiSbGrw8Ob8v9Ne+Hl8rBAgLBZn5wjEz3s/s6U1WXFUFOcxxAwUpg==" + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==" }, "object-visit": { "version": "1.0.1", @@ -2899,38 +3522,56 @@ "wrappy": "1" } }, - "opn": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/opn/-/opn-6.0.0.tgz", - "integrity": "sha512-I9PKfIZC+e4RXZ/qr1RhgyCnGgYX0UEIlXgWnCOVACIvFgaC9rz6Won7xbdhoHrd8IIhV7YEpHjreNUNkqCGkQ==", + "open": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/open/-/open-6.4.0.tgz", + "integrity": "sha512-IFenVPgF70fSm1keSd2iDBIDIBZkroLeuffXq+wKTzTJlBpesFWojV9lb8mzOfaAzM1sr7HQHuO0vtV0zYekGg==", "requires": { "is-wsl": "^1.1.0" } }, - "optimist": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", - "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", - "requires": { - "minimist": "~0.0.1", - "wordwrap": "~0.0.2" - }, - "dependencies": { - "minimist": { - "version": "0.0.10", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", - "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=" - } - } - }, "ordered-read-streams": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-1.0.1.tgz", "integrity": "sha1-d8DLN8QVJdZBZtmQ/61+xqDhNj4=", "requires": { "readable-stream": "^2.0.1" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + } } }, + "os-homedir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=" + }, "os-locale": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", @@ -2939,6 +3580,28 @@ "lcid": "^1.0.0" } }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" + }, + "osenv": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", + "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", + "requires": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" + } + }, + "parent-module": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-0.1.0.tgz", + "integrity": "sha1-tSkoY6HoxHbs+Ffn11yYkgskuKY=", + "requires": { + "callsites": "^1.0.0" + } + }, "parse-filepath": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.2.tgz", @@ -2968,24 +3631,15 @@ "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=" }, "parseurl": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", - "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" }, "pascalcase": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=" }, - "path": { - "version": "0.12.7", - "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", - "integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=", - "requires": { - "process": "^0.11.1", - "util": "^0.10.3" - } - }, "path-dirname": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", @@ -3045,6 +3699,11 @@ "through": "~2.3" } }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" + }, "pify": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", @@ -3063,6 +3722,17 @@ "pinkie": "^2.0.0" } }, + "plugin-error": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-1.0.1.tgz", + "integrity": "sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==", + "requires": { + "ansi-colors": "^1.0.1", + "arr-diff": "^4.0.0", + "arr-union": "^3.1.0", + "extend-shallow": "^3.0.2" + } + }, "posix-character-classes": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", @@ -3073,25 +3743,30 @@ "resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=" }, - "process": { - "version": "0.11.10", - "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=" - }, "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" }, "proxy-addr": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.4.tgz", - "integrity": "sha512-5erio2h9jp5CHGwcybmxmVqHmnCBZeewlfJ0pex+UW7Qny7OOZXTtH56TGNyBizkgiOwhJtMKrVzDTeKcySZwA==", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz", + "integrity": "sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw==", "requires": { "forwarded": "~0.1.2", - "ipaddr.js": "1.8.0" + "ipaddr.js": "1.9.1" } }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" + }, + "psl": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", + "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==" + }, "pump": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", @@ -3111,24 +3786,29 @@ "pump": "^2.0.0" } }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" + }, "qs": { "version": "6.5.2", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" }, "range-parser": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", - "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" }, "raw-body": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.3.tgz", - "integrity": "sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", + "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", "requires": { - "bytes": "3.0.0", - "http-errors": "1.6.3", - "iconv-lite": "0.4.23", + "bytes": "3.1.0", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", "unpipe": "1.0.0" } }, @@ -3152,24 +3832,13 @@ } }, "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - }, - "dependencies": { - "process-nextick-args": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" - } + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" } }, "readdirp": { @@ -3180,6 +3849,35 @@ "graceful-fs": "^4.1.11", "micromatch": "^3.1.10", "readable-stream": "^2.0.2" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + } } }, "rechoir": { @@ -3225,6 +3923,53 @@ "remove-bom-buffer": "^3.0.0", "safe-buffer": "^5.1.0", "through2": "^2.0.3" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + } + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + } + } + }, + "through2": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", + "requires": { + "readable-stream": "~2.3.6", + "xtend": "~4.0.1" + } + } } }, "remove-trailing-separator": { @@ -3265,20 +4010,57 @@ "remove-trailing-separator": "^1.1.0" } }, + "request": { + "version": "2.88.2", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", + "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.3", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.5.0", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + } + }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" }, + "require-glob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/require-glob/-/require-glob-3.2.0.tgz", + "integrity": "sha1-kL/iyO+0ufly65o/XlgIMuBPZNM=", + "requires": { + "glob-parent": "^3.0.0", + "globby": "^6.0.0", + "parent-module": "^0.1.0" + } + }, "require-main-filename": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=" }, "resolve": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.0.tgz", - "integrity": "sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg==", + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.1.tgz", + "integrity": "sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w==", "requires": { "path-parse": "^1.0.6" } @@ -3310,10 +4092,18 @@ "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==" }, + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "requires": { + "glob": "^7.1.3" + } + }, "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", + "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==" }, "safe-regex": { "version": "1.1.0", @@ -3329,17 +4119,47 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "sass": { - "version": "1.17.3", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.17.3.tgz", - "integrity": "sha512-S4vJawbrNUxJUBiHLXPYUKZCoO6cvq3/3ZFBV66a+PafTxcDEFJB+FHLDFl0P+rUfha/703ajEXMuGTYhJESkQ==", + "version": "1.26.3", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.26.3.tgz", + "integrity": "sha512-5NMHI1+YFYw4sN3yfKjpLuV9B5l7MqQ6FlkTcC4FT+oHbBRUZoSjHrrt/mE0nFXJyY2kQtU9ou9HxvFVjLFuuw==", "requires": { - "chokidar": "^2.0.0" + "chokidar": ">=2.0.0 <4.0.0" + } + }, + "sass-graph": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/sass-graph/-/sass-graph-2.2.4.tgz", + "integrity": "sha1-E/vWPNHK8JCLn9k0dq1DpR0eC0k=", + "requires": { + "glob": "^7.0.0", + "lodash": "^4.0.0", + "scss-tokenizer": "^0.2.3", + "yargs": "^7.0.0" + } + }, + "scss-tokenizer": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/scss-tokenizer/-/scss-tokenizer-0.2.3.tgz", + "integrity": "sha1-jrBtualyMzOCTT9VMGQRSYR85dE=", + "requires": { + "js-base64": "^2.1.8", + "source-map": "^0.4.2" + }, + "dependencies": { + "source-map": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", + "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", + "requires": { + "amdefine": ">=0.0.4" + } + } } }, "semver": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", - "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==" + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" }, "semver-greatest-satisfied-range": { "version": "1.1.0", @@ -3350,9 +4170,9 @@ } }, "send": { - "version": "0.16.2", - "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", - "integrity": "sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw==", + "version": "0.17.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", + "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", "requires": { "debug": "2.6.9", "depd": "~1.1.2", @@ -3361,23 +4181,30 @@ "escape-html": "~1.0.3", "etag": "~1.8.1", "fresh": "0.5.2", - "http-errors": "~1.6.2", - "mime": "1.4.1", - "ms": "2.0.0", + "http-errors": "~1.7.2", + "mime": "1.6.0", + "ms": "2.1.1", "on-finished": "~2.3.0", - "range-parser": "~1.2.0", - "statuses": "~1.4.0" + "range-parser": "~1.2.1", + "statuses": "~1.5.0" + }, + "dependencies": { + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + } } }, "serve-static": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz", - "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", + "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", "requires": { "encodeurl": "~1.0.2", "escape-html": "~1.0.3", - "parseurl": "~1.3.2", - "send": "0.16.2" + "parseurl": "~1.3.3", + "send": "0.17.1" } }, "set-blocking": { @@ -3386,9 +4213,9 @@ "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" }, "set-value": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", - "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", + "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", "requires": { "extend-shallow": "^2.0.1", "is-extendable": "^0.1.1", @@ -3403,18 +4230,23 @@ "requires": { "is-extendable": "^0.1.0" } + }, + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=" } } }, "setprototypeof": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", - "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" }, "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", + "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==" }, "snapdragon": { "version": "0.8.2", @@ -3446,6 +4278,16 @@ "requires": { "is-extendable": "^0.1.0" } + }, + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=" + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" } } }, @@ -3514,16 +4356,16 @@ } }, "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" }, "source-map-resolve": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", - "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz", + "integrity": "sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw==", "requires": { - "atob": "^2.1.1", + "atob": "^2.1.2", "decode-uri-component": "^0.2.0", "resolve-url": "^0.2.1", "source-map-url": "^0.4.0", @@ -3564,14 +4406,14 @@ } }, "spdx-license-ids": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.3.tgz", - "integrity": "sha512-uBIcIl3Ih6Phe3XHK1NqboJLdGfwr1UN3k6wSD1dZpmPsIkb8AGNbZYJ1fOBk834+Gxy8rpfDxrS6XLEMZMY2g==" + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.5.tgz", + "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==" }, "split": { - "version": "0.2.10", - "resolved": "https://registry.npmjs.org/split/-/split-0.2.10.tgz", - "integrity": "sha1-Zwl8YB1pfOE2j0GPBs0gHPBSGlc=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", + "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", "requires": { "through": "2" } @@ -3584,6 +4426,22 @@ "extend-shallow": "^3.0.0" } }, + "sshpk": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", + "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + } + }, "stack-trace": { "version": "0.0.10", "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", @@ -3609,16 +4467,54 @@ } }, "statuses": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", - "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" + }, + "stdout-stream": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/stdout-stream/-/stdout-stream-1.4.1.tgz", + "integrity": "sha512-j4emi03KXqJWcIeF8eIXkjMFN1Cmb8gUlDYGeBALLPo5qdyTfA9bOtl8m33lRoC+vFMkP3gl0WsDr6+gzxbbTA==", + "requires": { + "readable-stream": "^2.0.1" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + } + } }, "stream-combiner": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz", - "integrity": "sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ=", + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.2.2.tgz", + "integrity": "sha1-rsjLrBd7Vrb0+kec7YwZEs7lKFg=", "requires": { - "duplexer": "~0.1.1" + "duplexer": "~0.1.1", + "through": "~2.3.4" } }, "stream-exhaust": { @@ -3627,26 +4523,35 @@ "integrity": "sha512-b/qaq/GlBK5xaq1yrK9/zFcyRSTNxmcZwFLGSTG0mXgZl/4Z6GgiyYOXOvY7N3eEvFRAG1bkDRz5EPGSvPYQlw==" }, "stream-shift": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz", - "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=" + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz", + "integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==" }, "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + }, + "dependencies": { + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "requires": { + "ansi-regex": "^3.0.0" + } + } } }, "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", "requires": { - "safe-buffer": "~5.1.0" + "safe-buffer": "~5.2.0" } }, "strip-ansi": { @@ -3655,6 +4560,13 @@ "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "requires": { "ansi-regex": "^2.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + } } }, "strip-bom": { @@ -3674,9 +4586,12 @@ } }, "supports-color": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz", - "integrity": "sha1-2S3iaU6z9nMjlz1649i1W0wiGQo=" + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } }, "sver-compat": { "version": "1.5.0", @@ -3687,18 +4602,27 @@ "es6-symbol": "^3.1.1" } }, + "tar": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.2.tgz", + "integrity": "sha512-FCEhQ/4rE1zYv9rYXJw/msRqsnmlje5jHP6huWeBZ704jUTy02c5AZyWujpMR1ax6mVw9NyJMfuK2CMDWVIfgA==", + "requires": { + "block-stream": "*", + "fstream": "^1.0.12", + "inherits": "2" + } + }, "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" }, "through2": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", - "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/through2/-/through2-3.0.1.tgz", + "integrity": "sha512-M96dvTalPT3YbYLaKaCuwu+j06D/8Jfib0o/PxbVt6Amhv3dUAtW6rTV1jPgJSBG83I/e04Y6xkVdVhSRhi0ww==", "requires": { - "readable-stream": "~2.3.6", - "xtend": "~4.0.1" + "readable-stream": "2 || 3" } }, "through2-filter": { @@ -3708,6 +4632,44 @@ "requires": { "through2": "~2.0.0", "xtend": "~4.0.0" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "through2": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", + "requires": { + "readable-stream": "~2.3.6", + "xtend": "~4.0.1" + } + } } }, "time-stamp": { @@ -3768,6 +4730,58 @@ "integrity": "sha1-/JKtq6ByZHvAtn1rA2ZKoZUJOvY=", "requires": { "through2": "^2.0.3" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "through2": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", + "requires": { + "readable-stream": "~2.3.6", + "xtend": "~4.0.1" + } + } + } + }, + "toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" + }, + "tough-cookie": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", + "requires": { + "psl": "^1.1.28", + "punycode": "^2.1.1" } }, "trim-newlines": { @@ -3775,13 +4789,39 @@ "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=" }, + "true-case-path": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/true-case-path/-/true-case-path-1.0.3.tgz", + "integrity": "sha512-m6s2OdQe5wgpFMC+pAJ+q9djG82O2jcHPOI6RNg1yy9rCYR+WD6Nbpl32fDpfC56nirdRy+opFa/Vk7HYhqaew==", + "requires": { + "glob": "^7.1.2" + } + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" + }, + "type": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", + "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" + }, "type-is": { - "version": "1.6.16", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", - "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", "requires": { "media-typer": "0.3.0", - "mime-types": "~2.1.18" + "mime-types": "~2.1.24" } }, "typedarray": { @@ -3790,21 +4830,13 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" }, "uglify-js": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.2.tgz", - "integrity": "sha512-imog1WIsi9Yb56yRt5TfYVxGmnWs3WSGU73ieSOlMVFwhJCA9W8fqFFMMj4kgDqiS/80LGdsYnWL7O9UcjEBlg==", + "version": "3.8.1", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.8.1.tgz", + "integrity": "sha512-W7KxyzeaQmZvUFbGj4+YFshhVrMBGSg2IbcYAjGWGvx8DHvJMclbTDMpffdxFUGPBHjIytk7KJUR/KUXstUGDw==", "optional": true, "requires": { - "commander": "~2.19.0", + "commander": "~2.20.3", "source-map": "~0.6.1" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "optional": true - } } }, "unc-path-regex": { @@ -3813,9 +4845,9 @@ "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=" }, "undertaker": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/undertaker/-/undertaker-1.2.0.tgz", - "integrity": "sha1-M52kZGJS0ILcN45wgGcpl1DhG0k=", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/undertaker/-/undertaker-1.2.1.tgz", + "integrity": "sha512-71WxIzDkgYk9ZS+spIB8iZXchFhAdEo2YU8xYqBYJ39DIUIqziK78ftm26eecoIY49X0J2MLhG4hr18Yp6/CMA==", "requires": { "arr-flatten": "^1.0.1", "arr-map": "^2.0.0", @@ -3834,34 +4866,20 @@ "integrity": "sha1-XkvaMI5KiirlhPm5pDWaSZglzFA=" }, "union-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", - "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", + "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", "requires": { "arr-union": "^3.1.0", "get-value": "^2.0.6", "is-extendable": "^0.1.1", - "set-value": "^0.4.3" + "set-value": "^2.0.1" }, "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "requires": { - "is-extendable": "^0.1.0" - } - }, - "set-value": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", - "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", - "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.1", - "to-object-path": "^0.3.0" - } + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=" } } }, @@ -3921,9 +4939,17 @@ } }, "upath": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/upath/-/upath-1.1.2.tgz", - "integrity": "sha512-kXpym8nmDmlCBr7nKdIx8P2jNBa+pBpIUFRnKJ4dr8htyYGJFokkr2ZvERRtUN+9SY+JqXouNgUPtv6JQva/2Q==" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz", + "integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==" + }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "requires": { + "punycode": "^2.1.0" + } }, "urix": { "version": "0.1.0", @@ -3935,14 +4961,6 @@ "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==" }, - "util": { - "version": "0.10.4", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", - "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", - "requires": { - "inherits": "2.0.3" - } - }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -3953,10 +4971,15 @@ "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" }, + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" + }, "v8flags": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.1.2.tgz", - "integrity": "sha512-MtivA7GF24yMPte9Rp/BWGCYQNaUj86zeYxV/x2RRJMKagImbbv3u8iJC57lNhWLPcGLJmHcHmFWkNsplbbLWw==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.1.3.tgz", + "integrity": "sha512-amh9CCg3ZxkzQ48Mhcb8iX7xpAfYJgePHxWMQCBWECpOSqJUXgY26ncA61UTV0BkPqfhcy6mzwCIoP4ygxpW8w==", "requires": { "homedir-polyfill": "^1.0.1" } @@ -3980,6 +5003,16 @@ "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "requires": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } + }, "vinyl": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.0.tgz", @@ -4015,6 +5048,44 @@ "value-or-function": "^3.0.0", "vinyl": "^2.0.0", "vinyl-sourcemap": "^1.1.0" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "through2": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", + "requires": { + "readable-stream": "~2.3.6", + "xtend": "~4.0.1" + } + } } }, "vinyl-sourcemap": { @@ -4037,14 +5108,13 @@ "integrity": "sha1-q2VJ1h0XLCsbh75cUI0jnI74dwU=", "requires": { "source-map": "^0.5.1" - } - }, - "walk": { - "version": "2.3.9", - "resolved": "https://registry.npmjs.org/walk/-/walk-2.3.9.tgz", - "integrity": "sha1-MbTbZnjyrgHDnqn7hyWpAx5Vins=", - "requires": { - "foreachasync": "^3.0.0" + }, + "dependencies": { + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" + } } }, "which": { @@ -4060,10 +5130,18 @@ "resolved": "https://registry.npmjs.org/which-module/-/which-module-1.0.0.tgz", "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=" }, + "wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "requires": { + "string-width": "^1.0.2 || 2" + } + }, "wordwrap": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", - "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=" + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=" }, "wrap-ansi": { "version": "2.1.0", @@ -4072,6 +5150,26 @@ "requires": { "string-width": "^1.0.1", "strip-ansi": "^3.0.1" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + } } }, "wrappy": { @@ -4080,15 +5178,20 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" }, "y18n": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=" }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=" + }, "yargs": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-7.1.0.tgz", @@ -4107,6 +5210,31 @@ "which-module": "^1.0.0", "y18n": "^3.2.1", "yargs-parser": "^5.0.0" + }, + "dependencies": { + "camelcase": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", + "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=" + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + } } }, "yargs-parser": { @@ -4115,6 +5243,13 @@ "integrity": "sha1-J17PDX/+Bcd+ZOfIbkzZS/DhIoo=", "requires": { "camelcase": "^3.0.0" + }, + "dependencies": { + "camelcase": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", + "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=" + } } } } diff --git a/package.json b/package.json index c2251a6..98a7f48 100644 --- a/package.json +++ b/package.json @@ -4,21 +4,22 @@ "description": "Online pixel art creation tool", "main": "build.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "build": "node ./build.js ./build", + "serve": "node ./server.js ./build 3000", + "test": "npm run build && npm run serve" }, "author": "Lospec", "license": "ISC", "dependencies": { "express": "^4.16.4", "fs-extra": "^7.0.1", - "glob": "^7.1.3", - "gulp": "^4.0.0", + "gulp": "^4.0.2", + "gulp-hb": "^8.0.0", "gulp-include": "^2.3.1", + "gulp-rename": "^2.0.0", + "gulp-sass": "^4.0.2", "handlebars-helper-svg": "git+https://bitbucket.org/skeddles/npm-handlebars-helper-svg-lospec-open-source.git", - "hbs": "^4.0.3", - "hbs-register-helpers": "git+https://skeddles@bitbucket.org/skeddles/hbs-register-helpers.git", - "hbs-register-partials": "git+https://skeddles@bitbucket.org/skeddles/hbs-register-partials.git", - "opn": "^6.0.0", + "open": "^6.0.0", "sass": "^1.17.3" } } diff --git a/server.js b/server.js new file mode 100644 index 0000000..465a0ae --- /dev/null +++ b/server.js @@ -0,0 +1,37 @@ +const path = require('path'); +const express = require('express'); + +const app = express(); + +const BUILDDIR = process.argv[2] || './build'; +const PORT = process.argv[3] || 3000; + +//ROUTE - index.htm +app.get('/', (req, res) => { + res.sendFile(path.join(__dirname, BUILDDIR, 'index.htm'), {}, function (err) { + if(err){ + console.log('error sending file',err); + } else { + setTimeout(()=>{ + console.log('closing server'); + server.close(); + process.exit(); + },1000*10); + } + }); +}); + +//ROUTE - other files +app.use(express.static(path.join(__dirname, BUILDDIR))); + +//start server +var server = app.listen(PORT, () => { + console.log(`\nTemp server started at http://localhost:${PORT}!`); + //console.log('press ctrl+c to stop '); + + var opn = require('open'); + + // opens the url in the default browser + opn(`http://localhost:${PORT}`); +}); +