cancel
Showing results for 
Search instead for 
Did you mean: 

Extend dnd-upload component using YAHOO.extend

streetturtle
Confirmed Champ
Confirmed Champ
Hello,

I would like to customize the dnd-upload.js file. For example I want to override
_adjustGuiIfFinished
method. I've tried several times to do it, but all of them failed (I was using some tutorials/examples:
- http://blogs.alfresco.com/wp/wabson/2011/08/12/custom-admin-console-components-in-share/
- https://forums.alfresco.com/forum/developer-discussions/alfresco-share-development/javascrip-autocom...)

Here are my steps:

- create .js file, let's say
dnd-upload-ep.js
with following content:

<javascript>
(function ()
{
  Alfresco.EpDNDUpload = function Alfresco_EpDNDUpload(htmlId)
  {
    Alfresco.EpDNDUpload.superclass.constructor.call(this, htmlId);
    return this;
  };
 
  YAHOO.extend(Alfresco.EpDNDUpload, Alfresco.DNDUpload,{
    _adjustGuiIfFinished: function EpDNDUpload_adjustGuiIfFinished()
    {

// function body with some modifications

  })
});
</javascript>

- include just created file in .ftl. Override
dnd-upload.get.html.ftl
and include file in js dependencies:



<@markup id="js">
   <#– JavaScript Dependencies –>
  <@script type="text/javascript" src="${url.context}/res/components/upload/dnd-upload.js" group="upload"/>
  <@script type="text/javascript" src="${url.context}/res/components/upload/dnd-upload-ep.js" group="upload"/>
</@>



- instead of original
DNDUpload
instantiate recently created
EpDNDUpload
. To do it override
dnd-upload.get.js
changing 'Widget instantiation metadata':

<javascript>

//Widget instantiation metadata…
   var dndUpload = {
      id : "EpDNDUpload",
      name : "Alfresco.EpDNDUpload",
      assignTo : "dndUpload"
   };
   model.widgets = [dndUpload];

</javascript>

Seems that it should work, but it doesn't. When I upload document I got error that
Alfresco.EpDNDUpload
not created and could't be instantiated.

Is there something I do wrong?
1 REPLY 1

muralidharand
Star Contributor
Star Contributor
Hi,
You can use OOPS principle in JavaScript to override a particular method.



    Alfresco.DNDUpload.prototype._adjustGuiIfFinished = function EpDNDUpload_adjustGuiIfFinished(){………..}


Now inject this into a new javascript file, load into share and hopefully it should call the new method description.


There is a very similar question here and I answered also.
https://forums.alfresco.com/comment/155503#comment-155503

Please let me know, if you're not clear.

Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.