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

@ -68,7 +68,7 @@
this.unmount();
ok() {
this.trigger 'selected' @files
this.trigger 'selected' this.files
this.unmount();
</script>
</mk-drive-selector>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -41,6 +41,6 @@
this.folder = this.opts.folder
onclick() {
@browser.move @folder
this.browser.move this.folder
</script>
</mk-drive-folder>

View file

@ -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