-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HypeSymbolCache.min.js
8 lines (8 loc) · 1.77 KB
/
HypeSymbolCache.min.js
1
2
3
4
5
6
7
8
/*
Hype SymbolCache 1.1
copyright (c) 2020 Max Ziebell, (https://maxziebell.de). MIT-license
*/
!1==="HypeSymbolCache"in window&&(window.HypeSymbolCache=function(){var c={};!1==="HYPE_eventListeners"in window&&(window.HYPE_eventListeners=[]);window.HYPE_eventListeners.push({type:"HypeDocumentLoad",callback:function(b,f,g){c[b.documentId()]={};b.notifyEvent=function(a,b){var e=window.HYPE_eventListeners;if(null!=e){for(var c,d=0;d<e.length;d++)if(e[d].type==a.type&&null!=e[d].callback&&(c=e[d].callback(this,b,a),!1===c))return!1;return c}};b.getSymbolInstanceForElement=function(a){if(c[this.documentId()][a.id])return c[this.documentId()][a.id];
for(var d=null,e=a,f=document.getElementById(b.documentId());null==d&&null!=e&&e!=f;)d=c[this.documentId()][e.id],null!=d?a!=e&&(c[this.documentId()][a.id]=d):e=e.parentNode;return d};b.purgeSymbolCache=function(a){if(a)for(var d in c[this.documentId()])b.refreshSymbolCacheForId(d);else c[this.documentId()]={}};b.purgeSymbolCacheForId=function(a,d){d?b.refreshSymbolCacheForId(a):delete c[this.documentId()][a]};b._getSymbolInstanceById=b.getSymbolInstanceById;b._getSymbolInstancesByName=b.getSymbolInstancesByName;
b.getSymbolInstanceById=function(a){return c[this.documentId()][a]};b.getSymbolInstancesByName=function(a){a=b._getSymbolInstancesByName(a);for(var d=[],e=0;e<a.length;e++)d.push(c[this.documentId()][a[e].element().id]);return d};b.refreshSymbolCacheForId=function(a){c[b.documentId()][a]=b._getSymbolInstanceById(a);b.notifyEvent({type:"HypeSymbolInit"},document.getElementById(a))};b.refreshSymbolCacheForIdIfNecessary=function(a){c[b.documentId()][a]||this.refreshSymbolCacheForId(a)}}});window.HYPE_eventListeners.push({type:"HypeSymbolLoad",
callback:function(b,c,g){b.refreshSymbolCacheForIdIfNecessary(c.id)}});return{version:"1.1"}}());