{"version":3,"sources":["Honeywell.ClientModel.Events.ts"],"names":["exports","callbackToPromise","loadFunction","Q","Promise","resolve","reject","arguments","waitForAllEvents","functional","compose2","all","map","executeOrDelayUntilScriptLoaded","reverseCurry2","SP","SOD","jqueryClick","selector","handler","click","spLoad"],"mappings":"sJAaaA,EAAAC,kBAAoB,SAACC,GAC9B,MAAOC,GAAEC,QACL,SAACC,EAA6DC,GAC1DJ,EAAa,WAAcG,EAAQE,gBAQlCP,EAAAQ,iBAAmBC,EAAWC,SACdP,EAAEQ,IAAKF,EAAWG,IAAIZ,EAAAC,oBAOtCD,EAAAa,gCAAkCJ,EAAWK,cAAcC,GAAGC,IAAIH,iCAQlEb,EAAAiB,YAAc,SAACC,GAAqB,MAAA,UAACC,GAAsB,MAAAD,GAASE,MAAMD,KAK1EnB,EAAAqB,OAAS,WAAM,MAAArB,GAAAQ,kBAAkBR,EAAAa,gCAAgC","file":"Honeywell.ClientModel.Events.js","sourcesContent":["///\r\n\r\nimport * as Q from \"q\"\r\nimport * as functional from \"./Honeywell.ClientModel.Functional\";\r\n\r\ntype eventFunction = (callback: () => any) => any;\r\n\r\n\r\n/**\r\n * This function converts a load event to a promise\r\n * @param loadFunction This is the event function\r\n * @returns a promise that encapsulate the arguments\r\n */\r\nexport const callbackToPromise = (loadFunction: eventFunction) => {\r\n return Q.Promise(\r\n (resolve: (val: IArguments | Q.IPromise) => void, reject: (reason: any) => void) => {\r\n loadFunction(function () { resolve(arguments); });\r\n });\r\n};\r\n\r\n\r\n/**\r\n * This function takes an array of eventFunctions and returns a promise that will resolve when all events are resolved.\r\n */\r\nexport const waitForAllEvents = functional.compose2[],\r\n Q.Promise>(Q.all, functional.map(callbackToPromise));\r\n\r\n/**\r\n * Curried version of SP.SOD.executeOrDelayUntilScriptLoaded\r\n * @param script: The script that has to load before the event triggered\r\n * @returns : a function of the type eventFunction\r\n */\r\nexport const executeOrDelayUntilScriptLoaded = functional.reverseCurry2(SP.SOD.executeOrDelayUntilScriptLoaded);\r\n\r\n\r\n/**\r\n * Point-free JQuery click function\r\n * @param selector \r\n * @returns a function\r\n */\r\nexport const jqueryClick = (selector: JQuery) => (handler: Function) => selector.click(handler);\r\n\r\n/**\r\n * Convenience method: spLoad\r\n */\r\nexport const spLoad = () => waitForAllEvents([executeOrDelayUntilScriptLoaded(\"sp.js\")])"]}