From 26105034da4fcce7ac883c899d781f016559310d Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 8 Nov 2018 00:38:48 +0800 Subject: switch to vuepress --- node_modules/select/.editorconfig | 22 +++++++ node_modules/select/.npmignore | 1 + node_modules/select/.travis.yml | 3 + node_modules/select/bower.json | 13 ++++ node_modules/select/demo/contenteditable.html | 26 ++++++++ node_modules/select/demo/dropdown.html | 30 +++++++++ node_modules/select/demo/editable.html | 26 ++++++++ node_modules/select/demo/multiple.html | 28 ++++++++ node_modules/select/demo/nested.html | 34 ++++++++++ node_modules/select/demo/non-editable.html | 26 ++++++++ node_modules/select/dist/select.js | 47 ++++++++++++++ node_modules/select/karma.conf.js | 23 +++++++ node_modules/select/package.json | 29 +++++++++ node_modules/select/readme.md | 49 ++++++++++++++ node_modules/select/src/select.js | 43 +++++++++++++ node_modules/select/test/select.js | 93 +++++++++++++++++++++++++++ 16 files changed, 493 insertions(+) create mode 100644 node_modules/select/.editorconfig create mode 100644 node_modules/select/.npmignore create mode 100644 node_modules/select/.travis.yml create mode 100644 node_modules/select/bower.json create mode 100644 node_modules/select/demo/contenteditable.html create mode 100644 node_modules/select/demo/dropdown.html create mode 100644 node_modules/select/demo/editable.html create mode 100644 node_modules/select/demo/multiple.html create mode 100644 node_modules/select/demo/nested.html create mode 100644 node_modules/select/demo/non-editable.html create mode 100644 node_modules/select/dist/select.js create mode 100644 node_modules/select/karma.conf.js create mode 100644 node_modules/select/package.json create mode 100644 node_modules/select/readme.md create mode 100644 node_modules/select/src/select.js create mode 100644 node_modules/select/test/select.js (limited to 'node_modules/select') diff --git a/node_modules/select/.editorconfig b/node_modules/select/.editorconfig new file mode 100644 index 00000000..0f1d01bd --- /dev/null +++ b/node_modules/select/.editorconfig @@ -0,0 +1,22 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# http://editorconfig.org + +root = true + +[*] +# Change these settings to your own preference +indent_style = space +indent_size = 4 + +# We recommend you to keep these unchanged +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false + +[{package.json,bower.json}] +indent_size = 2 diff --git a/node_modules/select/.npmignore b/node_modules/select/.npmignore new file mode 100644 index 00000000..b512c09d --- /dev/null +++ b/node_modules/select/.npmignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/node_modules/select/.travis.yml b/node_modules/select/.travis.yml new file mode 100644 index 00000000..833d09d1 --- /dev/null +++ b/node_modules/select/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: + - stable diff --git a/node_modules/select/bower.json b/node_modules/select/bower.json new file mode 100644 index 00000000..281b34ca --- /dev/null +++ b/node_modules/select/bower.json @@ -0,0 +1,13 @@ +{ + "name": "select", + "version": "1.1.0", + "description": "Programmatically select the text of a HTML element", + "license": "MIT", + "main": "dist/select.js", + "keywords": [ + "range", + "select", + "selecting", + "selection" + ] +} diff --git a/node_modules/select/demo/contenteditable.html b/node_modules/select/demo/contenteditable.html new file mode 100644 index 00000000..47f9b993 --- /dev/null +++ b/node_modules/select/demo/contenteditable.html @@ -0,0 +1,26 @@ + + + + + contenteditable + + + + +

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio totam adipisci, saepe ad vero dignissimos laborum non eum eveniet aperiam, consequuntur repellendus architecto inventore iusto blanditiis quasi commodi voluptatum vitae!

+ + + + + + + + diff --git a/node_modules/select/demo/dropdown.html b/node_modules/select/demo/dropdown.html new file mode 100644 index 00000000..aa739d58 --- /dev/null +++ b/node_modules/select/demo/dropdown.html @@ -0,0 +1,30 @@ + + + + + dropdown + + + + + + + + + + + + + diff --git a/node_modules/select/demo/editable.html b/node_modules/select/demo/editable.html new file mode 100644 index 00000000..f51d9c29 --- /dev/null +++ b/node_modules/select/demo/editable.html @@ -0,0 +1,26 @@ + + + + + editable + + + + + + + + + + + + + diff --git a/node_modules/select/demo/multiple.html b/node_modules/select/demo/multiple.html new file mode 100644 index 00000000..a19ae7df --- /dev/null +++ b/node_modules/select/demo/multiple.html @@ -0,0 +1,28 @@ + + + + + multiple + + + + + + + + + + + + + + diff --git a/node_modules/select/demo/nested.html b/node_modules/select/demo/nested.html new file mode 100644 index 00000000..11e11f3b --- /dev/null +++ b/node_modules/select/demo/nested.html @@ -0,0 +1,34 @@ + + + + + non-editable + + + + +
+

