Add: show modal when selecting

This commit is contained in:
cutls 2020-02-08 23:35:22 +09:00
parent e1a0a69a2a
commit 72daf55e4e
4 changed files with 401 additions and 339 deletions

View File

@ -129,7 +129,7 @@ option {
}
code:before,
.pre:before {
content: "Code";
content: 'Code';
font-size: 1.8rem;
line-height: 1em;
font-family: monospace, monospace;
@ -171,7 +171,7 @@ blockquote,
}
blockquote:before,
.quote:before {
content: "Quote";
content: 'Quote';
font-size: 1.8rem;
line-height: 1em;
font-family: Open Sans, cursive;
@ -191,7 +191,7 @@ blockquote:before,
border-left: 5px solid #0096fa;
}
.pixiv-post :before {
content: "From Pixiv";
content: 'From Pixiv';
font-size: 1.8rem;
line-height: 1em;
font-family: Open Sans;
@ -421,7 +421,7 @@ blockquote:before,
display: grid;
grid-template-columns: 3fr 1fr 1fr;
grid-template-rows: 1fr 36px;
grid-template-areas: "note middle right" "note close close";
grid-template-areas: 'note middle right' 'note close close';
}
#support-btm-en,
#support-btm-ja {
@ -461,13 +461,13 @@ textarea {
.contributor img {
width: 1rem;
}
.tagComp{
.tagComp {
display: grid;
grid-template-columns: 60px 80px 1fr;
grid-template-rows: 1fr 1fr;
grid-template-areas: "svg toot user" "svg toot tag" "svg toots tag";
grid-template-areas: 'svg toot user' 'svg toot tag' 'svg toots tag';
border-top: dotted 0.5px var(--gray);
padding: 5px
padding: 5px;
}
.tagCompSvg {
grid-area: svg;
@ -493,6 +493,25 @@ textarea {
#sabakanMark {
background-color: var(--emphasized);
}
#pageSrc {
position: fixed;
top: 0;
left: calc(50vw - 150px);
width: 300px;
max-width: 100%;
background-color: var(--box);
z-index: 501;
padding: 5px;
}
#pageSrcInput {
width: 160px;
}
@media (max-width: 500px) {
#pageSrc {
left: 0;
}
}
/*スクロールバー*/
::-webkit-scrollbar {
@ -513,25 +532,23 @@ textarea {
}
/* Web Fonts */
@font-face {
font-family: "Open Sans";
font-family: 'Open Sans';
font-style: normal;
font-weight: 300;
src: local("Open Sans Light"), local("OpenSans-Light"),
url(https://fonts.gstatic.com/s/opensans/v17/mem5YaGs126MiZpBA-UN_r8OUuhp.woff2)
format("woff2");
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
U+FEFF, U+FFFD;
src: local('Open Sans Light'), local('OpenSans-Light'),
url(https://fonts.gstatic.com/s/opensans/v17/mem5YaGs126MiZpBA-UN_r8OUuhp.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F,
U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
font-family: "Material Icons";
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(https://fonts.gstatic.com/s/materialicons/v48/flUhRq6tzZclQEJ-Vdg-IuiaDsNc.woff2)
format("woff2");
format('woff2');
}
.material-icons {
font-family: "Material Icons";
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 24px;
@ -542,6 +559,6 @@ textarea {
white-space: nowrap;
word-wrap: normal;
direction: ltr;
-webkit-font-feature-settings: "liga";
-webkit-font-feature-settings: 'liga';
-webkit-font-smoothing: antialiased;
}

View File

@ -218,7 +218,7 @@ function graphDraw(tag, acct_id) {
var his = tag.history
return graphDrawCore(his, tag)
}
function graphDrawCore(his, tag){
function graphDrawCore(his, tag) {
var max = Math.max.apply(null, [
his[0].uses,
his[1].uses,
@ -252,7 +252,9 @@ function graphDrawCore(his, tag){
toot
</div>
<div class="tagCompTag">
<a onclick="tl('tag','${escapeHTML(tag.name)}','${acct_id}','add')" class="pointer" title="${escapeHTML(tag.name)}">
<a onclick="tl('tag','${escapeHTML(
tag.name
)}','${acct_id}','add')" class="pointer" title="${escapeHTML(tag.name)}">
#${escapeHTML(tag.name)}
</a>
</div>
@ -308,3 +310,40 @@ function trend() {
})
})
}
function srcBox(mode) {
var selectedText = window.getSelection().toString()
if (mode == 'open') {
$('#pageSrc').removeClass('hide')
} else if (mode == 'close') {
if(!selectedText) {
$('#pageSrc').addClass('hide')
}
} else {
$('#pageSrc').toggleClass('hide')
}
if(!$('#pageSrc').hasClass('keep')) {
$('#pageSrcInput').val(selectedText)
}
}
$('#pageSrcInput').click(function() {
$('#pageSrc').addClass('keep')
})
$('#pageSrcInput').on('input', function(evt) {
if(!$('#pageSrcInput').val()) {
$('#pageSrc').removeClass('keep')
}
})
document.addEventListener('selectionchange', function() {
var selectedText = window.getSelection().toString()
if (selectedText && !$('input').is(':focus') && !$('textarea').is(':focus')) {
srcBox('open')
}
})
function doSrc(type) {
var q = $('#pageSrcInput').val()
if(type == 'web') {
postMessage(["openUrl", 'https://google.com/search?q=' + q], "*")
} else if(type == 'ts') {
tsAdd(q)
}
}

View File

@ -122,6 +122,7 @@ $('#timeline-container,#group').click(function(e) {
selectedColumn = 0
selectedToot = 0
localStorage.removeItem('nohide')
srcBox('close')
})
$('#contextWrap').click(function(e) {
$('#contextWrap').addClass('hide')

View File

@ -35,6 +35,11 @@
</script>
<textarea id="copy" style="top:-100px; position:fixed;"></textarea>
<canvas id="canvas" style="top:-100px; position:fixed;width:32px;height:32px" width="32" height="32"></canvas>
<div id="pageSrc" class="hide z-depth-5">
<input type="text" id="pageSrcInput">
<button class="btn waves-effect" onclick="doSrc('web')" title="@@webSrc@@"><i class="material-icons">open_in_browser</i></button>
<button class="btn waves-effect" onclick="doSrc('ts')" title="@@tsSrc@@"><i class="material-icons">chat</i></button>
</div>
<div id="tl">
<!--TL-->
<!--スターター-->