Fix multi-line confirmation dialog
This commit is contained in:
parent
f9c0c21714
commit
2677ad92d3
4 changed files with 19 additions and 11 deletions
|
@ -204,17 +204,19 @@ class Wrapper
|
|||
@notifications.add("notification-#{message.id}", message.params[0], body, message.params[2])
|
||||
|
||||
displayConfirm: (message, captions, cb) ->
|
||||
body = $("<span class='message'>"+message+"</span>")
|
||||
body = $("<span class='message-outer'><span class='message'>"+message+"</span></span>")
|
||||
buttons = $("<span class='buttons'></span>")
|
||||
if captions not instanceof Array then captions = [captions] # Convert to list if necessary
|
||||
for caption, i in captions
|
||||
button = $("<a href='##{caption}' class='button button-#{caption} button-#{i+1}' data-value='#{i+1}'>#{caption}</a>") # Add confirm button
|
||||
button = $("<a href='##{caption}' class='button button-confirm button-#{caption} button-#{i+1}' data-value='#{i+1}'>#{caption}</a>") # Add confirm button
|
||||
button.on "click", (e) =>
|
||||
cb(parseInt(e.currentTarget.dataset.value))
|
||||
return false
|
||||
body.append(button)
|
||||
buttons.append(button)
|
||||
body.append(buttons)
|
||||
@notifications.add("notification-#{caption}", "ask", body)
|
||||
|
||||
button.focus()
|
||||
buttons.first().focus()
|
||||
$(".notification").scrollLeft(0)
|
||||
|
||||
|
||||
|
|
|
@ -54,8 +54,10 @@ a { color: black }
|
|||
padding-left: 14px; padding-right: 60px; height: 40px; vertical-align: middle; display: table;
|
||||
background-color: white; left: 50px; top: 0; position: relative; padding-top: 5px; padding-bottom: 5px;
|
||||
}
|
||||
.notification .message-outer { display: table-row }
|
||||
.notification .buttons { display: table-cell; vertical-align: top; padding-top: 9px; }
|
||||
.notification.long .body { padding-top: 10px; padding-bottom: 10px }
|
||||
.notification .message { display: table-cell; vertical-align: middle }
|
||||
.notification .message { display: table-cell; vertical-align: middle; }
|
||||
|
||||
.notification.visible { max-width: 350px }
|
||||
|
||||
|
|
|
@ -59,8 +59,10 @@ a { color: black }
|
|||
padding-left: 14px; padding-right: 60px; height: 40px; vertical-align: middle; display: table;
|
||||
background-color: white; left: 50px; top: 0; position: relative; padding-top: 5px; padding-bottom: 5px;
|
||||
}
|
||||
.notification .message-outer { display: table-row }
|
||||
.notification .buttons { display: table-cell; vertical-align: top; padding-top: 9px; }
|
||||
.notification.long .body { padding-top: 10px; padding-bottom: 10px }
|
||||
.notification .message { display: table-cell; vertical-align: middle }
|
||||
.notification .message { display: table-cell; vertical-align: middle; }
|
||||
|
||||
.notification.visible { max-width: 350px }
|
||||
|
||||
|
|
|
@ -1087,24 +1087,26 @@ jQuery.extend( jQuery.easing,
|
|||
};
|
||||
|
||||
Wrapper.prototype.displayConfirm = function(message, captions, cb) {
|
||||
var body, button, caption, i, j, len;
|
||||
body = $("<span class='message'>" + message + "</span>");
|
||||
var body, button, buttons, caption, i, j, len;
|
||||
body = $("<span class='message-outer'><span class='message'>" + message + "</span></span>");
|
||||
buttons = $("<span class='buttons'></span>");
|
||||
if (!(captions instanceof Array)) {
|
||||
captions = [captions];
|
||||
}
|
||||
for (i = j = 0, len = captions.length; j < len; i = ++j) {
|
||||
caption = captions[i];
|
||||
button = $("<a href='#" + caption + "' class='button button-" + caption + " button-" + (i + 1) + "' data-value='" + (i + 1) + "'>" + caption + "</a>");
|
||||
button = $("<a href='#" + caption + "' class='button button-confirm button-" + caption + " button-" + (i + 1) + "' data-value='" + (i + 1) + "'>" + caption + "</a>");
|
||||
button.on("click", (function(_this) {
|
||||
return function(e) {
|
||||
cb(parseInt(e.currentTarget.dataset.value));
|
||||
return false;
|
||||
};
|
||||
})(this));
|
||||
body.append(button);
|
||||
buttons.append(button);
|
||||
}
|
||||
body.append(buttons);
|
||||
this.notifications.add("notification-" + caption, "ask", body);
|
||||
button.focus();
|
||||
buttons.first().focus();
|
||||
return $(".notification").scrollLeft(0);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue