Page MenuHomePhabricator

No OneTemporary

diff --git a/js/ui/tag/editor.js b/js/ui/tag/editor.js
index e508b22..d199def 100644
--- a/js/ui/tag/editor.js
+++ b/js/ui/tag/editor.js
@@ -1,120 +1,122 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
depend('_scss/ui/tag/editor', ['m3/core/collection'], function (collect) {
var RichEditor = function (tags, onchange) {
var ctx = this;
this.outer = document.createElement('div');
this.input = document.createElement('input');
this.rendered = document.createElement('span');
this.tags = tags;
this.onchange = onchange;
this.outer.appendChild(this.rendered);
this.outer.appendChild(this.input);
this.redraw();
this.outer.className = 'tag-editor tag-editor-outer';
this.input.className = 'tag-editor tag-editor-input';
this.rendered.className = 'tag-editor tag-editor-rendered';
this.input.addEventListener('keydown', function (e) {
/*
* When the key pressed is a comma, the tag is committed to the list
* of tags.
*/
if (ctx.input.value.trim().length !== 0 && (e.key === ',' || e.key === 'Enter' || e.key === 'Tab')) {
ctx.tags.push(new Tag(this.value));
ctx.redraw();
this.value = '';
e.preventDefault();
ctx.onchange();
}
/*
* When the user presses the backspace key and nothing is in the current
* tag, we delete the previous tag.
*/
if (e.keyCode === 8 && ctx.input.value.length === 0) {
ctx.tags.pop();
ctx.redraw();
ctx.onchange();
}
});
this.outer.addEventListener('click', function () {
ctx.input.focus();
});
};
RichEditor.prototype = {
getOuter : function () { return this.outer; },
redraw : function () {
var ctx = this;
this.rendered.innerHTML = '';
this.tags.each(function (e) {
var span = document.createElement('span');
var del = document.createElement('span');
span.appendChild(document.createTextNode(e.content));
span.className = 'tag-editor tag-editor-tag';
span.addEventListener('click', function () { ctx.input.value.trim() && ctx.tags.push(new Tag(ctx.input.value)); ctx.remove(e); ctx.input.value = e.content; })
ctx.rendered.appendChild(span);
span.appendChild(del);
del.className = 'tag-editor tag-editor-delete';
del.addEventListener('click', function (ev) { ctx.remove(e); ev.stopPropagation(); });
});
},
remove: function (element) {
this.tags = this.tags.filter(function (e) { return element !== e; });
this.redraw();
this.onchange();
},
getTags : function () { return this.tags; },
};
var Tag = function (content) {
this.content = content;
/*
* Maps the tag to a specific span, so when the user clicks the span, we
* can programtically remove it.
*/
this.html = undefined;
};
Tag.prototype = {
};
var TagEditor = function (element, listener) {
var ctx = this;
this.element = element;
this.listener = listener;
this.tags = collect(element.innerHTML.split(',')).filter(function (e) { return e !== ''}).each(function (e) { return new Tag(e.trim()); });
this.replace = new RichEditor(this.tags, function () { ctx.commit(); });
this.element.style.display = 'none';
this.element.parentNode.insertBefore(this.replace.getOuter(), this.element)
+
+ this.replace.input.placeholder = element.placeholder;
};
TagEditor.prototype = {
sync : function () { this.tags = this.replace.getTags(); },
commit : function () { this.sync(); this.element.innerHTML = this.tags.each(function (e) { return e.content; }).raw().join(','); this.listener(this.tags); }
};
return TagEditor;
});
diff --git a/ui/form/_controls.scss b/ui/form/_controls.scss
index fa99130..5779ab0 100644
--- a/ui/form/_controls.scss
+++ b/ui/form/_controls.scss
@@ -1,353 +1,348 @@
/*
The MIT License
Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/*
Created on : Jun 17, 2019, 11:59:07 AM
Author : César de la Cal Bretschneider <cesar@magic3w.com>
*/
/*
* A form control is anything the user can interact with when filling out a form,
* this includes inputs, textareas and selects.
*/
.frm-ctrl {
display: block;
width: 100%;
&.ctrl-borderless {
border: solid 1px $controlBorderlessBg;
background-color: $controlBorderlessBg;
&:active,
&:focus {
border: solid 1px $controlBorderlessBg;
box-shadow: none;
}
}
&.ctrl-android {
border-top: none;
border-left: none;
border-right: none;
border-bottom: solid .2rem #BBB;
border-radius: 0;
background-color: $controlBorderlessBg;
&:active,
&:focus {
box-shadow: none;
border-bottom: solid .2rem #1470b3;
}
}
}
.frm-lbl {
padding: .75rem .4rem;
color: #444;
font-size: .9rem;
}
input:not([type]).frm-ctrl,
input[type="text"].frm-ctrl,
input[type="url"].frm-ctrl,
input[type="tel"].frm-ctrl,
input[type="search"].frm-ctrl,
input[type="number"].frm-ctrl,
input[type="password"].frm-ctrl,
input[type="email"].frm-ctrl,
textarea.frm-ctrl {
border: solid 1px #CCC;
height: $controlHeight;
padding:
map-get($controlPadding, "y")
map-get($controlPadding, "x");
&.ctrl-borderless {
border: solid 1px $controlBorderlessBg;
background-color: $controlBorderlessBg;
&:active,
&:focus {
border: solid 1px $controlBorderlessBg;
box-shadow: none;
}
}
&.ctrl-android {
border-top: none;
border-left: none;
border-right: none;
border-bottom: solid .2rem #BBB;
border-radius: 0;
background-color: $controlBorderlessBg;
&:active,
&:focus {
box-shadow: none;
border-bottom: solid .2rem #1470b3;
}
}
}
/*
* Checkbox specific styling
*/
input[type="checkbox"].frm-ctrl {
display: none;
}
span.frm-ctrl-chk {
display: inline-block;
- width: 1.3rem;
- height: 1.3rem;
+ width: 1.2rem;
+ height: 1.2rem;
border-radius: .25rem;
border: solid 1px #CCC;
background-color: #DDD;
position: relative;
margin-right: .2rem;
- vertical-align: -.4rem;
+ vertical-align: -.2rem;
transition: background-color .3s ease;
&:before {
content: '';
position: absolute;
top: 0;
left: 0;
- height: 1.3rem;
- width: 1.3rem;
+ height: 1.2rem;
+ width: 1.2rem;
background-image: url('data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%228%22%20height%3D%228%22%20viewBox%3D%220%200%208%208%22%3E%3Cpath%20fill%3D%22%23FFF%22%20d%3D%22M6.41%200l-.69.72-2.78%202.78-.81-.78-.72-.72-1.41%201.41.72.72%201.5%201.5.69.72.72-.72%203.5-3.5.72-.72-1.44-1.41z%22%2F%3E%3C%2Fsvg%3E%0A');
background-position: center center;
background-repeat: no-repeat;
background-size: 0 0;
border-radius: 50%;
transition: background-size .15s ease;
}
}
span.frm-ctrl-chk.toggle {
display: inline-block;
width: 2rem;
height: 1.3rem;
border-radius: .65rem;
background-color: #CCC;
position: relative;
margin-right: .2rem;
vertical-align: -.4rem;
transition: background-color .3s ease;
border: none;
&:before {
content: '';
position: absolute;
top: .15rem;
left: .15rem;
height: 1rem;
width: 1rem;
background-color: #FFF;
border-radius: 50%;
transition: left .3s ease;
}
}
input[type="checkbox"].frm-ctrl:checked + span.frm-ctrl-chk{
background-color: #56a1d6;
border: solid 1px #56a1d6;
&:before {
- background-size: .8rem .8rem;
+ background-size: .7rem .7rem;
}
&.toggle {
border: none;
&:before {
left: .9rem;
}
}
}
/*
* Radio specific styling
*/
input[type="radio"].frm-ctrl {
display: none;
}
span.frm-ctrl-rad {
display: inline-block;
- border: solid .05rem #777;
+ border: solid .05rem $grey600;
width: 1.3rem;
height: 1.3rem;
border-radius: .65rem;
- background-color: #DDD;
+ background-color: $white;
position: relative;
margin-right: .2rem;
vertical-align: -.4rem;
transition: background-color .3s ease;
&:before {
- position: absolute;
- background: #FFF;
- top: .65rem;
- left: .65rem;
- height: .0rem;
- width: .0rem;
content: '';
+ position: absolute;
+ top: 0;
+ left: 0;
+ height: 1.3rem;
+ width: 1.3rem;
+ background-image: url('data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%228%22%20height%3D%228%22%20viewBox%3D%220%200%208%208%22%3E%3Cpath%20fill%3D%22%23FFF%22%20d%3D%22M6.41%200l-.69.72-2.78%202.78-.81-.78-.72-.72-1.41%201.41.72.72%201.5%201.5.69.72.72-.72%203.5-3.5.72-.72-1.44-1.41z%22%2F%3E%3C%2Fsvg%3E%0A');
+ background-position: center center;
+ background-repeat: no-repeat;
+ background-size: 0 0;
border-radius: 50%;
- transition: left .3s ease, top .3s ease, width .3s ease, height .3s ease, opacity .3s ease;
+ transition: background-size .15s ease, border-color .30s ease;
}
}
input[type="radio"].frm-ctrl:checked + span.frm-ctrl-rad{
- background-color: #56a1d6;
+ border: solid .05rem $purple300;
+ background-color: $purple300;
&:before {
- top: .3rem;
- left: .3rem;
- height: .6rem;
- width: .6rem;
- background-color: #FFF;
- color: #FFF;
- line-height: .9rem;
- font-size: .9rem;
- text-align: center;
- font-weight: bold;
+ background-size: .8rem .8rem;
}
}
/*
* The outer wrappers for form controls allow the system to style form controls
* in a very interactive way that makes the label behave like a placeholder and
* but does not lose the context of the input.
*/
.frm-ctrl-outer {
position: relative;
display: inline-block;
width: 100%;
height: $controlHeight;
}
/*
* When the outer control wraps around an input, select, textarea, or label, the
* application should reset their styles to a state that we can manage.
*/
.frm-ctrl-outer label,
.frm-ctrl-outer input[type="text"].frm-ctrl,
.frm-ctrl-outer input[type="password"].frm-ctrl,
.frm-ctrl-outer textarea.frm-ctrl,
.frm-ctrl-outer select.frm-ctrl {
display: inline-block;
height: ($controlHeight + map-get($controlPadding, "x") * .5);
font-size: $controlFontSize;
line-height: $controlFontSize * 1.4;
/*
* The padding of these inputs needs to be carefully managed, unlike the regular HTML elements
* where the text should be centered, these offset the text slightly in order to make it fit
* together with the label in the input.
*/
padding:
map-get($controlPadding, "y")*1.5
map-get($controlPadding, "x")
map-get($controlPadding, "y");
// Some browsers would like to render an outline around our form, this is not what we want
// either
outline: none;
// The appearance needs to be appropriately set for the browsers to not render UI components
// within our inputs.
-moz-appearance: none;
appearance: none;
}
.frm-ctrl-outer input[type="text"].frm-ctrl,
.frm-ctrl-outer input[type="password"].frm-ctrl,
.frm-ctrl-outer select,
.frm-ctrl-outer textarea {
min-width: 10rem;
border-radius: .3rem;
transition: .2s ease all;
&.ctrl-android {
border-radius: 0;
}
}
.frm-ctrl-outer label {
transform-origin: top left;
position: absolute;
top: 0;
left: 0;
transition: .2s ease all;
color: #444;
background-color: transparent;
cursor: text;
user-select: none;
padding: map-get($controlPadding, "y") 0rem 0rem 0rem;
left: map-get($controlPadding, "x");
}
.frm-ctrl-outer input[type="text"].frm-ctrl:placeholder-shown + label,
.frm-ctrl-outer input[type="password"].frm-ctrl:placeholder-shown + label {
transform: scale(1);
top: .3rem;
}
.frm-ctrl-outer input[type="text"].frm-ctrl + label,
.frm-ctrl-outer input[type="password"].frm-ctrl + label,
.frm-ctrl-outer select + label,
.frm-ctrl-outer input[type="text"].frm-ctrl:focus + label,
.frm-ctrl-outer input[type="password"].frm-ctrl:focus + label {
transform: scale(.6);
color: #444;
height: 2rem;
top: 0;
}
.frm-ctrl-outer input[type="text"].frm-ctrl:focus + label,
.frm-ctrl-outer input[type="password"].frm-ctrl:focus + label {
color: #1c89d6;
}
.frm-ctrl-outer input[type="text"].frm-ctrl.ctrl-borderless:focus + label,
.frm-ctrl-outer input[type="password"].frm-ctrl.ctrl-borderless:focus + label {
color: #222;
}
.frm-ctrl-outer input[type="text"].frm-ctrl.ctrl-android:focus + label,
.frm-ctrl-outer input[type="password"].frm-ctrl.ctrl-android:focus + label {
color: #222;
}
\ No newline at end of file
diff --git a/ui/form/_reset.scss b/ui/form/_reset.scss
index e727e16..c04b4a5 100644
--- a/ui/form/_reset.scss
+++ b/ui/form/_reset.scss
@@ -1,92 +1,98 @@
/*
The MIT License
Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/*
Created on : Jun 17, 2019, 11:56:04 AM
Author : César de la Cal Bretschneider <cesar@magic3w.com>
*/
label {
display: inline-block;
}
input, textarea {
line-height: inherit;
margin: 0;
}
textarea {
resize: vertical;
}
input[type="text"],
input[type="url"],
input[type="tel"],
input[type="search"],
input[type="number"],
input[type="password"],
input[type="email"],
textarea {
border-radius: 3px;
border: solid 1px #CCC;
box-shadow: 0 0 0 transparent;
transition: box-shadow .15s ease;
+ line-height: 1.3rem;
+ padding: .55rem .4rem;
+ height: calc(2.4rem + 2px);
&:focus {
border-color: #279af1;
box-shadow: 0px 0px 2px #279af1;
outline: none;
}
}
select {
border-radius: 3px;
border: solid 1px #CCC;
box-shadow: 0 0 0 transparent;
transition: box-shadow .15s ease;
background: #FFF;
+ line-height: 1.3rem;
+ padding: .55rem .4rem;
+ height: calc(2.4rem + 2px);
&:focus {
border-color: #279af1;
box-shadow: 0px 0px 2px #279af1;
outline: none;
}
}
fieldset {
border: none;
padding: 0;
margin: 0;
}
legend {
font-size: 1.3rem;
margin-bottom: .3rem;
}
input[type="submit"]:not([disabled]),
button:not([disabled])
{
cursor: pointer;
}
\ No newline at end of file
diff --git a/ui/form/_select.scss b/ui/form/_select.scss
index 4d473aa..9a649e6 100644
--- a/ui/form/_select.scss
+++ b/ui/form/_select.scss
@@ -1,39 +1,38 @@
/*
The MIT License
Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/*
Created on : Aug 22, 2019, 4:19:27 PM
Author : César de la Cal Bretschneider <cesar@magic3w.com>
*/
select.frm-ctrl {
- padding: .75rem .4rem;
background-repeat: no-repeat;
background-position: center right 1.1rem;
background-size: .8rem .8rem;
padding-right: 2.4rem;
-moz-appearance: none;
-webkit-appearance: none;
appearance: none;
background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007CB2%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');
}
\ No newline at end of file

File Metadata

Mime Type
text/x-diff
Expires
Apr 13 2021, 2:15 PM (9 w, 6 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5337
Default Alt Text
(18 KB)

Event Timeline