diff --git a/dist/amd/aurelia/dragula.js b/dist/amd/aurelia/dragula.js new file mode 100644 index 0000000..97ba612 --- /dev/null +++ b/dist/amd/aurelia/dragula.js @@ -0,0 +1,33 @@ +define(['exports', 'aurelia-dependency-injection'], function (exports, _aureliaDependencyInjection) { + 'use strict'; + + Object.defineProperty(exports, '__esModule', { + value: true + }); + + var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + + var Dragula = (function () { + function Dragula(options) { + _classCallCheck(this, Dragula); + + this.options = Object.assign({}, _aureliaDependencyInjection.Container.instance.get(GLOBAL_OPTIONS), options); + } + + _createClass(Dragula, [{ + key: 'containers', + get: function get() { + return this.options.containers; + }, + set: function set(value) { + this.options.containers = value; + } + }]); + + return Dragula; + })(); + + exports.Dragula = Dragula; +}); \ No newline at end of file diff --git a/dist/amd/aurelia/options.js b/dist/amd/aurelia/options.js new file mode 100644 index 0000000..8f4900e --- /dev/null +++ b/dist/amd/aurelia/options.js @@ -0,0 +1,60 @@ +define(['exports'], function (exports) { + 'use strict'; + + Object.defineProperty(exports, '__esModule', { + value: true + }); + + var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + + var GLOBAL_OPTIONS = 'GlobalOptions'; + + exports.GLOBAL_OPTIONS = GLOBAL_OPTIONS; + var DIRECTION = { + VERTICAL: 'vertical', + HORIZONTAL: 'horizontal' + }; + + exports.DIRECTION = DIRECTION; + + var Options = (function () { + function Options() { + _classCallCheck(this, Options); + + this.moves = this.always; + this.accepts = this.always; + this.invalid = this.invalidTarget; + this.containers = []; + this.isContainer = this.never; + this.copy = false; + this.copySortSource = false; + this.revertOnSpill = false; + this.removeOnSpill = false; + this.direction = DIRECTION.VERTICAL, this.ignoreInputTextSelection = true; + this.mirrorContainer = document.body; + } + + _createClass(Options, [{ + key: 'always', + value: function always() { + return true; + } + }, { + key: 'never', + value: function never() { + return false; + } + }, { + key: 'invalidTarget', + value: function invalidTarget() { + return false; + } + }]); + + return Options; + })(); + + exports.Options = Options; +}); \ No newline at end of file diff --git a/dist/amd/classes.js b/dist/amd/classes.js new file mode 100644 index 0000000..b140ad2 --- /dev/null +++ b/dist/amd/classes.js @@ -0,0 +1,36 @@ +define(['exports'], function (exports) { + 'use strict'; + + Object.defineProperty(exports, '__esModule', { + value: true + }); + exports.add = add; + exports.rm = rm; + + var cache = {}; + var start = '(?:^|\\s)'; + var end = '(?:\\s|$)'; + + function lookupClass(className) { + var cached = cache[className]; + if (cached) { + cached.lastIndex = 0; + } else { + cache[className] = cached = new RegExp(start + className + end, 'g'); + } + return cached; + } + + function add(el, className) { + var current = el.className; + if (!current.length) { + el.className = className; + } else if (!lookupClass(className).test(current)) { + el.className += ' ' + className; + } + } + + function rm(el, className) { + el.className = el.className.replace(lookupClass(className), ' ').trim(); + } +}); \ No newline at end of file diff --git a/dist/amd/dragula.js b/dist/amd/dragula.js index 1c46a97..5f8f22b 100644 --- a/dist/amd/dragula.js +++ b/dist/amd/dragula.js @@ -1,9 +1,11 @@ -define(['exports'], function (exports) { +define(['exports', 'contra', 'crossvent', './classes'], function (exports, _contra, _crossvent, _classes) { 'use strict'; - var emitter = require('contra/emitter'); - var crossvent = require('crossvent'); - var classes = require('./classes'); + Object.defineProperty(exports, '__esModule', { + value: true + }); + exports.dragula = dragula; + var doc = document; var documentElement = doc.documentElement; @@ -65,7 +67,7 @@ define(['exports'], function (exports) { o.mirrorContainer = doc.body; } - var drake = emitter({ + var drake = (0, _contra.emitter)({ containers: o.containers, start: manualStart, end: end, @@ -100,8 +102,8 @@ define(['exports'], function (exports) { function movements(remove) { var op = remove ? 'remove' : 'add'; - crossvent[op](documentElement, 'selectstart', preventGrabbed); - crossvent[op](documentElement, 'click', preventGrabbed); + _crossvent[op](documentElement, 'selectstart', preventGrabbed); + _crossvent[op](documentElement, 'click', preventGrabbed); } function destroy() { @@ -170,7 +172,7 @@ define(['exports'], function (exports) { _offsetX = getCoord('pageX', e) - offset.left; _offsetY = getCoord('pageY', e) - offset.top; - classes.add(_copy || _item, 'gu-transit'); + _classes.add(_copy || _item, 'gu-transit'); renderMirrorImage(); drag(e); } @@ -323,7 +325,7 @@ define(['exports'], function (exports) { ungrab(); removeMirrorImage(); if (item) { - classes.rm(item, 'gu-transit'); + _classes.rm(item, 'gu-transit'); } if (_renderTimer) { clearTimeout(_renderTimer); @@ -435,12 +437,12 @@ define(['exports'], function (exports) { } function spillOver(el) { - classes.rm(el, 'gu-hide'); + _classes.rm(el, 'gu-hide'); } function spillOut(el) { if (drake.dragging) { - classes.add(el, 'gu-hide'); + _classes.add(el, 'gu-hide'); } } @@ -452,17 +454,17 @@ define(['exports'], function (exports) { _mirror = _item.cloneNode(true); _mirror.style.width = getRectWidth(rect) + 'px'; _mirror.style.height = getRectHeight(rect) + 'px'; - classes.rm(_mirror, 'gu-transit'); - classes.add(_mirror, 'gu-mirror'); + _classes.rm(_mirror, 'gu-transit'); + _classes.add(_mirror, 'gu-mirror'); o.mirrorContainer.appendChild(_mirror); touchy(documentElement, 'add', 'mousemove', drag); - classes.add(o.mirrorContainer, 'gu-unselectable'); + _classes.add(o.mirrorContainer, 'gu-unselectable'); drake.emit('cloned', _mirror, _item, 'mirror'); } function removeMirrorImage() { if (_mirror) { - classes.rm(o.mirrorContainer, 'gu-unselectable'); + _classes.rm(o.mirrorContainer, 'gu-unselectable'); touchy(documentElement, 'remove', 'mousemove', drag); getParent(_mirror).removeChild(_mirror); _mirror = null; @@ -537,13 +539,13 @@ define(['exports'], function (exports) { mousedown: 'MSPointerDown', mousemove: 'MSPointerMove' }; - if (global.navigator.pointerEnabled) { - crossvent[op](el, pointers[type], fn); - } else if (global.navigator.msPointerEnabled) { - crossvent[op](el, microsoft[type], fn); + if (window.navigator.pointerEnabled) { + _crossvent[op](el, pointers[type], fn); + } else if (window.navigator.msPointerEnabled) { + _crossvent[op](el, microsoft[type], fn); } else { - crossvent[op](el, touch[type], fn); - crossvent[op](el, type, fn); + _crossvent[op](el, touch[type], fn); + _crossvent[op](el, type, fn); } } @@ -572,8 +574,8 @@ define(['exports'], function (exports) { } function getScroll(scrollProp, offsetProp) { - if (typeof global[offsetProp] !== 'undefined') { - return global[offsetProp]; + if (typeof window[offsetProp] !== 'undefined') { + return window[offsetProp]; } if (documentElement.clientHeight) { return documentElement[scrollProp]; @@ -661,6 +663,4 @@ define(['exports'], function (exports) { } return host[coord]; } - - module.exports = dragula; }); \ No newline at end of file diff --git a/dist/amd/index.js b/dist/amd/index.js index 57d7cdb..bb18724 100644 --- a/dist/amd/index.js +++ b/dist/amd/index.js @@ -1,12 +1,18 @@ -define(['exports'], function (exports) { +define(['exports', './aurelia/options', './dragula'], function (exports, _aureliaOptions, _dragula) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); exports.configure = configure; + exports.dragula = _dragula.dragula; - function configure(config) { - config.globalResources('./dragula.js'); + function configure(config, callback) { + var defaults = new _aureliaOptions.Options(); + config.container.registerInstance(_aureliaOptions.GLOBAL_OPTIONS, defaults); + + if (callback !== undefined && typeof callback === 'function') { + callback(defaults); + } } }); \ No newline at end of file diff --git a/dist/commonjs/aurelia/dragula.js b/dist/commonjs/aurelia/dragula.js new file mode 100644 index 0000000..70e4776 --- /dev/null +++ b/dist/commonjs/aurelia/dragula.js @@ -0,0 +1,33 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +var _aureliaDependencyInjection = require('aurelia-dependency-injection'); + +var Dragula = (function () { + function Dragula(options) { + _classCallCheck(this, Dragula); + + this.options = Object.assign({}, _aureliaDependencyInjection.Container.instance.get(GLOBAL_OPTIONS), options); + } + + _createClass(Dragula, [{ + key: 'containers', + get: function get() { + return this.options.containers; + }, + set: function set(value) { + this.options.containers = value; + } + }]); + + return Dragula; +})(); + +exports.Dragula = Dragula; \ No newline at end of file diff --git a/dist/commonjs/aurelia/options.js b/dist/commonjs/aurelia/options.js new file mode 100644 index 0000000..f0c5be0 --- /dev/null +++ b/dist/commonjs/aurelia/options.js @@ -0,0 +1,58 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +var GLOBAL_OPTIONS = 'GlobalOptions'; + +exports.GLOBAL_OPTIONS = GLOBAL_OPTIONS; +var DIRECTION = { + VERTICAL: 'vertical', + HORIZONTAL: 'horizontal' +}; + +exports.DIRECTION = DIRECTION; + +var Options = (function () { + function Options() { + _classCallCheck(this, Options); + + this.moves = this.always; + this.accepts = this.always; + this.invalid = this.invalidTarget; + this.containers = []; + this.isContainer = this.never; + this.copy = false; + this.copySortSource = false; + this.revertOnSpill = false; + this.removeOnSpill = false; + this.direction = DIRECTION.VERTICAL, this.ignoreInputTextSelection = true; + this.mirrorContainer = document.body; + } + + _createClass(Options, [{ + key: 'always', + value: function always() { + return true; + } + }, { + key: 'never', + value: function never() { + return false; + } + }, { + key: 'invalidTarget', + value: function invalidTarget() { + return false; + } + }]); + + return Options; +})(); + +exports.Options = Options; \ No newline at end of file diff --git a/dist/commonjs/classes.js b/dist/commonjs/classes.js new file mode 100644 index 0000000..c324c7b --- /dev/null +++ b/dist/commonjs/classes.js @@ -0,0 +1,34 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.add = add; +exports.rm = rm; + +var cache = {}; +var start = '(?:^|\\s)'; +var end = '(?:\\s|$)'; + +function lookupClass(className) { + var cached = cache[className]; + if (cached) { + cached.lastIndex = 0; + } else { + cache[className] = cached = new RegExp(start + className + end, 'g'); + } + return cached; +} + +function add(el, className) { + var current = el.className; + if (!current.length) { + el.className = className; + } else if (!lookupClass(className).test(current)) { + el.className += ' ' + className; + } +} + +function rm(el, className) { + el.className = el.className.replace(lookupClass(className), ' ').trim(); +} \ No newline at end of file diff --git a/dist/commonjs/dragula.js b/dist/commonjs/dragula.js index 07a1834..88741b4 100644 --- a/dist/commonjs/dragula.js +++ b/dist/commonjs/dragula.js @@ -1,8 +1,22 @@ 'use strict'; -var emitter = require('contra/emitter'); -var crossvent = require('crossvent'); -var classes = require('./classes'); +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.dragula = dragula; + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } } + +var _contra = require('contra'); + +var _crossvent = require('crossvent'); + +var crossvent = _interopRequireWildcard(_crossvent); + +var _classes = require('./classes'); + +var classes = _interopRequireWildcard(_classes); + var doc = document; var documentElement = doc.documentElement; @@ -64,7 +78,7 @@ function dragula(initialContainers, options) { o.mirrorContainer = doc.body; } - var drake = emitter({ + var drake = (0, _contra.emitter)({ containers: o.containers, start: manualStart, end: end, @@ -536,9 +550,9 @@ function touchy(el, op, type, fn) { mousedown: 'MSPointerDown', mousemove: 'MSPointerMove' }; - if (global.navigator.pointerEnabled) { + if (window.navigator.pointerEnabled) { crossvent[op](el, pointers[type], fn); - } else if (global.navigator.msPointerEnabled) { + } else if (window.navigator.msPointerEnabled) { crossvent[op](el, microsoft[type], fn); } else { crossvent[op](el, touch[type], fn); @@ -571,8 +585,8 @@ function getOffset(el) { } function getScroll(scrollProp, offsetProp) { - if (typeof global[offsetProp] !== 'undefined') { - return global[offsetProp]; + if (typeof window[offsetProp] !== 'undefined') { + return window[offsetProp]; } if (documentElement.clientHeight) { return documentElement[scrollProp]; @@ -659,6 +673,4 @@ function getCoord(coord, e) { coord = missMap[coord]; } return host[coord]; -} - -module.exports = dragula; \ No newline at end of file +} \ No newline at end of file diff --git a/dist/commonjs/index.js b/dist/commonjs/index.js index 62758ed..ef246b4 100644 --- a/dist/commonjs/index.js +++ b/dist/commonjs/index.js @@ -5,6 +5,17 @@ Object.defineProperty(exports, '__esModule', { }); exports.configure = configure; -function configure(config) { - config.globalResources('./dragula.js'); +var _aureliaOptions = require('./aurelia/options'); + +var _dragula = require('./dragula'); + +exports.dragula = _dragula.dragula; + +function configure(config, callback) { + var defaults = new _aureliaOptions.Options(); + config.container.registerInstance(_aureliaOptions.GLOBAL_OPTIONS, defaults); + + if (callback !== undefined && typeof callback === 'function') { + callback(defaults); + } } \ No newline at end of file diff --git a/dist/es6/aurelia/dragula.js b/dist/es6/aurelia/dragula.js new file mode 100644 index 0000000..51f002f --- /dev/null +++ b/dist/es6/aurelia/dragula.js @@ -0,0 +1,26 @@ +import {Container} from 'aurelia-dependency-injection'; + +export class Dragula { + + constructor(options) { + this.options = Object.assign({}, Container.instance.get(GLOBAL_OPTIONS), options); + // var drake = emitter({ + // containers: o.containers, + // start: manualStart, + // end: end, + // cancel: cancel, + // remove: remove, + // destroy: destroy, + // dragging: false + // }); + } + + get containers() { + return this.options.containers; + } + + set containers(value) { + this.options.containers = value; + } + +} \ No newline at end of file diff --git a/dist/es6/aurelia/options.js b/dist/es6/aurelia/options.js new file mode 100644 index 0000000..b91f4dc --- /dev/null +++ b/dist/es6/aurelia/options.js @@ -0,0 +1,36 @@ +export const GLOBAL_OPTIONS = 'GlobalOptions'; + +export const DIRECTION = { + VERTICAL: 'vertical', + HORIZONTAL: 'horizontal' +}; + +export class Options { + + constructor() { + this.moves = this.always; + this.accepts = this.always; + this.invalid = this.invalidTarget; + this.containers = []; + this.isContainer = this.never; + this.copy = false; + this.copySortSource = false; + this.revertOnSpill = false; + this.removeOnSpill = false; + this.direction = DIRECTION.VERTICAL, + this.ignoreInputTextSelection = true; + this.mirrorContainer = document.body; + } + + always() { + return true; + } + + never() { + return false; + } + + invalidTarget() { + return false; + } +} \ No newline at end of file diff --git a/dist/es6/classes.js b/dist/es6/classes.js new file mode 100644 index 0000000..65e7e57 --- /dev/null +++ b/dist/es6/classes.js @@ -0,0 +1,28 @@ +/** This is purportedly necessary to support Internet Explorer (not Edge) properly (it doesn't support classList on SVG elements!) */ + +let cache = {}; +const start = '(?:^|\\s)'; +const end = '(?:\\s|$)'; + +function lookupClass(className) { + var cached = cache[className]; + if (cached) { + cached.lastIndex = 0; + } else { + cache[className] = cached = new RegExp(start + className + end, 'g'); + } + return cached; +} + +export function add(el, className) { + var current = el.className; + if (!current.length) { + el.className = className; + } else if (!lookupClass(className).test(current)) { + el.className += ' ' + className; + } +} + +export function rm(el, className) { + el.className = el.className.replace(lookupClass(className), ' ').trim(); +} diff --git a/dist/es6/dragula.js b/dist/es6/dragula.js index bf28474..6da29fc 100644 --- a/dist/es6/dragula.js +++ b/dist/es6/dragula.js @@ -1,12 +1,12 @@ -'use strict'; +import {emitter} from 'contra'; +import * as crossvent from 'crossvent'; + +import * as classes from './classes'; -var emitter = require('contra/emitter'); -var crossvent = require('crossvent'); -var classes = require('./classes'); var doc = document; var documentElement = doc.documentElement; -function dragula (initialContainers, options) { +export function dragula(initialContainers, options) { var len = arguments.length; if (len === 1 && Array.isArray(initialContainers) === false) { options = initialContainers; @@ -500,9 +500,9 @@ function touchy (el, op, type, fn) { mousedown: 'MSPointerDown', mousemove: 'MSPointerMove' }; - if (global.navigator.pointerEnabled) { + if (window.navigator.pointerEnabled) { crossvent[op](el, pointers[type], fn); - } else if (global.navigator.msPointerEnabled) { + } else if (window.navigator.msPointerEnabled) { crossvent[op](el, microsoft[type], fn); } else { crossvent[op](el, touch[type], fn); @@ -529,8 +529,8 @@ function getOffset (el) { } function getScroll (scrollProp, offsetProp) { - if (typeof global[offsetProp] !== 'undefined') { - return global[offsetProp]; + if (typeof window[offsetProp] !== 'undefined') { + return window[offsetProp]; } if (documentElement.clientHeight) { return documentElement[scrollProp]; @@ -597,4 +597,3 @@ function getCoord (coord, e) { return host[coord]; } -module.exports = dragula; diff --git a/dist/es6/index.js b/dist/es6/index.js index 0a3e643..7e1eefd 100644 --- a/dist/es6/index.js +++ b/dist/es6/index.js @@ -1,3 +1,13 @@ -export function configure(config) { - config.globalResources('./dragula.js'); +import {Options, GLOBAL_OPTIONS} from './aurelia/options'; + +import {dragula} from './dragula'; +export {dragula}; + +export function configure(config, callback) { + let defaults = new Options(); + config.container.registerInstance(GLOBAL_OPTIONS, defaults); + + if (callback !== undefined && typeof(callback) === 'function') { + callback(defaults); + } } diff --git a/dist/system/aurelia/dragula.js b/dist/system/aurelia/dragula.js new file mode 100644 index 0000000..978ba89 --- /dev/null +++ b/dist/system/aurelia/dragula.js @@ -0,0 +1,38 @@ +System.register(['aurelia-dependency-injection'], function (_export) { + 'use strict'; + + var Container, Dragula; + + var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + + return { + setters: [function (_aureliaDependencyInjection) { + Container = _aureliaDependencyInjection.Container; + }], + execute: function () { + Dragula = (function () { + function Dragula(options) { + _classCallCheck(this, Dragula); + + this.options = Object.assign({}, Container.instance.get(GLOBAL_OPTIONS), options); + } + + _createClass(Dragula, [{ + key: 'containers', + get: function get() { + return this.options.containers; + }, + set: function set(value) { + this.options.containers = value; + } + }]); + + return Dragula; + })(); + + _export('Dragula', Dragula); + } + }; +}); \ No newline at end of file diff --git a/dist/system/aurelia/options.js b/dist/system/aurelia/options.js new file mode 100644 index 0000000..3c7b40e --- /dev/null +++ b/dist/system/aurelia/options.js @@ -0,0 +1,64 @@ +System.register([], function (_export) { + 'use strict'; + + var GLOBAL_OPTIONS, DIRECTION, Options; + + var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + + return { + setters: [], + execute: function () { + GLOBAL_OPTIONS = 'GlobalOptions'; + + _export('GLOBAL_OPTIONS', GLOBAL_OPTIONS); + + DIRECTION = { + VERTICAL: 'vertical', + HORIZONTAL: 'horizontal' + }; + + _export('DIRECTION', DIRECTION); + + Options = (function () { + function Options() { + _classCallCheck(this, Options); + + this.moves = this.always; + this.accepts = this.always; + this.invalid = this.invalidTarget; + this.containers = []; + this.isContainer = this.never; + this.copy = false; + this.copySortSource = false; + this.revertOnSpill = false; + this.removeOnSpill = false; + this.direction = DIRECTION.VERTICAL, this.ignoreInputTextSelection = true; + this.mirrorContainer = document.body; + } + + _createClass(Options, [{ + key: 'always', + value: function always() { + return true; + } + }, { + key: 'never', + value: function never() { + return false; + } + }, { + key: 'invalidTarget', + value: function invalidTarget() { + return false; + } + }]); + + return Options; + })(); + + _export('Options', Options); + } + }; +}); \ No newline at end of file diff --git a/dist/system/classes.js b/dist/system/classes.js new file mode 100644 index 0000000..04b12a5 --- /dev/null +++ b/dist/system/classes.js @@ -0,0 +1,41 @@ +System.register([], function (_export) { + 'use strict'; + + var cache, start, end; + + _export('add', add); + + _export('rm', rm); + + function lookupClass(className) { + var cached = cache[className]; + if (cached) { + cached.lastIndex = 0; + } else { + cache[className] = cached = new RegExp(start + className + end, 'g'); + } + return cached; + } + + function add(el, className) { + var current = el.className; + if (!current.length) { + el.className = className; + } else if (!lookupClass(className).test(current)) { + el.className += ' ' + className; + } + } + + function rm(el, className) { + el.className = el.className.replace(lookupClass(className), ' ').trim(); + } + + return { + setters: [], + execute: function () { + cache = {}; + start = '(?:^|\\s)'; + end = '(?:\\s|$)'; + } + }; +}); \ No newline at end of file diff --git a/dist/system/dragula.js b/dist/system/dragula.js index d5c483e..f0960e4 100644 --- a/dist/system/dragula.js +++ b/dist/system/dragula.js @@ -1,8 +1,10 @@ -System.register([], function (_export) { +System.register(['contra', 'crossvent', './classes'], function (_export) { 'use strict'; var emitter, crossvent, classes, doc, documentElement; + _export('dragula', dragula); + function dragula(initialContainers, options) { var len = arguments.length; if (len === 1 && Array.isArray(initialContainers) === false) { @@ -533,9 +535,9 @@ System.register([], function (_export) { mousedown: 'MSPointerDown', mousemove: 'MSPointerMove' }; - if (global.navigator.pointerEnabled) { + if (window.navigator.pointerEnabled) { crossvent[op](el, pointers[type], fn); - } else if (global.navigator.msPointerEnabled) { + } else if (window.navigator.msPointerEnabled) { crossvent[op](el, microsoft[type], fn); } else { crossvent[op](el, touch[type], fn); @@ -568,8 +570,8 @@ System.register([], function (_export) { } function getScroll(scrollProp, offsetProp) { - if (typeof global[offsetProp] !== 'undefined') { - return global[offsetProp]; + if (typeof window[offsetProp] !== 'undefined') { + return window[offsetProp]; } if (documentElement.clientHeight) { return documentElement[scrollProp]; @@ -657,16 +659,17 @@ System.register([], function (_export) { } return host[coord]; } - return { - setters: [], + setters: [function (_contra) { + emitter = _contra.emitter; + }, function (_crossvent) { + crossvent = _crossvent; + }, function (_classes) { + classes = _classes; + }], execute: function () { - emitter = require('contra/emitter'); - crossvent = require('crossvent'); - classes = require('./classes'); doc = document; documentElement = doc.documentElement; - module.exports = dragula; } }; }); \ No newline at end of file diff --git a/dist/system/index.js b/dist/system/index.js index 667284a..38478b7 100644 --- a/dist/system/index.js +++ b/dist/system/index.js @@ -1,13 +1,11 @@ -System.register(['./aurelia/options'], function (_export) { +System.register(['./aurelia/options', './dragula'], function (_export) { 'use strict'; - var Options, GLOBAL_OPTIONS; + var Options, GLOBAL_OPTIONS, dragula; _export('configure', configure); function configure(config, callback) { - config.globalResources(['./dragula.js', './aurelia/options']); - var defaults = new Options(); config.container.registerInstance(GLOBAL_OPTIONS, defaults); @@ -20,7 +18,11 @@ System.register(['./aurelia/options'], function (_export) { setters: [function (_aureliaOptions) { Options = _aureliaOptions.Options; GLOBAL_OPTIONS = _aureliaOptions.GLOBAL_OPTIONS; + }, function (_dragula) { + dragula = _dragula.dragula; }], - execute: function () {} + execute: function () { + _export('dragula', dragula); + } }; }); \ No newline at end of file diff --git a/src/aurelia/dragula.js b/src/aurelia/dragula.js index 87382f0..51f002f 100644 --- a/src/aurelia/dragula.js +++ b/src/aurelia/dragula.js @@ -4,5 +4,23 @@ export class Dragula { constructor(options) { this.options = Object.assign({}, Container.instance.get(GLOBAL_OPTIONS), options); + // var drake = emitter({ + // containers: o.containers, + // start: manualStart, + // end: end, + // cancel: cancel, + // remove: remove, + // destroy: destroy, + // dragging: false + // }); } + + get containers() { + return this.options.containers; + } + + set containers(value) { + this.options.containers = value; + } + } \ No newline at end of file