Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Numbered Posted October 5, 2017 Posted October 5, 2017 Hi friends. Could anybody help me with mixins? I have a plugin, which redefine relative dates return of \IPS\DateTime class. All worked well, but in some JS-generated blocks, such as quote/citation block in editor return relative date, generated by JS. I found method and file, who did it. But got a trouble with redefine this method with mixin. I read two documents: But there said about mixins for controllers (and i not understand where it must be located, how named and how activate them on needed places). So, better doc or simple example will be perfect for me. Example, which will alert('test') on using ips.utils.time relative method. Calls @Rikki here too Thanks!
Numbered Posted October 9, 2017 Author Posted October 9, 2017 Anybody here? I can redefine post controller, but it will fix only one place with relative date calling( Or i need to fork editor's JS - it will be hard bad..
Martin A. Posted October 12, 2017 Posted October 12, 2017 You can't use a "mixin", as that only works on controllers, what you want to extend/override is created as a module. This appears to work ;( function($, _, undefined){ "use strict"; var _readableOrig = ips.utils.time.readable; /* Store a reference to the original function if you need to call it in your override */ ips.utils.time.readable = function (timestamp) { var date = _readableOrig( timestamp ); return date.replace( '2017', '1999' ); }; }( jQuery, _ ));
Recommended Posts
Archived
This topic is now archived and is closed to further replies.