pict 1.0.220 → 1.0.221
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/package.json
CHANGED
|
@@ -265,6 +265,44 @@ class PictContentAssignment extends libFableServiceBase
|
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
+
/**
|
|
269
|
+
* Project content into a destination address based on a render method -- as the views do.
|
|
270
|
+
* Valid render methods are:
|
|
271
|
+
* - append: Append the content to the destination address.
|
|
272
|
+
* - prepend: Prepend the content to the destination address.
|
|
273
|
+
* - append_once: Append the content to the destination address only if it doesn't already exist in the test address.
|
|
274
|
+
* - replace: Replace the content of the destination address with the new content.
|
|
275
|
+
* @param {string} pRenderMethod
|
|
276
|
+
* @param {string} pDestinationAddress
|
|
277
|
+
* @param {string} pContent
|
|
278
|
+
* @param {string} pTestAddress
|
|
279
|
+
* @returns Result of the content assignment.
|
|
280
|
+
*/
|
|
281
|
+
projectContent(pRenderMethod, pDestinationAddress, pContent, pTestAddress)
|
|
282
|
+
{
|
|
283
|
+
// Assign the content to the destination address
|
|
284
|
+
switch(pRenderMethod)
|
|
285
|
+
{
|
|
286
|
+
case 'append':
|
|
287
|
+
return this.appendContent(pDestinationAddress, pContent);
|
|
288
|
+
case 'prepend':
|
|
289
|
+
return this.prependContent(pDestinationAddress, pContent);
|
|
290
|
+
case 'append_once':
|
|
291
|
+
// Try to find the content in either the test address or the destination address
|
|
292
|
+
let tmpTestAddress = (typeof(pTestAddress) == 'string') ? pTestAddress : pDestinationAddress;
|
|
293
|
+
let tmpExistingContent = this.getElement(`#${tmpTestAddress}`);
|
|
294
|
+
if (tmpExistingContent.length < 1)
|
|
295
|
+
{
|
|
296
|
+
return this.appendContent(pRenderDestinationAddress, pContent);
|
|
297
|
+
}
|
|
298
|
+
break;
|
|
299
|
+
case 'replace':
|
|
300
|
+
// TODO: Should this be the default?
|
|
301
|
+
default:
|
|
302
|
+
return this.assignContent(pDestinationAddress, pContent);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
268
306
|
/**
|
|
269
307
|
* Read content from an element.
|
|
270
308
|
*
|