diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..857d4ea --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +## v1.0.0 +- Add proper UMD to `Tooltip` +- Convert from `Coffeescript` to `ES6 (Babel)` +- Fix `*.json` files to include `main` +- Remove bundled `tooltip.js` +- Restructure directory layout +- Update `gulp` builds +- Update `drop` dependency to `v1.0.0` +- Update `tether` dependency to `v0.7.1` + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..67c3d17 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,57 @@ +# Contributing Guide + +You will need: + +- Node.js/io.js & npm +- Bower +- Gulp +- _Ruby_ (to be deprecated) +- _Sass gem_ (to be deprecated) +- _Compass gem_ (to be deprecated) + + +## Getting started + +1. Fork the project +2. Clone your forked project by running `git clone git@github.com:{ + YOUR_USERNAME }/drop.git` +3. Run `npm install` to install both node modules and bower components +4. Test that you can build the source by moving/renaming the existing `dist` + directory and running `npm run build` +5. Assuming everything went well, you should now have a `dist` directory that + matches the one you moved in step 4. +6. __NOTE__: Depending on your local version of Sass and Compass, you may end up + with slightly different stylesheets. In most cases, the changes are + equivalents and nothing to worry about. That said, we are planning on + removing the Ruby dependencies to alleviate issues like this. + + +## Writing code! + +We use `gulp` to facilitate things like transpilation, minification, etc. so +can focus on writing relevant code. If there is a fix or feature you would like +to contribute, we ask that you take the following steps: + +1. Most of the _editable_ code lives in the `src` directory while built code + will end up in the `dist` directory upon running `npm run build`. +2. Depending on how big your changes are, bump the version numbers appropriately + in `bower.json` and `package.json`. We try to follow semver, so a good rule + of thumb for how to bump the version is: + - A fix to existing code, perform a patch bump e.g. x.x.0 -> x.x.1 + - New feature, perform a minor bump e.g. x.0.x -> x.1.x + - Breaking changes such a rewrite, perform a major bump e.g. + 1.x.x -> 2.x.x + + Versioning is hard, so just use good judgement and we'll be more than happy + to help out. +3. Provide a thoughtful commit message and push your changes to your fork using + `git push origin master` (assuming your forked project is using `origin` for + the remote name and you are on the `master` branch). +4. Open a Pull Request on GitHub with a description of your changes. + + +## Testing + +Work in progress. We are hoping to add some tests, so if you would like to help +us get started, feel free to contact us through the Issues or open a Pull +Request. diff --git a/README.md b/README.md index 0724e29..5afec07 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,48 @@ ## Tooltip -### [Demo](http://github.hubspot.com/tooltip/docs/welcome)    [Documentation](http://github.hubspot.com/tooltip) - Tooltip.js is a Javascript and CSS library for creating styleable tooltips. -It only depends on [Tether.js](https://github.com/HubSpot/tether). -It is free and open source and was developed by HubSpot developers Zack Bloom ([@zackbloom](github.com/zackbloom)) and Adam Schwartz ([@adamschwartz](github.com/adamschwartz)). + + +## Install + +__Dependencies__ + +* __[Tether](https://github.com/HubSpot/tether)__ +* __[Drop](https://github.com/HubSpot/drop)__ + +Installing via `npm` and `bower` will bring in the above dependencies as well. + + +__npm__ +```sh +$ npm install tether-tooltip +``` + +__bower__ +```sh +$ bower install tether-tooltip +``` + +## Usage + +```javascript +let tooltipInstance = new Tooltip({ + target: document.querySelector('.tooltip-target'), + content: "My awesome content.", + classes: 'tooltip-tether-arrows', + position: 'top left' +}) +``` + +[API Documentation](http://github.hubspot.com/tooltip) + +[Demo](http://github.hubspot.com/tooltip/docs/welcome) + + +## Contributing + +We encourage contributions of all kinds. If you would like to contribute in some way, please review our [guidelines for contributing](CONTRIBUTING.md). + + +## License +Copyright © 2015 HubSpot - [MIT License](LICENSE) diff --git a/bower.json b/bower.json index 55b144f..ce9fd2e 100644 --- a/bower.json +++ b/bower.json @@ -1,16 +1,22 @@ { "name": "tether-tooltip", - "version": "0.2.6", + "version": "1.0.0", "homepage": "https://github.hubspot.com/tooltip", "authors": [ "Zack Bloom ", "Adam Schwartz " ], + "maintainers": [ + "Nicholas Hwang " + ], "description": "Tooltips built on Tether", "keywords": [ - "javascript" + "tooltip", + "overlay", + "tether" ], "license": "MIT", + "main": "dist/js/tooltip.js", "ignore": [ "**/.*", "node_modules", @@ -19,7 +25,7 @@ "tests" ], "dependencies": { - "drop": "0.5.4", - "tether": "0.6.5" + "drop": "~1.0.0", + "tether": "~0.7.1" } } diff --git a/coffee/tooltip.coffee b/coffee/tooltip.coffee deleted file mode 100644 index f38dd4f..0000000 --- a/coffee/tooltip.coffee +++ /dev/null @@ -1,60 +0,0 @@ -{addClass, removeClass, extend} = Tether.Utils - -_Drop = Drop.createContext - classPrefix: 'tooltip' - -defaults = - position: 'top center' - openOn: 'hover' - classes: 'tooltip-theme-arrows' - constrainToWindow: true - constrainToScrollParent: false - -class Tooltip - constructor: (@options) -> - if not @options.target - throw new Error "Tooltip Error: You must provide a target for Tooltip to attach to" - - if position = @options.target.getAttribute('data-tooltip-position') - @options.position ?= position - - if content = @options.target.getAttribute('data-tooltip') - @options.content ?= content - - if not @options.content - throw new Error "Tooltip Error: You must provide content for Tooltip to display" - - @options = extend {}, defaults, @options - - @drop = new _Drop @options - - close: -> - @drop.close() - - open: -> - @drop.open() - - toggle: -> - @drop.toggle() - - remove: -> - @drop.remove() - - destroy: -> - @drop.destroy() - - position: -> - @drop.position() - -initialized = [] -Tooltip.init = -> - for el in document.querySelectorAll('[data-tooltip]') when el not in initialized - new Tooltip {target: el} - - initialized.push el - -document.addEventListener 'DOMContentLoaded', -> - if Tooltip.autoinit isnt false - Tooltip.init() - -window.Tooltip = Tooltip diff --git a/config.rb b/config.rb deleted file mode 100644 index 1b59e68..0000000 --- a/config.rb +++ /dev/null @@ -1,5 +0,0 @@ -css_dir = "css" -sass_dir = "sass" -output_style = :nested -relative_assets = true -line_comments = false \ No newline at end of file diff --git a/css/tooltip-theme-arrows.css b/dist/css/tooltip-theme-arrows.css similarity index 91% rename from css/tooltip-theme-arrows.css rename to dist/css/tooltip-theme-arrows.css index 2a78152..c59a5b1 100644 --- a/css/tooltip-theme-arrows.css +++ b/dist/css/tooltip-theme-arrows.css @@ -1,6 +1,6 @@ .tooltip-element, .tooltip-element:after, .tooltip-element:before, .tooltip-element *, .tooltip-element *:after, .tooltip-element *:before { - -webkit-box-sizing: border-box; -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; box-sizing: border-box; } .tooltip-element { @@ -13,15 +13,13 @@ max-width: 100%; max-height: 100%; } .tooltip-element.tooltip-theme-arrows .tooltip-content { - -webkit-border-radius: 5px; -moz-border-radius: 5px; - -ms-border-radius: 5px; - -o-border-radius: 5px; + -webkit-border-radius: 5px; border-radius: 5px; position: relative; font-family: inherit; - background: black; - color: #eeeeee; + background: #000; + color: #eee; padding: 1em; font-size: 1.1em; line-height: 1.5em; } @@ -40,76 +38,76 @@ top: 100%; left: 50%; margin-left: -8px; - border-top-color: black; } + border-top-color: #000; } .tooltip-element.tooltip-theme-arrows.tooltip-element-attached-top.tooltip-element-attached-center .tooltip-content { margin-top: 8px; } .tooltip-element.tooltip-theme-arrows.tooltip-element-attached-top.tooltip-element-attached-center .tooltip-content:before { bottom: 100%; left: 50%; margin-left: -8px; - border-bottom-color: black; } + border-bottom-color: #000; } .tooltip-element.tooltip-theme-arrows.tooltip-element-attached-right.tooltip-element-attached-middle .tooltip-content { margin-right: 8px; } .tooltip-element.tooltip-theme-arrows.tooltip-element-attached-right.tooltip-element-attached-middle .tooltip-content:before { left: 100%; top: 50%; margin-top: -8px; - border-left-color: black; } + border-left-color: #000; } .tooltip-element.tooltip-theme-arrows.tooltip-element-attached-left.tooltip-element-attached-middle .tooltip-content { margin-left: 8px; } .tooltip-element.tooltip-theme-arrows.tooltip-element-attached-left.tooltip-element-attached-middle .tooltip-content:before { right: 100%; top: 50%; margin-top: -8px; - border-right-color: black; } + border-right-color: #000; } .tooltip-element.tooltip-theme-arrows.tooltip-element-attached-top.tooltip-element-attached-left.tooltip-target-attached-bottom .tooltip-content { margin-top: 8px; } .tooltip-element.tooltip-theme-arrows.tooltip-element-attached-top.tooltip-element-attached-left.tooltip-target-attached-bottom .tooltip-content:before { bottom: 100%; left: 8px; - border-bottom-color: black; } + border-bottom-color: #000; } .tooltip-element.tooltip-theme-arrows.tooltip-element-attached-top.tooltip-element-attached-right.tooltip-target-attached-bottom .tooltip-content { margin-top: 8px; } .tooltip-element.tooltip-theme-arrows.tooltip-element-attached-top.tooltip-element-attached-right.tooltip-target-attached-bottom .tooltip-content:before { bottom: 100%; right: 8px; - border-bottom-color: black; } + border-bottom-color: #000; } .tooltip-element.tooltip-theme-arrows.tooltip-element-attached-bottom.tooltip-element-attached-left.tooltip-target-attached-top .tooltip-content { margin-bottom: 8px; } .tooltip-element.tooltip-theme-arrows.tooltip-element-attached-bottom.tooltip-element-attached-left.tooltip-target-attached-top .tooltip-content:before { top: 100%; left: 8px; - border-top-color: black; } + border-top-color: #000; } .tooltip-element.tooltip-theme-arrows.tooltip-element-attached-bottom.tooltip-element-attached-right.tooltip-target-attached-top .tooltip-content { margin-bottom: 8px; } .tooltip-element.tooltip-theme-arrows.tooltip-element-attached-bottom.tooltip-element-attached-right.tooltip-target-attached-top .tooltip-content:before { top: 100%; right: 8px; - border-top-color: black; } + border-top-color: #000; } .tooltip-element.tooltip-theme-arrows.tooltip-element-attached-top.tooltip-element-attached-right.tooltip-target-attached-left .tooltip-content { margin-right: 8px; } .tooltip-element.tooltip-theme-arrows.tooltip-element-attached-top.tooltip-element-attached-right.tooltip-target-attached-left .tooltip-content:before { top: 8px; left: 100%; - border-left-color: black; } + border-left-color: #000; } .tooltip-element.tooltip-theme-arrows.tooltip-element-attached-top.tooltip-element-attached-left.tooltip-target-attached-right .tooltip-content { margin-left: 8px; } .tooltip-element.tooltip-theme-arrows.tooltip-element-attached-top.tooltip-element-attached-left.tooltip-target-attached-right .tooltip-content:before { top: 8px; right: 100%; - border-right-color: black; } + border-right-color: #000; } .tooltip-element.tooltip-theme-arrows.tooltip-element-attached-bottom.tooltip-element-attached-right.tooltip-target-attached-left .tooltip-content { margin-right: 8px; } .tooltip-element.tooltip-theme-arrows.tooltip-element-attached-bottom.tooltip-element-attached-right.tooltip-target-attached-left .tooltip-content:before { bottom: 8px; left: 100%; - border-left-color: black; } + border-left-color: #000; } .tooltip-element.tooltip-theme-arrows.tooltip-element-attached-bottom.tooltip-element-attached-left.tooltip-target-attached-right .tooltip-content { margin-left: 8px; } .tooltip-element.tooltip-theme-arrows.tooltip-element-attached-bottom.tooltip-element-attached-left.tooltip-target-attached-right .tooltip-content:before { bottom: 8px; right: 100%; - border-right-color: black; } + border-right-color: #000; } .tooltip-element.tooltip-theme-arrows { -webkit-pointer-events: none; diff --git a/dist/js/tooltip.js b/dist/js/tooltip.js new file mode 100644 index 0000000..5441d74 --- /dev/null +++ b/dist/js/tooltip.js @@ -0,0 +1,126 @@ +/*! tether-tooltip 1.0.0 */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(["drop","tether"], factory); + } else if (typeof exports === 'object') { + module.exports = factory(require('drop'), require('tether')); + } else { + root.Tooltip = factory(root.Drop, root.Tether); + } +}(this, function(Drop, Tether) { + +'use strict'; + +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'); } } + +/* global Tether Drop */ + +var extend = Tether.Utils.extend; + +var _Drop = Drop.createContext({ + classPrefix: 'tooltip' +}); + +var defaults = { + position: 'top center', + openOn: 'hover', + classes: 'tooltip-theme-arrows', + constrainToWindow: true, + constrainToScrollParent: false +}; + +var Tooltip = (function () { + function Tooltip(options) { + _classCallCheck(this, Tooltip); + + this.options = options; + + if (!this.options.target) { + throw new Error('Tooltip Error: You must provide a target for Tooltip to attach to'); + } + + var position = this.options.target.getAttribute('data-tooltip-position'); + if (position) { + if (typeof this.options.position === 'undefined') { + this.options.position = position; + } + } + + var content = this.options.target.getAttribute('data-tooltip'); + if (content) { + if (typeof this.options.content === 'undefined') { + this.options.content = content; + } + } + + if (!this.options.content) { + throw new Error('Tooltip Error: You must provide content for Tooltip to display'); + } + + this.options = extend({}, defaults, this.options); + + this.drop = new _Drop(this.options); + } + + _createClass(Tooltip, [{ + key: 'close', + value: function close() { + this.drop.close(); + } + }, { + key: 'open', + value: function open() { + this.drop.open(); + } + }, { + key: 'toggle', + value: function toggle() { + this.drop.toggle(); + } + }, { + key: 'remove', + value: function remove() { + this.drop.remove(); + } + }, { + key: 'destroy', + value: function destroy() { + this.drop.destroy(); + } + }, { + key: 'position', + value: function position() { + this.drop.position(); + } + }]); + + return Tooltip; +})(); + +var initialized = []; + +Tooltip.init = function () { + var tooltipElements = document.querySelectorAll('[data-tooltip]'); + var len = tooltipElements.length; + for (var i = 0; i < len; ++i) { + var el = tooltipElements[i]; + if (initialized.indexOf(el) === -1) { + new Tooltip({ + target: el + }); + initialized.push(el); + } + } +}; + +document.addEventListener('DOMContentLoaded', function () { + if (Tooltip.autoinit !== false) { + Tooltip.init(); + } +}); +return Tooltip; + +})); diff --git a/dist/js/tooltip.min.js b/dist/js/tooltip.min.js new file mode 100644 index 0000000..bdd8692 --- /dev/null +++ b/dist/js/tooltip.min.js @@ -0,0 +1 @@ +!function(t,o){"function"==typeof define&&define.amd?define(["drop","tether"],o):"object"==typeof exports?module.exports=o(require("drop"),require("tether")):t.Tooltip=o(t.Drop,t.Tether)}(this,function(t,o){"use strict";function e(t,o){if(!(t instanceof o))throw new TypeError("Cannot call a class as a function")}var n=function(){function t(t,o){for(var e=0;ee;++e){var n=t[e];-1===a.indexOf(n)&&(new p({target:n}),a.push(n))}},document.addEventListener("DOMContentLoaded",function(){p.autoinit!==!1&&p.init()}),p}); \ No newline at end of file diff --git a/gulpfile.coffee b/gulpfile.coffee deleted file mode 100644 index 2379e2a..0000000 --- a/gulpfile.coffee +++ /dev/null @@ -1,59 +0,0 @@ -gulp = require('gulp') -coffee = require('gulp-coffee') -compass = require('gulp-compass') -concat = require('gulp-concat') -uglify = require('gulp-uglify') -header = require('gulp-header') -rename = require('gulp-rename') -bower = require('gulp-bower') - -pkg = require('./package.json') -banner = "/*! #{ pkg.name } #{ pkg.version } */\n" - -gulp.task 'bower', -> - bower().pipe(gulp.dest('./bower_components')) - -gulp.task 'coffee', -> - gulp.src('coffee/*') - .pipe(coffee()) - .pipe(gulp.dest('./js/')) - - gulp.src('docs/welcome/coffee/*') - .pipe(coffee()) - .pipe(gulp.dest('./docs/welcome/js/')) - -gulp.task 'concat', -> - gulp.src(['./bower_components/tether/tether.js', './bower_components/drop/js/drop.js', './js/tooltip.js']) - .pipe(concat('tooltip.js')) - .pipe(header(banner)) - .pipe(gulp.dest('./')) - -gulp.task 'uglify', -> - gulp.src('./tooltip.js') - .pipe(uglify()) - .pipe(header(banner)) - .pipe(rename('tooltip.min.js')) - .pipe(gulp.dest('./')) - -gulp.task 'js', -> - gulp.run 'coffee', 'concat', 'uglify' - -gulp.task 'compass', -> - for path in ['', 'docs/welcome/'] - gulp.src("./#{ path }sass/*") - .pipe(compass( - sass: "#{ path }sass" - css: "#{ path }css" - comments: false - )) - .pipe(gulp.dest("./#{ path }css")) - -gulp.task 'default', -> - gulp.run 'bower', -> - gulp.run 'js', 'compass' - - gulp.watch './coffee/*', -> - gulp.run 'js' - - gulp.watch './**/*.sass', -> - gulp.run 'compass' diff --git a/gulpfile.js b/gulpfile.js index cfbdf87..f0ad275 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,2 +1,82 @@ -require('coffee-script') -require('./gulpfile.coffee') +var del = require('del'); +var gulp = require('gulp'); +var babel = require('gulp-babel'); +var sass = require('gulp-ruby-sass'); +var header = require('gulp-header'); +var rename = require('gulp-rename'); +var uglify = require('gulp-uglify'); +var umd = require('gulp-wrap-umd'); + + +// Variables +var distDir = './dist'; +var pkg = require('./package.json'); +var banner = ['/*!', pkg.name, pkg.version, '*/\n'].join(' '); +var umdOptions = { + exports: 'Tooltip', + namespace: 'Tooltip', + deps: [{ + name: 'Drop', + globalName: 'Drop', + paramName: 'Drop', + amdName: 'drop', + cjsName: 'drop' + }, + { + name: 'Tether', + globalName: 'Tether', + paramName: 'Tether', + amdName: 'tether', + cjsName: 'tether' + }] +}; + + +// Clean +gulp.task('clean', function() { + del.sync([distDir]); +}); + + +// Javascript +gulp.task('js', ['clean'], function() { + gulp.src('./src/js/**/*.js') + .pipe(babel()) + .pipe(umd(umdOptions)) + .pipe(header(banner)) + + // Original + .pipe(gulp.dest(distDir + '/js')) + + // Minified + .pipe(uglify()) + .pipe(rename({suffix: '.min'})) + .pipe(gulp.dest(distDir + '/js')); +}); + + +// CSS +gulp.task('css', function() { + sass('./src/css', { + loadPath: './bower_components', + compass: true + }) + .pipe(gulp.dest(distDir + '/css')); +}); + + +// Documentation +// TODO: Redo documentation + + +// Watch +gulp.task('watch', ['js', 'css'], function() { + gulp.watch('./src/js/**/*', ['js']); + gulp.watch('./src/css/**/*', ['css']); +}); + + +// Defaults +gulp.task('build', ['js', 'css']) +gulp.task('default', ['build']) + diff --git a/js/tooltip.js b/js/tooltip.js deleted file mode 100644 index 76c9d69..0000000 --- a/js/tooltip.js +++ /dev/null @@ -1,98 +0,0 @@ -(function() { - var Tooltip, addClass, defaults, extend, initialized, removeClass, _Drop, _ref, - __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; - - _ref = Tether.Utils, addClass = _ref.addClass, removeClass = _ref.removeClass, extend = _ref.extend; - - _Drop = Drop.createContext({ - classPrefix: 'tooltip' - }); - - defaults = { - position: 'top center', - openOn: 'hover', - classes: 'tooltip-theme-arrows', - constrainToWindow: true, - constrainToScrollParent: false - }; - - Tooltip = (function() { - function Tooltip(options) { - var content, position, _base, _base1; - this.options = options; - if (!this.options.target) { - throw new Error("Tooltip Error: You must provide a target for Tooltip to attach to"); - } - if (position = this.options.target.getAttribute('data-tooltip-position')) { - if ((_base = this.options).position == null) { - _base.position = position; - } - } - if (content = this.options.target.getAttribute('data-tooltip')) { - if ((_base1 = this.options).content == null) { - _base1.content = content; - } - } - if (!this.options.content) { - throw new Error("Tooltip Error: You must provide content for Tooltip to display"); - } - this.options = extend({}, defaults, this.options); - this.drop = new _Drop(this.options); - } - - Tooltip.prototype.close = function() { - return this.drop.close(); - }; - - Tooltip.prototype.open = function() { - return this.drop.open(); - }; - - Tooltip.prototype.toggle = function() { - return this.drop.toggle(); - }; - - Tooltip.prototype.remove = function() { - return this.drop.remove(); - }; - - Tooltip.prototype.destroy = function() { - return this.drop.destroy(); - }; - - Tooltip.prototype.position = function() { - return this.drop.position(); - }; - - return Tooltip; - - })(); - - initialized = []; - - Tooltip.init = function() { - var el, _i, _len, _ref1, _results; - _ref1 = document.querySelectorAll('[data-tooltip]'); - _results = []; - for (_i = 0, _len = _ref1.length; _i < _len; _i++) { - el = _ref1[_i]; - if (!(__indexOf.call(initialized, el) < 0)) { - continue; - } - new Tooltip({ - target: el - }); - _results.push(initialized.push(el)); - } - return _results; - }; - - document.addEventListener('DOMContentLoaded', function() { - if (Tooltip.autoinit !== false) { - return Tooltip.init(); - } - }); - - window.Tooltip = Tooltip; - -}).call(this); diff --git a/package.json b/package.json index 88e73df..e1cf340 100644 --- a/package.json +++ b/package.json @@ -1,22 +1,32 @@ { "name": "tether-tooltip", - "version": "0.2.6", + "version": "1.0.0", "description": "CSS tooltips built on Tether", "authors": [ "Adam Schwartz ", "Zack Bloom " ], + "maintainers": [ + "Nicholas Hwang " + ], + "scripts": { + "install": "bower install", + "build": "gulp build" + }, "license": "MIT", + "main": "dist/js/tooltip.js", "devDependencies": { - "coffee-script": "~1.6.3", - "gulp": "~3.3.0", - "gulp-header": "~1.0.2", - "gulp-uglify": "~0.1.0", - "gulp-compass": "~1.0.3", - "gulp-coffee": "~1.2.5", - "gulp-concat": "~2.1.7", - "gulp-rename": "~0.2.1", - "gulp-bower": "0.0.1", - "underscore": "~1.5.2" + "del": "^1.1.1", + "gulp": "^3.8.11", + "gulp-babel": "^5.1.0", + "gulp-header": "^1.2.2", + "gulp-rename": "^1.2.2", + "gulp-ruby-sass": "^1.0.5", + "gulp-uglify": "^1.2.0", + "gulp-wrap-umd": "^0.2.1" + }, + "dependencies": { + "tether": "^0.7.1", + "tether-drop": "^1.0.0" } } diff --git a/src/css/mixins/_pointer-events-temporary.sass b/src/css/mixins/_pointer-events-temporary.sass new file mode 100644 index 0000000..c336d6b --- /dev/null +++ b/src/css/mixins/_pointer-events-temporary.sass @@ -0,0 +1,4 @@ +@mixin pointer-events($type: none) + -webkit-pointer-events: $type + -moz-pointer-events: $type + pointer-events: $type diff --git a/sass/tooltip-theme-arrows.sass b/src/css/tooltip-theme-arrows.sass similarity index 87% rename from sass/tooltip-theme-arrows.sass rename to src/css/tooltip-theme-arrows.sass index 6c2eb9c..71d4def 100644 --- a/sass/tooltip-theme-arrows.sass +++ b/src/css/tooltip-theme-arrows.sass @@ -1,10 +1,10 @@ -@import ../bower_components/tether/sass/mixins/pointer-events - // The majority of the tooltip styles come from a tether helper @import ../bower_components/tether/sass/helpers/tether @import ../bower_components/tether/sass/helpers/tether-theme-arrows +@import mixins/pointer-events-temporary + $themePrefix: "tooltip" $arrowSize: 8px $backgroundColor: #000 @@ -20,4 +20,4 @@ $useDropShadow: false +pointer-events(none) .#{ $themePrefix }-content - padding: .5em 1em \ No newline at end of file + padding: .5em 1em diff --git a/src/js/tooltip.js b/src/js/tooltip.js new file mode 100644 index 0000000..5096ebc --- /dev/null +++ b/src/js/tooltip.js @@ -0,0 +1,93 @@ +/* global Tether Drop */ + +const { extend } = Tether.Utils; + +const _Drop = Drop.createContext({ + classPrefix: 'tooltip' +}); + +const defaults = { + position: 'top center', + openOn: 'hover', + classes: 'tooltip-theme-arrows', + constrainToWindow: true, + constrainToScrollParent: false +}; + +class Tooltip { + constructor(options) { + this.options = options; + + if (!this.options.target) { + throw new Error('Tooltip Error: You must provide a target for Tooltip to attach to'); + } + + const position = this.options.target.getAttribute('data-tooltip-position'); + if (position) { + if (typeof this.options.position === 'undefined') { + this.options.position = position; + } + } + + const content = this.options.target.getAttribute('data-tooltip'); + if (content) { + if (typeof this.options.content === 'undefined') { + this.options.content = content; + } + } + + if (!this.options.content) { + throw new Error('Tooltip Error: You must provide content for Tooltip to display'); + } + + this.options = extend({}, defaults, this.options); + + this.drop = new _Drop(this.options); + } + + close() { + this.drop.close(); + } + + open() { + this.drop.open(); + } + + toggle() { + this.drop.toggle(); + } + + remove() { + this.drop.remove(); + } + + destroy() { + this.drop.destroy(); + } + + position() { + this.drop.position(); + } +} + +let initialized = []; + +Tooltip.init = () => { + const tooltipElements = document.querySelectorAll('[data-tooltip]'); + const len = tooltipElements.length; + for (let i = 0; i < len; ++i) { + const el = tooltipElements[i]; + if (initialized.indexOf(el) === -1) { + new Tooltip({ + target: el + }); + initialized.push(el); + } + } +}; + +document.addEventListener('DOMContentLoaded', () => { + if (Tooltip.autoinit !== false) { + Tooltip.init(); + } +}); diff --git a/tooltip.js b/tooltip.js deleted file mode 100644 index d08052d..0000000 --- a/tooltip.js +++ /dev/null @@ -1,1896 +0,0 @@ -/*! tether-tooltip 0.2.6 */ -/*! tether 0.6.5 */ - - -(function(root, factory) { - if (typeof define === 'function' && define.amd) { - define(factory); - } else if (typeof exports === 'object') { - module.exports = factory(require,exports,module); - } else { - root.Tether = factory(); - } -}(this, function(require,exports,module) { - -(function() { - var Evented, addClass, defer, deferred, extend, flush, getBounds, getOffsetParent, getOrigin, getScrollBarSize, getScrollParent, hasClass, node, removeClass, uniqueId, updateClasses, zeroPosCache, - __hasProp = {}.hasOwnProperty, - __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, - __slice = [].slice; - - if (this.Tether == null) { - this.Tether = { - modules: [] - }; - } - - getScrollParent = function(el) { - var parent, position, scrollParent, style, _ref; - position = getComputedStyle(el).position; - if (position === 'fixed') { - return el; - } - scrollParent = void 0; - parent = el; - while (parent = parent.parentNode) { - try { - style = getComputedStyle(parent); - } catch (_error) {} - if (style == null) { - return parent; - } - if (/(auto|scroll)/.test(style['overflow'] + style['overflow-y'] + style['overflow-x'])) { - if (position !== 'absolute' || ((_ref = style['position']) === 'relative' || _ref === 'absolute' || _ref === 'fixed')) { - return parent; - } - } - } - return document.body; - }; - - uniqueId = (function() { - var id; - id = 0; - return function() { - return id++; - }; - })(); - - zeroPosCache = {}; - - getOrigin = function(doc) { - var id, k, node, v, _ref; - node = doc._tetherZeroElement; - if (node == null) { - node = doc.createElement('div'); - node.setAttribute('data-tether-id', uniqueId()); - extend(node.style, { - top: 0, - left: 0, - position: 'absolute' - }); - doc.body.appendChild(node); - doc._tetherZeroElement = node; - } - id = node.getAttribute('data-tether-id'); - if (zeroPosCache[id] == null) { - zeroPosCache[id] = {}; - _ref = node.getBoundingClientRect(); - for (k in _ref) { - v = _ref[k]; - zeroPosCache[id][k] = v; - } - defer(function() { - return zeroPosCache[id] = void 0; - }); - } - return zeroPosCache[id]; - }; - - node = null; - - getBounds = function(el) { - var box, doc, docEl, k, origin, v, _ref; - if (el === document) { - doc = document; - el = document.documentElement; - } else { - doc = el.ownerDocument; - } - docEl = doc.documentElement; - box = {}; - _ref = el.getBoundingClientRect(); - for (k in _ref) { - v = _ref[k]; - box[k] = v; - } - origin = getOrigin(doc); - box.top -= origin.top; - box.left -= origin.left; - if (box.width == null) { - box.width = document.body.scrollWidth - box.left - box.right; - } - if (box.height == null) { - box.height = document.body.scrollHeight - box.top - box.bottom; - } - box.top = box.top - docEl.clientTop; - box.left = box.left - docEl.clientLeft; - box.right = doc.body.clientWidth - box.width - box.left; - box.bottom = doc.body.clientHeight - box.height - box.top; - return box; - }; - - getOffsetParent = function(el) { - return el.offsetParent || document.documentElement; - }; - - getScrollBarSize = function() { - var inner, outer, width, widthContained, widthScroll; - inner = document.createElement('div'); - inner.style.width = '100%'; - inner.style.height = '200px'; - outer = document.createElement('div'); - extend(outer.style, { - position: 'absolute', - top: 0, - left: 0, - pointerEvents: 'none', - visibility: 'hidden', - width: '200px', - height: '150px', - overflow: 'hidden' - }); - outer.appendChild(inner); - document.body.appendChild(outer); - widthContained = inner.offsetWidth; - outer.style.overflow = 'scroll'; - widthScroll = inner.offsetWidth; - if (widthContained === widthScroll) { - widthScroll = outer.clientWidth; - } - document.body.removeChild(outer); - width = widthContained - widthScroll; - return { - width: width, - height: width - }; - }; - - extend = function(out) { - var args, key, obj, val, _i, _len, _ref; - if (out == null) { - out = {}; - } - args = []; - Array.prototype.push.apply(args, arguments); - _ref = args.slice(1); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - obj = _ref[_i]; - if (obj) { - for (key in obj) { - if (!__hasProp.call(obj, key)) continue; - val = obj[key]; - out[key] = val; - } - } - } - return out; - }; - - removeClass = function(el, name) { - var cls, _i, _len, _ref, _results; - if (el.classList != null) { - _ref = name.split(' '); - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - cls = _ref[_i]; - if (cls.trim()) { - _results.push(el.classList.remove(cls)); - } - } - return _results; - } else { - return el.className = el.className.replace(new RegExp("(^| )" + (name.split(' ').join('|')) + "( |$)", 'gi'), ' '); - } - }; - - addClass = function(el, name) { - var cls, _i, _len, _ref, _results; - if (el.classList != null) { - _ref = name.split(' '); - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - cls = _ref[_i]; - if (cls.trim()) { - _results.push(el.classList.add(cls)); - } - } - return _results; - } else { - removeClass(el, name); - return el.className += " " + name; - } - }; - - hasClass = function(el, name) { - if (el.classList != null) { - return el.classList.contains(name); - } else { - return new RegExp("(^| )" + name + "( |$)", 'gi').test(el.className); - } - }; - - updateClasses = function(el, add, all) { - var cls, _i, _j, _len, _len1, _results; - for (_i = 0, _len = all.length; _i < _len; _i++) { - cls = all[_i]; - if (__indexOf.call(add, cls) < 0) { - if (hasClass(el, cls)) { - removeClass(el, cls); - } - } - } - _results = []; - for (_j = 0, _len1 = add.length; _j < _len1; _j++) { - cls = add[_j]; - if (!hasClass(el, cls)) { - _results.push(addClass(el, cls)); - } else { - _results.push(void 0); - } - } - return _results; - }; - - deferred = []; - - defer = function(fn) { - return deferred.push(fn); - }; - - flush = function() { - var fn, _results; - _results = []; - while (fn = deferred.pop()) { - _results.push(fn()); - } - return _results; - }; - - Evented = (function() { - function Evented() {} - - Evented.prototype.on = function(event, handler, ctx, once) { - var _base; - if (once == null) { - once = false; - } - if (this.bindings == null) { - this.bindings = {}; - } - if ((_base = this.bindings)[event] == null) { - _base[event] = []; - } - return this.bindings[event].push({ - handler: handler, - ctx: ctx, - once: once - }); - }; - - Evented.prototype.once = function(event, handler, ctx) { - return this.on(event, handler, ctx, true); - }; - - Evented.prototype.off = function(event, handler) { - var i, _ref, _results; - if (((_ref = this.bindings) != null ? _ref[event] : void 0) == null) { - return; - } - if (handler == null) { - return delete this.bindings[event]; - } else { - i = 0; - _results = []; - while (i < this.bindings[event].length) { - if (this.bindings[event][i].handler === handler) { - _results.push(this.bindings[event].splice(i, 1)); - } else { - _results.push(i++); - } - } - return _results; - } - }; - - Evented.prototype.trigger = function() { - var args, ctx, event, handler, i, once, _ref, _ref1, _results; - event = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : []; - if ((_ref = this.bindings) != null ? _ref[event] : void 0) { - i = 0; - _results = []; - while (i < this.bindings[event].length) { - _ref1 = this.bindings[event][i], handler = _ref1.handler, ctx = _ref1.ctx, once = _ref1.once; - handler.apply(ctx != null ? ctx : this, args); - if (once) { - _results.push(this.bindings[event].splice(i, 1)); - } else { - _results.push(i++); - } - } - return _results; - } - }; - - return Evented; - - })(); - - this.Tether.Utils = { - getScrollParent: getScrollParent, - getBounds: getBounds, - getOffsetParent: getOffsetParent, - extend: extend, - addClass: addClass, - removeClass: removeClass, - hasClass: hasClass, - updateClasses: updateClasses, - defer: defer, - flush: flush, - uniqueId: uniqueId, - Evented: Evented, - getScrollBarSize: getScrollBarSize - }; - -}).call(this); - -(function() { - var MIRROR_LR, MIRROR_TB, OFFSET_MAP, Tether, addClass, addOffset, attachmentToOffset, autoToFixedAttachment, defer, extend, flush, getBounds, getOffsetParent, getOuterSize, getScrollBarSize, getScrollParent, getSize, now, offsetToPx, parseAttachment, parseOffset, position, removeClass, tethers, transformKey, updateClasses, within, _Tether, _ref, - __slice = [].slice, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - if (this.Tether == null) { - throw new Error("You must include the utils.js file before tether.js"); - } - - Tether = this.Tether; - - _ref = Tether.Utils, getScrollParent = _ref.getScrollParent, getSize = _ref.getSize, getOuterSize = _ref.getOuterSize, getBounds = _ref.getBounds, getOffsetParent = _ref.getOffsetParent, extend = _ref.extend, addClass = _ref.addClass, removeClass = _ref.removeClass, updateClasses = _ref.updateClasses, defer = _ref.defer, flush = _ref.flush, getScrollBarSize = _ref.getScrollBarSize; - - within = function(a, b, diff) { - if (diff == null) { - diff = 1; - } - return (a + diff >= b && b >= a - diff); - }; - - transformKey = (function() { - var el, key, _i, _len, _ref1; - el = document.createElement('div'); - _ref1 = ['transform', 'webkitTransform', 'OTransform', 'MozTransform', 'msTransform']; - for (_i = 0, _len = _ref1.length; _i < _len; _i++) { - key = _ref1[_i]; - if (el.style[key] !== void 0) { - return key; - } - } - })(); - - tethers = []; - - position = function() { - var tether, _i, _len; - for (_i = 0, _len = tethers.length; _i < _len; _i++) { - tether = tethers[_i]; - tether.position(false); - } - return flush(); - }; - - now = function() { - var _ref1; - return (_ref1 = typeof performance !== "undefined" && performance !== null ? typeof performance.now === "function" ? performance.now() : void 0 : void 0) != null ? _ref1 : +(new Date); - }; - - (function() { - var event, lastCall, lastDuration, pendingTimeout, tick, _i, _len, _ref1, _results; - lastCall = null; - lastDuration = null; - pendingTimeout = null; - tick = function() { - if ((lastDuration != null) && lastDuration > 16) { - lastDuration = Math.min(lastDuration - 16, 250); - pendingTimeout = setTimeout(tick, 250); - return; - } - if ((lastCall != null) && (now() - lastCall) < 10) { - return; - } - if (pendingTimeout != null) { - clearTimeout(pendingTimeout); - pendingTimeout = null; - } - lastCall = now(); - position(); - return lastDuration = now() - lastCall; - }; - _ref1 = ['resize', 'scroll', 'touchmove']; - _results = []; - for (_i = 0, _len = _ref1.length; _i < _len; _i++) { - event = _ref1[_i]; - _results.push(window.addEventListener(event, tick)); - } - return _results; - })(); - - MIRROR_LR = { - center: 'center', - left: 'right', - right: 'left' - }; - - MIRROR_TB = { - middle: 'middle', - top: 'bottom', - bottom: 'top' - }; - - OFFSET_MAP = { - top: 0, - left: 0, - middle: '50%', - center: '50%', - bottom: '100%', - right: '100%' - }; - - autoToFixedAttachment = function(attachment, relativeToAttachment) { - var left, top; - left = attachment.left, top = attachment.top; - if (left === 'auto') { - left = MIRROR_LR[relativeToAttachment.left]; - } - if (top === 'auto') { - top = MIRROR_TB[relativeToAttachment.top]; - } - return { - left: left, - top: top - }; - }; - - attachmentToOffset = function(attachment) { - var _ref1, _ref2; - return { - left: (_ref1 = OFFSET_MAP[attachment.left]) != null ? _ref1 : attachment.left, - top: (_ref2 = OFFSET_MAP[attachment.top]) != null ? _ref2 : attachment.top - }; - }; - - addOffset = function() { - var left, offsets, out, top, _i, _len, _ref1; - offsets = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - out = { - top: 0, - left: 0 - }; - for (_i = 0, _len = offsets.length; _i < _len; _i++) { - _ref1 = offsets[_i], top = _ref1.top, left = _ref1.left; - if (typeof top === 'string') { - top = parseFloat(top, 10); - } - if (typeof left === 'string') { - left = parseFloat(left, 10); - } - out.top += top; - out.left += left; - } - return out; - }; - - offsetToPx = function(offset, size) { - if (typeof offset.left === 'string' && offset.left.indexOf('%') !== -1) { - offset.left = parseFloat(offset.left, 10) / 100 * size.width; - } - if (typeof offset.top === 'string' && offset.top.indexOf('%') !== -1) { - offset.top = parseFloat(offset.top, 10) / 100 * size.height; - } - return offset; - }; - - parseAttachment = parseOffset = function(value) { - var left, top, _ref1; - _ref1 = value.split(' '), top = _ref1[0], left = _ref1[1]; - return { - top: top, - left: left - }; - }; - - _Tether = (function() { - _Tether.modules = []; - - function _Tether(options) { - this.position = __bind(this.position, this); - var module, _i, _len, _ref1, _ref2; - tethers.push(this); - this.history = []; - this.setOptions(options, false); - _ref1 = Tether.modules; - for (_i = 0, _len = _ref1.length; _i < _len; _i++) { - module = _ref1[_i]; - if ((_ref2 = module.initialize) != null) { - _ref2.call(this); - } - } - this.position(); - } - - _Tether.prototype.getClass = function(key) { - var _ref1, _ref2; - if ((_ref1 = this.options.classes) != null ? _ref1[key] : void 0) { - return this.options.classes[key]; - } else if (((_ref2 = this.options.classes) != null ? _ref2[key] : void 0) !== false) { - if (this.options.classPrefix) { - return "" + this.options.classPrefix + "-" + key; - } else { - return key; - } - } else { - return ''; - } - }; - - _Tether.prototype.setOptions = function(options, position) { - var defaults, key, _i, _len, _ref1, _ref2; - this.options = options; - if (position == null) { - position = true; - } - defaults = { - offset: '0 0', - targetOffset: '0 0', - targetAttachment: 'auto auto', - classPrefix: 'tether' - }; - this.options = extend(defaults, this.options); - _ref1 = this.options, this.element = _ref1.element, this.target = _ref1.target, this.targetModifier = _ref1.targetModifier; - if (this.target === 'viewport') { - this.target = document.body; - this.targetModifier = 'visible'; - } else if (this.target === 'scroll-handle') { - this.target = document.body; - this.targetModifier = 'scroll-handle'; - } - _ref2 = ['element', 'target']; - for (_i = 0, _len = _ref2.length; _i < _len; _i++) { - key = _ref2[_i]; - if (this[key] == null) { - throw new Error("Tether Error: Both element and target must be defined"); - } - if (this[key].jquery != null) { - this[key] = this[key][0]; - } else if (typeof this[key] === 'string') { - this[key] = document.querySelector(this[key]); - } - } - addClass(this.element, this.getClass('element')); - addClass(this.target, this.getClass('target')); - if (!this.options.attachment) { - throw new Error("Tether Error: You must provide an attachment"); - } - this.targetAttachment = parseAttachment(this.options.targetAttachment); - this.attachment = parseAttachment(this.options.attachment); - this.offset = parseOffset(this.options.offset); - this.targetOffset = parseOffset(this.options.targetOffset); - if (this.scrollParent != null) { - this.disable(); - } - if (this.targetModifier === 'scroll-handle') { - this.scrollParent = this.target; - } else { - this.scrollParent = getScrollParent(this.target); - } - if (this.options.enabled !== false) { - return this.enable(position); - } - }; - - _Tether.prototype.getTargetBounds = function() { - var bounds, fitAdj, hasBottomScroll, height, out, scrollBottom, scrollPercentage, style, target; - if (this.targetModifier != null) { - switch (this.targetModifier) { - case 'visible': - if (this.target === document.body) { - return { - top: pageYOffset, - left: pageXOffset, - height: innerHeight, - width: innerWidth - }; - } else { - bounds = getBounds(this.target); - out = { - height: bounds.height, - width: bounds.width, - top: bounds.top, - left: bounds.left - }; - out.height = Math.min(out.height, bounds.height - (pageYOffset - bounds.top)); - out.height = Math.min(out.height, bounds.height - ((bounds.top + bounds.height) - (pageYOffset + innerHeight))); - out.height = Math.min(innerHeight, out.height); - out.height -= 2; - out.width = Math.min(out.width, bounds.width - (pageXOffset - bounds.left)); - out.width = Math.min(out.width, bounds.width - ((bounds.left + bounds.width) - (pageXOffset + innerWidth))); - out.width = Math.min(innerWidth, out.width); - out.width -= 2; - if (out.top < pageYOffset) { - out.top = pageYOffset; - } - if (out.left < pageXOffset) { - out.left = pageXOffset; - } - return out; - } - break; - case 'scroll-handle': - target = this.target; - if (target === document.body) { - target = document.documentElement; - bounds = { - left: pageXOffset, - top: pageYOffset, - height: innerHeight, - width: innerWidth - }; - } else { - bounds = getBounds(target); - } - style = getComputedStyle(target); - hasBottomScroll = target.scrollWidth > target.clientWidth || 'scroll' === [style.overflow, style.overflowX] || this.target !== document.body; - scrollBottom = 0; - if (hasBottomScroll) { - scrollBottom = 15; - } - height = bounds.height - parseFloat(style.borderTopWidth) - parseFloat(style.borderBottomWidth) - scrollBottom; - out = { - width: 15, - height: height * 0.975 * (height / target.scrollHeight), - left: bounds.left + bounds.width - parseFloat(style.borderLeftWidth) - 15 - }; - fitAdj = 0; - if (height < 408 && this.target === document.body) { - fitAdj = -0.00011 * Math.pow(height, 2) - 0.00727 * height + 22.58; - } - if (this.target !== document.body) { - out.height = Math.max(out.height, 24); - } - scrollPercentage = this.target.scrollTop / (target.scrollHeight - height); - out.top = scrollPercentage * (height - out.height - fitAdj) + bounds.top + parseFloat(style.borderTopWidth); - if (this.target === document.body) { - out.height = Math.max(out.height, 24); - } - return out; - } - } else { - return getBounds(this.target); - } - }; - - _Tether.prototype.clearCache = function() { - return this._cache = {}; - }; - - _Tether.prototype.cache = function(k, getter) { - if (this._cache == null) { - this._cache = {}; - } - if (this._cache[k] == null) { - this._cache[k] = getter.call(this); - } - return this._cache[k]; - }; - - _Tether.prototype.enable = function(position) { - if (position == null) { - position = true; - } - addClass(this.target, this.getClass('enabled')); - addClass(this.element, this.getClass('enabled')); - this.enabled = true; - if (this.scrollParent !== document) { - this.scrollParent.addEventListener('scroll', this.position); - } - if (position) { - return this.position(); - } - }; - - _Tether.prototype.disable = function() { - removeClass(this.target, this.getClass('enabled')); - removeClass(this.element, this.getClass('enabled')); - this.enabled = false; - if (this.scrollParent != null) { - return this.scrollParent.removeEventListener('scroll', this.position); - } - }; - - _Tether.prototype.destroy = function() { - var i, tether, _i, _len, _results; - this.disable(); - _results = []; - for (i = _i = 0, _len = tethers.length; _i < _len; i = ++_i) { - tether = tethers[i]; - if (tether === this) { - tethers.splice(i, 1); - break; - } else { - _results.push(void 0); - } - } - return _results; - }; - - _Tether.prototype.updateAttachClasses = function(elementAttach, targetAttach) { - var add, all, side, sides, _i, _j, _len, _len1, _ref1, - _this = this; - if (elementAttach == null) { - elementAttach = this.attachment; - } - if (targetAttach == null) { - targetAttach = this.targetAttachment; - } - sides = ['left', 'top', 'bottom', 'right', 'middle', 'center']; - if ((_ref1 = this._addAttachClasses) != null ? _ref1.length : void 0) { - this._addAttachClasses.splice(0, this._addAttachClasses.length); - } - add = this._addAttachClasses != null ? this._addAttachClasses : this._addAttachClasses = []; - if (elementAttach.top) { - add.push("" + (this.getClass('element-attached')) + "-" + elementAttach.top); - } - if (elementAttach.left) { - add.push("" + (this.getClass('element-attached')) + "-" + elementAttach.left); - } - if (targetAttach.top) { - add.push("" + (this.getClass('target-attached')) + "-" + targetAttach.top); - } - if (targetAttach.left) { - add.push("" + (this.getClass('target-attached')) + "-" + targetAttach.left); - } - all = []; - for (_i = 0, _len = sides.length; _i < _len; _i++) { - side = sides[_i]; - all.push("" + (this.getClass('element-attached')) + "-" + side); - } - for (_j = 0, _len1 = sides.length; _j < _len1; _j++) { - side = sides[_j]; - all.push("" + (this.getClass('target-attached')) + "-" + side); - } - return defer(function() { - if (_this._addAttachClasses == null) { - return; - } - updateClasses(_this.element, _this._addAttachClasses, all); - updateClasses(_this.target, _this._addAttachClasses, all); - return _this._addAttachClasses = void 0; - }); - }; - - _Tether.prototype.position = function(flushChanges) { - var elementPos, elementStyle, height, left, manualOffset, manualTargetOffset, module, next, offset, offsetBorder, offsetParent, offsetParentSize, offsetParentStyle, offsetPosition, ret, scrollLeft, scrollTop, scrollbarSize, side, targetAttachment, targetOffset, targetPos, targetSize, top, width, _i, _j, _len, _len1, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, - _this = this; - if (flushChanges == null) { - flushChanges = true; - } - if (!this.enabled) { - return; - } - this.clearCache(); - targetAttachment = autoToFixedAttachment(this.targetAttachment, this.attachment); - this.updateAttachClasses(this.attachment, targetAttachment); - elementPos = this.cache('element-bounds', function() { - return getBounds(_this.element); - }); - width = elementPos.width, height = elementPos.height; - if (width === 0 && height === 0 && (this.lastSize != null)) { - _ref1 = this.lastSize, width = _ref1.width, height = _ref1.height; - } else { - this.lastSize = { - width: width, - height: height - }; - } - targetSize = targetPos = this.cache('target-bounds', function() { - return _this.getTargetBounds(); - }); - offset = offsetToPx(attachmentToOffset(this.attachment), { - width: width, - height: height - }); - targetOffset = offsetToPx(attachmentToOffset(targetAttachment), targetSize); - manualOffset = offsetToPx(this.offset, { - width: width, - height: height - }); - manualTargetOffset = offsetToPx(this.targetOffset, targetSize); - offset = addOffset(offset, manualOffset); - targetOffset = addOffset(targetOffset, manualTargetOffset); - left = targetPos.left + targetOffset.left - offset.left; - top = targetPos.top + targetOffset.top - offset.top; - _ref2 = Tether.modules; - for (_i = 0, _len = _ref2.length; _i < _len; _i++) { - module = _ref2[_i]; - ret = module.position.call(this, { - left: left, - top: top, - targetAttachment: targetAttachment, - targetPos: targetPos, - attachment: this.attachment, - elementPos: elementPos, - offset: offset, - targetOffset: targetOffset, - manualOffset: manualOffset, - manualTargetOffset: manualTargetOffset, - scrollbarSize: scrollbarSize - }); - if ((ret == null) || typeof ret !== 'object') { - continue; - } else if (ret === false) { - return false; - } else { - top = ret.top, left = ret.left; - } - } - next = { - page: { - top: top, - left: left - }, - viewport: { - top: top - pageYOffset, - bottom: pageYOffset - top - height + innerHeight, - left: left - pageXOffset, - right: pageXOffset - left - width + innerWidth - } - }; - if (document.body.scrollWidth > window.innerWidth) { - scrollbarSize = this.cache('scrollbar-size', getScrollBarSize); - next.viewport.bottom -= scrollbarSize.height; - } - if (document.body.scrollHeight > window.innerHeight) { - scrollbarSize = this.cache('scrollbar-size', getScrollBarSize); - next.viewport.right -= scrollbarSize.width; - } - if (((_ref3 = document.body.style.position) !== '' && _ref3 !== 'static') || ((_ref4 = document.body.parentElement.style.position) !== '' && _ref4 !== 'static')) { - next.page.bottom = document.body.scrollHeight - top - height; - next.page.right = document.body.scrollWidth - left - width; - } - if (((_ref5 = this.options.optimizations) != null ? _ref5.moveElement : void 0) !== false && (this.targetModifier == null)) { - offsetParent = this.cache('target-offsetparent', function() { - return getOffsetParent(_this.target); - }); - offsetPosition = this.cache('target-offsetparent-bounds', function() { - return getBounds(offsetParent); - }); - offsetParentStyle = getComputedStyle(offsetParent); - elementStyle = getComputedStyle(this.element); - offsetParentSize = offsetPosition; - offsetBorder = {}; - _ref6 = ['Top', 'Left', 'Bottom', 'Right']; - for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) { - side = _ref6[_j]; - offsetBorder[side.toLowerCase()] = parseFloat(offsetParentStyle["border" + side + "Width"]); - } - offsetPosition.right = document.body.scrollWidth - offsetPosition.left - offsetParentSize.width + offsetBorder.right; - offsetPosition.bottom = document.body.scrollHeight - offsetPosition.top - offsetParentSize.height + offsetBorder.bottom; - if (next.page.top >= (offsetPosition.top + offsetBorder.top) && next.page.bottom >= offsetPosition.bottom) { - if (next.page.left >= (offsetPosition.left + offsetBorder.left) && next.page.right >= offsetPosition.right) { - scrollTop = offsetParent.scrollTop; - scrollLeft = offsetParent.scrollLeft; - next.offset = { - top: next.page.top - offsetPosition.top + scrollTop - offsetBorder.top, - left: next.page.left - offsetPosition.left + scrollLeft - offsetBorder.left - }; - } - } - } - this.move(next); - this.history.unshift(next); - if (this.history.length > 3) { - this.history.pop(); - } - if (flushChanges) { - flush(); - } - return true; - }; - - _Tether.prototype.move = function(position) { - var css, elVal, found, key, moved, offsetParent, point, same, transcribe, type, val, write, writeCSS, _i, _len, _ref1, _ref2, - _this = this; - if (this.element.parentNode == null) { - return; - } - same = {}; - for (type in position) { - same[type] = {}; - for (key in position[type]) { - found = false; - _ref1 = this.history; - for (_i = 0, _len = _ref1.length; _i < _len; _i++) { - point = _ref1[_i]; - if (!within((_ref2 = point[type]) != null ? _ref2[key] : void 0, position[type][key])) { - found = true; - break; - } - } - if (!found) { - same[type][key] = true; - } - } - } - css = { - top: '', - left: '', - right: '', - bottom: '' - }; - transcribe = function(same, pos) { - var xPos, yPos, _ref3; - if (((_ref3 = _this.options.optimizations) != null ? _ref3.gpu : void 0) !== false) { - if (same.top) { - css.top = 0; - yPos = pos.top; - } else { - css.bottom = 0; - yPos = -pos.bottom; - } - if (same.left) { - css.left = 0; - xPos = pos.left; - } else { - css.right = 0; - xPos = -pos.right; - } - css[transformKey] = "translateX(" + (Math.round(xPos)) + "px) translateY(" + (Math.round(yPos)) + "px)"; - if (transformKey !== 'msTransform') { - return css[transformKey] += " translateZ(0)"; - } - } else { - if (same.top) { - css.top = "" + pos.top + "px"; - } else { - css.bottom = "" + pos.bottom + "px"; - } - if (same.left) { - return css.left = "" + pos.left + "px"; - } else { - return css.right = "" + pos.right + "px"; - } - } - }; - moved = false; - if ((same.page.top || same.page.bottom) && (same.page.left || same.page.right)) { - css.position = 'absolute'; - transcribe(same.page, position.page); - } else if ((same.viewport.top || same.viewport.bottom) && (same.viewport.left || same.viewport.right)) { - css.position = 'fixed'; - transcribe(same.viewport, position.viewport); - } else if ((same.offset != null) && same.offset.top && same.offset.left) { - css.position = 'absolute'; - offsetParent = this.cache('target-offsetparent', function() { - return getOffsetParent(_this.target); - }); - if (getOffsetParent(this.element) !== offsetParent) { - defer(function() { - _this.element.parentNode.removeChild(_this.element); - return offsetParent.appendChild(_this.element); - }); - } - transcribe(same.offset, position.offset); - moved = true; - } else { - css.position = 'absolute'; - transcribe({ - top: true, - left: true - }, position.page); - } - if (!moved && this.element.parentNode.tagName !== 'BODY') { - this.element.parentNode.removeChild(this.element); - document.body.appendChild(this.element); - } - writeCSS = {}; - write = false; - for (key in css) { - val = css[key]; - elVal = this.element.style[key]; - if (elVal !== '' && val !== '' && (key === 'top' || key === 'left' || key === 'bottom' || key === 'right')) { - elVal = parseFloat(elVal); - val = parseFloat(val); - } - if (elVal !== val) { - write = true; - writeCSS[key] = css[key]; - } - } - if (write) { - return defer(function() { - return extend(_this.element.style, writeCSS); - }); - } - }; - - return _Tether; - - })(); - - Tether.position = position; - - this.Tether = extend(_Tether, Tether); - -}).call(this); - -(function() { - var BOUNDS_FORMAT, MIRROR_ATTACH, defer, extend, getBoundingRect, getBounds, getOuterSize, getSize, updateClasses, _ref, - __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; - - _ref = this.Tether.Utils, getOuterSize = _ref.getOuterSize, getBounds = _ref.getBounds, getSize = _ref.getSize, extend = _ref.extend, updateClasses = _ref.updateClasses, defer = _ref.defer; - - MIRROR_ATTACH = { - left: 'right', - right: 'left', - top: 'bottom', - bottom: 'top', - middle: 'middle' - }; - - BOUNDS_FORMAT = ['left', 'top', 'right', 'bottom']; - - getBoundingRect = function(tether, to) { - var i, pos, side, size, style, _i, _len; - if (to === 'scrollParent') { - to = tether.scrollParent; - } else if (to === 'window') { - to = [pageXOffset, pageYOffset, innerWidth + pageXOffset, innerHeight + pageYOffset]; - } - if (to === document) { - to = to.documentElement; - } - if (to.nodeType != null) { - pos = size = getBounds(to); - style = getComputedStyle(to); - to = [pos.left, pos.top, size.width + pos.left, size.height + pos.top]; - for (i = _i = 0, _len = BOUNDS_FORMAT.length; _i < _len; i = ++_i) { - side = BOUNDS_FORMAT[i]; - side = side[0].toUpperCase() + side.substr(1); - if (side === 'Top' || side === 'Left') { - to[i] += parseFloat(style["border" + side + "Width"]); - } else { - to[i] -= parseFloat(style["border" + side + "Width"]); - } - } - } - return to; - }; - - this.Tether.modules.push({ - position: function(_arg) { - var addClasses, allClasses, attachment, bounds, changeAttachX, changeAttachY, cls, constraint, eAttachment, height, left, oob, oobClass, p, pin, pinned, pinnedClass, removeClass, side, tAttachment, targetAttachment, targetHeight, targetSize, targetWidth, to, top, width, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _len5, _m, _n, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, - _this = this; - top = _arg.top, left = _arg.left, targetAttachment = _arg.targetAttachment; - if (!this.options.constraints) { - return true; - } - removeClass = function(prefix) { - var side, _i, _len, _results; - _this.removeClass(prefix); - _results = []; - for (_i = 0, _len = BOUNDS_FORMAT.length; _i < _len; _i++) { - side = BOUNDS_FORMAT[_i]; - _results.push(_this.removeClass("" + prefix + "-" + side)); - } - return _results; - }; - _ref1 = this.cache('element-bounds', function() { - return getBounds(_this.element); - }), height = _ref1.height, width = _ref1.width; - if (width === 0 && height === 0 && (this.lastSize != null)) { - _ref2 = this.lastSize, width = _ref2.width, height = _ref2.height; - } - targetSize = this.cache('target-bounds', function() { - return _this.getTargetBounds(); - }); - targetHeight = targetSize.height; - targetWidth = targetSize.width; - tAttachment = {}; - eAttachment = {}; - allClasses = [this.getClass('pinned'), this.getClass('out-of-bounds')]; - _ref3 = this.options.constraints; - for (_i = 0, _len = _ref3.length; _i < _len; _i++) { - constraint = _ref3[_i]; - if (constraint.outOfBoundsClass) { - allClasses.push(constraint.outOfBoundsClass); - } - if (constraint.pinnedClass) { - allClasses.push(constraint.pinnedClass); - } - } - for (_j = 0, _len1 = allClasses.length; _j < _len1; _j++) { - cls = allClasses[_j]; - _ref4 = ['left', 'top', 'right', 'bottom']; - for (_k = 0, _len2 = _ref4.length; _k < _len2; _k++) { - side = _ref4[_k]; - allClasses.push("" + cls + "-" + side); - } - } - addClasses = []; - tAttachment = extend({}, targetAttachment); - eAttachment = extend({}, this.attachment); - _ref5 = this.options.constraints; - for (_l = 0, _len3 = _ref5.length; _l < _len3; _l++) { - constraint = _ref5[_l]; - to = constraint.to, attachment = constraint.attachment, pin = constraint.pin; - if (attachment == null) { - attachment = ''; - } - if (__indexOf.call(attachment, ' ') >= 0) { - _ref6 = attachment.split(' '), changeAttachY = _ref6[0], changeAttachX = _ref6[1]; - } else { - changeAttachX = changeAttachY = attachment; - } - bounds = getBoundingRect(this, to); - if (changeAttachY === 'target' || changeAttachY === 'both') { - if (top < bounds[1] && tAttachment.top === 'top') { - top += targetHeight; - tAttachment.top = 'bottom'; - } - if (top + height > bounds[3] && tAttachment.top === 'bottom') { - top -= targetHeight; - tAttachment.top = 'top'; - } - } - if (changeAttachY === 'together') { - if (top < bounds[1] && tAttachment.top === 'top') { - if (eAttachment.top === 'bottom') { - top += targetHeight; - tAttachment.top = 'bottom'; - top += height; - eAttachment.top = 'top'; - } else if (eAttachment.top === 'top') { - top += targetHeight; - tAttachment.top = 'bottom'; - top -= height; - eAttachment.top = 'bottom'; - } - } - if (top + height > bounds[3] && tAttachment.top === 'bottom') { - if (eAttachment.top === 'top') { - top -= targetHeight; - tAttachment.top = 'top'; - top -= height; - eAttachment.top = 'bottom'; - } else if (eAttachment.top === 'bottom') { - top -= targetHeight; - tAttachment.top = 'top'; - top += height; - eAttachment.top = 'top'; - } - } - if (tAttachment.top === 'middle') { - if (top + height > bounds[3] && eAttachment.top === 'top') { - top -= height; - eAttachment.top = 'bottom'; - } else if (top < bounds[1] && eAttachment.top === 'bottom') { - top += height; - eAttachment.top = 'top'; - } - } - } - if (changeAttachX === 'target' || changeAttachX === 'both') { - if (left < bounds[0] && tAttachment.left === 'left') { - left += targetWidth; - tAttachment.left = 'right'; - } - if (left + width > bounds[2] && tAttachment.left === 'right') { - left -= targetWidth; - tAttachment.left = 'left'; - } - } - if (changeAttachX === 'together') { - if (left < bounds[0] && tAttachment.left === 'left') { - if (eAttachment.left === 'right') { - left += targetWidth; - tAttachment.left = 'right'; - left += width; - eAttachment.left = 'left'; - } else if (eAttachment.left === 'left') { - left += targetWidth; - tAttachment.left = 'right'; - left -= width; - eAttachment.left = 'right'; - } - } else if (left + width > bounds[2] && tAttachment.left === 'right') { - if (eAttachment.left === 'left') { - left -= targetWidth; - tAttachment.left = 'left'; - left -= width; - eAttachment.left = 'right'; - } else if (eAttachment.left === 'right') { - left -= targetWidth; - tAttachment.left = 'left'; - left += width; - eAttachment.left = 'left'; - } - } else if (tAttachment.left === 'center') { - if (left + width > bounds[2] && eAttachment.left === 'left') { - left -= width; - eAttachment.left = 'right'; - } else if (left < bounds[0] && eAttachment.left === 'right') { - left += width; - eAttachment.left = 'left'; - } - } - } - if (changeAttachY === 'element' || changeAttachY === 'both') { - if (top < bounds[1] && eAttachment.top === 'bottom') { - top += height; - eAttachment.top = 'top'; - } - if (top + height > bounds[3] && eAttachment.top === 'top') { - top -= height; - eAttachment.top = 'bottom'; - } - } - if (changeAttachX === 'element' || changeAttachX === 'both') { - if (left < bounds[0] && eAttachment.left === 'right') { - left += width; - eAttachment.left = 'left'; - } - if (left + width > bounds[2] && eAttachment.left === 'left') { - left -= width; - eAttachment.left = 'right'; - } - } - if (typeof pin === 'string') { - pin = (function() { - var _len4, _m, _ref7, _results; - _ref7 = pin.split(','); - _results = []; - for (_m = 0, _len4 = _ref7.length; _m < _len4; _m++) { - p = _ref7[_m]; - _results.push(p.trim()); - } - return _results; - })(); - } else if (pin === true) { - pin = ['top', 'left', 'right', 'bottom']; - } - pin || (pin = []); - pinned = []; - oob = []; - if (top < bounds[1]) { - if (__indexOf.call(pin, 'top') >= 0) { - top = bounds[1]; - pinned.push('top'); - } else { - oob.push('top'); - } - } - if (top + height > bounds[3]) { - if (__indexOf.call(pin, 'bottom') >= 0) { - top = bounds[3] - height; - pinned.push('bottom'); - } else { - oob.push('bottom'); - } - } - if (left < bounds[0]) { - if (__indexOf.call(pin, 'left') >= 0) { - left = bounds[0]; - pinned.push('left'); - } else { - oob.push('left'); - } - } - if (left + width > bounds[2]) { - if (__indexOf.call(pin, 'right') >= 0) { - left = bounds[2] - width; - pinned.push('right'); - } else { - oob.push('right'); - } - } - if (pinned.length) { - pinnedClass = (_ref7 = this.options.pinnedClass) != null ? _ref7 : this.getClass('pinned'); - addClasses.push(pinnedClass); - for (_m = 0, _len4 = pinned.length; _m < _len4; _m++) { - side = pinned[_m]; - addClasses.push("" + pinnedClass + "-" + side); - } - } - if (oob.length) { - oobClass = (_ref8 = this.options.outOfBoundsClass) != null ? _ref8 : this.getClass('out-of-bounds'); - addClasses.push(oobClass); - for (_n = 0, _len5 = oob.length; _n < _len5; _n++) { - side = oob[_n]; - addClasses.push("" + oobClass + "-" + side); - } - } - if (__indexOf.call(pinned, 'left') >= 0 || __indexOf.call(pinned, 'right') >= 0) { - eAttachment.left = tAttachment.left = false; - } - if (__indexOf.call(pinned, 'top') >= 0 || __indexOf.call(pinned, 'bottom') >= 0) { - eAttachment.top = tAttachment.top = false; - } - if (tAttachment.top !== targetAttachment.top || tAttachment.left !== targetAttachment.left || eAttachment.top !== this.attachment.top || eAttachment.left !== this.attachment.left) { - this.updateAttachClasses(eAttachment, tAttachment); - } - } - defer(function() { - updateClasses(_this.target, addClasses, allClasses); - return updateClasses(_this.element, addClasses, allClasses); - }); - return { - top: top, - left: left - }; - } - }); - -}).call(this); - -(function() { - var defer, getBounds, updateClasses, _ref; - - _ref = this.Tether.Utils, getBounds = _ref.getBounds, updateClasses = _ref.updateClasses, defer = _ref.defer; - - this.Tether.modules.push({ - position: function(_arg) { - var abutted, addClasses, allClasses, bottom, height, left, right, side, sides, targetPos, top, width, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref1, _ref2, _ref3, _ref4, _ref5, - _this = this; - top = _arg.top, left = _arg.left; - _ref1 = this.cache('element-bounds', function() { - return getBounds(_this.element); - }), height = _ref1.height, width = _ref1.width; - targetPos = this.getTargetBounds(); - bottom = top + height; - right = left + width; - abutted = []; - if (top <= targetPos.bottom && bottom >= targetPos.top) { - _ref2 = ['left', 'right']; - for (_i = 0, _len = _ref2.length; _i < _len; _i++) { - side = _ref2[_i]; - if ((_ref3 = targetPos[side]) === left || _ref3 === right) { - abutted.push(side); - } - } - } - if (left <= targetPos.right && right >= targetPos.left) { - _ref4 = ['top', 'bottom']; - for (_j = 0, _len1 = _ref4.length; _j < _len1; _j++) { - side = _ref4[_j]; - if ((_ref5 = targetPos[side]) === top || _ref5 === bottom) { - abutted.push(side); - } - } - } - allClasses = []; - addClasses = []; - sides = ['left', 'top', 'right', 'bottom']; - allClasses.push(this.getClass('abutted')); - for (_k = 0, _len2 = sides.length; _k < _len2; _k++) { - side = sides[_k]; - allClasses.push("" + (this.getClass('abutted')) + "-" + side); - } - if (abutted.length) { - addClasses.push(this.getClass('abutted')); - } - for (_l = 0, _len3 = abutted.length; _l < _len3; _l++) { - side = abutted[_l]; - addClasses.push("" + (this.getClass('abutted')) + "-" + side); - } - defer(function() { - updateClasses(_this.target, addClasses, allClasses); - return updateClasses(_this.element, addClasses, allClasses); - }); - return true; - } - }); - -}).call(this); - -(function() { - this.Tether.modules.push({ - position: function(_arg) { - var left, result, shift, shiftLeft, shiftTop, top, _ref; - top = _arg.top, left = _arg.left; - if (!this.options.shift) { - return; - } - result = function(val) { - if (typeof val === 'function') { - return val.call(this, { - top: top, - left: left - }); - } else { - return val; - } - }; - shift = result(this.options.shift); - if (typeof shift === 'string') { - shift = shift.split(' '); - shift[1] || (shift[1] = shift[0]); - shiftTop = shift[0], shiftLeft = shift[1]; - shiftTop = parseFloat(shiftTop, 10); - shiftLeft = parseFloat(shiftLeft, 10); - } else { - _ref = [shift.top, shift.left], shiftTop = _ref[0], shiftLeft = _ref[1]; - } - top += shiftTop; - left += shiftLeft; - return { - top: top, - left: left - }; - } - }); - -}).call(this); - -return this.Tether; - -})); - -(function() { - var Evented, MIRROR_ATTACH, addClass, allDrops, clickEvents, createContext, extend, hasClass, removeClass, removeFromArray, sortAttach, touchDevice, _ref, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; - - _ref = Tether.Utils, extend = _ref.extend, addClass = _ref.addClass, removeClass = _ref.removeClass, hasClass = _ref.hasClass, Evented = _ref.Evented; - - touchDevice = 'ontouchstart' in document.documentElement; - - clickEvents = ['click']; - - if (touchDevice) { - clickEvents.push('touchstart'); - } - - sortAttach = function(str) { - var first, second, _ref1, _ref2; - _ref1 = str.split(' '), first = _ref1[0], second = _ref1[1]; - if (first === 'left' || first === 'right') { - _ref2 = [second, first], first = _ref2[0], second = _ref2[1]; - } - return [first, second].join(' '); - }; - - MIRROR_ATTACH = { - left: 'right', - right: 'left', - top: 'bottom', - bottom: 'top', - middle: 'middle', - center: 'center' - }; - - allDrops = {}; - - removeFromArray = function(arr, item) { - var index, _results; - _results = []; - while ((index = arr.indexOf(item)) !== -1) { - _results.push(arr.splice(index, 1)); - } - return _results; - }; - - createContext = function(options) { - var DropInstance, defaultOptions, drop, _name; - if (options == null) { - options = {}; - } - drop = function() { - return (function(func, args, ctor) { - ctor.prototype = func.prototype; - var child = new ctor, result = func.apply(child, args); - return Object(result) === result ? result : child; - })(DropInstance, arguments, function(){}); - }; - extend(drop, { - createContext: createContext, - drops: [], - defaults: {} - }); - defaultOptions = { - classPrefix: 'drop', - defaults: { - position: 'bottom left', - openOn: 'click', - constrainToScrollParent: true, - constrainToWindow: true, - classes: '', - remove: false, - tetherOptions: {} - } - }; - extend(drop, defaultOptions, options); - extend(drop.defaults, defaultOptions.defaults, options.defaults); - if (allDrops[_name = drop.classPrefix] == null) { - allDrops[_name] = []; - } - drop.updateBodyClasses = function() { - var anyOpen, _drop, _i, _len, _ref1; - anyOpen = false; - _ref1 = allDrops[drop.classPrefix]; - for (_i = 0, _len = _ref1.length; _i < _len; _i++) { - _drop = _ref1[_i]; - if (!(_drop.isOpened())) { - continue; - } - anyOpen = true; - break; - } - if (anyOpen) { - return addClass(document.body, "" + drop.classPrefix + "-open"); - } else { - return removeClass(document.body, "" + drop.classPrefix + "-open"); - } - }; - DropInstance = (function(_super) { - __extends(DropInstance, _super); - - function DropInstance(options) { - this.options = options; - this.options = extend({}, drop.defaults, this.options); - this.target = this.options.target; - if (this.target == null) { - throw new Error('Drop Error: You must provide a target.'); - } - if (this.options.classes) { - addClass(this.target, this.options.classes); - } - drop.drops.push(this); - allDrops[drop.classPrefix].push(this); - this._boundEvents = []; - this.setupElements(); - this.setupEvents(); - this.setupTether(); - } - - DropInstance.prototype._on = function(element, event, handler) { - this._boundEvents.push({ - element: element, - event: event, - handler: handler - }); - return element.addEventListener(event, handler); - }; - - DropInstance.prototype.setupElements = function() { - this.drop = document.createElement('div'); - addClass(this.drop, drop.classPrefix); - if (this.options.classes) { - addClass(this.drop, this.options.classes); - } - this.content = document.createElement('div'); - addClass(this.content, "" + drop.classPrefix + "-content"); - if (typeof this.options.content === 'object') { - this.content.appendChild(this.options.content); - } else { - this.content.innerHTML = this.options.content; - } - return this.drop.appendChild(this.content); - }; - - DropInstance.prototype.setupTether = function() { - var constraints, dropAttach; - dropAttach = this.options.position.split(' '); - dropAttach[0] = MIRROR_ATTACH[dropAttach[0]]; - dropAttach = dropAttach.join(' '); - constraints = []; - if (this.options.constrainToScrollParent) { - constraints.push({ - to: 'scrollParent', - pin: 'top, bottom', - attachment: 'together none' - }); - } else { - constraints.push({ - to: 'scrollParent' - }); - } - if (this.options.constrainToWindow !== false) { - constraints.push({ - to: 'window', - attachment: 'together' - }); - } else { - constraints.push({ - to: 'window' - }); - } - options = { - element: this.drop, - target: this.target, - attachment: sortAttach(dropAttach), - targetAttachment: sortAttach(this.options.position), - classPrefix: drop.classPrefix, - offset: '0 0', - targetOffset: '0 0', - enabled: false, - constraints: constraints - }; - if (this.options.tetherOptions !== false) { - return this.tether = new Tether(extend({}, options, this.options.tetherOptions)); - } - }; - - DropInstance.prototype.setupEvents = function() { - var clickEvent, closeHandler, events, onUs, openHandler, out, outTimeout, over, _i, _len, - _this = this; - if (!this.options.openOn) { - return; - } - if (this.options.openOn === 'always') { - setTimeout(this.open.bind(this)); - return; - } - events = this.options.openOn.split(' '); - if (__indexOf.call(events, 'click') >= 0) { - openHandler = function(event) { - _this.toggle(); - return event.preventDefault(); - }; - closeHandler = function(event) { - if (!_this.isOpened()) { - return; - } - if (event.target === _this.drop || _this.drop.contains(event.target)) { - return; - } - if (event.target === _this.target || _this.target.contains(event.target)) { - return; - } - return _this.close(); - }; - for (_i = 0, _len = clickEvents.length; _i < _len; _i++) { - clickEvent = clickEvents[_i]; - this._on(this.target, clickEvent, openHandler); - this._on(document, clickEvent, closeHandler); - } - } - if (__indexOf.call(events, 'hover') >= 0) { - onUs = false; - over = function() { - onUs = true; - return _this.open(); - }; - outTimeout = null; - out = function() { - onUs = false; - if (outTimeout != null) { - clearTimeout(outTimeout); - } - return outTimeout = setTimeout(function() { - if (!onUs) { - _this.close(); - } - return outTimeout = null; - }, 50); - }; - this._on(this.target, 'mouseover', over); - this._on(this.drop, 'mouseover', over); - this._on(this.target, 'mouseout', out); - return this._on(this.drop, 'mouseout', out); - } - }; - - DropInstance.prototype.isOpened = function() { - return hasClass(this.drop, "" + drop.classPrefix + "-open"); - }; - - DropInstance.prototype.toggle = function() { - if (this.isOpened()) { - return this.close(); - } else { - return this.open(); - } - }; - - DropInstance.prototype.open = function() { - var _ref1, _ref2, - _this = this; - if (this.isOpened()) { - return; - } - if (!this.drop.parentNode) { - document.body.appendChild(this.drop); - } - if ((_ref1 = this.tether) != null) { - _ref1.enable(); - } - addClass(this.drop, "" + drop.classPrefix + "-open"); - addClass(this.drop, "" + drop.classPrefix + "-open-transitionend"); - setTimeout(function() { - return addClass(_this.drop, "" + drop.classPrefix + "-after-open"); - }); - if ((_ref2 = this.tether) != null) { - _ref2.position(); - } - this.trigger('open'); - return drop.updateBodyClasses(); - }; - - DropInstance.prototype.close = function() { - var handler, _ref1, - _this = this; - if (!this.isOpened()) { - return; - } - removeClass(this.drop, "" + drop.classPrefix + "-open"); - removeClass(this.drop, "" + drop.classPrefix + "-after-open"); - this.drop.addEventListener('transitionend', handler = function() { - if (!hasClass(_this.drop, "" + drop.classPrefix + "-open")) { - removeClass(_this.drop, "" + drop.classPrefix + "-open-transitionend"); - } - return _this.drop.removeEventListener('transitionend', handler); - }); - this.trigger('close'); - if ((_ref1 = this.tether) != null) { - _ref1.disable(); - } - drop.updateBodyClasses(); - if (this.options.remove) { - return this.remove(); - } - }; - - DropInstance.prototype.remove = function() { - var _ref1; - this.close(); - return (_ref1 = this.drop.parentNode) != null ? _ref1.removeChild(this.drop) : void 0; - }; - - DropInstance.prototype.position = function() { - var _ref1; - if (this.isOpened()) { - return (_ref1 = this.tether) != null ? _ref1.position() : void 0; - } - }; - - DropInstance.prototype.destroy = function() { - var element, event, handler, _i, _len, _ref1, _ref2, _ref3; - this.remove(); - if ((_ref1 = this.tether) != null) { - _ref1.destroy(); - } - _ref2 = this._boundEvents; - for (_i = 0, _len = _ref2.length; _i < _len; _i++) { - _ref3 = _ref2[_i], element = _ref3.element, event = _ref3.event, handler = _ref3.handler; - element.removeEventListener(event, handler); - } - this._boundEvents = []; - this.tether = null; - this.drop = null; - this.content = null; - this.target = null; - removeFromArray(allDrops[drop.classPrefix], this); - return removeFromArray(drop.drops, this); - }; - - return DropInstance; - - })(Evented); - return drop; - }; - - window.Drop = createContext(); - - document.addEventListener('DOMContentLoaded', function() { - return Drop.updateBodyClasses(); - }); - -}).call(this); - -(function() { - var Tooltip, addClass, defaults, extend, initialized, removeClass, _Drop, _ref, - __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; - - _ref = Tether.Utils, addClass = _ref.addClass, removeClass = _ref.removeClass, extend = _ref.extend; - - _Drop = Drop.createContext({ - classPrefix: 'tooltip' - }); - - defaults = { - position: 'top center', - openOn: 'hover', - classes: 'tooltip-theme-arrows', - constrainToWindow: true, - constrainToScrollParent: false - }; - - Tooltip = (function() { - function Tooltip(options) { - var content, position, _base, _base1; - this.options = options; - if (!this.options.target) { - throw new Error("Tooltip Error: You must provide a target for Tooltip to attach to"); - } - if (position = this.options.target.getAttribute('data-tooltip-position')) { - if ((_base = this.options).position == null) { - _base.position = position; - } - } - if (content = this.options.target.getAttribute('data-tooltip')) { - if ((_base1 = this.options).content == null) { - _base1.content = content; - } - } - if (!this.options.content) { - throw new Error("Tooltip Error: You must provide content for Tooltip to display"); - } - this.options = extend({}, defaults, this.options); - this.drop = new _Drop(this.options); - } - - Tooltip.prototype.close = function() { - return this.drop.close(); - }; - - Tooltip.prototype.open = function() { - return this.drop.open(); - }; - - Tooltip.prototype.toggle = function() { - return this.drop.toggle(); - }; - - Tooltip.prototype.remove = function() { - return this.drop.remove(); - }; - - Tooltip.prototype.destroy = function() { - return this.drop.destroy(); - }; - - Tooltip.prototype.position = function() { - return this.drop.position(); - }; - - return Tooltip; - - })(); - - initialized = []; - - Tooltip.init = function() { - var el, _i, _len, _ref1, _results; - _ref1 = document.querySelectorAll('[data-tooltip]'); - _results = []; - for (_i = 0, _len = _ref1.length; _i < _len; _i++) { - el = _ref1[_i]; - if (!(__indexOf.call(initialized, el) < 0)) { - continue; - } - new Tooltip({ - target: el - }); - _results.push(initialized.push(el)); - } - return _results; - }; - - document.addEventListener('DOMContentLoaded', function() { - if (Tooltip.autoinit !== false) { - return Tooltip.init(); - } - }); - - window.Tooltip = Tooltip; - -}).call(this); diff --git a/tooltip.min.js b/tooltip.min.js deleted file mode 100644 index 425aae3..0000000 --- a/tooltip.min.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! tether-tooltip 0.2.6 */ -!function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e(require,exports,module):t.Tether=e()}(this,function(){return function(){var t,e,o,i,n,s,r,l,h,a,p,u,f,d,c,g,m,v={}.hasOwnProperty,b=[].indexOf||function(t){for(var e=0,o=this.length;o>e;e++)if(e in this&&this[e]===t)return e;return-1},y=[].slice;null==this.Tether&&(this.Tether={modules:[]}),p=function(t){var e,o,i,n,s;if(o=getComputedStyle(t).position,"fixed"===o)return t;for(i=void 0,e=t;e=e.parentNode;){try{n=getComputedStyle(e)}catch(r){}if(null==n)return e;if(/(auto|scroll)/.test(n.overflow+n["overflow-y"]+n["overflow-x"])&&("absolute"!==o||"relative"===(s=n.position)||"absolute"===s||"fixed"===s))return e}return document.body},c=function(){var t;return t=0,function(){return t++}}(),m={},h=function(t){var e,i,s,r,l;if(s=t._tetherZeroElement,null==s&&(s=t.createElement("div"),s.setAttribute("data-tether-id",c()),n(s.style,{top:0,left:0,position:"absolute"}),t.body.appendChild(s),t._tetherZeroElement=s),e=s.getAttribute("data-tether-id"),null==m[e]){m[e]={},l=s.getBoundingClientRect();for(i in l)r=l[i],m[e][i]=r;o(function(){return m[e]=void 0})}return m[e]},f=null,r=function(t){var e,o,i,n,s,r,l;t===document?(o=document,t=document.documentElement):o=t.ownerDocument,i=o.documentElement,e={},l=t.getBoundingClientRect();for(n in l)r=l[n],e[n]=r;return s=h(o),e.top-=s.top,e.left-=s.left,null==e.width&&(e.width=document.body.scrollWidth-e.left-e.right),null==e.height&&(e.height=document.body.scrollHeight-e.top-e.bottom),e.top=e.top-i.clientTop,e.left=e.left-i.clientLeft,e.right=o.body.clientWidth-e.width-e.left,e.bottom=o.body.clientHeight-e.height-e.top,e},l=function(t){return t.offsetParent||document.documentElement},a=function(){var t,e,o,i,s;return t=document.createElement("div"),t.style.width="100%",t.style.height="200px",e=document.createElement("div"),n(e.style,{position:"absolute",top:0,left:0,pointerEvents:"none",visibility:"hidden",width:"200px",height:"150px",overflow:"hidden"}),e.appendChild(t),document.body.appendChild(e),i=t.offsetWidth,e.style.overflow="scroll",s=t.offsetWidth,i===s&&(s=e.clientWidth),document.body.removeChild(e),o=i-s,{width:o,height:o}},n=function(t){var e,o,i,n,s,r,l;for(null==t&&(t={}),e=[],Array.prototype.push.apply(e,arguments),l=e.slice(1),s=0,r=l.length;r>s;s++)if(i=l[s])for(o in i)v.call(i,o)&&(n=i[o],t[o]=n);return t},d=function(t,e){var o,i,n,s,r;if(null!=t.classList){for(s=e.split(" "),r=[],i=0,n=s.length;n>i;i++)o=s[i],o.trim()&&r.push(t.classList.remove(o));return r}return t.className=t.className.replace(new RegExp("(^| )"+e.split(" ").join("|")+"( |$)","gi")," ")},e=function(t,e){var o,i,n,s,r;if(null!=t.classList){for(s=e.split(" "),r=[],i=0,n=s.length;n>i;i++)o=s[i],o.trim()&&r.push(t.classList.add(o));return r}return d(t,e),t.className+=" "+e},u=function(t,e){return null!=t.classList?t.classList.contains(e):new RegExp("(^| )"+e+"( |$)","gi").test(t.className)},g=function(t,o,i){var n,s,r,l,h,a;for(s=0,l=i.length;l>s;s++)n=i[s],b.call(o,n)<0&&u(t,n)&&d(t,n);for(a=[],r=0,h=o.length;h>r;r++)n=o[r],a.push(u(t,n)?void 0:e(t,n));return a},i=[],o=function(t){return i.push(t)},s=function(){var t,e;for(e=[];t=i.pop();)e.push(t());return e},t=function(){function t(){}return t.prototype.on=function(t,e,o,i){var n;return null==i&&(i=!1),null==this.bindings&&(this.bindings={}),null==(n=this.bindings)[t]&&(n[t]=[]),this.bindings[t].push({handler:e,ctx:o,once:i})},t.prototype.once=function(t,e,o){return this.on(t,e,o,!0)},t.prototype.off=function(t,e){var o,i,n;if(null!=(null!=(i=this.bindings)?i[t]:void 0)){if(null==e)return delete this.bindings[t];for(o=0,n=[];o=e&&e>=t-o},T=function(){var t,e,o,i,n;for(t=document.createElement("div"),n=["transform","webkitTransform","OTransform","MozTransform","msTransform"],o=0,i=n.length;i>o;o++)if(e=n[o],void 0!==t.style[e])return e}(),x=[],C=function(){var t,e,o;for(e=0,o=x.length;o>e;e++)t=x[e],t.position(!1);return p()},v=function(){var t;return null!=(t="undefined"!=typeof performance&&null!==performance&&"function"==typeof performance.now?performance.now():void 0)?t:+new Date},function(){var t,e,o,i,n,s,r,l,h;for(e=null,o=null,i=null,n=function(){if(null!=o&&o>16)return o=Math.min(o-16,250),void(i=setTimeout(n,250));if(!(null!=e&&v()-e<10))return null!=i&&(clearTimeout(i),i=null),e=v(),C(),o=v()-e},l=["resize","scroll","touchmove"],h=[],s=0,r=l.length;r>s;s++)t=l[s],h.push(window.addEventListener(t,n));return h}(),t={center:"center",left:"right",right:"left"},e={middle:"middle",top:"bottom",bottom:"top"},o={top:0,left:0,middle:"50%",center:"50%",bottom:"100%",right:"100%"},l=function(o,i){var n,s;return n=o.left,s=o.top,"auto"===n&&(n=t[i.left]),"auto"===s&&(s=e[i.top]),{left:n,top:s}},r=function(t){var e,i;return{left:null!=(e=o[t.left])?e:t.left,top:null!=(i=o[t.top])?i:t.top}},s=function(){var t,e,o,i,n,s,r;for(e=1<=arguments.length?S.call(arguments,0):[],o={top:0,left:0},n=0,s=e.length;s>n;n++)r=e[n],i=r.top,t=r.left,"string"==typeof i&&(i=parseFloat(i,10)),"string"==typeof t&&(t=parseFloat(t,10)),o.top+=i,o.left+=t;return o},b=function(t,e){return"string"==typeof t.left&&-1!==t.left.indexOf("%")&&(t.left=parseFloat(t.left,10)/100*e.width),"string"==typeof t.top&&-1!==t.top.indexOf("%")&&(t.top=parseFloat(t.top,10)/100*e.height),t},y=w=function(t){var e,o,i;return i=t.split(" "),o=i[0],e=i[1],{top:o,left:e}},_=function(){function t(t){this.position=W(this.position,this);var e,o,n,s,r;for(x.push(this),this.history=[],this.setOptions(t,!1),s=i.modules,o=0,n=s.length;n>o;o++)e=s[o],null!=(r=e.initialize)&&r.call(this);this.position()}return t.modules=[],t.prototype.getClass=function(t){var e,o;return(null!=(e=this.options.classes)?e[t]:void 0)?this.options.classes[t]:(null!=(o=this.options.classes)?o[t]:void 0)!==!1?this.options.classPrefix?""+this.options.classPrefix+"-"+t:t:""},t.prototype.setOptions=function(t,e){var o,i,s,r,l,h;for(this.options=t,null==e&&(e=!0),o={offset:"0 0",targetOffset:"0 0",targetAttachment:"auto auto",classPrefix:"tether"},this.options=a(o,this.options),l=this.options,this.element=l.element,this.target=l.target,this.targetModifier=l.targetModifier,"viewport"===this.target?(this.target=document.body,this.targetModifier="visible"):"scroll-handle"===this.target&&(this.target=document.body,this.targetModifier="scroll-handle"),h=["element","target"],s=0,r=h.length;r>s;s++){if(i=h[s],null==this[i])throw new Error("Tether Error: Both element and target must be defined");null!=this[i].jquery?this[i]=this[i][0]:"string"==typeof this[i]&&(this[i]=document.querySelector(this[i]))}if(n(this.element,this.getClass("element")),n(this.target,this.getClass("target")),!this.options.attachment)throw new Error("Tether Error: You must provide an attachment");return this.targetAttachment=y(this.options.targetAttachment),this.attachment=y(this.options.attachment),this.offset=w(this.options.offset),this.targetOffset=w(this.options.targetOffset),null!=this.scrollParent&&this.disable(),this.scrollParent="scroll-handle"===this.targetModifier?this.target:g(this.target),this.options.enabled!==!1?this.enable(e):void 0},t.prototype.getTargetBounds=function(){var t,e,o,i,n,s,r,l,h;if(null==this.targetModifier)return u(this.target);switch(this.targetModifier){case"visible":return this.target===document.body?{top:pageYOffset,left:pageXOffset,height:innerHeight,width:innerWidth}:(t=u(this.target),n={height:t.height,width:t.width,top:t.top,left:t.left},n.height=Math.min(n.height,t.height-(pageYOffset-t.top)),n.height=Math.min(n.height,t.height-(t.top+t.height-(pageYOffset+innerHeight))),n.height=Math.min(innerHeight,n.height),n.height-=2,n.width=Math.min(n.width,t.width-(pageXOffset-t.left)),n.width=Math.min(n.width,t.width-(t.left+t.width-(pageXOffset+innerWidth))),n.width=Math.min(innerWidth,n.width),n.width-=2,n.toph.clientWidth||"scroll"===[l.overflow,l.overflowX]||this.target!==document.body,s=0,o&&(s=15),i=t.height-parseFloat(l.borderTopWidth)-parseFloat(l.borderBottomWidth)-s,n={width:15,height:.975*i*(i/h.scrollHeight),left:t.left+t.width-parseFloat(l.borderLeftWidth)-15},e=0,408>i&&this.target===document.body&&(e=-11e-5*Math.pow(i,2)-.00727*i+22.58),this.target!==document.body&&(n.height=Math.max(n.height,24)),r=this.target.scrollTop/(h.scrollHeight-i),n.top=r*(i-n.height-e)+t.top+parseFloat(l.borderTopWidth),this.target===document.body&&(n.height=Math.max(n.height,24)),n}},t.prototype.clearCache=function(){return this._cache={}},t.prototype.cache=function(t,e){return null==this._cache&&(this._cache={}),null==this._cache[t]&&(this._cache[t]=e.call(this)),this._cache[t]},t.prototype.enable=function(t){return null==t&&(t=!0),n(this.target,this.getClass("enabled")),n(this.element,this.getClass("enabled")),this.enabled=!0,this.scrollParent!==document&&this.scrollParent.addEventListener("scroll",this.position),t?this.position():void 0},t.prototype.disable=function(){return O(this.target,this.getClass("enabled")),O(this.element,this.getClass("enabled")),this.enabled=!1,null!=this.scrollParent?this.scrollParent.removeEventListener("scroll",this.position):void 0},t.prototype.destroy=function(){var t,e,o,i,n;for(this.disable(),n=[],t=o=0,i=x.length;i>o;t=++o){if(e=x[t],e===this){x.splice(t,1);break}n.push(void 0)}return n},t.prototype.updateAttachClasses=function(t,e){var o,i,n,s,r,l,a,p,u,f=this;for(null==t&&(t=this.attachment),null==e&&(e=this.targetAttachment),s=["left","top","bottom","right","middle","center"],(null!=(u=this._addAttachClasses)?u.length:void 0)&&this._addAttachClasses.splice(0,this._addAttachClasses.length),o=null!=this._addAttachClasses?this._addAttachClasses:this._addAttachClasses=[],t.top&&o.push(""+this.getClass("element-attached")+"-"+t.top),t.left&&o.push(""+this.getClass("element-attached")+"-"+t.left),e.top&&o.push(""+this.getClass("target-attached")+"-"+e.top),e.left&&o.push(""+this.getClass("target-attached")+"-"+e.left),i=[],r=0,a=s.length;a>r;r++)n=s[r],i.push(""+this.getClass("element-attached")+"-"+n);for(l=0,p=s.length;p>l;l++)n=s[l],i.push(""+this.getClass("target-attached")+"-"+n);return h(function(){return null!=f._addAttachClasses?(E(f.element,f._addAttachClasses,i),E(f.target,f._addAttachClasses,i),f._addAttachClasses=void 0):void 0})},t.prototype.position=function(t){var e,o,n,h,a,d,g,m,v,y,w,C,O,x,T,E,P,_,A,S,W,L,M,B,z,Y,F,H,N,X,j,D,k,U,q,R=this;if(null==t&&(t=!0),this.enabled){for(this.clearCache(),S=l(this.targetAttachment,this.attachment),this.updateAttachClasses(this.attachment,S),e=this.cache("element-bounds",function(){return u(R.element)}),z=e.width,n=e.height,0===z&&0===n&&null!=this.lastSize?(X=this.lastSize,z=X.width,n=X.height):this.lastSize={width:z,height:n},M=L=this.cache("target-bounds",function(){return R.getTargetBounds()}),v=b(r(this.attachment),{width:z,height:n}),W=b(r(S),M),a=b(this.offset,{width:z,height:n}),d=b(this.targetOffset,M),v=s(v,a),W=s(W,d),h=L.left+W.left-v.left,B=L.top+W.top-v.top,j=i.modules,Y=0,H=j.length;H>Y;Y++)if(g=j[Y],T=g.position.call(this,{left:h,top:B,targetAttachment:S,targetPos:L,attachment:this.attachment,elementPos:e,offset:v,targetOffset:W,manualOffset:a,manualTargetOffset:d,scrollbarSize:_}),null!=T&&"object"==typeof T){if(T===!1)return!1;B=T.top,h=T.left}if(m={page:{top:B,left:h},viewport:{top:B-pageYOffset,bottom:pageYOffset-B-n+innerHeight,left:h-pageXOffset,right:pageXOffset-h-z+innerWidth}},document.body.scrollWidth>window.innerWidth&&(_=this.cache("scrollbar-size",c),m.viewport.bottom-=_.height),document.body.scrollHeight>window.innerHeight&&(_=this.cache("scrollbar-size",c),m.viewport.right-=_.width),(""!==(D=document.body.style.position)&&"static"!==D||""!==(k=document.body.parentElement.style.position)&&"static"!==k)&&(m.page.bottom=document.body.scrollHeight-B-n,m.page.right=document.body.scrollWidth-h-z),(null!=(U=this.options.optimizations)?U.moveElement:void 0)!==!1&&null==this.targetModifier){for(w=this.cache("target-offsetparent",function(){return f(R.target)}),x=this.cache("target-offsetparent-bounds",function(){return u(w)}),O=getComputedStyle(w),o=getComputedStyle(this.element),C=x,y={},q=["Top","Left","Bottom","Right"],F=0,N=q.length;N>F;F++)A=q[F],y[A.toLowerCase()]=parseFloat(O["border"+A+"Width"]);x.right=document.body.scrollWidth-x.left-C.width+y.right,x.bottom=document.body.scrollHeight-x.top-C.height+y.bottom,m.page.top>=x.top+y.top&&m.page.bottom>=x.bottom&&m.page.left>=x.left+y.left&&m.page.right>=x.right&&(P=w.scrollTop,E=w.scrollLeft,m.offset={top:m.page.top-x.top+P-y.top,left:m.page.left-x.left+E-y.left})}return this.move(m),this.history.unshift(m),this.history.length>3&&this.history.pop(),t&&p(),!0}},t.prototype.move=function(t){var e,o,i,n,s,r,l,p,u,d,c,g,m,v,b,y,w,C=this;if(null!=this.element.parentNode){p={};for(d in t){p[d]={};for(n in t[d]){for(i=!1,y=this.history,v=0,b=y.length;b>v;v++)if(l=y[v],!P(null!=(w=l[d])?w[n]:void 0,t[d][n])){i=!0;break}i||(p[d][n]=!0)}}e={top:"",left:"",right:"",bottom:""},u=function(t,o){var i,n,s;return(null!=(s=C.options.optimizations)?s.gpu:void 0)===!1?(t.top?e.top=""+o.top+"px":e.bottom=""+o.bottom+"px",t.left?e.left=""+o.left+"px":e.right=""+o.right+"px"):(t.top?(e.top=0,n=o.top):(e.bottom=0,n=-o.bottom),t.left?(e.left=0,i=o.left):(e.right=0,i=-o.right),e[T]="translateX("+Math.round(i)+"px) translateY("+Math.round(n)+"px)","msTransform"!==T?e[T]+=" translateZ(0)":void 0)},s=!1,(p.page.top||p.page.bottom)&&(p.page.left||p.page.right)?(e.position="absolute",u(p.page,t.page)):(p.viewport.top||p.viewport.bottom)&&(p.viewport.left||p.viewport.right)?(e.position="fixed",u(p.viewport,t.viewport)):null!=p.offset&&p.offset.top&&p.offset.left?(e.position="absolute",r=this.cache("target-offsetparent",function(){return f(C.target)}),f(this.element)!==r&&h(function(){return C.element.parentNode.removeChild(C.element),r.appendChild(C.element)}),u(p.offset,t.offset),s=!0):(e.position="absolute",u({top:!0,left:!0},t.page)),s||"BODY"===this.element.parentNode.tagName||(this.element.parentNode.removeChild(this.element),document.body.appendChild(this.element)),m={},g=!1;for(n in e)c=e[n],o=this.element.style[n],""===o||""===c||"top"!==n&&"left"!==n&&"bottom"!==n&&"right"!==n||(o=parseFloat(o),c=parseFloat(c)),o!==c&&(g=!0,m[n]=e[n]);return g?h(function(){return a(C.element.style,m)}):void 0}},t}(),i.position=C,this.Tether=a(_,i)}.call(this),function(){var t,e,o,i,n,s,r,l,h,a,p=[].indexOf||function(t){for(var e=0,o=this.length;o>e;e++)if(e in this&&this[e]===t)return e;return-1};a=this.Tether.Utils,r=a.getOuterSize,s=a.getBounds,l=a.getSize,i=a.extend,h=a.updateClasses,o=a.defer,e={left:"right",right:"left",top:"bottom",bottom:"top",middle:"middle"},t=["left","top","right","bottom"],n=function(e,o){var i,n,r,l,h,a,p;if("scrollParent"===o?o=e.scrollParent:"window"===o&&(o=[pageXOffset,pageYOffset,innerWidth+pageXOffset,innerHeight+pageYOffset]),o===document&&(o=o.documentElement),null!=o.nodeType)for(n=l=s(o),h=getComputedStyle(o),o=[n.left,n.top,l.width+n.left,l.height+n.top],i=a=0,p=t.length;p>a;i=++a)r=t[i],r=r[0].toUpperCase()+r.substr(1),"Top"===r||"Left"===r?o[i]+=parseFloat(h["border"+r+"Width"]):o[i]-=parseFloat(h["border"+r+"Width"]);return o},this.Tether.modules.push({position:function(e){var r,l,a,u,f,d,c,g,m,v,b,y,w,C,O,x,T,E,P,_,A,S,W,L,M,B,z,Y,F,H,N,X,j,D,k,U,q,R,Z,$,I,G,J,K,Q,V,te,ee=this;if(B=e.top,b=e.left,A=e.targetAttachment,!this.options.constraints)return!0;for(E=function(e){var o,i,n,s;for(ee.removeClass(e),s=[],i=0,n=t.length;n>i;i++)o=t[i],s.push(ee.removeClass(""+e+"-"+o));return s},$=this.cache("element-bounds",function(){return s(ee.element)}),v=$.height,z=$.width,0===z&&0===v&&null!=this.lastSize&&(I=this.lastSize,z=I.width,v=I.height),W=this.cache("target-bounds",function(){return ee.getTargetBounds()}),S=W.height,L=W.width,_={},m={},l=[this.getClass("pinned"),this.getClass("out-of-bounds")],G=this.options.constraints,Y=0,X=G.length;X>Y;Y++)g=G[Y],g.outOfBoundsClass&&l.push(g.outOfBoundsClass),g.pinnedClass&&l.push(g.pinnedClass);for(F=0,j=l.length;j>F;F++)for(c=l[F],J=["left","top","right","bottom"],H=0,D=J.length;D>H;H++)P=J[H],l.push(""+c+"-"+P);for(r=[],_=i({},A),m=i({},this.attachment),K=this.options.constraints,N=0,k=K.length;k>N;N++){if(g=K[N],M=g.to,a=g.attachment,O=g.pin,null==a&&(a=""),p.call(a," ")>=0?(Q=a.split(" "),d=Q[0],f=Q[1]):f=d=a,u=n(this,M),("target"===d||"both"===d)&&(Bu[3]&&"bottom"===_.top&&(B-=S,_.top="top")),"together"===d&&(Bu[3]&&"bottom"===_.top&&("top"===m.top?(B-=S,_.top="top",B-=v,m.top="bottom"):"bottom"===m.top&&(B-=S,_.top="top",B+=v,m.top="top")),"middle"===_.top&&(B+v>u[3]&&"top"===m.top?(B-=v,m.top="bottom"):Bu[2]&&"right"===_.left&&(b-=L,_.left="left")),"together"===f&&(bu[2]&&"right"===_.left?"left"===m.left?(b-=L,_.left="left",b-=z,m.left="right"):"right"===m.left&&(b-=L,_.left="left",b+=z,m.left="left"):"center"===_.left&&(b+z>u[2]&&"left"===m.left?(b-=z,m.left="right"):bu[3]&&"top"===m.top&&(B-=v,m.top="bottom")),("element"===f||"both"===f)&&(bu[2]&&"left"===m.left&&(b-=z,m.left="right")),"string"==typeof O?O=function(){var t,e,o,i;for(o=O.split(","),i=[],e=0,t=o.length;t>e;e++)C=o[e],i.push(C.trim());return i}():O===!0&&(O=["top","left","right","bottom"]),O||(O=[]),x=[],y=[],B=0?(B=u[1],x.push("top")):y.push("top")),B+v>u[3]&&(p.call(O,"bottom")>=0?(B=u[3]-v,x.push("bottom")):y.push("bottom")),b=0?(b=u[0],x.push("left")):y.push("left")),b+z>u[2]&&(p.call(O,"right")>=0?(b=u[2]-z,x.push("right")):y.push("right")),x.length)for(T=null!=(V=this.options.pinnedClass)?V:this.getClass("pinned"),r.push(T),R=0,U=x.length;U>R;R++)P=x[R],r.push(""+T+"-"+P);if(y.length)for(w=null!=(te=this.options.outOfBoundsClass)?te:this.getClass("out-of-bounds"),r.push(w),Z=0,q=y.length;q>Z;Z++)P=y[Z],r.push(""+w+"-"+P);(p.call(x,"left")>=0||p.call(x,"right")>=0)&&(m.left=_.left=!1),(p.call(x,"top")>=0||p.call(x,"bottom")>=0)&&(m.top=_.top=!1),(_.top!==A.top||_.left!==A.left||m.top!==this.attachment.top||m.left!==this.attachment.left)&&this.updateAttachClasses(m,_)}return o(function(){return h(ee.target,r,l),h(ee.element,r,l)}),{top:B,left:b}}})}.call(this),function(){var t,e,o,i;i=this.Tether.Utils,e=i.getBounds,o=i.updateClasses,t=i.defer,this.Tether.modules.push({position:function(i){var n,s,r,l,h,a,p,u,f,d,c,g,m,v,b,y,w,C,O,x,T,E,P,_,A,S=this;if(c=i.top,a=i.left,T=this.cache("element-bounds",function(){return e(S.element)}),h=T.height,g=T.width,d=this.getTargetBounds(),l=c+h,p=a+g,n=[],c<=d.bottom&&l>=d.top)for(E=["left","right"],m=0,w=E.length;w>m;m++)u=E[m],((P=d[u])===a||P===p)&&n.push(u);if(a<=d.right&&p>=d.left)for(_=["top","bottom"],v=0,C=_.length;C>v;v++)u=_[v],((A=d[u])===c||A===l)&&n.push(u);for(r=[],s=[],f=["left","top","right","bottom"],r.push(this.getClass("abutted")),b=0,O=f.length;O>b;b++)u=f[b],r.push(""+this.getClass("abutted")+"-"+u);for(n.length&&s.push(this.getClass("abutted")),y=0,x=n.length;x>y;y++)u=n[y],s.push(""+this.getClass("abutted")+"-"+u);return t(function(){return o(S.target,s,r),o(S.element,s,r)}),!0}})}.call(this),function(){this.Tether.modules.push({position:function(t){var e,o,i,n,s,r,l;return r=t.top,e=t.left,this.options.shift?(o=function(t){return"function"==typeof t?t.call(this,{top:r,left:e}):t},i=o(this.options.shift),"string"==typeof i?(i=i.split(" "),i[1]||(i[1]=i[0]),s=i[0],n=i[1],s=parseFloat(s,10),n=parseFloat(n,10)):(l=[i.top,i.left],s=l[0],n=l[1]),r+=s,e+=n,{top:r,left:e}):void 0}})}.call(this),this.Tether}),function(){var t,e,o,i,n,s,r,l,h,a,p,u,f,d={}.hasOwnProperty,c=function(t,e){function o(){this.constructor=t}for(var i in e)d.call(e,i)&&(t[i]=e[i]);return o.prototype=e.prototype,t.prototype=new o,t.__super__=e.prototype,t},g=[].indexOf||function(t){for(var e=0,o=this.length;o>e;e++)if(e in this&&this[e]===t)return e;return-1};f=Tether.Utils,r=f.extend,o=f.addClass,h=f.removeClass,l=f.hasClass,t=f.Evented,u="ontouchstart"in document.documentElement,n=["click"],u&&n.push("touchstart"),p=function(t){var e,o,i,n;return i=t.split(" "),e=i[0],o=i[1],("left"===e||"right"===e)&&(n=[o,e],e=n[0],o=n[1]),[e,o].join(" ")},e={left:"right",right:"left",top:"bottom",bottom:"top",middle:"middle",center:"center"},i={},a=function(t,e){var o,i;for(i=[];-1!==(o=t.indexOf(e));)i.push(t.splice(o,1));return i},s=function(u){var f,d,m,v;return null==u&&(u={}),m=function(){return function(t,e,o){o.prototype=t.prototype;var i=new o,n=t.apply(i,e);return Object(n)===n?n:i}(f,arguments,function(){})},r(m,{createContext:s,drops:[],defaults:{}}),d={classPrefix:"drop",defaults:{position:"bottom left",openOn:"click",constrainToScrollParent:!0,constrainToWindow:!0,classes:"",remove:!1,tetherOptions:{}}},r(m,d,u),r(m.defaults,d.defaults,u.defaults),null==i[v=m.classPrefix]&&(i[v]=[]),m.updateBodyClasses=function(){var t,e,n,s,r;for(t=!1,r=i[m.classPrefix],n=0,s=r.length;s>n;n++)if(e=r[n],e.isOpened()){t=!0;break}return t?o(document.body,""+m.classPrefix+"-open"):h(document.body,""+m.classPrefix+"-open")},f=function(t){function s(t){if(this.options=t,this.options=r({},m.defaults,this.options),this.target=this.options.target,null==this.target)throw new Error("Drop Error: You must provide a target.");this.options.classes&&o(this.target,this.options.classes),m.drops.push(this),i[m.classPrefix].push(this),this._boundEvents=[],this.setupElements(),this.setupEvents(),this.setupTether()}return c(s,t),s.prototype._on=function(t,e,o){return this._boundEvents.push({element:t,event:e,handler:o}),t.addEventListener(e,o)},s.prototype.setupElements=function(){return this.drop=document.createElement("div"),o(this.drop,m.classPrefix),this.options.classes&&o(this.drop,this.options.classes),this.content=document.createElement("div"),o(this.content,""+m.classPrefix+"-content"),"object"==typeof this.options.content?this.content.appendChild(this.options.content):this.content.innerHTML=this.options.content,this.drop.appendChild(this.content)},s.prototype.setupTether=function(){var t,o;return o=this.options.position.split(" "),o[0]=e[o[0]],o=o.join(" "),t=[],t.push(this.options.constrainToScrollParent?{to:"scrollParent",pin:"top, bottom",attachment:"together none"}:{to:"scrollParent"}),t.push(this.options.constrainToWindow!==!1?{to:"window",attachment:"together"}:{to:"window"}),u={element:this.drop,target:this.target,attachment:p(o),targetAttachment:p(this.options.position),classPrefix:m.classPrefix,offset:"0 0",targetOffset:"0 0",enabled:!1,constraints:t},this.options.tetherOptions!==!1?this.tether=new Tether(r({},u,this.options.tetherOptions)):void 0},s.prototype.setupEvents=function(){var t,e,o,i,s,r,l,h,a,p,u=this;if(this.options.openOn){if("always"===this.options.openOn)return void setTimeout(this.open.bind(this));if(o=this.options.openOn.split(" "),g.call(o,"click")>=0)for(s=function(t){return u.toggle(),t.preventDefault()},e=function(t){return!u.isOpened()||t.target===u.drop||u.drop.contains(t.target)||t.target===u.target||u.target.contains(t.target)?void 0:u.close()},a=0,p=n.length;p>a;a++)t=n[a],this._on(this.target,t,s),this._on(document,t,e);return g.call(o,"hover")>=0?(i=!1,h=function(){return i=!0,u.open()},l=null,r=function(){return i=!1,null!=l&&clearTimeout(l),l=setTimeout(function(){return i||u.close(),l=null},50)},this._on(this.target,"mouseover",h),this._on(this.drop,"mouseover",h),this._on(this.target,"mouseout",r),this._on(this.drop,"mouseout",r)):void 0}},s.prototype.isOpened=function(){return l(this.drop,""+m.classPrefix+"-open")},s.prototype.toggle=function(){return this.isOpened()?this.close():this.open()},s.prototype.open=function(){var t,e,i=this;if(!this.isOpened())return this.drop.parentNode||document.body.appendChild(this.drop),null!=(t=this.tether)&&t.enable(),o(this.drop,""+m.classPrefix+"-open"),o(this.drop,""+m.classPrefix+"-open-transitionend"),setTimeout(function(){return o(i.drop,""+m.classPrefix+"-after-open")}),null!=(e=this.tether)&&e.position(),this.trigger("open"),m.updateBodyClasses()},s.prototype.close=function(){var t,e,o=this;if(this.isOpened())return h(this.drop,""+m.classPrefix+"-open"),h(this.drop,""+m.classPrefix+"-after-open"),this.drop.addEventListener("transitionend",t=function(){return l(o.drop,""+m.classPrefix+"-open")||h(o.drop,""+m.classPrefix+"-open-transitionend"),o.drop.removeEventListener("transitionend",t)}),this.trigger("close"),null!=(e=this.tether)&&e.disable(),m.updateBodyClasses(),this.options.remove?this.remove():void 0},s.prototype.remove=function(){var t;return this.close(),null!=(t=this.drop.parentNode)?t.removeChild(this.drop):void 0},s.prototype.position=function(){var t;return this.isOpened()&&null!=(t=this.tether)?t.position():void 0},s.prototype.destroy=function(){var t,e,o,n,s,r,l,h;for(this.remove(),null!=(r=this.tether)&&r.destroy(),l=this._boundEvents,n=0,s=l.length;s>n;n++)h=l[n],t=h.element,e=h.event,o=h.handler,t.removeEventListener(e,o);return this._boundEvents=[],this.tether=null,this.drop=null,this.content=null,this.target=null,a(i[m.classPrefix],this),a(m.drops,this)},s}(t),m},window.Drop=s(),document.addEventListener("DOMContentLoaded",function(){return Drop.updateBodyClasses()})}.call(this),function(){var t,e,o,i,n,s,r,l,h=[].indexOf||function(t){for(var e=0,o=this.length;o>e;e++)if(e in this&&this[e]===t)return e;return-1};l=Tether.Utils,e=l.addClass,s=l.removeClass,i=l.extend,r=Drop.createContext({classPrefix:"tooltip"}),o={position:"top center",openOn:"hover",classes:"tooltip-theme-arrows",constrainToWindow:!0,constrainToScrollParent:!1},t=function(){function t(t){var e,n,s,l;if(this.options=t,!this.options.target)throw new Error("Tooltip Error: You must provide a target for Tooltip to attach to");if((n=this.options.target.getAttribute("data-tooltip-position"))&&null==(s=this.options).position&&(s.position=n),(e=this.options.target.getAttribute("data-tooltip"))&&null==(l=this.options).content&&(l.content=e),!this.options.content)throw new Error("Tooltip Error: You must provide content for Tooltip to display");this.options=i({},o,this.options),this.drop=new r(this.options)}return t.prototype.close=function(){return this.drop.close()},t.prototype.open=function(){return this.drop.open()},t.prototype.toggle=function(){return this.drop.toggle()},t.prototype.remove=function(){return this.drop.remove()},t.prototype.destroy=function(){return this.drop.destroy()},t.prototype.position=function(){return this.drop.position()},t}(),n=[],t.init=function(){var e,o,i,s,r;for(s=document.querySelectorAll("[data-tooltip]"),r=[],o=0,i=s.length;i>o;o++)e=s[o],h.call(n,e)<0&&(new t({target:e}),r.push(n.push(e)));return r},document.addEventListener("DOMContentLoaded",function(){return t.autoinit!==!1?t.init():void 0}),window.Tooltip=t}.call(this); \ No newline at end of file