Skip to content

Commit

Permalink
chore(cs): run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
SamMousa committed Aug 14, 2024
1 parent d98f1d2 commit 3cd4094
Show file tree
Hide file tree
Showing 13 changed files with 1,436 additions and 1,537 deletions.
364 changes: 189 additions & 175 deletions demo/style.css

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/css/themes/modern.less
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}

//&.min:not(:hover),
&:not(.min,.focus) {
&:not(.min, .focus) {
background: #666;
}

Expand Down Expand Up @@ -44,7 +44,6 @@
}

.wb-body {

& {
/* width of window border: */
margin: 4px;
Expand Down
2 changes: 1 addition & 1 deletion src/css/themes/white.less
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
.wb-control {
filter: invert(1);
}
}
}
14 changes: 10 additions & 4 deletions src/css/winbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
left: 0;
top: 0;
background: #0050ff;
box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
box-shadow:
0 14px 28px rgba(0, 0, 0, 0.25),
0 10px 10px rgba(0, 0, 0, 0.22);
/* using transform make contents blur when applied and requires more gpu memory */
transition: width 0.3s, height 0.3s, left 0.3s, top 0.3s;
transition:
width 0.3s,
height 0.3s,
left 0.3s,
top 0.3s;
transition-timing-function: cubic-bezier(0.3, 1, 0.3, 1);
/* contain "strict" does not make overflow contents selectable */
contain: layout size;
Expand Down Expand Up @@ -236,7 +242,7 @@ body.wb-lock iframe {
pointer-events: none;
}
.winbox.modal:before {
content: '';
content: "";
position: absolute;
top: 0;
left: 0;
Expand All @@ -246,7 +252,7 @@ body.wb-lock iframe {
border-radius: inherit;
}
.winbox.modal:after {
content: '';
content: "";
position: absolute;
top: -50vh;
left: -50vw;
Expand Down
42 changes: 24 additions & 18 deletions src/css/winbox.less
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
left: 0;
top: 0;
background: #0050ff;
box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
box-shadow:
0 14px 28px rgba(0, 0, 0, 0.25),
0 10px 10px rgba(0, 0, 0, 0.22);
/* using transform make contents blur when applied and requires more gpu memory */
//transition: width .3s, height .3s, transform .3s;
transition: width .3s, height .3s, left .3s, top .3s;
transition:
width 0.3s,
height 0.3s,
left 0.3s,
top 0.3s;
transition-timing-function: cubic-bezier(0.3, 1, 0.3, 1);
//transform-origin: bottom center;
/* contain "strict" does not make overflow contents selectable */
Expand Down Expand Up @@ -60,14 +66,14 @@ body > .wb-body{
}
*/

.wb-drag{
.wb-drag {
height: 100%;
padding-left: 10px;
cursor: move;
}

.wb-title{
font-family : Arial, sans-serif;
.wb-title {
font-family: Arial, sans-serif;
font-size: 14px;
white-space: nowrap;
overflow: hidden;
Expand Down Expand Up @@ -165,7 +171,7 @@ body > .wb-body{
z-index: 2;
}

.wb-control{
.wb-control {
float: right;
height: 100%;
max-width: 100%;
Expand Down Expand Up @@ -229,7 +235,7 @@ body > .wb-body{
.winbox.max .wb-body ~ div {
pointer-events: none;
}
.winbox.max .wb-drag{
.winbox.max .wb-drag {
cursor: default;
}

Expand All @@ -241,7 +247,7 @@ body > .wb-body{
.wb-drag {
cursor: default;
}
.wb-body > *{
.wb-body > * {
display: none;
}
}
Expand All @@ -259,24 +265,24 @@ body > .wb-body{
margin: 0 !important;
}

.winbox iframe{
.winbox iframe {
position: absolute;
width: 100%;
height: 100%;
border: 0;
}

body.wb-lock .winbox{
body.wb-lock .winbox {
will-change: left, top, width, height;
transition: none;
}
body.wb-lock iframe {
pointer-events: none;
}

.winbox.modal{
&:before{
content: '';
.winbox.modal {
&:before {
content: "";
position: absolute;
top: 0;
left: 0;
Expand All @@ -285,8 +291,8 @@ body.wb-lock iframe {
background: inherit;
border-radius: inherit;
}
&:after{
content: '';
&:after {
content: "";
position: absolute;
top: -50vh;
left: -50vw;
Expand All @@ -298,16 +304,16 @@ body.wb-lock iframe {
}
.wb-min,
.wb-max,
.wb-full{
.wb-full {
display: none;
}
}

@keyframes wb-fade-in {
0%{
0% {
opacity: 0;
}
100%{
100% {
opacity: 0.85;
}
}
Expand Down
88 changes: 37 additions & 51 deletions src/js/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
* @param {AddEventListenerOptions|boolean=} opt
*/

export function addListener(node, event, fn, opt){

node && node.addEventListener(event, fn, opt || false);
export function addListener(node, event, fn, opt) {
node && node.addEventListener(event, fn, opt || false);
}

/**
Expand All @@ -17,78 +16,65 @@ export function addListener(node, event, fn, opt){
* @param {AddEventListenerOptions|boolean=} opt
*/

export function removeListener(node, event, fn, opt){

node && node.removeEventListener(event, fn, opt || false);
export function removeListener(node, event, fn, opt) {
node && node.removeEventListener(event, fn, opt || false);
}

/**
* @param event
* @param {boolean=} prevent
*/

export function preventEvent(event, prevent){
export function preventEvent(event, prevent) {
event.stopPropagation();
prevent && /*event.cancelable &&*/ event.preventDefault();

event.stopPropagation();
prevent && /*event.cancelable &&*/ event.preventDefault();

//event.stopImmediatePropagation();
//event.returnValue = false;
//event.stopImmediatePropagation();
//event.returnValue = false;
}

export function getByClass(root, name){

return root.getElementsByClassName(name)[0];
export function getByClass(root, name) {
return root.getElementsByClassName(name)[0];
}

export function addClass(node, classname){

node.classList.add(classname);
export function addClass(node, classname) {
node.classList.add(classname);
}

export function hasClass(node, classname){

return node.classList.contains(classname);
export function hasClass(node, classname) {
return node.classList.contains(classname);
}

export function removeClass(node, classname){

node.classList.remove(classname);
export function removeClass(node, classname) {
node.classList.remove(classname);
}

export function setStyle(node, style, value){
export function setStyle(node, style, value) {
value = "" + value;

value = "" + value;

if(node["_s_" + style] !== value){

node.style.setProperty(style, value);
node["_s_" + style] = value;
}
if (node["_s_" + style] !== value) {
node.style.setProperty(style, value);
node["_s_" + style] = value;
}
}

export function setAttribute(node, key, value){

value = "" + value;

if(node["_a_" + key] !== value){
export function setAttribute(node, key, value) {
value = "" + value;

node.setAttribute(key, value);
node["_a_" + key] = value;
}
if (node["_a_" + key] !== value) {
node.setAttribute(key, value);
node["_a_" + key] = value;
}
}

export function removeAttribute(node, key){

if(node["_a_" + key] !== null){

node.removeAttribute(key);
node["_a_" + key] = null;
}
export function removeAttribute(node, key) {
if (node["_a_" + key] !== null) {
node.removeAttribute(key);
node["_a_" + key] = null;
}
}

export function setText(node, value){

const textnode = node.firstChild;
textnode ? textnode.nodeValue = value : node.textContent = value;
export function setText(node, value) {
const textnode = node.firstChild;
textnode ? (textnode.nodeValue = value) : (node.textContent = value);
}
64 changes: 30 additions & 34 deletions src/js/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,38 @@
@type null|HTMLDivElement
*/
let template = null;
const templateHTML = (
const templateHTML =
//'<div class=winbox>' +

//'<div class=winbox>' +
"<div class=wb-header>" +
"<div class=wb-control>" +
"<span class=wb-min></span>" +
"<span class=wb-max></span>" +
"<span class=wb-full></span>" +
"<span class=wb-close></span>" +
"</div>" +
"<div class=wb-drag>" +
"<div class=wb-icon></div>" +
"<div class=wb-title></div>" +
"</div>" +
"</div>" +
"<div class=wb-body></div>" +
"<div class=wb-n></div>" +
"<div class=wb-s></div>" +
"<div class=wb-w></div>" +
"<div class=wb-e></div>" +
"<div class=wb-nw></div>" +
"<div class=wb-ne></div>" +
"<div class=wb-se></div>" +
"<div class=wb-sw></div>";

'<div class=wb-header>' +
'<div class=wb-control>' +
'<span class=wb-min></span>' +
'<span class=wb-max></span>' +
'<span class=wb-full></span>' +
'<span class=wb-close></span>' +
'</div>' +
'<div class=wb-drag>'+
'<div class=wb-icon></div>' +
'<div class=wb-title></div>' +
'</div>' +
'</div>' +
//'</div>'

'<div class=wb-body></div>' +
export default function (tpl) {
if (!template) {
template = document.createElement("div");
template.innerHTML = templateHTML;
}

'<div class=wb-n></div>' +
'<div class=wb-s></div>' +
'<div class=wb-w></div>' +
'<div class=wb-e></div>' +
'<div class=wb-nw></div>' +
'<div class=wb-ne></div>' +
'<div class=wb-se></div>' +
'<div class=wb-sw></div>'

//'</div>'
);

export default function(tpl){
if (!template) {
template = document.createElement('div');
template.innerHTML = templateHTML;
}

return (tpl || template).cloneNode(true);
return (tpl || template).cloneNode(true);
}
Loading

0 comments on commit 3cd4094

Please sign in to comment.