mirror of https://github.com/snachodog/mybuddy.git
Update Node dependencies
This commit is contained in:
parent
35c825f223
commit
4639cfb9b0
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
|
@ -7,8 +7,8 @@
|
||||||
"url": "https://github.com/babybuddy/babybuddy.git"
|
"url": "https://github.com/babybuddy/babybuddy.git"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"bootstrap": "4.5.0",
|
"bootstrap": "4.5.3",
|
||||||
"del": "^5.1.0",
|
"del": "^6.0.0",
|
||||||
"font-awesome": "^4.7.0",
|
"font-awesome": "^4.7.0",
|
||||||
"gulp": "^4.0.2",
|
"gulp": "^4.0.2",
|
||||||
"gulp-concat": "^2.6.1",
|
"gulp-concat": "^2.6.1",
|
||||||
|
@ -20,13 +20,13 @@
|
||||||
"gulp-stylelint": "^13.0.0",
|
"gulp-stylelint": "^13.0.0",
|
||||||
"gulp-uglify": "^3.0.2",
|
"gulp-uglify": "^3.0.2",
|
||||||
"jquery": "^3.5.1",
|
"jquery": "^3.5.1",
|
||||||
"moment": "^2.27.0",
|
"moment": "^2.29.1",
|
||||||
"moment-timezone": "^0.5.31",
|
"moment-timezone": "^0.5.31",
|
||||||
"plotly.js": "^1.54.6",
|
"plotly.js": "^1.57.1",
|
||||||
"popper.js": "^1.16.1",
|
"popper.js": "^1.16.1",
|
||||||
"pulltorefreshjs": "^0.1.20",
|
"pulltorefreshjs": "^0.1.20",
|
||||||
"pump": "^3.0.0",
|
"pump": "^3.0.0",
|
||||||
"stylelint": "^13.6.1",
|
"stylelint": "^13.7.2",
|
||||||
"stylelint-config-recommended-scss": "^4.2.0",
|
"stylelint-config-recommended-scss": "^4.2.0",
|
||||||
"stylelint-order": "^4.1.0",
|
"stylelint-order": "^4.1.0",
|
||||||
"stylelint-scss": "^3.18.0",
|
"stylelint-scss": "^3.18.0",
|
||||||
|
|
Binary file not shown.
|
@ -4,6 +4,10 @@
|
||||||
|
|
||||||
@import url(fonts.css);
|
@import url(fonts.css);
|
||||||
|
|
||||||
|
html, body {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
@ -94,7 +98,7 @@ h5 {
|
||||||
letter-spacing: 1px;
|
letter-spacing: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul li {
|
ul > li {
|
||||||
list-style-type: square;
|
list-style-type: square;
|
||||||
padding: 1px 0;
|
padding: 1px 0;
|
||||||
}
|
}
|
||||||
|
@ -124,6 +128,7 @@ form {
|
||||||
|
|
||||||
fieldset {
|
fieldset {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
min-width: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border: none;
|
border: none;
|
||||||
border-top: 1px solid #eee;
|
border-top: 1px solid #eee;
|
||||||
|
@ -141,6 +146,7 @@ code, pre {
|
||||||
font-family: "Bitstream Vera Sans Mono", Monaco, "Courier New", Courier, monospace;
|
font-family: "Bitstream Vera Sans Mono", Monaco, "Courier New", Courier, monospace;
|
||||||
color: #666;
|
color: #666;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
overflow-x: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
pre.literal-block {
|
pre.literal-block {
|
||||||
|
@ -171,22 +177,10 @@ hr {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tiny {
|
|
||||||
font-size: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.tiny {
|
|
||||||
margin-top: -2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mini {
|
.mini {
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.mini {
|
|
||||||
margin-top: -3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.help, p.help, form p.help, div.help, form div.help, div.help li {
|
.help, p.help, form p.help, div.help, form div.help, div.help li {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
color: #999;
|
color: #999;
|
||||||
|
@ -209,32 +203,10 @@ p img, h1 img, h2 img, h3 img, h4 img, td img {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
.float-right {
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.float-left {
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.clear {
|
.clear {
|
||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
|
|
||||||
.align-left {
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.align-right {
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.example {
|
|
||||||
margin: 10px 0;
|
|
||||||
padding: 5px 10px;
|
|
||||||
background: #efefef;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nowrap {
|
.nowrap {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
@ -284,11 +256,14 @@ tr.alt {
|
||||||
background: #f6f6f6;
|
background: #f6f6f6;
|
||||||
}
|
}
|
||||||
|
|
||||||
.row1 {
|
tr:nth-child(odd), .row-form-errors {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.row2 {
|
tr:nth-child(even),
|
||||||
|
tr:nth-child(even) .errorlist,
|
||||||
|
tr:nth-child(odd) + .row-form-errors,
|
||||||
|
tr:nth-child(odd) + .row-form-errors .errorlist {
|
||||||
background: #f9f9f9;
|
background: #f9f9f9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -620,24 +595,11 @@ td ul.errorlist li {
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.errors input, .errors select, .errors textarea {
|
.errors input, .errors select, .errors textarea,
|
||||||
|
td ul.errorlist + input, td ul.errorlist + select, td ul.errorlist + textarea {
|
||||||
border: 1px solid #ba2121;
|
border: 1px solid #ba2121;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.system-message {
|
|
||||||
background: #ffc;
|
|
||||||
margin: 10px;
|
|
||||||
padding: 6px 8px;
|
|
||||||
font-size: .8em;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.system-message p.system-message-title {
|
|
||||||
padding: 4px 5px 4px 25px;
|
|
||||||
margin: 0;
|
|
||||||
color: #c11;
|
|
||||||
background: #ffefef url(../img/icon-no.svg) 5px 5px no-repeat;
|
|
||||||
}
|
|
||||||
|
|
||||||
.description {
|
.description {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
padding: 5px 0 0 12px;
|
padding: 5px 0 0 12px;
|
||||||
|
@ -774,6 +736,23 @@ table#change-history tbody th {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-width: 980px;
|
min-width: 980px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#container > div {
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#container > .main {
|
||||||
|
display: flex;
|
||||||
|
flex: 1 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main > .content {
|
||||||
|
flex: 1 0;
|
||||||
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#content {
|
#content {
|
||||||
|
|
Binary file not shown.
|
@ -4,6 +4,10 @@
|
||||||
|
|
||||||
@import url("fonts.168bab448fee.css");
|
@import url("fonts.168bab448fee.css");
|
||||||
|
|
||||||
|
html, body {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
@ -94,7 +98,7 @@ h5 {
|
||||||
letter-spacing: 1px;
|
letter-spacing: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul li {
|
ul > li {
|
||||||
list-style-type: square;
|
list-style-type: square;
|
||||||
padding: 1px 0;
|
padding: 1px 0;
|
||||||
}
|
}
|
||||||
|
@ -124,6 +128,7 @@ form {
|
||||||
|
|
||||||
fieldset {
|
fieldset {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
min-width: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border: none;
|
border: none;
|
||||||
border-top: 1px solid #eee;
|
border-top: 1px solid #eee;
|
||||||
|
@ -141,6 +146,7 @@ code, pre {
|
||||||
font-family: "Bitstream Vera Sans Mono", Monaco, "Courier New", Courier, monospace;
|
font-family: "Bitstream Vera Sans Mono", Monaco, "Courier New", Courier, monospace;
|
||||||
color: #666;
|
color: #666;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
overflow-x: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
pre.literal-block {
|
pre.literal-block {
|
||||||
|
@ -171,22 +177,10 @@ hr {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tiny {
|
|
||||||
font-size: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.tiny {
|
|
||||||
margin-top: -2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mini {
|
.mini {
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.mini {
|
|
||||||
margin-top: -3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.help, p.help, form p.help, div.help, form div.help, div.help li {
|
.help, p.help, form p.help, div.help, form div.help, div.help li {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
color: #999;
|
color: #999;
|
||||||
|
@ -209,32 +203,10 @@ p img, h1 img, h2 img, h3 img, h4 img, td img {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
.float-right {
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.float-left {
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.clear {
|
.clear {
|
||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
|
|
||||||
.align-left {
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.align-right {
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.example {
|
|
||||||
margin: 10px 0;
|
|
||||||
padding: 5px 10px;
|
|
||||||
background: #efefef;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nowrap {
|
.nowrap {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
@ -284,11 +256,14 @@ tr.alt {
|
||||||
background: #f6f6f6;
|
background: #f6f6f6;
|
||||||
}
|
}
|
||||||
|
|
||||||
.row1 {
|
tr:nth-child(odd), .row-form-errors {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.row2 {
|
tr:nth-child(even),
|
||||||
|
tr:nth-child(even) .errorlist,
|
||||||
|
tr:nth-child(odd) + .row-form-errors,
|
||||||
|
tr:nth-child(odd) + .row-form-errors .errorlist {
|
||||||
background: #f9f9f9;
|
background: #f9f9f9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -620,24 +595,11 @@ td ul.errorlist li {
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.errors input, .errors select, .errors textarea {
|
.errors input, .errors select, .errors textarea,
|
||||||
|
td ul.errorlist + input, td ul.errorlist + select, td ul.errorlist + textarea {
|
||||||
border: 1px solid #ba2121;
|
border: 1px solid #ba2121;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.system-message {
|
|
||||||
background: #ffc;
|
|
||||||
margin: 10px;
|
|
||||||
padding: 6px 8px;
|
|
||||||
font-size: .8em;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.system-message p.system-message-title {
|
|
||||||
padding: 4px 5px 4px 25px;
|
|
||||||
margin: 0;
|
|
||||||
color: #c11;
|
|
||||||
background: #ffefef url("../img/icon-no.439e821418cd.svg") 5px 5px no-repeat;
|
|
||||||
}
|
|
||||||
|
|
||||||
.description {
|
.description {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
padding: 5px 0 0 12px;
|
padding: 5px 0 0 12px;
|
||||||
|
@ -774,6 +736,23 @@ table#change-history tbody th {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-width: 980px;
|
min-width: 980px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#container > div {
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#container > .main {
|
||||||
|
display: flex;
|
||||||
|
flex: 1 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main > .content {
|
||||||
|
flex: 1 0;
|
||||||
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#content {
|
#content {
|
Binary file not shown.
|
@ -155,7 +155,6 @@
|
||||||
|
|
||||||
#changelist-filter ul:last-child {
|
#changelist-filter ul:last-child {
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
padding-bottom: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#changelist-filter li {
|
#changelist-filter li {
|
||||||
|
@ -187,6 +186,12 @@
|
||||||
color: #036;
|
color: #036;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#changelist-filter #changelist-filter-clear a {
|
||||||
|
font-size: 13px;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
border-bottom: 1px solid #eaeaea;
|
||||||
|
}
|
||||||
|
|
||||||
/* DATE DRILLDOWN */
|
/* DATE DRILLDOWN */
|
||||||
|
|
||||||
.change-list ul.toplinks {
|
.change-list ul.toplinks {
|
||||||
|
@ -232,7 +237,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.paginator a.showall {
|
.paginator a.showall {
|
||||||
padding: 0;
|
|
||||||
border: none;
|
border: none;
|
||||||
background: none;
|
background: none;
|
||||||
color: #5b80b2;
|
color: #5b80b2;
|
Binary file not shown.
Binary file not shown.
|
@ -155,7 +155,6 @@
|
||||||
|
|
||||||
#changelist-filter ul:last-child {
|
#changelist-filter ul:last-child {
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
padding-bottom: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#changelist-filter li {
|
#changelist-filter li {
|
||||||
|
@ -187,6 +186,12 @@
|
||||||
color: #036;
|
color: #036;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#changelist-filter #changelist-filter-clear a {
|
||||||
|
font-size: 13px;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
border-bottom: 1px solid #eaeaea;
|
||||||
|
}
|
||||||
|
|
||||||
/* DATE DRILLDOWN */
|
/* DATE DRILLDOWN */
|
||||||
|
|
||||||
.change-list ul.toplinks {
|
.change-list ul.toplinks {
|
||||||
|
@ -232,7 +237,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.paginator a.showall {
|
.paginator a.showall {
|
||||||
padding: 0;
|
|
||||||
border: none;
|
border: none;
|
||||||
background: none;
|
background: none;
|
||||||
color: #5b80b2;
|
color: #5b80b2;
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -23,5 +23,4 @@ ul.actionlist li {
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
-o-text-overflow: ellipsis;
|
|
||||||
}
|
}
|
Binary file not shown.
|
@ -23,5 +23,4 @@ ul.actionlist li {
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
-o-text-overflow: ellipsis;
|
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -1,4 +1,4 @@
|
||||||
@import url("widgets.8874c301e7bc.css");
|
@import url("widgets.b12c020d05e0.css");
|
||||||
|
|
||||||
/* FORM ROWS */
|
/* FORM ROWS */
|
||||||
|
|
||||||
|
@ -501,7 +501,7 @@ body.popup .submit-row {
|
||||||
|
|
||||||
/* RELATED FIELD ADD ONE / LOOKUP */
|
/* RELATED FIELD ADD ONE / LOOKUP */
|
||||||
|
|
||||||
.add-another, .related-lookup {
|
.related-lookup {
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
@ -509,12 +509,6 @@ body.popup .submit-row {
|
||||||
background-size: 14px;
|
background-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.add-another {
|
|
||||||
width: 16px;
|
|
||||||
height: 16px;
|
|
||||||
background-image: url("../img/icon-addlink.d519b3bab011.svg");
|
|
||||||
}
|
|
||||||
|
|
||||||
.related-lookup {
|
.related-lookup {
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
Binary file not shown.
Binary file not shown.
|
@ -501,7 +501,7 @@ body.popup .submit-row {
|
||||||
|
|
||||||
/* RELATED FIELD ADD ONE / LOOKUP */
|
/* RELATED FIELD ADD ONE / LOOKUP */
|
||||||
|
|
||||||
.add-another, .related-lookup {
|
.related-lookup {
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
@ -509,12 +509,6 @@ body.popup .submit-row {
|
||||||
background-size: 14px;
|
background-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.add-another {
|
|
||||||
width: 16px;
|
|
||||||
height: 16px;
|
|
||||||
background-image: url(../img/icon-addlink.svg);
|
|
||||||
}
|
|
||||||
|
|
||||||
.related-lookup {
|
.related-lookup {
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,7 +1,8 @@
|
||||||
/* LOGIN FORM */
|
/* LOGIN FORM */
|
||||||
|
|
||||||
body.login {
|
.login {
|
||||||
background: #f8f8f8;
|
background: #f8f8f8;
|
||||||
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.login #header {
|
.login #header {
|
||||||
|
@ -30,6 +31,7 @@ body.login {
|
||||||
width: 28em;
|
width: 28em;
|
||||||
min-width: 300px;
|
min-width: 300px;
|
||||||
margin: 100px auto;
|
margin: 100px auto;
|
||||||
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.login #content-main {
|
.login #content-main {
|
||||||
|
@ -55,9 +57,7 @@ body.login {
|
||||||
clear: both;
|
clear: both;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
-webkit-box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
-moz-box-sizing: border-box;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.login span.help {
|
.login span.help {
|
||||||
|
|
Binary file not shown.
|
@ -1,7 +1,8 @@
|
||||||
/* LOGIN FORM */
|
/* LOGIN FORM */
|
||||||
|
|
||||||
body.login {
|
.login {
|
||||||
background: #f8f8f8;
|
background: #f8f8f8;
|
||||||
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.login #header {
|
.login #header {
|
||||||
|
@ -30,6 +31,7 @@ body.login {
|
||||||
width: 28em;
|
width: 28em;
|
||||||
min-width: 300px;
|
min-width: 300px;
|
||||||
margin: 100px auto;
|
margin: 100px auto;
|
||||||
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.login #content-main {
|
.login #content-main {
|
||||||
|
@ -55,9 +57,7 @@ body.login {
|
||||||
clear: both;
|
clear: both;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
-webkit-box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
-moz-box-sizing: border-box;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.login span.help {
|
.login span.help {
|
Binary file not shown.
|
@ -0,0 +1,101 @@
|
||||||
|
.sticky {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
max-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-nav-sidebar {
|
||||||
|
z-index: 20;
|
||||||
|
left: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex: 0 0 23px;
|
||||||
|
width: 23px;
|
||||||
|
border-right: 1px solid #eaeaea;
|
||||||
|
background-color: #ffffff;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 20px;
|
||||||
|
color: #447e9b;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
[dir="rtl"] .toggle-nav-sidebar {
|
||||||
|
border-left: 1px solid #eaeaea;
|
||||||
|
border-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-nav-sidebar:hover,
|
||||||
|
.toggle-nav-sidebar:focus {
|
||||||
|
background-color: #f6f6f6;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav-sidebar {
|
||||||
|
z-index: 15;
|
||||||
|
flex: 0 0 275px;
|
||||||
|
left: -276px;
|
||||||
|
margin-left: -276px;
|
||||||
|
border-top: 1px solid transparent;
|
||||||
|
border-right: 1px solid #eaeaea;
|
||||||
|
background-color: #ffffff;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
[dir="rtl"] #nav-sidebar {
|
||||||
|
border-left: 1px solid #eaeaea;
|
||||||
|
border-right: 0;
|
||||||
|
left: 0;
|
||||||
|
margin-left: 0;
|
||||||
|
right: -276px;
|
||||||
|
margin-right: -276px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-nav-sidebar::before {
|
||||||
|
content: '\00BB';
|
||||||
|
}
|
||||||
|
|
||||||
|
.main.shifted .toggle-nav-sidebar::before {
|
||||||
|
content: '\00AB';
|
||||||
|
}
|
||||||
|
|
||||||
|
.main.shifted > #nav-sidebar {
|
||||||
|
left: 24px;
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
[dir="rtl"] .main.shifted > #nav-sidebar {
|
||||||
|
left: 0;
|
||||||
|
right: 24px;
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav-sidebar .module th {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav-sidebar .module th,
|
||||||
|
#nav-sidebar .module caption {
|
||||||
|
padding-left: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
[dir="rtl"] #nav-sidebar .module th,
|
||||||
|
[dir="rtl"] #nav-sidebar .module caption {
|
||||||
|
padding-left: 8px;
|
||||||
|
padding-right: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav-sidebar .current-app .section:link,
|
||||||
|
#nav-sidebar .current-app .section:visited {
|
||||||
|
color: #ffc;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav-sidebar .current-model {
|
||||||
|
background: #ffc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 767px) {
|
||||||
|
#nav-sidebar, #toggle-nav-sidebar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,101 @@
|
||||||
|
.sticky {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
max-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-nav-sidebar {
|
||||||
|
z-index: 20;
|
||||||
|
left: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex: 0 0 23px;
|
||||||
|
width: 23px;
|
||||||
|
border-right: 1px solid #eaeaea;
|
||||||
|
background-color: #ffffff;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 20px;
|
||||||
|
color: #447e9b;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
[dir="rtl"] .toggle-nav-sidebar {
|
||||||
|
border-left: 1px solid #eaeaea;
|
||||||
|
border-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-nav-sidebar:hover,
|
||||||
|
.toggle-nav-sidebar:focus {
|
||||||
|
background-color: #f6f6f6;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav-sidebar {
|
||||||
|
z-index: 15;
|
||||||
|
flex: 0 0 275px;
|
||||||
|
left: -276px;
|
||||||
|
margin-left: -276px;
|
||||||
|
border-top: 1px solid transparent;
|
||||||
|
border-right: 1px solid #eaeaea;
|
||||||
|
background-color: #ffffff;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
[dir="rtl"] #nav-sidebar {
|
||||||
|
border-left: 1px solid #eaeaea;
|
||||||
|
border-right: 0;
|
||||||
|
left: 0;
|
||||||
|
margin-left: 0;
|
||||||
|
right: -276px;
|
||||||
|
margin-right: -276px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-nav-sidebar::before {
|
||||||
|
content: '\00BB';
|
||||||
|
}
|
||||||
|
|
||||||
|
.main.shifted .toggle-nav-sidebar::before {
|
||||||
|
content: '\00AB';
|
||||||
|
}
|
||||||
|
|
||||||
|
.main.shifted > #nav-sidebar {
|
||||||
|
left: 24px;
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
[dir="rtl"] .main.shifted > #nav-sidebar {
|
||||||
|
left: 0;
|
||||||
|
right: 24px;
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav-sidebar .module th {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav-sidebar .module th,
|
||||||
|
#nav-sidebar .module caption {
|
||||||
|
padding-left: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
[dir="rtl"] #nav-sidebar .module th,
|
||||||
|
[dir="rtl"] #nav-sidebar .module caption {
|
||||||
|
padding-left: 8px;
|
||||||
|
padding-right: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav-sidebar .current-app .section:link,
|
||||||
|
#nav-sidebar .current-app .section:visited {
|
||||||
|
color: #ffc;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav-sidebar .current-model {
|
||||||
|
background: #ffc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 767px) {
|
||||||
|
#nav-sidebar, #toggle-nav-sidebar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
|
@ -99,9 +99,7 @@ input[type="submit"], button {
|
||||||
}
|
}
|
||||||
|
|
||||||
#changelist-search > div {
|
#changelist-search > div {
|
||||||
display: -webkit-flex;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
-webkit-flex-wrap: wrap;
|
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
max-width: 480px;
|
max-width: 480px;
|
||||||
}
|
}
|
||||||
|
@ -111,7 +109,6 @@ input[type="submit"], button {
|
||||||
}
|
}
|
||||||
|
|
||||||
#changelist #toolbar form #searchbar {
|
#changelist #toolbar form #searchbar {
|
||||||
-webkit-flex: 1 0 auto;
|
|
||||||
flex: 1 0 auto;
|
flex: 1 0 auto;
|
||||||
width: 0;
|
width: 0;
|
||||||
height: 22px;
|
height: 22px;
|
||||||
|
@ -226,7 +223,6 @@ input[type="submit"], button {
|
||||||
padding-top: 6px;
|
padding-top: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.aligned .add-another,
|
|
||||||
.aligned .related-lookup,
|
.aligned .related-lookup,
|
||||||
.aligned .datetimeshortcuts,
|
.aligned .datetimeshortcuts,
|
||||||
.aligned .related-lookup + strong {
|
.aligned .related-lookup + strong {
|
||||||
|
@ -354,6 +350,14 @@ input[type="submit"], button {
|
||||||
}
|
}
|
||||||
|
|
||||||
.stacked .active.selector-add {
|
.stacked .active.selector-add {
|
||||||
|
background-position: 0 -40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.active.selector-add:focus, .active.selector-add:hover {
|
||||||
|
background-position: 0 -140px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stacked .active.selector-add:focus, .stacked .active.selector-add:hover {
|
||||||
background-position: 0 -60px;
|
background-position: 0 -60px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,6 +366,14 @@ input[type="submit"], button {
|
||||||
}
|
}
|
||||||
|
|
||||||
.stacked .active.selector-remove {
|
.stacked .active.selector-remove {
|
||||||
|
background-position: 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.active.selector-remove:focus, .active.selector-remove:hover {
|
||||||
|
background-position: 0 -100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stacked .active.selector-remove:focus, .stacked .active.selector-remove:hover {
|
||||||
background-position: 0 -20px;
|
background-position: 0 -20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -725,10 +737,18 @@ input[type="submit"], button {
|
||||||
background-position: 0 0;
|
background-position: 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.active.selector-remove:focus, .active.selector-remove:hover {
|
||||||
|
background-position: 0 -20px;
|
||||||
|
}
|
||||||
|
|
||||||
.selector-add {
|
.selector-add {
|
||||||
background-position: 0 -40px;
|
background-position: 0 -40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.active.selector-add:focus, .active.selector-add:hover {
|
||||||
|
background-position: 0 -60px;
|
||||||
|
}
|
||||||
|
|
||||||
/* Inlines */
|
/* Inlines */
|
||||||
|
|
||||||
.inline-group[data-inline-type="stacked"] .inline-related {
|
.inline-group[data-inline-type="stacked"] .inline-related {
|
Binary file not shown.
|
@ -99,9 +99,7 @@ input[type="submit"], button {
|
||||||
}
|
}
|
||||||
|
|
||||||
#changelist-search > div {
|
#changelist-search > div {
|
||||||
display: -webkit-flex;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
-webkit-flex-wrap: wrap;
|
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
max-width: 480px;
|
max-width: 480px;
|
||||||
}
|
}
|
||||||
|
@ -111,7 +109,6 @@ input[type="submit"], button {
|
||||||
}
|
}
|
||||||
|
|
||||||
#changelist #toolbar form #searchbar {
|
#changelist #toolbar form #searchbar {
|
||||||
-webkit-flex: 1 0 auto;
|
|
||||||
flex: 1 0 auto;
|
flex: 1 0 auto;
|
||||||
width: 0;
|
width: 0;
|
||||||
height: 22px;
|
height: 22px;
|
||||||
|
@ -226,7 +223,6 @@ input[type="submit"], button {
|
||||||
padding-top: 6px;
|
padding-top: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.aligned .add-another,
|
|
||||||
.aligned .related-lookup,
|
.aligned .related-lookup,
|
||||||
.aligned .datetimeshortcuts,
|
.aligned .datetimeshortcuts,
|
||||||
.aligned .related-lookup + strong {
|
.aligned .related-lookup + strong {
|
||||||
|
@ -354,6 +350,14 @@ input[type="submit"], button {
|
||||||
}
|
}
|
||||||
|
|
||||||
.stacked .active.selector-add {
|
.stacked .active.selector-add {
|
||||||
|
background-position: 0 -40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.active.selector-add:focus, .active.selector-add:hover {
|
||||||
|
background-position: 0 -140px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stacked .active.selector-add:focus, .stacked .active.selector-add:hover {
|
||||||
background-position: 0 -60px;
|
background-position: 0 -60px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,6 +366,14 @@ input[type="submit"], button {
|
||||||
}
|
}
|
||||||
|
|
||||||
.stacked .active.selector-remove {
|
.stacked .active.selector-remove {
|
||||||
|
background-position: 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.active.selector-remove:focus, .active.selector-remove:hover {
|
||||||
|
background-position: 0 -100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stacked .active.selector-remove:focus, .stacked .active.selector-remove:hover {
|
||||||
background-position: 0 -20px;
|
background-position: 0 -20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -725,10 +737,18 @@ input[type="submit"], button {
|
||||||
background-position: 0 0;
|
background-position: 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.active.selector-remove:focus, .active.selector-remove:hover {
|
||||||
|
background-position: 0 -20px;
|
||||||
|
}
|
||||||
|
|
||||||
.selector-add {
|
.selector-add {
|
||||||
background-position: 0 -40px;
|
background-position: 0 -40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.active.selector-add:focus, .active.selector-add:hover {
|
||||||
|
background-position: 0 -60px;
|
||||||
|
}
|
||||||
|
|
||||||
/* Inlines */
|
/* Inlines */
|
||||||
|
|
||||||
.inline-group[data-inline-type="stacked"] .inline-related {
|
.inline-group[data-inline-type="stacked"] .inline-related {
|
||||||
|
|
Binary file not shown.
|
@ -71,7 +71,6 @@
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[dir="rtl"] .aligned .add-another,
|
|
||||||
[dir="rtl"] .aligned .related-lookup,
|
[dir="rtl"] .aligned .related-lookup,
|
||||||
[dir="rtl"] .aligned .datetimeshortcuts {
|
[dir="rtl"] .aligned .datetimeshortcuts {
|
||||||
margin-left: 0;
|
margin-left: 0;
|
Binary file not shown.
Binary file not shown.
|
@ -71,7 +71,6 @@
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[dir="rtl"] .aligned .add-another,
|
|
||||||
[dir="rtl"] .aligned .related-lookup,
|
[dir="rtl"] .aligned .related-lookup,
|
||||||
[dir="rtl"] .aligned .datetimeshortcuts {
|
[dir="rtl"] .aligned .datetimeshortcuts {
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -257,13 +257,3 @@ form .form-row p.datetime {
|
||||||
margin-left: inherit;
|
margin-left: inherit;
|
||||||
margin-right: 2px;
|
margin-right: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* IE7 specific bug fixes */
|
|
||||||
|
|
||||||
div.colM {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.submit-row input {
|
|
||||||
float: left;
|
|
||||||
}
|
|
Binary file not shown.
|
@ -257,13 +257,3 @@ form .form-row p.datetime {
|
||||||
margin-left: inherit;
|
margin-left: inherit;
|
||||||
margin-right: 2px;
|
margin-right: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* IE7 specific bug fixes */
|
|
||||||
|
|
||||||
div.colM {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.submit-row input {
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
Binary file not shown.
|
@ -188,16 +188,13 @@
|
||||||
width: 100%; }
|
width: 100%; }
|
||||||
.select2-container--default .select2-selection--multiple .select2-selection__rendered li {
|
.select2-container--default .select2-selection--multiple .select2-selection__rendered li {
|
||||||
list-style: none; }
|
list-style: none; }
|
||||||
.select2-container--default .select2-selection--multiple .select2-selection__placeholder {
|
|
||||||
color: #999;
|
|
||||||
margin-top: 5px;
|
|
||||||
float: left; }
|
|
||||||
.select2-container--default .select2-selection--multiple .select2-selection__clear {
|
.select2-container--default .select2-selection--multiple .select2-selection__clear {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
float: right;
|
float: right;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
margin-right: 10px; }
|
margin-right: 10px;
|
||||||
|
padding: 1px; }
|
||||||
.select2-container--default .select2-selection--multiple .select2-selection__choice {
|
.select2-container--default .select2-selection--multiple .select2-selection__choice {
|
||||||
background-color: #e4e4e4;
|
background-color: #e4e4e4;
|
||||||
border: 1px solid #aaa;
|
border: 1px solid #aaa;
|
||||||
|
@ -216,7 +213,7 @@
|
||||||
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
|
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
|
||||||
color: #333; }
|
color: #333; }
|
||||||
|
|
||||||
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline {
|
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline {
|
||||||
float: right; }
|
float: right; }
|
||||||
|
|
||||||
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
|
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
|
Binary file not shown.
|
@ -188,16 +188,13 @@
|
||||||
width: 100%; }
|
width: 100%; }
|
||||||
.select2-container--default .select2-selection--multiple .select2-selection__rendered li {
|
.select2-container--default .select2-selection--multiple .select2-selection__rendered li {
|
||||||
list-style: none; }
|
list-style: none; }
|
||||||
.select2-container--default .select2-selection--multiple .select2-selection__placeholder {
|
|
||||||
color: #999;
|
|
||||||
margin-top: 5px;
|
|
||||||
float: left; }
|
|
||||||
.select2-container--default .select2-selection--multiple .select2-selection__clear {
|
.select2-container--default .select2-selection--multiple .select2-selection__clear {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
float: right;
|
float: right;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
margin-right: 10px; }
|
margin-right: 10px;
|
||||||
|
padding: 1px; }
|
||||||
.select2-container--default .select2-selection--multiple .select2-selection__choice {
|
.select2-container--default .select2-selection--multiple .select2-selection__choice {
|
||||||
background-color: #e4e4e4;
|
background-color: #e4e4e4;
|
||||||
border: 1px solid #aaa;
|
border: 1px solid #aaa;
|
||||||
|
@ -216,7 +213,7 @@
|
||||||
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
|
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
|
||||||
color: #333; }
|
color: #333; }
|
||||||
|
|
||||||
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline {
|
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline {
|
||||||
float: right; }
|
float: right; }
|
||||||
|
|
||||||
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
|
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
|
||||||
|
|
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
|
@ -211,6 +211,11 @@ a.active.selector-clearall:focus, a.active.selector-clearall:hover {
|
||||||
}
|
}
|
||||||
|
|
||||||
.stacked .active.selector-add {
|
.stacked .active.selector-add {
|
||||||
|
background-position: 0 -32px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stacked .active.selector-add:focus, .stacked .active.selector-add:hover {
|
||||||
background-position: 0 -48px;
|
background-position: 0 -48px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
@ -221,6 +226,11 @@ a.active.selector-clearall:focus, a.active.selector-clearall:hover {
|
||||||
}
|
}
|
||||||
|
|
||||||
.stacked .active.selector-remove {
|
.stacked .active.selector-remove {
|
||||||
|
background-position: 0 0px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stacked .active.selector-remove:focus, .stacked .active.selector-remove:hover {
|
||||||
background-position: 0 -16px;
|
background-position: 0 -16px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
Binary file not shown.
|
@ -211,6 +211,11 @@ a.active.selector-clearall:focus, a.active.selector-clearall:hover {
|
||||||
}
|
}
|
||||||
|
|
||||||
.stacked .active.selector-add {
|
.stacked .active.selector-add {
|
||||||
|
background-position: 0 -32px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stacked .active.selector-add:focus, .stacked .active.selector-add:hover {
|
||||||
background-position: 0 -48px;
|
background-position: 0 -48px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
@ -221,6 +226,11 @@ a.active.selector-clearall:focus, a.active.selector-clearall:hover {
|
||||||
}
|
}
|
||||||
|
|
||||||
.stacked .active.selector-remove {
|
.stacked .active.selector-remove {
|
||||||
|
background-position: 0 0px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stacked .active.selector-remove:focus, .stacked .active.selector-remove:hover {
|
||||||
background-position: 0 -16px;
|
background-position: 0 -16px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,110 @@
|
||||||
|
'use strict';
|
||||||
|
{
|
||||||
|
const SelectBox = {
|
||||||
|
cache: {},
|
||||||
|
init: function(id) {
|
||||||
|
const box = document.getElementById(id);
|
||||||
|
SelectBox.cache[id] = [];
|
||||||
|
const cache = SelectBox.cache[id];
|
||||||
|
for (const node of box.options) {
|
||||||
|
cache.push({value: node.value, text: node.text, displayed: 1});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
redisplay: function(id) {
|
||||||
|
// Repopulate HTML select box from cache
|
||||||
|
const box = document.getElementById(id);
|
||||||
|
box.innerHTML = '';
|
||||||
|
for (const node of SelectBox.cache[id]) {
|
||||||
|
if (node.displayed) {
|
||||||
|
const new_option = new Option(node.text, node.value, false, false);
|
||||||
|
// Shows a tooltip when hovering over the option
|
||||||
|
new_option.title = node.text;
|
||||||
|
box.appendChild(new_option);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
filter: function(id, text) {
|
||||||
|
// Redisplay the HTML select box, displaying only the choices containing ALL
|
||||||
|
// the words in text. (It's an AND search.)
|
||||||
|
const tokens = text.toLowerCase().split(/\s+/);
|
||||||
|
for (const node of SelectBox.cache[id]) {
|
||||||
|
node.displayed = 1;
|
||||||
|
const node_text = node.text.toLowerCase();
|
||||||
|
for (const token of tokens) {
|
||||||
|
if (node_text.indexOf(token) === -1) {
|
||||||
|
node.displayed = 0;
|
||||||
|
break; // Once the first token isn't found we're done
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SelectBox.redisplay(id);
|
||||||
|
},
|
||||||
|
delete_from_cache: function(id, value) {
|
||||||
|
let delete_index = null;
|
||||||
|
const cache = SelectBox.cache[id];
|
||||||
|
for (const [i, node] of cache.entries()) {
|
||||||
|
if (node.value === value) {
|
||||||
|
delete_index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cache.splice(delete_index, 1);
|
||||||
|
},
|
||||||
|
add_to_cache: function(id, option) {
|
||||||
|
SelectBox.cache[id].push({value: option.value, text: option.text, displayed: 1});
|
||||||
|
},
|
||||||
|
cache_contains: function(id, value) {
|
||||||
|
// Check if an item is contained in the cache
|
||||||
|
for (const node of SelectBox.cache[id]) {
|
||||||
|
if (node.value === value) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
move: function(from, to) {
|
||||||
|
const from_box = document.getElementById(from);
|
||||||
|
for (const option of from_box.options) {
|
||||||
|
const option_value = option.value;
|
||||||
|
if (option.selected && SelectBox.cache_contains(from, option_value)) {
|
||||||
|
SelectBox.add_to_cache(to, {value: option_value, text: option.text, displayed: 1});
|
||||||
|
SelectBox.delete_from_cache(from, option_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SelectBox.redisplay(from);
|
||||||
|
SelectBox.redisplay(to);
|
||||||
|
},
|
||||||
|
move_all: function(from, to) {
|
||||||
|
const from_box = document.getElementById(from);
|
||||||
|
for (const option of from_box.options) {
|
||||||
|
const option_value = option.value;
|
||||||
|
if (SelectBox.cache_contains(from, option_value)) {
|
||||||
|
SelectBox.add_to_cache(to, {value: option_value, text: option.text, displayed: 1});
|
||||||
|
SelectBox.delete_from_cache(from, option_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SelectBox.redisplay(from);
|
||||||
|
SelectBox.redisplay(to);
|
||||||
|
},
|
||||||
|
sort: function(id) {
|
||||||
|
SelectBox.cache[id].sort(function(a, b) {
|
||||||
|
a = a.text.toLowerCase();
|
||||||
|
b = b.text.toLowerCase();
|
||||||
|
if (a > b) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (a < b) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
select_all: function(id) {
|
||||||
|
const box = document.getElementById(id);
|
||||||
|
for (const option of box.options) {
|
||||||
|
option.selected = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
window.SelectBox = SelectBox;
|
||||||
|
}
|
Binary file not shown.
|
@ -1,144 +0,0 @@
|
||||||
(function($) {
|
|
||||||
'use strict';
|
|
||||||
var SelectBox = {
|
|
||||||
cache: {},
|
|
||||||
init: function(id) {
|
|
||||||
var box = document.getElementById(id);
|
|
||||||
var node;
|
|
||||||
SelectBox.cache[id] = [];
|
|
||||||
var cache = SelectBox.cache[id];
|
|
||||||
var boxOptions = box.options;
|
|
||||||
var boxOptionsLength = boxOptions.length;
|
|
||||||
for (var i = 0, j = boxOptionsLength; i < j; i++) {
|
|
||||||
node = boxOptions[i];
|
|
||||||
cache.push({value: node.value, text: node.text, displayed: 1});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
redisplay: function(id) {
|
|
||||||
// Repopulate HTML select box from cache
|
|
||||||
var box = document.getElementById(id);
|
|
||||||
var node;
|
|
||||||
$(box).empty(); // clear all options
|
|
||||||
var new_options = box.outerHTML.slice(0, -9); // grab just the opening tag
|
|
||||||
var cache = SelectBox.cache[id];
|
|
||||||
for (var i = 0, j = cache.length; i < j; i++) {
|
|
||||||
node = cache[i];
|
|
||||||
if (node.displayed) {
|
|
||||||
var new_option = new Option(node.text, node.value, false, false);
|
|
||||||
// Shows a tooltip when hovering over the option
|
|
||||||
new_option.setAttribute("title", node.text);
|
|
||||||
new_options += new_option.outerHTML;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
new_options += '</select>';
|
|
||||||
box.outerHTML = new_options;
|
|
||||||
},
|
|
||||||
filter: function(id, text) {
|
|
||||||
// Redisplay the HTML select box, displaying only the choices containing ALL
|
|
||||||
// the words in text. (It's an AND search.)
|
|
||||||
var tokens = text.toLowerCase().split(/\s+/);
|
|
||||||
var node, token;
|
|
||||||
var cache = SelectBox.cache[id];
|
|
||||||
for (var i = 0, j = cache.length; i < j; i++) {
|
|
||||||
node = cache[i];
|
|
||||||
node.displayed = 1;
|
|
||||||
var node_text = node.text.toLowerCase();
|
|
||||||
var numTokens = tokens.length;
|
|
||||||
for (var k = 0; k < numTokens; k++) {
|
|
||||||
token = tokens[k];
|
|
||||||
if (node_text.indexOf(token) === -1) {
|
|
||||||
node.displayed = 0;
|
|
||||||
break; // Once the first token isn't found we're done
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SelectBox.redisplay(id);
|
|
||||||
},
|
|
||||||
delete_from_cache: function(id, value) {
|
|
||||||
var node, delete_index = null;
|
|
||||||
var cache = SelectBox.cache[id];
|
|
||||||
for (var i = 0, j = cache.length; i < j; i++) {
|
|
||||||
node = cache[i];
|
|
||||||
if (node.value === value) {
|
|
||||||
delete_index = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cache.splice(delete_index, 1);
|
|
||||||
},
|
|
||||||
add_to_cache: function(id, option) {
|
|
||||||
SelectBox.cache[id].push({value: option.value, text: option.text, displayed: 1});
|
|
||||||
},
|
|
||||||
cache_contains: function(id, value) {
|
|
||||||
// Check if an item is contained in the cache
|
|
||||||
var node;
|
|
||||||
var cache = SelectBox.cache[id];
|
|
||||||
for (var i = 0, j = cache.length; i < j; i++) {
|
|
||||||
node = cache[i];
|
|
||||||
if (node.value === value) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
move: function(from, to) {
|
|
||||||
var from_box = document.getElementById(from);
|
|
||||||
var option;
|
|
||||||
var boxOptions = from_box.options;
|
|
||||||
var boxOptionsLength = boxOptions.length;
|
|
||||||
for (var i = 0, j = boxOptionsLength; i < j; i++) {
|
|
||||||
option = boxOptions[i];
|
|
||||||
var option_value = option.value;
|
|
||||||
if (option.selected && SelectBox.cache_contains(from, option_value)) {
|
|
||||||
SelectBox.add_to_cache(to, {value: option_value, text: option.text, displayed: 1});
|
|
||||||
SelectBox.delete_from_cache(from, option_value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SelectBox.redisplay(from);
|
|
||||||
SelectBox.redisplay(to);
|
|
||||||
},
|
|
||||||
move_all: function(from, to) {
|
|
||||||
var from_box = document.getElementById(from);
|
|
||||||
var option;
|
|
||||||
var boxOptions = from_box.options;
|
|
||||||
var boxOptionsLength = boxOptions.length;
|
|
||||||
for (var i = 0, j = boxOptionsLength; i < j; i++) {
|
|
||||||
option = boxOptions[i];
|
|
||||||
var option_value = option.value;
|
|
||||||
if (SelectBox.cache_contains(from, option_value)) {
|
|
||||||
SelectBox.add_to_cache(to, {value: option_value, text: option.text, displayed: 1});
|
|
||||||
SelectBox.delete_from_cache(from, option_value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SelectBox.redisplay(from);
|
|
||||||
SelectBox.redisplay(to);
|
|
||||||
},
|
|
||||||
sort: function(id) {
|
|
||||||
SelectBox.cache[id].sort(function(a, b) {
|
|
||||||
a = a.text.toLowerCase();
|
|
||||||
b = b.text.toLowerCase();
|
|
||||||
try {
|
|
||||||
if (a > b) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (a < b) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
// silently fail on IE 'unknown' exception
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
} );
|
|
||||||
},
|
|
||||||
select_all: function(id) {
|
|
||||||
var box = document.getElementById(id);
|
|
||||||
var boxOptions = box.options;
|
|
||||||
var boxOptionsLength = boxOptions.length;
|
|
||||||
for (var i = 0; i < boxOptionsLength; i++) {
|
|
||||||
boxOptions[i].selected = 'selected';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
window.SelectBox = SelectBox;
|
|
||||||
})(django.jQuery);
|
|
Binary file not shown.
|
@ -1,51 +1,36 @@
|
||||||
(function($) {
|
'use strict';
|
||||||
'use strict';
|
{
|
||||||
var SelectBox = {
|
const SelectBox = {
|
||||||
cache: {},
|
cache: {},
|
||||||
init: function(id) {
|
init: function(id) {
|
||||||
var box = document.getElementById(id);
|
const box = document.getElementById(id);
|
||||||
var node;
|
|
||||||
SelectBox.cache[id] = [];
|
SelectBox.cache[id] = [];
|
||||||
var cache = SelectBox.cache[id];
|
const cache = SelectBox.cache[id];
|
||||||
var boxOptions = box.options;
|
for (const node of box.options) {
|
||||||
var boxOptionsLength = boxOptions.length;
|
|
||||||
for (var i = 0, j = boxOptionsLength; i < j; i++) {
|
|
||||||
node = boxOptions[i];
|
|
||||||
cache.push({value: node.value, text: node.text, displayed: 1});
|
cache.push({value: node.value, text: node.text, displayed: 1});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
redisplay: function(id) {
|
redisplay: function(id) {
|
||||||
// Repopulate HTML select box from cache
|
// Repopulate HTML select box from cache
|
||||||
var box = document.getElementById(id);
|
const box = document.getElementById(id);
|
||||||
var node;
|
box.innerHTML = '';
|
||||||
$(box).empty(); // clear all options
|
for (const node of SelectBox.cache[id]) {
|
||||||
var new_options = box.outerHTML.slice(0, -9); // grab just the opening tag
|
|
||||||
var cache = SelectBox.cache[id];
|
|
||||||
for (var i = 0, j = cache.length; i < j; i++) {
|
|
||||||
node = cache[i];
|
|
||||||
if (node.displayed) {
|
if (node.displayed) {
|
||||||
var new_option = new Option(node.text, node.value, false, false);
|
const new_option = new Option(node.text, node.value, false, false);
|
||||||
// Shows a tooltip when hovering over the option
|
// Shows a tooltip when hovering over the option
|
||||||
new_option.setAttribute("title", node.text);
|
new_option.title = node.text;
|
||||||
new_options += new_option.outerHTML;
|
box.appendChild(new_option);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
new_options += '</select>';
|
|
||||||
box.outerHTML = new_options;
|
|
||||||
},
|
},
|
||||||
filter: function(id, text) {
|
filter: function(id, text) {
|
||||||
// Redisplay the HTML select box, displaying only the choices containing ALL
|
// Redisplay the HTML select box, displaying only the choices containing ALL
|
||||||
// the words in text. (It's an AND search.)
|
// the words in text. (It's an AND search.)
|
||||||
var tokens = text.toLowerCase().split(/\s+/);
|
const tokens = text.toLowerCase().split(/\s+/);
|
||||||
var node, token;
|
for (const node of SelectBox.cache[id]) {
|
||||||
var cache = SelectBox.cache[id];
|
|
||||||
for (var i = 0, j = cache.length; i < j; i++) {
|
|
||||||
node = cache[i];
|
|
||||||
node.displayed = 1;
|
node.displayed = 1;
|
||||||
var node_text = node.text.toLowerCase();
|
const node_text = node.text.toLowerCase();
|
||||||
var numTokens = tokens.length;
|
for (const token of tokens) {
|
||||||
for (var k = 0; k < numTokens; k++) {
|
|
||||||
token = tokens[k];
|
|
||||||
if (node_text.indexOf(token) === -1) {
|
if (node_text.indexOf(token) === -1) {
|
||||||
node.displayed = 0;
|
node.displayed = 0;
|
||||||
break; // Once the first token isn't found we're done
|
break; // Once the first token isn't found we're done
|
||||||
|
@ -55,10 +40,9 @@
|
||||||
SelectBox.redisplay(id);
|
SelectBox.redisplay(id);
|
||||||
},
|
},
|
||||||
delete_from_cache: function(id, value) {
|
delete_from_cache: function(id, value) {
|
||||||
var node, delete_index = null;
|
let delete_index = null;
|
||||||
var cache = SelectBox.cache[id];
|
const cache = SelectBox.cache[id];
|
||||||
for (var i = 0, j = cache.length; i < j; i++) {
|
for (const [i, node] of cache.entries()) {
|
||||||
node = cache[i];
|
|
||||||
if (node.value === value) {
|
if (node.value === value) {
|
||||||
delete_index = i;
|
delete_index = i;
|
||||||
break;
|
break;
|
||||||
|
@ -71,10 +55,7 @@
|
||||||
},
|
},
|
||||||
cache_contains: function(id, value) {
|
cache_contains: function(id, value) {
|
||||||
// Check if an item is contained in the cache
|
// Check if an item is contained in the cache
|
||||||
var node;
|
for (const node of SelectBox.cache[id]) {
|
||||||
var cache = SelectBox.cache[id];
|
|
||||||
for (var i = 0, j = cache.length; i < j; i++) {
|
|
||||||
node = cache[i];
|
|
||||||
if (node.value === value) {
|
if (node.value === value) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -82,13 +63,9 @@
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
move: function(from, to) {
|
move: function(from, to) {
|
||||||
var from_box = document.getElementById(from);
|
const from_box = document.getElementById(from);
|
||||||
var option;
|
for (const option of from_box.options) {
|
||||||
var boxOptions = from_box.options;
|
const option_value = option.value;
|
||||||
var boxOptionsLength = boxOptions.length;
|
|
||||||
for (var i = 0, j = boxOptionsLength; i < j; i++) {
|
|
||||||
option = boxOptions[i];
|
|
||||||
var option_value = option.value;
|
|
||||||
if (option.selected && SelectBox.cache_contains(from, option_value)) {
|
if (option.selected && SelectBox.cache_contains(from, option_value)) {
|
||||||
SelectBox.add_to_cache(to, {value: option_value, text: option.text, displayed: 1});
|
SelectBox.add_to_cache(to, {value: option_value, text: option.text, displayed: 1});
|
||||||
SelectBox.delete_from_cache(from, option_value);
|
SelectBox.delete_from_cache(from, option_value);
|
||||||
|
@ -98,13 +75,9 @@
|
||||||
SelectBox.redisplay(to);
|
SelectBox.redisplay(to);
|
||||||
},
|
},
|
||||||
move_all: function(from, to) {
|
move_all: function(from, to) {
|
||||||
var from_box = document.getElementById(from);
|
const from_box = document.getElementById(from);
|
||||||
var option;
|
for (const option of from_box.options) {
|
||||||
var boxOptions = from_box.options;
|
const option_value = option.value;
|
||||||
var boxOptionsLength = boxOptions.length;
|
|
||||||
for (var i = 0, j = boxOptionsLength; i < j; i++) {
|
|
||||||
option = boxOptions[i];
|
|
||||||
var option_value = option.value;
|
|
||||||
if (SelectBox.cache_contains(from, option_value)) {
|
if (SelectBox.cache_contains(from, option_value)) {
|
||||||
SelectBox.add_to_cache(to, {value: option_value, text: option.text, displayed: 1});
|
SelectBox.add_to_cache(to, {value: option_value, text: option.text, displayed: 1});
|
||||||
SelectBox.delete_from_cache(from, option_value);
|
SelectBox.delete_from_cache(from, option_value);
|
||||||
|
@ -117,28 +90,21 @@
|
||||||
SelectBox.cache[id].sort(function(a, b) {
|
SelectBox.cache[id].sort(function(a, b) {
|
||||||
a = a.text.toLowerCase();
|
a = a.text.toLowerCase();
|
||||||
b = b.text.toLowerCase();
|
b = b.text.toLowerCase();
|
||||||
try {
|
if (a > b) {
|
||||||
if (a > b) {
|
return 1;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (a < b) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (e) {
|
if (a < b) {
|
||||||
// silently fail on IE 'unknown' exception
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
select_all: function(id) {
|
select_all: function(id) {
|
||||||
var box = document.getElementById(id);
|
const box = document.getElementById(id);
|
||||||
var boxOptions = box.options;
|
for (const option of box.options) {
|
||||||
var boxOptionsLength = boxOptions.length;
|
option.selected = true;
|
||||||
for (var i = 0; i < boxOptionsLength; i++) {
|
|
||||||
boxOptions[i].selected = 'selected';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
window.SelectBox = SelectBox;
|
window.SelectBox = SelectBox;
|
||||||
})(django.jQuery);
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -2,49 +2,40 @@
|
||||||
/*
|
/*
|
||||||
SelectFilter2 - Turns a multiple-select box into a filter interface.
|
SelectFilter2 - Turns a multiple-select box into a filter interface.
|
||||||
|
|
||||||
Requires jQuery, core.js, and SelectBox.js.
|
Requires core.js and SelectBox.js.
|
||||||
*/
|
*/
|
||||||
(function($) {
|
'use strict';
|
||||||
'use strict';
|
{
|
||||||
function findForm(node) {
|
|
||||||
// returns the node of the form containing the given node
|
|
||||||
if (node.tagName.toLowerCase() !== 'form') {
|
|
||||||
return findForm(node.parentNode);
|
|
||||||
}
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
window.SelectFilter = {
|
window.SelectFilter = {
|
||||||
init: function(field_id, field_name, is_stacked) {
|
init: function(field_id, field_name, is_stacked) {
|
||||||
if (field_id.match(/__prefix__/)) {
|
if (field_id.match(/__prefix__/)) {
|
||||||
// Don't initialize on empty forms.
|
// Don't initialize on empty forms.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var from_box = document.getElementById(field_id);
|
const from_box = document.getElementById(field_id);
|
||||||
from_box.id += '_from'; // change its ID
|
from_box.id += '_from'; // change its ID
|
||||||
from_box.className = 'filtered';
|
from_box.className = 'filtered';
|
||||||
|
|
||||||
var ps = from_box.parentNode.getElementsByTagName('p');
|
for (const p of from_box.parentNode.getElementsByTagName('p')) {
|
||||||
for (var i = 0; i < ps.length; i++) {
|
if (p.classList.contains("info")) {
|
||||||
if (ps[i].className.indexOf("info") !== -1) {
|
|
||||||
// Remove <p class="info">, because it just gets in the way.
|
// Remove <p class="info">, because it just gets in the way.
|
||||||
from_box.parentNode.removeChild(ps[i]);
|
from_box.parentNode.removeChild(p);
|
||||||
} else if (ps[i].className.indexOf("help") !== -1) {
|
} else if (p.classList.contains("help")) {
|
||||||
// Move help text up to the top so it isn't below the select
|
// Move help text up to the top so it isn't below the select
|
||||||
// boxes or wrapped off on the side to the right of the add
|
// boxes or wrapped off on the side to the right of the add
|
||||||
// button:
|
// button:
|
||||||
from_box.parentNode.insertBefore(ps[i], from_box.parentNode.firstChild);
|
from_box.parentNode.insertBefore(p, from_box.parentNode.firstChild);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// <div class="selector"> or <div class="selector stacked">
|
// <div class="selector"> or <div class="selector stacked">
|
||||||
var selector_div = quickElement('div', from_box.parentNode);
|
const selector_div = quickElement('div', from_box.parentNode);
|
||||||
selector_div.className = is_stacked ? 'selector stacked' : 'selector';
|
selector_div.className = is_stacked ? 'selector stacked' : 'selector';
|
||||||
|
|
||||||
// <div class="selector-available">
|
// <div class="selector-available">
|
||||||
var selector_available = quickElement('div', selector_div);
|
const selector_available = quickElement('div', selector_div);
|
||||||
selector_available.className = 'selector-available';
|
selector_available.className = 'selector-available';
|
||||||
var title_available = quickElement('h2', selector_available, interpolate(gettext('Available %s') + ' ', [field_name]));
|
const title_available = quickElement('h2', selector_available, interpolate(gettext('Available %s') + ' ', [field_name]));
|
||||||
quickElement(
|
quickElement(
|
||||||
'span', title_available, '',
|
'span', title_available, '',
|
||||||
'class', 'help help-tooltip help-icon',
|
'class', 'help help-tooltip help-icon',
|
||||||
|
@ -58,10 +49,10 @@ Requires jQuery, core.js, and SelectBox.js.
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
var filter_p = quickElement('p', selector_available, '', 'id', field_id + '_filter');
|
const filter_p = quickElement('p', selector_available, '', 'id', field_id + '_filter');
|
||||||
filter_p.className = 'selector-filter';
|
filter_p.className = 'selector-filter';
|
||||||
|
|
||||||
var search_filter_label = quickElement('label', filter_p, '', 'for', field_id + '_input');
|
const search_filter_label = quickElement('label', filter_p, '', 'for', field_id + '_input');
|
||||||
|
|
||||||
quickElement(
|
quickElement(
|
||||||
'span', search_filter_label, '',
|
'span', search_filter_label, '',
|
||||||
|
@ -71,25 +62,25 @@ Requires jQuery, core.js, and SelectBox.js.
|
||||||
|
|
||||||
filter_p.appendChild(document.createTextNode(' '));
|
filter_p.appendChild(document.createTextNode(' '));
|
||||||
|
|
||||||
var filter_input = quickElement('input', filter_p, '', 'type', 'text', 'placeholder', gettext("Filter"));
|
const filter_input = quickElement('input', filter_p, '', 'type', 'text', 'placeholder', gettext("Filter"));
|
||||||
filter_input.id = field_id + '_input';
|
filter_input.id = field_id + '_input';
|
||||||
|
|
||||||
selector_available.appendChild(from_box);
|
selector_available.appendChild(from_box);
|
||||||
var choose_all = quickElement('a', selector_available, gettext('Choose all'), 'title', interpolate(gettext('Click to choose all %s at once.'), [field_name]), 'href', '#', 'id', field_id + '_add_all_link');
|
const choose_all = quickElement('a', selector_available, gettext('Choose all'), 'title', interpolate(gettext('Click to choose all %s at once.'), [field_name]), 'href', '#', 'id', field_id + '_add_all_link');
|
||||||
choose_all.className = 'selector-chooseall';
|
choose_all.className = 'selector-chooseall';
|
||||||
|
|
||||||
// <ul class="selector-chooser">
|
// <ul class="selector-chooser">
|
||||||
var selector_chooser = quickElement('ul', selector_div);
|
const selector_chooser = quickElement('ul', selector_div);
|
||||||
selector_chooser.className = 'selector-chooser';
|
selector_chooser.className = 'selector-chooser';
|
||||||
var add_link = quickElement('a', quickElement('li', selector_chooser), gettext('Choose'), 'title', gettext('Choose'), 'href', '#', 'id', field_id + '_add_link');
|
const add_link = quickElement('a', quickElement('li', selector_chooser), gettext('Choose'), 'title', gettext('Choose'), 'href', '#', 'id', field_id + '_add_link');
|
||||||
add_link.className = 'selector-add';
|
add_link.className = 'selector-add';
|
||||||
var remove_link = quickElement('a', quickElement('li', selector_chooser), gettext('Remove'), 'title', gettext('Remove'), 'href', '#', 'id', field_id + '_remove_link');
|
const remove_link = quickElement('a', quickElement('li', selector_chooser), gettext('Remove'), 'title', gettext('Remove'), 'href', '#', 'id', field_id + '_remove_link');
|
||||||
remove_link.className = 'selector-remove';
|
remove_link.className = 'selector-remove';
|
||||||
|
|
||||||
// <div class="selector-chosen">
|
// <div class="selector-chosen">
|
||||||
var selector_chosen = quickElement('div', selector_div);
|
const selector_chosen = quickElement('div', selector_div);
|
||||||
selector_chosen.className = 'selector-chosen';
|
selector_chosen.className = 'selector-chosen';
|
||||||
var title_chosen = quickElement('h2', selector_chosen, interpolate(gettext('Chosen %s') + ' ', [field_name]));
|
const title_chosen = quickElement('h2', selector_chosen, interpolate(gettext('Chosen %s') + ' ', [field_name]));
|
||||||
quickElement(
|
quickElement(
|
||||||
'span', title_chosen, '',
|
'span', title_chosen, '',
|
||||||
'class', 'help help-tooltip help-icon',
|
'class', 'help help-tooltip help-icon',
|
||||||
|
@ -103,16 +94,16 @@ Requires jQuery, core.js, and SelectBox.js.
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
var to_box = quickElement('select', selector_chosen, '', 'id', field_id + '_to', 'multiple', 'multiple', 'size', from_box.size, 'name', from_box.getAttribute('name'));
|
const to_box = quickElement('select', selector_chosen, '', 'id', field_id + '_to', 'multiple', '', 'size', from_box.size, 'name', from_box.name);
|
||||||
to_box.className = 'filtered';
|
to_box.className = 'filtered';
|
||||||
var clear_all = quickElement('a', selector_chosen, gettext('Remove all'), 'title', interpolate(gettext('Click to remove all chosen %s at once.'), [field_name]), 'href', '#', 'id', field_id + '_remove_all_link');
|
const clear_all = quickElement('a', selector_chosen, gettext('Remove all'), 'title', interpolate(gettext('Click to remove all chosen %s at once.'), [field_name]), 'href', '#', 'id', field_id + '_remove_all_link');
|
||||||
clear_all.className = 'selector-clearall';
|
clear_all.className = 'selector-clearall';
|
||||||
|
|
||||||
from_box.setAttribute('name', from_box.getAttribute('name') + '_old');
|
from_box.name = from_box.name + '_old';
|
||||||
|
|
||||||
// Set up the JavaScript event handlers for the select box filter interface
|
// Set up the JavaScript event handlers for the select box filter interface
|
||||||
var move_selection = function(e, elem, move_func, from, to) {
|
const move_selection = function(e, elem, move_func, from, to) {
|
||||||
if (elem.className.indexOf('active') !== -1) {
|
if (elem.classList.contains('active')) {
|
||||||
move_func(from, to);
|
move_func(from, to);
|
||||||
SelectFilter.refresh_icons(field_id);
|
SelectFilter.refresh_icons(field_id);
|
||||||
}
|
}
|
||||||
|
@ -154,7 +145,7 @@ Requires jQuery, core.js, and SelectBox.js.
|
||||||
SelectFilter.refresh_icons(field_id);
|
SelectFilter.refresh_icons(field_id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
findForm(from_box).addEventListener('submit', function() {
|
from_box.closest('form').addEventListener('submit', function() {
|
||||||
SelectBox.select_all(field_id + '_to');
|
SelectBox.select_all(field_id + '_to');
|
||||||
});
|
});
|
||||||
SelectBox.init(field_id + '_from');
|
SelectBox.init(field_id + '_from');
|
||||||
|
@ -164,64 +155,66 @@ Requires jQuery, core.js, and SelectBox.js.
|
||||||
|
|
||||||
if (!is_stacked) {
|
if (!is_stacked) {
|
||||||
// In horizontal mode, give the same height to the two boxes.
|
// In horizontal mode, give the same height to the two boxes.
|
||||||
var j_from_box = $('#' + field_id + '_from');
|
const j_from_box = document.getElementById(field_id + '_from');
|
||||||
var j_to_box = $('#' + field_id + '_to');
|
const j_to_box = document.getElementById(field_id + '_to');
|
||||||
j_to_box.height($(filter_p).outerHeight() + j_from_box.outerHeight());
|
let height = filter_p.offsetHeight + j_from_box.offsetHeight;
|
||||||
|
|
||||||
|
const j_to_box_style = window.getComputedStyle(j_to_box);
|
||||||
|
if (j_to_box_style.getPropertyValue('box-sizing') === 'border-box') {
|
||||||
|
// Add the padding and border to the final height.
|
||||||
|
height += parseInt(j_to_box_style.getPropertyValue('padding-top'), 10)
|
||||||
|
+ parseInt(j_to_box_style.getPropertyValue('padding-bottom'), 10)
|
||||||
|
+ parseInt(j_to_box_style.getPropertyValue('border-top-width'), 10)
|
||||||
|
+ parseInt(j_to_box_style.getPropertyValue('border-bottom-width'), 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
j_to_box.style.height = height + 'px';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initial icon refresh
|
// Initial icon refresh
|
||||||
SelectFilter.refresh_icons(field_id);
|
SelectFilter.refresh_icons(field_id);
|
||||||
},
|
},
|
||||||
any_selected: function(field) {
|
any_selected: function(field) {
|
||||||
var any_selected = false;
|
// Temporarily add the required attribute and check validity.
|
||||||
try {
|
field.required = true;
|
||||||
// Temporarily add the required attribute and check validity.
|
const any_selected = field.checkValidity();
|
||||||
// This is much faster in WebKit browsers than the fallback.
|
field.required = false;
|
||||||
field.attr('required', 'required');
|
|
||||||
any_selected = field.is(':valid');
|
|
||||||
} catch (e) {
|
|
||||||
// Browsers that don't support :valid (IE < 10)
|
|
||||||
any_selected = field.find('option:selected').length > 0;
|
|
||||||
}
|
|
||||||
field.removeAttr('required');
|
|
||||||
return any_selected;
|
return any_selected;
|
||||||
},
|
},
|
||||||
refresh_icons: function(field_id) {
|
refresh_icons: function(field_id) {
|
||||||
var from = $('#' + field_id + '_from');
|
const from = document.getElementById(field_id + '_from');
|
||||||
var to = $('#' + field_id + '_to');
|
const to = document.getElementById(field_id + '_to');
|
||||||
// Active if at least one item is selected
|
// Active if at least one item is selected
|
||||||
$('#' + field_id + '_add_link').toggleClass('active', SelectFilter.any_selected(from));
|
document.getElementById(field_id + '_add_link').classList.toggle('active', SelectFilter.any_selected(from));
|
||||||
$('#' + field_id + '_remove_link').toggleClass('active', SelectFilter.any_selected(to));
|
document.getElementById(field_id + '_remove_link').classList.toggle('active', SelectFilter.any_selected(to));
|
||||||
// Active if the corresponding box isn't empty
|
// Active if the corresponding box isn't empty
|
||||||
$('#' + field_id + '_add_all_link').toggleClass('active', from.find('option').length > 0);
|
document.getElementById(field_id + '_add_all_link').classList.toggle('active', from.querySelector('option'));
|
||||||
$('#' + field_id + '_remove_all_link').toggleClass('active', to.find('option').length > 0);
|
document.getElementById(field_id + '_remove_all_link').classList.toggle('active', to.querySelector('option'));
|
||||||
},
|
},
|
||||||
filter_key_press: function(event, field_id) {
|
filter_key_press: function(event, field_id) {
|
||||||
var from = document.getElementById(field_id + '_from');
|
const from = document.getElementById(field_id + '_from');
|
||||||
// don't submit form if user pressed Enter
|
// don't submit form if user pressed Enter
|
||||||
if ((event.which && event.which === 13) || (event.keyCode && event.keyCode === 13)) {
|
if ((event.which && event.which === 13) || (event.keyCode && event.keyCode === 13)) {
|
||||||
from.selectedIndex = 0;
|
from.selectedIndex = 0;
|
||||||
SelectBox.move(field_id + '_from', field_id + '_to');
|
SelectBox.move(field_id + '_from', field_id + '_to');
|
||||||
from.selectedIndex = 0;
|
from.selectedIndex = 0;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
filter_key_up: function(event, field_id) {
|
filter_key_up: function(event, field_id) {
|
||||||
var from = document.getElementById(field_id + '_from');
|
const from = document.getElementById(field_id + '_from');
|
||||||
var temp = from.selectedIndex;
|
const temp = from.selectedIndex;
|
||||||
SelectBox.filter(field_id + '_from', document.getElementById(field_id + '_input').value);
|
SelectBox.filter(field_id + '_from', document.getElementById(field_id + '_input').value);
|
||||||
from.selectedIndex = temp;
|
from.selectedIndex = temp;
|
||||||
return true;
|
|
||||||
},
|
},
|
||||||
filter_key_down: function(event, field_id) {
|
filter_key_down: function(event, field_id) {
|
||||||
var from = document.getElementById(field_id + '_from');
|
const from = document.getElementById(field_id + '_from');
|
||||||
// right arrow -- move across
|
// right arrow -- move across
|
||||||
if ((event.which && event.which === 39) || (event.keyCode && event.keyCode === 39)) {
|
if ((event.which && event.which === 39) || (event.keyCode && event.keyCode === 39)) {
|
||||||
var old_index = from.selectedIndex;
|
const old_index = from.selectedIndex;
|
||||||
SelectBox.move(field_id + '_from', field_id + '_to');
|
SelectBox.move(field_id + '_from', field_id + '_to');
|
||||||
from.selectedIndex = (old_index === from.length) ? from.length - 1 : old_index;
|
from.selectedIndex = (old_index === from.length) ? from.length - 1 : old_index;
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
// down arrow -- wrap around
|
// down arrow -- wrap around
|
||||||
if ((event.which && event.which === 40) || (event.keyCode && event.keyCode === 40)) {
|
if ((event.which && event.which === 40) || (event.keyCode && event.keyCode === 40)) {
|
||||||
|
@ -231,16 +224,13 @@ Requires jQuery, core.js, and SelectBox.js.
|
||||||
if ((event.which && event.which === 38) || (event.keyCode && event.keyCode === 38)) {
|
if ((event.which && event.which === 38) || (event.keyCode && event.keyCode === 38)) {
|
||||||
from.selectedIndex = (from.selectedIndex === 0) ? from.length - 1 : from.selectedIndex - 1;
|
from.selectedIndex = (from.selectedIndex === 0) ? from.length - 1 : from.selectedIndex - 1;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener('load', function(e) {
|
window.addEventListener('load', function(e) {
|
||||||
$('select.selectfilter, select.selectfilterstacked').each(function() {
|
document.querySelectorAll('select.selectfilter, select.selectfilterstacked').forEach(function(el) {
|
||||||
var $el = $(this),
|
const data = el.dataset;
|
||||||
data = $el.data();
|
SelectFilter.init(el.id, data.fieldName, parseInt(data.isStacked, 10));
|
||||||
SelectFilter.init($el.attr('id'), data.fieldName, parseInt(data.isStacked, 10));
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
})(django.jQuery);
|
|
Binary file not shown.
|
@ -2,49 +2,40 @@
|
||||||
/*
|
/*
|
||||||
SelectFilter2 - Turns a multiple-select box into a filter interface.
|
SelectFilter2 - Turns a multiple-select box into a filter interface.
|
||||||
|
|
||||||
Requires jQuery, core.js, and SelectBox.js.
|
Requires core.js and SelectBox.js.
|
||||||
*/
|
*/
|
||||||
(function($) {
|
'use strict';
|
||||||
'use strict';
|
{
|
||||||
function findForm(node) {
|
|
||||||
// returns the node of the form containing the given node
|
|
||||||
if (node.tagName.toLowerCase() !== 'form') {
|
|
||||||
return findForm(node.parentNode);
|
|
||||||
}
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
window.SelectFilter = {
|
window.SelectFilter = {
|
||||||
init: function(field_id, field_name, is_stacked) {
|
init: function(field_id, field_name, is_stacked) {
|
||||||
if (field_id.match(/__prefix__/)) {
|
if (field_id.match(/__prefix__/)) {
|
||||||
// Don't initialize on empty forms.
|
// Don't initialize on empty forms.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var from_box = document.getElementById(field_id);
|
const from_box = document.getElementById(field_id);
|
||||||
from_box.id += '_from'; // change its ID
|
from_box.id += '_from'; // change its ID
|
||||||
from_box.className = 'filtered';
|
from_box.className = 'filtered';
|
||||||
|
|
||||||
var ps = from_box.parentNode.getElementsByTagName('p');
|
for (const p of from_box.parentNode.getElementsByTagName('p')) {
|
||||||
for (var i = 0; i < ps.length; i++) {
|
if (p.classList.contains("info")) {
|
||||||
if (ps[i].className.indexOf("info") !== -1) {
|
|
||||||
// Remove <p class="info">, because it just gets in the way.
|
// Remove <p class="info">, because it just gets in the way.
|
||||||
from_box.parentNode.removeChild(ps[i]);
|
from_box.parentNode.removeChild(p);
|
||||||
} else if (ps[i].className.indexOf("help") !== -1) {
|
} else if (p.classList.contains("help")) {
|
||||||
// Move help text up to the top so it isn't below the select
|
// Move help text up to the top so it isn't below the select
|
||||||
// boxes or wrapped off on the side to the right of the add
|
// boxes or wrapped off on the side to the right of the add
|
||||||
// button:
|
// button:
|
||||||
from_box.parentNode.insertBefore(ps[i], from_box.parentNode.firstChild);
|
from_box.parentNode.insertBefore(p, from_box.parentNode.firstChild);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// <div class="selector"> or <div class="selector stacked">
|
// <div class="selector"> or <div class="selector stacked">
|
||||||
var selector_div = quickElement('div', from_box.parentNode);
|
const selector_div = quickElement('div', from_box.parentNode);
|
||||||
selector_div.className = is_stacked ? 'selector stacked' : 'selector';
|
selector_div.className = is_stacked ? 'selector stacked' : 'selector';
|
||||||
|
|
||||||
// <div class="selector-available">
|
// <div class="selector-available">
|
||||||
var selector_available = quickElement('div', selector_div);
|
const selector_available = quickElement('div', selector_div);
|
||||||
selector_available.className = 'selector-available';
|
selector_available.className = 'selector-available';
|
||||||
var title_available = quickElement('h2', selector_available, interpolate(gettext('Available %s') + ' ', [field_name]));
|
const title_available = quickElement('h2', selector_available, interpolate(gettext('Available %s') + ' ', [field_name]));
|
||||||
quickElement(
|
quickElement(
|
||||||
'span', title_available, '',
|
'span', title_available, '',
|
||||||
'class', 'help help-tooltip help-icon',
|
'class', 'help help-tooltip help-icon',
|
||||||
|
@ -58,10 +49,10 @@ Requires jQuery, core.js, and SelectBox.js.
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
var filter_p = quickElement('p', selector_available, '', 'id', field_id + '_filter');
|
const filter_p = quickElement('p', selector_available, '', 'id', field_id + '_filter');
|
||||||
filter_p.className = 'selector-filter';
|
filter_p.className = 'selector-filter';
|
||||||
|
|
||||||
var search_filter_label = quickElement('label', filter_p, '', 'for', field_id + '_input');
|
const search_filter_label = quickElement('label', filter_p, '', 'for', field_id + '_input');
|
||||||
|
|
||||||
quickElement(
|
quickElement(
|
||||||
'span', search_filter_label, '',
|
'span', search_filter_label, '',
|
||||||
|
@ -71,25 +62,25 @@ Requires jQuery, core.js, and SelectBox.js.
|
||||||
|
|
||||||
filter_p.appendChild(document.createTextNode(' '));
|
filter_p.appendChild(document.createTextNode(' '));
|
||||||
|
|
||||||
var filter_input = quickElement('input', filter_p, '', 'type', 'text', 'placeholder', gettext("Filter"));
|
const filter_input = quickElement('input', filter_p, '', 'type', 'text', 'placeholder', gettext("Filter"));
|
||||||
filter_input.id = field_id + '_input';
|
filter_input.id = field_id + '_input';
|
||||||
|
|
||||||
selector_available.appendChild(from_box);
|
selector_available.appendChild(from_box);
|
||||||
var choose_all = quickElement('a', selector_available, gettext('Choose all'), 'title', interpolate(gettext('Click to choose all %s at once.'), [field_name]), 'href', '#', 'id', field_id + '_add_all_link');
|
const choose_all = quickElement('a', selector_available, gettext('Choose all'), 'title', interpolate(gettext('Click to choose all %s at once.'), [field_name]), 'href', '#', 'id', field_id + '_add_all_link');
|
||||||
choose_all.className = 'selector-chooseall';
|
choose_all.className = 'selector-chooseall';
|
||||||
|
|
||||||
// <ul class="selector-chooser">
|
// <ul class="selector-chooser">
|
||||||
var selector_chooser = quickElement('ul', selector_div);
|
const selector_chooser = quickElement('ul', selector_div);
|
||||||
selector_chooser.className = 'selector-chooser';
|
selector_chooser.className = 'selector-chooser';
|
||||||
var add_link = quickElement('a', quickElement('li', selector_chooser), gettext('Choose'), 'title', gettext('Choose'), 'href', '#', 'id', field_id + '_add_link');
|
const add_link = quickElement('a', quickElement('li', selector_chooser), gettext('Choose'), 'title', gettext('Choose'), 'href', '#', 'id', field_id + '_add_link');
|
||||||
add_link.className = 'selector-add';
|
add_link.className = 'selector-add';
|
||||||
var remove_link = quickElement('a', quickElement('li', selector_chooser), gettext('Remove'), 'title', gettext('Remove'), 'href', '#', 'id', field_id + '_remove_link');
|
const remove_link = quickElement('a', quickElement('li', selector_chooser), gettext('Remove'), 'title', gettext('Remove'), 'href', '#', 'id', field_id + '_remove_link');
|
||||||
remove_link.className = 'selector-remove';
|
remove_link.className = 'selector-remove';
|
||||||
|
|
||||||
// <div class="selector-chosen">
|
// <div class="selector-chosen">
|
||||||
var selector_chosen = quickElement('div', selector_div);
|
const selector_chosen = quickElement('div', selector_div);
|
||||||
selector_chosen.className = 'selector-chosen';
|
selector_chosen.className = 'selector-chosen';
|
||||||
var title_chosen = quickElement('h2', selector_chosen, interpolate(gettext('Chosen %s') + ' ', [field_name]));
|
const title_chosen = quickElement('h2', selector_chosen, interpolate(gettext('Chosen %s') + ' ', [field_name]));
|
||||||
quickElement(
|
quickElement(
|
||||||
'span', title_chosen, '',
|
'span', title_chosen, '',
|
||||||
'class', 'help help-tooltip help-icon',
|
'class', 'help help-tooltip help-icon',
|
||||||
|
@ -103,16 +94,16 @@ Requires jQuery, core.js, and SelectBox.js.
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
var to_box = quickElement('select', selector_chosen, '', 'id', field_id + '_to', 'multiple', 'multiple', 'size', from_box.size, 'name', from_box.getAttribute('name'));
|
const to_box = quickElement('select', selector_chosen, '', 'id', field_id + '_to', 'multiple', '', 'size', from_box.size, 'name', from_box.name);
|
||||||
to_box.className = 'filtered';
|
to_box.className = 'filtered';
|
||||||
var clear_all = quickElement('a', selector_chosen, gettext('Remove all'), 'title', interpolate(gettext('Click to remove all chosen %s at once.'), [field_name]), 'href', '#', 'id', field_id + '_remove_all_link');
|
const clear_all = quickElement('a', selector_chosen, gettext('Remove all'), 'title', interpolate(gettext('Click to remove all chosen %s at once.'), [field_name]), 'href', '#', 'id', field_id + '_remove_all_link');
|
||||||
clear_all.className = 'selector-clearall';
|
clear_all.className = 'selector-clearall';
|
||||||
|
|
||||||
from_box.setAttribute('name', from_box.getAttribute('name') + '_old');
|
from_box.name = from_box.name + '_old';
|
||||||
|
|
||||||
// Set up the JavaScript event handlers for the select box filter interface
|
// Set up the JavaScript event handlers for the select box filter interface
|
||||||
var move_selection = function(e, elem, move_func, from, to) {
|
const move_selection = function(e, elem, move_func, from, to) {
|
||||||
if (elem.className.indexOf('active') !== -1) {
|
if (elem.classList.contains('active')) {
|
||||||
move_func(from, to);
|
move_func(from, to);
|
||||||
SelectFilter.refresh_icons(field_id);
|
SelectFilter.refresh_icons(field_id);
|
||||||
}
|
}
|
||||||
|
@ -154,7 +145,7 @@ Requires jQuery, core.js, and SelectBox.js.
|
||||||
SelectFilter.refresh_icons(field_id);
|
SelectFilter.refresh_icons(field_id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
findForm(from_box).addEventListener('submit', function() {
|
from_box.closest('form').addEventListener('submit', function() {
|
||||||
SelectBox.select_all(field_id + '_to');
|
SelectBox.select_all(field_id + '_to');
|
||||||
});
|
});
|
||||||
SelectBox.init(field_id + '_from');
|
SelectBox.init(field_id + '_from');
|
||||||
|
@ -164,64 +155,66 @@ Requires jQuery, core.js, and SelectBox.js.
|
||||||
|
|
||||||
if (!is_stacked) {
|
if (!is_stacked) {
|
||||||
// In horizontal mode, give the same height to the two boxes.
|
// In horizontal mode, give the same height to the two boxes.
|
||||||
var j_from_box = $('#' + field_id + '_from');
|
const j_from_box = document.getElementById(field_id + '_from');
|
||||||
var j_to_box = $('#' + field_id + '_to');
|
const j_to_box = document.getElementById(field_id + '_to');
|
||||||
j_to_box.height($(filter_p).outerHeight() + j_from_box.outerHeight());
|
let height = filter_p.offsetHeight + j_from_box.offsetHeight;
|
||||||
|
|
||||||
|
const j_to_box_style = window.getComputedStyle(j_to_box);
|
||||||
|
if (j_to_box_style.getPropertyValue('box-sizing') === 'border-box') {
|
||||||
|
// Add the padding and border to the final height.
|
||||||
|
height += parseInt(j_to_box_style.getPropertyValue('padding-top'), 10)
|
||||||
|
+ parseInt(j_to_box_style.getPropertyValue('padding-bottom'), 10)
|
||||||
|
+ parseInt(j_to_box_style.getPropertyValue('border-top-width'), 10)
|
||||||
|
+ parseInt(j_to_box_style.getPropertyValue('border-bottom-width'), 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
j_to_box.style.height = height + 'px';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initial icon refresh
|
// Initial icon refresh
|
||||||
SelectFilter.refresh_icons(field_id);
|
SelectFilter.refresh_icons(field_id);
|
||||||
},
|
},
|
||||||
any_selected: function(field) {
|
any_selected: function(field) {
|
||||||
var any_selected = false;
|
// Temporarily add the required attribute and check validity.
|
||||||
try {
|
field.required = true;
|
||||||
// Temporarily add the required attribute and check validity.
|
const any_selected = field.checkValidity();
|
||||||
// This is much faster in WebKit browsers than the fallback.
|
field.required = false;
|
||||||
field.attr('required', 'required');
|
|
||||||
any_selected = field.is(':valid');
|
|
||||||
} catch (e) {
|
|
||||||
// Browsers that don't support :valid (IE < 10)
|
|
||||||
any_selected = field.find('option:selected').length > 0;
|
|
||||||
}
|
|
||||||
field.removeAttr('required');
|
|
||||||
return any_selected;
|
return any_selected;
|
||||||
},
|
},
|
||||||
refresh_icons: function(field_id) {
|
refresh_icons: function(field_id) {
|
||||||
var from = $('#' + field_id + '_from');
|
const from = document.getElementById(field_id + '_from');
|
||||||
var to = $('#' + field_id + '_to');
|
const to = document.getElementById(field_id + '_to');
|
||||||
// Active if at least one item is selected
|
// Active if at least one item is selected
|
||||||
$('#' + field_id + '_add_link').toggleClass('active', SelectFilter.any_selected(from));
|
document.getElementById(field_id + '_add_link').classList.toggle('active', SelectFilter.any_selected(from));
|
||||||
$('#' + field_id + '_remove_link').toggleClass('active', SelectFilter.any_selected(to));
|
document.getElementById(field_id + '_remove_link').classList.toggle('active', SelectFilter.any_selected(to));
|
||||||
// Active if the corresponding box isn't empty
|
// Active if the corresponding box isn't empty
|
||||||
$('#' + field_id + '_add_all_link').toggleClass('active', from.find('option').length > 0);
|
document.getElementById(field_id + '_add_all_link').classList.toggle('active', from.querySelector('option'));
|
||||||
$('#' + field_id + '_remove_all_link').toggleClass('active', to.find('option').length > 0);
|
document.getElementById(field_id + '_remove_all_link').classList.toggle('active', to.querySelector('option'));
|
||||||
},
|
},
|
||||||
filter_key_press: function(event, field_id) {
|
filter_key_press: function(event, field_id) {
|
||||||
var from = document.getElementById(field_id + '_from');
|
const from = document.getElementById(field_id + '_from');
|
||||||
// don't submit form if user pressed Enter
|
// don't submit form if user pressed Enter
|
||||||
if ((event.which && event.which === 13) || (event.keyCode && event.keyCode === 13)) {
|
if ((event.which && event.which === 13) || (event.keyCode && event.keyCode === 13)) {
|
||||||
from.selectedIndex = 0;
|
from.selectedIndex = 0;
|
||||||
SelectBox.move(field_id + '_from', field_id + '_to');
|
SelectBox.move(field_id + '_from', field_id + '_to');
|
||||||
from.selectedIndex = 0;
|
from.selectedIndex = 0;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
filter_key_up: function(event, field_id) {
|
filter_key_up: function(event, field_id) {
|
||||||
var from = document.getElementById(field_id + '_from');
|
const from = document.getElementById(field_id + '_from');
|
||||||
var temp = from.selectedIndex;
|
const temp = from.selectedIndex;
|
||||||
SelectBox.filter(field_id + '_from', document.getElementById(field_id + '_input').value);
|
SelectBox.filter(field_id + '_from', document.getElementById(field_id + '_input').value);
|
||||||
from.selectedIndex = temp;
|
from.selectedIndex = temp;
|
||||||
return true;
|
|
||||||
},
|
},
|
||||||
filter_key_down: function(event, field_id) {
|
filter_key_down: function(event, field_id) {
|
||||||
var from = document.getElementById(field_id + '_from');
|
const from = document.getElementById(field_id + '_from');
|
||||||
// right arrow -- move across
|
// right arrow -- move across
|
||||||
if ((event.which && event.which === 39) || (event.keyCode && event.keyCode === 39)) {
|
if ((event.which && event.which === 39) || (event.keyCode && event.keyCode === 39)) {
|
||||||
var old_index = from.selectedIndex;
|
const old_index = from.selectedIndex;
|
||||||
SelectBox.move(field_id + '_from', field_id + '_to');
|
SelectBox.move(field_id + '_from', field_id + '_to');
|
||||||
from.selectedIndex = (old_index === from.length) ? from.length - 1 : old_index;
|
from.selectedIndex = (old_index === from.length) ? from.length - 1 : old_index;
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
// down arrow -- wrap around
|
// down arrow -- wrap around
|
||||||
if ((event.which && event.which === 40) || (event.keyCode && event.keyCode === 40)) {
|
if ((event.which && event.which === 40) || (event.keyCode && event.keyCode === 40)) {
|
||||||
|
@ -231,16 +224,13 @@ Requires jQuery, core.js, and SelectBox.js.
|
||||||
if ((event.which && event.which === 38) || (event.keyCode && event.keyCode === 38)) {
|
if ((event.which && event.which === 38) || (event.keyCode && event.keyCode === 38)) {
|
||||||
from.selectedIndex = (from.selectedIndex === 0) ? from.length - 1 : from.selectedIndex - 1;
|
from.selectedIndex = (from.selectedIndex === 0) ? from.length - 1 : from.selectedIndex - 1;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener('load', function(e) {
|
window.addEventListener('load', function(e) {
|
||||||
$('select.selectfilter, select.selectfilterstacked').each(function() {
|
document.querySelectorAll('select.selectfilter, select.selectfilterstacked').forEach(function(el) {
|
||||||
var $el = $(this),
|
const data = el.dataset;
|
||||||
data = $el.data();
|
SelectFilter.init(el.id, data.fieldName, parseInt(data.isStacked, 10));
|
||||||
SelectFilter.init($el.attr('id'), data.fieldName, parseInt(data.isStacked, 10));
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
})(django.jQuery);
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,13 +1,14 @@
|
||||||
/*global gettext, interpolate, ngettext*/
|
/*global gettext, interpolate, ngettext*/
|
||||||
(function($) {
|
'use strict';
|
||||||
'use strict';
|
{
|
||||||
var lastChecked;
|
const $ = django.jQuery;
|
||||||
|
let lastChecked;
|
||||||
|
|
||||||
$.fn.actions = function(opts) {
|
$.fn.actions = function(opts) {
|
||||||
var options = $.extend({}, $.fn.actions.defaults, opts);
|
const options = $.extend({}, $.fn.actions.defaults, opts);
|
||||||
var actionCheckboxes = $(this);
|
const actionCheckboxes = $(this);
|
||||||
var list_editable_changed = false;
|
let list_editable_changed = false;
|
||||||
var showQuestion = function() {
|
const showQuestion = function() {
|
||||||
$(options.acrossClears).hide();
|
$(options.acrossClears).hide();
|
||||||
$(options.acrossQuestions).show();
|
$(options.acrossQuestions).show();
|
||||||
$(options.allContainer).hide();
|
$(options.allContainer).hide();
|
||||||
|
@ -40,17 +41,17 @@
|
||||||
.parent().parent().toggleClass(options.selectedClass, checked);
|
.parent().parent().toggleClass(options.selectedClass, checked);
|
||||||
},
|
},
|
||||||
updateCounter = function() {
|
updateCounter = function() {
|
||||||
var sel = $(actionCheckboxes).filter(":checked").length;
|
const sel = $(actionCheckboxes).filter(":checked").length;
|
||||||
// data-actions-icnt is defined in the generated HTML
|
// data-actions-icnt is defined in the generated HTML
|
||||||
// and contains the total amount of objects in the queryset
|
// and contains the total amount of objects in the queryset
|
||||||
var actions_icnt = $('.action-counter').data('actionsIcnt');
|
const actions_icnt = $('.action-counter').data('actionsIcnt');
|
||||||
$(options.counterContainer).html(interpolate(
|
$(options.counterContainer).html(interpolate(
|
||||||
ngettext('%(sel)s of %(cnt)s selected', '%(sel)s of %(cnt)s selected', sel), {
|
ngettext('%(sel)s of %(cnt)s selected', '%(sel)s of %(cnt)s selected', sel), {
|
||||||
sel: sel,
|
sel: sel,
|
||||||
cnt: actions_icnt
|
cnt: actions_icnt
|
||||||
}, true));
|
}, true));
|
||||||
$(options.allToggle).prop("checked", function() {
|
$(options.allToggle).prop("checked", function() {
|
||||||
var value;
|
let value;
|
||||||
if (sel === actionCheckboxes.length) {
|
if (sel === actionCheckboxes.length) {
|
||||||
value = true;
|
value = true;
|
||||||
showQuestion();
|
showQuestion();
|
||||||
|
@ -90,9 +91,9 @@
|
||||||
lastChecked = null;
|
lastChecked = null;
|
||||||
$(actionCheckboxes).on('click', function(event) {
|
$(actionCheckboxes).on('click', function(event) {
|
||||||
if (!event) { event = window.event; }
|
if (!event) { event = window.event; }
|
||||||
var target = event.target ? event.target : event.srcElement;
|
const target = event.target ? event.target : event.srcElement;
|
||||||
if (lastChecked && $.data(lastChecked) !== $.data(target) && event.shiftKey === true) {
|
if (lastChecked && $.data(lastChecked) !== $.data(target) && event.shiftKey === true) {
|
||||||
var inrange = false;
|
let inrange = false;
|
||||||
$(lastChecked).prop("checked", target.checked)
|
$(lastChecked).prop("checked", target.checked)
|
||||||
.parent().parent().toggleClass(options.selectedClass, target.checked);
|
.parent().parent().toggleClass(options.selectedClass, target.checked);
|
||||||
$(actionCheckboxes).each(function() {
|
$(actionCheckboxes).each(function() {
|
||||||
|
@ -118,7 +119,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('form#changelist-form input[name="_save"]').on('click', function(event) {
|
$('form#changelist-form input[name="_save"]').on('click', function(event) {
|
||||||
var action_changed = false;
|
let action_changed = false;
|
||||||
$('select option:selected', options.actionContainer).each(function() {
|
$('select option:selected', options.actionContainer).each(function() {
|
||||||
if ($(this).val()) {
|
if ($(this).val()) {
|
||||||
action_changed = true;
|
action_changed = true;
|
||||||
|
@ -126,9 +127,9 @@
|
||||||
});
|
});
|
||||||
if (action_changed) {
|
if (action_changed) {
|
||||||
if (list_editable_changed) {
|
if (list_editable_changed) {
|
||||||
return confirm(gettext("You have selected an action, but you haven't saved your changes to individual fields yet. Please click OK to save. You'll need to re-run the action."));
|
return confirm(gettext("You have selected an action, but you haven’t saved your changes to individual fields yet. Please click OK to save. You’ll need to re-run the action."));
|
||||||
} else {
|
} else {
|
||||||
return confirm(gettext("You have selected an action, and you haven't made any changes on individual fields. You're probably looking for the Go button rather than the Save button."));
|
return confirm(gettext("You have selected an action, and you haven’t made any changes on individual fields. You’re probably looking for the Go button rather than the Save button."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -145,9 +146,9 @@
|
||||||
selectedClass: "selected"
|
selectedClass: "selected"
|
||||||
};
|
};
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var $actionsEls = $('tr input.action-select');
|
const $actionsEls = $('tr input.action-select');
|
||||||
if ($actionsEls.length > 0) {
|
if ($actionsEls.length > 0) {
|
||||||
$actionsEls.actions();
|
$actionsEls.actions();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})(django.jQuery);
|
}
|
Binary file not shown.
|
@ -1,13 +1,14 @@
|
||||||
/*global gettext, interpolate, ngettext*/
|
/*global gettext, interpolate, ngettext*/
|
||||||
(function($) {
|
'use strict';
|
||||||
'use strict';
|
{
|
||||||
var lastChecked;
|
const $ = django.jQuery;
|
||||||
|
let lastChecked;
|
||||||
|
|
||||||
$.fn.actions = function(opts) {
|
$.fn.actions = function(opts) {
|
||||||
var options = $.extend({}, $.fn.actions.defaults, opts);
|
const options = $.extend({}, $.fn.actions.defaults, opts);
|
||||||
var actionCheckboxes = $(this);
|
const actionCheckboxes = $(this);
|
||||||
var list_editable_changed = false;
|
let list_editable_changed = false;
|
||||||
var showQuestion = function() {
|
const showQuestion = function() {
|
||||||
$(options.acrossClears).hide();
|
$(options.acrossClears).hide();
|
||||||
$(options.acrossQuestions).show();
|
$(options.acrossQuestions).show();
|
||||||
$(options.allContainer).hide();
|
$(options.allContainer).hide();
|
||||||
|
@ -40,17 +41,17 @@
|
||||||
.parent().parent().toggleClass(options.selectedClass, checked);
|
.parent().parent().toggleClass(options.selectedClass, checked);
|
||||||
},
|
},
|
||||||
updateCounter = function() {
|
updateCounter = function() {
|
||||||
var sel = $(actionCheckboxes).filter(":checked").length;
|
const sel = $(actionCheckboxes).filter(":checked").length;
|
||||||
// data-actions-icnt is defined in the generated HTML
|
// data-actions-icnt is defined in the generated HTML
|
||||||
// and contains the total amount of objects in the queryset
|
// and contains the total amount of objects in the queryset
|
||||||
var actions_icnt = $('.action-counter').data('actionsIcnt');
|
const actions_icnt = $('.action-counter').data('actionsIcnt');
|
||||||
$(options.counterContainer).html(interpolate(
|
$(options.counterContainer).html(interpolate(
|
||||||
ngettext('%(sel)s of %(cnt)s selected', '%(sel)s of %(cnt)s selected', sel), {
|
ngettext('%(sel)s of %(cnt)s selected', '%(sel)s of %(cnt)s selected', sel), {
|
||||||
sel: sel,
|
sel: sel,
|
||||||
cnt: actions_icnt
|
cnt: actions_icnt
|
||||||
}, true));
|
}, true));
|
||||||
$(options.allToggle).prop("checked", function() {
|
$(options.allToggle).prop("checked", function() {
|
||||||
var value;
|
let value;
|
||||||
if (sel === actionCheckboxes.length) {
|
if (sel === actionCheckboxes.length) {
|
||||||
value = true;
|
value = true;
|
||||||
showQuestion();
|
showQuestion();
|
||||||
|
@ -90,9 +91,9 @@
|
||||||
lastChecked = null;
|
lastChecked = null;
|
||||||
$(actionCheckboxes).on('click', function(event) {
|
$(actionCheckboxes).on('click', function(event) {
|
||||||
if (!event) { event = window.event; }
|
if (!event) { event = window.event; }
|
||||||
var target = event.target ? event.target : event.srcElement;
|
const target = event.target ? event.target : event.srcElement;
|
||||||
if (lastChecked && $.data(lastChecked) !== $.data(target) && event.shiftKey === true) {
|
if (lastChecked && $.data(lastChecked) !== $.data(target) && event.shiftKey === true) {
|
||||||
var inrange = false;
|
let inrange = false;
|
||||||
$(lastChecked).prop("checked", target.checked)
|
$(lastChecked).prop("checked", target.checked)
|
||||||
.parent().parent().toggleClass(options.selectedClass, target.checked);
|
.parent().parent().toggleClass(options.selectedClass, target.checked);
|
||||||
$(actionCheckboxes).each(function() {
|
$(actionCheckboxes).each(function() {
|
||||||
|
@ -118,7 +119,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('form#changelist-form input[name="_save"]').on('click', function(event) {
|
$('form#changelist-form input[name="_save"]').on('click', function(event) {
|
||||||
var action_changed = false;
|
let action_changed = false;
|
||||||
$('select option:selected', options.actionContainer).each(function() {
|
$('select option:selected', options.actionContainer).each(function() {
|
||||||
if ($(this).val()) {
|
if ($(this).val()) {
|
||||||
action_changed = true;
|
action_changed = true;
|
||||||
|
@ -126,9 +127,9 @@
|
||||||
});
|
});
|
||||||
if (action_changed) {
|
if (action_changed) {
|
||||||
if (list_editable_changed) {
|
if (list_editable_changed) {
|
||||||
return confirm(gettext("You have selected an action, but you haven't saved your changes to individual fields yet. Please click OK to save. You'll need to re-run the action."));
|
return confirm(gettext("You have selected an action, but you haven’t saved your changes to individual fields yet. Please click OK to save. You’ll need to re-run the action."));
|
||||||
} else {
|
} else {
|
||||||
return confirm(gettext("You have selected an action, and you haven't made any changes on individual fields. You're probably looking for the Go button rather than the Save button."));
|
return confirm(gettext("You have selected an action, and you haven’t made any changes on individual fields. You’re probably looking for the Go button rather than the Save button."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -145,9 +146,9 @@
|
||||||
selectedClass: "selected"
|
selectedClass: "selected"
|
||||||
};
|
};
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var $actionsEls = $('tr input.action-select');
|
const $actionsEls = $('tr input.action-select');
|
||||||
if ($actionsEls.length > 0) {
|
if ($actionsEls.length > 0) {
|
||||||
$actionsEls.actions();
|
$actionsEls.actions();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})(django.jQuery);
|
}
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,7 @@
|
||||||
|
'use strict';{const a=django.jQuery;let e;a.fn.actions=function(g){const b=a.extend({},a.fn.actions.defaults,g),f=a(this);let k=!1;const l=function(){a(b.acrossClears).hide();a(b.acrossQuestions).show();a(b.allContainer).hide()},m=function(){a(b.acrossClears).show();a(b.acrossQuestions).hide();a(b.actionContainer).toggleClass(b.selectedClass);a(b.allContainer).show();a(b.counterContainer).hide()},n=function(){a(b.acrossClears).hide();a(b.acrossQuestions).hide();a(b.allContainer).hide();a(b.counterContainer).show()},
|
||||||
|
p=function(){n();a(b.acrossInput).val(0);a(b.actionContainer).removeClass(b.selectedClass)},q=function(c){c?l():n();a(f).prop("checked",c).parent().parent().toggleClass(b.selectedClass,c)},h=function(){const c=a(f).filter(":checked").length,d=a(".action-counter").data("actionsIcnt");a(b.counterContainer).html(interpolate(ngettext("%(sel)s of %(cnt)s selected","%(sel)s of %(cnt)s selected",c),{sel:c,cnt:d},!0));a(b.allToggle).prop("checked",function(){let a;c===f.length?(a=!0,l()):(a=!1,p());return a})};
|
||||||
|
a(b.counterContainer).show();a(this).filter(":checked").each(function(c){a(this).parent().parent().toggleClass(b.selectedClass);h();1===a(b.acrossInput).val()&&m()});a(b.allToggle).show().on("click",function(){q(a(this).prop("checked"));h()});a("a",b.acrossQuestions).on("click",function(c){c.preventDefault();a(b.acrossInput).val(1);m()});a("a",b.acrossClears).on("click",function(c){c.preventDefault();a(b.allToggle).prop("checked",!1);p();q(0);h()});e=null;a(f).on("click",function(c){c||(c=window.event);
|
||||||
|
const d=c.target?c.target:c.srcElement;if(e&&a.data(e)!==a.data(d)&&!0===c.shiftKey){let c=!1;a(e).prop("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked);a(f).each(function(){if(a.data(this)===a.data(e)||a.data(this)===a.data(d))c=c?!1:!0;c&&a(this).prop("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked)})}a(d).parent().parent().toggleClass(b.selectedClass,d.checked);e=d;h()});a("form#changelist-form table#result_list tr").on("change","td:gt(0) :input",
|
||||||
|
function(){k=!0});a('form#changelist-form button[name="index"]').on("click",function(a){if(k)return confirm(gettext("You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost."))});a('form#changelist-form input[name="_save"]').on("click",function(c){let d=!1;a("select option:selected",b.actionContainer).each(function(){a(this).val()&&(d=!0)});if(d)return k?confirm(gettext("You have selected an action, but you haven\u2019t saved your changes to individual fields yet. Please click OK to save. You\u2019ll need to re-run the action.")):
|
||||||
|
confirm(gettext("You have selected an action, and you haven\u2019t made any changes on individual fields. You\u2019re probably looking for the Go button rather than the Save button."))})};a.fn.actions.defaults={actionContainer:"div.actions",counterContainer:"span.action-counter",allContainer:"div.actions span.all",acrossInput:"div.actions input.select-across",acrossQuestions:"div.actions span.question",acrossClears:"div.actions span.clear",allToggle:"#action-toggle",selectedClass:"selected"};a(document).ready(function(){const g=
|
||||||
|
a("tr input.action-select");0<g.length&&g.actions()})};
|
Binary file not shown.
|
@ -1,7 +0,0 @@
|
||||||
(function(a){var f;a.fn.actions=function(e){var b=a.extend({},a.fn.actions.defaults,e),g=a(this),k=!1,l=function(){a(b.acrossClears).hide();a(b.acrossQuestions).show();a(b.allContainer).hide()},m=function(){a(b.acrossClears).show();a(b.acrossQuestions).hide();a(b.actionContainer).toggleClass(b.selectedClass);a(b.allContainer).show();a(b.counterContainer).hide()},n=function(){a(b.acrossClears).hide();a(b.acrossQuestions).hide();a(b.allContainer).hide();a(b.counterContainer).show()},p=function(){n();
|
|
||||||
a(b.acrossInput).val(0);a(b.actionContainer).removeClass(b.selectedClass)},q=function(c){c?l():n();a(g).prop("checked",c).parent().parent().toggleClass(b.selectedClass,c)},h=function(){var c=a(g).filter(":checked").length,d=a(".action-counter").data("actionsIcnt");a(b.counterContainer).html(interpolate(ngettext("%(sel)s of %(cnt)s selected","%(sel)s of %(cnt)s selected",c),{sel:c,cnt:d},!0));a(b.allToggle).prop("checked",function(){if(c===g.length){var a=!0;l()}else a=!1,p();return a})};a(b.counterContainer).show();
|
|
||||||
a(this).filter(":checked").each(function(c){a(this).parent().parent().toggleClass(b.selectedClass);h();1===a(b.acrossInput).val()&&m()});a(b.allToggle).show().on("click",function(){q(a(this).prop("checked"));h()});a("a",b.acrossQuestions).on("click",function(c){c.preventDefault();a(b.acrossInput).val(1);m()});a("a",b.acrossClears).on("click",function(c){c.preventDefault();a(b.allToggle).prop("checked",!1);p();q(0);h()});f=null;a(g).on("click",function(c){c||(c=window.event);var d=c.target?c.target:
|
|
||||||
c.srcElement;if(f&&a.data(f)!==a.data(d)&&!0===c.shiftKey){var e=!1;a(f).prop("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked);a(g).each(function(){if(a.data(this)===a.data(f)||a.data(this)===a.data(d))e=e?!1:!0;e&&a(this).prop("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked)})}a(d).parent().parent().toggleClass(b.selectedClass,d.checked);f=d;h()});a("form#changelist-form table#result_list tr").on("change","td:gt(0) :input",function(){k=!0});
|
|
||||||
a('form#changelist-form button[name="index"]').on("click",function(a){if(k)return confirm(gettext("You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost."))});a('form#changelist-form input[name="_save"]').on("click",function(c){var d=!1;a("select option:selected",b.actionContainer).each(function(){a(this).val()&&(d=!0)});if(d)return k?confirm(gettext("You have selected an action, but you haven't saved your changes to individual fields yet. Please click OK to save. You'll need to re-run the action.")):
|
|
||||||
confirm(gettext("You have selected an action, and you haven't made any changes on individual fields. You're probably looking for the Go button rather than the Save button."))})};a.fn.actions.defaults={actionContainer:"div.actions",counterContainer:"span.action-counter",allContainer:"div.actions span.all",acrossInput:"div.actions input.select-across",acrossQuestions:"div.actions span.question",acrossClears:"div.actions span.clear",allToggle:"#action-toggle",selectedClass:"selected"};a(document).ready(function(){var e=
|
|
||||||
a("tr input.action-select");0<e.length&&e.actions()})})(django.jQuery);
|
|
Binary file not shown.
|
@ -1,7 +1,7 @@
|
||||||
(function(a){var f;a.fn.actions=function(e){var b=a.extend({},a.fn.actions.defaults,e),g=a(this),k=!1,l=function(){a(b.acrossClears).hide();a(b.acrossQuestions).show();a(b.allContainer).hide()},m=function(){a(b.acrossClears).show();a(b.acrossQuestions).hide();a(b.actionContainer).toggleClass(b.selectedClass);a(b.allContainer).show();a(b.counterContainer).hide()},n=function(){a(b.acrossClears).hide();a(b.acrossQuestions).hide();a(b.allContainer).hide();a(b.counterContainer).show()},p=function(){n();
|
'use strict';{const a=django.jQuery;let e;a.fn.actions=function(g){const b=a.extend({},a.fn.actions.defaults,g),f=a(this);let k=!1;const l=function(){a(b.acrossClears).hide();a(b.acrossQuestions).show();a(b.allContainer).hide()},m=function(){a(b.acrossClears).show();a(b.acrossQuestions).hide();a(b.actionContainer).toggleClass(b.selectedClass);a(b.allContainer).show();a(b.counterContainer).hide()},n=function(){a(b.acrossClears).hide();a(b.acrossQuestions).hide();a(b.allContainer).hide();a(b.counterContainer).show()},
|
||||||
a(b.acrossInput).val(0);a(b.actionContainer).removeClass(b.selectedClass)},q=function(c){c?l():n();a(g).prop("checked",c).parent().parent().toggleClass(b.selectedClass,c)},h=function(){var c=a(g).filter(":checked").length,d=a(".action-counter").data("actionsIcnt");a(b.counterContainer).html(interpolate(ngettext("%(sel)s of %(cnt)s selected","%(sel)s of %(cnt)s selected",c),{sel:c,cnt:d},!0));a(b.allToggle).prop("checked",function(){if(c===g.length){var a=!0;l()}else a=!1,p();return a})};a(b.counterContainer).show();
|
p=function(){n();a(b.acrossInput).val(0);a(b.actionContainer).removeClass(b.selectedClass)},q=function(c){c?l():n();a(f).prop("checked",c).parent().parent().toggleClass(b.selectedClass,c)},h=function(){const c=a(f).filter(":checked").length,d=a(".action-counter").data("actionsIcnt");a(b.counterContainer).html(interpolate(ngettext("%(sel)s of %(cnt)s selected","%(sel)s of %(cnt)s selected",c),{sel:c,cnt:d},!0));a(b.allToggle).prop("checked",function(){let a;c===f.length?(a=!0,l()):(a=!1,p());return a})};
|
||||||
a(this).filter(":checked").each(function(c){a(this).parent().parent().toggleClass(b.selectedClass);h();1===a(b.acrossInput).val()&&m()});a(b.allToggle).show().on("click",function(){q(a(this).prop("checked"));h()});a("a",b.acrossQuestions).on("click",function(c){c.preventDefault();a(b.acrossInput).val(1);m()});a("a",b.acrossClears).on("click",function(c){c.preventDefault();a(b.allToggle).prop("checked",!1);p();q(0);h()});f=null;a(g).on("click",function(c){c||(c=window.event);var d=c.target?c.target:
|
a(b.counterContainer).show();a(this).filter(":checked").each(function(c){a(this).parent().parent().toggleClass(b.selectedClass);h();1===a(b.acrossInput).val()&&m()});a(b.allToggle).show().on("click",function(){q(a(this).prop("checked"));h()});a("a",b.acrossQuestions).on("click",function(c){c.preventDefault();a(b.acrossInput).val(1);m()});a("a",b.acrossClears).on("click",function(c){c.preventDefault();a(b.allToggle).prop("checked",!1);p();q(0);h()});e=null;a(f).on("click",function(c){c||(c=window.event);
|
||||||
c.srcElement;if(f&&a.data(f)!==a.data(d)&&!0===c.shiftKey){var e=!1;a(f).prop("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked);a(g).each(function(){if(a.data(this)===a.data(f)||a.data(this)===a.data(d))e=e?!1:!0;e&&a(this).prop("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked)})}a(d).parent().parent().toggleClass(b.selectedClass,d.checked);f=d;h()});a("form#changelist-form table#result_list tr").on("change","td:gt(0) :input",function(){k=!0});
|
const d=c.target?c.target:c.srcElement;if(e&&a.data(e)!==a.data(d)&&!0===c.shiftKey){let c=!1;a(e).prop("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked);a(f).each(function(){if(a.data(this)===a.data(e)||a.data(this)===a.data(d))c=c?!1:!0;c&&a(this).prop("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked)})}a(d).parent().parent().toggleClass(b.selectedClass,d.checked);e=d;h()});a("form#changelist-form table#result_list tr").on("change","td:gt(0) :input",
|
||||||
a('form#changelist-form button[name="index"]').on("click",function(a){if(k)return confirm(gettext("You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost."))});a('form#changelist-form input[name="_save"]').on("click",function(c){var d=!1;a("select option:selected",b.actionContainer).each(function(){a(this).val()&&(d=!0)});if(d)return k?confirm(gettext("You have selected an action, but you haven't saved your changes to individual fields yet. Please click OK to save. You'll need to re-run the action.")):
|
function(){k=!0});a('form#changelist-form button[name="index"]').on("click",function(a){if(k)return confirm(gettext("You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost."))});a('form#changelist-form input[name="_save"]').on("click",function(c){let d=!1;a("select option:selected",b.actionContainer).each(function(){a(this).val()&&(d=!0)});if(d)return k?confirm(gettext("You have selected an action, but you haven\u2019t saved your changes to individual fields yet. Please click OK to save. You\u2019ll need to re-run the action.")):
|
||||||
confirm(gettext("You have selected an action, and you haven't made any changes on individual fields. You're probably looking for the Go button rather than the Save button."))})};a.fn.actions.defaults={actionContainer:"div.actions",counterContainer:"span.action-counter",allContainer:"div.actions span.all",acrossInput:"div.actions input.select-across",acrossQuestions:"div.actions span.question",acrossClears:"div.actions span.clear",allToggle:"#action-toggle",selectedClass:"selected"};a(document).ready(function(){var e=
|
confirm(gettext("You have selected an action, and you haven\u2019t made any changes on individual fields. You\u2019re probably looking for the Go button rather than the Save button."))})};a.fn.actions.defaults={actionContainer:"div.actions",counterContainer:"span.action-counter",allContainer:"div.actions span.all",acrossInput:"div.actions input.select-across",acrossQuestions:"div.actions span.question",acrossClears:"div.actions span.clear",allToggle:"#action-toggle",selectedClass:"selected"};a(document).ready(function(){const g=
|
||||||
a("tr input.action-select");0<e.length&&e.actions()})})(django.jQuery);
|
a("tr input.action-select");0<g.length&&g.actions()})};
|
||||||
|
|
Binary file not shown.
|
@ -2,9 +2,9 @@
|
||||||
// Inserts shortcut buttons after all of the following:
|
// Inserts shortcut buttons after all of the following:
|
||||||
// <input type="text" class="vDateField">
|
// <input type="text" class="vDateField">
|
||||||
// <input type="text" class="vTimeField">
|
// <input type="text" class="vTimeField">
|
||||||
(function() {
|
'use strict';
|
||||||
'use strict';
|
{
|
||||||
var DateTimeShortcuts = {
|
const DateTimeShortcuts = {
|
||||||
calendars: [],
|
calendars: [],
|
||||||
calendarInputs: [],
|
calendarInputs: [],
|
||||||
clockInputs: [],
|
clockInputs: [],
|
||||||
|
@ -28,21 +28,19 @@
|
||||||
timezoneWarningClass: 'timezonewarning', // class of the warning for timezone mismatch
|
timezoneWarningClass: 'timezonewarning', // class of the warning for timezone mismatch
|
||||||
timezoneOffset: 0,
|
timezoneOffset: 0,
|
||||||
init: function() {
|
init: function() {
|
||||||
var body = document.getElementsByTagName('body')[0];
|
const body = document.getElementsByTagName('body')[0];
|
||||||
var serverOffset = body.getAttribute('data-admin-utc-offset');
|
const serverOffset = body.dataset.adminUtcOffset;
|
||||||
if (serverOffset) {
|
if (serverOffset) {
|
||||||
var localOffset = new Date().getTimezoneOffset() * -60;
|
const localOffset = new Date().getTimezoneOffset() * -60;
|
||||||
DateTimeShortcuts.timezoneOffset = localOffset - serverOffset;
|
DateTimeShortcuts.timezoneOffset = localOffset - serverOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
var inputs = document.getElementsByTagName('input');
|
for (const inp of document.getElementsByTagName('input')) {
|
||||||
for (var i = 0; i < inputs.length; i++) {
|
if (inp.type === 'text' && inp.classList.contains('vTimeField')) {
|
||||||
var inp = inputs[i];
|
|
||||||
if (inp.getAttribute('type') === 'text' && inp.className.match(/vTimeField/)) {
|
|
||||||
DateTimeShortcuts.addClock(inp);
|
DateTimeShortcuts.addClock(inp);
|
||||||
DateTimeShortcuts.addTimezoneWarning(inp);
|
DateTimeShortcuts.addTimezoneWarning(inp);
|
||||||
}
|
}
|
||||||
else if (inp.getAttribute('type') === 'text' && inp.className.match(/vDateField/)) {
|
else if (inp.type === 'text' && inp.classList.contains('vDateField')) {
|
||||||
DateTimeShortcuts.addCalendar(inp);
|
DateTimeShortcuts.addCalendar(inp);
|
||||||
DateTimeShortcuts.addTimezoneWarning(inp);
|
DateTimeShortcuts.addTimezoneWarning(inp);
|
||||||
}
|
}
|
||||||
|
@ -50,11 +48,11 @@
|
||||||
},
|
},
|
||||||
// Return the current time while accounting for the server timezone.
|
// Return the current time while accounting for the server timezone.
|
||||||
now: function() {
|
now: function() {
|
||||||
var body = document.getElementsByTagName('body')[0];
|
const body = document.getElementsByTagName('body')[0];
|
||||||
var serverOffset = body.getAttribute('data-admin-utc-offset');
|
const serverOffset = body.dataset.adminUtcOffset;
|
||||||
if (serverOffset) {
|
if (serverOffset) {
|
||||||
var localNow = new Date();
|
const localNow = new Date();
|
||||||
var localOffset = localNow.getTimezoneOffset() * -60;
|
const localOffset = localNow.getTimezoneOffset() * -60;
|
||||||
localNow.setTime(localNow.getTime() + 1000 * (serverOffset - localOffset));
|
localNow.setTime(localNow.getTime() + 1000 * (serverOffset - localOffset));
|
||||||
return localNow;
|
return localNow;
|
||||||
} else {
|
} else {
|
||||||
|
@ -63,8 +61,8 @@
|
||||||
},
|
},
|
||||||
// Add a warning when the time zone in the browser and backend do not match.
|
// Add a warning when the time zone in the browser and backend do not match.
|
||||||
addTimezoneWarning: function(inp) {
|
addTimezoneWarning: function(inp) {
|
||||||
var warningClass = DateTimeShortcuts.timezoneWarningClass;
|
const warningClass = DateTimeShortcuts.timezoneWarningClass;
|
||||||
var timezoneOffset = DateTimeShortcuts.timezoneOffset / 3600;
|
let timezoneOffset = DateTimeShortcuts.timezoneOffset / 3600;
|
||||||
|
|
||||||
// Only warn if there is a time zone mismatch.
|
// Only warn if there is a time zone mismatch.
|
||||||
if (!timezoneOffset) {
|
if (!timezoneOffset) {
|
||||||
|
@ -76,7 +74,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var message;
|
let message;
|
||||||
if (timezoneOffset > 0) {
|
if (timezoneOffset > 0) {
|
||||||
message = ngettext(
|
message = ngettext(
|
||||||
'Note: You are %s hour ahead of server time.',
|
'Note: You are %s hour ahead of server time.',
|
||||||
|
@ -94,7 +92,7 @@
|
||||||
}
|
}
|
||||||
message = interpolate(message, [timezoneOffset]);
|
message = interpolate(message, [timezoneOffset]);
|
||||||
|
|
||||||
var warning = document.createElement('span');
|
const warning = document.createElement('span');
|
||||||
warning.className = warningClass;
|
warning.className = warningClass;
|
||||||
warning.textContent = message;
|
warning.textContent = message;
|
||||||
inp.parentNode.appendChild(document.createElement('br'));
|
inp.parentNode.appendChild(document.createElement('br'));
|
||||||
|
@ -102,23 +100,23 @@
|
||||||
},
|
},
|
||||||
// Add clock widget to a given field
|
// Add clock widget to a given field
|
||||||
addClock: function(inp) {
|
addClock: function(inp) {
|
||||||
var num = DateTimeShortcuts.clockInputs.length;
|
const num = DateTimeShortcuts.clockInputs.length;
|
||||||
DateTimeShortcuts.clockInputs[num] = inp;
|
DateTimeShortcuts.clockInputs[num] = inp;
|
||||||
DateTimeShortcuts.dismissClockFunc[num] = function() { DateTimeShortcuts.dismissClock(num); return true; };
|
DateTimeShortcuts.dismissClockFunc[num] = function() { DateTimeShortcuts.dismissClock(num); return true; };
|
||||||
|
|
||||||
// Shortcut links (clock icon and "Now" link)
|
// Shortcut links (clock icon and "Now" link)
|
||||||
var shortcuts_span = document.createElement('span');
|
const shortcuts_span = document.createElement('span');
|
||||||
shortcuts_span.className = DateTimeShortcuts.shortCutsClass;
|
shortcuts_span.className = DateTimeShortcuts.shortCutsClass;
|
||||||
inp.parentNode.insertBefore(shortcuts_span, inp.nextSibling);
|
inp.parentNode.insertBefore(shortcuts_span, inp.nextSibling);
|
||||||
var now_link = document.createElement('a');
|
const now_link = document.createElement('a');
|
||||||
now_link.setAttribute('href', "#");
|
now_link.href = "#";
|
||||||
now_link.textContent = gettext('Now');
|
now_link.textContent = gettext('Now');
|
||||||
now_link.addEventListener('click', function(e) {
|
now_link.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
DateTimeShortcuts.handleClockQuicklink(num, -1);
|
DateTimeShortcuts.handleClockQuicklink(num, -1);
|
||||||
});
|
});
|
||||||
var clock_link = document.createElement('a');
|
const clock_link = document.createElement('a');
|
||||||
clock_link.setAttribute('href', '#');
|
clock_link.href = '#';
|
||||||
clock_link.id = DateTimeShortcuts.clockLinkName + num;
|
clock_link.id = DateTimeShortcuts.clockLinkName + num;
|
||||||
clock_link.addEventListener('click', function(e) {
|
clock_link.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -152,32 +150,32 @@
|
||||||
// <p class="calendar-cancel"><a href="#">Cancel</a></p>
|
// <p class="calendar-cancel"><a href="#">Cancel</a></p>
|
||||||
// </div>
|
// </div>
|
||||||
|
|
||||||
var clock_box = document.createElement('div');
|
const clock_box = document.createElement('div');
|
||||||
clock_box.style.display = 'none';
|
clock_box.style.display = 'none';
|
||||||
clock_box.style.position = 'absolute';
|
clock_box.style.position = 'absolute';
|
||||||
clock_box.className = 'clockbox module';
|
clock_box.className = 'clockbox module';
|
||||||
clock_box.setAttribute('id', DateTimeShortcuts.clockDivName + num);
|
clock_box.id = DateTimeShortcuts.clockDivName + num;
|
||||||
document.body.appendChild(clock_box);
|
document.body.appendChild(clock_box);
|
||||||
clock_box.addEventListener('click', function(e) { e.stopPropagation(); });
|
clock_box.addEventListener('click', function(e) { e.stopPropagation(); });
|
||||||
|
|
||||||
quickElement('h2', clock_box, gettext('Choose a time'));
|
quickElement('h2', clock_box, gettext('Choose a time'));
|
||||||
var time_list = quickElement('ul', clock_box);
|
const time_list = quickElement('ul', clock_box);
|
||||||
time_list.className = 'timelist';
|
time_list.className = 'timelist';
|
||||||
// The list of choices can be overridden in JavaScript like this:
|
// The list of choices can be overridden in JavaScript like this:
|
||||||
// DateTimeShortcuts.clockHours.name = [['3 a.m.', 3]];
|
// DateTimeShortcuts.clockHours.name = [['3 a.m.', 3]];
|
||||||
// where name is the name attribute of the <input>.
|
// where name is the name attribute of the <input>.
|
||||||
var name = typeof DateTimeShortcuts.clockHours[inp.name] === 'undefined' ? 'default_' : inp.name;
|
const name = typeof DateTimeShortcuts.clockHours[inp.name] === 'undefined' ? 'default_' : inp.name;
|
||||||
DateTimeShortcuts.clockHours[name].forEach(function(element) {
|
DateTimeShortcuts.clockHours[name].forEach(function(element) {
|
||||||
var time_link = quickElement('a', quickElement('li', time_list), gettext(element[0]), 'href', '#');
|
const time_link = quickElement('a', quickElement('li', time_list), gettext(element[0]), 'href', '#');
|
||||||
time_link.addEventListener('click', function(e) {
|
time_link.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
DateTimeShortcuts.handleClockQuicklink(num, element[1]);
|
DateTimeShortcuts.handleClockQuicklink(num, element[1]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
var cancel_p = quickElement('p', clock_box);
|
const cancel_p = quickElement('p', clock_box);
|
||||||
cancel_p.className = 'calendar-cancel';
|
cancel_p.className = 'calendar-cancel';
|
||||||
var cancel_link = quickElement('a', cancel_p, gettext('Cancel'), 'href', '#');
|
const cancel_link = quickElement('a', cancel_p, gettext('Cancel'), 'href', '#');
|
||||||
cancel_link.addEventListener('click', function(e) {
|
cancel_link.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
DateTimeShortcuts.dismissClock(num);
|
DateTimeShortcuts.dismissClock(num);
|
||||||
|
@ -192,8 +190,8 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
openClock: function(num) {
|
openClock: function(num) {
|
||||||
var clock_box = document.getElementById(DateTimeShortcuts.clockDivName + num);
|
const clock_box = document.getElementById(DateTimeShortcuts.clockDivName + num);
|
||||||
var clock_link = document.getElementById(DateTimeShortcuts.clockLinkName + num);
|
const clock_link = document.getElementById(DateTimeShortcuts.clockLinkName + num);
|
||||||
|
|
||||||
// Recalculate the clockbox position
|
// Recalculate the clockbox position
|
||||||
// is it left-to-right or right-to-left layout ?
|
// is it left-to-right or right-to-left layout ?
|
||||||
|
@ -203,8 +201,6 @@
|
||||||
else {
|
else {
|
||||||
// since style's width is in em, it'd be tough to calculate
|
// since style's width is in em, it'd be tough to calculate
|
||||||
// px value of it. let's use an estimated px for now
|
// px value of it. let's use an estimated px for now
|
||||||
// TODO: IE returns wrong value for findPosX when in rtl mode
|
|
||||||
// (it returns as it was left aligned), needs to be fixed.
|
|
||||||
clock_box.style.left = findPosX(clock_link) - 110 + 'px';
|
clock_box.style.left = findPosX(clock_link) - 110 + 'px';
|
||||||
}
|
}
|
||||||
clock_box.style.top = Math.max(0, findPosY(clock_link) - 30) + 'px';
|
clock_box.style.top = Math.max(0, findPosY(clock_link) - 30) + 'px';
|
||||||
|
@ -218,7 +214,7 @@
|
||||||
document.removeEventListener('click', DateTimeShortcuts.dismissClockFunc[num]);
|
document.removeEventListener('click', DateTimeShortcuts.dismissClockFunc[num]);
|
||||||
},
|
},
|
||||||
handleClockQuicklink: function(num, val) {
|
handleClockQuicklink: function(num, val) {
|
||||||
var d;
|
let d;
|
||||||
if (val === -1) {
|
if (val === -1) {
|
||||||
d = DateTimeShortcuts.now();
|
d = DateTimeShortcuts.now();
|
||||||
}
|
}
|
||||||
|
@ -231,24 +227,24 @@
|
||||||
},
|
},
|
||||||
// Add calendar widget to a given field.
|
// Add calendar widget to a given field.
|
||||||
addCalendar: function(inp) {
|
addCalendar: function(inp) {
|
||||||
var num = DateTimeShortcuts.calendars.length;
|
const num = DateTimeShortcuts.calendars.length;
|
||||||
|
|
||||||
DateTimeShortcuts.calendarInputs[num] = inp;
|
DateTimeShortcuts.calendarInputs[num] = inp;
|
||||||
DateTimeShortcuts.dismissCalendarFunc[num] = function() { DateTimeShortcuts.dismissCalendar(num); return true; };
|
DateTimeShortcuts.dismissCalendarFunc[num] = function() { DateTimeShortcuts.dismissCalendar(num); return true; };
|
||||||
|
|
||||||
// Shortcut links (calendar icon and "Today" link)
|
// Shortcut links (calendar icon and "Today" link)
|
||||||
var shortcuts_span = document.createElement('span');
|
const shortcuts_span = document.createElement('span');
|
||||||
shortcuts_span.className = DateTimeShortcuts.shortCutsClass;
|
shortcuts_span.className = DateTimeShortcuts.shortCutsClass;
|
||||||
inp.parentNode.insertBefore(shortcuts_span, inp.nextSibling);
|
inp.parentNode.insertBefore(shortcuts_span, inp.nextSibling);
|
||||||
var today_link = document.createElement('a');
|
const today_link = document.createElement('a');
|
||||||
today_link.setAttribute('href', '#');
|
today_link.href = '#';
|
||||||
today_link.appendChild(document.createTextNode(gettext('Today')));
|
today_link.appendChild(document.createTextNode(gettext('Today')));
|
||||||
today_link.addEventListener('click', function(e) {
|
today_link.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
DateTimeShortcuts.handleCalendarQuickLink(num, 0);
|
DateTimeShortcuts.handleCalendarQuickLink(num, 0);
|
||||||
});
|
});
|
||||||
var cal_link = document.createElement('a');
|
const cal_link = document.createElement('a');
|
||||||
cal_link.setAttribute('href', '#');
|
cal_link.href = '#';
|
||||||
cal_link.id = DateTimeShortcuts.calendarLinkName + num;
|
cal_link.id = DateTimeShortcuts.calendarLinkName + num;
|
||||||
cal_link.addEventListener('click', function(e) {
|
cal_link.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -283,24 +279,24 @@
|
||||||
// </div>
|
// </div>
|
||||||
// <p class="calendar-cancel"><a href="#">Cancel</a></p>
|
// <p class="calendar-cancel"><a href="#">Cancel</a></p>
|
||||||
// </div>
|
// </div>
|
||||||
var cal_box = document.createElement('div');
|
const cal_box = document.createElement('div');
|
||||||
cal_box.style.display = 'none';
|
cal_box.style.display = 'none';
|
||||||
cal_box.style.position = 'absolute';
|
cal_box.style.position = 'absolute';
|
||||||
cal_box.className = 'calendarbox module';
|
cal_box.className = 'calendarbox module';
|
||||||
cal_box.setAttribute('id', DateTimeShortcuts.calendarDivName1 + num);
|
cal_box.id = DateTimeShortcuts.calendarDivName1 + num;
|
||||||
document.body.appendChild(cal_box);
|
document.body.appendChild(cal_box);
|
||||||
cal_box.addEventListener('click', function(e) { e.stopPropagation(); });
|
cal_box.addEventListener('click', function(e) { e.stopPropagation(); });
|
||||||
|
|
||||||
// next-prev links
|
// next-prev links
|
||||||
var cal_nav = quickElement('div', cal_box);
|
const cal_nav = quickElement('div', cal_box);
|
||||||
var cal_nav_prev = quickElement('a', cal_nav, '<', 'href', '#');
|
const cal_nav_prev = quickElement('a', cal_nav, '<', 'href', '#');
|
||||||
cal_nav_prev.className = 'calendarnav-previous';
|
cal_nav_prev.className = 'calendarnav-previous';
|
||||||
cal_nav_prev.addEventListener('click', function(e) {
|
cal_nav_prev.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
DateTimeShortcuts.drawPrev(num);
|
DateTimeShortcuts.drawPrev(num);
|
||||||
});
|
});
|
||||||
|
|
||||||
var cal_nav_next = quickElement('a', cal_nav, '>', 'href', '#');
|
const cal_nav_next = quickElement('a', cal_nav, '>', 'href', '#');
|
||||||
cal_nav_next.className = 'calendarnav-next';
|
cal_nav_next.className = 'calendarnav-next';
|
||||||
cal_nav_next.addEventListener('click', function(e) {
|
cal_nav_next.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -308,15 +304,15 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
// main box
|
// main box
|
||||||
var cal_main = quickElement('div', cal_box, '', 'id', DateTimeShortcuts.calendarDivName2 + num);
|
const cal_main = quickElement('div', cal_box, '', 'id', DateTimeShortcuts.calendarDivName2 + num);
|
||||||
cal_main.className = 'calendar';
|
cal_main.className = 'calendar';
|
||||||
DateTimeShortcuts.calendars[num] = new Calendar(DateTimeShortcuts.calendarDivName2 + num, DateTimeShortcuts.handleCalendarCallback(num));
|
DateTimeShortcuts.calendars[num] = new Calendar(DateTimeShortcuts.calendarDivName2 + num, DateTimeShortcuts.handleCalendarCallback(num));
|
||||||
DateTimeShortcuts.calendars[num].drawCurrent();
|
DateTimeShortcuts.calendars[num].drawCurrent();
|
||||||
|
|
||||||
// calendar shortcuts
|
// calendar shortcuts
|
||||||
var shortcuts = quickElement('div', cal_box);
|
const shortcuts = quickElement('div', cal_box);
|
||||||
shortcuts.className = 'calendar-shortcuts';
|
shortcuts.className = 'calendar-shortcuts';
|
||||||
var day_link = quickElement('a', shortcuts, gettext('Yesterday'), 'href', '#');
|
let day_link = quickElement('a', shortcuts, gettext('Yesterday'), 'href', '#');
|
||||||
day_link.addEventListener('click', function(e) {
|
day_link.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
DateTimeShortcuts.handleCalendarQuickLink(num, -1);
|
DateTimeShortcuts.handleCalendarQuickLink(num, -1);
|
||||||
|
@ -335,9 +331,9 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
// cancel bar
|
// cancel bar
|
||||||
var cancel_p = quickElement('p', cal_box);
|
const cancel_p = quickElement('p', cal_box);
|
||||||
cancel_p.className = 'calendar-cancel';
|
cancel_p.className = 'calendar-cancel';
|
||||||
var cancel_link = quickElement('a', cancel_p, gettext('Cancel'), 'href', '#');
|
const cancel_link = quickElement('a', cancel_p, gettext('Cancel'), 'href', '#');
|
||||||
cancel_link.addEventListener('click', function(e) {
|
cancel_link.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
DateTimeShortcuts.dismissCalendar(num);
|
DateTimeShortcuts.dismissCalendar(num);
|
||||||
|
@ -351,18 +347,18 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
openCalendar: function(num) {
|
openCalendar: function(num) {
|
||||||
var cal_box = document.getElementById(DateTimeShortcuts.calendarDivName1 + num);
|
const cal_box = document.getElementById(DateTimeShortcuts.calendarDivName1 + num);
|
||||||
var cal_link = document.getElementById(DateTimeShortcuts.calendarLinkName + num);
|
const cal_link = document.getElementById(DateTimeShortcuts.calendarLinkName + num);
|
||||||
var inp = DateTimeShortcuts.calendarInputs[num];
|
const inp = DateTimeShortcuts.calendarInputs[num];
|
||||||
|
|
||||||
// Determine if the current value in the input has a valid date.
|
// Determine if the current value in the input has a valid date.
|
||||||
// If so, draw the calendar with that date's year and month.
|
// If so, draw the calendar with that date's year and month.
|
||||||
if (inp.value) {
|
if (inp.value) {
|
||||||
var format = get_format('DATE_INPUT_FORMATS')[0];
|
const format = get_format('DATE_INPUT_FORMATS')[0];
|
||||||
var selected = inp.value.strptime(format);
|
const selected = inp.value.strptime(format);
|
||||||
var year = selected.getUTCFullYear();
|
const year = selected.getUTCFullYear();
|
||||||
var month = selected.getUTCMonth() + 1;
|
const month = selected.getUTCMonth() + 1;
|
||||||
var re = /\d{4}/;
|
const re = /\d{4}/;
|
||||||
if (re.test(year.toString()) && month >= 1 && month <= 12) {
|
if (re.test(year.toString()) && month >= 1 && month <= 12) {
|
||||||
DateTimeShortcuts.calendars[num].drawDate(month, year, selected);
|
DateTimeShortcuts.calendars[num].drawDate(month, year, selected);
|
||||||
}
|
}
|
||||||
|
@ -376,8 +372,6 @@
|
||||||
else {
|
else {
|
||||||
// since style's width is in em, it'd be tough to calculate
|
// since style's width is in em, it'd be tough to calculate
|
||||||
// px value of it. let's use an estimated px for now
|
// px value of it. let's use an estimated px for now
|
||||||
// TODO: IE returns wrong value for findPosX when in rtl mode
|
|
||||||
// (it returns as it was left aligned), needs to be fixed.
|
|
||||||
cal_box.style.left = findPosX(cal_link) - 180 + 'px';
|
cal_box.style.left = findPosX(cal_link) - 180 + 'px';
|
||||||
}
|
}
|
||||||
cal_box.style.top = Math.max(0, findPosY(cal_link) - 75) + 'px';
|
cal_box.style.top = Math.max(0, findPosY(cal_link) - 75) + 'px';
|
||||||
|
@ -396,7 +390,7 @@
|
||||||
DateTimeShortcuts.calendars[num].drawNextMonth();
|
DateTimeShortcuts.calendars[num].drawNextMonth();
|
||||||
},
|
},
|
||||||
handleCalendarCallback: function(num) {
|
handleCalendarCallback: function(num) {
|
||||||
var format = get_format('DATE_INPUT_FORMATS')[0];
|
let format = get_format('DATE_INPUT_FORMATS')[0];
|
||||||
// the format needs to be escaped a little
|
// the format needs to be escaped a little
|
||||||
format = format.replace('\\', '\\\\')
|
format = format.replace('\\', '\\\\')
|
||||||
.replace('\r', '\\r')
|
.replace('\r', '\\r')
|
||||||
|
@ -410,7 +404,7 @@
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
handleCalendarQuickLink: function(num, offset) {
|
handleCalendarQuickLink: function(num, offset) {
|
||||||
var d = DateTimeShortcuts.now();
|
const d = DateTimeShortcuts.now();
|
||||||
d.setDate(d.getDate() + offset);
|
d.setDate(d.getDate() + offset);
|
||||||
DateTimeShortcuts.calendarInputs[num].value = d.strftime(get_format('DATE_INPUT_FORMATS')[0]);
|
DateTimeShortcuts.calendarInputs[num].value = d.strftime(get_format('DATE_INPUT_FORMATS')[0]);
|
||||||
DateTimeShortcuts.calendarInputs[num].focus();
|
DateTimeShortcuts.calendarInputs[num].focus();
|
||||||
|
@ -420,4 +414,4 @@
|
||||||
|
|
||||||
window.addEventListener('load', DateTimeShortcuts.init);
|
window.addEventListener('load', DateTimeShortcuts.init);
|
||||||
window.DateTimeShortcuts = DateTimeShortcuts;
|
window.DateTimeShortcuts = DateTimeShortcuts;
|
||||||
})();
|
}
|
Binary file not shown.
Binary file not shown.
|
@ -2,9 +2,9 @@
|
||||||
// Inserts shortcut buttons after all of the following:
|
// Inserts shortcut buttons after all of the following:
|
||||||
// <input type="text" class="vDateField">
|
// <input type="text" class="vDateField">
|
||||||
// <input type="text" class="vTimeField">
|
// <input type="text" class="vTimeField">
|
||||||
(function() {
|
'use strict';
|
||||||
'use strict';
|
{
|
||||||
var DateTimeShortcuts = {
|
const DateTimeShortcuts = {
|
||||||
calendars: [],
|
calendars: [],
|
||||||
calendarInputs: [],
|
calendarInputs: [],
|
||||||
clockInputs: [],
|
clockInputs: [],
|
||||||
|
@ -28,21 +28,19 @@
|
||||||
timezoneWarningClass: 'timezonewarning', // class of the warning for timezone mismatch
|
timezoneWarningClass: 'timezonewarning', // class of the warning for timezone mismatch
|
||||||
timezoneOffset: 0,
|
timezoneOffset: 0,
|
||||||
init: function() {
|
init: function() {
|
||||||
var body = document.getElementsByTagName('body')[0];
|
const body = document.getElementsByTagName('body')[0];
|
||||||
var serverOffset = body.getAttribute('data-admin-utc-offset');
|
const serverOffset = body.dataset.adminUtcOffset;
|
||||||
if (serverOffset) {
|
if (serverOffset) {
|
||||||
var localOffset = new Date().getTimezoneOffset() * -60;
|
const localOffset = new Date().getTimezoneOffset() * -60;
|
||||||
DateTimeShortcuts.timezoneOffset = localOffset - serverOffset;
|
DateTimeShortcuts.timezoneOffset = localOffset - serverOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
var inputs = document.getElementsByTagName('input');
|
for (const inp of document.getElementsByTagName('input')) {
|
||||||
for (var i = 0; i < inputs.length; i++) {
|
if (inp.type === 'text' && inp.classList.contains('vTimeField')) {
|
||||||
var inp = inputs[i];
|
|
||||||
if (inp.getAttribute('type') === 'text' && inp.className.match(/vTimeField/)) {
|
|
||||||
DateTimeShortcuts.addClock(inp);
|
DateTimeShortcuts.addClock(inp);
|
||||||
DateTimeShortcuts.addTimezoneWarning(inp);
|
DateTimeShortcuts.addTimezoneWarning(inp);
|
||||||
}
|
}
|
||||||
else if (inp.getAttribute('type') === 'text' && inp.className.match(/vDateField/)) {
|
else if (inp.type === 'text' && inp.classList.contains('vDateField')) {
|
||||||
DateTimeShortcuts.addCalendar(inp);
|
DateTimeShortcuts.addCalendar(inp);
|
||||||
DateTimeShortcuts.addTimezoneWarning(inp);
|
DateTimeShortcuts.addTimezoneWarning(inp);
|
||||||
}
|
}
|
||||||
|
@ -50,11 +48,11 @@
|
||||||
},
|
},
|
||||||
// Return the current time while accounting for the server timezone.
|
// Return the current time while accounting for the server timezone.
|
||||||
now: function() {
|
now: function() {
|
||||||
var body = document.getElementsByTagName('body')[0];
|
const body = document.getElementsByTagName('body')[0];
|
||||||
var serverOffset = body.getAttribute('data-admin-utc-offset');
|
const serverOffset = body.dataset.adminUtcOffset;
|
||||||
if (serverOffset) {
|
if (serverOffset) {
|
||||||
var localNow = new Date();
|
const localNow = new Date();
|
||||||
var localOffset = localNow.getTimezoneOffset() * -60;
|
const localOffset = localNow.getTimezoneOffset() * -60;
|
||||||
localNow.setTime(localNow.getTime() + 1000 * (serverOffset - localOffset));
|
localNow.setTime(localNow.getTime() + 1000 * (serverOffset - localOffset));
|
||||||
return localNow;
|
return localNow;
|
||||||
} else {
|
} else {
|
||||||
|
@ -63,8 +61,8 @@
|
||||||
},
|
},
|
||||||
// Add a warning when the time zone in the browser and backend do not match.
|
// Add a warning when the time zone in the browser and backend do not match.
|
||||||
addTimezoneWarning: function(inp) {
|
addTimezoneWarning: function(inp) {
|
||||||
var warningClass = DateTimeShortcuts.timezoneWarningClass;
|
const warningClass = DateTimeShortcuts.timezoneWarningClass;
|
||||||
var timezoneOffset = DateTimeShortcuts.timezoneOffset / 3600;
|
let timezoneOffset = DateTimeShortcuts.timezoneOffset / 3600;
|
||||||
|
|
||||||
// Only warn if there is a time zone mismatch.
|
// Only warn if there is a time zone mismatch.
|
||||||
if (!timezoneOffset) {
|
if (!timezoneOffset) {
|
||||||
|
@ -76,7 +74,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var message;
|
let message;
|
||||||
if (timezoneOffset > 0) {
|
if (timezoneOffset > 0) {
|
||||||
message = ngettext(
|
message = ngettext(
|
||||||
'Note: You are %s hour ahead of server time.',
|
'Note: You are %s hour ahead of server time.',
|
||||||
|
@ -94,7 +92,7 @@
|
||||||
}
|
}
|
||||||
message = interpolate(message, [timezoneOffset]);
|
message = interpolate(message, [timezoneOffset]);
|
||||||
|
|
||||||
var warning = document.createElement('span');
|
const warning = document.createElement('span');
|
||||||
warning.className = warningClass;
|
warning.className = warningClass;
|
||||||
warning.textContent = message;
|
warning.textContent = message;
|
||||||
inp.parentNode.appendChild(document.createElement('br'));
|
inp.parentNode.appendChild(document.createElement('br'));
|
||||||
|
@ -102,23 +100,23 @@
|
||||||
},
|
},
|
||||||
// Add clock widget to a given field
|
// Add clock widget to a given field
|
||||||
addClock: function(inp) {
|
addClock: function(inp) {
|
||||||
var num = DateTimeShortcuts.clockInputs.length;
|
const num = DateTimeShortcuts.clockInputs.length;
|
||||||
DateTimeShortcuts.clockInputs[num] = inp;
|
DateTimeShortcuts.clockInputs[num] = inp;
|
||||||
DateTimeShortcuts.dismissClockFunc[num] = function() { DateTimeShortcuts.dismissClock(num); return true; };
|
DateTimeShortcuts.dismissClockFunc[num] = function() { DateTimeShortcuts.dismissClock(num); return true; };
|
||||||
|
|
||||||
// Shortcut links (clock icon and "Now" link)
|
// Shortcut links (clock icon and "Now" link)
|
||||||
var shortcuts_span = document.createElement('span');
|
const shortcuts_span = document.createElement('span');
|
||||||
shortcuts_span.className = DateTimeShortcuts.shortCutsClass;
|
shortcuts_span.className = DateTimeShortcuts.shortCutsClass;
|
||||||
inp.parentNode.insertBefore(shortcuts_span, inp.nextSibling);
|
inp.parentNode.insertBefore(shortcuts_span, inp.nextSibling);
|
||||||
var now_link = document.createElement('a');
|
const now_link = document.createElement('a');
|
||||||
now_link.setAttribute('href', "#");
|
now_link.href = "#";
|
||||||
now_link.textContent = gettext('Now');
|
now_link.textContent = gettext('Now');
|
||||||
now_link.addEventListener('click', function(e) {
|
now_link.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
DateTimeShortcuts.handleClockQuicklink(num, -1);
|
DateTimeShortcuts.handleClockQuicklink(num, -1);
|
||||||
});
|
});
|
||||||
var clock_link = document.createElement('a');
|
const clock_link = document.createElement('a');
|
||||||
clock_link.setAttribute('href', '#');
|
clock_link.href = '#';
|
||||||
clock_link.id = DateTimeShortcuts.clockLinkName + num;
|
clock_link.id = DateTimeShortcuts.clockLinkName + num;
|
||||||
clock_link.addEventListener('click', function(e) {
|
clock_link.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -152,32 +150,32 @@
|
||||||
// <p class="calendar-cancel"><a href="#">Cancel</a></p>
|
// <p class="calendar-cancel"><a href="#">Cancel</a></p>
|
||||||
// </div>
|
// </div>
|
||||||
|
|
||||||
var clock_box = document.createElement('div');
|
const clock_box = document.createElement('div');
|
||||||
clock_box.style.display = 'none';
|
clock_box.style.display = 'none';
|
||||||
clock_box.style.position = 'absolute';
|
clock_box.style.position = 'absolute';
|
||||||
clock_box.className = 'clockbox module';
|
clock_box.className = 'clockbox module';
|
||||||
clock_box.setAttribute('id', DateTimeShortcuts.clockDivName + num);
|
clock_box.id = DateTimeShortcuts.clockDivName + num;
|
||||||
document.body.appendChild(clock_box);
|
document.body.appendChild(clock_box);
|
||||||
clock_box.addEventListener('click', function(e) { e.stopPropagation(); });
|
clock_box.addEventListener('click', function(e) { e.stopPropagation(); });
|
||||||
|
|
||||||
quickElement('h2', clock_box, gettext('Choose a time'));
|
quickElement('h2', clock_box, gettext('Choose a time'));
|
||||||
var time_list = quickElement('ul', clock_box);
|
const time_list = quickElement('ul', clock_box);
|
||||||
time_list.className = 'timelist';
|
time_list.className = 'timelist';
|
||||||
// The list of choices can be overridden in JavaScript like this:
|
// The list of choices can be overridden in JavaScript like this:
|
||||||
// DateTimeShortcuts.clockHours.name = [['3 a.m.', 3]];
|
// DateTimeShortcuts.clockHours.name = [['3 a.m.', 3]];
|
||||||
// where name is the name attribute of the <input>.
|
// where name is the name attribute of the <input>.
|
||||||
var name = typeof DateTimeShortcuts.clockHours[inp.name] === 'undefined' ? 'default_' : inp.name;
|
const name = typeof DateTimeShortcuts.clockHours[inp.name] === 'undefined' ? 'default_' : inp.name;
|
||||||
DateTimeShortcuts.clockHours[name].forEach(function(element) {
|
DateTimeShortcuts.clockHours[name].forEach(function(element) {
|
||||||
var time_link = quickElement('a', quickElement('li', time_list), gettext(element[0]), 'href', '#');
|
const time_link = quickElement('a', quickElement('li', time_list), gettext(element[0]), 'href', '#');
|
||||||
time_link.addEventListener('click', function(e) {
|
time_link.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
DateTimeShortcuts.handleClockQuicklink(num, element[1]);
|
DateTimeShortcuts.handleClockQuicklink(num, element[1]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
var cancel_p = quickElement('p', clock_box);
|
const cancel_p = quickElement('p', clock_box);
|
||||||
cancel_p.className = 'calendar-cancel';
|
cancel_p.className = 'calendar-cancel';
|
||||||
var cancel_link = quickElement('a', cancel_p, gettext('Cancel'), 'href', '#');
|
const cancel_link = quickElement('a', cancel_p, gettext('Cancel'), 'href', '#');
|
||||||
cancel_link.addEventListener('click', function(e) {
|
cancel_link.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
DateTimeShortcuts.dismissClock(num);
|
DateTimeShortcuts.dismissClock(num);
|
||||||
|
@ -192,8 +190,8 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
openClock: function(num) {
|
openClock: function(num) {
|
||||||
var clock_box = document.getElementById(DateTimeShortcuts.clockDivName + num);
|
const clock_box = document.getElementById(DateTimeShortcuts.clockDivName + num);
|
||||||
var clock_link = document.getElementById(DateTimeShortcuts.clockLinkName + num);
|
const clock_link = document.getElementById(DateTimeShortcuts.clockLinkName + num);
|
||||||
|
|
||||||
// Recalculate the clockbox position
|
// Recalculate the clockbox position
|
||||||
// is it left-to-right or right-to-left layout ?
|
// is it left-to-right or right-to-left layout ?
|
||||||
|
@ -203,8 +201,6 @@
|
||||||
else {
|
else {
|
||||||
// since style's width is in em, it'd be tough to calculate
|
// since style's width is in em, it'd be tough to calculate
|
||||||
// px value of it. let's use an estimated px for now
|
// px value of it. let's use an estimated px for now
|
||||||
// TODO: IE returns wrong value for findPosX when in rtl mode
|
|
||||||
// (it returns as it was left aligned), needs to be fixed.
|
|
||||||
clock_box.style.left = findPosX(clock_link) - 110 + 'px';
|
clock_box.style.left = findPosX(clock_link) - 110 + 'px';
|
||||||
}
|
}
|
||||||
clock_box.style.top = Math.max(0, findPosY(clock_link) - 30) + 'px';
|
clock_box.style.top = Math.max(0, findPosY(clock_link) - 30) + 'px';
|
||||||
|
@ -218,7 +214,7 @@
|
||||||
document.removeEventListener('click', DateTimeShortcuts.dismissClockFunc[num]);
|
document.removeEventListener('click', DateTimeShortcuts.dismissClockFunc[num]);
|
||||||
},
|
},
|
||||||
handleClockQuicklink: function(num, val) {
|
handleClockQuicklink: function(num, val) {
|
||||||
var d;
|
let d;
|
||||||
if (val === -1) {
|
if (val === -1) {
|
||||||
d = DateTimeShortcuts.now();
|
d = DateTimeShortcuts.now();
|
||||||
}
|
}
|
||||||
|
@ -231,24 +227,24 @@
|
||||||
},
|
},
|
||||||
// Add calendar widget to a given field.
|
// Add calendar widget to a given field.
|
||||||
addCalendar: function(inp) {
|
addCalendar: function(inp) {
|
||||||
var num = DateTimeShortcuts.calendars.length;
|
const num = DateTimeShortcuts.calendars.length;
|
||||||
|
|
||||||
DateTimeShortcuts.calendarInputs[num] = inp;
|
DateTimeShortcuts.calendarInputs[num] = inp;
|
||||||
DateTimeShortcuts.dismissCalendarFunc[num] = function() { DateTimeShortcuts.dismissCalendar(num); return true; };
|
DateTimeShortcuts.dismissCalendarFunc[num] = function() { DateTimeShortcuts.dismissCalendar(num); return true; };
|
||||||
|
|
||||||
// Shortcut links (calendar icon and "Today" link)
|
// Shortcut links (calendar icon and "Today" link)
|
||||||
var shortcuts_span = document.createElement('span');
|
const shortcuts_span = document.createElement('span');
|
||||||
shortcuts_span.className = DateTimeShortcuts.shortCutsClass;
|
shortcuts_span.className = DateTimeShortcuts.shortCutsClass;
|
||||||
inp.parentNode.insertBefore(shortcuts_span, inp.nextSibling);
|
inp.parentNode.insertBefore(shortcuts_span, inp.nextSibling);
|
||||||
var today_link = document.createElement('a');
|
const today_link = document.createElement('a');
|
||||||
today_link.setAttribute('href', '#');
|
today_link.href = '#';
|
||||||
today_link.appendChild(document.createTextNode(gettext('Today')));
|
today_link.appendChild(document.createTextNode(gettext('Today')));
|
||||||
today_link.addEventListener('click', function(e) {
|
today_link.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
DateTimeShortcuts.handleCalendarQuickLink(num, 0);
|
DateTimeShortcuts.handleCalendarQuickLink(num, 0);
|
||||||
});
|
});
|
||||||
var cal_link = document.createElement('a');
|
const cal_link = document.createElement('a');
|
||||||
cal_link.setAttribute('href', '#');
|
cal_link.href = '#';
|
||||||
cal_link.id = DateTimeShortcuts.calendarLinkName + num;
|
cal_link.id = DateTimeShortcuts.calendarLinkName + num;
|
||||||
cal_link.addEventListener('click', function(e) {
|
cal_link.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -283,24 +279,24 @@
|
||||||
// </div>
|
// </div>
|
||||||
// <p class="calendar-cancel"><a href="#">Cancel</a></p>
|
// <p class="calendar-cancel"><a href="#">Cancel</a></p>
|
||||||
// </div>
|
// </div>
|
||||||
var cal_box = document.createElement('div');
|
const cal_box = document.createElement('div');
|
||||||
cal_box.style.display = 'none';
|
cal_box.style.display = 'none';
|
||||||
cal_box.style.position = 'absolute';
|
cal_box.style.position = 'absolute';
|
||||||
cal_box.className = 'calendarbox module';
|
cal_box.className = 'calendarbox module';
|
||||||
cal_box.setAttribute('id', DateTimeShortcuts.calendarDivName1 + num);
|
cal_box.id = DateTimeShortcuts.calendarDivName1 + num;
|
||||||
document.body.appendChild(cal_box);
|
document.body.appendChild(cal_box);
|
||||||
cal_box.addEventListener('click', function(e) { e.stopPropagation(); });
|
cal_box.addEventListener('click', function(e) { e.stopPropagation(); });
|
||||||
|
|
||||||
// next-prev links
|
// next-prev links
|
||||||
var cal_nav = quickElement('div', cal_box);
|
const cal_nav = quickElement('div', cal_box);
|
||||||
var cal_nav_prev = quickElement('a', cal_nav, '<', 'href', '#');
|
const cal_nav_prev = quickElement('a', cal_nav, '<', 'href', '#');
|
||||||
cal_nav_prev.className = 'calendarnav-previous';
|
cal_nav_prev.className = 'calendarnav-previous';
|
||||||
cal_nav_prev.addEventListener('click', function(e) {
|
cal_nav_prev.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
DateTimeShortcuts.drawPrev(num);
|
DateTimeShortcuts.drawPrev(num);
|
||||||
});
|
});
|
||||||
|
|
||||||
var cal_nav_next = quickElement('a', cal_nav, '>', 'href', '#');
|
const cal_nav_next = quickElement('a', cal_nav, '>', 'href', '#');
|
||||||
cal_nav_next.className = 'calendarnav-next';
|
cal_nav_next.className = 'calendarnav-next';
|
||||||
cal_nav_next.addEventListener('click', function(e) {
|
cal_nav_next.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -308,15 +304,15 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
// main box
|
// main box
|
||||||
var cal_main = quickElement('div', cal_box, '', 'id', DateTimeShortcuts.calendarDivName2 + num);
|
const cal_main = quickElement('div', cal_box, '', 'id', DateTimeShortcuts.calendarDivName2 + num);
|
||||||
cal_main.className = 'calendar';
|
cal_main.className = 'calendar';
|
||||||
DateTimeShortcuts.calendars[num] = new Calendar(DateTimeShortcuts.calendarDivName2 + num, DateTimeShortcuts.handleCalendarCallback(num));
|
DateTimeShortcuts.calendars[num] = new Calendar(DateTimeShortcuts.calendarDivName2 + num, DateTimeShortcuts.handleCalendarCallback(num));
|
||||||
DateTimeShortcuts.calendars[num].drawCurrent();
|
DateTimeShortcuts.calendars[num].drawCurrent();
|
||||||
|
|
||||||
// calendar shortcuts
|
// calendar shortcuts
|
||||||
var shortcuts = quickElement('div', cal_box);
|
const shortcuts = quickElement('div', cal_box);
|
||||||
shortcuts.className = 'calendar-shortcuts';
|
shortcuts.className = 'calendar-shortcuts';
|
||||||
var day_link = quickElement('a', shortcuts, gettext('Yesterday'), 'href', '#');
|
let day_link = quickElement('a', shortcuts, gettext('Yesterday'), 'href', '#');
|
||||||
day_link.addEventListener('click', function(e) {
|
day_link.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
DateTimeShortcuts.handleCalendarQuickLink(num, -1);
|
DateTimeShortcuts.handleCalendarQuickLink(num, -1);
|
||||||
|
@ -335,9 +331,9 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
// cancel bar
|
// cancel bar
|
||||||
var cancel_p = quickElement('p', cal_box);
|
const cancel_p = quickElement('p', cal_box);
|
||||||
cancel_p.className = 'calendar-cancel';
|
cancel_p.className = 'calendar-cancel';
|
||||||
var cancel_link = quickElement('a', cancel_p, gettext('Cancel'), 'href', '#');
|
const cancel_link = quickElement('a', cancel_p, gettext('Cancel'), 'href', '#');
|
||||||
cancel_link.addEventListener('click', function(e) {
|
cancel_link.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
DateTimeShortcuts.dismissCalendar(num);
|
DateTimeShortcuts.dismissCalendar(num);
|
||||||
|
@ -351,18 +347,18 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
openCalendar: function(num) {
|
openCalendar: function(num) {
|
||||||
var cal_box = document.getElementById(DateTimeShortcuts.calendarDivName1 + num);
|
const cal_box = document.getElementById(DateTimeShortcuts.calendarDivName1 + num);
|
||||||
var cal_link = document.getElementById(DateTimeShortcuts.calendarLinkName + num);
|
const cal_link = document.getElementById(DateTimeShortcuts.calendarLinkName + num);
|
||||||
var inp = DateTimeShortcuts.calendarInputs[num];
|
const inp = DateTimeShortcuts.calendarInputs[num];
|
||||||
|
|
||||||
// Determine if the current value in the input has a valid date.
|
// Determine if the current value in the input has a valid date.
|
||||||
// If so, draw the calendar with that date's year and month.
|
// If so, draw the calendar with that date's year and month.
|
||||||
if (inp.value) {
|
if (inp.value) {
|
||||||
var format = get_format('DATE_INPUT_FORMATS')[0];
|
const format = get_format('DATE_INPUT_FORMATS')[0];
|
||||||
var selected = inp.value.strptime(format);
|
const selected = inp.value.strptime(format);
|
||||||
var year = selected.getUTCFullYear();
|
const year = selected.getUTCFullYear();
|
||||||
var month = selected.getUTCMonth() + 1;
|
const month = selected.getUTCMonth() + 1;
|
||||||
var re = /\d{4}/;
|
const re = /\d{4}/;
|
||||||
if (re.test(year.toString()) && month >= 1 && month <= 12) {
|
if (re.test(year.toString()) && month >= 1 && month <= 12) {
|
||||||
DateTimeShortcuts.calendars[num].drawDate(month, year, selected);
|
DateTimeShortcuts.calendars[num].drawDate(month, year, selected);
|
||||||
}
|
}
|
||||||
|
@ -376,8 +372,6 @@
|
||||||
else {
|
else {
|
||||||
// since style's width is in em, it'd be tough to calculate
|
// since style's width is in em, it'd be tough to calculate
|
||||||
// px value of it. let's use an estimated px for now
|
// px value of it. let's use an estimated px for now
|
||||||
// TODO: IE returns wrong value for findPosX when in rtl mode
|
|
||||||
// (it returns as it was left aligned), needs to be fixed.
|
|
||||||
cal_box.style.left = findPosX(cal_link) - 180 + 'px';
|
cal_box.style.left = findPosX(cal_link) - 180 + 'px';
|
||||||
}
|
}
|
||||||
cal_box.style.top = Math.max(0, findPosY(cal_link) - 75) + 'px';
|
cal_box.style.top = Math.max(0, findPosY(cal_link) - 75) + 'px';
|
||||||
|
@ -396,7 +390,7 @@
|
||||||
DateTimeShortcuts.calendars[num].drawNextMonth();
|
DateTimeShortcuts.calendars[num].drawNextMonth();
|
||||||
},
|
},
|
||||||
handleCalendarCallback: function(num) {
|
handleCalendarCallback: function(num) {
|
||||||
var format = get_format('DATE_INPUT_FORMATS')[0];
|
let format = get_format('DATE_INPUT_FORMATS')[0];
|
||||||
// the format needs to be escaped a little
|
// the format needs to be escaped a little
|
||||||
format = format.replace('\\', '\\\\')
|
format = format.replace('\\', '\\\\')
|
||||||
.replace('\r', '\\r')
|
.replace('\r', '\\r')
|
||||||
|
@ -410,7 +404,7 @@
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
handleCalendarQuickLink: function(num, offset) {
|
handleCalendarQuickLink: function(num, offset) {
|
||||||
var d = DateTimeShortcuts.now();
|
const d = DateTimeShortcuts.now();
|
||||||
d.setDate(d.getDate() + offset);
|
d.setDate(d.getDate() + offset);
|
||||||
DateTimeShortcuts.calendarInputs[num].value = d.strftime(get_format('DATE_INPUT_FORMATS')[0]);
|
DateTimeShortcuts.calendarInputs[num].value = d.strftime(get_format('DATE_INPUT_FORMATS')[0]);
|
||||||
DateTimeShortcuts.calendarInputs[num].focus();
|
DateTimeShortcuts.calendarInputs[num].focus();
|
||||||
|
@ -420,4 +414,4 @@
|
||||||
|
|
||||||
window.addEventListener('load', DateTimeShortcuts.init);
|
window.addEventListener('load', DateTimeShortcuts.init);
|
||||||
window.DateTimeShortcuts = DateTimeShortcuts;
|
window.DateTimeShortcuts = DateTimeShortcuts;
|
||||||
})();
|
}
|
||||||
|
|
Binary file not shown.
|
@ -1,30 +1,13 @@
|
||||||
/*global SelectBox, interpolate*/
|
/*global SelectBox, interpolate*/
|
||||||
// Handles related-objects functionality: lookup link for raw_id_fields
|
// Handles related-objects functionality: lookup link for raw_id_fields
|
||||||
// and Add Another links.
|
// and Add Another links.
|
||||||
|
'use strict';
|
||||||
(function($) {
|
{
|
||||||
'use strict';
|
const $ = django.jQuery;
|
||||||
|
|
||||||
// IE doesn't accept periods or dashes in the window name, but the element IDs
|
|
||||||
// we use to generate popup window names may contain them, therefore we map them
|
|
||||||
// to allowed characters in a reversible way so that we can locate the correct
|
|
||||||
// element when the popup window is dismissed.
|
|
||||||
function id_to_windowname(text) {
|
|
||||||
text = text.replace(/\./g, '__dot__');
|
|
||||||
text = text.replace(/\-/g, '__dash__');
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
function windowname_to_id(text) {
|
|
||||||
text = text.replace(/__dot__/g, '.');
|
|
||||||
text = text.replace(/__dash__/g, '-');
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
function showAdminPopup(triggeringLink, name_regexp, add_popup) {
|
function showAdminPopup(triggeringLink, name_regexp, add_popup) {
|
||||||
var name = triggeringLink.id.replace(name_regexp, '');
|
const name = triggeringLink.id.replace(name_regexp, '');
|
||||||
name = id_to_windowname(name);
|
let href = triggeringLink.href;
|
||||||
var href = triggeringLink.href;
|
|
||||||
if (add_popup) {
|
if (add_popup) {
|
||||||
if (href.indexOf('?') === -1) {
|
if (href.indexOf('?') === -1) {
|
||||||
href += '?_popup=1';
|
href += '?_popup=1';
|
||||||
|
@ -32,7 +15,7 @@
|
||||||
href += '&_popup=1';
|
href += '&_popup=1';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes');
|
const win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes');
|
||||||
win.focus();
|
win.focus();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -42,9 +25,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function dismissRelatedLookupPopup(win, chosenId) {
|
function dismissRelatedLookupPopup(win, chosenId) {
|
||||||
var name = windowname_to_id(win.name);
|
const name = win.name;
|
||||||
var elem = document.getElementById(name);
|
const elem = document.getElementById(name);
|
||||||
if (elem.className.indexOf('vManyToManyRawIdAdminField') !== -1 && elem.value) {
|
if (elem.classList.contains('vManyToManyRawIdAdminField') && elem.value) {
|
||||||
elem.value += ',' + chosenId;
|
elem.value += ',' + chosenId;
|
||||||
} else {
|
} else {
|
||||||
document.getElementById(name).value = chosenId;
|
document.getElementById(name).value = chosenId;
|
||||||
|
@ -57,15 +40,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateRelatedObjectLinks(triggeringLink) {
|
function updateRelatedObjectLinks(triggeringLink) {
|
||||||
var $this = $(triggeringLink);
|
const $this = $(triggeringLink);
|
||||||
var siblings = $this.nextAll('.view-related, .change-related, .delete-related');
|
const siblings = $this.nextAll('.view-related, .change-related, .delete-related');
|
||||||
if (!siblings.length) {
|
if (!siblings.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var value = $this.val();
|
const value = $this.val();
|
||||||
if (value) {
|
if (value) {
|
||||||
siblings.each(function() {
|
siblings.each(function() {
|
||||||
var elm = $(this);
|
const elm = $(this);
|
||||||
elm.attr('href', elm.attr('data-href-template').replace('__fk__', value));
|
elm.attr('href', elm.attr('data-href-template').replace('__fk__', value));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -74,14 +57,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function dismissAddRelatedObjectPopup(win, newId, newRepr) {
|
function dismissAddRelatedObjectPopup(win, newId, newRepr) {
|
||||||
var name = windowname_to_id(win.name);
|
const name = win.name;
|
||||||
var elem = document.getElementById(name);
|
const elem = document.getElementById(name);
|
||||||
if (elem) {
|
if (elem) {
|
||||||
var elemName = elem.nodeName.toUpperCase();
|
const elemName = elem.nodeName.toUpperCase();
|
||||||
if (elemName === 'SELECT') {
|
if (elemName === 'SELECT') {
|
||||||
elem.options[elem.options.length] = new Option(newRepr, newId, true, true);
|
elem.options[elem.options.length] = new Option(newRepr, newId, true, true);
|
||||||
} else if (elemName === 'INPUT') {
|
} else if (elemName === 'INPUT') {
|
||||||
if (elem.className.indexOf('vManyToManyRawIdAdminField') !== -1 && elem.value) {
|
if (elem.classList.contains('vManyToManyRawIdAdminField') && elem.value) {
|
||||||
elem.value += ',' + newId;
|
elem.value += ',' + newId;
|
||||||
} else {
|
} else {
|
||||||
elem.value = newId;
|
elem.value = newId;
|
||||||
|
@ -90,8 +73,8 @@
|
||||||
// Trigger a change event to update related links if required.
|
// Trigger a change event to update related links if required.
|
||||||
$(elem).trigger('change');
|
$(elem).trigger('change');
|
||||||
} else {
|
} else {
|
||||||
var toId = name + "_to";
|
const toId = name + "_to";
|
||||||
var o = new Option(newRepr, newId);
|
const o = new Option(newRepr, newId);
|
||||||
SelectBox.add_to_cache(toId, o);
|
SelectBox.add_to_cache(toId, o);
|
||||||
SelectBox.redisplay(toId);
|
SelectBox.redisplay(toId);
|
||||||
}
|
}
|
||||||
|
@ -99,9 +82,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function dismissChangeRelatedObjectPopup(win, objId, newRepr, newId) {
|
function dismissChangeRelatedObjectPopup(win, objId, newRepr, newId) {
|
||||||
var id = windowname_to_id(win.name).replace(/^edit_/, '');
|
const id = win.name.replace(/^edit_/, '');
|
||||||
var selectsSelector = interpolate('#%s, #%s_from, #%s_to', [id, id, id]);
|
const selectsSelector = interpolate('#%s, #%s_from, #%s_to', [id, id, id]);
|
||||||
var selects = $(selectsSelector);
|
const selects = $(selectsSelector);
|
||||||
selects.find('option').each(function() {
|
selects.find('option').each(function() {
|
||||||
if (this.value === objId) {
|
if (this.value === objId) {
|
||||||
this.textContent = newRepr;
|
this.textContent = newRepr;
|
||||||
|
@ -118,9 +101,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function dismissDeleteRelatedObjectPopup(win, objId) {
|
function dismissDeleteRelatedObjectPopup(win, objId) {
|
||||||
var id = windowname_to_id(win.name).replace(/^delete_/, '');
|
const id = win.name.replace(/^delete_/, '');
|
||||||
var selectsSelector = interpolate('#%s, #%s_from, #%s_to', [id, id, id]);
|
const selectsSelector = interpolate('#%s, #%s_from, #%s_to', [id, id, id]);
|
||||||
var selects = $(selectsSelector);
|
const selects = $(selectsSelector);
|
||||||
selects.find('option').each(function() {
|
selects.find('option').each(function() {
|
||||||
if (this.value === objId) {
|
if (this.value === objId) {
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
|
@ -129,10 +112,6 @@
|
||||||
win.close();
|
win.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Global for testing purposes
|
|
||||||
window.id_to_windowname = id_to_windowname;
|
|
||||||
window.windowname_to_id = windowname_to_id;
|
|
||||||
|
|
||||||
window.showRelatedObjectLookupPopup = showRelatedObjectLookupPopup;
|
window.showRelatedObjectLookupPopup = showRelatedObjectLookupPopup;
|
||||||
window.dismissRelatedLookupPopup = dismissRelatedLookupPopup;
|
window.dismissRelatedLookupPopup = dismissRelatedLookupPopup;
|
||||||
window.showRelatedObjectPopup = showRelatedObjectPopup;
|
window.showRelatedObjectPopup = showRelatedObjectPopup;
|
||||||
|
@ -153,7 +132,7 @@
|
||||||
$('body').on('click', '.related-widget-wrapper-link', function(e) {
|
$('body').on('click', '.related-widget-wrapper-link', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (this.href) {
|
if (this.href) {
|
||||||
var event = $.Event('django:show-related', {href: this.href});
|
const event = $.Event('django:show-related', {href: this.href});
|
||||||
$(this).trigger(event);
|
$(this).trigger(event);
|
||||||
if (!event.isDefaultPrevented()) {
|
if (!event.isDefaultPrevented()) {
|
||||||
showRelatedObjectPopup(this);
|
showRelatedObjectPopup(this);
|
||||||
|
@ -161,7 +140,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('body').on('change', '.related-widget-wrapper select', function(e) {
|
$('body').on('change', '.related-widget-wrapper select', function(e) {
|
||||||
var event = $.Event('django:update-related');
|
const event = $.Event('django:update-related');
|
||||||
$(this).trigger(event);
|
$(this).trigger(event);
|
||||||
if (!event.isDefaultPrevented()) {
|
if (!event.isDefaultPrevented()) {
|
||||||
updateRelatedObjectLinks(this);
|
updateRelatedObjectLinks(this);
|
||||||
|
@ -170,12 +149,11 @@
|
||||||
$('.related-widget-wrapper select').trigger('change');
|
$('.related-widget-wrapper select').trigger('change');
|
||||||
$('body').on('click', '.related-lookup', function(e) {
|
$('body').on('click', '.related-lookup', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var event = $.Event('django:lookup-related');
|
const event = $.Event('django:lookup-related');
|
||||||
$(this).trigger(event);
|
$(this).trigger(event);
|
||||||
if (!event.isDefaultPrevented()) {
|
if (!event.isDefaultPrevented()) {
|
||||||
showRelatedObjectLookupPopup(this);
|
showRelatedObjectLookupPopup(this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
})(django.jQuery);
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,30 +1,13 @@
|
||||||
/*global SelectBox, interpolate*/
|
/*global SelectBox, interpolate*/
|
||||||
// Handles related-objects functionality: lookup link for raw_id_fields
|
// Handles related-objects functionality: lookup link for raw_id_fields
|
||||||
// and Add Another links.
|
// and Add Another links.
|
||||||
|
'use strict';
|
||||||
(function($) {
|
{
|
||||||
'use strict';
|
const $ = django.jQuery;
|
||||||
|
|
||||||
// IE doesn't accept periods or dashes in the window name, but the element IDs
|
|
||||||
// we use to generate popup window names may contain them, therefore we map them
|
|
||||||
// to allowed characters in a reversible way so that we can locate the correct
|
|
||||||
// element when the popup window is dismissed.
|
|
||||||
function id_to_windowname(text) {
|
|
||||||
text = text.replace(/\./g, '__dot__');
|
|
||||||
text = text.replace(/\-/g, '__dash__');
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
function windowname_to_id(text) {
|
|
||||||
text = text.replace(/__dot__/g, '.');
|
|
||||||
text = text.replace(/__dash__/g, '-');
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
function showAdminPopup(triggeringLink, name_regexp, add_popup) {
|
function showAdminPopup(triggeringLink, name_regexp, add_popup) {
|
||||||
var name = triggeringLink.id.replace(name_regexp, '');
|
const name = triggeringLink.id.replace(name_regexp, '');
|
||||||
name = id_to_windowname(name);
|
let href = triggeringLink.href;
|
||||||
var href = triggeringLink.href;
|
|
||||||
if (add_popup) {
|
if (add_popup) {
|
||||||
if (href.indexOf('?') === -1) {
|
if (href.indexOf('?') === -1) {
|
||||||
href += '?_popup=1';
|
href += '?_popup=1';
|
||||||
|
@ -32,7 +15,7 @@
|
||||||
href += '&_popup=1';
|
href += '&_popup=1';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes');
|
const win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes');
|
||||||
win.focus();
|
win.focus();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -42,9 +25,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function dismissRelatedLookupPopup(win, chosenId) {
|
function dismissRelatedLookupPopup(win, chosenId) {
|
||||||
var name = windowname_to_id(win.name);
|
const name = win.name;
|
||||||
var elem = document.getElementById(name);
|
const elem = document.getElementById(name);
|
||||||
if (elem.className.indexOf('vManyToManyRawIdAdminField') !== -1 && elem.value) {
|
if (elem.classList.contains('vManyToManyRawIdAdminField') && elem.value) {
|
||||||
elem.value += ',' + chosenId;
|
elem.value += ',' + chosenId;
|
||||||
} else {
|
} else {
|
||||||
document.getElementById(name).value = chosenId;
|
document.getElementById(name).value = chosenId;
|
||||||
|
@ -57,15 +40,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateRelatedObjectLinks(triggeringLink) {
|
function updateRelatedObjectLinks(triggeringLink) {
|
||||||
var $this = $(triggeringLink);
|
const $this = $(triggeringLink);
|
||||||
var siblings = $this.nextAll('.view-related, .change-related, .delete-related');
|
const siblings = $this.nextAll('.view-related, .change-related, .delete-related');
|
||||||
if (!siblings.length) {
|
if (!siblings.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var value = $this.val();
|
const value = $this.val();
|
||||||
if (value) {
|
if (value) {
|
||||||
siblings.each(function() {
|
siblings.each(function() {
|
||||||
var elm = $(this);
|
const elm = $(this);
|
||||||
elm.attr('href', elm.attr('data-href-template').replace('__fk__', value));
|
elm.attr('href', elm.attr('data-href-template').replace('__fk__', value));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -74,14 +57,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function dismissAddRelatedObjectPopup(win, newId, newRepr) {
|
function dismissAddRelatedObjectPopup(win, newId, newRepr) {
|
||||||
var name = windowname_to_id(win.name);
|
const name = win.name;
|
||||||
var elem = document.getElementById(name);
|
const elem = document.getElementById(name);
|
||||||
if (elem) {
|
if (elem) {
|
||||||
var elemName = elem.nodeName.toUpperCase();
|
const elemName = elem.nodeName.toUpperCase();
|
||||||
if (elemName === 'SELECT') {
|
if (elemName === 'SELECT') {
|
||||||
elem.options[elem.options.length] = new Option(newRepr, newId, true, true);
|
elem.options[elem.options.length] = new Option(newRepr, newId, true, true);
|
||||||
} else if (elemName === 'INPUT') {
|
} else if (elemName === 'INPUT') {
|
||||||
if (elem.className.indexOf('vManyToManyRawIdAdminField') !== -1 && elem.value) {
|
if (elem.classList.contains('vManyToManyRawIdAdminField') && elem.value) {
|
||||||
elem.value += ',' + newId;
|
elem.value += ',' + newId;
|
||||||
} else {
|
} else {
|
||||||
elem.value = newId;
|
elem.value = newId;
|
||||||
|
@ -90,8 +73,8 @@
|
||||||
// Trigger a change event to update related links if required.
|
// Trigger a change event to update related links if required.
|
||||||
$(elem).trigger('change');
|
$(elem).trigger('change');
|
||||||
} else {
|
} else {
|
||||||
var toId = name + "_to";
|
const toId = name + "_to";
|
||||||
var o = new Option(newRepr, newId);
|
const o = new Option(newRepr, newId);
|
||||||
SelectBox.add_to_cache(toId, o);
|
SelectBox.add_to_cache(toId, o);
|
||||||
SelectBox.redisplay(toId);
|
SelectBox.redisplay(toId);
|
||||||
}
|
}
|
||||||
|
@ -99,9 +82,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function dismissChangeRelatedObjectPopup(win, objId, newRepr, newId) {
|
function dismissChangeRelatedObjectPopup(win, objId, newRepr, newId) {
|
||||||
var id = windowname_to_id(win.name).replace(/^edit_/, '');
|
const id = win.name.replace(/^edit_/, '');
|
||||||
var selectsSelector = interpolate('#%s, #%s_from, #%s_to', [id, id, id]);
|
const selectsSelector = interpolate('#%s, #%s_from, #%s_to', [id, id, id]);
|
||||||
var selects = $(selectsSelector);
|
const selects = $(selectsSelector);
|
||||||
selects.find('option').each(function() {
|
selects.find('option').each(function() {
|
||||||
if (this.value === objId) {
|
if (this.value === objId) {
|
||||||
this.textContent = newRepr;
|
this.textContent = newRepr;
|
||||||
|
@ -118,9 +101,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function dismissDeleteRelatedObjectPopup(win, objId) {
|
function dismissDeleteRelatedObjectPopup(win, objId) {
|
||||||
var id = windowname_to_id(win.name).replace(/^delete_/, '');
|
const id = win.name.replace(/^delete_/, '');
|
||||||
var selectsSelector = interpolate('#%s, #%s_from, #%s_to', [id, id, id]);
|
const selectsSelector = interpolate('#%s, #%s_from, #%s_to', [id, id, id]);
|
||||||
var selects = $(selectsSelector);
|
const selects = $(selectsSelector);
|
||||||
selects.find('option').each(function() {
|
selects.find('option').each(function() {
|
||||||
if (this.value === objId) {
|
if (this.value === objId) {
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
|
@ -129,10 +112,6 @@
|
||||||
win.close();
|
win.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Global for testing purposes
|
|
||||||
window.id_to_windowname = id_to_windowname;
|
|
||||||
window.windowname_to_id = windowname_to_id;
|
|
||||||
|
|
||||||
window.showRelatedObjectLookupPopup = showRelatedObjectLookupPopup;
|
window.showRelatedObjectLookupPopup = showRelatedObjectLookupPopup;
|
||||||
window.dismissRelatedLookupPopup = dismissRelatedLookupPopup;
|
window.dismissRelatedLookupPopup = dismissRelatedLookupPopup;
|
||||||
window.showRelatedObjectPopup = showRelatedObjectPopup;
|
window.showRelatedObjectPopup = showRelatedObjectPopup;
|
||||||
|
@ -153,7 +132,7 @@
|
||||||
$('body').on('click', '.related-widget-wrapper-link', function(e) {
|
$('body').on('click', '.related-widget-wrapper-link', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (this.href) {
|
if (this.href) {
|
||||||
var event = $.Event('django:show-related', {href: this.href});
|
const event = $.Event('django:show-related', {href: this.href});
|
||||||
$(this).trigger(event);
|
$(this).trigger(event);
|
||||||
if (!event.isDefaultPrevented()) {
|
if (!event.isDefaultPrevented()) {
|
||||||
showRelatedObjectPopup(this);
|
showRelatedObjectPopup(this);
|
||||||
|
@ -161,7 +140,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('body').on('change', '.related-widget-wrapper select', function(e) {
|
$('body').on('change', '.related-widget-wrapper select', function(e) {
|
||||||
var event = $.Event('django:update-related');
|
const event = $.Event('django:update-related');
|
||||||
$(this).trigger(event);
|
$(this).trigger(event);
|
||||||
if (!event.isDefaultPrevented()) {
|
if (!event.isDefaultPrevented()) {
|
||||||
updateRelatedObjectLinks(this);
|
updateRelatedObjectLinks(this);
|
||||||
|
@ -170,12 +149,11 @@
|
||||||
$('.related-widget-wrapper select').trigger('change');
|
$('.related-widget-wrapper select').trigger('change');
|
||||||
$('body').on('click', '.related-lookup', function(e) {
|
$('body').on('click', '.related-lookup', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var event = $.Event('django:lookup-related');
|
const event = $.Event('django:lookup-related');
|
||||||
$(this).trigger(event);
|
$(this).trigger(event);
|
||||||
if (!event.isDefaultPrevented()) {
|
if (!event.isDefaultPrevented()) {
|
||||||
showRelatedObjectLookupPopup(this);
|
showRelatedObjectLookupPopup(this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
})(django.jQuery);
|
|
||||||
|
|
Binary file not shown.
|
@ -1,7 +1,8 @@
|
||||||
(function($) {
|
'use strict';
|
||||||
'use strict';
|
{
|
||||||
var init = function($element, options) {
|
const $ = django.jQuery;
|
||||||
var settings = $.extend({
|
const init = function($element, options) {
|
||||||
|
const settings = $.extend({
|
||||||
ajax: {
|
ajax: {
|
||||||
data: function(params) {
|
data: function(params) {
|
||||||
return {
|
return {
|
||||||
|
@ -15,9 +16,9 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
$.fn.djangoAdminSelect2 = function(options) {
|
$.fn.djangoAdminSelect2 = function(options) {
|
||||||
var settings = $.extend({}, options);
|
const settings = $.extend({}, options);
|
||||||
$.each(this, function(i, element) {
|
$.each(this, function(i, element) {
|
||||||
var $element = $(element);
|
const $element = $(element);
|
||||||
init($element, settings);
|
init($element, settings);
|
||||||
});
|
});
|
||||||
return this;
|
return this;
|
||||||
|
@ -34,4 +35,4 @@
|
||||||
return $newFormset.find('.admin-autocomplete').djangoAdminSelect2();
|
return $newFormset.find('.admin-autocomplete').djangoAdminSelect2();
|
||||||
};
|
};
|
||||||
})(this));
|
})(this));
|
||||||
}(django.jQuery));
|
}
|
Binary file not shown.
Binary file not shown.
|
@ -1,7 +1,8 @@
|
||||||
(function($) {
|
'use strict';
|
||||||
'use strict';
|
{
|
||||||
var init = function($element, options) {
|
const $ = django.jQuery;
|
||||||
var settings = $.extend({
|
const init = function($element, options) {
|
||||||
|
const settings = $.extend({
|
||||||
ajax: {
|
ajax: {
|
||||||
data: function(params) {
|
data: function(params) {
|
||||||
return {
|
return {
|
||||||
|
@ -15,9 +16,9 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
$.fn.djangoAdminSelect2 = function(options) {
|
$.fn.djangoAdminSelect2 = function(options) {
|
||||||
var settings = $.extend({}, options);
|
const settings = $.extend({}, options);
|
||||||
$.each(this, function(i, element) {
|
$.each(this, function(i, element) {
|
||||||
var $element = $(element);
|
const $element = $(element);
|
||||||
init($element, settings);
|
init($element, settings);
|
||||||
});
|
});
|
||||||
return this;
|
return this;
|
||||||
|
@ -34,4 +35,4 @@
|
||||||
return $newFormset.find('.admin-autocomplete').djangoAdminSelect2();
|
return $newFormset.find('.admin-autocomplete').djangoAdminSelect2();
|
||||||
};
|
};
|
||||||
})(this));
|
})(this));
|
||||||
}(django.jQuery));
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -3,11 +3,10 @@
|
||||||
calendar.js - Calendar functions by Adrian Holovaty
|
calendar.js - Calendar functions by Adrian Holovaty
|
||||||
depends on core.js for utility functions like removeChildren or quickElement
|
depends on core.js for utility functions like removeChildren or quickElement
|
||||||
*/
|
*/
|
||||||
|
'use strict';
|
||||||
(function() {
|
{
|
||||||
'use strict';
|
|
||||||
// CalendarNamespace -- Provides a collection of HTML calendar-related helper functions
|
// CalendarNamespace -- Provides a collection of HTML calendar-related helper functions
|
||||||
var CalendarNamespace = {
|
const CalendarNamespace = {
|
||||||
monthsOfYear: [
|
monthsOfYear: [
|
||||||
gettext('January'),
|
gettext('January'),
|
||||||
gettext('February'),
|
gettext('February'),
|
||||||
|
@ -36,7 +35,7 @@ depends on core.js for utility functions like removeChildren or quickElement
|
||||||
return (((year % 4) === 0) && ((year % 100) !== 0 ) || ((year % 400) === 0));
|
return (((year % 4) === 0) && ((year % 100) !== 0 ) || ((year % 400) === 0));
|
||||||
},
|
},
|
||||||
getDaysInMonth: function(month, year) {
|
getDaysInMonth: function(month, year) {
|
||||||
var days;
|
let days;
|
||||||
if (month === 1 || month === 3 || month === 5 || month === 7 || month === 8 || month === 10 || month === 12) {
|
if (month === 1 || month === 3 || month === 5 || month === 7 || month === 8 || month === 10 || month === 12) {
|
||||||
days = 31;
|
days = 31;
|
||||||
}
|
}
|
||||||
|
@ -52,11 +51,11 @@ depends on core.js for utility functions like removeChildren or quickElement
|
||||||
return days;
|
return days;
|
||||||
},
|
},
|
||||||
draw: function(month, year, div_id, callback, selected) { // month = 1-12, year = 1-9999
|
draw: function(month, year, div_id, callback, selected) { // month = 1-12, year = 1-9999
|
||||||
var today = new Date();
|
const today = new Date();
|
||||||
var todayDay = today.getDate();
|
const todayDay = today.getDate();
|
||||||
var todayMonth = today.getMonth() + 1;
|
const todayMonth = today.getMonth() + 1;
|
||||||
var todayYear = today.getFullYear();
|
const todayYear = today.getFullYear();
|
||||||
var todayClass = '';
|
let todayClass = '';
|
||||||
|
|
||||||
// Use UTC functions here because the date field does not contain time
|
// Use UTC functions here because the date field does not contain time
|
||||||
// and using the UTC function variants prevent the local time offset
|
// and using the UTC function variants prevent the local time offset
|
||||||
|
@ -69,33 +68,33 @@ depends on core.js for utility functions like removeChildren or quickElement
|
||||||
//
|
//
|
||||||
// The day variable above will be 1 instead of 2 in, say, US Pacific time
|
// The day variable above will be 1 instead of 2 in, say, US Pacific time
|
||||||
// zone.
|
// zone.
|
||||||
var isSelectedMonth = false;
|
let isSelectedMonth = false;
|
||||||
if (typeof selected !== 'undefined') {
|
if (typeof selected !== 'undefined') {
|
||||||
isSelectedMonth = (selected.getUTCFullYear() === year && (selected.getUTCMonth() + 1) === month);
|
isSelectedMonth = (selected.getUTCFullYear() === year && (selected.getUTCMonth() + 1) === month);
|
||||||
}
|
}
|
||||||
|
|
||||||
month = parseInt(month);
|
month = parseInt(month);
|
||||||
year = parseInt(year);
|
year = parseInt(year);
|
||||||
var calDiv = document.getElementById(div_id);
|
const calDiv = document.getElementById(div_id);
|
||||||
removeChildren(calDiv);
|
removeChildren(calDiv);
|
||||||
var calTable = document.createElement('table');
|
const calTable = document.createElement('table');
|
||||||
quickElement('caption', calTable, CalendarNamespace.monthsOfYear[month - 1] + ' ' + year);
|
quickElement('caption', calTable, CalendarNamespace.monthsOfYear[month - 1] + ' ' + year);
|
||||||
var tableBody = quickElement('tbody', calTable);
|
const tableBody = quickElement('tbody', calTable);
|
||||||
|
|
||||||
// Draw days-of-week header
|
// Draw days-of-week header
|
||||||
var tableRow = quickElement('tr', tableBody);
|
let tableRow = quickElement('tr', tableBody);
|
||||||
for (var i = 0; i < 7; i++) {
|
for (let i = 0; i < 7; i++) {
|
||||||
quickElement('th', tableRow, CalendarNamespace.daysOfWeek[(i + CalendarNamespace.firstDayOfWeek) % 7]);
|
quickElement('th', tableRow, CalendarNamespace.daysOfWeek[(i + CalendarNamespace.firstDayOfWeek) % 7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var startingPos = new Date(year, month - 1, 1 - CalendarNamespace.firstDayOfWeek).getDay();
|
const startingPos = new Date(year, month - 1, 1 - CalendarNamespace.firstDayOfWeek).getDay();
|
||||||
var days = CalendarNamespace.getDaysInMonth(month, year);
|
const days = CalendarNamespace.getDaysInMonth(month, year);
|
||||||
|
|
||||||
var nonDayCell;
|
let nonDayCell;
|
||||||
|
|
||||||
// Draw blanks before first of month
|
// Draw blanks before first of month
|
||||||
tableRow = quickElement('tr', tableBody);
|
tableRow = quickElement('tr', tableBody);
|
||||||
for (i = 0; i < startingPos; i++) {
|
for (let i = 0; i < startingPos; i++) {
|
||||||
nonDayCell = quickElement('td', tableRow, ' ');
|
nonDayCell = quickElement('td', tableRow, ' ');
|
||||||
nonDayCell.className = "nonday";
|
nonDayCell.className = "nonday";
|
||||||
}
|
}
|
||||||
|
@ -109,8 +108,8 @@ depends on core.js for utility functions like removeChildren or quickElement
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw days of month
|
// Draw days of month
|
||||||
var currentDay = 1;
|
let currentDay = 1;
|
||||||
for (i = startingPos; currentDay <= days; i++) {
|
for (let i = startingPos; currentDay <= days; i++) {
|
||||||
if (i % 7 === 0 && currentDay !== 1) {
|
if (i % 7 === 0 && currentDay !== 1) {
|
||||||
tableRow = quickElement('tr', tableBody);
|
tableRow = quickElement('tr', tableBody);
|
||||||
}
|
}
|
||||||
|
@ -128,8 +127,8 @@ depends on core.js for utility functions like removeChildren or quickElement
|
||||||
todayClass += "selected";
|
todayClass += "selected";
|
||||||
}
|
}
|
||||||
|
|
||||||
var cell = quickElement('td', tableRow, '', 'class', todayClass);
|
const cell = quickElement('td', tableRow, '', 'class', todayClass);
|
||||||
var link = quickElement('a', cell, currentDay, 'href', '#');
|
const link = quickElement('a', cell, currentDay, 'href', '#');
|
||||||
link.addEventListener('click', calendarMonth(year, month));
|
link.addEventListener('click', calendarMonth(year, month));
|
||||||
currentDay++;
|
currentDay++;
|
||||||
}
|
}
|
||||||
|
@ -205,4 +204,4 @@ depends on core.js for utility functions like removeChildren or quickElement
|
||||||
};
|
};
|
||||||
window.Calendar = Calendar;
|
window.Calendar = Calendar;
|
||||||
window.CalendarNamespace = CalendarNamespace;
|
window.CalendarNamespace = CalendarNamespace;
|
||||||
})();
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue