Browse Source

isolated clipboard, styling

tags/v1.0.0
Uvis Grinfelds 9 years ago
parent
commit
950e165e2e
6 changed files with 60 additions and 98 deletions
  1. +1
    -0
      transfersh-web/includes/download-btn.html
  2. +57
    -0
      transfersh-web/scripts/clipboard.js
  3. +0
    -57
      transfersh-web/scripts/main.js
  4. +1
    -1
      transfersh-web/styles/bootstrap.less
  5. +0
    -39
      transfersh-web/styles/main.css
  6. +1
    -1
      transfersh-web/styles/main.css.map

+ 1
- 0
transfersh-web/includes/download-btn.html View File

@@ -7,3 +7,4 @@
</div>
<div id="overlay" class="overlay"></div>
</div>
<script src="scripts/clipboard.js"></script>

+ 57
- 0
transfersh-web/scripts/clipboard.js View File

@@ -0,0 +1,57 @@
(function() {
var copylinkbtn = document.getElementById("copy-link-btn"),
copylink = document.getElementById("copy-link-wrapper"),
overlay = document.getElementById("overlay");

var url = "http://url"
copylinkbtn.addEventListener("click", function() {
var error = document.getElementsByClassName('error');
while (error[0]) {
error[0].parentNode.removeChild(error[0]);
}

document.body.className += ' active';
copylink.children[1].value = url;
copylink.children[1].focus();
copylink.children[1].select();
}, false);

overlay.addEventListener("click", function() {
document.body.className = '';
}, false);

copylink.children[2].addEventListener("keydown", function(e) {

var error = document.getElementsByClassName('error');

while (error[0]) {
error[0].parentNode.removeChild(error[0]);
}

setTimeout(function() {

if((e.metaKey || e.ctrlKey) && e.keyCode === 67 && isTextSelected(copylink.children[2])) {
document.body.className = '';
} else if((e.metaKey || e.ctrlKey) && e.keyCode === 67 && isTextSelected(copylink.children[2]) === false) {
var error = document.createElement('span');
error.className = 'error';
var errortext = document.createTextNode('The link was not copied, make sure the entire text is selected.');
error.appendChild(errortext);
copylink.appendChild(error);
}
}, 100);

function isTextSelected(input) {
if (typeof input.selectionStart == "number") {
return input.selectionStart == 0 && input.selectionEnd == input.value.length;
} else if (typeof document.selection != "undefined") {
input.focus();
return document.selection.createRange().text == input.value;
}
}
}, false);
})();

+ 0
- 57
transfersh-web/scripts/main.js View File

@@ -104,60 +104,3 @@ $(document).ready(function() {
})();


(function() {
var copylinkbtn = document.getElementById("copy-link-btn"),
copylink = document.getElementById("copy-link-wrapper"),
overlay = document.getElementById("overlay");

var url = "http://url"
copylinkbtn.addEventListener("click", function() {
var error = document.getElementsByClassName('error');
while (error[0]) {
error[0].parentNode.removeChild(error[0]);
}

document.body.className += ' active';
copylink.children[1].value = url;
copylink.children[1].focus();
copylink.children[1].select();
}, false);

overlay.addEventListener("click", function() {
document.body.className = '';
}, false);

copylink.children[2].addEventListener("keydown", function(e) {

var error = document.getElementsByClassName('error');

while (error[0]) {
error[0].parentNode.removeChild(error[0]);
}

setTimeout(function() {

if((e.metaKey || e.ctrlKey) && e.keyCode === 67 && isTextSelected(copylink.children[2])) {
document.body.className = '';
} else if((e.metaKey || e.ctrlKey) && e.keyCode === 67 && isTextSelected(copylink.children[2]) === false) {
var error = document.createElement('span');
error.className = 'error';
var errortext = document.createTextNode('The link was not copied, make sure the entire text is selected.');
error.appendChild(errortext);
copylink.appendChild(error);
}
}, 100);

function isTextSelected(input) {
if (typeof input.selectionStart == "number") {
return input.selectionStart == 0 && input.selectionEnd == input.value.length;
} else if (typeof document.selection != "undefined") {
input.focus();
return document.selection.createRange().text == input.value;
}
}
}, false);
})();

+ 1
- 1
transfersh-web/styles/bootstrap.less View File

@@ -9,7 +9,7 @@
// Core CSS
@import "../bower_components/bootstrap/less/scaffolding.less";
@import "../bower_components/bootstrap/less/type.less";
@import "../bower_components/bootstrap/less/code.less";
// @import "../bower_components/bootstrap/less/code.less";
@import "../bower_components/bootstrap/less/grid.less";
@import "../bower_components/bootstrap/less/tables.less";
@import "../bower_components/bootstrap/less/forms.less";


+ 0
- 39
transfersh-web/styles/main.css View File

@@ -622,45 +622,6 @@ address {
font-style: normal;
line-height: 1.42857143;
}
code,
kbd,
pre,
samp {
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
}
code {
padding: 2px 4px;
font-size: 90%;
color: #c7254e;
background-color: #f9f2f4;
white-space: nowrap;
border-radius: 4px;
}
pre {
display: block;
padding: 9.5px;
margin: 0 0 10px;
font-size: 13px;
line-height: 1.42857143;
word-break: break-all;
word-wrap: break-word;
color: #333333;
background-color: #f5f5f5;
border: 1px solid #cccccc;
border-radius: 4px;
}
pre code {
padding: 0;
font-size: inherit;
color: inherit;
white-space: pre-wrap;
background-color: transparent;
border-radius: 0;
}
.pre-scrollable {
max-height: 340px;
overflow-y: scroll;
}
.container {
margin-right: auto;
margin-left: auto;


+ 1
- 1
transfersh-web/styles/main.css.map
File diff suppressed because it is too large
View File


Loading…
Cancel
Save