Manipulate Attachment Uploader

  • Thread starter Thread starter ragtek
  • Start date Start date
R

ragtek

Guest
Is it possible to overwrite JS OOP just like PHP OOP?

I want to add an extrabutton to the form and overwrite XenForo.AttachmentInserter = function($trigger) without creating a own editor.js file (copy the complete attachment_editor.js file and change some lines)
If i would copy it, i also wouldn't be allowed to release the add-on because of the copyright problems^^
 
I don't know if this is the XenForo way to do it, but you might try this in the time being and see if it works:
Code:
_oldMethod = XenForo.someMethod;
XenForo.someMethod = function(param1, param2)
{
    _oldMethod.apply(this, arguments);
    alert('hey');
    // Add other things here
}
I think that should work if you only want to add something to the code. If you want to actually change something from the method you might try extending it like:
Code:
$.extend(XenForo.someMethod = function(param1, param2)
{
    // You would need to copy and paste the code of the original method here and change it to your liking
});
 
I don't think monkey patching is a good idea since XenForo is in active development and things get changed fast. Anyway, I have used quite some Javascript events designed in XenForo and it works really good. For instance, I once used AttachmentsChanged to modify the behavior of the uploader
 
Top Bottom