This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.scripting.sightly.js.provider-1.0.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-js-provider.git
commit 4e32d86263c85408a4efe894f43ea9d3c1656257 Author: Radu Cotescu <[email protected]> AuthorDate: Mon Mar 16 13:03:32 2015 +0000 SLING-4506 - Java APIs not consistently available in JavaScript * added getName() and getResourceType() for Resource in addition to name and resourceType properties git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/sightly/js-use-provider@1666983 13f79535-47bb-0310-9956-ffa450edef68 --- .../libs/sling/sightly/js/internal/resource.js | 28 +++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/main/resources/SLING-INF/libs/sling/sightly/js/internal/resource.js b/src/main/resources/SLING-INF/libs/sling/sightly/js/internal/resource.js index b74296c..ba0eb0a 100644 --- a/src/main/resources/SLING-INF/libs/sling/sightly/js/internal/resource.js +++ b/src/main/resources/SLING-INF/libs/sling/sightly/js/internal/resource.js @@ -99,6 +99,26 @@ use(['helper.js'], function(helper) { }, /** + * Returns the name of this resource. The name of a resource is the last segment of the path. + * @returns {string} the name of this resource + */ + getName: function () { + var index = this.path.lastIndexOf('/'); + if (index == -1) { + return this.path; + } + return this.path.substring(index + 1); + }, + + /** + * The resource type is meant to point to rendering/processing scripts, editing dialogs, etc. + * @return {string} the resource type of this resource + */ + getResourceType: function () { + return this.nativeResource.resourceType; + }, + + /** * Resolve a path to a resource. The path may be relative * to this path * @param {string} path the requested path @@ -124,11 +144,7 @@ use(['helper.js'], function(helper) { */ name: { get: function() { - var index = this.path.lastIndexOf('/'); - if (index == -1) { - return this.path; - } - return this.path.substring(index + 1); + return this.getName(); } }, @@ -140,7 +156,7 @@ use(['helper.js'], function(helper) { */ resourceType: { get: function() { - return this.nativeResource.resourceType; + return this.getResourceType(); } } }); -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
