scratch – Diff between revs 58 and 125

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 58 Rev 125
Line 1... Line 1...
1 /*! 1 /*!
2 * clipboard.js v1.6.1 2 * clipboard.js v1.7.1
3 * https://zenorocha.github.io/clipboard.js 3 * https://zenorocha.github.io/clipboard.js
4 * 4 *
5 * Licensed MIT © Zeno Rocha 5 * Licensed MIT © Zeno Rocha
6 */ 6 */
7 (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.Clipboard = 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<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ 7 (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.Clipboard = 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<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
Line 27... Line 27...
27 * @param {String} selector 27 * @param {String} selector
28 * @return {Function} 28 * @return {Function}
29 */ 29 */
30 function closest (element, selector) { 30 function closest (element, selector) {
31 while (element && element.nodeType !== DOCUMENT_NODE_TYPE) { 31 while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
-   32 if (typeof element.matches === 'function' &&
32 if (element.matches(selector)) return element; 33 element.matches(selector)) {
-   34 return element;
-   35 }
33 element = element.parentNode; 36 element = element.parentNode;
34 } 37 }
35 } 38 }
Line 36... Line 39...
36   39  
Line 418... Line 421...
418 key: 'resolveOptions', 421 key: 'resolveOptions',
419 value: function resolveOptions() { 422 value: function resolveOptions() {
420 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 423 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
Line 421... Line 424...
421   424  
-   425 this.action = options.action;
422 this.action = options.action; 426 this.container = options.container;
423 this.emitter = options.emitter; 427 this.emitter = options.emitter;
424 this.target = options.target; 428 this.target = options.target;
425 this.text = options.text; 429 this.text = options.text;
Line 446... Line 450...
446 this.removeFake(); 450 this.removeFake();
Line 447... Line 451...
447   451  
448 this.fakeHandlerCallback = function () { 452 this.fakeHandlerCallback = function () {
449 return _this.removeFake(); 453 return _this.removeFake();
450 }; 454 };
Line 451... Line 455...
451 this.fakeHandler = document.body.addEventListener('click', this.fakeHandlerCallback) || true; 455 this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true;
452   456  
453 this.fakeElem = document.createElement('textarea'); 457 this.fakeElem = document.createElement('textarea');
454 // Prevent zooming on iOS 458 // Prevent zooming on iOS
Line 465... Line 469...
465 this.fakeElem.style.top = yPosition + 'px'; 469 this.fakeElem.style.top = yPosition + 'px';
Line 466... Line 470...
466   470  
467 this.fakeElem.setAttribute('readonly', ''); 471 this.fakeElem.setAttribute('readonly', '');
Line 468... Line 472...
468 this.fakeElem.value = this.text; 472 this.fakeElem.value = this.text;
Line 469... Line 473...
469   473  
470 document.body.appendChild(this.fakeElem); 474 this.container.appendChild(this.fakeElem);
471   475  
472 this.selectedText = (0, _select2.default)(this.fakeElem); 476 this.selectedText = (0, _select2.default)(this.fakeElem);
473 this.copyText(); 477 this.copyText();
474 } 478 }
475 }, { 479 }, {
476 key: 'removeFake', 480 key: 'removeFake',
477 value: function removeFake() { 481 value: function removeFake() {
478 if (this.fakeHandler) { 482 if (this.fakeHandler) {
479 document.body.removeEventListener('click', this.fakeHandlerCallback); 483 this.container.removeEventListener('click', this.fakeHandlerCallback);
Line 480... Line 484...
480 this.fakeHandler = null; 484 this.fakeHandler = null;
481 this.fakeHandlerCallback = null; 485 this.fakeHandlerCallback = null;
482 } 486 }
483   487  
484 if (this.fakeElem) { 488 if (this.fakeElem) {
485 document.body.removeChild(this.fakeElem); 489 this.container.removeChild(this.fakeElem);
486 this.fakeElem = null; 490 this.fakeElem = null;
Line 516... Line 520...
516 }); 520 });
517 } 521 }
518 }, { 522 }, {
519 key: 'clearSelection', 523 key: 'clearSelection',
520 value: function clearSelection() { 524 value: function clearSelection() {
521 if (this.target) { 525 if (this.trigger) {
522 this.target.blur(); 526 this.trigger.focus();
523 } 527 }
Line 524... Line 528...
524   528  
525 window.getSelection().removeAllRanges(); 529 window.getSelection().removeAllRanges();
526 } 530 }
Line 599... Line 603...
599 return obj && obj.__esModule ? obj : { 603 return obj && obj.__esModule ? obj : {
600 default: obj 604 default: obj
601 }; 605 };
602 } 606 }
Line -... Line 607...
-   607  
-   608 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
-   609 return typeof obj;
-   610 } : function (obj) {
-   611 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
-   612 };
603   613  
604 function _classCallCheck(instance, Constructor) { 614 function _classCallCheck(instance, Constructor) {
605 if (!(instance instanceof Constructor)) { 615 if (!(instance instanceof Constructor)) {
606 throw new TypeError("Cannot call a class as a function"); 616 throw new TypeError("Cannot call a class as a function");
607 } 617 }
Line 679... Line 689...
679 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 689 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
Line 680... Line 690...
680   690  
681 this.action = typeof options.action === 'function' ? options.action : this.defaultAction; 691 this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
682 this.target = typeof options.target === 'function' ? options.target : this.defaultTarget; 692 this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
-   693 this.text = typeof options.text === 'function' ? options.text : this.defaultText;
683 this.text = typeof options.text === 'function' ? options.text : this.defaultText; 694 this.container = _typeof(options.container) === 'object' ? options.container : document.body;
684 } 695 }
685 }, { 696 }, {
686 key: 'listenClick', 697 key: 'listenClick',
687 value: function listenClick(trigger) { 698 value: function listenClick(trigger) {
Line 702... Line 713...
702   713  
703 this.clipboardAction = new _clipboardAction2.default({ 714 this.clipboardAction = new _clipboardAction2.default({
704 action: this.action(trigger), 715 action: this.action(trigger),
705 target: this.target(trigger), 716 target: this.target(trigger),
-   717 text: this.text(trigger),
706 text: this.text(trigger), 718 container: this.container,
707 trigger: trigger, 719 trigger: trigger,
708 emitter: this 720 emitter: this
709 }); 721 });
710 } 722 }