Item 1

+

Item 2

+ +
+ + + + + + + + diff --git a/node_modules/select/demo/non-editable.html b/node_modules/select/demo/non-editable.html new file mode 100644 index 00000000..2c34be93 --- /dev/null +++ b/node_modules/select/demo/non-editable.html @@ -0,0 +1,26 @@ + + + + + non-editable + + + + +

Lorem ipsum

+ + + + + + + + diff --git a/node_modules/select/dist/select.js b/node_modules/select/dist/select.js new file mode 100644 index 00000000..c3bdfe27 --- /dev/null +++ b/node_modules/select/dist/select.js @@ -0,0 +1,47 @@ +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.select = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o +``` + +```js +var input = document.querySelector('input'); +var result = select(input); +``` + +### Browserify + +```js +var select = require('select'); +``` + +```js +var input = document.querySelector('input'); +var result = select(input); +``` + +## License + +[MIT License](http://zenorocha.mit-license.org/) © Zeno Rocha diff --git a/node_modules/select/src/select.js b/node_modules/select/src/select.js new file mode 100644 index 00000000..3e36485a --- /dev/null +++ b/node_modules/select/src/select.js @@ -0,0 +1,43 @@ +function select(element) { + var selectedText; + + if (element.nodeName === 'SELECT') { + element.focus(); + + selectedText = element.value; + } + else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') { + var isReadOnly = element.hasAttribute('readonly'); + + if (!isReadOnly) { + element.setAttribute('readonly', ''); + } + + element.select(); + element.setSelectionRange(0, element.value.length); + + if (!isReadOnly) { + element.removeAttribute('readonly'); + } + + selectedText = element.value; + } + else { + if (element.hasAttribute('contenteditable')) { + element.focus(); + } + + var selection = window.getSelection(); + var range = document.createRange(); + + range.selectNodeContents(element); + selection.removeAllRanges(); + selection.addRange(range); + + selectedText = selection.toString(); + } + + return selectedText; +} + +module.exports = select; diff --git a/node_modules/select/test/select.js b/node_modules/select/test/select.js new file mode 100644 index 00000000..604dc945 --- /dev/null +++ b/node_modules/select/test/select.js @@ -0,0 +1,93 @@ +var select = require('../src/select'); + +describe('select editable elements', function() { + before(function() { + global.input = document.createElement('input'); + global.input.value = 'lorem ipsum'; + + global.textarea = document.createElement('textarea'); + global.textarea.value = 'lorem ipsum'; + + document.body.appendChild(global.input); + document.body.appendChild(global.textarea); + }); + + after(function() { + document.body.innerHTML = ''; + }); + + it('should return the selected text on input', function() { + var result = select(global.input); + assert.equal(result, global.input.value); + }); + + it('should return the selected text on textarea', function() { + var result = select(global.textarea); + assert.equal(result, global.textarea.value); + }); +}); + +describe('select non-editable element with no children', function() { + before(function() { + global.paragraph = document.createElement('p'); + global.paragraph.textContent = 'lorem ipsum'; + + document.body.appendChild(global.paragraph); + }); + + after(function() { + document.body.innerHTML = ''; + }); + + it('should return the selected text', function() { + var result = select(global.paragraph); + assert.equal(result, global.paragraph.textContent); + }); +}); + +describe('select non-editable element with child node', function() { + before(function() { + global.li = document.createElement('li'); + global.li.textContent = 'lorem ipsum'; + + global.ul = document.createElement('ul'); + global.ul.appendChild(global.li); + + document.body.appendChild(global.ul); + }); + + after(function() { + document.body.innerHTML = ''; + }); + + it('should return the selected text', function() { + var result = select(global.ul); + assert.equal(result, global.ul.textContent); + }); +}); + +describe('select non-editable svg element w/ multiple text children', function() { + before(function() { + global.text1 = document.createElement('text'); + global.text1.textContent = 'lorem ipsum'; + + global.text2 = document.createElement('text'); + global.text2.textContent = 'dolor zet'; + + global.svg = document.createElement('svg'); + global.svg.appendChild(global.text1); + global.svg.appendChild(global.text2); + + document.body.appendChild(global.svg); + }); + + after(function() { + document.body.innerHTML = ''; + }); + + it('should return the selected text', function() { + var result = select(global.svg); + assert.equal(result, global.text1.textContent + + global.text2.textContent); + }); +}); -- cgit v1.2.3