commit 24feab31d5616b133f4455894a3b0380290ddd4c
parent 35918ca50622c1f3a44cca67cb0cf293cd0c344a
Author: dankert <openrat@jandankert.de>
Date: Tue, 1 Mar 2022 23:03:32 +0100
New: OQuery support for 'parent(selector)' and 'parents(selector)'
Diffstat:
7 files changed, 96 insertions(+), 14 deletions(-)
diff --git a/modules/cms/ui/themes/default/script/Oquery.js b/modules/cms/ui/themes/default/script/Oquery.js
@@ -80,10 +80,44 @@ export class OQuery {
}
- parent() {
- return this.createNew( this.nodes.map(node => node.parentNode ).filter( node => node !== null ) );
+ /**
+ * Reads the direct parent of all nodes, optionally filtered by a selector.
+ * @param selector
+ * @return {OQuery}
+ */
+ parent( selector = null ) {
+ return this.createNew(
+ this.nodes.map(node => node.parentElement )
+ .filter( node => !!node ) // Filter non-existent parents
+ .filter( node => !selector || node.matches(selector) )
+ );
+ };
+
+
+ /**
+ * Reads all parents of all nodes, optionally filtered by a selector.
+ *
+ * @param selector
+ * @return {OQuery}
+ */
+ parents( selector = null ) {
+ let parents = [];
+ for( let node of this.nodes )
+ while (node) {
+ node = node.parentElement;
+ if ( node && (!selector || node.matches(selector)) )
+ parents.unshift(node);
+ }
+ return this.createNew( parents );
};
+
+ /**
+ * reads the closest anchestor that meets the selector.
+ *
+ * @param selector
+ * @return {OQuery}
+ */
closest( selector ) {
return this.createNew( this.nodes.map(node => node.closest( selector ) ).filter( node => node !== null ) );
};
@@ -91,7 +125,7 @@ export class OQuery {
children( selector ) {
let result = [];
for( let node of this.nodes )
- result = result.concat( Array.from(node.children).filter( node => selector ? node.matches(selector) : true ) );
+ result = result.concat( Array.from(node.children).filter( node => !selector || node.matches(selector) ) );
return this.createNew( result );
};
@@ -203,6 +237,17 @@ export class OQuery {
return this;
}
+ toggle( handler ) {
+ let idx = -1;
+ for( let node of this.nodes )
+ if ( handler.call(node,idx,node) === false )
+ node.style.display = 'none';
+ else
+ node.style.display = '';
+
+ return this;
+ }
+
hide() {
this.nodes.forEach(node => node.style.display = 'none' );
return this;
diff --git a/modules/cms/ui/themes/default/script/Oquery.min.js b/modules/cms/ui/themes/default/script/Oquery.min.js
@@ -49,8 +49,22 @@ return this.createNew( this.nodes.length > 0 ? [this.nodes[0]] : [] );
get length() {
return this.nodes.length;
}
-parent() {
-return this.createNew( this.nodes.map(node => node.parentNode ).filter( node => node !== null ) );
+parent( selector = null ) {
+return this.createNew(
+this.nodes.map(node => node.parentElement )
+.filter( node => !!node )
+.filter( node => !selector || node.matches(selector) )
+);
+};
+parents( selector = null ) {
+let parents = [];
+for( let node of this.nodes )
+while (node) {
+node = node.parentElement;
+if ( node && (!selector || node.matches(selector)) )
+parents.unshift(node);
+}
+return this.createNew( parents );
};
closest( selector ) {
return this.createNew( this.nodes.map(node => node.closest( selector ) ).filter( node => node !== null ) );
@@ -58,7 +72,7 @@ return this.createNew( this.nodes.map(node => node.closest( selector ) ).filter(
children( selector ) {
let result = [];
for( let node of this.nodes )
-result = result.concat( Array.from(node.children).filter( node => selector ? node.matches(selector) : true ) );
+result = result.concat( Array.from(node.children).filter( node => !selector || node.matches(selector) ) );
return this.createNew( result );
};
find(selector) {
@@ -149,6 +163,15 @@ if ( handler.call(node,idx,node) === false )
break;
return this;
}
+toggle( handler ) {
+let idx = -1;
+for( let node of this.nodes )
+if ( handler.call(node,idx,node) === false )
+node.style.display = 'none';
+else
+node.style.display = '';
+return this;
+}
hide() {
this.nodes.forEach(node => node.style.display = 'none' );
return this;
diff --git a/modules/cms/ui/themes/default/style/openrat-ui.less b/modules/cms/ui/themes/default/style/openrat-ui.less
@@ -140,6 +140,9 @@ a:hover {
&--visible {
visibility: visible;
}
+ &--off {
+ display: none;
+ }
&-link {
diff --git a/modules/cms/ui/themes/default/style/openrat.css b/modules/cms/ui/themes/default/style/openrat.css
@@ -1471,6 +1471,9 @@ a:hover {
.or--visible {
visibility: visible;
}
+.or--off {
+ display: none;
+}
.or-link {
color: inherit;
}
@@ -1482,7 +1485,7 @@ legend {
font-weight: bold;
padding: 0 0.5em;
}
-/*# sourceMappingURL=data:application/json,%7B%22version%22%3A3%2C%22sources%22%3A%5B%22var%5C%2Fwww%5C%2Flocalhost%5C%2Fcms%5C%2Fmodules%5C%2Fcms%5C%2Fui%5C%2Fthemes%5C%2Fdefault%5C%2Fstyle%5C%2Fopenrat-ui.less%22%5D%2C%22names%22%3A%5B%5D%2C%22mappings%22%3A%22%3BAAIA%3BAAAM%3BCAAO%3BCAAY%3B%3BAAuBzB%3BCAfQ%2CIAAC%3BEACG%2CSAAS%2CEAAT%3BEACA%3BEACA%3BEACA%3BEACA%3BEACA%3BEACA%3BEACA%3BEAEA%3BEACA%3BEACA%3B%3B%3BAAIZ%3BCACE%3B%3BAAWF%3BCACE%3BCACA%3BCACA%3B%3B%3BAAKF%2CCAAC%3BAACD%2CCAAC%3BCACC%3BCACA%3B%3BAAGF%2CCAAC%3BAACD%2CCAAC%3BCACC%3BCACA%3B%3BAAIF%3BCACE%3B%3B%3BAAMF%3BCACE%3B%3BAAMF%3B%3B%3BAACI%2CGAAC%2COAAU%3BCAEP%3BCACA%3B%3BAAKJ%2CGAAC%3BCACG%3B%3BAAIJ%2CGAAC%3BCACG%3BCACA%3BCACA%3BCACA%3B%3BAAGJ%2CGAAC%3BCACG%3BCACA%3BCACA%2CgBAAA%3B%3BAAHJ%2CGAAC%2CSAKK%3BCACE%2CiBAAA%3BCACA%3BCACA%3BCAvEV%2CoBAAA%3BCACA%2CyBAAA%3BCACA%2C4BAAA%3BCACA%2C2BAAA%3B%3BAA0EE%2CGAAC%3BCACG%3B%3BAAGJ%2CGAAC%3BCACC%3B%3BAAKE%2CGAFH%2CUAEI%3BCAEG%3BCACA%3BCACA%3B%3BAAGJ%2CGATH%2CUASI%3BCACG%3BCACA%3BCACA%3B%3BAAKR%2CGAAC%3BCACG%3B%3BAAGJ%2CGAAC%3BCACG%3B%3BAAIJ%2CGAAC%3BCACC%3B%3BAACA%2CGAFD%2CKAEE%3BCACC%3B%3BAAWR%3BCACI%3BCACA%3BCACA%2CgBAAA%22%7D */
+/*# sourceMappingURL=data:application/json,%7B%22version%22%3A3%2C%22sources%22%3A%5B%22var%5C%2Fwww%5C%2Flocalhost%5C%2Fcms%5C%2Fmodules%5C%2Fcms%5C%2Fui%5C%2Fthemes%5C%2Fdefault%5C%2Fstyle%5C%2Fopenrat-ui.less%22%5D%2C%22names%22%3A%5B%5D%2C%22mappings%22%3A%22%3BAAIA%3BAAAM%3BCAAO%3BCAAY%3B%3BAAuBzB%3BCAfQ%2CIAAC%3BEACG%2CSAAS%2CEAAT%3BEACA%3BEACA%3BEACA%3BEACA%3BEACA%3BEACA%3BEACA%3BEAEA%3BEACA%3BEACA%3B%3B%3BAAIZ%3BCACE%3B%3BAAWF%3BCACE%3BCACA%3BCACA%3B%3B%3BAAKF%2CCAAC%3BAACD%2CCAAC%3BCACC%3BCACA%3B%3BAAGF%2CCAAC%3BAACD%2CCAAC%3BCACC%3BCACA%3B%3BAAIF%3BCACE%3B%3B%3BAAMF%3BCACE%3B%3BAAMF%3B%3B%3BAACI%2CGAAC%2COAAU%3BCAEP%3BCACA%3B%3BAAKJ%2CGAAC%3BCACG%3B%3BAAIJ%2CGAAC%3BCACG%3BCACA%3BCACA%3BCACA%3B%3BAAGJ%2CGAAC%3BCACG%3BCACA%3BCACA%2CgBAAA%3B%3BAAHJ%2CGAAC%2CSAKK%3BCACE%2CiBAAA%3BCACA%3BCACA%3BCAvEV%2CoBAAA%3BCACA%2CyBAAA%3BCACA%2C4BAAA%3BCACA%2C2BAAA%3B%3BAA0EE%2CGAAC%3BCACG%3B%3BAAGJ%2CGAAC%3BCACC%3B%3BAAKE%2CGAFH%2CUAEI%3BCAEG%3BCACA%3BCACA%3B%3BAAGJ%2CGATH%2CUASI%3BCACG%3BCACA%3BCACA%3B%3BAAKR%2CGAAC%3BCACG%3B%3BAAGJ%2CGAAC%3BCACG%3B%3BAAEJ%2CGAAC%3BCACG%3B%3BAAIJ%2CGAAC%3BCACC%3B%3BAACA%2CGAFD%2CKAEE%3BCACC%3B%3BAAWR%3BCACI%3BCACA%3BCACA%2CgBAAA%22%7D */
/* Include style: /default/style/openrat-view */
/*
OpenRat Content Management System
diff --git a/modules/cms/ui/themes/default/style/openrat.min.css b/modules/cms/ui/themes/default/style/openrat.min.css
@@ -17,7 +17,7 @@
.or-search--on-active{display: none}.or-search--on-inactive{display: inline}.or-search-input{border-bottom: .1em solid}.or-search-input .or-input{border: 0;padding: 0;box-shadow: 0 0 0 !important;border-radius: 0;width: 8em}.or-search--is-active .or-search--on-active{display: inline}.or-search--is-active .or-search--on-inactive{display: none}.or-search-result{display: none;padding: 1em}.or-search-result-entry{padding-top: 0.2em}
.or-selector-tree{display: none}.or-selector-search{display: none}.or-selector--is-tree-active .or-selector-tree{display: block}.or-selector--is-search-active .or-selector-search{display: block}
-html,body{width: 100%;height: 100%}@media only screen and (min-width: 56rem){body:before{content: "";position: fixed;left: 0;right: 0;z-index: -1;width: 100%;height: 100%;display: block;background-size: cover;background-position: center;background-repeat: no-repeat}}.or-editor-toolbar{font-size: 1.5em}iframe{width: 100%;height: 500px;display: block}a:link,a:visited{font-weight: normal;text-decoration: none}a:active,a:hover{font-weight: normal;text-decoration: none}.or-act-clickable{cursor: pointer}.CodeMirror{height: auto}.or-search > .or-input{box-shadow: none !important;background-color: transparent !important}.or--initial-hidden{opacity: 0}.or-view-flying-button{display: block;bottom: 1em;right: 1em;position: absolute}.or-linklist{display: flex;flex-direction: column;padding: 10% 20%}.or-linklist > .or-linklist-line{border: 1px solid;margin-top: 1em;padding: 1em;border-radius: .5em;-moz-border-radius: .5em;-webkit-border-radius: .5em;-khtml-border-radius: .5em}.or-dirty{font-weight: bold}.or-draggable{cursor: move}.or-droppable--active{background-color: #3c8b2e !important;cursor: move;z-index: 3}.or-droppable--hover{background-color: #08f169 !important;cursor: move;z-index: 3}.or--invisible{visibility: hidden}.or--visible{visibility: visible}.or-link{color: inherit}.or-link--is-active{font-weight: bold}legend{font-size: 1.1em;font-weight: bold;padding: 0 .5em}
+html,body{width: 100%;height: 100%}@media only screen and (min-width: 56rem){body:before{content: "";position: fixed;left: 0;right: 0;z-index: -1;width: 100%;height: 100%;display: block;background-size: cover;background-position: center;background-repeat: no-repeat}}.or-editor-toolbar{font-size: 1.5em}iframe{width: 100%;height: 500px;display: block}a:link,a:visited{font-weight: normal;text-decoration: none}a:active,a:hover{font-weight: normal;text-decoration: none}.or-act-clickable{cursor: pointer}.CodeMirror{height: auto}.or-search > .or-input{box-shadow: none !important;background-color: transparent !important}.or--initial-hidden{opacity: 0}.or-view-flying-button{display: block;bottom: 1em;right: 1em;position: absolute}.or-linklist{display: flex;flex-direction: column;padding: 10% 20%}.or-linklist > .or-linklist-line{border: 1px solid;margin-top: 1em;padding: 1em;border-radius: .5em;-moz-border-radius: .5em;-webkit-border-radius: .5em;-khtml-border-radius: .5em}.or-dirty{font-weight: bold}.or-draggable{cursor: move}.or-droppable--active{background-color: #3c8b2e !important;cursor: move;z-index: 3}.or-droppable--hover{background-color: #08f169 !important;cursor: move;z-index: 3}.or--invisible{visibility: hidden}.or--visible{visibility: visible}.or--off{display: none}.or-link{color: inherit}.or-link--is-active{font-weight: bold}legend{font-size: 1.1em;font-weight: bold;padding: 0 .5em}
.or-view{padding: 0.5em}.or-view-header{font-size: 1.2em}.or-view-central{position: absolute;top: 30%;margin-left: 40%;margin-right: 40%;font-size: 3em}
.or-workbench{width: 100%;height: 100%;display: flex;flex-direction: row;visibility: hidden}.or-workbench--visible-on-dialog-open{z-index: 3}.or-workbench-screen{display: flex;flex-direction: column;position: relative}.or-workbench-screen > *{overflow-y: auto;overflow-x: hidden}.or-workbench-main{flex: 1;min-width: 0}.or-workbench-title{height: 3.0rem;max-height: 3.0rem;min-height: 3.0rem;overflow: hidden;padding: 0.5em;font-size: 1.2em}.or-workbench-title .toolbar-icon .arrow-down{display: inline}@media only screen and (max-width: 55rem){.or-workbench-title .toolbar-icon span.label,.or-workbench-title .toolbar-icon .arrow-down{display: none}}.or-workbench-content{flex: 1}.or-workbench--visible-on-small{display: none}.or-workbench--visible-on-wide{display: block}.or-workbench--navigation-is-small .or-workbench--visible-on-wide{display: none}.or-workbench--navigation-is-small .or-workbench--visible-on-small{display: block}.or-workbench-navigation{display: flex;flex-direction: row;width: 30em}.or-workbench-navigation-content{flex: 1}@media only screen and (max-width: 55rem){.or-workbench-navigation-content{flex: none}}.or-workbench-navigation-filler{flex: 0;opacity: 0.6}.or-workbench-navigation-container{width: 100%;position: relative;padding: 0.7em;overflow-x: hidden}.or-workbench-navigation--is-small{width: 0}.or-workbench-navigation--is-small .or-workbench-navigation-container{width: 0;overflow-y: hidden}.or-workbench-navigation--is-small .or-workbench-navigation-container .or-navtree{opacity: 0.2}.or-workbench-navigation--is-small .or-navtree{opacity: 0}@media only screen and (max-width: 55rem){.or-workbench-navigation{width: 0}.or-workbench-navigation--is-open{position: fixed;width: 100%;z-index: 1;opacity: 1;height: 100%}.or-workbench-navigation--is-open .or-workbench-navigation-content{width: 90%}.or-workbench-navigation--is-open .or-workbench-navigation-filler{flex: 1}}@media only screen and (min-width: 75rem){.or-workbench-navigation{overflow-y: auto}}.or-workbench-navigation .or-view{height: 100%}.or--visible-on-mobile{display: none}@media only screen and (max-width: 55rem){.or--visible-on-mobile{display: inline}}@media only screen and (max-width: 55rem){.or--visible-on-desktop{display: none}}.or-toggle-nav-small{display: inline}@media only screen and (max-width: 55rem){.or-toggle-nav-small{display: none}}.or-toggle-nav-open-close{display: none}@media only screen and (max-width: 55rem){.or-toggle-nav-open-close{display: inline}}.or-loader{position: absolute;top: 30%;left: 0;right: 0;margin-left: auto;margin-right: auto;border-width: 0.5em;border-style: solid;border-radius: 50%;visibility: hidden;z-index: 6}.or-loader--is-active{visibility: visible;width: 5em;height: 5em;animation: spin 2s linear infinite}@keyframes spin{0%{transform: rotate(0deg)}100%{transform: rotate(360deg)}}@media screen and (prefers-reduced-motion: reduce){.or-loader--is-active{display: none}}@media only screen and (max-width: 55rem){html{font-size: 1.1em}}
.editor__text-editor{width: 100%;height: 300px}textarea.editor__code-editor{display: none}div.editor__code-editor{position: absolute;height: 500px;width: 100%;font-size: 14px;z-index: 256}textarea.editor__text-editor,textarea.editor__wiki-editor,textarea.editor__html-editor{width: 100%}a.editorlink:active,a.editorlink:hover{font-weight: normal;text-decoration: none}a.editorlink:link,a.editorlink:visited{font-weight: normal;text-decoration: none}
diff --git a/modules/template_engine/components/html/component_table/table.js b/modules/template_engine/components/html/component_table/table.js
@@ -48,9 +48,13 @@ export default function(element ) {
table.addClass('loader');
setTimeout( () => {
- table.find('tr:not(.or-table-header)').filter(function () {
- $(this).toggle($(this).text().toLowerCase().indexOf(filterExpression) > -1)
- })
+ table.find('tr:not(.or-table-header)').each(function () {
+ let $row = $(this);
+ if ( $row.text().toLowerCase().indexOf(filterExpression) > -1)
+ $row.removeClass('-off');
+ else
+ $row.addClass('-off');
+ } );
table.removeClass('loader');
}, 50);
diff --git a/modules/template_engine/components/html/component_table/table.min.js b/modules/template_engine/components/html/component_table/table.min.js
@@ -24,9 +24,13 @@ let filterExpression = $(this).val().toLowerCase();
let table = $(this).parents('.or-table-wrapper').find('table');
table.addClass('loader');
setTimeout( () => {
-table.find('tr:not(.or-table-header)').filter(function () {
-$(this).toggle($(this).text().toLowerCase().indexOf(filterExpression) > -1)
-})
+table.find('tr:not(.or-table-header)').each(function () {
+let $row = $(this);
+if ( $row.text().toLowerCase().indexOf(filterExpression) > -1)
+$row.removeClass('-off');
+else
+$row.addClass('-off');
+} );
table.removeClass('loader');
}, 50);
} );