0 Replies Latest reply on Dec 3, 2012 4:56 PM by sara2012sara

    Overriding a single function in sidekick.js?

    sara2012sara Level 1

      I made a change to the function called when the "Activate" button is clicked in the CQ 5.4 sidekick.

      The function is "getPublishConfig" in sidekick.js.

      It works fine when I clone the entire sidekick.js file to [1], and then modify the existing method.


      However, I would like to be able to override the getPublishConfig function code only, instead of the entire siteadmin.js, to help control the impact on future CQ upgrades.


      I have tried these approaches below, but without luck.  If you have any other direction that perhaps I should look at, I would appreciate the tip.





      Approach 1: I tried the clientlibs approach, but the new code was not being picked up- it was the OOB code that was being executed.   I am pretty sure the clientlibs was set up correctly, because this approach did work for overriding the SiteAdmin.Actions.js functions.  The custom js file contained code like [2].


      Approach 2: I also tried to modify init.jsp in the template folder as shown in [3].  This worked in the simple activation cases.  However, when there are assets on the page that also need activating, and the Asset Reference Dialog is shown, then the AssetReferenceSearchDialog.js [4] script fails with an error because dlg.path.push is undefined.  I wonder if it is possible that this approach may have worked for simpler functions, but because of the level of indirection it does not work here?



      [1] /apps/cq/ui/widgets/source/widgets/wcm/Sidekick.js


      [2] CQ.wcm.Sidekick.getPublishConfig = function() { [snip--custom code]};


      [3] CQ.WCM.launchSidekick("<%= currentPage.getPath() %>", {

                  propsDialog: "<%= dlgPath == null ? "" : dlgPath %>",

                  locked: <%= currentPage.isLocked() %>,

                  actions: act,

                 getPublishConfig : function() {  [snip--custom code]};



      [4] /libs/cq/ui/widgets/source/widgets/wcm/AssetReferenceSearchDialog.js