├── .babelrc ├── .bowerrc ├── src ├── info.js ├── images │ ├── alpha.png │ ├── hue.png │ ├── saturation.png │ └── transparent.png ├── i18n │ ├── cn.js │ ├── ja.js │ ├── de.js │ ├── dk.js │ ├── es.js │ ├── fi.js │ ├── fr.js │ ├── it.js │ ├── ru.js │ ├── sv.js │ └── tr.js ├── components │ ├── clear.js │ ├── hex.js │ ├── trigger.js │ ├── buttons.js │ ├── preview.js │ ├── info.js │ ├── palettes.js │ ├── saturation.js │ ├── hue.js │ ├── alpha.js │ └── gradient.js ├── modes.js ├── defaults.js ├── keyboard.js ├── main.js ├── scss │ └── asColorPicker.scss └── asColorPicker.js ├── .stylelintrc.json ├── examples ├── demo.gif ├── css │ ├── prism.css │ ├── main.css │ └── normalize.css ├── js │ ├── prism.js │ └── jquery.toc.js └── index.html ├── dist ├── images │ ├── hue.png │ ├── alpha.png │ ├── saturation.png │ └── transparent.png └── css │ ├── asColorPicker.min.css │ └── asColorPicker.css ├── manifest.json ├── .travis.yml ├── gulp ├── tasks │ ├── clean.js │ ├── test.js │ ├── archive.js │ ├── lint-styles.js │ ├── images.js │ ├── release.js │ ├── lint-scripts.js │ ├── browser.js │ ├── assets.js │ ├── styles.js │ ├── deploy.js │ └── scripts.js └── util │ ├── getFolders.js │ ├── getSrcFiles.js │ └── handleErrors.js ├── .release.json ├── .npmignore ├── .github ├── PULL_REQUEST_TEMPLATE.md └── ISSUE_TEMPLATE.md ├── .editorconfig ├── bower.json ├── .gitattributes ├── .gitignore ├── config.js ├── karma.conf.js ├── package.json ├── gulpfile.babel.js ├── CONTRIBUTING.md ├── LICENSE ├── .eslintrc.json ├── .csscomb.json └── README.md /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015"] 3 | } 4 | -------------------------------------------------------------------------------- /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "bower_components" 3 | } 4 | -------------------------------------------------------------------------------- /src/info.js: -------------------------------------------------------------------------------- 1 | export default { 2 | version:'0.4.4' 3 | }; 4 | -------------------------------------------------------------------------------- /.stylelintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "stylelint-config-bootstrap" 3 | } 4 | -------------------------------------------------------------------------------- /examples/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecreation/jquery-asColorPicker/HEAD/examples/demo.gif -------------------------------------------------------------------------------- /dist/images/hue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecreation/jquery-asColorPicker/HEAD/dist/images/hue.png -------------------------------------------------------------------------------- /src/images/alpha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecreation/jquery-asColorPicker/HEAD/src/images/alpha.png -------------------------------------------------------------------------------- /src/images/hue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecreation/jquery-asColorPicker/HEAD/src/images/hue.png -------------------------------------------------------------------------------- /dist/images/alpha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecreation/jquery-asColorPicker/HEAD/dist/images/alpha.png -------------------------------------------------------------------------------- /src/images/saturation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecreation/jquery-asColorPicker/HEAD/src/images/saturation.png -------------------------------------------------------------------------------- /dist/images/saturation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecreation/jquery-asColorPicker/HEAD/dist/images/saturation.png -------------------------------------------------------------------------------- /dist/images/transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecreation/jquery-asColorPicker/HEAD/dist/images/transparent.png -------------------------------------------------------------------------------- /src/images/transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecreation/jquery-asColorPicker/HEAD/src/images/transparent.png -------------------------------------------------------------------------------- /src/i18n/cn.js: -------------------------------------------------------------------------------- 1 | import AsColorPicker from '../asColorPicker'; 2 | 3 | // Chinese (cn) localization 4 | AsColorPicker.setLocalization('cn', { 5 | cancelText: "取消", 6 | applyText: "应用" 7 | }); 8 | -------------------------------------------------------------------------------- /src/i18n/ja.js: -------------------------------------------------------------------------------- 1 | import AsColorPicker from '../asColorPicker'; 2 | 3 | // Japanese (ja) localization 4 | AsColorPicker.setLocalization('ja', { 5 | cancelText: "中止", 6 | applyText: "選択" 7 | }); 8 | -------------------------------------------------------------------------------- /src/i18n/de.js: -------------------------------------------------------------------------------- 1 | import AsColorPicker from '../asColorPicker'; 2 | 3 | // German (de) localization 4 | AsColorPicker.setLocalization('de', { 5 | cancelText: "Abbrechen", 6 | applyText: "Wählen" 7 | }); 8 | -------------------------------------------------------------------------------- /src/i18n/dk.js: -------------------------------------------------------------------------------- 1 | import AsColorPicker from '../asColorPicker'; 2 | 3 | // Danish (dk) localization 4 | AsColorPicker.setLocalization('dk', { 5 | cancelText: "annuller", 6 | applyText: "Vælg" 7 | }); 8 | -------------------------------------------------------------------------------- /src/i18n/es.js: -------------------------------------------------------------------------------- 1 | import AsColorPicker from '../asColorPicker'; 2 | 3 | // Spanish (es) localization 4 | AsColorPicker.setLocalization('es', { 5 | cancelText: "Cancelar", 6 | applyText: "Elegir" 7 | }); 8 | -------------------------------------------------------------------------------- /src/i18n/fi.js: -------------------------------------------------------------------------------- 1 | import AsColorPicker from '../asColorPicker'; 2 | 3 | // Finnish (fi) localization 4 | AsColorPicker.setLocalization('fi', { 5 | cancelText: "Kumoa", 6 | applyText: "Valitse" 7 | }); 8 | -------------------------------------------------------------------------------- /src/i18n/fr.js: -------------------------------------------------------------------------------- 1 | import AsColorPicker from '../asColorPicker'; 2 | 3 | // French (fr) localization 4 | AsColorPicker.setLocalization('fr', { 5 | cancelText: "Annuler", 6 | applyText: "Valider" 7 | }); 8 | -------------------------------------------------------------------------------- /src/i18n/it.js: -------------------------------------------------------------------------------- 1 | import AsColorPicker from '../asColorPicker'; 2 | 3 | // Italian (it) localization 4 | AsColorPicker.setLocalization('it', { 5 | cancelText: "annulla", 6 | applyText: "scegli" 7 | }); 8 | -------------------------------------------------------------------------------- /src/i18n/ru.js: -------------------------------------------------------------------------------- 1 | import AsColorPicker from '../asColorPicker'; 2 | 3 | // Russian (ru) localization 4 | AsColorPicker.setLocalization('ru', { 5 | cancelText: "отмена", 6 | applyText: "выбрать" 7 | }); 8 | -------------------------------------------------------------------------------- /src/i18n/sv.js: -------------------------------------------------------------------------------- 1 | import AsColorPicker from '../asColorPicker'; 2 | 3 | // Swedish (sv) localization 4 | AsColorPicker.setLocalization('sv', { 5 | cancelText: "Avbryt", 6 | applyText: "Välj" 7 | }); 8 | -------------------------------------------------------------------------------- /src/i18n/tr.js: -------------------------------------------------------------------------------- 1 | import AsColorPicker from '../asColorPicker'; 2 | 3 | // Turkish (tr) localization 4 | AsColorPicker.setLocalization('tr', { 5 | cancelText: "Avbryt", 6 | applyText: "Välj" 7 | }); 8 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dest": "examples", 3 | "packages": { 4 | "npm:jquery": true, 5 | "npm:normalize.css": true, 6 | "npm:jquery-asColor": true, 7 | "npm:jquery-asGradient": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "5.10" 4 | - "6.2" 5 | - "stable" 6 | sudo: false 7 | 8 | script: 9 | - npm run test 10 | 11 | cache: 12 | directories: 13 | - node_modules 14 | 15 | addons: 16 | sauce_connect: true 17 | -------------------------------------------------------------------------------- /gulp/tasks/clean.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import config from '../../config'; 4 | import del from 'del'; 5 | 6 | export default function (src = config.paths.destDir) { 7 | return function (done) { 8 | del.sync([src]); 9 | 10 | done(); 11 | }; 12 | } 13 | -------------------------------------------------------------------------------- /gulp/util/getFolders.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import fs from 'graceful-fs'; 4 | import path from 'path'; 5 | 6 | export default function(dir) { 7 | return fs.readdirSync(dir).filter((file) => { 8 | return fs.statSync(path.join(dir, file)).isDirectory(); 9 | }); 10 | } 11 | -------------------------------------------------------------------------------- /.release.json: -------------------------------------------------------------------------------- 1 | { 2 | "verbose": false, 3 | "force": false, 4 | "pkgFiles": ["package.json", "bower.json"], 5 | "increment": "patch", 6 | "commitMessage": "Release v%s", 7 | "tagName": "v%s", 8 | "tagAnnotation": "Release v%s", 9 | "buildCommand": "gulp build", 10 | "npm": { 11 | "publish": true 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /gulp/tasks/test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { Server as KarmaServer } from 'karma'; 4 | 5 | export default function (options = {}) { 6 | return function(done) { 7 | options = Object.assign({ 8 | configFile: `${__dirname}/../../karma.conf.js`, 9 | }, options); 10 | 11 | let karma = new KarmaServer(options, done); 12 | 13 | karma.start(); 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .travis.xml 2 | yarn.lock 3 | package-lock.json 4 | .editorconfig 5 | .babelrc 6 | .beautifyrc 7 | .sass-cache 8 | .bowerrc 9 | .eslintrc.yml 10 | .github 11 | .gitattributes 12 | .release.json 13 | _build 14 | bower.json 15 | composer.json 16 | gulpfile.js 17 | gulpfile.babel.js 18 | README.md 19 | CONTRIBUTING.md 20 | coverage 21 | docs 22 | test 23 | gulp 24 | test 25 | demo 26 | libs 27 | archives 28 | config.js 29 | karma.conf.js 30 | bower_components 31 | -------------------------------------------------------------------------------- /gulp/tasks/archive.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import config from '../../config'; 4 | import gulp from 'gulp'; 5 | import zip from 'gulp-zip'; 6 | import notify from 'gulp-notify'; 7 | 8 | export default function (src = config.archive.src, dest = config.archive.dest, message = 'Archive task complete') { 9 | return function () { 10 | return gulp.src(src) 11 | .pipe(zip(`${config.version}.zip`)) 12 | .pipe(gulp.dest(dest)) 13 | .pipe(notify({ 14 | title: config.notify.title, 15 | message: message 16 | })); 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /src/components/clear.js: -------------------------------------------------------------------------------- 1 | // clear 2 | export default { 3 | defaults: { 4 | template(namespace) { 5 | return ``; 6 | } 7 | }, 8 | 9 | init: function(api, options) { 10 | if (api.options.hideInput) { 11 | return; 12 | } 13 | this.options = $.extend(this.defaults, options); 14 | this.$clear = $(this.options.template.call(this, api.namespace)).insertAfter(api.$element); 15 | 16 | this.$clear.on('click', () => { 17 | api.clear(); 18 | return false; 19 | }); 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /src/components/hex.js: -------------------------------------------------------------------------------- 1 | // hex 2 | export default { 3 | init: function(api) { 4 | const template = ``; 5 | this.$hex = $(template).appendTo(api.$dropdown); 6 | 7 | this.$hex.on('change', function() { 8 | api.set(this.value); 9 | }); 10 | 11 | const that = this; 12 | api.$element.on('asColorPicker::update asColorPicker::setup', (e, api, color) => { 13 | that.update(color); 14 | }); 15 | }, 16 | 17 | update: function(color) { 18 | this.$hex.val(color.toHEX()); 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /gulp/tasks/lint-styles.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import config from '../../config'; 4 | import gulp from 'gulp'; 5 | import stylelint from 'gulp-stylelint'; 6 | import getSrcFiles from '../util/getSrcFiles'; 7 | 8 | export function style(src = config.styles.src, files = '**/*.scss') { 9 | return function() { 10 | let srcFiles = getSrcFiles(src, files); 11 | 12 | return gulp.src(srcFiles) 13 | .pipe(stylelint({ 14 | reporters: [{ 15 | formatter: 'string', 16 | console: true 17 | }] 18 | })); 19 | }; 20 | } 21 | -------------------------------------------------------------------------------- /gulp/tasks/images.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import config from '../../config'; 4 | import gulp from 'gulp'; 5 | import path from 'path'; 6 | import notify from 'gulp-notify'; 7 | 8 | export default function (src = config.images.src, dest = config.images.dest, files = config.images.files, message = 'Images task complete') { 9 | return function () { 10 | return gulp.src(path.join(src, files)) 11 | .pipe(gulp.dest(dest)) 12 | .pipe(notify({ 13 | title: config.notify.title, 14 | message: message, 15 | onLast: true 16 | })); 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /gulp/tasks/release.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import config from '../../config'; 4 | import releaseIt from 'release-it'; 5 | import handleErrors from '../util/handleErrors'; 6 | import {argv} from 'yargs'; 7 | 8 | export default function release() { 9 | let options = {}; 10 | options.increment = argv.increment || "patch"; 11 | options.verbose = argv.verbose || true; 12 | options.debug = argv.debug || false; 13 | options.force = argv.force || false; 14 | options['dry-run'] = argv['dry-run'] || false; 15 | 16 | config.setEnv('production'); 17 | 18 | return function(done) { 19 | releaseIt.execute(options).catch(handleErrors).finally(done); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 13 | 14 | _[Remove this line and all of the above before submitting your PR]_ 15 | 16 | ### Pull Request 17 | 18 | Fixes # 19 | 20 | Changes proposed: 21 | 22 | * [ ] Add 23 | * [ ] Fix 24 | * [ ] Remove 25 | * [ ] Update 26 | -------------------------------------------------------------------------------- /src/modes.js: -------------------------------------------------------------------------------- 1 | export default { 2 | 'simple': { 3 | trigger: true, 4 | clear: true, 5 | saturation: true, 6 | hue: true, 7 | alpha: true 8 | }, 9 | 'palettes': { 10 | trigger: true, 11 | clear: true, 12 | palettes: true 13 | }, 14 | 'complex': { 15 | trigger: true, 16 | clear: true, 17 | preview: true, 18 | palettes: true, 19 | saturation: true, 20 | hue: true, 21 | alpha: true, 22 | hex: true, 23 | buttons: true 24 | }, 25 | 'gradient': { 26 | trigger: true, 27 | clear: true, 28 | preview: true, 29 | palettes: true, 30 | saturation: true, 31 | hue: true, 32 | alpha: true, 33 | hex: true, 34 | gradient: true 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /gulp/util/getSrcFiles.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import {argv} from 'yargs'; 4 | import path from 'path'; 5 | import pathExists from 'path-exists'; 6 | 7 | export default function(src, files, argName = 'file') { 8 | let srcFiles = ''; 9 | 10 | if(argv[argName] && pathExists.sync(path.join(src, argv[argName]))) { 11 | let arg = argv[argName]; 12 | srcFiles = `${src}/${arg}`; 13 | } else if(Array.isArray(files)) { 14 | srcFiles = files.map((file) => { 15 | if(file.indexOf('!') === 0) { 16 | file = file.substr(1); 17 | return `!${src}/${file}`; 18 | } 19 | 20 | return `${src}/${file}`; 21 | }); 22 | } else { 23 | srcFiles = `${src}/${files}`; 24 | } 25 | 26 | return srcFiles; 27 | } 28 | -------------------------------------------------------------------------------- /gulp/util/handleErrors.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import gutil from 'gulp-util'; 4 | import config from '../../config'; 5 | import notifier from 'node-notifier'; 6 | 7 | export default function(error) { 8 | if (!config.deploy) { 9 | // Send error to notification center with gulp-notify 10 | notifier.notify({ 11 | title: config.notify.title, 12 | subtitle: 'Failure!', 13 | message: error.message, 14 | }); 15 | gutil.log(gutil.colors.red(error)); 16 | // Keep gulp from hanging on this task 17 | this.emit('end'); 18 | } else { 19 | // Log the error and stop the process 20 | // to prevent broken code from building 21 | gutil.log(gutil.colors.red(error)); 22 | process.exit(1); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /gulp/tasks/lint-scripts.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import config from '../../config'; 4 | import gulp from 'gulp'; 5 | import eslint from 'gulp-eslint'; 6 | import getSrcFiles from '../util/getSrcFiles'; 7 | 8 | export function es(src = config.scripts.src, options = {}, files = ['**/*.js', '!**/*.min.js']) { 9 | return function() { 10 | let srcFiles = getSrcFiles(src, files); 11 | 12 | options = Object.assign({ 13 | useEslintrc: true, 14 | configFile: '.eslintrc.json', 15 | fix: true 16 | }, options); 17 | 18 | return gulp.src(srcFiles, { 19 | base: './' 20 | }) 21 | .pipe(eslint(options)) 22 | .pipe(eslint.format()) 23 | .pipe(eslint.failAfterError()); 24 | }; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /src/defaults.js: -------------------------------------------------------------------------------- 1 | export default { 2 | namespace: 'asColorPicker', 3 | readonly: false, 4 | skin: null, 5 | lang: 'en', 6 | hideInput: false, 7 | hideFireChange: true, 8 | keyboard: false, 9 | color: { 10 | format: false, 11 | alphaConvert: { // or false will disable convert 12 | 'RGB': 'RGBA', 13 | 'HSL': 'HSLA', 14 | 'HEX': 'RGBA', 15 | 'NAMESPACE': 'RGBA', 16 | }, 17 | shortenHex: false, 18 | hexUseName: false, 19 | reduceAlpha: true, 20 | nameDegradation: 'HEX', 21 | invalidValue: '', 22 | zeroAlphaAsTransparent: true 23 | }, 24 | mode: 'simple', 25 | onInit: null, 26 | onReady: null, 27 | onChange: null, 28 | onClose: null, 29 | onOpen: null, 30 | onApply: null 31 | }; 32 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | _[Remove this line and all of the above before submitting your issue]_ 7 | 8 | ### Checklist 9 | * [ ] I'm using **version** [x.x.x] 10 | * [ ] My **browser** is: 11 | * [ ] This is a **Sass** issue: I'm using version [x.x.x] 12 | * [ ] I am sure this issue is **not a duplicate**? 13 | 14 | ### Description 15 | 16 | [Description of the bug, enhancement, or question] 17 | [Please tag accordingly] 18 | 19 | ### How can we reproduce this bug? 20 | 21 | 1. [First Step] 22 | 2. [Second Step] 23 | 3. [and so on...] 24 | 25 | ### What did you expect to happen? 26 | 27 | ### What happened instead? 28 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # End every file with a newline 7 | [*] 8 | charset = utf-8 9 | indent_style = space 10 | indent_size = 2 11 | end_of_line = lf 12 | insert_final_newline = true 13 | trim_trailing_whitespace = true 14 | 15 | [*.{css,less,scss}] 16 | indent_style = space 17 | indent_size = 2 18 | 19 | [*.{js,json}] 20 | indent_style = space 21 | indent_size = 2 22 | 23 | [*.{html,hbs}] 24 | indent_style = tab 25 | indent_size = 2 26 | 27 | [*.md] 28 | indent_style = space 29 | indent_size = 2 30 | insert_final_newline = false 31 | trim_trailing_whitespace = false 32 | 33 | [*.xml] 34 | indent_style = space 35 | indent_size = 2 36 | 37 | [*.yml] 38 | indent_style = space 39 | indent_size = 2 40 | 41 | [*.inc] 42 | indent_style = tab 43 | indent_size = 2 -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-asColorPicker", 3 | "version": "0.4.4", 4 | "description": "A jquery plugin that convent input into color picker.", 5 | "main": "dist/jquery-asColorPicker.js", 6 | "copyright": "amazingSurge", 7 | "license": "LGPL-3.0", 8 | "ignore": [ 9 | "**/.*", 10 | "node_modules", 11 | "bower_components", 12 | "test", 13 | "demo", 14 | "gulp", 15 | "CONTRIBUTING.md", 16 | "manifest.json", 17 | "karma.conf.js", 18 | "config.js", 19 | "package.json", 20 | "gulpfile.babel.js", 21 | "tests" 22 | ], 23 | "homepage": "https://github.com/amazingSurge/jquery-asColorPicker", 24 | "authors": [ 25 | "amazingSurge " 26 | ], 27 | "moduleType": [ 28 | "globals" 29 | ], 30 | "dependencies": { 31 | "jquery": ">=1.11.0", 32 | "jquery-asColor": "^0.3.3", 33 | "jquery-asGradient": "^0.3.1" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /gulp/tasks/browser.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import config from '../../config'; 4 | import browser from 'browser-sync'; 5 | import notifier from 'node-notifier'; 6 | 7 | export function init(options = {}, message = 'Browser starting') { 8 | options = Object.assign(options, { 9 | server: { 10 | baseDir: config.browser.baseDir, 11 | }, 12 | startPath: config.browser.startPath, 13 | port: config.browser.browserPort, 14 | ui: { 15 | port: config.browser.UIPort 16 | }, 17 | ghostMode: { 18 | links: false 19 | } 20 | }); 21 | 22 | return function() { 23 | browser.init(options, () => { 24 | notifier.notify({ 25 | title: config.notify.title, 26 | message: message 27 | }); 28 | }); 29 | }; 30 | } 31 | 32 | export function reload(message = 'Browser reloaded') { 33 | return function(done) { 34 | browser.reload(); 35 | done(); 36 | 37 | notifier.notify({ 38 | title: config.notify.title, 39 | message: message 40 | }); 41 | }; 42 | } 43 | -------------------------------------------------------------------------------- /src/components/trigger.js: -------------------------------------------------------------------------------- 1 | // trigger 2 | export default { 3 | defaults: { 4 | template(namespace) { 5 | return `
`; 6 | } 7 | }, 8 | 9 | init: function(api, options) { 10 | this.options = $.extend(this.defaults, options); 11 | api.$trigger = $(this.options.template.call(this, api.namespace)); 12 | this.$triggerInner = api.$trigger.children('span'); 13 | 14 | api.$trigger.insertAfter(api.$element); 15 | api.$trigger.on('click', () => { 16 | if (!api.opened) { 17 | api.open(); 18 | } else { 19 | api.close(); 20 | } 21 | return false; 22 | }); 23 | const that = this; 24 | api.$element.on('asColorPicker::update', (e, api, color, gradient) => { 25 | if (typeof gradient === 'undefined') { 26 | gradient = false; 27 | } 28 | that.update(color, gradient); 29 | }); 30 | 31 | this.update(api.color); 32 | }, 33 | 34 | update: function(color, gradient) { 35 | if (gradient) { 36 | this.$triggerInner.css('background', gradient.toString(true)); 37 | } else { 38 | this.$triggerInner.css('background', color.toRGBA()); 39 | } 40 | }, 41 | 42 | destroy: function(api) { 43 | api.$trigger.remove(); 44 | } 45 | }; 46 | -------------------------------------------------------------------------------- /src/keyboard.js: -------------------------------------------------------------------------------- 1 | // keyboard 2 | import $ from 'jquery'; 3 | 4 | const $doc = $(document); 5 | const keyboard = { 6 | keys: { 7 | 'UP': 38, 8 | 'DOWN': 40, 9 | 'LEFT': 37, 10 | 'RIGHT': 39, 11 | 'RETURN': 13, 12 | 'ESCAPE': 27, 13 | 'BACKSPACE': 8, 14 | 'SPACE': 32 15 | }, 16 | map: {}, 17 | bound: false, 18 | press(e) { 19 | const key = e.keyCode || e.which; 20 | if (key in keyboard.map && typeof keyboard.map[key] === 'function') { 21 | keyboard.map[key](e); 22 | } 23 | return false; 24 | }, 25 | attach(map) { 26 | let key; 27 | let up; 28 | for (key in map) { 29 | if (map.hasOwnProperty(key)) { 30 | up = key.toUpperCase(); 31 | if (up in keyboard.keys) { 32 | keyboard.map[keyboard.keys[up]] = map[key]; 33 | } else { 34 | keyboard.map[up] = map[key]; 35 | } 36 | } 37 | } 38 | if (!keyboard.bound) { 39 | keyboard.bound = true; 40 | $doc.bind('keydown', keyboard.press); 41 | } 42 | }, 43 | detach() { 44 | keyboard.bound = false; 45 | keyboard.map = {}; 46 | $doc.unbind('keydown', keyboard.press); 47 | } 48 | }; 49 | $doc.on('asColorPicker::init', (event, instance) => { 50 | if (instance.options.keyboard === true) { 51 | instance._keyboard = keyboard; 52 | } 53 | }); 54 | -------------------------------------------------------------------------------- /gulp/tasks/assets.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import config from '../../config'; 4 | import merge from 'merge-stream'; 5 | import gulp from 'gulp'; 6 | import notify from 'gulp-notify'; 7 | import AssetsManager from 'assets-manager'; 8 | import {argv} from 'yargs'; 9 | 10 | function getPackage() { 11 | if (argv.package) { 12 | return argv.package; 13 | } 14 | return null; 15 | } 16 | 17 | /* 18 | * Checkout https://github.com/amazingSurge/assets-manager 19 | */ 20 | export function copy(options = config.assets, message = 'Assets task complete') { 21 | return function (done) { 22 | let pkgName = getPackage(); 23 | const manager = new AssetsManager('manifest.json', options); 24 | 25 | if(pkgName) { 26 | manager.copyPackage(pkgName).then(()=>{ 27 | done(); 28 | }); 29 | } else { 30 | manager.copyPackages().then(()=>{ 31 | done(); 32 | }); 33 | } 34 | } 35 | } 36 | 37 | export function clean(options = config.assets, message = 'Assets clean task complete') { 38 | return function (done) { 39 | let pkgName = getPackage(); 40 | const manager = new AssetsManager('manifest.json', options); 41 | 42 | if(pkgName) { 43 | manager.cleanPackage(pkgName).then(()=>{ 44 | done(); 45 | }); 46 | } else { 47 | manager.cleanPackages().then(()=>{ 48 | done(); 49 | }); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ################################## 2 | # project-specific.gitattributes # 3 | ################################## 4 | 5 | 6 | ########################### 7 | # documents.gitattributes # 8 | ########################### 9 | *.doc diff=astextplain 10 | *.docx diff=astextplain 11 | *.dot diff=astextplain 12 | *.pdf diff=astextplain 13 | *.rtf diff=astextplain 14 | *.css text eol=lf 15 | *.scss text eol=lf 16 | *.less text eol=lf 17 | *.html text eol=lf 18 | *.js text eol=lf 19 | *.json text eol=lf 20 | *.md text eol=lf 21 | *.txt text eol=lf 22 | *.hbs text eol=lf 23 | *.mustache text eol=lf 24 | *.xml text eol=lf 25 | *.csv text eol=lf 26 | *.tab text eol=lf 27 | *.tsv text eol=lf 28 | *.sql text eol=lf 29 | 30 | ############################ 31 | ### graphics.gitattributes # 32 | ############################ 33 | *.png binary 34 | *.jpg binary 35 | *.jpeg binary 36 | *.gif binary 37 | *.tif binary 38 | *.tiff binary 39 | *.ico binary 40 | *.svg binary 41 | *.eps binary 42 | *.psd binary 43 | *.ai binary 44 | 45 | ########################### 46 | # git-crypt.gitattributes # 47 | ########################### 48 | vault_* binary filter=git-crypt diff=git-crypt 49 | vault.* binary filter=git-crypt diff=git-crypt 50 | 51 | ####################### 52 | # shell.gitattributes # 53 | ####################### 54 | # Linux 55 | *.sh text eol=lf 56 | 57 | # Windows 58 | *.bat text eol=crlf 59 | *.cmd text eol=crlf 60 | *.ps1 text eol=crlf -------------------------------------------------------------------------------- /src/components/buttons.js: -------------------------------------------------------------------------------- 1 | // buttons 2 | export default { 3 | defaults: { 4 | apply: false, 5 | cancel: true, 6 | applyText: null, 7 | cancelText: null, 8 | template(namespace) { 9 | return `
`; 10 | }, 11 | applyTemplate(namespace) { 12 | return `${this.options.applyText}`; 13 | }, 14 | cancelTemplate(namespace) { 15 | return `${this.options.cancelText}`; 16 | } 17 | }, 18 | 19 | init: function(api, options) { 20 | const that = this; 21 | 22 | this.options = $.extend(this.defaults, { 23 | applyText: api.getString('applyText', 'apply'), 24 | cancelText: api.getString('cancelText', 'cancel') 25 | }, options); 26 | this.$buttons = $(this.options.template.call(this, api.namespace)).appendTo(api.$dropdown); 27 | 28 | api.$element.on('asColorPicker::firstOpen', () => { 29 | if (that.options.apply) { 30 | that.$apply = $(that.options.applyTemplate.call(that, api.namespace)).appendTo(that.$buttons).on('click', () => { 31 | api.apply(); 32 | return false; 33 | }); 34 | } 35 | 36 | if (that.options.cancel) { 37 | that.$cancel = $(that.options.cancelTemplate.call(that, api.namespace)).appendTo(that.$buttons).on('click', () => { 38 | api.cancel(); 39 | return false; 40 | }); 41 | } 42 | }); 43 | } 44 | }; 45 | -------------------------------------------------------------------------------- /src/components/preview.js: -------------------------------------------------------------------------------- 1 | // preview 2 | export default { 3 | defaults: { 4 | template(namespace) { 5 | return ``; 6 | } 7 | }, 8 | 9 | init: function(api, options) { 10 | const that = this; 11 | this.options = $.extend(this.defaults, options); 12 | this.$preview = $(this.options.template.call(that, api.namespace)).appendTo(api.$dropdown); 13 | this.$current = this.$preview.find(`.${api.namespace}-preview-current span`); 14 | this.$previous = this.$preview.find(`.${api.namespace}-preview-previous span`); 15 | 16 | api.$element.on('asColorPicker::firstOpen', () => { 17 | that.$previous.on('click', function() { 18 | api.set($(this).data('color')); 19 | return false; 20 | }); 21 | }); 22 | 23 | api.$element.on('asColorPicker::setup', (e, api, color) => { 24 | that.updateCurrent(color); 25 | that.updatePreview(color); 26 | }); 27 | api.$element.on('asColorPicker::update', (e, api, color) => { 28 | that.updateCurrent(color); 29 | }); 30 | }, 31 | 32 | updateCurrent: function(color) { 33 | this.$current.css('backgroundColor', color.toRGBA()); 34 | }, 35 | 36 | updatePreview: function(color) { 37 | this.$previous.css('backgroundColor', color.toRGBA()); 38 | this.$previous.data('color', { 39 | r: color.value.r, 40 | g: color.value.g, 41 | b: color.value.b, 42 | a: color.value.a 43 | }); 44 | } 45 | }; 46 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import $ from 'jquery'; 2 | import AsColorPicker from './asColorPicker'; 3 | import "./i18n/cn"; 4 | import "./i18n/de"; 5 | import "./i18n/dk"; 6 | import "./i18n/es"; 7 | import "./i18n/fi"; 8 | import "./i18n/fr"; 9 | import "./i18n/it"; 10 | import "./i18n/ja"; 11 | import "./i18n/ru"; 12 | import "./i18n/sv"; 13 | import "./i18n/tr"; 14 | 15 | import info from './info'; 16 | 17 | const NAMESPACE = 'asColorPicker'; 18 | const OtherAsColorPicker = $.fn.asColorPicker; 19 | 20 | const jQueryAsColorPicker = function(options, ...args) { 21 | if (typeof options === 'string') { 22 | const method = options; 23 | 24 | if (/^_/.test(method)) { 25 | return false; 26 | } else if ((/^(get)$/.test(method)) || (method === 'val' && args.length === 0)) { 27 | const instance = this.first().data(NAMESPACE); 28 | if (instance && typeof instance[method] === 'function') { 29 | return instance[method](...args); 30 | } 31 | } else { 32 | return this.each(function() { 33 | const instance = $.data(this, NAMESPACE); 34 | if (instance && typeof instance[method] === 'function') { 35 | instance[method](...args); 36 | } 37 | }); 38 | } 39 | } 40 | 41 | return this.each(function() { 42 | if (!$(this).data(NAMESPACE)) { 43 | $(this).data(NAMESPACE, new AsColorPicker(this, options)); 44 | } 45 | }); 46 | }; 47 | 48 | $.fn.asColorPicker = jQueryAsColorPicker; 49 | 50 | $.asColorPicker = $.extend({ 51 | setDefaults: AsColorPicker.setDefaults, 52 | registerComponent: AsColorPicker.registerComponent, 53 | setLocalization: AsColorPicker.setLocalization, 54 | noConflict: function() { 55 | $.fn.asColorPicker = OtherAsColorPicker; 56 | return jQueryAsColorPicker; 57 | } 58 | }, info); 59 | 60 | 61 | -------------------------------------------------------------------------------- /src/components/info.js: -------------------------------------------------------------------------------- 1 | // info 2 | export default { 3 | color: ['white', 'black', 'transparent'], 4 | 5 | init: function(api) { 6 | const template = ``; 7 | this.$info = $(template).appendTo(api.$dropdown); 8 | this.$r = this.$info.find('[data-type="r"]'); 9 | this.$g = this.$info.find('[data-type="g"]'); 10 | this.$b = this.$info.find('[data-type="b"]'); 11 | this.$a = this.$info.find('[data-type="a"]'); 12 | 13 | this.$info.on(api.eventName('keyup update change'), 'input', function(e) { 14 | let val; 15 | const type = $(e.target).data('type'); 16 | switch (type) { 17 | case 'r': 18 | case 'g': 19 | case 'b': 20 | val = parseInt(this.value, 10); 21 | if (val > 255) { 22 | val = 255; 23 | } else if (val < 0) { 24 | val = 0; 25 | } 26 | break; 27 | case 'a': 28 | val = parseFloat(this.value, 10); 29 | if (val > 1) { 30 | val = 1; 31 | } else if (val < 0) { 32 | val = 0; 33 | } 34 | break; 35 | default: 36 | break; 37 | } 38 | if (isNaN(val)) { 39 | val = 0; 40 | } 41 | const color = {}; 42 | color[type] = val; 43 | api.set(color); 44 | }); 45 | 46 | const that = this; 47 | api.$element.on('asColorPicker::update asColorPicker::setup', (e, color) => { 48 | that.update(color); 49 | }); 50 | }, 51 | 52 | update: function(color) { 53 | this.$r.val(color.value.r); 54 | this.$g.val(color.value.g); 55 | this.$b.val(color.value.b); 56 | this.$a.val(color.value.a); 57 | } 58 | }; 59 | -------------------------------------------------------------------------------- /examples/css/prism.css: -------------------------------------------------------------------------------- 1 | /** 2 | * prism.js default theme for JavaScript, CSS and HTML 3 | * Based on dabblet (http://dabblet.com) 4 | * @author Lea Verou 5 | */ 6 | 7 | code[class*="language-"], 8 | pre[class*="language-"] { 9 | color: black; 10 | text-shadow: 0 1px white; 11 | font-family: Consolas, Monaco, 'Andale Mono', monospace; 12 | direction: ltr; 13 | text-align: left; 14 | white-space: pre; 15 | word-spacing: normal; 16 | 17 | -moz-tab-size: 4; 18 | -o-tab-size: 4; 19 | tab-size: 4; 20 | 21 | -webkit-hyphens: none; 22 | -moz-hyphens: none; 23 | -ms-hyphens: none; 24 | hyphens: none; 25 | } 26 | 27 | /* Code blocks */ 28 | pre[class*="language-"] { 29 | padding: 1em; 30 | margin: .5em 0; 31 | overflow: auto; 32 | } 33 | 34 | :not(pre) > code[class*="language-"], 35 | pre[class*="language-"] { 36 | background: #f5f2f0; 37 | } 38 | 39 | /* Inline code */ 40 | :not(pre) > code[class*="language-"] { 41 | padding: .1em; 42 | border-radius: .3em; 43 | } 44 | 45 | .token.comment, 46 | .token.prolog, 47 | .token.doctype, 48 | .token.cdata { 49 | color: slategray; 50 | } 51 | 52 | .token.punctuation { 53 | color: #999; 54 | } 55 | 56 | .namespace { 57 | opacity: .7; 58 | } 59 | 60 | .token.property, 61 | .token.tag, 62 | .token.boolean, 63 | .token.number { 64 | color: #905; 65 | } 66 | 67 | .token.selector, 68 | .token.attr-name, 69 | .token.string { 70 | color: #690; 71 | } 72 | 73 | .token.operator, 74 | .token.entity, 75 | .token.url, 76 | .language-css .token.string, 77 | .style .token.string { 78 | color: #a67f59; 79 | background: hsla(0,0%,100%,.5); 80 | } 81 | 82 | .token.atrule, 83 | .token.attr-value, 84 | .token.keyword { 85 | color: #07a; 86 | } 87 | 88 | 89 | .token.regex, 90 | .token.important { 91 | color: #e90; 92 | } 93 | 94 | .token.important { 95 | font-weight: bold; 96 | } 97 | 98 | .token.entity { 99 | cursor: help; 100 | } 101 | -------------------------------------------------------------------------------- /gulp/tasks/styles.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import config from '../../config'; 4 | import gulp from 'gulp'; 5 | import gulpif from 'gulp-if'; 6 | import sourcemaps from 'gulp-sourcemaps'; 7 | import sass from 'gulp-sass'; 8 | import sassUnicode from 'gulp-sass-unicode'; 9 | import handleErrors from '../util/handleErrors'; 10 | import browser from 'browser-sync'; 11 | import autoprefixer from 'gulp-autoprefixer'; 12 | import cssnano from 'gulp-cssnano'; 13 | import csscomb from 'gulp-csscomb'; 14 | import rename from 'gulp-rename'; 15 | import header from 'gulp-header'; 16 | import size from 'gulp-size'; 17 | import plumber from 'gulp-plumber'; 18 | import notify from 'gulp-notify'; 19 | import getSrcFiles from '../util/getSrcFiles'; 20 | 21 | export default function (src = config.styles.src, dest = config.styles.dest, files = config.styles.files, message = 'Styles task complete') { 22 | const createSourcemap = config.deploy || config.styles.prodSourcemap; 23 | 24 | return function() { 25 | let srcFiles = getSrcFiles(src, files); 26 | 27 | return gulp.src(srcFiles) 28 | .on('error', handleErrors) 29 | .pipe(plumber({errorHandler: handleErrors})) 30 | .pipe(sass({ 31 | outputStyle: 'nested', 32 | includePaths: config.styles.sassIncludePaths 33 | })) 34 | .pipe(sassUnicode()) 35 | .pipe(csscomb('.csscomb.json')) 36 | .pipe(autoprefixer(config.styles.autoprefixer)) 37 | .pipe(header(config.banner)) 38 | .pipe(gulp.dest(dest)) 39 | .pipe(size({ 40 | title: 'styles', 41 | showFiles: true 42 | })) 43 | .pipe(rename({ 44 | suffix: '.min' 45 | })) 46 | .pipe(gulpif(createSourcemap, sourcemaps.init())) 47 | .pipe(cssnano({ 48 | safe: true, 49 | autoprefixer: false 50 | })) 51 | .pipe(header(config.banner)) 52 | .pipe(gulpif( 53 | createSourcemap, 54 | sourcemaps.write(config.deploy ? './' : null)) 55 | ) 56 | .pipe(gulp.dest(dest)) 57 | .pipe(size({ 58 | title: 'minified styles', 59 | showFiles: true 60 | })) 61 | .pipe(browser.stream()) 62 | .pipe(notify({ 63 | title: config.notify.title, 64 | message: message, 65 | onLast: true 66 | })); 67 | }; 68 | } 69 | -------------------------------------------------------------------------------- /gulp/tasks/deploy.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import config from '../../config'; 4 | import gulp from 'gulp'; 5 | import inquirer from 'inquirer'; 6 | import replace from 'gulp-replace'; 7 | import { execSync as exec, spawnSync as spawn } from 'child_process'; 8 | import semver from 'semver'; 9 | import gutil from 'gulp-util'; 10 | 11 | const CURRENT_VERSION = config.version; 12 | let NEXT_VERSION; 13 | let NEXT_MESSAGE; 14 | 15 | export function prompt(done) { 16 | inquirer.prompt([{ 17 | type: 'input', 18 | name: 'version', 19 | message: `What version are we moving to? (Current version is ${CURRENT_VERSION})`, 20 | validate: function (input) { 21 | if(input === '') { 22 | input = CURRENT_VERSION; 23 | } 24 | return /^\d*[\d.]*\d*$/.test(input); 25 | } 26 | }]).then((answers) => { 27 | if (answers.version === '') { 28 | NEXT_VERSION = semver.inc(CURRENT_VERSION, config.deploy.increment); 29 | gutil.log(gutil.colors.green(`No version inputted, bump to version ${NEXT_VERSION}`)); 30 | } else { 31 | NEXT_VERSION = answers.version; 32 | } 33 | 34 | done(); 35 | }); 36 | } 37 | 38 | export function message(done) { 39 | inquirer.prompt([{ 40 | type: 'input', 41 | name: 'message', 42 | message: `What message are we going to commit?`, 43 | validate: function (input) { 44 | if(input === '' && NEXT_VERSION === CURRENT_VERSION) { 45 | return false; 46 | } 47 | return true; 48 | } 49 | }]).then((answers) => { 50 | if (answers.message !== '') { 51 | NEXT_MESSAGE = answers.message; 52 | } else { 53 | NEXT_MESSAGE = ''; 54 | } 55 | done(); 56 | }); 57 | } 58 | 59 | // Bumps the version number in any file that has one 60 | export function version() { 61 | return gulp.src(config.deploy.versionFiles, { 62 | base: process.cwd() 63 | }) 64 | // .pipe(replace(CURRENT_VERSION, NEXT_VERSION)) 65 | .pipe(replace(/Version\s*:\s*([\d.]+)/, `Version: ${NEXT_VERSION}`)) 66 | .pipe(replace(/("|')version\1\s*:\s*("|')([\d.]+)\2/, `$1version$1: $2${NEXT_VERSION}$2`)) 67 | .pipe(gulp.dest('.')); 68 | } 69 | 70 | export function init(done) { 71 | config.production = true; 72 | config.init(); 73 | 74 | done(); 75 | } 76 | 77 | // Writes a commit with the changes to the version numbers 78 | export function commit(done) { 79 | let message = `Release ${NEXT_VERSION}`; 80 | 81 | if (NEXT_VERSION === CURRENT_VERSION) { 82 | message = NEXT_MESSAGE; 83 | } else if(NEXT_MESSAGE !== '') { 84 | message = `${message}; ${NEXT_MESSAGE}`; 85 | } 86 | exec('git add .'); 87 | exec(`git commit -am "${message}"`); 88 | 89 | if (NEXT_VERSION !== CURRENT_VERSION) { 90 | exec(`git tag v${NEXT_VERSION}`); 91 | } 92 | 93 | exec('git push origin master --follow-tags'); 94 | done(); 95 | } 96 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #################### 2 | # project-specific # 3 | #################### 4 | 5 | 6 | #################### 7 | # Generated source # 8 | #################### 9 | _build/ 10 | archives/ 11 | results 12 | screenshots 13 | 14 | ########################## 15 | # Dependency directories # 16 | ########################## 17 | bower_components 18 | node_modules 19 | 20 | ####### 21 | # OSX # 22 | ####### 23 | .DS_Store 24 | .AppleDouble 25 | .LSOverride 26 | 27 | # Icon must end with two \r 28 | Icon 29 | 30 | # Thumbnails 31 | ._* 32 | 33 | # Files that might appear in the root of a volume 34 | .DocumentRevisions-V100 35 | .fseventsd 36 | .Spotlight-V100 37 | .TemporaryItems 38 | .Trashes 39 | .VolumeIcon.icns 40 | 41 | # Directories potentially created on remote AFP share 42 | .AppleDB 43 | .AppleDesktop 44 | Network Trash Folder 45 | Temporary Items 46 | .apdisk 47 | 48 | ########### 49 | # Windows # 50 | ########### 51 | # Windows image file caches 52 | Thumbs.db 53 | ehthumbs.db 54 | 55 | # Folder config file 56 | Desktop.ini 57 | 58 | # Recycle Bin used on file shares 59 | $RECYCLE.BIN/ 60 | 61 | # Windows Installer files 62 | *.cab 63 | *.msi 64 | *.msm 65 | *.msp 66 | 67 | # Windows shortcuts 68 | *.lnk 69 | 70 | ######## 71 | # Node # 72 | ######## 73 | # Logs 74 | logs 75 | *.log 76 | npm-debug.log* 77 | 78 | # Runtime data 79 | pids 80 | *.pid 81 | *.seed 82 | 83 | # Directory for instrumented libs generated by jscoverage/JSCover 84 | lib-cov 85 | 86 | # Coverage directory used by tools like istanbul 87 | coverage 88 | 89 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 90 | .grunt 91 | 92 | # Sass 93 | .sass-cache/ 94 | *.css.map 95 | 96 | # node-waf configuration 97 | .lock-wscript 98 | 99 | # Compiled binary addons (http://nodejs.org/api/addons.html) 100 | build/Release 101 | 102 | # Dependency directory 103 | node_modules 104 | 105 | # JSPM 106 | jspm_packages 107 | 108 | # Optional npm cache directory 109 | .npm 110 | 111 | ############### 112 | # SublimeText # 113 | ############### 114 | # cache files for sublime text 115 | *.tmlanguage.cache 116 | *.tmPreferences.cache 117 | *.stTheme.cache 118 | 119 | # workspace files are user-specific 120 | *.sublime-workspace 121 | 122 | # project files should be checked into the repository, unless a significant 123 | # proportion of contributors will probably not be using SublimeText 124 | # *.sublime-project 125 | 126 | # sftp configuration file 127 | sftp-config.json 128 | 129 | ####### 130 | # Vim # 131 | ####### 132 | # swap 133 | [._]*.s[a-w][a-z] 134 | [._]s[a-w][a-z] 135 | # persistent undo 136 | *.un~ 137 | # session 138 | Session.vim 139 | # temporary 140 | .netrwhist 141 | *~ 142 | 143 | ############# 144 | # NotepadPP # 145 | ############## 146 | *.bak 147 | -------------------------------------------------------------------------------- /config.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import fs from 'graceful-fs'; 4 | import {argv} from 'yargs'; 5 | 6 | const production = argv.production || argv.prod || false; 7 | 8 | export default { 9 | getConfig: function(pkg, src, dest) { 10 | return { 11 | version: pkg.version, 12 | name: pkg.name, 13 | title: pkg.title, 14 | description: pkg.description, 15 | author: pkg.author, 16 | banner: `/** 17 | * ${pkg.title} v${pkg.version} 18 | * ${pkg.homepage} 19 | * 20 | * Copyright (c) ${pkg.author.name} 21 | * Released under the ${pkg.license} license 22 | */ 23 | `, 24 | // basic locations 25 | paths: { 26 | root: './', 27 | srcDir: `${src}/`, 28 | destDir: `${dest}/`, 29 | }, 30 | 31 | styles: { 32 | files: '**/*.scss', 33 | src: `${src}/scss`, 34 | dest: `${dest}/css`, 35 | prodSourcemap: false, 36 | sassIncludePaths: [], 37 | autoprefixer: { 38 | browsers: ['last 2 versions', 'ie >= 9', 'Android >= 2.3'] 39 | } 40 | }, 41 | 42 | scripts: { 43 | input: 'main.js', 44 | version: 'info.js', 45 | files: '**/*.js', 46 | src: `${src}`, 47 | dest: `${dest}`, 48 | prodSourcemap: false, 49 | test: './test', 50 | gulp: './gulp' 51 | }, 52 | 53 | images: { 54 | files: '**/*.{png,jpg,gif,svg}', 55 | src: `${src}/images`, 56 | dest: `${dest}/images` 57 | }, 58 | 59 | archive: { 60 | src: `${dest}/**/*`, 61 | dest: './archives/', 62 | zip: {} 63 | }, 64 | 65 | browser: { 66 | baseDir: './', 67 | startPath: "examples/index.html", 68 | browserPort: 3000, 69 | UIPort: 3001, 70 | testPort: 3002, 71 | }, 72 | 73 | deploy: { 74 | versionFiles: ['package.json', 'bower.json'], 75 | increment: "patch", // major, minor, patch, premajor, preminor, prepatch, or prerelease. 76 | }, 77 | 78 | notify: { 79 | title: pkg.title 80 | }, 81 | 82 | env: 'development', 83 | production: production, 84 | setEnv: function(env) { 85 | if (typeof env !== 'string') return; 86 | this.env = env; 87 | this.production = env === 'production'; 88 | process.env.NODE_ENV = env; 89 | }, 90 | 91 | test: {}, 92 | }; 93 | }, 94 | 95 | init: function() { 96 | const pkg = JSON.parse(fs.readFileSync('./package.json', { encoding: 'utf-8' })); 97 | 98 | let src = 'src'; 99 | let dest = 'dist'; 100 | 101 | Object.assign(this, this.getConfig(pkg, src, dest, production)); 102 | this.setEnv(production? 'production': 'development'); 103 | 104 | return this; 105 | } 106 | 107 | }.init(); 108 | -------------------------------------------------------------------------------- /src/components/palettes.js: -------------------------------------------------------------------------------- 1 | import AsColor from 'jquery-asColor'; 2 | 3 | // palettes 4 | function noop() { 5 | return; 6 | } 7 | if (!window.localStorage) { 8 | window.localStorage = noop; 9 | } 10 | 11 | export default { 12 | defaults: { 13 | template(namespace) { 14 | return ``; 15 | }, 16 | item(namespace, color) { 17 | return `
  • `; 18 | }, 19 | colors: ['white', 'black', 'red', 'blue', 'yellow'], 20 | max: 10, 21 | localStorage: true 22 | }, 23 | 24 | init: function(api, options) { 25 | const that = this; 26 | let colors; 27 | const asColor = AsColor(); 28 | 29 | this.options = $.extend(true, {}, this.defaults, options); 30 | this.colors = []; 31 | let localKey; 32 | 33 | if (this.options.localStorage) { 34 | localKey = `${api.namespace}_palettes_${api.id}`; 35 | colors = this.getLocal(localKey); 36 | if (!colors) { 37 | colors = this.options.colors; 38 | this.setLocal(localKey, colors); 39 | } 40 | } else { 41 | colors = this.options.colors; 42 | } 43 | 44 | for (const i in colors) { 45 | if(Object.hasOwnProperty.call(colors, i)){ 46 | this.colors.push(asColor.val(colors[i]).toRGBA()); 47 | } 48 | } 49 | 50 | let list = ''; 51 | $.each(this.colors, (i, color) => { 52 | list += that.options.item(api.namespace, color); 53 | }); 54 | 55 | this.$palettes = $(this.options.template.call(this, api.namespace)).html(list).appendTo(api.$dropdown); 56 | 57 | this.$palettes.on(api.eventName('click'), 'li', function(e) { 58 | const color = $(this).data('color'); 59 | api.set(color); 60 | 61 | e.preventDefault(); 62 | e.stopPropagation(); 63 | }); 64 | 65 | api.$element.on('asColorPicker::apply', (e, api, color) => { 66 | if (typeof color.toRGBA !== 'function') { 67 | color = color.get().color; 68 | } 69 | 70 | const rgba = color.toRGBA(); 71 | if ($.inArray(rgba, that.colors) === -1) { 72 | if (that.colors.length >= that.options.max) { 73 | that.colors.shift(); 74 | that.$palettes.find('li').eq(0).remove(); 75 | } 76 | 77 | that.colors.push(rgba); 78 | 79 | that.$palettes.append(that.options.item(api.namespace, color)); 80 | 81 | if (that.options.localStorage) { 82 | that.setLocal(localKey, that.colors); 83 | } 84 | } 85 | }); 86 | }, 87 | 88 | setLocal: function(key, value) { 89 | const jsonValue = JSON.stringify(value); 90 | 91 | localStorage[key] = jsonValue; 92 | }, 93 | 94 | getLocal: function(key) { 95 | const value = localStorage[key]; 96 | 97 | return value ? JSON.parse(value) : value; 98 | } 99 | }; 100 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration 2 | import babel from 'rollup-plugin-babel'; 3 | import babelrc from 'babelrc-rollup'; 4 | import istanbul from 'rollup-plugin-istanbul'; 5 | import babel_istanbul from 'babel-istanbul'; 6 | 7 | module.exports = function(config) { 8 | config.set({ 9 | 10 | // base path that will be used to resolve all patterns (eg. files, exclude) 11 | basePath: '', 12 | 13 | // frameworks to use 14 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter 15 | frameworks: ['mocha', 'sinon-chai'], 16 | 17 | // list of files / patterns to load in the browser 18 | files: [ 19 | 'test/spec/*.js' 20 | ], 21 | 22 | // preprocess matching files before serving them to the browser 23 | // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor 24 | preprocessors: { 25 | // "dist/**/*.es.js": ["rollup"], 26 | "src/**/*.js": ["rollup", "coverage"], 27 | "test/spec/**/*.spec.js": ["rollup"] 28 | }, 29 | 30 | // optionally, configure the reporter 31 | // text displays it within the console (alternative: text-summary) 32 | // lcov creates a codecov compatible report 33 | coverageReporter: { 34 | reporters: [ 35 | {'type': 'text'}, 36 | {'type': 'html', dir: 'coverage'}, 37 | {'type': 'lcov'} 38 | ] 39 | }, 40 | 41 | // list of files to exclude 42 | exclude: [ 43 | ], 44 | 45 | 46 | // test results reporter to use 47 | // possible values: 'dots', 'progress' 48 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter 49 | // coverage is from karma-coverage and provides Istanbul code coverage report 50 | reporters: ['mocha', 'coverage'], 51 | 52 | 53 | // web server port 54 | port: 9876, 55 | 56 | 57 | // enable / disable colors in the output (reporters and logs) 58 | colors: true, 59 | 60 | 61 | // level of logging 62 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 63 | logLevel: config.LOG_INFO, 64 | 65 | 66 | // enable / disable watching file and executing tests whenever any file changes 67 | autoWatch: true, 68 | 69 | 70 | // start these browsers 71 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher 72 | // Currently available: 73 | // - Chrome 74 | // - ChromeCanary 75 | // - Firefox 76 | // - Opera 77 | // - Safari (only Mac) 78 | // - PhantomJS 79 | // - IE (only Windows) 80 | browsers: ['Firefox'], 81 | 82 | // Which plugins to enable 83 | plugins: [ 84 | 'karma-mocha', 85 | 'karma-sinon-chai', 86 | 'karma-chrome-launcher', 87 | 'karma-firefox-launcher', 88 | 'karma-phantomjs-launcher', 89 | 'karma-mocha-reporter', 90 | 'karma-coverage', 91 | 'karma-rollup-plugin' 92 | ], 93 | 94 | rollupPreprocessor: { 95 | plugins: [ 96 | babel(babelrc()), 97 | istanbul({ 98 | include: ['src/**/*.js'], 99 | exclude: ['test/spec/**/*.spec.js', 'node_modules/**'], 100 | // instrumenter: babel_istanbul 101 | }), 102 | ], 103 | sourceMap: 'inline' 104 | }, 105 | 106 | // Continuous Integration mode 107 | // if true, Karma captures browsers, runs the tests and exits 108 | singleRun: false, 109 | 110 | // Concurrency level 111 | // how many browser should be started simultaneous 112 | concurrency: Infinity 113 | }) 114 | } 115 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-asColorPicker", 3 | "title": "asColorPicker", 4 | "description": "A jquery plugin that convent input into color picker.", 5 | "version": "0.4.4", 6 | "homepage": "https://github.com/amazingSurge/jquery-asColorPicker", 7 | "author": { 8 | "name": "amazingSurge", 9 | "email": "amazingSurge@gmail.com", 10 | "url": "amazingSurge.com" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git@github.com:amazingSurge/jquery-asColorPicker.git" 15 | }, 16 | "keywords": [ 17 | "jquery", 18 | "jquery-plugin", 19 | "ecosystem:jquery", 20 | "ui", 21 | "es6", 22 | "Scrollbar" 23 | ], 24 | "bugs": "https://github.com/amazingSurge/jquery-asColorPicker/issues", 25 | "licenses": [ 26 | { 27 | "type": "LGPL-3.0", 28 | "url": "https://github.com/amazingSurge/jquery-asColorPicker/blob/master/LICENSE" 29 | } 30 | ], 31 | "license": "LGPL-3.0", 32 | "main": "dist/jquery-asColorPicker.js", 33 | "module": "dist/jquery-asColorPicker.es.js", 34 | "files": [ 35 | "dist", 36 | "src" 37 | ], 38 | "scripts": { 39 | "prestart": "npm install", 40 | "start": "gulp serve", 41 | "build": "npm run prestart && gulp build", 42 | "deploy": "gulp deploy", 43 | "deploy:prepare": "gulp deploy:prepare", 44 | "release": "gulp release", 45 | "test": "gulp test" 46 | }, 47 | "devDependencies": { 48 | "yargs": "*", 49 | "assets-manager": "*", 50 | "babel-core": "*", 51 | "babel-eslint": "*", 52 | "babel-istanbul": "*", 53 | "babel-plugin-transform-es2015-modules-umd": "*", 54 | "babel-preset-es2015": "*", 55 | "babel-preset-es2015-rollup": "*", 56 | "babelrc-rollup": "*", 57 | "browser-sync": "*", 58 | "chai": "*", 59 | "del": "*", 60 | "prettier": "*", 61 | "gulp-nf-prettier": "*", 62 | "graceful-fs": "*", 63 | "gulp": "github:gulpjs/gulp#4.0", 64 | "gulp-autoprefixer": "*", 65 | "gulp-babel": "*", 66 | "gulp-changed": "*", 67 | "gulp-csscomb": "*", 68 | "gulp-cssnano": "*", 69 | "gulp-eslint": "*", 70 | "gulp-extname": "*", 71 | "gulp-filter": "*", 72 | "gulp-header": "*", 73 | "gulp-iconfont-css": "*", 74 | "gulp-if": "*", 75 | "gulp-notify": "*", 76 | "gulp-plumber": "*", 77 | "gulp-rename": "*", 78 | "gulp-replace": "*", 79 | "gulp-rollup": "*", 80 | "gulp-sass": "*", 81 | "gulp-sass-unicode": "*", 82 | "gulp-size": "*", 83 | "gulp-sourcemaps": "*", 84 | "gulp-stylelint": "*", 85 | "gulp-uglify": "*", 86 | "gulp-util": "*", 87 | "gulp-zip": "*", 88 | "inquirer": "*", 89 | "semver": "*", 90 | "karma": "*", 91 | "karma-babel-preprocessor": "*", 92 | "karma-chrome-launcher": "*", 93 | "karma-commonjs": "*", 94 | "karma-coverage": "*", 95 | "karma-firefox-launcher": "*", 96 | "karma-mocha": "*", 97 | "karma-mocha-reporter": "*", 98 | "karma-phantomjs-launcher": "*", 99 | "karma-rollup-plugin": "*", 100 | "karma-sinon-chai": "*", 101 | "merge-stream": "*", 102 | "mkdirp": "*", 103 | "mocha": "*", 104 | "node-notifier": "*", 105 | "normalize.css": "^7.0.0", 106 | "path-exists": "*", 107 | "phantomjs-prebuilt": "*", 108 | "release-it": "*", 109 | "rollup-plugin-babel": "*", 110 | "rollup-plugin-istanbul": "*", 111 | "sinon": "*", 112 | "sinon-chai": "*", 113 | "stylelint-config-bootstrap": "*", 114 | "stylelint-scss": "*", 115 | "through2": "*" 116 | }, 117 | "engines": { 118 | "node": ">= 6.2.2", 119 | "npm": ">= 3" 120 | }, 121 | "dependencies": { 122 | "jquery": ">=2.2.0", 123 | "jquery-asColor": "^0.3.4", 124 | "jquery-asGradient": "^0.3.2" 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /gulpfile.babel.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import config from './config'; 4 | import fs from 'graceful-fs'; 5 | import gulp from 'gulp'; 6 | import gutil from 'gulp-util'; 7 | 8 | // Tasks 9 | import clean from './gulp/tasks/clean'; 10 | import styles from './gulp/tasks/styles'; 11 | import {version,bundler,scripts} from './gulp/tasks/scripts'; 12 | import * as lintScripts from './gulp/tasks/lint-scripts'; 13 | import * as lintStyles from './gulp/tasks/lint-styles'; 14 | import test from './gulp/tasks/test'; 15 | import * as deploy from './gulp/tasks/deploy'; 16 | import * as browser from './gulp/tasks/browser'; 17 | import * as assets from './gulp/tasks/assets'; 18 | import images from './gulp/tasks/images'; 19 | import archive from './gulp/tasks/archive'; 20 | import release from './gulp/tasks/release'; 21 | 22 | if (config.production) { 23 | gutil.log(gutil.colors.bold.green('� Production Mode')); 24 | } else { 25 | gutil.log(gutil.colors.bold.green('� Development Mode')); 26 | } 27 | 28 | gulp.task('version', version()); 29 | gulp.task('bundler', bundler()); 30 | gulp.task('scripts', scripts()); 31 | gulp.task('clean', clean(config.scripts.dest)); 32 | 33 | // Styles 34 | gulp.task('styles', styles()); 35 | gulp.task('clean:styles', clean(config.styles.dest)); 36 | 37 | // Images 38 | gulp.task('images', images()); 39 | gulp.task('clean:images', clean(config.images.dest)); 40 | 41 | // Build the files 42 | gulp.task('build', gulp.series('clean', 'version', 'bundler', 'scripts', 'styles', 'images')); 43 | 44 | // Assets 45 | gulp.task('assets', assets.copy()); 46 | gulp.task('clean:assets', assets.clean()); 47 | 48 | // Lint Styles 49 | gulp.task('lint:style', lintStyles.style()); 50 | 51 | // Lint Scripts 52 | gulp.task('lint:script:src', lintScripts.es(config.scripts.src)); 53 | gulp.task('lint:script:dest', lintScripts.es(config.scripts.dest)); 54 | gulp.task('lint:script:test', lintScripts.es(config.scripts.test)); 55 | gulp.task('lint:script:gulp', lintScripts.es(config.scripts.gulp, {rules: {'no-console': 'off'}})); 56 | gulp.task('lint:script', gulp.series('lint:script:src', 'lint:script:dest', 'lint:script:test', 'lint:script:gulp')); 57 | 58 | // Run karma for development, will watch and reload 59 | gulp.task('tdd', test()); 60 | 61 | // Run tests and report for ci 62 | gulp.task('test', test({ 63 | singleRun: true, 64 | browsers: ['PhantomJS'], 65 | reporters: ['mocha'] 66 | })); 67 | 68 | gulp.task('coverage', test({ 69 | singleRun: true, 70 | browsers: ['PhantomJS'], 71 | reporters: ['coverage'], 72 | })); 73 | 74 | // Deploy 75 | gulp.task('deploy:prompt', deploy.prompt); 76 | gulp.task('deploy:version', deploy.version); 77 | gulp.task('deploy:message', deploy.message); 78 | gulp.task('deploy:init', deploy.init); 79 | gulp.task('deploy:commit', deploy.commit); 80 | 81 | // Generates compiled CSS and JS files and puts them in the dist/ folder 82 | gulp.task('deploy:dist', gulp.series('build')); 83 | gulp.task('deploy:prepare', gulp.series('deploy:prompt', 'deploy:version', 'deploy:init', 'deploy:dist')); 84 | gulp.task('deploy', gulp.series('deploy:prompt', 'deploy:version', 'deploy:message', 'deploy:dist', 'deploy:commit')); 85 | 86 | // Archive the distrubution files into package 87 | gulp.task('archive', archive()); 88 | 89 | // Starts a BrowerSync instance 90 | gulp.task('serve', browser.init()); 91 | 92 | // Reload browser 93 | gulp.task('reload', browser.reload()); 94 | 95 | // Watch files for changes 96 | gulp.task('watch', () => { 97 | gulp.watch(config.scripts.src, gulp.series('scripts', 'reload')); 98 | gulp.watch(config.styles.src, gulp.series('styles', 'reload')); 99 | }); 100 | 101 | // Release task 102 | gulp.task('release', release()); 103 | 104 | // Dev task 105 | gulp.task('dev', gulp.series('build', 'serve')); 106 | 107 | // Register default task 108 | gulp.task('default', gulp.series('lint:script:src', 'serve')); 109 | -------------------------------------------------------------------------------- /gulp/tasks/scripts.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import config from '../../config'; 4 | import gulp from 'gulp'; 5 | import babel from 'gulp-babel'; 6 | import gulpif from 'gulp-if'; 7 | import sourcemaps from 'gulp-sourcemaps'; 8 | import handleErrors from '../util/handleErrors'; 9 | import getSrcFiles from '../util/getSrcFiles'; 10 | import browser from 'browser-sync'; 11 | import header from 'gulp-header'; 12 | import rename from 'gulp-rename'; 13 | import rollup from 'gulp-rollup'; 14 | import uglify from 'gulp-uglify'; 15 | import size from 'gulp-size'; 16 | import plumber from 'gulp-plumber'; 17 | import prettier from 'gulp-nf-prettier'; 18 | import path from 'path'; 19 | import notify from 'gulp-notify'; 20 | import replace from 'gulp-replace'; 21 | 22 | export function bundler(src = config.scripts.src, dest = config.scripts.dest, input = config.scripts.input, files = config.scripts.files, message = 'Bundler task complete') { 23 | return function () { 24 | let srcFiles = getSrcFiles(src, files); 25 | 26 | return gulp.src(srcFiles) 27 | .on('error', handleErrors) 28 | .pipe(plumber({errorHandler: handleErrors})) 29 | .pipe(rollup({ 30 | input: `${src}/${input}`, 31 | format: 'es', 32 | globals: { 33 | jquery: 'jQuery', 34 | "jquery-asColor": "AsColor", 35 | "jquery-asGradient": "AsGradient" 36 | } 37 | })) 38 | .pipe(header(config.banner)) 39 | .pipe(rename({ 40 | basename: config.name, 41 | suffix: '.es' 42 | })) 43 | .pipe(gulp.dest(dest)) 44 | .pipe(notify({ 45 | title: config.notify.title, 46 | message: message, 47 | onLast: true 48 | })); 49 | }; 50 | } 51 | 52 | export function scripts(src = config.scripts.src, dest = config.scripts.dest, input = config.scripts.input, files = config.scripts.files, message = 'Scripts task complete') { 53 | const createSourcemap = config.deploy || config.scripts.prodSourcemap; 54 | 55 | return function () { 56 | let srcFiles = getSrcFiles(src, files); 57 | 58 | return gulp.src(`${dest}/${config.name}.es.js`) 59 | .on('error', handleErrors) 60 | .pipe(plumber({errorHandler: handleErrors})) 61 | // .pipe(rollup({ 62 | // input: `${src}/${input}`, 63 | // })) 64 | .pipe(babel({ 65 | "presets": ["es2015"], 66 | "plugins": [ 67 | ["transform-es2015-modules-umd", { 68 | "globals": { 69 | "jquery": "jQuery", 70 | "jquery-asColor": "AsColor", 71 | "jquery-asGradient": "AsGradient" 72 | } 73 | }] 74 | ] 75 | })) 76 | .pipe(header(config.banner)) 77 | .pipe( 78 | prettier({ 79 | parser: 'flow', 80 | tabWidth: 2, 81 | useTabs: false, 82 | semi: true, 83 | singleQuote: true, 84 | bracketSpacing: true, 85 | }) 86 | ) 87 | .pipe(rename({ 88 | basename: config.name 89 | })) 90 | .pipe(gulp.dest(dest)) 91 | .pipe(size({ 92 | title: 'scripts', 93 | showFiles: true 94 | })) 95 | .pipe(rename({ 96 | suffix: '.min' 97 | })) 98 | .pipe(gulpif(createSourcemap, sourcemaps.init())) 99 | .pipe(uglify()) 100 | .pipe(header(config.banner)) 101 | .pipe(gulpif( 102 | createSourcemap, 103 | sourcemaps.write(config.deploy ? './' : null)) 104 | ) 105 | .pipe(gulp.dest(dest)) 106 | .pipe(size({ 107 | title: 'minified scripts', 108 | showFiles: true 109 | })) 110 | .pipe(browser.stream()) 111 | .pipe(notify({ 112 | title: config.notify.title, 113 | message: message, 114 | onLast: true 115 | })); 116 | }; 117 | } 118 | 119 | export function version(src = config.scripts.src, file = config.scripts.version) { 120 | return function() { 121 | return gulp.src(path.join(src, file), {base: "./"}) 122 | .pipe(replace(/("{0,1}|'{0,1})version\1\s*:\s*("|')([\d.]+)\2/, `$1version$1:$2${config.version}$2`)) 123 | .pipe(gulp.dest("./", {overwrite: true})); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /examples/js/prism.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Prism: Lightweight, robust, elegant syntax highlighting 3 | * MIT license http://www.opensource.org/licenses/mit-license.php/ 4 | * @author Lea Verou http://lea.verou.me 5 | */(function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=self.Prism={languages:{insertBefore:function(e,n,r,i){i=i||t.languages;var s=i[e],o={};for(var u in s)if(s.hasOwnProperty(u)){if(u==n)for(var a in r)r.hasOwnProperty(a)&&(o[a]=r[a]);o[u]=s[u]}return i[e]=o},DFS:function(e,n){for(var r in e){n.call(e,r,e[r]);Object.prototype.toString.call(e)==="[object Object]"&&t.languages.DFS(e[r],n)}}},highlightAll:function(e,n){var r=document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code');for(var i=0,s;s=r[i++];)t.highlightElement(s,e===!0,n)},highlightElement:function(r,i,s){var o,u,a=r;while(a&&!e.test(a.className))a=a.parentNode;if(a){o=(a.className.match(e)||[,""])[1];u=t.languages[o]}if(!u)return;r.className=r.className.replace(e,"").replace(/\s+/g," ")+" language-"+o;a=r.parentNode;/pre/i.test(a.nodeName)&&(a.className=a.className.replace(e,"").replace(/\s+/g," ")+" language-"+o);var f=r.textContent.trim();if(!f)return;f=f.replace(/&/g,"&").replace(//g,">").replace(/\u00a0/g," ");var l={element:r,language:o,grammar:u,code:f};t.hooks.run("before-highlight",l);if(i&&self.Worker){var c=new Worker(t.filename);c.onmessage=function(e){l.highlightedCode=n.stringify(JSON.parse(e.data));l.element.innerHTML=l.highlightedCode;s&&s.call(l.element);t.hooks.run("after-highlight",l)};c.postMessage(JSON.stringify({language:l.language,code:l.code}))}else{l.highlightedCode=t.highlight(l.code,l.grammar);l.element.innerHTML=l.highlightedCode;s&&s.call(r);t.hooks.run("after-highlight",l)}},highlight:function(e,r){return n.stringify(t.tokenize(e,r))},tokenize:function(e,n){var r=t.Token,i=[e],s=n.rest;if(s){for(var o in s)n[o]=s[o];delete n.rest}e:for(var o in n){if(!n.hasOwnProperty(o)||!n[o])continue;var u=n[o],a=u.inside,f=!!u.lookbehind||0;u=u.pattern||u;for(var l=0;le.length)break e;if(c instanceof r)continue;u.lastIndex=0;var h=u.exec(c);if(h){f&&(f=h[1].length);var p=h.index-1+f,h=h[0].slice(f),d=h.length,v=p+d,m=c.slice(0,p+1),g=c.slice(v+1),y=[l,1];m&&y.push(m);var b=new r(o,a?t.tokenize(h,a):h);y.push(b);g&&y.push(g);Array.prototype.splice.apply(i,y)}}}return i},hooks:{all:{},add:function(e,n){var r=t.hooks.all;r[e]=r[e]||[];r[e].push(n)},run:function(e,n){var r=t.hooks.all[e];if(!r||!r.length)return;for(var i=0,s;s=r[i++];)s(n)}}},n=t.Token=function(e,t){this.type=e;this.content=t};n.stringify=function(e){if(typeof e=="string")return e;if(Object.prototype.toString.call(e)=="[object Array]"){for(var r=0;r"+i.content+""};if(!self.document){self.addEventListener("message",function(e){var n=JSON.parse(e.data),r=n.language,i=n.code;self.postMessage(JSON.stringify(t.tokenize(i,t.languages[r])));self.close()},!1);return}var r=document.getElementsByTagName("script");r=r[r.length-1];if(r){t.filename=r.src;document.addEventListener&&!r.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)}})(); 6 | Prism.languages.markup={comment:/<!--[\w\W]*?--(>|>)/g,prolog:/<\?.+?\?>/,doctype:/<!DOCTYPE.+?>/,cdata:/<!\[CDATA\[[\w\W]+?]]>/i,tag:{pattern:/<\/?[\w:-]+\s*[\w\W]*?>/gi,inside:{tag:{pattern:/^<\/?[\w:-]+/i,inside:{punctuation:/^<\/?/,namespace:/^[\w-]+?:/}},"attr-value":{pattern:/=(('|")[\w\W]*?(\2)|[^\s>]+)/gi,inside:{punctuation:/=/g}},punctuation:/\/?>/g,"attr-name":{pattern:/[\w:-]+/g,inside:{namespace:/^[\w-]+?:/}}}},entity:/&#?[\da-z]{1,8};/gi};Prism.hooks.add("wrap",function(e){e.type==="entity"&&(e.attributes.title=e.content.replace(/&/,"&"))}); 7 | Prism.languages.css={comment:/\/\*[\w\W]*?\*\//g,atrule:/@[\w-]+?(\s+.+)?(?=\s*{|\s*;)/gi,url:/url\((["']?).*?\1\)/gi,selector:/[^\{\}\s][^\{\}]*(?=\s*\{)/g,property:/(\b|\B)[a-z-]+(?=\s*:)/ig,string:/("|')(\\?.)*?\1/g,important:/\B!important\b/gi,ignore:/&(lt|gt|amp);/gi,punctuation:/[\{\};:]/g};Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{style:{pattern:/(<|<)style[\w\W]*?(>|>)[\w\W]*?(<|<)\/style(>|>)/ig,inside:{tag:{pattern:/(<|<)style[\w\W]*?(>|>)|(<|<)\/style(>|>)/ig,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.css}}}); 8 | Prism.languages.javascript={comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*?(\r?\n|$))/g,lookbehind:!0},string:/("|')(\\?.)*?\1/g,regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/g,lookbehind:!0},keyword:/\b(var|let|if|else|while|do|for|return|in|instanceof|function|new|with|typeof|try|catch|finally|null|break|continue)\b/g,"boolean":/\b(true|false)\b/g,number:/\b-?(0x)?\d*\.?\d+\b/g,operator:/[-+]{1,2}|!|=?<|=?>|={1,2}|(&){1,2}|\|?\||\?|\*|\//g,ignore:/&(lt|gt|amp);/gi,punctuation:/[{}[\];(),.:]/g};Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/(<|<)script[\w\W]*?(>|>)[\w\W]*?(<|<)\/script(>|>)/ig,inside:{tag:{pattern:/(<|<)script[\w\W]*?(>|>)|(<|<)\/script(>|>)/ig,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript}}}); 9 | -------------------------------------------------------------------------------- /src/components/saturation.js: -------------------------------------------------------------------------------- 1 | import AsColor from 'jquery-asColor'; 2 | 3 | // saturation 4 | export default { 5 | defaults: { 6 | template(namespace) { 7 | return `
    `; 8 | } 9 | }, 10 | 11 | width: 0, 12 | height: 0, 13 | size: 6, 14 | data: {}, 15 | 16 | init: function(api, options) { 17 | const that = this; 18 | this.options = $.extend(this.defaults, options); 19 | this.api = api; 20 | 21 | //build element and add component to picker 22 | this.$saturation = $(this.options.template.call(that, api.namespace)).appendTo(api.$dropdown); 23 | this.$handle = this.$saturation.find('i'); 24 | 25 | api.$element.on('asColorPicker::firstOpen', () => { 26 | // init variable 27 | that.width = that.$saturation.width(); 28 | that.height = that.$saturation.height(); 29 | that.step = { 30 | left: that.width / 20, 31 | top: that.height / 20 32 | }; 33 | that.size = that.$handle.width() / 2; 34 | 35 | // bind events 36 | that.bindEvents(); 37 | that.keyboard(api); 38 | }); 39 | 40 | api.$element.on('asColorPicker::update asColorPicker::setup', (e, api, color) => { 41 | that.update(color); 42 | }); 43 | }, 44 | 45 | bindEvents: function() { 46 | const that = this; 47 | 48 | this.$saturation.on(this.api.eventName('mousedown'), e => { 49 | const rightclick = (e.which) ? (e.which === 3) : (e.button === 2); 50 | if (rightclick) { 51 | return false; 52 | } 53 | that.mousedown(e); 54 | }); 55 | }, 56 | 57 | mousedown: function(e) { 58 | const offset = this.$saturation.offset(); 59 | 60 | this.data.startY = e.pageY; 61 | this.data.startX = e.pageX; 62 | this.data.top = e.pageY - offset.top; 63 | this.data.left = e.pageX - offset.left; 64 | this.data.cach = {}; 65 | 66 | this.move(this.data.left, this.data.top); 67 | 68 | this.mousemove = function(e) { 69 | const x = this.data.left + (e.pageX || this.data.startX) - this.data.startX; 70 | const y = this.data.top + (e.pageY || this.data.startY) - this.data.startY; 71 | this.move(x, y); 72 | return false; 73 | }; 74 | 75 | this.mouseup = function() { 76 | $(document).off({ 77 | mousemove: this.mousemove, 78 | mouseup: this.mouseup 79 | }); 80 | this.data.left = this.data.cach.left; 81 | this.data.top = this.data.cach.top; 82 | 83 | return false; 84 | }; 85 | 86 | $(document).on({ 87 | mousemove: $.proxy(this.mousemove, this), 88 | mouseup: $.proxy(this.mouseup, this) 89 | }); 90 | 91 | return false; 92 | }, 93 | 94 | move: function(x, y, update) { 95 | y = Math.max(0, Math.min(this.height, y)); 96 | x = Math.max(0, Math.min(this.width, x)); 97 | 98 | if (this.data.cach === undefined) { 99 | this.data.cach = {}; 100 | } 101 | this.data.cach.left = x; 102 | this.data.cach.top = y; 103 | 104 | this.$handle.css({ 105 | top: y - this.size, 106 | left: x - this.size 107 | }); 108 | 109 | if (update !== false) { 110 | this.api.set({ 111 | s: x / this.width, 112 | v: 1 - (y / this.height) 113 | }); 114 | } 115 | }, 116 | 117 | update: function(color) { 118 | if (color.value.h === undefined) { 119 | color.value.h = 0; 120 | } 121 | this.$saturation.css('backgroundColor', AsColor.HSLtoHEX({ 122 | h: color.value.h, 123 | s: 1, 124 | l: 0.5 125 | })); 126 | 127 | const x = color.value.s * this.width; 128 | const y = (1 - color.value.v) * this.height; 129 | 130 | this.move(x, y, false); 131 | }, 132 | 133 | moveLeft: function() { 134 | const step = this.step.left; 135 | const data = this.data; 136 | data.left = Math.max(0, Math.min(this.width, data.left - step)); 137 | this.move(data.left, data.top); 138 | }, 139 | 140 | moveRight: function() { 141 | const step = this.step.left; 142 | const data = this.data; 143 | data.left = Math.max(0, Math.min(this.width, data.left + step)); 144 | this.move(data.left, data.top); 145 | }, 146 | 147 | moveUp: function() { 148 | const step = this.step.top; 149 | const data = this.data; 150 | data.top = Math.max(0, Math.min(this.width, data.top - step)); 151 | this.move(data.left, data.top); 152 | }, 153 | 154 | moveDown: function() { 155 | const step = this.step.top; 156 | const data = this.data; 157 | data.top = Math.max(0, Math.min(this.width, data.top + step)); 158 | this.move(data.left, data.top); 159 | }, 160 | 161 | keyboard: function() { 162 | let keyboard; 163 | const that = this; 164 | if (this.api._keyboard) { 165 | keyboard = $.extend(true, {}, this.api._keyboard); 166 | } else { 167 | return false; 168 | } 169 | 170 | this.$saturation.attr('tabindex', '0').on('focus', () => { 171 | keyboard.attach({ 172 | left() { 173 | that.moveLeft(); 174 | }, 175 | right() { 176 | that.moveRight(); 177 | }, 178 | up() { 179 | that.moveUp(); 180 | }, 181 | down() { 182 | that.moveDown(); 183 | } 184 | }); 185 | return false; 186 | }).on('blur', () => { 187 | keyboard.detach(); 188 | }); 189 | }, 190 | 191 | destroy: function() { 192 | $(document).off({ 193 | mousemove: this.mousemove, 194 | mouseup: this.mouseup 195 | }); 196 | } 197 | }; 198 | -------------------------------------------------------------------------------- /src/components/hue.js: -------------------------------------------------------------------------------- 1 | // hue 2 | export default { 3 | size: 150, 4 | 5 | defaults: { 6 | direction: 'vertical', // horizontal 7 | template() { 8 | const namespace = this.api.namespace; 9 | return `
    `; 10 | } 11 | }, 12 | 13 | data: {}, 14 | 15 | init: function(api, options) { 16 | const that = this; 17 | 18 | this.options = $.extend(this.defaults, options); 19 | this.direction = this.options.direction; 20 | this.api = api; 21 | 22 | this.$hue = $(this.options.template.call(that)).appendTo(api.$dropdown); 23 | this.$handle = this.$hue.find('i'); 24 | 25 | api.$element.on('asColorPicker::firstOpen', () => { 26 | // init variable 27 | if (that.direction === 'vertical') { 28 | that.size = that.$hue.height(); 29 | } else { 30 | that.size = that.$hue.width(); 31 | } 32 | that.step = that.size / 360; 33 | 34 | // bind events 35 | that.bindEvents(api); 36 | that.keyboard(api); 37 | }); 38 | 39 | api.$element.on('asColorPicker::update asColorPicker::setup', (e, api, color) => { 40 | that.update(color); 41 | }); 42 | }, 43 | 44 | bindEvents: function() { 45 | const that = this; 46 | this.$hue.on(this.api.eventName('mousedown'), e => { 47 | const rightclick = (e.which) ? (e.which === 3) : (e.button === 2); 48 | if (rightclick) { 49 | return false; 50 | } 51 | $.proxy(that.mousedown, that)(e); 52 | }); 53 | }, 54 | 55 | mousedown: function(e) { 56 | const offset = this.$hue.offset(); 57 | if (this.direction === 'vertical') { 58 | this.data.startY = e.pageY; 59 | this.data.top = e.pageY - offset.top; 60 | this.move(this.data.top); 61 | } else { 62 | this.data.startX = e.pageX; 63 | this.data.left = e.pageX - offset.left; 64 | this.move(this.data.left); 65 | } 66 | 67 | this.mousemove = function(e) { 68 | let position; 69 | if (this.direction === 'vertical') { 70 | position = this.data.top + (e.pageY || this.data.startY) - this.data.startY; 71 | } else { 72 | position = this.data.left + (e.pageX || this.data.startX) - this.data.startX; 73 | } 74 | 75 | this.move(position); 76 | return false; 77 | }; 78 | 79 | this.mouseup = function() { 80 | $(document).off({ 81 | mousemove: this.mousemove, 82 | mouseup: this.mouseup 83 | }); 84 | if (this.direction === 'vertical') { 85 | this.data.top = this.data.cach; 86 | } else { 87 | this.data.left = this.data.cach; 88 | } 89 | 90 | return false; 91 | }; 92 | 93 | $(document).on({ 94 | mousemove: $.proxy(this.mousemove, this), 95 | mouseup: $.proxy(this.mouseup, this) 96 | }); 97 | 98 | return false; 99 | }, 100 | 101 | move: function(position, hub, update) { 102 | position = Math.max(0, Math.min(this.size, position)); 103 | this.data.cach = position; 104 | if (typeof hub === 'undefined') { 105 | hub = (1 - position / this.size) * 360; 106 | } 107 | hub = Math.max(0, Math.min(360, hub)); 108 | if (this.direction === 'vertical') { 109 | this.$handle.css({ 110 | top: position 111 | }); 112 | } else { 113 | this.$handle.css({ 114 | left: position 115 | }); 116 | } 117 | if (update !== false) { 118 | this.api.set({ 119 | h: hub 120 | }); 121 | } 122 | }, 123 | 124 | moveLeft: function() { 125 | const step = this.step; 126 | const data = this.data; 127 | data.left = Math.max(0, Math.min(this.width, data.left - step)); 128 | this.move(data.left); 129 | }, 130 | 131 | moveRight: function() { 132 | const step = this.step; 133 | const data = this.data; 134 | data.left = Math.max(0, Math.min(this.width, data.left + step)); 135 | this.move(data.left); 136 | }, 137 | 138 | moveUp: function() { 139 | const step = this.step; 140 | const data = this.data; 141 | data.top = Math.max(0, Math.min(this.width, data.top - step)); 142 | this.move(data.top); 143 | }, 144 | 145 | moveDown: function() { 146 | const step = this.step; 147 | const data = this.data; 148 | data.top = Math.max(0, Math.min(this.width, data.top + step)); 149 | this.move(data.top); 150 | }, 151 | 152 | keyboard: function() { 153 | let keyboard; 154 | const that = this; 155 | if (this.api._keyboard) { 156 | keyboard = $.extend(true, {}, this.api._keyboard); 157 | } else { 158 | return false; 159 | } 160 | 161 | this.$hue.attr('tabindex', '0').on('focus', function() { 162 | if (this.direction === 'vertical') { 163 | keyboard.attach({ 164 | up() { 165 | that.moveUp(); 166 | }, 167 | down() { 168 | that.moveDown(); 169 | } 170 | }); 171 | } else { 172 | keyboard.attach({ 173 | left() { 174 | that.moveLeft(); 175 | }, 176 | right() { 177 | that.moveRight(); 178 | } 179 | }); 180 | } 181 | return false; 182 | }).on('blur', () => { 183 | keyboard.detach(); 184 | }); 185 | }, 186 | 187 | update: function(color) { 188 | const position = (color.value.h === 0) ? 0 : this.size * (1 - color.value.h / 360); 189 | this.move(position, color.value.h, false); 190 | }, 191 | 192 | destroy: function() { 193 | $(document).off({ 194 | mousemove: this.mousemove, 195 | mouseup: this.mouseup 196 | }); 197 | } 198 | }; 199 | -------------------------------------------------------------------------------- /src/components/alpha.js: -------------------------------------------------------------------------------- 1 | // alpha 2 | export default { 3 | size: 150, 4 | 5 | defaults: { 6 | direction: 'vertical', // horizontal 7 | template(namespace) { 8 | return `
    `; 9 | } 10 | }, 11 | 12 | data: {}, 13 | 14 | init: function(api, options) { 15 | const that = this; 16 | 17 | this.options = $.extend(this.defaults, options); 18 | that.direction = this.options.direction; 19 | this.api = api; 20 | 21 | this.$alpha = $(this.options.template.call(that, api.namespace)).appendTo(api.$dropdown); 22 | this.$handle = this.$alpha.find('i'); 23 | 24 | api.$element.on('asColorPicker::firstOpen', () => { 25 | // init variable 26 | if (that.direction === 'vertical') { 27 | that.size = that.$alpha.height(); 28 | } else { 29 | that.size = that.$alpha.width(); 30 | } 31 | that.step = that.size / 360; 32 | 33 | // bind events 34 | that.bindEvents(); 35 | that.keyboard(); 36 | }); 37 | 38 | api.$element.on('asColorPicker::update asColorPicker::setup', (e, api, color) => { 39 | that.update(color); 40 | }); 41 | }, 42 | 43 | bindEvents: function() { 44 | const that = this; 45 | this.$alpha.on(this.api.eventName('mousedown'), e => { 46 | const rightclick = (e.which) ? (e.which === 3) : (e.button === 2); 47 | if (rightclick) { 48 | return false; 49 | } 50 | $.proxy(that.mousedown, that)(e); 51 | }); 52 | }, 53 | 54 | mousedown: function(e) { 55 | const offset = this.$alpha.offset(); 56 | if (this.direction === 'vertical') { 57 | this.data.startY = e.pageY; 58 | this.data.top = e.pageY - offset.top; 59 | this.move(this.data.top); 60 | } else { 61 | this.data.startX = e.pageX; 62 | this.data.left = e.pageX - offset.left; 63 | this.move(this.data.left); 64 | } 65 | 66 | this.mousemove = function(e) { 67 | let position; 68 | if (this.direction === 'vertical') { 69 | position = this.data.top + (e.pageY || this.data.startY) - this.data.startY; 70 | } else { 71 | position = this.data.left + (e.pageX || this.data.startX) - this.data.startX; 72 | } 73 | 74 | this.move(position); 75 | return false; 76 | }; 77 | 78 | this.mouseup = function() { 79 | $(document).off({ 80 | mousemove: this.mousemove, 81 | mouseup: this.mouseup 82 | }); 83 | if (this.direction === 'vertical') { 84 | this.data.top = this.data.cach; 85 | } else { 86 | this.data.left = this.data.cach; 87 | } 88 | 89 | return false; 90 | }; 91 | 92 | $(document).on({ 93 | mousemove: $.proxy(this.mousemove, this), 94 | mouseup: $.proxy(this.mouseup, this) 95 | }); 96 | return false; 97 | }, 98 | 99 | move: function(position, alpha, update) { 100 | position = Math.max(0, Math.min(this.size, position)); 101 | this.data.cach = position; 102 | if (typeof alpha === 'undefined') { 103 | alpha = 1 - (position / this.size); 104 | } 105 | alpha = Math.max(0, Math.min(1, alpha)); 106 | if (this.direction === 'vertical') { 107 | this.$handle.css({ 108 | top: position 109 | }); 110 | } else { 111 | this.$handle.css({ 112 | left: position 113 | }); 114 | } 115 | 116 | if (update !== false) { 117 | this.api.set({ 118 | a: Math.round(alpha * 100) / 100 119 | }); 120 | } 121 | }, 122 | 123 | moveLeft: function() { 124 | const step = this.step; 125 | const data = this.data; 126 | data.left = Math.max(0, Math.min(this.width, data.left - step)); 127 | this.move(data.left); 128 | }, 129 | 130 | moveRight: function() { 131 | const step = this.step; 132 | const data = this.data; 133 | data.left = Math.max(0, Math.min(this.width, data.left + step)); 134 | this.move(data.left); 135 | }, 136 | 137 | moveUp: function() { 138 | const step = this.step; 139 | const data = this.data; 140 | data.top = Math.max(0, Math.min(this.width, data.top - step)); 141 | this.move(data.top); 142 | }, 143 | 144 | moveDown: function() { 145 | const step = this.step; 146 | const data = this.data; 147 | data.top = Math.max(0, Math.min(this.width, data.top + step)); 148 | this.move(data.top); 149 | }, 150 | 151 | keyboard: function() { 152 | let keyboard; 153 | const that = this; 154 | if (this.api._keyboard) { 155 | keyboard = $.extend(true, {}, this.api._keyboard); 156 | } else { 157 | return false; 158 | } 159 | 160 | this.$alpha.attr('tabindex', '0').on('focus', function() { 161 | if (this.direction === 'vertical') { 162 | keyboard.attach({ 163 | up() { 164 | that.moveUp(); 165 | }, 166 | down() { 167 | that.moveDown(); 168 | } 169 | }); 170 | } else { 171 | keyboard.attach({ 172 | left() { 173 | that.moveLeft(); 174 | }, 175 | right() { 176 | that.moveRight(); 177 | } 178 | }); 179 | } 180 | return false; 181 | }).on('blur', () => { 182 | keyboard.detach(); 183 | }); 184 | }, 185 | 186 | update: function(color) { 187 | const position = this.size * (1 - color.value.a); 188 | this.$alpha.css('backgroundColor', color.toHEX()); 189 | 190 | this.move(position, color.value.a, false); 191 | }, 192 | 193 | destroy: function() { 194 | $(document).off({ 195 | mousemove: this.mousemove, 196 | mouseup: this.mouseup 197 | }); 198 | } 199 | }; 200 | -------------------------------------------------------------------------------- /dist/css/asColorPicker.min.css: -------------------------------------------------------------------------------- 1 | /** 2 | * asColorPicker v0.4.4 3 | * https://github.com/amazingSurge/jquery-asColorPicker 4 | * 5 | * Copyright (c) amazingSurge 6 | * Released under the LGPL-3.0 license 7 | */ 8 | .asColorPicker-wrap{position:relative;display:inline-block}.asColorPicker_hideInput,.asColorPicker_hideInput .asColorPicker-clear{display:none}.asColorPicker-dropdown{position:absolute;z-index:9999;display:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.asColorPicker-dropdown *{padding:0;margin:0}.asColorPicker_open{display:block}.asColorPicker-mask{position:fixed;top:0;left:0;z-index:9998;width:100%;height:100%}.asColorPicker-trigger{position:relative;display:inline-block;width:18px;height:20px;cursor:pointer;background-image:url(../images/transparent.png)}.asColorPicker-trigger span{display:inline-block;width:100%;height:100%}.asColorPicker-input,.asColorPicker-trigger{vertical-align:middle}.asColorPicker-clear{position:absolute;top:0;right:26px;display:none;color:#777;text-decoration:none}.asColorPicker-clear:after{content:"x"}.asColorPicker-wrap:hover .asColorPicker-clear{display:inline-block}.asColorPicker-preview{float:left;list-style:none}.asColorPicker-preview li{display:inline-block;vertical-align:top;background-image:url(../images/transparent.png);*display:inline;*zoom:1}.asColorPicker-preview li span{display:block;height:100%}.asColorPicker-preview-previous{cursor:pointer}.asColorPicker-palettes ul{display:block}.asColorPicker-palettes ul:after,.asColorPicker-palettes ul:before{display:table;content:""}.asColorPicker-palettes ul:after{clear:both}.asColorPicker-palettes li{display:block;float:left;overflow:hidden;text-indent:100%;white-space:nowrap;cursor:pointer;background-image:url(../images/transparent.png)}.asColorPicker-palettes li span{display:block;height:100%}.asColorPicker-saturation{position:relative;display:inline-block;width:175px;height:175px;clear:both;background-image:url(../images/saturation.png);*display:inline;*zoom:1}.asColorPicker-saturation i{position:absolute}.asColorPicker-alpha,.asColorPicker-hue{position:relative;display:inline-block;width:20px;height:175px;cursor:pointer;*display:inline;*zoom:1}.asColorPicker-alpha i,.asColorPicker-hue i{position:absolute;cursor:row-resize}.asColorPicker-hue{background-image:url(../images/hue.png)}.asColorPicker-alpha{background-image:url(../images/alpha.png)}.asColorPicker-buttons a,.asColorPicker-gradient-control a{text-decoration:none;cursor:pointer}.asColorPicker-gradient{display:none}.asColorPicker-gradient_enable{display:block}.asColorPicker-gradient-preview{float:left;height:20px}.asColorPicker-gradient-markers{position:relative;width:100%}.asColorPicker-gradient-marker{position:absolute;outline:none}.asColorPicker-gradient-wheel{position:relative;float:left;width:20px;height:20px;border:1px solid #bbb;border-radius:100%}.asColorPicker-gradient-wheel i{position:absolute;width:3px;height:3px;border-radius:100%}.asColorPicker-gradient-angle{float:left}.asColorPicker-dropdown{min-width:205px;max-width:235px;padding:10px;background:#fefefe;border:1px solid #bbb}[data-mode=palettes] .asColorPicker-dropdown{min-width:auto;max-width:auto}.asColorPicker-trigger{border:1px solid #bbb}.asColorPicker-saturation{-webkit-box-shadow:inset 0 0 0 1px rgba(0,0,0,.05);box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.asColorPicker-saturation i{width:5px;height:5px;margin-top:-2px;margin-left:-2px;border:2px solid #fff;border-radius:100%}.asColorPicker-alpha,.asColorPicker-hue{margin-left:10px;-webkit-box-shadow:inset 0 0 0 1px rgba(0,0,0,.05);box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.asColorPicker-alpha i,.asColorPicker-hue i{left:-2px;width:20px;height:2px;margin-top:-2px;border:2px solid #fff}.asColorPicker-preview{position:relative;height:33px;margin-right:10px;margin-bottom:10px}.asColorPicker-preview:after{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;content:"";-webkit-box-shadow:inset 0 0 0 1px rgba(0,0,0,.05);box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.asColorPicker-preview li{width:48px;height:33px}.asColorPicker-hex{width:100px;border-color:rgba(0,0,0,.05)}.asColorPicker-palettes li{width:21px;height:15px;margin-right:6px;margin-bottom:3px}.asColorPicker-palettes li span{-webkit-box-sizing:border-box;box-sizing:border-box;border:1px solid rgba(0,0,0,.05)}.asColorPicker-palettes li:nth-child(5n){margin-right:0}[data-mode=palettes] .asColorPicker-palettes li:nth-child(5n){margin-right:6px}.asColorPicker-buttons,.asColorPicker-gradient-control{float:right}.asColorPicker-buttons a,.asColorPicker-gradient-control a{margin-left:5px}.asColorPicker-gradient{padding-top:20px;margin-top:10px;border-top:1px solid rgba(0,0,0,.05)}.asColorPicker-gradient-preview{position:relative;width:160px;border:1px solid rgba(0,0,0,.05)}.asColorPicker-gradient-preview:after{position:absolute;top:0;left:0;z-index:-1;width:100%;height:100%;content:"";background-image:url(../images/transparent.png)}.asColorPicker-gradient-markers{top:-16px;display:block;width:160px;height:16px;padding:0;margin:0;list-style:none}.asColorPicker-gradient-marker{width:10px;height:10px;margin-left:-6px;background:#fff;border:1px solid #bbb}.asColorPicker-gradient-marker span{display:block;width:100%;height:100%}.asColorPicker-gradient-marker i{position:absolute;bottom:-3px;left:2px;width:4px;height:4px;background:#fff;border:1px solid transparent;border-right-color:rgba(0,0,0,.05);border-bottom-color:rgba(0,0,0,.05);-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg)}.asColorPicker-gradient-marker_active{z-index:1;border:2px solid #41a9e5}.asColorPicker-gradient-marker_active i{left:1px;border:2px solid transparent;border-right-color:#41a9e5;border-bottom-color:#41a9e5}.asColorPicker-gradient-wheel{margin-left:10px}.asColorPicker-gradient-wheel i{background-color:#888}.asColorPicker-gradient-angle{width:24px;margin-left:10px} 9 | /*# sourceMappingURL=asColorPicker.min.css.map */ 10 | -------------------------------------------------------------------------------- /examples/js/jquery.toc.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * toc - jQuery Table of Contents Plugin 3 | * v0.3.2 4 | * http://projects.jga.me/toc/ 5 | * copyright Greg Allen 2014 6 | * MIT License 7 | */ 8 | /*! 9 | * smooth-scroller - Javascript lib to handle smooth scrolling 10 | * v0.1.2 11 | * https://github.com/firstandthird/smooth-scroller 12 | * copyright First+Third 2014 13 | * MIT License 14 | */ 15 | //smooth-scroller.js 16 | 17 | (function($) { 18 | $.fn.smoothScroller = function(options) { 19 | options = $.extend({}, $.fn.smoothScroller.defaults, options); 20 | var el = $(this); 21 | 22 | $(options.scrollEl).animate({ 23 | scrollTop: el.offset().top - $(options.scrollEl).offset().top - options.offset 24 | }, options.speed, options.ease, function() { 25 | var hash = el.attr('id'); 26 | 27 | if(hash.length) { 28 | if(history.pushState) { 29 | history.pushState(null, null, '#' + hash); 30 | } else { 31 | document.location.hash = hash; 32 | } 33 | } 34 | 35 | el.trigger('smoothScrollerComplete'); 36 | }); 37 | 38 | return this; 39 | }; 40 | 41 | $.fn.smoothScroller.defaults = { 42 | speed: 400, 43 | ease: 'swing', 44 | scrollEl: 'body,html', 45 | offset: 0 46 | }; 47 | 48 | $('body').on('click', '[data-smoothscroller]', function(e) { 49 | e.preventDefault(); 50 | var href = $(this).attr('href'); 51 | 52 | if(href.indexOf('#') === 0) { 53 | $(href).smoothScroller(); 54 | } 55 | }); 56 | }(jQuery)); 57 | 58 | (function($) { 59 | var verboseIdCache = {}; 60 | $.fn.toc = function(options) { 61 | var self = this; 62 | var opts = $.extend({}, jQuery.fn.toc.defaults, options); 63 | 64 | var container = $(opts.container); 65 | var headings = $(opts.selectors, container); 66 | var headingOffsets = []; 67 | var activeClassName = opts.activeClass; 68 | 69 | var scrollTo = function(e, callback) { 70 | if (opts.smoothScrolling && typeof opts.smoothScrolling === 'function') { 71 | e.preventDefault(); 72 | var elScrollTo = $(e.target).attr('href'); 73 | 74 | opts.smoothScrolling(elScrollTo, opts, callback); 75 | } 76 | $('li', self).removeClass(activeClassName); 77 | $(e.target).parent().addClass(activeClassName); 78 | }; 79 | 80 | //highlight on scroll 81 | var timeout; 82 | var highlightOnScroll = function(e) { 83 | if (timeout) { 84 | clearTimeout(timeout); 85 | } 86 | timeout = setTimeout(function() { 87 | var top = $(window).scrollTop(), 88 | highlighted, closest = Number.MAX_VALUE, index = 0; 89 | 90 | for (var i = 0, c = headingOffsets.length; i < c; i++) { 91 | var currentClosest = Math.abs(headingOffsets[i] - top); 92 | if (currentClosest < closest) { 93 | index = i; 94 | closest = currentClosest; 95 | } 96 | } 97 | 98 | $('li', self).removeClass(activeClassName); 99 | highlighted = $('li:eq('+ index +')', self).addClass(activeClassName); 100 | opts.onHighlight(highlighted); 101 | }, 50); 102 | }; 103 | if (opts.highlightOnScroll) { 104 | $(window).bind('scroll', highlightOnScroll); 105 | highlightOnScroll(); 106 | } 107 | 108 | return this.each(function() { 109 | //build TOC 110 | var el = $(this); 111 | var ul = $(opts.listType); 112 | 113 | headings.each(function(i, heading) { 114 | var $h = $(heading); 115 | headingOffsets.push($h.offset().top - opts.highlightOffset); 116 | 117 | var anchorName = opts.anchorName(i, heading, opts.prefix); 118 | 119 | //add anchor 120 | if(heading.id !== anchorName) { 121 | var anchor = $('').attr('id', anchorName).insertBefore($h); 122 | } 123 | 124 | //build TOC item 125 | var a = $('') 126 | .text(opts.headerText(i, heading, $h)) 127 | .attr('href', '#' + anchorName) 128 | .bind('click', function(e) { 129 | $(window).unbind('scroll', highlightOnScroll); 130 | scrollTo(e, function() { 131 | $(window).bind('scroll', highlightOnScroll); 132 | }); 133 | el.trigger('selected', $(this).attr('href')); 134 | }); 135 | 136 | var li = $('
  • ') 137 | .addClass(opts.itemClass(i, heading, $h, opts.prefix)) 138 | .append(a); 139 | 140 | ul.append(li); 141 | }); 142 | el.html(ul); 143 | }); 144 | }; 145 | 146 | 147 | jQuery.fn.toc.defaults = { 148 | container: 'body', 149 | listType: '