Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save victor-homyakov/cac1c61e9dc67483b1e2 to your computer and use it in GitHub Desktop.
Save victor-homyakov/cac1c61e9dc67483b1e2 to your computer and use it in GitHub Desktop.
// name: Remove To Do Planned and Done from column headings
// placeholder: restui_board
tau.mashups
.addDependency('tau/core/bus.reg')
.addModule('BusListeners', function(reg){
function Listener(bus, event, func){
this.bus = bus
this.event = event
this.func = func
};
function BusListeners(){
var listeners = [];
this.Add = function Add(bus, event, func){
listeners.push(new Listener(bus, event, func));
};
reg.on('create', function(e, data) {
for (var i = 0; i < listeners.length; i++){
var listener = listeners[i];
var bus = data.bus;
if (bus.name === listener.bus) {
bus.on(listener.event, listener.func);
}
};
});
reg.on('destroy', function(e, data) {
for (var i = 0; i < listeners.length; i++){
var listener = listeners[i];
var bus = data.bus;
if (bus.name === listener.bus) {
bus.removeListener(listener.event, listener.func);
}
};
});
};
return BusListeners;
});
tau.mashups
.addDependency('jQuery')
.addDependency('BusListeners')
.addMashup(function($, BusListeners) {
var to_strip = ['To Do (', 'Planned (', 'Done ('];
function strip_all(element){
var names = element.find('.i-role-name');
for (var i = 0; i < names.length; i++){
var inner = names[i].innerHTML;
var index = inner.indexOf('(');
if (index > -1){
for (var j = 0; j < to_strip.length; j++){
var str_to_strip = to_strip[j];
if (inner.indexOf(str_to_strip) > -1){
inner = inner.substring(index + 1, inner.length - 1);
names[i].innerHTML = inner;
}
}
}
}
};
console.log('Adding listener');
var listeners = new BusListeners();
listeners.Add('board_plus', 'template.boardplus.cell.axis.skeleton.bound', function(e, data){
console.log('Running listener');
strip_all(data.element);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment