This commit is contained in:
syuilo
2017-02-20 10:27:44 +09:00
parent 3c3040783f
commit 7791431717
44 changed files with 344 additions and 340 deletions

View File

@@ -19,16 +19,15 @@
<script>
this.mixin('api');
this.apps = []
this.fetching = true
this.apps = [];
this.fetching = true;
this.on('mount', () => {
this.api 'i/authorized_apps'
.then (apps) =>
this.apps = apps
this.fetching = false
this.api('i/authorized_apps').then(apps => {
this.apps = apps;
this.fetching = false;
this.update();
.catch (err) =>
console.error err
});
});
</script>
</mk-authorized-apps>

View File

@@ -1,11 +1,7 @@
<mk-copyright><span>(c) syuilo 2014-2017</span>
<mk-copyright>
<span>(c) syuilo 2014-2017</span>
<style>
:scope
display block
</style>
</mk-copyright>

View File

@@ -59,6 +59,7 @@
<script>
retry() {
this.unmount();
this.opts.retry!
this.opts.retry();
}
</script>
</mk-core-error>

View File

@@ -20,10 +20,5 @@
opacity 1
40%
opacity 0
</style>
</mk-ellipsis>

View File

@@ -21,9 +21,5 @@
margin 0
text-align center
</style>
</mk-introduction>

View File

