style tables, opts menu

This commit is contained in:
loro2
2019-07-25 10:16:27 +02:00
parent 573cb5321b
commit 12f51f1171
2 changed files with 245 additions and 87 deletions
+36 -34
View File
@@ -5,16 +5,16 @@ SQL.Row = function(owner, title, data) {
this.keys = []; this.keys = [];
this.selected = false; this.selected = false;
this.expanded = false; this.expanded = false;
SQL.Visual.apply(this); SQL.Visual.apply(this);
this.data.type = 0; this.data.type = 0;
this.data.size = ""; this.data.size = "";
this.data.def = null; this.data.def = null;
this.data.nll = true; this.data.nll = true;
this.data.ai = false; this.data.ai = false;
this.data.comment = ""; this.data.comment = "";
if (data) { this.update(data); } if (data) { this.update(data); }
this.setTitle(title); this.setTitle(title);
} }
@@ -22,7 +22,7 @@ SQL.Row.prototype = Object.create(SQL.Visual.prototype);
SQL.Row.prototype._build = function() { SQL.Row.prototype._build = function() {
this.dom.container = OZ.DOM.elm("tbody"); this.dom.container = OZ.DOM.elm("tbody");
this.dom.content = OZ.DOM.elm("tr"); this.dom.content = OZ.DOM.elm("tr");
this.dom.selected = OZ.DOM.elm("div", {className:"selected",innerHTML:"» "}); this.dom.selected = OZ.DOM.elm("div", {className:"selected",innerHTML:"» "});
this.dom.title = OZ.DOM.elm("div", {className:"title"}); this.dom.title = OZ.DOM.elm("div", {className:"title"});
@@ -35,7 +35,7 @@ SQL.Row.prototype._build = function() {
[this.dom.content, td1, td2], [this.dom.content, td1, td2],
[td1, this.dom.selected, this.dom.title] [td1, this.dom.selected, this.dom.title]
); );
this.enter = this.enter.bind(this); this.enter = this.enter.bind(this);
this.changeComment = this.changeComment.bind(this); this.changeComment = this.changeComment.bind(this);
@@ -64,7 +64,7 @@ SQL.Row.prototype.setTitle = function(t) {
var tt = r.row2.getTitle().replace(new RegExp(old,"g"),t); var tt = r.row2.getTitle().replace(new RegExp(old,"g"),t);
if (tt != r.row2.getTitle()) { r.row2.setTitle(tt); } if (tt != r.row2.getTitle()) { r.row2.setTitle(tt); }
} }
SQL.Visual.prototype.setTitle.apply(this, [t]); SQL.Visual.prototype.setTitle.apply(this, [t]);
} }
@@ -82,7 +82,7 @@ SQL.Row.prototype.dblclick = function(e) { /* dblclicked on row */
SQL.Row.prototype.update = function(data) { /* update subset of row data */ SQL.Row.prototype.update = function(data) { /* update subset of row data */
var des = SQL.Designer; var des = SQL.Designer;
if (data.nll && data.def && data.def.match(/^null$/i)) { data.def = null; } if (data.nll && data.def && data.def.match(/^null$/i)) { data.def = null; }
for (var p in data) { this.data[p] = data[p]; } for (var p in data) { this.data[p] = data[p]; }
if (!this.data.nll && this.data.def === null) { this.data.def = ""; } if (!this.data.nll && this.data.def === null) { this.data.def = ""; }
@@ -116,7 +116,7 @@ SQL.Row.prototype.down = function() { /* shift down */
SQL.Row.prototype.buildEdit = function() { SQL.Row.prototype.buildEdit = function() {
OZ.DOM.clear(this.dom.container); OZ.DOM.clear(this.dom.container);
var elms = []; var elms = [];
this.dom.name = OZ.DOM.elm("input"); this.dom.name = OZ.DOM.elm("input");
this.dom.name.type = "text"; this.dom.name.type = "text";
@@ -141,15 +141,16 @@ SQL.Row.prototype.buildEdit = function() {
this.dom.nll = OZ.DOM.elm("input"); this.dom.nll = OZ.DOM.elm("input");
this.dom.nll.type = "checkbox"; this.dom.nll.type = "checkbox";
elms.push(["null",this.dom.nll]); elms.push(["null",this.dom.nll]);
this.dom.comment = OZ.DOM.elm("span",{className:"comment"}); this.dom.comment = OZ.DOM.elm("span",{className:"comment"});
this.dom.comment.innerHTML = ""; this.dom.comment.innerHTML = "";
this.dom.comment.appendChild(document.createTextNode(this.data.comment)); this.dom.comment.appendChild(document.createTextNode(this.data.comment));
this.dom.commentbtn = OZ.DOM.elm("input"); this.dom.commentbtn = OZ.DOM.elm("input");
this.dom.commentbtn.type = "button"; this.dom.commentbtn.type = "button";
this.dom.commentbtn.id = "commentbtn"
this.dom.commentbtn.value = _("comment"); this.dom.commentbtn.value = _("comment");
OZ.Event.add(this.dom.commentbtn, "click", this.changeComment); OZ.Event.add(this.dom.commentbtn, "click", this.changeComment);
for (var i=0;i<elms.length;i++) { for (var i=0;i<elms.length;i++) {
@@ -165,7 +166,7 @@ SQL.Row.prototype.buildEdit = function() {
); );
this.dom.container.appendChild(tr); this.dom.container.appendChild(tr);
} }
var tr = OZ.DOM.elm("tr"); var tr = OZ.DOM.elm("tr");
var td1 = OZ.DOM.elm("td"); var td1 = OZ.DOM.elm("td");
var td2 = OZ.DOM.elm("td"); var td2 = OZ.DOM.elm("td");
@@ -208,7 +209,7 @@ SQL.Row.prototype.collapse = function() {
nll: this.dom.nll.checked, nll: this.dom.nll.checked,
ai: this.dom.ai.checked ai: this.dom.ai.checked
} }
OZ.DOM.clear(this.dom.container); OZ.DOM.clear(this.dom.container);
this.dom.container.appendChild(this.dom.content); this.dom.container.appendChild(this.dom.content);
@@ -220,7 +221,7 @@ SQL.Row.prototype.load = function() { /* put data to expanded form */
this.dom.name.value = this.getTitle(); this.dom.name.value = this.getTitle();
var def = this.data.def; var def = this.data.def;
if (def === null) { def = "NULL"; } if (def === null) { def = "NULL"; }
this.dom.def.value = def; this.dom.def.value = def;
this.dom.size.value = this.data.size; this.dom.size.value = this.data.size;
this.dom.nll.checked = this.data.nll; this.dom.nll.checked = this.data.nll;
@@ -230,23 +231,24 @@ SQL.Row.prototype.load = function() { /* put data to expanded form */
SQL.Row.prototype.redraw = function() { SQL.Row.prototype.redraw = function() {
var color = this.getColor(); var color = this.getColor();
this.dom.container.style.backgroundColor = color; this.dom.container.style.backgroundColor = color;
this.dom.container.style.borderColor = color;
OZ.DOM.removeClass(this.dom.title, "primary"); OZ.DOM.removeClass(this.dom.title, "primary");
OZ.DOM.removeClass(this.dom.title, "key"); OZ.DOM.removeClass(this.dom.title, "key");
if (this.isPrimary()) { OZ.DOM.addClass(this.dom.title, "primary"); } if (this.isPrimary()) { OZ.DOM.addClass(this.dom.title, "primary"); }
if (this.isKey()) { OZ.DOM.addClass(this.dom.title, "key"); } if (this.isKey()) { OZ.DOM.addClass(this.dom.title, "key"); }
this.dom.selected.style.display = (this.selected ? "" : "none"); this.dom.selected.style.display = (this.selected ? "" : "none");
this.dom.container.title = this.data.comment; this.dom.container.title = this.data.comment;
var typehint = []; var typehint = [];
if (this.owner.owner.getOption("showtype")) { if (this.owner.owner.getOption("showtype")) {
var elm = this.getDataType(); var elm = this.getDataType();
typehint.push(elm.getAttribute("sql")); typehint.push(elm.getAttribute("sql"));
} }
if (this.owner.owner.getOption("showsize") && this.data.size) { if (this.owner.owner.getOption("showsize") && this.data.size) {
typehint.push("(" + this.data.size + ")"); typehint.push("(" + this.data.size + ")");
} }
this.dom.typehint.innerHTML = typehint.join(" "); this.dom.typehint.innerHTML = typehint.join(" ");
this.owner.redraw(); this.owner.redraw();
this.owner.owner.rowManager.redraw(); this.owner.owner.rowManager.redraw();
@@ -314,14 +316,14 @@ SQL.Row.prototype.destroy = function() {
while (this.relations.length) { while (this.relations.length) {
this.owner.owner.removeRelation(this.relations[0]); this.owner.owner.removeRelation(this.relations[0]);
} }
for (var i=0;i<this.keys.length;i++){ for (var i=0;i<this.keys.length;i++){
this.keys[i].removeRow(this); this.keys[i].removeRow(this);
} }
} }
SQL.Row.prototype.toXML = function() { SQL.Row.prototype.toXML = function() {
var xml = ""; var xml = "";
var t = this.getTitle().replace(/"/g,"&quot;"); var t = this.getTitle().replace(/"/g,"&quot;");
var nn = (this.data.nll ? "1" : "0"); var nn = (this.data.nll ? "1" : "0");
var ai = (this.data.ai ? "1" : "0"); var ai = (this.data.ai ? "1" : "0");
@@ -331,14 +333,14 @@ SQL.Row.prototype.toXML = function() {
var t = elm.getAttribute("sql"); var t = elm.getAttribute("sql");
if (this.data.size.length) { t += "("+this.data.size+")"; } if (this.data.size.length) { t += "("+this.data.size+")"; }
xml += "<datatype>"+t+"</datatype>\n"; xml += "<datatype>"+t+"</datatype>\n";
if (this.data.def || this.data.def === null) { if (this.data.def || this.data.def === null) {
var q = elm.getAttribute("quote"); var q = elm.getAttribute("quote");
var d = this.data.def; var d = this.data.def;
if (d === null) { if (d === null) {
d = "NULL"; d = "NULL";
} else if (d != "CURRENT_TIMESTAMP") { } else if (d != "CURRENT_TIMESTAMP") {
d = q+d+q; d = q+d+q;
} }
xml += "<default>"+SQL.escape(d)+"</default>"; xml += "<default>"+SQL.escape(d)+"</default>";
} }
@@ -348,27 +350,27 @@ SQL.Row.prototype.toXML = function() {
if (r.row2 != this) { continue; } if (r.row2 != this) { continue; }
xml += '<relation table="'+r.row1.owner.getTitle()+'" row="'+r.row1.getTitle()+'" />\n'; xml += '<relation table="'+r.row1.owner.getTitle()+'" row="'+r.row1.getTitle()+'" />\n';
} }
if (this.data.comment) { if (this.data.comment) {
xml += "<comment>"+SQL.escape(this.data.comment)+"</comment>\n"; xml += "<comment>"+SQL.escape(this.data.comment)+"</comment>\n";
} }
xml += "</row>\n"; xml += "</row>\n";
return xml; return xml;
} }
SQL.Row.prototype.fromXML = function(node) { SQL.Row.prototype.fromXML = function(node) {
var name = node.getAttribute("name"); var name = node.getAttribute("name");
var obj = { type:0, size:"" }; var obj = { type:0, size:"" };
obj.nll = (node.getAttribute("null") == "1"); obj.nll = (node.getAttribute("null") == "1");
obj.ai = (node.getAttribute("autoincrement") == "1"); obj.ai = (node.getAttribute("autoincrement") == "1");
var cs = node.getElementsByTagName("comment"); var cs = node.getElementsByTagName("comment");
if (cs.length && cs[0].firstChild) { obj.comment = cs[0].firstChild.nodeValue; } if (cs.length && cs[0].firstChild) { obj.comment = cs[0].firstChild.nodeValue; }
var d = node.getElementsByTagName("datatype"); var d = node.getElementsByTagName("datatype");
if (d.length && d[0].firstChild) { if (d.length && d[0].firstChild) {
var s = d[0].firstChild.nodeValue; var s = d[0].firstChild.nodeValue;
var r = s.match(/^([^\(]+)(\((.*)\))?.*$/); var r = s.match(/^([^\(]+)(\((.*)\))?.*$/);
var type = r[1]; var type = r[1];
@@ -380,10 +382,10 @@ SQL.Row.prototype.fromXML = function(node) {
if (sql == type || (re && new RegExp(re).exec(type)) ) { obj.type = i; } if (sql == type || (re && new RegExp(re).exec(type)) ) { obj.type = i; }
} }
} }
var elm = DATATYPES.getElementsByTagName("type")[obj.type]; var elm = DATATYPES.getElementsByTagName("type")[obj.type];
var d = node.getElementsByTagName("default"); var d = node.getElementsByTagName("default");
if (d.length && d[0].firstChild) { if (d.length && d[0].firstChild) {
var def = d[0].firstChild.nodeValue; var def = d[0].firstChild.nodeValue;
obj.def = def; obj.def = def;
var q = elm.getAttribute("quote"); var q = elm.getAttribute("quote");
@@ -420,7 +422,7 @@ SQL.Row.prototype.isKey = function() {
} }
SQL.Row.prototype.enter = function(e) { SQL.Row.prototype.enter = function(e) {
if (e.keyCode == 13) { if (e.keyCode == 13) {
this.collapse(); this.collapse();
} }
} }
+209 -53
View File
@@ -1,9 +1,12 @@
body { body {
font-family: verdana, sans serif; font-family: verdana, sans-serif;
font-size: small; font-size: 12px;
padding: 0px; padding: 0px;
margin: 0px; margin: 0px;
background: #FFF; background: #FFF;
font-weight: 400;
line-height: 1.429;
color: rgba(0, 0, 0, .87);
visibility: hidden; visibility: hidden;
-moz-user-select: -moz-none; -moz-user-select: -moz-none;
-khtml-user-select: none; -khtml-user-select: none;
@@ -12,6 +15,158 @@ body {
user-select: none; user-select: none;
} }
input[type=text] {
font-family: verdana, sans-serif;
height: 32px;
display: block;
background-color: transparent;
color: rgba(0, 0, 0, .87);
border: none;
border-bottom-color: currentcolor;
border-bottom-style: none;
border-bottom-width: medium;
border-bottom: 1px solid rgba(0, 0, 0, .26);
outline: 0;
width: 100%;
font-size: 16px;
padding: 0;
box-shadow: none;
border-radius: 0;
background-image: none;
}
input[type=text]:focus {
border-color: #2196F3;
border-width: 2px;
}
textarea {
min-width: 500px;
font-family: verdana, sans-serif;
min-height: 64px;
display: block;
background-color: transparent;
color: rgba(0, 0, 0, .87);
border: none;
border-bottom-color: currentcolor;
border-bottom-style: none;
border-bottom-width: medium;
border-bottom: 1px solid rgba(0, 0, 0, .26);
outline: 0;
width: 100%;
font-size: 16px;
padding: 0;
box-shadow: none;
border-radius: 0;
background-image: none;
}
textarea:focus {
border-color: #2196F3;
border-width: 2px;
}
input[type=button] {
font-family: verdana, sans-serif;
-webkit-appearance: button;
cursor: pointer;
font-weight: 500;
font-size: 14px;
line-height: 18px;
text-transform: uppercase;
color: rgba(0, 0, 0, .87);
background-color: #FFF;
display: inline-block;
height: 36px;
padding: 0 26px;
margin-top: 6px;
margin-bottom: 6px;
border: none;
border-radius: 2px;
cursor: pointer;
-ms-touch-action: manipulation;
touch-action: manipulation;
background-image: none;
text-align: center;
line-height: 36px;
vertical-align: middle;
white-space: nowrap;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
font-size: 14px;
letter-spacing: .03em;
position: relative;
overflow: hidden;
}
legend {
font-weight: bold;
}
label, input, select {
vertical-align: middle;
}
label {
opacity: 0.7;
}
#commentbtn {
box-shadow: 0 0 2px rgba(0, 0, 0, .12), 0 2px 2px rgba(0, 0, 0, .2);
}
#windowok {
color: #FF4081;
}
#windowok, #windowcancel {
float: right;
}
#windowok:hover, #windowcancel:hover {
background-color: #f2f2f2;
}
select {
font-family: verdana, sans-serif;
display: block;
height: 32px;
width: 100%;
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
outline: 0;
border: none;
border-bottom-color: currentcolor;
border-bottom-style: none;
border-bottom-width: medium;
border-bottom: 1px solid rgba(0, 0, 0, .26);
border-radius: 0;
box-shadow: none;
background-color: transparent;
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iNiIgd2lkdGg9IjEwIj48cG9seWdvbiBwb2ludHM9IjAsMCAxMCwwIDUsNiIgc3R5bGU9ImZpbGw6cmdiYSgwLDAsMCwuMjQpOyIvPjwvc3ZnPg==);
background-repeat: no-repeat;
background-position: right center;
cursor: pointer;
color: rgba(0, 0, 0, .87);
font-size: 16px;
padding: 0 25px 0 0;
}
select:focus {
border-color: #2196F3;
border-width: 2px;
}
select optgroup {
color: rgba(0, 0, 0, .54);
font-size: .9em;
background: white !important;
font-style: normal;
}
#area { #area {
position: relative; position: relative;
background: transparent url(../images/back_dim.png); background: transparent url(../images/back_dim.png);
@@ -36,7 +191,6 @@ body {
padding: 0px; padding: 0px;
background-color: rgb(255, 255, 255); background-color: rgb(255, 255, 255);
text-align: center; text-align: center;
color: rgba(0, 0, 0, 0.87);
border-radius: 0px; border-radius: 0px;
box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 6px 0px, rgba(0, 0, 0, 0.23) 0px 3px 6px 0px; box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 6px 0px, rgba(0, 0, 0, 0.23) 0px 3px 6px 0px;
box-sizing: border-box; box-sizing: border-box;
@@ -44,32 +198,26 @@ body {
} }
#bar input { #bar input {
display: block;
cursor: pointer;
transition: all .2s ease-in-out; transition: all .2s ease-in-out;
border-radius: 2px; border-radius: 2px;
width: 100%; width: 100%;
height: auto; height: auto;
background-color: transparent;
border: none;
margin: auto auto 3px auto; margin: auto auto 3px auto;
padding: 2px; padding: 2px;
line-height: 1.3; line-height: 1.3;
font-size: small; font-size: small;
text-transform: uppercase; opacity: .7;
letter-spacing: .03em;
font-family: verdana, sans-serif;
} }
#bar input:hover { #bar input:hover {
background-color: #FF4081; background-color: #e9115d;
color: #fff; color: #fff;
} }
#bar input:disabled { #bar input:disabled {
cursor: not-allowed; cursor: not-allowed;
pointer-events: none; pointer-events: none;
opacity: .6; opacity: .4;
box-shadow: none; box-shadow: none;
} }
@@ -93,10 +241,11 @@ body {
background-position: center; background-position: center;
background-repeat: no-repeat; background-repeat: no-repeat;
height: 21px; height: 21px;
opacity: .7;
} }
#toggle:hover { #toggle:hover {
background-color: #FF4081; background-color: #e9115d;
} }
#toggle.on:hover { #toggle.on:hover {
@@ -124,7 +273,7 @@ body {
background-color: #fff; background-color: #fff;
opacity: 0.9; opacity: 0.9;
overflow: hidden; overflow: hidden;
box-shadow: 0 1px 3px rgba(0,0,0,.12),0 1px 2px rgba(0,0,0,.24); box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 1px 2px rgba(0, 0, 0, .24);
} }
.mini { .mini {
@@ -141,29 +290,21 @@ body {
.port { .port {
position: absolute; position: absolute;
transition: border 0.2s ease-in-out; transition: border 0.2s ease-in-out;
border: 2px solid rgba(0,0,0,.3); border: 2px solid rgba(0, 0, 0, .3);
} }
#minimap:hover .port { #minimap:hover .port {
border: 2px solid rgba(0,0,0,.8); border: 2px solid rgba(0, 0, 0, .8);
} }
.table { .table {
position: absolute; position: absolute;
border: 1px solid #000; padding: 0 6px 6px 6px;
background-color: #ddd;
cursor: pointer; cursor: pointer;
-moz-box-shadow: 4px 4px 8px #888; margin-bottom: 20px;
/* FF 3.5+ */ border-radius: 0;
-webkit-box-shadow: 4px 4px 8px #888; background-color: #FFF;
/* Safari 3.0+, Chrome */ box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .16), 0 0 2px 0 rgba(0, 0, 0, .12);
box-shadow: 4px 4px 8px #888;
/* Opera 10.5, IE 9.0 */
filter: progid:DXImageTransform.Microsoft.Shadow(Strength=5, Direction=135, Color='#888888');
/* IE 6, IE 7 */
-ms-filter: progid:DXImageTransform.Microsoft.Shadow(Strength=5, Direction=135, Color='#888888');
/* IE 8 */
border-radius: 3px;
} }
.table table { .table table {
@@ -171,22 +312,28 @@ body {
} }
.table.selected { .table.selected {
border: 2px solid #000; border: 1px solid #FF4081;
} }
.table thead .title { .table thead .title {
text-align: center; text-align: center;
padding: 3px 30px; padding: 6px 30px;
} }
.table tbody { .table tbody {
border-top: 1px dotted #888; border-right: 4px solid transparent;
background: none !important;
} }
.table tbody td { .table tbody td {
padding: 3px; padding: 3px;
} }
.table tbody.expanded {
border-right: 6px solid rgba(0, 0, 0, .12);
background-color: whitesmoke !important;
}
.table tbody .selected { .table tbody .selected {
font-weight: bold; font-weight: bold;
color: #f00; color: #f00;
@@ -202,7 +349,7 @@ body {
position: absolute; position: absolute;
top: 0; top: 0;
right: 0; right: 0;
border-color: royalblue; border-color: rgb(125, 178, 221);
border-style: solid; border-style: solid;
border-width: 5px; border-width: 5px;
border-bottom-color: transparent; border-bottom-color: transparent;
@@ -215,14 +362,14 @@ body {
.table tbody[title]:not(.expanded):not([title=""]) td:last-child:after { .table tbody[title]:not(.expanded):not([title=""]) td:last-child:after {
content: ''; content: '';
position: absolute; position: relative;
top: 0; border-color: rgb(125, 178, 221);
right: 0;
border-color: royalblue;
border-style: solid; border-style: solid;
border-width: 5px; border-width: 6px;
border-bottom-color: transparent; border-bottom-color: transparent;
border-left-color: transparent; border-left-color: transparent;
border-top-color: transparent;
float: right;
} }
.primary { .primary {
@@ -267,23 +414,23 @@ body {
position: absolute; position: absolute;
visibility: hidden; visibility: hidden;
background-color: #fff; background-color: #fff;
border: 6px double #333; box-shadow: 0 10px 20px rgba(0, 0, 0, .19), 0 6px 6px rgba(0, 0, 0, .23);
padding: 15px;
} }
#windowtitle { #windowtitle {
border-bottom: 2px solid #333; font-size: x-large;
padding: 2px; margin: 15px 15px 24px 15px;
padding-left: 1em; padding-left: 15px;
font-weight: bold; padding-right: 15px;
background-color: rgb(238, 238, 170);
} }
#windowcontent { #windowcontent {
padding: 1em; padding: 1em;
} }
#windowok, #windowcancel { #tablename, #tablecomment {
margin: 0em 1em 1em; margin-bottom: 10px;
} }
.small { .small {
@@ -299,18 +446,27 @@ body {
width: 700px; width: 700px;
} }
#opts td {
padding-top: 15px;
margin-bottom: 20px;
}
#opts #optionsnotice {
opacity: 0.7;
}
#opts hr {
background-color: #ddd;
height: 1px;
border: none;
margin: 25px 0px 25px 0px;
}
#keys { #keys {
white-space: nowrap; white-space: nowrap;
text-align: center; text-align: center;
} }
legend {
font-weight: bold;
}
label, input, select {
vertical-align: middle;
}
#throbber { #throbber {
position: absolute; position: absolute;