projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Better randomness in Ball variant + notify when receiving targetting challenge
[vchess.git]
/
client
/
src
/
views
/
News.vue
diff --git
a/client/src/views/News.vue
b/client/src/views/News.vue
index
0e3c3c7
..
97f0eb8
100644
(file)
--- a/
client/src/views/News.vue
+++ b/
client/src/views/News.vue
@@
-23,13
+23,16
@@
main
| {{ st.tr["Write news"] }}
.news(
v-for="n,idx in newsList"
| {{ st.tr["Write news"] }}
.news(
v-for="n,idx in newsList"
+ :id="'n' + n.id"
:class="{margintop:idx>0}"
)
span.ndt {{ formatDatetime(n.added) }}
:class="{margintop:idx>0}"
)
span.ndt {{ formatDatetime(n.added) }}
-
div
(v-if="devs.includes(st.user.id)")
+
.dev-buttons
(v-if="devs.includes(st.user.id)")
button(@click="editNews(n)") {{ st.tr["Edit"] }}
button(@click="deleteNews(n)") {{ st.tr["Delete"] }}
button(@click="editNews(n)") {{ st.tr["Edit"] }}
button(@click="deleteNews(n)") {{ st.tr["Delete"] }}
- p(v-html="parseHtml(n.content)")
+ button(@click="gotoPrevNext(n, 1)") {{ st.tr["Previous_n"] }}
+ button(@click="gotoPrevNext(n, -1)") {{ st.tr["Next_n"] }}
+ .news-content(v-html="parseHtml(n.content)")
button#loadMoreBtn(
v-if="hasMore"
@click="loadMore()"
button#loadMoreBtn(
v-if="hasMore"
@click="loadMore()"
@@
-68,6
+71,7
@@
export default {
this.newsList = res.newsList;
const L = res.newsList.length;
if (L > 0) this.cursor = res.newsList[L - 1].added;
this.newsList = res.newsList;
const L = res.newsList.length;
if (L > 0) this.cursor = res.newsList[L - 1].added;
+ else this.hasMore = false;
}
}
);
}
}
);
@@
-97,7
+101,7
@@
export default {
},
adjustHeight: function() {
const newsContent = document.getElementById("newsContent");
},
adjustHeight: function() {
const newsContent = document.getElementById("newsContent");
- // https://stackoverflow.com/
questions/995168/textarea-to-resize-based-on-content-length
+ // https://stackoverflow.com/
a/995374
newsContent.style.height = "1px";
newsContent.style.height = 10 + newsContent.scrollHeight + "px";
},
newsContent.style.height = "1px";
newsContent.style.height = 10 + newsContent.scrollHeight + "px";
},
@@
-106,6
+110,10
@@
export default {
this.curnews.content = "";
// No need for added and uid fields: never updated
},
this.curnews.content = "";
// No need for added and uid fields: never updated
},
+ gotoPrevNext: function(n, dir) {
+ document.getElementById("n" + n.id)[
+ (dir < 0 ? "previous" : "next") + "ElementSibling"].scrollIntoView();
+ },
showModalNews: function() {
this.resetCurnews();
window.doClick("modalNews");
showModalNews: function() {
this.resetCurnews();
window.doClick("modalNews");
@@
-121,7
+129,7
@@
export default {
success: (res) => {
if (edit) {
let n = this.newsList.find(n => n.id == this.curnews.id);
success: (res) => {
if (edit) {
let n = this.newsList.find(n => n.id == this.curnews.id);
- if (n) n.content = this.curnews.content;
+ if (
!!
n) n.content = this.curnews.content;
} else {
const newNews = {
content: this.curnews.content,
} else {
const newNews = {
content: this.curnews.content,
@@
-169,10
+177,10
@@
export default {
{
data: { cursor: this.cursor },
success: (res) => {
{
data: { cursor: this.cursor },
success: (res) => {
- if (res.newsList.length > 0) {
+ const L = res.newsList.length;
+ if (L > 0) {
this.newsList = this.newsList.concat(res.newsList);
this.newsList = this.newsList.concat(res.newsList);
- const L = res.newsList.length;
- if (L > 0) this.cursor = res.newsList[L - 1].added;
+ this.cursor = res.newsList[L - 1].added;
} else this.hasMore = false;
}
}
} else this.hasMore = false;
}
}
@@
-182,7
+190,7
@@
export default {
};
</script>
};
</script>
-<style lang="sass"
scoped
>
+<style lang="sass">
[type="checkbox"].modal+div .card
max-width: 767px
max-height: 100%
[type="checkbox"].modal+div .card
max-width: 767px
max-height: 100%
@@
-210,8
+218,16
@@
span.ndt
.news
padding-top: 10px
.news
padding-top: 10px
- & >
div
+ & >
.dev-buttons
display: inline-block
display: inline-block
+ & > .news-content
+ margin: var(--universal-margin)
+ & > p
+ margin: 10px 0
+ & > br
+ display: block
+ margin-top: 10px
+ content: " "
.margintop
margin-top: 25px
.margintop
margin-top: 25px