thedesk/app/js/ui/post-box.js

117 lines
2.8 KiB
JavaScript
Raw Normal View History

2018-01-28 23:22:43 +11:00
/*ささやきボックス(Cr民並感)*/
//✕隠す
function hide() {
2019-03-06 19:08:48 +11:00
$('#post-box').fadeOut()
$("#post-box").removeClass("appear")
2018-09-19 02:41:48 +10:00
$("#emoji").addClass("hide")
2018-01-28 23:22:43 +11:00
}
2018-02-18 03:44:03 +11:00
//最小化
function mini() {
$("body").toggleClass("mini-post");
if($("body").hasClass("mini-post")){
$(".mini-btn").text("expand_less");
}else{
$(".mini-btn").text("expand_more");
}
}
2018-01-28 23:22:43 +11:00
//最小化時に展開
function show() {
2019-03-06 19:08:48 +11:00
$("#post-box").addClass("appear")
2018-07-28 07:25:12 +10:00
$("#textarea").focus();
2019-03-06 19:08:48 +11:00
console.log("show"+localStorage.getItem("postbox-left"));
2019-03-10 02:03:02 +11:00
var left=localStorage.getItem("postbox-left");
if(left>$('body').width()-$('#post-box').width()){
left=$('body').width()-$('#post-box').width();
}else if(left<0){
left=0;
}
var top=localStorage.getItem("postbox-top");
if(top>$('body').height()-$('#post-box').height()){
top=$('body').height()-$('#post-box').height();
}else if(top<0){
top=0;
}
$('#post-box').css("left",left+"px")
$('#post-box').css("top",top+"px")
2019-03-06 19:08:48 +11:00
$('#post-box').fadeIn();
2018-03-14 17:52:55 +11:00
}
2019-03-06 19:08:48 +11:00
$(function() {
$( "#post-box" ).draggable({handle: "#post-bar",
stop: function() {
2019-03-10 02:03:02 +11:00
var left=$('#post-box').offset().left;
if(left>$('body').width()-$('#post-box').width()){
left=$('body').width()-$('#post-box').width();
}else if(left<0){
left=0;
}
var top=$('#post-box').offset().top;
if(top>$('body').height()-$('#post-box').height()){
top=$('body').height()-$('#post-box').height();
}else if(top<0){
top=0;
}
localStorage.setItem("postbox-left",left);
localStorage.setItem("postbox-top",top);
2019-03-06 19:08:48 +11:00
}
});
});
2018-07-28 07:25:12 +10:00
2018-02-26 02:32:10 +11:00
//コード受信
if(location.search){
var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/);
var mode=m[1];
var codex=m[2];
if(mode=="share"){
console.log(codex);
$('textarea').focus();
$("#textarea").val(decodeURI(codex));
show();
$("body").removeClass("mini-post");
$(".mini-btn").text("expand_less");
}
2018-07-28 07:25:12 +10:00
}
2019-03-06 19:08:48 +11:00
$('#posttgl').click(function(e) {
2018-07-28 07:25:12 +10:00
if(!$('#post-box').hasClass("appear")){
show();
2019-03-06 19:08:48 +11:00
}else{
hide();
2018-07-28 07:25:12 +10:00
}
});
$("#timeline-container,#group").click(function(e) {
2018-09-19 02:41:48 +10:00
2018-08-05 13:36:23 +10:00
if(localStorage.getItem("box")!="absolute"){
if($('#post-box').hasClass("appear") && !localStorage.getItem("nohide")){
hide();
}
2018-07-28 07:25:12 +10:00
}
localStorage.removeItem("nohide")
});
2018-09-19 02:41:48 +10:00
$('#textarea,#cw-text').focusout(function(e) {
localStorage.setItem("nohide",true)
var countup = function(){
localStorage.removeItem("nohide")
}
//setTimeout(remove, 100);
});
2018-07-28 07:25:12 +10:00
$("#timeline-container").click(function(e) {
if(!$('#list-box').hasClass("hide")){
$("#list-box").removeClass("show");
$("#list-box").addClass("hide")
}
if(!$('#src-box').hasClass("hide")){
$("#src-box").removeClass("show");
$("#src-box").addClass("hide")
}
if(!$('#filter-box').hasClass("hide")){
$("#filter-box").removeClass("show");
$("#filter-box").addClass("hide")
}
if(!$('#add-box').hasClass("hide")){
$("#add-box").removeClass("show");
$("#add-box").addClass("hide")
}
});