Jump to content

JS mixin to ips.utils.date


Recommended Posts

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 ;)


Link to comment
Share on other sites

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, _ ));



Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...