-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathview.min.js
9 lines (9 loc) · 1.6 KB
/
view.min.js
1
2
3
4
5
6
7
8
9
/*!
* view.js
* Swap visible elements in a single call.
*
* Copyright (c) 2013-2014 Tony Ross
* Released under the MIT license
* http://github.com/antross/view
*/
!function(a,b){"use strict";function c(a){function b(b,c){f(b,j,a,c)}return b.hide=function(b,c){f(b,e,a,c)},b.show=function(b,c){f(b,h,a,c)},b.toggle=function(b,c){f(b,i,a,c)},b.scope=function(a){if(!a||!a.querySelectorAll)throw new Error("[view.js] The `root` passed to `view.scope` must support `querySelectorAll`.");return c(a)},b}function d(a,b){var c=[].slice.call(b.querySelectorAll(a));if(!c.length)throw new Error('[view.js] No targets found for "'+a+'".');return c}function e(a){a.hasAttribute(k)||(a.setAttribute(k,""),g(a,"view:hide"),[].forEach.call(a.querySelectorAll("[hidden] ~ :not([hidden])"),function(a){g(a,"view:hide")}))}function f(a,b,c,e){e||(e={});var f=e.data;"string"==typeof a?a=d(a,c):(!a.length||a instanceof Element)&&(a=[a]),a.forEach(function(c){b(c,a,f,e)})}function g(a,c,d){var e=b.createEvent("CustomEvent");e.initCustomEvent(c,!1,!1,d||{}),l(function(){a.dispatchEvent(e)})}function h(a,b,c){a.hasAttribute(k)&&(a.removeAttribute(k),g(a,"view:show",{data:c}),[].forEach.call(a.querySelectorAll("[hidden] ~ :not([hidden])"),function(a){g(a,"view:show")}))}function i(a,b,c){a.hasAttribute(k)?h(a,b,c):e(a,b,c)}function j(a,b,c,d){h(a,b,c);for(var f=a.parentNode,g=f&&f.firstElementChild;g;)-1==b.indexOf(g)&&e(g),g=g.nextElementSibling;d.deep&&f&&f.hasAttribute&&j(f,b,null,d)}var k="hidden",l=a.setImmediate||function(a){setTimeout(a,0)},m=a.view=c(b);"function"==typeof define&&define(function(){return m})}(this,this.document);