pict 1.0.150 → 1.0.151
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/pict.compatible.js
CHANGED
|
@@ -2099,14 +2099,15 @@ _this43.renderables={};for(var _i22=0;_i22<_this43.options.Renderables.length;_i
|
|
|
2099
2099
|
// Use theirs instead!
|
|
2100
2100
|
tmpRenderable=pRenderableHash;}else{var tmpRenderMethod=typeof pRenderMethod!=='string'?pRenderMethod:'replace';tmpRenderable={RenderableHash:pRenderableHash,TemplateHash:pTemplateHash,DefaultTemplateDataAddress:pDefaultTemplateDataAddress,DefaultDestinationAddress:pDefaultDestinationAddress,RenderMethod:tmpRenderMethod};}if(typeof tmpRenderable.RenderableHash!='string'||typeof tmpRenderable.TemplateHash!='string'){this.log.error("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," could not load Renderable; RenderableHash or TemplateHash are invalid."),tmpRenderable);}else{if(this.pict.LogNoisiness>0){this.log.trace("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," adding renderable [").concat(tmpRenderable.RenderableHash,"] pointed to template ").concat(tmpRenderable.TemplateHash,"."));}this.renderables[tmpRenderable.RenderableHash]=tmpRenderable;}}/* -------------------------------------------------------------------------- */ /* Code Section: Initialization */ /* -------------------------------------------------------------------------- */},{key:"onBeforeInitialize",value:function onBeforeInitialize(){if(this.pict.LogNoisiness>3){this.log.trace("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," onBeforeInitialize:"));}return true;}},{key:"onBeforeInitializeAsync",value:function onBeforeInitializeAsync(fCallback){this.onBeforeInitialize();return fCallback();}},{key:"onInitialize",value:function onInitialize(){if(this.pict.LogNoisiness>3){this.log.trace("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," onInitialize:"));}return true;}},{key:"onInitializeAsync",value:function onInitializeAsync(fCallback){this.onInitialize();return fCallback();}},{key:"initialize",value:function initialize(){if(!this.initializeTimestamp){this.onBeforeInitialize();this.onInitialize();this.onAfterInitialize();this.initializeTimestamp=this.pict.log.getTimeStamp();return true;}else{this.log.warn("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," initialize called but initialization is already completed. Aborting."));return false;}}},{key:"initializeAsync",value:function initializeAsync(fCallback){var _this44=this;if(!this.initializeTimestamp){var tmpAnticipate=this.pict.instantiateServiceProviderWithoutRegistration('Anticipate');if(this.pict.LogNoisiness>0){this.log.info("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," beginning initialization..."));}tmpAnticipate.anticipate(this.onBeforeInitializeAsync.bind(this));tmpAnticipate.anticipate(this.onInitializeAsync.bind(this));tmpAnticipate.anticipate(this.onAfterInitializeAsync.bind(this));tmpAnticipate.wait(function(pError){_this44.initializeTimestamp=_this44.pict.log.getTimeStamp();if(_this44.pict.LogNoisiness>0){_this44.log.info("PictView [".concat(_this44.UUID,"]::[").concat(_this44.Hash,"] ").concat(_this44.options.ViewIdentifier," initialization complete."));}return fCallback();});}else{this.log.warn("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," async initialize called but initialization is already completed. Aborting."));// TODO: Should this be an error?
|
|
2101
2101
|
return fCallback();}}},{key:"onAfterInitialize",value:function onAfterInitialize(){if(this.pict.LogNoisiness>3){this.log.trace("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," onAfterInitialize:"));}return true;}},{key:"onAfterInitializeAsync",value:function onAfterInitializeAsync(fCallback){this.onAfterInitialize();return fCallback();}/* -------------------------------------------------------------------------- */ /* Code Section: Render */ /* -------------------------------------------------------------------------- */},{key:"onBeforeRender",value:function onBeforeRender(pRenderable,pRenderDestinationAddress,pData){// Overload this to mess with stuff before the content gets generated from the template
|
|
2102
|
-
if(this.pict.LogNoisiness>3){this.log.trace("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," onBeforeRender:"));}return true;}},{key:"onBeforeRenderAsync",value:function onBeforeRenderAsync(fCallback){
|
|
2102
|
+
if(this.pict.LogNoisiness>3){this.log.trace("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," onBeforeRender:"));}return true;}},{key:"onBeforeRenderAsync",value:function onBeforeRenderAsync(fCallback){return fCallback();}},{key:"render",value:function render(pRenderable,pRenderDestinationAddress,pTemplateDataAddress){var tmpRenderableHash=typeof pRenderable==='string'?pRenderable:typeof this.options.DefaultRenderable=='string'?this.options.DefaultRenderable:false;if(!tmpRenderableHash){this.log.error("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," could not render ").concat(tmpRenderableHash," (param ").concat(pRenderable,") because it is not a valid renderable."));return false;}var tmpRenderable=this.renderables[tmpRenderableHash];if(!tmpRenderable){this.log.error("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," could not render ").concat(tmpRenderableHash," (param ").concat(pRenderable,") because it does not exist."));return false;}var tmpRenderDestinationAddress=typeof pRenderDestinationAddress==='string'?pRenderDestinationAddress:typeof tmpRenderable.ContentDestinationAddress==='string'?tmpRenderable.ContentDestinationAddress:typeof this.options.DefaultDestinationAddress==='string'?this.options.DefaultDestinationAddress:false;if(!tmpRenderDestinationAddress){this.log.error("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," could not render ").concat(tmpRenderableHash," (param ").concat(pRenderable,") because it does not have a valid destination address."));return false;}var tmpDataAddress;var tmpData;if(_typeof(pTemplateDataAddress)==='object'){tmpData=pTemplateDataAddress;tmpDataAddress='Passed in as object';}else{tmpDataAddress=typeof pTemplateDataAddress==='string'?pTemplateDataAddress:typeof tmpRenderable.DefaultTemplateRecordAddress==='string'?tmpRenderable.DefaultTemplateRecordAddress:typeof this.options.DefaultTemplateRecordAddress==='string'?this.options.DefaultTemplateRecordAddress:false;tmpData=typeof tmpDataAddress==='string'?this.pict.DataProvider.getDataByAddress(tmpDataAddress):undefined;}// Execute the developer-overridable pre-render behavior
|
|
2103
2103
|
this.onBeforeRender(tmpRenderable,tmpRenderDestinationAddress,tmpData);// Generate the content output from the template and data
|
|
2104
2104
|
var tmpContent=this.pict.parseTemplateByHash(tmpRenderable.TemplateHash,tmpData);// Assign the content to the destination address
|
|
2105
2105
|
switch(tmpRenderable.RenderMethod){case'append':this.pict.ContentAssignment.appendContent(tmpRenderDestinationAddress,tmpContent);break;case'prepend':this.pict.ContentAssignment.prependContent(tmpRenderDestinationAddress,tmpContent);break;case'append_once':// Try to find the content in the destination address
|
|
2106
|
-
var tmpExistingContent=this.pict.ContentAssignment.getElement("#".concat(tmpRenderableHash));if(tmpExistingContent.length<1){this.pict.ContentAssignment.appendContent(tmpRenderDestinationAddress,tmpContent);}case'replace':
|
|
2106
|
+
var tmpExistingContent=this.pict.ContentAssignment.getElement("#".concat(tmpRenderableHash));if(tmpExistingContent.length<1){this.pict.ContentAssignment.appendContent(tmpRenderDestinationAddress,tmpContent);}break;case'replace':// TODO: Should this be the default?
|
|
2107
|
+
default:this.pict.ContentAssignment.assignContent(tmpRenderDestinationAddress,tmpContent);break;}// Execute the developer-overridable post-render behavior
|
|
2107
2108
|
this.onAfterRender(tmpRenderable,tmpRenderDestinationAddress,tmpData,tmpContent);this.lastRenderedTimestamp=this.pict.log.getTimeStamp();return true;}},{key:"renderAsync",value:function renderAsync(pRenderable,pRenderDestinationAddress,pTemplateDataAddress,fCallback){var _this45=this;var tmpRenderableHash=typeof pRenderable==='string'?pRenderable:typeof this.options.DefaultRenderable=='string'?this.options.DefaultRenderable:false;if(!tmpRenderableHash){this.log.error("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," could not asynchronously render ").concat(tmpRenderableHash," (param ").concat(pRenderable,"because it is not a valid renderable."));return fCallback(Error("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," could not asynchronously render ").concat(tmpRenderableHash," (param ").concat(pRenderable,"because it is not a valid renderable.")));}var tmpRenderable=this.renderables[tmpRenderableHash];if(!tmpRenderable){this.log.error("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," could not render ").concat(tmpRenderableHash," (param ").concat(pRenderable,") because it does not exist."));return fCallback(Error("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," could not render ").concat(tmpRenderableHash," (param ").concat(pRenderable,") because it does not exist.")));}var tmpRenderDestinationAddress=typeof pRenderDestinationAddress==='string'?pRenderDestinationAddress:typeof tmpRenderable.ContentDestinationAddress==='string'?tmpRenderable.ContentDestinationAddress:typeof this.options.DefaultDestinationAddress==='string'?this.options.DefaultDestinationAddress:false;if(!tmpRenderDestinationAddress){this.log.error("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," could not render ").concat(tmpRenderableHash," (param ").concat(pRenderable,") because it does not have a valid destination address."));return fCallback(Error("Could not render ".concat(tmpRenderableHash)));}var tmpDataAddress;var tmpData;if(_typeof(pTemplateDataAddress)==='object'){tmpData=pTemplateDataAddress;tmpDataAddress='Passed in as object';}else{tmpDataAddress=typeof pTemplateDataAddress==='string'?pTemplateDataAddress:typeof tmpRenderable.DefaultTemplateRecordAddress==='string'?tmpRenderable.DefaultTemplateRecordAddress:typeof this.options.DefaultTemplateRecordAddress==='string'?this.options.DefaultTemplateRecordAddress:false;tmpData=typeof tmpDataAddress==='string'?this.pict.DataProvider.getDataByAddress(tmpDataAddress):undefined;}var tmpAnticipate=this.fable.newAnticipate();// Execute the developer-overridable pre-render behavior
|
|
2108
|
-
//
|
|
2109
|
-
tmpAnticipate.anticipate(function(fOnBeforeRenderCallback){_this45.
|
|
2109
|
+
//
|
|
2110
|
+
tmpAnticipate.anticipate(function(fOnBeforeRenderCallback){_this45.onBeforeRender(tmpRenderable,tmpRenderDestinationAddress,tmpData);_this45.onBeforeRenderAsync(function(pError){return fOnBeforeRenderCallback(pError);});});tmpAnticipate.anticipate(function(fAsyncTemplateCallback){// Render the template (asynchronously)
|
|
2110
2111
|
_this45.pict.parseTemplateByHash(tmpRenderable.TemplateHash,tmpData,function(pError,pContent){if(pError){_this45.log.error("PictView [".concat(_this45.UUID,"]::[").concat(_this45.Hash,"] ").concat(_this45.options.ViewIdentifier," could not render (asynchronously) ").concat(tmpRenderableHash," (param ").concat(pRenderable,") because it did not parse the template."),pError);return fAsyncTemplateCallback(pError);}// Assign the content to the destination address
|
|
2111
2112
|
switch(tmpRenderable.RenderMethod){case'append':_this45.pict.ContentAssignment.appendContent(tmpRenderDestinationAddress,pContent);break;case'prepend':_this45.pict.ContentAssignment.prependContent(tmpRenderDestinationAddress,pContent);break;case'append_once':// Try to find the content in the destination address
|
|
2112
2113
|
var tmpExistingContent=_this45.pict.ContentAssignment.getElement("#".concat(tmpRenderableHash));if(tmpExistingContent.length<1){_this45.pict.ContentAssignment.appendContent(tmpRenderDestinationAddress,pContent);}case'replace':default:_this45.pict.ContentAssignment.assignContent(tmpRenderDestinationAddress,pContent);break;}// Execute the developer-overridable asynchronous post-render behavior
|