-
Notifications
You must be signed in to change notification settings - Fork 0
/
bee.min.js
2 lines (2 loc) · 1022 Bytes
/
bee.min.js
1
2
/*! bee-js 1.0.2 */
bee=function(){var a={},b="data-bee",c=b+"-opts-",d="function",e=function(a){throw"bee: "+a},f=function(a,b){return JSON.parse(a.getAttribute(c+b.toLowerCase()))},g=function(a,b){var c=a.split("-");return{name:c[0],action:c[1]?c[1]:b}},h=function(b,c){var h=g(c,"create");j(b,c)?e('already applied "'+c+'"'):"object"!=typeof a[h.name]?e('no filter for "'+h.name+'"'):typeof a[h.name][h.action]!==d?e('no "'+h.action+'" for "'+h.name+'"'):(b.bees=b.bees||{},b.bees[c]=a[h.name][h.action](b,f(b,c)))},i=function(a,b){var c=j(a,b),e="destroy";if(c){if(typeof c[e]===d)c[e]();else{var f=g(b,e);typeof c[f.action]===d&&c[f.action](e)}delete a.bees[b]}},j=function(a,b){return a.bees&&a.bees.hasOwnProperty(b)?a.bees[b]:null},k=function(a,b){return a.querySelectorAll(b)},l=function(a,c){Array.prototype.forEach.call(k(a,"["+b+"]"),function(a){a.getAttribute(b).split(/\s+/).forEach(function(b){b&&c(a,b)})})};return{filter:function(b,c){a[b]=c},init:function(a){l(a,h)},deinit:function(a){l(a,i)},get:j}}();