Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the broken points button #107

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git
35 changes: 21 additions & 14 deletions trelloscrum.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ var recalcTotalsObserver = new CrossBrowser.MutationObserver(function(mutations)
if($editControls.length == 0){
$editControls = $(".js-card-detail-title-input.is-editing").closest('.window-header'); // new selector
}
if($editControls.length == 0){
$editControls = $(".quick-card-editor-buttons"); // new selector
}

if($editControls.length > 0)
{
showPointPicker($editControls.get(0));
Expand Down Expand Up @@ -712,43 +716,44 @@ function showPointPicker(location) {
if($(location).find('.picker').length) return;

// Try to allow this to work with old card style (with save button) or new style (where title is always a textarea).
var $elementToAddPickerTo = $('.card-detail-title .edit-controls');
var $elementToAddPickerTo = $('.quick-card-editor-buttons');
if($elementToAddPickerTo.length == 0){
$elementToAddPickerTo = $(".js-card-detail-title-input").closest('.window-header');
}

var $picker = $('<div/>', {class: "picker"}).appendTo($elementToAddPickerTo.get(0));
var $picker = $('<div/>', {class: "picker quick-card-editor-buttons-item"}).appendTo($elementToAddPickerTo.get(0));
$picker.append($('<span>', {class: "picker-title"}).text("Estimated Points"));

var estimateSequence = (S4T_SETTINGS[SETTING_NAME_ESTIMATES].replace(/ /g, '')).split(',');
for (var i in estimateSequence) $picker.append($('<span>', {class: "point-value"}).text(estimateSequence[i]).click(function(){
var value = $(this).text();
var $text = $('.card-detail-title .edit textarea'); // old text-areas
if($text.length == 0){
$text = $('textarea.js-card-detail-title-input'); // new text-area
$text = $('textarea.list-card-edit-title'); // new text-area
}
var text = $text.val();

// replace estimates in card title
$text[0].value=text.match(reg)?text.replace(reg, '('+value+') '):'('+value+') ' + text;

// in old-textarea method, click our button so it all gets saved away
$(".card-detail-title .edit .js-save-edit").click();
// in new-textarea method, have to do a few actions to get it to save after we click away from the card
$('textarea.js-card-detail-title-input').click();
$('textarea.js-card-detail-title-input').focus();
var $saveButton = $('input.js-save-edits');
$saveButton.click();
// // in new-textarea method, have to do a few actions to get it to save after we click away from the card
// $('textarea.js-card-detail-title-input').click();
// $('textarea.js-card-detail-title-input').focus();

return false;
}));

if($(location).find('.picker-consumed').length) return;
var $pickerConsumed = $('<div/>', {class: "picker-consumed"}).appendTo($elementToAddPickerTo.get(0));
var $pickerConsumed = $('<div/>', {class: "picker-consumed quick-card-editor-buttons-item"}).appendTo($elementToAddPickerTo.get(0));
$pickerConsumed.append($('<span>', {class: "picker-title"}).text("Consumed Points"));

var consumedSequence = (S4T_SETTINGS[SETTING_NAME_ESTIMATES]).split(',');
for (var i in consumedSequence) $pickerConsumed.append($('<span>', {class: "point-value"}).text(consumedSequence[i]).click(function(){
var value = $(this).text();
var $text = $('.card-detail-title .edit textarea'); // old text-areas
var $text = $('textarea.list-card-edit-title'); // old text-areas
if($text.length == 0){
$text = $('textarea.js-card-detail-title-input'); // new text-area
}
Expand All @@ -757,11 +762,13 @@ function showPointPicker(location) {
// replace consumed value in card title
$text[0].value=text.match(regC)?text.replace(regC, ' ['+value+']'):text + ' ['+value+']';

// in old-textarea method, click our button so it all gets saved away
$(".card-detail-title .edit .js-save-edit").click();
// in new-textarea method, have to do a few actions to get it to save after we click away from the card
$('textarea.js-card-detail-title-input').click();
$('textarea.js-card-detail-title-input').focus();
var $saveButton = $('input.js-save-edits');
$saveButton.click();
// // in old-textarea method, click our button so it all gets saved away
// $(".card-detail-title .edit .js-save-edit").click();
// // in new-textarea method, have to do a few actions to get it to save after we click away from the card
// $('textarea.js-card-detail-title-input').click();
// $('textarea.js-card-detail-title-input').focus();

return false;
}));
Expand Down