| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940 |
- ;
- (function () {
- /**
- * Require the given path.
- *
- * @param {String} path
- * @return {Object} exports
- * @api public
- */
- function require(path, parent, orig) {
- var resolved = require.resolve(path);
- // lookup failed
- if (null == resolved) {
- orig = orig || path;
- parent = parent || 'root';
- var err = new Error('Failed to require "' + orig + '" from "' + parent + '"');
- err.path = orig;
- err.parent = parent;
- err.require = true;
- throw err;
- }
- var module = require.modules[resolved];
- // perform real require()
- // by invoking the module's
- // registered function
- if (!module._resolving && !module.exports) {
- var mod = {};
- mod.exports = {};
- mod.client = mod.component = true;
- module._resolving = true;
- module.call(this, mod.exports, require.relative(resolved), mod);
- delete module._resolving;
- module.exports = mod.exports;
- }
- return module.exports;
- }
- /**
- * Registered modules.
- */
- require.modules = {};
- /**
- * Registered aliases.
- */
- require.aliases = {};
- /**
- * Resolve `path`.
- *
- * Lookup:
- *
- * - PATH/index.js
- * - PATH.js
- * - PATH
- *
- * @param {String} path
- * @return {String} path or null
- * @api private
- */
- require.resolve = function (path) {
- if (path.charAt(0) === '/') path = path.slice(1);
- var paths = [
- path,
- path + '.js',
- path + '.json',
- path + '/index.js',
- path + '/index.json'
- ];
- for (var i = 0; i < paths.length; i++) {
- var path = paths[i];
- if (require.modules.hasOwnProperty(path)) return path;
- if (require.aliases.hasOwnProperty(path)) return require.aliases[path];
- }
- };
- /**
- * Normalize `path` relative to the current path.
- *
- * @param {String} curr
- * @param {String} path
- * @return {String}
- * @api private
- */
- require.normalize = function (curr, path) {
- var segs = [];
- if ('.' != path.charAt(0)) return path;
- curr = curr.split('/');
- path = path.split('/');
- for (var i = 0; i < path.length; ++i) {
- if ('..' == path[i]) {
- curr.pop();
- } else if ('.' != path[i] && '' != path[i]) {
- segs.push(path[i]);
- }
- }
- return curr.concat(segs).join('/');
- };
- /**
- * Register module at `path` with callback `definition`.
- *
- * @param {String} path
- * @param {Function} definition
- * @api private
- */
- require.register = function (path, definition) {
- require.modules[path] = definition;
- };
- /**
- * Alias a module definition.
- *
- * @param {String} from
- * @param {String} to
- * @api private
- */
- require.alias = function (from, to) {
- if (!require.modules.hasOwnProperty(from)) {
- throw new Error('Failed to alias "' + from + '", it does not exist');
- }
- require.aliases[to] = from;
- };
- /**
- * Return a require function relative to the `parent` path.
- *
- * @param {String} parent
- * @return {Function}
- * @api private
- */
- require.relative = function (parent) {
- var p = require.normalize(parent, '..');
- /**
- * lastIndexOf helper.
- */
- function lastIndexOf(arr, obj) {
- var i = arr.length;
- while (i--) {
- if (arr[i] === obj) return i;
- }
- return -1;
- }
- /**
- * The relative require() itself.
- */
- function localRequire(path) {
- var resolved = localRequire.resolve(path);
- return require(resolved, parent, path);
- }
- /**
- * Resolve relative to the parent.
- */
- localRequire.resolve = function (path) {
- var c = path.charAt(0);
- if ('/' == c) return path.slice(1);
- if ('.' == c) return require.normalize(p, path);
- // resolve deps by returning
- // the dep in the nearest "deps"
- // directory
- var segs = parent.split('/');
- var i = lastIndexOf(segs, 'deps') + 1;
- if (!i) i = 0;
- path = segs.slice(0, i + 1).join('/') + '/deps/' + path;
- return path;
- };
- /**
- * Check if module is defined at `path`.
- */
- localRequire.exists = function (path) {
- return require.modules.hasOwnProperty(localRequire.resolve(path));
- };
- return localRequire;
- };
- require.register("component-event/index.js", function (exports, require, module) {
- var bind = window.addEventListener ? 'addEventListener' : 'attachEvent',
- unbind = window.removeEventListener ? 'removeEventListener' : 'detachEvent',
- prefix = bind !== 'addEventListener' ? 'on' : '';
- /**
- * Bind `el` event `type` to `fn`.
- *
- * @param {Element} el
- * @param {String} type
- * @param {Function} fn
- * @param {Boolean} capture
- * @return {Function}
- * @api public
- */
- exports.bind = function (el, type, fn, capture) {
- el[bind](prefix + type, fn, capture || false);
- return fn;
- };
- /**
- * Unbind `el` event `type`'s callback `fn`.
- *
- * @param {Element} el
- * @param {String} type
- * @param {Function} fn
- * @param {Boolean} capture
- * @return {Function}
- * @api public
- */
- exports.unbind = function (el, type, fn, capture) {
- el[unbind](prefix + type, fn, capture || false);
- return fn;
- };
- });
- require.register("component-query/index.js", function (exports, require, module) {
- function one(selector, el) {
- return el.querySelector(selector);
- }
- exports = module.exports = function (selector, el) {
- el = el || document;
- return one(selector, el);
- };
- exports.all = function (selector, el) {
- el = el || document;
- return el.querySelectorAll(selector);
- };
- exports.engine = function (obj) {
- if (!obj.one) throw new Error('.one callback required');
- if (!obj.all) throw new Error('.all callback required');
- one = obj.one;
- exports.all = obj.all;
- return exports;
- };
- });
- require.register("component-matches-selector/index.js", function (exports, require, module) {
- /**
- * Module dependencies.
- */
- var query = require('query');
- /**
- * Element prototype.
- */
- var proto = Element.prototype;
- /**
- * Vendor function.
- */
- var vendor = proto.matches || proto.webkitMatchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector || proto.oMatchesSelector;
- /**
- * Expose `match()`.
- */
- module.exports = match;
- /**
- * Match `el` to `selector`.
- *
- * @param {Element} el
- * @param {String} selector
- * @return {Boolean}
- * @api public
- */
- function match(el, selector) {
- if (vendor) return vendor.call(el, selector);
- var nodes = query.all(selector, el.parentNode);
- for (var i = 0; i < nodes.length; ++i) {
- if (nodes[i] == el) return true;
- }
- return false;
- }
- });
- require.register("discore-closest/index.js", function (exports, require, module) {
- var matches = require('matches-selector')
- module.exports = function (element, selector, checkYoSelf, root) {
- element = checkYoSelf ? {
- parentNode: element
- } : element
- root = root || document
- // Make sure `element !== document` and `element != null`
- // otherwise we get an illegal invocation
- while ((element = element.parentNode) && element !== document) {
- if (matches(element, selector))
- return element
- // After `matches` on the edge case that
- // the selector matches the root
- // (when the root is not the document)
- if (element === root)
- return
- }
- }
- });
- require.register("component-delegate/index.js", function (exports, require, module) {
- /**
- * Module dependencies.
- */
- var closest = require('closest'),
- event = require('event');
- /**
- * Delegate event `type` to `selector`
- * and invoke `fn(e)`. A callback function
- * is returned which may be passed to `.unbind()`.
- *
- * @param {Element} el
- * @param {String} selector
- * @param {String} type
- * @param {Function} fn
- * @param {Boolean} capture
- * @return {Function}
- * @api public
- */
- exports.bind = function (el, selector, type, fn, capture) {
- return event.bind(el, type, function (e) {
- var target = e.target || e.srcElement;
- e.delegateTarget = closest(target, selector, true, el);
- if (e.delegateTarget) fn.call(el, e);
- }, capture);
- };
- /**
- * Unbind event `type`'s callback `fn`.
- *
- * @param {Element} el
- * @param {String} type
- * @param {Function} fn
- * @param {Boolean} capture
- * @api public
- */
- exports.unbind = function (el, type, fn, capture) {
- event.unbind(el, type, fn, capture);
- };
- });
- require.register("component-events/index.js", function (exports, require, module) {
- /**
- * Module dependencies.
- */
- var events = require('event');
- var delegate = require('delegate');
- /**
- * Expose `Events`.
- */
- module.exports = Events;
- /**
- * Initialize an `Events` with the given
- * `el` object which events will be bound to,
- * and the `obj` which will receive method calls.
- *
- * @param {Object} el
- * @param {Object} obj
- * @api public
- */
- function Events(el, obj) {
- if (!(this instanceof Events)) return new Events(el, obj);
- if (!el) throw new Error('element required');
- if (!obj) throw new Error('object required');
- this.el = el;
- this.obj = obj;
- this._events = {};
- }
- /**
- * Subscription helper.
- */
- Events.prototype.sub = function (event, method, cb) {
- this._events[event] = this._events[event] || {};
- this._events[event][method] = cb;
- };
- /**
- * Bind to `event` with optional `method` name.
- * When `method` is undefined it becomes `event`
- * with the "on" prefix.
- *
- * Examples:
- *
- * Direct event handling:
- *
- * events.bind('click') // implies "onclick"
- * events.bind('click', 'remove')
- * events.bind('click', 'sort', 'asc')
- *
- * Delegated event handling:
- *
- * events.bind('click li > a')
- * events.bind('click li > a', 'remove')
- * events.bind('click a.sort-ascending', 'sort', 'asc')
- * events.bind('click a.sort-descending', 'sort', 'desc')
- *
- * @param {String} event
- * @param {String|function} [method]
- * @return {Function} callback
- * @api public
- */
- Events.prototype.bind = function (event, method) {
- var e = parse(event);
- var el = this.el;
- var obj = this.obj;
- var name = e.name;
- var method = method || 'on' + name;
- var args = [].slice.call(arguments, 2);
- // callback
- function cb() {
- var a = [].slice.call(arguments).concat(args);
- obj[method].apply(obj, a);
- }
- // bind
- if (e.selector) {
- cb = delegate.bind(el, e.selector, name, cb);
- } else {
- events.bind(el, name, cb);
- }
- // subscription for unbinding
- this.sub(name, method, cb);
- return cb;
- };
- /**
- * Unbind a single binding, all bindings for `event`,
- * or all bindings within the manager.
- *
- * Examples:
- *
- * Unbind direct handlers:
- *
- * events.unbind('click', 'remove')
- * events.unbind('click')
- * events.unbind()
- *
- * Unbind delegate handlers:
- *
- * events.unbind('click', 'remove')
- * events.unbind('click')
- * events.unbind()
- *
- * @param {String|Function} [event]
- * @param {String|Function} [method]
- * @api public
- */
- Events.prototype.unbind = function (event, method) {
- if (0 == arguments.length) return this.unbindAll();
- if (1 == arguments.length) return this.unbindAllOf(event);
- // no bindings for this event
- var bindings = this._events[event];
- if (!bindings) return;
- // no bindings for this method
- var cb = bindings[method];
- if (!cb) return;
- events.unbind(this.el, event, cb);
- };
- /**
- * Unbind all events.
- *
- * @api private
- */
- Events.prototype.unbindAll = function () {
- for (var event in this._events) {
- this.unbindAllOf(event);
- }
- };
- /**
- * Unbind all events for `event`.
- *
- * @param {String} event
- * @api private
- */
- Events.prototype.unbindAllOf = function (event) {
- var bindings = this._events[event];
- if (!bindings) return;
- for (var method in bindings) {
- this.unbind(event, method);
- }
- };
- /**
- * Parse `event`.
- *
- * @param {String} event
- * @return {Object}
- * @api private
- */
- function parse(event) {
- var parts = event.split(/ +/);
- return {
- name: parts.shift(),
- selector: parts.join(' ')
- }
- }
- });
- require.register("component-indexof/index.js", function (exports, require, module) {
- module.exports = function (arr, obj) {
- if (arr.indexOf) return arr.indexOf(obj);
- for (var i = 0; i < arr.length; ++i) {
- if (arr[i] === obj) return i;
- }
- return -1;
- };
- });
- require.register("component-classes/index.js", function (exports, require, module) {
- /**
- * Module dependencies.
- */
- var index = require('indexof');
- /**
- * Whitespace regexp.
- */
- var re = /\s+/;
- /**
- * toString reference.
- */
- var toString = Object.prototype.toString;
- /**
- * Wrap `el` in a `ClassList`.
- *
- * @param {Element} el
- * @return {ClassList}
- * @api public
- */
- module.exports = function (el) {
- return new ClassList(el);
- };
- /**
- * Initialize a new ClassList for `el`.
- *
- * @param {Element} el
- * @api private
- */
- function ClassList(el) {
- if (!el) throw new Error('A DOM element reference is required');
- this.el = el;
- this.list = el.classList;
- }
- /**
- * Add class `name` if not already present.
- *
- * @param {String} name
- * @return {ClassList}
- * @api public
- */
- ClassList.prototype.add = function (name) {
- // classList
- if (this.list) {
- this.list.add(name);
- return this;
- }
- // fallback
- var arr = this.array();
- var i = index(arr, name);
- if (!~i) arr.push(name);
- this.el.className = arr.join(' ');
- return this;
- };
- /**
- * Remove class `name` when present, or
- * pass a regular expression to remove
- * any which match.
- *
- * @param {String|RegExp} name
- * @return {ClassList}
- * @api public
- */
- ClassList.prototype.remove = function (name) {
- if ('[object RegExp]' == toString.call(name)) {
- return this.removeMatching(name);
- }
- // classList
- if (this.list) {
- this.list.remove(name);
- return this;
- }
- // fallback
- var arr = this.array();
- var i = index(arr, name);
- if (~i) arr.splice(i, 1);
- this.el.className = arr.join(' ');
- return this;
- };
- /**
- * Remove all classes matching `re`.
- *
- * @param {RegExp} re
- * @return {ClassList}
- * @api private
- */
- ClassList.prototype.removeMatching = function (re) {
- var arr = this.array();
- for (var i = 0; i < arr.length; i++) {
- if (re.test(arr[i])) {
- this.remove(arr[i]);
- }
- }
- return this;
- };
- /**
- * Toggle class `name`, can force state via `force`.
- *
- * For browsers that support classList, but do not support `force` yet,
- * the mistake will be detected and corrected.
- *
- * @param {String} name
- * @param {Boolean} force
- * @return {ClassList}
- * @api public
- */
- ClassList.prototype.toggle = function (name, force) {
- // classList
- if (this.list) {
- if ("undefined" !== typeof force) {
- if (force !== this.list.toggle(name, force)) {
- this.list.toggle(name); // toggle again to correct
- }
- } else {
- this.list.toggle(name);
- }
- return this;
- }
- // fallback
- if ("undefined" !== typeof force) {
- if (!force) {
- this.remove(name);
- } else {
- this.add(name);
- }
- } else {
- if (this.has(name)) {
- this.remove(name);
- } else {
- this.add(name);
- }
- }
- return this;
- };
- /**
- * Return an array of classes.
- *
- * @return {Array}
- * @api public
- */
- ClassList.prototype.array = function () {
- var str = this.el.className.replace(/^\s+|\s+$/g, '');
- var arr = str.split(re);
- if ('' === arr[0]) arr.shift();
- return arr;
- };
- /**
- * Check if class `name` is present.
- *
- * @param {String} name
- * @return {ClassList}
- * @api public
- */
- ClassList.prototype.has =
- ClassList.prototype.contains = function (name) {
- return this.list ? this.list.contains(name) : !!~index(this.array(), name);
- };
- });
- require.register("component-emitter/index.js", function (exports, require, module) {
- /**
- * Expose `Emitter`.
- */
- module.exports = Emitter;
- /**
- * Initialize a new `Emitter`.
- *
- * @api public
- */
- function Emitter(obj) {
- if (obj) return mixin(obj);
- };
- /**
- * Mixin the emitter properties.
- *
- * @param {Object} obj
- * @return {Object}
- * @api private
- */
- function mixin(obj) {
- for (var key in Emitter.prototype) {
- obj[key] = Emitter.prototype[key];
- }
- return obj;
- }
- /**
- * Listen on the given `event` with `fn`.
- *
- * @param {String} event
- * @param {Function} fn
- * @return {Emitter}
- * @api public
- */
- Emitter.prototype.on =
- Emitter.prototype.addEventListener = function (event, fn) {
- this._callbacks = this._callbacks || {};
- (this._callbacks[event] = this._callbacks[event] || [])
- .push(fn);
- return this;
- };
- /**
- * Adds an `event` listener that will be invoked a single
- * time then automatically removed.
- *
- * @param {String} event
- * @param {Function} fn
- * @return {Emitter}
- * @api public
- */
- Emitter.prototype.once = function (event, fn) {
- var self = this;
- this._callbacks = this._callbacks || {};
- function on() {
- self.off(event, on);
- fn.apply(this, arguments);
- }
- on.fn = fn;
- this.on(event, on);
- return this;
- };
- /**
- * Remove the given callback for `event` or all
- * registered callbacks.
- *
- * @param {String} event
- * @param {Function} fn
- * @return {Emitter}
- * @api public
- */
- Emitter.prototype.off =
- Emitter.prototype.removeListener =
- Emitter.prototype.removeAllListeners =
- Emitter.prototype.removeEventListener = function (event, fn) {
- this._callbacks = this._callbacks || {};
- // all
- if (0 == arguments.length) {
- this._callbacks = {};
- return this;
- }
- // specific event
- var callbacks = this._callbacks[event];
- if (!callbacks) return this;
- // remove all handlers
- if (1 == arguments.length) {
- delete this._callbacks[event];
- return this;
- }
- // remove specific handler
- var cb;
- for (var i = 0; i < callbacks.length; i++) {
- cb = callbacks[i];
- if (cb === fn || cb.fn === fn) {
- callbacks.splice(i, 1);
- break;
- }
- }
- return this;
- };
- /**
- * Emit `event` with the given args.
- *
- * @param {String} event
- * @param {Mixed} ...
- * @return {Emitter}
- */
- Emitter.prototype.emit = function (event) {
- this._callbacks = this._callbacks || {};
- var args = [].slice.call(arguments, 1),
- callbacks = this._callbacks[event];
- if (callbacks) {
- callbacks = callbacks.slice(0);
- for (var i = 0, len = callbacks.length; i < len; ++i) {
- callbacks[i].apply(this, args);
- }
- }
- return this;
- };
- /**
- * Return array of callbacks for `event`.
- *
- * @param {String} event
- * @return {Array}
- * @api public
- */
- Emitter.prototype.listeners = function (event) {
- this._callbacks = this._callbacks || {};
- return this._callbacks[event] || [];
- };
- /**
- * Check if this emitter has `event` handlers.
- *
- * @param {String} event
- * @return {Boolean}
- * @api public
- */
- Emitter.prototype.hasListeners = function (event) {
- return !!this.listeners(event).length;
- };
- });
- require.register("ui-component-mouse/index.js", function (exports, require, module) {
- /**
- * dependencies.
- */
- var emitter = require('emitter'),
- event = require('event');
- /**
- * export `Mouse`
- */
- module.exports = function (el, obj) {
- return new Mouse(el, obj);
- };
- /**
- * initialize new `Mouse`.
- *
- * @param {Element} el
- * @param {Object} obj
- */
- function Mouse(el, obj) {
- this.obj = obj || {};
- this.el = el;
- }
- /**
- * mixin emitter.
- */
- emitter(Mouse.prototype);
- /**
- * bind mouse.
- *
- * @return {Mouse}
- */
- Mouse.prototype.bind = function () {
- var obj = this.obj,
- self = this;
- // up
- function up(e) {
- obj.onmouseup && obj.onmouseup(e);
- event.unbind(document, 'mousemove', move);
- event.unbind(document, 'mouseup', up);
- self.emit('up', e);
- }
- // move
- function move(e) {
- obj.onmousemove && obj.onmousemove(e);
- self.emit('move', e);
- }
- // down
- self.down = function (e) {
- obj.onmousedown && obj.onmousedown(e);
- event.bind(document, 'mouseup', up);
- event.bind(document, 'mousemove', move);
- self.emit('down', e);
- };
- // bind all.
- event.bind(this.el, 'mousedown', self.down);
- return this;
- };
- /**
- * unbind mouse.
- *
- * @return {Mouse}
- */
- Mouse.prototype.unbind = function () {
- event.unbind(this.el, 'mousedown', this.down);
- this.down = null;
- };
- });
- require.register("abpetkov-percentage-calc/percentage-calc.js", function (exports, require, module) {
- /**
- * Percentage-Calc 0.0.1
- * https://github.com/abpetkov/percentage-calc
- *
- * Authored by Alexander Petkov
- * https://github.com/abpetkov
- *
- * Copyright 2014, Alexander Petkov
- * License: The MIT License (MIT)
- * http://opensource.org/licenses/MIT
- *
- */
- /**
- * Check if number.
- *
- * @param {Number} num
- * @returns {Boolean}
- * @api public
- */
- exports.isNumber = function (num) {
- return (typeof num === 'number') ? true : false;
- };
- /**
- * Calculate percentage of a number.
- *
- * @param {Number} perc
- * @param {Number} num
- * @returns {Number} result
- * @api public
- */
- exports.of = function (perc, num) {
- if (exports.isNumber(perc) && exports.isNumber(num)) return (perc / 100) * num;
- };
- /**
- * Calculate percentage of a number out ot another number.
- *
- * @param {Number} part
- * @param {Number} target
- * @returns {Number} result
- * @api public
- */
- exports.from = function (part, target) {
- if (exports.isNumber(part) && exports.isNumber(target)) return (part / target) * 100;
- };
- });
- require.register("abpetkov-closest-num/closest-num.js", function (exports, require, module) {
- /**
- * Closest-num 0.0.1
- * https://github.com/abpetkov/closest-num
- *
- * Author: Alexander Petkov
- * https://github.com/abpetkov
- *
- * Copyright 2014, Alexander Petkov
- * License: The MIT License (MIT)
- * http://opensource.org/licenses/MIT
- *
- */
- /**
- * Get closest number in array.
- *
- * @param {Number} target
- * @param {Array} points
- * @returns {Number} closest
- * @api private
- */
- exports.find = function (target, points) {
- var diff = null,
- current = null,
- closest = points[0];
- for (i = 0; i < points.length; i++) {
- diff = Math.abs(target - closest);
- current = Math.abs(target - points[i]);
- if (current < diff) closest = points[i];
- }
- return closest;
- };
- });
- require.register("vesln-super/lib/super.js", function (exports, require, module) {
- /**
- * slice
- */
- var slice = Array.prototype.slice;
- /**
- * Primary export
- */
- var exports = module.exports = super_;
- /**
- * ### _super (dest, orig)
- *
- * Inherits the prototype methods or merges objects.
- * This is the primary export and it is recommended
- * that it be imported as `inherits` in node to match
- * the auto imported browser interface.
- *
- * var inherits = require('super');
- *
- * @param {Object|Function} destination object
- * @param {Object|Function} source object
- * @name _super
- * @api public
- */
- function super_() {
- var args = slice.call(arguments);
- if (!args.length) return;
- if (typeof args[0] !== 'function') return exports.merge(args);
- exports.inherits.apply(null, args);
- };
- /**
- * ### extend (proto[, klass])
- *
- * Provide `.extend` mechanism to allow extenion without
- * needing to use dependancy.
- *
- * function Bar () {
- * this._konstructed = true;
- * }
- *
- * Bar.extend = inherits.extend;
- *
- * var Fu = Bar.extend({
- * initialize: function () {
- * this._initialized = true;
- * }
- * });
- *
- * var fu = new Fu();
- * fu.should.be.instanceof(Fu); // true
- * fu.should.be.instanceof(Bar); // true
- *
- * @param {Object} properties/methods to add to new prototype
- * @param {Object} properties/methods to add to new class
- * @returns {Object} new constructor
- * @name extend
- * @api public
- */
- exports.extend = function (proto, klass) {
- var self = this,
- child = function () {
- return self.apply(this, arguments);
- };
- exports.merge([child, this]);
- exports.inherits(child, this);
- if (proto) exports.merge([child.prototype, proto]);
- if (klass) exports.merge([child, klass]);
- child.extend = this.extend; // prevent overwrite
- return child;
- };
- /**
- * ### inherits (ctor, superCtor)
- *
- * Inherit the prototype methods from on contructor
- * to another.
- *
- * @param {Function} destination
- * @param {Function} source
- * @api private
- */
- exports.inherits = function (ctor, superCtor) {
- ctor.super_ = superCtor;
- if (Object.create) {
- ctor.prototype = Object.create(superCtor.prototype, {
- constructor: {
- value: ctor,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
- } else {
- ctor.prototype = new superCtor();
- ctor.prototype.constructor = ctor;
- }
- }
- /**
- * Extends multiple objects.
- *
- * @param {Array} array of objects
- * @api private
- */
- exports.merge = function (arr) {
- var main = arr.length === 2 ? arr.shift() : {};
- var obj = null;
- for (var i = 0, len = arr.length; i < len; i++) {
- obj = arr[i];
- for (var p in obj) {
- if (!obj.hasOwnProperty(p)) continue;
- main[p] = obj[p];
- }
- }
- return main;
- };
- });
- require.register("powerange/lib/powerange.js", function (exports, require, module) {
- /**
- * Require classes.
- */
- var Main = require('./main'),
- Horizontal = require('./horizontal'),
- Vertical = require('./vertical');
- /**
- * Set default values.
- *
- * @api public
- */
- var defaults = {
- callback: function () {},
- decimal: false,
- disable: false,
- disableOpacity: 0.5,
- hideRange: false,
- klass: '',
- min: 0,
- max: 100,
- handleDiameter: 20,
- touchDiameter: 42,
- start: null,
- step: null,
- vertical: false
- };
- /**
- * Expose proper type of `Powerange`.
- */
- module.exports = function (element, options) {
- options = options || {};
- for (var i in defaults) {
- if (options[i] == null) {
- options[i] = defaults[i];
- }
- }
- if (options.vertical) {
- return new Vertical(element, options);
- } else {
- return new Horizontal(element, options);
- }
- };
- });
- require.register("powerange/lib/main.js", function (exports, require, module) {
- /**
- * External dependencies.
- *
- */
- var mouse = require('mouse'),
- events = require('events'),
- classes = require('classes'),
- percentage = require('percentage-calc');
- /**
- * Expose `Powerange`.
- */
- module.exports = Powerange;
- /**
- * Create Powerange object.
- *
- * @constructor
- * @param {Object} element
- * @param {Object} options
- * @api public
- */
- function Powerange(element, options) {
- if (!(this instanceof Powerange)) return new Powerange(element, options);
- this.element = element;
- this.options = options || {};
- //this.slider = this.create('span', 'range-bar');
- this.slider = this.create('div', 'range-container');
- if (this.element !== null && this.element.type === 'text') this.init();
- }
- /**
- * Bind events on handle element.
- *
- * @api private
- */
- Powerange.prototype.bindEvents = function () {
- this.handle = this.slider.querySelector('.range-handle');
- this.touch = events(this.slider, this);
- this.touch.bind('touchstart', 'onmousedown');
- this.touch.bind('touchmove', 'onmousemove');
- this.touch.bind('touchend', 'onmouseup');
- this.mouse = mouse(this.slider, this);
- this.mouse.bind();
- };
- /**
- * Hide the target element.
- *
- * @api private
- */
- Powerange.prototype.hide = function () {
- this.element.style.display = 'none';
- };
- /**
- * Append the target after the element.
- *
- * @api private
- */
- Powerange.prototype.append = function () {
- var slider = this.generate();
- this.insertAfter(this.element, slider);
- };
- /**
- * Generate the appropriate type of slider.
- *
- * @returns {Object} this.slider
- * @api private
- */
- Powerange.prototype.generate = function () {
- var elems = {
- 'handle': {
- 'type': 'span',
- 'selector': 'range-handle'
- },
- 'min': {
- 'type': 'span',
- 'selector': 'range-min'
- },
- 'max': {
- 'type': 'span',
- 'selector': 'range-max'
- },
- 'quantity': {
- 'type': 'span',
- 'selector': 'range-quantity'
- }
- };
- var bar = this.create('span', 'range-bar');
- this.slider.appendChild(bar);
- for (var key in elems) {
- if (elems.hasOwnProperty(key)) {
- var temp = this.create(elems[key].type, elems[key].selector);
- bar.appendChild(temp);
- }
- }
- return this.slider;
- };
- /**
- * Create HTML element.
- *
- * @param {String} type
- * @param {String} name
- * @returns {Object} elem
- * @api private
- */
- Powerange.prototype.create = function (type, name) {
- var elem = document.createElement(type);
- elem.className = name;
- return elem;
- };
- /**
- * Insert element after another element.
- *
- * @param {Object} reference
- * @param {Object} target
- * @api private
- */
- Powerange.prototype.insertAfter = function (reference, target) {
- reference.parentNode.insertBefore(target, reference.nextSibling);
- };
- /**
- * Add an additional class for extra customization.
- *
- * @param {String} klass
- * @api private
- */
- Powerange.prototype.extraClass = function (klass) {
- if (this.options.klass) classes(this.slider).add(klass);
- };
- /**
- * Set min and max values.
- *
- * @param {Number} min
- * @param {Number} max
- * @api private
- */
- Powerange.prototype.setRange = function (min, max) {
- if (typeof min === 'number' && typeof max === 'number' && !this.options.hideRange) {
- this.slider.querySelector('.range-min').innerHTML = min;
- this.slider.querySelector('.range-max').innerHTML = max;
- }
- };
- /**
- * Set slider current value.
- *
- * @param {Number} offset
- * @param {Number} size
- * @api private
- */
- Powerange.prototype.setValue = function (offset, size) {
- var part = percentage.from(parseFloat(offset), size),
- value = percentage.of(part, this.options.max - this.options.min) + this.options.min,
- changed = false;
- value = (this.options.decimal) ? (Math.round(value * 100) / 100) : Math.round(value);
- changed = (this.element.value != value) ? true : false;
- this.element.value = value;
- this.options.callback();
- if (changed) this.changeEvent();
- };
- /**
- * Set step.
- *
- * @param {Number} sliderSize
- * @param {Number} handleSize
- * @returns {Array} this.steps
- * @api private
- */
- Powerange.prototype.step = function (sliderSize, handleSize) {
- var dimension = sliderSize - handleSize,
- part = percentage.from(this.checkStep(this.options.step), this.options.max - this.options.min),
- interval = percentage.of(part, dimension),
- steps = [];
- if (interval == 0) interval = 1;
- for (i = 0; i <= dimension; i += interval) {
- steps.push(i);
- }
- this.steps = steps;
- return this.steps;
- };
- /**
- * Check values.
- *
- * @param {Number} start
- * @api private
- */
- Powerange.prototype.checkValues = function (start) {
- if (start < this.options.min) this.options.start = this.options.min;
- if (start > this.options.max) this.options.start = this.options.max;
- if (this.options.min >= this.options.max) this.options.min = this.options.max;
- };
- /**
- * Make sure `step` is positive.
- *
- * @param {Number} value
- * @returns {Number} this.options.step
- * @api private
- */
- Powerange.prototype.checkStep = function (value) {
- if (value < 0) value = Math.abs(value);
- this.options.step = value;
- return this.options.step;
- };
- /**
- * Disable range slider.
- *
- * @api private
- */
- Powerange.prototype.disable = function () {
- if (this.options.min == this.options.max || this.options.min > this.options.max || this.options.disable) {
- this.mouse.unbind();
- this.touch.unbind();
- this.slider.style.opacity = this.options.disableOpacity;
- classes(this.handle).add('range-disabled');
- }
- };
- /**
- * Make element unselectable.
- *
- * @param {Object} element
- * @param {Boolean} set
- * @api private
- */
- Powerange.prototype.unselectable = function (element, set) {
- if (!classes(this.slider).has('unselectable') && set === true) {
- classes(this.slider).add('unselectable');
- } else {
- classes(this.slider).remove('unselectable');
- }
- };
- /**
- * Handle the onchange event.
- *
- * @param {Boolean} state
- * @api private
- */
- Powerange.prototype.changeEvent = function (state) {
- if (typeof Event === 'function' || !document.fireEvent) {
- var event = document.createEvent('HTMLEvents');
- event.initEvent('change', false, true);
- this.element.dispatchEvent(event);
- } else {
- this.element.fireEvent('onchange');
- }
- };
- /**
- * Initialize main class.
- *
- * @api private
- */
- Powerange.prototype.init = function () {
- this.hide();
- this.append();
- this.bindEvents();
- this.extraClass(this.options.klass);
- this.checkValues(this.options.start);
- this.setRange(this.options.min, this.options.max);
- this.disable();
- };
- });
- require.register("powerange/lib/horizontal.js", function (exports, require, module) {
- /**
- * External dependencies.
- *
- */
- var inherits = require('super'),
- closest = require('closest-num'),
- percentage = require('percentage-calc');
- /**
- * Require main class.
- */
- var Powerange = require('./main');
- /**
- * Expose `Horizontal`.
- */
- module.exports = Horizontal;
- /**
- * Create horizontal slider object.
- *
- * @api public
- */
- function Horizontal() {
- Powerange.apply(this, arguments);
- this.handle.style.width = this.options.handleDiameter + "px";
- this.handle.style.height = this.options.handleDiameter + "px";
- this.handle.style.top = - (this.options.handleDiameter)/2 + 2 + "px";
- if (this.options.step) this.step($(this.slider).width(), $(this.handle).width());
- this.setStart(this.options.start);
- }
- /**
- * Inherit the main class.
- */
- inherits(Horizontal, Powerange);
- /**
- * Set horizontal slider position.
- *
- * @param {Number} start
- * @api private
- */
- Horizontal.prototype.setStart = function (start) {
- var begin = (start === null) ? this.options.min : start,
- part = percentage.from(begin - this.options.min, this.options.max - this.options.min) || 0,
- offset = percentage.of(part, $(this.slider).width() - $(this.handle).width()),
- position = (this.options.step) ? closest.find(offset, this.steps) : offset;
- this.setPosition(position);
- this.setValue(this.handle.style.left, $(this.slider).width() - $(this.handle).width());
- if (this.options.step) this.step($(this.slider).width(), $(this.handle).width());
- };
- /**
- * Set horizontal slider current position.
- *
- * @param {Number} val
- * @api private
- */
- Horizontal.prototype.setPosition = function (val) {
- this.handle.style.left = val + 'px';
- this.slider.querySelector('.range-quantity').style.width = val + 'px';
- };
- /**
- * On slider mouse down.
- *
- * @param {Object} e
- * @api private
- */
- Horizontal.prototype.onmousedown = function (e) {
- if (e.touches) e = e.touches[0];
- // snap to the touched position
- if (e.target.className !== 'range-handle') {
- if (!this.options.tap)
- return;
- var offset = 0;
- var elm = this.handle;
- while (elm !== null) {
- offset += elm.offsetLeft;
- elm = elm.offsetParent;
- }
- this.startX = offset - window.scrollX + this.handle.clientWidth / 2;
- } else {
- this.startX = e.clientX;
- this.ht = $(this.handle).css("top");
- this.handle.style.marginLeft = - (this.options.touchDiameter-this.options.handleDiameter)/4 + "px";
- this.handle.style.width = this.options.touchDiameter + "px";
- this.handle.style.height = this.options.touchDiameter + "px";
- this.handle.style.top = parseInt(this.handle.style.top) - (this.options.touchDiameter-this.options.handleDiameter)/2 +'px';
- }
- this.handleOffsetX = this.handle.offsetLeft;
- this.restrictHandleX = $(this.slider).width() - $(this.handle).width();
- this.unselectable(this.slider, true);
- this.onmousemove(e);
- };
- /**
- * On slider mouse move.
- *
- * @param {Object} e
- * @api private
- */
- Horizontal.prototype.onmousemove = function (e) {
- if (e.target.className !== 'range-handle' && !this.options.tap)
- return;
- if (typeof e.preventDefault == 'function') {
- e.preventDefault()
- }
- if (e.touches) e = e.touches[0];
- var leftOffset = this.handleOffsetX + e.clientX - this.startX,
- position = (this.steps) ? closest.find(leftOffset, this.steps) : leftOffset;
- if (leftOffset <= 0) {
- this.setPosition(0);
- } else if (leftOffset >= this.restrictHandleX) {
- this.setPosition(this.restrictHandleX);
- } else {
- this.setPosition(position);
- }
- this.setValue(this.handle.style.left, $(this.slider).width() - this.options.handleDiameter);
- };
- /**
- * On mouse up.
- *
- * @param {Object} e
- * @api private
- */
- Horizontal.prototype.onmouseup = function (e) {
- this.unselectable(this.slider, false);
- this.handle.style.marginLeft = "0px";
- this.handle.style.width = this.options.handleDiameter + "px";
- this.handle.style.height = this.options.handleDiameter + "px";
- this.handle.style.top = this.ht;
- this.setValue(this.handle.style.left, $(this.slider).width() - $(this.handle).width());
- };
- });
- require.register("powerange/lib/vertical.js", function (exports, require, module) {
- /**
- * External dependencies.
- *
- */
- var inherits = require('super'),
- classes = require('classes'),
- closest = require('closest-num'),
- percentage = require('percentage-calc');
- /**
- * Require main class.
- */
- var Powerange = require('./main');
- /**
- * Expose `Vertical`.
- */
- module.exports = Vertical;
- /**
- * Create vertical slider object.
- *
- * @api public
- */
- function Vertical() {
- Powerange.apply(this, arguments);
- this.handle.style.width = this.options.handleDiameter + "px";
- this.handle.style.height = this.options.handleDiameter + "px";
- classes(this.slider).add('vertical');
- if (this.options.step) this.step($(this.slider).height(), $(this.handle).height());
- this.setStart(this.options.start);
- }
- /**
- * Inherit the main class.
- */
- inherits(Vertical, Powerange);
- /**
- * Set vertical slider position.
- *
- * @param {Number} start
- * @api private
- */
- Vertical.prototype.setStart = function (start) {
- var begin = (start === null) ? this.options.min : start,
- part = percentage.from(begin - this.options.min, this.options.max - this.options.min) || 0,
- offset = percentage.of(part, $(this.slider).height() - $(this.handle).height()),
- position = (this.options.step) ? closest.find(offset, this.steps) : offset;
- this.setPosition(position);
- this.setValue(this.handle.style.bottom, $(this.slider).height() - $(this.handle).height());
- if (this.options.step) this.step($(this.slider).height(), $(this.handle).height());
- };
- /**
- * Set vertical slider current position.
- *
- * @param {Number} val
- * @api private
- */
- Vertical.prototype.setPosition = function (val) {
- this.handle.style.bottom = val + 'px';
- this.slider.querySelector('.range-quantity').style.height = val + 'px';
- };
- /**
- * On mouse down.
- *
- * @param {Object} e
- * @api private
- */
- Vertical.prototype.onmousedown = function (e) {
- if (e.touches) e = e.touches[0];
- // snap to the touched position
- if (e.target.className !== 'range-handle') {
- if (!this.options.tap)
- return;
- var offset = 0;
- var elm = this.handle;
- while (elm !== null) {
- offset += elm.offsetTop;
- elm = elm.offsetParent;
- }
- this.startY = offset - window.scrollY + this.handle.clientHeight / 2;
- } else {
- this.startY = e.clientY;
- this.handle.style.marginLeft = - (this.options.touchDiameter-this.options.handleDiameter)/2 + "px";
- this.handle.style.width = this.options.touchDiameter + "px";
- this.handle.style.height = this.options.touchDiameter + "px";
- }
- this.handleOffsetY = $(this.slider).height() - $(this.handle).height() - this.handle.offsetTop;
- this.restrictHandleY = $(this.slider).height() - $(this.handle).height();
- this.unselectable(this.slider, true);
- this.onmousemove(e);
- };
- /**
- * On vertical slider mouse move.
- *
- * @param {Object} e
- * @api private
- */
- Vertical.prototype.onmousemove = function (e) {
- if (e.target.className !== 'range-handle' && !this.options.tap)
- return;
- if (typeof e.preventDefault == 'function') {
- e.preventDefault()
- }
- if (e.touches) e = e.touches[0];
- var bottomOffset = this.handleOffsetY + this.startY - e.clientY,
- position = (this.steps) ? closest.find(bottomOffset, this.steps) : bottomOffset;
- if (bottomOffset <= 0) {
- this.setPosition(0);
- } else if (bottomOffset >= this.restrictHandleY) {
- this.setPosition(this.restrictHandleY);
- } else {
- this.setPosition(position);
- }
- this.setValue(this.handle.style.bottom, $(this.slider).height() - $(this.handle).height());
- };
- /**
- * On mouse up.
- *
- * @param {Object} e
- * @api private
- */
- Vertical.prototype.onmouseup = function (e) {
- this.unselectable(this.slider, false);
- this.handle.style.marginLeft = "0px";
- this.handle.style.width = this.options.handleDiameter + "px";
- this.handle.style.height = this.options.handleDiameter + "px";
- //this.handle.style.top = this.ht;
- this.setValue(this.handle.style.bottom, $(this.slider).height() - $(this.handle).height());
- };
- });
- require.alias("component-events/index.js", "powerange/deps/events/index.js");
- require.alias("component-events/index.js", "events/index.js");
- require.alias("component-event/index.js", "component-events/deps/event/index.js");
- require.alias("component-delegate/index.js", "component-events/deps/delegate/index.js");
- require.alias("discore-closest/index.js", "component-delegate/deps/closest/index.js");
- require.alias("discore-closest/index.js", "component-delegate/deps/closest/index.js");
- require.alias("component-matches-selector/index.js", "discore-closest/deps/matches-selector/index.js");
- require.alias("component-query/index.js", "component-matches-selector/deps/query/index.js");
- require.alias("discore-closest/index.js", "discore-closest/index.js");
- require.alias("component-event/index.js", "component-delegate/deps/event/index.js");
- require.alias("component-classes/index.js", "powerange/deps/classes/index.js");
- require.alias("component-classes/index.js", "classes/index.js");
- require.alias("component-indexof/index.js", "component-classes/deps/indexof/index.js");
- require.alias("ui-component-mouse/index.js", "powerange/deps/mouse/index.js");
- require.alias("ui-component-mouse/index.js", "mouse/index.js");
- require.alias("component-emitter/index.js", "ui-component-mouse/deps/emitter/index.js");
- require.alias("component-event/index.js", "ui-component-mouse/deps/event/index.js");
- require.alias("abpetkov-percentage-calc/percentage-calc.js", "powerange/deps/percentage-calc/percentage-calc.js");
- require.alias("abpetkov-percentage-calc/percentage-calc.js", "powerange/deps/percentage-calc/index.js");
- require.alias("abpetkov-percentage-calc/percentage-calc.js", "percentage-calc/index.js");
- require.alias("abpetkov-percentage-calc/percentage-calc.js", "abpetkov-percentage-calc/index.js");
- require.alias("abpetkov-closest-num/closest-num.js", "powerange/deps/closest-num/closest-num.js");
- require.alias("abpetkov-closest-num/closest-num.js", "powerange/deps/closest-num/index.js");
- require.alias("abpetkov-closest-num/closest-num.js", "closest-num/index.js");
- require.alias("abpetkov-closest-num/closest-num.js", "abpetkov-closest-num/index.js");
- require.alias("vesln-super/lib/super.js", "powerange/deps/super/lib/super.js");
- require.alias("vesln-super/lib/super.js", "powerange/deps/super/index.js");
- require.alias("vesln-super/lib/super.js", "super/index.js");
- require.alias("vesln-super/lib/super.js", "vesln-super/index.js");
- require.alias("powerange/lib/powerange.js", "powerange/index.js");
- if (typeof exports == "object") {
- module.exports = require("powerange");
- } else if (typeof define == "function" && define.amd) {
- define([], function () {
- return require("powerange");
- });
- } else {
- this["Powerange"] = require("powerange");
- }
- })();
|