From 096424e1e48bc00fa376f3de2ea4b02968fb0d12 Mon Sep 17 00:00:00 2001
From: Patrick Jentsch
Date: Fri, 16 Jul 2021 10:51:39 +0200
Subject: [PATCH] Restructure some javascript
---
.gitignore | 3 ++-
web/app/static/js/list.min.js | 2 +-
web/app/static/js/list.min.js.map | 1 +
web/app/static/js/nopaque/RessourceLists/CorpusFileList.js | 2 +-
web/app/static/js/nopaque/RessourceLists/CorpusList.js | 2 +-
web/app/static/js/nopaque/RessourceLists/JobList.js | 2 +-
web/app/static/js/nopaque/RessourceLists/QueryResultList.js | 2 +-
web/app/static/js/nopaque/RessourceLists/RessourceList.js | 1 +
web/app/static/js/nopaque/RessourceLists/UserList.js | 2 +-
web/app/templates/_scripts.html.j2 | 4 ++--
web/app/templates/base.html.j2 | 2 ++
11 files changed, 14 insertions(+), 9 deletions(-)
create mode 100644 web/app/static/js/list.min.js.map
diff --git a/.gitignore b/.gitignore
index 9d5ca616..bdef04f3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,7 +5,8 @@
# Flask-Assets files
.webassets-cache
-*.compiled.js
+*.bundle.css
+*.bundle.js
# Docker related files
docker-compose.override.yml
diff --git a/web/app/static/js/list.min.js b/web/app/static/js/list.min.js
index 16247404..81318815 100644
--- a/web/app/static/js/list.min.js
+++ b/web/app/static/js/list.min.js
@@ -1,2 +1,2 @@
var List;List=function(){var t={"./src/add-async.js":function(t){t.exports=function(t){return function e(r,n,s){var i=r.splice(0,50);s=(s=s||[]).concat(t.add(i)),r.length>0?setTimeout((function(){e(r,n,s)}),1):(t.update(),n(s))}}},"./src/filter.js":function(t){t.exports=function(t){return t.handlers.filterStart=t.handlers.filterStart||[],t.handlers.filterComplete=t.handlers.filterComplete||[],function(e){if(t.trigger("filterStart"),t.i=1,t.reset.filter(),void 0===e)t.filtered=!1;else{t.filtered=!0;for(var r=t.items,n=0,s=r.length;nv.page,a=new g(t[s],void 0,n),v.items.push(a),r.push(a)}return v.update(),r}m(t.slice(0),e)}},this.show=function(t,e){return this.i=t,this.page=e,v.update(),v},this.remove=function(t,e,r){for(var n=0,s=0,i=v.items.length;s-1&&r.splice(n,1),v},this.trigger=function(t){for(var e=v.handlers[t].length;e--;)v.handlers[t][e](v);return v},this.reset={filter:function(){for(var t=v.items,e=t.length;e--;)t[e].filtered=!1;return v},search:function(){for(var t=v.items,e=t.length;e--;)t[e].found=!1;return v}},this.update=function(){var t=v.items,e=t.length;v.visibleItems=[],v.matchingItems=[],v.templater.clear();for(var r=0;r=v.i&&v.visibleItems.lengthe},innerWindow:function(t,e,r){return t>=e-r&&t<=e+r},dotted:function(t,e,r,n,s,i,a){return this.dottedLeft(t,e,r,n,s,i)||this.dottedRight(t,e,r,n,s,i,a)},dottedLeft:function(t,e,r,n,s,i){return e==r+1&&!this.innerWindow(e,s,i)&&!this.right(e,n)},dottedRight:function(t,e,r,n,s,i,a){return!t.items[a-1].values().dotted&&(e==n&&!this.innerWindow(e,s,i)&&!this.right(e,n))}};return function(e){var n=new i(t.listContainer.id,{listClass:e.paginationClass||"pagination",item:e.item||"",valueNames:["page","dotted"],searchClass:"pagination-search-that-is-not-supposed-to-exist",sortClass:"pagination-sort-that-is-not-supposed-to-exist"});s.bind(n.listContainer,"click",(function(e){var r=e.target||e.srcElement,n=t.utils.getAttribute(r,"data-page"),s=t.utils.getAttribute(r,"data-i");s&&t.show((s-1)*n+1,n)})),t.on("updated",(function(){r(n,e)})),r(n,e)}}},"./src/parse.js":function(t,e,r){t.exports=function(t){var e=r("./src/item.js")(t),n=function(r,n){for(var s=0,i=r.length;s0?setTimeout((function(){e(r,s)}),1):(t.update(),t.trigger("parseComplete"))};return t.handlers.parseComplete=t.handlers.parseComplete||[],function(){var e=function(t){for(var e=t.childNodes,r=[],n=0,s=e.length;n]/g.exec(t)){var e=document.createElement("tbody");return e.innerHTML=t,e.firstElementChild}if(-1!==t.indexOf("<")){var r=document.createElement("div");return r.innerHTML=t,r.firstElementChild}}},a=function(e,r,n){var s=void 0,i=function(e){for(var r=0,n=t.valueNames.length;r=1;)t.list.removeChild(t.list.firstChild)},function(){var r;if("function"!=typeof t.item){if(!(r="string"==typeof t.item?-1===t.item.indexOf("<")?document.getElementById(t.item):i(t.item):s()))throw new Error("The list needs to have at least one item on init otherwise you'll have to add a template.");r=n(r,t.valueNames),e=function(){return r.cloneNode(!0)}}else e=function(e){var r=t.item(e);return i(r)}}()};t.exports=function(t){return new e(t)}},"./src/utils/classes.js":function(t,e,r){var n=r("./src/utils/index-of.js"),s=/\s+/;Object.prototype.toString;function i(t){if(!t||!t.nodeType)throw new Error("A DOM element reference is required");this.el=t,this.list=t.classList}t.exports=function(t){return new i(t)},i.prototype.add=function(t){if(this.list)return this.list.add(t),this;var e=this.array();return~n(e,t)||e.push(t),this.el.className=e.join(" "),this},i.prototype.remove=function(t){if(this.list)return this.list.remove(t),this;var e=this.array(),r=n(e,t);return~r&&e.splice(r,1),this.el.className=e.join(" "),this},i.prototype.toggle=function(t,e){return this.list?(void 0!==e?e!==this.list.toggle(t,e)&&this.list.toggle(t):this.list.toggle(t),this):(void 0!==e?e?this.add(t):this.remove(t):this.has(t)?this.remove(t):this.add(t),this)},i.prototype.array=function(){var t=(this.el.getAttribute("class")||"").replace(/^\s+|\s+$/g,"").split(s);return""===t[0]&&t.shift(),t},i.prototype.has=i.prototype.contains=function(t){return this.list?this.list.contains(t):!!~n(this.array(),t)}},"./src/utils/events.js":function(t,e,r){var n=window.addEventListener?"addEventListener":"attachEvent",s=window.removeEventListener?"removeEventListener":"detachEvent",i="addEventListener"!==n?"on":"",a=r("./src/utils/to-array.js");e.bind=function(t,e,r,s){for(var o=0,l=(t=a(t)).length;o32)return!1;var a=n,o=function(){var t,r={};for(t=0;t=p;b--){var j=o[t.charAt(b-1)];if(C[b]=0===m?(C[b+1]<<1|1)&j:(C[b+1]<<1|1)&j|(v[b+1]|v[b])<<1|1|v[b+1],C[b]&d){var x=l(m,b-1);if(x<=u){if(u=x,!((c=b-1)>a))break;p=Math.max(1,2*a-c)}}}if(l(m+1,a)>u)break;v=C}return!(c<0)}},"./src/utils/get-attribute.js":function(t){t.exports=function(t,e){var r=t.getAttribute&&t.getAttribute(e)||null;if(!r)for(var n=t.attributes,s=n.length,i=0;i=48&&t<=57}function i(t,e){for(var i=(t+="").length,a=(e+="").length,o=0,l=0;o=i&&l=a?-1:l>=a&&o=i?1:i-a}i.caseInsensitive=i.i=function(t,e){return i((""+t).toLowerCase(),(""+e).toLowerCase())},Object.defineProperties(i,{alphabet:{get:function(){return e},set:function(t){r=[];var s=0;if(e=t)for(;sdeleteDelete
`;
- let deleteModalParentElement = document.querySelector('main');
+ let deleteModalParentElement = document.querySelector('#modals');
deleteModalParentElement.insertAdjacentHTML('beforeend', deleteModalHTML);
let deleteModalElement = deleteModalParentElement.lastChild;
let deleteModal = M.Modal.init(deleteModalElement, {onCloseEnd: () => {deleteModal.destroy(); deleteModalElement.remove();}});
diff --git a/web/app/static/js/nopaque/RessourceLists/CorpusList.js b/web/app/static/js/nopaque/RessourceLists/CorpusList.js
index fadb4fa1..ffe555cf 100644
--- a/web/app/static/js/nopaque/RessourceLists/CorpusList.js
+++ b/web/app/static/js/nopaque/RessourceLists/CorpusList.js
@@ -26,7 +26,7 @@ class CorpusList extends RessourceList {
deleteDelete
`;
- let deleteModalParentElement = document.querySelector('main');
+ let deleteModalParentElement = document.querySelector('#modals');
deleteModalParentElement.insertAdjacentHTML('beforeend', deleteModalHTML);
let deleteModalElement = deleteModalParentElement.lastChild;
let deleteModal = M.Modal.init(deleteModalElement, {onCloseEnd: () => {deleteModal.destroy(); deleteModalElement.remove();}});
diff --git a/web/app/static/js/nopaque/RessourceLists/JobList.js b/web/app/static/js/nopaque/RessourceLists/JobList.js
index cb88b1e3..d0311928 100644
--- a/web/app/static/js/nopaque/RessourceLists/JobList.js
+++ b/web/app/static/js/nopaque/RessourceLists/JobList.js
@@ -26,7 +26,7 @@ class JobList extends RessourceList {
deleteDelete
`;
- let deleteModalParentElement = document.querySelector('main');
+ let deleteModalParentElement = document.querySelector('#modals');
deleteModalParentElement.insertAdjacentHTML('beforeend', deleteModalHTML);
let deleteModalElement = deleteModalParentElement.lastChild;
let deleteModal = M.Modal.init(deleteModalElement, {onCloseEnd: () => {deleteModal.destroy(); deleteModalElement.remove();}});
diff --git a/web/app/static/js/nopaque/RessourceLists/QueryResultList.js b/web/app/static/js/nopaque/RessourceLists/QueryResultList.js
index ae9b2fb1..4fb7b44b 100644
--- a/web/app/static/js/nopaque/RessourceLists/QueryResultList.js
+++ b/web/app/static/js/nopaque/RessourceLists/QueryResultList.js
@@ -26,7 +26,7 @@ class QueryResultList extends RessourceList {
deleteDelete
`;
- let deleteModalParentElement = document.querySelector('main');
+ let deleteModalParentElement = document.querySelector('#modals');
deleteModalParentElement.insertAdjacentHTML('beforeend', deleteModalHTML);
let deleteModalElement = deleteModalParentElement.lastChild;
let deleteModal = M.Modal.init(deleteModalElement, {onCloseEnd: () => {deleteModal.destroy(); deleteModalElement.remove();}});
diff --git a/web/app/static/js/nopaque/RessourceLists/RessourceList.js b/web/app/static/js/nopaque/RessourceLists/RessourceList.js
index 81ad95c0..cd400692 100644
--- a/web/app/static/js/nopaque/RessourceLists/RessourceList.js
+++ b/web/app/static/js/nopaque/RessourceLists/RessourceList.js
@@ -39,6 +39,7 @@ class RessourceList {
`;
+ this.list.list.style.cursor = 'pointer';
if (typeof this.onclick === 'function') {this.list.list.addEventListener('click', event => this.onclick(event));}
}
diff --git a/web/app/static/js/nopaque/RessourceLists/UserList.js b/web/app/static/js/nopaque/RessourceLists/UserList.js
index c1abce8f..f22f63c0 100644
--- a/web/app/static/js/nopaque/RessourceLists/UserList.js
+++ b/web/app/static/js/nopaque/RessourceLists/UserList.js
@@ -27,7 +27,7 @@ class UserList extends RessourceList {
deleteDelete
`;
- let deleteModalParentElement = document.querySelector('main');
+ let deleteModalParentElement = document.querySelector('#modals');
deleteModalParentElement.insertAdjacentHTML('beforeend', deleteModalHTML);
let deleteModalElement = deleteModalParentElement.lastChild;
let deleteModal = M.Modal.init(deleteModalElement, {onCloseEnd: () => {deleteModal.destroy(); deleteModalElement.remove();}});
diff --git a/web/app/templates/_scripts.html.j2 b/web/app/templates/_scripts.html.j2
index ec485beb..49796bcc 100644
--- a/web/app/templates/_scripts.html.j2
+++ b/web/app/templates/_scripts.html.j2
@@ -8,13 +8,13 @@
-{% assets filters='rjsmin', output="js/nopaque/RessourceDisplays.min.compiled.js",
+{% assets filters='rjsmin', output="js/nopaque/RessourceDisplays.min.bundle.js",
"js/nopaque/RessourceDisplays/RessourceDisplay.js",
"js/nopaque/RessourceDisplays/CorpusDisplay.js",
"js/nopaque/RessourceDisplays/JobDisplay.js" %}
{% endassets %}
-{% assets filters='rjsmin', output="js/nopaque/RessourceLists.min.compiled.js",
+{% assets filters='rjsmin', output="js/nopaque/RessourceLists.min.bundle.js",
"js/nopaque/RessourceLists/RessourceList.js",
"js/nopaque/RessourceLists/CorpusList.js",
"js/nopaque/RessourceLists/CorpusFileList.js",
diff --git a/web/app/templates/base.html.j2 b/web/app/templates/base.html.j2
index bafabe91..747f7dfb 100644
--- a/web/app/templates/base.html.j2
+++ b/web/app/templates/base.html.j2
@@ -33,9 +33,11 @@
{% block main_attribs %} class="background-color"{% endblock main_attribs %}
{% block main %}
{% block page_content %}{% endblock page_content %}
+
{% if current_user.is_authenticated %}
{% include "_roadmap.html.j2" %}
{% endif %}
+
{% endblock main %}
{% block footer_attribs %} class="page-footer primary-variant-color"{% endblock footer_attribs %}