Permalink
Browse files

Add an option to show dialog at the bottom.

  • Loading branch information...
1 parent 3e088ab commit 0682373fb8ea950d1e44a2e4af5b60631f7248a7 @mightyguava mightyguava committed with marijnh Dec 8, 2012
Showing with 26 additions and 16 deletions.
  1. +12 −7 lib/util/dialog.css
  2. +14 −9 lib/util/dialog.js
View
@@ -1,18 +1,23 @@
.CodeMirror-dialog {
- position: relative;
-}
-
-.CodeMirror-dialog > div {
position: absolute;
- top: 0; left: 0; right: 0;
+ left: 0; right: 0;
background: white;
- border-bottom: 1px solid #eee;
z-index: 15;
padding: .1em .8em;
overflow: hidden;
color: #333;
}
+.CodeMirror-dialog-top {
+ border-bottom: 1px solid #eee;
+ top: 0;
+}
+
+.CodeMirror-dialog-bottom {
+ border-top: 1px solid #eee;
+ bottom: 0;
+}
+
.CodeMirror-dialog input {
border: none;
outline: none;
@@ -24,4 +29,4 @@
.CodeMirror-dialog button {
font-size: 70%;
-}
+}
View
@@ -1,16 +1,21 @@
// Open simple dialogs on top of an editor. Relies on dialog.css.
(function() {
- function dialogDiv(cm, template) {
+ function dialogDiv(cm, template, bottom) {
var wrap = cm.getWrapperElement();
- var dialog = wrap.insertBefore(document.createElement("div"), wrap.firstChild);
- dialog.className = "CodeMirror-dialog";
- dialog.innerHTML = '<div>' + template + '</div>';
+ var dialog;
+ dialog = wrap.appendChild(document.createElement("div"));
+ if (bottom) {
+ dialog.className = "CodeMirror-dialog CodeMirror-dialog-bottom";
+ } else {
+ dialog.className = "CodeMirror-dialog CodeMirror-dialog-top";
+ }
+ dialog.innerHTML = template;
return dialog;
}
- CodeMirror.defineExtension("openDialog", function(template, callback) {
- var dialog = dialogDiv(this, template);
+ CodeMirror.defineExtension("openDialog", function(template, callback, bottom) {
+ var dialog = dialogDiv(this, template, bottom);
var closed = false, me = this;
function close() {
if (closed) return;
@@ -40,8 +45,8 @@
return close;
});
- CodeMirror.defineExtension("openConfirm", function(template, callbacks) {
- var dialog = dialogDiv(this, template);
+ CodeMirror.defineExtension("openConfirm", function(template, callbacks, bottom) {
+ var dialog = dialogDiv(this, template, bottom);
var buttons = dialog.getElementsByTagName("button");
var closed = false, me = this, blurring = 1;
function close() {
@@ -67,4 +72,4 @@
CodeMirror.on(b, "focus", function() { ++blurring; });
}
});
-})();
+})();

0 comments on commit 0682373

Please sign in to comment.