{"version":3,"sources":["index.ts"],"names":["com","aboersch","wp","GistContainer","container","_this","this","_collapsed","_container","_rawUrl","getAttribute","r","gistRegex","exec","_fileName","_collapsedElement","jQuery","on","expandCollapse","prepend","append","copy","prototype","gist","querySelector","show","hide","toggleClass","getText","_getRequest","ajax","url","done","data","$temp","val","select","document","execCommand","remove","init","_initCalled","each","i","e","create"],"mappings":"AAAA,GAAUA,MAAV,SAAUA,IAAI,SAAAC,IAAS,SAAAC,GACnB,GAAAC,GAAA,WAUI,QAAAA,GAAYC,GAAZ,GAAAC,GAAAC,IAFQA,MAAAC,YAAa,EAGjBD,KAAKE,WAAaJ,EAClBE,KAAKG,QAAUL,EAAUM,aAAa,SACtC,IAAIC,GAAIR,EAAcS,UAAUC,KAAKP,KAAKG,QAC1CH,MAAKQ,UAAYH,EAAE,GACnBL,KAAKS,kBAAoBC,OAAO,2CAC3BC,GAAG,QAAS,WAAQZ,EAAKa,mBAC9BF,OAAOZ,GAAWe,QAAQH,OAAO,4BAC5BI,OAAOJ,OAAO,SACVI,OAAOJ,OAAO,6CAA6CV,KAAKQ,UAAS,sCACrEG,GAAG,QAAS,WAAQZ,EAAKa,qBACjCE,OAAOJ,OAAO,SACVI,OAAOJ,OAAO,+CACVC,GAAG,QAAS,WAAQZ,EAAKgB,UAC7BD,OAAOJ,OAAO,OAAOI,OAAOd,KAAKS,sBAiDlD,MA9CYZ,GAAAmB,UAAAC,KAAR,WACI,MAAOjB,MAAKE,WAAWgB,cAAc,yBAGjCrB,EAAAmB,UAAAJ,eAAR,WACQZ,KAAKC,WACLS,OAAOV,KAAKiB,QAAQE,OAEpBT,OAAOV,KAAKiB,QAAQG,OAExBpB,KAAKS,kBAAkBY,YAAY,wCACnCrB,KAAKC,YAAcD,KAAKC,YAGpBJ,EAAAmB,UAAAM,QAAR,WAII,MAHKtB,MAAKuB,cACNvB,KAAKuB,YAAcb,OAAOc,MAAOC,IAAKzB,KAAKG,WAExCH,KAAKuB,aAGR1B,EAAAmB,UAAAD,KAAR,WACIf,KAAKsB,UAAUI,KAAK,SAACC,GACjB,GAAMC,GAAQlB,OAAO,UACrBA,QAAO,QAAQI,OAAOc,GACtBA,EAAMC,IAAIF,GAAMG,SAChBC,SAASC,YAAY,QACrBJ,EAAMK,YAIApC,EAAAqC,KAAd,WACQrC,EAAcsC,cAGlBtC,EAAcsC,aAAc,EAC5BzB,OAAO,qBAAqB0B,KAAK,SAACC,EAAGC,GAEjC,MADAzC,GAAc0C,OAAOD,IACd,IAEX5B,OAAO,QAAQI,OAAO,wDAGXjB,EAAA0C,OAAf,SAAsBzC,GAClB,MAAO,IAAID,GAAcC,IAEjCD,IAvEmBA,GAAAS,UAAY,+EAFlBV,EAAAC,cAAaA,GADPF,EAAAC,KAAAD,EAAAC,SAATF,EAAAC,WAAAD,EAAAC,eAAJD,MAAAA","file":"index.js","sourcesContent":["namespace com.aboersch.wp {\r\n export class GistContainer {\r\n private static _initCalled: boolean;\r\n private static gistRegex = /\\/\\/gist.githubusercontent.com\\/(.*?)\\/([0-9a-f]*?)\\/raw\\/[0-9a-f]*?\\/(.*?)$/;\r\n\r\n private _container: HTMLElement;\r\n private _rawUrl: string;\r\n private _fileName: string;\r\n private _getRequest: JQueryXHR;\r\n private _collapsed = true;\r\n private _collapsedElement: JQuery;\r\n constructor(container: HTMLElement) {\r\n this._container = container;\r\n this._rawUrl = container.getAttribute('rawUrl');\r\n let r = GistContainer.gistRegex.exec(this._rawUrl);\r\n this._fileName = r[3];\r\n this._collapsedElement = jQuery('')\r\n .on('click', () => { this.expandCollapse(); });\r\n jQuery(container).prepend(jQuery('
')\r\n .append(jQuery('
')\r\n .append(jQuery(`${this._fileName} (click here to expand)`)\r\n .on('click', () => { this.expandCollapse(); })))\r\n .append(jQuery('
')\r\n .append(jQuery('')\r\n .on('click', () => { this.copy(); }))\r\n .append(jQuery('').append(this._collapsedElement))));\r\n }\r\n\r\n private gist(): HTMLElement {\r\n return this._container.querySelector('.gistScriptContainer') as HTMLDivElement;\r\n }\r\n\r\n private expandCollapse() {\r\n if (this._collapsed) {\r\n jQuery(this.gist()).show();\r\n } else {\r\n jQuery(this.gist()).hide();\r\n }\r\n this._collapsedElement.toggleClass('icon-plus-circled icon-minus-circled');\r\n this._collapsed = !this._collapsed;\r\n }\r\n\r\n private getText() {\r\n if (!this._getRequest) {\r\n this._getRequest = jQuery.ajax({ url: this._rawUrl });\r\n }\r\n return this._getRequest;\r\n }\r\n\r\n private copy() {\r\n this.getText().done((data) => {\r\n const $temp = jQuery('');\r\n jQuery('body').append($temp);\r\n $temp.val(data).select();\r\n document.execCommand('copy');\r\n $temp.remove();\r\n });\r\n }\r\n\r\n public static init() {\r\n if (GistContainer._initCalled) {\r\n return;\r\n }\r\n GistContainer._initCalled = true;\r\n jQuery('div.gistContainer').each((i, e) => {\r\n GistContainer.create(e as HTMLDivElement);\r\n return true;\r\n });\r\n jQuery('head').append('');\r\n }\r\n\r\n private static create(container: HTMLElement) {\r\n return new GistContainer(container);\r\n }\r\n }\r\n}"]}