Source: search/SearchResultPropertyLink.js

/**
 * Copyright (C) 2005-2016 Alfresco Software Limited.
 *
 * This file is part of Alfresco
 *
 * Alfresco is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Alfresco is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * Extends the Property renderer ({@link module:alfresco/renderers/Property}) to provide a linked property.
 * 
 * @module alfresco/search/SearchResultPropertyLink
 * @extends alfresco/renderers/PropertyLink
 * @mixes alfresco/navigation/_HtmlAnchorMixin
 * @mixes alfresco/renderers/_SearchResultLinkMixin
 * @author Dave Draper
 */
define(["dojo/_base/declare",
        "alfresco/renderers/PropertyLink",
        "alfresco/navigation/_HtmlAnchorMixin",
        "alfresco/renderers/_SearchResultLinkMixin"], 
        function(declare, PropertyLink, _HtmlAnchorMixin, _SearchResultLinkMixin) {

   return declare([PropertyLink, _HtmlAnchorMixin, _SearchResultLinkMixin], {

      /**
       * Generates the publication payload by calling the mixed in 
       * [generatePayload]{@link module:alfresco/renderers/_SearchResultLinkMixin#generatePayload}
       * function and then wraps the property in an anchor element by calling the mixed in 
       * [makeAnchor]{@link module:alfresco/navigation/_HtmlAnchorMixin#makeAnchor} function
       *
       * @instance
       */
      postCreate: function alfresco_search_SearchResultPropertyLink__postCreate() {
         this.inherited(arguments);
         this.publishPayload = this.generateSearchLinkPayload(this.payload, this.currentItem, null, this.publishPayloadType, this.publishPayloadItemMixin, this.publishPayloadModifiers);
         this.makeAnchor(this.publishPayload.url, this.publishPayload.type);
      },

      /**
       * Returns an array containing the selector that identifies the span to wrap in an anchor.
       * This overrides the [mixed in function]{@link module:alfresco/navigation/_HtmlAnchorMixin}
       * that just returns an empty array.
       *
       * @instance
       */
      getAnchorTargetSelectors: function alfresco_search_SearchResultPropertyLink__getAnchorTargetSelectors() {
         return ["span.inner"];
      },

      /**
       * Overrides the [inherited function]{@link module:alfresco/renderers/PropertyLink#getPublishTopic}
       * to return the "ALF_NAVIGATE_TO_PAGE" topic.
       * 
       * @instance
       * @return {object} The generated payload
       */
      getPublishTopic: function alfresco_search_SearchResultPropertyLink__getPublishTopic() {
         return "ALF_NAVIGATE_TO_PAGE";
      },

      /**
       * Overrides the [inherited function]{@link module:alfresco/renderers/PropertyLink#getPublishPayload}
       * to return the payload generated by the [generatePayload function]
       * {@link module:alfresco/search/SearchResultPropertyLink#generatePayload}.
       * 
       * @instance
       * @return {object} The generated payload
       */
      getPublishPayload: function alfresco_search_SearchResultPropertyLink__getPublishPayload() {
         return this.publishPayload;
      }
   });
});