@@ -327,29 +327,29 @@
key = e.which
switch (key)
| 9, 40 => // Key[TAB] or Key[↓]
e.prevent-default!
e.stop-propagation!
this.refs.search-result.child-nodes[0].focus();
e.preventDefault();
e.stopPropagation();
this.refs.search-result.childNodes[0].focus();
on-search-result-keydown(i, e) {
key = e.which
switch (key)
| 10, 13 => // Key[ENTER]
e.prevent-default!
e.stop-propagation!
e.preventDefault();
e.stopPropagation();
@search-result[i]._click!
| 27 => // Key[ESC]
e.prevent-default!
e.stop-propagation!
e.preventDefault();
e.stopPropagation();
this.refs.search.focus();
| 38 => // Key[↑]
e.prevent-default!
e.stop-propagation!
(this.refs.search-result.child-nodes[i].previous-element-sibling || this.refs.search-result.child-nodes[@search-result.length - 1]).focus();
e.preventDefault();
e.stopPropagation();
(this.refs.search-result.childNodes[i].previous-element-sibling || this.refs.search-result.childNodes[@search-result.length - 1]).focus();
| 9, 40 => // Key[TAB] or Key[↓]
e.prevent-default!
e.stop-propagation!
(this.refs.search-result.child-nodes[i].next-element-sibling || this.refs.search-result.child-nodes[0]).focus();
e.preventDefault();
e.stopPropagation();
(this.refs.search-result.childNodes[i].next-element-sibling || this.refs.search-result.childNodes[0]).focus();
</script>
</mk-messaging>

View File

@@ -203,13 +203,13 @@
n.inner-HTML = '<i class="fa fa-arrow-circle-down"></i>' + message
n.onclick = =>
@scroll-to-bottom!
n.parent-node.remove-child n
n.parentNode.removeChild n
this.refs.notifications.appendChild n
setTimeout =>
n.style.opacity = 0
setTimeout =>
n.parent-node.remove-child n
n.parentNode.removeChild n
, 1000ms
, 4000ms

View File

@@ -6,13 +6,14 @@
</style>
<script>
this.on('mount', () => {
// バグ? https://github.com/riot/riot/issues/2103
#value = this.opts.value
value = this.opts.riot-value
max = this.opts.max
// https://github.com/riot/riot/issues/2103
//value = this.opts.value
const value = this.opts.riotValue;
const max = this.opts.max;
if max? then if value > max then value = max
if (max != null && value > max) value = max;
this.root.innerHTML = value.to-locale-string!
this.root.innerHTML = value.toLocaleString();
});
</script>
</mk-number>

View File

@@ -86,26 +86,31 @@
</style>
<script>
this.choices = ['', '']
this.choices = ['', ''];
oninput(i, e) {
@choices[i] = e.target.value
this.choices[i] = e.target.value;
}
add() {
@choices.push ''
this.choices.push('');
this.update();
this.refs.choices.child-nodes[@choices.length - 1].child-nodes[0].focus();
this.refs.choices.childNodes[this.choices.length - 1].childNodes[0].focus();
}
remove(i) {
this.choices = @choices.filter((_, _i) -> _i != i)
this.choices = this.choices.filter((_, _i) => _i != i);
this.update();
}
destroy() {
this.opts.ondestroy!
this.opts.ondestroy();
}
get() {
return {
choices: @choices.filter (choice) -> choice != ''
choices: this.choices.filter(choice => choice != '')
}
}
</script>
</mk-poll-editor>

View File

@@ -70,30 +70,35 @@
<script>
this.mixin('api');
this.post = this.opts.post
this.poll = @post.poll
this.total = @poll.choices.reduce ((a, b) -> a + b.votes), 0
this.is-voted = @poll.choices.some (c) -> c.is_voted
this.result = @is-voted
this.post = this.opts.post;
this.poll = this.post.poll;
this.total = this.poll.choices.reduce((a, b) => a + b.votes, 0);
this.isVoted = this.poll.choices.some(c => c.is_voted);
this.result = this.isVoted;
toggle-result() {
this.result = !@result
toggleResult() {
this.result = !this.result;
}
vote(id) {
if (@poll.choices.some (c) -> c.is_voted) then return
this.api 'posts/polls/vote' do
post_id: @post.id
if (this.poll.choices.some(c => c.is_voted)) return;
this.api('posts/polls/vote', {
post_id: this.post.id,
choice: id
.then =>
@poll.choices.for-each (c) ->
if c.id == id
c.votes++
c.is_voted = true
@update do
poll: @poll
is-voted: true
result: true
total: @total + 1
}).then(() => {
this.poll.choices.forEach(c => {
if (c.id == id) {
c.votes++;
c.is_voted = true;
}
});
this.update({
poll: this.poll,
isVoted: true,
result: true,
total: this.total + 1
});
});
}
</script>
</mk-poll>

View File

@@ -51,8 +51,8 @@
this.mixin('api');
this.mixin('stream');
this.history = []
this.fetching = true
this.history = [];
this.fetching = true;
this.on('mount', () => {
this.api 'i/signin_history'

View File

@@ -99,8 +99,8 @@
<script>
this.mixin('api');
this.user = null
this.signing = false
this.user = null;
this.signing = false;
oninput() {
this.api 'users/show' do
@@ -111,7 +111,7 @@
this.update();
onsubmit(e) {
e.prevent-default!
e.preventDefault();
if this.refs.username.value == ''
this.refs.username.focus();

View File

@@ -177,24 +177,27 @@
this.mixin('api');
this.mixin('get-password-strength');
this.username-state = null
this.password-strength = ''
this.password-retype-state = null
this.recaptchaed = false
this.usernameState = null;
this.passwordStrength = '';
this.passwordRetypeState = null;
this.recaptchaed = false;
window.on-recaptchaed = =>
this.recaptchaed = true
window.onEecaptchaed = () => {
this.recaptchaed = true;
this.update();
}
window.on-recaptcha-expired = =>
this.recaptchaed = false
window.onRecaptchaExpired = () => {
this.recaptchaed = false;
this.update();
}
this.on('mount', () => {
head = (document.get-elements-by-tag-name 'head).0'
const head = (document.getElementsByTagName('head'))[0];
script = document.createElement 'script'
..set-attribute 'src' \https://www.google.com/recaptcha/api.js
..setAttribute 'src' \https://www.google.com/recaptcha/api.js
head.appendChild script
});
on-change-username() {
username = this.refs.username.value
@@ -263,7 +266,7 @@
this.password-retype-state = 'not-match'
onsubmit(e) {
e.prevent-default!
e.preventDefault();
username = this.refs.username.value
password = this.refs.password.value
@@ -286,7 +289,7 @@
grecaptcha.reset!
this.recaptchaed = false
locker.parent-node.remove-child locker
locker.parentNode.removeChild locker
false
</script>

View File

@@ -20,8 +20,8 @@
</style>
<script>
now = new Date!
this.d = now.get-date!
this.m = now.get-month! + 1
const now = new Date();
this.d = now.getDate();
this.m = now.getMonth() + 1;
</script>
</mk-special-message>

View File

@@ -93,20 +93,22 @@
<script>
this.mixin('api');
this.url = this.opts.url
this.loading = true
this.url = this.opts.url;
this.loading = true;
this.on('mount', () => {
fetch CONFIG.url + '/api:url?url=' + @url
.then (res) =>
info <~ res.json!.then
this.title = info.title
this.description = info.description
this.thumbnail = info.thumbnail
this.icon = info.icon
this.sitename = info.sitename
fetch(CONFIG.url + '/api:url?url=' + this.url).then(res => {
res.json().then(info => {
this.title = info.title;
this.description = info.description;
this.thumbnail = info.thumbnail;
this.icon = info.icon;
this.sitename = info.sitename;
this.loading = false
this.update();
this.loading = false;
this.update();
});
});
});
</script>
</mk-url-preview>

View File

@@ -30,19 +30,20 @@
</style>
<script>
this.url = this.opts.href
this.url = this.opts.href;
this.on('before-mount', () => {
parser = document.createElement 'a'
parser.href = @url
parser = document.createElement('a');
parser.href = this.url;
this.schema = parser.protocol
this.hostname = parser.hostname
this.port = parser.port
this.pathname = parser.pathname
this.query = parser.search
this.hash = parser.hash
this.schema = parser.protocol;
this.hostname = parser.hostname;
this.port = parser.port;
this.pathname = parser.pathname;
this.query = parser.search;
this.hash = parser.hash;
this.update();
});
</script>
</mk-url>