2018-01-28 23:22:43 +11:00
|
|
|
/*イメージビューワー*/
|
|
|
|
//postのimg.jsとは異なります。
|
2018-02-14 03:19:44 +11:00
|
|
|
function imgv(id, key, acct_id) {
|
2018-04-07 14:31:09 +10:00
|
|
|
$("#imgprog").text(0);
|
2018-09-19 02:41:48 +10:00
|
|
|
$('#imgmodal').hide();
|
2019-02-05 13:33:32 +11:00
|
|
|
$('#imgmodal').attr('src', '../../img/loading.svg');
|
2018-01-28 23:22:43 +11:00
|
|
|
var murl = $("#" + id + "-image-" + key).attr("data-url");
|
|
|
|
var type = $("#" + id + "-image-" + key).attr("data-type");
|
2019-05-19 17:39:30 +10:00
|
|
|
$("#imagemodal").attr("data-id", id);
|
|
|
|
$("#imagemodal").attr("data-acct", acct_id);
|
|
|
|
$(document).ready(function () {
|
2018-01-28 23:22:43 +11:00
|
|
|
if (type == "image") {
|
2019-03-16 02:29:54 +11:00
|
|
|
$('#imagemodal').modal('open');
|
2019-05-19 17:39:30 +10:00
|
|
|
xhr = new XMLHttpRequest;
|
2018-04-07 14:31:09 +10:00
|
|
|
xhr.open('GET', murl, true);
|
|
|
|
xhr.addEventListener('progress', function (event) {
|
2019-05-19 17:39:30 +10:00
|
|
|
if (event.lengthComputable) {
|
|
|
|
var total = event.total;
|
|
|
|
var now = event.loaded;
|
|
|
|
var per = now / total * 100;
|
|
|
|
$("#imgprog").text(Math.floor(per));
|
|
|
|
}
|
2018-04-07 14:31:09 +10:00
|
|
|
}, false);
|
|
|
|
xhr.addEventListener('loadend', function (event) {
|
2019-05-19 17:39:30 +10:00
|
|
|
var total = event.total;
|
|
|
|
var now = event.loaded;
|
|
|
|
var per = now / total * 100;
|
2018-07-07 03:51:48 +10:00
|
|
|
$("#imgprog").text(Math.floor(per));
|
2018-04-07 14:31:09 +10:00
|
|
|
}, false);
|
|
|
|
xhr.send();
|
2018-01-28 23:22:43 +11:00
|
|
|
$('#imgmodal').attr('src', murl);
|
|
|
|
$('#imagewrap').dragScroll(); // ドラッグスクロール設定
|
2018-09-19 02:41:48 +10:00
|
|
|
$('#imgmodal').show();
|
2018-01-28 23:22:43 +11:00
|
|
|
$('#imagemodal').attr('data-key', key);
|
|
|
|
$('#imagemodal').attr('data-id', id);
|
|
|
|
} else if (type == "video" || type == "gifv") {
|
|
|
|
$('#video').attr('src', murl);
|
|
|
|
$('#videomodal').modal('open');
|
2018-09-19 02:41:48 +10:00
|
|
|
$('#imgmodal').show();
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
var element = new Image();
|
|
|
|
var width;
|
2019-05-19 17:39:30 +10:00
|
|
|
element.onload = function () {
|
2018-01-28 23:22:43 +11:00
|
|
|
var width = element.naturalWidth;
|
|
|
|
var height = element.naturalHeight;
|
2018-02-14 03:19:44 +11:00
|
|
|
var windowH = $(window).height();
|
|
|
|
var windowW = $(window).width();
|
2019-05-19 17:39:30 +10:00
|
|
|
$("#imagemodal").css("bottom", "0")
|
|
|
|
$("#imagemodal img").css("width", "auto")
|
|
|
|
if (height < windowH) {
|
|
|
|
$("#imagemodal").css("height", height + 60 + "px")
|
|
|
|
$("#imagemodal img").css("height", "100%")
|
|
|
|
if (width > windowW * 0.8) {
|
|
|
|
$("#imagemodal").css("width", "80vw")
|
|
|
|
$("#imagemodal img").css("width", "100%")
|
|
|
|
var heightS = windowW * 0.8 / width * height;
|
|
|
|
$("#imagemodal").css("height", heightS + 60 + "px")
|
|
|
|
} else {
|
|
|
|
$("#imagemodal").css("width", width + "px")
|
2019-03-16 02:29:54 +11:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
|
|
|
$("#imagemodal img").css("width", "auto")
|
|
|
|
var widthS = windowH / height * width;
|
|
|
|
if (widthS < windowW) {
|
|
|
|
$("#imagemodal").css("width", widthS + "px")
|
|
|
|
} else {
|
|
|
|
$("#imagemodal").css("width", "100vw")
|
2018-02-17 00:08:43 +11:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
|
|
|
$("#imagemodal").css("height", "100vh")
|
|
|
|
$("#imagemodal img").css("height", "calc(100vh - 60px)")
|
2018-02-14 03:19:44 +11:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
if ($("#" + id + "-image-" + (key * 1 + 1)).length == 0) {
|
|
|
|
$("#image-next").prop("disabled", true);
|
2018-01-29 01:01:18 +11:00
|
|
|
} else {
|
|
|
|
$("#image-next").prop("disabled", false);
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
if ($("#" + id + "-image-" + (key * 1 - 1)).length == 0) {
|
|
|
|
$("#image-prev").prop("disabled", true);
|
2018-01-29 01:01:18 +11:00
|
|
|
} else {
|
|
|
|
$("#image-prev").prop("disabled", false);
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
element.src = murl;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
//イメージビューワーの送り
|
|
|
|
function imgCont(type) {
|
2018-04-07 14:31:09 +10:00
|
|
|
$("#imgprog").text(0);
|
2018-01-28 23:22:43 +11:00
|
|
|
var key = $('#imagemodal').attr('data-key');
|
|
|
|
var id = $('#imagemodal').attr('data-id');
|
|
|
|
if (type == "next") {
|
|
|
|
key++;
|
|
|
|
} else if (type == "prev") {
|
|
|
|
key = key * 1 - 1;
|
|
|
|
}
|
|
|
|
var murl = $("#" + id + "-image-" + key).attr("data-url");
|
2019-05-19 17:39:30 +10:00
|
|
|
if (murl) {
|
|
|
|
$('#imgmodal').attr('src', '../../img/loading.svg');
|
|
|
|
var type = $("#" + id + "-image-" + key).attr("data-type");
|
|
|
|
$(document).ready(function () {
|
|
|
|
if (type == "image") {
|
|
|
|
xhr = new XMLHttpRequest;
|
|
|
|
xhr.open('GET', murl, true);
|
|
|
|
xhr.responseType = "arraybuffer";
|
|
|
|
xhr.addEventListener('progress', function (event) {
|
|
|
|
if (event.lengthComputable) {
|
|
|
|
var total = event.total;
|
|
|
|
var now = event.loaded;
|
|
|
|
var per = now / total * 100;
|
|
|
|
$("#imgprog").text(Math.floor(per));
|
|
|
|
}
|
|
|
|
}, false);
|
|
|
|
xhr.addEventListener('loadend', function (event) {
|
|
|
|
var total = event.total;
|
|
|
|
var now = event.loaded;
|
|
|
|
var per = now / total * 100;
|
|
|
|
$("#imgprog").text(Math.floor(per));
|
|
|
|
}, false);
|
|
|
|
xhr.send();
|
|
|
|
$('#imgmodal').attr('src', murl);
|
|
|
|
$('#imagewrap').dragScroll(); // ドラッグスクロール設定
|
|
|
|
$('#imagemodal').attr('data-key', key);
|
|
|
|
$('#imagemodal').attr('data-id', id);
|
|
|
|
} else if (type == "video" || type == "gifv") {
|
|
|
|
$('#video').attr('src', murl);
|
|
|
|
$('#videomodal').modal('open');
|
|
|
|
}
|
|
|
|
var element = new Image();
|
|
|
|
var width;
|
|
|
|
element.onload = function () {
|
|
|
|
var width = element.naturalWidth;
|
|
|
|
var height = element.naturalHeight;
|
|
|
|
var windowH = $(window).height();
|
|
|
|
var windowW = $(window).width();
|
|
|
|
$("#imagemodal").css("bottom", "0")
|
|
|
|
$("#imagemodal img").css("width", "auto")
|
|
|
|
if (height < windowH) {
|
|
|
|
$("#imagemodal").css("height", height + 60 + "px")
|
|
|
|
$("#imagemodal img").css("height", "100%")
|
|
|
|
if (width > windowW * 0.8) {
|
|
|
|
$("#imagemodal").css("width", "80vw")
|
|
|
|
$("#imagemodal img").css("width", "100%")
|
|
|
|
var heightS = windowW * 0.8 / width * height;
|
|
|
|
$("#imagemodal").css("height", heightS + 60 + "px")
|
|
|
|
} else {
|
|
|
|
$("#imagemodal").css("width", width + "px")
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$("#imagemodal img").css("width", "auto")
|
|
|
|
var widthS = windowH / height * width;
|
|
|
|
if (widthS < windowW) {
|
|
|
|
$("#imagemodal").css("width", widthS + "px")
|
|
|
|
} else {
|
|
|
|
$("#imagemodal").css("width", "100vw")
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#imagemodal").css("height", "100vh")
|
|
|
|
$("#imagemodal img").css("height", "calc(100vh - 60px)")
|
2018-02-17 00:08:43 +11:00
|
|
|
}
|
2018-02-14 03:19:44 +11:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
if ($("#" + id + "-image-" + (key * 1 + 1)).length === 0) {
|
|
|
|
$("#image-next").prop("disabled", true);
|
|
|
|
} else {
|
|
|
|
$("#image-next").prop("disabled", false);
|
|
|
|
}
|
|
|
|
if ($("#" + id + "-image-" + (key * 1 - 1)).length === 0) {
|
|
|
|
$("#image-prev").prop("disabled", true);
|
|
|
|
} else {
|
|
|
|
$("#image-prev").prop("disabled", false);
|
|
|
|
}
|
|
|
|
element.src = murl;
|
|
|
|
|
|
|
|
});
|
2018-01-29 01:01:18 +11:00
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
//ズームボタン(z:倍率)
|
|
|
|
function zoom(z) {
|
|
|
|
var wdth = $('#imagewrap img').width();
|
|
|
|
var wdth = wdth * z;
|
2019-05-19 17:39:30 +10:00
|
|
|
$('#imagewrap img').css("width", wdth + "px");
|
2018-02-14 03:19:44 +11:00
|
|
|
var hgt = $('#imagewrap img').height();
|
|
|
|
var hgt = hgt * z;
|
2019-05-19 17:39:30 +10:00
|
|
|
$('#imagewrap img').css("height", hgt + "px");
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
//スマホ対応ドラッグ移動システム
|
2019-05-19 17:39:30 +10:00
|
|
|
(function () {
|
|
|
|
$.fn.dragScroll = function () {
|
2018-01-28 23:22:43 +11:00
|
|
|
var target = this;
|
2019-05-19 17:39:30 +10:00
|
|
|
$(this).mousedown(function (event) {
|
2018-01-28 23:22:43 +11:00
|
|
|
$(this)
|
|
|
|
.data('down', true)
|
|
|
|
.data('x', event.clientX)
|
|
|
|
.data('y', event.clientY)
|
|
|
|
.data('scrollLeft', this.scrollLeft)
|
|
|
|
.data('scrollTop', this.scrollTop);
|
|
|
|
return false;
|
|
|
|
}).css({
|
|
|
|
'overflow': 'hidden', // スクロールバー非表示
|
|
|
|
'cursor': 'move'
|
|
|
|
});
|
|
|
|
// ウィンドウから外れてもイベント実行
|
2019-05-19 17:39:30 +10:00
|
|
|
$(document).mousemove(function (event) {
|
2018-01-28 23:22:43 +11:00
|
|
|
if ($(target).data('down') == true) {
|
|
|
|
// スクロール
|
|
|
|
target.scrollLeft($(target).data('scrollLeft') + $(target).data('x') -
|
|
|
|
event.clientX);
|
|
|
|
target.scrollTop($(target).data('scrollTop') + $(target).data('y') -
|
|
|
|
event.clientY);
|
|
|
|
return false; // 文字列選択を抑止
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
}).mouseup(function (event) {
|
2018-01-28 23:22:43 +11:00
|
|
|
$(target).data('down', false);
|
|
|
|
});
|
2019-05-19 17:39:30 +10:00
|
|
|
$(this).on('touchstart', function (event) {
|
2018-01-28 23:22:43 +11:00
|
|
|
$(this)
|
|
|
|
.data('down', true)
|
|
|
|
.data('x', getX(event))
|
|
|
|
.data('y', getY(event))
|
|
|
|
.data('scrollLeft', this.scrollLeft)
|
|
|
|
.data('scrollTop', this.scrollTop);
|
|
|
|
return false;
|
|
|
|
}).css({
|
|
|
|
'overflow': 'hidden', // スクロールバー非表示
|
|
|
|
'cursor': 'move'
|
|
|
|
}); //指が触れたか検知
|
2019-05-19 17:39:30 +10:00
|
|
|
$(this).on('touchmove', function (event) {
|
2019-03-08 05:19:26 +11:00
|
|
|
if ($(target).data('down') === true) {
|
2018-01-28 23:22:43 +11:00
|
|
|
// スクロール
|
|
|
|
target.scrollLeft($(target).data('scrollLeft') + $(target).data('x') -
|
|
|
|
getX(event));
|
|
|
|
target.scrollTop($(target).data('scrollTop') + $(target).data('y') -
|
|
|
|
getY(event));
|
|
|
|
return false; // 文字列選択を抑止
|
2019-05-19 17:39:30 +10:00
|
|
|
} else { }
|
2018-01-28 23:22:43 +11:00
|
|
|
}); //指が動いたか検知
|
2019-05-19 17:39:30 +10:00
|
|
|
$(this).on('touchend', function (event) {
|
2018-01-28 23:22:43 +11:00
|
|
|
$(target).data('down', false);
|
|
|
|
});
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
})(jQuery);
|
|
|
|
|
|
|
|
function getX(event) {
|
|
|
|
return event.originalEvent.touches[0].pageX;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getY(event) {
|
|
|
|
return event.originalEvent.touches[0].pageY;
|
|
|
|
}
|
|
|
|
//マウスホイールで拡大
|
|
|
|
var element = document.getElementById("imagemodal");
|
2019-05-19 17:39:30 +10:00
|
|
|
element.onmousewheel = function (e) {
|
2018-01-28 23:22:43 +11:00
|
|
|
var delta = e.wheelDelta;
|
|
|
|
if (delta > 0) {
|
|
|
|
zoom(1.1)
|
|
|
|
} else {
|
|
|
|
zoom(0.9)
|
|
|
|
}
|
|
|
|
}
|
2018-03-31 13:39:06 +11:00
|
|
|
|
2018-02-18 16:43:11 +11:00
|
|
|
//当該トゥート
|
2019-05-19 17:39:30 +10:00
|
|
|
function detFromImg() {
|
|
|
|
var id = $("#imagemodal").attr("data-id");
|
|
|
|
var acct_id = $("#imagemodal").attr("data-acct");
|
2018-02-14 03:19:44 +11:00
|
|
|
$('#imagemodal').modal('close');
|
2019-05-19 17:39:30 +10:00
|
|
|
details(id, acct_id);
|
2018-02-17 00:08:43 +11:00
|
|
|
}
|
2018-02-18 16:43:11 +11:00
|
|
|
//画像保存
|
2019-05-19 17:39:30 +10:00
|
|
|
function dlImg() {
|
|
|
|
var url = $("#imgmodal").attr("src");
|
|
|
|
if (localStorage.getItem("savefolder")) {
|
|
|
|
var save = localStorage.getItem("savefolder");
|
|
|
|
} else {
|
|
|
|
var save = "";
|
2018-09-06 02:47:27 +10:00
|
|
|
}
|
2019-06-15 02:32:59 +10:00
|
|
|
postMessage(["generalDL", [url, save, false]], "*")
|
|
|
|
|
2019-04-03 14:59:29 +11:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
function openFinder(dir) {
|
2019-06-15 02:32:59 +10:00
|
|
|
postMessage(["openFinder", dir], "*")
|
2019-10-20 21:09:52 +11:00
|
|
|
}
|
|
|
|
function stopVideo(){
|
|
|
|
document.getElementById('video').pause()
|
2018-02-14 03:19:44 +11:00
|
|
|
}
|