diff --git a/Gruntfile.js b/Gruntfile.js index b379e85..158ee79 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -139,34 +139,6 @@ const release = { pushTo: 'origin', }, }, - clean: ['release/*'], - copy: { - expand: true, - src: ['dist/*'], - dest: 'release/', - extDot: 'last', - flatten: true, - }, - uglify: { - files: { - 'release/hlf-dom-extensions.min.js': [ - 'dist/core.js', - 'dist/hover-intent.js', - 'dist/media-grid.js', - 'dist/tip.js', - ], - }, - }, - registerTasks(grunt) { - grunt.registerTask('release', [ - 'dist', - // Uncompressed version. - 'clean:release', - 'copy:release', - // Compressed version. - 'uglify:release', - ]); - }, }; module.exports = (grunt) => { @@ -178,13 +150,11 @@ module.exports = (grunt) => { docs: docs.clean, 'gh-pages': pages.clean, lib: lib.clean, - release: release.clean, }, copy: { dist: dist.copy, 'gh-pages': pages.copy, lib: lib.copy, - release: release.copy, }, 'gh-pages': { 'gh-pages': pages['gh-pages'], @@ -195,9 +165,6 @@ module.exports = (grunt) => { markdown: { 'gh-pages': pages.markdown, }, - uglify: { - release: release.uglify, - }, watch: {}, }; if (!grunt.option('fast')) { @@ -214,5 +181,4 @@ module.exports = (grunt) => { docs.registerTasks(grunt); lib.registerTasks(grunt); pages.registerTasks(grunt); - release.registerTasks(grunt); }; diff --git a/hlf-dom-extensions.sublime-project b/hlf-dom-extensions.sublime-project index db45cf8..725cc2f 100644 --- a/hlf-dom-extensions.sublime-project +++ b/hlf-dom-extensions.sublime-project @@ -8,7 +8,6 @@ "*.sublime-workspace", "dist/*", "docs/index.html", - "release/*" ], "folder_exclude_patterns": [ diff --git a/package.json b/package.json index 9085863..6702036 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,6 @@ "grunt-bump": "^0.8", "grunt-contrib-clean": "^1.0", "grunt-contrib-copy": "^1.0", - "grunt-contrib-uglify": "^3.1", "grunt-contrib-watch": "^1.0", "grunt-gh-pages": "^2.0", "grunt-groc": "^0.7", diff --git a/release/editable.css b/release/editable.css deleted file mode 100644 index f4f4970..0000000 --- a/release/editable.css +++ /dev/null @@ -1,50 +0,0 @@ -/* -HLF Editable Extension -====================== -[Source](../js/jquery.hlf.editable.html) | [Tests](../../tests/css/editable.html) -*/ - -/* -skin -*/ -.js-editable-inline { - --edit-hover-bg-color: rgba(0, 0, 0, 0.1); - --edit-inline-width: 10rem; - --edit-stroke-color: #000; -} -.js-editable-inline .js-text, -.js-editable-inline .js-input input { - border-color: transparent; - background-color: transparent; -} -.js-editable-inline .js-text:focus, -.js-editable-inline .js-input input:focus { - outline-style: none; -} -.js-editable-inline .js-text { - cursor: text; -} -.js-editable-inline .js-text:hover { - background-color: var(--edit-hover-bg-color); -} -.js-editable-inline .js-input input { - border-bottom-color: var(--edit-stroke-color); -} - -/* -layout -*/ -.js-editable-inline .js-text, -.js-editable-inline .js-input input { - border-width: 1px; - margin: 0; - padding: 0; - width: var(--edit-inline-width); -} -.js-editable-inline .js-text { - overflow-x: hidden; - white-space: nowrap; -} -.js-editable-inline .js-input input { - margin: -1px; -} diff --git a/release/jquery.extension.hlf.core.js b/release/jquery.extension.hlf.core.js deleted file mode 100644 index 5004e32..0000000 --- a/release/jquery.extension.hlf.core.js +++ /dev/null @@ -1,374 +0,0 @@ - -/* -HLF Core jQuery Extension -========================= - */ - -(function() { - var slice = [].slice, - 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; }; - - (function(root, attach) { - if (typeof define === 'function' && (define.amd != null)) { - define(['jquery', 'underscore'], attach); - } else if (typeof exports === 'object') { - module.exports = attach(require('jquery', require('underscore'))); - } else { - attach(jQuery, _); - } - })(this, function($, _) { - 'use strict'; - var _createPluginAPIAdditions, _createPluginInstance, _noConflicts, _safeSet, hlf; - hlf = { - debug: true, - toString: _.constant('hlf'), - noConflict: function() { - var fn; - return ((function() { - var i, len, results; - results = []; - for (i = 0, len = _noConflicts.length; i < len; i++) { - fn = _noConflicts[i]; - results.push(fn()); - } - return results; - })()).length; - } - }; - hlf.debugLog = hlf.debug === false ? $.noop : (console.log.bind ? console.log.bind(console) : console.log); - _noConflicts = []; - _.extend(hlf, { - createPlugin: function(createOptions) { - var _noConflict, _plugin, apiAdditions, apiClass, apiMixins, deep, mixinFilter, name, namespace, plugin, safeName; - name = createOptions.name; - safeName = "" + (this.toString()) + (name[0].toUpperCase()) + name.slice(1); - namespace = createOptions.namespace; - apiAdditions = _createPluginAPIAdditions(name, namespace); - if (createOptions.apiClass != null) { - apiClass = namespace.apiClass = createOptions.apiClass; - _.extend(apiClass.prototype, apiAdditions); - } - if (createOptions.apiMixins != null) { - mixinFilter = createOptions.mixinFilter; - if (mixinFilter == null) { - mixinFilter = function(mixin) { - return mixin; - }; - } - apiMixins = namespace.apiMixins = createOptions.apiMixins; - $.extend((deep = true), apiMixins, { - base: apiAdditions - }); - } - _noConflict = namespace.noConflict; - _plugin = $.fn[name]; - _noConflicts.push((namespace.noConflict = function() { - if (_.isFunction(_noConflict)) { - _noConflict(); - } - $.fn[name] = _plugin; - })); - return plugin = $.fn[name] = $.fn[safeName] = function() { - var $context, $el, command, instance, options; - if (_.isString(arguments[0])) { - command = { - type: arguments[0], - userInfo: arguments[1] - }; - } else { - options = arguments[0]; - if (arguments[1] != null) { - $context = arguments[1]; - } - } - if ($context == null) { - $context = $('body'); - } - if (command != null) { - this.each(function() { - var $el, instance, sender; - $el = $(this); - instance = $el.data(namespace.toString('data')); - if (_.isFunction(instance.handleCommand)) { - if (_.isFunction(command.userInfo)) { - command.userInfo($el); - } - sender = null; - instance.handleCommand(command, sender); - } - }); - return this; - } else { - $el = createOptions.asSharedInstance === true ? $context : this.first(); - instance = $el.data(namespace.toString('data')); - if ((instance != null) && (instance.$el != null) && (options == null)) { - return instance; - } - } - options = $.extend((deep = true), {}, namespace.defaults, options); - $el = this; - (function() { - var args; - args = arguments; - if (createOptions.asSharedInstance === true) { - _createPluginInstance.apply(null, [$el].concat(slice.call(args))); - } else { - $el.each(function() { - _createPluginInstance.apply(null, [$(this)].concat(slice.call(args))); - }); - } - })(options, $context, namespace, apiClass, apiMixins, mixinFilter, createOptions); - return this; - }; - } - }); - _.bindAll(hlf, 'createPlugin'); - _createPluginInstance = function($el, options, $context, namespace, apiClass, apiMixins, mixinFilter, createOptions) { - var $root, data, deep, finalOptions, instance, otherMixins; - data = $el.data(namespace.toString('data')); - finalOptions = options; - if ($.isPlainObject(data)) { - finalOptions = $.extend((deep = true), {}, options, data); - $root = $el; - } else if (createOptions.asSharedInstance) { - $root = $context; - } else { - $root = $el; - } - if (apiClass != null) { - instance = new apiClass($el, finalOptions, $context); - if (createOptions.baseMixins != null) { - hlf.applyMixins.apply(hlf, [instance, namespace].concat(slice.call(createOptions.baseMixins))); - } - if (createOptions.apiMixins != null) { - hlf.applyMixins.apply(hlf, [instance, namespace].concat(slice.call(createOptions.apiMixins))); - } - } else if (apiMixins != null) { - instance = { - $el: $el, - options: finalOptions - }; - if (createOptions.baseMixins != null) { - hlf.applyMixins.apply(hlf, [instance, namespace].concat(slice.call(createOptions.baseMixins))); - } - hlf.applyMixin(instance, namespace, apiMixins.base); - otherMixins = _.chain(apiMixins).filter(mixinFilter, instance).values().without(apiMixins.base).value(); - hlf.applyMixins.apply(hlf, [instance, namespace].concat(slice.call(otherMixins))); - } - if (createOptions.compactOptions === true) { - $.extend((deep = true), instance, finalOptions); - delete instance.options; - } else { - if (finalOptions.selectors != null) { - instance.selectors = finalOptions.selectors; - } - if (finalOptions.classNames != null) { - instance.classNames = finalOptions.classNames; - } - } - if (createOptions.autoSelect === true && _.isFunction(instance.select)) { - instance.select(); - } - if (instance.cls !== $.noop) { - $root.addClass(instance.cls()); - } - if (_.isFunction(instance.init)) { - instance.init(); - } else if (apiClass == null) { - hlf.debugLog('ERROR: No `init` method on instance.', instance); - } - $root.data(instance.attr(), instance); - }; - _createPluginAPIAdditions = function(name, namespace) { - return { - evt: _.memoize(function(name) { - if (_.contains(name, ' ')) { - return name.split(' ').reduce(((function(_this) { - return function(names, n) { - return names + " " + (_this.evt(n)); - }; - })(this)), ''); - } - return "" + name + (namespace.toString('event')); - }), - attr: _.memoize(function(name) { - name = name != null ? "-" + name : ''; - return namespace.toString('data') + name; - }), - cls: namespace.toString('class') === namespace.toString() ? $.noop : _.memoize(function(name) { - name = name != null ? "-" + name : ''; - return namespace.toString('class') + name; - }), - debugLog: namespace.debug === false ? $.noop : function() { - hlf.debugLog.apply(hlf, [namespace.toString('log')].concat(slice.call(arguments))); - } - }; - }; - hlf._createPluginAPIAdditions = _createPluginAPIAdditions; - _.extend(hlf, { - applyMixin: function(context, dependencies, mixin) { - var handlerNames, i, len, method, mixinToApply, name, onceMethods, prop; - if (_.isString(mixin)) { - mixin = this.mixins[mixin]; - } - if (_.isFunction(mixin)) { - mixin = mixin(dependencies); - } - if (mixin == null) { - return; - } - onceMethods = []; - handlerNames = []; - for (name in mixin) { - if (!hasProp.call(mixin, name)) continue; - prop = mixin[name]; - if (!(_.isFunction(prop))) { - continue; - } - if (indexOf.call(this.mixinOnceNames, name) >= 0) { - onceMethods.push(prop); - } - if (name.indexOf('handle') === 0 && name !== 'handleCommand') { - handlerNames.push(name); - } - } - mixinToApply = _.omit(mixin, this.mixinOnceNames); - _.extend(context, mixinToApply); - for (i = 0, len = onceMethods.length; i < len; i++) { - method = onceMethods[i]; - method.call(context); - } - if (handlerNames.length) { - _.bindAll.apply(_, [context].concat(slice.call(handlerNames))); - } - }, - applyMixins: function() { - var context, dependencies, i, len, mixin, mixins; - context = arguments[0], dependencies = arguments[1], mixins = 3 <= arguments.length ? slice.call(arguments, 2) : []; - for (i = 0, len = mixins.length; i < len; i++) { - mixin = mixins[i]; - this.applyMixin(context, dependencies, mixin); - } - }, - createMixin: function(mixins, name, mixin) { - var k, prop; - if (mixins == null) { - mixins = hlf.mixins; - } - if (name in mixins) { - return false; - } - mixins[name] = mixin; - if ($.isPlainObject(mixin)) { - for (k in mixin) { - if (!hasProp.call(mixin, k)) continue; - prop = mixin[k]; - if (_.isFunction(prop)) { - prop.mixin = name; - } - } - } - return mixin; - }, - mixinOnceNames: ['decorate', 'decorateOptions'], - mixins: { - data: function() { - return { - data: function() { - var first, k, pairs, v; - if (arguments.length) { - first = arguments[0]; - if (_.isString(first)) { - arguments[0] = this.attr(first); - } else if (_.isObject(first)) { - pairs = {}; - for (k in first) { - if (!hasProp.call(first, k)) continue; - v = first[k]; - pairs[this.attr(k)] = v; - } - arguments[0] = pairs; - } - } - return this.$el.data.apply(this.$el, arguments); - } - }; - }, - event: function() { - return { - evtMap: function(map) { - var handler, name, namespaced; - namespaced = {}; - for (name in map) { - if (!hasProp.call(map, name)) continue; - handler = map[name]; - namespaced[this.evt(name)] = handler; - } - return namespaced; - }, - on: function(obj) { - arguments[0] = _.isString(obj) ? this.evt(obj) : this.evtMap(obj); - this.$el.on.apply(this.$el, arguments); - }, - off: function(obj) { - arguments[0] = _.isString(obj) ? this.evt(obj) : this.evtMap(obj); - this.$el.off.apply(this.$el, arguments); - }, - trigger: function(name, userInfo) { - this.$el.trigger({ - type: this.evt(name), - userInfo: userInfo - }); - } - }; - }, - selection: function() { - return { - select: function() { - var name, ref, result, selector; - ref = this.selectors; - for (name in ref) { - if (!hasProp.call(ref, name)) continue; - selector = ref[name]; - if ((result = this.$el.find(selector)) != null) { - this["$" + name] = result; - } - } - }, - selectByClass: function(className) { - var classNames, ref; - classNames = (ref = this.options) != null ? ref.classNames : void 0; - if (classNames == null) { - classNames = this.classNames; - } - return this.$el.find("." + this.classNames[className]); - } - }; - } - } - }); - _safeSet = function(key, toContext, fromContext) { - var _oldValue; - if (toContext == null) { - toContext = $; - } - if (fromContext == null) { - fromContext = hlf; - } - _oldValue = toContext[key]; - toContext[key] = fromContext[key]; - _noConflicts.push(function() { - toContext[key] = _oldValue; - }); - }; - _safeSet('applyMixin'); - _safeSet('applyMixins'); - _safeSet('createMixin'); - _safeSet('createPlugin'); - _safeSet('mixinOnceNames'); - _safeSet('mixins'); - return $.hlf = hlf; - }); - -}).call(this); diff --git a/release/jquery.extension.hlf.event.js b/release/jquery.extension.hlf.event.js deleted file mode 100644 index 6085363..0000000 --- a/release/jquery.extension.hlf.event.js +++ /dev/null @@ -1,168 +0,0 @@ - -/* -HLF Event jQuery Extension -========================== - */ - -(function() { - var slice = [].slice, - hasProp = {}.hasOwnProperty; - - (function(root, attach) { - if (typeof define === 'function' && (define.amd != null)) { - define(['jquery', 'underscore', 'hlf/jquery.extension.hlf.core'], attach); - } else if (typeof exports === 'object') { - module.exports = attach(require('jquery', require('underscore', require('hlf/jquery.extension.hlf.core')))); - } else { - attach(jQuery, _, jQuery.hlf); - } - })(this, function($, _, hlf) { - 'use strict'; - $.extend(true, hlf, { - hoverIntent: { - debug: false, - mouse: { - x: { - current: 0, - previous: 0 - }, - y: { - current: 0, - previous: 0 - } - }, - sensitivity: 8, - interval: 300, - toString: _.memoize(function(context) { - switch (context) { - case 'attr': - return 'hlf-hover-intent'; - default: - return 'hlf.hoverIntent'; - } - }) - } - }); - return (function(hoverIntent, mouse) { - var attr, check, debugLog, defaultState, getComputedState, performCheck, setupCheckIfNeeded, teardownCheckIfNeeded, trackMouse, triggerEvent; - attr = function(name) { - if (name == null) { - name = ''; - } - return (hoverIntent.toString('attr')) + "-" + name; - }; - debugLog = hoverIntent.debug === false ? $.noop : function() { - hlf.debugLog.apply(hlf, [hoverIntent.toString('log')].concat(slice.call(arguments))); - }; - defaultState = { - intentional: true, - timer: { - cleared: true, - timeout: null - }, - sensitivity: hoverIntent.sensitivity, - interval: hoverIntent.interval - }; - getComputedState = function($trigger) { - var key, state, value; - state = {}; - for (key in defaultState) { - if (!hasProp.call(defaultState, key)) continue; - value = defaultState[key]; - if ($.isPlainObject(value)) { - value = _.clone(value); - } - state[key] = $trigger.data(attr(key)) || value; - } - return state; - }; - check = function(event) { - var $trigger, didTeardown, state; - $trigger = $(this); - state = getComputedState($trigger); - debugLog(state); - didTeardown = teardownCheckIfNeeded(event, $trigger, state); - if (didTeardown === false) { - setupCheckIfNeeded(event, $trigger, state); - } - }; - setupCheckIfNeeded = function(event, $trigger, state) { - if (state.timer.cleared === false && (state.timer.timeout != null)) { - return false; - } - debugLog('setup'); - state.timer.timeout = setTimeout(function() { - debugLog('check and update'); - return performCheck(event, $trigger, state); - }, state.interval); - state.timer.cleared = false; - $trigger.data(attr('timer'), state.timer); - return true; - }; - teardownCheckIfNeeded = function(event, $trigger, state) { - if (event.type !== 'mouseleave') { - return false; - } - if (state.timer.cleared === false) { - debugLog('teardown'); - clearTimeout(state.timer.timeout); - $trigger.removeData(attr('timer')).removeData(attr('intentional')); - } - triggerEvent('truemouseleave', $trigger, event); - return true; - }; - performCheck = function(event, $trigger, state) { - state.intentional = (Math.abs(mouse.x.previous - mouse.x.current) + Math.abs(mouse.y.previous - mouse.y.current)) > state.sensitivity; - mouse.x.previous = event.pageX; - mouse.y.previous = event.pageY; - if (state.intentional === true && event.type === 'mouseover') { - triggerEvent('truemouseenter', $trigger, event); - } - state.timer.cleared = true; - $trigger.data(attr('intentional'), state.intentional); - $trigger.data(attr('timer'), state.timer); - }; - trackMouse = _.throttle(function(event) { - mouse.x.current = event.pageX; - mouse.y.current = event.pageY; - }, 16); - triggerEvent = function(name, $trigger, oldEvent) { - var event; - event = new $.Event(name, { - pageX: mouse.x.current, - pageY: mouse.y.current, - relatedTarget: oldEvent.relatedTarget - }); - debugLog(name); - $trigger.trigger(event); - }; - $.event.special.truemouseenter = { - setup: function(data, namespaces) { - $(this).on({ - mouseover: check, - mousemove: trackMouse - }, data != null ? data.selector : void 0); - }, - teardown: function(data, namespaces) { - $(this).off({ - mouseover: check, - mousemove: trackMouse - }, data != null ? data.selector : void 0); - } - }; - return $.event.special.truemouseleave = { - setup: function(data, namespaces) { - $(this).on({ - mouseleave: check - }, data != null ? data.selector : void 0); - }, - teardown: function(data, namespaces) { - $(this).off({ - mouseleave: check - }, data != null ? data.selector : void 0); - } - }; - })(hlf.hoverIntent, hlf.hoverIntent.mouse); - }); - -}).call(this); diff --git a/release/jquery.hlf.editable.js b/release/jquery.hlf.editable.js deleted file mode 100644 index 70151fc..0000000 --- a/release/jquery.hlf.editable.js +++ /dev/null @@ -1,337 +0,0 @@ - -/* -HLF Editable jQuery Plugin -========================== - */ - -(function() { - var 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; }; - - (function(root, attach) { - if (typeof define === 'function' && (define.amd != null)) { - define(['jquery', 'underscore', 'hlf/jquery.extension.hlf.core'], attach); - } else if (typeof exports === 'object') { - module.exports = attach(require('jquery', require('underscore', require('hlf/jquery.extension.hlf.core')))); - } else { - attach(jQuery, _, jQuery.hlf); - } - })(this, function($, _, hlf) { - 'use strict'; - var mixins; - hlf.editable = { - debug: true, - toString: _.memoize(function(context) { - switch (context) { - case 'event': - return '.hlf.editable'; - case 'data': - return 'hlf-editable'; - case 'class': - return 'js-editable'; - default: - return 'hlf.editable'; - } - }), - defaults: { - selectors: { - text: '.js-text', - input: '.js-input input', - inputWrap: '.js-input' - }, - classNames: { - container: '' - } - }, - types: _.memoize(function() { - return _.chain(mixins).keys().without('base').value(); - }) - }; - mixins = {}; - $.createMixin(mixins, 'base', { - isEditing: null, - init: function() { - this.trigger('will-init'); - this.$el.addClass(this.classNames.container); - this.bind(); - if (this.toggleEditing != null) { - this.toggleEditing(false); - } - return this.trigger('did-init'); - }, - bind: function() { - if (this.toggleEditing != null) { - this.on('click', this.selectors.text, (function(_this) { - return function(e) { - return _this.toggleEditing(true); - }; - })(this)); - this.on('blur', this.selectors.input, (function(_this) { - return function(e) { - return _this.toggleEditing(false); - }; - })(this)); - } - return this.on('change', this.selectors.input, this.handleValueChange); - }, - handleCommand: function(command, sender) { - this.trigger('before-command', { - command: command - }); - switch (command.type) { - case 'update': - this.renderText(command.userInfo.text); - break; - } - return this.trigger('after-command', { - command: command - }); - }, - handleValueChange: function(sender) { - var text, userInfo; - text = this.inputValue(); - text = this.textOnValueChange(text); - userInfo = { - text: text - }; - this.trigger('will-commit', userInfo); - return this.trigger('commit', userInfo); - }, - toggleEditing: function(state) { - var toggleOriginalDisplay; - this.isEditing = state; - toggleOriginalDisplay = (function(_this) { - return function($el, state) { - var display; - display = $el.data(_this.attr('display')); - if (state === true) { - if (display == null) { - display = 'block'; - } - return $el.css({ - display: display - }); - } else if (state === false) { - if (display == null) { - display = $el.css('display'); - if (display !== 'none') { - $el.data(_this.attr('display'), display); - } - } - return $el.hide(); - } - }; - })(this); - if (state === true) { - toggleOriginalDisplay(this.$text, false); - toggleOriginalDisplay(this.$inputWrap, true); - this.$input.focus(); - } else if (state === false) { - toggleOriginalDisplay(this.$text, true); - toggleOriginalDisplay(this.$inputWrap, false); - } - return this.trigger('toggle-edit', { - state: state - }); - }, - renderText: function(text) { - return this.$text.text(text); - }, - inputValue: function() { - return this.$input.val(); - }, - textOnValueChange: function(text) {} - }); - $.createMixin(mixins, 'inline', { - textOnValueChange: function(text) { - if (!text.length) { - return this.$input.attr('placeholder'); - } else { - return text; - } - }, - decorateOptions: function() { - return this.options.classNames.container += " " + (this.cls('inline')); - }, - decorate: function() { - this.on('did-init', (function(_this) { - return function() { - return _this.initInline(); - }; - })(this)); - this.on('will-commit', (function(_this) { - return function(e) { - return _this.renderText(e.userInfo.text); - }; - })(this)); - return this.on('after-command', (function(_this) { - return function(e) { - var command; - command = e.userInfo.command; - switch (command.type) { - case 'update': - return _this.updatePlaceholder(); - } - }; - })(this)); - }, - initInline: function() { - return this.updatePlaceholder(); - }, - updatePlaceholder: function() { - return this.$input.attr('placeholder', this.$text.text()); - } - }); - $.createMixin(mixins, 'editor', { - inputValue: function() { - switch (this.editorName) { - case 'CodeMirror': - return this.editor.getValue(); - default: - return ''; - } - }, - renderText: function(text) { - switch (this.editorName) { - case 'CodeMirror': - return this.editor.setValue(text); - } - }, - decorateOptions: function() { - return this.opts.selectors.markup = '.editor-markup'; - }, - decorate: function() { - delete this.toggleEditing; - this.on('will-init', (function(_this) { - return function() {}; - })(this)); - return this.on('did-init', (function(_this) { - return function() { - return _this.initEditor(); - }; - })(this)); - }, - initEditor: function() { - var didInit, location, opts; - this.editorName = this.data('editor'); - switch (this.editorName) { - case 'CodeMirror': - opts = this.data('editor-options'); - opts.value = this.$markup.text(); - location = (function(_this) { - return function(el) { - _this.$editor = el; - return _this.$markup.replaceWith(_this.$editor); - }; - })(this); - this.editor = CodeMirror(location, opts); - break; - default: - didInit = false; - } - this.bindEditor(); - return didInit !== false; - }, - bindEditor: function() { - switch (this.editorName) { - case 'CodeMirror': - return this.editor.on('blur', this.handleValueChange); - } - } - }); - $.createMixin(mixins, 'color-picker', { - decorateOptions: function() { - return this.opts.selectors.well = '.color-well'; - }, - decorate: function() { - this.on('will-commit', (function(_this) { - return function(e) { - return _this.renderColor(e.userInfo.text); - }; - })(this)); - return this.on('did-init', (function(_this) { - return function() { - return _this.initColorPicker(); - }; - })(this)); - }, - initColorPicker: function() { - var didInit, opts; - _.bindAll(this, 'handleColorPickerChange'); - this.pickerName = this.data('color-picker'); - switch (this.pickerName) { - case 'Spectrum': - opts = this.data('color-picker-options'); - opts.color = "#" + (this.$input.val()); - opts.change = this.handleColorPickerChange; - this.$well.spectrum(opts); - break; - default: - didInit = false; - } - this.bindColorPicker(); - return didInit !== false; - }, - bindColorPicker: function() {}, - handleColorPickerChange: function(color) { - switch (this.pickerName) { - case 'Spectrum': - color = color.toHexString().substring(1); - } - return this.$input.val(color).trigger('change'); - }, - renderColor: function(color) { - switch (this.pickerName) { - case 'Spectrum': - return this.$well.spectrum('set', color); - } - } - }); - $.createMixin(mixins, 'file-uploader', { - decorateOptions: function() { - this.opts.selectors.text = '.preview > figcaption'; - return this.opts.selectors.thumb = '.preview > .thumb'; - }, - decorate: function() { - delete this.toggleEditing; - this.on('will-commit', (function(_this) { - return function(e) {}; - })(this)); - return this.on('did-init', (function(_this) { - return function() { - return _this.initFileUploader(); - }; - })(this)); - }, - initFileUploader: function() { - var didInit, opts; - this.uploaderName = this.data('file-uploader'); - switch (this.uploaderName) { - case 'jQueryFileUpload': - opts = this.data('file-uploader-options'); - this.$input.fileupload(opts); - break; - default: - didInit = false; - } - this.bindFileUploader(); - return didInit !== false; - }, - bindFileUploader: function() {} - }); - return hlf.createPlugin({ - name: 'editable', - namespace: hlf.editable, - apiMixins: mixins, - mixinFilter: function(mixin, name) { - if (_.isString(this.options.types)) { - this.options.types = this.options.types.split(' '); - } - return indexOf.call(this.options.types, name) >= 0 && indexOf.call(hlf.editable.types(), name) >= 0; - }, - baseMixins: ['data', 'event', 'selection'], - autoSelect: true, - compactOptions: true - }); - }); - -}).call(this); diff --git a/release/jquery.hlf.media-grid.js b/release/jquery.hlf.media-grid.js deleted file mode 100644 index 7153882..0000000 --- a/release/jquery.hlf.media-grid.js +++ /dev/null @@ -1,299 +0,0 @@ - -/* -HLF Media Grid jQuery Plugin -============================ - */ - -(function() { - (function(root, attach) { - if (typeof define === 'function' && (define.amd != null)) { - define(['jquery', 'underscore', 'hlf/jquery.extension.hlf.core'], attach); - } else if (typeof module === 'object' && (module.exports != null)) { - module.exports = attach(require('jquery', require('underscore', require('hlf/jquery.extension.hlf.core')))); - } else { - attach(jQuery, _, jQuery.hlf); - } - })(this, function($, _, hlf) { - var MediaGrid; - hlf.mediaGrid = { - debug: false, - toString: _.memoize(function(context) { - switch (context) { - case 'event': - return '.hlf.mg'; - case 'data': - return 'hlf-mg'; - case 'class': - return 'js-mg'; - default: - return 'hlf.mg'; - } - }), - defaults: (function(pre) { - return { - autoReady: false, - resizeDelay: 100, - undimDelay: 1000, - classNames: (function() { - var classNames, j, key, keys, len; - classNames = {}; - keys = ['item', 'sample', 'transitioning', 'expanded', 'dimmed', 'focused', 'ready']; - for (j = 0, len = keys.length; j < len; j++) { - key = keys[j]; - classNames[key] = "" + pre + key; - } - return classNames; - })() - }; - })('js-mg-') - }; - MediaGrid = (function() { - function MediaGrid($el, options) { - this.$el = $el; - } - - MediaGrid.prototype.init = function() { - if (this.$items == null) { - this.$items = this.selectByClass('item'); - } - this.$sampleItem = this.$items.first(); - this.expandDuration = 1000 * parseFloat(this.$sampleItem.css('transition-duration')); - this.$items.on('click', (function(_this) { - return function(e) { - _this.toggleItemExpansion($(e.currentTarget)); - }; - })(this)); - this.$expandedItem = null; - this.on({ - mouseenter: (function(_this) { - return function(e) { - _this.toggleExpandedItemFocus($(e.currentTarget), true); - }; - })(this), - mouseleave: (function(_this) { - return function(e) { - _this.toggleExpandedItemFocus($(e.currentTarget), false); - }; - })(this), - expand: (function(_this) { - return function(e, expanded) { - _this.toggleItemFocus($(e.currentTarget), expanded, _this.expandDuration); - }; - })(this) - }, "." + this.classNames.item); - this.on('mouseleave', (function(_this) { - return function() { - if (_this.$expandedItem != null) { - _this.toggleItemFocus(_this.$expandedItem, false, 0); - } - }; - })(this)); - this.metrics = {}; - this.on('ready', (function(_this) { - return function() { - _this._updateMetrics(); - _this._layoutItems(); - _this.$el.addClass(_this.classNames.ready); - }; - })(this)); - if (this.autoReady === true) { - this.trigger('ready'); - } - $(window).resize(_.debounce((function(_this) { - return function() { - _this._updateMetrics(false); - if (_this.$expandedItem != null) { - _this.toggleItemExpansion(_this.$expandedItem, false); - _this._reLayoutItems(_this.expandDuration); - } else { - _this._reLayoutItems(); - } - }; - })(this), this.resizeDelay)); - }; - - MediaGrid.prototype.toggleItemExpansion = function($item, expanded) { - var i; - if (expanded == null) { - expanded = !$item.hasClass(this.classNames.expanded); - } - if (expanded) { - if (this.$expandedItem != null) { - this.toggleItemExpansion(this.$expandedItem, false); - } - i = $item.index(); - if (this._isRightEdgeItem(i)) { - this._adjustItemToRightEdge($item); - } - if (this._isBottomEdgeItem(i)) { - this._adjustItemToBottomEdge($item); - } - } - $item.addClass(this.classNames.transitioning); - clearTimeout($item.data(this.attr('expand-timeout'))); - $item.data(this.attr('expand-timeout'), setTimeout((function(_this) { - return function() { - $item.removeClass(_this.classNames.transitioning); - }; - })(this), this.expandDuration)); - $item.toggleClass(this.classNames.expanded, expanded); - this.$expandedItem = expanded ? $item : null; - $item.trigger(this.evt('expand'), [expanded]); - }; - - MediaGrid.prototype.toggleExpandedItemFocus = function($item, focused) { - var delay; - if (!($item != null ? $item.hasClass(this.classNames.expanded) : void 0)) { - return; - } - delay = focused ? 0 : this.undimDelay; - this.toggleItemFocus($item, focused, delay); - }; - - MediaGrid.prototype.toggleItemFocus = function($item, focused, delay) { - if (focused) { - this.$items.removeClass(this.classNames.focused); - } - $item.toggleClass(this.classNames.focused, focused); - clearTimeout(this._dimTimeout); - this._dimTimeout = setTimeout((function(_this) { - return function() { - _this.$el.toggleClass(_this.classNames.dimmed, focused); - }; - })(this), delay); - }; - - MediaGrid.prototype._adjustItemToBottomEdge = function($item) { - $item.css({ - top: 'auto', - bottom: 0 - }); - }; - - MediaGrid.prototype._adjustItemToRightEdge = function($item) { - $item.css({ - left: 'auto', - right: 0 - }); - }; - - MediaGrid.prototype._getMetricSamples = function() { - var $expanded, $item, ref; - if ((ref = this.selectByClass('sample')) != null) { - ref.remove(); - } - $item = this.$sampleItem.clone(); - $expanded = this.$sampleItem.clone().addClass(this.classNames.expanded); - $('
').addClass(this.classNames.sample).css({ - left: 0, - position: 'absolute', - right: 0, - top: 0 - }).css({ - visibility: 'hidden', - zIndex: 0 - }).append($item, $expanded).appendTo(this.$el); - return { - $item: $item, - $expanded: $expanded - }; - }; - - MediaGrid.prototype._isBottomEdgeItem = function(i) { - return (i + 1) > (this.$items.length - this.metrics.rowSize); - }; - - MediaGrid.prototype._isRightEdgeItem = function(i) { - return (i + 1) % this.metrics.rowSize === 0; - }; - - MediaGrid.prototype._layoutItems = function() { - this.$items.get().reverse().forEach((function(_this) { - return function(item, i) { - var $item, offset; - $item = $(item); - offset = $item.position(); - if ($item.data(_this.attr('original-position')) == null) { - $item.data(_this.attr('original-position'), $item.css('position')); - } - return $item.css($.extend(offset, { - position: 'absolute' - })); - }; - })(this)); - this.$el.css({ - width: this.metrics.wrapWidth, - height: this.metrics.wrapHeight - }); - }; - - MediaGrid.prototype._reLayoutItems = function(delay) { - if (delay == null) { - delay = 0; - } - clearTimeout(this._layoutTimeout); - this._layoutTimeout = setTimeout((function(_this) { - return function() { - var key; - key = _this.attr('original-position'); - _this.$items.css({ - top: 'auto', - left: 'auto', - bottom: 'auto', - right: 'auto', - position: function() { - return $(this).data(key); - } - }); - return _this._layoutItems(); - }; - })(this), delay); - }; - - MediaGrid.prototype._updateMetrics = function(hard) { - var $expanded, $item, colSize, fullHeight, fullWidth, gutter, ref, rowSize; - if (hard == null) { - hard = true; - } - if (hard === true) { - ref = this._getMetricSamples(), $item = ref.$item, $expanded = ref.$expanded; - this.metrics = { - itemWidth: $item.outerWidth(), - itemHeight: $item.outerHeight(), - expandedWidth: $expanded.outerWidth(), - expandedHeight: $expanded.outerHeight() - }; - } - gutter = Math.round(parseFloat(this.$sampleItem.css('margin-right'))); - fullWidth = this.metrics.itemWidth + gutter; - fullHeight = this.metrics.itemHeight + gutter; - this.$el.css({ - width: 'auto', - height: 'auto' - }); - rowSize = parseInt((this.$el.outerWidth() + gutter) / fullWidth, 10); - colSize = Math.ceil(this.$items.length / rowSize); - $.extend(this.metrics, { - gutter: gutter, - rowSize: rowSize, - colSize: colSize - }, { - wrapWidth: fullWidth * rowSize, - wrapHeight: fullHeight * colSize - }); - }; - - return MediaGrid; - - })(); - hlf.createPlugin({ - name: 'mediaGrid', - namespace: hlf.mediaGrid, - apiClass: MediaGrid, - baseMixins: ['data', 'event', 'selection'], - compactOptions: true - }); - return true; - }); - -}).call(this); diff --git a/release/jquery.hlf.min.js b/release/jquery.hlf.min.js deleted file mode 100644 index 1ab4275..0000000 --- a/release/jquery.hlf.min.js +++ /dev/null @@ -1,2 +0,0 @@ -(function(){var a=[].slice,b={}.hasOwnProperty,c=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};!function(a,b){return"function"==typeof define&&null!=define.amd?define(["jquery","underscore"],b):"object"==typeof exports?module.exports=b(require("jquery",require("underscore"))):b(jQuery,_)}(this,function(d,e){"use strict";var f,g,h,i,j;return j={debug:!0,toString:e.constant("hlf"),noConflict:function(){var a;return function(){var b,c,d;for(d=[],b=0,c=h.length;c>b;b++)a=h[b],d.push(a());return d}().length}},j.debugLog=j.debug===!1?d.noop:console.log.bind?console.log.bind(console):console.log,h=[],e.extend(j,{createPlugin:function(b){var c,i,j,k,l,m,n,o,p,q,r;return o=b.name,r=""+this.toString()+o[0].toUpperCase()+o.slice(1),p=b.namespace,j=f(o,p),null!=b.apiClass&&(k=p.apiClass=b.apiClass,e.extend(k.prototype,j)),null!=b.apiMixins&&(n=b.mixinFilter,null==n&&(n=function(a){return a}),l=p.apiMixins=b.apiMixins,d.extend(m=!0,l,{base:j})),c=p.noConflict,i=d.fn[o],h.push(p.noConflict=function(){e.isFunction(c)&&c(),d.fn[o]=i}),q=d.fn[o]=d.fn[r]=function(){var c,f,h,i,j;return e.isString(arguments[0])?h={type:arguments[0],userInfo:arguments[1]}:(j=arguments[0],null!=arguments[1]&&(c=arguments[1])),null==c&&(c=d("body")),null!=h?(this.each(function(){var a,b,c;a=d(this),b=a.data(p.toString("data")),e.isFunction(b.handleCommand)&&(e.isFunction(h.userInfo)&&h.userInfo(a),c=null,b.handleCommand(h,c))}),this):(f=b.asSharedInstance===!0?c:this.first(),i=f.data(p.toString("data")),null!=i&&null!=i.$el&&null==j?i:(j=d.extend(m=!0,{},p.defaults,j),f=this,function(){var c;c=arguments,b.asSharedInstance===!0?g.apply(null,[f].concat(a.call(c))):f.each(function(){g.apply(null,[d(this)].concat(a.call(c)))})}(j,c,p,k,l,n,b),this))}}}),e.bindAll(j,"createPlugin"),g=function(b,c,f,g,h,i,k,l){var m,n,o,p,q,r;n=b.data(g.toString("data")),p=c,d.isPlainObject(n)?(p=d.extend(o=!0,{},c,n),m=b):m=l.asSharedInstance?f:b,null!=h?(q=new h(b,p,f),null!=l.baseMixins&&j.applyMixins.apply(j,[q,g].concat(a.call(l.baseMixins))),null!=l.apiMixins&&j.applyMixins.apply(j,[q,g].concat(a.call(l.apiMixins)))):null!=i&&(q={$el:b,options:p},null!=l.baseMixins&&j.applyMixins.apply(j,[q,g].concat(a.call(l.baseMixins))),j.applyMixin(q,g,i.base),r=e.chain(i).filter(k,q).values().without(i.base).value(),j.applyMixins.apply(j,[q,g].concat(a.call(r)))),l.compactOptions===!0?(d.extend(o=!0,q,p),delete q.options):(null!=p.selectors&&(q.selectors=p.selectors),null!=p.classNames&&(q.classNames=p.classNames)),l.autoSelect===!0&&e.isFunction(q.select)&&q.select(),q.cls!==d.noop&&m.addClass(q.cls()),e.isFunction(q.init)?q.init():null==h&&j.debugLog("ERROR: No `init` method on instance.",q),m.data(q.attr(),q)},f=function(b,c){return{evt:e.memoize(function(a){return e.contains(a," ")?a.split(" ").reduce(function(a){return function(b,c){return b+" "+a.evt(c)}}(this),""):""+a+c.toString("event")}),attr:e.memoize(function(a){return a=null!=a?"-"+a:"",c.toString("data")+a}),cls:c.toString("class")===c.toString()?d.noop:e.memoize(function(a){return a=null!=a?"-"+a:"",c.toString("class")+a}),debugLog:c.debug===!1?d.noop:function(){j.debugLog.apply(j,[c.toString("log")].concat(a.call(arguments)))}}},j._createPluginAPIAdditions=f,e.extend(j,{applyMixin:function(d,f,g){var h,i,j,k,l,m,n,o;if(e.isString(g)&&(g=this.mixins[g]),e.isFunction(g)&&(g=g(f)),null!=g){n=[],h=[];for(m in g)b.call(g,m)&&(o=g[m],e.isFunction(o)&&(c.call(this.mixinOnceNames,m)>=0&&n.push(o),0===m.indexOf("handle")&&"handleCommand"!==m&&h.push(m)));for(l=e.omit(g,this.mixinOnceNames),e.extend(d,l),i=0,j=n.length;j>i;i++)k=n[i],k.call(d);h.length&&e.bindAll.apply(e,[d].concat(a.call(h)))}},applyMixins:function(){var b,c,d,e,f,g;for(b=arguments[0],c=arguments[1],g=3<=arguments.length?a.call(arguments,2):[],d=0,e=g.length;e>d;d++)f=g[d],this.applyMixin(b,c,f)},createMixin:function(a,c,f){var g,h;if(null==a&&(a=j.mixins),c in a)return!1;if(a[c]=f,d.isPlainObject(f))for(g in f)b.call(f,g)&&(h=f[g],e.isFunction(h)&&(h.mixin=c));return f},mixinOnceNames:["decorate","decorateOptions"],mixins:{data:function(){return{data:function(){var a,c,d,f;if(arguments.length)if(a=arguments[0],e.isString(a))arguments[0]=this.attr(a);else if(e.isObject(a)){d={};for(c in a)b.call(a,c)&&(f=a[c],d[this.attr(c)]=f);arguments[0]=d}return this.$el.data.apply(this.$el,arguments)}}},event:function(){return{evtMap:function(a){var c,d,e;e={};for(d in a)b.call(a,d)&&(c=a[d],e[this.evt(d)]=c);return e},on:function(a){arguments[0]=e.isString(a)?this.evt(a):this.evtMap(a),this.$el.on.apply(this.$el,arguments)},off:function(a){arguments[0]=e.isString(a)?this.evt(a):this.evtMap(a),this.$el.off.apply(this.$el,arguments)},trigger:function(a,b){this.$el.trigger({type:this.evt(a),userInfo:b})}}},selection:function(){return{select:function(){var a,c,d,e;c=this.selectors;for(a in c)b.call(c,a)&&(e=c[a],null!=(d=this.$el.find(e))&&(this["$"+a]=d))},selectByClass:function(a){var b,c;return b=null!=(c=this.options)?c.classNames:void 0,null==b&&(b=this.classNames),this.$el.find("."+this.classNames[a])}}}}}),i=function(a,b,c){var e;null==b&&(b=d),null==c&&(c=j),e=b[a],b[a]=c[a],h.push(function(){b[a]=e})},i("applyMixin"),i("applyMixins"),i("createMixin"),i("createPlugin"),i("mixinOnceNames"),i("mixins"),d.hlf=j})}).call(this),function(){var a=[].slice,b={}.hasOwnProperty;!function(a,b){return"function"==typeof define&&null!=define.amd?define(["jquery","underscore","hlf/jquery.extension.hlf.core"],b):"object"==typeof exports?module.exports=b(require("jquery",require("underscore",require("hlf/jquery.extension.hlf.core")))):b(jQuery,_,jQuery.hlf)}(this,function(c,d,e){"use strict";return c.extend(!0,e,{hoverIntent:{debug:!1,mouse:{x:{current:0,previous:0},y:{current:0,previous:0}},sensitivity:8,interval:300,toString:d.memoize(function(a){switch(a){case"attr":return"hlf-hover-intent";default:return"hlf.hoverIntent"}})}}),function(f,g){var h,i,j,k,l,m,n,o,p,q;return h=function(a){return null==a&&(a=""),f.toString("attr")+"-"+a},j=f.debug===!1?c.noop:function(){e.debugLog.apply(e,[f.toString("log")].concat(a.call(arguments)))},k={intentional:!0,timer:{cleared:!0,timeout:null},sensitivity:f.sensitivity,interval:f.interval},l=function(a){var e,f,g;f={};for(e in k)b.call(k,e)&&(g=k[e],c.isPlainObject(g)&&(g=d.clone(g)),f[e]=a.data(h(e))||g);return f},i=function(a){var b,d,e;b=c(this),e=l(b),j(e),d=o(a,b,e),d===!1&&n(a,b,e)},n=function(a,b,c){return c.timer.cleared===!1&&null!=c.timer.timeout?!1:(j("setup"),c.timer.timeout=setTimeout(function(){return j("check and update"),m(a,b,c)},c.interval),c.timer.cleared=!1,b.data(h("timer"),c.timer),!0)},o=function(a,b,c){return"mouseleave"!==a.type?!1:(c.timer.cleared===!1&&(j("teardown"),clearTimeout(c.timer.timeout),b.removeData(h("timer")).removeData(h("intentional"))),q("truemouseleave",b,a),!0)},m=function(a,b,c){c.intentional=Math.abs(g.x.previous-g.x.current)+Math.abs(g.y.previous-g.y.current)>c.sensitivity,g.x.previous=a.pageX,g.y.previous=a.pageY,c.intentional===!0&&"mouseover"===a.type&&q("truemouseenter",b,a),c.timer.cleared=!0,b.data(h("intentional"),c.intentional),b.data(h("timer"),c.timer)},p=d.throttle(function(a){g.x.current=a.pageX,g.y.current=a.pageY},16),q=function(a,b,d){var e;e=new c.Event(a,{pageX:g.x.current,pageY:g.y.current,relatedTarget:d.relatedTarget}),j(a),b.trigger(e)},c.event.special.truemouseenter={setup:function(a,b){c(this).on({mouseover:i,mousemove:p},null!=a?a.selector:void 0)},teardown:function(a,b){c(this).off({mouseover:i,mousemove:p},null!=a?a.selector:void 0)}},c.event.special.truemouseleave={setup:function(a,b){c(this).on({mouseleave:i},null!=a?a.selector:void 0)},teardown:function(a,b){c(this).off({mouseleave:i},null!=a?a.selector:void 0)}}}(e.hoverIntent,e.hoverIntent.mouse)})}.call(this),function(){var a={}.hasOwnProperty,b=function(a,b){return function(){return a.apply(b,arguments)}},c=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};!function(a,b){"function"==typeof define&&null!=define.amd?define(["jquery","underscore","hlf/jquery.extension.hlf.core","hlf/jquery.extension.hlf.event"],b):"object"==typeof module&&null!=module.exports?module.exports=b(require("jquery",require("underscore",require("hlf/jquery.extension.hlf.core",require("hlf/jquery.extension.hlf.event"))))):b(jQuery,_,jQuery.hlf)}(this,function(d,e,f){"use strict";var g,h,i,j;return i=window.requireAnimationFrame||(null!=(j=window.Modernizr)?j.prefixed("requestAnimationFrame",window):void 0),f.tip={debug:!1,toString:e.memoize(function(a){switch(a){case"event":return".hlf.tip";case"data":return"hlf-tip";case"class":return"js-tips";default:return"hlf.tip"}}),defaults:function(a){var b;return{$viewport:d("body"),autoDirection:!0,cursorHeight:12,defaultDirection:["bottom","right"],fireEvents:!0,tipTemplate:function(a){var b;return this.doStem===!0&&(b="
"),'
\n
\n '+b+"\n
\n
\n
"},triggerContent:null,classNames:function(){var b,c,d,e,f;for(b={},e=["inner","content","stem","top","right","bottom","left","follow","trigger"],c=0,f=e.length;f>c;c++)d=e[c],b[d]=""+a+d;return b.tip="js-tip",b}(),animator:{show:function(a,b){return a.stop().fadeIn(b)},hide:function(a,b){return a.stop().fadeOut(b)}},animations:{base:{delay:0,duration:200,enabled:!0},show:{delay:200},hide:{delay:200},resize:{delay:300,easing:"ease-in-out"}},followUsingTransform:null!=(b=window.Modernizr)?b.csstransforms:void 0}}("js-tip-")},f.tip.snap={debug:!1,toString:e.memoize(function(a){switch(a){case"event":return".hlf.snap-tip";case"data":return"hlf-snap-tip";case"class":return"js-snap-tips";default:return"hlf.tip.snap"}}),defaults:function(b){var c;return d.extend(c=!0,{},f.tip.defaults,{snap:{toTrigger:!0,toXAxis:!1,toYAxis:!1},classNames:function(){var c,d,e,f;c={snap:{}},d={toXAxis:"x-side",toYAxis:"y-side",toTrigger:"trigger"};for(e in d)a.call(d,e)&&(f=d[e],c.snap[e]=""+b+f);return c.tip="js-tip js-snap-tip",c}()})}("js-snap-tip-")},h=function(){function c(c,d,f){var g,h,i;this.$triggers=c,this.$context=f,this._setTip=b(this._setTip,this),i=d.animations;for(h in i)a.call(i,h)&&(g=i[h],"base"!==h&&e.defaults(g,d.animations.base))}return c.prototype.init=function(){e.bindAll(this,"_onTriggerMouseMove","_setBounds"),this._setTip(d("
")),this.doStem=""!==this.classNames.stem,this.doFollow=""!==this.classNames.follow,this._setState("asleep"),this._wakeCountdown=null,this._sleepCountdown=null,this._$currentTrigger=null,this._render(),this._bind(),this._bindContext(),this._processTriggers(),this._bindTriggers()},c.prototype._defaultHtml=function(){var a,b,c;return b=d.trim(e.reduce(this.defaultDirection,function(a){return function(b,c){return b+" "+a.classNames[c]}}(this),"")),a=d.trim([this.classNames.tip,this.classNames.follow,b].join(" ")),c=this.tipTemplate(a)},c.prototype._isDirection=function(a,b){return this.$tip.hasClass(this.classNames[a])||(null==b||!b.data(this.attr("direction")))&&e.include(this.defaultDirection,a)},c.prototype._offsetForTrigger=function(a){return"fixed"===a.css("position")?a.offset():a.position()},c.prototype._setCurrentTrigger=function(a){return this._triggerChanged=!a.is(this._$currentTrigger),this._triggerChanged?(this._inflateByTrigger(a),void(this._$currentTrigger=a)):!1},c.prototype._setState=function(a,b){var c,f,g,h,i;if(a===this._state)return!1;switch(this._state=a,this.debugLog(this._state),a){case"asleep":this.fireEvents===!0&&null!=(f=this._$currentTrigger)&&f.trigger(this.evt("hidden")),this.afterHide(null!=b?b.event:void 0),e.defer(function(a){return function(){return a._togglePositionTransition(!1)}}(this));break;case"awake":this.fireEvents===!0&&null!=(g=this._$currentTrigger)&&g.trigger(this.evt("shown")),this.afterShow(null!=b?b.event:void 0),e.defer(function(a){return function(){return a._togglePositionTransition(!1)}}(this));break;case"sleeping":this.fireEvents===!0&&null!=(h=this._$currentTrigger)&&h.trigger(this.evt("hide")),clearTimeout(this._wakeCountdown),null!=(null!=b?b.event:void 0)&&d(b.event.target).hasClass(this.classNames.trigger)&&(c=!d(b.event.relatedTarget).hasClass(this.classNames.trigger),this._togglePositionTransition(c));break;case"waking":this.fireEvents===!0&&null!=(i=this._$currentTrigger)&&i.trigger(this.evt("show")),clearTimeout(this._sleepCountdown),this._triggerChanged=!0}},c.prototype._setTip=function(a){this.$tip=this.$el=a},c.prototype._sizeForTrigger=function(a,b){var c,d,e,f,g,h,i,j,k,l;return null==b&&(b=!1),j={width:a.data("width"),height:a.data("height")},c=this.selectByClass("content"),null!=j.width&&null!=j.height||(c.text(a.data(this.attr("content"))),(l=this._wrapStealthRender(function(){return a.data("width",j.width=this.$tip.outerWidth()),a.data("height",j.height=this.$tip.outerHeight())}))()),b===!0&&(f=c.css("padding").split(" "),g=function(){var a,b,c;for(c=[],a=0,b=f.length;b>a;a++)i=f[a],c.push(parseInt(i,10));return c}(),k=g[0],h=g[1],d=g[2],e=g[3],null==d&&(d=k),null==e&&(e=h),j.width-=e+h,j.height-=k+d),j},c.prototype._stemSize=function(){var a,b,c,d;return b=this.attr("stem-size"),c=this.$tip.data(b),null!=c?c:(a=this.selectByClass("stem"),(d=this._wrapStealthRender(function(d){return function(){return c=Math.abs(parseInt(a.css("margin").replace(/0px/g,""),10)),d.$tip.data(b,c),c}}(this)))())},c.prototype.wakeByTrigger=function(a,b){var c,f,g,h,i;return c=d.Deferred(),f=c.promise(),this._setCurrentTrigger(a),h=function(c){return function(){return c._positionToTrigger(a,b),c.onShow(b)}}(this),"awake"===this._state?(this.debugLog("quick update"),h(),c.resolve(),f):(null!=b&&this.debugLog(b.type),"awake"===(g=this._state)||"waking"===g?(c.reject(),f):(i=function(a){return function(d){var f;return h(),f=e.defaults({duration:d},a.animations.show),f.done=function(){return a._setState("awake",{event:b}),c.resolve()},f.fail=function(){return c.reject()},a.animator.show(a.$tip,f),a.$tip.siblings(a.classNames.tip).each(function(b,c){return f=e.defaults({duration:d},a.animation.hide),a.animator.hide($el,f)})}}(this),"sleeping"===this._state?(this.debugLog("clear sleep"),clearTimeout(this._sleepCountdown),i(0)):null!=b&&"truemouseenter"===b.type&&(this._setState("waking",{event:b}),this._wakeCountdown=setTimeout(i,this.animations.show.delay)),f))},c.prototype.sleepByTrigger=function(a,b){var c,f,g;return c=d.Deferred(),f=c.promise(),"asleep"===(g=this._state)||"sleeping"===g?(c.reject(),f):(this._setState("sleeping",{event:b}),this._sleepCountdown=setTimeout(function(a){return function(){var d;return a.onHide(),d=e.clone(a.animations.hide),d.done=function(){return a._setState("asleep",{event:b}),c.resolve()},d.fail=function(){return c.reject()},a.animator.hide(a.$tip,d)}}(this),this.animations.hide.delay),f)},c.prototype._togglePositionTransition=function(a){var b,c;b="0.1s linear",c=a?this.followUsingTransform?"transform "+b:"top "+b+", left "+b:"",this.$tip.css("transition",c)},c.prototype._saveTriggerContent=function(a){var b,c,d;d=null,b=null,c=!0,null!=this.triggerContent?e.isFunction(this.triggerContent)?d=this.triggerContent(a):b=this.triggerContent:a.is("[title]")?b="title":a.is("[alt]")&&(b="alt",c=!1),null!=b&&(d=a.attr(b),c&&a.removeAttr(b)),null!=d&&a.data(this.attr("content"),d)},c.prototype._bind=function(){this.$tip.on({mouseenter:function(a){return function(b){return a.debugLog("enter tip"),null!=a._$currentTrigger?(a._$currentTrigger.data(a.attr("is-active"),!0),a.wakeByTrigger(a._$currentTrigger,b)):void 0}}(this),mouseleave:function(a){return function(b){return a.debugLog("leave tip"),null!=a._$currentTrigger?(a._$currentTrigger.data(a.attr("is-active"),!1),a.sleepByTrigger(a._$currentTrigger,b)):void 0}}(this)}),this.autoDirection===!0&&d(window).resize(e.debounce(this._setBounds,300))},c.prototype._bindContext=function(){var a;return null==window.MutationObserver?!1:(a=this.$triggers.selector,this._mutationObserver=new MutationObserver(function(a){return function(b){var c,e,f,g,h,i;for(i=[],f=0,g=b.length;g>f;f++)h=b[f],c=d(h.target),c.hasClass(a.classNames.content)||(h.addedNodes.length?(e=d(h.addedNodes).find("[title],[alt]"),a._processTriggers(e),i.push(a.$triggers=a.$triggers.add(e))):i.push(void 0));return i}}(this)),void this._mutationObserver.observe(this.$context[0],{childList:!0,subtree:!0}))},c.prototype._bindTriggers=function(){var a,b;b="."+this.classNames.trigger,this.$context.on([this.evt("truemouseenter"),this.evt("truemouseleave")].join(" "),b,{selector:b},function(a){return function(b){switch(a.debugLog(b.type),b.type){case"truemouseenter":a._onTriggerMouseMove(b);break;case"truemouseleave":a.sleepByTrigger(d(b.target),b);break;default:a.debugLog("unknown event type",b.type)}return b.stopPropagation()}}(this)),this.doFollow===!0&&(a=null!=i?function(a){return function(b){return i(function(c){return a._onTriggerMouseMove(b)})}}(this):e.throttle(this._onTriggerMouseMove,16),this.$context.on("mousemove",b,a))},c.prototype._onTriggerMouseMove=function(a){var b;return null==a.pageX?!1:(b=(b=d(a.currentTarget))&&b.hasClass(this.classNames.trigger)?b:b.closest(this.classNames.trigger),b.length?void this.wakeByTrigger(b,a):!1)},c.prototype._positionToTrigger=function(a,b,c){var d,e,f,g;return null==c&&(c=this.cursorHeight),null==b?!1:(e={top:b.pageY,left:b.pageX},e=this.offsetOnTriggerMouseMove(b,e,a)||e,this._isDirection("top",a)?e.top-=this.$tip.outerHeight()+this._stemSize():this._isDirection("bottom",a)&&(e.top+=this._stemSize()+c),this._isDirection("left",a)&&(f=this.$tip.outerWidth(),g=a.outerWidth(),e.left-=f,f>g&&(e.left+=g)),d=this.followUsingTransform?{top:0,left:0,transform:"translate("+e.left+"px, "+e.top+"px)"}:e,void this.$tip.css(d))},c.prototype._setBounds=function(){var a;a=this.$viewport.is("body")?d(window):this.$viewport,this._bounds={top:d.css(this.$viewport[0],"padding-top",!0),left:d.css(this.$viewport[0],"padding-left",!0),bottom:a.innerHeight(),right:a.innerWidth()}},c.prototype._inflateByTrigger=function(a){var b,c,f,g;b=this.selectByClass("content"),b.text(a.data(this.attr("content"))),this.animations.resize.enabled&&(g=this._sizeForTrigger(a,f=!0),b.width(g.width+1).height(g.height)),c=a.data(this.attr("direction"))?a.data(this.attr("direction")).split(" "):this.defaultDirection,this.debugLog("update direction class",c),this.$tip.removeClass(e.chain(this.classNames).pick("top","bottom","right","left").values().join(" ").value()).addClass(d.trim(e.reduce(c,function(a){return function(b,c){return b+" "+a.classNames[c]}}(this),"")))},c.prototype._render=function(){var a,b,c,e,f;return this.$tip.html().length?!1:(e=this.htmlOnRender(),null!=e&&e.length||(e=this._defaultHtml()),a=d(e).addClass(this.classNames.follow),f=[],this.animations.resize.enabled&&(b=this.animations.resize.duration/1e3+"s",c=this.animations.resize.easing,f.push("width "+b+" "+c,"height "+b+" "+c)),this._setTip(a),this.selectByClass("content").css("transition",f.join(",")),void this.$tip.prependTo(this.$viewport))},c.prototype._processTriggers=function(a){null==a&&(a=this.$triggers),a.each(function(a){return function(b,c){var e;return e=d(c),e.length?(e.addClass(a.classNames.trigger),a._saveTriggerContent(e),a._updateDirectionByTrigger(e)):!1}}(this))},c.prototype._updateDirectionByTrigger=function(a){var b,c,d,f,g,h,i,j,k,l,m;if(this.autoDirection===!1)return!1;for(l=this._offsetForTrigger(a),m=a.outerWidth(),k=a.outerHeight(),j=this._sizeForTrigger(a),g=e.clone(this.defaultDirection),this.debugLog({triggerOffset:l,triggerWidth:m,triggerHeight:k,tipSize:j}),i=this.defaultDirection,d=0,f=i.length;f>d;d++){switch(b=i[d],null==this._bounds&&this._setBounds(),h=!0,b){case"bottom":h=(c=l.top+k+j.height)&&this._bounds.bottom>c;break;case"right":h=(c=l.left+j.width)&&this._bounds.right>c;break;case"top":h=(c=l.top-j.height)&&this._bounds.top
"; - } - return "
\n
\n " + stemHtml + "\n
\n
\n
"; - }, - triggerContent: null, - classNames: (function() { - var classNames, j, key, keys, len; - classNames = {}; - keys = ['inner', 'content', 'stem', 'top', 'right', 'bottom', 'left', 'follow', 'trigger']; - for (j = 0, len = keys.length; j < len; j++) { - key = keys[j]; - classNames[key] = "" + pre + key; - } - classNames.tip = 'js-tip'; - return classNames; - })(), - animator: { - show: function($el, options) { - return $el.stop().fadeIn(options); - }, - hide: function($el, options) { - return $el.stop().fadeOut(options); - } - }, - animations: { - base: { - delay: 0, - duration: 200, - enabled: true - }, - show: { - delay: 200 - }, - hide: { - delay: 200 - }, - resize: { - delay: 300, - easing: 'ease-in-out' - } - }, - followUsingTransform: (ref1 = window.Modernizr) != null ? ref1.csstransforms : void 0 - }; - })('js-tip-') - }; - hlf.tip.snap = { - debug: false, - toString: _.memoize(function(context) { - switch (context) { - case 'event': - return '.hlf.snap-tip'; - case 'data': - return 'hlf-snap-tip'; - case 'class': - return 'js-snap-tips'; - default: - return 'hlf.tip.snap'; - } - }), - defaults: (function(pre) { - var deep; - return $.extend((deep = true), {}, hlf.tip.defaults, { - snap: { - toTrigger: true, - toXAxis: false, - toYAxis: false - }, - classNames: (function() { - var classNames, dictionary, key, value; - classNames = { - snap: {} - }; - dictionary = { - toXAxis: 'x-side', - toYAxis: 'y-side', - toTrigger: 'trigger' - }; - for (key in dictionary) { - if (!hasProp.call(dictionary, key)) continue; - value = dictionary[key]; - classNames.snap[key] = "" + pre + value; - } - classNames.tip = 'js-tip js-snap-tip'; - return classNames; - })() - }); - })('js-snap-tip-') - }; - Tip = (function() { - function Tip($triggers1, options, $context) { - var animation, name, ref1; - this.$triggers = $triggers1; - this.$context = $context; - this._setTip = bind(this._setTip, this); - ref1 = options.animations; - for (name in ref1) { - if (!hasProp.call(ref1, name)) continue; - animation = ref1[name]; - if (name !== 'base') { - _.defaults(animation, options.animations.base); - } - } - } - - Tip.prototype.init = function() { - _.bindAll(this, '_onTriggerMouseMove', '_setBounds'); - this._setTip($('
')); - this.doStem = this.classNames.stem !== ''; - this.doFollow = this.classNames.follow !== ''; - this._setState('asleep'); - this._wakeCountdown = null; - this._sleepCountdown = null; - this._$currentTrigger = null; - this._render(); - this._bind(); - this._bindContext(); - this._processTriggers(); - this._bindTriggers(); - }; - - Tip.prototype._defaultHtml = function() { - var containerClass, directionClass, html; - directionClass = $.trim(_.reduce(this.defaultDirection, (function(_this) { - return function(classListMemo, directionComponent) { - return classListMemo + " " + _this.classNames[directionComponent]; - }; - })(this), '')); - containerClass = $.trim([this.classNames.tip, this.classNames.follow, directionClass].join(' ')); - return html = this.tipTemplate(containerClass); - }; - - Tip.prototype._isDirection = function(directionComponent, $trigger) { - return this.$tip.hasClass(this.classNames[directionComponent]) || ((($trigger == null) || !$trigger.data(this.attr('direction'))) && _.include(this.defaultDirection, directionComponent)); - }; - - Tip.prototype._offsetForTrigger = function($trigger) { - if ($trigger.css('position') === 'fixed') { - return $trigger.offset(); - } else { - return $trigger.position(); - } - }; - - Tip.prototype._setCurrentTrigger = function($trigger) { - this._triggerChanged = !$trigger.is(this._$currentTrigger); - if (!this._triggerChanged) { - return false; - } - this._inflateByTrigger($trigger); - this._$currentTrigger = $trigger; - }; - - Tip.prototype._setState = function(state, data) { - var isLeavingToContext, ref1, ref2, ref3, ref4; - if (state === this._state) { - return false; - } - this._state = state; - this.debugLog(this._state); - switch (state) { - case 'asleep': - if (this.fireEvents === true) { - if ((ref1 = this._$currentTrigger) != null) { - ref1.trigger(this.evt('hidden')); - } - } - this.afterHide(data != null ? data.event : void 0); - _.defer((function(_this) { - return function() { - return _this._togglePositionTransition(false); - }; - })(this)); - break; - case 'awake': - if (this.fireEvents === true) { - if ((ref2 = this._$currentTrigger) != null) { - ref2.trigger(this.evt('shown')); - } - } - this.afterShow(data != null ? data.event : void 0); - _.defer((function(_this) { - return function() { - return _this._togglePositionTransition(false); - }; - })(this)); - break; - case 'sleeping': - if (this.fireEvents === true) { - if ((ref3 = this._$currentTrigger) != null) { - ref3.trigger(this.evt('hide')); - } - } - clearTimeout(this._wakeCountdown); - if (((data != null ? data.event : void 0) != null) && $(data.event.target).hasClass(this.classNames.trigger)) { - isLeavingToContext = !$(data.event.relatedTarget).hasClass(this.classNames.trigger); - this._togglePositionTransition(isLeavingToContext); - } - break; - case 'waking': - if (this.fireEvents === true) { - if ((ref4 = this._$currentTrigger) != null) { - ref4.trigger(this.evt('show')); - } - } - clearTimeout(this._sleepCountdown); - this._triggerChanged = true; - } - }; - - Tip.prototype._setTip = function($tip) { - this.$tip = this.$el = $tip; - }; - - Tip.prototype._sizeForTrigger = function($trigger, contentOnly) { - var $content, bottom, left, padding, ref1, right, side, size, top, wrapped; - if (contentOnly == null) { - contentOnly = false; - } - size = { - width: $trigger.data('width'), - height: $trigger.data('height') - }; - $content = this.selectByClass('content'); - if (!((size.width != null) && (size.height != null))) { - $content.text($trigger.data(this.attr('content'))); - wrapped = this._wrapStealthRender(function() { - $trigger.data('width', (size.width = this.$tip.outerWidth())); - return $trigger.data('height', (size.height = this.$tip.outerHeight())); - }); - wrapped(); - } - if (contentOnly === true) { - padding = $content.css('padding').split(' '); - ref1 = (function() { - var j, len, results; - results = []; - for (j = 0, len = padding.length; j < len; j++) { - side = padding[j]; - results.push(parseInt(side, 10)); - } - return results; - })(), top = ref1[0], right = ref1[1], bottom = ref1[2], left = ref1[3]; - if (bottom == null) { - bottom = top; - } - if (left == null) { - left = right; - } - size.width -= left + right; - size.height -= top + bottom; - } - return size; - }; - - Tip.prototype._stemSize = function() { - var $stem, key, size, wrapped; - key = this.attr('stem-size'); - size = this.$tip.data(key); - if (size != null) { - return size; - } - $stem = this.selectByClass('stem'); - wrapped = this._wrapStealthRender((function(_this) { - return function() { - size = Math.abs(parseInt($stem.css('margin').replace(/0px/g, ''), 10)); - _this.$tip.data(key, size); - return size; - }; - })(this)); - return wrapped(); - }; - - Tip.prototype.wakeByTrigger = function($trigger, event) { - var deferred, promise, ref1, updateBeforeWake, wake; - deferred = $.Deferred(); - promise = deferred.promise(); - this._setCurrentTrigger($trigger); - updateBeforeWake = (function(_this) { - return function() { - _this._positionToTrigger($trigger, event); - return _this.onShow(event); - }; - })(this); - if (this._state === 'awake') { - this.debugLog('quick update'); - updateBeforeWake(); - deferred.resolve(); - return promise; - } - if (event != null) { - this.debugLog(event.type); - } - if ((ref1 = this._state) === 'awake' || ref1 === 'waking') { - deferred.reject(); - return promise; - } - wake = (function(_this) { - return function(duration) { - var options; - updateBeforeWake(); - options = _.defaults({ - duration: duration - }, _this.animations.show); - options.done = function() { - _this._setState('awake', { - event: event - }); - return deferred.resolve(); - }; - options.fail = function() { - return deferred.reject(); - }; - _this.animator.show(_this.$tip, options); - return _this.$tip.siblings(_this.classNames.tip).each(function(idx, el) { - options = _.defaults({ - duration: duration - }, _this.animation.hide); - return _this.animator.hide($el, options); - }); - }; - })(this); - if (this._state === 'sleeping') { - this.debugLog('clear sleep'); - clearTimeout(this._sleepCountdown); - wake(0); - } else if ((event != null) && event.type === 'truemouseenter') { - this._setState('waking', { - event: event - }); - this._wakeCountdown = setTimeout(wake, this.animations.show.delay); - } - return promise; - }; - - Tip.prototype.sleepByTrigger = function($trigger, event) { - var deferred, promise, ref1; - deferred = $.Deferred(); - promise = deferred.promise(); - if ((ref1 = this._state) === 'asleep' || ref1 === 'sleeping') { - deferred.reject(); - return promise; - } - this._setState('sleeping', { - event: event - }); - this._sleepCountdown = setTimeout((function(_this) { - return function() { - var options; - _this.onHide(); - options = _.clone(_this.animations.hide); - options.done = function() { - _this._setState('asleep', { - event: event - }); - return deferred.resolve(); - }; - options.fail = function() { - return deferred.reject(); - }; - return _this.animator.hide(_this.$tip, options); - }; - })(this), this.animations.hide.delay); - return promise; - }; - - Tip.prototype._togglePositionTransition = function(toggled) { - var rest, transition; - rest = '0.1s linear'; - transition = toggled ? (this.followUsingTransform ? "transform " + rest : "top " + rest + ", left " + rest) : ''; - this.$tip.css('transition', transition); - }; - - Tip.prototype._saveTriggerContent = function($trigger) { - var attr, canRemoveAttr, content; - content = null; - attr = null; - canRemoveAttr = true; - if (this.triggerContent != null) { - if (_.isFunction(this.triggerContent)) { - content = this.triggerContent($trigger); - } else { - attr = this.triggerContent; - } - } else { - if ($trigger.is('[title]')) { - attr = 'title'; - } else if ($trigger.is('[alt]')) { - attr = 'alt'; - canRemoveAttr = false; - } - } - if (attr != null) { - content = $trigger.attr(attr); - if (canRemoveAttr) { - $trigger.removeAttr(attr); - } - } - if (content != null) { - $trigger.data(this.attr('content'), content); - } - }; - - Tip.prototype._bind = function() { - this.$tip.on({ - mouseenter: (function(_this) { - return function(event) { - _this.debugLog('enter tip'); - if (_this._$currentTrigger != null) { - _this._$currentTrigger.data(_this.attr('is-active'), true); - return _this.wakeByTrigger(_this._$currentTrigger, event); - } - }; - })(this), - mouseleave: (function(_this) { - return function(event) { - _this.debugLog('leave tip'); - if (_this._$currentTrigger != null) { - _this._$currentTrigger.data(_this.attr('is-active'), false); - return _this.sleepByTrigger(_this._$currentTrigger, event); - } - }; - })(this) - }); - if (this.autoDirection === true) { - $(window).resize(_.debounce(this._setBounds, 300)); - } - }; - - Tip.prototype._bindContext = function() { - var selector; - if (window.MutationObserver == null) { - return false; - } - selector = this.$triggers.selector; - this._mutationObserver = new MutationObserver((function(_this) { - return function(mutations) { - var $target, $triggers, j, len, mutation, results; - results = []; - for (j = 0, len = mutations.length; j < len; j++) { - mutation = mutations[j]; - $target = $(mutation.target); - if ($target.hasClass(_this.classNames.content)) { - continue; - } - if (mutation.addedNodes.length) { - $triggers = $(mutation.addedNodes).find('[title],[alt]'); - _this._processTriggers($triggers); - results.push(_this.$triggers = _this.$triggers.add($triggers)); - } else { - results.push(void 0); - } - } - return results; - }; - })(this)); - this._mutationObserver.observe(this.$context[0], { - childList: true, - subtree: true - }); - }; - - Tip.prototype._bindTriggers = function() { - var onMouseMove, selector; - selector = "." + this.classNames.trigger; - this.$context.on([this.evt('truemouseenter'), this.evt('truemouseleave')].join(' '), selector, { - selector: selector - }, (function(_this) { - return function(event) { - _this.debugLog(event.type); - switch (event.type) { - case 'truemouseenter': - _this._onTriggerMouseMove(event); - break; - case 'truemouseleave': - _this.sleepByTrigger($(event.target), event); - break; - default: - _this.debugLog('unknown event type', event.type); - } - return event.stopPropagation(); - }; - })(this)); - if (this.doFollow === true) { - if (_requestAnimationFrame != null) { - onMouseMove = (function(_this) { - return function(event) { - return _requestAnimationFrame(function(timestamp) { - return _this._onTriggerMouseMove(event); - }); - }; - })(this); - } else { - onMouseMove = _.throttle(this._onTriggerMouseMove, 16); - } - this.$context.on('mousemove', selector, onMouseMove); - } - }; - - Tip.prototype._onTriggerMouseMove = function(event) { - var $trigger; - if (event.pageX == null) { - return false; - } - $trigger = ($trigger = $(event.currentTarget)) && $trigger.hasClass(this.classNames.trigger) ? $trigger : $trigger.closest(this.classNames.trigger); - if (!$trigger.length) { - return false; - } - this.wakeByTrigger($trigger, event); - }; - - Tip.prototype._positionToTrigger = function($trigger, mouseEvent, cursorHeight) { - var css, offset, tipWidth, triggerWidth; - if (cursorHeight == null) { - cursorHeight = this.cursorHeight; - } - if (mouseEvent == null) { - return false; - } - offset = { - top: mouseEvent.pageY, - left: mouseEvent.pageX - }; - offset = this.offsetOnTriggerMouseMove(mouseEvent, offset, $trigger) || offset; - if (this._isDirection('top', $trigger)) { - offset.top -= this.$tip.outerHeight() + this._stemSize(); - } else if (this._isDirection('bottom', $trigger)) { - offset.top += this._stemSize() + cursorHeight; - } - if (this._isDirection('left', $trigger)) { - tipWidth = this.$tip.outerWidth(); - triggerWidth = $trigger.outerWidth(); - offset.left -= tipWidth; - if (tipWidth > triggerWidth) { - offset.left += triggerWidth; - } - } - css = this.followUsingTransform ? { - top: 0, - left: 0, - transform: "translate(" + offset.left + "px, " + offset.top + "px)" - } : offset; - this.$tip.css(css); - }; - - Tip.prototype._setBounds = function() { - var $viewport; - $viewport = this.$viewport.is('body') ? $(window) : this.$viewport; - this._bounds = { - top: $.css(this.$viewport[0], 'padding-top', true), - left: $.css(this.$viewport[0], 'padding-left', true), - bottom: $viewport.innerHeight(), - right: $viewport.innerWidth() - }; - }; - - Tip.prototype._inflateByTrigger = function($trigger) { - var $content, compoundDirection, contentOnly, contentSize; - $content = this.selectByClass('content'); - $content.text($trigger.data(this.attr('content'))); - if (this.animations.resize.enabled) { - contentSize = this._sizeForTrigger($trigger, (contentOnly = true)); - $content.width(contentSize.width + 1).height(contentSize.height); - } - compoundDirection = $trigger.data(this.attr('direction')) ? $trigger.data(this.attr('direction')).split(' ') : this.defaultDirection; - this.debugLog('update direction class', compoundDirection); - this.$tip.removeClass(_.chain(this.classNames).pick('top', 'bottom', 'right', 'left').values().join(' ').value()).addClass($.trim(_.reduce(compoundDirection, (function(_this) { - return function(classListMemo, directionComponent) { - return classListMemo + " " + _this.classNames[directionComponent]; - }; - })(this), ''))); - }; - - Tip.prototype._render = function() { - var $tip, duration, easing, html, transitionStyle; - if (this.$tip.html().length) { - return false; - } - html = this.htmlOnRender(); - if (!((html != null) && html.length)) { - html = this._defaultHtml(); - } - $tip = $(html).addClass(this.classNames.follow); - transitionStyle = []; - if (this.animations.resize.enabled) { - duration = this.animations.resize.duration / 1000.0 + 's'; - easing = this.animations.resize.easing; - transitionStyle.push("width " + duration + " " + easing, "height " + duration + " " + easing); - } - this._setTip($tip); - this.selectByClass('content').css('transition', transitionStyle.join(',')); - this.$tip.prependTo(this.$viewport); - }; - - Tip.prototype._processTriggers = function($triggers) { - if ($triggers == null) { - $triggers = this.$triggers; - } - $triggers.each((function(_this) { - return function(i, el) { - var $trigger; - $trigger = $(el); - if (!$trigger.length) { - return false; - } - $trigger.addClass(_this.classNames.trigger); - _this._saveTriggerContent($trigger); - return _this._updateDirectionByTrigger($trigger); - }; - })(this)); - }; - - Tip.prototype._updateDirectionByTrigger = function($trigger) { - var component, edge, j, len, newDirection, ok, ref1, tipSize, triggerHeight, triggerOffset, triggerWidth; - if (this.autoDirection === false) { - return false; - } - triggerOffset = this._offsetForTrigger($trigger); - triggerWidth = $trigger.outerWidth(); - triggerHeight = $trigger.outerHeight(); - tipSize = this._sizeForTrigger($trigger); - newDirection = _.clone(this.defaultDirection); - this.debugLog({ - triggerOffset: triggerOffset, - triggerWidth: triggerWidth, - triggerHeight: triggerHeight, - tipSize: tipSize - }); - ref1 = this.defaultDirection; - for (j = 0, len = ref1.length; j < len; j++) { - component = ref1[j]; - if (this._bounds == null) { - this._setBounds(); - } - ok = true; - switch (component) { - case 'bottom': - ok = (edge = triggerOffset.top + triggerHeight + tipSize.height) && this._bounds.bottom > edge; - break; - case 'right': - ok = (edge = triggerOffset.left + tipSize.width) && this._bounds.right > edge; - break; - case 'top': - ok = (edge = triggerOffset.top - tipSize.height) && this._bounds.top < edge; - break; - case 'left': - ok = (edge = triggerOffset.left - tipSize.width) && this._bounds.left < edge; - } - this.debugLog('checkDirectionComponent', { - component: component, - edge: edge - }); - if (!ok) { - switch (component) { - case 'bottom': - newDirection[0] = 'top'; - break; - case 'right': - newDirection[1] = 'left'; - break; - case 'top': - newDirection[0] = 'bottom'; - break; - case 'left': - newDirection[1] = 'right'; - } - $trigger.data(this.attr('direction'), newDirection.join(' ')); - } - } - }; - - Tip.prototype._wrapStealthRender = function(func) { - return (function(_this) { - return function() { - var result; - if (!_this.$tip.is(':hidden')) { - return func.apply(_this, arguments); - } - _this.$tip.css({ - display: 'block', - visibility: 'hidden' - }); - result = func.apply(_this, arguments); - _this.$tip.css({ - display: 'none', - visibility: 'visible' - }); - return result; - }; - })(this); - }; - - Tip.prototype.onShow = function(event) {}; - - Tip.prototype.onHide = $.noop; - - Tip.prototype.afterShow = function(event) {}; - - Tip.prototype.afterHide = $.noop; - - Tip.prototype.htmlOnRender = $.noop; - - Tip.prototype.offsetOnTriggerMouseMove = function(event, offset, $trigger) { - return false; - }; - - return Tip; - - })(); - SnapTip = (function(superClass) { - extend(SnapTip, superClass); - - function SnapTip() { - return SnapTip.__super__.constructor.apply(this, arguments); - } - - SnapTip.prototype.init = function() { - var active, key, ref1; - SnapTip.__super__.init.call(this); - if (this.snap.toTrigger === false) { - this.snap.toTrigger = this.snap.toXAxis === true || this.snap.toYAxis === true; - } - this._offsetStart = null; - ref1 = this.snap; - for (key in ref1) { - if (!hasProp.call(ref1, key)) continue; - active = ref1[key]; - if (active) { - this.$tip.addClass(this.classNames.snap[key]); - } - } - }; - - SnapTip.prototype._bindTriggers = function() { - var selector; - SnapTip.__super__._bindTriggers.call(this); - selector = "." + this.classNames.trigger; - this.$context.on(this.evt('truemouseleave'), selector, { - selector: selector - }, (function(_this) { - return function(event) { - return _this._offsetStart = null; - }; - })(this)); - }; - - SnapTip.prototype._moveToTrigger = function($trigger, baseOffset) { - var offset, toTriggerOnly; - offset = this._offsetForTrigger($trigger); - toTriggerOnly = this.snap.toTrigger === true && this.snap.toXAxis === false && this.snap.toYAxis === false; - if (this.snap.toXAxis === true) { - if (this._isDirection('bottom', $trigger)) { - offset.top += $trigger.outerHeight(); - } - if (this.snap.toYAxis === false) { - offset.left = baseOffset.left - this.$tip.outerWidth() / 2; - } - } - if (this.snap.toYAxis === true) { - if (this._isDirection('right', $trigger)) { - offset.left += $trigger.outerWidth() + this._stemSize(); - } else if (this._isDirection('left', $trigger)) { - offset.left -= this._stemSize(); - } - if (this.snap.toXAxis === false) { - offset.top = baseOffset.top - this.$tip.outerHeight() / 2 - this._stemSize(); - } - } - if (toTriggerOnly === true) { - if (this._isDirection('bottom', $trigger)) { - offset.top += $trigger.outerHeight(); - } - } - return offset; - }; - - SnapTip.prototype._positionToTrigger = function($trigger, mouseEvent, cursorHeight) { - if (cursorHeight == null) { - cursorHeight = this.cursorHeight; - } - SnapTip.__super__._positionToTrigger.call(this, $trigger, mouseEvent, 0); - }; - - SnapTip.prototype.onShow = function(event) { - if (this._triggerChanged !== true) { - return; - } - this.$tip.css('visibility', 'hidden'); - }; - - SnapTip.prototype.afterShow = function(event) { - if (this._triggerChanged !== true) { - return; - } - this.$tip.css('visibility', 'visible'); - this._offsetStart = { - top: event.pageY, - left: event.pageX - }; - }; - - SnapTip.prototype.offsetOnTriggerMouseMove = function(event, offset, $trigger) { - var newOffset; - return newOffset = this._moveToTrigger($trigger, _.clone(offset)); - }; - - return SnapTip; - - })(Tip); - hlf.createPlugin({ - name: 'tip', - namespace: hlf.tip, - apiClass: Tip, - asSharedInstance: true, - baseMixins: ['selection'], - compactOptions: true - }); - hlf.createPlugin({ - name: 'snapTip', - namespace: hlf.tip.snap, - apiClass: SnapTip, - asSharedInstance: true, - baseMixins: ['selection'], - compactOptions: true - }); - return true; - }); - -}).call(this); diff --git a/release/media-grid.css b/release/media-grid.css deleted file mode 100644 index b392f8f..0000000 --- a/release/media-grid.css +++ /dev/null @@ -1,176 +0,0 @@ -/* -HLF Media Grid Extension -======================== -[Source](../js/jquery.hlf.media-grid.html) | [Tests](../../tests/css/media-grid.html) - -The required extension styling is crucial to extension usage. There's an -optional, opinionated set of styles in `mg-item-extras`. -*/ - -/* -clearfix -*/ -.mg-item-extras .js-mg-item.js-mg-expanded hgroup::after, -.js-mg::after { - clear: both; - content: ''; -} - -/* -`js-mg` is modified with the `-dimmed` and `-ready` classes. Note it sets -`box-sizing: border-box` for itself and its descendants. -*/ -.js-mg { - --mg-fade-duration: 0.3s; - --mg-gutter-size: 6px; - --mg-fill-color: #333; - --mg-item-expanded-scale: 2; - --mg-item-fill-color: #000; - --mg-item-height: 232px; - --mg-item-stroke-color: #fff; - --mg-item-transition: 0.4s cubic-bezier(0.8, 0, 0.2, 1); - --mg-item-width: 212px; - - background: var(--mg-fill-color); - margin-left: var(--mg-gutter-size); - margin-top: var(--mg-gutter-size); - opacity: 0; - position: relative; - transition: opacity var(--mg-fade-duration) ease-in-out; -} -.js-mg *, -.js-mg { - box-sizing: border-box; -} -.js-mg.js-mg-ready { - opacity: 1; -} - -/* -`js-mg-item` can be modified with the `-expanded`, `-focused`, `-transitioning` -classes. Note the initial `float` positioning, as well as the complex `z-index` -rules when the item has modifier classes. - -Its element's DOM can look like (especially if using `mg-item-extras`): -```html -
-
- -
-

...

-

...

-
-
    -
  • ...
  • -
  • ...
  • -
-
-
- -
-

...

-

...

-
-

...

-
    -
  • ...
  • -
  • ...
  • -
-
-
-``` -*/ -.js-mg-item { - background: var(--mg-item-fill-color); - color: var(--mg-item-stroke-color); - float: left; /* Original positioning; will be replaced by position-absolute. */ - height: var(--mg-item-height); - margin-bottom: var(--mg-gutter-size); - margin-right: var(--mg-gutter-size); - overflow: hidden; - padding: var(--mg-gutter-size); - transition: - height var(--mg-item-transition), - left var(--mg-item-transition), - top var(--mg-item-transition), - width var(--mg-item-transition), - opacity var(--mg-fade-duration) ease-in-out; - width: var(--mg-item-width); -} -.js-mg-item >.mg-preview, -.js-mg-item >.mg-detail { - overflow: hidden; -} -.js-mg-item.js-mg-expanded >.mg-detail, -.js-mg-item >.mg-preview { - display: block; - height: auto; - opacity: 1; - width: auto; -} -.js-mg-item.js-mg-expanded >.mg-preview, -.js-mg-item >.mg-detail { - display: none; - height: 0; - opacity: 0; - width: 0; -} -.js-mg-item:not(.js-mg-expanded):not(.js-mg-transitioning):hover { - background: var(--mg-item-stroke-color); - color: var(--mg-item-fill-color); -} -.js-mg-item.js-mg-transitioning, -.js-mg-item.js-mg-expanded { - z-index: 10; -} -.js-mg-item.js-mg-transitioning.js-mg-focused, -.js-mg-item.js-mg-expanded.js-mg-focused { - z-index: 11; -} -.js-mg-item.js-mg-expanded { - height: calc(var(--mg-item-height) * var(--mg-item-expanded-scale) + var(--mg-gutter-size)); - width: calc(var(--mg-item-width) * var(--mg-item-expanded-scale) + var(--mg-gutter-size)); -} -.js-mg-dimmed > .js-mg-item:not(.js-mg-expanded):not(.js-mg-transitioning) { - opacity: 0.3; -} - -.mg-item-extras { - --mg-item-corner-radius: 4px; - --mg-item-font-size: 10px; -} -.mg-item-extras .js-mg-item { - border-radius: var(--mg-item-corner-radius); - font-family: Helvetica, sans-serif; - font-size: var(--mg-item-font-size); - line-height: 2em; -} -.mg-item-extras .js-mg-item p { - line-height: 1.6em; -} -.mg-item-extras .js-mg-item .mg-date { - font-size: var(--mg-item-font-size); - margin: 0; - padding: 0; -} -.mg-item-extras .js-mg-item.js-mg-expanded hgroup > .mg-date { - float: right; -} -.mg-item-extras .js-mg-item .mg-tags { - list-style: none; - padding-left: 0; -} -.mg-item-extras .mg-tags li { - display: inline; -} -.mg-item-extras .mg-tags li:not(:last-child)::after { - content: ',\0020'; -} -.mg-item-extras .js-mg-item .mg-title { - font-size: 14px; - margin: 0; - padding: 0; -} -.mg-item-extras .js-mg-item.js-mg-expanded hgroup > .mg-title { - float: left; -} diff --git a/release/tip.css b/release/tip.css deleted file mode 100644 index aca5eef..0000000 --- a/release/tip.css +++ /dev/null @@ -1,128 +0,0 @@ -/* -HLF Tip Extension -================= -[Source](../js/jquery.hlf.tip.html) | [Tests](../../tests/css/tip.html) - -The main responsibility for the required extension styling is to provide core -layout styles but allow easy customization of skin styles, ie. colors, fonts, -borders, shadows. - -The required DOM structure looks like: -```html -
-
-
-
...
-
-
-``` - -Example of the variations of classes on the tip element: -```html -
-``` -*/ - -.js-tip { - --tip-em: 12px; - --tip-fill-color: #666; - --tip-text-color: #fff; - --stem-size: var(--tip-em); - --stem-size-wide-half: calc(var(--tip-em) * 1.5 / 2); - --tip-max-width: calc(var(--tip-em) * 18); - --tip-z-index: 9999; - - display: none; - position: absolute; - - z-index: var(--tip-z-index); -} - -.js-tip-inner { - position: relative; - - max-width: var(--tip-max-width); -} - -.js-tip-stem { - background: none; - border: 0 solid transparent; /* Initial value. */ - height: 0; /* Initial value. */ - position: absolute; - width: 0; /* Initial value. */ -} -.js-tip.js-tip-left .js-tip-stem, -.js-tip.js-tip-left.js-snap-tip-y-side .js-tip-stem { - border-left-width: var(--stem-size); - left: auto; - margin-bottom: auto; /* Reset. */ - margin-right: calc(var(--stem-size) * -1); /* Positioning. */ - margin-top: auto; /* Reset. */ - right: -1px; /* To match the JS. */ - - border-color: transparent; - border-left-color: var(--tip-fill-color); -} -.js-tip.js-tip-right .js-tip-stem, -.js-tip.js-tip-right.js-snap-tip-y-side .js-tip-stem { - border-right-width: var(--stem-size); - left: 0; - margin-bottom: auto; /* Reset. */ - margin-left: calc(var(--stem-size) * -1); /* Positioning. */ - margin-top: auto; /* Reset. */ - right: auto; - - border-color: transparent; - border-right-color: var(--tip-fill-color); -} -.js-tip.js-tip-bottom .js-tip-stem, -.js-tip.js-tip-bottom.js-snap-tip-x-side .js-tip-stem { - border-bottom-width: var(--stem-size); - bottom: auto; - margin-left: auto; /* Reset. */ - margin-right: auto; /* Reset. */ - margin-top: calc(var(--stem-size) * -1); /* Positioning. */ - top: 0; - - border-color: transparent; - border-bottom-color: var(--tip-fill-color); -} -.js-tip.js-tip-top .js-tip-stem, -.js-tip.js-tip-top.js-snap-tip-x-side .js-tip-stem { - border-top-width: var(--stem-size); - bottom: 0; - margin-bottom: calc(var(--stem-size) * -1); /* Positioning. */ - margin-left: auto; /* Reset. */ - margin-right: auto; /* Reset. */ - top: auto; - - border-color: transparent; - border-top-color: var(--tip-fill-color); -} -.js-tip.js-snap-tip-x-side > .js-tip-inner > .js-tip-stem { /* Add specifity. */ - border-left-width: var(--stem-size-wide-half); - border-right-width: var(--stem-size-wide-half); - left: 50%; - margin-left: calc(var(--stem-size-wide-half) * -1); - margin-right: auto; -} -.js-tip.js-snap-tip-y-side > .js-tip-inner > .js-tip-stem { /* Add specifity. */ - border-top-width: var(--stem-size-wide-half); - border-bottom-width: var(--stem-size-wide-half); - margin-bottom: auto; - margin-top: calc(var(--stem-size-wide-half) * -1); - top: 50%; -} - -.js-tip-content { - overflow: hidden; - position: relative; - - padding-bottom: calc(var(--tip-em) * 5 / 6); - padding-left: var(--tip-em); - padding-right: var(--tip-em); - padding-top: calc(var(--tip-em) * 2 / 3); - - background-color: var(--tip-fill-color); - color: var(--tip-text-color); -}