Hello,
we have mixins for controllers:
But what about mixins for UI? For example how can I change that part from a ips.ui.uploader.js:
/**
* Sets up this instance
*
* @returns {void}
*/
var init = function () {
uploaderID = $( elem ).identify().attr('id');
if( options.listContainer ){
listContainer = $( options.listContainer );
} else if( $( elem ).find('[data-role="fileList"]').length ) {
listContainer = $( elem ).find('[data-role="fileList"]');
} else {
listContainer = $( elem );
}
// Do we need to insert a wrapper though?
if( ips.templates.get( options.template + 'Wrapper' ) ){
listContainer.prepend( ips.templates.render( options.template + 'Wrapper' ) );
// Move any existing items
var firstItem = listContainer.children().first();
firstItem.append( listContainer.children().not( firstItem ) );
// Set listContainer to the wrapper
listContainer = firstItem;
// And initialize any widgets we might have
$( document ).trigger( 'contentChange', [ listContainer.parent() ] );
}
// Add document events
$( document ).on( 'addUploaderFile', _addUploaderFile );
$( document ).on( 'removeAllFiles', _removeAllFiles );
// Any files to start with?
if( options.existingFiles ){
try {
var files = $.parseJSON( options.existingFiles );
if( files.length ){
_buildExistingFiles( files );
}
} catch (err) {
Debug.error("Couldn't build existing files: " + err );
}
}
if( _supportsDraggable() ){
$( elem ).find('.ipsAttachment_supportDrag')
.show()
.end()
.find('.ipsAttachment_nonDrag')
.hide();
}
// Load the appropriate files
var load = ['core/interface/plupload/plupload.full.min.js'];
if( !ips.getSetting('useCompiledFiles') ){
load = ['core/interface/plupload/moxie.js', 'core/interface/plupload/plupload.dev.js'];
}
ips.loader.get( load ).then( function () {
_setUpUploader();
_initUploader();
_postInitEvents();
_setUpFormEvents();
});
},
And add something after:
_setUpFormEvents();