wip
This commit is contained in:
parent
3c3040783f
commit
7791431717
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
<script>
|
||||
retry() {
|
||||
this.unmount();
|
||||
this.opts.retry!
|
||||
this.opts.retry();
|
||||
}
|
||||
</script>
|
||||
</mk-core-error>
|
||||
|
|
|
@ -20,10 +20,5 @@
|
|||
opacity 1
|
||||
40%
|
||||
opacity 0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
</mk-ellipsis>
|
||||
|
|
|
@ -21,9 +21,5 @@
|
|||
margin 0
|
||||
text-align center
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
</mk-introduction>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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.loading = false;
|
||||
this.update();
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</mk-url-preview>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -124,25 +124,25 @@
|
|||
switch (key)
|
||||
| 10, 13 => // Key[ENTER]
|
||||
if @select != -1
|
||||
e.prevent-default!
|
||||
e.stop-propagation!
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
@complete @users[@select]
|
||||
else
|
||||
@close!
|
||||
| 27 => // Key[ESC]
|
||||
e.prevent-default!
|
||||
e.stop-propagation!
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
@close!
|
||||
| 38 => // Key[↑]
|
||||
if @select != -1
|
||||
e.prevent-default!
|
||||
e.stop-propagation!
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
@select-prev!
|
||||
else
|
||||
@close!
|
||||
| 9, 40 => // Key[TAB] or Key[↓]
|
||||
e.prevent-default!
|
||||
e.stop-propagation!
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
@select-next!
|
||||
| _ =>
|
||||
@close!
|
||||
|
@ -167,7 +167,7 @@
|
|||
this.refs.users.children.for-each (el) =>
|
||||
el.remove-attribute 'data-selected'
|
||||
|
||||
this.refs.users.children[@select].set-attribute 'data-selected' \true
|
||||
this.refs.users.children[@select].setAttribute 'data-selected' \true
|
||||
this.refs.users.children[@select].focus();
|
||||
|
||||
complete(user) {
|
||||
|
@ -177,11 +177,11 @@
|
|||
this.opts.close!
|
||||
|
||||
function contains(parent, child)
|
||||
node = child.parent-node
|
||||
node = child.parentNode
|
||||
while node?
|
||||
if node == parent
|
||||
return true
|
||||
node = node.parent-node
|
||||
node = node.parentNode
|
||||
return false
|
||||
</script>
|
||||
</mk-autocomplete-suggestion>
|
||||
|
|
|
@ -95,10 +95,10 @@
|
|||
</style>
|
||||
<script>
|
||||
this.root.add-event-listener 'contextmenu' (e) =>
|
||||
e.prevent-default!
|
||||
e.preventDefault();
|
||||
|
||||
mousedown(e) {
|
||||
e.prevent-default!
|
||||
e.preventDefault();
|
||||
if (!contains this.root, e.target) and (this.root != e.target)
|
||||
@close!
|
||||
return false
|
||||
|
@ -129,11 +129,11 @@
|
|||
this.unmount();
|
||||
|
||||
function contains(parent, child)
|
||||
node = child.parent-node
|
||||
node = child.parentNode
|
||||
while (node != null)
|
||||
if (node == parent)
|
||||
return true
|
||||
node = node.parent-node
|
||||
node = node.parentNode
|
||||
return false
|
||||
</script>
|
||||
</mk-contextmenu>
|
||||
|
|
|
@ -51,8 +51,8 @@
|
|||
this.mixin('i');
|
||||
|
||||
close(e) {
|
||||
e.prevent-default!
|
||||
e.stop-propagation!
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
this.I.data.no_donation = true
|
||||
this.I.update!
|
||||
|
|
|
@ -24,15 +24,15 @@
|
|||
this.refs.ctx.open pos
|
||||
|
||||
create-folder() {
|
||||
@browser.create-folder!
|
||||
this.browser.create-folder!
|
||||
this.refs.ctx.close!
|
||||
|
||||
upload() {
|
||||
@browser.select-local-file!
|
||||
this.browser.select-local-file!
|
||||
this.refs.ctx.close!
|
||||
|
||||
url-upload() {
|
||||
@browser.url-upload!
|
||||
this.browser.url-upload!
|
||||
this.refs.ctx.close!
|
||||
</script>
|
||||
</mk-drive-browser-base-contextmenu>
|
||||
|
|
|
@ -293,7 +293,7 @@
|
|||
@add-file file, true
|
||||
|
||||
on-stream-drive-file-updated(file) {
|
||||
current = if @folder? then @folder.id else null
|
||||
current = if this.folder? then this.folder.id else null
|
||||
if current != file.folder_id
|
||||
@remove-file file
|
||||
else
|
||||
|
@ -303,7 +303,7 @@
|
|||
@add-folder folder, true
|
||||
|
||||
on-stream-drive-folder-updated(folder) {
|
||||
current = if @folder? then @folder.id else null
|
||||
current = if this.folder? then this.folder.id else null
|
||||
if current != folder.parent_id
|
||||
@remove-folder folder
|
||||
else
|
||||
|
@ -350,29 +350,29 @@
|
|||
document.document-element.add-event-listener 'mouseup' up
|
||||
|
||||
path-oncontextmenu(e) {
|
||||
e.prevent-default!
|
||||
e.preventDefault();
|
||||
e.stop-immediate-propagation!
|
||||
return false
|
||||
|
||||
ondragover(e) {
|
||||
e.prevent-default!
|
||||
e.stop-propagation!
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
// ドラッグ元が自分自身の所有するアイテムかどうか
|
||||
if !@is-drag-source
|
||||
// ドラッグされてきたものがファイルだったら
|
||||
if e.data-transfer.effect-allowed == 'all'
|
||||
e.data-transfer.drop-effect = 'copy'
|
||||
if e.dataTransfer.effect-allowed == 'all'
|
||||
e.dataTransfer.dropEffect = 'copy'
|
||||
else
|
||||
e.data-transfer.drop-effect = 'move'
|
||||
e.dataTransfer.dropEffect = 'move'
|
||||
this.draghover = true
|
||||
else
|
||||
// 自分自身にはドロップさせない
|
||||
e.data-transfer.drop-effect = 'none'
|
||||
e.dataTransfer.dropEffect = 'none'
|
||||
return false
|
||||
|
||||
ondragenter(e) {
|
||||
e.prevent-default!
|
||||
e.preventDefault();
|
||||
if !@is-drag-source
|
||||
this.draghover = true
|
||||
|
||||
|
@ -380,19 +380,19 @@
|
|||
this.draghover = false
|
||||
|
||||
ondrop(e) {
|
||||
e.prevent-default!
|
||||
e.stop-propagation!
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
this.draghover = false
|
||||
|
||||
// ドロップされてきたものがファイルだったら
|
||||
if e.data-transfer.files.length > 0
|
||||
Array.prototype.for-each.call e.data-transfer.files, (file) =>
|
||||
@upload file, @folder
|
||||
if e.dataTransfer.files.length > 0
|
||||
Array.prototype.for-each.call e.dataTransfer.files, (file) =>
|
||||
@upload file, this.folder
|
||||
return false
|
||||
|
||||
// データ取得
|
||||
data = e.data-transfer.get-data 'text'
|
||||
data = e.dataTransfer.get-data 'text'
|
||||
if !data?
|
||||
return false
|
||||
|
||||
|
@ -402,12 +402,12 @@
|
|||
// (ドライブの)ファイルだったら
|
||||
if obj.type == 'file'
|
||||
file = obj.id
|
||||
if (@files.some (f) => f.id == file)
|
||||
if (this.files.some (f) => f.id == file)
|
||||
return false
|
||||
@remove-file file
|
||||
this.api 'drive/files/update' do
|
||||
file_id: file
|
||||
folder_id: if @folder? then @folder.id else null
|
||||
folder_id: if this.folder? then this.folder.id else null
|
||||
.then =>
|
||||
// something
|
||||
.catch (err, text-status) =>
|
||||
|
@ -417,14 +417,14 @@
|
|||
else if obj.type == 'folder'
|
||||
folder = obj.id
|
||||
// 移動先が自分自身ならreject
|
||||
if @folder? and folder == @folder.id
|
||||
if this.folder? and folder == this.folder.id
|
||||
return false
|
||||
if (@folders.some (f) => f.id == folder)
|
||||
if (this.folders.some (f) => f.id == folder)
|
||||
return false
|
||||
@remove-folder folder
|
||||
this.api 'drive/folders/update' do
|
||||
folder_id: folder
|
||||
parent_id: if @folder? then @folder.id else null
|
||||
parent_id: if this.folder? then this.folder.id else null
|
||||
.then =>
|
||||
// something
|
||||
.catch (err) =>
|
||||
|
@ -439,7 +439,7 @@
|
|||
return false
|
||||
|
||||
oncontextmenu(e) {
|
||||
e.prevent-default!
|
||||
e.preventDefault();
|
||||
e.stop-immediate-propagation!
|
||||
|
||||
ctx = document.body.appendChild document.createElement 'mk-drive-browser-base-contextmenu'
|
||||
|
@ -464,7 +464,7 @@
|
|||
if url? and url != ''
|
||||
this.api 'drive/files/upload_from_url' do
|
||||
url: url
|
||||
folder_id: if @folder? then @folder.id else undefined
|
||||
folder_id: if this.folder? then this.folder.id else undefined
|
||||
|
||||
@dialog do
|
||||
'<i class="fa fa-check"></i>アップロードをリクエストしました'
|
||||
|
@ -481,7 +481,7 @@
|
|||
|
||||
this.api 'drive/folders/create' do
|
||||
name: name
|
||||
folder_id: if @folder? then @folder.id else undefined
|
||||
folder_id: if this.folder? then this.folder.id else undefined
|
||||
.then (folder) =>
|
||||
@add-folder folder, true
|
||||
this.update();
|
||||
|
@ -492,7 +492,7 @@
|
|||
files = this.refs.file-input.files
|
||||
for i from 0 to files.length - 1
|
||||
file = files.item i
|
||||
@upload file, @folder
|
||||
@upload file, this.folder
|
||||
|
||||
upload(file, folder) {
|
||||
if folder? and typeof folder == 'object'
|
||||
|
@ -500,7 +500,7 @@
|
|||
this.refs.uploader.upload file, folder
|
||||
|
||||
get-selection() {
|
||||
@files.filter (file) -> file._selected
|
||||
this.files.filter (file) -> file._selected
|
||||
|
||||
new-window(folder-id) {
|
||||
browser = document.body.appendChild document.createElement 'mk-drive-browser-window'
|
||||
|
@ -538,55 +538,55 @@
|
|||
console.error err
|
||||
|
||||
add-folder(folder, unshift = false) {
|
||||
current = if @folder? then @folder.id else null
|
||||
current = if this.folder? then this.folder.id else null
|
||||
if current != folder.parent_id
|
||||
return
|
||||
|
||||
if (@folders.some (f) => f.id == folder.id)
|
||||
exist = (@folders.map (f) -> f.id).index-of folder.id
|
||||
@folders[exist] = folder
|
||||
if (this.folders.some (f) => f.id == folder.id)
|
||||
exist = (this.folders.map (f) -> f.id).index-of folder.id
|
||||
this.folders[exist] = folder
|
||||
this.update();
|
||||
return
|
||||
|
||||
if unshift
|
||||
@folders.unshift folder
|
||||
this.folders.unshift folder
|
||||
else
|
||||
@folders.push folder
|
||||
this.folders.push folder
|
||||
|
||||
this.update();
|
||||
|
||||
add-file(file, unshift = false) {
|
||||
current = if @folder? then @folder.id else null
|
||||
current = if this.folder? then this.folder.id else null
|
||||
if current != file.folder_id
|
||||
return
|
||||
|
||||
if (@files.some (f) => f.id == file.id)
|
||||
exist = (@files.map (f) -> f.id).index-of file.id
|
||||
@files[exist] = file
|
||||
if (this.files.some (f) => f.id == file.id)
|
||||
exist = (this.files.map (f) -> f.id).index-of file.id
|
||||
this.files[exist] = file
|
||||
this.update();
|
||||
return
|
||||
|
||||
if unshift
|
||||
@files.unshift file
|
||||
this.files.unshift file
|
||||
else
|
||||
@files.push file
|
||||
this.files.push file
|
||||
|
||||
this.update();
|
||||
|
||||
remove-folder(folder) {
|
||||
if typeof folder == 'object'
|
||||
folder = folder.id
|
||||
this.folders = @folders.filter (f) -> f.id != folder
|
||||
this.folders = this.folders.filter (f) -> f.id != folder
|
||||
this.update();
|
||||
|
||||
remove-file(file) {
|
||||
if typeof file == 'object'
|
||||
file = file.id
|
||||
this.files = @files.filter (f) -> f.id != file
|
||||
this.files = this.files.filter (f) -> f.id != file
|
||||
this.update();
|
||||
|
||||
go-root() {
|
||||
if @folder != null
|
||||
if this.folder != null
|
||||
this.folder = null
|
||||
this.hierarchy-folders = []
|
||||
this.update();
|
||||
|
@ -608,7 +608,7 @@
|
|||
|
||||
// フォルダ一覧取得
|
||||
this.api 'drive/folders' do
|
||||
folder_id: if @folder? then @folder.id else null
|
||||
folder_id: if this.folder? then this.folder.id else null
|
||||
limit: folders-max + 1
|
||||
.then (folders) =>
|
||||
if folders.length == folders-max + 1
|
||||
|
@ -621,7 +621,7 @@
|
|||
|
||||
// ファイル一覧取得
|
||||
this.api 'drive/files' do
|
||||
folder_id: if @folder? then @folder.id else null
|
||||
folder_id: if this.folder? then this.folder.id else null
|
||||
limit: files-max + 1
|
||||
.then (files) =>
|
||||
if files.length == files-max + 1
|
||||
|
@ -645,11 +645,11 @@
|
|||
flag := true
|
||||
|
||||
function contains(parent, child)
|
||||
node = child.parent-node
|
||||
node = child.parentNode
|
||||
while node?
|
||||
if node == parent
|
||||
return true
|
||||
node = node.parent-node
|
||||
node = node.parentNode
|
||||
return false
|
||||
</script>
|
||||
</mk-drive-browser>
|
||||
|
|
|
@ -63,10 +63,10 @@
|
|||
name <~ @input-dialog do
|
||||
'ファイル名の変更'
|
||||
'新しいファイル名を入力してください'
|
||||
@file.name
|
||||
this.file.name
|
||||
|
||||
this.api 'drive/files/update' do
|
||||
file_id: @file.id
|
||||
file_id: this.file.id
|
||||
name: name
|
||||
.then =>
|
||||
// something
|
||||
|
@ -81,15 +81,15 @@
|
|||
|
||||
set-avatar() {
|
||||
this.refs.ctx.close!
|
||||
@update-avatar this.I, null, @file
|
||||
@update-avatar this.I, null, this.file
|
||||
|
||||
set-banner() {
|
||||
this.refs.ctx.close!
|
||||
@update-banner this.I, null, @file
|
||||
@update-banner this.I, null, this.file
|
||||
|
||||
set-wallpaper() {
|
||||
this.refs.ctx.close!
|
||||
@update-wallpaper this.I, null, @file
|
||||
@update-wallpaper this.I, null, this.file
|
||||
|
||||
add-app() {
|
||||
@NotImplementedException!
|
||||
|
|
|
@ -144,43 +144,43 @@
|
|||
|
||||
</style>
|
||||
<script>
|
||||
this.bytes-to-size = require('../../../common/scripts/bytes-to-size.js');
|
||||
this.bytesToSize = require('../../../common/scripts/bytesToSize.js');
|
||||
|
||||
this.mixin('i');
|
||||
|
||||
this.file = this.opts.file
|
||||
this.browser = this.parent
|
||||
|
||||
this.title = @file.name + '\n' + @file.type + ' ' + (@bytes-to-size @file.datasize)
|
||||
this.title = this.file.name + '\n' + this.file.type + ' ' + (@bytesToSize this.file.datasize)
|
||||
|
||||
this.is-contextmenu-showing = false
|
||||
|
||||
onclick() {
|
||||
if @browser.multiple
|
||||
if @file._selected?
|
||||
@file._selected = !@file._selected
|
||||
if this.browser.multiple
|
||||
if this.file._selected?
|
||||
this.file._selected = !this.file._selected
|
||||
else
|
||||
@file._selected = true
|
||||
@browser.trigger 'change-selection' @browser.get-selection!
|
||||
this.file._selected = true
|
||||
this.browser.trigger 'change-selection' this.browser.get-selection!
|
||||
else
|
||||
if @file._selected
|
||||
@browser.trigger 'selected' @file
|
||||
if this.file._selected
|
||||
this.browser.trigger 'selected' this.file
|
||||
else
|
||||
@browser.files.for-each (file) =>
|
||||
this.browser.files.for-each (file) =>
|
||||
file._selected = false
|
||||
@file._selected = true
|
||||
@browser.trigger 'change-selection' @file
|
||||
this.file._selected = true
|
||||
this.browser.trigger 'change-selection' this.file
|
||||
|
||||
oncontextmenu(e) {
|
||||
e.prevent-default!
|
||||
e.preventDefault();
|
||||
e.stop-immediate-propagation!
|
||||
|
||||
this.is-contextmenu-showing = true
|
||||
this.update();
|
||||
ctx = document.body.appendChild document.createElement 'mk-drive-browser-file-contextmenu'
|
||||
ctx = riot.mount ctx, do
|
||||
browser: @browser
|
||||
file: @file
|
||||
browser: this.browser
|
||||
file: this.file
|
||||
ctx = ctx.0
|
||||
ctx.open do
|
||||
x: e.page-x - window.page-x-offset
|
||||
|
@ -191,19 +191,19 @@
|
|||
return false
|
||||
|
||||
ondragstart(e) {
|
||||
e.data-transfer.effect-allowed = 'move'
|
||||
e.data-transfer.set-data 'text' JSON.stringify do
|
||||
e.dataTransfer.effect-allowed = 'move'
|
||||
e.dataTransfer.set-data 'text' JSON.stringify do
|
||||
type: 'file'
|
||||
id: @file.id
|
||||
file: @file
|
||||
id: this.file.id
|
||||
file: this.file
|
||||
this.is-dragging = true
|
||||
|
||||
// 親ブラウザに対して、ドラッグが開始されたフラグを立てる
|
||||
// (=あなたの子供が、ドラッグを開始しましたよ)
|
||||
@browser.is-drag-source = true
|
||||
this.browser.is-drag-source = true
|
||||
|
||||
ondragend(e) {
|
||||
this.is-dragging = false
|
||||
@browser.is-drag-source = false
|
||||
this.browser.is-drag-source = false
|
||||
</script>
|
||||
</mk-drive-browser-file>
|
||||
|
|
|
@ -32,19 +32,19 @@
|
|||
this.unmount();
|
||||
|
||||
move() {
|
||||
@browser.move @folder.id
|
||||
this.browser.move this.folder.id
|
||||
this.refs.ctx.close!
|
||||
|
||||
new-window() {
|
||||
@browser.new-window @folder.id
|
||||
this.browser.new-window this.folder.id
|
||||
this.refs.ctx.close!
|
||||
|
||||
create-folder() {
|
||||
@browser.create-folder!
|
||||
this.browser.create-folder!
|
||||
this.refs.ctx.close!
|
||||
|
||||
upload() {
|
||||
@browser.select-lcoal-file!
|
||||
this.browser.select-lcoal-file!
|
||||
this.refs.ctx.close!
|
||||
|
||||
rename() {
|
||||
|
@ -53,10 +53,10 @@
|
|||
name <~ @input-dialog do
|
||||
'フォルダ名の変更'
|
||||
'新しいフォルダ名を入力してください'
|
||||
@folder.name
|
||||
this.folder.name
|
||||
|
||||
this.api 'drive/folders/update' do
|
||||
folder_id: @folder.id
|
||||
folder_id: this.folder.id
|
||||
name: name
|
||||
.then =>
|
||||
// something
|
||||
|
|
|
@ -56,13 +56,13 @@
|
|||
this.folder = this.opts.folder
|
||||
this.browser = this.parent
|
||||
|
||||
this.title = @folder.name
|
||||
this.title = this.folder.name
|
||||
this.hover = false
|
||||
this.draghover = false
|
||||
this.is-contextmenu-showing = false
|
||||
|
||||
onclick() {
|
||||
@browser.move @folder
|
||||
this.browser.move this.folder
|
||||
|
||||
onmouseover() {
|
||||
this.hover = true
|
||||
|
@ -71,19 +71,19 @@
|
|||
this.hover = false
|
||||
|
||||
ondragover(e) {
|
||||
e.prevent-default!
|
||||
e.stop-propagation!
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
// 自分自身がドラッグされていない場合
|
||||
if !@is-dragging
|
||||
// ドラッグされてきたものがファイルだったら
|
||||
if e.data-transfer.effect-allowed == 'all'
|
||||
e.data-transfer.drop-effect = 'copy'
|
||||
if e.dataTransfer.effect-allowed == 'all'
|
||||
e.dataTransfer.dropEffect = 'copy'
|
||||
else
|
||||
e.data-transfer.drop-effect = 'move'
|
||||
e.dataTransfer.dropEffect = 'move'
|
||||
else
|
||||
// 自分自身にはドロップさせない
|
||||
e.data-transfer.drop-effect = 'none'
|
||||
e.dataTransfer.dropEffect = 'none'
|
||||
return false
|
||||
|
||||
ondragenter() {
|
||||
|
@ -94,17 +94,17 @@
|
|||
this.draghover = false
|
||||
|
||||
ondrop(e) {
|
||||
e.stop-propagation!
|
||||
e.stopPropagation();
|
||||
this.draghover = false
|
||||
|
||||
// ファイルだったら
|
||||
if e.data-transfer.files.length > 0
|
||||
Array.prototype.for-each.call e.data-transfer.files, (file) =>
|
||||
@browser.upload file, @folder
|
||||
if e.dataTransfer.files.length > 0
|
||||
Array.prototype.for-each.call e.dataTransfer.files, (file) =>
|
||||
this.browser.upload file, this.folder
|
||||
return false
|
||||
|
||||
// データ取得
|
||||
data = e.data-transfer.get-data 'text'
|
||||
data = e.dataTransfer.get-data 'text'
|
||||
if !data?
|
||||
return false
|
||||
|
||||
|
@ -114,10 +114,10 @@
|
|||
// (ドライブの)ファイルだったら
|
||||
if obj.type == 'file'
|
||||
file = obj.id
|
||||
@browser.remove-file file
|
||||
this.browser.remove-file file
|
||||
this.api 'drive/files/update' do
|
||||
file_id: file
|
||||
folder_id: @folder.id
|
||||
folder_id: this.folder.id
|
||||
.then =>
|
||||
// something
|
||||
.catch (err, text-status) =>
|
||||
|
@ -127,12 +127,12 @@
|
|||
else if obj.type == 'folder'
|
||||
folder = obj.id
|
||||
// 移動先が自分自身ならreject
|
||||
if folder == @folder.id
|
||||
if folder == this.folder.id
|
||||
return false
|
||||
@browser.remove-folder folder
|
||||
this.browser.remove-folder folder
|
||||
this.api 'drive/folders/update' do
|
||||
folder_id: folder
|
||||
parent_id: @folder.id
|
||||
parent_id: this.folder.id
|
||||
.then =>
|
||||
// something
|
||||
.catch (err) =>
|
||||
|
@ -147,30 +147,30 @@
|
|||
return false
|
||||
|
||||
ondragstart(e) {
|
||||
e.data-transfer.effect-allowed = 'move'
|
||||
e.data-transfer.set-data 'text' JSON.stringify do
|
||||
e.dataTransfer.effect-allowed = 'move'
|
||||
e.dataTransfer.set-data 'text' JSON.stringify do
|
||||
type: 'folder'
|
||||
id: @folder.id
|
||||
id: this.folder.id
|
||||
this.is-dragging = true
|
||||
|
||||
// 親ブラウザに対して、ドラッグが開始されたフラグを立てる
|
||||
// (=あなたの子供が、ドラッグを開始しましたよ)
|
||||
@browser.is-drag-source = true
|
||||
this.browser.is-drag-source = true
|
||||
|
||||
ondragend(e) {
|
||||
this.is-dragging = false
|
||||
@browser.is-drag-source = false
|
||||
this.browser.is-drag-source = false
|
||||
|
||||
oncontextmenu(e) {
|
||||
e.prevent-default!
|
||||
e.preventDefault();
|
||||
e.stop-immediate-propagation!
|
||||
|
||||
this.is-contextmenu-showing = true
|
||||
this.update();
|
||||
ctx = document.body.appendChild document.createElement 'mk-drive-browser-folder-contextmenu'
|
||||
ctx = riot.mount ctx, do
|
||||
browser: @browser
|
||||
folder: @folder
|
||||
browser: this.browser
|
||||
folder: this.folder
|
||||
ctx = ctx.0
|
||||
ctx.open do
|
||||
x: e.page-x - window.page-x-offset
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
this.hover = false
|
||||
|
||||
onclick() {
|
||||
@browser.move @folder
|
||||
this.browser.move this.folder
|
||||
|
||||
onmouseover() {
|
||||
this.hover = true
|
||||
|
@ -26,39 +26,39 @@
|
|||
this.hover = false
|
||||
|
||||
ondragover(e) {
|
||||
e.prevent-default!
|
||||
e.stop-propagation!
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
// このフォルダがルートかつカレントディレクトリならドロップ禁止
|
||||
if @folder == null and @browser.folder == null
|
||||
e.data-transfer.drop-effect = 'none'
|
||||
if this.folder == null and this.browser.folder == null
|
||||
e.dataTransfer.dropEffect = 'none'
|
||||
// ドラッグされてきたものがファイルだったら
|
||||
else if e.data-transfer.effect-allowed == 'all'
|
||||
e.data-transfer.drop-effect = 'copy'
|
||||
else if e.dataTransfer.effect-allowed == 'all'
|
||||
e.dataTransfer.dropEffect = 'copy'
|
||||
else
|
||||
e.data-transfer.drop-effect = 'move'
|
||||
e.dataTransfer.dropEffect = 'move'
|
||||
return false
|
||||
|
||||
ondragenter() {
|
||||
if @folder != null or @browser.folder != null
|
||||
if this.folder != null or this.browser.folder != null
|
||||
this.draghover = true
|
||||
|
||||
ondragleave() {
|
||||
if @folder != null or @browser.folder != null
|
||||
if this.folder != null or this.browser.folder != null
|
||||
this.draghover = false
|
||||
|
||||
ondrop(e) {
|
||||
e.stop-propagation!
|
||||
e.stopPropagation();
|
||||
this.draghover = false
|
||||
|
||||
// ファイルだったら
|
||||
if e.data-transfer.files.length > 0
|
||||
Array.prototype.for-each.call e.data-transfer.files, (file) =>
|
||||
@browser.upload file, @folder
|
||||
if e.dataTransfer.files.length > 0
|
||||
Array.prototype.for-each.call e.dataTransfer.files, (file) =>
|
||||
this.browser.upload file, this.folder
|
||||
return false
|
||||
|
||||
// データ取得
|
||||
data = e.data-transfer.get-data 'text'
|
||||
data = e.dataTransfer.get-data 'text'
|
||||
if !data?
|
||||
return false
|
||||
|
||||
|
@ -68,10 +68,10 @@
|
|||
// (ドライブの)ファイルだったら
|
||||
if obj.type == 'file'
|
||||
file = obj.id
|
||||
@browser.remove-file file
|
||||
this.browser.remove-file file
|
||||
this.api 'drive/files/update' do
|
||||
file_id: file
|
||||
folder_id: if @folder? then @folder.id else null
|
||||
folder_id: if this.folder? then this.folder.id else null
|
||||
.then =>
|
||||
// something
|
||||
.catch (err, text-status) =>
|
||||
|
@ -81,12 +81,12 @@
|
|||
else if obj.type == 'folder'
|
||||
folder = obj.id
|
||||
// 移動先が自分自身ならreject
|
||||
if @folder? and folder == @folder.id
|
||||
if this.folder? and folder == this.folder.id
|
||||
return false
|
||||
@browser.remove-folder folder
|
||||
this.browser.remove-folder folder
|
||||
this.api 'drive/folders/update' do
|
||||
folder_id: folder
|
||||
parent_id: if @folder? then @folder.id else null
|
||||
parent_id: if this.folder? then this.folder.id else null
|
||||
.then =>
|
||||
// something
|
||||
.catch (err, text-status) =>
|
||||
|
|
|
@ -150,8 +150,8 @@
|
|||
|
||||
on-keydown(e) {
|
||||
if e.which == 13 // Enter
|
||||
e.prevent-default!
|
||||
e.stop-propagation!
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
@ok!
|
||||
</script>
|
||||
</mk-input-dialog>
|
||||
|
|
|
@ -345,13 +345,13 @@
|
|||
this.update();
|
||||
|
||||
ondragover(e) {
|
||||
e.stop-propagation!
|
||||
e.stopPropagation();
|
||||
this.draghover = true
|
||||
// ドラッグされてきたものがファイルだったら
|
||||
if e.data-transfer.effect-allowed == 'all'
|
||||
e.data-transfer.drop-effect = 'copy'
|
||||
if e.dataTransfer.effect-allowed == 'all'
|
||||
e.dataTransfer.dropEffect = 'copy'
|
||||
else
|
||||
e.data-transfer.drop-effect = 'move'
|
||||
e.dataTransfer.dropEffect = 'move'
|
||||
return false
|
||||
|
||||
ondragenter(e) {
|
||||
|
@ -361,18 +361,18 @@
|
|||
this.draghover = false
|
||||
|
||||
ondrop(e) {
|
||||
e.prevent-default!
|
||||
e.stop-propagation!
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.draghover = false
|
||||
|
||||
// ファイルだったら
|
||||
if e.data-transfer.files.length > 0
|
||||
Array.prototype.for-each.call e.data-transfer.files, (file) =>
|
||||
if e.dataTransfer.files.length > 0
|
||||
Array.prototype.for-each.call e.dataTransfer.files, (file) =>
|
||||
@upload file
|
||||
return false
|
||||
|
||||
// データ取得
|
||||
data = e.data-transfer.get-data 'text'
|
||||
data = e.dataTransfer.get-data 'text'
|
||||
if !data?
|
||||
return false
|
||||
|
||||
|
@ -422,12 +422,12 @@
|
|||
|
||||
add-file(file) {
|
||||
file._remove = =>
|
||||
this.files = @files.filter (x) -> x.id != file.id
|
||||
this.trigger 'change-files' @files
|
||||
this.files = this.files.filter (x) -> x.id != file.id
|
||||
this.trigger 'change-files' this.files
|
||||
this.update();
|
||||
|
||||
@files.push file
|
||||
this.trigger 'change-files' @files
|
||||
this.files.push file
|
||||
this.trigger 'change-files' this.files
|
||||
this.update();
|
||||
|
||||
add-poll() {
|
||||
|
@ -440,8 +440,8 @@
|
|||
post(e) {
|
||||
this.wait = true
|
||||
|
||||
files = if @files? and @files.length > 0
|
||||
then @files.map (f) -> f.id
|
||||
files = if this.files? and this.files.length > 0
|
||||
then this.files.map (f) -> f.id
|
||||
else undefined
|
||||
|
||||
this.api 'posts/create' do
|
||||
|
|
|
@ -155,7 +155,7 @@
|
|||
this.refs.window.refs.browser.select-local-file!
|
||||
|
||||
ok() {
|
||||
this.trigger 'selected' @file
|
||||
this.trigger 'selected' this.file
|
||||
this.refs.window.close!
|
||||
</script>
|
||||
</mk-select-file-from-drive-window>
|
||||
|
|
|
@ -38,8 +38,8 @@
|
|||
@update-avatar this.I
|
||||
|
||||
close(e) {
|
||||
e.prevent-default!
|
||||
e.stop-propagation!
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.unmount();
|
||||
</script>
|
||||
</mk-set-avatar-suggestion>
|
||||
|
|
|
@ -38,8 +38,8 @@
|
|||
@update-banner this.I
|
||||
|
||||
close(e) {
|
||||
e.prevent-default!
|
||||
e.stop-propagation!
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.unmount();
|
||||
</script>
|
||||
</mk-set-banner-suggestion>
|
||||
|
|
|
@ -394,7 +394,7 @@
|
|||
should-be-cancel = false
|
||||
|
||||
if should-be-cancel
|
||||
e.prevent-default!
|
||||
e.preventDefault();
|
||||
|
||||
function focus(el, fn)
|
||||
target = fn el
|
||||
|
|
|
@ -188,7 +188,7 @@
|
|||
el.remove-event-listener 'mousedown' @mousedown
|
||||
|
||||
mousedown(e) {
|
||||
e.prevent-default!
|
||||
e.preventDefault();
|
||||
if (!contains this.root, e.target) and (this.root != e.target)
|
||||
@close!
|
||||
return false
|
||||
|
@ -202,11 +202,11 @@
|
|||
riot.mount document.body.appendChild document.createElement 'mk-settings-window'
|
||||
|
||||
function contains(parent, child)
|
||||
node = child.parent-node
|
||||
node = child.parentNode
|
||||
while node?
|
||||
if node == parent
|
||||
return true
|
||||
node = node.parent-node
|
||||
node = node.parentNode
|
||||
return false
|
||||
</script>
|
||||
</mk-ui-header-account>
|
||||
|
|
|
@ -98,17 +98,17 @@
|
|||
el.remove-event-listener 'mousedown' @mousedown
|
||||
|
||||
mousedown(e) {
|
||||
e.prevent-default!
|
||||
e.preventDefault();
|
||||
if (!contains this.root, e.target) and (this.root != e.target)
|
||||
@close!
|
||||
return false
|
||||
|
||||
function contains(parent, child)
|
||||
node = child.parent-node
|
||||
node = child.parentNode
|
||||
while node?
|
||||
if node == parent
|
||||
return true
|
||||
node = node.parent-node
|
||||
node = node.parentNode
|
||||
return false
|
||||
</script>
|
||||
</mk-ui-header-notifications>
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
this.mixin('page');
|
||||
|
||||
onsubmit(e) {
|
||||
e.prevent-default!
|
||||
e.preventDefault();
|
||||
@page '/search:' + this.refs.q.value
|
||||
</script>
|
||||
</mk-ui-header-search>
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
tag = e.target.tag-name.to-lower-case!
|
||||
if tag != 'input' and tag != 'textarea'
|
||||
if e.which == 80 or e.which == 78 // p or n
|
||||
e.prevent-default!
|
||||
e.preventDefault();
|
||||
@open-post-form!
|
||||
</script>
|
||||
</mk-ui>
|
||||
|
|
|
@ -208,7 +208,7 @@
|
|||
this.refs.main.style.left = (window.inner-width / 2) - (this.refs.main.offset-width / 2) + 'px'
|
||||
|
||||
this.refs.header.add-event-listener 'contextmenu' (e) =>
|
||||
e.prevent-default!
|
||||
e.preventDefault();
|
||||
|
||||
window.add-event-listener 'resize' this.on-browser-resize
|
||||
|
||||
|
@ -315,7 +315,7 @@
|
|||
if @is-modal then this.refs.bg.style.z-index = z + 1
|
||||
|
||||
repel-move(e) {
|
||||
e.stop-propagation!
|
||||
e.stopPropagation();
|
||||
return true
|
||||
|
||||
bg-click() {
|
||||
|
@ -328,7 +328,7 @@
|
|||
|
||||
// ヘッダー掴み時
|
||||
on-header-mousedown(e) {
|
||||
e.prevent-default!
|
||||
e.preventDefault();
|
||||
|
||||
if not contains this.refs.main, document.active-element
|
||||
this.refs.main.focus();
|
||||
|
@ -370,7 +370,7 @@
|
|||
|
||||
// 上ハンドル掴み時
|
||||
on-top-handle-mousedown(e) {
|
||||
e.prevent-default!
|
||||
e.preventDefault();
|
||||
|
||||
base = e.client-y
|
||||
height = parse-int((get-computed-style this.refs.main, '').height, 10)
|
||||
|
@ -392,7 +392,7 @@
|
|||
|
||||
// 右ハンドル掴み時
|
||||
on-right-handle-mousedown(e) {
|
||||
e.prevent-default!
|
||||
e.preventDefault();
|
||||
|
||||
base = e.client-x
|
||||
width = parse-int((get-computed-style this.refs.main, '').width, 10)
|
||||
|
@ -412,7 +412,7 @@
|
|||
|
||||
// 下ハンドル掴み時
|
||||
on-bottom-handle-mousedown(e) {
|
||||
e.prevent-default!
|
||||
e.preventDefault();
|
||||
|
||||
base = e.client-y
|
||||
height = parse-int((get-computed-style this.refs.main, '').height, 10)
|
||||
|
@ -432,7 +432,7 @@
|
|||
|
||||
// 左ハンドル掴み時
|
||||
on-left-handle-mousedown(e) {
|
||||
e.prevent-default!
|
||||
e.preventDefault();
|
||||
|
||||
base = e.client-x
|
||||
width = parse-int((get-computed-style this.refs.main, '').width, 10)
|
||||
|
@ -499,21 +499,21 @@
|
|||
window.remove-event-listener 'mouseup' drag-clear
|
||||
|
||||
ondragover(e) {
|
||||
e.data-transfer.drop-effect = 'none'
|
||||
e.dataTransfer.dropEffect = 'none'
|
||||
|
||||
on-keydown(e) {
|
||||
if e.which == 27 // Esc
|
||||
if @can-close
|
||||
e.prevent-default!
|
||||
e.stop-propagation!
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
@close!
|
||||
|
||||
function contains(parent, child)
|
||||
node = child.parent-node
|
||||
node = child.parentNode
|
||||
while node?
|
||||
if node == parent
|
||||
return true
|
||||
node = node.parent-node
|
||||
node = node.parentNode
|
||||
return false
|
||||
</script>
|
||||
</mk-window>
|
||||
|
|
|
@ -238,6 +238,6 @@
|
|||
.catch =>
|
||||
alert 'アプリの作成に失敗しました。再度お試しください。'
|
||||
|
||||
locker.parent-node.remove-child locker
|
||||
locker.parentNode.removeChild locker
|
||||
</script>
|
||||
</mk-new-app-form>
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
this.unmount();
|
||||
|
||||
ok() {
|
||||
this.trigger 'selected' @files
|
||||
this.trigger 'selected' this.files
|
||||
this.unmount();
|
||||
</script>
|
||||
</mk-drive-selector>
|
||||
|
|
|
@ -171,7 +171,7 @@
|
|||
@add-file file, true
|
||||
|
||||
on-stream-drive-file-updated(file) {
|
||||
current = if @folder? then @folder.id else null
|
||||
current = if this.folder? then this.folder.id else null
|
||||
if current != file.folder_id
|
||||
@remove-file file
|
||||
else
|
||||
|
@ -181,7 +181,7 @@
|
|||
@add-folder folder, true
|
||||
|
||||
on-stream-drive-folder-updated(folder) {
|
||||
current = if @folder? then @folder.id else null
|
||||
current = if this.folder? then this.folder.id else null
|
||||
if current != folder.parent_id
|
||||
@remove-folder folder
|
||||
else
|
||||
|
@ -221,58 +221,58 @@
|
|||
x folder.parent
|
||||
|
||||
this.update();
|
||||
this.trigger 'open-folder' @folder, silent
|
||||
this.trigger 'open-folder' this.folder, silent
|
||||
@load!
|
||||
.catch (err, text-status) ->
|
||||
console.error err
|
||||
|
||||
add-folder(folder, unshift = false) {
|
||||
current = if @folder? then @folder.id else null
|
||||
current = if this.folder? then this.folder.id else null
|
||||
if current != folder.parent_id
|
||||
return
|
||||
|
||||
if (@folders.some (f) => f.id == folder.id)
|
||||
if (this.folders.some (f) => f.id == folder.id)
|
||||
return
|
||||
|
||||
if unshift
|
||||
@folders.unshift folder
|
||||
this.folders.unshift folder
|
||||
else
|
||||
@folders.push folder
|
||||
this.folders.push folder
|
||||
|
||||
this.update();
|
||||
|
||||
add-file(file, unshift = false) {
|
||||
current = if @folder? then @folder.id else null
|
||||
current = if this.folder? then this.folder.id else null
|
||||
if current != file.folder_id
|
||||
return
|
||||
|
||||
if (@files.some (f) => f.id == file.id)
|
||||
exist = (@files.map (f) -> f.id).index-of file.id
|
||||
@files[exist] = file
|
||||
if (this.files.some (f) => f.id == file.id)
|
||||
exist = (this.files.map (f) -> f.id).index-of file.id
|
||||
this.files[exist] = file
|
||||
this.update();
|
||||
return
|
||||
|
||||
if unshift
|
||||
@files.unshift file
|
||||
this.files.unshift file
|
||||
else
|
||||
@files.push file
|
||||
this.files.push file
|
||||
|
||||
this.update();
|
||||
|
||||
remove-folder(folder) {
|
||||
if typeof folder == 'object'
|
||||
folder = folder.id
|
||||
this.folders = @folders.filter (f) -> f.id != folder
|
||||
this.folders = this.folders.filter (f) -> f.id != folder
|
||||
this.update();
|
||||
|
||||
remove-file(file) {
|
||||
if typeof file == 'object'
|
||||
file = file.id
|
||||
this.files = @files.filter (f) -> f.id != file
|
||||
this.files = this.files.filter (f) -> f.id != file
|
||||
this.update();
|
||||
|
||||
go-root() {
|
||||
if @folder != null or @file != null
|
||||
if this.folder != null or this.file != null
|
||||
this.file = null
|
||||
this.folder = null
|
||||
this.hierarchy-folders = []
|
||||
|
@ -298,7 +298,7 @@
|
|||
|
||||
// フォルダ一覧取得
|
||||
this.api 'drive/folders' do
|
||||
folder_id: if @folder? then @folder.id else null
|
||||
folder_id: if this.folder? then this.folder.id else null
|
||||
limit: folders-max + 1
|
||||
.then (folders) =>
|
||||
if folders.length == folders-max + 1
|
||||
|
@ -311,7 +311,7 @@
|
|||
|
||||
// ファイル一覧取得
|
||||
this.api 'drive/files' do
|
||||
folder_id: if @folder? then @folder.id else null
|
||||
folder_id: if this.folder? then this.folder.id else null
|
||||
limit: files-max + 1
|
||||
.then (files) =>
|
||||
if files.length == files-max + 1
|
||||
|
@ -372,6 +372,6 @@
|
|||
x file.folder
|
||||
|
||||
this.update();
|
||||
this.trigger 'open-file' @file, silent
|
||||
this.trigger 'open-file' this.file, silent
|
||||
</script>
|
||||
</mk-drive>
|
||||
|
|
|
@ -180,22 +180,22 @@
|
|||
|
||||
</style>
|
||||
<script>
|
||||
this.bytes-to-size = require('../../../common/scripts/bytes-to-size.js');
|
||||
this.get-gcd = require('../../../common/scripts/gcd.js');
|
||||
this.bytesToSize = require('../../../common/scripts/bytes-to-size.js');
|
||||
this.getGcd = require('../../../common/scripts/gcd.js');
|
||||
|
||||
this.mixin('api');
|
||||
|
||||
this.file = this.opts.file
|
||||
this.kind = @file.type.split '/' .0
|
||||
this.kind = this.file.type.split '/' .0
|
||||
|
||||
rename() {
|
||||
name = window.prompt '名前を変更' @file.name
|
||||
if name? and name != '' and name != @file.name
|
||||
name = window.prompt '名前を変更' this.file.name
|
||||
if name? and name != '' and name != this.file.name
|
||||
this.api 'drive/files/update' do
|
||||
file_id: @file.id
|
||||
file_id: this.file.id
|
||||
name: name
|
||||
.then =>
|
||||
this.parent.cf @file, true
|
||||
this.parent.cf this.file, true
|
||||
|
||||
</script>
|
||||
</mk-drive-file-viewer>
|
||||
|
|
|
@ -122,16 +122,16 @@
|
|||
|
||||
</style>
|
||||
<script>
|
||||
this.bytes-to-size = require('../../../common/scripts/bytes-to-size.js');
|
||||
this.bytesToSize = require('../../../common/scripts/bytesToSize.js');
|
||||
|
||||
this.browser = this.parent
|
||||
this.file = this.opts.file
|
||||
this.is-selected = @browser.selected-files.some (f) => f.id == @file.id
|
||||
this.is-selected = this.browser.selected-files.some (f) => f.id == this.file.id
|
||||
|
||||
@browser.on('change-selected', (selects) => {
|
||||
this.is-selected = selects.some (f) => f.id == @file.id
|
||||
this.browser.on('change-selected', (selects) => {
|
||||
this.is-selected = selects.some (f) => f.id == this.file.id
|
||||
|
||||
onclick() {
|
||||
@browser.choose-file @file
|
||||
this.browser.choose-file this.file
|
||||
</script>
|
||||
</mk-drive-file>
|
||||
|
|
|
@ -41,6 +41,6 @@
|
|||
this.folder = this.opts.folder
|
||||
|
||||
onclick() {
|
||||
@browser.move @folder
|
||||
this.browser.move this.folder
|
||||
</script>
|
||||
</mk-drive-folder>
|
||||
|
|
|
@ -238,12 +238,12 @@
|
|||
|
||||
add-file(file) {
|
||||
file._remove = =>
|
||||
this.files = @files.filter (x) -> x.id != file.id
|
||||
this.trigger 'change-files' @files
|
||||
this.files = this.files.filter (x) -> x.id != file.id
|
||||
this.trigger 'change-files' this.files
|
||||
this.update();
|
||||
|
||||
@files.push file
|
||||
this.trigger 'change-files' @files
|
||||
this.files.push file
|
||||
this.trigger 'change-files' this.files
|
||||
this.update();
|
||||
|
||||
add-poll() {
|
||||
|
@ -256,8 +256,8 @@
|
|||
post() {
|
||||
this.wait = true
|
||||
|
||||
files = if @files? and @files.length > 0
|
||||
then @files.map (f) -> f.id
|
||||
files = if this.files? and this.files.length > 0
|
||||
then this.files.map (f) -> f.id
|
||||
else undefined
|
||||
|
||||
this.api 'posts/create' do
|
||||
|
|
Loading…
Reference in a new issue